summaryrefslogtreecommitdiffstats
path: root/avahi-autoipd/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-05-09 12:19:11 +0000
committerLennart Poettering <lennart@poettering.net>2007-05-09 12:19:11 +0000
commit747f75372063371865bf5fc9857982defcffdca4 (patch)
treebf07bd5e2006f9d5dbec3987186d0e5a247c7a5f /avahi-autoipd/main.c
parentf6208e2b347866df4b9a411e15eb0329afb07655 (diff)
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
Diffstat (limited to 'avahi-autoipd/main.c')
-rw-r--r--avahi-autoipd/main.c10
1 files changed, 7 insertions, 3 deletions
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;
}