]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Fix last commit to not crash if uid changing not configured.
authorSimon Kelley <simon@thekelleys.org.uk>
Mon, 2 Mar 2015 22:47:23 +0000 (22:47 +0000)
committerSimon Kelley <simon@thekelleys.org.uk>
Mon, 2 Mar 2015 22:47:23 +0000 (22:47 +0000)
src/dnsmasq.c
src/dnsmasq.h
src/dnssec.c

index 769a19afe6c5b5ba6db293ffeb63314ecc83deab..9e05c0e31569b6320f2e1e3a5668639b078f8423 100644 (file)
@@ -374,7 +374,7 @@ int main (int argc, char **argv)
     die(_("unknown user or group: %s"), baduser, EC_BADCONF);
 
 #ifdef HAVE_DNSSEC  
-  badtime = setup_timestamp(ent_pw->pw_uid);
+  badtime = setup_timestamp(ent_pw);
 #endif
 
   /* implement group defaults, "dip" if available, or group associated with uid */
index b2f02dda63f00e6cf4ea0218f74c12d127f3c3e8..a451cb4dd03c394e1d1e80df2894f4fabba861d6 100644 (file)
@@ -1152,7 +1152,7 @@ int dnssec_chase_cname(time_t now, struct dns_header *header, size_t plen, char
 int dnskey_keytag(int alg, int flags, unsigned char *rdata, int rdlen);
 size_t filter_rrsigs(struct dns_header *header, size_t plen);
 unsigned char* hash_questions(struct dns_header *header, size_t plen, char *name);
-int setup_timestamp(uid_t uid);
+int setup_timestamp(struct passwd *ent_pw);
 
 /* util.c */
 void rand_init(void);
index bf4406469de05a8f98a3360532870be28b40f5d5..c60eacf73c6bc8d0729e416c13e3233bb11b4ccc 100644 (file)
@@ -402,7 +402,7 @@ static int serial_compare_32(unsigned long s1, unsigned long s2)
 static time_t timestamp_time;
 static int back_to_the_future;
 
-int setup_timestamp(uid_t uid)
+int setup_timestamp(struct passwd *ent_pw)
 {
   struct stat statbuf;
   
@@ -437,7 +437,7 @@ int setup_timestamp(uid_t uid)
          
          timestamp_time = timbuf.actime = timbuf.modtime = 1420070400; /* 1-1-2015 */
          if (utime(daemon->timestamp_file, &timbuf) == 0 &&
-             (getuid() != 0 || chown(daemon->timestamp_file, uid, -1) == 0))
+             (!ent_pw || getuid() != 0 || chown(daemon->timestamp_file, ent_pw->pw_uid, -1) == 0))
            goto check_and_exit;
        }
     }