]> git.meshlink.io Git - catta/commitdiff
Reset umask before writing files to /var/lib/avahi-autoipd. Fix for ubuntu bug 83521
authorLennart Poettering <lennart@poettering.net>
Wed, 9 May 2007 12:19:11 +0000 (12:19 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 May 2007 12:19:11 +0000 (12:19 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1468 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-autoipd/main.c

index 26a516ae98ae4c79c748013a245a4a589a781b85..446b8b7ac88cf955e252c1223c6651ab2b7e11c3 100644 (file)
@@ -248,13 +248,16 @@ fail:
 static int save_address(const char *fn, uint32_t addr) {
     FILE *f;
     char buf[32];
+    mode_t u;
 
     assert(fn);
-    
+
+    u = umask(0033);
     if (!(f = fopen(fn, "w"))) {
         daemon_log(LOG_ERR, "fopen() failed: %s", strerror(errno));
         goto fail;
     }
+    umask(u);
 
     fprintf(f, "%s\n", inet_ntop(AF_INET, &addr, buf, sizeof (buf)));
     fclose(f);
@@ -265,6 +268,8 @@ fail:
     if (f)
         fclose(f);
 
+    umask(u);
+    
     return -1;
 }
 
@@ -767,7 +772,6 @@ int is_ll_address(uint32_t addr) {
         ((ntohl(addr) & 0x0000FF00) != 0xFF00);
 }
 
-
 static struct timeval *elapse_time(struct timeval *tv, unsigned msec, unsigned jitter) {
     assert(tv);
 
@@ -1028,7 +1032,7 @@ static int drop_privs(void) {
         
         daemon_log(LOG_INFO, "Successfully dropped root privileges.");
     }
-    
+
     return 0;
 }