[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-383-g6a556fd
Jeremy Allison
jra at samba.org
Wed Nov 28 01:51:23 GMT 2007
The branch, v3-2-test has been updated
via 6a556fd73ac8c247c15df664f7910f8688abfdbc (commit)
via 3052172d2bfe9d787777525e90816394aac2dd54 (commit)
via 04aecde5cfdb00d5aa32f9675c797266aba83c0f (commit)
from 0002a9e96b0ef78316295a6eb94ff29b64e2f988 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 6a556fd73ac8c247c15df664f7910f8688abfdbc
Author: Jeremy Allison <jra at samba.org>
Date: Tue Nov 27 17:50:39 2007 -0800
Fix old cut-and-paste bug where the wrong field was being written to.
Jerry please check.
Jeremy.
commit 3052172d2bfe9d787777525e90816394aac2dd54
Author: Jeremy Allison <jra at samba.org>
Date: Tue Nov 27 17:48:59 2007 -0800
Whitespace cleanup.
Jeremy.
commit 04aecde5cfdb00d5aa32f9675c797266aba83c0f
Author: Jeremy Allison <jra at samba.org>
Date: Tue Nov 27 17:48:44 2007 -0800
Make init_unistr2_from_unistr take an explicit talloc context.
Make init_unistr() re-use rpcstr_push_talloc().
Jeremy.
-----------------------------------------------------------------------
Summary of changes:
source/rpc_parse/parse_misc.c | 17 +-
source/rpc_parse/parse_spoolss.c | 56 +-
source/rpc_server/srv_spoolss_nt.c | 2076 ++++++++++++++++++------------------
3 files changed, 1070 insertions(+), 1079 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c
index 2e85b59..783c7fb 100644
--- a/source/rpc_parse/parse_misc.c
+++ b/source/rpc_parse/parse_misc.c
@@ -430,16 +430,9 @@ void init_unistr(UNISTR *str, const char *buf)
str->buffer = NULL;
return;
}
-
- len = strlen(buf) + 1;
- if (len) {
- str->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, len);
- if (str->buffer == NULL)
- smb_panic("init_unistr: malloc fail");
-
- rpcstr_push(str->buffer, buf, len*sizeof(uint16), STR_TERMINATE);
- } else {
+ len = rpcstr_push_talloc(talloc_tos(), &str->buffer, buf);
+ if (len == (size_t)-1) {
str->buffer = NULL;
}
}
@@ -870,7 +863,7 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
Inits a UNISTR2 structure from a UNISTR
********************************************************************/
-void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from)
+void init_unistr2_from_unistr(TALLOC_CTX *ctx, UNISTR2 *to, const UNISTR *from)
{
uint32 i;
@@ -898,9 +891,9 @@ void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from)
/* allocate the space and copy the string buffer */
if (i) {
- to->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, i);
+ to->buffer = TALLOC_ZERO_ARRAY(ctx, uint16, i);
if (to->buffer == NULL)
- smb_panic("init_unistr2_from_unistr: malloc fail");
+ smb_panic("init_unistr2_from_unistr: talloc fail");
memcpy(to->buffer, from->buffer, i*sizeof(uint16));
} else {
to->buffer = NULL;
diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c
index 3030ff1..ea76c57 100644
--- a/source/rpc_parse/parse_spoolss.c
+++ b/source/rpc_parse/parse_spoolss.c
@@ -1016,18 +1016,18 @@ bool make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u
create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
*******************************************************************/
-bool make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
+bool make_spoolss_printer_info_2(TALLOC_CTX *ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
PRINTER_INFO_2 *info)
{
SPOOL_PRINTER_INFO_LEVEL_2 *inf;
/* allocate the necessary memory */
- if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
+ if (!(inf=TALLOC_P(ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
return False;
}
-
+
inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
@@ -1048,18 +1048,18 @@ bool make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2
inf->untiltime = info->untiltime;
inf->cjobs = info->cjobs;
inf->averageppm = info->averageppm;
- init_unistr2_from_unistr(&inf->servername, &info->servername);
- init_unistr2_from_unistr(&inf->printername, &info->printername);
- init_unistr2_from_unistr(&inf->sharename, &info->sharename);
- init_unistr2_from_unistr(&inf->portname, &info->portname);
- init_unistr2_from_unistr(&inf->drivername, &info->drivername);
- init_unistr2_from_unistr(&inf->comment, &info->comment);
- init_unistr2_from_unistr(&inf->location, &info->location);
- init_unistr2_from_unistr(&inf->sepfile, &info->sepfile);
- init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor);
- init_unistr2_from_unistr(&inf->datatype, &info->datatype);
- init_unistr2_from_unistr(&inf->parameters, &info->parameters);
- init_unistr2_from_unistr(&inf->datatype, &info->datatype);
+ init_unistr2_from_unistr(inf, &inf->servername, &info->servername);
+ init_unistr2_from_unistr(inf, &inf->printername, &info->printername);
+ init_unistr2_from_unistr(inf, &inf->sharename, &info->sharename);
+ init_unistr2_from_unistr(inf, &inf->portname, &info->portname);
+ init_unistr2_from_unistr(inf, &inf->drivername, &info->drivername);
+ init_unistr2_from_unistr(inf, &inf->comment, &info->comment);
+ init_unistr2_from_unistr(inf, &inf->location, &info->location);
+ init_unistr2_from_unistr(inf, &inf->sepfile, &info->sepfile);
+ init_unistr2_from_unistr(inf, &inf->printprocessor, &info->printprocessor);
+ init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
+ init_unistr2_from_unistr(inf, &inf->parameters, &info->parameters);
+ init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
*spool_info2 = inf;
@@ -1105,9 +1105,9 @@ bool make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7
return False;
}
- inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
- inf->action = info->action;
- init_unistr2_from_unistr(&inf->guid, &info->guid);
+ inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
+ inf->action = info->action;
+ init_unistr2_from_unistr(inf, &inf->guid, &info->guid);
*spool_info7 = inf;
@@ -5182,7 +5182,7 @@ bool make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
return True;
}
-bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
+bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
DRIVER_INFO_3 *info3)
{
@@ -5191,7 +5191,7 @@ bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
if (!(inf=TALLOC_ZERO_P(mem_ctx, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)))
return False;
-
+
inf->cversion = info3->version;
inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
@@ -5202,14 +5202,14 @@ bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
- init_unistr2_from_unistr(&inf->name, &info3->name);
- init_unistr2_from_unistr(&inf->environment, &info3->architecture);
- init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath);
- init_unistr2_from_unistr(&inf->datafile, &info3->datafile);
- init_unistr2_from_unistr(&inf->configfile, &info3->configfile);
- init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile);
- init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname);
- init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype);
+ init_unistr2_from_unistr(inf, &inf->name, &info3->name);
+ init_unistr2_from_unistr(inf, &inf->environment, &info3->architecture);
+ init_unistr2_from_unistr(inf, &inf->driverpath, &info3->driverpath);
+ init_unistr2_from_unistr(inf, &inf->datafile, &info3->datafile);
+ init_unistr2_from_unistr(inf, &inf->configfile, &info3->configfile);
+ init_unistr2_from_unistr(inf, &inf->helpfile, &info3->helpfile);
+ init_unistr2_from_unistr(inf, &inf->monitorname, &info3->monitorname);
+ init_unistr2_from_unistr(inf, &inf->defaultdatatype, &info3->defaultdatatype);
if (info3->dependentfiles) {
bool done = False;
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index d497312..a6f3bfb 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -50,7 +50,7 @@ static Printer_entry *printers_list;
typedef struct _counter_printer_0 {
struct _counter_printer_0 *next;
struct _counter_printer_0 *prev;
-
+
int snum;
uint32 counter;
} counter_printer_0;
@@ -139,7 +139,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
{
WERROR result;
- /*
+ /*
* Tell the specific printing tdb we no longer want messages for this printer
* by deregistering our PID.
*/
@@ -154,7 +154,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
}
result = rpccli_spoolss_reply_close_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, handle);
-
+
if (!W_ERROR_IS_OK(result))
DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n",
dos_errstr(result)));
@@ -206,10 +206,10 @@ static void free_printer_entry(void *ptr)
free_spool_notify_option(&Printer->notify.option);
Printer->notify.option=NULL;
Printer->notify.client_connected=False;
-
+
free_nt_devicemode( &Printer->nt_devmode );
free_a_printer( &Printer->printer_info, 2 );
-
+
talloc_destroy( Printer->ctx );
/* Remove from the internal list. */
@@ -279,7 +279,7 @@ static bool close_printer_handle(pipes_struct *p, POLICY_HND *hnd)
close_policy_hnd(p, hnd);
return True;
-}
+}
/****************************************************************************
Delete a printer given a handle.
@@ -291,46 +291,46 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename )
int ret;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
bool is_print_op = False;
-
+
/* can't fail if we don't try */
-
+
if ( !*cmd )
return WERR_OK;
-
+
pstr_sprintf(command, "%s \"%s\"", cmd, sharename);
if ( token )
is_print_op = user_has_privileges( token, &se_printop );
-
+
DEBUG(10,("Running [%s]\n", command));
/********** BEGIN SePrintOperatorPrivlege BLOCK **********/
-
+
if ( is_print_op )
become_root();
-
+
if ( (ret = smbrun(command, NULL)) == 0 ) {
/* Tell everyone we updated smb.conf. */
message_send_all(smbd_messaging_context(),
MSG_SMB_CONF_UPDATED, NULL, 0, NULL);
}
-
+
if ( is_print_op )
unbecome_root();
/********** END SePrintOperatorPrivlege BLOCK **********/
-
+
DEBUGADD(10,("returned [%d]\n", ret));
- if (ret != 0)
+ if (ret != 0)
return WERR_BADFID; /* What to return here? */
/* go ahead and re-read the services immediately */
reload_services( False );
-
+
if ( lp_servicenumber( sharename ) < 0 )
return WERR_ACCESS_DENIED;
-
+
return WERR_OK;
}
@@ -347,7 +347,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
return WERR_BADFID;
}
- /*
+ /*
* It turns out that Windows allows delete printer on a handle
* opened by an admin user, then used on a pipe handle created
* by an anonymous user..... but they're working on security.... riiight !
@@ -358,10 +358,10 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd)
DEBUG(3, ("delete_printer_handle: denied by handle\n"));
return WERR_ACCESS_DENIED;
}
-
- /* this does not need a become root since the access check has been
+
+ /* this does not need a become root since the access check has been
done on the handle already */
-
+
if (del_a_printer( Printer->sharename ) != 0) {
DEBUG(3,("Error deleting printer %s\n", Printer->sharename));
return WERR_BADFID;
@@ -378,15 +378,15 @@ static bool get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number,
struct share_params **params)
{
Printer_entry *Printer = find_printer_index_by_hnd(p, hnd);
-
+
if (!Printer) {
DEBUG(2,("get_printer_snum: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd)));
return False;
}
-
+
switch (Printer->printer_type) {
- case SPLHND_PRINTER:
- DEBUG(4,("short name:%s\n", Printer->sharename));
+ case SPLHND_PRINTER:
+ DEBUG(4,("short name:%s\n", Printer->sharename));
*number = print_queue_snum(Printer->sharename);
return (*number != -1);
case SPLHND_SERVER:
@@ -413,7 +413,7 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename
/* it's a print server */
if (*handlename=='\\' && *(handlename+1)=='\\' && !strchr_m(handlename+2, '\\')) {
DEBUGADD(4,("Printer is a print server\n"));
- Printer->printer_type = SPLHND_SERVER;
+ Printer->printer_type = SPLHND_SERVER;
}
/* it's a printer (set_printer_hnd_name() will handle port monitors */
else {
@@ -425,9 +425,9 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename
}
/****************************************************************************
- Set printer handle name.. Accept names like \\server, \\server\printer,
+ Set printer handle name.. Accept names like \\server, \\server\printer,
\\server\SHARE, & "\\server\,XcvMonitor Standard TCP/IP Port" See
- the MSDN docs regarding OpenPrinter() for details on the XcvData() and
+ the MSDN docs regarding OpenPrinter() for details on the XcvData() and
XcvDataPort() interface.
****************************************************************************/
@@ -441,7 +441,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
bool found=False;
NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR result;
-
+
DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename)));
aprinter = handlename;
@@ -455,14 +455,14 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
else {
servername = "";
}
-
+
/* save the servername to fill in replies on this handle */
-
+
if ( !is_myname_or_ipaddr( servername ) )
return False;
fstrcpy( Printer->servername, servername );
-
+
if ( Printer->printer_type == SPLHND_SERVER )
return True;
@@ -470,9 +470,9 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
return False;
DEBUGADD(5, ("searching for [%s]\n", aprinter ));
-
+
/* check for the Port Monitor Interface */
-
+
if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) {
Printer->printer_type = SPLHND_PORTMON_TCP;
fstrcpy(sname, SPL_XCV_MONITOR_TCPMON);
@@ -484,12 +484,12 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
found = True;
}
- /* Search all sharenames first as this is easier than pulling
+ /* Search all sharenames first as this is easier than pulling
the printer_info_2 off of disk. Don't use find_service() since
that calls out to map_username() */
-
+
/* do another loop to look for printernames */
-
+
for (snum=0; !found && snum<n_services; snum++) {
/* no point going on if this is not a printer */
@@ -505,7 +505,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
/* no point looking up the printer object if
we aren't allowing printername != sharename */
-
+
if ( lp_force_printername(snum) )
continue;
@@ -518,7 +518,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
sname, dos_errstr(result)));
continue;
}
-
+
/* printername is always returned as \\server\printername */
if ( !(printername = strchr_m(&printer->info_2->printername[2], '\\')) ) {
DEBUG(0,("set_printer_hnd_name: info2->printername in wrong format! [%s]\n",
@@ -526,17 +526,17 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
free_a_printer( &printer, 2);
continue;
}
-
+
printername++;
-
+
if ( strequal(printername, aprinter) ) {
free_a_printer( &printer, 2);
found = True;
break;
}
-
+
DEBUGADD(10, ("printername: %s\n", printername));
-
+
free_a_printer( &printer, 2);
}
@@ -546,7 +546,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
DEBUGADD(4,("Printer not found\n"));
return False;
}
-
+
DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname));
fstrcpy(Printer->sharename, sname);
@@ -568,28 +568,28 @@ static bool open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3
return False;
ZERO_STRUCTP(new_printer);
-
+
if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) {
SAFE_FREE(new_printer);
return False;
}
-
+
/* Add to the internal list. */
DLIST_ADD(printers_list, new_printer);
-
+
new_printer->notify.option=NULL;
-
+
if ( !(new_printer->ctx = talloc_init("Printer Entry [%p]", hnd)) ) {
DEBUG(0,("open_printer_hnd: talloc_init() failed!\n"));
close_printer_handle(p, hnd);
return False;
}
-
+
if (!set_printer_hnd_printertype(new_printer, name)) {
close_printer_handle(p, hnd);
return False;
}
-
+
if (!set_printer_hnd_name(new_printer, name)) {
close_printer_handle(p, hnd);
return False;
@@ -619,10 +619,10 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
SPOOL_NOTIFY_OPTION *option = p->notify.option;
uint32 i, j;
- /*
+ /*
* Flags should always be zero when the change notify
* is registered by the client's spooler. A user Win32 app
- * might use the flags though instead of the NOTIFY_OPTION_INFO
+ * might use the flags though instead of the NOTIFY_OPTION_INFO
* --jerry
*/
@@ -635,24 +635,24 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
p->notify.flags, notify_type, notify_field);
for (i = 0; i < option->count; i++) {
-
+
/* Check match for notify_type */
-
+
if (option->ctr.type[i].type != notify_type)
continue;
/* Check match for field */
-
+
for (j = 0; j < option->ctr.type[i].count; j++) {
if (option->ctr.type[i].fields[j] == notify_field) {
return True;
--
Samba Shared Repository
More information about the samba-cvs
mailing list