2 Unix SMB/Netbios implementation.
3 SMB client library implementation
4 Copyright (C) Andrew Tridgell 1998
5 Copyright (C) Richard Sharpe 2000, 2002
6 Copyright (C) John Terpstra 2000
7 Copyright (C) Tom Jansen (Ninja ISD) 2002
8 Copyright (C) Derrell Lipman 2003-2008
9 Copyright (C) Jeremy Allison 2007, 2008
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "libsmb/libsmb.h"
27 #include "libsmbclient.h"
28 #include "libsmb_internal.h"
29 #include "../librpc/gen_ndr/ndr_lsa.h"
30 #include "rpc_client/rpc_client.h"
31 #include "rpc_client/cli_lsarpc.h"
32 #include "../libcli/security/security.h"
35 * Find an lsa pipe handle associated with a cli struct.
37 static struct rpc_pipe_client *
38 find_lsa_pipe_hnd(struct cli_state *ipc_cli)
40 struct rpc_pipe_client *pipe_hnd;
42 for (pipe_hnd = ipc_cli->pipe_list;
44 pipe_hnd = pipe_hnd->next) {
45 if (ndr_syntax_id_equal(&pipe_hnd->abstract_syntax,
46 &ndr_table_lsarpc.syntax_id)) {
54 * Sort ACEs according to the documentation at
55 * http://support.microsoft.com/kb/269175, at least as far as it defines the
60 ace_compare(struct security_ace *ace1,
61 struct security_ace *ace2)
66 /* If the ACEs are equal, we have nothing more to do. */
67 if (sec_ace_equal(ace1, ace2)) {
71 /* Inherited follow non-inherited */
72 b1 = ((ace1->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0);
73 b2 = ((ace2->flags & SEC_ACE_FLAG_INHERITED_ACE) != 0);
79 * What shall we do with AUDITs and ALARMs? It's undefined. We'll
80 * sort them after DENY and ALLOW.
82 b1 = (ace1->type != SEC_ACE_TYPE_ACCESS_ALLOWED &&
83 ace1->type != SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT &&
84 ace1->type != SEC_ACE_TYPE_ACCESS_DENIED &&
85 ace1->type != SEC_ACE_TYPE_ACCESS_DENIED_OBJECT);
86 b2 = (ace2->type != SEC_ACE_TYPE_ACCESS_ALLOWED &&
87 ace2->type != SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT &&
88 ace2->type != SEC_ACE_TYPE_ACCESS_DENIED &&
89 ace2->type != SEC_ACE_TYPE_ACCESS_DENIED_OBJECT);
94 /* Allowed ACEs follow denied ACEs */
95 b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED ||
96 ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT);
97 b2 = (ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED ||
98 ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT);
100 return (b1 ? 1 : -1);
104 * ACEs applying to an entity's object follow those applying to the
107 b1 = (ace1->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT ||
108 ace1->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT);
109 b2 = (ace2->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT ||
110 ace2->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT);
112 return (b1 ? 1 : -1);
116 * If we get this far, the ACEs are similar as far as the
117 * characteristics we typically care about (those defined by the
118 * referenced MS document). We'll now sort by characteristics that
119 * just seems reasonable.
122 if (ace1->type != ace2->type) {
123 return ace2->type - ace1->type;
126 if (dom_sid_compare(&ace1->trustee, &ace2->trustee)) {
127 return dom_sid_compare(&ace1->trustee, &ace2->trustee);
130 if (ace1->flags != ace2->flags) {
131 return ace1->flags - ace2->flags;
134 if (ace1->access_mask != ace2->access_mask) {
135 return ace1->access_mask - ace2->access_mask;
138 if (ace1->size != ace2->size) {
139 return ace1->size - ace2->size;
142 return memcmp(ace1, ace2, sizeof(struct security_ace));
147 sort_acl(struct security_acl *the_acl)
150 if (!the_acl) return;
152 TYPESAFE_QSORT(the_acl->aces, the_acl->num_aces, ace_compare);
154 for (i=1;i<the_acl->num_aces;) {
155 if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) {
157 for (j=i; j<the_acl->num_aces-1; j++) {
158 the_acl->aces[j] = the_acl->aces[j+1];
167 /* convert a SID to a string, either numeric or username/group */
169 convert_sid_to_string(struct cli_state *ipc_cli,
170 struct policy_handle *pol,
175 char **domains = NULL;
177 enum lsa_SidType *types = NULL;
178 struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli);
181 sid_to_fstring(str, sid);
184 return; /* no lookup desired */
191 /* Ask LSA to convert the sid to a name */
193 ctx = talloc_stackframe();
195 if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_sids(pipe_hnd, ctx,
196 pol, 1, sid, &domains,
198 !domains || !domains[0] || !names || !names[0]) {
205 slprintf(str, sizeof(fstring) - 1, "%s%s%s",
206 domains[0], lp_winbind_separator(),
212 /* convert a string to a SID, either numeric or username/group */
214 convert_string_to_sid(struct cli_state *ipc_cli,
215 struct policy_handle *pol,
220 enum lsa_SidType *types = NULL;
221 struct dom_sid *sids = NULL;
223 TALLOC_CTX *ctx = NULL;
224 struct rpc_pipe_client *pipe_hnd = find_lsa_pipe_hnd(ipc_cli);
231 if (strncmp(str, "S-", 2) == 0) {
232 return string_to_sid(sid, str);
239 ctx = talloc_stackframe();
240 if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ctx,
248 sid_copy(sid, &sids[0]);
255 /* parse an struct security_ace in the same format as print_ace() */
257 parse_ace(struct cli_state *ipc_cli,
258 struct policy_handle *pol,
259 struct security_ace *ace,
271 const struct perm_value *v;
276 TALLOC_CTX *frame = talloc_stackframe();
278 /* These values discovered by inspection */
279 static const struct perm_value special_values[] = {
289 static const struct perm_value standard_values[] = {
290 { "READ", 0x001200a9 },
291 { "CHANGE", 0x001301bf },
292 { "FULL", 0x001f01ff },
297 p = strchr_m(str,':');
304 /* Try to parse numeric form */
306 if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 &&
307 convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) {
311 /* Try to parse text form */
313 if (!convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) {
319 if (!next_token_talloc(frame, &cp, &tok, "/")) {
324 if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
325 atype = SEC_ACE_TYPE_ACCESS_ALLOWED;
326 } else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) {
327 atype = SEC_ACE_TYPE_ACCESS_DENIED;
333 /* Only numeric form accepted for flags at present */
335 if (!(next_token_talloc(frame, &cp, &tok, "/") &&
336 sscanf(tok, "%i", &aflags))) {
341 if (!next_token_talloc(frame, &cp, &tok, "/")) {
346 if (strncmp(tok, "0x", 2) == 0) {
347 if (sscanf(tok, "%i", &amask) != 1) {
354 for (v = standard_values; v->perm; v++) {
355 if (strcmp(tok, v->perm) == 0) {
366 for (v = special_values; v->perm; v++) {
367 if (v->perm[0] == *p) {
387 init_sec_ace(ace, &sid, atype, mask, aflags);
392 /* add an struct security_ace to a list of struct security_aces in a struct security_acl */
394 add_ace(struct security_acl **the_acl,
395 struct security_ace *ace,
398 struct security_acl *newacl;
399 struct security_ace *aces;
402 (*the_acl) = make_sec_acl(ctx, 3, 1, ace);
406 if ((aces = SMB_CALLOC_ARRAY(struct security_ace,
407 1+(*the_acl)->num_aces)) == NULL) {
410 memcpy(aces, (*the_acl)->aces, (*the_acl)->num_aces * sizeof(struct security_ace));
411 memcpy(aces+(*the_acl)->num_aces, ace, sizeof(struct security_ace));
412 newacl = make_sec_acl(ctx, (*the_acl)->revision,
413 1+(*the_acl)->num_aces, aces);
420 /* parse a ascii version of a security descriptor */
421 static struct security_descriptor *
422 sec_desc_parse(TALLOC_CTX *ctx,
423 struct cli_state *ipc_cli,
424 struct policy_handle *pol,
430 struct security_descriptor *ret = NULL;
432 struct dom_sid *group_sid=NULL;
433 struct dom_sid *owner_sid=NULL;
434 struct security_acl *dacl=NULL;
437 while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) {
439 if (StrnCaseCmp(tok,"REVISION:", 9) == 0) {
440 revision = strtol(tok+9, NULL, 16);
444 if (StrnCaseCmp(tok,"OWNER:", 6) == 0) {
446 DEBUG(5,("OWNER specified more than once!\n"));
449 owner_sid = SMB_CALLOC_ARRAY(struct dom_sid, 1);
451 !convert_string_to_sid(ipc_cli, pol,
454 DEBUG(5, ("Failed to parse owner sid\n"));
460 if (StrnCaseCmp(tok,"OWNER+:", 7) == 0) {
462 DEBUG(5,("OWNER specified more than once!\n"));
465 owner_sid = SMB_CALLOC_ARRAY(struct dom_sid, 1);
467 !convert_string_to_sid(ipc_cli, pol,
470 DEBUG(5, ("Failed to parse owner sid\n"));
476 if (StrnCaseCmp(tok,"GROUP:", 6) == 0) {
478 DEBUG(5,("GROUP specified more than once!\n"));
481 group_sid = SMB_CALLOC_ARRAY(struct dom_sid, 1);
483 !convert_string_to_sid(ipc_cli, pol,
486 DEBUG(5, ("Failed to parse group sid\n"));
492 if (StrnCaseCmp(tok,"GROUP+:", 7) == 0) {
494 DEBUG(5,("GROUP specified more than once!\n"));
497 group_sid = SMB_CALLOC_ARRAY(struct dom_sid, 1);
499 !convert_string_to_sid(ipc_cli, pol,
502 DEBUG(5, ("Failed to parse group sid\n"));
508 if (StrnCaseCmp(tok,"ACL:", 4) == 0) {
509 struct security_ace ace;
510 if (!parse_ace(ipc_cli, pol, &ace, numeric, tok+4)) {
511 DEBUG(5, ("Failed to parse ACL %s\n", tok));
514 if(!add_ace(&dacl, &ace, ctx)) {
515 DEBUG(5, ("Failed to add ACL %s\n", tok));
521 if (StrnCaseCmp(tok,"ACL+:", 5) == 0) {
522 struct security_ace ace;
523 if (!parse_ace(ipc_cli, pol, &ace, False, tok+5)) {
524 DEBUG(5, ("Failed to parse ACL %s\n", tok));
527 if(!add_ace(&dacl, &ace, ctx)) {
528 DEBUG(5, ("Failed to add ACL %s\n", tok));
534 DEBUG(5, ("Failed to parse security descriptor\n"));
538 ret = make_sec_desc(ctx, revision, SEC_DESC_SELF_RELATIVE,
539 owner_sid, group_sid, NULL, dacl, &sd_size);
542 SAFE_FREE(group_sid);
543 SAFE_FREE(owner_sid);
548 /* Obtain the current dos attributes */
549 static DOS_ATTR_DESC *
550 dos_attr_query(SMBCCTX *context,
552 const char *filename,
555 struct timespec create_time_ts;
556 struct timespec write_time_ts;
557 struct timespec access_time_ts;
558 struct timespec change_time_ts;
564 ret = TALLOC_P(ctx, DOS_ATTR_DESC);
570 /* Obtain the DOS attributes */
571 if (!SMBC_getatr(context, srv, filename,
578 errno = SMBC_errno(context, srv->cli);
579 DEBUG(5, ("dos_attr_query Failed to query old attributes\n"));
585 ret->create_time = convert_timespec_to_time_t(create_time_ts);
586 ret->access_time = convert_timespec_to_time_t(access_time_ts);
587 ret->write_time = convert_timespec_to_time_t(write_time_ts);
588 ret->change_time = convert_timespec_to_time_t(change_time_ts);
595 /* parse a ascii version of a security descriptor */
597 dos_attr_parse(SMBCCTX *context,
605 TALLOC_CTX *frame = NULL;
607 const char * create_time_attr;
608 const char * access_time_attr;
609 const char * write_time_attr;
610 const char * change_time_attr;
613 /* Determine whether to use old-style or new-style attribute names */
614 if (context->internal->full_time_names) {
615 /* new-style names */
616 attr_strings.create_time_attr = "CREATE_TIME";
617 attr_strings.access_time_attr = "ACCESS_TIME";
618 attr_strings.write_time_attr = "WRITE_TIME";
619 attr_strings.change_time_attr = "CHANGE_TIME";
621 /* old-style names */
622 attr_strings.create_time_attr = NULL;
623 attr_strings.access_time_attr = "A_TIME";
624 attr_strings.write_time_attr = "M_TIME";
625 attr_strings.change_time_attr = "C_TIME";
628 /* if this is to set the entire ACL... */
630 /* ... then increment past the first colon if there is one */
631 if ((p = strchr(str, ':')) != NULL) {
638 frame = talloc_stackframe();
639 while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) {
640 if (StrnCaseCmp(tok, "MODE:", 5) == 0) {
641 long request = strtol(tok+5, NULL, 16);
643 dad->mode = (request |
644 (IS_DOS_DIR(dad->mode)
645 ? FILE_ATTRIBUTE_DIRECTORY
646 : FILE_ATTRIBUTE_NORMAL));
653 if (StrnCaseCmp(tok, "SIZE:", 5) == 0) {
654 dad->size = (SMB_OFF_T)atof(tok+5);
658 n = strlen(attr_strings.access_time_attr);
659 if (StrnCaseCmp(tok, attr_strings.access_time_attr, n) == 0) {
660 dad->access_time = (time_t)strtol(tok+n+1, NULL, 10);
664 n = strlen(attr_strings.change_time_attr);
665 if (StrnCaseCmp(tok, attr_strings.change_time_attr, n) == 0) {
666 dad->change_time = (time_t)strtol(tok+n+1, NULL, 10);
670 n = strlen(attr_strings.write_time_attr);
671 if (StrnCaseCmp(tok, attr_strings.write_time_attr, n) == 0) {
672 dad->write_time = (time_t)strtol(tok+n+1, NULL, 10);
676 if (attr_strings.create_time_attr != NULL) {
677 n = strlen(attr_strings.create_time_attr);
678 if (StrnCaseCmp(tok, attr_strings.create_time_attr,
680 dad->create_time = (time_t)strtol(tok+n+1,
686 if (StrnCaseCmp(tok, "INODE:", 6) == 0) {
687 dad->inode = (SMB_INO_T)atof(tok+6);
694 /*****************************************************
695 Retrieve the acls for a file.
696 *******************************************************/
699 cacl_get(SMBCCTX *context,
702 struct cli_state *ipc_cli,
703 struct policy_handle *pol,
704 const char *filename,
705 const char *attr_name,
718 bool exclude_nt_revision = False;
719 bool exclude_nt_owner = False;
720 bool exclude_nt_group = False;
721 bool exclude_nt_acl = False;
722 bool exclude_dos_mode = False;
723 bool exclude_dos_size = False;
724 bool exclude_dos_create_time = False;
725 bool exclude_dos_access_time = False;
726 bool exclude_dos_write_time = False;
727 bool exclude_dos_change_time = False;
728 bool exclude_dos_inode = False;
730 bool determine_size = (bufsize == 0);
732 struct security_descriptor *sd;
734 fstring name_sandbox;
738 struct timespec create_time_ts;
739 struct timespec write_time_ts;
740 struct timespec access_time_ts;
741 struct timespec change_time_ts;
742 time_t create_time = (time_t)0;
743 time_t write_time = (time_t)0;
744 time_t access_time = (time_t)0;
745 time_t change_time = (time_t)0;
749 struct cli_state *cli = srv->cli;
751 const char * create_time_attr;
752 const char * access_time_attr;
753 const char * write_time_attr;
754 const char * change_time_attr;
757 const char * create_time_attr;
758 const char * access_time_attr;
759 const char * write_time_attr;
760 const char * change_time_attr;
763 /* Determine whether to use old-style or new-style attribute names */
764 if (context->internal->full_time_names) {
765 /* new-style names */
766 attr_strings.create_time_attr = "CREATE_TIME";
767 attr_strings.access_time_attr = "ACCESS_TIME";
768 attr_strings.write_time_attr = "WRITE_TIME";
769 attr_strings.change_time_attr = "CHANGE_TIME";
771 excl_attr_strings.create_time_attr = "CREATE_TIME";
772 excl_attr_strings.access_time_attr = "ACCESS_TIME";
773 excl_attr_strings.write_time_attr = "WRITE_TIME";
774 excl_attr_strings.change_time_attr = "CHANGE_TIME";
776 /* old-style names */
777 attr_strings.create_time_attr = NULL;
778 attr_strings.access_time_attr = "A_TIME";
779 attr_strings.write_time_attr = "M_TIME";
780 attr_strings.change_time_attr = "C_TIME";
782 excl_attr_strings.create_time_attr = NULL;
783 excl_attr_strings.access_time_attr = "dos_attr.A_TIME";
784 excl_attr_strings.write_time_attr = "dos_attr.M_TIME";
785 excl_attr_strings.change_time_attr = "dos_attr.C_TIME";
788 /* Copy name so we can strip off exclusions (if any are specified) */
789 strncpy(name_sandbox, attr_name, sizeof(name_sandbox) - 1);
791 /* Ensure name is null terminated */
792 name_sandbox[sizeof(name_sandbox) - 1] = '\0';
794 /* Play in the sandbox */
797 /* If there are any exclusions, point to them and mask them from name */
798 if ((pExclude = strchr(name, '!')) != NULL)
803 all = (StrnCaseCmp(name, "system.*", 8) == 0);
804 all_nt = (StrnCaseCmp(name, "system.nt_sec_desc.*", 20) == 0);
805 all_nt_acls = (StrnCaseCmp(name, "system.nt_sec_desc.acl.*", 24) == 0);
806 all_dos = (StrnCaseCmp(name, "system.dos_attr.*", 17) == 0);
807 some_nt = (StrnCaseCmp(name, "system.nt_sec_desc.", 19) == 0);
808 some_dos = (StrnCaseCmp(name, "system.dos_attr.", 16) == 0);
809 numeric = (* (name + strlen(name) - 1) != '+');
811 /* Look for exclusions from "all" requests */
812 if (all || all_nt || all_dos) {
813 /* Exclusions are delimited by '!' */
816 pExclude = (p == NULL ? NULL : p + 1)) {
818 /* Find end of this exclusion name */
819 if ((p = strchr(pExclude, '!')) != NULL)
824 /* Which exclusion name is this? */
825 if (StrCaseCmp(pExclude,
826 "nt_sec_desc.revision") == 0) {
827 exclude_nt_revision = True;
829 else if (StrCaseCmp(pExclude,
830 "nt_sec_desc.owner") == 0) {
831 exclude_nt_owner = True;
833 else if (StrCaseCmp(pExclude,
834 "nt_sec_desc.group") == 0) {
835 exclude_nt_group = True;
837 else if (StrCaseCmp(pExclude,
838 "nt_sec_desc.acl") == 0) {
839 exclude_nt_acl = True;
841 else if (StrCaseCmp(pExclude,
842 "dos_attr.mode") == 0) {
843 exclude_dos_mode = True;
845 else if (StrCaseCmp(pExclude,
846 "dos_attr.size") == 0) {
847 exclude_dos_size = True;
849 else if (excl_attr_strings.create_time_attr != NULL &&
851 excl_attr_strings.change_time_attr) == 0) {
852 exclude_dos_create_time = True;
854 else if (StrCaseCmp(pExclude,
855 excl_attr_strings.access_time_attr) == 0) {
856 exclude_dos_access_time = True;
858 else if (StrCaseCmp(pExclude,
859 excl_attr_strings.write_time_attr) == 0) {
860 exclude_dos_write_time = True;
862 else if (StrCaseCmp(pExclude,
863 excl_attr_strings.change_time_attr) == 0) {
864 exclude_dos_change_time = True;
866 else if (StrCaseCmp(pExclude, "dos_attr.inode") == 0) {
867 exclude_dos_inode = True;
870 DEBUG(5, ("cacl_get received unknown exclusion: %s\n",
881 * If we are (possibly) talking to an NT or new system and some NT
882 * attributes have been requested...
884 if (ipc_cli && (all || some_nt || all_nt_acls)) {
885 char *targetpath = NULL;
886 struct cli_state *targetcli = NULL;
888 /* Point to the portion after "system.nt_sec_desc." */
889 name += 19; /* if (all) this will be invalid but unused */
891 if (!cli_resolve_path(ctx, "", context->internal->auth_info,
893 &targetcli, &targetpath)) {
894 DEBUG(5, ("cacl_get Could not resolve %s\n",
900 /* ... then obtain any NT attributes which were requested */
901 if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
902 FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
903 DEBUG(5, ("cacl_get failed to open %s: %s\n",
904 targetpath, cli_errstr(targetcli)));
909 sd = cli_query_secdesc(targetcli, fnum, ctx);
913 ("cacl_get Failed to query old descriptor\n"));
918 cli_close(targetcli, fnum);
920 if (! exclude_nt_revision) {
922 if (determine_size) {
923 p = talloc_asprintf(ctx,
932 n = snprintf(buf, bufsize,
936 } else if (StrCaseCmp(name, "revision") == 0) {
937 if (determine_size) {
938 p = talloc_asprintf(ctx, "%d",
946 n = snprintf(buf, bufsize, "%d",
951 if (!determine_size && n > bufsize) {
961 if (! exclude_nt_owner) {
962 /* Get owner and group sid */
964 convert_sid_to_string(ipc_cli, pol,
973 if (determine_size) {
974 p = talloc_asprintf(ctx, ",OWNER:%s",
981 } else if (sidstr[0] != '\0') {
982 n = snprintf(buf, bufsize,
983 ",OWNER:%s", sidstr);
985 } else if (StrnCaseCmp(name, "owner", 5) == 0) {
986 if (determine_size) {
987 p = talloc_asprintf(ctx, "%s", sidstr);
994 n = snprintf(buf, bufsize, "%s",
999 if (!determine_size && n > bufsize) {
1009 if (! exclude_nt_group) {
1010 if (sd->group_sid) {
1011 convert_sid_to_string(ipc_cli, pol,
1015 fstrcpy(sidstr, "");
1018 if (all || all_nt) {
1019 if (determine_size) {
1020 p = talloc_asprintf(ctx, ",GROUP:%s",
1027 } else if (sidstr[0] != '\0') {
1028 n = snprintf(buf, bufsize,
1029 ",GROUP:%s", sidstr);
1031 } else if (StrnCaseCmp(name, "group", 5) == 0) {
1032 if (determine_size) {
1033 p = talloc_asprintf(ctx, "%s", sidstr);
1040 n = snprintf(buf, bufsize,
1045 if (!determine_size && n > bufsize) {
1055 if (! exclude_nt_acl) {
1056 /* Add aces to value buffer */
1057 for (i = 0; sd->dacl && i < sd->dacl->num_aces; i++) {
1059 struct security_ace *ace = &sd->dacl->aces[i];
1060 convert_sid_to_string(ipc_cli, pol,
1064 if (all || all_nt) {
1065 if (determine_size) {
1066 p = talloc_asprintf(
1082 ",ACL:%s:%d/%d/0x%08x",
1088 } else if ((StrnCaseCmp(name, "acl", 3) == 0 &&
1089 StrCaseCmp(name+3, sidstr) == 0) ||
1090 (StrnCaseCmp(name, "acl+", 4) == 0 &&
1091 StrCaseCmp(name+4, sidstr) == 0)) {
1092 if (determine_size) {
1093 p = talloc_asprintf(
1105 n = snprintf(buf, bufsize,
1111 } else if (all_nt_acls) {
1112 if (determine_size) {
1113 p = talloc_asprintf(
1115 "%s%s:%d/%d/0x%08x",
1127 n = snprintf(buf, bufsize,
1128 "%s%s:%d/%d/0x%08x",
1136 if (!determine_size && n > bufsize) {
1147 /* Restore name pointer to its original value */
1151 if (all || some_dos) {
1152 /* Point to the portion after "system.dos_attr." */
1153 name += 16; /* if (all) this will be invalid but unused */
1155 /* Obtain the DOS attributes */
1156 if (!SMBC_getatr(context, srv, filename, &mode, &size,
1163 errno = SMBC_errno(context, srv->cli);
1167 create_time = convert_timespec_to_time_t(create_time_ts);
1168 access_time = convert_timespec_to_time_t(access_time_ts);
1169 write_time = convert_timespec_to_time_t(write_time_ts);
1170 change_time = convert_timespec_to_time_t(change_time_ts);
1172 if (! exclude_dos_mode) {
1173 if (all || all_dos) {
1174 if (determine_size) {
1175 p = talloc_asprintf(ctx,
1188 n = snprintf(buf, bufsize,
1196 } else if (StrCaseCmp(name, "mode") == 0) {
1197 if (determine_size) {
1198 p = talloc_asprintf(ctx, "0x%x", mode);
1205 n = snprintf(buf, bufsize,
1210 if (!determine_size && n > bufsize) {
1220 if (! exclude_dos_size) {
1221 if (all || all_dos) {
1222 if (determine_size) {
1223 p = talloc_asprintf(
1233 n = snprintf(buf, bufsize,
1237 } else if (StrCaseCmp(name, "size") == 0) {
1238 if (determine_size) {
1239 p = talloc_asprintf(
1249 n = snprintf(buf, bufsize,
1255 if (!determine_size && n > bufsize) {
1265 if (! exclude_dos_create_time &&
1266 attr_strings.create_time_attr != NULL) {
1267 if (all || all_dos) {
1268 if (determine_size) {
1269 p = talloc_asprintf(ctx,
1271 attr_strings.create_time_attr,
1272 (unsigned long) create_time);
1279 n = snprintf(buf, bufsize,
1281 attr_strings.create_time_attr,
1282 (unsigned long) create_time);
1284 } else if (StrCaseCmp(name, attr_strings.create_time_attr) == 0) {
1285 if (determine_size) {
1286 p = talloc_asprintf(ctx, "%lu", (unsigned long) create_time);
1293 n = snprintf(buf, bufsize,
1294 "%lu", (unsigned long) create_time);
1298 if (!determine_size && n > bufsize) {
1308 if (! exclude_dos_access_time) {
1309 if (all || all_dos) {
1310 if (determine_size) {
1311 p = talloc_asprintf(ctx,
1313 attr_strings.access_time_attr,
1314 (unsigned long) access_time);
1321 n = snprintf(buf, bufsize,
1323 attr_strings.access_time_attr,
1324 (unsigned long) access_time);
1326 } else if (StrCaseCmp(name, attr_strings.access_time_attr) == 0) {
1327 if (determine_size) {
1328 p = talloc_asprintf(ctx, "%lu", (unsigned long) access_time);
1335 n = snprintf(buf, bufsize,
1336 "%lu", (unsigned long) access_time);
1340 if (!determine_size && n > bufsize) {
1350 if (! exclude_dos_write_time) {
1351 if (all || all_dos) {
1352 if (determine_size) {
1353 p = talloc_asprintf(ctx,
1355 attr_strings.write_time_attr,
1356 (unsigned long) write_time);
1363 n = snprintf(buf, bufsize,
1365 attr_strings.write_time_attr,
1366 (unsigned long) write_time);
1368 } else if (StrCaseCmp(name, attr_strings.write_time_attr) == 0) {
1369 if (determine_size) {
1370 p = talloc_asprintf(ctx, "%lu", (unsigned long) write_time);
1377 n = snprintf(buf, bufsize,
1378 "%lu", (unsigned long) write_time);
1382 if (!determine_size && n > bufsize) {
1392 if (! exclude_dos_change_time) {
1393 if (all || all_dos) {
1394 if (determine_size) {
1395 p = talloc_asprintf(ctx,
1397 attr_strings.change_time_attr,
1398 (unsigned long) change_time);
1405 n = snprintf(buf, bufsize,
1407 attr_strings.change_time_attr,
1408 (unsigned long) change_time);
1410 } else if (StrCaseCmp(name, attr_strings.change_time_attr) == 0) {
1411 if (determine_size) {
1412 p = talloc_asprintf(ctx, "%lu", (unsigned long) change_time);
1419 n = snprintf(buf, bufsize,
1420 "%lu", (unsigned long) change_time);
1424 if (!determine_size && n > bufsize) {
1434 if (! exclude_dos_inode) {
1435 if (all || all_dos) {
1436 if (determine_size) {
1437 p = talloc_asprintf(
1447 n = snprintf(buf, bufsize,
1451 } else if (StrCaseCmp(name, "inode") == 0) {
1452 if (determine_size) {
1453 p = talloc_asprintf(
1463 n = snprintf(buf, bufsize,
1469 if (!determine_size && n > bufsize) {
1479 /* Restore name pointer to its original value */
1491 /*****************************************************
1492 set the ACLs on a file given an ascii description
1493 *******************************************************/
1495 cacl_set(SMBCCTX *context,
1497 struct cli_state *cli,
1498 struct cli_state *ipc_cli,
1499 struct policy_handle *pol,
1500 const char *filename,
1505 uint16_t fnum = (uint16_t)-1;
1507 struct security_descriptor *sd = NULL, *old;
1508 struct security_acl *dacl = NULL;
1509 struct dom_sid *owner_sid = NULL;
1510 struct dom_sid *group_sid = NULL;
1515 bool numeric = True;
1516 char *targetpath = NULL;
1517 struct cli_state *targetcli = NULL;
1520 /* the_acl will be null for REMOVE_ALL operations */
1522 numeric = ((p = strchr(the_acl, ':')) != NULL &&
1526 /* if this is to set the entire ACL... */
1527 if (*the_acl == '*') {
1528 /* ... then increment past the first colon */
1532 sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, the_acl);
1539 /* SMBC_XATTR_MODE_REMOVE_ALL is the only caller
1540 that doesn't deref sd */
1542 if (!sd && (mode != SMBC_XATTR_MODE_REMOVE_ALL)) {
1547 if (!cli_resolve_path(ctx, "", context->internal->auth_info,
1549 &targetcli, &targetpath)) {
1550 DEBUG(5,("cacl_set: Could not resolve %s\n", filename));
1555 /* The desired access below is the only one I could find that works
1556 with NT4, W2KP and Samba */
1558 if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
1559 FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
1560 DEBUG(5, ("cacl_set failed to open %s: %s\n",
1561 targetpath, cli_errstr(targetcli)));
1566 old = cli_query_secdesc(targetcli, fnum, ctx);
1569 DEBUG(5, ("cacl_set Failed to query old descriptor\n"));
1574 cli_close(targetcli, fnum);
1577 case SMBC_XATTR_MODE_REMOVE_ALL:
1578 old->dacl->num_aces = 0;
1582 case SMBC_XATTR_MODE_REMOVE:
1583 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
1586 for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
1587 if (sec_ace_equal(&sd->dacl->aces[i],
1588 &old->dacl->aces[j])) {
1590 for (k=j; k<old->dacl->num_aces-1;k++) {
1591 old->dacl->aces[k] =
1592 old->dacl->aces[k+1];
1594 old->dacl->num_aces--;
1609 case SMBC_XATTR_MODE_ADD:
1610 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
1613 for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
1614 if (dom_sid_equal(&sd->dacl->aces[i].trustee,
1615 &old->dacl->aces[j].trustee)) {
1616 if (!(flags & SMBC_XATTR_FLAG_CREATE)) {
1621 old->dacl->aces[j] = sd->dacl->aces[i];
1627 if (!found && (flags & SMBC_XATTR_FLAG_REPLACE)) {
1633 for (i=0;sd->dacl && i<sd->dacl->num_aces;i++) {
1634 add_ace(&old->dacl, &sd->dacl->aces[i], ctx);
1640 case SMBC_XATTR_MODE_SET:
1642 owner_sid = old->owner_sid;
1643 group_sid = old->group_sid;
1647 case SMBC_XATTR_MODE_CHOWN:
1648 owner_sid = sd->owner_sid;
1651 case SMBC_XATTR_MODE_CHGRP:
1652 group_sid = sd->group_sid;
1656 /* Denied ACE entries must come before allowed ones */
1657 sort_acl(old->dacl);
1659 /* Create new security descriptor and set it */
1660 sd = make_sec_desc(ctx, old->revision, SEC_DESC_SELF_RELATIVE,
1661 owner_sid, group_sid, NULL, dacl, &sd_size);
1663 if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetpath, 0,
1664 WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
1665 FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
1666 DEBUG(5, ("cacl_set failed to open %s: %s\n",
1667 targetpath, cli_errstr(targetcli)));
1672 status = cli_set_secdesc(targetcli, fnum, sd);
1673 if (!NT_STATUS_IS_OK(status)) {
1674 DEBUG(5, ("ERROR: secdesc set failed: %s\n",
1675 nt_errstr(status)));
1682 cli_close(targetcli, fnum);
1693 SMBC_setxattr_ctx(SMBCCTX *context,
1702 SMBCSRV *srv = NULL;
1703 SMBCSRV *ipc_srv = NULL;
1704 char *server = NULL;
1707 char *password = NULL;
1708 char *workgroup = NULL;
1710 DOS_ATTR_DESC *dad = NULL;
1712 const char * create_time_attr;
1713 const char * access_time_attr;
1714 const char * write_time_attr;
1715 const char * change_time_attr;
1717 TALLOC_CTX *frame = talloc_stackframe();
1719 if (!context || !context->internal->initialized) {
1720 errno = EINVAL; /* Best I can think of ... */
1731 DEBUG(4, ("smbc_setxattr(%s, %s, %.*s)\n",
1732 fname, name, (int) size, (const char*)value));
1734 if (SMBC_parse_path(frame,
1749 if (!user || user[0] == (char)0) {
1750 user = talloc_strdup(frame, smbc_getUser(context));
1758 srv = SMBC_server(frame, context, True,
1759 server, share, &workgroup, &user, &password);
1762 return -1; /* errno set by SMBC_server */
1765 if (! srv->no_nt_session) {
1766 ipc_srv = SMBC_attr_server(frame, context, server, share,
1767 &workgroup, &user, &password);
1769 srv->no_nt_session = True;
1776 * Are they asking to set the entire set of known attributes?
1778 if (StrCaseCmp(name, "system.*") == 0 ||
1779 StrCaseCmp(name, "system.*+") == 0) {
1782 talloc_asprintf(talloc_tos(), "%s:%s",
1783 name+7, (const char *) value);
1792 ret = cacl_set(context, talloc_tos(), srv->cli,
1793 ipc_srv->cli, &ipc_srv->pol, path,
1796 ? SMBC_XATTR_MODE_SET
1797 : SMBC_XATTR_MODE_ADD),
1803 /* get a DOS Attribute Descriptor with current attributes */
1804 dad = dos_attr_query(context, talloc_tos(), path, srv);
1806 /* Overwrite old with new, using what was provided */
1807 dos_attr_parse(context, dad, srv, namevalue);
1809 /* Set the new DOS attributes */
1810 if (! SMBC_setatr(context, srv, path,
1817 /* cause failure if NT failed too */
1822 /* we only fail if both NT and DOS sets failed */
1823 if (ret < 0 && ! dad) {
1824 ret = -1; /* in case dad was null */
1835 * Are they asking to set an access control element or to set
1836 * the entire access control list?
1838 if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
1839 StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 ||
1840 StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
1841 StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
1842 StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) {
1846 talloc_asprintf(talloc_tos(), "%s:%s",
1847 name+19, (const char *) value);
1850 ret = -1; /* errno set by SMBC_server() */
1852 else if (! namevalue) {
1856 ret = cacl_set(context, talloc_tos(), srv->cli,
1857 ipc_srv->cli, &ipc_srv->pol, path,
1860 ? SMBC_XATTR_MODE_SET
1861 : SMBC_XATTR_MODE_ADD),
1869 * Are they asking to set the owner?
1871 if (StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
1872 StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0) {
1876 talloc_asprintf(talloc_tos(), "%s:%s",
1877 name+19, (const char *) value);
1880 ret = -1; /* errno set by SMBC_server() */
1882 else if (! namevalue) {
1886 ret = cacl_set(context, talloc_tos(), srv->cli,
1887 ipc_srv->cli, &ipc_srv->pol, path,
1888 namevalue, SMBC_XATTR_MODE_CHOWN, 0);
1895 * Are they asking to set the group?
1897 if (StrCaseCmp(name, "system.nt_sec_desc.group") == 0 ||
1898 StrCaseCmp(name, "system.nt_sec_desc.group+") == 0) {
1902 talloc_asprintf(talloc_tos(), "%s:%s",
1903 name+19, (const char *) value);
1906 /* errno set by SMBC_server() */
1909 else if (! namevalue) {
1913 ret = cacl_set(context, talloc_tos(), srv->cli,
1914 ipc_srv->cli, &ipc_srv->pol, path,
1915 namevalue, SMBC_XATTR_MODE_CHGRP, 0);
1921 /* Determine whether to use old-style or new-style attribute names */
1922 if (context->internal->full_time_names) {
1923 /* new-style names */
1924 attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME";
1925 attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME";
1926 attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME";
1927 attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME";
1929 /* old-style names */
1930 attr_strings.create_time_attr = NULL;
1931 attr_strings.access_time_attr = "system.dos_attr.A_TIME";
1932 attr_strings.write_time_attr = "system.dos_attr.M_TIME";
1933 attr_strings.change_time_attr = "system.dos_attr.C_TIME";
1937 * Are they asking to set a DOS attribute?
1939 if (StrCaseCmp(name, "system.dos_attr.*") == 0 ||
1940 StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
1941 (attr_strings.create_time_attr != NULL &&
1942 StrCaseCmp(name, attr_strings.create_time_attr) == 0) ||
1943 StrCaseCmp(name, attr_strings.access_time_attr) == 0 ||
1944 StrCaseCmp(name, attr_strings.write_time_attr) == 0 ||
1945 StrCaseCmp(name, attr_strings.change_time_attr) == 0) {
1947 /* get a DOS Attribute Descriptor with current attributes */
1948 dad = dos_attr_query(context, talloc_tos(), path, srv);
1951 talloc_asprintf(talloc_tos(), "%s:%s",
1952 name+16, (const char *) value);
1957 /* Overwrite old with provided new params */
1958 dos_attr_parse(context, dad, srv, namevalue);
1960 /* Set the new DOS attributes */
1961 ret2 = SMBC_setatr(context, srv, path,
1968 /* ret2 has True (success) / False (failure) */
1983 /* Unsupported attribute name */
1990 SMBC_getxattr_ctx(SMBCCTX *context,
1997 SMBCSRV *srv = NULL;
1998 SMBCSRV *ipc_srv = NULL;
1999 char *server = NULL;
2002 char *password = NULL;
2003 char *workgroup = NULL;
2006 const char * create_time_attr;
2007 const char * access_time_attr;
2008 const char * write_time_attr;
2009 const char * change_time_attr;
2011 TALLOC_CTX *frame = talloc_stackframe();
2013 if (!context || !context->internal->initialized) {
2014 errno = EINVAL; /* Best I can think of ... */
2025 DEBUG(4, ("smbc_getxattr(%s, %s)\n", fname, name));
2027 if (SMBC_parse_path(frame,
2042 if (!user || user[0] == (char)0) {
2043 user = talloc_strdup(frame, smbc_getUser(context));
2051 srv = SMBC_server(frame, context, True,
2052 server, share, &workgroup, &user, &password);
2055 return -1; /* errno set by SMBC_server */
2058 if (! srv->no_nt_session) {
2059 ipc_srv = SMBC_attr_server(frame, context, server, share,
2060 &workgroup, &user, &password);
2062 srv->no_nt_session = True;
2068 /* Determine whether to use old-style or new-style attribute names */
2069 if (context->internal->full_time_names) {
2070 /* new-style names */
2071 attr_strings.create_time_attr = "system.dos_attr.CREATE_TIME";
2072 attr_strings.access_time_attr = "system.dos_attr.ACCESS_TIME";
2073 attr_strings.write_time_attr = "system.dos_attr.WRITE_TIME";
2074 attr_strings.change_time_attr = "system.dos_attr.CHANGE_TIME";
2076 /* old-style names */
2077 attr_strings.create_time_attr = NULL;
2078 attr_strings.access_time_attr = "system.dos_attr.A_TIME";
2079 attr_strings.write_time_attr = "system.dos_attr.M_TIME";
2080 attr_strings.change_time_attr = "system.dos_attr.C_TIME";
2083 /* Are they requesting a supported attribute? */
2084 if (StrCaseCmp(name, "system.*") == 0 ||
2085 StrnCaseCmp(name, "system.*!", 9) == 0 ||
2086 StrCaseCmp(name, "system.*+") == 0 ||
2087 StrnCaseCmp(name, "system.*+!", 10) == 0 ||
2088 StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
2089 StrnCaseCmp(name, "system.nt_sec_desc.*!", 21) == 0 ||
2090 StrCaseCmp(name, "system.nt_sec_desc.*+") == 0 ||
2091 StrnCaseCmp(name, "system.nt_sec_desc.*+!", 22) == 0 ||
2092 StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
2093 StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
2094 StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 ||
2095 StrCaseCmp(name, "system.nt_sec_desc.group") == 0 ||
2096 StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 ||
2097 StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
2098 StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0 ||
2099 StrCaseCmp(name, "system.dos_attr.*") == 0 ||
2100 StrnCaseCmp(name, "system.dos_attr.*!", 18) == 0 ||
2101 StrCaseCmp(name, "system.dos_attr.mode") == 0 ||
2102 StrCaseCmp(name, "system.dos_attr.size") == 0 ||
2103 (attr_strings.create_time_attr != NULL &&
2104 StrCaseCmp(name, attr_strings.create_time_attr) == 0) ||
2105 StrCaseCmp(name, attr_strings.access_time_attr) == 0 ||
2106 StrCaseCmp(name, attr_strings.write_time_attr) == 0 ||
2107 StrCaseCmp(name, attr_strings.change_time_attr) == 0 ||
2108 StrCaseCmp(name, "system.dos_attr.inode") == 0) {
2111 const char *filename = name;
2112 ret = cacl_get(context, talloc_tos(), srv,
2113 ipc_srv == NULL ? NULL : ipc_srv->cli,
2114 &ipc_srv->pol, path,
2116 discard_const_p(char, value),
2118 if (ret < 0 && errno == 0) {
2119 errno = SMBC_errno(context, srv->cli);
2125 /* Unsupported attribute name */
2133 SMBC_removexattr_ctx(SMBCCTX *context,
2138 SMBCSRV *srv = NULL;
2139 SMBCSRV *ipc_srv = NULL;
2140 char *server = NULL;
2143 char *password = NULL;
2144 char *workgroup = NULL;
2146 TALLOC_CTX *frame = talloc_stackframe();
2148 if (!context || !context->internal->initialized) {
2149 errno = EINVAL; /* Best I can think of ... */
2160 DEBUG(4, ("smbc_removexattr(%s, %s)\n", fname, name));
2162 if (SMBC_parse_path(frame,
2177 if (!user || user[0] == (char)0) {
2178 user = talloc_strdup(frame, smbc_getUser(context));
2186 srv = SMBC_server(frame, context, True,
2187 server, share, &workgroup, &user, &password);
2190 return -1; /* errno set by SMBC_server */
2193 if (! srv->no_nt_session) {
2194 ipc_srv = SMBC_attr_server(frame, context, server, share,
2195 &workgroup, &user, &password);
2197 srv->no_nt_session = True;
2205 return -1; /* errno set by SMBC_attr_server */
2208 /* Are they asking to set the entire ACL? */
2209 if (StrCaseCmp(name, "system.nt_sec_desc.*") == 0 ||
2210 StrCaseCmp(name, "system.nt_sec_desc.*+") == 0) {
2213 ret = cacl_set(context, talloc_tos(), srv->cli,
2214 ipc_srv->cli, &ipc_srv->pol, path,
2215 NULL, SMBC_XATTR_MODE_REMOVE_ALL, 0);
2221 * Are they asking to remove one or more spceific security descriptor
2224 if (StrCaseCmp(name, "system.nt_sec_desc.revision") == 0 ||
2225 StrCaseCmp(name, "system.nt_sec_desc.owner") == 0 ||
2226 StrCaseCmp(name, "system.nt_sec_desc.owner+") == 0 ||
2227 StrCaseCmp(name, "system.nt_sec_desc.group") == 0 ||
2228 StrCaseCmp(name, "system.nt_sec_desc.group+") == 0 ||
2229 StrnCaseCmp(name, "system.nt_sec_desc.acl", 22) == 0 ||
2230 StrnCaseCmp(name, "system.nt_sec_desc.acl+", 23) == 0) {
2233 ret = cacl_set(context, talloc_tos(), srv->cli,
2234 ipc_srv->cli, &ipc_srv->pol, path,
2235 discard_const_p(char, name) + 19,
2236 SMBC_XATTR_MODE_REMOVE, 0);
2241 /* Unsupported attribute name */
2248 SMBC_listxattr_ctx(SMBCCTX *context,
2254 * This isn't quite what listxattr() is supposed to do. This returns
2255 * the complete set of attribute names, always, rather than only those
2256 * attribute names which actually exist for a file. Hmmm...
2259 const char supported_old[] =
2262 "system.nt_sec_desc.revision\0"
2263 "system.nt_sec_desc.owner\0"
2264 "system.nt_sec_desc.owner+\0"
2265 "system.nt_sec_desc.group\0"
2266 "system.nt_sec_desc.group+\0"
2267 "system.nt_sec_desc.acl.*\0"
2268 "system.nt_sec_desc.acl\0"
2269 "system.nt_sec_desc.acl+\0"
2270 "system.nt_sec_desc.*\0"
2271 "system.nt_sec_desc.*+\0"
2272 "system.dos_attr.*\0"
2273 "system.dos_attr.mode\0"
2274 "system.dos_attr.c_time\0"
2275 "system.dos_attr.a_time\0"
2276 "system.dos_attr.m_time\0"
2278 const char supported_new[] =
2281 "system.nt_sec_desc.revision\0"
2282 "system.nt_sec_desc.owner\0"
2283 "system.nt_sec_desc.owner+\0"
2284 "system.nt_sec_desc.group\0"
2285 "system.nt_sec_desc.group+\0"
2286 "system.nt_sec_desc.acl.*\0"
2287 "system.nt_sec_desc.acl\0"
2288 "system.nt_sec_desc.acl+\0"
2289 "system.nt_sec_desc.*\0"
2290 "system.nt_sec_desc.*+\0"
2291 "system.dos_attr.*\0"
2292 "system.dos_attr.mode\0"
2293 "system.dos_attr.create_time\0"
2294 "system.dos_attr.access_time\0"
2295 "system.dos_attr.write_time\0"
2296 "system.dos_attr.change_time\0"
2298 const char * supported;
2300 if (context->internal->full_time_names) {
2301 supported = supported_new;
2302 retsize = sizeof(supported_new);
2304 supported = supported_old;
2305 retsize = sizeof(supported_old);
2312 if (retsize > size) {
2317 /* this can't be strcpy() because there are embedded null characters */
2318 memcpy(list, supported, retsize);