summaryrefslogtreecommitdiff
path: root/source3/printing
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 /source3/printing
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)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c58
1 files changed, 46 insertions, 12 deletions
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;
}
/****************************************************************************