Deleted Added
full compact
yppasswdd_server.c (90253) yppasswdd_server.c (90297)
1/*
2 * Copyright (c) 1995, 1996
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef lint
34static const char rcsid[] =
1/*
2 * Copyright (c) 1995, 1996
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#ifndef lint
34static const char rcsid[] =
35 "$FreeBSD: head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c 90253 2002-02-05 18:51:13Z alfred $";
35 "$FreeBSD: head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c 90297 2002-02-06 13:30:31Z des $";
36#endif /* not lint */
37
38#include <stdio.h>
39#include <string.h>
40#include <ctype.h>
41#include <stdlib.h>
42#include <unistd.h>
43#include <dirent.h>

--- 27 unchanged lines hidden (view full) ---

71 extern int pstat;
72 int st;
73 int saved_errno;
74
75 saved_errno = errno;
76
77 if (sig > 0) {
78 if (sig == SIGCHLD)
36#endif /* not lint */
37
38#include <stdio.h>
39#include <string.h>
40#include <ctype.h>
41#include <stdlib.h>
42#include <unistd.h>
43#include <dirent.h>

--- 27 unchanged lines hidden (view full) ---

71 extern int pstat;
72 int st;
73 int saved_errno;
74
75 saved_errno = errno;
76
77 if (sig > 0) {
78 if (sig == SIGCHLD)
79 while(wait3(&st, WNOHANG, NULL) > 0) ;
79 while (wait3(&st, WNOHANG, NULL) > 0) ;
80 } else {
81 pid = waitpid(pid, &pstat, 0);
82 }
83
84 errno = saved_errno;
85 return;
86}
87

--- 445 unchanged lines hidden (view full) ---

533 } else
534 yp_error("updating user %s in domain %s",
535 argp->newpw.pw_name, domain);
536 }
537
538 key.data = argp->newpw.pw_name;
539 key.size = strlen(argp->newpw.pw_name);
540
80 } else {
81 pid = waitpid(pid, &pstat, 0);
82 }
83
84 errno = saved_errno;
85 return;
86}
87

--- 445 unchanged lines hidden (view full) ---

533 } else
534 yp_error("updating user %s in domain %s",
535 argp->newpw.pw_name, domain);
536 }
537
538 key.data = argp->newpw.pw_name;
539 key.size = strlen(argp->newpw.pw_name);
540
541 if ((rval=yp_get_record(domain,"master.passwd.byname",
541 if ((rval = yp_get_record(domain,"master.passwd.byname",
542 &key, &data, 0)) != YP_TRUE) {
543 if (rval == YP_NOKEY) {
544 yp_error("user %s not found in passwd database",
545 argp->newpw.pw_name);
546 } else {
547 yp_error("database access error: %s",
548 yperr_string(rval));
549 }

--- 87 unchanged lines hidden (view full) ---

637 }
638
639 if (inplace) {
640 if ((rval = update_inplace(&yp_password, domain))) {
641 yp_error("inplace update failed -- rebuilding maps");
642 }
643 }
644
542 &key, &data, 0)) != YP_TRUE) {
543 if (rval == YP_NOKEY) {
544 yp_error("user %s not found in passwd database",
545 argp->newpw.pw_name);
546 } else {
547 yp_error("database access error: %s",
548 yperr_string(rval));
549 }

--- 87 unchanged lines hidden (view full) ---

637 }
638
639 if (inplace) {
640 if ((rval = update_inplace(&yp_password, domain))) {
641 yp_error("inplace update failed -- rebuilding maps");
642 }
643 }
644
645 switch((pid = fork())) {
645 switch ((pid = fork())) {
646 case 0:
647 if (inplace && !rval) {
648 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
649 yppasswd_domain, "pushpw", (char *)NULL);
650 } else {
651 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
652 yppasswd_domain, (char *)NULL);
653 }

--- 74 unchanged lines hidden (view full) ---

728 return(&result);
729 }
730
731 if (__rpc_get_local_uid(transp, &uid) < 0) {
732 yp_error("caller didn't send proper credentials");
733 svcerr_auth(transp, AUTH_BADCRED);
734 return(&result);
735 }
646 case 0:
647 if (inplace && !rval) {
648 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
649 yppasswd_domain, "pushpw", (char *)NULL);
650 } else {
651 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
652 yppasswd_domain, (char *)NULL);
653 }

--- 74 unchanged lines hidden (view full) ---

728 return(&result);
729 }
730
731 if (__rpc_get_local_uid(transp, &uid) < 0) {
732 yp_error("caller didn't send proper credentials");
733 svcerr_auth(transp, AUTH_BADCRED);
734 return(&result);
735 }
736
736
737 if (uid) {
738 yp_error("caller euid is %d, expecting 0 -- rejecting request",
739 uid);
740 svcerr_auth(rqstp->rq_xprt, AUTH_BADCRED);
741 return(&result);
742 }
743
744 passfile = passfile_default;

--- 44 unchanged lines hidden (view full) ---

789 * If the caller specified a domain other than our 'default'
790 * domain, change the path to master.passwd accordingly.
791 */
792
793 if (strcmp(argp->domain, yppasswd_domain)) {
794 snprintf(passfile_buf, sizeof(passfile_buf),
795 "%s/%s/master.passwd", yp_dir, argp->domain);
796 passfile = (char *)&passfile_buf;
737 if (uid) {
738 yp_error("caller euid is %d, expecting 0 -- rejecting request",
739 uid);
740 svcerr_auth(rqstp->rq_xprt, AUTH_BADCRED);
741 return(&result);
742 }
743
744 passfile = passfile_default;

--- 44 unchanged lines hidden (view full) ---

789 * If the caller specified a domain other than our 'default'
790 * domain, change the path to master.passwd accordingly.
791 */
792
793 if (strcmp(argp->domain, yppasswd_domain)) {
794 snprintf(passfile_buf, sizeof(passfile_buf),
795 "%s/%s/master.passwd", yp_dir, argp->domain);
796 passfile = (char *)&passfile_buf;
797 }
797 }
798
799 if ((pfd = pw_lock()) < 0) {
800 return (&result);
801 }
802 if ((tfd = pw_tmp()) < 0) {
803 return (&result);
804 }
805

--- 17 unchanged lines hidden (view full) ---

823
824 if (inplace) {
825 if ((rval = update_inplace((struct passwd *)&argp->newpw,
826 argp->domain))) {
827 yp_error("inplace update failed -- rebuilding maps");
828 }
829 }
830
798
799 if ((pfd = pw_lock()) < 0) {
800 return (&result);
801 }
802 if ((tfd = pw_tmp()) < 0) {
803 return (&result);
804 }
805

--- 17 unchanged lines hidden (view full) ---

823
824 if (inplace) {
825 if ((rval = update_inplace((struct passwd *)&argp->newpw,
826 argp->domain))) {
827 yp_error("inplace update failed -- rebuilding maps");
828 }
829 }
830
831 switch((pid = fork())) {
831 switch ((pid = fork())) {
832 case 0:
833 if (inplace && !rval) {
834 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
835 argp->domain, "pushpw", (char *)NULL);
836 } else {
837 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
838 argp->domain, (char *)NULL);
839 }

--- 25 unchanged lines hidden ---
832 case 0:
833 if (inplace && !rval) {
834 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
835 argp->domain, "pushpw", (char *)NULL);
836 } else {
837 execlp(MAP_UPDATE_PATH, MAP_UPDATE, passfile,
838 argp->domain, (char *)NULL);
839 }

--- 25 unchanged lines hidden ---