Diff for /embedaddon/dnsmasq/src/log.c between versions 1.1.1.4 and 1.1.1.5

version 1.1.1.4, 2021/03/17 00:56:46 version 1.1.1.5, 2023/09/27 11:02:07
Line 1 Line 1
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley/* dnsmasq is Copyright (c) 2000-2022 Simon Kelley
   
    This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
Line 100  int log_start(struct passwd *ent_pw, int errfd) Line 100  int log_start(struct passwd *ent_pw, int errfd)
   /* If we're running as root and going to change uid later,    /* If we're running as root and going to change uid later,
      change the ownership here so that the file is always owned by       change the ownership here so that the file is always owned by
      the dnsmasq user. Then logrotate can just copy the owner.       the dnsmasq user. Then logrotate can just copy the owner.
     Failure of the chown call is OK, (for instance when started as non-root) */     Failure of the chown call is OK, (for instance when started as non-root).
  if (log_to_file && !log_stderr && ent_pw && ent_pw->pw_uid != 0 &&      
      fchown(log_fd, ent_pw->pw_uid, -1) != 0)     If we've created a file with group-id root, we also make
    ret = errno;     the file group-writable. This gives processes in the root group
      write access to the file and avoids the problem that on some systems,
      once the file is owned by the dnsmasq user, it can't be written
      whilst dnsmasq is running as root during startup.
  */
   if (log_to_file && !log_stderr && ent_pw && ent_pw->pw_uid != 0)
     {
       struct stat ls;
       if (getgid() == 0 && fstat(log_fd, &ls) == 0 && ls.st_gid == 0 &&
           (ls.st_mode & S_IWGRP) == 0)
         (void)fchmod(log_fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
       if (fchown(log_fd, ent_pw->pw_uid, -1) != 0)
         ret = errno;
     }
   
   return ret;    return ret;
 }  }
Line 118  int log_reopen(char *log_file) Line 131  int log_reopen(char *log_file)
       /* NOTE: umask is set to 022 by the time this gets called */        /* NOTE: umask is set to 022 by the time this gets called */
               
       if (log_file)        if (log_file)
        log_fd = open(log_file, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);              log_fd = open(log_file, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP);
       else        else
         {          {
 #if defined(HAVE_SOLARIS_NETWORK) || defined(__ANDROID__)  #if defined(HAVE_SOLARIS_NETWORK) || defined(__ANDROID__)
Line 273  static void log_write(void) Line 286  static void log_write(void)
 /* priority is one of LOG_DEBUG, LOG_INFO, LOG_NOTICE, etc. See sys/syslog.h.  /* priority is one of LOG_DEBUG, LOG_INFO, LOG_NOTICE, etc. See sys/syslog.h.
    OR'd to priority can be MS_TFTP, MS_DHCP, ... to be able to do log separation between     OR'd to priority can be MS_TFTP, MS_DHCP, ... to be able to do log separation between
    DNS, DHCP and TFTP services.     DNS, DHCP and TFTP services.
*/   If OR'd with MS_DEBUG, the messages are suppressed unless --log-debug is set. */
 void my_syslog(int priority, const char *format, ...)  void my_syslog(int priority, const char *format, ...)
 {  {
   va_list ap;    va_list ap;
Line 290  void my_syslog(int priority, const char *format, ...) Line 303  void my_syslog(int priority, const char *format, ...)
     func = "-dhcp";      func = "-dhcp";
   else if ((LOG_FACMASK & priority) == MS_SCRIPT)    else if ((LOG_FACMASK & priority) == MS_SCRIPT)
     func = "-script";      func = "-script";
              else if ((LOG_FACMASK & priority) == MS_DEBUG)
     {
       if (!option_bool(OPT_LOG_DEBUG))
         return;
       func = "-debug";
     }
   
 #ifdef LOG_PRI  #ifdef LOG_PRI
   priority = LOG_PRI(priority);    priority = LOG_PRI(priority);
 #else  #else

Removed from v.1.1.1.4  
changed lines
  Added in v.1.1.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>