2 Unix SMB/CIFS implementation.
5 Copyright (C) Andrew Tridgell 2000
6 Copyright (C) Tim Potter 2000
7 Copyright (C) Jeremy Allison 2000
8 Copyright (C) Jelmer Vernooij 2003
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #define CREATE_ACCESS_READ READ_CONTROL_ACCESS
30 /* numeric is set when the user wants numeric SIDs and ACEs rather
31 than going via LSA calls to resolve them */
34 enum acl_mode {SMB_ACL_SET, SMB_ACL_DELETE, SMB_ACL_MODIFY, SMB_ACL_ADD };
35 enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP};
36 enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR};
43 /* These values discovered by inspection */
45 static const struct perm_value special_values[] = {
55 static const struct perm_value standard_values[] = {
56 { "READ", 0x001200a9 },
57 { "CHANGE", 0x001301bf },
58 { "FULL", 0x001f01ff },
62 /* Open cli connection and policy handle */
64 static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli,
67 enum lsa_SidType *type,
68 char **domain, char **name)
70 uint16 orig_cnum = cli->cnum;
71 struct rpc_pipe_client *p;
72 struct policy_handle handle;
74 TALLOC_CTX *frame = talloc_stackframe();
75 enum lsa_SidType *types;
79 if (!cli_send_tconX(cli, "IPC$", "?????", "", 0)) {
80 return cli_nt_error(cli);
83 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
85 if (!NT_STATUS_IS_OK(status)) {
89 status = rpccli_lsa_open_policy(p, talloc_tos(), True,
90 GENERIC_EXECUTE_ACCESS, &handle);
91 if (!NT_STATUS_IS_OK(status)) {
95 status = rpccli_lsa_lookup_sids(p, talloc_tos(), &handle, 1, sid,
96 &domains, &names, &types);
97 if (!NT_STATUS_IS_OK(status)) {
102 *domain = talloc_move(mem_ctx, &domains[0]);
103 *name = talloc_move(mem_ctx, &names[0]);
105 status = NT_STATUS_OK;
109 cli->cnum = orig_cnum;
114 static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli,
116 enum lsa_SidType *type,
119 uint16 orig_cnum = cli->cnum;
120 struct rpc_pipe_client *p;
121 struct policy_handle handle;
123 TALLOC_CTX *frame = talloc_stackframe();
125 enum lsa_SidType *types;
127 if (!cli_send_tconX(cli, "IPC$", "?????", "", 0)) {
128 return cli_nt_error(cli);
131 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
133 if (!NT_STATUS_IS_OK(status)) {
137 status = rpccli_lsa_open_policy(p, talloc_tos(), True,
138 GENERIC_EXECUTE_ACCESS, &handle);
139 if (!NT_STATUS_IS_OK(status)) {
143 status = rpccli_lsa_lookup_names(p, talloc_tos(), &handle, 1, &name,
144 NULL, 1, &sids, &types);
145 if (!NT_STATUS_IS_OK(status)) {
152 status = NT_STATUS_OK;
156 cli->cnum = orig_cnum;
161 /* convert a SID to a string, either numeric or username/group */
162 static void SidToString(struct cli_state *cli, fstring str, const DOM_SID *sid)
166 enum lsa_SidType type;
169 sid_to_fstring(str, sid);
175 status = cli_lsa_lookup_sid(cli, sid, talloc_tos(), &type,
178 if (!NT_STATUS_IS_OK(status)) {
183 slprintf(str, sizeof(fstring) - 1, "%s%s%s",
184 domain, lp_winbind_separator(), name);
190 /* convert a string to a SID, either numeric or username/group */
191 static bool StringToSid(struct cli_state *cli, DOM_SID *sid, const char *str)
193 enum lsa_SidType type;
195 if (strncmp(str, "S-", 2) == 0) {
196 return string_to_sid(sid, str);
199 return NT_STATUS_IS_OK(cli_lsa_lookup_name(cli, str, &type, sid));
202 static void print_ace_flags(FILE *f, uint8_t flags)
204 char *str = talloc_strdup(NULL, "");
210 if (flags & SEC_ACE_FLAG_OBJECT_INHERIT) {
211 str = talloc_asprintf(str, "%s%s",
217 if (flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
218 str = talloc_asprintf(str, "%s%s",
224 if (flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) {
225 str = talloc_asprintf(str, "%s%s",
231 if (flags & SEC_ACE_FLAG_INHERIT_ONLY) {
232 str = talloc_asprintf(str, "%s%s",
238 if (flags & SEC_ACE_FLAG_INHERITED_ACE) {
239 str = talloc_asprintf(str, "%s%s",
245 /* Ignore define SEC_ACE_FLAG_SUCCESSFUL_ACCESS ( 0x40 )
246 and SEC_ACE_FLAG_FAILED_ACCESS ( 0x80 ) as they're
249 if (str[strlen(str)-1] == '|') {
250 str[strlen(str)-1] = '\0';
251 fprintf(f, "/%s/", str);
253 fprintf(f, "/0x%x/", flags);
259 fprintf(f, "/0x%x/", flags);
262 /* print an ACE on a FILE, using either numeric or ascii representation */
263 static void print_ace(struct cli_state *cli, FILE *f, SEC_ACE *ace)
265 const struct perm_value *v;
270 SidToString(cli, sidstr, &ace->trustee);
272 fprintf(f, "%s:", sidstr);
275 fprintf(f, "%d/0x%x/0x%08x",
276 ace->type, ace->flags, ace->access_mask);
282 if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED) {
283 fprintf(f, "ALLOWED");
284 } else if (ace->type == SEC_ACE_TYPE_ACCESS_DENIED) {
285 fprintf(f, "DENIED");
287 fprintf(f, "%d", ace->type);
290 print_ace_flags(f, ace->flags);
292 /* Standard permissions */
294 for (v = standard_values; v->perm; v++) {
295 if (ace->access_mask == v->mask) {
296 fprintf(f, "%s", v->perm);
301 /* Special permissions. Print out a hex value if we have
302 leftover bits in the mask. */
304 got_mask = ace->access_mask;
307 for (v = special_values; v->perm; v++) {
308 if ((ace->access_mask & v->mask) == v->mask) {
310 fprintf(f, "%s", v->perm);
312 got_mask &= ~v->mask;
318 fprintf(f, "0x%08x", ace->access_mask);
326 static bool parse_ace_flags(const char *str, unsigned int *pflags)
332 if (strnequal(p, "OI", 2)) {
333 *pflags |= SEC_ACE_FLAG_OBJECT_INHERIT;
335 } else if (strnequal(p, "CI", 2)) {
336 *pflags |= SEC_ACE_FLAG_CONTAINER_INHERIT;
338 } else if (strnequal(p, "NP", 2)) {
339 *pflags |= SEC_ACE_FLAG_NO_PROPAGATE_INHERIT;
341 } else if (strnequal(p, "IO", 2)) {
342 *pflags |= SEC_ACE_FLAG_INHERIT_ONLY;
344 } else if (*p == 'I') {
345 *pflags |= SEC_ACE_FLAG_INHERITED_ACE;
351 if (*p != '|' && *p != '\0') {
358 /* parse an ACE in the same format as print_ace() */
359 static bool parse_ace(struct cli_state *cli, SEC_ACE *ace,
360 const char *orig_str)
365 unsigned int atype = 0;
366 unsigned int aflags = 0;
367 unsigned int amask = 0;
370 const struct perm_value *v;
371 char *str = SMB_STRDUP(orig_str);
372 TALLOC_CTX *frame = talloc_stackframe();
380 p = strchr_m(str,':');
382 printf("ACE '%s': missing ':'.\n", orig_str);
389 /* Try to parse numeric form */
391 if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 &&
392 StringToSid(cli, &sid, str)) {
396 /* Try to parse text form */
398 if (!StringToSid(cli, &sid, str)) {
399 printf("ACE '%s': failed to convert '%s' to SID\n",
407 if (!next_token_talloc(frame, &cp, &tok, "/")) {
408 printf("ACE '%s': failed to find '/' character.\n",
415 if (strncmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
416 atype = SEC_ACE_TYPE_ACCESS_ALLOWED;
417 } else if (strncmp(tok, "DENIED", strlen("DENIED")) == 0) {
418 atype = SEC_ACE_TYPE_ACCESS_DENIED;
420 printf("ACE '%s': missing 'ALLOWED' or 'DENIED' entry at '%s'\n",
427 /* Only numeric form accepted for flags at present */
429 if (!next_token_talloc(frame, &cp, &tok, "/")) {
430 printf("ACE '%s': bad flags entry at '%s'\n",
437 if (tok[0] < '0' || tok[0] > '9') {
438 if (!parse_ace_flags(tok, &aflags)) {
439 printf("ACE '%s': bad named flags entry at '%s'\n",
445 } else if (strnequal(tok, "0x", 2)) {
446 if (!sscanf(tok, "%x", &aflags)) {
447 printf("ACE '%s': bad hex flags entry at '%s'\n",
454 if (!sscanf(tok, "%i", &aflags)) {
455 printf("ACE '%s': bad integer flags entry at '%s'\n",
463 if (!next_token_talloc(frame, &cp, &tok, "/")) {
464 printf("ACE '%s': missing / at '%s'\n",
471 if (strncmp(tok, "0x", 2) == 0) {
472 if (sscanf(tok, "%i", &amask) != 1) {
473 printf("ACE '%s': bad hex number at '%s'\n",
482 for (v = standard_values; v->perm; v++) {
483 if (strcmp(tok, v->perm) == 0) {
494 for (v = special_values; v->perm; v++) {
495 if (v->perm[0] == *p) {
502 printf("ACE '%s': bad permission value at '%s'\n",
519 init_sec_ace(ace, &sid, atype, mask, aflags);
525 /* add an ACE to a list of ACEs in a SEC_ACL */
526 static bool add_ace(SEC_ACL **the_acl, SEC_ACE *ace)
531 return (((*the_acl) = make_sec_acl(talloc_tos(), 3, 1, ace))
535 if (!(aces = SMB_CALLOC_ARRAY(SEC_ACE, 1+(*the_acl)->num_aces))) {
538 memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(SEC_ACE));
539 memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE));
540 new_ace = make_sec_acl(talloc_tos(),(*the_acl)->revision,1+(*the_acl)->num_aces, aces);
542 (*the_acl) = new_ace;
546 /* parse a ascii version of a security descriptor */
547 static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx, struct cli_state *cli, char *str)
551 SEC_DESC *ret = NULL;
553 DOM_SID *grp_sid=NULL, *owner_sid=NULL;
557 while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) {
558 if (strncmp(tok,"REVISION:", 9) == 0) {
559 revision = strtol(tok+9, NULL, 16);
563 if (strncmp(tok,"OWNER:", 6) == 0) {
565 printf("Only specify owner once\n");
568 owner_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
570 !StringToSid(cli, owner_sid, tok+6)) {
571 printf("Failed to parse owner sid\n");
577 if (strncmp(tok,"GROUP:", 6) == 0) {
579 printf("Only specify group once\n");
582 grp_sid = SMB_CALLOC_ARRAY(DOM_SID, 1);
584 !StringToSid(cli, grp_sid, tok+6)) {
585 printf("Failed to parse group sid\n");
591 if (strncmp(tok,"ACL:", 4) == 0) {
593 if (!parse_ace(cli, &ace, tok+4)) {
596 if(!add_ace(&dacl, &ace)) {
597 printf("Failed to add ACL %s\n", tok);
603 printf("Failed to parse token '%s' in security descriptor,\n", tok);
607 ret = make_sec_desc(ctx,revision, SEC_DESC_SELF_RELATIVE, owner_sid, grp_sid,
608 NULL, dacl, &sd_size);
612 SAFE_FREE(owner_sid);
618 /* print a ascii version of a security descriptor on a FILE handle */
619 static void sec_desc_print(struct cli_state *cli, FILE *f, SEC_DESC *sd)
624 fprintf(f, "REVISION:%d\n", sd->revision);
625 fprintf(f, "CONTROL:0x%x\n", sd->type);
627 /* Print owner and group sid */
630 SidToString(cli, sidstr, sd->owner_sid);
635 fprintf(f, "OWNER:%s\n", sidstr);
638 SidToString(cli, sidstr, sd->group_sid);
643 fprintf(f, "GROUP:%s\n", sidstr);
646 for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) {
647 SEC_ACE *ace = &sd->dacl->aces[i];
649 print_ace(cli, f, ace);
655 /*****************************************************
656 dump the acls for a file
657 *******************************************************/
658 static int cacl_dump(struct cli_state *cli, char *filename)
660 int result = EXIT_FAILED;
667 fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
670 printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
674 sd = cli_query_secdesc(cli, fnum, talloc_tos());
677 printf("ERROR: secdesc query failed: %s\n", cli_errstr(cli));
681 sec_desc_print(cli, stdout, sd);
687 cli_close(cli, fnum);
692 /*****************************************************
693 Change the ownership or group ownership of a file. Just
694 because the NT docs say this can't be done :-). JRA.
695 *******************************************************/
697 static int owner_set(struct cli_state *cli, enum chown_mode change_mode,
698 const char *filename, const char *new_username)
705 fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
708 printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
712 if (!StringToSid(cli, &sid, new_username))
713 return EXIT_PARSE_ERROR;
715 old = cli_query_secdesc(cli, fnum, talloc_tos());
717 cli_close(cli, fnum);
720 printf("owner_set: Failed to query old descriptor\n");
724 sd = make_sec_desc(talloc_tos(),old->revision, old->type,
725 (change_mode == REQUEST_CHOWN) ? &sid : NULL,
726 (change_mode == REQUEST_CHGRP) ? &sid : NULL,
727 NULL, NULL, &sd_size);
729 fnum = cli_nt_create(cli, filename, WRITE_OWNER_ACCESS);
732 printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
736 if (!cli_set_secdesc(cli, fnum, sd)) {
737 printf("ERROR: secdesc set failed: %s\n", cli_errstr(cli));
740 cli_close(cli, fnum);
746 /* The MSDN is contradictory over the ordering of ACE entries in an
747 ACL. However NT4 gives a "The information may have been modified
748 by a computer running Windows NT 5.0" if denied ACEs do not appear
749 before allowed ACEs. At
750 http://technet.microsoft.com/en-us/library/cc781716.aspx the
751 canonical order is specified as "Explicit Deny, Explicit Allow,
752 Inherited ACEs unchanged" */
754 static int ace_compare(SEC_ACE *ace1, SEC_ACE *ace2)
756 if (sec_ace_equal(ace1, ace2))
759 if ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) &&
760 !(ace2->flags & SEC_ACE_FLAG_INHERITED_ACE))
762 if (!(ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) &&
763 (ace2->flags & SEC_ACE_FLAG_INHERITED_ACE))
765 if ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) &&
766 (ace2->flags & SEC_ACE_FLAG_INHERITED_ACE))
769 if (ace1->type != ace2->type)
770 return ace2->type - ace1->type;
772 if (sid_compare(&ace1->trustee, &ace2->trustee))
773 return sid_compare(&ace1->trustee, &ace2->trustee);
775 if (ace1->flags != ace2->flags)
776 return ace1->flags - ace2->flags;
778 if (ace1->access_mask != ace2->access_mask)
779 return ace1->access_mask - ace2->access_mask;
781 if (ace1->size != ace2->size)
782 return ace1->size - ace2->size;
784 return memcmp(ace1, ace2, sizeof(SEC_ACE));
787 static void sort_acl(SEC_ACL *the_acl)
790 if (!the_acl) return;
792 qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), QSORT_CAST ace_compare);
794 for (i=1;i<the_acl->num_aces;) {
795 if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) {
797 for (j=i; j<the_acl->num_aces-1; j++) {
798 the_acl->aces[j] = the_acl->aces[j+1];
807 /*****************************************************
808 set the ACLs on a file given an ascii description
809 *******************************************************/
811 static int cacl_set(struct cli_state *cli, char *filename,
812 char *the_acl, enum acl_mode mode)
818 int result = EXIT_OK;
820 sd = sec_desc_parse(talloc_tos(), cli, the_acl);
822 if (!sd) return EXIT_PARSE_ERROR;
823 if (test_args) return EXIT_OK;
825 /* The desired access below is the only one I could find that works
826 with NT4, W2KP and Samba */
828 fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
831 printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
835 old = cli_query_secdesc(cli, fnum, talloc_tos());
838 printf("calc_set: Failed to query old descriptor\n");
842 cli_close(cli, fnum);
844 /* the logic here is rather more complex than I would like */
847 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
850 for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
851 if (sec_ace_equal(&sd->dacl->aces[i],
852 &old->dacl->aces[j])) {
854 for (k=j; k<old->dacl->num_aces-1;k++) {
855 old->dacl->aces[k] = old->dacl->aces[k+1];
857 old->dacl->num_aces--;
864 printf("ACL for ACE:");
865 print_ace(cli, stdout, &sd->dacl->aces[i]);
866 printf(" not found\n");
872 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
875 for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
876 if (sid_equal(&sd->dacl->aces[i].trustee,
877 &old->dacl->aces[j].trustee)) {
878 old->dacl->aces[j] = sd->dacl->aces[i];
886 SidToString(cli, str,
887 &sd->dacl->aces[i].trustee);
888 printf("ACL for SID %s not found\n", str);
893 old->owner_sid = sd->owner_sid;
897 old->group_sid = sd->group_sid;
903 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
904 add_ace(&old->dacl, &sd->dacl->aces[i]);
913 /* Denied ACE entries must come before allowed ones */
916 /* Create new security descriptor and set it */
918 /* We used to just have "WRITE_DAC_ACCESS" without WRITE_OWNER.
919 But if we're sending an owner, even if it's the same as the one
920 that already exists then W2K3 insists we open with WRITE_OWNER access.
921 I need to check that setting a SD with no owner set works against WNT
925 sd = make_sec_desc(talloc_tos(),old->revision, old->type,
926 old->owner_sid, old->group_sid,
927 NULL, old->dacl, &sd_size);
929 fnum = cli_nt_create(cli, filename, WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS);
932 printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
936 if (!cli_set_secdesc(cli, fnum, sd)) {
937 printf("ERROR: secdesc set failed: %s\n", cli_errstr(cli));
938 result = EXIT_FAILED;
943 cli_close(cli, fnum);
949 /*****************************************************
950 Return a connection to a server.
951 *******************************************************/
952 static struct cli_state *connect_one(const char *server, const char *share)
954 struct cli_state *c = NULL;
955 struct sockaddr_storage ss;
961 if (get_cmdline_auth_info_use_kerberos()) {
962 flags |= CLI_FULL_CONNECTION_USE_KERBEROS |
963 CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS;
966 if (get_cmdline_auth_info_use_machine_account() &&
967 !set_cmdline_auth_info_machine_account_creds()) {
971 if (!get_cmdline_auth_info_got_pass()) {
972 char *pass = getpass("Password: ");
974 set_cmdline_auth_info_password(pass);
978 nt_status = cli_full_connection(&c, global_myname(), server,
981 get_cmdline_auth_info_username(),
983 get_cmdline_auth_info_password(),
985 get_cmdline_auth_info_signing_state(),
987 if (!NT_STATUS_IS_OK(nt_status)) {
988 DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status)));
992 if (get_cmdline_auth_info_smb_encrypt()) {
993 nt_status = cli_cm_force_encryption(c,
994 get_cmdline_auth_info_username(),
995 get_cmdline_auth_info_password(),
998 if (!NT_STATUS_IS_OK(nt_status)) {
1007 /****************************************************************************
1009 ****************************************************************************/
1010 int main(int argc, const char *argv[])
1014 enum acl_mode mode = SMB_ACL_SET;
1015 static char *the_acl = NULL;
1016 enum chown_mode change_mode = REQUEST_NONE;
1019 char *filename = NULL;
1021 struct poptOption long_options[] = {
1023 { "delete", 'D', POPT_ARG_STRING, NULL, 'D', "Delete an acl", "ACL" },
1024 { "modify", 'M', POPT_ARG_STRING, NULL, 'M', "Modify an acl", "ACL" },
1025 { "add", 'a', POPT_ARG_STRING, NULL, 'a', "Add an acl", "ACL" },
1026 { "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" },
1027 { "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" },
1028 { "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" },
1029 { "numeric", 0, POPT_ARG_NONE, &numeric, 1, "Don't resolve sids or masks to names" },
1030 { "test-args", 't', POPT_ARG_NONE, &test_args, 1, "Test arguments"},
1032 POPT_COMMON_CONNECTION
1033 POPT_COMMON_CREDENTIALS
1037 struct cli_state *cli;
1038 TALLOC_CTX *frame = talloc_stackframe();
1039 const char *owner_username = "";
1045 /* set default debug level to 1 regardless of what smb.conf sets */
1046 setup_logging( "smbcacls", True );
1047 DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
1049 x_setbuf( x_stderr, NULL );
1053 lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
1056 pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
1058 poptSetOtherOptionHelp(pc, "//server1/share1 filename\nACLs look like: "
1059 "'ACL:user:[ALLOWED|DENIED]/flags/permissions'");
1061 while ((opt = poptGetNextOpt(pc)) != -1) {
1064 the_acl = smb_xstrdup(poptGetOptArg(pc));
1069 the_acl = smb_xstrdup(poptGetOptArg(pc));
1070 mode = SMB_ACL_DELETE;
1074 the_acl = smb_xstrdup(poptGetOptArg(pc));
1075 mode = SMB_ACL_MODIFY;
1079 the_acl = smb_xstrdup(poptGetOptArg(pc));
1084 owner_username = poptGetOptArg(pc);
1085 change_mode = REQUEST_CHOWN;
1089 owner_username = poptGetOptArg(pc);
1090 change_mode = REQUEST_CHGRP;
1095 /* Make connection to server */
1096 if(!poptPeekArg(pc)) {
1097 poptPrintUsage(pc, stderr, 0);
1101 path = talloc_strdup(frame, poptGetArg(pc));
1106 if(!poptPeekArg(pc)) {
1107 poptPrintUsage(pc, stderr, 0);
1111 filename = talloc_strdup(frame, poptGetArg(pc));
1116 string_replace(path,'/','\\');
1118 server = talloc_strdup(frame, path+2);
1122 share = strchr_m(server,'\\');
1124 printf("Invalid argument: %s\n", share);
1132 cli = connect_one(server, share);
1140 string_replace(filename, '/', '\\');
1141 if (filename[0] != '\\') {
1142 filename = talloc_asprintf(frame,
1150 /* Perform requested action */
1152 if (change_mode != REQUEST_NONE) {
1153 result = owner_set(cli, change_mode, filename, owner_username);
1154 } else if (the_acl) {
1155 result = cacl_set(cli, filename, the_acl, mode);
1157 result = cacl_dump(cli, filename);