aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mds.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mds.c b/src/mds.c
index 9405139..16d6275 100644
--- a/src/mds.c
+++ b/src/mds.c
@@ -204,6 +204,11 @@ int main(int argc_, char** argv_)
}
fflush(f);
fclose(f);
+ if (chmod(pathname, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0)
+ {
+ perror(*argv);
+ eprintf("while setting permissions for PID file: %s", pathname);
+ }
/* Create data storage directory. */
if (create_directory_root(MDS_STORAGE_ROOT_DIRECTORY))
@@ -223,11 +228,10 @@ int main(int argc_, char** argv_)
strcpy(address.sun_path, pathname);
unlink(pathname);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if ((fchmod(fd, S_IRWXU) < 0) ||
- (fchown(fd, getuid(), NOBODY_GROUP_GID) < 0))
+ if (fchmod(fd, S_IRWXU) < 0)
{
perror(*argv);
- eprint("while making anonymous socket private to the real user.");
+ eprint("while making anonymous socket private to its owner.");
goto fail;
}
if (bind(fd, (struct sockaddr*)(&address), sizeof(address)) < 0)
@@ -236,6 +240,12 @@ int main(int argc_, char** argv_)
eprintf("while binding socket to file: %s", pathname);
goto fail;
}
+ if (chown(pathname, getuid(), NOBODY_GROUP_GID) < 0)
+ {
+ perror(*argv);
+ eprint("while making socket private to the real user.");
+ goto fail;
+ }
/* Start listening on socket. */
if (listen(fd, SOMAXCONN) < 0)