The branch, master has been updated via a3e2151 s3:smbd: also create ncalrpc/np directory before forking rpc daemons via 800209a lib/util: only change umask during mkdir() via bfe990a lib/util: cope with races between lstat and mkdir in directory_create_or_exist() via e03059f lib/util: use a helper variable in directory_create_or_exist() via f306261 lib/util: do an early return on error directory_create_or_exist() via bd492be lib/util: remove unneeded else branch in directory_create_or_exist() via 687606b lib/util: don't start DEBUG output with 'error ' from ab37552 s4-dsdb: Fix the case for attribute name msDS-hasMasterNCs
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit a3e2151edd8fb6a7df41ea508e6d222938fcfe0b Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:56:28 2012 +0100 s3:smbd: also create ncalrpc/np directory before forking rpc daemons After the fixes to directory_create_or_exist(), this should not be needed anymore, but lets try to make autobuild reliable first. metze Autobuild-User: Stefan Metzmacher <me...@samba.org> Autobuild-Date: Wed Mar 14 13:44:41 CET 2012 on sn-devel-104 commit 800209aad5b07f9c61d7986971f42ff0f5ade78e Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:52:50 2012 +0100 lib/util: only change umask during mkdir() metze commit bfe990af89ebd870625c0740f1c6073a5349771e Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:50:34 2012 +0100 lib/util: cope with races between lstat and mkdir in directory_create_or_exist() metze commit e03059fc96931416c551d7d0a30eccb727a4f524 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:46:14 2012 +0100 lib/util: use a helper variable in directory_create_or_exist() metze commit f30626111994c0a5a4b886f52de1f62bfc52de3c Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:43:54 2012 +0100 lib/util: do an early return on error directory_create_or_exist() metze commit bd492befc0cbaa3d1ba3438a62d6e4832b98ee54 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:41:47 2012 +0100 lib/util: remove unneeded else branch in directory_create_or_exist() metze commit 687606b452ce6f9ebd853f4ffb569e513e38685c Author: Stefan Metzmacher <me...@samba.org> Date: Wed Mar 14 10:39:49 2012 +0100 lib/util: don't start DEBUG output with 'error ' This confused the subunit code. metze ----------------------------------------------------------------------- Summary of changes: lib/util/util.c | 69 +++++++++++++++++++++++++++--------------------- source3/smbd/server.c | 13 +++++++++ 2 files changed, 52 insertions(+), 30 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/util/util.c b/lib/util/util.c index 867da0a..960bda0 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -145,48 +145,57 @@ _PUBLIC_ bool directory_exist(const char *dname) _PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid, mode_t dir_perms) { - mode_t old_umask; + int ret; struct stat st; - old_umask = umask(0); - if (lstat(dname, &st) == -1) { - if (errno == ENOENT) { - /* Create directory */ - if (mkdir(dname, dir_perms) == -1) { - DEBUG(0, ("error creating directory " - "%s: %s\n", dname, - strerror(errno))); - umask(old_umask); - return false; - } - } else { + ret = lstat(dname, &st); + if (ret == -1) { + mode_t old_umask; + + if (errno != ENOENT) { DEBUG(0, ("lstat failed on directory %s: %s\n", dname, strerror(errno))); - umask(old_umask); return false; } - } else { - /* Check ownership and permission on existing directory */ - if (!S_ISDIR(st.st_mode)) { - DEBUG(0, ("directory %s isn't a directory\n", - dname)); - umask(old_umask); - return false; - } - if (st.st_uid != uid && !uwrap_enabled()) { - DEBUG(0, ("invalid ownership on directory " - "%s\n", dname)); + + /* Create directory */ + old_umask = umask(0); + ret = mkdir(dname, dir_perms); + if (ret == -1 && errno != EEXIST) { + DEBUG(0, ("mkdir failed on directory " + "%s: %s\n", dname, + strerror(errno))); umask(old_umask); return false; } - if ((st.st_mode & 0777) != dir_perms) { - DEBUG(0, ("invalid permissions on directory " - "'%s': has 0%o should be 0%o\n", dname, - (st.st_mode & 0777), dir_perms)); - umask(old_umask); + umask(old_umask); + + ret = lstat(dname, &st); + if (ret == -1) { + DEBUG(0, ("lstat failed on created directory %s: %s\n", + dname, strerror(errno))); return false; } } + + /* Check ownership and permission on existing directory */ + if (!S_ISDIR(st.st_mode)) { + DEBUG(0, ("directory %s isn't a directory\n", + dname)); + return false; + } + if (st.st_uid != uid && !uwrap_enabled()) { + DEBUG(0, ("invalid ownership on directory " + "%s\n", dname)); + return false; + } + if ((st.st_mode & 0777) != dir_perms) { + DEBUG(0, ("invalid permissions on directory " + "'%s': has 0%o should be 0%o\n", dname, + (st.st_mode & 0777), dir_perms)); + return false; + } + return true; } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 22b6a7a..aa3da1f 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -988,6 +988,7 @@ extern void build_options(bool screen); struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; struct tevent_signal *se; + char *np_dir = NULL; /* * Do this before any other talloc operation @@ -1351,6 +1352,18 @@ extern void build_options(bool screen); return -1; } + np_dir = talloc_asprintf(talloc_tos(), "%s/np", lp_ncalrpc_dir()); + if (!np_dir) { + DEBUG(0, ("%s: Out of memory\n", __location__)); + return -1; + } + + if (!directory_create_or_exist(np_dir, geteuid(), 0700)) { + DEBUG(0, ("Failed to create pipe directory %s - %s\n", + np_dir, strerror(errno))); + return -1; + } + if (is_daemon && !interactive) { if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) { start_epmd(ev_ctx, msg_ctx); -- Samba Shared Repository