Skip site navigation (1)Skip section navigation (2)
Date:      29 Jun 1999 01:32:30 +0200
From:      Dag-Erling Smorgrav <des@flood.ping.uio.no>
To:        Pierre Beyssac <beyssac@enst.fr>
Cc:        Dag-Erling Smorgrav <des@flood.ping.uio.no>, Pierre Beyssac <pb@FreeBSD.ORG>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/usr.sbin/vipw pw_util.c vipw.c
Message-ID:  <xzpd7yf2969.fsf@flood.ping.uio.no>
In-Reply-To: Pierre Beyssac's message of "Mon, 28 Jun 1999 19:33:11 %2B0200"
References:  <199906261215.FAA18022@freefall.freebsd.org> <xzpogi01e8n.fsf@flood.ping.uio.no> <19990628193311.A63701@enst.fr>

next in thread | previous in thread | raw e-mail | index | archive | help
Pierre Beyssac <beyssac@enst.fr> writes:
> On Mon, Jun 28, 1999 at 06:28:24PM +0200, Dag-Erling Smorgrav wrote:
> > >   Force umask to 077 (instead of 000) during the edit phase, to get
> > Wrong fix. The correct fix is to save and restore the original umask.
> > See attached patch.
> I disagree; the umask 077 is on purpose because we're dealing with
> the password file, not just any random use of $EDITOR.

I believe you don't quite understand the code. What happens is:

 * set umask to 0
 * create a temp file containing a copy of master.passwd, with mode
   0600
 * restore the umask to 077, on the mistaken assumption that it
   actually has an effect.
 * start the editor
 * check the syntax of the temp file
 * regenerate the password database

Now there are two instances in which the second call to umask(2) has
any effect at all:

 1) you use a losing editor which creates backup files with
    permissions different from those of the file you're editing.

 2) while editing the password file, you create and edit another file.

The solution to the first case should be obvious to everyone. As for
the second case, it is my humble opinion that we should restore the
original umask, if only in the name of POLA.

The second call to umask(2) does not in any way affect the file mode
of either master.passwd or the temp file used for editing it.

DES
-- 
Dag-Erling Smorgrav - des@flood.ping.uio.no


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpd7yf2969.fsf>