summaryrefslogtreecommitdiffstats
path: root/source/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-07-25 22:35:57 +0000
committerJeremy Allison <jra@samba.org>2000-07-25 22:35:57 +0000
commit5130dd0f8b80aed5fb3c0df290b627057cc9b825 (patch)
tree24032169fd42c978c4e1bfd52afe7bfb24b63539 /source/printing
parent1f65b13dd56fbe41320f6c4e8f391ce739509e45 (diff)
downloadsamba-5130dd0f8b80aed5fb3c0df290b627057cc9b825.tar.gz
samba-5130dd0f8b80aed5fb3c0df290b627057cc9b825.tar.xz
samba-5130dd0f8b80aed5fb3c0df290b627057cc9b825.zip
Fixed up error checking and move printer file code. Fixed a memory leak.
Jeremy.
Diffstat (limited to 'source/printing')
-rw-r--r--source/printing/nt_printing.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c
index 9661c9265fe..77f2ec47dae 100644
--- a/source/printing/nt_printing.c
+++ b/source/printing/nt_printing.c
@@ -1,3 +1,4 @@
+#define OLD_NTDOMAIN 1
/*
* Unix SMB/Netbios implementation.
* Version 1.9.
@@ -391,6 +392,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
pstring old_name;
pstring new_name;
fstring user_name;
+ fstring null_pw;
connection_struct *conn;
pstring inbuf;
pstring outbuf;
@@ -410,16 +412,30 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
/* connect to the print$ share under the same account as the user connected to the rpc pipe */
fstrcpy(user_name, uidtoname(user->uid));
- if((smb_pass = getsmbpwnam(user_name)) == NULL) {
+ DEBUG(10,("move_driver_to_download_area: uid %d -> user %s\n", (int)user->uid, user_name));
+
+ become_root();
+ smb_pass = getsmbpwnam(user_name);
+ if(smb_pass == NULL) {
DEBUG(0,("move_driver_to_download_area: Unable to get smbpasswd entry for user %s\n",
user_name ));
+ unbecome_root();
return False;
}
- conn = make_connection("print$", uidtoname(user->uid), smb_pass->smb_nt_passwd, 24, "A:", user->vuid, &ecode);
+ /* 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"));
+ unbecome_root();
+ return False;
+ }
+
+ if (!become_user(conn, conn->vuid)) {
+ DEBUG(0,("move_driver_to_download_area: Can't become user %s\n", user_name ));
+ unbecome_root();
return False;
}
@@ -445,6 +461,8 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
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 ));
+ close_cnum(conn, user->vuid);
+ unbecome_root();
return False;
}
@@ -453,6 +471,8 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
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 ));
+ close_cnum(conn, user->vuid);
+ unbecome_root();
return False;
}
@@ -461,6 +481,8 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
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 ));
+ close_cnum(conn, user->vuid);
+ unbecome_root();
return False;
}
@@ -469,6 +491,8 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
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 ));
+ close_cnum(conn, user->vuid);
+ unbecome_root();
return False;
}
@@ -476,15 +500,16 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
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]);
- 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;
- }
+ /*
+ * We don't check the error returns here as several of these
+ * files may have already been moved in the list above...
+ */
+ rename_internals(conn, inbuf, outbuf, old_name, new_name, False);
}
}
close_cnum(conn, user->vuid);
+ unbecome_root();
return True;
}
@@ -699,7 +724,7 @@ static uint32 get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr,
uint32 get_a_printer_driver_9x_compatible(pstring line, fstring model)
{
NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3;
- TDB_DATA kbuf, dbuf;
+ TDB_DATA kbuf;
pstring key;
int i;
line[0] = '\0';