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/>.
25 #include "popt_common_cmdline.h"
26 #include "rpc_client/cli_pipe.h"
27 #include "../librpc/gen_ndr/ndr_lsa.h"
28 #include "rpc_client/cli_lsarpc.h"
29 #include "../libcli/security/security.h"
30 #include "libsmb/libsmb.h"
31 #include "libsmb/clirap.h"
32 #include "passdb/machine_sid.h"
33 #include "../librpc/gen_ndr/ndr_lsa_c.h"
38 static int query_sec_info = -1;
39 static int set_sec_info = -1;
40 static bool want_mxac;
42 static const char *domain_sid = NULL;
44 enum acl_mode {SMB_ACL_SET, SMB_ACL_DELETE, SMB_ACL_MODIFY, SMB_ACL_ADD };
45 enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP, REQUEST_INHERIT};
46 enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR};
48 static NTSTATUS cli_lsa_lookup_domain_sid(struct cli_state *cli,
51 union lsa_PolicyInformation *info = NULL;
52 struct smbXcli_tcon *orig_tcon = NULL;
53 struct rpc_pipe_client *rpc_pipe = NULL;
54 struct policy_handle handle;
55 NTSTATUS status, result;
56 TALLOC_CTX *frame = talloc_stackframe();
58 if (cli_state_has_tcon(cli)) {
59 orig_tcon = cli_state_save_tcon(cli);
60 if (orig_tcon == NULL) {
61 status = NT_STATUS_NO_MEMORY;
66 status = cli_tree_connect(cli, "IPC$", "?????", NULL);
67 if (!NT_STATUS_IS_OK(status)) {
71 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc, &rpc_pipe);
72 if (!NT_STATUS_IS_OK(status)) {
76 status = rpccli_lsa_open_policy(rpc_pipe, frame, True,
77 GENERIC_EXECUTE_ACCESS, &handle);
78 if (!NT_STATUS_IS_OK(status)) {
82 status = dcerpc_lsa_QueryInfoPolicy2(rpc_pipe->binding_handle,
84 LSA_POLICY_INFO_DOMAIN,
87 if (any_nt_status_not_ok(status, result, &status)) {
91 *sid = *info->domain.sid;
94 TALLOC_FREE(rpc_pipe);
97 cli_state_restore_tcon(cli, orig_tcon);
102 static struct dom_sid *get_domain_sid(struct cli_state *cli)
105 struct dom_sid_buf buf;
107 struct dom_sid *sid = talloc(talloc_tos(), struct dom_sid);
109 DEBUG(0, ("Out of memory\n"));
114 if (!dom_sid_parse(domain_sid, sid)) {
115 DEBUG(0,("failed to parse domain sid\n"));
119 status = cli_lsa_lookup_domain_sid(cli, sid);
121 if (!NT_STATUS_IS_OK(status)) {
122 DEBUG(0,("failed to lookup domain sid: %s\n", nt_errstr(status)));
128 DEBUG(2,("Domain SID: %s\n", dom_sid_str_buf(sid, &buf)));
132 /* add an ACE to a list of ACEs in a struct security_acl */
133 static bool add_ace(struct security_acl **the_acl, struct security_ace *ace)
135 struct security_acl *new_ace;
136 struct security_ace *aces;
138 return (((*the_acl) = make_sec_acl(talloc_tos(), 3, 1, ace))
142 if (!(aces = SMB_CALLOC_ARRAY(struct security_ace, 1+(*the_acl)->num_aces))) {
145 memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(struct
147 memcpy(aces+(*the_acl)->num_aces, ace, sizeof(struct security_ace));
148 new_ace = make_sec_acl(talloc_tos(),(*the_acl)->revision,1+(*the_acl)->num_aces, aces);
150 (*the_acl) = new_ace;
154 /* parse a ascii version of a security descriptor */
155 static struct security_descriptor *sec_desc_parse(TALLOC_CTX *ctx, struct cli_state *cli, char *str)
159 struct security_descriptor *ret = NULL;
161 struct dom_sid *grp_sid=NULL, *owner_sid=NULL;
162 struct security_acl *dacl=NULL;
165 while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) {
166 if (strncmp(tok,"REVISION:", 9) == 0) {
167 revision = strtol(tok+9, NULL, 16);
171 if (strncmp(tok,"OWNER:", 6) == 0) {
173 printf("Only specify owner once\n");
176 owner_sid = SMB_CALLOC_ARRAY(struct dom_sid, 1);
178 !StringToSid(cli, owner_sid, tok+6)) {
179 printf("Failed to parse owner sid\n");
185 if (strncmp(tok,"GROUP:", 6) == 0) {
187 printf("Only specify group once\n");
190 grp_sid = SMB_CALLOC_ARRAY(struct dom_sid, 1);
192 !StringToSid(cli, grp_sid, tok+6)) {
193 printf("Failed to parse group sid\n");
199 if (strncmp(tok,"ACL:", 4) == 0) {
200 struct security_ace ace;
201 if (!parse_ace(cli, &ace, tok+4)) {
204 if(!add_ace(&dacl, &ace)) {
205 printf("Failed to add ACL %s\n", tok);
211 printf("Failed to parse token '%s' in security descriptor,\n", tok);
215 ret = make_sec_desc(ctx,revision, SEC_DESC_SELF_RELATIVE, owner_sid, grp_sid,
216 NULL, dacl, &sd_size);
220 SAFE_FREE(owner_sid);
225 /*****************************************************
226 get fileinfo for filename
227 *******************************************************/
228 static uint16_t get_fileinfo(struct cli_state *cli, const char *filename)
230 uint16_t fnum = (uint16_t)-1;
232 struct smb_create_returns cr = {0};
234 /* The desired access below is the only one I could find that works
235 with NT4, W2KP and Samba */
237 status = cli_ntcreate(
239 filename, /* fname */
241 READ_CONTROL_ACCESS, /* CreatFlags */
242 0, /* FileAttributes */
244 FILE_SHARE_WRITE, /* ShareAccess */
245 FILE_OPEN, /* CreateDisposition */
246 0x0, /* CreateOptions */
247 0x0, /* SecurityFlags */
250 if (!NT_STATUS_IS_OK(status)) {
251 printf("Failed to open %s: %s\n", filename, nt_errstr(status));
255 cli_close(cli, fnum);
256 return cr.file_attributes;
259 /*****************************************************
260 get sec desc for filename
261 *******************************************************/
262 static struct security_descriptor *get_secdesc(struct cli_state *cli, const char *filename)
264 uint16_t fnum = (uint16_t)-1;
265 struct security_descriptor *sd;
268 uint32_t desired_access = 0;
270 if (query_sec_info == -1) {
271 sec_info = SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL;
273 sec_info = query_sec_info;
276 if (sec_info & (SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL)) {
277 desired_access |= SEC_STD_READ_CONTROL;
279 if (sec_info & SECINFO_SACL) {
280 desired_access |= SEC_FLAG_SYSTEM_SECURITY;
283 if (desired_access == 0) {
284 desired_access |= SEC_STD_READ_CONTROL;
287 status = cli_ntcreate(cli, filename, 0, desired_access,
288 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
289 FILE_OPEN, 0x0, 0x0, &fnum, NULL);
290 if (!NT_STATUS_IS_OK(status)) {
291 printf("Failed to open %s: %s\n", filename, nt_errstr(status));
295 status = cli_query_security_descriptor(cli, fnum, sec_info,
298 cli_close(cli, fnum);
300 if (!NT_STATUS_IS_OK(status)) {
301 printf("Failed to get security descriptor: %s\n",
308 /*****************************************************
309 set sec desc for filename
310 *******************************************************/
311 static bool set_secdesc(struct cli_state *cli, const char *filename,
312 struct security_descriptor *sd)
314 uint16_t fnum = (uint16_t)-1;
317 uint32_t desired_access = 0;
320 if (set_sec_info == -1) {
323 if (sd->dacl || (sd->type & SEC_DESC_DACL_PRESENT)) {
324 sec_info |= SECINFO_DACL;
326 if (sd->sacl || (sd->type & SEC_DESC_SACL_PRESENT)) {
327 sec_info |= SECINFO_SACL;
330 sec_info |= SECINFO_OWNER;
333 sec_info |= SECINFO_GROUP;
336 sec_info = set_sec_info;
339 /* Make the desired_access more specific. */
340 if (sec_info & SECINFO_DACL) {
341 desired_access |= SEC_STD_WRITE_DAC;
343 if (sec_info & SECINFO_SACL) {
344 desired_access |= SEC_FLAG_SYSTEM_SECURITY;
346 if (sec_info & (SECINFO_OWNER | SECINFO_GROUP)) {
347 desired_access |= SEC_STD_WRITE_OWNER;
350 status = cli_ntcreate(cli, filename, 0,
352 0, FILE_SHARE_READ|FILE_SHARE_WRITE,
353 FILE_OPEN, 0x0, 0x0, &fnum, NULL);
354 if (!NT_STATUS_IS_OK(status)) {
355 printf("Failed to open %s: %s\n", filename, nt_errstr(status));
359 status = cli_set_security_descriptor(cli, fnum, sec_info, sd);
360 if (!NT_STATUS_IS_OK(status)) {
361 printf("ERROR: security descriptor set failed: %s\n",
366 cli_close(cli, fnum);
370 /*****************************************************
371 get maximum access for a file
372 *******************************************************/
373 static int cacl_mxac(struct cli_state *cli, const char *filename)
378 status = cli_query_mxac(cli, filename, &mxac);
379 if (!NT_STATUS_IS_OK(status)) {
380 printf("Failed to get mxac: %s\n", nt_errstr(status));
384 printf("Maximum access: 0x%x\n", mxac);
390 /*****************************************************
391 dump the acls for a file
392 *******************************************************/
393 static int cacl_dump(struct cli_state *cli, const char *filename, bool numeric)
395 struct security_descriptor *sd;
402 sd = get_secdesc(cli, filename);
408 char *str = sddl_encode(talloc_tos(), sd, get_domain_sid(cli));
415 sec_desc_print(cli, stdout, sd, numeric);
419 ret = cacl_mxac(cli, filename);
420 if (ret != EXIT_OK) {
428 /*****************************************************
429 Change the ownership or group ownership of a file. Just
430 because the NT docs say this can't be done :-). JRA.
431 *******************************************************/
433 static int owner_set(struct cli_state *cli, enum chown_mode change_mode,
434 const char *filename, const char *new_username)
437 struct security_descriptor *sd;
440 if (!StringToSid(cli, &sid, new_username))
441 return EXIT_PARSE_ERROR;
443 sd = make_sec_desc(talloc_tos(),
444 SECURITY_DESCRIPTOR_REVISION_1,
445 SEC_DESC_SELF_RELATIVE,
446 (change_mode == REQUEST_CHOWN) ? &sid : NULL,
447 (change_mode == REQUEST_CHGRP) ? &sid : NULL,
448 NULL, NULL, &sd_size);
450 if (!set_secdesc(cli, filename, sd)) {
458 /* The MSDN is contradictory over the ordering of ACE entries in an
459 ACL. However NT4 gives a "The information may have been modified
460 by a computer running Windows NT 5.0" if denied ACEs do not appear
461 before allowed ACEs. At
462 http://technet.microsoft.com/en-us/library/cc781716.aspx the
463 canonical order is specified as "Explicit Deny, Explicit Allow,
464 Inherited ACEs unchanged" */
466 static int ace_compare(struct security_ace *ace1, struct security_ace *ace2)
468 if (security_ace_equal(ace1, ace2))
471 if ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) &&
472 !(ace2->flags & SEC_ACE_FLAG_INHERITED_ACE))
474 if (!(ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) &&
475 (ace2->flags & SEC_ACE_FLAG_INHERITED_ACE))
477 if ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) &&
478 (ace2->flags & SEC_ACE_FLAG_INHERITED_ACE))
481 if (ace1->type != ace2->type)
482 return ace2->type - ace1->type;
484 if (dom_sid_compare(&ace1->trustee, &ace2->trustee))
485 return dom_sid_compare(&ace1->trustee, &ace2->trustee);
487 if (ace1->flags != ace2->flags)
488 return ace1->flags - ace2->flags;
490 if (ace1->access_mask != ace2->access_mask)
491 return ace1->access_mask - ace2->access_mask;
493 if (ace1->size != ace2->size)
494 return ace1->size - ace2->size;
496 return memcmp(ace1, ace2, sizeof(struct security_ace));
499 static void sort_acl(struct security_acl *the_acl)
502 if (!the_acl) return;
504 TYPESAFE_QSORT(the_acl->aces, the_acl->num_aces, ace_compare);
506 for (i=1;i<the_acl->num_aces;) {
507 if (security_ace_equal(&the_acl->aces[i-1],
508 &the_acl->aces[i])) {
510 the_acl->aces, i, the_acl->num_aces);
518 /*****************************************************
519 set the ACLs on a file given an ascii description
520 *******************************************************/
522 static int cacl_set(struct cli_state *cli, const char *filename,
523 char *the_acl, enum acl_mode mode, bool numeric)
525 struct security_descriptor *sd, *old;
528 int result = EXIT_OK;
531 sd = sddl_decode(talloc_tos(), the_acl, get_domain_sid(cli));
533 sd = sec_desc_parse(talloc_tos(), cli, the_acl);
536 if (!sd) return EXIT_PARSE_ERROR;
537 if (test_args) return EXIT_OK;
539 if (mode != SMB_ACL_SET) {
541 * Do not fetch old ACL when it will be overwritten
542 * completely with a new one.
544 old = get_secdesc(cli, filename);
551 /* the logic here is rather more complex than I would like */
554 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
557 for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
558 if (security_ace_equal(&sd->dacl->aces[i],
559 &old->dacl->aces[j])) {
561 for (k=j; k<old->dacl->num_aces-1;k++) {
562 old->dacl->aces[k] = old->dacl->aces[k+1];
564 old->dacl->num_aces--;
571 printf("ACL for ACE:");
572 print_ace(cli, stdout, &sd->dacl->aces[i],
574 printf(" not found\n");
580 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
583 for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
584 if (dom_sid_equal(&sd->dacl->aces[i].trustee,
585 &old->dacl->aces[j].trustee)) {
586 old->dacl->aces[j] = sd->dacl->aces[i];
594 SidToString(cli, str,
595 &sd->dacl->aces[i].trustee,
597 printf("ACL for SID %s not found\n", str);
602 old->owner_sid = sd->owner_sid;
606 old->group_sid = sd->group_sid;
612 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
613 add_ace(&old->dacl, &sd->dacl->aces[i]);
622 /* Denied ACE entries must come before allowed ones */
625 /* Create new security descriptor and set it */
627 /* We used to just have "WRITE_DAC_ACCESS" without WRITE_OWNER.
628 But if we're sending an owner, even if it's the same as the one
629 that already exists then W2K3 insists we open with WRITE_OWNER access.
630 I need to check that setting a SD with no owner set works against WNT
634 sd = make_sec_desc(talloc_tos(),old->revision, old->type,
635 old->owner_sid, old->group_sid,
636 NULL, old->dacl, &sd_size);
638 if (!set_secdesc(cli, filename, sd)) {
639 result = EXIT_FAILED;
645 /*****************************************************
646 set the inherit on a file
647 *******************************************************/
648 static int inherit(struct cli_state *cli, const char *filename,
651 struct security_descriptor *old,*sd;
654 int result = EXIT_OK;
656 old = get_secdesc(cli, filename);
662 oldattr = get_fileinfo(cli,filename);
664 if (strcmp(type,"allow")==0) {
665 if ((old->type & SEC_DESC_DACL_PROTECTED) ==
666 SEC_DESC_DACL_PROTECTED) {
668 char *parentname,*temp;
669 struct security_descriptor *parent;
670 temp = talloc_strdup(talloc_tos(), filename);
672 old->type=old->type & (~SEC_DESC_DACL_PROTECTED);
674 /* look at parent and copy in all its inheritable ACL's. */
675 string_replace(temp, '\\', '/');
676 if (!parent_dirname(talloc_tos(),temp,&parentname,NULL)) {
679 string_replace(parentname, '/', '\\');
680 parent = get_secdesc(cli,parentname);
681 if (parent == NULL) {
684 for (i=0;i<parent->dacl->num_aces;i++) {
685 struct security_ace *ace=&parent->dacl->aces[i];
686 /* Add inherited flag to all aces */
687 ace->flags=ace->flags|
688 SEC_ACE_FLAG_INHERITED_ACE;
689 if ((oldattr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
690 if ((ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) ==
691 SEC_ACE_FLAG_CONTAINER_INHERIT) {
692 add_ace(&old->dacl, ace);
695 if ((ace->flags & SEC_ACE_FLAG_OBJECT_INHERIT) ==
696 SEC_ACE_FLAG_OBJECT_INHERIT) {
697 /* clear flags for files */
699 add_ace(&old->dacl, ace);
704 printf("Already set to inheritable permissions.\n");
707 } else if (strcmp(type,"remove")==0) {
708 if ((old->type & SEC_DESC_DACL_PROTECTED) !=
709 SEC_DESC_DACL_PROTECTED) {
710 old->type=old->type | SEC_DESC_DACL_PROTECTED;
712 /* remove all inherited ACL's. */
715 struct security_acl *temp=old->dacl;
716 old->dacl=make_sec_acl(talloc_tos(), 3, 0, NULL);
717 for (i=temp->num_aces-1;i>=0;i--) {
718 struct security_ace *ace=&temp->aces[i];
719 /* Remove all ace with INHERITED flag set */
720 if ((ace->flags & SEC_ACE_FLAG_INHERITED_ACE) !=
721 SEC_ACE_FLAG_INHERITED_ACE) {
722 add_ace(&old->dacl,ace);
727 printf("Already set to no inheritable permissions.\n");
730 } else if (strcmp(type,"copy")==0) {
731 if ((old->type & SEC_DESC_DACL_PROTECTED) !=
732 SEC_DESC_DACL_PROTECTED) {
733 old->type=old->type | SEC_DESC_DACL_PROTECTED;
735 /* convert all inherited ACL's to non inherated ACL's. */
738 for (i=0;i<old->dacl->num_aces;i++) {
739 struct security_ace *ace=&old->dacl->aces[i];
740 /* Remove INHERITED FLAG from all aces */
741 ace->flags=ace->flags&(~SEC_ACE_FLAG_INHERITED_ACE);
745 printf("Already set to no inheritable permissions.\n");
750 /* Denied ACE entries must come before allowed ones */
753 sd = make_sec_desc(talloc_tos(),old->revision, old->type,
754 old->owner_sid, old->group_sid,
755 NULL, old->dacl, &sd_size);
757 if (!set_secdesc(cli, filename, sd)) {
758 result = EXIT_FAILED;
764 /*****************************************************
765 Return a connection to a server.
766 *******************************************************/
767 static struct cli_state *connect_one(const struct user_auth_info *auth_info,
768 const char *server, const char *share)
770 struct cli_state *c = NULL;
774 nt_status = cli_full_connection_creds(&c, lp_netbios_name(), server,
777 get_cmdline_auth_info_creds(auth_info),
779 get_cmdline_auth_info_signing_state(auth_info));
780 if (!NT_STATUS_IS_OK(nt_status)) {
781 DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status)));
785 if (get_cmdline_auth_info_smb_encrypt(auth_info)) {
786 nt_status = cli_cm_force_encryption_creds(c,
787 get_cmdline_auth_info_creds(auth_info),
789 if (!NT_STATUS_IS_OK(nt_status)) {
798 /****************************************************************************
800 ****************************************************************************/
801 int main(int argc, char *argv[])
803 const char **argv_const = discard_const_p(const char *, argv);
806 enum acl_mode mode = SMB_ACL_SET;
807 static char *the_acl = NULL;
808 enum chown_mode change_mode = REQUEST_NONE;
811 char *filename = NULL;
813 /* numeric is set when the user wants numeric SIDs and ACEs rather
814 than going via LSA calls to resolve them */
817 struct poptOption long_options[] = {
820 .longName = "delete",
822 .argInfo = POPT_ARG_STRING,
825 .descrip = "Delete an acl",
829 .longName = "modify",
831 .argInfo = POPT_ARG_STRING,
834 .descrip = "Modify an acl",
840 .argInfo = POPT_ARG_STRING,
843 .descrip = "Add an acl",
849 .argInfo = POPT_ARG_STRING,
852 .descrip = "Set acls",
853 .argDescrip = "ACLS",
858 .argInfo = POPT_ARG_STRING,
861 .descrip = "Change ownership of a file",
862 .argDescrip = "USERNAME",
867 .argInfo = POPT_ARG_STRING,
870 .descrip = "Change group ownership of a file",
871 .argDescrip = "GROUPNAME",
874 .longName = "inherit",
876 .argInfo = POPT_ARG_STRING,
879 .descrip = "Inherit allow|remove|copy",
882 .longName = "numeric",
884 .argInfo = POPT_ARG_NONE,
887 .descrip = "Don't resolve sids or masks to names",
892 .argInfo = POPT_ARG_NONE,
895 .descrip = "Output and input acls in sddl format",
898 .longName = "query-security-info",
900 .argInfo = POPT_ARG_INT,
901 .arg = &query_sec_info,
903 .descrip = "The security-info flags for queries"
906 .longName = "set-security-info",
908 .argInfo = POPT_ARG_INT,
909 .arg = &set_sec_info,
911 .descrip = "The security-info flags for modifications"
914 .longName = "test-args",
916 .argInfo = POPT_ARG_NONE,
919 .descrip = "Test arguments"
922 .longName = "domain-sid",
924 .argInfo = POPT_ARG_STRING,
927 .descrip = "Domain SID for sddl",
928 .argDescrip = "SID"},
930 .longName = "max-protocol",
932 .argInfo = POPT_ARG_STRING,
935 .descrip = "Set the max protocol level",
936 .argDescrip = "LEVEL",
939 .longName = "maximum-access",
941 .argInfo = POPT_ARG_NONE,
944 .descrip = "Query maximum persmissions",
947 POPT_COMMON_CONNECTION
948 POPT_COMMON_CREDENTIALS
952 struct cli_state *cli;
953 TALLOC_CTX *frame = talloc_stackframe();
954 const char *owner_username = "";
959 /* set default debug level to 1 regardless of what smb.conf sets */
960 setup_logging( "smbcacls", DEBUG_STDERR);
961 lp_set_cmdline("log level", "1");
965 popt_common_credentials_set_ignore_missing_conf();
967 pc = poptGetContext("smbcacls", argc, argv_const, long_options, 0);
969 poptSetOtherOptionHelp(pc, "//server1/share1 filename\nACLs look like: "
970 "'ACL:user:[ALLOWED|DENIED]/flags/permissions'");
972 while ((opt = poptGetNextOpt(pc)) != -1) {
975 the_acl = smb_xstrdup(poptGetOptArg(pc));
980 the_acl = smb_xstrdup(poptGetOptArg(pc));
981 mode = SMB_ACL_DELETE;
985 the_acl = smb_xstrdup(poptGetOptArg(pc));
986 mode = SMB_ACL_MODIFY;
990 the_acl = smb_xstrdup(poptGetOptArg(pc));
995 owner_username = poptGetOptArg(pc);
996 change_mode = REQUEST_CHOWN;
1000 owner_username = poptGetOptArg(pc);
1001 change_mode = REQUEST_CHGRP;
1005 owner_username = poptGetOptArg(pc);
1006 change_mode = REQUEST_INHERIT;
1009 lp_set_cmdline("client max protocol", poptGetOptArg(pc));
1017 /* Make connection to server */
1018 if(!poptPeekArg(pc)) {
1019 poptPrintUsage(pc, stderr, 0);
1023 path = talloc_strdup(frame, poptGetArg(pc));
1028 if(!poptPeekArg(pc)) {
1029 poptPrintUsage(pc, stderr, 0);
1033 filename = talloc_strdup(frame, poptGetArg(pc));
1038 poptFreeContext(pc);
1039 popt_burn_cmdline_password(argc, argv);
1040 popt_common_credentials_post();
1042 string_replace(path,'/','\\');
1044 server = talloc_strdup(frame, path+2);
1048 share = strchr_m(server,'\\');
1049 if (share == NULL) {
1050 printf("Invalid argument\n");
1058 cli = connect_one(popt_get_cmdline_auth_info(), server, share);
1063 popt_free_cmdline_auth_info();
1067 string_replace(filename, '/', '\\');
1068 if (filename[0] != '\\') {
1069 filename = talloc_asprintf(frame,
1077 /* Perform requested action */
1079 if (change_mode == REQUEST_INHERIT) {
1080 result = inherit(cli, filename, owner_username);
1081 } else if (change_mode != REQUEST_NONE) {
1082 result = owner_set(cli, change_mode, filename, owner_username);
1083 } else if (the_acl) {
1084 result = cacl_set(cli, filename, the_acl, mode, numeric);
1086 result = cacl_dump(cli, filename, numeric);
1089 popt_free_cmdline_auth_info();