The Samba-Bugzilla – Attachment 15613 Details for
Bug 13745
print command %J substitution
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.10 and 4.11 backported from master
bug13745-v410,v411.patch (text/plain), 30.30 KB, created by
Ralph Böhme
on 2019-11-07 20:03:38 UTC
(
hide
)
Description:
Patch for 4.10 and 4.11 backported from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2019-11-07 20:03:38 UTC
Size:
30.30 KB
patch
obsolete
>From b83d9f4cbba6622cd201b0d5ba0cc131772bb1c5 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 12:43:25 +0100 >Subject: [PATCH 1/7] s3:printing: fix a long line > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit dcb555c06a6341871b691dab3758e7de04110282) >--- > source3/printing/printing.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/source3/printing/printing.c b/source3/printing/printing.c >index e6caaa1222f..42036a56bb5 100644 >--- a/source3/printing/printing.c >+++ b/source3/printing/printing.c >@@ -2867,7 +2867,8 @@ WERROR print_job_start(const struct auth_session_info *server_info, > fstrcpy(pjob.clientmachine, clientmachine); > > fstrcpy(pjob.user, lp_printjob_username(snum)); >- standard_sub_advanced(sharename, server_info->unix_info->sanitized_username, >+ standard_sub_advanced(sharename, >+ server_info->unix_info->sanitized_username, > path, server_info->unix_token->gid, > server_info->unix_info->sanitized_username, > server_info->info->domain_name, >-- >2.23.0 > > >From 4962a1d94475b2f0c85d07ccfc36ea7e673cc108 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 12:44:45 +0100 >Subject: [PATCH 2/7] s3: replace standard_sub_advanced with > talloc_sub_advanced in one place > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 81ae199bb72886f2f1ed87b22b4c75b6b99c72f6) >--- > source3/printing/printing.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > >diff --git a/source3/printing/printing.c b/source3/printing/printing.c >index 42036a56bb5..0ad07046850 100644 >--- a/source3/printing/printing.c >+++ b/source3/printing/printing.c >@@ -2819,7 +2819,7 @@ WERROR print_job_start(const struct auth_session_info *server_info, > struct spoolss_DeviceMode *devmode, uint32_t *_jobid) > { > uint32_t jobid; >- char *path; >+ char *path = NULL, *userstr = NULL; > struct printjob pjob; > const char *sharename = lp_const_servicename(snum); > struct tdb_print_db *pdb = get_print_db_byname(sharename); >@@ -2866,13 +2866,19 @@ WERROR print_job_start(const struct auth_session_info *server_info, > > fstrcpy(pjob.clientmachine, clientmachine); > >- fstrcpy(pjob.user, lp_printjob_username(snum)); >- standard_sub_advanced(sharename, >+ userstr = talloc_sub_advanced(talloc_tos(), >+ sharename, > server_info->unix_info->sanitized_username, > path, server_info->unix_token->gid, > server_info->unix_info->sanitized_username, > server_info->info->domain_name, >- pjob.user, sizeof(pjob.user)); >+ lp_printjob_username(snum)); >+ if (userstr == NULL) { >+ werr = WERR_NOT_ENOUGH_MEMORY; >+ goto fail; >+ } >+ strlcpy(pjob.user, userstr, sizeof(pjob.user)); >+ TALLOC_FREE(userstr); > > fstrcpy(pjob.queuename, lp_const_servicename(snum)); > >-- >2.23.0 > > >From 9aab19a80919dda6feb9c8bc932e22f35a0fc45f Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 10:19:13 +0100 >Subject: [PATCH 3/7] s3: remove unused function standard_sub_advanced() > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit a591de28659919d2afd7ed55106cded6a0d9ab35) >--- > source3/include/proto.h | 4 ---- > source3/lib/substitute.c | 16 ---------------- > 2 files changed, 20 deletions(-) > >diff --git a/source3/include/proto.h b/source3/include/proto.h >index cb8890d340b..60db3aaa4a1 100644 >--- a/source3/include/proto.h >+++ b/source3/include/proto.h >@@ -185,10 +185,6 @@ char *talloc_sub_advanced(TALLOC_CTX *mem_ctx, > const char *connectpath, gid_t gid, > const char *smb_name, const char *domain_name, > const char *str); >-void standard_sub_advanced(const char *servicename, const char *user, >- const char *connectpath, gid_t gid, >- const char *smb_name, const char *domain_name, >- char *str, size_t len); > > /* The following definitions come from lib/sysquotas.c */ > >diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c >index ea227c5ab68..a6af5deb381 100644 >--- a/source3/lib/substitute.c >+++ b/source3/lib/substitute.c >@@ -863,22 +863,6 @@ char *talloc_sub_advanced(TALLOC_CTX *ctx, > return ret_string; > } > >-void standard_sub_advanced(const char *servicename, const char *user, >- const char *connectpath, gid_t gid, >- const char *smb_name, const char *domain_name, >- char *str, size_t len) >-{ >- char *s = talloc_sub_advanced(talloc_tos(), >- servicename, user, connectpath, >- gid, smb_name, domain_name, str); >- >- if (!s) { >- return; >- } >- strlcpy( str, s, len ); >- TALLOC_FREE( s ); >-} >- > /****************************************************************************** > version of standard_sub_basic() for string lists; uses talloc_sub_basic() > for the work >-- >2.23.0 > > >From dd25fc5b2a599b1f89f99417afa059b81a492690 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 12:45:44 +0100 >Subject: [PATCH 4/7] s3: rename talloc_sub_advanced() to talloc_sub_full() > >We currently have the following substitution functions: > > talloc_sub_basic() > talloc_sub_advanced() > >talloc_sub_basic() currently substitutes a subset of talloc_sub_advanced(). > >We'll need a function X that only substitutes what talloc_sub_advanced() >substitutes *without* what talloc_sub_basic() does. > >To get there rename talloc_sub_advanced() to talloc_sub_full(). A subsequent >commit will then bring back talloc_sub_advanced() as described above. > >Examples with fictional replacement letters A and B. Currently: > > talloc_sub_basic: A > talloc_sub_advanced: AB > >New: > > talloc_sub_basic: A > talloc_sub_advanced: B > talloc_sub_full: AB > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(backported from commit 4736623c24503b3ca09c76c9dbb134ef833b2f80) >--- > source3/include/proto.h | 2 +- > source3/lib/substitute.c | 4 ++-- > source3/modules/vfs_expand_msdfs.c | 2 +- > source3/modules/vfs_full_audit.c | 2 +- > source3/modules/vfs_recycle.c | 2 +- > source3/modules/vfs_virusfilter_utils.c | 2 +- > source3/printing/print_generic.c | 2 +- > source3/printing/printing.c | 8 ++++---- > source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 10 +++++----- > source3/smbd/lanman.c | 4 ++-- > source3/smbd/service.c | 10 +++++----- > 11 files changed, 24 insertions(+), 24 deletions(-) > >diff --git a/source3/include/proto.h b/source3/include/proto.h >index 60db3aaa4a1..b508022925e 100644 >--- a/source3/include/proto.h >+++ b/source3/include/proto.h >@@ -180,7 +180,7 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, > const char *domain, > uid_t uid, > gid_t gid); >-char *talloc_sub_advanced(TALLOC_CTX *mem_ctx, >+char *talloc_sub_full(TALLOC_CTX *mem_ctx, > const char *servicename, const char *user, > const char *connectpath, gid_t gid, > const char *smb_name, const char *domain_name, >diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c >index a6af5deb381..80fc43e35c9 100644 >--- a/source3/lib/substitute.c >+++ b/source3/lib/substitute.c >@@ -790,7 +790,7 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, > /**************************************************************************** > ****************************************************************************/ > >-char *talloc_sub_advanced(TALLOC_CTX *ctx, >+char *talloc_sub_full(TALLOC_CTX *ctx, > const char *servicename, > const char *user, > const char *connectpath, >@@ -804,7 +804,7 @@ char *talloc_sub_advanced(TALLOC_CTX *ctx, > > a_string = talloc_strdup(talloc_tos(), str); > if (a_string == NULL) { >- DEBUG(0, ("talloc_sub_advanced: Out of memory!\n")); >+ DBG_ERR("Out of memory!\n"); > return NULL; > } > >diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c >index 598da08c0c8..ccd124ac617 100644 >--- a/source3/modules/vfs_expand_msdfs.c >+++ b/source3/modules/vfs_expand_msdfs.c >@@ -154,7 +154,7 @@ static char *expand_msdfs_target(TALLOC_CTX *ctx, > return NULL; > } > >- targethost = talloc_sub_advanced(ctx, >+ targethost = talloc_sub_full(ctx, > lp_servicename(talloc_tos(), SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c >index f6e11516970..a442563115c 100644 >--- a/source3/modules/vfs_full_audit.c >+++ b/source3/modules/vfs_full_audit.c >@@ -485,7 +485,7 @@ static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn) > if (!prefix) { > return NULL; > } >- result = talloc_sub_advanced(ctx, >+ result = talloc_sub_full(ctx, > lp_servicename(talloc_tos(), SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c >index e84f0351c87..0b7b820f18b 100644 >--- a/source3/modules/vfs_recycle.c >+++ b/source3/modules/vfs_recycle.c >@@ -460,7 +460,7 @@ static int recycle_unlink(vfs_handle_struct *handle, > bool exist; > int rc = -1; > >- repository = talloc_sub_advanced(NULL, lp_servicename(talloc_tos(), SNUM(conn)), >+ repository = talloc_sub_full(NULL, lp_servicename(talloc_tos(), SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, > conn->session_info->unix_token->gid, >diff --git a/source3/modules/vfs_virusfilter_utils.c b/source3/modules/vfs_virusfilter_utils.c >index f56fc6ed5d8..8ec61a0c8f2 100644 >--- a/source3/modules/vfs_virusfilter_utils.c >+++ b/source3/modules/vfs_virusfilter_utils.c >@@ -35,7 +35,7 @@ char *virusfilter_string_sub( > connection_struct *conn, > const char *str) > { >- return talloc_sub_advanced(mem_ctx, >+ return talloc_sub_full(mem_ctx, > lp_servicename(mem_ctx, SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c >index b6b50062caf..9c47d3ff7a5 100644 >--- a/source3/printing/print_generic.c >+++ b/source3/printing/print_generic.c >@@ -72,7 +72,7 @@ static int print_run_command(int snum, const char* printername, bool do_sub, > } > > if (do_sub && snum != -1) { >- syscmd = talloc_sub_advanced(ctx, >+ syscmd = talloc_sub_full(ctx, > lp_servicename(talloc_tos(), snum), > current_user_info.unix_name, > "", >diff --git a/source3/printing/printing.c b/source3/printing/printing.c >index 0ad07046850..c6bf6ec69dd 100644 >--- a/source3/printing/printing.c >+++ b/source3/printing/printing.c >@@ -1724,7 +1724,7 @@ static void print_queue_update(struct messaging_context *msg_ctx, > if (!lpqcommand) { > return; > } >- lpqcommand = talloc_sub_advanced(ctx, >+ lpqcommand = talloc_sub_full(ctx, > lp_servicename(talloc_tos(), snum), > current_user_info.unix_name, > "", >@@ -1744,7 +1744,7 @@ static void print_queue_update(struct messaging_context *msg_ctx, > if (!lprmcommand) { > return; > } >- lprmcommand = talloc_sub_advanced(ctx, >+ lprmcommand = talloc_sub_full(ctx, > lp_servicename(talloc_tos(), snum), > current_user_info.unix_name, > "", >@@ -2866,7 +2866,7 @@ WERROR print_job_start(const struct auth_session_info *server_info, > > fstrcpy(pjob.clientmachine, clientmachine); > >- userstr = talloc_sub_advanced(talloc_tos(), >+ userstr = talloc_sub_full(talloc_tos(), > sharename, > server_info->unix_info->sanitized_username, > path, server_info->unix_token->gid, >@@ -3035,7 +3035,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum, > status = NT_STATUS_PRINT_CANCELLED; > goto fail; > } >- lpq_cmd = talloc_sub_advanced(tmp_ctx, >+ lpq_cmd = talloc_sub_full(tmp_ctx, > lp_servicename(talloc_tos(), snum), > current_user_info.unix_name, > "", >diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c >index 6246a61672e..3af4cef4bc0 100644 >--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c >+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c >@@ -225,7 +225,7 @@ static void init_srv_share_info_1(struct pipes_struct *p, > char *remark = lp_comment(p->mem_ctx, snum); > > if (remark) { >- remark = talloc_sub_advanced( >+ remark = talloc_sub_full( > p->mem_ctx, lp_servicename(talloc_tos(), snum), > get_current_username(), lp_path(talloc_tos(), snum), > p->session_info->unix_token->uid, get_current_username(), >@@ -253,7 +253,7 @@ static void init_srv_share_info_2(struct pipes_struct *p, > > remark = lp_comment(p->mem_ctx, snum); > if (remark) { >- remark = talloc_sub_advanced( >+ remark = talloc_sub_full( > p->mem_ctx, lp_servicename(talloc_tos(), snum), > get_current_username(), lp_path(talloc_tos(), snum), > p->session_info->unix_token->uid, get_current_username(), >@@ -318,7 +318,7 @@ static void init_srv_share_info_501(struct pipes_struct *p, > char *remark = lp_comment(p->mem_ctx, snum); > > if (remark) { >- remark = talloc_sub_advanced( >+ remark = talloc_sub_full( > p->mem_ctx, lp_servicename(talloc_tos(), snum), > get_current_username(), lp_path(talloc_tos(), snum), > p->session_info->unix_token->uid, get_current_username(), >@@ -352,7 +352,7 @@ static void init_srv_share_info_502(struct pipes_struct *p, > char *remark = lp_comment(ctx, snum); > > if (remark) { >- remark = talloc_sub_advanced( >+ remark = talloc_sub_full( > p->mem_ctx, lp_servicename(talloc_tos(), snum), > get_current_username(), lp_path(talloc_tos(), snum), > p->session_info->unix_token->uid, get_current_username(), >@@ -393,7 +393,7 @@ static void init_srv_share_info_1004(struct pipes_struct *p, > char *remark = lp_comment(p->mem_ctx, snum); > > if (remark) { >- remark = talloc_sub_advanced( >+ remark = talloc_sub_full( > p->mem_ctx, lp_servicename(talloc_tos(), snum), > get_current_username(), lp_path(talloc_tos(), snum), > p->session_info->unix_token->uid, get_current_username(), >diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c >index 50451b2778d..ee6e9a481e2 100644 >--- a/source3/smbd/lanman.c >+++ b/source3/smbd/lanman.c >@@ -115,7 +115,7 @@ static int CopyExpanded(connection_struct *conn, > *p_space_remaining = 0; > return 0; > } >- buf = talloc_sub_advanced(ctx, >+ buf = talloc_sub_full(ctx, > lp_servicename(ctx, SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >@@ -166,7 +166,7 @@ static int StrlenExpanded(connection_struct *conn, int snum, char *s) > if (!buf) { > return 0; > } >- buf = talloc_sub_advanced(ctx, >+ buf = talloc_sub_full(ctx, > lp_servicename(ctx, SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >diff --git a/source3/smbd/service.c b/source3/smbd/service.c >index d7c85d8b6ca..fd23d1a2d60 100644 >--- a/source3/smbd/service.c >+++ b/source3/smbd/service.c >@@ -583,7 +583,7 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > conn->vuid = vuser->vuid; > > { >- char *s = talloc_sub_advanced(talloc_tos(), >+ char *s = talloc_sub_full(talloc_tos(), > lp_const_servicename(SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >@@ -699,7 +699,7 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > * to below */ > /* execute any "root preexec = " line */ > if (*lp_root_preexec(talloc_tos(), snum)) { >- char *cmd = talloc_sub_advanced(talloc_tos(), >+ char *cmd = talloc_sub_full(talloc_tos(), > lp_const_servicename(SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >@@ -737,7 +737,7 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > > /* execute any "preexec = " line */ > if (*lp_preexec(talloc_tos(), snum)) { >- char *cmd = talloc_sub_advanced(talloc_tos(), >+ char *cmd = talloc_sub_full(talloc_tos(), > lp_const_servicename(SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >@@ -1139,7 +1139,7 @@ void close_cnum(connection_struct *conn, uint64_t vuid) > /* execute any "postexec = " line */ > if (*lp_postexec(talloc_tos(), SNUM(conn)) && > change_to_user(conn, vuid)) { >- char *cmd = talloc_sub_advanced(talloc_tos(), >+ char *cmd = talloc_sub_full(talloc_tos(), > lp_const_servicename(SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >@@ -1155,7 +1155,7 @@ void close_cnum(connection_struct *conn, uint64_t vuid) > change_to_root_user(); > /* execute any "root postexec = " line */ > if (*lp_root_postexec(talloc_tos(), SNUM(conn))) { >- char *cmd = talloc_sub_advanced(talloc_tos(), >+ char *cmd = talloc_sub_full(talloc_tos(), > lp_const_servicename(SNUM(conn)), > conn->session_info->unix_info->unix_name, > conn->connectpath, >-- >2.23.0 > > >From 5c5bba53626f5cbfb0662c763df68e23f8d582ad Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 11:57:39 +0100 >Subject: [PATCH 5/7] s3:lib: factor out talloc_sub_advanced() from > talloc_sub_full() > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 41ab92b62fbf029374b89f9d0ddf7578981f37cf) >--- > source3/include/proto.h | 4 ++++ > source3/lib/substitute.c | 28 +++++++++++++++++++++++----- > 2 files changed, 27 insertions(+), 5 deletions(-) > >diff --git a/source3/include/proto.h b/source3/include/proto.h >index b508022925e..43a4b8f8b4d 100644 >--- a/source3/include/proto.h >+++ b/source3/include/proto.h >@@ -180,6 +180,10 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, > const char *domain, > uid_t uid, > gid_t gid); >+char *talloc_sub_advanced(TALLOC_CTX *mem_ctx, >+ const char *servicename, const char *user, >+ const char *connectpath, gid_t gid, >+ const char *str); > char *talloc_sub_full(TALLOC_CTX *mem_ctx, > const char *servicename, const char *user, > const char *connectpath, gid_t gid, >diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c >index 80fc43e35c9..95369b838ea 100644 >--- a/source3/lib/substitute.c >+++ b/source3/lib/substitute.c >@@ -790,21 +790,19 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx, > /**************************************************************************** > ****************************************************************************/ > >-char *talloc_sub_full(TALLOC_CTX *ctx, >+char *talloc_sub_advanced(TALLOC_CTX *ctx, > const char *servicename, > const char *user, > const char *connectpath, > gid_t gid, >- const char *smb_name, >- const char *domain_name, > const char *str) > { >- char *a_string, *ret_string; >+ char *a_string; > char *b, *p, *s; > > a_string = talloc_strdup(talloc_tos(), str); > if (a_string == NULL) { >- DBG_ERR("Out of memory!\n"); >+ DEBUG(0, ("talloc_sub_advanced_only: Out of memory!\n")); > return NULL; > } > >@@ -858,6 +856,26 @@ char *talloc_sub_full(TALLOC_CTX *ctx, > } > } > >+ return a_string; >+} >+ >+char *talloc_sub_full(TALLOC_CTX *ctx, >+ const char *servicename, >+ const char *user, >+ const char *connectpath, >+ gid_t gid, >+ const char *smb_name, >+ const char *domain_name, >+ const char *str) >+{ >+ char *a_string, *ret_string; >+ >+ a_string = talloc_sub_advanced(ctx, servicename, user, connectpath, >+ gid, str); >+ if (a_string == NULL) { >+ return NULL; >+ } >+ > ret_string = talloc_sub_basic(ctx, smb_name, domain_name, a_string); > TALLOC_FREE(a_string); > return ret_string; >-- >2.23.0 > > >From d043e5a0c1bce0edfd8755764e5da5a1fe1d15dc Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 12:03:31 +0100 >Subject: [PATCH 6/7] s3:printing: add a DEBUG statement > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit ede00779ab2d881e061adb9d861879e8c68e272b) >--- > source3/printing/print_generic.c | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c >index 9c47d3ff7a5..d3c72dd6a9a 100644 >--- a/source3/printing/print_generic.c >+++ b/source3/printing/print_generic.c >@@ -56,6 +56,8 @@ static int print_run_command(int snum, const char* printername, bool do_sub, > return -1; > } > >+ DBG_DEBUG("Incoming command '%s'\n", syscmd); >+ > while ((arg = va_arg(ap, char *))) { > char *value = va_arg(ap,char *); > syscmd = talloc_string_sub(ctx, syscmd, arg, value); >-- >2.23.0 > > >From 5c8a29e66c935bdfe016043a50064c996a777615 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 31 Oct 2019 12:46:38 +0100 >Subject: [PATCH 7/7] s3:printing: Fix %J substition > >print_run_command() uses lp_print_command() which internally performs basic >substition by calling talloc_sub_basic(). As a result. any of the variables in >the "basic set", including "%J" are already substituted. > >To prevent the unwanted subtitution, we declare all affected configuration >options as const, which disabled the basic substition. > >As a result print_run_command() can run manual substitution on all characters, >including %J, in the variadic argument list *before* calling lp_string() to run >basic substition which we had disabled before with the const. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13745 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> > >Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> >Autobuild-Date(master): Thu Nov 7 16:01:21 UTC 2019 on sn-devel-184 > >(cherry picked from commit 8846887a55b0c97a1639fc6ecb228941cf16b8f2) >--- > .../smbdotconf/printing/lppausecommand.xml | 1 + > docs-xml/smbdotconf/printing/lpqcommand.xml | 1 + > .../smbdotconf/printing/lpresumecommand.xml | 1 + > docs-xml/smbdotconf/printing/lprmcommand.xml | 1 + > docs-xml/smbdotconf/printing/printcommand.xml | 1 + > .../smbdotconf/printing/queuepausecommand.xml | 1 + > .../printing/queueresumecommand.xml | 1 + > source3/printing/print_generic.c | 19 +++++++++++-------- > source3/printing/printing.c | 8 ++++---- > source3/utils/testparm.c | 2 +- > 10 files changed, 23 insertions(+), 13 deletions(-) > >diff --git a/docs-xml/smbdotconf/printing/lppausecommand.xml b/docs-xml/smbdotconf/printing/lppausecommand.xml >index 3aa134c4377..f2518d3def0 100644 >--- a/docs-xml/smbdotconf/printing/lppausecommand.xml >+++ b/docs-xml/smbdotconf/printing/lppausecommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="lppause command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>This parameter specifies the command to be >diff --git a/docs-xml/smbdotconf/printing/lpqcommand.xml b/docs-xml/smbdotconf/printing/lpqcommand.xml >index f3c17f286d1..f0161f3448d 100644 >--- a/docs-xml/smbdotconf/printing/lpqcommand.xml >+++ b/docs-xml/smbdotconf/printing/lpqcommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="lpq command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>This parameter specifies the command to be >diff --git a/docs-xml/smbdotconf/printing/lpresumecommand.xml b/docs-xml/smbdotconf/printing/lpresumecommand.xml >index 153ba76a693..2cee574bd73 100644 >--- a/docs-xml/smbdotconf/printing/lpresumecommand.xml >+++ b/docs-xml/smbdotconf/printing/lpresumecommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="lpresume command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>This parameter specifies the command to be >diff --git a/docs-xml/smbdotconf/printing/lprmcommand.xml b/docs-xml/smbdotconf/printing/lprmcommand.xml >index 4b7f3dd75c3..a595c1225c0 100644 >--- a/docs-xml/smbdotconf/printing/lprmcommand.xml >+++ b/docs-xml/smbdotconf/printing/lprmcommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="lprm command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>This parameter specifies the command to be >diff --git a/docs-xml/smbdotconf/printing/printcommand.xml b/docs-xml/smbdotconf/printing/printcommand.xml >index c84e45f404d..42a7188cb9a 100644 >--- a/docs-xml/smbdotconf/printing/printcommand.xml >+++ b/docs-xml/smbdotconf/printing/printcommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="print command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>After a print job has finished spooling to >diff --git a/docs-xml/smbdotconf/printing/queuepausecommand.xml b/docs-xml/smbdotconf/printing/queuepausecommand.xml >index 5dca45657cc..600a2baa621 100644 >--- a/docs-xml/smbdotconf/printing/queuepausecommand.xml >+++ b/docs-xml/smbdotconf/printing/queuepausecommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="queuepause command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>This parameter specifies the command to be >diff --git a/docs-xml/smbdotconf/printing/queueresumecommand.xml b/docs-xml/smbdotconf/printing/queueresumecommand.xml >index 4a573330048..431295a804e 100644 >--- a/docs-xml/smbdotconf/printing/queueresumecommand.xml >+++ b/docs-xml/smbdotconf/printing/queueresumecommand.xml >@@ -1,6 +1,7 @@ > <samba:parameter name="queueresume command" > context="S" > type="string" >+ constant="1" > xmlns:samba="http://www.samba.org/samba/DTD/samba-doc"> > <description> > <para>This parameter specifies the command to be >diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c >index d3c72dd6a9a..574f357c76c 100644 >--- a/source3/printing/print_generic.c >+++ b/source3/printing/print_generic.c >@@ -73,14 +73,17 @@ static int print_run_command(int snum, const char* printername, bool do_sub, > return -1; > } > >+ syscmd = lp_string(ctx, syscmd); >+ if (syscmd == NULL) { >+ return -1; >+ } >+ > if (do_sub && snum != -1) { >- syscmd = talloc_sub_full(ctx, >+ syscmd = talloc_sub_advanced(ctx, > lp_servicename(talloc_tos(), snum), > current_user_info.unix_name, > "", > get_current_gid(NULL), >- get_current_username(), >- current_user_info.domain, > syscmd); > if (!syscmd) { > return -1; >@@ -120,7 +123,7 @@ static int generic_job_pause(int snum, struct printjob *pjob) > /* need to pause the spooled entry */ > slprintf(jobstr, sizeof(jobstr)-1, "%d", pjob->sysjob); > return print_run_command(snum, lp_printername(talloc_tos(), snum), True, >- lp_lppause_command(talloc_tos(), snum), NULL, >+ lp_lppause_command(snum), NULL, > "%j", jobstr, > NULL); > } >@@ -135,7 +138,7 @@ static int generic_job_resume(int snum, struct printjob *pjob) > /* need to pause the spooled entry */ > slprintf(jobstr, sizeof(jobstr)-1, "%d", pjob->sysjob); > return print_run_command(snum, lp_printername(talloc_tos(), snum), True, >- lp_lpresume_command(talloc_tos(), snum), NULL, >+ lp_lpresume_command(snum), NULL, > "%j", jobstr, > NULL); > } >@@ -257,7 +260,7 @@ static int generic_job_submit(int snum, struct printjob *pjob, > > /* send it to the system spooler */ > ret = print_run_command(snum, lp_printername(talloc_tos(), snum), True, >- lp_print_command(talloc_tos(), snum), NULL, >+ lp_print_command(snum), NULL, > "%s", p, > "%J", jobname, > "%f", p, >@@ -310,7 +313,7 @@ static int generic_job_submit(int snum, struct printjob *pjob, > static int generic_queue_pause(int snum) > { > return print_run_command(snum, lp_printername(talloc_tos(), snum), True, >- lp_queuepause_command(talloc_tos(), snum), NULL, NULL); >+ lp_queuepause_command(snum), NULL, NULL); > } > > /**************************************************************************** >@@ -319,7 +322,7 @@ static int generic_queue_pause(int snum) > static int generic_queue_resume(int snum) > { > return print_run_command(snum, lp_printername(talloc_tos(), snum), True, >- lp_queueresume_command(talloc_tos(), snum), NULL, NULL); >+ lp_queueresume_command(snum), NULL, NULL); > } > > /**************************************************************************** >diff --git a/source3/printing/printing.c b/source3/printing/printing.c >index c6bf6ec69dd..0f4db52e011 100644 >--- a/source3/printing/printing.c >+++ b/source3/printing/printing.c >@@ -1717,7 +1717,7 @@ static void print_queue_update(struct messaging_context *msg_ctx, > /* don't strip out characters like '$' from the printername */ > > lpqcommand = talloc_string_sub2(ctx, >- lp_lpq_command(talloc_tos(), snum), >+ lp_lpq_command(snum), > "%p", > lp_printername(talloc_tos(), snum), > false, false, false); >@@ -1737,7 +1737,7 @@ static void print_queue_update(struct messaging_context *msg_ctx, > } > > lprmcommand = talloc_string_sub2(ctx, >- lp_lprm_command(talloc_tos(), snum), >+ lp_lprm_command(snum), > "%p", > lp_printername(talloc_tos(), snum), > false, false, false); >@@ -2199,7 +2199,7 @@ static bool print_job_delete1(struct tevent_context *ev, > { > result = (*(current_printif->job_delete))( > lp_printername(talloc_tos(), snum), >- lp_lprm_command(talloc_tos(), snum), >+ lp_lprm_command(snum), > pjob); > > /* Delete the tdb entry if the delete succeeded or the job hasn't >@@ -3027,7 +3027,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum, > > /* don't strip out characters like '$' from the printername */ > lpq_cmd = talloc_string_sub2(tmp_ctx, >- lp_lpq_command(talloc_tos(), snum), >+ lp_lpq_command(snum), > "%p", > lp_printername(talloc_tos(), snum), > false, false, false); >diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c >index 9ba625da4bf..f4e94b6ef74 100644 >--- a/source3/utils/testparm.c >+++ b/source3/utils/testparm.c >@@ -611,7 +611,7 @@ static void do_per_share_checks(int s) > "excludes octal 010 (S_IXGRP).\n\n", > lp_servicename(talloc_tos(), s)); > } >- if (lp_printing(s) == PRINT_CUPS && *(lp_print_command(talloc_tos(), s)) != '\0') { >+ 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", >-- >2.23.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
slow
:
review?
(
metze
)
asn
:
review+
Actions:
View
Attachments on
bug 13745
:
14933
|
14934
|
15487
|
15504
|
15516
| 15613