From d24a954dde20a303b01f09f96c957a6fc062f077 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 20 Sep 2014 17:08:54 +0200 Subject: kernel: remove umask until we exec into mds-server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mds.c b/src/mds.c index 40d9a42..6d8707a 100644 --- a/src/mds.c +++ b/src/mds.c @@ -53,6 +53,11 @@ static char** argv; */ static const char* master_server = LIBEXECDIR "/mds-server"; +/** + * The umask the server start with + */ +static mode_t saved_umask; + /** * Entry point of the program @@ -107,6 +112,9 @@ int main(int argc_, char** argv_) if (xsigaction(SIGDANGER, SIG_IGN) < 0) xperror(*argv); + /* Remove umask. */ + saved_umask = umask(0); + /* Create directory for socket files, PID files and such. */ if (create_directory_root(MDS_RUNTIME_ROOT_DIRECTORY)) return 1; @@ -333,7 +341,11 @@ int spawn_and_respawn_server(int fd) if (pid == 0) /* Child. */ { + /* If this image exits, it should do so with failure status. */ rc++; + /* Reinstate original umask. */ + umask(saved_umask); + /* Change image into the master server. */ exec_master_server(child_args); goto pfail; } @@ -435,9 +447,11 @@ int create_directory_root(const char* pathname) goto pfail; } else - /* Set ownership. */ - if (chown(pathname, ROOT_USER_UID, ROOT_GROUP_GID) < 0) - goto pfail; + { + /* Set ownership. */ + if (chown(pathname, ROOT_USER_UID, ROOT_GROUP_GID) < 0) + goto pfail; + } return 0; -- cgit v1.2.3-70-g09d2