pw_nis.c (302408) | pw_nis.c (308815) |
---|---|
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: stable/11/usr.sbin/pw/pw_nis.c 286201 2015-08-02 13:22:46Z bapt $"; | 29 "$FreeBSD: stable/11/usr.sbin/pw/pw_nis.c 308815 2016-11-18 22:28:57Z asomers $"; |
30#endif /* not lint */ 31 32#include <sys/types.h> 33 34#include <err.h> 35#include <pwd.h> 36#include <libutil.h> | 30#endif /* not lint */ 31 32#include <sys/types.h> 33 34#include <err.h> 35#include <pwd.h> 36#include <libutil.h> |
37#include <unistd.h> |
|
37 38#include "pw.h" 39 40static int 41pw_nisupdate(const char * path, struct passwd * pwd, char const * user) 42{ 43 int pfd, tfd; 44 struct passwd *pw = NULL; --- 13 unchanged lines hidden (view full) --- 58 err(1, "pw_lock()"); 59 } 60 if ((tfd = pw_tmp(-1)) == -1) { 61 pw_fini(); 62 err(1, "pw_tmp()"); 63 } 64 if (pw_copy(pfd, tfd, pw, old_pw) == -1) { 65 pw_fini(); | 38 39#include "pw.h" 40 41static int 42pw_nisupdate(const char * path, struct passwd * pwd, char const * user) 43{ 44 int pfd, tfd; 45 struct passwd *pw = NULL; --- 13 unchanged lines hidden (view full) --- 59 err(1, "pw_lock()"); 60 } 61 if ((tfd = pw_tmp(-1)) == -1) { 62 pw_fini(); 63 err(1, "pw_tmp()"); 64 } 65 if (pw_copy(pfd, tfd, pw, old_pw) == -1) { 66 pw_fini(); |
67 close(tfd); |
|
66 err(1, "pw_copy()"); 67 } | 68 err(1, "pw_copy()"); 69 } |
70 close(tfd); |
|
68 if (chmod(pw_tempname(), 0644) == -1) 69 err(1, "chmod()"); 70 if (rename(pw_tempname(), path) == -1) 71 err(1, "rename()"); 72 73 free(pw); 74 pw_fini(); 75 --- 20 unchanged lines hidden --- | 71 if (chmod(pw_tempname(), 0644) == -1) 72 err(1, "chmod()"); 73 if (rename(pw_tempname(), path) == -1) 74 err(1, "rename()"); 75 76 free(pw); 77 pw_fini(); 78 --- 20 unchanged lines hidden --- |