1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-03 04:23:50 +03:00

Sorry JF - no billable hours :-). I fixed the "stream of events" problem

with PCL drivers. The problem was we were updating the changeid on every
SETPRINTERDATA/DELETEPRINTERDATA call. We should not do this, we should
just update the 'setprinter' called count. We update the changeid on calls
to SETPRINTER/ADDPRINTER/ADDPRINTEREX etc. Also fixed the correct returning
of the create time on printers.
Jeremy.
This commit is contained in:
Jeremy Allison
-
parent 0435af4417
commit 521f09829f
4 changed files with 49 additions and 22 deletions

View File

@@ -1737,6 +1737,7 @@ NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename);
NT_DEVICEMODE *dup_nt_devicemode(NT_DEVICEMODE *nt_devicemode); NT_DEVICEMODE *dup_nt_devicemode(NT_DEVICEMODE *nt_devicemode);
void free_nt_devicemode(NT_DEVICEMODE **devmode_ptr); void free_nt_devicemode(NT_DEVICEMODE **devmode_ptr);
void get_printer_subst_params(int snum, fstring *printername, fstring *sharename, fstring *portname); void get_printer_subst_params(int snum, fstring *printername, fstring *sharename, fstring *portname);
uint32 mod_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level);
uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level); uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level);
uint32 get_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, fstring sharename); uint32 get_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, fstring sharename);
uint32 free_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level); uint32 free_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level);

View File

@@ -1230,14 +1230,12 @@ uint32 del_a_printer(char *sharename)
/**************************************************************************** /****************************************************************************
****************************************************************************/ ****************************************************************************/
static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info) static uint32 update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
{ {
pstring key; pstring key;
char *buf; char *buf;
int buflen, len, ret; int buflen, len, ret;
TDB_DATA kbuf, dbuf; TDB_DATA kbuf, dbuf;
NTTIME time_nt;
time_t time_unix = time(NULL);
/* /*
* in addprinter: no servername and the printer is the name * in addprinter: no servername and the printer is the name
@@ -1264,10 +1262,6 @@ static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
* behind a SAMBA share. * behind a SAMBA share.
*/ */
unix_to_nt_time(&time_nt, time_unix);
info->changeid=time_nt.low;
info->c_setprinter++;
buf = NULL; buf = NULL;
buflen = 0; buflen = 0;
@@ -1684,6 +1678,7 @@ static uint32 get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
info.untiltime = 0; /* Minutes since 12:00am GMT */ info.untiltime = 0; /* Minutes since 12:00am GMT */
info.priority = 1; info.priority = 1;
info.default_priority = 1; info.default_priority = 1;
info.setuptime = (uint32)time(NULL);
if ((info.devmode = construct_nt_devicemode(info.printername)) == NULL) if ((info.devmode = construct_nt_devicemode(info.printername)) == NULL)
goto fail; goto fail;
@@ -1725,12 +1720,8 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
kbuf.dsize = strlen(key)+1; kbuf.dsize = strlen(key)+1;
dbuf = tdb_fetch(tdb, kbuf); dbuf = tdb_fetch(tdb, kbuf);
#if 1 /* JRATEST */
if (!dbuf.dptr) if (!dbuf.dptr)
return get_a_printer_2_default(info_ptr, sharename); return get_a_printer_2_default(info_ptr, sharename);
#else
if (!dbuf.dptr) return 1;
#endif
len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddfffffPfffff", len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddfffffPfffff",
&info.attributes, &info.attributes,
@@ -1762,9 +1753,7 @@ static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len); len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
len += unpack_specifics(&info.specific,dbuf.dptr+len, dbuf.dsize-len); len += unpack_specifics(&info.specific,dbuf.dptr+len, dbuf.dsize-len);
#if 1 /* JRATEST */
nt_printing_getsec(sharename, &info.secdesc_buf); nt_printing_getsec(sharename, &info.secdesc_buf);
#endif /* JRATEST */
safe_free(dbuf.dptr); safe_free(dbuf.dptr);
*info_ptr=memdup(&info, sizeof(info)); *info_ptr=memdup(&info, sizeof(info));
@@ -1859,7 +1848,36 @@ void get_printer_subst_params(int snum, fstring *printername, fstring *sharename
*/ */
/**************************************************************************** /****************************************************************************
Modify a printer. This is called from SETPRINTERDATA/DELETEPRINTERDATA.
****************************************************************************/ ****************************************************************************/
uint32 mod_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
uint32 success;
dump_a_printer(printer, level);
switch (level)
{
case 2:
{
printer.info_2->c_setprinter++;
success=update_a_printer_2(printer.info_2);
break;
}
default:
success=1;
break;
}
return (success);
}
/****************************************************************************
Add a printer. This is called from ADDPRINTER(EX) and also SETPRINTER.
We split this out from mod_a_printer as it updates the id's and timestamps.
****************************************************************************/
uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level) uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{ {
uint32 success; uint32 success;
@@ -1870,7 +1888,17 @@ uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{ {
case 2: case 2:
{ {
success=add_a_printer_2(printer.info_2); /*
* Update the changestamp.
* Note we must *not* do this in mod_a_printer().
*/
NTTIME time_nt;
time_t time_unix = time(NULL);
unix_to_nt_time(&time_nt, time_unix);
printer.info_2->changeid=time_nt.low;
printer.info_2->c_setprinter++;
success=update_a_printer_2(printer.info_2);
break; break;
} }
default: default:

View File

@@ -1816,7 +1816,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring
counter_printer_0 *session_counter; counter_printer_0 *session_counter;
uint32 global_counter; uint32 global_counter;
struct tm *t; struct tm *t;
time_t setup_time = time(NULL); time_t setuptime;
print_queue_struct *queue=NULL; print_queue_struct *queue=NULL;
print_status_struct status; print_status_struct status;
@@ -1869,8 +1869,8 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring
printer->total_jobs = 0; printer->total_jobs = 0;
printer->total_bytes = 0; printer->total_bytes = 0;
t=gmtime(&setup_time); setuptime = (time_t)ntprinter->info_2->setuptime;
ntprinter->info_2->setuptime = (uint32)setup_time; /* FIXME !! */ t=gmtime(&setuptime);
printer->year = t->tm_year+1900; printer->year = t->tm_year+1900;
printer->month = t->tm_mon+1; printer->month = t->tm_mon+1;
@@ -4957,7 +4957,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx,
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
} }
ZERO_STRUCTP(*data_out); memset(*data_out,'\0',in_data_len);
memcpy(*data_out, data, (size_t)data_len); memcpy(*data_out, data, (size_t)data_len);
*out_data_len=data_len; *out_data_len=data_len;
@@ -5009,7 +5009,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle,
if (!add_a_specific_param(printer->info_2, param)) if (!add_a_specific_param(printer->info_2, param))
status = ERROR_INVALID_PARAMETER; status = ERROR_INVALID_PARAMETER;
else else
status = add_a_printer(*printer, 2); status = mod_a_printer(*printer, 2);
free_a_printer(&printer, 2); free_a_printer(&printer, 2);
return status; return status;
@@ -5051,7 +5051,7 @@ uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value)
if(!unlink_specific_param_if_exist(printer->info_2, &param)) if(!unlink_specific_param_if_exist(printer->info_2, &param))
status = ERROR_INVALID_PARAMETER; status = ERROR_INVALID_PARAMETER;
else else
status = add_a_printer(*printer, 2); status = mod_a_printer(*printer, 2);
free_a_printer(&printer, 2); free_a_printer(&printer, 2);
return status; return status;

View File

@@ -318,10 +318,8 @@ void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, NT_USER_TOKEN
ctx_p->ngroups = ngroups; ctx_p->ngroups = ngroups;
safe_free(ctx_p->groups); safe_free(ctx_p->groups);
#if 1 /* JRATEST */
if (token && (token == ctx_p->token)) if (token && (token == ctx_p->token))
smb_panic("DUPLICATE_TOKEN"); smb_panic("DUPLICATE_TOKEN");
#endif
delete_nt_token(&ctx_p->token); delete_nt_token(&ctx_p->token);