summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/libads/ldap_printer.c7
-rw-r--r--source3/rpcclient/cmd_spoolss.c183
-rw-r--r--source3/utils/net_rpc_printer.c17
3 files changed, 62 insertions, 145 deletions
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c
index 023acaa638..c9c43f0e10 100644
--- a/source3/libads/ldap_printer.c
+++ b/source3/libads/ldap_printer.c
@@ -310,20 +310,19 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
const char *printer)
{
WERROR result;
- char *printername, *servername;
+ char *printername;
REGVAL_CTR *dsdriver_ctr, *dsspooler_ctr;
uint32 i;
POLICY_HND pol;
- if ((asprintf(&servername, "\\\\%s", cli->desthost) == -1)
- || (asprintf(&printername, "%s\\%s", servername, printer) == -1)) {
+ if ((asprintf(&printername, "%s\\%s", cli->srv_name_slash, printer) == -1)) {
DEBUG(3, ("Insufficient memory\n"));
return WERR_NOMEM;
}
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->auth->user_name,
+ cli->srv_name_slash, cli->auth->user_name,
&pol);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Unable to open printer %s, error is %s.\n",
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 4b35f57900..f026f486ce 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -98,7 +98,7 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli,
{
WERROR werror;
fstring printername;
- fstring servername, user;
+ fstring user;
POLICY_HND hnd;
if (argc != 2) {
@@ -109,8 +109,6 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli,
if (!cli)
return WERR_GENERAL_FAILURE;
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
fstrcpy(user, cli->auth->user_name);
fstrcpy(printername, argv[1]);
@@ -118,7 +116,7 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli,
werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", PRINTER_ALL_ACCESS,
- servername, user, &hnd);
+ cli->srv_name_slash, user, &hnd);
if (W_ERROR_IS_OK(werror)) {
printf("Printer %s opened successfully\n", printername);
@@ -473,7 +471,6 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
bool opened_hnd = False;
PRINTER_INFO_CTR ctr;
fstring printername,
- servername,
user,
comment;
@@ -488,14 +485,12 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
fstrcpy(comment, argv[2]);
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
- slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
/* get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
- PRINTER_ALL_ACCESS, servername,
+ PRINTER_ALL_ACCESS, cli->srv_name_slash,
user, &pol);
if (!W_ERROR_IS_OK(result))
@@ -539,7 +534,6 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
bool opened_hnd = False;
PRINTER_INFO_CTR ctr;
fstring printername,
- servername,
user,
new_printername;
@@ -554,14 +548,12 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
fstrcpy(new_printername, argv[2]);
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
- slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
/* get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
- PRINTER_ALL_ACCESS, servername,
+ PRINTER_ALL_ACCESS, cli->srv_name_slash,
user, &pol);
if (!W_ERROR_IS_OK(result))
@@ -604,7 +596,6 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
bool opened_hnd = False;
PRINTER_INFO_CTR ctr;
fstring printername,
- servername,
user;
if (argc == 1 || argc > 3) {
@@ -617,16 +608,14 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
info_level = atoi(argv[2]);
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
- slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
/* get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &pol);
+ cli->srv_name_slash, user, &pol);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -742,7 +731,6 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
WERROR result;
bool opened_hnd = False;
fstring printername,
- servername,
user;
const char *valuename;
REGISTRY_VALUE value;
@@ -756,20 +744,18 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
/* Open a printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
if (strncmp(argv[1], ".", sizeof(".")) == 0)
- fstrcpy(printername, servername);
+ fstrcpy(printername, cli->srv_name_slash);
else
- slprintf(printername, sizeof(servername)-1, "%s\\%s",
- servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s",
+ cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
/* get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &pol);
+ cli->srv_name_slash, user, &pol);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -807,7 +793,6 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
WERROR result;
bool opened_hnd = False;
fstring printername,
- servername,
user;
const char *valuename, *keyname;
REGISTRY_VALUE value;
@@ -823,20 +808,18 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
/* Open a printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
if (strncmp(argv[1], ".", sizeof(".")) == 0)
- fstrcpy(printername, servername);
+ fstrcpy(printername, cli->srv_name_slash);
else
slprintf(printername, sizeof(printername)-1, "%s\\%s",
- servername, argv[1]);
+ cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
/* get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &pol);
+ cli->srv_name_slash, user, &pol);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -987,7 +970,6 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
bool opened_hnd = False;
PRINTER_DRIVER_CTR ctr;
fstring printername,
- servername,
user;
uint32 i;
bool success = False;
@@ -999,10 +981,8 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
}
/* get the arguments need to open the printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
fstrcpy(user, cli->auth->user_name);
- slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
if (argc == 3)
info_level = atoi(argv[2]);
@@ -1010,7 +990,7 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
PRINTER_ACCESS_USE,
- servername, user, &pol);
+ cli->srv_name_slash, user, &pol);
if (!W_ERROR_IS_OK(werror)) {
printf("Error opening printer handle for %s!\n", printername);
@@ -1374,7 +1354,6 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
uint32 level = 2;
PRINTER_INFO_CTR ctr;
PRINTER_INFO_2 info2;
- fstring servername;
/* parse the command arguments */
if (argc != 5)
@@ -1383,9 +1362,6 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
return WERR_OK;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
-
/* Fill in the DRIVER_INFO_2 struct */
ZERO_STRUCT(info2);
@@ -1434,8 +1410,7 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
bool opened_hnd = False;
PRINTER_INFO_CTR ctr;
PRINTER_INFO_2 info2;
- fstring servername,
- printername,
+ fstring printername,
user;
/* parse the command arguments */
@@ -1445,16 +1420,14 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
return WERR_OK;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
- slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
/* Get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
PRINTER_ALL_ACCESS,
- servername, user, &pol);
+ cli->srv_name_slash, user, &pol);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -1573,7 +1546,6 @@ static WERROR cmd_spoolss_deletedriver(struct rpc_pipe_client *cli,
{
WERROR result = WERR_OK;
NTSTATUS status;
- fstring servername;
int i;
/* parse the command arguments */
@@ -1582,14 +1554,11 @@ static WERROR cmd_spoolss_deletedriver(struct rpc_pipe_client *cli,
return WERR_OK;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
-
/* delete the driver for all architectures */
for (i=0; archi_table[i].long_archi; i++) {
/* make the call to remove the driver */
status = rpccli_spoolss_DeletePrinterDriver(cli, mem_ctx,
- servername,
+ cli->srv_name_slash,
archi_table[i].long_archi,
argv[1],
&result);
@@ -1619,7 +1588,7 @@ static WERROR cmd_spoolss_getprintprocdir(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
WERROR result;
- char *servername = NULL, *environment = NULL;
+ char *environment = NULL;
fstring procdir;
/* parse the command arguments */
@@ -1628,23 +1597,17 @@ static WERROR cmd_spoolss_getprintprocdir(struct rpc_pipe_client *cli,
return WERR_OK;
}
- if (asprintf(&servername, "\\\\%s", cli->desthost) < 0)
- return WERR_NOMEM;
- strupper_m(servername);
-
if (asprintf(&environment, "%s", (argc == 2) ? argv[1] :
PRINTER_DRIVER_ARCHITECTURE) < 0) {
- SAFE_FREE(servername);
return WERR_NOMEM;
}
result = rpccli_spoolss_getprintprocessordirectory(
- cli, mem_ctx, servername, environment, procdir);
+ cli, mem_ctx, cli->srv_name_slash, environment, procdir);
if (W_ERROR_IS_OK(result))
printf("%s\n", procdir);
- SAFE_FREE(servername);
SAFE_FREE(environment);
return result;
@@ -1659,7 +1622,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
POLICY_HND handle;
WERROR werror;
NTSTATUS status;
- char *servername = NULL, *printername = NULL;
+ char *printername = NULL;
bool got_handle = False;
union spoolss_AddFormInfo info;
struct spoolss_AddFormInfo1 info1;
@@ -1673,18 +1636,13 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Get a printer handle */
- if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) {
- return WERR_NOMEM;
- }
- strupper_m(servername);
- if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) {
- SAFE_FREE(servername);
+ if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) {
return WERR_NOMEM;
}
werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
PRINTER_ALL_ACCESS,
- servername, cli->auth->user_name,
+ cli->srv_name_slash, cli->auth->user_name,
&handle);
if (!W_ERROR_IS_OK(werror))
@@ -1718,7 +1676,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
if (got_handle)
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
- SAFE_FREE(servername);
SAFE_FREE(printername);
return werror;
@@ -1733,7 +1690,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
POLICY_HND handle;
WERROR werror;
NTSTATUS status;
- char *servername = NULL, *printername = NULL;
+ char *printername = NULL;
bool got_handle = False;
union spoolss_AddFormInfo info;
struct spoolss_AddFormInfo1 info1;
@@ -1747,18 +1704,13 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Get a printer handle */
- if (asprintf(&servername, "\\\\%s", cli->desthost)) {
- return WERR_NOMEM;
- }
- strupper_m(servername);
- if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) {
- SAFE_FREE(servername);
+ if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) {
return WERR_NOMEM;
}
werror = rpccli_spoolss_open_printer_ex(
cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->auth->user_name, &handle);
+ cli->srv_name_slash, cli->auth->user_name, &handle);
if (!W_ERROR_IS_OK(werror))
goto done;
@@ -1791,7 +1743,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
if (got_handle)
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
- SAFE_FREE(servername);
SAFE_FREE(printername);
return werror;
@@ -1859,7 +1810,7 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
POLICY_HND handle;
WERROR werror;
NTSTATUS status;
- char *servername = NULL, *printername = NULL;
+ char *printername = NULL;
bool got_handle = False;
DATA_BLOB buffer;
uint32_t offered = 0;
@@ -1875,18 +1826,13 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
/* Get a printer handle */
- if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) {
- return WERR_NOMEM;
- }
- strupper_m(servername);
- if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) {
- SAFE_FREE(servername);
+ if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) {
return WERR_NOMEM;
}
werror = rpccli_spoolss_open_printer_ex(
cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->auth->user_name, &handle);
+ cli->srv_name_slash, cli->auth->user_name, &handle);
if (!W_ERROR_IS_OK(werror))
goto done;
@@ -1927,7 +1873,6 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
if (got_handle)
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
- SAFE_FREE(servername);
SAFE_FREE(printername);
return werror;
@@ -1943,7 +1888,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
POLICY_HND handle;
WERROR werror;
NTSTATUS status;
- char *servername = NULL, *printername = NULL;
+ char *printername = NULL;
bool got_handle = False;
/* Parse the command arguments */
@@ -1955,18 +1900,13 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
/* Get a printer handle */
- if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) {
- return WERR_NOMEM;
- }
- strupper_m(servername);
- if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) {
- SAFE_FREE(servername);
+ if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) {
return WERR_NOMEM;
}
werror = rpccli_spoolss_open_printer_ex(
cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->auth->user_name, &handle);
+ cli->srv_name_slash, cli->auth->user_name, &handle);
if (!W_ERROR_IS_OK(werror))
goto done;
@@ -1987,7 +1927,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
if (got_handle)
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
- SAFE_FREE(servername);
SAFE_FREE(printername);
return werror;
@@ -2002,7 +1941,7 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
{
POLICY_HND handle;
WERROR werror;
- char *servername = NULL, *printername = NULL;
+ char *printername = NULL;
bool got_handle = False;
uint32 num_forms, level = 1, i;
FORM_1 *forms;
@@ -2016,18 +1955,13 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
/* Get a printer handle */
- if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) {
- return WERR_NOMEM;
- }
- strupper_m(servername);
- if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) {
- SAFE_FREE(servername);
+ if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) {
return WERR_NOMEM;
}
werror = rpccli_spoolss_open_printer_ex(
cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->auth->user_name, &handle);
+ cli->srv_name_slash, cli->auth->user_name, &handle);
if (!W_ERROR_IS_OK(werror))
goto done;
@@ -2053,7 +1987,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
if (got_handle)
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
- SAFE_FREE(servername);
SAFE_FREE(printername);
return werror;
@@ -2067,7 +2000,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
WERROR result;
- fstring servername, printername, user;
+ fstring printername, user;
POLICY_HND pol;
bool opened_hnd = False;
PRINTER_INFO_CTR ctr;
@@ -2084,9 +2017,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
goto done;
}
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
- slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
+ slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
fstrcpy(user, cli->auth->user_name);
value.type = REG_NONE;
@@ -2115,7 +2046,8 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
/* get a printer handle */
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
- MAXIMUM_ALLOWED_ACCESS, servername,
+ MAXIMUM_ALLOWED_ACCESS,
+ cli->srv_name_slash,
user, &pol);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -2280,7 +2212,7 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
uint32 level = 1, num_jobs, i;
bool got_hnd = False;
char *printername = NULL;
- fstring servername, user;
+ fstring user;
POLICY_HND hnd;
JOB_INFO_CTR ctr;
@@ -2294,8 +2226,6 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
fstrcpy(user, cli->auth->user_name);
printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
if (!printername) {
@@ -2309,7 +2239,7 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &hnd);
+ cli->srv_name_slash, user, &hnd);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -2356,7 +2286,7 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
uint32 i=0, val_needed, data_needed;
bool got_hnd = False;
char *printername = NULL;
- fstring servername, user;
+ fstring user;
POLICY_HND hnd;
if (argc != 2) {
@@ -2366,8 +2296,6 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
fstrcpy(user, cli->auth->user_name);
printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
if (!printername) {
@@ -2381,7 +2309,7 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &hnd);
+ cli->srv_name_slash, user, &hnd);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -2422,7 +2350,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
uint32 i;
bool got_hnd = False;
char *printername = NULL;
- fstring servername, user;
+ fstring user;
const char *keyname = NULL;
POLICY_HND hnd;
REGVAL_CTR *ctr = NULL;
@@ -2436,8 +2364,6 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
fstrcpy(user, cli->auth->user_name);
printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
@@ -2452,7 +2378,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &hnd);
+ cli->srv_name_slash, user, &hnd);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -2492,7 +2418,7 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
WERROR result;
bool got_hnd = False;
char *printername = NULL;
- fstring servername, user;
+ fstring user;
const char *keyname = NULL;
POLICY_HND hnd;
uint16 *keylist = NULL, *curkey;
@@ -2509,8 +2435,6 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
/* Open printer handle */
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
- strupper_m(servername);
fstrcpy(user, cli->auth->user_name);
printername = talloc_asprintf(mem_ctx, "\\\\%s\\", cli->desthost);
@@ -2526,7 +2450,7 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
"", MAXIMUM_ALLOWED_ACCESS,
- servername, user, &hnd);
+ cli->srv_name_slash, user, &hnd);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -2583,16 +2507,13 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
/* Open printer */
- slprintf(servername, sizeof(servername) - 1, "\\\\%s", cli->desthost);
- strupper_m(servername);
-
slprintf(printername, sizeof(printername) - 1, "\\\\%s\\%s",
cli->desthost, argv[1]);
strupper_m(printername);
result = rpccli_spoolss_open_printer_ex(
cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
- servername, cli->auth->user_name, &hnd);
+ cli->srv_name_slash, cli->auth->user_name, &hnd);
if (!W_ERROR_IS_OK(result)) {
printf("Error opening %s\n", argv[1]);
@@ -2633,7 +2554,7 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
strupper_m(servername);
result = rpccli_spoolss_rffpcnex(
- cli, mem_ctx, &hnd, 0, 0, servername, 123, &option);
+ cli, mem_ctx, &hnd, 0, 0, cli->srv_name_slash, 123, &option);
if (!W_ERROR_IS_OK(result)) {
printf("Error rffpcnex %s\n", argv[1]);
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index ad9be05798..e74524beb7 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -726,38 +726,35 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
POLICY_HND *hnd)
{
WERROR result;
- fstring servername, printername2;
+ fstring printername2;
- slprintf(servername, sizeof(servername)-1, "\\\\%s",
- pipe_hnd->desthost);
-
- fstrcpy(printername2, servername);
+ fstrcpy(printername2, pipe_hnd->srv_name_slash);
fstrcat(printername2, "\\");
fstrcat(printername2, printername);
DEBUG(10,("connecting to: %s as %s for %s and access: %x\n",
- servername, username, printername2, access_required));
+ pipe_hnd->srv_name_slash, username, printername2, access_required));
/* open printer */
result = rpccli_spoolss_open_printer_ex(pipe_hnd, mem_ctx, printername2,
"", access_required,
- servername, username, hnd);
+ pipe_hnd->csrv_name_slash, username, hnd);
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
- printername2, servername, username);
+ printername2, pipe_hnd->csrv_name_slash, username);
return false;
}
if (!W_ERROR_IS_OK(result)) {
d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
- printername2, servername, win_errstr(result));
+ printername2, pipe_hnd->csrv_name_slash, win_errstr(result));
return false;
}
DEBUG(2,("got printer handle for printer: %s, server: %s\n",
- printername2, servername));
+ printername2, pipe_hnd->csrv_name_slash));
return true;
}