[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[samba.git] / source / winbindd / winbindd_util.c
index 37d29e1765b8a77c951db3ebc6062af19e607089..c2fe09eead3a3177d4a2c46a334ccb11c2ba0fd0 100644 (file)
@@ -35,6 +35,7 @@ extern struct winbindd_methods passdb_methods;
  * Winbind daemon for NT domain authentication nss module.
  **/
 
+
 /* The list of trusted domains.  Note that the list can be deleted and
    recreated using the init_domain_list() function so pointers to
    individual winbindd_domain structures cannot be made.  Keep a copy of
@@ -186,7 +187,7 @@ static struct winbindd_domain *add_trusted_domain(const char *domain_name, const
        }
        
        /* Link to domain list */
-       DLIST_ADD(_domain_list, domain);
+       DLIST_ADD_END(_domain_list, domain, struct winbindd_domain *);
         
        wcache_tdc_add_domain( domain );
         
@@ -631,8 +632,6 @@ static void init_child_recv(void *private_data, BOOL success)
                state->response->data.domain_info.native_mode;
        state->domain->active_directory =
                state->response->data.domain_info.active_directory;
-       state->domain->sequence_number =
-               state->response->data.domain_info.sequence_number;
 
        init_dc_connection(state->domain);
 
@@ -677,8 +676,6 @@ enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domai
                = domain->active_directory;
        state->response.data.domain_info.primary
                = domain->primary;
-       state->response.data.domain_info.sequence_number =
-               domain->sequence_number;
 
        return WINBINDD_OK;
 }
@@ -692,6 +689,25 @@ BOOL init_domain_list(void)
        /* Free existing list */
        free_domain_list();
 
+       /* BUILTIN domain */
+
+       domain = add_trusted_domain("BUILTIN", NULL, &passdb_methods,
+                                   &global_sid_Builtin);
+       if (domain) {
+               setup_domain_child(domain, &domain->child, NULL);
+       }
+
+       /* Local SAM */
+
+       domain = add_trusted_domain(get_global_sam_name(), NULL,
+                                   &passdb_methods, get_global_sam_sid());
+       if (domain) {
+               if ( role != ROLE_DOMAIN_MEMBER ) {
+                       domain->primary = True;
+               }
+               setup_domain_child(domain, &domain->child, NULL);
+       }
+
        /* Add ourselves as the first entry. */
 
        if ( role == ROLE_DOMAIN_MEMBER ) {
@@ -718,25 +734,6 @@ BOOL init_domain_list(void)
                }
        }
 
-       /* Local SAM */
-
-       domain = add_trusted_domain(get_global_sam_name(), NULL,
-                                   &passdb_methods, get_global_sam_sid());
-       if (domain) {
-               if ( role != ROLE_DOMAIN_MEMBER ) {
-                       domain->primary = True;
-               }
-               setup_domain_child(domain, &domain->child, NULL);
-       }
-
-       /* BUILTIN domain */
-
-       domain = add_trusted_domain("BUILTIN", NULL, &passdb_methods,
-                                   &global_sid_Builtin);
-       if (domain) {
-               setup_domain_child(domain, &domain->child, NULL);
-       }
-
        return True;
 }
 
@@ -1158,11 +1155,63 @@ void fill_domain_username(fstring name, const char *domain, const char *user, BO
  * 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;
+}
+
+/* Close the winbindd socket */
+
+void close_winbindd_socket(void)
+{
+       if (_winbindd_socket != -1) {
+               DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
+                          _winbindd_socket));
+               close(_winbindd_socket);
+               _winbindd_socket = -1;
+       }
+       if (_winbindd_priv_socket != -1) {
+               DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n",
+                          _winbindd_priv_socket));
+               close(_winbindd_priv_socket);
+               _winbindd_priv_socket = -1;
+       }
+}
+
 /*
  * Client list accessor functions
  */