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

Diff for /src/usr.bin/newsyslog/newsyslog.c between version 1.108 and 1.109

version 1.108, 2017/07/24 12:57:01 version 1.109, 2018/09/16 02:44:06
Line 191 
Line 191 
         TAILQ_INIT(&config);          TAILQ_INIT(&config);
         TAILQ_INIT(&runlist);          TAILQ_INIT(&runlist);
   
           /* Keep passwd and group files open for faster lookups. */
           setpassent(1);
           setgroupent(1);
   
         ret = parse_file(&config, &listlen);          ret = parse_file(&config, &listlen);
         if (argc == 0)          if (argc == 0)
                 TAILQ_CONCAT(&runlist, &config, next);                  TAILQ_CONCAT(&runlist, &config, next);
Line 468 
Line 472 
 {  {
         char line[BUFSIZ], *parse, *q, *errline, *group, *tmp, *ep;          char line[BUFSIZ], *parse, *q, *errline, *group, *tmp, *ep;
         struct conf_entry *working;          struct conf_entry *working;
         struct passwd *pwd;  
         struct group *grp;  
         struct stat sb;          struct stat sb;
         int lineno = 0;          int lineno = 0;
         int ret = 0;          int ret = 0;
Line 510 
Line 512 
                 if ((group = strchr(q, ':')) != NULL ||                  if ((group = strchr(q, ':')) != NULL ||
                     (group = strrchr(q, '.')) != NULL)  {                      (group = strrchr(q, '.')) != NULL)  {
                         *group++ = '\0';                          *group++ = '\0';
                         if (*q) {                          if (*q == '\0') {
                                 if (!(isnumberstr(q))) {  
                                         if ((pwd = getpwnam(q)) == NULL) {  
                                                 warnx("%s:%d: unknown user"  
                                                     " %s --> skipping",  
                                                     conf, lineno, q);  
                                                 ret = 1;  
                                                 goto nextline;  
                                         }  
                                         working->uid = pwd->pw_uid;  
                                 } else  
                                         working->uid = atoi(q);  
                         } else  
                                 working->uid = (uid_t)-1;                                  working->uid = (uid_t)-1;
                           } else if (isnumberstr(q)) {
                                   working->uid = atoi(q);
                           } else if (uid_from_user(q, &working->uid) == -1) {
                                   warnx("%s:%d: unknown user %s --> skipping",
                                       conf, lineno, q);
                                   ret = 1;
                                   goto nextline;
                           }
   
                         q = group;                          q = group;
                         if (*q) {                          if (*q == '\0') {
                                 if (!(isnumberstr(q))) {  
                                         if ((grp = getgrnam(q)) == NULL) {  
                                                 warnx("%s:%d: unknown group"  
                                                     " %s --> skipping",  
                                                     conf, lineno, q);  
                                                 ret = 1;  
                                                 goto nextline;  
                                         }  
                                         working->gid = grp->gr_gid;  
                                 } else  
                                         working->gid = atoi(q);  
                         } else  
                                 working->gid = (gid_t)-1;                                  working->gid = (gid_t)-1;
                           } else if (isnumberstr(q)) {
                                   working->gid = atoi(q);
                           } else if (gid_from_group(q, &working->gid) == -1) {
                                   warnx("%s:%d: unknown group %s --> skipping",
                                       conf, lineno, q);
                                   ret = 1;
                                   goto nextline;
                           }
   
                         q = parse = missing_field(sob(++parse), errline, lineno);                          q = parse = missing_field(sob(++parse), errline, lineno);
                         *(parse = son(parse)) = '\0';                          *(parse = son(parse)) = '\0';

Legend:
Removed from v.1.108  
changed lines
  Added in v.1.109