1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

Fixed error returns for moving printer driver files around so generic

"Access denied" isn't always returned. More fixes found using Gerald's
wonderful Win32 test progs :-).
Jeremy.
(This used to be commit 67b9d40e3d)
This commit is contained in:
Jeremy Allison 2000-08-30 21:09:21 +00:00
parent 177b962dfe
commit c77bf3d9e2
3 changed files with 22 additions and 11 deletions

View File

@ -1686,7 +1686,7 @@ void update_a_form(nt_forms_struct **list, const FORM *form, int count);
int get_ntdrivers(fstring **list, char *architecture, uint32 version);
BOOL get_short_archi(char *short_archi, char *long_archi);
void clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level);
BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, struct current_user *user);
BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, struct current_user *user, uint32 *perr);
uint32 get_a_printer_driver_9x_compatible(pstring line, fstring model);
uint32 del_a_printer(char *sharename);
BOOL add_a_specific_param(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param);

View File

@ -383,7 +383,7 @@ void clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32
/****************************************************************************
****************************************************************************/
BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, struct current_user *user)
BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, struct current_user *user, uint32 *perr)
{
NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
fstring architecture;
@ -400,31 +400,36 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
int outsize = 0;
int i;
*perr = 0;
memset(inbuf, '\0', sizeof(inbuf));
memset(outbuf, '\0', sizeof(outbuf));
if (level==3)
driver=driver_abstract.info_3;
get_short_archi(architecture, driver->environment);
/* connect to the print$ share under the same account as the user connected to the rpc pipe */
fstrcpy(user_name, uidtoname(user->uid));
DEBUG(10,("move_driver_to_download_area: uid %d -> user %s\n", (int)user->uid, user_name));
become_root();
smb_pass = getsmbpwnam(user_name);
smb_pass = getsmbpwuid(user->uid);
if(smb_pass == NULL) {
DEBUG(0,("move_driver_to_download_area: Unable to get smbpasswd entry for user %s\n",
user_name ));
DEBUG(0,("move_driver_to_download_area: Unable to get smbpasswd entry for uid %u\n",
(unsigned int)user->uid ));
unbecome_root();
return False;
}
unbecome_root();
/* connect to the print$ share under the same account as the user connected to the rpc pipe */
fstrcpy(user_name, smb_pass->smb_name );
DEBUG(10,("move_driver_to_download_area: uid %d -> user %s\n", (int)user->uid, user_name));
/* Null password is ok - we are already an authenticated user... */
*null_pw = '\0';
conn = make_connection("print$", user_name, null_pw, 0, "A:", user->vuid, &ecode);
if (conn == NULL) {
DEBUG(0,("move_driver_to_download_area: Unable to connect\n"));
*perr = (uint32)ecode;
return False;
}
@ -468,6 +473,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
old_name, new_name ));
close_cnum(conn, user->vuid);
pop_sec_ctx();
*perr = (uint32)SVAL(outbuf,smb_err);
return False;
}
@ -479,6 +485,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
old_name, new_name ));
close_cnum(conn, user->vuid);
pop_sec_ctx();
*perr = (uint32)SVAL(outbuf,smb_err);
return False;
}
}
@ -492,6 +499,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
old_name, new_name ));
close_cnum(conn, user->vuid);
pop_sec_ctx();
*perr = (uint32)SVAL(outbuf,smb_err);
return False;
}
}
@ -506,6 +514,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
old_name, new_name ));
close_cnum(conn, user->vuid);
pop_sec_ctx();
*perr = (uint32)SVAL(outbuf,smb_err);
return False;
}
}
@ -530,6 +539,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
old_name, new_name ));
close_cnum(conn, user->vuid);
pop_sec_ctx();
*perr = (uint32)SVAL(outbuf,smb_err);
return False;
}
}

View File

@ -4327,8 +4327,9 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name,
clean_up_driver_struct(driver, level);
DEBUG(5,("Moving driver to final destination\n"));
if(!move_driver_to_download_area(driver, level, &user)) {
err = ERROR_ACCESS_DENIED;
if(!move_driver_to_download_area(driver, level, &user, &err)) {
if (err == 0)
err = ERROR_ACCESS_DENIED;
goto done;
}