summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-02-24 10:34:40 +0100
committerGünther Deschner <gd@samba.org>2009-02-24 11:03:28 +0100
commit00173c6ce6e6aa394acc0685827b0b9fb1faf45c (patch)
treeb7d67718ca7b7a0fcfb3b63529adf3139ed51f71 /source3
parent13995f5212bf1f5db4d246e8de3f63b761788d71 (diff)
downloadsamba-00173c6ce6e6aa394acc0685827b0b9fb1faf45c.tar.gz
samba-00173c6ce6e6aa394acc0685827b0b9fb1faf45c.tar.bz2
samba-00173c6ce6e6aa394acc0685827b0b9fb1faf45c.zip
s3-spoolss: merge path handling in _spoolss_PrintProcessorDirectory and
_spoolss_PrinterDriverDirectory. Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c127
1 files changed, 91 insertions, 36 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index a4679eb717..62301c001b 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -8059,45 +8059,106 @@ WERROR _spoolss_AddPrinterDriverEx(pipes_struct *p,
/****************************************************************************
****************************************************************************/
-static WERROR getprinterdriverdir_level_1(TALLOC_CTX *mem_ctx,
+struct _spoolss_paths {
+ int type;
+ const char *share;
+ const char *dir;
+};
+
+enum { SPOOLSS_DRIVER_PATH, SPOOLSS_PRTPROCS_PATH };
+
+static const struct _spoolss_paths spoolss_paths[]= {
+ { SPOOLSS_DRIVER_PATH, "print$", "DRIVERS" },
+ { SPOOLSS_PRTPROCS_PATH, "prnproc$", "PRTPROCS" }
+};
+
+static WERROR compose_spoolss_server_path(TALLOC_CTX *mem_ctx,
const char *servername,
const char *environment,
- struct spoolss_DriverDirectoryInfo1 *info1,
- uint32_t offered,
- uint32_t *needed)
+ int component,
+ char **path)
{
- char *path = NULL;
const char *pservername = NULL;
const char *long_archi = SPOOLSS_ARCHITECTURE_NT_X86;
const char *short_archi;
- if (environment) {
+ *path = NULL;
+
+ /* environment may be empty */
+ if (environment && strlen(environment)) {
long_archi = environment;
}
- pservername = canon_servername(servername);
+ /* servername may be empty */
+ if (servername && strlen(servername)) {
+ pservername = canon_servername(servername);
- if ( !is_myname_or_ipaddr(pservername))
- return WERR_INVALID_PARAM;
+ if (!is_myname_or_ipaddr(pservername)) {
+ return WERR_INVALID_PARAM;
+ }
+ }
- if (!(short_archi = get_short_archi(long_archi)))
+ if (!(short_archi = get_short_archi(long_archi))) {
return WERR_INVALID_ENVIRONMENT;
+ }
- path = talloc_asprintf(mem_ctx,
- "\\\\%s\\print$\\%s", pservername, short_archi);
- if (!path) {
+ switch (component) {
+ case SPOOLSS_PRTPROCS_PATH:
+ case SPOOLSS_DRIVER_PATH:
+ if (pservername) {
+ *path = talloc_asprintf(mem_ctx,
+ "\\\\%s\\%s\\%s",
+ pservername,
+ spoolss_paths[component].share,
+ short_archi);
+ } else {
+ *path = talloc_asprintf(mem_ctx, "%s\\%s\\%s",
+ SPOOLSS_DEFAULT_SERVER_PATH,
+ spoolss_paths[component].dir,
+ short_archi);
+ }
+ break;
+ default:
+ return WERR_INVALID_PARAM;
+ }
+
+ if (!*path) {
return WERR_NOMEM;
}
+ return WERR_OK;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static WERROR getprinterdriverdir_level_1(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *environment,
+ struct spoolss_DriverDirectoryInfo1 *r,
+ uint32_t offered,
+ uint32_t *needed)
+{
+ WERROR werr;
+ char *path = NULL;
+
+ werr = compose_spoolss_server_path(mem_ctx,
+ servername,
+ environment,
+ SPOOLSS_DRIVER_PATH,
+ &path);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
+ }
+
DEBUG(4,("printer driver directory: [%s]\n", path));
- info1->directory_name = path;
+ r->directory_name = path;
- *needed += ndr_size_spoolss_DriverDirectoryInfo1(info1, NULL, 0);
+ *needed += ndr_size_spoolss_DriverDirectoryInfo1(r, NULL, 0);
if (*needed > offered) {
talloc_free(path);
- ZERO_STRUCTP(info1);
return WERR_INSUFFICIENT_BUFFER;
}
@@ -9728,36 +9789,30 @@ done:
static WERROR getprintprocessordirectory_level_1(TALLOC_CTX *mem_ctx,
const char *servername,
const char *environment,
- struct spoolss_PrintProcessorDirectoryInfo1 *info1,
+ struct spoolss_PrintProcessorDirectoryInfo1 *r,
uint32_t offered,
uint32_t *needed)
{
- const char *long_archi = SPOOLSS_ARCHITECTURE_NT_X86;
- const char *short_archi;
-
- if (environment) {
- long_archi = environment;
- }
+ WERROR werr;
+ char *path = NULL;
- short_archi = get_short_archi(long_archi);
- if (!short_archi) {
- return WERR_INVALID_ENVIRONMENT;
+ werr = compose_spoolss_server_path(mem_ctx,
+ servername,
+ environment,
+ SPOOLSS_PRTPROCS_PATH,
+ &path);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
}
- /* I think this should look like this - gd
- info1->directory_name = talloc_asprintf(mem_ctx,
- "C:\\WINNT\\System32\\spool\\PRTPROCS\\%s", short_archi);
- */
- info1->directory_name = talloc_strdup(mem_ctx,
- "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86");
+ DEBUG(4,("print processor directory: [%s]\n", path));
- if (!info1->directory_name) {
- return WERR_NOMEM;
- }
+ r->directory_name = path;
- *needed += ndr_size_spoolss_PrintProcessorDirectoryInfo1(info1, NULL, 0);
+ *needed += ndr_size_spoolss_PrintProcessorDirectoryInfo1(r, NULL, 0);
if (*needed > offered) {
+ talloc_free(path);
return WERR_INSUFFICIENT_BUFFER;
}