From 1277312b41c4c4645f862e203ed88ac491d9ae2d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 14 May 2014 04:02:00 +0200 Subject: m + add test client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') 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) -- cgit v1.2.3-70-g09d2