From: Lennart Poettering Date: Wed, 9 May 2007 12:19:11 +0000 (+0000) Subject: Reset umask before writing files to /var/lib/avahi-autoipd. Fix for ubuntu bug 83521 X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=747f75372063371865bf5fc9857982defcffdca4;p=catta Reset umask before writing files to /var/lib/avahi-autoipd. Fix for ubuntu bug 83521 git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1468 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-autoipd/main.c b/avahi-autoipd/main.c index 26a516a..446b8b7 100644 --- a/avahi-autoipd/main.c +++ b/avahi-autoipd/main.c @@ -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; }