/* go ahead and re-read the services immediately */
reload_services( False );
- if ( lp_servicenumber( sharename ) < 0 )
+ if ( !share_defined( sharename ) )
return WERR_ACCESS_DENIED;
return WERR_OK;
fstring name;
int snum;
- struct current_user user;
Printer_entry *Printer=NULL;
if ( !q_u->printername )
return WERR_INVALID_PRINTER_NAME;
}
- get_current_user(&user, p);
-
/*
* First case: the user is opening the print server:
*
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ((user.ut.uid != 0) &&
- !user_has_privileges(user.nt_user_token,
+ if ((p->pipe_user.ut.uid != 0) &&
+ !user_has_privileges(p->pipe_user.nt_user_token,
&se_printop ) &&
!token_contains_name_in_list(
- uidtoname(user.ut.uid), NULL,
- user.nt_user_token,
+ uidtoname(p->pipe_user.ut.uid), NULL,
+ p->pipe_user.nt_user_token,
lp_printer_admin(snum))) {
close_printer_handle(p, handle);
return WERR_ACCESS_DENIED;
return WERR_ACCESS_DENIED;
}
- if (!user_ok_token(uidtoname(user.ut.uid), user.nt_user_token,
- snum) ||
- !print_access_check(&user, snum,
+ if (!user_ok_token(uidtoname(p->pipe_user.ut.uid),
+ p->pipe_user.nt_user_token, snum) ||
+ !print_access_check(&p->pipe_user, snum,
printer_default->access_required)) {
DEBUG(3, ("access DENIED for printer open\n"));
close_printer_handle(p, handle);
NT_PRINTER_DRIVER_INFO_LEVEL info;
NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
int version;
- struct current_user user;
WERROR status;
WERROR status_win2k = WERR_ACCESS_DENIED;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- get_current_user(&user, p);
-
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ( (user.ut.uid != 0)
- && !user_has_privileges(user.nt_user_token, &se_printop )
- && !token_contains_name_in_list( uidtoname(user.ut.uid),
- NULL, user.nt_user_token, lp_printer_admin(-1)) )
+ if ( (p->pipe_user.ut.uid != 0)
+ && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop )
+ && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid),
+ NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) )
{
return WERR_ACCESS_DENIED;
}
/* if we get to here, we now have 2 driver info structures to remove */
/* remove the Win2k driver first*/
- status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, False );
+ status_win2k = delete_printer_driver(info_win2k.info_3, &p->pipe_user, 3, False );
free_a_printer_driver( info_win2k, 3 );
/* this should not have failed---if it did, report to client */
}
}
- status = delete_printer_driver(info.info_3, &user, version, False);
+ status = delete_printer_driver(info.info_3, &p->pipe_user, version, False);
/* if at least one of the deletes succeeded return OK */
int version;
uint32 flags = q_u->delete_flags;
BOOL delete_files;
- struct current_user user;
WERROR status;
WERROR status_win2k = WERR_ACCESS_DENIED;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- get_current_user(&user, p);
-
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ( (user.ut.uid != 0)
- && !user_has_privileges(user.nt_user_token, &se_printop )
- && !token_contains_name_in_list( uidtoname(user.ut.uid),
- NULL, user.nt_user_token, lp_printer_admin(-1)) )
+ if ( (p->pipe_user.ut.uid != 0)
+ && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop )
+ && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid),
+ NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) )
{
return WERR_ACCESS_DENIED;
}
/* if we get to here, we now have 2 driver info structures to remove */
/* remove the Win2k driver first*/
- status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, delete_files);
+ status_win2k = delete_printer_driver(info_win2k.info_3, &p->pipe_user, 3, delete_files);
free_a_printer_driver( info_win2k, 3 );
/* this should not have failed---if it did, report to client */
}
}
- status = delete_printer_driver(info.info_3, &user, version, delete_files);
+ status = delete_printer_driver(info.info_3, &p->pipe_user, version, delete_files);
if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) )
status = WERR_OK;
Create a DEVMODE struct. Returns malloced memory.
****************************************************************************/
-DEVICEMODE *construct_dev_mode(int snum)
+DEVICEMODE *construct_dev_mode(const char *servicename)
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
DEVICEMODE *devmode = NULL;
DEBUGADD(8,("getting printer characteristics\n"));
- if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename)))
return NULL;
if ( !printer->info_2->devmode ) {
printer->cjobs = count; /* jobs */
printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */
- if ( !(printer->devmode = construct_dev_mode(snum)) )
+ if ( !(printer->devmode = construct_dev_mode(lp_const_servicename(snum))) )
DEBUG(8, ("Returning NULL Devicemode!\n"));
printer->secdesc = NULL;
pstring jobname;
fstring datatype;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
- struct current_user user;
if (!Printer) {
DEBUG(2,("_spoolss_startdocprinter: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle)));
return WERR_BADFID;
}
- get_current_user(&user, p);
-
/*
* a nice thing with NT is it doesn't listen to what you tell it.
* when asked to send _only_ RAW datas, it tries to send datas
unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname));
- Printer->jobid = print_job_start(&user, snum, jobname, Printer->nt_devmode);
+ Printer->jobid = print_job_start(&p->pipe_user, snum, jobname, Printer->nt_devmode);
/* An error occured in print_job_start() so return an appropriate
NT error code. */
static WERROR control_printer(POLICY_HND *handle, uint32 command,
pipes_struct *p)
{
- struct current_user user;
int snum;
WERROR errcode = WERR_BADFUNC;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
- get_current_user(&user, p);
-
if (!Printer) {
DEBUG(2,("control_printer: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle)));
return WERR_BADFID;
switch (command) {
case PRINTER_CONTROL_PAUSE:
- if (print_queue_pause(&user, snum, &errcode)) {
+ if (print_queue_pause(&p->pipe_user, snum, &errcode)) {
errcode = WERR_OK;
}
break;
case PRINTER_CONTROL_RESUME:
case PRINTER_CONTROL_UNPAUSE:
- if (print_queue_resume(&user, snum, &errcode)) {
+ if (print_queue_resume(&p->pipe_user, snum, &errcode)) {
errcode = WERR_OK;
}
break;
case PRINTER_CONTROL_PURGE:
- if (print_queue_purge(&user, snum, &errcode)) {
+ if (print_queue_purge(&p->pipe_user, snum, &errcode)) {
errcode = WERR_OK;
}
break;
POLICY_HND *handle = &q_u->handle;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
int snum;
- struct current_user user;
WERROR errcode = WERR_OK;
if (!Printer) {
if (!get_printer_snum(p, handle, &snum))
return WERR_BADFID;
- get_current_user( &user, p );
-
- print_job_delete( &user, snum, Printer->jobid, &errcode );
+ print_job_delete( &p->pipe_user, snum, Printer->jobid, &errcode );
return errcode;
}
SE_PRIV se_printop = SE_PRINT_OPERATOR;
BOOL is_print_op = False;
- standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine));
+ standard_sub_basic(current_user_info.smb_name,
+ current_user_info.domain,
+ remote_machine,sizeof(remote_machine));
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
cmd, printer->info_2->printername, printer->info_2->sharename,
/* this should not be a failure condition if the devmode is NULL */
- devmode = construct_dev_mode(snum);
+ devmode = construct_dev_mode(lp_const_servicename(snum));
for (i=0; i<*returned; i++)
fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, devmode);
uint32 jobid = q_u->jobid;
uint32 command = q_u->command;
- struct current_user user;
int snum;
WERROR errcode = WERR_BADFUNC;
return WERR_INVALID_PRINTER_NAME;
}
- get_current_user(&user, p);
-
switch (command) {
case JOB_CONTROL_CANCEL:
case JOB_CONTROL_DELETE:
- if (print_job_delete(&user, snum, jobid, &errcode)) {
+ if (print_job_delete(&p->pipe_user, snum, jobid, &errcode)) {
errcode = WERR_OK;
}
break;
case JOB_CONTROL_PAUSE:
- if (print_job_pause(&user, snum, jobid, &errcode)) {
+ if (print_job_pause(&p->pipe_user, snum, jobid, &errcode)) {
errcode = WERR_OK;
}
break;
case JOB_CONTROL_RESTART:
case JOB_CONTROL_RESUME:
- if (print_job_resume(&user, snum, jobid, &errcode)) {
+ if (print_job_resume(&p->pipe_user, snum, jobid, &errcode)) {
errcode = WERR_OK;
}
break;
SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info;
WERROR err = WERR_OK;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
- struct current_user user;
fstring driver_name;
uint32 version;
ZERO_STRUCT(driver);
- get_current_user(&user, p);
-
if (!convert_printer_driver_info(info, &driver, level)) {
err = WERR_NOMEM;
goto done;
}
DEBUG(5,("Cleaning driver's information\n"));
- err = clean_up_driver_struct(driver, level, &user);
+ err = clean_up_driver_struct(driver, level, &p->pipe_user);
if (!W_ERROR_IS_OK(err))
goto done;
DEBUG(5,("Moving driver to final destination\n"));
- if( !W_ERROR_IS_OK(err = move_driver_to_download_area(driver, level, &user, &err)) ) {
+ if( !W_ERROR_IS_OK(err = move_driver_to_download_area(driver, level, &p->pipe_user, &err)) ) {
goto done;
}
*/
if ( !(nt_devmode=print_job_devmode( lp_const_servicename(snum), jobid )) )
- devmode = construct_dev_mode(snum);
+ devmode = construct_dev_mode(lp_const_servicename(snum));
else {
if ((devmode = SMB_MALLOC_P(DEVICEMODE)) != NULL) {
ZERO_STRUCTP( devmode );