pwupd.c (50653) | pwupd.c (52502) |
---|---|
1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. 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 --- 12 unchanged lines hidden (view full) --- 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 24 * SUCH DAMAGE. 25 */ 26 27#ifndef lint 28static const char rcsid[] = | 1/*- 2 * Copyright (C) 1996 3 * David L. Nugent. 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 --- 12 unchanged lines hidden (view full) --- 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 24 * SUCH DAMAGE. 25 */ 26 27#ifndef lint 28static const char rcsid[] = |
29 "$FreeBSD: head/usr.sbin/pw/pwupd.c 50653 1999-08-30 10:35:38Z sheldonh $"; | 29 "$FreeBSD: head/usr.sbin/pw/pwupd.c 52502 1999-10-26 04:27:14Z davidn $"; |
30#endif /* not lint */ 31 32#include <stdio.h> 33#include <stdlib.h> 34#include <string.h> 35#include <unistd.h> 36#include <stdarg.h> 37#include <errno.h> --- 49 unchanged lines hidden (view full) --- 87 if (pwpath != pathpwd) { 88 args[i++] = "-d"; 89 args[i++] = pwpath; 90 } 91 args[i++] = getpwpath(_MASTERPASSWD); 92 args[i] = NULL; 93 94 if ((pid = fork()) == -1) /* Error (errno set) */ | 30#endif /* not lint */ 31 32#include <stdio.h> 33#include <stdlib.h> 34#include <string.h> 35#include <unistd.h> 36#include <stdarg.h> 37#include <errno.h> --- 49 unchanged lines hidden (view full) --- 87 if (pwpath != pathpwd) { 88 args[i++] = "-d"; 89 args[i++] = pwpath; 90 } 91 args[i++] = getpwpath(_MASTERPASSWD); 92 args[i] = NULL; 93 94 if ((pid = fork()) == -1) /* Error (errno set) */ |
95 i = -1; | 95 i = errno; |
96 else if (pid == 0) { /* Child */ 97 execv(args[0], args); 98 _exit(1); 99 } else { /* Parent */ 100 waitpid(pid, &i, 0); | 96 else if (pid == 0) { /* Child */ 97 execv(args[0], args); 98 _exit(1); 99 } else { /* Parent */ 100 waitpid(pid, &i, 0); |
101 if ((i = WEXITSTATUS(i)) != 0) 102 errno = EIO; /* set SOMETHING */ | 101 if (WEXITSTATUS(i)) 102 i = EIO; |
103 } 104 return i; 105} 106 107int 108fmtpwentry(char *buf, struct passwd * pwd, int type) 109{ 110 int l; --- 45 unchanged lines hidden (view full) --- 156 157 /* 158 * Update the passwd file first 159 */ 160 if (pwd == NULL) 161 *pwbuf = '\0'; 162 else 163 fmtpwentry(pwbuf, pwd, PWF_PASSWD); | 103 } 104 return i; 105} 106 107int 108fmtpwentry(char *buf, struct passwd * pwd, int type) 109{ 110 int l; --- 45 unchanged lines hidden (view full) --- 156 157 /* 158 * Update the passwd file first 159 */ 160 if (pwd == NULL) 161 *pwbuf = '\0'; 162 else 163 fmtpwentry(pwbuf, pwd, PWF_PASSWD); |
164 if ((rc = fileupdate(getpwpath(_PASSWD), 0644, pwbuf, pfx, l, mode)) != 0) { | |
165 | 164 |
165 rc = fileupdate(getpwpath(_PASSWD), 0644, pwbuf, pfx, l, mode); 166 if (rc == 0) { 167 |
|
166 /* 167 * Then the master.passwd file 168 */ 169 if (pwd != NULL) 170 fmtpwentry(pwbuf, pwd, PWF_MASTER); | 168 /* 169 * Then the master.passwd file 170 */ 171 if (pwd != NULL) 172 fmtpwentry(pwbuf, pwd, PWF_MASTER); |
171 if ((rc = fileupdate(getpwpath(_MASTERPASSWD), 0644, pwbuf, pfx, l, mode)) != 0) { | 173 rc = fileupdate(getpwpath(_MASTERPASSWD), 0644, pwbuf, pfx, l, mode); 174 if (rc != 0) { |
172 if (mode == UPD_DELETE) | 175 if (mode == UPD_DELETE) |
173 rc = pwdb(NULL) == 0; | 176 rc = pwdb(NULL); |
174 else | 177 else |
175 rc = pwdb("-u", user, NULL) == 0; | 178 rc = pwdb("-u", user, NULL); |
176 } 177 } 178 } 179 return rc; 180} 181 182int 183addpwent(struct passwd * pwd) --- 15 unchanged lines hidden --- | 179 } 180 } 181 } 182 return rc; 183} 184 185int 186addpwent(struct passwd * pwd) --- 15 unchanged lines hidden --- |