From 8e86ac18e7d6c3b3e9c5786138d1c90e699843c8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Oct 2019 16:54:45 +0200 Subject: [PATCH] smbdotconf: mark "comment" with substitution="1" Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- docs-xml/smbdotconf/base/comment.xml | 1 + source3/rpc_server/spoolss/srv_spoolss_nt.c | 12 ++++++--- source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 29 +++++++++++++++------ source3/smbd/lanman.c | 6 +++-- source3/smbd/msdfs.c | 4 ++- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/docs-xml/smbdotconf/base/comment.xml b/docs-xml/smbdotconf/base/comment.xml index b0dd91c8839..c5aba83451a 100644 --- a/docs-xml/smbdotconf/base/comment.xml +++ b/docs-xml/smbdotconf/base/comment.xml @@ -1,6 +1,7 @@ This is a text field that is seen next to a share diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index f32b465afb6..c80996532ad 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -2805,10 +2805,12 @@ static void spoolss_notify_comment(struct messaging_context *msg_ctx, struct spoolss_PrinterInfo2 *pinfo2, TALLOC_CTX *mem_ctx) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); const char *p; if (*pinfo2->comment == '\0') { - p = lp_comment(talloc_tos(), snum); + p = lp_comment(talloc_tos(), lp_sub, snum); } else { p = pinfo2->comment; } @@ -3970,12 +3972,14 @@ static WERROR construct_printer_info1(TALLOC_CTX *mem_ctx, struct spoolss_PrinterInfo1 *r, int snum) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); WERROR result; r->flags = flags; if (info2->comment == NULL || info2->comment[0] == '\0') { - r->comment = lp_comment(mem_ctx, snum); + r->comment = lp_comment(mem_ctx, lp_sub, snum); } else { r->comment = talloc_strdup(mem_ctx, info2->comment); /* saved comment */ } @@ -4007,6 +4011,8 @@ static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx, struct spoolss_PrinterInfo2 *r, int snum) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); int count; print_status_struct status; WERROR result; @@ -4033,7 +4039,7 @@ static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx, W_ERROR_HAVE_NO_MEMORY(r->drivername); if (info2->comment[0] == '\0') { - r->comment = lp_comment(mem_ctx, snum); + r->comment = lp_comment(mem_ctx, lp_sub, snum); } else { r->comment = talloc_strdup(mem_ctx, info2->comment); } diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c index c0d74bb7af4..1280cc90f69 100644 --- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c @@ -221,8 +221,10 @@ static void init_srv_share_info_1(struct pipes_struct *p, struct srvsvc_NetShareInfo1 *r, int snum) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); char *net_name = lp_servicename(talloc_tos(), snum); - char *remark = lp_comment(p->mem_ctx, snum); + char *remark = lp_comment(p->mem_ctx, lp_sub, snum); if (remark) { remark = talloc_sub_full( @@ -245,13 +247,15 @@ static void init_srv_share_info_2(struct pipes_struct *p, struct srvsvc_NetShareInfo2 *r, int snum) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); char *remark = NULL; 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); - remark = lp_comment(p->mem_ctx, snum); + remark = lp_comment(p->mem_ctx, lp_sub, snum); if (remark) { remark = talloc_sub_full( p->mem_ctx, lp_servicename(talloc_tos(), snum), @@ -314,8 +318,10 @@ static void map_generic_share_sd_bits(struct security_descriptor *psd) static void init_srv_share_info_501(struct pipes_struct *p, struct srvsvc_NetShareInfo501 *r, int snum) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); const char *net_name = lp_servicename(talloc_tos(), snum); - char *remark = lp_comment(p->mem_ctx, snum); + char *remark = lp_comment(p->mem_ctx, lp_sub, snum); if (remark) { remark = talloc_sub_full( @@ -343,13 +349,15 @@ static void init_srv_share_info_501(struct pipes_struct *p, static void init_srv_share_info_502(struct pipes_struct *p, struct srvsvc_NetShareInfo502 *r, int snum) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); const char *net_name = lp_servicename(talloc_tos(), snum); char *path = NULL; struct security_descriptor *sd = NULL; struct sec_desc_buf *sd_buf = NULL; size_t sd_size = 0; TALLOC_CTX *ctx = p->mem_ctx; - char *remark = lp_comment(ctx, snum); + char *remark = lp_comment(ctx, lp_sub, snum); if (remark) { remark = talloc_sub_full( @@ -390,7 +398,9 @@ static void init_srv_share_info_1004(struct pipes_struct *p, struct srvsvc_NetShareInfo1004 *r, int snum) { - char *remark = lp_comment(p->mem_ctx, snum); + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); + char *remark = lp_comment(p->mem_ctx, lp_sub, snum); if (remark) { remark = talloc_sub_full( @@ -1711,6 +1721,8 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p, WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p, struct srvsvc_NetShareSetInfo *r) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); char *command = NULL; char *share_name = NULL; char *comment = NULL; @@ -1831,7 +1843,7 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p, } pathname = lp_path(ctx, snum); - comment = lp_comment(ctx, snum); + comment = lp_comment(ctx, lp_sub, snum); type = STYPE_DISKTREE; break; case 1006: @@ -1839,7 +1851,7 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p, return WERR_ACCESS_DENIED; case 1501: pathname = lp_path(ctx, snum); - comment = lp_comment(ctx, snum); + comment = lp_comment(ctx, lp_sub, snum); psd = info->info1501->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; @@ -1879,7 +1891,8 @@ WERROR _srvsvc_NetShareSetInfo(struct pipes_struct *p, /* Only call modify function if something changed. */ - if (strcmp(path, lp_path(talloc_tos(), snum)) || strcmp(comment, lp_comment(talloc_tos(), snum)) + if (strcmp(path, lp_path(talloc_tos(), snum)) + || strcmp(comment, lp_comment(talloc_tos(), lp_sub, snum)) || (lp_max_connections(snum) != max_connections) || csc_policy_changed) { diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index ee6e9a481e2..0a3e1073eb6 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -1888,6 +1888,8 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, char** buf, int* buflen, char** stringbuf, int* stringspace, char* baseaddr) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); int struct_len; char* p; char* p2; @@ -1915,7 +1917,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, len = 0; if (uLevel > 0) { - len += StrlenExpanded(conn,snum,lp_comment(talloc_tos(), snum)); + len += StrlenExpanded(conn,snum,lp_comment(talloc_tos(), lp_sub, snum)); } if (uLevel > 1) { len += strlen(lp_path(talloc_tos(), snum)) + 1; @@ -1962,7 +1964,7 @@ static int fill_share_info(connection_struct *conn, int snum, int uLevel, } SSVAL(p,14,type); /* device type */ SIVAL(p,16,PTR_DIFF(p2,baseaddr)); - len += CopyExpanded(conn,snum,&p2,lp_comment(talloc_tos(),snum),&l2); + len += CopyExpanded(conn,snum,&p2,lp_comment(talloc_tos(), lp_sub, snum),&l2); } if (uLevel > 1) { diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index fe8553215a4..7ef368240d5 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -1264,6 +1264,8 @@ bool create_junction(TALLOC_CTX *ctx, bool allow_broken_path, struct junction_map *jucn) { + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); int snum; bool dummy; struct dfs_path *pdp = talloc(ctx,struct dfs_path); @@ -1299,7 +1301,7 @@ bool create_junction(TALLOC_CTX *ctx, jucn->service_name = talloc_strdup(ctx, pdp->servicename); jucn->volume_name = talloc_strdup(ctx, pdp->reqpath); - jucn->comment = lp_comment(ctx, snum); + jucn->comment = lp_comment(ctx, lp_sub, snum); TALLOC_FREE(pdp); if (!jucn->service_name || !jucn->volume_name || ! jucn->comment) {