From b70009649a23ee8f0e88c1b9935e739537f4a960 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 31 Jan 2006 00:48:57 +0000 Subject: r13244: Allow control of the location of the Samba3-compatible winbindd pipe in Samba4. This allows us to start winbindd by default, including in 'make test'. This is via a new 'winbindd socket directory' parameter for utilities linked against loadparm, as well as a --with-winbindd-socket-dir option to configure (setting the default and the value for simple clients). I hope to add basic winbindd tests, to ensure continued correct operation, but at least now I don't have to manually change my 'server services' line. The other problem with the hard-coded /tmp/.winbind is that RedHat has moved this in Fedora (to /var/run I think). For this reason, this functionality should probably be ported to Samba3 as well. The default for Samba4 is PREFIX/var/run/winbind_pipe. I have also re-added the paranoia checks from Samba3 for correct permissions on the socket directory. Andrew Bartlett (This used to be commit 8866aa06ffc3896094c878e9c07b40c03826d9a7) --- source4/lib/util.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/util.c b/source4/lib/util.c index ed384572fe..7d3f21c1e8 100644 --- a/source4/lib/util.c +++ b/source4/lib/util.c @@ -88,6 +88,49 @@ BOOL directory_exist(const char *dname) return ret; } +BOOL directory_create_or_exist(const char *dname, uid_t uid, + mode_t dir_perms) +{ + mode_t old_umask; + 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 { + 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) || + ((st.st_mode & 0777) != dir_perms)) { + DEBUG(0, ("invalid permissions on directory " + "%s\n", dname)); + umask(old_umask); + return False; + } + } + return True; +} + + /******************************************************************* Returns the size in bytes of the named file. ********************************************************************/ -- cgit