s3/profiles: improve copy_registry_tree() errors
[samba.git] / source3 / utils / profiles.c
index 53862f441fc39af93642237cd6075cfe89c4d65c..0f274ad604a2aa94cf2cbcc29ee2f138ea58d9ae 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 #include "popt_common.h"
 #include "registry/reg_objects.h"
 #include "registry/regfio.h"
@@ -128,8 +129,15 @@ static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
 
        /* swap out the SIDs in the security descriptor */
 
-       if ( !(new_sd = dup_sec_desc( outfile->mem_ctx, nk->sec_desc->sec_desc )) ) {
-               fprintf( stderr, "Failed to copy security descriptor!\n" );
+       if (nk->sec_desc->sec_desc == NULL) {
+               fprintf(stderr, "Invalid (NULL) security descriptor!\n");
+               return false;
+       }
+
+       new_sd = security_descriptor_copy(outfile->mem_ctx,
+                                         nk->sec_desc->sec_desc);
+       if (new_sd == NULL) {
+               fprintf(stderr, "Failed to copy security descriptor!\n");
                return False;
        }
 
@@ -193,7 +201,7 @@ static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
 /*********************************************************************
 *********************************************************************/
 
-int main( int argc, char *argv[] )
+int main( int argc, const char *argv[] )
 {
        TALLOC_CTX *frame = talloc_stackframe();
        int opt;
@@ -217,7 +225,7 @@ int main( int argc, char *argv[] )
 
        setup_logging( "profiles", DEBUG_STDERR);
 
-       pc = poptGetContext("profiles", argc, (const char **)argv, long_options,
+       pc = poptGetContext("profiles", argc, argv, long_options,
                POPT_CONTEXT_KEEP_FIRST);
 
        poptSetOtherOptionHelp(pc, "<profilefile>");