summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-07-25 17:09:29 +0000
committerJeremy Allison <jra@samba.org>2000-07-25 17:09:29 +0000
commitfcbf69495784000861d432c13217702cc28884f8 (patch)
treed86360aff4267a94d9a697d3822946f5f18b253a
parent5a5ef183799dd84ff453db849e929533e709fd0b (diff)
downloadsamba-fcbf69495784000861d432c13217702cc28884f8.tar.gz
samba-fcbf69495784000861d432c13217702cc28884f8.tar.bz2
samba-fcbf69495784000861d432c13217702cc28884f8.zip
Added some error checking and returns to the new 'move' code.
Jeremy. (This used to be commit 0bd88d304cd773e0bbf3e6f7fedcb3b544d41cbe)
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/printing/nt_printing.c58
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c5
-rw-r--r--source3/smbd/reply.c2
4 files changed, 53 insertions, 16 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7a52506451..a97eaa4e4b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1670,8 +1670,8 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count);
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);
-uint32 clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level);
-uint32 move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, struct current_user *user);
+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);
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 76ec4d4ace..9661c9265f 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -286,7 +286,7 @@ BOOL get_short_archi(char *short_archi, char *long_archi)
/****************************************************************************
****************************************************************************/
-static uint32 clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver)
+static void clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver)
{
fstring architecture;
fstring new_name;
@@ -353,14 +353,14 @@ static uint32 clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *dri
/****************************************************************************
****************************************************************************/
-static uint32 clean_up_driver_struct_level_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver)
+static void clean_up_driver_struct_level_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver)
{
}
/****************************************************************************
****************************************************************************/
-uint32 clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level)
+void clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level)
{
switch (level) {
case 3:
@@ -382,7 +382,7 @@ uint32 clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint
/****************************************************************************
****************************************************************************/
-uint32 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)
{
NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
fstring architecture;
@@ -390,9 +390,10 @@ uint32 move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
pstring new_dir;
pstring old_name;
pstring new_name;
+ fstring user_name;
connection_struct *conn;
- fstring inbuf;
- fstring outbuf;
+ pstring inbuf;
+ pstring outbuf;
struct smb_passwd *smb_pass;
int ecode;
int outsize = 0;
@@ -408,9 +409,20 @@ uint32 move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
all_string_sub(clean_driver_name, "/", "#", 0);
/* connect to the print$ share under the same account as the user connected to the rpc pipe */
- smb_pass = getsmbpwnam(uidtoname(user->uid));
+ fstrcpy(user_name, uidtoname(user->uid));
+ if((smb_pass = getsmbpwnam(user_name)) == NULL) {
+ DEBUG(0,("move_driver_to_download_area: Unable to get smbpasswd entry for user %s\n",
+ user_name ));
+ return False;
+ }
+
conn = make_connection("print$", uidtoname(user->uid), smb_pass->smb_nt_passwd, 24, "A:", user->vuid, &ecode);
+ if (conn == NULL) {
+ DEBUG(0,("move_driver_to_download_area: Unable to connect\n"));
+ return False;
+ }
+
/*
* make the directories version and version\driver_name
* under the architecture directory.
@@ -430,29 +442,51 @@ uint32 move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
DEBUG(5,("Moving file now !\n"));
slprintf(old_name, sizeof(old_name), "%s\\%s", architecture, driver->driverpath);
slprintf(new_name, sizeof(new_name), "%s\\%s", new_dir, driver->driverpath);
- outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False);
+ if ((outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False)) != 0) {
+ DEBUG(0,("move_driver_to_download_area: Unable to rename %s to %s\n",
+ old_name, new_name ));
+ return False;
+ }
slprintf(old_name, sizeof(old_name), "%s\\%s", architecture, driver->datafile);
slprintf(new_name, sizeof(new_name), "%s\\%s", new_dir, driver->datafile);
- outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False);
+ if ((outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False)) != 0) {
+ DEBUG(0,("move_driver_to_download_area: Unable to rename %s to %s\n",
+ old_name, new_name ));
+ return False;
+ }
slprintf(old_name, sizeof(old_name), "%s\\%s", architecture, driver->configfile);
slprintf(new_name, sizeof(new_name), "%s\\%s", new_dir, driver->configfile);
- outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False);
+ if ((outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False)) != 0) {
+ DEBUG(0,("move_driver_to_download_area: Unable to rename %s to %s\n",
+ old_name, new_name ));
+ return False;
+ }
slprintf(old_name, sizeof(old_name), "%s\\%s", architecture, driver->helpfile);
slprintf(new_name, sizeof(new_name), "%s\\%s", new_dir, driver->helpfile);
- outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False);
+ if ((outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False)) != 0) {
+ DEBUG(0,("move_driver_to_download_area: Unable to rename %s to %s\n",
+ old_name, new_name ));
+ return False;
+ }
if (driver->dependentfiles) {
for (i=0; *driver->dependentfiles[i]; i++) {
slprintf(old_name, sizeof(old_name), "%s\\%s", architecture, driver->dependentfiles[i]);
slprintf(new_name, sizeof(new_name), "%s\\%s", new_dir, driver->dependentfiles[i]);
- outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False);
+ if ((outsize = rename_internals(conn, inbuf, outbuf, old_name, new_name, False)) != 0) {
+ DEBUG(0,("move_driver_to_download_area: Unable to rename %s to %s\n",
+ old_name, new_name ));
+ return False;
+ }
}
}
close_cnum(conn, user->vuid);
+
+ return True;
}
/****************************************************************************
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 99ed18677a..53df5dfee4 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -4176,7 +4176,8 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name,
clean_up_driver_struct(driver, level);
DEBUG(5,("Moving driver to final destination\n"));
- move_driver_to_download_area(driver, level, &user);
+ if(!move_driver_to_download_area(driver, level, &user))
+ return ERROR_ACCESS_DENIED;
if (add_a_printer_driver(driver, level)!=0)
return ERROR_ACCESS_DENIED;
@@ -4190,7 +4191,7 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name,
****************************************************************************/
static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name)
{
- init_unistr(&(info->name), name);
+ init_unistr(&info->name, name);
}
/****************************************************************************
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 19af1fdc3d..8aa7f7c9e4 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3124,6 +3124,8 @@ int mkdir_internal(connection_struct *conn, char *inbuf, char *outbuf, pstring d
}
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
+
+ return ret;
}
/****************************************************************************