]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-spoolss: Create default DsSpooler values.
authorAndreas Schneider <asn@samba.org>
Fri, 30 Apr 2010 08:01:10 +0000 (10:01 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 5 May 2010 16:22:45 +0000 (18:22 +0200)
Signed-off-by: Günther Deschner <gd@samba.org>
source3/rpc_server/srv_spoolss_util.c

index 0e9c3d1a45336479b9877686006a8222bc70a644..ef136eb37eaf7295f37cd21221dcccde0af43663 100644 (file)
@@ -1303,7 +1303,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
        struct security_descriptor *secdesc;
        struct winreg_String wkey, wkeyclass;
        const char *path;
-       const char *subkeys[] = { "DsDriver", "DsSpooler", "PrinterDriverData" };
+       const char *subkeys[] = { SPOOL_DSDRIVER_KEY, SPOOL_DSSPOOLER_KEY, SPOOL_PRINTERDATA_KEY };
        uint32_t i, count = ARRAY_SIZE(subkeys);
        uint32_t info2_mask = 0;
        WERROR result = WERR_OK;
@@ -1400,6 +1400,119 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                        goto done;
                }
 
+               switch (i) {
+               case 1: {
+                       const char *dnssuffix;
+                       const char *longname;
+                       const char *uncname;
+
+                       result = winreg_printer_write_sz(tmp_ctx,
+                                                        winreg_pipe,
+                                                        &key_hnd,
+                                                        SPOOL_REG_PRINTERNAME,
+                                                        sharename);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_sz(tmp_ctx,
+                                                        winreg_pipe,
+                                                        &key_hnd,
+                                                        SPOOL_REG_SHORTSERVERNAME,
+                                                        global_myname());
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       /* We make the assumption that the netbios name
+                        * is the same as the DNS name since the former
+                        * will be what we used to join the domain
+                        */
+                       dnssuffix = get_mydnsdomname(tmp_ctx);
+                       if (dnssuffix != NULL && dnssuffix[0] != '\0') {
+                               longname = talloc_asprintf(tmp_ctx, "%s.%s", global_myname(), dnssuffix);
+                       } else {
+                               longname = talloc_strdup(tmp_ctx, global_myname());
+                       }
+                       if (longname == NULL) {
+                               result = WERR_NOMEM;
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_sz(tmp_ctx,
+                                                        winreg_pipe,
+                                                        &key_hnd,
+                                                        SPOOL_REG_SERVERNAME,
+                                                        longname);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       uncname = talloc_asprintf(tmp_ctx, "\\\\%s\\%s",
+                                                 longname, sharename);
+                       if (uncname == NULL) {
+                               result = WERR_NOMEM;
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_sz(tmp_ctx,
+                                                        winreg_pipe,
+                                                        &key_hnd,
+                                                        SPOOL_REG_UNCNAME,
+                                                        uncname);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_dword(tmp_ctx,
+                                                           winreg_pipe,
+                                                           &key_hnd,
+                                                           SPOOL_REG_VERSIONNUMBER,
+                                                           4);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_dword(tmp_ctx,
+                                                           winreg_pipe,
+                                                           &key_hnd,
+                                                           SPOOL_REG_PRINTSTARTTIME,
+                                                           0);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_dword(tmp_ctx,
+                                                           winreg_pipe,
+                                                           &key_hnd,
+                                                           SPOOL_REG_PRINTENDTIME,
+                                                           0);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_dword(tmp_ctx,
+                                                           winreg_pipe,
+                                                           &key_hnd,
+                                                           SPOOL_REG_PRIORITY,
+                                                           1);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+
+                       result = winreg_printer_write_dword(tmp_ctx,
+                                                           winreg_pipe,
+                                                           &key_hnd,
+                                                           SPOOL_REG_PRINTKEEPPRINTEDJOBS,
+                                                           0);
+                       if (!W_ERROR_IS_OK(result)) {
+                               goto done;
+                       }
+               } /* case 1 */
+               default:
+                       break;
+               }
+
                if (is_valid_policy_hnd(&key_hnd)) {
                        rpccli_winreg_CloseKey(winreg_pipe, tmp_ctx, &key_hnd, NULL);
                }