1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

r3049: fixing some calls in the printing code to stanard_sub_basic(); fix standard_sub_snum() to use the current user's gid; add some (snum == -1) checks to standard_sub_advanced()

This commit is contained in:
Gerald Carter 2004-10-18 19:57:03 +00:00 committed by Gerald (Jerry) Carter
parent 78e904c27b
commit 8c3fd1908d
4 changed files with 19 additions and 14 deletions

View File

@ -446,7 +446,8 @@ static void standard_sub_advanced(int snum, const char *user,
string_sub(p,"%P", connectpath, l); string_sub(p,"%P", connectpath, l);
break; break;
case 'S': case 'S':
string_sub(p,"%S", lp_servicename(snum), l); if ( snum != -1 )
string_sub(p,"%S", lp_servicename(snum), l);
break; break;
case 'g': case 'g':
string_sub(p,"%g", gidtoname(gid), l); string_sub(p,"%g", gidtoname(gid), l);
@ -463,7 +464,8 @@ static void standard_sub_advanced(int snum, const char *user,
* "path =" string in [homes] and so needs the * "path =" string in [homes] and so needs the
* service name, not the username. */ * service name, not the username. */
case 'p': case 'p':
string_sub(p,"%p", automount_path(lp_servicename(snum)), l); if ( snum != -1 )
string_sub(p,"%p", automount_path(lp_servicename(snum)), l);
break; break;
case '\0': case '\0':
p++; p++;
@ -797,6 +799,6 @@ void standard_sub_snum(int snum, char *str, size_t len)
cached_uid = current_user.uid; cached_uid = current_user.uid;
} }
standard_sub_advanced(snum, cached_user, "", -1, standard_sub_advanced(snum, cached_user, "", current_user.gid,
smb_user_name, str, len); smb_user_name, str, len);
} }

View File

@ -4080,7 +4080,7 @@ WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_print
fstrcpy( servername, print_hnd->servername ); fstrcpy( servername, print_hnd->servername );
else { else {
fstrcpy( servername, "%L" ); fstrcpy( servername, "%L" );
standard_sub_basic( NULL, servername, sizeof(servername)-1 ); standard_sub_basic( "", servername, sizeof(servername)-1 );
} }
/* /*

View File

@ -2766,7 +2766,7 @@ void spoolss_notify_server_name(int snum,
uint32 len; uint32 len;
fstrcpy( temp_name, "\\\\%L" ); fstrcpy( temp_name, "\\\\%L" );
standard_sub_basic( NULL, temp_name, sizeof(temp_name)-1 ); standard_sub_basic( "", temp_name, sizeof(temp_name)-1 );
len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE);
@ -6623,7 +6623,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u
return WERR_BADFID; return WERR_BADFID;
} }
if (!print_job_exists(snum, jobid)) { if (!print_job_exists(lp_const_servicename(snum), jobid)) {
return WERR_INVALID_PRINTER_NAME; return WERR_INVALID_PRINTER_NAME;
} }
@ -8640,7 +8640,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum,
* a failure condition * a failure condition
*/ */
if ( !(nt_devmode=print_job_devmode( snum, jobid )) ) if ( !(nt_devmode=print_job_devmode( lp_const_servicename(snum), jobid )) )
devmode = construct_dev_mode(snum); devmode = construct_dev_mode(snum);
else { else {
if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) != NULL) { if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) != NULL) {

View File

@ -441,7 +441,7 @@ static void fill_printjob_info(connection_struct *conn, int snum, int uLevel,
/* the client expects localtime */ /* the client expects localtime */
t -= TimeDiff(t); t -= TimeDiff(t);
PACKI(desc,"W",pjobid_to_rap(snum,queue->job)); /* uJobId */ PACKI(desc,"W",pjobid_to_rap(lp_const_servicename(snum),queue->job)); /* uJobId */
if (uLevel == 1) { if (uLevel == 1) {
PACKS(desc,"B21",queue->fs_user); /* szUserName */ PACKS(desc,"B21",queue->fs_user); /* szUserName */
PACKS(desc,"B",""); /* pad */ PACKS(desc,"B",""); /* pad */
@ -549,7 +549,7 @@ static void fill_printq_info_52(connection_struct *conn, int snum,
PACKS(desc, "z", driver.info_3->monitorname); /* language monitor */ PACKS(desc, "z", driver.info_3->monitorname); /* language monitor */
fstrcpy(location, "\\\\%L\\print$\\WIN40\\0"); fstrcpy(location, "\\\\%L\\print$\\WIN40\\0");
standard_sub_basic( NULL, location, sizeof(location)-1 ); standard_sub_basic( "", location, sizeof(location)-1 );
PACKS(desc,"z", location); /* share to retrieve files */ PACKS(desc,"z", location); /* share to retrieve files */
PACKS(desc,"z", driver.info_3->defaultdatatype); /* default data type */ PACKS(desc,"z", driver.info_3->defaultdatatype); /* default data type */
@ -2122,11 +2122,12 @@ static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param
char *p = skip_string(str2,1); char *p = skip_string(str2,1);
uint32 jobid; uint32 jobid;
int snum; int snum;
fstring sharename;
int errcode; int errcode;
extern struct current_user current_user; extern struct current_user current_user;
WERROR werr = WERR_OK; WERROR werr = WERR_OK;
if(!rap_to_pjobid(SVAL(p,0),&snum,&jobid)) if(!rap_to_pjobid(SVAL(p,0), sharename, &jobid))
return False; return False;
/* check it's a supported varient */ /* check it's a supported varient */
@ -2137,7 +2138,7 @@ static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param
*rparam = REALLOC(*rparam,*rparam_len); *rparam = REALLOC(*rparam,*rparam_len);
*rdata_len = 0; *rdata_len = 0;
if (!print_job_exists(snum, jobid)) { if (!print_job_exists(sharename, jobid)) {
errcode = NERR_JobNotFound; errcode = NERR_JobNotFound;
goto out; goto out;
} }
@ -2257,11 +2258,12 @@ static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,cha
char *p = skip_string(str2,1); char *p = skip_string(str2,1);
uint32 jobid; uint32 jobid;
int snum; int snum;
fstring sharename;
int uLevel = SVAL(p,2); int uLevel = SVAL(p,2);
int function = SVAL(p,4); int function = SVAL(p,4);
int place, errcode; int place, errcode;
if(!rap_to_pjobid(SVAL(p,0),&snum,&jobid)) if(!rap_to_pjobid(SVAL(p,0), sharename, &jobid))
return False; return False;
*rparam_len = 4; *rparam_len = 4;
*rparam = REALLOC(*rparam,*rparam_len); *rparam = REALLOC(*rparam,*rparam_len);
@ -2273,7 +2275,7 @@ static BOOL api_PrintJobInfo(connection_struct *conn,uint16 vuid,char *param,cha
(!check_printjob_info(&desc,uLevel,str2))) (!check_printjob_info(&desc,uLevel,str2)))
return(False); return(False);
if (!print_job_exists(snum, jobid)) { if (!print_job_exists(sharename, jobid)) {
errcode=NERR_JobNotFound; errcode=NERR_JobNotFound;
goto out; goto out;
} }
@ -2939,6 +2941,7 @@ static BOOL api_WPrintJobGetInfo(connection_struct *conn,uint16 vuid, char *para
int count; int count;
int i; int i;
int snum; int snum;
fstring sharename;
uint32 jobid; uint32 jobid;
struct pack_desc desc; struct pack_desc desc;
print_queue_struct *queue=NULL; print_queue_struct *queue=NULL;
@ -2956,7 +2959,7 @@ static BOOL api_WPrintJobGetInfo(connection_struct *conn,uint16 vuid, char *para
if (strcmp(str1,"WWrLh") != 0) return False; if (strcmp(str1,"WWrLh") != 0) return False;
if (!check_printjob_info(&desc,uLevel,str2)) return False; if (!check_printjob_info(&desc,uLevel,str2)) return False;
if(!rap_to_pjobid(SVAL(p,0),&snum,&jobid)) if(!rap_to_pjobid(SVAL(p,0), sharename, &jobid))
return False; return False;
if (snum < 0 || !VALID_SNUM(snum)) return(False); if (snum < 0 || !VALID_SNUM(snum)) return(False);