aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-05-14 04:02:00 +0200
committerMattias Andrée <maandree@operamail.com>2014-05-14 04:02:00 +0200
commit1277312b41c4c4645f862e203ed88ac491d9ae2d (patch)
treeda09163dbc23511a9230bacf27be144794826f31 /src
parentadd fix export of variable (diff)
downloadmds-1277312b41c4c4645f862e203ed88ac491d9ae2d.tar.gz
mds-1277312b41c4c4645f862e203ed88ac491d9ae2d.tar.bz2
mds-1277312b41c4c4645f862e203ed88ac491d9ae2d.tar.xz
m + add test client
Signed-off-by: Mattias Andrée <maandree@operamail.com>
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)