Ignore:
Timestamp:
Jun 16, 2009, 5:52:30 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 to 3.2.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/smbd/posix_acls.c

    r233 r272  
    44   Copyright (C) Jeremy Allison 1994-2000.
    55   Copyright (C) Andreas Gruenbacher 2002.
     6   Copyright (C) Simo Sorce <idra@samba.org> 2009.
    67
    78   This program is free software; you can redistribute it and/or modify
     
    11191120                return True;
    11201121
    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        }
    11251139
    11261140        /* u_name talloc'ed off tos. */
     
    11291143                return False;
    11301144        }
     1145
     1146        /* notice that this is not reliable for users exported by winbindd! */
    11311147        return user_in_group_sid(u_name, &group_ace->trustee);
    11321148}
     
    28152831}
    28162832
     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
     2844static 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
    28172869/****************************************************************************
    28182870 Reply to query a security descriptor from an fsp. If it succeeds it allocates
     
    28422894        SEC_ACE *nt_ace_list = NULL;
    28432895        size_t num_profile_acls = 0;
     2896        DOM_SID orig_owner_sid;
    28442897        SEC_DESC *psd = NULL;
     2898        int i;
    28452899
    28462900        /*
     
    28482902         */
    28492903
     2904        create_file_sids(sbuf, &owner_sid, &group_sid);
     2905
    28502906        if (lp_profile_acls(SNUM(conn))) {
    28512907                /* For WXP SP1 the owner must be administrators. */
     2908                sid_copy(&orig_owner_sid, &owner_sid);
    28522909                sid_copy(&owner_sid, &global_sid_Builtin_Administrators);
    28532910                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;
    28572912        }
    28582913
     
    29783033                         * if we can't map the SID. */
    29793034                        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);
    29873039                        }
    29883040
     
    30083060                         * if we can't map the SID. */
    30093061                        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);
    30163069                        }
    30173070
     
    30243077                        num_aces = merge_default_aces(nt_ace_list, num_aces);
    30253078
     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                        }
    30263091                }
    30273092
Note: See TracChangeset for help on using the changeset viewer.