2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 1995, 1996
5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #include <sys/param.h>
39 #include <sys/fcntl.h>
40 #include <sys/socket.h>
44 #include <arpa/inet.h>
45 #include <netinet/in.h>
63 #include <rpcsvc/yp.h>
65 #include <rpcsvc/ypclnt.h>
66 #include "yppasswdd_extern.h"
68 #include "yppasswd_private.h"
69 #include "ypxfr_extern.h"
70 #include "yp_extern.h"
72 static struct passwd yp_password;
75 xlate_passwd(struct x_master_passwd *xpwd, struct passwd *pwd)
77 pwd->pw_name = xpwd->pw_name;
78 pwd->pw_passwd = xpwd->pw_passwd;
79 pwd->pw_uid = xpwd->pw_uid;
80 pwd->pw_gid = xpwd->pw_gid;
81 pwd->pw_change = xpwd->pw_change;
82 pwd->pw_class = xpwd->pw_class;
83 pwd->pw_gecos = xpwd->pw_gecos;
84 pwd->pw_dir = xpwd->pw_dir;
85 pwd->pw_shell = xpwd->pw_shell;
86 pwd->pw_expire = xpwd->pw_expire;
87 pwd->pw_fields = xpwd->pw_fields;
91 copy_yp_pass(char *p, int x, int m)
96 yp_password.pw_fields = 0;
98 buf = realloc(buf, m + 10);
101 /* Turn all colons into NULLs */
102 while (strchr(s, ':')) {
103 s = (strchr(s, ':') + 1);
108 #define EXPAND(e) do { \
110 while ((*t++ = *p++)); \
112 EXPAND(yp_password.pw_name);
113 yp_password.pw_fields |= _PWF_NAME;
114 EXPAND(yp_password.pw_passwd);
115 yp_password.pw_fields |= _PWF_PASSWD;
116 yp_password.pw_uid = atoi(p);
117 p += (strlen(p) + 1);
118 yp_password.pw_fields |= _PWF_UID;
119 yp_password.pw_gid = atoi(p);
120 p += (strlen(p) + 1);
121 yp_password.pw_fields |= _PWF_GID;
123 EXPAND(yp_password.pw_class);
124 yp_password.pw_fields |= _PWF_CLASS;
125 yp_password.pw_change = atol(p);
126 p += (strlen(p) + 1);
127 yp_password.pw_fields |= _PWF_CHANGE;
128 yp_password.pw_expire = atol(p);
129 p += (strlen(p) + 1);
130 yp_password.pw_fields |= _PWF_EXPIRE;
132 EXPAND(yp_password.pw_gecos);
133 yp_password.pw_fields |= _PWF_GECOS;
134 EXPAND(yp_password.pw_dir);
135 yp_password.pw_fields |= _PWF_DIR;
136 EXPAND(yp_password.pw_shell);
137 yp_password.pw_fields |= _PWF_SHELL;
143 validchars(char *arg)
147 for (i = 0; i < strlen(arg); i++) {
148 if (iscntrl(arg[i])) {
149 yp_error("string contains a control character");
153 yp_error("string contains a colon");
156 /* Be evil: truncate strings with \n in them silently. */
157 if (arg[i] == '\n') {
166 validate_master(struct passwd *opw __unused, struct x_master_passwd *npw)
169 if (npw->pw_name[0] == '+' || npw->pw_name[0] == '-') {
170 yp_error("client tried to modify an NIS entry");
174 if (validchars(npw->pw_shell)) {
175 yp_error("specified shell contains invalid characters");
179 if (validchars(npw->pw_gecos)) {
180 yp_error("specified gecos field contains invalid characters");
184 if (validchars(npw->pw_passwd)) {
185 yp_error("specified password contains invalid characters");
192 validate(struct passwd *opw, struct x_passwd *npw)
195 if (npw->pw_name[0] == '+' || npw->pw_name[0] == '-') {
196 yp_error("client tried to modify an NIS entry");
200 if ((uid_t)npw->pw_uid != opw->pw_uid) {
201 yp_error("UID mismatch: client says user %s has UID %d",
202 npw->pw_name, npw->pw_uid);
203 yp_error("database says user %s has UID %d", opw->pw_name,
208 if ((gid_t)npw->pw_gid != opw->pw_gid) {
209 yp_error("GID mismatch: client says user %s has GID %d",
210 npw->pw_name, npw->pw_gid);
211 yp_error("database says user %s has GID %d", opw->pw_name,
217 * Don't allow the user to shoot himself in the foot,
220 if (!no_chsh && !ok_shell(npw->pw_shell)) {
221 yp_error("%s is not a valid shell", npw->pw_shell);
225 if (!no_chsh && validchars(npw->pw_shell)) {
226 yp_error("specified shell contains invalid characters");
230 if (validchars(npw->pw_gecos)) {
231 yp_error("specified gecos field contains invalid characters");
235 if (validchars(npw->pw_passwd)) {
236 yp_error("specified password contains invalid characters");
244 * In order to have one rpc.yppasswdd support multiple domains,
245 * we have to cheat: we search each directory under /var/yp
246 * and try to match the user in each master.passwd.byname
247 * map that we find. If the user matches (username, uid and gid
248 * all agree), then we use that domain. If we match the user in
249 * more than one database, we must abort.
252 find_domain(struct x_passwd *pw)
257 char yp_mapdir[MAXPATHLEN + 2];
258 static char domain[YPMAXDOMAIN];
263 yp_error("performing multidomain lookup");
265 if ((dird = opendir(yp_dir)) == NULL) {
266 yp_error("opendir(%s) failed: %s", yp_dir, strerror(errno));
270 while ((dirp = readdir(dird)) != NULL) {
271 snprintf(yp_mapdir, sizeof yp_mapdir, "%s/%s",
272 yp_dir, dirp->d_name);
273 if (stat(yp_mapdir, &statbuf) < 0) {
274 yp_error("stat(%s) failed: %s", yp_mapdir,
279 if (S_ISDIR(statbuf.st_mode)) {
280 tmp = (char *)dirp->d_name;
281 key.data = pw->pw_name;
282 key.size = strlen(pw->pw_name);
284 if (yp_get_record(tmp,"master.passwd.byname",
285 &key, &data, 0) != YP_TRUE) {
288 *((char *)data.data + data.size) = '\0';
289 copy_yp_pass(data.data, 1, data.size);
290 if (yp_password.pw_uid == (uid_t)pw->pw_uid &&
291 yp_password.pw_gid == (gid_t)pw->pw_gid) {
293 snprintf(domain, YPMAXDOMAIN, "%s", tmp);
300 yp_error("found same user in two different domains");
303 return((char *)&domain);
306 static const char *maps[] = {
307 "master.passwd.byname",
308 "master.passwd.byuid",
313 static const char *formats[] = {
314 "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s",
315 "%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s",
316 "%s:%s:%d:%d:%s:%s:%s",
317 "%s:%s:%d:%d:%s:%s:%s"
321 update_inplace(struct passwd *pw, char *domain)
324 DBT key = { NULL, 0 };
325 DBT data = { NULL, 0 };
330 static char yp_last[] = "YP_LAST_MODIFIED";
333 snprintf(yplastbuf, sizeof yplastbuf, "%llu",
334 (unsigned long long)time(NULL));
337 for (i = 0; i < 4; i++) {
340 snprintf(keybuf, sizeof keybuf,
341 "%llu", (unsigned long long)pw->pw_uid);
343 key.size = strlen(keybuf);
345 key.data = pw->pw_name;
346 key.size = strlen(pw->pw_name);
350 * XXX The passwd.byname and passwd.byuid maps come in
351 * two flavors: secure and insecure. The secure version
352 * has a '*' in the password field whereas the insecure one
353 * has a real crypted password. The maps will be insecure
354 * if they were built with 'unsecure = TRUE' enabled in
355 * /var/yp/Makefile, but we'd have no way of knowing if
356 * this has been done unless we were to try parsing the
357 * Makefile, which is a disgusting thought. Instead, we
358 * read the records from the maps, skip to the first ':'
359 * in them, and then look at the character immediately
360 * following it. If it's an '*' then the map is 'secure'
361 * and we must not insert a real password into the pw_passwd
362 * field. If it's not an '*', then we put the real crypted
365 if (yp_get_record(domain,maps[i],&key,&data,1) != YP_TRUE) {
366 yp_error("couldn't read %s/%s: %s", domain,
367 maps[i], strerror(errno));
371 if ((ptr = strchr(data.data, ':')) == NULL) {
372 yp_error("no colon in passwd record?!");
377 * XXX Supposing we have more than one user with the same
378 * UID? (Or more than one user with the same name?) We could
379 * end up modifying the wrong record if were not careful.
382 if (strncmp(data.data, pw->pw_name,
383 strlen(pw->pw_name))) {
384 yp_error("warning: found entry for UID %d \
385 in map %s@%s with wrong name (%.*s)", pw->pw_uid, maps[i], domain,
386 (int)(ptr - (char *)data.data),
388 yp_error("there may be more than one user \
389 with the same UID - continuing");
394 * We're really being ultra-paranoid here.
395 * This is generally a 'can't happen' condition.
398 asprintf(&pwbuf, ":%d:%d:", pw->pw_uid, pw->pw_gid);
400 yp_error("no memory");
403 if (!strstr(data.data, pwbuf)) {
404 yp_error("warning: found entry for user %s \
405 in map %s@%s with wrong UID", pw->pw_name, maps[i], domain);
406 yp_error("there may be more than one user \
407 with the same name - continuing");
414 asprintf(&pwbuf, formats[i],
415 pw->pw_name, pw->pw_passwd, pw->pw_uid,
416 pw->pw_gid, pw->pw_class, pw->pw_change,
417 pw->pw_expire, pw->pw_gecos, pw->pw_dir,
421 asprintf(&pwbuf, formats[i],
422 pw->pw_name, *(ptr+1) == '*' ? "*" : pw->pw_passwd,
423 pw->pw_uid, pw->pw_gid, pw->pw_gecos, pw->pw_dir,
427 yp_error("no memory");
431 #define FLAGS O_RDWR|O_CREAT
433 if ((dbp = yp_open_db_rw(domain, maps[i], FLAGS)) == NULL) {
434 yp_error("couldn't open %s/%s r/w: %s",domain,
435 maps[i],strerror(errno));
440 data.size = strlen(pwbuf);
442 if (yp_put_record(dbp, &key, &data, 1) != YP_TRUE) {
443 yp_error("failed to update record in %s/%s", domain,
445 (void)(dbp->close)(dbp);
450 key.size = strlen(yp_last);
451 data.data = (char *)&yplastbuf;
452 data.size = strlen(yplastbuf);
454 if (yp_put_record(dbp, &key, &data, 1) != YP_TRUE) {
455 yp_error("failed to update timestamp in %s/%s", domain,
457 (void)(dbp->close)(dbp);
461 (void)(dbp->close)(dbp);
472 yppasswdproc_update_1_svc(yppasswd *argp, struct svc_req *rqstp)
475 struct sockaddr_in *rqhost;
480 int passwd_changed = 0;
481 int shell_changed = 0;
482 int gecos_changed = 0;
484 char *oldshell = NULL;
485 char *oldgecos = NULL;
488 char passdir_buf[MAXPATHLEN + 2];
489 char passfile_buf[MAXPATHLEN + 2];
490 char passfile_hold_buf[MAXPATHLEN + 2];
491 char *domain = yppasswd_domain;
492 static struct sockaddr_in clntaddr;
493 static struct timeval t_saved, t_test;
496 * Normal user updates always use the 'default' master.passwd file.
499 passfile = passfile_default;
502 rqhost = svc_getcaller(rqstp->rq_xprt);
504 gettimeofday(&t_test, NULL);
505 if (!bcmp(rqhost, &clntaddr, sizeof *rqhost) &&
506 t_test.tv_sec > t_saved.tv_sec &&
507 t_test.tv_sec - t_saved.tv_sec < 300) {
509 bzero(&clntaddr, sizeof clntaddr);
510 bzero(&t_saved, sizeof t_saved);
514 bcopy(rqhost, &clntaddr, sizeof clntaddr);
515 gettimeofday(&t_saved, NULL);
517 if (yp_access(resvport ? "master.passwd.byname" : NULL, rqstp)) {
518 yp_error("rejected update request from unauthorized host");
519 svcerr_auth(rqstp->rq_xprt, AUTH_BADCRED);
524 * Step one: find the user. (It's kinda pointless to
525 * proceed if the user doesn't exist.) We look for the
526 * user in the master.passwd.byname database, _NOT_ by
527 * using getpwent() and friends! We can't use getpwent()
528 * since the NIS master server is not guaranteed to be
529 * configured as an NIS client.
533 if ((domain = find_domain(&argp->newpw)) == NULL) {
534 yp_error("multidomain lookup failed - aborting update");
537 yp_error("updating user %s in domain %s",
538 argp->newpw.pw_name, domain);
541 key.data = argp->newpw.pw_name;
542 key.size = strlen(argp->newpw.pw_name);
544 if ((rval = yp_get_record(domain,"master.passwd.byname",
545 &key, &data, 0)) != YP_TRUE) {
546 if (rval == YP_NOKEY) {
547 yp_error("user %s not found in passwd database",
548 argp->newpw.pw_name);
550 yp_error("database access error: %s",
556 /* Nul terminate, please. */
557 *((char *)data.data + data.size) = '\0';
559 copy_yp_pass(data.data, 1, data.size);
561 /* Step 2: check that the supplied oldpass is valid. */
563 cryptpw = crypt(argp->oldpass, yp_password.pw_passwd);
564 if (cryptpw == NULL || strcmp(cryptpw, yp_password.pw_passwd)) {
565 yp_error("rejected change attempt -- bad password");
566 yp_error("client address: %s username: %s",
567 inet_ntoa(rqhost->sin_addr),
568 argp->newpw.pw_name);
572 /* Step 3: validate the arguments passed to us by the client. */
574 if (validate(&yp_password, &argp->newpw)) {
575 yp_error("rejecting change attempt: bad arguments");
576 yp_error("client address: %s username: %s",
577 inet_ntoa(rqhost->sin_addr),
578 argp->newpw.pw_name);
579 svcerr_decode(rqstp->rq_xprt);
583 /* Step 4: update the user's passwd structure. */
585 if (!no_chsh && strcmp(argp->newpw.pw_shell, yp_password.pw_shell)) {
586 oldshell = yp_password.pw_shell;
587 yp_password.pw_shell = argp->newpw.pw_shell;
592 if (!no_chfn && strcmp(argp->newpw.pw_gecos, yp_password.pw_gecos)) {
593 oldgecos = yp_password.pw_gecos;
594 yp_password.pw_gecos = argp->newpw.pw_gecos;
598 if (strcmp(argp->newpw.pw_passwd, yp_password.pw_passwd)) {
599 yp_password.pw_passwd = argp->newpw.pw_passwd;
600 yp_password.pw_change = 0;
605 * If the caller specified a domain other than our 'default'
606 * domain, change the path to master.passwd accordingly.
609 if (strcmp(domain, yppasswd_domain)) {
610 snprintf(passfile_buf, sizeof(passfile_buf),
611 "%s/%s/master.passwd", yp_dir, domain);
612 passfile = (char *)&passfile_buf;
616 * Create a filename to hold the original master.passwd
617 * so if our call to yppwupdate fails we can roll back
619 snprintf(passfile_hold_buf, sizeof(passfile_hold_buf),
620 "%s.hold", passfile);
621 passfile_hold = (char *)&passfile_hold_buf;
624 /* Step 5: make a new password file with the updated info. */
626 snprintf(passdir_buf, sizeof(passdir_buf), "%s", passfile);
627 passdir = dirname(passdir_buf);
629 if (pw_init(passdir, passfile)) {
630 yp_error("pw_init() failed");
633 if ((pfd = pw_lock()) == -1) {
635 yp_error("pw_lock() failed");
638 if ((tfd = pw_tmp(-1)) == -1) {
640 yp_error("pw_tmp() failed");
643 if (pw_copy(pfd, tfd, &yp_password, NULL) == -1) {
645 yp_error("pw_copy() failed");
648 if (rename(passfile, passfile_hold) == -1) {
650 yp_error("rename of %s to %s failed", passfile,
655 if (strcmp(passfile, _PATH_MASTERPASSWD) == 0) {
657 * NIS server is exporting the system's master.passwd.
658 * Call pw_mkdb to rebuild passwd and the .db files
660 if (pw_mkdb(yp_password.pw_name) == -1) {
662 yp_error("pw_mkdb() failed");
663 rename(passfile_hold, passfile);
668 * NIS server is exporting a private master.passwd.
669 * Rename tempfile into final location
671 if (rename(pw_tempname(), passfile) == -1) {
673 yp_error("rename of %s to %s failed",
674 pw_tempname(), passfile);
675 rename(passfile_hold, passfile);
683 if ((rval = update_inplace(&yp_password, domain))) {
684 yp_error("inplace update failed -- rebuilding maps");
688 switch ((pid = fork())) {
690 if (inplace && !rval) {
691 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
692 yppasswd_domain, "pushpw", (char *)NULL);
694 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
695 yppasswd_domain, (char *)NULL);
697 yp_error("couldn't exec map update process: %s",
700 rename(passfile_hold, passfile);
704 yp_error("fork() failed: %s", strerror(errno));
706 rename(passfile_hold, passfile);
710 unlink(passfile_hold);
715 yp_error("update completed for user %s (uid %d) in %s:",
716 argp->newpw.pw_name, argp->newpw.pw_uid, passfile);
719 yp_error("password changed");
722 yp_error("gecos changed ('%s' -> '%s')",
723 oldgecos, argp->newpw.pw_gecos);
726 yp_error("shell changed ('%s' -> '%s')",
727 oldshell, argp->newpw.pw_shell);
735 * Note that this function performs a little less sanity checking
736 * than the last one. Since only the superuser is allowed to use it,
737 * it is assumed that the caller knows what he's doing.
740 yppasswdproc_update_master_1_svc(master_yppasswd *argp,
741 struct svc_req *rqstp)
751 char passdir_buf[MAXPATHLEN + 2];
752 char passfile_buf[MAXPATHLEN + 2];
753 char passfile_hold_buf[MAXPATHLEN + 2];
754 struct sockaddr_in *rqhost;
756 struct passwd newpasswd;
759 transp = rqstp->rq_xprt;
762 * NO AF_INET CONNETCIONS ALLOWED!
764 rqhost = svc_getcaller(transp);
765 if (rqhost->sin_family != AF_UNIX) {
766 yp_error("Alert! %s/%d attempted to use superuser-only \
767 procedure!\n", inet_ntoa(rqhost->sin_addr), rqhost->sin_port);
768 svcerr_auth(transp, AUTH_BADCRED);
772 if (rqstp->rq_cred.oa_flavor != AUTH_SYS) {
773 yp_error("caller didn't send proper credentials");
774 svcerr_auth(transp, AUTH_BADCRED);
778 if (__rpc_get_local_uid(transp, &uid) < 0) {
779 yp_error("caller didn't send proper credentials");
780 svcerr_auth(transp, AUTH_BADCRED);
785 yp_error("caller euid is %d, expecting 0 -- rejecting request",
787 svcerr_auth(rqstp->rq_xprt, AUTH_BADCRED);
791 passfile = passfile_default;
793 key.data = argp->newpw.pw_name;
794 key.size = strlen(argp->newpw.pw_name);
797 * The superuser may add entries to the passwd maps if
798 * rpc.yppasswdd is started with the -a flag. Paranoia
799 * prevents me from allowing additions by default.
801 if ((rval = yp_get_record(argp->domain, "master.passwd.byname",
802 &key, &data, 0)) != YP_TRUE) {
803 if (rval == YP_NOKEY) {
804 yp_error("user %s not found in passwd database",
805 argp->newpw.pw_name);
807 yp_error("notice: adding user %s to \
808 master.passwd database for domain %s", argp->newpw.pw_name, argp->domain);
810 yp_error("restart rpc.yppasswdd with the -a flag to \
811 allow additions to be made to the password database");
813 yp_error("database access error: %s",
816 if (!allow_additions)
820 /* Nul terminate, please. */
821 *((char *)data.data + data.size) = '\0';
823 copy_yp_pass(data.data, 1, data.size);
827 * Perform a small bit of sanity checking.
829 if (validate_master(rval == YP_TRUE ? &yp_password:NULL,&argp->newpw)){
830 yp_error("rejecting update attempt for %s: bad arguments",
831 argp->newpw.pw_name);
836 * If the caller specified a domain other than our 'default'
837 * domain, change the path to master.passwd accordingly.
840 if (strcmp(argp->domain, yppasswd_domain)) {
841 snprintf(passfile_buf, sizeof(passfile_buf),
842 "%s/%s/master.passwd", yp_dir, argp->domain);
843 passfile = (char *)&passfile_buf;
847 * Create a filename to hold the original master.passwd
848 * so if our call to yppwupdate fails we can roll back
850 snprintf(passfile_hold_buf, sizeof(passfile_hold_buf),
851 "%s.hold", passfile);
852 passfile_hold = (char *)&passfile_hold_buf;
854 snprintf(passdir_buf, sizeof(passdir_buf), "%s", passfile);
855 passdir = dirname(passdir_buf);
857 if (pw_init(passdir, passfile)) {
858 yp_error("pw_init() failed");
861 if ((pfd = pw_lock()) == -1) {
863 yp_error("pw_lock() failed");
866 if ((tfd = pw_tmp(-1)) == -1) {
868 yp_error("pw_tmp() failed");
871 xlate_passwd(&argp->newpw, &newpasswd);
872 if (pw_copy(pfd, tfd, &newpasswd, NULL) == -1) {
874 yp_error("pw_copy() failed");
877 if (rename(passfile, passfile_hold) == -1) {
879 yp_error("rename of %s to %s failed", passfile,
883 if (strcmp(passfile, _PATH_MASTERPASSWD) == 0) {
885 * NIS server is exporting the system's master.passwd.
886 * Call pw_mkdb to rebuild passwd and the .db files
888 if (pw_mkdb(argp->newpw.pw_name) == -1) {
890 yp_error("pw_mkdb() failed");
891 rename(passfile_hold, passfile);
896 * NIS server is exporting a private master.passwd.
897 * Rename tempfile into final location
899 if (rename(pw_tempname(), passfile) == -1) {
901 yp_error("rename of %s to %s failed",
902 pw_tempname(), passfile);
903 rename(passfile_hold, passfile);
910 xlate_passwd(&argp->newpw, &newpasswd);
911 if ((rval = update_inplace(&newpasswd, argp->domain))) {
912 yp_error("inplace update failed -- rebuilding maps");
916 switch ((pid = fork())) {
918 if (inplace && !rval) {
919 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
920 argp->domain, "pushpw", (char *)NULL);
922 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
923 argp->domain, (char *)NULL);
925 yp_error("couldn't exec map update process: %s",
928 rename(passfile_hold, passfile);
932 yp_error("fork() failed: %s", strerror(errno));
934 rename(passfile_hold, passfile);
938 unlink(passfile_hold);
942 yp_error("performed update of user %s (uid %d) domain %s",