[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha6-885-gbcdf345
Günther Deschner
gd at samba.org
Sat Feb 14 00:48:37 GMT 2009
The branch, master has been updated
via bcdf345df98ed356d94588f4617280450ff6e890 (commit)
via cd2af58af9f04ffaa59c482df8fdf5991cae4156 (commit)
via fbcccbc410ce23eb0f78f47fe5c7ee4a64e78a0c (commit)
via 9992827838d2f02226d91eaf67d68d2aa5adf265 (commit)
via cba40f65212814ddf7ccdcfdf92f799785a6ad4e (commit)
from 886c028e44a31c52f6595343f55236e27a8d0b40 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bcdf345df98ed356d94588f4617280450ff6e890
Author: Günther Deschner <gd at samba.org>
Date: Sat Feb 14 01:41:11 2009 +0100
s3-spoolss: remove unused convert_printer_info.
Guenther
commit cd2af58af9f04ffaa59c482df8fdf5991cae4156
Author: Günther Deschner <gd at samba.org>
Date: Fri Feb 13 00:10:10 2009 +0100
s3-spoolss: use pidl for _spoolss_SetPrinter.
Guenther
commit fbcccbc410ce23eb0f78f47fe5c7ee4a64e78a0c
Author: Günther Deschner <gd at samba.org>
Date: Tue Feb 10 23:35:19 2009 +0100
s3-spoolss: use pidl for _spoolss_AddPrinterEx.
Guenther
commit 9992827838d2f02226d91eaf67d68d2aa5adf265
Author: Günther Deschner <gd at samba.org>
Date: Tue Feb 10 23:34:35 2009 +0100
s3-spoolss: add printer_info2_to_nt_printer_info2 and convert_printer_info_new.
Guenther
commit cba40f65212814ddf7ccdcfdf92f799785a6ad4e
Author: Günther Deschner <gd at samba.org>
Date: Fri Feb 13 18:06:45 2009 +0100
s3-rpcclient: use rpccli_spoolss_AddPrinterEx.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 2 -
source3/rpc_server/srv_spoolss.c | 44 +-------
source3/rpc_server/srv_spoolss_nt.c | 215 +++++++++++++++++++----------------
source3/rpcclient/cmd_spoolss.c | 58 +++++++---
4 files changed, 159 insertions(+), 160 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index ed2c50a..bfbf972 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6245,13 +6245,11 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET
WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u);
WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri );
bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer);
-WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u);
WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u);
WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u);
WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u);
WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines );
WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u);
-WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u);
WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u);
WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, SPOOL_R_ADDPRINTERDRIVEREX *r_u);
WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u);
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index 68b7c3c..4a29e19 100644
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -370,27 +370,7 @@ static bool api_spoolss_writeprinter(pipes_struct *p)
static bool api_spoolss_setprinter(pipes_struct *p)
{
- SPOOL_Q_SETPRINTER q_u;
- SPOOL_R_SETPRINTER r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_setprinter("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n"));
- return False;
- }
-
- r_u.status = _spoolss_setprinter(p, &q_u, &r_u);
-
- if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTER);
}
/****************************************************************************
@@ -550,27 +530,7 @@ static bool api_spoolss_enumports(pipes_struct *p)
static bool api_spoolss_addprinterex(pipes_struct *p)
{
- SPOOL_Q_ADDPRINTEREX q_u;
- SPOOL_R_ADDPRINTEREX r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n"));
- return False;
- }
-
- r_u.status = _spoolss_addprinterex(p, &q_u, &r_u);
-
- if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) {
- DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ADDPRINTEREX);
}
/****************************************************************************
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index ef02dcf..249e324 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -1726,32 +1726,68 @@ WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
/****************************************************************************
****************************************************************************/
-static bool convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni,
- NT_PRINTER_INFO_LEVEL *printer, uint32 level)
+static bool printer_info2_to_nt_printer_info2(struct spoolss_SetPrinterInfo2 *r,
+ NT_PRINTER_INFO_LEVEL_2 *d)
+{
+ DEBUG(7,("printer_info2_to_nt_printer_info2\n"));
+
+ if (!r || !d) {
+ return false;
+ }
+
+ d->attributes = r->attributes;
+ d->priority = r->priority;
+ d->default_priority = r->defaultpriority;
+ d->starttime = r->starttime;
+ d->untiltime = r->untiltime;
+ d->status = r->status;
+ d->cjobs = r->cjobs;
+
+ fstrcpy(d->servername, r->servername);
+ fstrcpy(d->printername, r->printername);
+ fstrcpy(d->sharename, r->sharename);
+ fstrcpy(d->portname, r->portname);
+ fstrcpy(d->drivername, r->drivername);
+ slprintf(d->comment, sizeof(d->comment)-1, "%s", r->comment);
+ fstrcpy(d->location, r->location);
+ fstrcpy(d->sepfile, r->sepfile);
+ fstrcpy(d->printprocessor, r->printprocessor);
+ fstrcpy(d->datatype, r->datatype);
+ fstrcpy(d->parameters, r->parameters);
+
+ return true;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static bool convert_printer_info_new(struct spoolss_SetPrinterInfoCtr *info_ctr,
+ NT_PRINTER_INFO_LEVEL *printer)
{
bool ret;
- switch (level) {
- case 2:
- /* allocate memory if needed. Messy because
- convert_printer_info is used to update an existing
- printer or build a new one */
-
- if ( !printer->info_2 ) {
- printer->info_2 = TALLOC_ZERO_P( printer, NT_PRINTER_INFO_LEVEL_2 );
- if ( !printer->info_2 ) {
- DEBUG(0,("convert_printer_info: talloc() failed!\n"));
- return False;
- }
+ switch (info_ctr->level) {
+ case 2:
+ /* allocate memory if needed. Messy because
+ convert_printer_info is used to update an existing
+ printer or build a new one */
+
+ if (!printer->info_2) {
+ printer->info_2 = TALLOC_ZERO_P(printer, NT_PRINTER_INFO_LEVEL_2);
+ if (!printer->info_2) {
+ DEBUG(0,("convert_printer_info_new: "
+ "talloc() failed!\n"));
+ return false;
}
+ }
- ret = uni_2_asc_printer_info_2(uni->info_2, printer->info_2);
- printer->info_2->setuptime = time(NULL);
-
- return ret;
+ ret = printer_info2_to_nt_printer_info2(info_ctr->info.info2,
+ printer->info_2);
+ printer->info_2->setuptime = time(NULL);
+ return ret;
}
- return False;
+ return false;
}
static bool convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni,
@@ -5994,8 +6030,7 @@ WERROR _spoolss_AbortPrinter(pipes_struct *p,
* when updating a printer description
********************************************************************/
-static WERROR update_printer_sec(POLICY_HND *handle, uint32 level,
- const SPOOL_PRINTER_INFO_LEVEL *info,
+static WERROR update_printer_sec(POLICY_HND *handle,
pipes_struct *p, SEC_DESC_BUF *secdesc_ctr)
{
SEC_DESC_BUF *new_secdesc_ctr = NULL, *old_secdesc_ctr = NULL;
@@ -6281,9 +6316,9 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV
* when updating a printer description.
********************************************************************/
-static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
- const SPOOL_PRINTER_INFO_LEVEL *info,
- DEVICEMODE *devmode)
+static WERROR update_printer(pipes_struct *p, POLICY_HND *handle,
+ struct spoolss_SetPrinterInfoCtr *info_ctr,
+ struct spoolss_DeviceMode *devmode)
{
int snum;
NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL;
@@ -6320,7 +6355,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
* just read from the tdb in the pointer 'printer'.
*/
- if (!convert_printer_info(info, printer, level)) {
+ if (!convert_printer_info_new(info_ctr, printer)) {
result = WERR_NOMEM;
goto done;
}
@@ -6330,8 +6365,9 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level,
convert it and link it*/
DEBUGADD(8,("update_printer: Converting the devicemode struct\n"));
- if (!convert_devicemode(printer->info_2->printername, devmode,
- &printer->info_2->devmode)) {
+ if (!convert_devicemode_new(printer->info_2->printername,
+ devmode,
+ &printer->info_2->devmode)) {
result = WERR_NOMEM;
goto done;
}
@@ -6475,10 +6511,9 @@ done:
/****************************************************************************
****************************************************************************/
static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle,
- const SPOOL_PRINTER_INFO_LEVEL *info)
+ struct spoolss_SetPrinterInfo7 *info7)
{
#ifdef HAVE_ADS
- SPOOL_PRINTER_INFO_LEVEL_7 *info7 = info->info_7;
int snum;
Printer_entry *Printer;
@@ -6503,42 +6538,45 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle,
return WERR_UNKNOWN_LEVEL;
#endif
}
-/****************************************************************************
-****************************************************************************/
-WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u)
+/****************************************************************
+ _spoolss_SetPrinter
+****************************************************************/
+
+WERROR _spoolss_SetPrinter(pipes_struct *p,
+ struct spoolss_SetPrinter *r)
{
- POLICY_HND *handle = &q_u->handle;
- uint32 level = q_u->level;
- SPOOL_PRINTER_INFO_LEVEL *info = &q_u->info;
- DEVMODE_CTR devmode_ctr = q_u->devmode_ctr;
- SEC_DESC_BUF *secdesc_ctr = q_u->secdesc_ctr;
- uint32 command = q_u->command;
+ POLICY_HND *handle = r->in.handle;
WERROR result;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
if (!Printer) {
- DEBUG(2,("_spoolss_setprinter: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle)));
+ DEBUG(2,("_spoolss_SetPrinter: Invalid handle (%s:%u:%u)\n",
+ OUR_HANDLE(handle)));
return WERR_BADFID;
}
/* check the level */
- switch (level) {
+ switch (r->in.info_ctr->level) {
case 0:
- return control_printer(handle, command, p);
+ return control_printer(handle, r->in.command, p);
case 2:
- result = update_printer(p, handle, level, info, devmode_ctr.devmode);
+ result = update_printer(p, handle,
+ r->in.info_ctr,
+ r->in.devmode_ctr->devmode);
if (!W_ERROR_IS_OK(result))
return result;
- if (secdesc_ctr)
- result = update_printer_sec(handle, level, info, p, secdesc_ctr);
+ if (r->in.secdesc_ctr->sd)
+ result = update_printer_sec(handle, p,
+ r->in.secdesc_ctr);
return result;
case 3:
- return update_printer_sec(handle, level, info, p,
- secdesc_ctr);
+ return update_printer_sec(handle, p,
+ r->in.secdesc_ctr);
case 7:
- return publish_or_unpublish_printer(p, handle, info);
+ return publish_or_unpublish_printer(p, handle,
+ r->in.info_ctr->info.info7);
default:
return WERR_UNKNOWN_LEVEL;
}
@@ -7714,11 +7752,13 @@ WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM
/****************************************************************************
****************************************************************************/
-static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name,
- const SPOOL_PRINTER_INFO_LEVEL *info,
- DEVICEMODE *devmode, SEC_DESC_BUF *sec_desc_buf,
- uint32 user_switch, const SPOOL_USER_CTR *user,
- POLICY_HND *handle)
+static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
+ const char *server,
+ struct spoolss_SetPrinterInfoCtr *info_ctr,
+ struct spoolss_DeviceMode *devmode,
+ struct security_descriptor *sec_desc,
+ struct spoolss_UserLevelCtr *user_ctr,
+ POLICY_HND *handle)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
fstring name;
@@ -7731,7 +7771,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
}
/* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/
- if (!convert_printer_info(info, printer, 2)) {
+ if (!convert_printer_info_new(info_ctr, printer)) {
free_a_printer(&printer, 2);
return WERR_NOMEM;
}
@@ -7804,8 +7844,9 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
*/
DEBUGADD(10, ("spoolss_addprinterex_level_2: devmode included, converting\n"));
- if (!convert_devicemode(printer->info_2->printername, devmode,
- &printer->info_2->devmode))
+ if (!convert_devicemode_new(printer->info_2->printername,
+ devmode,
+ &printer->info_2->devmode))
return WERR_NOMEM;
}
@@ -7829,31 +7870,27 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_AddPrinterEx
+****************************************************************/
-WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u)
+WERROR _spoolss_AddPrinterEx(pipes_struct *p,
+ struct spoolss_AddPrinterEx *r)
{
- UNISTR2 *uni_srv_name = q_u->server_name;
- uint32 level = q_u->level;
- SPOOL_PRINTER_INFO_LEVEL *info = &q_u->info;
- DEVICEMODE *devmode = q_u->devmode_ctr.devmode;
- SEC_DESC_BUF *sdb = q_u->secdesc_ctr;
- uint32 user_switch = q_u->user_switch;
- SPOOL_USER_CTR *user = &q_u->user_ctr;
- POLICY_HND *handle = &r_u->handle;
-
- switch (level) {
- case 1:
- /* we don't handle yet */
- /* but I know what to do ... */
- return WERR_UNKNOWN_LEVEL;
- case 2:
- return spoolss_addprinterex_level_2(p, uni_srv_name, info,
- devmode, sdb,
- user_switch, user, handle);
- default:
- return WERR_UNKNOWN_LEVEL;
+ switch (r->in.info_ctr->level) {
+ case 1:
+ /* we don't handle yet */
+ /* but I know what to do ... */
+ return WERR_UNKNOWN_LEVEL;
+ case 2:
+ return spoolss_addprinterex_level_2(p, r->in.server,
+ r->in.info_ctr,
+ r->in.devmode_ctr->devmode,
+ r->in.secdesc_ctr->sd,
+ r->in.userlevel_ctr,
+ r->out.handle);
+ default:
+ return WERR_UNKNOWN_LEVEL;
}
}
@@ -10040,17 +10077,6 @@ WERROR _spoolss_AddPrinter(pipes_struct *p,
}
/****************************************************************
- _spoolss_SetPrinter
-****************************************************************/
-
-WERROR _spoolss_SetPrinter(pipes_struct *p,
- struct spoolss_SetPrinter *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
_spoolss_GetPrinter
****************************************************************/
@@ -10546,17 +10572,6 @@ WERROR _spoolss_44(pipes_struct *p,
}
/****************************************************************
- _spoolss_AddPrinterEx
-****************************************************************/
-
-WERROR _spoolss_AddPrinterEx(pipes_struct *p,
- struct spoolss_AddPrinterEx *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
_spoolss_47
****************************************************************/
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index b4dcad5..b6e8f7d 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -1380,9 +1380,14 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
WERROR result;
- uint32 level = 2;
- PRINTER_INFO_CTR ctr;
- PRINTER_INFO_2 info2;
+ NTSTATUS status;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_SetPrinterInfo2 info2;
+ struct policy_handle handle;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf sd;
+ struct spoolss_UserLevelCtr userlevel_ctr;
+ struct spoolss_UserLevel1 level1;
/* parse the command arguments */
if (argc != 5)
@@ -1392,17 +1397,19 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
}
/* Fill in the DRIVER_INFO_2 struct */
+ ZERO_STRUCT(devmode_ctr);
ZERO_STRUCT(info2);
-
- init_unistr( &info2.printername, argv[1]);
- init_unistr( &info2.sharename, argv[2]);
- init_unistr( &info2.drivername, argv[3]);
- init_unistr( &info2.portname, argv[4]);
- init_unistr( &info2.comment, "Created by rpcclient");
- init_unistr( &info2.printprocessor, "winprint");
- init_unistr( &info2.datatype, "RAW");
- info2.devmode = NULL;
- info2.secdesc = NULL;
+ ZERO_STRUCT(sd);
+
+ info2.printername = argv[1];
+ info2.drivername = argv[3];
+ info2.sharename = argv[2];
+ info2.portname = argv[4];
+ info2.comment = "Created by rpcclient";
+ info2.printprocessor = "winprint";
+ info2.datatype = "RAW";
+ info2.devmode = NULL;
+ info2.secdesc = NULL;
info2.attributes = PRINTER_ATTRIBUTE_SHARED;
info2.priority = 0;
info2.defaultpriority = 0;
@@ -1417,9 +1424,28 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
info2.averageppm = 0;
*/
- ctr.printers_2 = &info2;
- result = rpccli_spoolss_addprinterex (cli, mem_ctx, level, &ctr);
-
+ info_ctr.level = 2;
+ info_ctr.info.info2 = &info2;
+
+ level1.size = 28; /* wild guess */
+ level1.build = 1381;
+ level1.major = 2;
+ level1.minor = 0;
+ level1.processor = 0;
+ level1.client = global_myname();
+ level1.user = cli->auth->user_name;
+
+ userlevel_ctr.level = 1;
+ userlevel_ctr.user_info.level1 = &level1;
+
+ status = rpccli_spoolss_AddPrinterEx(cli, mem_ctx,
+ cli->srv_name_slash,
+ &info_ctr,
+ &devmode_ctr,
+ &sd,
+ &userlevel_ctr,
+ &handle,
+ &result);
--
Samba Shared Repository
More information about the samba-cvs
mailing list