Added some error checking and returns to the new 'move' code.
authorJeremy Allison <jra@samba.org>
Tue, 25 Jul 2000 17:09:29 +0000 (17:09 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 25 Jul 2000 17:09:29 +0000 (17:09 +0000)
Jeremy.
(This used to be commit 0bd88d304cd773e0bbf3e6f7fedcb3b544d41cbe)

source3/include/proto.h
source3/printing/nt_printing.c
source3/rpc_server/srv_spoolss_nt.c
source3/smbd/reply.c

index 7a5250645164f854f63ff024bd18c34fe3a7fdae..a97eaa4e4b64bf944794e7f98bb4b5bbaf1d3a2e 100644 (file)
@@ -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);
index 76ec4d4ace7d7fd703e8b5709840750c904de5ba..9661c9265fe3aac1916b5a7cfb4cc40c81b8070f 100644 (file)
@@ -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;
 }
 
 /****************************************************************************
index 99ed18677ad1260262ba6ff6428609f2f4da21d9..53df5dfee4ce207296a08592cc6e69c620c315ea 100644 (file)
@@ -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);
 }
 
 /****************************************************************************
index 19af1fdc3d3bba500c59f5f8bfefa271803bfc0e..8aa7f7c9e4facab4f3dba5c853761aa8fdf04614 100644 (file)
@@ -3124,6 +3124,8 @@ int mkdir_internal(connection_struct *conn, char *inbuf, char *outbuf, pstring d
     }
     return(UNIXERROR(ERRDOS,ERRnoaccess));
   }
+
+  return ret;
 }
 
 /****************************************************************************