Article View: net.bugs.4bsd
Article #1677Re: possible truncated /etc/passwd file
From: Chris Torek
Date: Wed, 17 Sep 1986 13:35
Date: Wed, 17 Sep 1986 13:35
30 lines
1611 bytes
1611 bytes
In article <185@uvicctr.UUCP> gduncan@uvicctr.UUCP (Gary Duncan) writes:
>Description:
> the passwd program ... works by creating a temporary copy of the
> updated passwd file by opening /etc/ptmp in exclusive-use mode then
> copying and modifying entries from the original. No problem so far.
> The program then:
> 1. renames the temporary file to /etc/passwd
> 2. closes the stream pointer for the file.
> Unfortunately the exclusive-use mode is lost on rename before the
> stream buffers have been flushed. ...
>Fix:
> Add a fflush(tf) immediately before the rename to flush the buffers.
>
> endpwent();
>+ fflush(tf);
> if (rename(temp, passwd) < 0) {
It would also be a very good idea to check for ferror(tf), in case
the root file system is full. Make that:
endpwent();
(void) fflush(tf);
if (ferror(tf))
/* do something */
This, too, is quite unlikely, but could have drastic consequences.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP: seismo!umcp-cs!chris
CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu
Technical Details
Message-ID:
<3480@umcp-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chrisReferences:
<185@uvicctr.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.bugs.4bsd Subject: Re: possible truncated /etc/passwd file Message-ID: <3480@umcp-cs.UUCP> Date: Wed, 17-Sep-86 09:35:46 EDT Article-I.D.: umcp-cs.3480 Posted: Wed Sep 17 09:35:46 1986 Date-Received: Fri, 19-Sep-86 21:19:12 EDT References: <185@uvicctr.UUCP> Distribution: net Organization: Computer Sci. Dept, U of Maryland, College Park, MD Lines: 30