s3:winbind tidy up connecting the winbind sockets.
authorAndrew Bartlett <abartlet@samba.org>
Mon, 17 May 2010 09:34:32 +0000 (19:34 +1000)
committerStefan Metzmacher <metze@samba.org>
Mon, 31 May 2010 19:36:55 +0000 (21:36 +0200)
By putting this code inline in winbindd_setup_listeners() we remove 2
static variables and simplify the code.

By putting the get_winbind_priv_pipe_dir() in the same file, we allow
it to be reimplemented in s3compat.

Andrew Bartlett

Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/winbindd/winbindd.c
source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_util.c

index 5e041fb57bd465d2ee7ae7d23858ad8bf30c9dde..c899360a6128628e6bf80740e690f3406fc64a8f 100644 (file)
@@ -938,6 +938,20 @@ static void winbindd_listen_fde_handler(struct tevent_context *ev,
        new_connection(s->fd, s->privileged);
 }
 
+/*
+ * Winbindd socket accessor functions
+ */
+
+const char *get_winbind_pipe_dir(void)
+{
+       return lp_parm_const_string(-1, "winbindd", "socket dir", WINBINDD_SOCKET_DIR);
+}
+
+char *get_winbind_priv_pipe_dir(void)
+{
+       return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR);
+}
+
 static bool winbindd_setup_listeners(void)
 {
        struct winbindd_listen_state *pub_state = NULL;
@@ -951,7 +965,8 @@ static bool winbindd_setup_listeners(void)
        }
 
        pub_state->privileged = false;
-       pub_state->fd = open_winbindd_socket();
+       pub_state->fd = create_pipe_sock(
+               get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);
        if (pub_state->fd == -1) {
                goto failed;
        }
@@ -972,7 +987,8 @@ static bool winbindd_setup_listeners(void)
        }
 
        priv_state->privileged = true;
-       priv_state->fd = open_winbindd_priv_socket();
+       priv_state->fd = create_pipe_sock(
+               get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750);
        if (priv_state->fd == -1) {
                goto failed;
        }
index 1b086734bce7823e1c09e16fc84a163f63cc3871..49e66f22c8e62af439eec78c95d32058a6a910d0 100644 (file)
@@ -52,6 +52,8 @@ bool winbindd_setup_sig_hup_handler(const char *lfile);
 bool winbindd_use_idmap_cache(void);
 bool winbindd_use_cache(void);
 void winbindd_register_handlers(void);
+const char *get_winbind_pipe_dir(void);
+char *get_winbind_priv_pipe_dir(void);
 int main(int argc, char **argv, char **envp);
 
 /* The following definitions come from winbindd/winbindd_ads.c  */
@@ -416,10 +418,6 @@ char *fill_domain_username_talloc(TALLOC_CTX *ctx,
                                  const char *domain,
                                  const char *user,
                                  bool can_assume);
-const char *get_winbind_pipe_dir(void) ;
-char *get_winbind_priv_pipe_dir(void) ;
-int open_winbindd_socket(void);
-int open_winbindd_priv_socket(void);
 struct winbindd_cli_state *winbindd_client_list(void);
 void winbindd_add_client(struct winbindd_cli_state *cli);
 void winbindd_remove_client(struct winbindd_cli_state *cli);
index 970e599e2b1f9d2e26191edd7d381dca2370290e..735a446e0787bef502a7780c014156e0bd4c3da8 100644 (file)
@@ -1028,49 +1028,6 @@ char *fill_domain_username_talloc(TALLOC_CTX *mem_ctx,
        return name;
 }
 
-/*
- * Winbindd socket accessor functions
- */
-
-const char *get_winbind_pipe_dir(void)
-{
-       return lp_parm_const_string(-1, "winbindd", "socket dir", WINBINDD_SOCKET_DIR);
-}
-
-char *get_winbind_priv_pipe_dir(void)
-{
-       return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR);
-}
-
-/* Open the winbindd socket */
-
-static int _winbindd_socket = -1;
-static int _winbindd_priv_socket = -1;
-
-int open_winbindd_socket(void)
-{
-       if (_winbindd_socket == -1) {
-               _winbindd_socket = create_pipe_sock(
-                       get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME, 0755);
-               DEBUG(10, ("open_winbindd_socket: opened socket fd %d\n",
-                          _winbindd_socket));
-       }
-
-       return _winbindd_socket;
-}
-
-int open_winbindd_priv_socket(void)
-{
-       if (_winbindd_priv_socket == -1) {
-               _winbindd_priv_socket = create_pipe_sock(
-                       get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750);
-               DEBUG(10, ("open_winbindd_priv_socket: opened socket fd %d\n",
-                          _winbindd_priv_socket));
-       }
-
-       return _winbindd_priv_socket;
-}
-
 /*
  * Client list accessor functions
  */