]>
git.cameronkatri.com Git - pw-darwin.git/blob - pw/pw_user.c
3 * David L. Nugent. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 static const char rcsid
[] =
33 #include <sys/param.h>
34 #include <sys/resource.h>
36 #include <sys/types.h>
45 #include <login_cap.h>
56 #define LOGNAMESIZE (MAXLOGNAME-1)
58 static char locked_str
[] = "*LOCKED*";
60 static struct passwd fakeuser
= {
74 static int print_user(struct passwd
*pwd
, bool pretty
, bool v7
);
75 static uid_t
pw_uidpolicy(struct userconf
*cnf
, intmax_t id
);
76 static uid_t
pw_gidpolicy(struct userconf
*cnf
, char *grname
, char *nam
,
77 gid_t prefer
, bool dryrun
);
78 static char *pw_homepolicy(struct userconf
* cnf
, char *homedir
,
80 static char *pw_shellpolicy(struct userconf
* cnf
);
81 static char *pw_password(struct userconf
* cnf
, char const * user
,
83 static char *shell_path(char const * path
, char *shells
[], char *sh
);
84 static void rmat(uid_t uid
);
85 static void rmopie(char const * name
);
88 create_and_populate_homedir(struct userconf
*cnf
, struct passwd
*pwd
,
89 const char *skeldir
, mode_t homemode
, bool update
)
93 if (skeldir
!= NULL
&& *skeldir
!= '\0') {
96 skelfd
= openat(conf
.rootfd
, skeldir
, O_DIRECTORY
|O_CLOEXEC
);
99 copymkdir(conf
.rootfd
, pwd
->pw_dir
, skelfd
, homemode
, pwd
->pw_uid
,
101 pw_log(cnf
, update
? M_UPDATE
: M_ADD
, W_USER
, "%s(%ju) home %s made",
102 pwd
->pw_name
, (uintmax_t)pwd
->pw_uid
, pwd
->pw_dir
);
106 pw_set_passwd(struct passwd
*pwd
, int fd
, bool precrypted
, bool update
)
111 char line
[_PASSWORD_LEN
+1];
115 if (!pwd
->pw_passwd
|| *pwd
->pw_passwd
!= '*') {
116 pwd
->pw_passwd
= "*"; /* No access */
122 if ((istty
= isatty(fd
))) {
123 if (tcgetattr(fd
, &t
) == -1)
127 n
.c_lflag
&= ~(ECHO
);
128 tcsetattr(fd
, TCSANOW
, &n
);
129 printf("%s%spassword for user %s:",
130 update
? "new " : "",
131 precrypted
? "encrypted " : "",
136 b
= read(fd
, line
, sizeof(line
) - 1);
137 if (istty
) { /* Restore state */
138 tcsetattr(fd
, TCSANOW
, &t
);
144 err(EX_IOERR
, "-%c file descriptor",
145 precrypted
? 'H' : 'h');
147 if ((p
= strpbrk(line
, "\r\n")) != NULL
)
150 errx(EX_DATAERR
, "empty password read on file descriptor %d",
153 if (strchr(line
, ':') != NULL
)
154 errx(EX_DATAERR
, "bad encrypted password");
155 pwd
->pw_passwd
= strdup(line
);
157 lc
= login_getpwclass(pwd
);
159 login_setcryptfmt(lc
, "sha512", NULL
) == NULL
)
160 warn("setting crypt(3) format");
162 pwd
->pw_passwd
= pw_pwcrypt(line
);
168 perform_chgpwent(const char *name
, struct passwd
*pwd
, char *nispasswd
)
171 struct passwd
*nispwd
;
173 /* duplicate for nis so that chgpwent is not modifying before NIS */
174 if (nispasswd
&& *nispasswd
== '/')
175 nispwd
= pw_dup(pwd
);
177 rc
= chgpwent(name
, pwd
);
179 errx(EX_IOERR
, "user '%s' does not exist (NIS?)", pwd
->pw_name
);
181 err(EX_IOERR
, "passwd file update");
183 if (nispasswd
&& *nispasswd
== '/') {
184 rc
= chgnispwent(nispasswd
, name
, nispwd
);
186 warn("User '%s' not found in NIS passwd", pwd
->pw_name
);
188 warn("NIS passwd update");
189 /* NOTE: NIS-only update errors are not fatal */
194 * The M_LOCK and M_UNLOCK functions simply add or remove
195 * a "*LOCKED*" prefix from in front of the password to
196 * prevent it decoding correctly, and therefore prevents
197 * access. Of course, this only prevents access via
198 * password authentication (not ssh, kerberos or any
199 * other method that does not use the UNIX password) but
200 * that is a known limitation.
203 pw_userlock(char *arg1
, int mode
)
205 struct passwd
*pwd
= NULL
;
206 char *passtmp
= NULL
;
212 errx(EX_NOPERM
, "you must be root");
215 errx(EX_DATAERR
, "username or id required");
217 if (strspn(arg1
, "0123456789") == strlen(arg1
))
218 id
= pw_checkid(arg1
, UID_MAX
);
222 pwd
= (name
!= NULL
) ? GETPWNAM(pw_checkname(name
, 0)) : GETPWUID(id
);
225 errx(EX_NOUSER
, "no such uid `%ju'", (uintmax_t) id
);
226 errx(EX_NOUSER
, "no such user `%s'", name
);
232 if (strncmp(pwd
->pw_passwd
, locked_str
, sizeof(locked_str
) -1) == 0)
234 if (mode
== M_LOCK
&& locked
)
235 errx(EX_DATAERR
, "user '%s' is already locked", pwd
->pw_name
);
236 if (mode
== M_UNLOCK
&& !locked
)
237 errx(EX_DATAERR
, "user '%s' is not locked", pwd
->pw_name
);
239 if (mode
== M_LOCK
) {
240 asprintf(&passtmp
, "%s%s", locked_str
, pwd
->pw_passwd
);
241 if (passtmp
== NULL
) /* disaster */
242 errx(EX_UNAVAILABLE
, "out of memory");
243 pwd
->pw_passwd
= passtmp
;
245 pwd
->pw_passwd
+= sizeof(locked_str
)-1;
248 perform_chgpwent(name
, pwd
, NULL
);
251 return (EXIT_SUCCESS
);
255 pw_uidpolicy(struct userconf
* cnf
, intmax_t id
)
259 uid_t uid
= (uid_t
) - 1;
262 * Check the given uid, if any
267 if ((pwd
= GETPWUID(uid
)) != NULL
&& conf
.checkduplicate
)
268 errx(EX_DATAERR
, "uid `%ju' has already been allocated",
269 (uintmax_t)pwd
->pw_uid
);
273 * We need to allocate the next available uid under one of
274 * two policies a) Grab the first unused uid b) Grab the
275 * highest possible unused uid
277 if (cnf
->min_uid
>= cnf
->max_uid
) { /* Sanity
278 * claus^H^H^H^Hheck */
280 cnf
->max_uid
= 32000;
282 bm
= bm_alloc(cnf
->max_uid
- cnf
->min_uid
+ 1);
285 * Now, let's fill the bitmap from the password file
288 while ((pwd
= GETPWENT()) != NULL
)
289 if (pwd
->pw_uid
>= (uid_t
) cnf
->min_uid
&& pwd
->pw_uid
<= (uid_t
) cnf
->max_uid
)
290 bm_setbit(&bm
, pwd
->pw_uid
- cnf
->min_uid
);
294 * Then apply the policy, with fallback to reuse if necessary
296 if (cnf
->reuse_uids
|| (uid
= (uid_t
) (bm_lastset(&bm
) + cnf
->min_uid
+ 1)) > cnf
->max_uid
)
297 uid
= (uid_t
) (bm_firstunset(&bm
) + cnf
->min_uid
);
300 * Another sanity check
302 if (uid
< cnf
->min_uid
|| uid
> cnf
->max_uid
)
303 errx(EX_SOFTWARE
, "unable to allocate a new uid - range fully used");
309 pw_gidpolicy(struct userconf
*cnf
, char *grname
, char *nam
, gid_t prefer
, bool dryrun
)
312 gid_t gid
= (uid_t
) - 1;
315 * Check the given gid, if any
319 if ((grp
= GETGRNAM(grname
)) == NULL
) {
320 gid
= pw_checkid(grname
, GID_MAX
);
324 } else if ((grp
= GETGRNAM(nam
)) != NULL
&&
325 (grp
->gr_mem
== NULL
|| grp
->gr_mem
[0] == NULL
)) {
326 gid
= grp
->gr_gid
; /* Already created? Use it anyway... */
331 * We need to auto-create a group with the user's name. We
332 * can send all the appropriate output to our sister routine
333 * bit first see if we can create a group with gid==uid so we
334 * can keep the user and group ids in sync. We purposely do
335 * NOT check the gid range if we can force the sync. If the
336 * user's name dups an existing group, then the group add
337 * function will happily handle that case for us and exit.
339 if (GETGRGID(prefer
) == NULL
)
342 gid
= pw_groupnext(cnf
, true);
345 grid
= pw_groupnext(cnf
, true);
346 groupadd(cnf
, nam
, grid
, NULL
, -1, false, false, false);
347 if ((grp
= GETGRNAM(nam
)) != NULL
)
356 pw_homepolicy(struct userconf
* cnf
, char *homedir
, const char *user
)
358 static char home
[128];
363 if (cnf
->home
== NULL
|| *cnf
->home
== '\0')
364 errx(EX_CONFIG
, "no base home directory set");
365 snprintf(home
, sizeof(home
), "%s/%s", cnf
->home
, user
);
371 shell_path(char const * path
, char *shells
[], char *sh
)
373 if (sh
!= NULL
&& (*sh
== '/' || *sh
== '\0'))
374 return sh
; /* specified full path or forced none */
377 char paths
[_UC_MAXLINE
];
380 * We need to search paths
382 strlcpy(paths
, path
, sizeof(paths
));
383 for (p
= strtok(paths
, ": \t\r\n"); p
!= NULL
; p
= strtok(NULL
, ": \t\r\n")) {
385 static char shellpath
[256];
388 snprintf(shellpath
, sizeof(shellpath
), "%s/%s", p
, sh
);
389 if (access(shellpath
, X_OK
) == 0)
392 for (i
= 0; i
< _UC_MAXSHELLS
&& shells
[i
] != NULL
; i
++) {
393 snprintf(shellpath
, sizeof(shellpath
), "%s/%s", p
, shells
[i
]);
394 if (access(shellpath
, X_OK
) == 0)
399 errx(EX_OSFILE
, "can't find shell `%s' in shell paths", sh
);
400 errx(EX_CONFIG
, "no default shell available or defined");
406 pw_shellpolicy(struct userconf
* cnf
)
409 return shell_path(cnf
->shelldir
, cnf
->shells
, cnf
->shell_default
);
414 static char const chars
[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./";
417 pw_pwcrypt(char *password
)
420 char salt
[SALTSIZE
+ 1];
422 static char buf
[256];
425 * Calculate a salt value
427 for (i
= 0; i
< SALTSIZE
; i
++)
428 salt
[i
] = chars
[arc4random_uniform(sizeof(chars
) - 1)];
429 salt
[SALTSIZE
] = '\0';
431 cryptpw
= crypt(password
, salt
);
433 errx(EX_CONFIG
, "crypt(3) failure");
434 return strcpy(buf
, cryptpw
);
438 pw_password(struct userconf
* cnf
, char const * user
, bool dryrun
)
443 switch (cnf
->default_password
) {
444 case -1: /* Random password */
445 l
= (arc4random() % 8 + 8); /* 8 - 16 chars */
446 for (i
= 0; i
< l
; i
++)
447 pwbuf
[i
] = chars
[arc4random_uniform(sizeof(chars
)-1)];
451 * We give this information back to the user
453 if (conf
.fd
== -1 && !dryrun
) {
454 if (isatty(STDOUT_FILENO
))
455 printf("Password for '%s' is: ", user
);
456 printf("%s\n", pwbuf
);
461 case -2: /* No password at all! */
464 case 0: /* No login - default */
468 case 1: /* user's name */
469 strlcpy(pwbuf
, user
, sizeof(pwbuf
));
472 return pw_pwcrypt(pwbuf
);
476 print_user(struct passwd
* pwd
, bool pretty
, bool v7
)
480 struct group
*grp
= GETGRGID(pwd
->pw_gid
);
481 char uname
[60] = "User &", office
[60] = "[None]",
482 wphone
[60] = "[None]", hphone
[60] = "[None]";
483 char acexpire
[32] = "[None]", pwexpire
[32] = "[None]";
487 p
= v7
? pw_make_v7(pwd
) : pw_make(pwd
);
490 return (EXIT_SUCCESS
);
493 if ((p
= strtok(pwd
->pw_gecos
, ",")) != NULL
) {
494 strlcpy(uname
, p
, sizeof(uname
));
495 if ((p
= strtok(NULL
, ",")) != NULL
) {
496 strlcpy(office
, p
, sizeof(office
));
497 if ((p
= strtok(NULL
, ",")) != NULL
) {
498 strlcpy(wphone
, p
, sizeof(wphone
));
499 if ((p
= strtok(NULL
, "")) != NULL
) {
500 strlcpy(hphone
, p
, sizeof(hphone
));
506 * Handle '&' in gecos field
508 if ((p
= strchr(uname
, '&')) != NULL
) {
509 int l
= strlen(pwd
->pw_name
);
512 memmove(p
+ l
, p
+ 1, m
);
513 memmove(p
, pwd
->pw_name
, l
);
514 *p
= (char) toupper((unsigned char)*p
);
516 if (pwd
->pw_expire
> (time_t)0 && (tptr
= localtime(&pwd
->pw_expire
)) != NULL
)
517 strftime(acexpire
, sizeof acexpire
, "%c", tptr
);
518 if (pwd
->pw_change
> (time_t)0 && (tptr
= localtime(&pwd
->pw_change
)) != NULL
)
519 strftime(pwexpire
, sizeof pwexpire
, "%c", tptr
);
520 printf("Login Name: %-15s #%-12ju Group: %-15s #%ju\n"
522 " Home: %-26.26s Class: %s\n"
523 " Shell: %-26.26s Office: %s\n"
524 "Work Phone: %-26.26s Home Phone: %s\n"
525 "Acc Expire: %-26.26s Pwd Expire: %s\n",
526 pwd
->pw_name
, (uintmax_t)pwd
->pw_uid
,
527 grp
? grp
->gr_name
: "(invalid)", (uintmax_t)pwd
->pw_gid
,
528 uname
, pwd
->pw_dir
, pwd
->pw_class
,
529 pwd
->pw_shell
, office
, wphone
, hphone
,
533 while ((grp
=GETGRENT()) != NULL
) {
535 if (grp
->gr_mem
!= NULL
) {
536 while (grp
->gr_mem
[i
] != NULL
) {
537 if (strcmp(grp
->gr_mem
[i
], pwd
->pw_name
)==0) {
538 printf(j
++ == 0 ? " Groups: %s" : ",%s", grp
->gr_name
);
546 printf("%s", j
? "\n" : "");
547 return (EXIT_SUCCESS
);
551 pw_checkname(char *name
, int gecos
)
554 const char *badchars
, *ch
, *showtype
;
560 /* See if the name is valid as a gecos (comment) field. */
562 showtype
= "gecos field";
564 /* See if the name is valid as a userid or group. */
565 badchars
= " ,\t:+&#%$^()!@~*?<>=|\\/\"";
566 showtype
= "userid/group name";
567 /* Userids and groups can not have a leading '-'. */
573 if (strchr(badchars
, *ch
) != NULL
|| *ch
< ' ' ||
578 /* 8-bit characters are only allowed in GECOS fields */
579 if (!gecos
&& (*ch
& 0x80)) {
587 * A `$' is allowed as the final character for userids and groups,
588 * mainly for the benefit of samba.
590 if (reject
&& !gecos
) {
591 if (*ch
== '$' && *(ch
+ 1) == '\0') {
597 snprintf(showch
, sizeof(showch
), (*ch
>= ' ' && *ch
< 127)
598 ? "`%c'" : "0x%02x", *ch
);
599 errx(EX_DATAERR
, "invalid character %s at position %td in %s",
600 showch
, (ch
- name
), showtype
);
602 if (!gecos
&& (ch
- name
) > LOGNAMESIZE
)
603 errx(EX_USAGE
, "name too long `%s' (max is %d)", name
,
612 DIR *d
= opendir("/var/at/jobs");
617 while ((e
= readdir(d
)) != NULL
) {
620 if (strncmp(e
->d_name
, ".lock", 5) != 0 &&
621 stat(e
->d_name
, &st
) == 0 &&
622 !S_ISDIR(st
.st_mode
) &&
624 char tmp
[MAXPATHLEN
];
626 snprintf(tmp
, sizeof(tmp
), "/usr/bin/atrm %s",
636 rmopie(char const * name
)
644 if ((fd
= openat(conf
.rootfd
, "etc/opiekeys", O_RDWR
)) == -1)
647 fp
= fdopen(fd
, "r+");
650 while (fgets(tmp
, sizeof(tmp
), fp
) != NULL
) {
651 if (strncmp(name
, tmp
, len
) == 0 && tmp
[len
]==' ') {
652 /* Comment username out */
653 if (fseek(fp
, atofs
, SEEK_SET
) == 0)
654 fwrite("#", 1, 1, fp
);
660 * If we got an error of any sort, don't update!
666 pw_user_next(int argc
, char **argv
, char *name __unused
)
668 struct userconf
*cnf
= NULL
;
669 const char *cfg
= NULL
;
674 while ((ch
= getopt(argc
, argv
, "Cq")) != -1) {
686 freopen(_PATH_DEVNULL
, "w", stderr
);
688 cnf
= get_userconfig(cfg
);
690 next
= pw_uidpolicy(cnf
, -1);
692 printf("%ju:", (uintmax_t)next
);
693 pw_groupnext(cnf
, quiet
);
695 return (EXIT_SUCCESS
);
699 pw_user_show(int argc
, char **argv
, char *arg1
)
701 struct passwd
*pwd
= NULL
;
712 if (strspn(arg1
, "0123456789") == strlen(arg1
))
713 id
= pw_checkid(arg1
, UID_MAX
);
718 while ((ch
= getopt(argc
, argv
, "C:qn:u:FPa7")) != -1) {
721 /* ignore compatibility */
730 id
= pw_checkid(optarg
, UID_MAX
);
748 freopen(_PATH_DEVNULL
, "w", stderr
);
752 while ((pwd
= GETPWENT()) != NULL
)
753 print_user(pwd
, pretty
, v7
);
755 return (EXIT_SUCCESS
);
758 if (id
< 0 && name
== NULL
)
759 errx(EX_DATAERR
, "username or id required");
761 pwd
= (name
!= NULL
) ? GETPWNAM(pw_checkname(name
, 0)) : GETPWUID(id
);
767 errx(EX_NOUSER
, "no such uid `%ju'",
769 errx(EX_NOUSER
, "no such user `%s'", name
);
773 return (print_user(pwd
, pretty
, v7
));
777 pw_user_del(int argc
, char **argv
, char *arg1
)
779 struct userconf
*cnf
= NULL
;
780 struct passwd
*pwd
= NULL
;
781 struct group
*gr
, *grp
;
783 char grname
[MAXLOGNAME
];
784 char *nispasswd
= NULL
;
785 char file
[MAXPATHLEN
];
786 char home
[MAXPATHLEN
];
787 const char *cfg
= NULL
;
792 bool deletehome
= false;
796 if (strspn(arg1
, "0123456789") == strlen(arg1
))
797 id
= pw_checkid(arg1
, UID_MAX
);
802 while ((ch
= getopt(argc
, argv
, "C:qn:u:rYy:")) != -1) {
814 id
= pw_checkid(optarg
, UID_MAX
);
829 freopen(_PATH_DEVNULL
, "w", stderr
);
831 if (id
< 0 && name
== NULL
)
832 errx(EX_DATAERR
, "username or id required");
834 cnf
= get_userconfig(cfg
);
836 if (nispasswd
== NULL
)
837 nispasswd
= cnf
->nispasswd
;
839 pwd
= (name
!= NULL
) ? GETPWNAM(pw_checkname(name
, 0)) : GETPWUID(id
);
842 errx(EX_NOUSER
, "no such uid `%ju'", (uintmax_t) id
);
843 errx(EX_NOUSER
, "no such user `%s'", name
);
846 if (PWF
._altdir
== PWF_REGULAR
&&
847 ((pwd
->pw_fields
& _PWF_SOURCE
) != _PWF_FILES
)) {
848 if ((pwd
->pw_fields
& _PWF_SOURCE
) == _PWF_NIS
) {
849 if (!nis
&& nispasswd
&& *nispasswd
!= '/')
850 errx(EX_NOUSER
, "Cannot remove NIS user `%s'",
853 errx(EX_NOUSER
, "Cannot remove non local user `%s'",
862 if (strcmp(pwd
->pw_name
, "root") == 0)
863 errx(EX_DATAERR
, "cannot remove user 'root'");
865 /* Remove opie record from /etc/opiekeys */
866 if (PWALTDIR() != PWF_ALT
)
867 rmopie(pwd
->pw_name
);
870 /* Remove crontabs */
871 snprintf(file
, sizeof(file
), "/var/cron/tabs/%s", pwd
->pw_name
);
872 if (access(file
, F_OK
) == 0) {
873 snprintf(file
, sizeof(file
), "crontab -u %s -r",
880 * Save these for later, since contents of pwd may be
881 * invalidated by deletion
883 snprintf(file
, sizeof(file
), "%s/%s", _PATH_MAILDIR
, pwd
->pw_name
);
884 strlcpy(home
, pwd
->pw_dir
, sizeof(home
));
885 gr
= GETGRGID(pwd
->pw_gid
);
887 strlcpy(grname
, gr
->gr_name
, LOGNAMESIZE
);
893 err(EX_IOERR
, "user '%s' does not exist", pwd
->pw_name
);
895 err(EX_IOERR
, "passwd update");
897 if (nis
&& nispasswd
&& *nispasswd
=='/') {
898 rc
= delnispwent(nispasswd
, name
);
900 warnx("WARNING: user '%s' does not exist in NIS passwd",
903 warn("WARNING: NIS passwd update");
906 grp
= GETGRNAM(name
);
908 (grp
->gr_mem
== NULL
|| *grp
->gr_mem
== NULL
) &&
909 strcmp(name
, grname
) == 0)
910 delgrent(GETGRNAM(name
));
912 while ((grp
= GETGRENT()) != NULL
) {
914 char group
[MAXLOGNAME
];
915 if (grp
->gr_mem
== NULL
)
918 for (i
= 0; grp
->gr_mem
[i
] != NULL
; i
++) {
919 if (strcmp(grp
->gr_mem
[i
], name
) != 0)
922 for (j
= i
; grp
->gr_mem
[j
] != NULL
; j
++)
923 grp
->gr_mem
[j
] = grp
->gr_mem
[j
+1];
924 strlcpy(group
, grp
->gr_name
, MAXLOGNAME
);
925 chggrent(group
, grp
);
930 pw_log(cnf
, M_DELETE
, W_USER
, "%s(%ju) account removed", name
,
933 /* Remove mail file */
934 if (PWALTDIR() != PWF_ALT
)
935 unlinkat(conf
.rootfd
, file
+ 1, 0);
938 if (!PWALTDIR() && getpwuid(id
) == NULL
)
941 /* Remove home directory and contents */
942 if (PWALTDIR() != PWF_ALT
&& deletehome
&& *home
== '/' &&
943 GETPWUID(id
) == NULL
&&
944 fstatat(conf
.rootfd
, home
+ 1, &st
, 0) != -1) {
945 rm_r(conf
.rootfd
, home
, id
);
946 pw_log(cnf
, M_DELETE
, W_USER
, "%s(%ju) home '%s' %s"
947 "removed", name
, (uintmax_t)id
, home
,
948 fstatat(conf
.rootfd
, home
+ 1, &st
, 0) == -1 ? "" : "not "
952 return (EXIT_SUCCESS
);
956 pw_user_lock(int argc
, char **argv
, char *arg1
)
960 while ((ch
= getopt(argc
, argv
, "Cq")) != -1) {
969 return (pw_userlock(arg1
, M_LOCK
));
973 pw_user_unlock(int argc
, char **argv
, char *arg1
)
977 while ((ch
= getopt(argc
, argv
, "Cq")) != -1) {
986 return (pw_userlock(arg1
, M_UNLOCK
));
989 static struct group
*
990 group_from_name_or_id(char *name
)
992 const char *errstr
= NULL
;
996 if ((grp
= GETGRNAM(name
)) == NULL
) {
997 id
= strtounum(name
, 0, GID_MAX
, &errstr
);
999 errx(EX_NOUSER
, "group `%s' does not exist", name
);
1002 errx(EX_NOUSER
, "group `%s' does not exist", name
);
1009 split_groups(StringList
**groups
, char *groupsstr
)
1013 char tok
[] = ", \t";
1015 for (p
= strtok(groupsstr
, tok
); p
!= NULL
; p
= strtok(NULL
, tok
)) {
1016 grp
= group_from_name_or_id(p
);
1017 if (*groups
== NULL
)
1018 *groups
= sl_init();
1019 sl_add(*groups
, newstr(grp
->gr_name
));
1024 validate_grname(struct userconf
*cnf
, char *group
)
1028 if (group
== NULL
|| *group
== '\0') {
1029 cnf
->default_group
= "";
1032 grp
= group_from_name_or_id(group
);
1033 cnf
->default_group
= newstr(grp
->gr_name
);
1037 validate_mode(char *mode
)
1042 if ((set
= setmode(mode
)) == NULL
)
1043 errx(EX_DATAERR
, "invalid directory creation mode '%s'", mode
);
1045 m
= getmode(set
, _DEF_DIRMODE
);
1051 mix_config(struct userconf
*cmdcnf
, struct userconf
*cfg
)
1054 if (cmdcnf
->default_password
== 0)
1055 cmdcnf
->default_password
= cfg
->default_password
;
1056 if (cmdcnf
->reuse_uids
== 0)
1057 cmdcnf
->reuse_uids
= cfg
->reuse_uids
;
1058 if (cmdcnf
->reuse_gids
== 0)
1059 cmdcnf
->reuse_gids
= cfg
->reuse_gids
;
1060 if (cmdcnf
->nispasswd
== NULL
)
1061 cmdcnf
->nispasswd
= cfg
->nispasswd
;
1062 if (cmdcnf
->dotdir
== NULL
)
1063 cmdcnf
->dotdir
= cfg
->dotdir
;
1064 if (cmdcnf
->newmail
== NULL
)
1065 cmdcnf
->newmail
= cfg
->newmail
;
1066 if (cmdcnf
->logfile
== NULL
)
1067 cmdcnf
->logfile
= cfg
->logfile
;
1068 if (cmdcnf
->home
== NULL
)
1069 cmdcnf
->home
= cfg
->home
;
1070 if (cmdcnf
->homemode
== 0)
1071 cmdcnf
->homemode
= cfg
->homemode
;
1072 if (cmdcnf
->shelldir
== NULL
)
1073 cmdcnf
->shelldir
= cfg
->shelldir
;
1074 if (cmdcnf
->shells
== NULL
)
1075 cmdcnf
->shells
= cfg
->shells
;
1076 if (cmdcnf
->shell_default
== NULL
)
1077 cmdcnf
->shell_default
= cfg
->shell_default
;
1078 if (cmdcnf
->default_group
== NULL
)
1079 cmdcnf
->default_group
= cfg
->default_group
;
1080 if (cmdcnf
->groups
== NULL
)
1081 cmdcnf
->groups
= cfg
->groups
;
1082 if (cmdcnf
->default_class
== NULL
)
1083 cmdcnf
->default_class
= cfg
->default_class
;
1084 if (cmdcnf
->min_uid
== 0)
1085 cmdcnf
->min_uid
= cfg
->min_uid
;
1086 if (cmdcnf
->max_uid
== 0)
1087 cmdcnf
->max_uid
= cfg
->max_uid
;
1088 if (cmdcnf
->min_gid
== 0)
1089 cmdcnf
->min_gid
= cfg
->min_gid
;
1090 if (cmdcnf
->max_gid
== 0)
1091 cmdcnf
->max_gid
= cfg
->max_gid
;
1092 if (cmdcnf
->expire_days
== 0)
1093 cmdcnf
->expire_days
= cfg
->expire_days
;
1094 if (cmdcnf
->password_days
== 0)
1095 cmdcnf
->password_days
= cfg
->password_days
;
1099 pw_user_add(int argc
, char **argv
, char *arg1
)
1101 struct userconf
*cnf
, *cmdcnf
;
1105 char args
[] = "C:qn:u:c:d:e:p:g:G:mM:k:s:oL:i:w:h:H:Db:NPy:Y";
1106 char line
[_PASSWORD_LEN
+1], path
[MAXPATHLEN
];
1107 char *gecos
, *homedir
, *skel
, *walk
, *userid
, *groupid
, *grname
;
1108 char *default_passwd
, *name
, *p
;
1114 int rc
, ch
, fd
= -1;
1116 bool dryrun
, nis
, pretty
, quiet
, createhome
, precrypted
, genconf
;
1118 dryrun
= nis
= pretty
= quiet
= createhome
= precrypted
= false;
1120 gecos
= homedir
= skel
= userid
= groupid
= default_passwd
= NULL
;
1121 grname
= name
= NULL
;
1123 if ((cmdcnf
= calloc(1, sizeof(struct userconf
))) == NULL
)
1124 err(EXIT_FAILURE
, "calloc()");
1127 if (strspn(arg1
, "0123456789") == strlen(arg1
))
1128 id
= pw_checkid(arg1
, UID_MAX
);
1133 while ((ch
= getopt(argc
, argv
, args
)) != -1) {
1148 gecos
= pw_checkname(optarg
, 1);
1155 cmdcnf
->expire_days
= parse_date(now
, optarg
);
1159 cmdcnf
->password_days
= parse_date(now
, optarg
);
1162 validate_grname(cmdcnf
, optarg
);
1166 split_groups(&cmdcnf
->groups
, optarg
);
1172 cmdcnf
->homemode
= validate_mode(optarg
);
1175 walk
= skel
= optarg
;
1178 if (fstatat(conf
.rootfd
, walk
, &st
, 0) == -1)
1179 errx(EX_OSFILE
, "skeleton `%s' does not "
1181 if (!S_ISDIR(st
.st_mode
))
1182 errx(EX_OSFILE
, "skeleton `%s' is not a "
1184 cmdcnf
->dotdir
= skel
;
1187 cmdcnf
->shell_default
= optarg
;
1190 conf
.checkduplicate
= false;
1193 cmdcnf
->default_class
= pw_checkname(optarg
, 0);
1199 default_passwd
= optarg
;
1203 errx(EX_USAGE
, "'-h' and '-H' are mutually "
1204 "exclusive options");
1205 fd
= pw_checkfd(optarg
);
1208 errx(EX_USAGE
, "-H expects a file descriptor");
1212 errx(EX_USAGE
, "'-h' and '-H' are mutually "
1213 "exclusive options");
1214 fd
= pw_checkfd(optarg
);
1220 cmdcnf
->home
= optarg
;
1229 cmdcnf
->nispasswd
= optarg
;
1237 if (geteuid() != 0 && ! dryrun
)
1238 errx(EX_NOPERM
, "you must be root");
1241 freopen(_PATH_DEVNULL
, "w", stderr
);
1243 cnf
= get_userconfig(cfg
);
1245 mix_config(cmdcnf
, cnf
);
1247 cmdcnf
->default_password
= boolean_val(default_passwd
,
1248 cnf
->default_password
);
1251 errx(EX_DATAERR
, "can't combine `-D' with `-n name'");
1252 if (userid
!= NULL
) {
1253 if ((p
= strtok(userid
, ", \t")) != NULL
)
1254 cmdcnf
->min_uid
= pw_checkid(p
, UID_MAX
);
1255 if (cmdcnf
->min_uid
== 0)
1256 cmdcnf
->min_uid
= 1000;
1257 if ((p
= strtok(NULL
, " ,\t")) != NULL
)
1258 cmdcnf
->max_uid
= pw_checkid(p
, UID_MAX
);
1259 if (cmdcnf
->max_uid
== 0)
1260 cmdcnf
->max_uid
= 32000;
1262 if (groupid
!= NULL
) {
1263 if ((p
= strtok(groupid
, ", \t")) != NULL
)
1264 cmdcnf
->min_gid
= pw_checkid(p
, GID_MAX
);
1265 if (cmdcnf
->min_gid
== 0)
1266 cmdcnf
->min_gid
= 1000;
1267 if ((p
= strtok(NULL
, " ,\t")) != NULL
)
1268 cmdcnf
->max_gid
= pw_checkid(p
, GID_MAX
);
1269 if (cmdcnf
->max_gid
== 0)
1270 cmdcnf
->max_gid
= 32000;
1272 if (write_userconfig(cmdcnf
, cfg
))
1273 return (EXIT_SUCCESS
);
1274 err(EX_IOERR
, "config update");
1278 id
= pw_checkid(userid
, UID_MAX
);
1279 if (id
< 0 && name
== NULL
)
1280 errx(EX_DATAERR
, "user name or id required");
1283 errx(EX_DATAERR
, "login name required");
1285 if (GETPWNAM(name
) != NULL
)
1286 errx(EX_DATAERR
, "login name `%s' already exists", name
);
1289 pwd
->pw_name
= name
;
1290 pwd
->pw_class
= cmdcnf
->default_class
? cmdcnf
->default_class
: "";
1291 pwd
->pw_uid
= pw_uidpolicy(cmdcnf
, id
);
1292 pwd
->pw_gid
= pw_gidpolicy(cnf
, grname
, pwd
->pw_name
,
1293 (gid_t
) pwd
->pw_uid
, dryrun
);
1294 pwd
->pw_change
= cmdcnf
->password_days
;
1295 pwd
->pw_expire
= cmdcnf
->expire_days
;
1296 pwd
->pw_dir
= pw_homepolicy(cmdcnf
, homedir
, pwd
->pw_name
);
1297 pwd
->pw_shell
= pw_shellpolicy(cmdcnf
);
1298 lc
= login_getpwclass(pwd
);
1299 if (lc
== NULL
|| login_setcryptfmt(lc
, "sha512", NULL
) == NULL
)
1300 warn("setting crypt(3) format");
1302 pwd
->pw_passwd
= pw_password(cmdcnf
, pwd
->pw_name
, dryrun
);
1303 if (pwd
->pw_uid
== 0 && strcmp(pwd
->pw_name
, "root") != 0)
1304 warnx("WARNING: new account `%s' has a uid of 0 "
1305 "(superuser access!)", pwd
->pw_name
);
1307 pwd
->pw_gecos
= gecos
;
1310 pw_set_passwd(pwd
, fd
, precrypted
, false);
1313 return (print_user(pwd
, pretty
, false));
1315 if ((rc
= addpwent(pwd
)) != 0) {
1317 errx(EX_IOERR
, "user '%s' already exists",
1320 err(EX_IOERR
, "passwd file update");
1322 if (nis
&& cmdcnf
->nispasswd
&& *cmdcnf
->nispasswd
== '/') {
1323 printf("%s\n", cmdcnf
->nispasswd
);
1324 rc
= addnispwent(cmdcnf
->nispasswd
, pwd
);
1326 warnx("User '%s' already exists in NIS passwd",
1329 warn("NIS passwd update");
1330 /* NOTE: we treat NIS-only update errors as non-fatal */
1333 if (cmdcnf
->groups
!= NULL
) {
1334 for (i
= 0; i
< cmdcnf
->groups
->sl_cur
; i
++) {
1335 grp
= GETGRNAM(cmdcnf
->groups
->sl_str
[i
]);
1336 grp
= gr_add(grp
, pwd
->pw_name
);
1338 * grp can only be NULL in 2 cases:
1339 * - the new member is already a member
1340 * - a problem with memory occurs
1341 * in both cases we want to skip now.
1345 chggrent(grp
->gr_name
, grp
);
1350 pwd
= GETPWNAM(name
);
1352 errx(EX_NOUSER
, "user '%s' disappeared during update", name
);
1354 grp
= GETGRGID(pwd
->pw_gid
);
1355 pw_log(cnf
, M_ADD
, W_USER
, "%s(%ju):%s(%ju):%s:%s:%s",
1356 pwd
->pw_name
, (uintmax_t)pwd
->pw_uid
,
1357 grp
? grp
->gr_name
: "unknown",
1358 (uintmax_t)(grp
? grp
->gr_gid
: (uid_t
)-1),
1359 pwd
->pw_gecos
, pwd
->pw_dir
, pwd
->pw_shell
);
1362 * let's touch and chown the user's mail file. This is not
1363 * strictly necessary under BSD with a 0755 maildir but it also
1364 * doesn't hurt anything to create the empty mailfile
1366 if (PWALTDIR() != PWF_ALT
) {
1367 snprintf(path
, sizeof(path
), "%s/%s", _PATH_MAILDIR
,
1369 /* Preserve contents & mtime */
1370 close(openat(conf
.rootfd
, path
+1, O_RDWR
| O_CREAT
, 0600));
1371 fchownat(conf
.rootfd
, path
+ 1, pwd
->pw_uid
, pwd
->pw_gid
,
1372 AT_SYMLINK_NOFOLLOW
);
1376 * Let's create and populate the user's home directory. Note
1377 * that this also `works' for editing users if -m is used, but
1378 * existing files will *not* be overwritten.
1380 if (PWALTDIR() != PWF_ALT
&& createhome
&& pwd
->pw_dir
&&
1381 *pwd
->pw_dir
== '/' && pwd
->pw_dir
[1])
1382 create_and_populate_homedir(cmdcnf
, pwd
, cmdcnf
->dotdir
,
1383 cmdcnf
->homemode
, false);
1385 if (!PWALTDIR() && cmdcnf
->newmail
&& *cmdcnf
->newmail
&&
1386 (fp
= fopen(cnf
->newmail
, "r")) != NULL
) {
1387 if ((pfp
= popen(_PATH_SENDMAIL
" -t", "w")) == NULL
)
1390 fprintf(pfp
, "From: root\n" "To: %s\n"
1391 "Subject: Welcome!\n\n", pwd
->pw_name
);
1392 while (fgets(line
, sizeof(line
), fp
) != NULL
) {
1393 /* Do substitutions? */
1397 pw_log(cnf
, M_ADD
, W_USER
, "%s(%ju) new user mail sent",
1398 pwd
->pw_name
, (uintmax_t)pwd
->pw_uid
);
1403 if (nis
&& nis_update() == 0)
1404 pw_log(cnf
, M_ADD
, W_USER
, "NIS maps updated");
1406 return (EXIT_SUCCESS
);
1410 pw_user_mod(int argc
, char **argv
, char *arg1
)
1412 struct userconf
*cnf
;
1415 StringList
*groups
= NULL
;
1416 char args
[] = "C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:NPYy:";
1418 char *gecos
, *homedir
, *grname
, *name
, *newname
, *walk
, *skel
, *shell
;
1419 char *passwd
, *class, *nispasswd
;
1425 bool quiet
, createhome
, pretty
, dryrun
, nis
, edited
, docreatehome
;
1426 mode_t homemode
= 0;
1427 time_t expire_days
, password_days
, now
, precrypted
;
1429 expire_days
= password_days
= -1;
1430 gecos
= homedir
= grname
= name
= newname
= skel
= shell
=NULL
;
1432 class = nispasswd
= NULL
;
1433 quiet
= createhome
= pretty
= dryrun
= nis
= precrypted
= false;
1434 edited
= docreatehome
= false;
1437 if (strspn(arg1
, "0123456789") == strlen(arg1
))
1438 id
= pw_checkid(arg1
, UID_MAX
);
1443 while ((ch
= getopt(argc
, argv
, args
)) != -1) {
1455 id
= pw_checkid(optarg
, UID_MAX
);
1458 gecos
= pw_checkname(optarg
, 1);
1465 expire_days
= parse_date(now
, optarg
);
1469 password_days
= parse_date(now
, optarg
);
1472 group_from_name_or_id(optarg
);
1476 split_groups(&groups
, optarg
);
1482 homemode
= validate_mode(optarg
);
1488 walk
= skel
= optarg
;
1491 if (fstatat(conf
.rootfd
, walk
, &st
, 0) == -1)
1492 errx(EX_OSFILE
, "skeleton `%s' does not "
1494 if (!S_ISDIR(st
.st_mode
))
1495 errx(EX_OSFILE
, "skeleton `%s' is not a "
1505 class = pw_checkname(optarg
, 0);
1509 errx(EX_USAGE
, "'-h' and '-H' are mutually "
1510 "exclusive options");
1511 fd
= pw_checkfd(optarg
);
1514 errx(EX_USAGE
, "-H expects a file descriptor");
1518 errx(EX_USAGE
, "'-h' and '-H' are mutually "
1519 "exclusive options");
1520 fd
= pw_checkfd(optarg
);
1537 if (geteuid() != 0 && ! dryrun
)
1538 errx(EX_NOPERM
, "you must be root");
1541 freopen(_PATH_DEVNULL
, "w", stderr
);
1543 cnf
= get_userconfig(cfg
);
1545 if (id
< 0 && name
== NULL
)
1546 errx(EX_DATAERR
, "username or id required");
1548 pwd
= (name
!= NULL
) ? GETPWNAM(pw_checkname(name
, 0)) : GETPWUID(id
);
1551 errx(EX_NOUSER
, "no such uid `%ju'",
1553 errx(EX_NOUSER
, "no such user `%s'", name
);
1557 name
= pwd
->pw_name
;
1559 if (nis
&& nispasswd
== NULL
)
1560 nispasswd
= cnf
->nispasswd
;
1562 if (PWF
._altdir
== PWF_REGULAR
&&
1563 ((pwd
->pw_fields
& _PWF_SOURCE
) != _PWF_FILES
)) {
1564 if ((pwd
->pw_fields
& _PWF_SOURCE
) == _PWF_NIS
) {
1565 if (!nis
&& nispasswd
&& *nispasswd
!= '/')
1566 errx(EX_NOUSER
, "Cannot modify NIS user `%s'",
1569 errx(EX_NOUSER
, "Cannot modify non local user `%s'",
1575 if (strcmp(pwd
->pw_name
, "root") == 0)
1576 errx(EX_DATAERR
, "can't rename `root' account");
1577 if (strcmp(pwd
->pw_name
, newname
) != 0) {
1578 pwd
->pw_name
= pw_checkname(newname
, 0);
1583 if (id
> 0 && pwd
->pw_uid
!= id
) {
1586 if (pwd
->pw_uid
!= 0 && strcmp(pwd
->pw_name
, "root") == 0)
1587 errx(EX_DATAERR
, "can't change uid of `root' account");
1588 if (pwd
->pw_uid
== 0 && strcmp(pwd
->pw_name
, "root") != 0)
1589 warnx("WARNING: account `%s' will have a uid of 0 "
1590 "(superuser access!)", pwd
->pw_name
);
1593 if (grname
&& pwd
->pw_uid
!= 0) {
1594 grp
= GETGRNAM(grname
);
1596 grp
= GETGRGID(pw_checkid(grname
, GID_MAX
));
1597 if (grp
->gr_gid
!= pwd
->pw_gid
) {
1598 pwd
->pw_gid
= grp
->gr_gid
;
1603 if (password_days
>= 0 && pwd
->pw_change
!= password_days
) {
1604 pwd
->pw_change
= password_days
;
1608 if (expire_days
>= 0 && pwd
->pw_expire
!= expire_days
) {
1609 pwd
->pw_expire
= expire_days
;
1614 shell
= shell_path(cnf
->shelldir
, cnf
->shells
, shell
);
1617 if (strcmp(shell
, pwd
->pw_shell
) != 0) {
1618 pwd
->pw_shell
= shell
;
1623 if (class && strcmp(pwd
->pw_class
, class) != 0) {
1624 pwd
->pw_class
= class;
1628 if (homedir
&& strcmp(pwd
->pw_dir
, homedir
) != 0) {
1629 pwd
->pw_dir
= homedir
;
1630 if (fstatat(conf
.rootfd
, pwd
->pw_dir
, &st
, 0) == -1) {
1632 warnx("WARNING: home `%s' does not exist",
1635 docreatehome
= true;
1636 } else if (!S_ISDIR(st
.st_mode
)) {
1637 warnx("WARNING: home `%s' is not a directory",
1642 if (passwd
&& conf
.fd
== -1) {
1643 lc
= login_getpwclass(pwd
);
1644 if (lc
== NULL
|| login_setcryptfmt(lc
, "sha512", NULL
) == NULL
)
1645 warn("setting crypt(3) format");
1647 pwd
->pw_passwd
= pw_password(cnf
, pwd
->pw_name
, dryrun
);
1651 if (gecos
&& strcmp(pwd
->pw_gecos
, gecos
) != 0) {
1652 pwd
->pw_gecos
= gecos
;
1657 edited
= pw_set_passwd(pwd
, fd
, precrypted
, true);
1660 return (print_user(pwd
, pretty
, false));
1662 if (edited
) /* Only updated this if required */
1663 perform_chgpwent(name
, pwd
, nis
? nispasswd
: NULL
);
1664 /* Now perform the needed changes concern groups */
1665 if (groups
!= NULL
) {
1666 /* Delete User from groups using old name */
1668 while ((grp
= GETGRENT()) != NULL
) {
1669 if (grp
->gr_mem
== NULL
)
1671 for (i
= 0; grp
->gr_mem
[i
] != NULL
; i
++) {
1672 if (strcmp(grp
->gr_mem
[i
] , name
) != 0)
1674 for (j
= i
; grp
->gr_mem
[j
] != NULL
; j
++)
1675 grp
->gr_mem
[j
] = grp
->gr_mem
[j
+1];
1676 chggrent(grp
->gr_name
, grp
);
1681 /* Add the user to the needed groups */
1682 for (i
= 0; i
< groups
->sl_cur
; i
++) {
1683 grp
= GETGRNAM(groups
->sl_str
[i
]);
1684 grp
= gr_add(grp
, pwd
->pw_name
);
1687 chggrent(grp
->gr_name
, grp
);
1691 /* In case of rename we need to walk over the different groups */
1694 while ((grp
= GETGRENT()) != NULL
) {
1695 if (grp
->gr_mem
== NULL
)
1697 for (i
= 0; grp
->gr_mem
[i
] != NULL
; i
++) {
1698 if (strcmp(grp
->gr_mem
[i
], name
) != 0)
1700 grp
->gr_mem
[i
] = newname
;
1701 chggrent(grp
->gr_name
, grp
);
1707 /* go get a current version of pwd */
1710 pwd
= GETPWNAM(name
);
1712 errx(EX_NOUSER
, "user '%s' disappeared during update", name
);
1713 grp
= GETGRGID(pwd
->pw_gid
);
1714 pw_log(cnf
, M_UPDATE
, W_USER
, "%s(%ju):%s(%ju):%s:%s:%s",
1715 pwd
->pw_name
, (uintmax_t)pwd
->pw_uid
,
1716 grp
? grp
->gr_name
: "unknown",
1717 (uintmax_t)(grp
? grp
->gr_gid
: (uid_t
)-1),
1718 pwd
->pw_gecos
, pwd
->pw_dir
, pwd
->pw_shell
);
1721 * Let's create and populate the user's home directory. Note
1722 * that this also `works' for editing users if -m is used, but
1723 * existing files will *not* be overwritten.
1725 if (PWALTDIR() != PWF_ALT
&& docreatehome
&& pwd
->pw_dir
&&
1726 *pwd
->pw_dir
== '/' && pwd
->pw_dir
[1]) {
1730 homemode
= cnf
->homemode
;
1731 create_and_populate_homedir(cnf
, pwd
, skel
, homemode
, true);
1734 if (nis
&& nis_update() == 0)
1735 pw_log(cnf
, M_UPDATE
, W_USER
, "NIS maps updated");
1737 return (EXIT_SUCCESS
);