summaryrefslogtreecommitdiff
path: root/source3
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
commitbc22ae0b47bddd919b07e4c81ae12243c1f3226a (patch)
tree78027928f28d6ef081b2fb83836c028cc86b4ba7 /source3
parent904a24a0129b9d9c7492b7eaadbb1fb3e076eac5 (diff)
downloadsamba-bc22ae0b47bddd919b07e4c81ae12243c1f3226a.tar.gz
samba-bc22ae0b47bddd919b07e4c81ae12243c1f3226a.tar.bz2
samba-bc22ae0b47bddd919b07e4c81ae12243c1f3226a.zip
Fixed up error checking and move printer file code. Fixed a memory leak.
Jeremy. (This used to be commit 5130dd0f8b80aed5fb3c0df290b627057cc9b825)
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/nt_printing.c41
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c5
-rw-r--r--source3/smbd/lanman.c4
3 files changed, 38 insertions, 12 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 9661c9265f..77f2ec47da 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/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';
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 53df5dfee4..30131482ac 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -2648,8 +2648,10 @@ uint32 status=0;
status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
DEBUG(8,("construct_printer_driver_info_3: status: %d\n", status));
- if (status != 0)
+ if (status != 0) {
+ free_a_printer(&printer,2);
return ERROR_UNKNOWN_PRINTER_DRIVER;
+ }
fill_printer_driver_info_3(info, driver, servername);
@@ -3764,7 +3766,6 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *returned)
{
- int i;
fstring *list = NULL;
fstring servername;
fstring architecture;
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 078e3385dc..6cb63f18f7 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -508,7 +508,7 @@ static void fill_printq_info_52(connection_struct *conn, int snum, int uLevel,
* the existing fileset. JRA.
*/
- if ( ok = get_a_printer_driver_9x_compatible(gen_line, lp_printerdriver(snum)) ) {
+ if ((ok = get_a_printer_driver_9x_compatible(gen_line, lp_printerdriver(snum)) ) == True) {
p = gen_line;
DEBUG(10,("9x compatable driver line for [%s]: [%s]\n", lp_printerdriver(snum), gen_line));
} else {
@@ -725,7 +725,7 @@ static int get_printerdrivernumber(int snum)
if( !ok ) {
/* no printers.def, or driver not found, check the NT driver tdb */
- if ( ok = get_a_printer_driver_9x_compatible(gen_line, lp_printerdriver(snum)) ) {
+ if ((ok = get_a_printer_driver_9x_compatible(gen_line, lp_printerdriver(snum)))==True ) {
p = gen_line;
DEBUG(10,("9x compatable driver line for [%s]: [%s]\n",
lp_printerdriver(snum), gen_line));