static char sccsid
[] = "@(#)vipw.c 4.1 (Berkeley) %G%";
* Password file editor with locking.
char *temp
= "/etc/ptmp";
char *passwd
= "/etc/passwd";
signal(SIGQUIT
, SIG_IGN
);
fd
= open(temp
, O_WRONLY
|O_CREAT
|O_EXCL
, 0644);
fprintf(stderr
, "vipw: password file busy\n");
fprintf(stderr
, "vipw: "); perror(temp
);
fprintf(stderr
, "vipw: "); perror(temp
);
fprintf(stderr
, "vipw: "); perror(passwd
);
while (fgets(buf
, sizeof (buf
) - 1, fp
) != NULL
)
editor
= getenv("EDITOR");
sprintf(buf
, "%s %s", editor
, temp
);
if (stat(temp
, &sbuf
) < 0) {
"vipw: can't stat temp file, %s unchanged\n",
fprintf(stderr
, "vipw: bad temp file, %s unchanged\n",
"vipw: can't reopen temp file, %s unchanged\n",
while (fgets(buf
, sizeof (buf
) - 1, ft
) != NULL
) {
if (*cp
&& strcmp(cp
, "/bin/sh") &&
if (rename(temp
, passwd
) < 0)
fprintf(stderr
, "vipw: "), perror("rename");
"vipw: you mangled the temp file, %s unchanged\n",