summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-07-11 18:01:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:14 -0500
commitfbdcf2663b56007a438ac4f0d8d82436b1bfe688 (patch)
tree4e42c1f061391cea3d640152fd240682cbf4fd9a /source3/printing
parent5bf62a0c3cc95abe918f3e772bb10e0a90fdce22 (diff)
downloadsamba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.gz
samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.bz2
samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.zip
r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c28
-rw-r--r--source3/printing/print_generic.c11
-rw-r--r--source3/printing/printfsp.c20
-rw-r--r--source3/printing/printing.c45
4 files changed, 66 insertions, 38 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index bcdf0e0462..4b71f6e0b6 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1281,6 +1281,8 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
SMB_STRUCT_STAT stat_buf;
BOOL bad_path;
+ NTSTATUS status;
+
SET_STAT_INVALID(st);
SET_STAT_INVALID(stat_buf);
new_create_time = (time_t)0;
@@ -1291,16 +1293,16 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
driver_unix_convert(filepath,conn,NULL,&bad_path,&stat_buf);
- fsp = open_file_ntcreate(conn, filepath, &stat_buf,
+ status = open_file_ntcreate(conn, filepath, &stat_buf,
FILE_GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
0,
FILE_ATTRIBUTE_NORMAL,
INTERNAL_OPEN_ONLY,
- NULL);
+ NULL, &fsp);
- if (!fsp) {
+ if (!NT_STATUS_IS_OK(status)) {
/* Old file not found, so by definition new file is in fact newer */
DEBUG(10,("file_version_is_newer: Can't open old file [%s], errno = %d\n",
filepath, errno));
@@ -1327,16 +1329,16 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
pstrcpy(filepath, new_file);
driver_unix_convert(filepath,conn,NULL,&bad_path,&stat_buf);
- fsp = open_file_ntcreate(conn, filepath, &stat_buf,
+ status = open_file_ntcreate(conn, filepath, &stat_buf,
FILE_GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
0,
FILE_ATTRIBUTE_NORMAL,
INTERNAL_OPEN_ONLY,
- NULL);
+ NULL, &fsp);
- if (!fsp) {
+ if (!NT_STATUS_IS_OK(status)) {
/* New file not found, this shouldn't occur if the caller did its job */
DEBUG(3,("file_version_is_newer: Can't open new file [%s], errno = %d\n",
filepath, errno));
@@ -1405,6 +1407,7 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_
BOOL bad_path;
SMB_STRUCT_STAT st;
connection_struct *conn;
+ NTSTATUS status;
SET_STAT_INVALID(st);
@@ -1460,16 +1463,16 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_
goto error_exit;
}
- fsp = open_file_ntcreate(conn, driverpath, &st,
+ status = open_file_ntcreate(conn, driverpath, &st,
FILE_GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
0,
FILE_ATTRIBUTE_NORMAL,
INTERNAL_OPEN_ONLY,
- NULL);
+ NULL, &fsp);
- if (!fsp) {
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(3,("get_correct_cversion: Can't open file [%s], errno = %d\n",
driverpath, errno));
*perr = WERR_ACCESS_DENIED;
@@ -4368,7 +4371,8 @@ WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_print
fstrcpy( servername, print_hnd->servername );
else {
fstrcpy( servername, "%L" );
- standard_sub_basic( "", servername, sizeof(servername)-1 );
+ standard_sub_basic( "", "", servername,
+ sizeof(servername)-1 );
}
result = get_a_printer_2( (*pp_printer)->info_2, servername, sharename );
@@ -5441,7 +5445,7 @@ BOOL print_access_check(struct current_user *user, int snum, int access_type)
Check the time parameters allow a print operation.
*****************************************************************************/
-BOOL print_time_access_check(int snum)
+BOOL print_time_access_check(const char *servicename)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
BOOL ok = False;
@@ -5449,7 +5453,7 @@ BOOL print_time_access_check(int snum)
struct tm *t;
uint32 mins;
- if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename)))
return False;
if (printer->info_2->starttime == 0 && printer->info_2->untiltime == 0)
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index 1ea762695b..aef4e50bfa 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -30,7 +30,9 @@ for local substitution strings
static int print_run_command(int snum, const char* printername, BOOL do_sub,
const char *command, int *outfd, ...)
{
-
+ extern struct current_user current_user;
+ extern userdom_struct current_user_info;
+
pstring syscmd;
char *arg;
int ret;
@@ -56,7 +58,12 @@ static int print_run_command(int snum, const char* printername, BOOL do_sub,
pstring_sub( syscmd, "%p", printername );
if ( do_sub && snum != -1 )
- standard_sub_snum(snum,syscmd,sizeof(syscmd));
+ standard_sub_advanced(lp_servicename(snum),
+ current_user_info.unix_name, "",
+ current_user.ut.gid,
+ get_current_username(),
+ current_user_info.domain,
+ syscmd, sizeof(syscmd));
ret = smbrun(syscmd,outfd);
diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c
index c248851822..5278c60f99 100644
--- a/source3/printing/printfsp.c
+++ b/source3/printing/printfsp.c
@@ -28,15 +28,19 @@ open a print file and setup a fsp for it. This is a wrapper around
print_job_start().
***************************************************************************/
-files_struct *print_fsp_open(connection_struct *conn, const char *fname)
+NTSTATUS print_fsp_open(connection_struct *conn, const char *fname,
+ files_struct **result)
{
int jobid;
SMB_STRUCT_STAT sbuf;
- files_struct *fsp = file_new(conn);
+ files_struct *fsp;
fstring name;
+ NTSTATUS status;
- if(!fsp)
- return NULL;
+ status = file_new(conn, &fsp);
+ if(!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
fstrcpy( name, "Remote Downlevel Document");
if (fname) {
@@ -50,8 +54,9 @@ files_struct *print_fsp_open(connection_struct *conn, const char *fname)
jobid = print_job_start(&current_user, SNUM(conn), name, NULL);
if (jobid == -1) {
+ status = map_nt_error_from_unix(errno);
file_free(fsp);
- return NULL;
+ return status;
}
/* Convert to RAP id. */
@@ -60,7 +65,7 @@ files_struct *print_fsp_open(connection_struct *conn, const char *fname)
/* We need to delete the entry in the tdb. */
pjob_delete(lp_const_servicename(SNUM(conn)), jobid);
file_free(fsp);
- return NULL;
+ return NT_STATUS_ACCESS_DENIED; /* No errno around here */
}
/* setup a full fsp */
@@ -87,7 +92,8 @@ files_struct *print_fsp_open(connection_struct *conn, const char *fname)
conn->num_files_open++;
- return fsp;
+ *result = fsp;
+ return NT_STATUS_OK;
}
/****************************************************************************
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 9dd6bec0be..bb756c8870 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -839,10 +839,9 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void
Check if the print queue has been updated recently enough.
****************************************************************************/
-static void print_cache_flush(int snum)
+static void print_cache_flush(const char *sharename)
{
fstring key;
- const char *sharename = lp_const_servicename(snum);
struct tdb_print_db *pdb = get_print_db_byname(sharename);
if (!pdb)
@@ -1439,6 +1438,8 @@ update the internal database from the system print queue for a queue
static void print_queue_update(int snum, BOOL force)
{
+ extern struct current_user current_user;
+ extern userdom_struct current_user_info;
fstring key;
fstring sharename;
pstring lpqcommand, lprmcommand;
@@ -1456,12 +1457,22 @@ static void print_queue_update(int snum, BOOL force)
pstrcpy( lpqcommand, lp_lpqcommand(snum));
string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand),
False, False, False );
- standard_sub_snum( snum, lpqcommand, sizeof(lpqcommand) );
+ standard_sub_advanced(lp_servicename(snum),
+ current_user_info.unix_name, "",
+ current_user.ut.gid,
+ get_current_username(),
+ current_user_info.domain,
+ lpqcommand, sizeof(lpqcommand) );
pstrcpy( lprmcommand, lp_lprmcommand(snum));
string_sub2( lprmcommand, "%p", PRINTERNAME(snum), sizeof(lprmcommand),
False, False, False );
- standard_sub_snum( snum, lprmcommand, sizeof(lprmcommand) );
+ standard_sub_advanced(lp_servicename(snum),
+ current_user_info.unix_name, "",
+ current_user.ut.gid,
+ get_current_username(),
+ current_user_info.domain,
+ lprmcommand, sizeof(lprmcommand) );
/*
* Make sure that the background queue process exists.
@@ -1781,7 +1792,7 @@ NT_DEVICEMODE *print_job_devmode(const char* sharename, uint32 jobid)
Set the place in the queue for a job.
****************************************************************************/
-BOOL print_job_set_place(int snum, uint32 jobid, int place)
+BOOL print_job_set_place(const char *sharename, uint32 jobid, int place)
{
DEBUG(2,("print_job_set_place not implemented yet\n"));
return False;
@@ -1791,9 +1802,8 @@ BOOL print_job_set_place(int snum, uint32 jobid, int place)
Set the name of a job. Only possible for owner.
****************************************************************************/
-BOOL print_job_set_name(int snum, uint32 jobid, char *name)
+BOOL print_job_set_name(const char *sharename, uint32 jobid, char *name)
{
- const char* sharename = lp_const_servicename(snum);
struct printjob *pjob;
pjob = print_job_find(sharename, jobid);
@@ -1930,9 +1940,10 @@ static BOOL print_job_delete1(int snum, uint32 jobid)
Return true if the current user owns the print job.
****************************************************************************/
-static BOOL is_owner(struct current_user *user, int snum, uint32 jobid)
+static BOOL is_owner(struct current_user *user, const char *servicename,
+ uint32 jobid)
{
- struct printjob *pjob = print_job_find(lp_const_servicename(snum), jobid);
+ struct printjob *pjob = print_job_find(servicename, jobid);
user_struct *vuser;
if (!pjob || !user)
@@ -1958,7 +1969,7 @@ BOOL print_job_delete(struct current_user *user, int snum, uint32 jobid, WERROR
*errcode = WERR_OK;
- owner = is_owner(user, snum, jobid);
+ owner = is_owner(user, lp_const_servicename(snum), jobid);
/* Check access against security descriptor or whether the user
owns their job. */
@@ -2037,7 +2048,7 @@ BOOL print_job_pause(struct current_user *user, int snum, uint32 jobid, WERROR *
return False;
}
- if (!is_owner(user, snum, jobid) &&
+ if (!is_owner(user, lp_const_servicename(snum), jobid) &&
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
DEBUG(3, ("pause denied by security descriptor\n"));
@@ -2061,7 +2072,7 @@ pause, or resume print job. User name: %s. Printer name: %s.",
}
/* force update the database */
- print_cache_flush(snum);
+ print_cache_flush(lp_const_servicename(snum));
/* Send a printer notify message */
@@ -2097,7 +2108,7 @@ BOOL print_job_resume(struct current_user *user, int snum, uint32 jobid, WERROR
return False;
}
- if (!is_owner(user, snum, jobid) &&
+ if (!is_owner(user, lp_const_servicename(snum), jobid) &&
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
DEBUG(3, ("resume denied by security descriptor\n"));
*errcode = WERR_ACCESS_DENIED;
@@ -2119,7 +2130,7 @@ pause, or resume print job. User name: %s. Printer name: %s.",
}
/* force update the database */
- print_cache_flush(snum);
+ print_cache_flush(lp_const_servicename(snum));
/* Send a printer notify message */
@@ -2325,7 +2336,7 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname, NT_DE
return (uint32)-1;
}
- if (!print_time_access_check(snum)) {
+ if (!print_time_access_check(lp_servicename(snum))) {
DEBUG(3, ("print_job_start: job start denied by time check\n"));
release_print_db(pdb);
return (uint32)-1;
@@ -2739,7 +2750,7 @@ BOOL print_queue_pause(struct current_user *user, int snum, WERROR *errcode)
}
/* force update the database */
- print_cache_flush(snum);
+ print_cache_flush(lp_const_servicename(snum));
/* Send a printer notify message */
@@ -2805,7 +2816,7 @@ BOOL print_queue_purge(struct current_user *user, int snum, WERROR *errcode)
become_root();
for (i=0;i<njobs;i++) {
- BOOL owner = is_owner(user, snum, queue[i].job);
+ BOOL owner = is_owner(user, lp_const_servicename(snum), queue[i].job);
if (owner || can_job_admin) {
print_job_delete1(snum, queue[i].job);