smbdotconf: mark "printername" with substitution="1"
authorRalph Boehme <slow@samba.org>
Mon, 4 Nov 2019 11:14:34 +0000 (12:14 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 27 Nov 2019 10:25:33 +0000 (10:25 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
docs-xml/smbdotconf/printing/printername.xml
source3/include/proto.h
source3/param/loadparm.c
source3/printing/nt_printing.c
source3/printing/print_cups.c
source3/printing/print_generic.c
source3/printing/print_iprint.c
source3/printing/printing.c
source3/printing/queue_process.c
source3/smbd/server_reload.c

index abe2b2483dcf0c8fa9089cc42f8f49e97cc7d1bd..6b82ef29de1165dec8be42e34e492ee95b9162c5 100644 (file)
@@ -2,6 +2,7 @@
                  context="S"
                  type="string"
                  function="_printername"
+                 substitution="1"
                  xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
  <synonym>printer</synonym>
 <description>
index 5a957c4bd99d16e2918001e40a2bfdc1f68a3ab5..2c22734ae98d62ac22d08dc0f529381b05504438 100644 (file)
@@ -860,7 +860,9 @@ bool lp_preferred_master(void);
 void lp_remove_service(int snum);
 void lp_copy_service(int snum, const char *new_name);
 int lp_default_server_announce(void);
-const char *lp_printername(TALLOC_CTX *ctx, int snum);
+const char *lp_printername(TALLOC_CTX *ctx,
+                          const struct loadparm_substitution *lp_sub,
+                          int snum);
 void lp_set_logfile(const char *name);
 int lp_maxprintjobs(int snum);
 const char *lp_printcapname(void);
index 1d47d74c5f4d19a17d08c7bea6dd3c6ed0fe3ef6..3d6149fd85b11dd61c9ba5e472d1e39942545573 100644 (file)
@@ -4421,9 +4421,12 @@ void lp_remove_service(int snum)
        ServicePtrs[snum]->valid = false;
 }
 
-const char *lp_printername(TALLOC_CTX *ctx, int snum)
+const char *lp_printername(TALLOC_CTX *ctx,
+                          const struct loadparm_substitution *lp_sub,
+                          int snum)
 {
-       const char *ret = lp__printername(ctx, snum);
+       const char *ret = lp__printername(ctx, lp_sub, snum);
+
        if (ret == NULL || *ret == '\0') {
                ret = lp_const_servicename(snum);
        }
index 46d2cea9e48c14b19f39250dca49e653e6a22fad..cd9ca9f945284cddfd8cea7e917151892ba28aeb 100644 (file)
@@ -2243,6 +2243,8 @@ WERROR print_access_check(const struct auth_session_info *session_info,
                          int access_type)
 {
        struct spoolss_security_descriptor *secdesc = NULL;
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        uint32_t access_granted;
        size_t sd_size;
        NTSTATUS status;
@@ -2262,7 +2264,7 @@ WERROR print_access_check(const struct auth_session_info *session_info,
 
        /* Get printer name */
 
-       pname = lp_printername(talloc_tos(), snum);
+       pname = lp_printername(talloc_tos(), lp_sub, snum);
 
        if (!pname || !*pname) {
                return WERR_ACCESS_DENIED;
index c0265186fffcd1d5d9db580246c28d5ae4c3c9d5..53e6dd05dfb024f10a468aa960f1f713e16cf633 100644 (file)
@@ -1014,7 +1014,7 @@ static int cups_job_submit(int snum, struct printjob *pjob,
                     "attributes-natural-language", NULL, language->language);
 
        if (!push_utf8_talloc(frame, &printername,
-                             lp_printername(talloc_tos(), snum),
+                             lp_printername(talloc_tos(), lp_sub, snum),
                              &size)) {
                goto out;
        }
@@ -1095,7 +1095,7 @@ static int cups_job_submit(int snum, struct printjob *pjob,
        if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) {
                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
                        DEBUG(0,("Unable to print file to %s - %s\n",
-                                lp_printername(talloc_tos(), snum),
+                                lp_printername(talloc_tos(), lp_sub, snum),
                                 ippErrorString(cupsLastError())));
                } else {
                        ret = 0;
@@ -1109,7 +1109,7 @@ static int cups_job_submit(int snum, struct printjob *pjob,
                }
        } else {
                DEBUG(0,("Unable to print file to `%s' - %s\n",
-                        lp_printername(talloc_tos(), snum),
+                        lp_printername(talloc_tos(), lp_sub, snum),
                         ippErrorString(cupsLastError())));
        }
 
@@ -1497,6 +1497,8 @@ static int cups_queue_get(const char *sharename,
 static int cups_queue_pause(int snum)
 {
        TALLOC_CTX *frame = talloc_stackframe();
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        int             ret = 1;                /* Return value */
        http_t          *http = NULL;           /* HTTP connection to server */
        ipp_t           *request = NULL,        /* IPP Request */
@@ -1548,7 +1550,7 @@ static int cups_queue_pause(int snum)
                     "attributes-natural-language", NULL, language->language);
 
        if (!push_utf8_talloc(frame, &printername,
-                             lp_printername(talloc_tos(), snum), &size)) {
+                             lp_printername(talloc_tos(), lp_sub, snum), &size)) {
                goto out;
        }
        ustatus = httpAssembleURIf(HTTP_URI_CODING_ALL,
@@ -1579,14 +1581,14 @@ static int cups_queue_pause(int snum)
        if ((response = cupsDoRequest(http, request, "/admin/")) != NULL) {
                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
                        DEBUG(0,("Unable to pause printer %s - %s\n",
-                                lp_printername(talloc_tos(), snum),
+                                lp_printername(talloc_tos(), lp_sub, snum),
                                ippErrorString(cupsLastError())));
                } else {
                        ret = 0;
                }
        } else {
                DEBUG(0,("Unable to pause printer %s - %s\n",
-                        lp_printername(talloc_tos(), snum),
+                        lp_printername(talloc_tos(), lp_sub, snum),
                        ippErrorString(cupsLastError())));
        }
 
@@ -1612,6 +1614,8 @@ static int cups_queue_pause(int snum)
 static int cups_queue_resume(int snum)
 {
        TALLOC_CTX *frame = talloc_stackframe();
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        int             ret = 1;                /* Return value */
        http_t          *http = NULL;           /* HTTP connection to server */
        ipp_t           *request = NULL,        /* IPP Request */
@@ -1662,7 +1666,7 @@ static int cups_queue_resume(int snum)
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
                     "attributes-natural-language", NULL, language->language);
 
-       if (!push_utf8_talloc(frame, &printername, lp_printername(talloc_tos(), snum),
+       if (!push_utf8_talloc(frame, &printername, lp_printername(talloc_tos(), lp_sub, snum),
                              &size)) {
                goto out;
        }
@@ -1694,14 +1698,14 @@ static int cups_queue_resume(int snum)
        if ((response = cupsDoRequest(http, request, "/admin/")) != NULL) {
                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
                        DEBUG(0,("Unable to resume printer %s - %s\n",
-                                lp_printername(talloc_tos(), snum),
+                                lp_printername(talloc_tos(), lp_sub, snum),
                                ippErrorString(cupsLastError())));
                } else {
                        ret = 0;
                }
        } else {
                DEBUG(0,("Unable to resume printer %s - %s\n",
-                        lp_printername(talloc_tos(), snum),
+                        lp_printername(talloc_tos(), lp_sub, snum),
                        ippErrorString(cupsLastError())));
        }
 
index 574f357c76c1efe66d61b72851f140f5ed005b4e..f9c7693b3583f421fd64a9d500e2099566dab26f 100644 (file)
@@ -118,11 +118,13 @@ pause a job
 ****************************************************************************/
 static int generic_job_pause(int snum, struct printjob *pjob)
 {
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        fstring jobstr;
        
        /* 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,
+       return print_run_command(snum, lp_printername(talloc_tos(), lp_sub, snum), True,
                                 lp_lppause_command(snum), NULL,
                                 "%j", jobstr,
                                 NULL);
@@ -133,11 +135,13 @@ resume a job
 ****************************************************************************/
 static int generic_job_resume(int snum, struct printjob *pjob)
 {
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        fstring jobstr;
 
        /* 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,
+       return print_run_command(snum, lp_printername(talloc_tos(), lp_sub, snum), True,
                                 lp_lpresume_command(snum), NULL,
                                 "%j", jobstr,
                                 NULL);
@@ -208,6 +212,8 @@ static int generic_job_submit(int snum, struct printjob *pjob,
                              char *lpq_cmd)
 {
        int ret = -1;
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        char *current_directory = NULL;
        char *print_directory = NULL;
        char *wd = NULL;
@@ -259,7 +265,7 @@ static int generic_job_submit(int snum, struct printjob *pjob,
        slprintf(job_size, sizeof(job_size)-1, "%lu", (unsigned long)pjob->size);
 
        /* send it to the system spooler */
-       ret = print_run_command(snum, lp_printername(talloc_tos(), snum), True,
+       ret = print_run_command(snum, lp_printername(talloc_tos(), lp_sub, snum), True,
                        lp_print_command(snum), NULL,
                        "%s", p,
                        "%J", jobname,
@@ -277,7 +283,7 @@ static int generic_job_submit(int snum, struct printjob *pjob,
         * determine the backend job identifier (sysjob).
         */
        pjob->sysjob = -1;
-       ret = generic_queue_get(lp_printername(talloc_tos(), snum),
+       ret = generic_queue_get(lp_printername(talloc_tos(), lp_sub, snum),
                                printing_type, lpq_cmd, &q, &status);
        if (ret > 0) {
                int i;
@@ -312,7 +318,10 @@ 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,
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
+
+       return print_run_command(snum, lp_printername(talloc_tos(), lp_sub, snum), True,
                                 lp_queuepause_command(snum), NULL, NULL);
 }
 
@@ -321,7 +330,10 @@ 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,
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
+
+       return print_run_command(snum, lp_printername(talloc_tos(), lp_sub, snum), True,
                                 lp_queueresume_command(snum), NULL, NULL);
 }
 
index e57d111acd04b5860beea7da5c05e411e03ad342..c05f5c86b46ff4d3056f8595f6f629f94f77bf38 100644 (file)
@@ -603,6 +603,8 @@ static int iprint_job_pause(int snum, struct printjob *pjob)
        cups_lang_t     *language = NULL;       /* Default language */
        char            uri[HTTP_MAX_URI];      /* printer-uri attribute */
        char            httpPath[HTTP_MAX_URI]; /* path portion of the printer-uri */
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
 
 
        DEBUG(5,("iprint_job_pause(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
@@ -660,7 +662,7 @@ static int iprint_job_pause(int snum, struct printjob *pjob)
                     "attributes-natural-language", NULL, language->language);
 
        slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(),
-                lp_printername(talloc_tos(), snum));
+                lp_printername(talloc_tos(), lp_sub, snum));
 
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
 
@@ -674,7 +676,7 @@ static int iprint_job_pause(int snum, struct printjob *pjob)
        */
 
        slprintf(httpPath, sizeof(httpPath) - 1, "/ipp/%s",
-                lp_printername(talloc_tos(), snum));
+                lp_printername(talloc_tos(), lp_sub, snum));
 
        if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {
                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
@@ -715,6 +717,8 @@ static int iprint_job_resume(int snum, struct printjob *pjob)
        cups_lang_t     *language = NULL;       /* Default language */
        char            uri[HTTP_MAX_URI];      /* printer-uri attribute */
        char            httpPath[HTTP_MAX_URI]; /* path portion of the printer-uri */
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
 
 
        DEBUG(5,("iprint_job_resume(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
@@ -772,7 +776,7 @@ static int iprint_job_resume(int snum, struct printjob *pjob)
                     "attributes-natural-language", NULL, language->language);
 
        slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(),
-                lp_printername(talloc_tos(), snum));
+                lp_printername(talloc_tos(), lp_sub, snum));
 
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
 
@@ -786,7 +790,7 @@ static int iprint_job_resume(int snum, struct printjob *pjob)
        */
 
        slprintf(httpPath, sizeof(httpPath) - 1, "/ipp/%s",
-                lp_printername(talloc_tos(), snum));
+                lp_printername(talloc_tos(), lp_sub, snum));
 
        if ((response = cupsDoRequest(http, request, httpPath)) != NULL) {
                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
@@ -829,6 +833,8 @@ static int iprint_job_submit(int snum, struct printjob *pjob,
        ipp_attribute_t *attr;          /* Current attribute */
        cups_lang_t     *language = NULL;       /* Default language */
        char            uri[HTTP_MAX_URI]; /* printer-uri attribute */
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
 
        DEBUG(5,("iprint_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
 
@@ -885,7 +891,7 @@ static int iprint_job_submit(int snum, struct printjob *pjob,
                     "attributes-natural-language", NULL, language->language);
 
        slprintf(uri, sizeof(uri) - 1, "ipp://%s/ipp/%s", iprint_server(),
-                lp_printername(talloc_tos(), snum));
+                lp_printername(talloc_tos(), lp_sub, snum));
 
        ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
                     "printer-uri", NULL, uri);
@@ -904,19 +910,19 @@ static int iprint_job_submit(int snum, struct printjob *pjob,
        * Do the request and get back a response...
        */
 
-       slprintf(uri, sizeof(uri) - 1, "/ipp/%s", lp_printername(talloc_tos(), snum));
+       slprintf(uri, sizeof(uri) - 1, "/ipp/%s", lp_printername(talloc_tos(), lp_sub, snum));
 
        if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) {
                if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) {
                        DEBUG(0,("Unable to print file to %s - %s\n",
-                                lp_printername(talloc_tos(), snum),
+                                lp_printername(talloc_tos(), lp_sub, snum),
                                 ippErrorString(cupsLastError())));
                } else {
                        ret = 0;
                }
        } else {
                DEBUG(0,("Unable to print file to `%s' - %s\n",
-                        lp_printername(talloc_tos(), snum),
+                        lp_printername(talloc_tos(), lp_sub, snum),
                         ippErrorString(cupsLastError())));
        }
 
index 18c7ca0616c04ccf38bee1af1bda8c41673ffb72..3d43887c5c08c0973935bf2c6ac77aa295fa455b 100644 (file)
@@ -1711,6 +1711,8 @@ static void print_queue_update(struct messaging_context *msg_ctx,
        int type;
        struct printif *current_printif;
        TALLOC_CTX *ctx = talloc_tos();
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
 
        fstrcpy( sharename, lp_const_servicename(snum));
 
@@ -1719,7 +1721,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
        lpqcommand = talloc_string_sub2(ctx,
                        lp_lpq_command(snum),
                        "%p",
-                       lp_printername(talloc_tos(), snum),
+                       lp_printername(talloc_tos(), lp_sub, snum),
                        false, false, false);
        if (!lpqcommand) {
                return;
@@ -1739,7 +1741,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
        lprmcommand = talloc_string_sub2(ctx,
                        lp_lprm_command(snum),
                        "%p",
-                       lp_printername(talloc_tos(), snum),
+                       lp_printername(talloc_tos(), lp_sub, snum),
                        false, false, false);
        if (!lprmcommand) {
                return;
@@ -2157,6 +2159,8 @@ static bool print_job_delete1(struct tevent_context *ev,
                              int snum, uint32_t jobid)
 {
        const char* sharename = lp_const_servicename(snum);
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        struct printjob *pjob;
        int result = 0;
        struct printif *current_printif = get_printer_fns( snum );
@@ -2198,7 +2202,7 @@ static bool print_job_delete1(struct tevent_context *ev,
        if (pjob->spooled && pjob->sysjob != -1)
        {
                result = (*(current_printif->job_delete))(
-                       lp_printername(talloc_tos(), snum),
+                       lp_printername(talloc_tos(), lp_sub, snum),
                        lp_lprm_command(snum),
                        pjob);
 
@@ -2264,6 +2268,8 @@ WERROR print_job_delete(const struct auth_session_info *server_info,
                        int snum, uint32_t jobid)
 {
        const char* sharename = lp_const_servicename(snum);
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        struct printjob *pjob;
        bool    owner;
        WERROR werr;
@@ -2283,7 +2289,7 @@ WERROR print_job_delete(const struct auth_session_info *server_info,
                DEBUG(0, ("print job delete denied."
                          "User name: %s, Printer name: %s.",
                          uidtoname(server_info->unix_token->uid),
-                         lp_printername(tmp_ctx, snum)));
+                         lp_printername(tmp_ctx, lp_sub, snum)));
 
                werr = WERR_ACCESS_DENIED;
                goto err_out;
@@ -2338,6 +2344,8 @@ WERROR print_job_pause(const struct auth_session_info *server_info,
                     int snum, uint32_t jobid)
 {
        const char* sharename = lp_const_servicename(snum);
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        struct printjob *pjob;
        int ret = -1;
        struct printif *current_printif = get_printer_fns( snum );
@@ -2368,7 +2376,7 @@ WERROR print_job_pause(const struct auth_session_info *server_info,
                DEBUG(0, ("print job pause denied."
                          "User name: %s, Printer name: %s.",
                          uidtoname(server_info->unix_token->uid),
-                         lp_printername(tmp_ctx, snum)));
+                         lp_printername(tmp_ctx, lp_sub, snum)));
 
                werr = WERR_ACCESS_DENIED;
                goto err_out;
@@ -2406,6 +2414,8 @@ WERROR print_job_resume(const struct auth_session_info *server_info,
                      int snum, uint32_t jobid)
 {
        const char *sharename = lp_const_servicename(snum);
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        struct printjob *pjob;
        int ret;
        struct printif *current_printif = get_printer_fns( snum );
@@ -2435,7 +2445,7 @@ WERROR print_job_resume(const struct auth_session_info *server_info,
                DEBUG(0, ("print job resume denied."
                          "User name: %s, Printer name: %s.",
                          uidtoname(server_info->unix_token->uid),
-                         lp_printername(tmp_ctx, snum)));
+                         lp_printername(tmp_ctx, lp_sub, snum)));
 
                werr = WERR_ACCESS_DENIED;
                goto err_out;
@@ -2958,6 +2968,8 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
                       uint32_t jobid, enum file_close_type close_type)
 {
        const char* sharename = lp_const_servicename(snum);
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        struct printjob *pjob;
        int ret;
        SMB_STRUCT_STAT sbuf;
@@ -3035,7 +3047,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
        lpq_cmd = talloc_string_sub2(tmp_ctx,
                                     lp_lpq_command(snum),
                                     "%p",
-                                    lp_printername(talloc_tos(), snum),
+                                    lp_printername(talloc_tos(), lp_sub, snum),
                                     false, false, false);
        if (lpq_cmd == NULL) {
                status = NT_STATUS_PRINT_CANCELLED;
index 905fd63970b858306c34cd30f55da67982ab80a7..38d50eeffa83f7cd008e1cef750d094ba5db6ba6 100644 (file)
@@ -56,6 +56,8 @@ static void delete_and_reload_printers_full(struct tevent_context *ev,
 {
        struct auth_session_info *session_info = NULL;
        struct spoolss_PrinterInfo2 *pinfo2 = NULL;
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        int n_services;
        int pnum;
        int snum;
@@ -91,7 +93,7 @@ static void delete_and_reload_printers_full(struct tevent_context *ev,
                }
 
                sname = lp_const_servicename(snum);
-               pname = lp_printername(session_info, snum);
+               pname = lp_printername(session_info, lp_sub, snum);
 
                /* check printer, but avoid removing non-autoloaded printers */
                if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {
index 0f0621e3e8139a9cf28f369dfb56d9ea1acda036..898c5110a060ca45decf47598ac6c754811b1799 100644 (file)
@@ -58,6 +58,8 @@ void delete_and_reload_printers(void)
        bool ok;
        time_t pcap_last_update;
        TALLOC_CTX *frame = talloc_stackframe();
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
 
        ok = pcap_cache_loaded(&pcap_last_update);
        if (!ok) {
@@ -96,7 +98,7 @@ void delete_and_reload_printers(void)
                        continue;
                }
 
-               pname = lp_printername(frame, snum);
+               pname = lp_printername(frame, lp_sub, snum);
 
                /* check printer, but avoid removing non-autoloaded printers */
                if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {