[BACK]Return to chpass.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / chpass

Diff for /src/usr.bin/chpass/chpass.c between version 1.29 and 1.30

version 1.29, 2003/11/26 00:33:58 version 1.30, 2004/04/20 23:21:23
Line 80 
Line 80 
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         struct passwd *pw = NULL, lpw;          struct passwd *pw = NULL, *opw, lpw;
         int i, ch, pfd, tfd, dfd;          int i, ch, pfd, tfd, dfd;
         char *arg = NULL;          char *arg = NULL;
         sigset_t fullset;          sigset_t fullset;
Line 170 
Line 170 
                 if (!pw_scan(arg, pw, NULL))                  if (!pw_scan(arg, pw, NULL))
                         exit(1);                          exit(1);
         }          }
           if ((opw = pw_dup(pw)) == NULL)
                   err(1, NULL);
   
         /* Edit the user passwd information if requested. */          /* Edit the user passwd information if requested. */
         if (op == EDITENTRY) {          if (op == EDITENTRY) {
                 char tempname[] = _PATH_VARTMP "pw.XXXXXXXXXX";                  char tempname[] = _PATH_VARTMP "pw.XXXXXXXXXX";
                 int edit_status;                  int edit_status;
   
                   if ((pw = pw_dup(pw)) == NULL)
                           pw_error(NULL, 1, 1);
                 dfd = mkstemp(tempname);                  dfd = mkstemp(tempname);
                 if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1)                  if (dfd == -1 || fcntl(dfd, F_SETFD, 1) == -1)
                         pw_error(tempname, 1, 1);                          pw_error(tempname, 1, 1);
Line 233 
Line 237 
 #endif  /* YP */  #endif  /* YP */
         {          {
                 /* Copy the passwd file to the lock file, updating pw. */                  /* Copy the passwd file to the lock file, updating pw. */
                 pw_copy(pfd, tfd, pw);                  pw_copy(pfd, tfd, pw, opw);
   
                   /* If username changed we need to rebuild the entire db. */
                   arg = !strcmp(opw->pw_name, pw->pw_name) ? pw->pw_name : NULL;
   
                 /* Now finish the passwd file update. */                  /* Now finish the passwd file update. */
                 if (pw_mkdb(pw->pw_name, 0) == -1)                  if (pw_mkdb(arg, 0) == -1)
                         pw_error(NULL, 0, 1);                          pw_error(NULL, 0, 1);
         }          }
   

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30