s3:net_rpc_printer: make use of cli_credentials_get_username()
authorStefan Metzmacher <metze@samba.org>
Fri, 26 Sep 2014 01:12:14 +0000 (03:12 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 29 Sep 2014 08:51:37 +0000 (10:51 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Sep 29 10:51:37 CEST 2014 on sn-devel-104

source3/utils/net_rpc_printer.c

index 8b5ea617a284a64fc2b834480845b76b8090a08d..242235bd314eb6540032d8b18a74a42c70436c0e 100644 (file)
@@ -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 */