-#ifdef HAVE_PWDB_C
- rc = pwdb("-C", (char *)NULL); /* Check only */
- if (rc == 0) {
-#else
- { /* No -C */
-#endif
- int pfd, tfd;
- struct passwd *pw = NULL;
- struct passwd *old_pw = NULL;
-
- if (pwd != NULL)
- pw = pw_dup(pwd);
-
- if (user != NULL)
- old_pw = GETPWNAM(user);
-
- if (pw_init(pwpath, NULL))
- err(1, "pw_init()");
- if ((pfd = pw_lock()) == -1) {
- pw_fini();
- err(1, "pw_lock()");
- }
- if ((tfd = pw_tmp(-1)) == -1) {
- pw_fini();
- err(1, "pw_tmp()");
- }
- if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
- pw_fini();
- err(1, "pw_copy()");
- }
- if (pw_mkdb(user) == -1) {
- pw_fini();
- err(1, "pw_mkdb()");
- }
- free(pw);