[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Mon May 3 00:07:40 MDT 2010
The branch, master has been updated
via 6be5bc8... Consolidate all get SEC_DESC into single procedure get_secdesc
via 0a8b2b2... always pass filename as const char
from d83850a... build: uname on opensolaris returns 1 for success
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 6be5bc8e8009ef19473f25b7c4841bf56c4d13c7
Author: Matthew McGillis <matthew at mcgillis.org>
Date: Sun May 2 18:08:29 2010 -0700
Consolidate all get SEC_DESC into single procedure get_secdesc
commit 0a8b2b2119e40e72764f6a47f85007d6c0029849
Author: Matthew McGillis <matthew at mcgillis.org>
Date: Sun May 2 18:08:02 2010 -0700
always pass filename as const char
-----------------------------------------------------------------------
Summary of changes:
source3/utils/smbcacls.c | 83 +++++++++++++++++++++-------------------------
1 files changed, 38 insertions(+), 45 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index e1e37ae..8dd2a36 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -658,43 +658,57 @@ static void sec_desc_print(struct cli_state *cli, FILE *f, SEC_DESC *sd)
}
-/*****************************************************
-dump the acls for a file
+/*****************************************************
+get sec desc for filename
*******************************************************/
-static int cacl_dump(struct cli_state *cli, char *filename)
+static SEC_DESC *get_secdesc(struct cli_state *cli, const char *filename)
{
- int result = EXIT_FAILED;
uint16_t fnum = (uint16_t)-1;
SEC_DESC *sd;
- if (test_args)
- return EXIT_OK;
+ /* The desired access below is the only one I could find that works
+ with NT4, W2KP and Samba */
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ,
+ 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
+ FILE_OPEN, 0x0, 0x0, &fnum))) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
- goto done;
+ return NULL;
}
sd = cli_query_secdesc(cli, fnum, talloc_tos());
+ cli_close(cli, fnum);
+
if (!sd) {
- printf("ERROR: secdesc query failed: %s\n", cli_errstr(cli));
- goto done;
+ printf("Failed to get security descriptor\n");
+ return NULL;
}
+ return sd;
+}
- if (sddl) {
- printf("%s\n", sddl_encode(talloc_tos(), sd,
- get_global_sam_sid()));
- } else {
- sec_desc_print(cli, stdout, sd);
- }
+/*****************************************************
+dump the acls for a file
+*******************************************************/
+static int cacl_dump(struct cli_state *cli, const char *filename)
+{
+ int result = EXIT_FAILED;
+ SEC_DESC *sd;
- result = EXIT_OK;
+ if (test_args)
+ return EXIT_OK;
-done:
- if (fnum != (uint16_t)-1)
- cli_close(cli, fnum);
+ sd = get_secdesc(cli, filename);
+
+ if (sd) {
+ if (sddl) {
+ printf("%s\n", sddl_encode(talloc_tos(), sd,
+ get_global_sam_sid()));
+ } else {
+ sec_desc_print(cli, stdout, sd);
+ }
+ result = EXIT_OK;
+ }
return result;
}
@@ -712,21 +726,12 @@ static int owner_set(struct cli_state *cli, enum chown_mode change_mode,
SEC_DESC *sd, *old;
size_t sd_size;
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
- printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
- return EXIT_FAILED;
- }
-
if (!StringToSid(cli, &sid, new_username))
return EXIT_PARSE_ERROR;
- old = cli_query_secdesc(cli, fnum, talloc_tos());
-
- cli_close(cli, fnum);
+ old = get_secdesc(cli, filename);
if (!old) {
- printf("owner_set: Failed to query old descriptor\n");
return EXIT_FAILED;
}
@@ -818,7 +823,7 @@ static void sort_acl(SEC_ACL *the_acl)
set the ACLs on a file given an ascii description
*******************************************************/
-static int cacl_set(struct cli_state *cli, char *filename,
+static int cacl_set(struct cli_state *cli, const char *filename,
char *the_acl, enum acl_mode mode)
{
uint16_t fnum;
@@ -836,24 +841,12 @@ static int cacl_set(struct cli_state *cli, char *filename,
if (!sd) return EXIT_PARSE_ERROR;
if (test_args) return EXIT_OK;
- /* The desired access below is the only one I could find that works
- with NT4, W2KP and Samba */
-
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
- printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
- return EXIT_FAILED;
- }
-
- old = cli_query_secdesc(cli, fnum, talloc_tos());
+ old = get_secdesc(cli, filename);
if (!old) {
- printf("calc_set: Failed to query old descriptor\n");
return EXIT_FAILED;
}
- cli_close(cli, fnum);
-
/* the logic here is rather more complex than I would like */
switch (mode) {
case SMB_ACL_DELETE:
--
Samba Shared Repository
More information about the samba-cvs
mailing list