Changeset 272 for branches/samba-3.2.x/source/smbd/posix_acls.c
- Timestamp:
- Jun 16, 2009, 5:52:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/smbd/posix_acls.c
r233 r272 4 4 Copyright (C) Jeremy Allison 1994-2000. 5 5 Copyright (C) Andreas Gruenbacher 2002. 6 Copyright (C) Simo Sorce <idra@samba.org> 2009. 6 7 7 8 This program is free software; you can redistribute it and/or modify … … 1119 1120 return True; 1120 1121 1121 /* Assume that the current user is in the current group (force group) */ 1122 1123 if (uid_ace->unix_ug.uid == current_user.ut.uid && group_ace->unix_ug.gid == current_user.ut.gid) 1124 return True; 1122 /* 1123 * if it's the current user, we already have the unix token 1124 * and don't need to do the complex user_in_group_sid() call 1125 */ 1126 if (uid_ace->unix_ug.uid == current_user.ut.uid) { 1127 size_t i; 1128 1129 if (group_ace->unix_ug.gid == current_user.ut.gid) { 1130 return True; 1131 } 1132 1133 for (i=0; i < current_user.ut.ngroups; i++) { 1134 if (group_ace->unix_ug.gid == current_user.ut.groups[i]) { 1135 return True; 1136 } 1137 } 1138 } 1125 1139 1126 1140 /* u_name talloc'ed off tos. */ … … 1129 1143 return False; 1130 1144 } 1145 1146 /* notice that this is not reliable for users exported by winbindd! */ 1131 1147 return user_in_group_sid(u_name, &group_ace->trustee); 1132 1148 } … … 2815 2831 } 2816 2832 2833 /* 2834 * Add or Replace ACE entry. 2835 * In some cases we need to add a specific ACE for compatibility reasons. 2836 * When doing that we must make sure we are not actually creating a duplicate 2837 * entry. So we need to search whether an ACE entry already exist and eventually 2838 * replacce the access mask, or add a completely new entry if none was found. 2839 * 2840 * This function assumes the array has enough space to add a new entry without 2841 * any reallocation of memory. 2842 */ 2843 2844 static void add_or_replace_ace(SEC_ACE *nt_ace_list, size_t *num_aces, 2845 const DOM_SID *sid, enum security_ace_type type, 2846 uint32_t mask, uint8_t flags) 2847 { 2848 int i; 2849 2850 /* first search for a duplicate */ 2851 for (i = 0; i < *num_aces; i++) { 2852 if (sid_equal(&nt_ace_list[i].trustee, sid) && 2853 (nt_ace_list[i].flags == flags)) break; 2854 } 2855 2856 if (i < *num_aces) { /* found */ 2857 nt_ace_list[i].type = type; 2858 nt_ace_list[i].access_mask = mask; 2859 DEBUG(10, ("Replacing ACE %d with SID %s and flags %02x\n", 2860 i, sid_string_dbg(sid), flags)); 2861 return; 2862 } 2863 2864 /* not found, append it */ 2865 init_sec_ace(&nt_ace_list[(*num_aces)++], sid, type, mask, flags); 2866 } 2867 2868 2817 2869 /**************************************************************************** 2818 2870 Reply to query a security descriptor from an fsp. If it succeeds it allocates … … 2842 2894 SEC_ACE *nt_ace_list = NULL; 2843 2895 size_t num_profile_acls = 0; 2896 DOM_SID orig_owner_sid; 2844 2897 SEC_DESC *psd = NULL; 2898 int i; 2845 2899 2846 2900 /* … … 2848 2902 */ 2849 2903 2904 create_file_sids(sbuf, &owner_sid, &group_sid); 2905 2850 2906 if (lp_profile_acls(SNUM(conn))) { 2851 2907 /* For WXP SP1 the owner must be administrators. */ 2908 sid_copy(&orig_owner_sid, &owner_sid); 2852 2909 sid_copy(&owner_sid, &global_sid_Builtin_Administrators); 2853 2910 sid_copy(&group_sid, &global_sid_Builtin_Users); 2854 num_profile_acls = 2; 2855 } else { 2856 create_file_sids(sbuf, &owner_sid, &group_sid); 2911 num_profile_acls = 3; 2857 2912 } 2858 2913 … … 2978 3033 * if we can't map the SID. */ 2979 3034 if (lp_profile_acls(SNUM(conn))) { 2980 SEC_ACCESS acc; 2981 2982 init_sec_access(&acc,FILE_GENERIC_ALL); 2983 init_sec_ace(&nt_ace_list[num_aces++], 2984 &global_sid_Builtin_Users, 2985 SEC_ACE_TYPE_ACCESS_ALLOWED, 2986 acc, 0); 3035 add_or_replace_ace(nt_ace_list, &num_aces, 3036 &global_sid_Builtin_Users, 3037 SEC_ACE_TYPE_ACCESS_ALLOWED, 3038 FILE_GENERIC_ALL, 0); 2987 3039 } 2988 3040 … … 3008 3060 * if we can't map the SID. */ 3009 3061 if (lp_profile_acls(SNUM(conn))) { 3010 SEC_ACCESS acc; 3011 3012 init_sec_access(&acc,FILE_GENERIC_ALL); 3013 init_sec_ace(&nt_ace_list[num_aces++], &global_sid_Builtin_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, acc, 3014 SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT| 3015 SEC_ACE_FLAG_INHERIT_ONLY|0); 3062 add_or_replace_ace(nt_ace_list, &num_aces, 3063 &global_sid_Builtin_Users, 3064 SEC_ACE_TYPE_ACCESS_ALLOWED, 3065 FILE_GENERIC_ALL, 3066 SEC_ACE_FLAG_OBJECT_INHERIT | 3067 SEC_ACE_FLAG_CONTAINER_INHERIT | 3068 SEC_ACE_FLAG_INHERIT_ONLY); 3016 3069 } 3017 3070 … … 3024 3077 num_aces = merge_default_aces(nt_ace_list, num_aces); 3025 3078 3079 if (lp_profile_acls(SNUM(conn))) { 3080 for (i = 0; i < num_aces; i++) { 3081 if (sid_equal(&nt_ace_list[i].trustee, &owner_sid)) { 3082 add_or_replace_ace(nt_ace_list, &num_aces, 3083 &orig_owner_sid, 3084 nt_ace_list[i].type, 3085 nt_ace_list[i].access_mask, 3086 nt_ace_list[i].flags); 3087 break; 3088 } 3089 } 3090 } 3026 3091 } 3027 3092
Note:
See TracChangeset
for help on using the changeset viewer.