summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs-xml/smbdotconf/printing/printername.xml1
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/param/loadparm.c7
-rw-r--r--source3/printing/nt_printing.c4
-rw-r--r--source3/printing/print_cups.c22
-rw-r--r--source3/printing/print_generic.c24
-rw-r--r--source3/printing/print_iprint.c22
-rw-r--r--source3/printing/printing.c26
-rw-r--r--source3/printing/queue_process.c4
-rw-r--r--source3/smbd/server_reload.c4
10 files changed, 82 insertions, 36 deletions
diff --git a/docs-xml/smbdotconf/printing/printername.xml b/docs-xml/smbdotconf/printing/printername.xml
index abe2b2483dc..6b82ef29de1 100644
--- a/docs-xml/smbdotconf/printing/printername.xml
+++ b/docs-xml/smbdotconf/printing/printername.xml
@@ -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>
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5a957c4bd99..2c22734ae98 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 1d47d74c5f4..3d6149fd85b 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -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);
}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 46d2cea9e48..cd9ca9f9452 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -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;
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index c0265186fff..53e6dd05dfb 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -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())));
}
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index 574f357c76c..f9c7693b358 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -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);
}
diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c
index e57d111acd0..c05f5c86b46 100644
--- a/source3/printing/print_iprint.c
+++ b/source3/printing/print_iprint.c
@@ -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())));
}
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 18c7ca0616c..3d43887c5c0 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -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;
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 905fd63970b..38d50eeffa8 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -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)) {
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index 0f0621e3e81..898c5110a06 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -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)) {