svn commit: samba r21540 - in branches: SAMBA_3_0/source/utils SAMBA_3_0_25/source/utils

gd at samba.org gd at samba.org
Mon Feb 26 13:07:34 GMT 2007


Author: gd
Date: 2007-02-26 13:07:34 +0000 (Mon, 26 Feb 2007)
New Revision: 21540

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21540

Log:
Fix Bug #3713 and readd reporting what the profiles tool does (when
called with the -v option).

Patch from William Jojo <jojowil at hvcc.edu>.

Guenther

Modified:
   branches/SAMBA_3_0/source/utils/profiles.c
   branches/SAMBA_3_0_25/source/utils/profiles.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/profiles.c
===================================================================
--- branches/SAMBA_3_0/source/utils/profiles.c	2007-02-26 12:02:10 UTC (rev 21539)
+++ branches/SAMBA_3_0/source/utils/profiles.c	2007-02-26 13:07:34 UTC (rev 21540)
@@ -27,34 +27,85 @@
 
 DOM_SID old_sid, new_sid;
 int change = 0, new_val = 0;
+BOOL opt_verbose = False;
 
+/********************************************************************
+********************************************************************/
 
+static void verbose_output(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
+static void verbose_output(const char *format, ...)
+{
+	va_list args;
+	char *var = NULL;
+
+	if (!opt_verbose) {
+		return;
+	}
+
+	va_start(args, format);
+	if ((vasprintf(&var, format, args)) == -1) {
+		va_end(args);
+		return;
+	}
+
+	fprintf(stdout, var);
+	va_end(args);
+	SAFE_FREE(var);
+}
+
 /********************************************************************
 ********************************************************************/
 
 static BOOL swap_sid_in_acl( SEC_DESC *sd, DOM_SID *s1, DOM_SID *s2 )
 {
-	SEC_ACL *acl = sd->dacl;
+	SEC_ACL *acl;
 	int i;
 	BOOL update = False;
 
+	verbose_output("  Owner SID: %s\n", sid_string_static(sd->owner_sid));
 	if ( sid_equal( sd->owner_sid, s1 ) ) {
 		sid_copy( sd->owner_sid, s2 );
 		update = True;
+		verbose_output("  New Owner SID: %s\n", 
+			sid_string_static(sd->owner_sid));
+
 	}
 
+	verbose_output("  Group SID: %s\n", sid_string_static(sd->group_sid));
 	if ( sid_equal( sd->group_sid, s1 ) ) {
 		sid_copy( sd->group_sid, s2 );
 		update = True;
+		verbose_output("  New Group SID: %s\n", 
+			sid_string_static(sd->group_sid));
 	}
 
+	acl = sd->dacl;
+	verbose_output("  DACL: %d entries:\n", acl->num_aces);
 	for ( i=0; i<acl->num_aces; i++ ) {
+		verbose_output("    Trustee SID: %s\n", 
+			sid_string_static(&acl->aces[i].trustee));
 		if ( sid_equal( &acl->aces[i].trustee, s1 ) ) {
 			sid_copy( &acl->aces[i].trustee, s2 );
 			update = True;
+			verbose_output("    New Trustee SID: %s\n", 
+				sid_string_static(&acl->aces[i].trustee));
 		}
 	}
 
+#if 0
+	acl = sd->sacl;
+	verbose_output("  SACL: %d entries: \n", acl->num_aces);
+	for ( i=0; i<acl->num_aces; i++ ) {
+		verbose_output("    Trustee SID: %s\n", 
+			sid_string_static(&acl->aces[i].trustee));
+		if ( sid_equal( &acl->aces[i].trustee, s1 ) ) {
+			sid_copy( &acl->aces[i].trustee, s2 );
+			update = True;
+			verbose_output("    New Trustee SID: %s\n", 
+				sid_string_static(&acl->aces[i].trustee));
+		}
+	}
+#endif
 	return update;
 }
 
@@ -79,8 +130,8 @@
 		return False;
 	}
 
-	if ( swap_sid_in_acl( new_sd, &old_sid, &new_sid ) )
-		DEBUG(2,("Updating ACL for %s\n", nk->keyname ));
+	verbose_output("ACL for %s%s%s\n", parentpath, parent ? "\\" : "", nk->keyname);
+	swap_sid_in_acl( new_sd, &old_sid, &new_sid );
 
 	if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) {
 		DEBUG(0,("copy_registry_tree: talloc() failure!\n"));
@@ -121,7 +172,7 @@
 
 	TALLOC_FREE( subkeys );
 
-	DEBUG(1,("[%s]\n", path));
+	verbose_output("[%s]\n", path);
 
 	return True;
 }
@@ -139,6 +190,7 @@
 		POPT_AUTOHELP
 		{ "change-sid", 'c', POPT_ARG_STRING, NULL, 'c', "Provides SID to change" },
 		{ "new-sid", 'n', POPT_ARG_STRING, NULL, 'n', "Provides SID to change to" },
+		{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 'v', "Verbose output" },
 		POPT_COMMON_SAMBA
 		POPT_COMMON_VERSION
 		POPT_TABLEEND

Modified: branches/SAMBA_3_0_25/source/utils/profiles.c
===================================================================
--- branches/SAMBA_3_0_25/source/utils/profiles.c	2007-02-26 12:02:10 UTC (rev 21539)
+++ branches/SAMBA_3_0_25/source/utils/profiles.c	2007-02-26 13:07:34 UTC (rev 21540)
@@ -27,34 +27,85 @@
 
 DOM_SID old_sid, new_sid;
 int change = 0, new_val = 0;
+BOOL opt_verbose = False;
 
+/********************************************************************
+********************************************************************/
 
+static void verbose_output(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
+static void verbose_output(const char *format, ...)
+{
+	va_list args;
+	char *var = NULL;
+
+	if (!opt_verbose) {
+		return;
+	}
+
+	va_start(args, format);
+	if ((vasprintf(&var, format, args)) == -1) {
+		va_end(args);
+		return;
+	}
+
+	fprintf(stdout, var);
+	va_end(args);
+	SAFE_FREE(var);
+}
+
 /********************************************************************
 ********************************************************************/
 
 static BOOL swap_sid_in_acl( SEC_DESC *sd, DOM_SID *s1, DOM_SID *s2 )
 {
-	SEC_ACL *acl = sd->dacl;
+	SEC_ACL *acl;
 	int i;
 	BOOL update = False;
 
+	verbose_output("  Owner SID: %s\n", sid_string_static(sd->owner_sid));
 	if ( sid_equal( sd->owner_sid, s1 ) ) {
 		sid_copy( sd->owner_sid, s2 );
 		update = True;
+		verbose_output("  New Owner SID: %s\n", 
+			sid_string_static(sd->owner_sid));
+
 	}
 
+	verbose_output("  Group SID: %s\n", sid_string_static(sd->group_sid));
 	if ( sid_equal( sd->group_sid, s1 ) ) {
 		sid_copy( sd->group_sid, s2 );
 		update = True;
+		verbose_output("  New Group SID: %s\n", 
+			sid_string_static(sd->group_sid));
 	}
 
+	acl = sd->dacl;
+	verbose_output("  DACL: %d entries:\n", acl->num_aces);
 	for ( i=0; i<acl->num_aces; i++ ) {
+		verbose_output("    Trustee SID: %s\n", 
+			sid_string_static(&acl->aces[i].trustee));
 		if ( sid_equal( &acl->aces[i].trustee, s1 ) ) {
 			sid_copy( &acl->aces[i].trustee, s2 );
 			update = True;
+			verbose_output("    New Trustee SID: %s\n", 
+				sid_string_static(&acl->aces[i].trustee));
 		}
 	}
 
+#if 0
+	acl = sd->sacl;
+	verbose_output("  SACL: %d entries: \n", acl->num_aces);
+	for ( i=0; i<acl->num_aces; i++ ) {
+		verbose_output("    Trustee SID: %s\n", 
+			sid_string_static(&acl->aces[i].trustee));
+		if ( sid_equal( &acl->aces[i].trustee, s1 ) ) {
+			sid_copy( &acl->aces[i].trustee, s2 );
+			update = True;
+			verbose_output("    New Trustee SID: %s\n", 
+				sid_string_static(&acl->aces[i].trustee));
+		}
+	}
+#endif
 	return update;
 }
 
@@ -79,8 +130,8 @@
 		return False;
 	}
 
-	if ( swap_sid_in_acl( new_sd, &old_sid, &new_sid ) )
-		DEBUG(2,("Updating ACL for %s\n", nk->keyname ));
+	verbose_output("ACL for %s%s%s\n", parentpath, parent ? "\\" : "", nk->keyname);
+	swap_sid_in_acl( new_sd, &old_sid, &new_sid );
 
 	if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) {
 		DEBUG(0,("copy_registry_tree: talloc() failure!\n"));
@@ -121,7 +172,7 @@
 
 	TALLOC_FREE( subkeys );
 
-	DEBUG(1,("[%s]\n", path));
+	verbose_output("[%s]\n", path);
 
 	return True;
 }
@@ -139,6 +190,7 @@
 		POPT_AUTOHELP
 		{ "change-sid", 'c', POPT_ARG_STRING, NULL, 'c', "Provides SID to change" },
 		{ "new-sid", 'n', POPT_ARG_STRING, NULL, 'n', "Provides SID to change to" },
+		{ "verbose", 'v', POPT_ARG_NONE, &opt_verbose, 'v', "Verbose output" },
 		POPT_COMMON_SAMBA
 		POPT_COMMON_VERSION
 		POPT_TABLEEND



More information about the samba-cvs mailing list