Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YLFHU-0005DM-7m for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Feb 2015 18:11:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YLFHT-0003HQ-KO for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Feb 2015 18:11:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YLFHR-0003GV-HQ for pgsql-bugs@postgresql.org; Tue, 10 Feb 2015 18:11:25 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YLFHJ-0002Rr-6N for pgsql-bugs@postgresql.org; Tue, 10 Feb 2015 18:11:23 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1YLFHI-00079N-28; Tue, 10 Feb 2015 13:11:16 -0500 Date: Tue, 10 Feb 2015 13:11:16 -0500 From: Bruce Momjian To: toni.helenius@syncrontech.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12755: pg_upgrage creates potentially dangerous delete_old_cluster.bat Message-ID: <20150210181116.GD18557@momjian.us> References: <20150210104441.18791.41198@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="p4qYPpj5QlsIQJ0K" Content-Disposition: inline In-Reply-To: <20150210104441.18791.41198@wrigleys.postgresql.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --p4qYPpj5QlsIQJ0K Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Feb 10, 2015 at 10:44:41AM +0000, toni.helenius@syncrontech.com wrote: > The following bug has been logged on the website: > > Bug reference: 12755 > Logged by: Toni Helenius > Email address: toni.helenius@syncrontech.com > PostgreSQL version: 9.4.1 > Operating system: Windows 7 > Description: > > pg_upgrage creates potentially dangerous delete_old_cluster.bat. RMDIR > without quotes. > > RMDIR /s/q C:\Program Files\PostgreSQL\9.3\data > > Executes as: > RMDIR /s/q C:\Program > > Needs quotes!! Wow, very good point. Not sure why this problem was not reported before. Patch attached. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --p4qYPpj5QlsIQJ0K Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_upgrade_rm.diff" diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c new file mode 100644 index 87e9031..6a498c3 *** a/contrib/pg_upgrade/check.c --- b/contrib/pg_upgrade/check.c *************** create_script_for_old_cluster_deletion(c *** 528,534 **** #endif /* delete old cluster's default tablespace */ ! fprintf(script, RMDIR_CMD " %s\n", fix_path_separator(old_cluster.pgdata)); /* delete old cluster's alternate tablespaces */ for (tblnum = 0; tblnum < os_info.num_old_tablespaces; tblnum++) --- 528,534 ---- #endif /* delete old cluster's default tablespace */ ! fprintf(script, RMDIR_CMD " \"%s\"\n", fix_path_separator(old_cluster.pgdata)); /* delete old cluster's alternate tablespaces */ for (tblnum = 0; tblnum < os_info.num_old_tablespaces; tblnum++) *************** create_script_for_old_cluster_deletion(c *** 550,556 **** PATH_SEPARATOR); for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++) ! fprintf(script, RMDIR_CMD " %s%c%d\n", fix_path_separator(os_info.old_tablespaces[tblnum]), PATH_SEPARATOR, old_cluster.dbarr.dbs[dbnum].db_oid); } --- 550,556 ---- PATH_SEPARATOR); for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++) ! fprintf(script, RMDIR_CMD " \"%s%c%d\"\n", fix_path_separator(os_info.old_tablespaces[tblnum]), PATH_SEPARATOR, old_cluster.dbarr.dbs[dbnum].db_oid); } *************** create_script_for_old_cluster_deletion(c *** 562,568 **** * Simply delete the tablespace directory, which might be ".old" * or a version-specific subdirectory. */ ! fprintf(script, RMDIR_CMD " %s%s\n", fix_path_separator(os_info.old_tablespaces[tblnum]), fix_path_separator(suffix_path)); pfree(suffix_path); --- 562,568 ---- * Simply delete the tablespace directory, which might be ".old" * or a version-specific subdirectory. */ ! fprintf(script, RMDIR_CMD " \"%s%s\"\n", fix_path_separator(os_info.old_tablespaces[tblnum]), fix_path_separator(suffix_path)); pfree(suffix_path); --p4qYPpj5QlsIQJ0K Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --p4qYPpj5QlsIQJ0K--