]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/pw_nis.c
Remove some code that's no longer needed because it's now part of pw_scan(3).
[pw-darwin.git] / pw / pw_nis.c
index c786cc7ba4dcf637506448c1d0b64815395ee9eb..4b70bc1de1f67995c566ada1b0f6d5501295a1f8 100644 (file)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 1996
  *     David L. Nugent.  All rights reserved.
  *
@@ -30,9 +32,11 @@ static const char rcsid[] =
 #endif /* not lint */
 
 #include <sys/types.h>
+
 #include <err.h>
 #include <pwd.h>
 #include <libutil.h>
+#include <unistd.h>
 
 #include "pw.h"
 
@@ -43,6 +47,7 @@ pw_nisupdate(const char * path, struct passwd * pwd, char const * user)
        struct passwd *pw = NULL;
        struct passwd *old_pw = NULL;
 
+       printf("===> %s\n", path);
        if (pwd != NULL)
                pw = pw_dup(pwd);
 
@@ -61,8 +66,11 @@ pw_nisupdate(const char * path, struct passwd * pwd, char const * user)
        }
        if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
                pw_fini();
+               close(tfd);
                err(1, "pw_copy()");
        }
+       fsync(tfd);
+       close(tfd);
        if (chmod(pw_tempname(), 0644) == -1)
                err(1, "chmod()");
        if (rename(pw_tempname(), path) == -1)