diff options
-rwxr-xr-x | source3/include/rpc_spoolss.h | 19 | ||||
-rw-r--r-- | source3/libsmb/cli_spoolss.c | 57 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 77 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 48 |
4 files changed, 200 insertions, 1 deletions
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index 1e0a43987c..9f6bc23614 100755 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -30,7 +30,6 @@ /* spoolss pipe: this are the calls which are not implemented ... #define SPOOLSS_OPENPRINTER 0x01 #define SPOOLSS_GETPRINTERDRIVER 0x0b -#define SPOOLSS_DELETEPRINTERDRIVER 0x0d #define SPOOLSS_ADDPRINTPROCESSOR 0x0e #define SPOOLSS_GETPRINTPROCESSORDIRECTORY 0x10 #define SPOOLSS_READPRINTER 0x16 @@ -74,6 +73,7 @@ #define SPOOLSS_ADDPRINTERDRIVER 0x09 #define SPOOLSS_ENUMPRINTERDRIVERS 0x0a #define SPOOLSS_GETPRINTERDRIVERDIRECTORY 0x0c +#define SPOOLSS_DELETEPRINTERDRIVER 0x0d #define SPOOLSS_ENUMPRINTPROCESSORS 0x0f #define SPOOLSS_STARTDOCPRINTER 0x11 #define SPOOLSS_STARTPAGEPRINTER 0x12 @@ -577,6 +577,23 @@ typedef struct spool_r_endpageprinter } SPOOL_R_ENDPAGEPRINTER; + +typedef struct spool_q_deleteprinterdriver +{ + uint32 server_ptr; + UNISTR2 server; + UNISTR2 arch; + UNISTR2 driver; +} +SPOOL_Q_DELETEPRINTERDRIVER; + +typedef struct spool_r_deleteprinterdriver +{ + uint32 status; +} +SPOOL_R_DELETEPRINTERDRIVER; + + typedef struct spool_doc_info_1 { uint32 p_docname; diff --git a/source3/libsmb/cli_spoolss.c b/source3/libsmb/cli_spoolss.c index f68483dabe..4f8d6c0c88 100644 --- a/source3/libsmb/cli_spoolss.c +++ b/source3/libsmb/cli_spoolss.c @@ -1053,4 +1053,61 @@ done: return result; } +/********************************************************************** + * Delete a Printer Driver from the server (does not remove + * the driver files + */ +uint32 cli_spoolss_deleteprinterdriver ( + struct cli_state *cli, + TALLOC_CTX *mem_ctx, + char *arch, + char *driver +) +{ + prs_struct qbuf, rbuf; + SPOOL_Q_DELETEPRINTERDRIVER q; + SPOOL_R_DELETEPRINTERDRIVER r; + uint32 result; + fstring server; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + + /* Initialise input parameters */ + prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL); + prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); + + slprintf (server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + strupper (server); + + /* write the request */ + make_spoolss_q_deleteprinterdriver (mem_ctx, &q, server, arch, driver); + + /* Marshall data and send request */ + result = NT_STATUS_UNSUCCESSFUL; + if (!spoolss_io_q_deleteprinterdriver ("", &q, &qbuf, 0) || + !rpc_api_pipe_req (cli,SPOOLSS_DELETEPRINTERDRIVER , &qbuf, &rbuf)) + { + goto done; + } + + + /* Unmarshall response */ + result = NT_STATUS_UNSUCCESSFUL; + if (!spoolss_io_r_deleteprinterdriver ("", &r, &rbuf, 0)) + { + goto done; + } + + /* Return output parameters */ + result = r.status; + +done: + prs_mem_free(&qbuf); + prs_mem_free(&rbuf); + + return result; +} + diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index b18656b482..84decdaf2d 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -909,6 +909,31 @@ BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_ } /******************************************************************* + * init a structure. + ********************************************************************/ +BOOL make_spoolss_q_deleteprinterdriver( + TALLOC_CTX *mem_ctx, + SPOOL_Q_DELETEPRINTERDRIVER *q_u, + const char *server, + const char* arch, + const char* driver +) +{ + DEBUG(5,("make_spoolss_q_deleteprinterdriver\n")); + + q_u->server_ptr = (server!=NULL)?1:0; + + /* these must be NULL terminated or else NT4 will + complain about invalid parameters --jerry */ + init_unistr2(&q_u->server, server, strlen(server)+1); + init_unistr2(&q_u->arch, arch, strlen(arch)+1); + init_unistr2(&q_u->driver, driver, strlen(driver)+1); + + + return True; +} + +/******************************************************************* * write a structure. * called from static spoolss_r_open_printer_ex (srv_spoolss.c) * called from spoolss_open_printer_ex (cli_spoolss.c) @@ -1151,6 +1176,58 @@ BOOL spoolss_io_r_deleteprinter(char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_stru return True; } + +/******************************************************************* + * read a structure. + * called from api_spoolss_deleteprinterdriver (srv_spoolss.c) + * called from spoolss_deleteprinterdriver (cli_spoolss.c) + ********************************************************************/ + +BOOL spoolss_io_q_deleteprinterdriver(char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth) +{ + if (q_u == NULL) return False; + + prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver"); + depth++; + + if (!prs_align(ps)) + return False; + + if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr)) + return False; + if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth)) + return False; + if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth)) + return False; + if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth)) + return False; + + + return True; +} + + +/******************************************************************* + * write a structure. + ********************************************************************/ +BOOL spoolss_io_r_deleteprinterdriver(char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth) +{ + if (r_u == NULL) return False; + + prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver"); + depth++; + + if (!prs_align(ps)) + return False; + + if (!prs_uint32("status", ps, depth, &r_u->status)) + return False; + + return True; +} + + + /******************************************************************* * read a structure. * called from static spoolss_q_closeprinter (srv_spoolss.c) diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index aeb4ce3e20..fc1ac49430 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1310,12 +1310,60 @@ done: } +static uint32 cmd_spoolss_deletedriver (struct cli_state *cli, int argc, char **argv) +{ + uint32 result = NT_STATUS_UNSUCCESSFUL; + fstring servername; + TALLOC_CTX *mem_ctx = NULL; + + /* parse the command arguements */ + if (argc != 3) + { + printf ("Usage: %s <arch> <driver>\n", argv[0]); + return NT_STATUS_NOPROBLEMO; + } + + if (!(mem_ctx=talloc_init())) + { + DEBUG(0,("cmd_spoolss_deletedriver: talloc_init returned NULL!\n")); + return NT_STATUS_UNSUCCESSFUL; + } + + slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost); + strupper (servername); + + /* Initialise RPC connection */ + if (!cli_nt_session_open (cli, PIPE_SPOOLSS)) + { + fprintf (stderr, "Could not initialize spoolss pipe!\n"); + return NT_STATUS_UNSUCCESSFUL; + } + + /* make the call to remove the driver */ + if ((result = cli_spoolss_deleteprinterdriver(cli, mem_ctx, argv[1], argv[2])) != NT_STATUS_NO_PROBLEMO) + { + printf ("Failed to remove %s driver %s!\n", argv[1], argv[2]); + goto done;; + } + printf ("%s driver %s removed.\n", argv[1], argv[2]); + + +done: + /* cleanup */ + cli_nt_session_close (cli); + talloc_destroy(mem_ctx); + + return result; +} + + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { { "SPOOLSS", NULL, "" }, { "adddriver", cmd_spoolss_addprinterdriver, "Add a print driver" }, { "addprinter", cmd_spoolss_addprinterex, "Add a printer" }, + { "deldriver", cmd_spoolss_deletedriver, "Delete a printer driver" }, { "enumdata", cmd_spoolss_not_implemented, "Enumerate printer data (*)" }, { "enumjobs", cmd_spoolss_not_implemented, "Enumerate print jobs (*)" }, { "enumports", cmd_spoolss_enum_ports, "Enumerate printer ports" }, |