summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-12-14 13:25:20 +0100
committerStefan Metzmacher <metze@samba.org>2011-12-15 11:11:24 +0100
commit03455519e70253cb86007ac5a8960999e9aa5fa4 (patch)
tree0203cadb5d8048e82682a42e913520d0de033a40
parent5061dd26d314baf38c7e8b3f8e495579baba49de (diff)
downloadsamba-03455519e70253cb86007ac5a8960999e9aa5fa4.tar.gz
samba-03455519e70253cb86007ac5a8960999e9aa5fa4.tar.bz2
samba-03455519e70253cb86007ac5a8960999e9aa5fa4.zip
s3:smbd: pass smbd_server_connection and a snumused function pointer to reload_services()
metze
-rw-r--r--source3/rpc_server/spoolss/srv_spoolss_nt.c12
-rw-r--r--source3/smbd/negprot.c4
-rw-r--r--source3/smbd/process.c8
-rw-r--r--source3/smbd/proto.h3
-rw-r--r--source3/smbd/reply.c2
-rw-r--r--source3/smbd/server.c6
-rw-r--r--source3/smbd/server_reload.c20
-rw-r--r--source3/smbd/sesssetup.c10
-rw-r--r--source3/smbd/smb2_sesssetup.c2
-rw-r--r--source3/torture/vfstest.c2
10 files changed, 39 insertions, 30 deletions
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 491d96566a..87df5659c7 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -6202,6 +6202,16 @@ static WERROR add_port_hook(TALLOC_CTX *ctx, struct security_token *token, const
/****************************************************************************
****************************************************************************/
+static bool spoolss_conn_snum_used(struct smbd_server_connection *sconn,
+ int snum)
+{
+ /*
+ * As we do not know if we are embedded in the file server process
+ * or not, we have to pretend that all shares are in use.
+ */
+ return true;
+}
+
static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
struct spoolss_SetPrinterInfo2 *info2,
const char *remote_machine,
@@ -6260,7 +6270,7 @@ static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
/* reload our services immediately */
become_root();
- reload_services(msg_ctx, -1, false);
+ reload_services(NULL, spoolss_conn_snum_used, false);
unbecome_root();
numlines = 0;
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index ae9ce5a2cf..52ef96d5fc 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -714,7 +714,7 @@ void reply_negprot(struct smb_request *req)
}
/* possibly reload - change of architecture */
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
/* moved from the netbios session setup code since we don't have that
when the client connects to port 445. Of course there is a small
@@ -740,7 +740,7 @@ void reply_negprot(struct smb_request *req)
if(choice != -1) {
fstrcpy(remote_proto,supported_protocols[protocol].short_name);
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
supported_protocols[protocol].proto_reply_fn(req, choice);
DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
} else {
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 2b35680949..c448267781 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -908,7 +908,7 @@ static void smbd_sig_hup_handler(struct tevent_context *ev,
change_to_root_user();
DEBUG(1,("Reloading services after SIGHUP\n"));
- reload_services(sconn->msg_ctx, sconn->sock, false);
+ reload_services(sconn, conn_snum_used, false);
}
void smbd_setup_sig_hup_handler(struct smbd_server_connection *sconn)
@@ -938,7 +938,7 @@ static void smbd_conf_updated(struct messaging_context *msg,
DEBUG(10,("smbd_conf_updated: Got message saying smb.conf was "
"updated. Reloading.\n"));
change_to_root_user();
- reload_services(sconn->msg_ctx, sconn->sock, False);
+ reload_services(sconn, conn_snum_used, false);
}
static NTSTATUS smbd_server_connection_loop_once(struct tevent_context *ev_ctx,
@@ -2221,7 +2221,7 @@ static void check_reload(struct smbd_server_connection *sconn, time_t t)
}
if (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK) {
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
last_smb_conf_reload_time = t;
}
}
@@ -3183,7 +3183,7 @@ void smbd_process(struct tevent_context *ev_ctx,
/* this is needed so that we get decent entries
in smbstatus for port 445 connects */
set_remote_machine_name(remaddr, false);
- reload_services(sconn->msg_ctx, sconn->sock, true);
+ reload_services(sconn, conn_snum_used, true);
/*
* Before the first packet, check the global hosts allow/ hosts deny
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 2fd59a1f47..92b1443a98 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -955,7 +955,8 @@ void init_sec_ctx(void);
struct memcache *smbd_memcache(void);
void delete_and_reload_printers(struct tevent_context *ev,
struct messaging_context *msg_ctx);
-bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
+bool reload_services(struct smbd_server_connection *sconn,
+ bool (*snumused) (struct smbd_server_connection *, int),
bool test);
void exit_server(const char *const explanation);
void exit_server_cleanly(const char *const explanation);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index a06e7b8339..d9b7500707 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -606,7 +606,7 @@ void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inb
add_session_user(sconn, get_remote_machine_name());
}
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
reopen_logs();
sconn->nbt.got_session = true;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index e58128ea58..369b7ab450 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -99,7 +99,7 @@ static void smbd_parent_conf_updated(struct messaging_context *msg,
DEBUG(10,("smbd_parent_conf_updated: Got message saying smb.conf was "
"updated. Reloading.\n"));
change_to_root_user();
- reload_services(msg, -1, false);
+ reload_services(NULL, NULL, false);
printing_subsystem_update(ev_ctx, msg, false);
}
@@ -910,7 +910,7 @@ static void smbd_parent_sig_hup_handler(struct tevent_context *ev,
change_to_root_user();
DEBUG(1,("parent: Reloading services after SIGHUP\n"));
- reload_services(parent->msg_ctx, -1, false);
+ reload_services(NULL, NULL, false);
printing_subsystem_update(parent->ev_ctx, parent->msg_ctx, true);
}
@@ -1138,7 +1138,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(NULL, -1, False)) {
+ if (!reload_services(NULL, NULL, false)) {
exit(1);
}
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index 0c2ea2c5b1..f15f80e13f 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -106,7 +106,8 @@ void delete_and_reload_printers(struct tevent_context *ev,
Reload the services file.
**************************************************************************/
-bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
+bool reload_services(struct smbd_server_connection *sconn,
+ bool (*snumused) (struct smbd_server_connection *, int),
bool test)
{
bool ret;
@@ -125,25 +126,22 @@ bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
if (test && !lp_file_list_changed())
return(True);
- if (msg_ctx) {
- lp_killunused(msg_ctx_to_sconn(msg_ctx), conn_snum_used);
- } else {
- lp_killunused(NULL, NULL);
- }
+ lp_killunused(sconn, snumused);
ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
/* perhaps the config filename is now set */
- if (!test)
- reload_services(msg_ctx, smb_sock, True);
+ if (!test) {
+ reload_services(sconn, snumused, true);
+ }
reopen_logs();
load_interfaces();
- if (smb_sock != -1) {
- set_socket_options(smb_sock,"SO_KEEPALIVE");
- set_socket_options(smb_sock, lp_socket_options());
+ if (sconn != NULL) {
+ set_socket_options(sconn->sock, "SO_KEEPALIVE");
+ set_socket_options(sconn->sock, lp_socket_options());
}
mangle_reset_cache();
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 5fa571a0e9..889361acb8 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -341,7 +341,7 @@ static void reply_spnego_kerberos(struct smb_request *req,
sub_set_smb_name(real_username);
/* reload services so that the new %U is taken into account */
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
ret = make_session_info_krb5(mem_ctx,
user, domain, real_username, pw,
@@ -377,7 +377,7 @@ static void reply_spnego_kerberos(struct smb_request *req,
ret = NT_STATUS_LOGON_FAILURE;
} else {
/* current_user_info is changed on new vuid */
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
SSVAL(req->outbuf, smb_vwv3, 0);
@@ -462,7 +462,7 @@ static void reply_spnego_ntlmssp(struct smb_request *req,
}
/* current_user_info is changed on new vuid */
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
SSVAL(req->outbuf, smb_vwv3, 0);
@@ -1574,7 +1574,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
sub_set_smb_name(sub_user);
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
if (lp_security() == SEC_SHARE) {
char *sub_user_mapped = NULL;
@@ -1727,7 +1727,7 @@ void reply_sesssetup_and_X(struct smb_request *req)
}
/* current_user_info is changed on new vuid */
- reload_services(sconn->msg_ctx, sconn->sock, True);
+ reload_services(sconn, conn_snum_used, true);
}
data_blob_free(&nt_resp);
diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c
index 64fa446059..f2ce989eb6 100644
--- a/source3/smbd/smb2_sesssetup.c
+++ b/source3/smbd/smb2_sesssetup.c
@@ -209,7 +209,7 @@ static NTSTATUS smbd_smb2_session_setup_krb5(struct smbd_smb2_session *session,
sub_set_smb_name(real_username);
/* reload services so that the new %U is taken into account */
- reload_services(smb2req->sconn->msg_ctx, smb2req->sconn->sock, true);
+ reload_services(smb2req->sconn, conn_snum_used, true);
status = make_session_info_krb5(session,
user, domain, real_username, pw,
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 3ed49c021e..01deba00d3 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -451,7 +451,7 @@ int main(int argc, char *argv[])
lp_load_initial_only(get_dyn_CONFIGFILE());
/* TODO: check output */
- reload_services(NULL, -1, False);
+ reload_services(NULL, NULL, false);
/* the following functions are part of the Samba debugging
facilities. See lib/debug.c */