r21446: Karolins "printjob username"
authorVolker Lendecke <vlendec@samba.org>
Mon, 19 Feb 2007 13:30:07 +0000 (13:30 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:18:04 +0000 (12:18 -0500)
(This used to be commit 19ee6779255a269830fa8ee51468a4738dadf942)

source3/param/loadparm.c
source3/printing/printing.c

index 7abbd0ca4e0400e59745797397afba9a7df8dbf8..8d7e3f06bb2e387ba8f142f0422296bea0aa56ee 100644 (file)
@@ -349,6 +349,7 @@ typedef struct {
        char *szQueuepausecommand;
        char *szQueueresumecommand;
        char *szPrintername;
+       char *szPrintjobUsername;
        char *szDontdescend;
        char **szHostsallow;
        char **szHostsdeny;
@@ -488,6 +489,7 @@ static service sDefault = {
        NULL,                   /* szQueuepausecommand */
        NULL,                   /* szQueueresumecommand */
        NULL,                   /* szPrintername */
+       NULL,                   /* szPrintjobUsername */
        NULL,                   /* szDontdescend */
        NULL,                   /* szHostsallow */
        NULL,                   /* szHostsdeny */
@@ -1065,6 +1067,7 @@ static struct parm_struct parm_table[] = {
        {"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
        {"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
        {"force printername", P_BOOL, P_LOCAL, &sDefault.bForcePrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT}, 
+       {"printjob username", P_STRING, P_LOCAL, &sDefault.szPrintjobUsername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
 
        {N_("Filename Handling"), P_SEP, P_SEPARATOR}, 
        {"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, FLAG_ADVANCED}, 
@@ -1409,6 +1412,7 @@ static void init_globals(BOOL first_time_only)
                                string_set((char **)parm_table[i].ptr, "");
 
                string_set(&sDefault.fstype, FSTYPE_STRING);
+               string_set(&sDefault.szPrintjobUsername, "%U");
 
                init_printer_values(&sDefault);
 
@@ -1995,6 +1999,7 @@ FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
 FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
 FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
 static FN_LOCAL_STRING(_lp_printername, szPrintername)
+FN_LOCAL_CONST_STRING(lp_printjob_username, szPrintjobUsername)
 FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
 FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
 FN_LOCAL_STRING(lp_magicscript, szMagicScript)
index 588641358f38fea04e16d1a5c4a909d5494533b1..39efe19604e9cdc213b266a905b67e7e8c927e48 100644 (file)
@@ -2396,7 +2396,11 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname, NT_DE
        fstrcpy(pjob.jobname, jobname);
 
        if ((vuser = get_valid_user_struct(user->vuid)) != NULL) {
-               fstrcpy(pjob.user, vuser->user.smb_name);
+               fstrcpy(pjob.user, lp_printjob_username(snum));
+               standard_sub_basic(vuser->user.smb_name, vuser->user.domain, 
+                                  pjob.user, sizeof(pjob.user)-1);
+               /* ensure NULL termination */ 
+               pjob.user[sizeof(pjob.user)-1] = '\0'; 
        } else {
                fstrcpy(pjob.user, uidtoname(user->ut.uid));
        }