1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

s3:param: make "servicename" a substituted option

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Ralph Boehme 2019-11-07 11:01:05 +01:00 committed by Stefan Metzmacher
parent eddc63be86
commit b5c6964a50
37 changed files with 254 additions and 113 deletions

View File

@ -221,6 +221,8 @@ char *afs_createtoken_str(const char *username, const char *cell)
bool afs_login(connection_struct *conn)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
DATA_BLOB ticket;
char *afs_username = NULL;
char *cell = NULL;
@ -239,7 +241,7 @@ bool afs_login(connection_struct *conn)
}
afs_username = talloc_sub_advanced(ctx,
lp_servicename(ctx, SNUM(conn)),
lp_servicename(ctx, lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,

View File

@ -742,7 +742,7 @@ char *lp_parm_substituted_string(TALLOC_CTX *mem_ctx,
#include "source3/param/param_proto.h"
char *lp_servicename(TALLOC_CTX *ctx, int);
char *lp_servicename(TALLOC_CTX *ctx, const struct loadparm_substitution *, int);
const char *lp_const_servicename(int);
bool lp_autoloaded(int);
const char *lp_dnsdomain(void);

View File

@ -123,6 +123,8 @@ static int vfswrap_statvfs(struct vfs_handle_struct *handle,
static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,
enum timestamp_set_resolution *p_ts_res)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
connection_struct *conn = handle->conn;
uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
struct smb_filename *smb_fname_cpath = NULL;
@ -174,7 +176,7 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,
"resolution of %s "
"available on share %s, directory %s\n",
*p_ts_res == TIMESTAMP_SET_MSEC ? "msec" : "sec",
lp_servicename(talloc_tos(), conn->params->service),
lp_servicename(talloc_tos(), lp_sub, conn->params->service),
conn->connectpath ));
}
TALLOC_FREE(smb_fname_cpath);

View File

@ -97,8 +97,11 @@ static int dfs_samba4_connect(struct vfs_handle_struct *handle,
static void dfs_samba4_disconnect(struct vfs_handle_struct *handle)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
DEBUG(10,("dfs_samba4_disconnect() connect to service[%s].\n",
lp_servicename(talloc_tos(), SNUM(handle->conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(handle->conn))));
SMB_VFS_NEXT_DISCONNECT(handle);
}

View File

@ -112,6 +112,8 @@ static char *expand_msdfs_target(TALLOC_CTX *ctx,
connection_struct *conn,
char *target)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *mapfilename = NULL;
char *filename_start = strchr_m(target, '@');
char *filename_end = NULL;
@ -155,7 +157,7 @@ static char *expand_msdfs_target(TALLOC_CTX *ctx,
}
targethost = talloc_sub_full(ctx,
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,

View File

@ -467,8 +467,11 @@ static int fileid_connect(struct vfs_handle_struct *handle,
static void fileid_disconnect(struct vfs_handle_struct *handle)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
DEBUG(10,("fileid_disconnect() connect to service[%s].\n",
lp_servicename(talloc_tos(), SNUM(handle->conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(handle->conn))));
SMB_VFS_NEXT_DISCONNECT(handle);
}

View File

@ -475,6 +475,8 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *prefix = NULL;
char *result;
@ -485,7 +487,7 @@ static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
return NULL;
}
result = talloc_sub_full(ctx,
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,
@ -771,10 +773,13 @@ static int smb_full_audit_connect(vfs_handle_struct *handle,
static void smb_full_audit_disconnect(vfs_handle_struct *handle)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
SMB_VFS_NEXT_DISCONNECT(handle);
do_log(SMB_VFS_OP_DISCONNECT, True, handle,
"%s", lp_servicename(talloc_tos(), SNUM(handle->conn)));
"%s", lp_servicename(talloc_tos(), lp_sub, SNUM(handle->conn)));
/* The bitmaps will be disconnected when the private
data is deleted. */

View File

@ -454,6 +454,8 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
int flags)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
connection_struct *conn = handle->conn;
char *path_name = NULL;
char *temp_name = NULL;
@ -467,7 +469,7 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
bool exist;
int rc = -1;
repository = talloc_sub_full(NULL, lp_servicename(talloc_tos(), SNUM(conn)),
repository = talloc_sub_full(NULL, lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,

View File

@ -35,8 +35,11 @@ char *virusfilter_string_sub(
connection_struct *conn,
const char *str)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
return talloc_sub_full(mem_ctx,
lp_servicename(mem_ctx, SNUM(conn)),
lp_servicename(mem_ctx, lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,

View File

@ -1097,7 +1097,7 @@ int lp_winbind_max_domain_connections(void)
#include "lib/param/param_functions.c"
FN_LOCAL_STRING(servicename, szService)
FN_LOCAL_SUBSTITUTED_STRING(servicename, szService)
FN_LOCAL_CONST_STRING(const_servicename, szService)
/* These functions cannot be auto-generated */
@ -3795,13 +3795,15 @@ int load_usershare_shares(struct smbd_server_connection *sconn,
tmp_ctx = talloc_stackframe();
for (iService = iNumServices - 1; iService >= 0; iService--) {
if (VALID(iService) && (ServicePtrs[iService]->usershare == USERSHARE_PENDING_DELETE)) {
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *servname;
if (snumused && snumused(sconn, iService)) {
continue;
}
servname = lp_servicename(tmp_ctx, iService);
servname = lp_servicename(tmp_ctx, lp_sub, iService);
/* Remove from the share ACL db. */
DEBUG(10,("load_usershare_shares: Removing deleted usershare %s\n",
@ -4292,7 +4294,7 @@ const char *volume_label(TALLOC_CTX *ctx, int snum)
size_t end = 32;
if (!*label) {
label = lp_servicename(ctx, snum);
label = lp_servicename(ctx, lp_sub, snum);
}
/*

View File

@ -423,7 +423,9 @@ void notify_printer_status(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, uint32_t status)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
if (sharename)
notify_printer_status_byname(ev, msg_ctx, sharename, status);
@ -511,7 +513,9 @@ void notify_printer_driver(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *driver_name)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,
@ -523,7 +527,9 @@ void notify_printer_comment(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *comment)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,
@ -535,7 +541,9 @@ void notify_printer_sharename(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *share_name)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,
@ -547,7 +555,9 @@ void notify_printer_printername(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *printername)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,
@ -559,7 +569,9 @@ void notify_printer_port(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *port_name)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,
@ -571,7 +583,9 @@ void notify_printer_location(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *location)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,
@ -583,7 +597,9 @@ void notify_printer_sepfile(struct tevent_context *ev,
struct messaging_context *msg_ctx,
int snum, const char *sepfile)
{
const char *sharename = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *sharename = lp_servicename(talloc_tos(), lp_sub, snum);
send_notify_field_buffer(
ev, msg_ctx,

View File

@ -1713,6 +1713,8 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
struct dcerpc_binding_handle *b,
const struct spoolss_DriverInfo8 *r)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int snum;
int n_services = lp_numservices();
bool in_use = false;
@ -1733,7 +1735,7 @@ bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
}
result = winreg_get_printer(mem_ctx, b,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
continue; /* skip */

View File

@ -619,6 +619,8 @@ done:
WERROR check_published_printers(struct messaging_context *msg_ctx)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
ADS_STATUS ads_rc;
ADS_STRUCT *ads = NULL;
int snum;
@ -666,7 +668,7 @@ WERROR check_published_printers(struct messaging_context *msg_ctx)
}
result = winreg_get_printer_internal(tmp_ctx, session_info, msg_ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
continue;

View File

@ -82,7 +82,7 @@ static int print_run_command(int snum, const char* printername, bool do_sub,
if (do_sub && snum != -1) {
syscmd = talloc_sub_advanced(ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
current_user_info.unix_name,
"",
get_current_gid(NULL),

View File

@ -1727,7 +1727,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
return;
}
lpqcommand = talloc_sub_full(ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
current_user_info.unix_name,
"",
get_current_gid(NULL),
@ -1747,7 +1747,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
return;
}
lprmcommand = talloc_sub_full(ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
current_user_info.unix_name,
"",
get_current_gid(NULL),
@ -3054,7 +3054,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
goto fail;
}
lpq_cmd = talloc_sub_full(tmp_ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
current_user_info.unix_name,
"",
get_current_gid(NULL),
@ -3105,6 +3105,8 @@ static bool get_stored_queue_info(struct messaging_context *msg_ctx,
struct tdb_print_db *pdb, int snum,
int *pcount, print_queue_struct **ppqueue)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
TDB_DATA data, cgdata, jcdata;
print_queue_struct *queue = NULL;
uint32_t qcount = 0;
@ -3115,7 +3117,7 @@ static bool get_stored_queue_info(struct messaging_context *msg_ctx,
uint32_t i;
int max_reported_jobs = lp_max_reported_print_jobs(snum);
bool ret = false;
const char* sharename = lp_servicename(talloc_tos(), snum);
const char* sharename = lp_servicename(talloc_tos(), lp_sub, snum);
TALLOC_CTX *tmp_ctx = talloc_new(msg_ctx);
if (tmp_ctx == NULL) {
return false;

View File

@ -80,7 +80,7 @@ NTSTATUS print_spool_open(files_struct *fsp,
status = NT_STATUS_NO_MEMORY;
goto done;
}
pf->svcname = lp_servicename(pf, SNUM(fsp->conn));
pf->svcname = lp_servicename(pf, lp_sub, SNUM(fsp->conn));
/* the document name is derived from the file name.
* "Remote Downlevel Document" is added in front to

View File

@ -103,6 +103,7 @@ static void delete_and_reload_printers_full(struct tevent_context *ev,
msg_ctx,
NULL,
lp_servicename(session_info,
lp_sub,
snum),
&pinfo2)) {
nt_printer_publish(session_info,

View File

@ -2764,7 +2764,10 @@ static void spoolss_notify_share_name(struct messaging_context *msg_ctx,
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, lp_servicename(talloc_tos(), snum));
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, lp_servicename(talloc_tos(), lp_sub, snum));
}
/*******************************************************************
@ -3376,6 +3379,8 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
uint32_t id,
TALLOC_CTX *mem_ctx)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int field_num,j;
enum spoolss_NotifyType type;
uint16_t field;
@ -3386,7 +3391,7 @@ static bool construct_notify_printer_info(struct messaging_context *msg_ctx,
DEBUG(4,("construct_notify_printer_info: Notify type: [%s], number of notify info: [%d] on printer: [%s]\n",
(type == PRINTER_NOTIFY_TYPE ? "PRINTER_NOTIFY_TYPE" : "JOB_NOTIFY_TYPE"),
option_type->count, lp_servicename(talloc_tos(), snum)));
option_type->count, lp_servicename(talloc_tos(), lp_sub, snum)));
for(field_num=0; field_num < option_type->count; field_num++) {
field = option_type->fields[field_num].field;
@ -3510,6 +3515,8 @@ static WERROR printserver_notify_info(struct pipes_struct *p,
struct spoolss_NotifyInfo *info,
TALLOC_CTX *mem_ctx)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int snum;
struct printer_handle *Printer = find_printer_index_by_hnd(p, hnd);
int n_services=lp_numservices();
@ -3553,12 +3560,12 @@ static WERROR printserver_notify_info(struct pipes_struct *p,
result = winreg_get_printer_internal(mem_ctx,
get_session_info_system(),
p->msg_ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
DEBUG(4, ("printserver_notify_info: "
"Failed to get printer [%s]\n",
lp_servicename(talloc_tos(), snum)));
lp_servicename(talloc_tos(), lp_sub, snum)));
continue;
}
@ -3603,6 +3610,8 @@ static WERROR printer_notify_info(struct pipes_struct *p,
struct spoolss_NotifyInfo *info,
TALLOC_CTX *mem_ctx)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int snum;
struct printer_handle *Printer = find_printer_index_by_hnd(p, hnd);
int i;
@ -3647,7 +3656,7 @@ static WERROR printer_notify_info(struct pipes_struct *p,
result = winreg_get_printer_internal(mem_ctx,
get_session_info_system(),
p->msg_ctx,
lp_servicename(talloc_tos(), snum), &pinfo2);
lp_servicename(talloc_tos(), lp_sub, snum), &pinfo2);
if (!W_ERROR_IS_OK(result)) {
result = WERR_INVALID_HANDLE;
goto err_pdb_drop;
@ -4033,7 +4042,7 @@ static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx,
return result;
}
r->sharename = lp_servicename(mem_ctx, snum);
r->sharename = lp_servicename(mem_ctx, lp_sub, snum);
W_ERROR_HAVE_NO_MEMORY(r->sharename);
r->portname = talloc_strdup(mem_ctx, info2->portname);
W_ERROR_HAVE_NO_MEMORY(r->portname);
@ -4241,6 +4250,8 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
struct spoolss_PrinterInfo7 *r,
int snum)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const struct auth_session_info *session_info;
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
char *printer;
@ -4253,7 +4264,7 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
session_info = get_session_info_system();
SMB_ASSERT(session_info != NULL);
printer = lp_servicename(tmp_ctx, snum);
printer = lp_servicename(tmp_ctx, lp_sub, snum);
if (printer == NULL) {
DEBUG(0, ("invalid printer snum %d\n", snum));
werr = WERR_INVALID_PARAMETER;
@ -7052,6 +7063,8 @@ static WERROR publish_or_unpublish_printer(struct pipes_struct *p,
struct spoolss_SetPrinterInfo7 *info7)
{
#ifdef HAVE_ADS
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
WERROR result;
int snum;
@ -7074,7 +7087,7 @@ static WERROR publish_or_unpublish_printer(struct pipes_struct *p,
result = winreg_get_printer_internal(p->mem_ctx,
get_session_info_system(),
p->msg_ctx,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
return WERR_INVALID_HANDLE;
@ -7328,13 +7341,15 @@ static WERROR fill_job_info1(TALLOC_CTX *mem_ctx,
int position, int snum,
struct spoolss_PrinterInfo2 *pinfo2)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct tm *t;
t = gmtime(&queue->time);
r->job_id = jobid;
r->printer_name = lp_servicename(mem_ctx, snum);
r->printer_name = lp_servicename(mem_ctx, lp_sub, snum);
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
r->server_name = talloc_strdup(mem_ctx, pinfo2->servername);
W_ERROR_HAVE_NO_MEMORY(r->server_name);
@ -7370,13 +7385,15 @@ static WERROR fill_job_info2(TALLOC_CTX *mem_ctx,
struct spoolss_PrinterInfo2 *pinfo2,
struct spoolss_DeviceMode *devmode)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct tm *t;
t = gmtime(&queue->time);
r->job_id = jobid;
r->printer_name = lp_servicename(mem_ctx, snum);
r->printer_name = lp_servicename(mem_ctx, lp_sub, snum);
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
r->server_name = talloc_strdup(mem_ctx, pinfo2->servername);
W_ERROR_HAVE_NO_MEMORY(r->server_name);
@ -9998,6 +10015,8 @@ done:
WERROR _spoolss_SetPrinterDataEx(struct pipes_struct *p,
struct spoolss_SetPrinterDataEx *r)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
int snum = 0;
WERROR result = WERR_OK;
@ -10055,7 +10074,7 @@ WERROR _spoolss_SetPrinterDataEx(struct pipes_struct *p,
}
result = winreg_get_printer(tmp_ctx, b,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
goto done;

View File

@ -210,7 +210,10 @@ static enum srvsvc_ShareType get_share_type(int snum)
static void init_srv_share_info_0(struct pipes_struct *p,
struct srvsvc_NetShareInfo0 *r, int snum)
{
r->name = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
r->name = lp_servicename(talloc_tos(), lp_sub, snum);
}
/*******************************************************************
@ -223,12 +226,12 @@ static void init_srv_share_info_1(struct pipes_struct *p,
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *net_name = lp_servicename(talloc_tos(), snum);
char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
char *remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
remark = talloc_sub_full(
p->mem_ctx, lp_servicename(talloc_tos(), snum),
p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
@ -253,12 +256,12 @@ static void init_srv_share_info_2(struct pipes_struct *p,
char *path = NULL;
int max_connections = lp_max_connections(snum);
uint32_t max_uses = max_connections!=0 ? max_connections : (uint32_t)-1;
char *net_name = lp_servicename(talloc_tos(), snum);
char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
remark = talloc_sub_full(
p->mem_ctx, lp_servicename(talloc_tos(), snum),
p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
@ -320,12 +323,12 @@ static void init_srv_share_info_501(struct pipes_struct *p,
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *net_name = lp_servicename(talloc_tos(), snum);
const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
char *remark = lp_comment(p->mem_ctx, lp_sub, snum);
if (remark) {
remark = talloc_sub_full(
p->mem_ctx, lp_servicename(talloc_tos(), snum),
p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
@ -351,7 +354,7 @@ static void init_srv_share_info_502(struct pipes_struct *p,
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *net_name = lp_servicename(talloc_tos(), snum);
const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
char *path = NULL;
struct security_descriptor *sd = NULL;
struct sec_desc_buf *sd_buf = NULL;
@ -361,7 +364,7 @@ static void init_srv_share_info_502(struct pipes_struct *p,
if (remark) {
remark = talloc_sub_full(
p->mem_ctx, lp_servicename(talloc_tos(), snum),
p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
@ -375,7 +378,7 @@ static void init_srv_share_info_502(struct pipes_struct *p,
string_replace(path, '/', '\\');
}
sd = get_share_security(ctx, lp_servicename(talloc_tos(), snum), &sd_size);
sd = get_share_security(ctx, lp_servicename(talloc_tos(), lp_sub, snum), &sd_size);
sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
@ -404,7 +407,7 @@ static void init_srv_share_info_1004(struct pipes_struct *p,
if (remark) {
remark = talloc_sub_full(
p->mem_ctx, lp_servicename(talloc_tos(), snum),
p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum),
get_current_username(), lp_path(talloc_tos(), lp_sub, snum),
p->session_info->unix_token->uid, get_current_username(),
"", remark);
@ -463,12 +466,14 @@ static void init_srv_share_info_1501(struct pipes_struct *p,
struct sec_desc_buf **r,
int snum)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct security_descriptor *sd;
struct sec_desc_buf *sd_buf = NULL;
size_t sd_size;
TALLOC_CTX *ctx = p->mem_ctx;
sd = get_share_security(ctx, lp_servicename(talloc_tos(), snum), &sd_size);
sd = get_share_security(ctx, lp_servicename(talloc_tos(), lp_sub, snum), &sd_size);
if (sd) {
sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
}
@ -482,7 +487,9 @@ static void init_srv_share_info_1501(struct pipes_struct *p,
static bool is_hidden_share(int snum)
{
const char *net_name = lp_servicename(talloc_tos(), snum);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *net_name = lp_servicename(talloc_tos(), lp_sub, snum);
return (net_name[strlen(net_name) - 1] == '$') ? True : False;
}
@ -493,6 +500,9 @@ static bool is_hidden_share(int snum)
static bool is_enumeration_allowed(struct pipes_struct *p,
int snum)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
if (!lp_access_based_share_enum(snum)) {
return true;
}
@ -504,7 +514,7 @@ static bool is_enumeration_allowed(struct pipes_struct *p,
}
return share_access_check(p->session_info->security_token,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
FILE_READ_DATA, NULL);
}
@ -561,6 +571,8 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
uint32_t *total_entries,
bool all_shares)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
uint32_t num_entries = 0;
uint32_t alloc_entries = 0;
int num_services = 0;
@ -591,12 +603,12 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
is_enumeration_allowed(p, snum) &&
(all_shares || !is_hidden_share(snum)) ) {
DEBUG(10, ("counting service %s\n",
lp_servicename(talloc_tos(), snum) ? lp_servicename(talloc_tos(), snum) : "(null)"));
lp_servicename(talloc_tos(), lp_sub, snum) ? lp_servicename(talloc_tos(), lp_sub, snum) : "(null)"));
allowed[snum] = true;
num_entries++;
} else {
DEBUG(10, ("NOT counting service %s\n",
lp_servicename(talloc_tos(), snum) ? lp_servicename(talloc_tos(), snum) : "(null)"));
lp_servicename(talloc_tos(), lp_sub, snum) ? lp_servicename(talloc_tos(), lp_sub, snum) : "(null)"));
}
}
@ -1955,7 +1967,7 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p,
size_t sd_size;
NTSTATUS status;
old_sd = get_share_security(p->mem_ctx, lp_servicename(talloc_tos(), snum), &sd_size);
old_sd = get_share_security(p->mem_ctx, lp_servicename(talloc_tos(), lp_sub, snum), &sd_size);
if (old_sd && !security_descriptor_equal(old_sd, psd)) {
status = set_share_security(share_name, psd);

View File

@ -83,6 +83,8 @@ bool conn_idle_all(struct smbd_server_connection *sconn, time_t t)
void conn_force_tdis(struct smbd_server_connection *sconn, const char *sharename)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
connection_struct *conn, *next;
bool close_all = false;
@ -107,7 +109,7 @@ void conn_force_tdis(struct smbd_server_connection *sconn, const char *sharename
if (close_all) {
do_close = true;
} else if (strequal(lp_servicename(talloc_tos(), SNUM(conn)),
} else if (strequal(lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
sharename)) {
DEBUG(1, ("conn_force_tdis: Forcing close of "
"share '%s' (wire_id=0x%08x)\n",

View File

@ -83,9 +83,11 @@ int count_current_connections(const char *sharename, bool verify)
bool connections_snum_used(struct smbd_server_connection *unused, int snum)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int active;
active = count_current_connections(lp_servicename(talloc_tos(), snum),
active = count_current_connections(lp_servicename(talloc_tos(), lp_sub, snum),
true);
if (active > 0) {
return true;

View File

@ -1122,6 +1122,8 @@ NTSTATUS file_set_sparse(connection_struct *conn,
files_struct *fsp,
bool sparse)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
uint32_t old_dosmode;
uint32_t new_dosmode;
NTSTATUS status;
@ -1131,7 +1133,7 @@ NTSTATUS file_set_sparse(connection_struct *conn,
"on readonly share[%s]\n",
smb_fname_str_dbg(fsp->fsp_name),
sparse,
lp_servicename(talloc_tos(), SNUM(conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
return NT_STATUS_MEDIA_WRITE_PROTECTED;
}

View File

@ -520,6 +520,8 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
files_struct **result,
DATA_BLOB *new_cookie)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct share_mode_lock *lck;
struct share_mode_entry e;
struct files_struct *fsp = NULL;
@ -650,7 +652,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
{
DEBUG(5, ("vfs_default_durable_reconnect: denying durable "
"share[%s] is not writeable anymore\n",
lp_servicename(talloc_tos(), SNUM(conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
TALLOC_FREE(lck);
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}

View File

@ -126,6 +126,8 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
uint32_t access_mask,
files_struct **result)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
files_struct *fsp = NULL;
NTSTATUS status;
@ -134,7 +136,7 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("open_fake_file: smbd_calculate_access_mask "
"on service[%s] file[%s] returned %s\n",
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
smb_fname_str_dbg(smb_fname),
nt_errstr(status)));
return status;
@ -144,7 +146,7 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
if (geteuid() != sec_initial_uid()) {
DEBUG(3, ("open_fake_file_shared: access_denied to "
"service[%s] file[%s] user[%s]\n",
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
smb_fname_str_dbg(smb_fname),
conn->session_info->unix_info->unix_name));
return NT_STATUS_ACCESS_DENIED;

View File

@ -97,6 +97,8 @@ static int CopyExpanded(connection_struct *conn,
int snum, char **dst, char *src, int *p_space_remaining)
{
TALLOC_CTX *ctx = talloc_tos();
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *buf = NULL;
int l;
@ -110,13 +112,13 @@ static int CopyExpanded(connection_struct *conn,
*p_space_remaining = 0;
return 0;
}
buf = talloc_string_sub(ctx, buf,"%S", lp_servicename(ctx, snum));
buf = talloc_string_sub(ctx, buf,"%S", lp_servicename(ctx, lp_sub, snum));
if (!buf) {
*p_space_remaining = 0;
return 0;
}
buf = talloc_sub_full(ctx,
lp_servicename(ctx, SNUM(conn)),
lp_servicename(ctx, lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,
@ -154,6 +156,8 @@ static int CopyAndAdvance(char **dst, char *src, int *n)
static int StrlenExpanded(connection_struct *conn, int snum, char *s)
{
TALLOC_CTX *ctx = talloc_tos();
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *buf = NULL;
if (!s) {
return 0;
@ -162,12 +166,12 @@ static int StrlenExpanded(connection_struct *conn, int snum, char *s)
if (!buf) {
return 0;
}
buf = talloc_string_sub(ctx,buf,"%S",lp_servicename(ctx, snum));
buf = talloc_string_sub(ctx,buf,"%S",lp_servicename(ctx, lp_sub, snum));
if (!buf) {
return 0;
}
buf = talloc_sub_full(ctx,
lp_servicename(ctx, SNUM(conn)),
lp_servicename(ctx, lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name,
conn->connectpath,
conn->session_info->unix_token->gid,
@ -1949,7 +1953,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel,
baseaddr = p;
}
push_ascii(p,lp_servicename(talloc_tos(), snum),13, STR_TERMINATE);
push_ascii(p,lp_servicename(talloc_tos(), lp_sub, snum),13, STR_TERMINATE);
if (uLevel > 0) {
int type;
@ -2076,6 +2080,8 @@ static bool api_RNetShareEnum(struct smbd_server_connection *sconn,
int *rdata_len,
int *rparam_len )
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *str1 = get_safe_str_ptr(param,tpscnt,param,2);
char *str2 = skip_string(param,tpscnt,str1);
char *p = skip_string(param,tpscnt,str2);
@ -2113,7 +2119,7 @@ static bool api_RNetShareEnum(struct smbd_server_connection *sconn,
if (!(lp_browseable(i) && lp_snum_ok(i))) {
continue;
}
push_ascii_fstring(servicename_dos, lp_servicename(talloc_tos(), i));
push_ascii_fstring(servicename_dos, lp_servicename(talloc_tos(), lp_sub, i));
/* Maximum name length = 13. */
if( lp_browseable( i ) && lp_snum_ok( i ) && (strlen(servicename_dos) < 13)) {
total++;
@ -2146,7 +2152,7 @@ static bool api_RNetShareEnum(struct smbd_server_connection *sconn,
}
push_ascii_fstring(servicename_dos,
lp_servicename(talloc_tos(), i));
lp_servicename(talloc_tos(), lp_sub, i));
if (lp_browseable(i) && lp_snum_ok(i) && (strlen(servicename_dos) < 13)) {
if (fill_share_info( conn,i,uLevel,&p,&f_len,&p2,&s_len,*rdata ) < 0) {
break;

View File

@ -61,6 +61,8 @@ static NTSTATUS parse_dfs_path(connection_struct *conn,
struct dfs_path *pdp, /* MUST BE TALLOCED */
bool *ppath_contains_wcard)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *pathname_local;
char *p,*temp;
char *servicename;
@ -162,9 +164,9 @@ static NTSTATUS parse_dfs_path(connection_struct *conn,
}
/* Is this really our servicename ? */
if (conn && !( strequal(servicename, lp_servicename(talloc_tos(), SNUM(conn)))
if (conn && !( strequal(servicename, lp_servicename(talloc_tos(), lp_sub, SNUM(conn)))
|| (strequal(servicename, HOMES_NAME)
&& strequal(lp_servicename(talloc_tos(), SNUM(conn)),
&& strequal(lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
get_current_username()) )) ) {
DEBUG(10,("parse_dfs_path: %s is not our servicename\n",
servicename));
@ -872,6 +874,8 @@ static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
char **pp_path_out,
bool *ppath_contains_wcard)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
NTSTATUS status;
bool search_wcard_flag = (ucf_flags &
(UCF_COND_ALLOW_WCARD_LCOMP|UCF_ALWAYS_ALLOW_WCARD_LCOMP));
@ -923,9 +927,9 @@ static NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
if (!( strequal(pdp->servicename, lp_servicename(talloc_tos(), SNUM(conn)))
if (!( strequal(pdp->servicename, lp_servicename(talloc_tos(), lp_sub, SNUM(conn)))
|| (strequal(pdp->servicename, HOMES_NAME)
&& strequal(lp_servicename(talloc_tos(), SNUM(conn)),
&& strequal(lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->sanitized_username) )) ) {
/* The given sharename doesn't match this connection. */
@ -1598,7 +1602,7 @@ static int form_junctions(TALLOC_CTX *ctx,
const char *dname = NULL;
char *talloced = NULL;
const char *connect_path = lp_path(frame, lp_sub, snum);
char *service_name = lp_servicename(frame, snum);
char *service_name = lp_servicename(frame, lp_sub, snum);
const char *msdfs_proxy = lp_msdfs_proxy(frame, lp_sub, snum);
struct conn_struct_tos *c = NULL;
connection_struct *conn = NULL;

View File

@ -2603,6 +2603,8 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
uint32_t data_count,
uint32_t max_data_count)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
NTSTATUS nt_status = NT_STATUS_OK;
char *params = *ppparams;
char *pdata = *ppdata;
@ -2625,7 +2627,7 @@ static void call_nt_transact_get_user_quota(connection_struct *conn,
/* access check */
if (get_current_uid(conn) != sec_initial_uid()) {
DEBUG(1,("get_user_quota: access_denied service [%s] user "
"[%s]\n", lp_servicename(talloc_tos(), SNUM(conn)),
"[%s]\n", lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name));
nt_status = NT_STATUS_ACCESS_DENIED;
goto error;
@ -2733,6 +2735,8 @@ static void call_nt_transact_set_user_quota(connection_struct *conn,
uint32_t data_count,
uint32_t max_data_count)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *params = *ppparams;
char *pdata = *ppdata;
int data_len=0,param_len=0;
@ -2749,7 +2753,7 @@ static void call_nt_transact_set_user_quota(connection_struct *conn,
/* access check */
if (get_current_uid(conn) != sec_initial_uid()) {
DEBUG(1,("set_user_quota: access_denied service [%s] user "
"[%s]\n", lp_servicename(talloc_tos(), SNUM(conn)),
"[%s]\n", lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name));
status = NT_STATUS_ACCESS_DENIED;
goto error;

View File

@ -4049,6 +4049,8 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
struct smb_filename *smb_dname,
uint32_t file_attributes)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
mode_t mode;
char *parent_dir = NULL;
NTSTATUS status;
@ -4059,7 +4061,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
if (!CAN_WRITE(conn) || (access_mask & ~(conn->share_access))) {
DEBUG(5,("mkdir_internal: failing share access "
"%s\n", lp_servicename(talloc_tos(), SNUM(conn))));
"%s\n", lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
return NT_STATUS_ACCESS_DENIED;
}

View File

@ -1503,6 +1503,8 @@ static void smb1srv_update_crypto_flags(struct smbXsrv_session *session,
static connection_struct *switch_message(uint8_t type, struct smb_request *req)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int flags;
uint64_t session_tag;
connection_struct *conn = NULL;
@ -1671,7 +1673,7 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req)
if (req->cmd != SMBtrans2 && req->cmd != SMBtranss2) {
DEBUG(1,("service[%s] requires encryption"
"%s ACCESS_DENIED. mid=%llu\n",
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
smb_fn_name(type),
(unsigned long long)req->mid));
reply_nterror(req, NT_STATUS_ACCESS_DENIED);

View File

@ -868,6 +868,8 @@ void reply_tcon(struct smb_request *req)
void reply_tcon_and_X(struct smb_request *req)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
connection_struct *conn = req->conn;
const char *service = NULL;
TALLOC_CTX *ctx = talloc_tos();
@ -1142,7 +1144,7 @@ void reply_tcon_and_X(struct smb_request *req)
if (lp_msdfs_root(SNUM(conn)) && lp_host_msdfs()) {
DEBUG(2,("Serving %s as a Dfs root\n",
lp_servicename(ctx, SNUM(conn)) ));
lp_servicename(ctx, lp_sub, SNUM(conn)) ));
optional_support |= SMB_SHARE_IN_DFS;
}
@ -1183,6 +1185,8 @@ void reply_unknown_new(struct smb_request *req, uint8_t type)
void reply_ioctl(struct smb_request *req)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
connection_struct *conn = req->conn;
uint16_t device;
uint16_t function;
@ -1249,6 +1253,7 @@ void reply_ioctl(struct smb_request *req)
status = srvstr_push((char *)req->outbuf, req->flags2,
p+18,
lp_servicename(talloc_tos(),
lp_sub,
SNUM(conn)),
13, STR_TERMINATE|STR_ASCII, &len);
if (!NT_STATUS_IS_OK(status)) {
@ -6210,6 +6215,8 @@ void reply_printclose(struct smb_request *req)
void reply_printqueue(struct smb_request *req)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
connection_struct *conn = req->conn;
int max_count;
int start_index;
@ -6248,7 +6255,7 @@ void reply_printqueue(struct smb_request *req)
TALLOC_CTX *mem_ctx = talloc_tos();
NTSTATUS status;
WERROR werr;
const char *sharename = lp_servicename(mem_ctx, SNUM(conn));
const char *sharename = lp_servicename(mem_ctx, lp_sub, SNUM(conn));
struct rpc_pipe_client *cli = NULL;
struct dcerpc_binding_handle *b = NULL;
struct policy_handle handle;

View File

@ -922,6 +922,8 @@ static connection_struct *make_connection_smb1(struct smb_request *req,
const char *pdev,
NTSTATUS *pstatus)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct smbXsrv_tcon *tcon;
NTSTATUS status;
struct connection_struct *conn;
@ -957,7 +959,7 @@ static connection_struct *make_connection_smb1(struct smb_request *req,
return NULL;
}
tcon->global->share_name = lp_servicename(tcon->global, SNUM(conn));
tcon->global->share_name = lp_servicename(tcon->global, lp_sub, SNUM(conn));
if (tcon->global->share_name == NULL) {
conn_free(conn);
TALLOC_FREE(tcon);

View File

@ -194,9 +194,12 @@ bool token_contains_name_in_list(const char *username,
bool user_ok_token(const char *username, const char *domain,
const struct security_token *token, int snum)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
if (lp_invalid_users(snum) != NULL) {
if (token_contains_name_in_list(username, domain,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
token,
lp_invalid_users(snum))) {
DEBUG(10, ("User %s in 'invalid users'\n", username));
@ -206,7 +209,7 @@ bool user_ok_token(const char *username, const char *domain,
if (lp_valid_users(snum) != NULL) {
if (!token_contains_name_in_list(username, domain,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
token,
lp_valid_users(snum))) {
DEBUG(10, ("User %s not in 'valid users'\n",
@ -216,7 +219,7 @@ bool user_ok_token(const char *username, const char *domain,
}
DEBUG(10, ("user_ok_token: share %s is ok for unix user %s\n",
lp_servicename(talloc_tos(), snum), username));
lp_servicename(talloc_tos(), lp_sub, snum), username));
return True;
}
@ -240,12 +243,14 @@ bool is_share_read_only_for_token(const char *username,
const struct security_token *token,
connection_struct *conn)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int snum = SNUM(conn);
bool result = conn->read_only;
if (lp_read_list(snum) != NULL) {
if (token_contains_name_in_list(username, domain,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
token,
lp_read_list(snum))) {
result = True;
@ -254,7 +259,7 @@ bool is_share_read_only_for_token(const char *username,
if (lp_write_list(snum) != NULL) {
if (token_contains_name_in_list(username, domain,
lp_servicename(talloc_tos(), snum),
lp_servicename(talloc_tos(), lp_sub, snum),
token,
lp_write_list(snum))) {
result = False;
@ -262,7 +267,7 @@ bool is_share_read_only_for_token(const char *username,
}
DEBUG(10,("is_share_read_only_for_user: share %s is %s for unix user "
"%s\n", lp_servicename(talloc_tos(), snum),
"%s\n", lp_servicename(talloc_tos(), lp_sub, snum),
result ? "read-only" : "read-write", username));
return result;

View File

@ -261,7 +261,7 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
snum = compat_vuser->homes_snum;
} else if ((compat_vuser->homes_snum != -1)
&& strequal(service,
lp_servicename(talloc_tos(), compat_vuser->homes_snum))) {
lp_servicename(talloc_tos(), lp_sub, compat_vuser->homes_snum))) {
snum = compat_vuser->homes_snum;
} else {
snum = find_service(talloc_tos(), service, &service);
@ -341,6 +341,7 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
}
tcon->global->share_name = lp_servicename(tcon->global,
lp_sub,
SNUM(compat_conn));
if (tcon->global->share_name == NULL) {
conn_free(compat_conn);

View File

@ -3522,7 +3522,10 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
unsigned char *create_volume_objectid(connection_struct *conn, unsigned char objid[16])
{
E_md4hash(lp_servicename(talloc_tos(), SNUM(conn)),objid);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
E_md4hash(lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),objid);
return objid;
}
@ -3572,6 +3575,8 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
char **ppdata,
int *ret_data_len)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *pdata, *end_data;
int data_len = 0;
size_t len = 0;
@ -3680,7 +3685,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
* Add volume serial number - hash of a combination of
* the called hostname and the service name.
*/
SIVAL(pdata,0,str_checksum(lp_servicename(talloc_tos(), snum)) ^ (str_checksum(get_local_machine_name())<<16) );
SIVAL(pdata,0,str_checksum(lp_servicename(talloc_tos(), lp_sub, snum)) ^ (str_checksum(get_local_machine_name())<<16) );
/*
* Win2k3 and previous mess this up by sending a name length
* one byte short. I believe only older clients (OS/2 Win9x) use
@ -3762,7 +3767,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
* Add volume serial number - hash of a combination of
* the called hostname and the service name.
*/
SIVAL(pdata,8,str_checksum(lp_servicename(talloc_tos(), snum)) ^
SIVAL(pdata,8,str_checksum(lp_servicename(talloc_tos(), lp_sub, snum)) ^
(str_checksum(get_local_machine_name())<<16));
/* Max label len is 32 characters. */
@ -3777,7 +3782,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
DEBUG(5,("smbd_do_qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol=%s serv=%s\n",
(int)strlen(vname),vname,
lp_servicename(talloc_tos(), snum)));
lp_servicename(talloc_tos(), lp_sub, snum)));
if (max_data_bytes >= 24 && data_len > max_data_bytes) {
/* the client only requested a portion of the
volume label */
@ -3910,7 +3915,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
if (get_current_uid(conn) != 0) {
DEBUG(0,("get_user_quota: access_denied "
"service [%s] user [%s]\n",
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name));
return NT_STATUS_ACCESS_DENIED;
}
@ -3918,14 +3923,14 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
status = vfs_get_ntquota(&fsp, SMB_USER_FS_QUOTA_TYPE,
NULL, &quotas);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("vfs_get_ntquota() failed for service [%s]\n",lp_servicename(talloc_tos(), SNUM(conn))));
DEBUG(0,("vfs_get_ntquota() failed for service [%s]\n",lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
return status;
}
data_len = 48;
DEBUG(10,("SMB_FS_QUOTA_INFORMATION: for service [%s]\n",
lp_servicename(talloc_tos(), SNUM(conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
/* Unknown1 24 NULL bytes*/
SBIG_UINT(pdata,0,(uint64_t)0);
@ -4071,7 +4076,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
return NT_STATUS_INVALID_LEVEL;
#endif /* EOPNOTSUPP */
} else {
DEBUG(0,("vfs_statvfs() failed for service [%s]\n",lp_servicename(talloc_tos(), SNUM(conn))));
DEBUG(0,("vfs_statvfs() failed for service [%s]\n",lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
return NT_STATUS_DOS(ERRSRV, ERRerror);
}
break;
@ -4202,6 +4207,8 @@ static NTSTATUS smb_set_fsquota(connection_struct *conn,
files_struct *fsp,
const DATA_BLOB *qdata)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
NTSTATUS status;
SMB_NTQUOTA_STRUCT quotas;
@ -4210,7 +4217,7 @@ static NTSTATUS smb_set_fsquota(connection_struct *conn,
/* access check */
if ((get_current_uid(conn) != 0) || !CAN_WRITE(conn)) {
DEBUG(3, ("set_fsquota: access_denied service [%s] user [%s]\n",
lp_servicename(talloc_tos(), SNUM(conn)),
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
conn->session_info->unix_info->unix_name));
return NT_STATUS_ACCESS_DENIED;
}
@ -4247,7 +4254,7 @@ static NTSTATUS smb_set_fsquota(connection_struct *conn,
/* now set the quotas */
if (vfs_set_ntquota(fsp, SMB_USER_FS_QUOTA_TYPE, NULL, &quotas)!=0) {
DEBUG(1, ("vfs_set_ntquota() failed for service [%s]\n",
lp_servicename(talloc_tos(), SNUM(conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
status = map_nt_error_from_unix(errno);
} else {
status = NT_STATUS_OK;
@ -4343,13 +4350,15 @@ static void call_trans2setfsinfo(connection_struct *conn,
char **ppdata, int total_data,
unsigned int max_data_bytes)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
struct smbXsrv_connection *xconn = req->xconn;
char *pdata = *ppdata;
char *params = *pparams;
uint16_t info_level;
DEBUG(10,("call_trans2setfsinfo: for service [%s]\n",
lp_servicename(talloc_tos(), SNUM(conn))));
lp_servicename(talloc_tos(), lp_sub, SNUM(conn))));
/* */
if (total_params < 4) {
@ -9667,6 +9676,8 @@ static void call_trans2ioctl(connection_struct *conn,
char **ppdata, int total_data,
unsigned int max_data_bytes)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
char *pdata = *ppdata;
files_struct *fsp = file_fsp(req, SVAL(req->vwv+15, 0));
NTSTATUS status;
@ -9702,7 +9713,7 @@ static void call_trans2ioctl(connection_struct *conn,
return;
}
status = srvstr_push(pdata, req->flags2, pdata+18,
lp_servicename(talloc_tos(), SNUM(conn)), 13,
lp_servicename(talloc_tos(), lp_sub, SNUM(conn)), 13,
STR_ASCII|STR_TERMINATE, &len); /* Service name */
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);

View File

@ -104,7 +104,10 @@ static NTSTATUS cmd_show_data(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar
static NTSTATUS cmd_connect(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
SMB_VFS_CONNECT(vfs->conn, lp_servicename(talloc_tos(), SNUM(vfs->conn)), "vfstest");
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
SMB_VFS_CONNECT(vfs->conn, lp_servicename(talloc_tos(), lp_sub, SNUM(vfs->conn)), "vfstest");
return NT_STATUS_OK;
}

View File

@ -534,7 +534,9 @@ int main(int argc, const char *argv[])
for (i=0; i<lp_numservices(); i++) {
TALLOC_CTX *frame = talloc_stackframe();
const char *service = lp_servicename(frame, i);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *service = lp_servicename(frame, lp_sub, i);
if (service == NULL) {
continue;

View File

@ -532,6 +532,8 @@ static int do_global_checks(void)
*/
static void do_per_share_checks(int s)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char **deny_list = lp_hosts_deny(s);
const char **allow_list = lp_hosts_allow(s);
const char **vfs_objects = NULL;
@ -550,7 +552,7 @@ static void do_per_share_checks(int s)
"(%s) for service %s.\n\n",
hasstar ? *hasstar : *hasquery,
deny_list[i],
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
}
}
@ -565,7 +567,7 @@ static void do_per_share_checks(int s)
"list (%s) for service %s.\n\n",
hasstar ? *hasstar : *hasquery,
allow_list[i],
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
}
}
@ -574,7 +576,7 @@ static void do_per_share_checks(int s)
fprintf(stderr, "Invalid combination of parameters for service "
"%s. Level II oplocks can only be set if oplocks "
"are also set.\n\n",
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
if (!lp_store_dos_attributes(s) && lp_map_hidden(s)
@ -584,7 +586,7 @@ static void do_per_share_checks(int s)
"Invalid combination of parameters for service %s. Map "
"hidden can only work if create mask includes octal "
"01 (S_IXOTH).\n\n",
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
if (!lp_store_dos_attributes(s) && lp_map_hidden(s)
&& (lp_force_create_mode(s) & S_IXOTH))
@ -593,7 +595,7 @@ static void do_per_share_checks(int s)
"Invalid combination of parameters for service "
"%s. Map hidden can only work if force create mode "
"excludes octal 01 (S_IXOTH).\n\n",
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
if (!lp_store_dos_attributes(s) && lp_map_system(s)
&& !(lp_create_mask(s) & S_IXGRP))
@ -602,7 +604,7 @@ static void do_per_share_checks(int s)
"Invalid combination of parameters for service "
"%s. Map system can only work if create mask includes "
"octal 010 (S_IXGRP).\n\n",
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
if (!lp_store_dos_attributes(s) && lp_map_system(s)
&& (lp_force_create_mode(s) & S_IXGRP))
@ -611,13 +613,13 @@ static void do_per_share_checks(int s)
"Invalid combination of parameters for service "
"%s. Map system can only work if force create mode "
"excludes octal 010 (S_IXGRP).\n\n",
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
if (lp_printing(s) == PRINT_CUPS && *(lp_print_command(s)) != '\0') {
fprintf(stderr,
"Warning: Service %s defines a print command, but "
"parameter is ignored when using CUPS libraries.\n\n",
lp_servicename(talloc_tos(), s));
lp_servicename(talloc_tos(), lp_sub, s));
}
vfs_objects = lp_vfs_objects(s);
@ -638,6 +640,8 @@ static void do_per_share_checks(int s)
int main(int argc, const char *argv[])
{
const char *config_file = get_dyn_CONFIGFILE();
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
int s;
static int silent_mode = False;
static int show_all_parameters = False;
@ -817,10 +821,10 @@ static void do_per_share_checks(int s)
if (allow_access(lp_hosts_deny(-1), lp_hosts_allow(-1), cname, caddr)
&& allow_access(lp_hosts_deny(s), lp_hosts_allow(s), cname, caddr)) {
fprintf(stderr,"Allow connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(talloc_tos(), s));
cname,caddr,lp_servicename(talloc_tos(), lp_sub, s));
} else {
fprintf(stderr,"Deny connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(talloc_tos(), s));
cname,caddr,lp_servicename(talloc_tos(), lp_sub, s));
}
}
}