From 6ed9b52862fa076c26a267ab48df5a097f17edd6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 01:38:12 +0000 Subject: Ooops - forgot to check the rpcclient and smbcacls compile with the new code :-(. Jeremy. (This used to be commit 70beabf73bdaad7b6a60e24b7a11798a411bed02) --- source3/utils/smbcacls.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'source3/utils/smbcacls.c') diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index b050139aa5..ea4191988a 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -30,6 +30,7 @@ static pstring owner_username; static fstring server; static int got_pass; static int test_args; +TALLOC_CTX *ctx; #define CREATE_ACCESS_READ READ_CONTROL_ACCESS #define CREATE_ACCESS_WRITE (WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS) @@ -327,15 +328,14 @@ static BOOL add_ace(SEC_ACL **the_acl, SEC_ACE *ace) SEC_ACL *new; SEC_ACE *aces; if (! *the_acl) { - (*the_acl) = make_sec_acl(3, 1, ace); + (*the_acl) = make_sec_acl(ctx, 3, 1, ace); return True; } aces = calloc(1+(*the_acl)->num_aces,sizeof(SEC_ACE)); memcpy(aces, (*the_acl)->ace, (*the_acl)->num_aces * sizeof(SEC_ACE)); memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE)); - new = make_sec_acl((*the_acl)->revision,1+(*the_acl)->num_aces, aces); - free_sec_acl(the_acl); + new = make_sec_acl(ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces); free(aces); (*the_acl) = new; return True; @@ -396,11 +396,9 @@ static SEC_DESC *sec_desc_parse(char *str) return NULL; } - ret = make_sec_desc(revision, owner_sid, grp_sid, + ret = make_sec_desc(ctx,revision, owner_sid, grp_sid, NULL, dacl, &sd_size); - free_sec_acl(&dacl); - if (grp_sid) free(grp_sid); if (owner_sid) free(owner_sid); @@ -469,8 +467,6 @@ static int cacl_dump(struct cli_state *cli, char *filename) sec_desc_print(stdout, sd); - free_sec_desc(&sd); - cli_close(cli, fnum); return EXIT_OK; @@ -508,7 +504,7 @@ static int owner_set(struct cli_state *cli, enum chown_mode change_mode, return EXIT_FAILED; } - sd = make_sec_desc(old->revision, + sd = make_sec_desc(ctx,old->revision, (change_mode == REQUEST_CHOWN) ? &sid : old->owner_sid, (change_mode == REQUEST_CHGRP) ? &sid : old->grp_sid, NULL, old->dacl, &sd_size); @@ -524,9 +520,6 @@ static int owner_set(struct cli_state *cli, enum chown_mode change_mode, printf("ERROR: secdesc set failed: %s\n", cli_errstr(cli)); } - free_sec_desc(&sd); - free_sec_desc(&old); - cli_close(cli, fnum); return EXIT_OK; @@ -668,20 +661,15 @@ static int cacl_set(struct cli_state *cli, char *filename, break; case ACL_SET: - free_sec_desc(&old); old = sd; break; } - if (sd != old) { - free_sec_desc(&sd); - } - /* Denied ACE entries must come before allowed ones */ sort_acl(old->dacl); /* Create new security descriptor and set it */ - sd = make_sec_desc(old->revision, old->owner_sid, old->grp_sid, + sd = make_sec_desc(ctx,old->revision, old->owner_sid, old->grp_sid, NULL, old->dacl, &sd_size); fnum = cli_nt_create(cli, filename, CREATE_ACCESS_WRITE); @@ -698,9 +686,6 @@ static int cacl_set(struct cli_state *cli, char *filename, /* Clean up */ - free_sec_desc(&sd); - free_sec_desc(&old); - cli_close(cli, fnum); return result; @@ -838,12 +823,15 @@ You can string acls together with spaces, commas or newlines\n\ enum chown_mode change_mode = REQUEST_NONE; int result; + ctx=talloc_init(); + setlinebuf(stdout); dbf = stderr; if (argc < 3 || argv[1][0] == '-') { usage(); + talloc_destroy(ctx); exit(EXIT_PARSE_ERROR); } @@ -929,10 +917,12 @@ You can string acls together with spaces, commas or newlines\n\ case 'h': usage(); + talloc_destroy(ctx); exit(EXIT_PARSE_ERROR); default: printf("Unknown option %c (%d)\n", (char)opt, opt); + talloc_destroy(ctx); exit(EXIT_PARSE_ERROR); } } @@ -942,6 +932,7 @@ You can string acls together with spaces, commas or newlines\n\ if (argc > 0) { usage(); + talloc_destroy(ctx); exit(EXIT_PARSE_ERROR); } @@ -949,7 +940,10 @@ You can string acls together with spaces, commas or newlines\n\ if (!test_args) { cli = connect_one(share); - if (!cli) exit(EXIT_FAILED); + if (!cli) { + talloc_destroy(ctx); + exit(EXIT_FAILED); + } } all_string_sub(filename, "/", "\\", 0); @@ -970,5 +964,7 @@ You can string acls together with spaces, commas or newlines\n\ result = cacl_dump(cli, filename); } + talloc_destroy(ctx); + return result; } -- cgit