s4-spoolss: implement dcesrv_spoolss_GetPrintProcessorDirectory.
authorGünther Deschner <gd@samba.org>
Wed, 25 Feb 2009 22:04:52 +0000 (23:04 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 25 Feb 2009 22:06:56 +0000 (23:06 +0100)
Guenther

source4/ntptr/ntptr.h
source4/ntptr/ntptr_interface.c
source4/ntptr/simple_ldb/ntptr_simple_ldb.c
source4/rpc_server/spoolss/dcesrv_spoolss.c

index 24c467fe6519caa9c0a03b3d7a9c2fce26d14df6..91817a202f2592c8092088de989bb3dcf2a8e892 100644 (file)
@@ -74,6 +74,7 @@ struct spoolss_EnumForms;
 struct spoolss_EnumPorts;
 struct spoolss_EnumPrintProcessors;
 struct spoolss_XcvData;
+struct spoolss_GetPrintProcessorDirectory;
 
 /* the ntptr operations structure - contains function pointers to 
    the backend implementations of each operation */
@@ -144,6 +145,8 @@ struct ntptr_ops {
        /* PrintProcessor functions */
        WERROR (*EnumPrintProcessors)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
                                      struct spoolss_EnumPrintProcessors *r);
+       WERROR (*GetPrintProcessorDirectory)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
+                                            struct spoolss_GetPrintProcessorDirectory *r);
 
        /* Printer functions */
        WERROR (*EnumPrinters)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
index 109a9f560b4552e270bb6f19e691accb13654ead..b65a2e32cd52314728b732e19a16139e47e850ca 100644 (file)
@@ -263,6 +263,15 @@ WERROR ntptr_EnumPrintProcessors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ct
        return ntptr->ops->EnumPrintProcessors(ntptr, mem_ctx, r);
 }
 
+WERROR ntptr_GetPrintProcessorDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
+                                       struct spoolss_GetPrintProcessorDirectory *r)
+{
+       if (!ntptr->ops->GetPrintProcessorDirectory) {
+               return WERR_NOT_SUPPORTED;
+       }
+       return ntptr->ops->GetPrintProcessorDirectory(ntptr, mem_ctx, r);
+}
+
 
 /* Printer functions */
 WERROR ntptr_EnumPrinters(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
index c570b03a35c02b333f3b6b35ca6b1e2cb8b86669..459babce0ee5d1d344bf70a7b0089c3678a49d9b 100644 (file)
@@ -750,6 +750,47 @@ static WERROR sptr_GetPrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CT
        return WERR_OK;
 }
 
+static WERROR sptr_GetPrintProcessorDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
+                                             struct spoolss_GetPrintProcessorDirectory *r)
+{
+       union spoolss_PrintProcessorDirectoryInfo *info;
+       const char *prefix;
+       const char *postfix;
+
+       /*
+        * NOTE: normally r->in.level is 1, but both w2k3 and nt4 sp6a
+        *        are ignoring the r->in.level completely, so we do :-)
+        */
+
+       /*
+        * TODO: check the server name is ours
+        * - if it's a invalid UNC then return WERR_INVALID_NAME
+        * - if it's the wrong host name return WERR_INVALID_PARAM
+        * - if it's "" then we need to return a local WINDOWS path
+        */
+       if (!r->in.server || !r->in.server[0]) {
+               prefix = "C:\\PRTPROCS";
+       } else {
+               prefix = talloc_asprintf(mem_ctx, "%s\\prnproc$", r->in.server);
+               W_ERROR_HAVE_NO_MEMORY(prefix);
+       }
+
+       if (r->in.environment && strcmp(SPOOLSS_ARCHITECTURE_NT_X86, r->in.environment) == 0) {
+               postfix = "W32X86";
+       } else {
+               return WERR_INVALID_ENVIRONMENT;
+       }
+
+       info = talloc(mem_ctx, union spoolss_PrintProcessorDirectoryInfo);
+       W_ERROR_HAVE_NO_MEMORY(info);
+
+       info->info1.directory_name      = talloc_asprintf(mem_ctx, "%s\\%s", prefix, postfix);
+       W_ERROR_HAVE_NO_MEMORY(info->info1.directory_name);
+
+       r->out.info = info;
+       return WERR_OK;
+}
+
 
 /*
   initialialise the simble ldb backend, registering ourselves with the ntptr subsystem
@@ -793,6 +834,8 @@ static const struct ntptr_ops ntptr_simple_ldb_ops = {
        /* PrintProcessor functions */
 /*     .EnumPrintProcessors            = sptr_EnumPrintProcessors,
 */
+       .GetPrintProcessorDirectory     = sptr_GetPrintProcessorDirectory,
+
        /* Printer functions */
        .EnumPrinters                   = sptr_EnumPrinters,
        .OpenPrinter                    = sptr_OpenPrinter,
index 33c657cc1b5d9467b1e6d4133b0b7668f5f37aa1..89b93bbaa49bbc0b71d2573f1d86415eb301ac63 100644 (file)
@@ -454,7 +454,19 @@ static WERROR dcesrv_spoolss_EnumPrintProcessors(struct dcesrv_call_state *dce_c
 static WERROR dcesrv_spoolss_GetPrintProcessorDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                       struct spoolss_GetPrintProcessorDirectory *r)
 {
-       DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+       struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context);
+       WERROR status;
+       struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx);
+
+       status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.server);
+       W_ERROR_NOT_OK_RETURN(status);
+
+       status = ntptr_GetPrintProcessorDirectory(ntptr, mem_ctx, r);
+       W_ERROR_NOT_OK_RETURN(status);
+
+       *r->out.needed  = SPOOLSS_BUFFER_UNION(spoolss_PrintProcessorDirectoryInfo, ic, r->out.info, r->in.level);
+       r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
+       return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
 }