| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: chpass.c,v 1.33 2008/07/21 14:19:21 lukem Exp $ */ | | 1 | /* $NetBSD: chpass.c,v 1.34 2011/08/29 14:08:39 joerg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1988, 1993, 1994 | | 4 | * Copyright (c) 1988, 1993, 1994 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\ | | 34 | __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\ |
35 | The Regents of the University of California. All rights reserved."); | | 35 | The Regents of the University of California. All rights reserved."); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94"; | | 40 | static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94"; |
41 | #else | | 41 | #else |
42 | __RCSID("$NetBSD: chpass.c,v 1.33 2008/07/21 14:19:21 lukem Exp $"); | | 42 | __RCSID("$NetBSD: chpass.c,v 1.34 2011/08/29 14:08:39 joerg Exp $"); |
43 | #endif | | 43 | #endif |
44 | #endif /* not lint */ | | 44 | #endif /* not lint */ |
45 | | | 45 | |
46 | #include <sys/param.h> | | 46 | #include <sys/param.h> |
47 | #include <sys/stat.h> | | 47 | #include <sys/stat.h> |
48 | #include <sys/time.h> | | 48 | #include <sys/time.h> |
49 | #include <sys/resource.h> | | 49 | #include <sys/resource.h> |
50 | | | 50 | |
51 | #include <ctype.h> | | 51 | #include <ctype.h> |
52 | #include <err.h> | | 52 | #include <err.h> |
53 | #include <errno.h> | | 53 | #include <errno.h> |
54 | #include <fcntl.h> | | 54 | #include <fcntl.h> |
55 | #include <pwd.h> | | 55 | #include <pwd.h> |
| @@ -63,29 +63,29 @@ __RCSID("$NetBSD: chpass.c,v 1.33 2008/0 | | | @@ -63,29 +63,29 @@ __RCSID("$NetBSD: chpass.c,v 1.33 2008/0 |
63 | #include "chpass.h" | | 63 | #include "chpass.h" |
64 | #include "pathnames.h" | | 64 | #include "pathnames.h" |
65 | | | 65 | |
66 | static char tempname[] = "/tmp/pw.XXXXXX"; | | 66 | static char tempname[] = "/tmp/pw.XXXXXX"; |
67 | uid_t uid; | | 67 | uid_t uid; |
68 | int use_yp; | | 68 | int use_yp; |
69 | | | 69 | |
70 | void (*Pw_error)(const char *, int, int); | | 70 | void (*Pw_error)(const char *, int, int); |
71 | | | 71 | |
72 | #ifdef YP | | 72 | #ifdef YP |
73 | extern int _yp_check(char **); /* buried deep inside libc */ | | 73 | extern int _yp_check(char **); /* buried deep inside libc */ |
74 | #endif | | 74 | #endif |
75 | | | 75 | |
76 | void baduser(void); | | 76 | __dead static void baduser(void); |
77 | void cleanup(void); | | 77 | static void cleanup(void); |
78 | void usage(void); | | 78 | __dead static void usage(void); |
79 | | | 79 | |
80 | int | | 80 | int |
81 | main(int argc, char **argv) | | 81 | main(int argc, char **argv) |
82 | { | | 82 | { |
83 | enum { NEWSH, LOADENTRY, EDITENTRY } op; | | 83 | enum { NEWSH, LOADENTRY, EDITENTRY } op; |
84 | struct passwd *pw, lpw, old_pw; | | 84 | struct passwd *pw, lpw, old_pw; |
85 | int ch, dfd, pfd, tfd; | | 85 | int ch, dfd, pfd, tfd; |
86 | #ifdef YP | | 86 | #ifdef YP |
87 | int yflag = 0; | | 87 | int yflag = 0; |
88 | #endif | | 88 | #endif |
89 | char *arg, *username = NULL; | | 89 | char *arg, *username = NULL; |
90 | | | 90 | |
91 | #ifdef __GNUC__ | | 91 | #ifdef __GNUC__ |
| @@ -280,37 +280,37 @@ main(int argc, char **argv) | | | @@ -280,37 +280,37 @@ main(int argc, char **argv) |
280 | /* Copy the passwd file to the lock file, updating pw. */ | | 280 | /* Copy the passwd file to the lock file, updating pw. */ |
281 | pw_copy(pfd, tfd, pw, (op == LOADENTRY) ? NULL : &old_pw); | | 281 | pw_copy(pfd, tfd, pw, (op == LOADENTRY) ? NULL : &old_pw); |
282 | | | 282 | |
283 | close(pfd); | | 283 | close(pfd); |
284 | close(tfd); | | 284 | close(tfd); |
285 | | | 285 | |
286 | /* Now finish the passwd file update. */ | | 286 | /* Now finish the passwd file update. */ |
287 | if (pw_mkdb(username, 0) < 0) | | 287 | if (pw_mkdb(username, 0) < 0) |
288 | pw_error(NULL, 0, 1); | | 288 | pw_error(NULL, 0, 1); |
289 | | | 289 | |
290 | exit(0); | | 290 | exit(0); |
291 | } | | 291 | } |
292 | | | 292 | |
293 | void | | 293 | static void |
294 | baduser(void) | | 294 | baduser(void) |
295 | { | | 295 | { |
296 | | | 296 | |
297 | errx(1, "%s", strerror(EACCES)); | | 297 | errx(1, "%s", strerror(EACCES)); |
298 | } | | 298 | } |
299 | | | 299 | |
300 | void | | 300 | static void |
301 | usage(void) | | 301 | usage(void) |
302 | { | | 302 | { |
303 | | | 303 | |
304 | (void)fprintf(stderr, | | 304 | (void)fprintf(stderr, |
305 | "usage: %s [-a list] [-s shell] [-l] [user]\n" | | 305 | "usage: %s [-a list] [-s shell] [-l] [user]\n" |
306 | " %s [-a list] [-s shell] [-y] [user]\n", | | 306 | " %s [-a list] [-s shell] [-y] [user]\n", |
307 | getprogname(), getprogname()); | | 307 | getprogname(), getprogname()); |
308 | exit(1); | | 308 | exit(1); |
309 | } | | 309 | } |
310 | | | 310 | |
311 | void | | 311 | static void |
312 | cleanup(void) | | 312 | cleanup(void) |
313 | { | | 313 | { |
314 | | | 314 | |
315 | (void)unlink(tempname); | | 315 | (void)unlink(tempname); |
316 | } | | 316 | } |