summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-03-15 08:14:10 +0000
committerGerald Carter <jerry@samba.org>2002-03-15 08:14:10 +0000
commit65c007b583e2107f5ad1ba6733d3e578a143863e (patch)
treea11e1da607580d291ce74926417126ce22f34852 /source3/printing
parentd19e06c0c620046658621fcec7c2cda9a77ceac3 (diff)
downloadsamba-65c007b583e2107f5ad1ba6733d3e578a143863e.tar.gz
samba-65c007b583e2107f5ad1ba6733d3e578a143863e.tar.bz2
samba-65c007b583e2107f5ad1ba6733d3e578a143863e.zip
syncing up printing code with SAMBA_2_2 (already done some merges
in the reverse). * add in new printer change notify code from SAMBA_2_2 * add in se_map_standard() from 2.2 in _spoolss_open_printer_ex() * sync up the _print_queue_struct in smb.h (why did someone change the user/file names in fs_user/fs_file (or vice-versa) ? ) * sync up some cli_spoolss_XXX functions (This used to be commit 5760315c1de4033fdc22684c940f18010010924f)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/lpq_parse.c72
-rw-r--r--source3/printing/nt_printing.c66
-rw-r--r--source3/printing/printing.c12
3 files changed, 96 insertions, 54 deletions
diff --git a/source3/printing/lpq_parse.c b/source3/printing/lpq_parse.c
index b513806473..13b87045cd 100644
--- a/source3/printing/lpq_parse.c
+++ b/source3/printing/lpq_parse.c
@@ -145,25 +145,25 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
buf->size = atoi(tok[TOTALTOK]);
buf->status = strequal(tok[RANKTOK],"active")?LPQ_PRINTING:LPQ_QUEUED;
buf->time = time(NULL);
- StrnCpy(buf->user,tok[USERTOK],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[FILETOK],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[USERTOK],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[FILETOK],sizeof(buf->fs_file)-1);
if ((FILETOK + 1) != TOTALTOK) {
int bufsize;
int i;
- bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
+ bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
for (i = (FILETOK + 1); i < TOTALTOK; i++) {
- safe_strcat(buf->file," ",bufsize);
- safe_strcat(buf->file,tok[i],bufsize - 1);
- bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
+ safe_strcat(buf->fs_file," ",bufsize);
+ safe_strcat(buf->fs_file,tok[i],bufsize - 1);
+ bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
if (bufsize <= 0) {
break;
}
}
/* Ensure null termination. */
- buf->file[sizeof(buf->file)-1] = '\0';
+ buf->fs_file[sizeof(buf->fs_file)-1] = '\0';
}
#ifdef PRIOTOK
@@ -269,34 +269,34 @@ static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
buf->time = LPRng_time(tokarr[LPRNG_TIMETOK]);
- StrnCpy(buf->user,tokarr[LPRNG_USERTOK],sizeof(buf->user)-1);
+ StrnCpy(buf->fs_user,tokarr[LPRNG_USERTOK],sizeof(buf->fs_user)-1);
/* The '@hostname' prevents windows from displaying the printing icon
* for the current user on the taskbar. Plop in a null.
*/
- if ((cptr = strchr_m(buf->user,'@')) != NULL) {
+ if ((cptr = strchr_m(buf->fs_user,'@')) != NULL) {
*cptr = '\0';
}
- StrnCpy(buf->file,tokarr[LPRNG_FILETOK],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_file,tokarr[LPRNG_FILETOK],sizeof(buf->fs_file)-1);
if ((LPRNG_FILETOK + 1) != LPRNG_TOTALTOK) {
int bufsize;
int i;
- bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
+ bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
for (i = (LPRNG_FILETOK + 1); i < LPRNG_TOTALTOK; i++) {
- safe_strcat(buf->file," ",bufsize);
- safe_strcat(buf->file,tokarr[i],bufsize - 1);
- bufsize = sizeof(buf->file) - strlen(buf->file) - 1;
+ safe_strcat(buf->fs_file," ",bufsize);
+ safe_strcat(buf->fs_file,tokarr[i],bufsize - 1);
+ bufsize = sizeof(buf->fs_file) - strlen(buf->fs_file) - 1;
if (bufsize <= 0) {
break;
}
}
/* Ensure null termination. */
- buf->file[sizeof(buf->file)-1] = '\0';
+ buf->fs_file[sizeof(buf->fs_file)-1] = '\0';
}
return(True);
@@ -359,8 +359,8 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[0],"HELD")?LPQ_PAUSED:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->user,tok[3],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[2],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[3],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[2],sizeof(buf->fs_file)-1);
}
else
{
@@ -393,8 +393,8 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[2],"RUNNING")?LPQ_PRINTING:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->user,tok[5],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[4],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[5],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[4],sizeof(buf->fs_file)-1);
}
@@ -455,14 +455,14 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
fstrcpy(tok[0],"STDIN");
buf->size = atoi(tok[1]);
- StrnCpy(buf->file,tok[0],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_file,tok[0],sizeof(buf->fs_file)-1);
/* fill things from header line */
buf->time = jobtime;
buf->job = jobid;
buf->status = jobstat;
buf->priority = jobprio;
- StrnCpy(buf->user,jobuser,sizeof(buf->user)-1);
+ StrnCpy(buf->fs_user,jobuser,sizeof(buf->fs_user)-1);
return(True);
}
@@ -488,7 +488,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
/* the 2nd, 5th & 7th column must be integer */
if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4]) || !isdigit((int)*tok[6])) return(False);
jobid = atoi(tok[1]);
- StrnCpy(jobuser,tok[2],sizeof(buf->user)-1);
+ StrnCpy(jobuser,tok[2],sizeof(buf->fs_user)-1);
jobprio = atoi(tok[4]);
/* process time */
@@ -578,8 +578,8 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
buf->status = LPQ_QUEUED;
buf->priority = 0;
buf->time = EntryTime(tok, 4, count, 7);
- StrnCpy(buf->user,tok[2],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[2],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[2],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[2],sizeof(buf->fs_file)-1);
return(True);
}
@@ -639,8 +639,8 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->user,tok[1],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[6],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[1],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[6],sizeof(buf->fs_file)-1);
return(True);
}
@@ -709,8 +709,8 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
buf->status = strequal(tok[0],"active")?LPQ_PRINTING:LPQ_QUEUED;
buf->priority = 0;
buf->time = time(NULL);
- StrnCpy(buf->user,tok[1],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[6],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[1],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[6],sizeof(buf->fs_file)-1);
return(True);
}
@@ -766,8 +766,8 @@ static BOOL parse_lpq_softq(char *line,print_queue_struct *buf,BOOL first)
buf->job = atoi(tok[0]);
buf->size = atoi(tok[count+6]);
buf->priority = atoi(tok[count+5]);
- StrnCpy(buf->user,tok[count+7],sizeof(buf->user)-1);
- StrnCpy(buf->file,tok[count+8],sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user,tok[count+7],sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file,tok[count+8],sizeof(buf->fs_file)-1);
buf->time = time(NULL); /* default case: take current time */
{
time_t jobtime;
@@ -863,8 +863,8 @@ static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
buf->priority = 0;
buf->size = atoi(parse_line.size);
buf->time = time(NULL);
- StrnCpy(buf->user, parse_line.owner, sizeof(buf->user)-1);
- StrnCpy(buf->file, parse_line.jobname, sizeof(buf->file)-1);
+ StrnCpy(buf->fs_user, parse_line.owner, sizeof(buf->fs_user)-1);
+ StrnCpy(buf->fs_file, parse_line.jobname, sizeof(buf->fs_file)-1);
if (strequal(parse_line.status, LPRNT_PRINTING))
buf->status = LPQ_PRINTING;
else if (strequal(parse_line.status, LPRNT_PAUSED))
@@ -922,7 +922,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
/* Get the job name */
parse_line.space2[0] = '\0';
trim_string(parse_line.jobname, NULL, " ");
- StrnCpy(buf->file, parse_line.jobname, sizeof(buf->file)-1);
+ StrnCpy(buf->fs_file, parse_line.jobname, sizeof(buf->fs_file)-1);
buf->priority = 0;
buf->size = atoi(parse_line.size);
@@ -940,7 +940,7 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
!strequal(parse_line.status, LPROS2_WAITING))
return(False);
- StrnCpy(buf->user, parse_line.owner, sizeof(buf->user)-1);
+ StrnCpy(buf->fs_user, parse_line.owner, sizeof(buf->fs_user)-1);
if (strequal(parse_line.status, LPROS2_PRINTING))
buf->status = LPQ_PRINTING;
else if (strequal(parse_line.status, LPROS2_PAUSED))
@@ -986,10 +986,10 @@ static BOOL parse_lpq_vlp(char *line,print_queue_struct *buf,BOOL first)
buf->time = atoi(tok);
break;
case 4:
- fstrcpy(buf->user, tok);
+ fstrcpy(buf->fs_user, tok);
break;
case 5:
- fstrcpy(buf->file, tok);
+ fstrcpy(buf->fs_file, tok);
break;
}
toknum++;
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 43667a674d..4cd9a0ec91 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -42,7 +42,13 @@ static TDB_CONTEXT *tdb_printers; /* used for printers files */
/* Map generic permissions to printer object specific permissions */
-struct generic_mapping printer_generic_mapping = {
+GENERIC_MAPPING printer_generic_mapping = {
+ PRINTER_READ,
+ PRINTER_EXECUTE,
+ PRINTER_ALL_ACCESS
+};
+
+STANDARD_MAPPING printer_std_mapping = {
PRINTER_READ,
PRINTER_WRITE,
PRINTER_EXECUTE,
@@ -2160,10 +2166,6 @@ void free_nt_printer_param(NT_PRINTER_PARAM **param_ptr)
NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename)
{
-/*
- * should I init this ones ???
- nt_devmode->devicename
-*/
char adevice[32];
NT_DEVICEMODE *nt_devmode = (NT_DEVICEMODE *)malloc(sizeof(NT_DEVICEMODE));
@@ -2485,11 +2487,8 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
snum = lp_servicenumber(sharename);
slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name());
- strupper(info.servername);
- slprintf(info.printername, sizeof(info.printername)-1, "\\\\%s\\",
- get_called_name());
- strupper(info.printername);
- fstrcat(info.printername, sharename);
+ slprintf(info.printername, sizeof(info.printername)-1, "\\\\%s\\%s",
+ get_called_name(), sharename);
fstrcpy(info.sharename, sharename);
fstrcpy(info.portname, SAMBA_PRINTER_PORT_NAME);
fstrcpy(info.drivername, lp_printerdriver(snum));
@@ -2605,8 +2604,7 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
info.attributes |= (PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK);
/* Restore the stripped strings. */
- slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s",
- get_called_name());
+ slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name());
slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", get_called_name(),
info.printername);
fstrcpy(info.printername, printername);
@@ -2739,8 +2737,17 @@ static uint32 rev_changeid(void)
get_process_uptime(&tv);
+#if 1 /* JERRY */
/* Return changeid as msec since spooler restart */
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+#else
+ /*
+ * This setting seems to work well but is too untested
+ * to replace the above calculation. Left in for experiementation
+ * of the reader --jerry (Tue Mar 12 09:15:05 CST 2002)
+ */
+ return tv.tv_sec * 10 + tv.tv_usec / 100000;
+#endif
}
/*
@@ -2857,11 +2864,44 @@ static uint32 set_driver_init_2(NT_PRINTER_INFO_LEVEL_2 *info_ptr)
ZERO_STRUCT(info.devmode->devicename);
fstrcpy(info.devmode->devicename, info_ptr->printername);
+
+ /*
+ * NT/2k does not change out the entire DeviceMode of a printer
+ * when changing the driver. Only the driverextra, private, &
+ * driverversion fields. --jerry (Thu Mar 14 08:58:43 CST 2002)
+ */
+
+#if 0 /* JERRY */
+
/*
* Bind the saved DEVMODE to the new the printer.
*/
free_nt_devicemode(&info_ptr->devmode);
info_ptr->devmode = info.devmode;
+#else
+ /* copy the entire devmode if we currently don't have one */
+
+ if (!info_ptr->devmode) {
+ DEBUG(10,("set_driver_init_2: Current Devmode is NULL. Copying entire Device Mode\n"));
+ info_ptr->devmode = info.devmode;
+ }
+ else {
+ /* only set the necessary fields */
+
+ DEBUG(10,("set_driver_init_2: Setting driverversion [0x%x] and private data [0x%x]\n",
+ info.devmode->driverversion, info.devmode->driverextra));
+
+ info_ptr->devmode->driverversion = info.devmode->driverversion;
+
+ SAFE_FREE(info_ptr->devmode->private);
+ info_ptr->devmode->private = NULL;
+
+ if (info.devmode->driverversion)
+ info_ptr->devmode->private = memdup(info.devmode->private, info.devmode->driverversion);
+
+ free_nt_devicemode(&info.devmode);
+ }
+#endif
DEBUG(10,("set_driver_init_2: Set printer [%s] init DEVMODE for driver [%s]\n",
info_ptr->printername, info_ptr->drivername));
@@ -3934,6 +3974,7 @@ BOOL print_time_access_check(int snum)
return ok;
}
+#if 0 /* JERRY - not used */
/****************************************************************************
Attempt to write a default device.
*****************************************************************************/
@@ -4005,3 +4046,4 @@ WERROR printer_write_default_dev(int snum, const PRINTER_DEFAULT *printer_defaul
free_a_printer(&printer, 2);
return result;
}
+#endif /* JERRY */
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 758c855188..97eaaebcc4 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -161,8 +161,8 @@ static void print_unix_job(int snum, print_queue_struct *q)
pj.spooled = True;
pj.smbjob = False;
fstrcpy(pj.filename, "");
- fstrcpy(pj.jobname, q->file);
- fstrcpy(pj.user, q->user);
+ fstrcpy(pj.jobname, q->fs_file);
+ fstrcpy(pj.user, q->fs_user);
pj.snum = snum;
print_job_store(jobid, &pj);
@@ -217,7 +217,7 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void
}
for (i=0;i<ts->qcount;i++) {
- int qid = print_parse_jobid(ts->queue[i].file);
+ int qid = print_parse_jobid(ts->queue[i].fs_file);
if (jobid == qid) break;
}
@@ -410,7 +410,7 @@ static void print_queue_update_background(int snum)
fill in any system job numbers as we go
*/
for (i=0; i<qcount; i++) {
- int jobid = print_parse_jobid(queue[i].file);
+ int jobid = print_parse_jobid(queue[i].fs_file);
if (jobid == -1) {
/* assume its a unix print job */
@@ -1140,8 +1140,8 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void *
ts->queue[i].status = pjob.status;
ts->queue[i].priority = 1;
ts->queue[i].time = pjob.starttime;
- fstrcpy(ts->queue[i].user, pjob.user);
- fstrcpy(ts->queue[i].file, pjob.jobname);
+ fstrcpy(ts->queue[i].fs_user, pjob.user);
+ fstrcpy(ts->queue[i].fs_file, pjob.jobname);
ts->qcount++;