projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_4_Lite1 release
[unix-history]
/
usr
/
src
/
usr.bin
/
chpass
/
chpass.c
diff --git
a/usr/src/usr.bin/chpass/chpass.c
b/usr/src/usr.bin/chpass/chpass.c
index
5ea51c9
..
0852c53
100644
(file)
--- a/
usr/src/usr.bin/chpass/chpass.c
+++ b/
usr/src/usr.bin/chpass/chpass.c
@@
-1,5
+1,5
@@
/*-
/*-
- * Copyright (c) 1988, 1993
+ * Copyright (c) 1988, 1993
, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@
-33,12
+33,12
@@
#ifndef lint
static char copyright[] =
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
+"@(#) Copyright (c) 1988, 1993
, 1994
\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)chpass.c 8.
1 (Berkeley) 6/6/93
";
+static char sccsid[] = "@(#)chpass.c 8.
4 (Berkeley) 4/2/94
";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
@@
-46,12
+46,21
@@
static char sccsid[] = "@(#)chpass.c 8.1 (Berkeley) 6/6/93";
#include <sys/signal.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/signal.h>
#include <sys/time.h>
#include <sys/resource.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <fcntl.h>
#include <pwd.h>
-#include <errno.h>
#include <stdio.h>
#include <stdio.h>
-#include <
ctype
.h>
+#include <
stdlib
.h>
#include <string.h>
#include <string.h>
+#include <unistd.h>
+
+#include <pw_scan.h>
+#include <pw_util.h>
+#include "pw_copy.h"
+
#include "chpass.h"
#include "pathnames.h"
#include "chpass.h"
#include "pathnames.h"
@@
-59,15
+68,16
@@
char *progname = "chpass";
char *tempname;
uid_t uid;
char *tempname;
uid_t uid;
+void baduser __P((void));
+void usage __P((void));
+
+int
main(argc, argv)
int argc;
char **argv;
{
main(argc, argv)
int argc;
char **argv;
{
- extern int optind;
- extern char *optarg;
- register enum { NEWSH, LOADENTRY, EDITENTRY } op;
- register struct passwd *pw;
- struct passwd lpw;
+ enum { NEWSH, LOADENTRY, EDITENTRY } op;
+ struct passwd *pw, lpw;
int ch, pfd, tfd;
char *arg;
int ch, pfd, tfd;
char *arg;
@@
-94,18
+104,12
@@
main(argc, argv)
if (op == EDITENTRY || op == NEWSH)
switch(argc) {
case 0:
if (op == EDITENTRY || op == NEWSH)
switch(argc) {
case 0:
- if (!(pw = getpwuid(uid))) {
- (void)fprintf(stderr,
- "chpass: unknown user: uid %u\n", uid);
- exit(1);
- }
+ if (!(pw = getpwuid(uid)))
+ errx(1, "unknown user: uid %u", uid);
break;
case 1:
break;
case 1:
- if (!(pw = getpwnam(*argv))) {
- (void)fprintf(stderr,
- "chpass: unknown user %s.\n", *argv);
- exit(1);
- }
+ if (!(pw = getpwnam(*argv)))
+ errx(1, "unknown user: %s", *argv);
if (uid && uid != pw->pw_uid)
baduser();
break;
if (uid && uid != pw->pw_uid)
baduser();
break;
@@
-172,14
+176,17
@@
main(argc, argv)
exit(0);
}
exit(0);
}
+void
baduser()
{
baduser()
{
- (void)fprintf(stderr, "chpass: %s\n", strerror(EACCES));
- e
xit(1
);
+
+ e
rrx(1, "%s", strerror(EACCES)
);
}
}
+void
usage()
{
usage()
{
+
(void)fprintf(stderr, "usage: chpass [-a list] [-s shell] [user]\n");
exit(1);
}
(void)fprintf(stderr, "usage: chpass [-a list] [-s shell] [user]\n");
exit(1);
}