From owner-cvs-all Mon Jun 28 9:28:38 1999 Delivered-To: cvs-all@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id ADCD714DD2; Mon, 28 Jun 1999 09:28:26 -0700 (PDT) (envelope-from des@flood.ping.uio.no) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.1) id SAA87226; Mon, 28 Jun 1999 18:28:25 +0200 (CEST) (envelope-from des) To: Pierre Beyssac Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/vipw pw_util.c vipw.c References: <199906261215.FAA18022@freefall.freebsd.org> From: Dag-Erling Smorgrav Date: 28 Jun 1999 18:28:24 +0200 In-Reply-To: Pierre Beyssac's message of "Sat, 26 Jun 1999 05:15:45 -0700 (PDT)" Message-ID: Lines: 45 X-Mailer: Gnus v5.5/Emacs 19.34 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk Pierre Beyssac writes: > Log: > Force umask to 077 (instead of 000) during the edit phase, to get > secure permissions in case the user attempts to save something to > a file of his own. Wrong fix. The correct fix is to save and restore the original umask. See attached patch. DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no Index: vipw.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/vipw/vipw.c,v retrieving revision 1.8 diff -u -r1.8 vipw.c --- vipw.c 1999/06/26 12:15:39 1.8 +++ vipw.c 1999/06/28 16:27:50 @@ -72,6 +72,7 @@ int pfd, tfd; struct stat begin, end; int ch; + mode_t um; while ((ch = getopt(argc, argv, "d:")) != -1) switch (ch) { @@ -101,13 +102,13 @@ pw_init(); /* Create with exact permissions. */ - (void)umask(0); + um = umask(0); pfd = pw_lock(); tfd = pw_tmp(); copyfile(pfd, tfd); (void)close(tfd); /* Force umask for partial writes made in the edit phase */ - (void)umask(077); + (void)umask(um); for (;;) { if (stat(tempname, &begin)) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message