summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-08-26 16:06:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:03:23 -0500
commit7343eb9172bab6466a5e49cb44f14142287cfa3e (patch)
tree8fb8855fbd7160dc3f191da7d75e812d6036cbac /source3/utils
parent77deaeac03e424f35d0cd902805ae6a3d67b9441 (diff)
downloadsamba-7343eb9172bab6466a5e49cb44f14142287cfa3e.tar.gz
samba-7343eb9172bab6466a5e49cb44f14142287cfa3e.tar.bz2
samba-7343eb9172bab6466a5e49cb44f14142287cfa3e.zip
r9653: adding common popt args to profiles tool (needed for debuglevel to regfio lib)
(This used to be commit 092ff7062544fba47a38e68aed9d3c9d6962fe2b)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/profiles.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/source3/utils/profiles.c b/source3/utils/profiles.c
index ac46f2eb00..424bc36695 100644
--- a/source3/utils/profiles.c
+++ b/source3/utils/profiles.c
@@ -25,7 +25,6 @@
/* GLOBAL VARIABLES */
-int verbose = 0;
DOM_SID old_sid, new_sid;
int change = 0, new_val = 0;
@@ -33,21 +32,30 @@ int change = 0, new_val = 0;
/********************************************************************
********************************************************************/
-static void swap_sid_in_acl( SEC_DESC *sd, DOM_SID *s1, DOM_SID *s2 )
+static BOOL swap_sid_in_acl( SEC_DESC *sd, DOM_SID *s1, DOM_SID *s2 )
{
SEC_ACL *acl = sd->dacl;
int i;
+ BOOL update = False;
- if ( sid_equal( sd->owner_sid, s1 ) )
+ if ( sid_equal( sd->owner_sid, s1 ) ) {
sid_copy( sd->owner_sid, s2 );
+ update = True;
+ }
- if ( sid_equal( sd->grp_sid, s1 ) )
+ if ( sid_equal( sd->grp_sid, s1 ) ) {
sid_copy( sd->grp_sid, s2 );
+ update = True;
+ }
for ( i=0; i<acl->num_aces; i++ ) {
- if ( sid_equal( &acl->ace[i].trustee, s1 ) )
+ if ( sid_equal( &acl->ace[i].trustee, s1 ) ) {
sid_copy( &acl->ace[i].trustee, s2 );
+ update = True;
+ }
}
+
+ return update;
}
/********************************************************************
@@ -71,7 +79,8 @@ static BOOL copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
return False;
}
- swap_sid_in_acl( new_sd, &old_sid, &new_sid );
+ if ( swap_sid_in_acl( new_sd, &old_sid, &new_sid ) )
+ DEBUG(1,("Updating ACL for %s\n", nk->keyname ));
regsubkey_ctr_init( &subkeys );
regval_ctr_init( &values );
@@ -104,8 +113,7 @@ static BOOL copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
regval_ctr_destroy( &values );
regsubkey_ctr_destroy( &subkeys );
- if ( verbose )
- printf("[%s]\n", path );
+ DEBUG(2,("[%s]\n", path));
return True;
}
@@ -121,14 +129,19 @@ int main( int argc, char *argv[] )
pstring orig_filename, new_filename;
struct poptOption long_options[] = {
POPT_AUTOHELP
- { "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Sets verbose mode" },
{ "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" },
- { 0, 0, 0, 0 }
+ POPT_COMMON_SAMBA
+ POPT_COMMON_VERSION
+ POPT_TABLEEND
};
+ poptContext pc;
+ /* setup logging options */
- poptContext pc;
+ setup_logging( "profiles", True );
+ dbf = x_stderr;
+ x_setbuf( x_stderr, NULL );
pc = poptGetContext("profiles", argc, (const char **)argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
@@ -157,13 +170,10 @@ int main( int argc, char *argv[] )
}
break;
- case 'v':
- verbose++;
- break;
}
}
- poptGetArg(pc); /* To get argv[0] */
+ poptGetArg(pc);
if (!poptPeekArg(pc)) {
poptPrintUsage(pc, stderr, 0);