summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/printing.c79
-rw-r--r--source3/smbd/lanman.c16
-rw-r--r--source3/smbd/posix_acls.c2
3 files changed, 88 insertions, 9 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index eb6d2f0159..f8dfea0a12 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -39,6 +39,84 @@ static struct printif *current_printif = &generic_printif;
jobids are assigned when a job starts spooling.
*/
+/***************************************************************************
+ Nightmare. LANMAN jobid's are 16 bit numbers..... We must map them to 32
+ bit RPC jobids.... JRA.
+***************************************************************************/
+
+static TDB_CONTEXT *rap_tdb;
+static uint16 next_rap_jobid;
+
+uint16 pjobid_to_rap(uint32 jobid)
+{
+ uint16 rap_jobid;
+ TDB_DATA data, key;
+
+ if (!rap_tdb) {
+ /* Create the in-memory tdb. */
+ rap_tdb = tdb_open_log(NULL, 0, TDB_INTERNAL, (O_RDWR|O_CREAT), 0644);
+ if (!rap_tdb)
+ return 0;
+ }
+
+ key.dptr = (char *)&jobid;
+ key.dsize = sizeof(jobid);
+ data = tdb_fetch(rap_tdb, key);
+ if (data.dptr && data.dsize == sizeof(uint16)) {
+ memcpy(&rap_jobid, data.dptr, sizeof(uint16));
+ SAFE_FREE(data.dptr);
+ return rap_jobid;
+ }
+ /* Not found - create and store mapping. */
+ rap_jobid = ++next_rap_jobid;
+ if (rap_jobid == 0)
+ rap_jobid = ++next_rap_jobid;
+ data.dptr = (char *)&rap_jobid;
+ data.dsize = sizeof(rap_jobid);
+ tdb_store(rap_tdb, key, data, TDB_REPLACE);
+ tdb_store(rap_tdb, data, key, TDB_REPLACE);
+ return rap_jobid;
+}
+
+uint32 rap_to_pjobid(uint16 rap_jobid)
+{
+ TDB_DATA data, key;
+ uint32 jobid = 0;
+
+ if (!rap_tdb)
+ return 0;
+
+ key.dptr = (char *)&rap_jobid;
+ key.dsize = sizeof(rap_jobid);
+ data = tdb_fetch(rap_tdb, key);
+ if (data.dptr && data.dsize == sizeof(uint32)) {
+ memcpy(&jobid, data.dptr, sizeof(uint32));
+ SAFE_FREE(data.dptr);
+ }
+ return jobid;
+}
+
+static void rap_jobid_delete(uint32 jobid)
+{
+ TDB_DATA key, data;
+ uint16 rap_jobid;
+
+ if (!rap_tdb)
+ return;
+ key.dptr = (char *)&jobid;
+ key.dsize = sizeof(jobid);
+ data = tdb_fetch(rap_tdb, key);
+ if (!data.dptr || (data.dsize != sizeof(uint16)))
+ return;
+
+ memcpy(&rap_jobid, data.dptr, sizeof(uint16));
+ SAFE_FREE(data.dptr);
+ data.dptr = (char *)&rap_jobid;
+ data.dsize = sizeof(rap_jobid);
+ tdb_delete(rap_tdb, key);
+ tdb_delete(rap_tdb, data);
+}
+
static pid_t local_pid;
/* Mapping between printer names and queue id's in job id's. */
@@ -501,6 +579,7 @@ static void pjob_delete(uint32 jobid)
/* Remove from printing.tdb */
tdb_delete(pdb->tdb, print_key(jobid));
+ rap_jobid_delete(jobid);
}
/****************************************************************************
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 996a17e932..619ecd736a 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -443,7 +443,7 @@ static void fill_printjob_info(connection_struct *conn, int snum, int uLevel,
/* the client expects localtime */
t -= TimeDiff(t);
- PACKI(desc,"W",queue->job); /* uJobId */
+ PACKI(desc,"W",pjobid_to_rap(queue->job)); /* uJobId */
if (uLevel == 1) {
PACKS(desc,"B21",queue->fs_user); /* szUserName */
PACKS(desc,"B",""); /* pad */
@@ -933,7 +933,7 @@ static BOOL api_DosPrintQGetInfo(connection_struct *conn,
if (!mdrcnt && lp_disable_spoolss())
desc.errcode = ERRbuftoosmall;
- *rdata_len = desc.usedlen;
+ *rdata_len = desc.usedlen;
*rparam_len = 6;
*rparam = REALLOC(*rparam,*rparam_len);
SSVALS(*rparam,0,desc.errcode);
@@ -2185,7 +2185,7 @@ static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param
extern struct current_user current_user;
WERROR werr = WERR_OK;
- jobid = SVAL(p,0);
+ jobid = rap_to_pjobid(SVAL(p,0));
/* check it's a supported varient */
if (!(strcsequal(str1,"W") && strcsequal(str2,"")))
@@ -2318,7 +2318,7 @@ static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,cha
int function = SVAL(p,4);
int place, errcode;
- jobid = SVAL(p,0);
+ jobid = rap_to_pjobid(SVAL(p,0));
*rparam_len = 4;
*rparam = REALLOC(*rparam,*rparam_len);
@@ -2994,7 +2994,7 @@ static BOOL api_WPrintJobGetInfo(connection_struct *conn,uint16 vuid, char *para
int count;
int i;
int snum;
- int job;
+ uint32 jobid;
struct pack_desc desc;
print_queue_struct *queue=NULL;
print_status_struct status;
@@ -3011,14 +3011,14 @@ static BOOL api_WPrintJobGetInfo(connection_struct *conn,uint16 vuid, char *para
if (strcmp(str1,"WWrLh") != 0) return False;
if (!check_printjob_info(&desc,uLevel,str2)) return False;
- job = SVAL(p,0);
- snum = print_job_snum(job);
+ jobid = rap_to_pjobid(SVAL(p,0));
+ snum = print_job_snum(jobid);
if (snum < 0 || !VALID_SNUM(snum)) return(False);
count = print_queue_status(snum,&queue,&status);
for (i = 0; i < count; i++) {
- if (queue[i].job == job) break;
+ if (queue[i].job == jobid) break;
}
if (mdrcnt > 0) {
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 85818d524a..043e33e836 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -2296,7 +2296,7 @@ static int chmod_acl_internals( connection_struct *conn, SMB_ACL_T posix_acl, mo
switch(tagtype) {
case SMB_ACL_USER_OBJ:
perms = unix_perms_to_acl_perms(mode, S_IRUSR, S_IWUSR, S_IXUSR);
- break;
+ break;
case SMB_ACL_GROUP_OBJ:
perms = unix_perms_to_acl_perms(mode, S_IRGRP, S_IWGRP, S_IXGRP);
break;