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

Diff for /src/usr.bin/htpasswd/htpasswd.c between version 1.1 and 1.2

version 1.1, 2014/03/17 12:49:13 version 1.2, 2014/03/17 12:51:58
Line 45 
Line 45 
         FILE *in, *out;          FILE *in, *out;
         size_t linesize;          size_t linesize;
         ssize_t linelen;          ssize_t linelen;
           mode_t old_umask;
         int fd, loginlen;          int fd, loginlen;
         char hash[_PASSWORD_LEN], *file, *line, *login, pass[1024], pass2[1024];          char hash[_PASSWORD_LEN], *file, *line, *login, pass[1024], pass2[1024];
         char salt[_PASSWORD_LEN], tmpl[sizeof("/tmp/htpasswd-XXXXXXXXXX")];          char salt[_PASSWORD_LEN], tmpl[sizeof("/tmp/htpasswd-XXXXXXXXXX")];
Line 97 
Line 98 
         else {          else {
                 if ((in = fopen(file, "r+")) == NULL) {                  if ((in = fopen(file, "r+")) == NULL) {
                         if (errno == ENOENT) {                          if (errno == ENOENT) {
                                   old_umask = umask(S_IXUSR|
                                       S_IWGRP|S_IRGRP|S_IXGRP|
                                       S_IWOTH|S_IROTH|S_IXOTH);
                                 if ((out = fopen(file, "w")) == NULL)                                  if ((out = fopen(file, "w")) == NULL)
                                         err(1, "cannot open password file for"                                          err(1, "cannot open password file for"
                                             " reading or writing");                                              " reading or writing");
                                 if (fchmod(fileno(out), S_IRUSR | S_IWUSR)                                  umask(old_umask);
                                     == -1)  
                                         err(1, "cannot chmod new password"  
                                             " file");  
                         } else                          } else
                                 err(1, "cannot open password file for reading");                                  err(1, "cannot open password file for reading");
                 }                  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2