summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/printing/nt_printing.c26
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c5
3 files changed, 22 insertions, 11 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9b144fd3ae..4fc65f8eda 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -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);
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 7fe21dc7e7..1dfced705b 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -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;
}
}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index b9266c7ee1..8f58f72d73 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -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;
}