From f3ce6b4d35f6e24fdbc6b6231e6d845eac87657c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 26 Sep 2014 03:12:14 +0200 Subject: [PATCH] s3:net_rpc_printer: make use of cli_credentials_get_username() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett Reviewed-by: Günther Deschner Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Mon Sep 29 10:51:37 CEST 2014 on sn-devel-104 --- source3/utils/net_rpc_printer.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 8b5ea617a28..242235bd314 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -706,9 +706,10 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, const char *printername, uint32_t access_required, - const char *username, struct policy_handle *hnd) { + struct cli_credentials *creds = gensec_get_credentials(pipe_hnd->auth->auth_ctx); + const char *username = cli_credentials_get_username(creds); WERROR result; fstring printername2; @@ -1122,7 +1123,6 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, { struct dcerpc_binding_handle *b = pipe_hnd->binding_handle; struct policy_handle hnd; - struct cli_credentials *creds = gensec_get_credentials(pipe_hnd->auth->auth_ctx); WERROR werr; /* no arguments given, enumerate all printers */ @@ -1139,7 +1139,6 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, /* argument given, get a single printer by name */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0], MAXIMUM_ALLOWED_ACCESS, - cli_credentials_get_username(creds), &hnd)) return false; @@ -1318,8 +1317,6 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ struct policy_handle hnd = { 0, }; WERROR result; const char *action_str; - struct cli_credentials *creds = gensec_get_credentials(pipe_hnd->auth->auth_ctx); - const char *username = cli_credentials_get_username(creds); if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum)) return nt_status; @@ -1335,7 +1332,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ /* open printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - PRINTER_ALL_ACCESS, username, &hnd)) + PRINTER_ALL_ACCESS, &hnd)) goto done; /* check for existing dst printer */ @@ -1492,7 +1489,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c, /* open printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - PRINTER_ALL_ACCESS, cli->user_name, &hnd)) + PRINTER_ALL_ACCESS, &hnd)) goto done; /* check for existing dst printer */ @@ -1628,12 +1625,12 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, /* open src printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) + MAXIMUM_ALLOWED_ACCESS, &hnd_src)) goto done; /* open dst printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename, - PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst)) + PRINTER_ALL_ACCESS, &hnd_dst)) goto done; /* check for existing dst printer */ @@ -1784,12 +1781,12 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, /* open src printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) + MAXIMUM_ALLOWED_ACCESS, &hnd_src)) goto done; /* open dst printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename, - PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) + PRINTER_ALL_ACCESS, &hnd_dst)) goto done; /* check for existing dst printer */ @@ -1917,8 +1914,6 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, struct cli_state *cli_share_src = NULL; struct cli_state *cli_share_dst = NULL; const char *drivername = NULL; - struct cli_credentials *creds = gensec_get_credentials(pipe_hnd->auth->auth_ctx); - const char *username = cli_credentials_get_username(creds); WERROR werr; DEBUG(3,("copying printer-drivers\n")); @@ -1986,7 +1981,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, /* open dst printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename, - PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) + PRINTER_ALL_ACCESS, &hnd_dst)) goto done; /* check for existing dst printer */ @@ -1997,7 +1992,6 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, /* open src printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, MAXIMUM_ALLOWED_ACCESS, - username, &hnd_src)) goto done; @@ -2183,7 +2177,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, /* open dst printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename, - PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) { + PRINTER_ALL_ACCESS, &hnd_dst)) { DEBUG(1,("could not open printer: %s\n", sharename)); } @@ -2205,7 +2199,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, /* open src printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) + MAXIMUM_ALLOWED_ACCESS, &hnd_src)) goto done; /* getprinter on the src server */ @@ -2370,12 +2364,12 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, /* open src printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src)) + MAXIMUM_ALLOWED_ACCESS, &hnd_src)) goto done; /* open dst printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename, - PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst)) + PRINTER_ALL_ACCESS, &hnd_dst)) goto done; /* check for existing dst printer */