From a5ac83d2b2fe84d5e940d94269ae6fb61167a809 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Sep 2000 04:42:06 +0000 Subject: When creating a print job entry for the printing backend, use the Windows username rather than the Unix username. The Windows username will then be shown in the port monitor regardless of the Unix username used to spool the job. (This used to be commit a15e610bb34636448cb30e590277c53e7f9efe1a) --- source3/printing/printing.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source3/printing') diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 70917b214e..28b5934c37 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -479,16 +479,20 @@ static BOOL print_job_delete1(int jobid) } /**************************************************************************** -return true if the uid owns the print job +return true if the current user owns the print job ****************************************************************************/ -static BOOL is_owner(uid_t uid, int jobid) +static BOOL is_owner(struct current_user *user, int jobid) { struct printjob *pjob = print_job_find(jobid); - struct passwd *pw; + user_struct *vuser; - if (!pjob || !(pw = sys_getpwuid(uid))) return False; + if (!pjob || !user) return False; - return (pw && pjob && strequal(pw->pw_name, pjob->user)); + if ((vuser = get_valid_user_struct(user->vuid)) != NULL) { + return strequal(pjob->user, vuser->user.smb_name); + } else { + return strequal(pjob->user, uidtoname(user->uid)); + } } /**************************************************************************** @@ -501,7 +505,7 @@ BOOL print_job_delete(struct current_user *user, int jobid) if (!user) return False; - owner = is_owner(user->uid, jobid); + owner = is_owner(user, jobid); /* Check access against security descriptor or whether the user owns their job. */ @@ -539,7 +543,7 @@ BOOL print_job_pause(struct current_user *user, int jobid) if (!pjob->spooled || pjob->sysjob == -1) return False; snum = print_job_snum(jobid); - owner = is_owner(user->uid, jobid); + owner = is_owner(user, jobid); if (!owner && !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) { @@ -576,9 +580,9 @@ BOOL print_job_resume(struct current_user *user, int jobid) if (!pjob->spooled || pjob->sysjob == -1) return False; snum = print_job_snum(jobid); - owner = is_owner(user->uid, jobid); + owner = is_owner(user, jobid); - if (!is_owner(user->uid, jobid) && + if (!is_owner(user, jobid) && !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) { DEBUG(3, ("resume denied by security descriptor\n")); return False; @@ -620,7 +624,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname) char *path; struct printjob pjob; int next_jobid; - extern struct current_user current_user; + user_struct *vuser; errno = 0; @@ -664,7 +668,13 @@ int print_job_start(struct current_user *user, int snum, char *jobname) pjob.smbjob = True; fstrcpy(pjob.jobname, jobname); - fstrcpy(pjob.user, uidtoname(current_user.uid)); + + if ((vuser = get_valid_user_struct(user->vuid)) != NULL) { + fstrcpy(pjob.user, vuser->user.smb_name); + } else { + fstrcpy(pjob.user, uidtoname(user->uid)); + } + fstrcpy(pjob.qname, lp_servicename(snum)); /* lock the database */ -- cgit