[SCM] Samba Shared Repository - branch v3-4-test updated - release-4-0-0alpha7-850-gd5da80b

Günther Deschner gd at samba.org
Thu Apr 30 12:24:22 GMT 2009


The branch, v3-4-test has been updated
       via  d5da80b175b8e7e12070577abdab4f57917727a3 (commit)
       via  6ca91ff2d56f33a96e013cc3ab796ba38aa10dcd (commit)
       via  bbeefe338e654cb0f43281d9dabe77b59fa931d6 (commit)
       via  be680b2aae289cc7e173c4a76802fe09ff7882f6 (commit)
      from  5b9477f9930d0c6511c70409561c04c5729bcc05 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit d5da80b175b8e7e12070577abdab4f57917727a3
Author: Günther Deschner <gd at samba.org>
Date:   Thu Apr 30 14:16:01 2009 +0200

    s3-nss_wins: Fix unresolved ldb symbols in libnss_wins.so.
    
    The objects for this module should probably be cleaned up once.
    
    Guenther
    (cherry picked from commit eee446a94841a5df97b3a47c7076ef52fb5ccdcf)

commit 6ca91ff2d56f33a96e013cc3ab796ba38aa10dcd
Author: Günther Deschner <gd at samba.org>
Date:   Thu Apr 30 11:19:42 2009 +0200

    s3-spoolss: avoid referring to uid 0 in spoolss server (use sec_initial_uid() instead).
    
    Guenther
    (cherry picked from commit d22965e2e596c8ad78f5330398d43d96bf564773)

commit bbeefe338e654cb0f43281d9dabe77b59fa931d6
Author: Günther Deschner <gd at samba.org>
Date:   Thu Apr 30 01:25:23 2009 +0200

    s3-printing: use move_driver_file_to_download_area() to avoid code duplication.
    
    Guenther
    (cherry picked from commit 233bfb25c9443688f74c506348b0a7b34489e1d1)

commit be680b2aae289cc7e173c4a76802fe09ff7882f6
Author: Günther Deschner <gd at samba.org>
Date:   Thu Apr 30 01:07:31 2009 +0200

    s3-printing: add move_driver_file_to_download_area().
    
    Guenther
    (cherry picked from commit a2a155bee59c7e849a492933d1ea5769e409bac5)

-----------------------------------------------------------------------

Summary of changes:
 source3/Makefile.in                 |    2 +-
 source3/printing/nt_printing.c      |  238 ++++++++++++++---------------------
 source3/rpc_server/srv_spoolss_nt.c |    6 +-
 3 files changed, 98 insertions(+), 148 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index aefc393..0e66f75 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1045,7 +1045,7 @@ SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) \
 
 WINBIND_WINS_NSS_OBJ = ../nsswitch/wins.o $(PARAM_OBJ) \
 	$(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) $(NSSWINS_OBJ) $(KRBCLIENT_OBJ) \
-	$(LIBNDR_GEN_OBJ0)
+	$(LIBNDR_GEN_OBJ0) $(LDB_OBJ)
 
 PAM_SMBPASS_OBJ_0 = pam_smbpass/pam_smb_auth.o pam_smbpass/pam_smb_passwd.o \
 		pam_smbpass/pam_smb_acct.o pam_smbpass/support.o
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index d6fead1..a7cca40 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1802,6 +1802,46 @@ static char* ffmt(unsigned char *c){
 
 /****************************************************************************
 ****************************************************************************/
+
+static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
+						connection_struct *conn,
+						const char *driver_file,
+						const char *architecture,
+						const char *new_dir,
+						uint32_t version)
+{
+	char *old_name = NULL;
+	char *new_name = NULL;
+	SMB_STRUCT_STAT st;
+	NTSTATUS status;
+
+	new_name = talloc_asprintf(mem_ctx, "%s/%s",
+				   architecture, driver_file);
+	W_ERROR_HAVE_NO_MEMORY(new_name);
+
+	old_name = talloc_asprintf(mem_ctx, "%s/%s",
+				   new_dir, driver_file);
+	W_ERROR_HAVE_NO_MEMORY(old_name);
+
+	if (version != -1 && (version = file_version_is_newer(conn, new_name, old_name)) > 0) {
+
+		new_name = driver_unix_convert(conn, new_name, &st);
+		W_ERROR_HAVE_NO_MEMORY(new_name);
+
+		status = copy_file(mem_ctx, conn, new_name, old_name,
+				   OPENX_FILE_EXISTS_TRUNCATE |
+				   OPENX_FILE_CREATE_IF_NOT_EXIST,
+				   0, false);
+		if (!NT_STATUS_IS_OK(status)) {
+			DEBUG(0,("move_driver_file_to_download_area: Unable to rename [%s] to [%s]\n",
+				new_name, old_name));
+			return WERR_ACCESS_DENIED;
+		}
+	}
+
+	return WERR_OK;
+}
+
 WERROR move_driver_to_download_area(struct pipes_struct *p,
 				    NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
 				    uint32 level, WERROR *perr)
@@ -1810,8 +1850,6 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 	NT_PRINTER_DRIVER_INFO_LEVEL_3 converted_driver;
 	const char *architecture;
 	char *new_dir = NULL;
-	char *old_name = NULL;
-	char *new_name = NULL;
 	connection_struct *conn = NULL;
 	NTSTATUS nt_status;
 	SMB_STRUCT_STAT st;
@@ -1894,143 +1932,74 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 	DEBUG(5,("Moving files now !\n"));
 
 	if (driver->driverpath && strlen(driver->driverpath)) {
-		new_name = talloc_asprintf(ctx,
-					"%s/%s",
-					architecture,
-					driver->driverpath);
-		if (!new_name) {
-			*perr = WERR_NOMEM;
-			goto err_exit;
-		}
-		old_name = talloc_asprintf(ctx,
-					"%s/%s",
-					new_dir,
-					driver->driverpath);
-		if (!old_name) {
-			*perr = WERR_NOMEM;
-			goto err_exit;
-		}
 
-		if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-			new_name = driver_unix_convert(conn,new_name,&st);
-			if (!new_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
-						OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
-				DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
-						new_name, old_name));
-				*perr = WERR_ACCESS_DENIED;
+		*perr = move_driver_file_to_download_area(ctx,
+							  conn,
+							  driver->driverpath,
+							  architecture,
+							  new_dir,
+							  ver);
+		if (!W_ERROR_IS_OK(*perr)) {
+			if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
 				ver = -1;
 			}
+			goto err_exit;
 		}
 	}
 
 	if (driver->datafile && strlen(driver->datafile)) {
 		if (!strequal(driver->datafile, driver->driverpath)) {
-			new_name = talloc_asprintf(ctx,
-					"%s/%s",
-					architecture,
-					driver->datafile);
-			if (!new_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			old_name = talloc_asprintf(ctx,
-					"%s/%s",
-					new_dir,
-					driver->datafile);
-			if (!old_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-				new_name = driver_unix_convert(conn,new_name,&st);
-				if (!new_name) {
-					*perr = WERR_NOMEM;
-					goto err_exit;
-				}
-				if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
-						OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
-					DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
-							new_name, old_name));
-					*perr = WERR_ACCESS_DENIED;
+
+			*perr = move_driver_file_to_download_area(ctx,
+								  conn,
+								  driver->datafile,
+								  architecture,
+								  new_dir,
+								  ver);
+			if (!W_ERROR_IS_OK(*perr)) {
+				if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
 					ver = -1;
 				}
+				goto err_exit;
 			}
 		}
 	}
 
 	if (driver->configfile && strlen(driver->configfile)) {
 		if (!strequal(driver->configfile, driver->driverpath) &&
-			!strequal(driver->configfile, driver->datafile)) {
-			new_name = talloc_asprintf(ctx,
-						"%s/%s",
-						architecture,
-						driver->configfile);
-			if (!new_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			old_name = talloc_asprintf(ctx,
-						"%s/%s",
-						new_dir,
-						driver->configfile);
-			if (!old_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-				new_name = driver_unix_convert(conn,new_name,&st);
-				if (!new_name) {
-					*perr = WERR_NOMEM;
-					goto err_exit;
-				}
-				if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
-						OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
-					DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
-							new_name, old_name));
-					*perr = WERR_ACCESS_DENIED;
+		    !strequal(driver->configfile, driver->datafile)) {
+
+			*perr = move_driver_file_to_download_area(ctx,
+								  conn,
+								  driver->configfile,
+								  architecture,
+								  new_dir,
+								  ver);
+			if (!W_ERROR_IS_OK(*perr)) {
+				if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
 					ver = -1;
 				}
+				goto err_exit;
 			}
 		}
 	}
 
 	if (driver->helpfile && strlen(driver->helpfile)) {
 		if (!strequal(driver->helpfile, driver->driverpath) &&
-			!strequal(driver->helpfile, driver->datafile) &&
-			!strequal(driver->helpfile, driver->configfile)) {
-			new_name = talloc_asprintf(ctx,
-					"%s/%s",
-					architecture,
-					driver->helpfile);
-			if (!new_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			old_name = talloc_asprintf(ctx,
-					"%s/%s",
-					new_dir,
-					driver->helpfile);
-			if (!old_name) {
-				*perr = WERR_NOMEM;
-				goto err_exit;
-			}
-			if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-				new_name = driver_unix_convert(conn,new_name,&st);
-				if (!new_name) {
-					*perr = WERR_NOMEM;
-					goto err_exit;
-				}
-				if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
-						OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
-					DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
-							new_name, old_name));
-					*perr = WERR_ACCESS_DENIED;
+		    !strequal(driver->helpfile, driver->datafile) &&
+		    !strequal(driver->helpfile, driver->configfile)) {
+
+			*perr = move_driver_file_to_download_area(ctx,
+								  conn,
+								  driver->helpfile,
+								  architecture,
+								  new_dir,
+								  ver);
+			if (!W_ERROR_IS_OK(*perr)) {
+				if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
 					ver = -1;
 				}
+				goto err_exit;
 			}
 		}
 	}
@@ -2038,9 +2007,9 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 	if (driver->dependentfiles) {
 		for (i=0; *driver->dependentfiles[i]; i++) {
 			if (!strequal(driver->dependentfiles[i], driver->driverpath) &&
-				!strequal(driver->dependentfiles[i], driver->datafile) &&
-				!strequal(driver->dependentfiles[i], driver->configfile) &&
-				!strequal(driver->dependentfiles[i], driver->helpfile)) {
+			    !strequal(driver->dependentfiles[i], driver->datafile) &&
+			    !strequal(driver->dependentfiles[i], driver->configfile) &&
+			    !strequal(driver->dependentfiles[i], driver->helpfile)) {
 				int j;
 				for (j=0; j < i; j++) {
 					if (strequal(driver->dependentfiles[i], driver->dependentfiles[j])) {
@@ -2048,36 +2017,17 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 					}
 				}
 
-				new_name = talloc_asprintf(ctx,
-						"%s/%s",
-						architecture,
-						driver->dependentfiles[i]);
-				if (!new_name) {
-					*perr = WERR_NOMEM;
-					goto err_exit;
-				}
-				old_name = talloc_asprintf(ctx,
-						"%s/%s",
-						new_dir,
-						driver->dependentfiles[i]);
-				if (!old_name) {
-					*perr = WERR_NOMEM;
-					goto err_exit;
-				}
-				if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
-					new_name = driver_unix_convert(conn,new_name,&st);
-					if (!new_name) {
-						*perr = WERR_NOMEM;
-						goto err_exit;
-					}
-					if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name,
-							OPENX_FILE_EXISTS_TRUNCATE|
-							OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
-						DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
-								new_name, old_name));
-						*perr = WERR_ACCESS_DENIED;
+				*perr = move_driver_file_to_download_area(ctx,
+									  conn,
+									  driver->dependentfiles[i],
+									  architecture,
+									  new_dir,
+									  ver);
+				if (!W_ERROR_IS_OK(*perr)) {
+					if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
 						ver = -1;
 					}
+					goto err_exit;
 				}
 			}
 		NextDriver: ;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index fee7383..0a8c31a 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -1638,7 +1638,7 @@ WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
 			/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
 			   and not a printer admin, then fail */
 
-			if ((p->server_info->utok.uid != 0) &&
+			if ((p->server_info->utok.uid != sec_initial_uid()) &&
 			    !user_has_privileges(p->server_info->ptok,
 						 &se_printop ) &&
 			    !token_contains_name_in_list(
@@ -2116,7 +2116,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
 	/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
 	   and not a printer admin, then fail */
 
-	if ( (p->server_info->utok.uid != 0)
+	if ( (p->server_info->utok.uid != sec_initial_uid())
 		&& !user_has_privileges(p->server_info->ptok, &se_printop )
 		&& !token_contains_name_in_list(
 			uidtoname(p->server_info->utok.uid), NULL,
@@ -2216,7 +2216,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
 	/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
 	   and not a printer admin, then fail */
 
-	if ( (p->server_info->utok.uid != 0)
+	if ( (p->server_info->utok.uid != sec_initial_uid())
 		&& !user_has_privileges(p->server_info->ptok, &se_printop )
 		&& !token_contains_name_in_list(
 			uidtoname(p->server_info->utok.uid), NULL, NULL,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list