summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-11-09 21:15:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:11 -0500
commit2d0f5486f085e0db4528fb3f72ca311c73c36b92 (patch)
treea6eb4c8a837b3398e052262aec765dc9bb59f794
parenta27837dac8240ef9d4f704540fe51ebbcb5b189f (diff)
downloadsamba-2d0f5486f085e0db4528fb3f72ca311c73c36b92.tar.gz
samba-2d0f5486f085e0db4528fb3f72ca311c73c36b92.tar.bz2
samba-2d0f5486f085e0db4528fb3f72ca311c73c36b92.zip
r3639: patch from Martin Zielinski <mz@seh.de> to add DeleteDriverEx() function to rpcclient
(This used to be commit cfd51c02447f7b42cffcaf4cc6179237d58c8229)
-rw-r--r--source3/rpc_client/cli_spoolss.c52
-rw-r--r--source3/rpc_parse/parse_spoolss.c24
-rw-r--r--source3/rpcclient/cmd_spoolss.c72
3 files changed, 142 insertions, 6 deletions
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 5303f83bf9..9a078e4720 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -1083,6 +1083,58 @@ WERROR cli_spoolss_addprinterex (struct cli_state *cli, TALLOC_CTX *mem_ctx,
return result;
}
+/**********************************************************************
+ * Delete a Printer Driver from the server (DOES remove
+ * the driver files)
+ */
+WERROR cli_spoolss_deleteprinterdriverex(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx, const char *arch,
+ const char *driver)
+{
+ prs_struct qbuf, rbuf;
+ SPOOL_Q_DELETEPRINTERDRIVEREX q;
+ SPOOL_R_DELETEPRINTERDRIVEREX r;
+ WERROR result = W_ERROR(ERRgeneral);
+ 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_m(server);
+
+ /* Write the request */
+ make_spoolss_q_deleteprinterdriverex(mem_ctx, &q, server, arch, driver);
+
+ /* Marshall data and send request */
+
+ if (!spoolss_io_q_deleteprinterdriverex ("", &q, &qbuf, 0)
+ || !rpc_api_pipe_req (cli,SPOOLSS_DELETEPRINTERDRIVEREX , &qbuf, &rbuf))
+ {
+ goto done;
+ }
+
+ /* Unmarshall response */
+
+ if (!spoolss_io_r_deleteprinterdriverex ("", &r, &rbuf, 0))
+ goto done;
+
+ /* Return output parameters */
+
+ result = r.status;
+
+done:
+ prs_mem_free(&qbuf);
+ prs_mem_free(&rbuf);
+
+ return result;
+}
+
/*********************************************************************************
Win32 API - DeltePrinterDriver()
********************************************************************************/
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 2b2038d16a..503a9454fc 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -1221,6 +1221,30 @@ BOOL spoolss_io_r_open_printer_ex(const char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u
/*******************************************************************
* init a structure.
********************************************************************/
+BOOL make_spoolss_q_deleteprinterdriverex( TALLOC_CTX *mem_ctx,
+ SPOOL_Q_DELETEPRINTERDRIVEREX *q_u,
+ const char *server,
+ const char* arch,
+ const char* driver )
+{
+ DEBUG(5,("make_spoolss_q_deleteprinterdriverex\n"));
+
+ q_u->server_ptr = (server!=NULL)?1:0;
+ q_u->delete_flags = DPD_DELETE_UNUSED_FILES;
+
+ /* these must be NULL terminated or else NT4 will
+ complain about invalid parameters --jerry */
+ init_unistr2(&q_u->server, server, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE);
+
+ return True;
+}
+
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
BOOL make_spoolss_q_deleteprinterdriver(
TALLOC_CTX *mem_ctx,
SPOOL_Q_DELETEPRINTERDRIVER *q_u,
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 4f936c3d2c..0ebe395ae5 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -1545,6 +1545,65 @@ done:
}
+static WERROR cmd_spoolss_deletedriverex(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ WERROR result, ret = WERR_UNKNOWN_PRINTER_DRIVER;
+
+ fstring servername;
+ int i;
+ int vers = -1;
+
+ const char *arch = NULL;
+
+ /* parse the command arguements */
+ if (argc < 2 || argc > 4) {
+ printf ("Usage: %s <driver> [arch] [version]\n", argv[0]);
+ return WERR_OK;
+ }
+
+ if (argc >= 3)
+ arch = argv[2];
+ if (argc == 4)
+ vers = atoi (argv[3]);
+
+
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
+ strupper_m(servername);
+
+ /* delete the driver for all architectures */
+ for (i=0; archi_table[i].long_archi; i++) {
+
+ if (arch && strcmp ( archi_table[i].long_archi, arch))
+ continue;
+
+ if (vers >= 0 && archi_table[i].version != vers)
+ continue;
+
+ /* make the call to remove the driver */
+ result = cli_spoolss_deleteprinterdriverex(
+ cli, mem_ctx, archi_table[i].long_archi, argv[1]);
+
+ if ( !W_ERROR_IS_OK(result) )
+ {
+ if ( !W_ERROR_EQUAL(result, WERR_UNKNOWN_PRINTER_DRIVER) ) {
+ printf ("Failed to remove driver %s for arch [%s] - error 0x%x!\n",
+ argv[1], archi_table[i].long_archi, W_ERROR_V(result));
+ }
+ }
+ else
+ {
+ printf ("Driver %s and files removed for arch [%s].\n", argv[1],
+ archi_table[i].long_archi);
+ ret = WERR_OK;
+ }
+ }
+
+ return ret;
+}
+
+
static WERROR cmd_spoolss_deletedriver(struct cli_state *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
@@ -2403,13 +2462,14 @@ struct cmd_set spoolss_commands[] = {
{ "SPOOLSS" },
{ "adddriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterdriver, PI_SPOOLSS, "Add a print driver", "" },
- { "addprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterex, PI_SPOOLSS, "Add a printer", "" },
+ { "addprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterex, PI_SPOOLSS, "Add a printer", "" },
{ "deldriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deletedriver, PI_SPOOLSS, "Delete a printer driver", "" },
+ { "deldriverex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deletedriverex, PI_SPOOLSS, "Delete a printer driver with files", "" },
{ "enumdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data, PI_SPOOLSS, "Enumerate printer data", "" },
- { "enumdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data_ex, PI_SPOOLSS, "Enumerate printer data for a key", "" },
+ { "enumdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data_ex, PI_SPOOLSS, "Enumerate printer data for a key", "" },
{ "enumkey", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printerkey, PI_SPOOLSS, "Enumerate printer keys", "" },
{ "enumjobs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_jobs, PI_SPOOLSS, "Enumerate print jobs", "" },
- { "enumports", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_ports, PI_SPOOLSS, "Enumerate printer ports", "" },
+ { "enumports", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_ports, PI_SPOOLSS, "Enumerate printer ports", "" },
{ "enumdrivers", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_drivers, PI_SPOOLSS, "Enumerate installed printer drivers", "" },
{ "enumprinters", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printers, PI_SPOOLSS, "Enumerate printers", "" },
{ "getdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinterdata, PI_SPOOLSS, "Get print driver data", "" },
@@ -2418,14 +2478,14 @@ struct cmd_set spoolss_commands[] = {
{ "getdriverdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriverdir, PI_SPOOLSS, "Get print driver upload directory", "" },
{ "getprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinter, PI_SPOOLSS, "Get printer info", "" },
{ "openprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex, PI_SPOOLSS, "Open printer handle", "" },
- { "setdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setdriver, PI_SPOOLSS, "Set printer driver", "" },
+ { "setdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setdriver, PI_SPOOLSS, "Set printer driver", "" },
{ "getprintprocdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprintprocdir, PI_SPOOLSS, "Get print processor directory", "" },
{ "addform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addform, PI_SPOOLSS, "Add form", "" },
{ "setform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setform, PI_SPOOLSS, "Set form", "" },
{ "getform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getform, PI_SPOOLSS, "Get form", "" },
- { "deleteform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deleteform, PI_SPOOLSS, "Delete form", "" },
+ { "deleteform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deleteform, PI_SPOOLSS, "Delete form", "" },
{ "enumforms", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_forms, PI_SPOOLSS, "Enumerate forms", "" },
- { "setprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinter, PI_SPOOLSS, "Set printer comment", "" },
+ { "setprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinter, PI_SPOOLSS, "Set printer comment", "" },
{ "setprintername", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprintername, PI_SPOOLSS, "Set printername", "" },
{ "setprinterdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinterdata, PI_SPOOLSS, "Set REG_SZ printer data", "" },
{ "rffpcnex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_rffpcnex, PI_SPOOLSS, "Rffpcnex test", "" },