1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

s3-smbd provide struct smbd_server_connection * to conn_snum_used

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
This commit is contained in:
Andrew Bartlett 2011-05-25 13:00:22 +10:00
parent c981d4fa12
commit 8524924a46
12 changed files with 33 additions and 21 deletions

View 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);

View 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;
}

View 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. */

View 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;

View 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"

View 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();

View 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;

View 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;

View 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++) {

View 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,

View 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);
}

View 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);