s3-smbd provide struct smbd_server_connection * to conn_snum_used
authorAndrew Bartlett <abartlet@samba.org>
Wed, 25 May 2011 03:00:22 +0000 (13:00 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 30 May 2011 22:32:07 +0000 (00:32 +0200)
This provides the 'sconn' parameter to this key functions, that
is currently duplicated in dummysmbd.c, which causes duplicate symbol
issues in the waf build.

This has natrually caused a number of consequential changes across the
codebase, includning not passing a messaging context into initial
reload_services():

This causes problems because the global smbd_server_connection isn't
yet set up, as there isn't a connection here, just the initial
process.

Andrew Bartlett

12 files changed:
source3/include/proto.h
source3/lib/dummysmbd.c
source3/param/loadparm.c
source3/rpc_server/dfs/srv_dfs_nt.c
source3/rpc_server/spoolss/srv_spoolss_nt.c
source3/rpc_server/srvsvc/srv_srvsvc_nt.c
source3/smbd/conn.c
source3/smbd/lanman.c
source3/smbd/msdfs.c
source3/smbd/proto.h
source3/smbd/server.c
source3/smbd/server_reload.c

index 76d9b64e013c74eddb3d66225b8462484d14c905..ac5e7553602bdb048f0816597558cdbdcadd0ded 100644 (file)
@@ -1635,7 +1635,8 @@ bool lp_snum_ok(int iService);
 void lp_add_one_printer(const char *name, const char *comment,
                        const char *location, void *pdata);
 bool lp_loaded(void);
-void lp_killunused(bool (*snumused) (int));
+void lp_killunused(struct smbd_server_connection *sconn,
+                  bool (*snumused) (struct smbd_server_connection *, int));
 void lp_kill_all_services(void);
 void lp_killservice(int iServiceIn);
 const char* server_role_str(uint32 role);
@@ -1651,7 +1652,7 @@ enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
                        struct security_descriptor **ppsd,
                        bool *pallow_guest);
 int load_usershare_service(const char *servicename);
-int load_usershare_shares(void);
+int load_usershare_shares(struct smbd_server_connection *sconn);
 void gfree_loadparm(void);
 void lp_set_in_client(bool b);
 bool lp_is_in_client(void);
@@ -1842,7 +1843,7 @@ void unbecome_root(void);
 /* The following definitions come from lib/dummysmbd.c */
 
 int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out);
-bool conn_snum_used(int snum);
+bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
 void cancel_pending_lock_requests_by_fid(files_struct *fsp,
                        struct byte_range_lock *br_lck,
                        enum file_close_type close_type);
index 2465e6552bc2dca7426757302cf41bd5da830558..7a6c2cd3199a54442e8537eb6cb93cd35c592ee7 100644 (file)
@@ -28,7 +28,8 @@ int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out)
        return -1;
 }
 
-bool conn_snum_used(int snum)
+bool conn_snum_used(struct smbd_server_connection *sconn,
+                   int snum)
 {
        return False;
 }
index 58ead5bbf7c2eb7b86e2a44e6999610dbb936e4f..8aff0cfdbe8bc65790c1ea318d44298c17e7cf5f 100644 (file)
@@ -8676,7 +8676,8 @@ bool lp_loaded(void)
  Unload unused services.
 ***************************************************************************/
 
-void lp_killunused(bool (*snumused) (int))
+void lp_killunused(struct smbd_server_connection *sconn,
+                  bool (*snumused) (struct smbd_server_connection *, int))
 {
        int i;
        for (i = 0; i < iNumServices; i++) {
@@ -8689,7 +8690,7 @@ void lp_killunused(bool (*snumused) (int))
                        continue;
                }
 
-               if (!snumused || !snumused(i)) {
+               if (!snumused || !snumused(sconn, i)) {
                        free_service_byindex(i);
                }
        }
@@ -8700,7 +8701,7 @@ void lp_killunused(bool (*snumused) (int))
  */
 void lp_kill_all_services(void)
 {
-       lp_killunused(NULL);
+       lp_killunused(NULL, NULL);
 }
 
 /***************************************************************************
@@ -9314,7 +9315,7 @@ int load_usershare_service(const char *servicename)
  been removed.
 ***************************************************************************/
 
-int load_usershare_shares(void)
+int load_usershare_shares(struct smbd_server_connection *sconn)
 {
        SMB_STRUCT_DIR *dp;
        SMB_STRUCT_STAT sbuf;
@@ -9452,7 +9453,7 @@ int load_usershare_shares(void)
           not currently in use. */
        for (iService = iNumServices - 1; iService >= 0; iService--) {
                if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
-                       if (conn_snum_used(iService)) {
+                       if (conn_snum_used(sconn, iService)) {
                                continue;
                        }
                        /* Remove from the share ACL db. */
index 324af534c9bf3788085d59b9bdee86a2b7f21c2c..6ca35a5dcc97023071956c5df8098f2b0eee564d 100644 (file)
@@ -26,6 +26,7 @@
 #include "../librpc/gen_ndr/srv_dfs.h"
 #include "msdfs.h"
 #include "smbd/smbd.h"
+#include "smbd/globals.h"
 #include "auth.h"
 
 #undef DBGC_CLASS
@@ -278,7 +279,8 @@ WERROR _dfs_Enum(struct pipes_struct *p, struct dfs_Enum *r)
        size_t i;
        TALLOC_CTX *ctx = talloc_tos();
 
-       jn = enum_msdfs_links(ctx, &num_jn);
+       jn = enum_msdfs_links(msg_ctx_to_sconn(p->msg_ctx),
+                             ctx, &num_jn);
        if (!jn || num_jn == 0) {
                num_jn = 0;
                jn = NULL;
index fce4fd8648c590dce892bccd61ba70fb9de44e37..f7fa189af5d913e74e40759fa5eb1c1f20ff31c8 100644 (file)
@@ -47,6 +47,7 @@
 #include "serverid.h"
 #include "../libcli/registry/util_reg.h"
 #include "smbd/smbd.h"
+#include "smbd/globals.h"
 #include "auth.h"
 #include "messages.h"
 #include "rpc_server/spoolss/srv_spoolss_nt.h"
index 472a31860e50511d54155217cdbf824ff5defb8b..7251d70dd986e3764f382b9f43140ae3f3ed50f6 100644 (file)
@@ -33,6 +33,7 @@
 #include "session.h"
 #include "../lib/util/util_pw.h"
 #include "smbd/smbd.h"
+#include "smbd/globals.h"
 #include "auth.h"
 #include "messages.h"
 
@@ -568,7 +569,7 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
 
        /* Ensure all the usershares are loaded. */
        become_root();
-       load_usershare_shares();
+       load_usershare_shares(msg_ctx_to_sconn(p->msg_ctx));
        load_registry_shares();
        num_services = lp_numservices();
        unbecome_root();
index 833147b1a645d76d584259b62278b77f8a4d94a1..c4ab5c17936c8cee052a4fbaf097ef142f5c065d 100644 (file)
@@ -54,10 +54,9 @@ int conn_num_open(struct smbd_server_connection *sconn)
  Check if a snum is in use.
 ****************************************************************************/
 
-bool conn_snum_used(int snum)
+bool conn_snum_used(struct smbd_server_connection *sconn,
+                   int snum)
 {
-       struct smbd_server_connection *sconn = smbd_server_conn;
-
        if (sconn->using_smb2) {
                /* SMB2 */
                struct smbd_smb2_session *sess;
index b012e09f5e3ac2cee9d24f0630e4aa99712e63ef..5958bb9746da1f8ee19c58b48dca3f0ce1ea4577 100644 (file)
@@ -2092,7 +2092,7 @@ static bool api_RNetShareEnum(struct smbd_server_connection *sconn,
        /* Ensure all the usershares are loaded. */
        become_root();
        load_registry_shares();
-       count = load_usershare_shares();
+       count = load_usershare_shares(sconn);
        unbecome_root();
 
        data_len = fixed_len = string_len = 0;
index 82abda79dee2910549e0841d100027e76b9f08f9..085834b4ee91ba94147e2322c1cb8823f955f31f 100644 (file)
@@ -1709,7 +1709,8 @@ out:
        return cnt;
 }
 
-struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn)
+struct junction_map *enum_msdfs_links(struct smbd_server_connection *sconn,
+                                     TALLOC_CTX *ctx, size_t *p_num_jn)
 {
        struct junction_map *jn = NULL;
        int i=0;
@@ -1724,7 +1725,7 @@ struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn)
        /* Ensure all the usershares are loaded. */
        become_root();
        load_registry_shares();
-       sharecount = load_usershare_shares();
+       sharecount = load_usershare_shares(sconn);
        unbecome_root();
 
        for(i=0;i < sharecount;i++) {
index 589d45daded8ad10d6be7384a0796563b038c367..5b45574bc515b851d52302831784bbb5e0d4c7a5 100644 (file)
@@ -94,7 +94,7 @@ NTSTATUS delete_all_streams(connection_struct *conn, const char *fname);
 
 void conn_init(struct smbd_server_connection *sconn);
 int conn_num_open(struct smbd_server_connection *sconn);
-bool conn_snum_used(int snum);
+bool conn_snum_used(struct smbd_server_connection *sconn, int snum);
 connection_struct *conn_find(struct smbd_server_connection *sconn,
                             unsigned cnum);
 connection_struct *conn_new(struct smbd_server_connection *sconn);
@@ -407,7 +407,8 @@ bool create_junction(TALLOC_CTX *ctx,
                struct junction_map *jucn);
 bool create_msdfs_link(const struct junction_map *jucn);
 bool remove_msdfs_link(const struct junction_map *jucn);
-struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn);
+struct junction_map *enum_msdfs_links(struct smbd_server_connection *sconn,
+                                     TALLOC_CTX *ctx, size_t *p_num_jn);
 NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
                        connection_struct *conn,
                        bool dfs_pathnames,
index 4125aebeb490f9407096cfda1262ea939aea339d..10edb5ef4521e7593daae4f5799b26a222107a23 100644 (file)
@@ -1033,7 +1033,7 @@ extern void build_options(bool screen);
         * Reloading of the printers will not work here as we don't have a
         * server info and rpc services set up. It will be called later.
         */
-       if (!reload_services(smbd_messaging_context(), -1, False)) {
+       if (!reload_services(NULL, -1, False)) {
                exit(1);
        }
 
index 82b0cb03e95f66ccdcb0893b7e0a9f32055b8749..fef66dac6a573ee713d4b28d03def8ae403518a8 100644 (file)
@@ -113,7 +113,11 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
        if (test && !lp_file_list_changed())
                return(True);
 
-       lp_killunused(conn_snum_used);
+       if (msg_ctx) {
+               lp_killunused(msg_ctx_to_sconn(msg_ctx), conn_snum_used);
+       } else {
+               lp_killunused(NULL, NULL);
+       }
 
        ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);