s3-spoolss: Added missing servername option to winreg_{create,get}_printer.
authorAndreas Schneider <asn@samba.org>
Mon, 26 Apr 2010 11:36:19 +0000 (13:36 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 5 May 2010 15:32:51 +0000 (17:32 +0200)
This is needed to be able to pass the correct servername from
Printer_entry.

Signed-off-by: Günther Deschner <gd@samba.org>
source3/rpc_server/srv_spoolss_util.c
source3/rpc_server/srv_spoolss_util.h

index b70090f44b34659bda4350b808134b199bc062df..f04e5dec976fee928538d4b65abd37f3cf027134 100644 (file)
@@ -1362,6 +1362,7 @@ static WERROR winreg_printer_ver_to_dword(const char *str, uint64_t *data)
 
 WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                             struct auth_serversupplied_info *server_info,
+                            const char *servername,
                             const char *sharename)
 {
        uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
@@ -1876,6 +1877,7 @@ done:
 
 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
                          struct auth_serversupplied_info *server_info,
+                         const char *servername,
                          const char *printer,
                          struct spoolss_PrinterInfo2 **pinfo2)
 {
@@ -1936,12 +1938,7 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       info2->servername = talloc_asprintf(info2, "\\\\%s", global_myname());
-       if (info2->servername == NULL) {
-               result = WERR_NOMEM;
-               goto done;
-       }
-
+       info2->servername     = EMPTY_STRING;
        info2->printername    = EMPTY_STRING;
        info2->sharename      = EMPTY_STRING;
        info2->portname       = EMPTY_STRING;
@@ -1953,6 +1950,14 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
        info2->datatype       = EMPTY_STRING;
        info2->parameters     = EMPTY_STRING;
 
+       if (servername != NULL && servername[0] != '\0') {
+               info2->servername = talloc_asprintf(info2, "\\\\%s", servername);
+               if (info2->servername == NULL) {
+                       result = WERR_NOMEM;
+                       goto done;
+               }
+       }
+
        for (i = 0; i < num_values; i++) {
                v = &enum_values[i];
 
@@ -1960,6 +1965,15 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
                                              v,
                                              "Name",
                                              &info2->printername);
+               if (W_ERROR_IS_OK(result) && info2->servername[0] != '\0') {
+                       char *p = talloc_asprintf(info2, "%s\\%s",
+                                                 info2->servername,
+                                                 info2->printername);
+                       if (p == NULL) {
+                               result = WERR_NOMEM;
+                       }
+                       info2->printername = p;
+               }
                CHECK_ERROR(result);
 
                result = winreg_enumval_to_sz(info2,
index 4b5117e937751d8641a2b83a0fd5f0139af75402..f883f20a456df41610bf7da52219eaa353297f59 100644 (file)
@@ -73,6 +73,7 @@ enum spoolss_PrinterInfo2Mask {
 
 WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                             struct auth_serversupplied_info *server_info,
+                            const char *servername,
                             const char *sharename);
 
 /**
@@ -110,6 +111,8 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
  *
  * @param[in]  server_info The server supplied session info.
  *
+ * @param[in]  printer  The servername to use.
+ *
  * @param[in]  printer  The name of the printer to get.
  *
  * @param[out] pinfo2   A pointer to store a PRINTER_INFO_2 structure.
@@ -119,6 +122,7 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
  */
 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
                          struct auth_serversupplied_info *server_info,
+                         const char *servername,
                          const char *printer,
                          struct spoolss_PrinterInfo2 **pinfo2);