diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-02-05 13:47:47 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-02-05 13:47:47 +0000 |
commit | 0c8455c344a3200a9969ae304c66b2c2cc809b04 (patch) | |
tree | 73d135e39ea79f90a0500c83d546f6cc81685446 /winsup/cygwin/sec_helper.cc | |
parent | b7b6c58a20a7de41e1d88a100391363fd68802de (diff) | |
download | cygnal-0c8455c344a3200a9969ae304c66b2c2cc809b04.tar.gz cygnal-0c8455c344a3200a9969ae304c66b2c2cc809b04.tar.bz2 cygnal-0c8455c344a3200a9969ae304c66b2c2cc809b04.zip |
* sec_helper.cc (get_sids_info): New function.
* security.cc (extract_nt_dom_user): Simplify with strechr.
(get_user_groups): Initialize glen to MAX_SID_LEN.
(get_user_local_groups): Ditto.
(get_attribute_from_acl): Define ace_sid as cygpsid.
(get_nt_attribute): Define owner_sid and group_sid as cygpsid.
Call get_sids_info instead of cygsid.get_{u,g}id and is_grp_member.
(get_nt_object_attribute): Ditto.
(alloc_sd): Define ace_sid as cygpsid.
Diffstat (limited to 'winsup/cygwin/sec_helper.cc')
-rw-r--r-- | winsup/cygwin/sec_helper.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index 59eba0887..e4f7419a7 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -186,6 +186,43 @@ cygsid::getfromgr (const struct __group32 *gr) return (*this = sp) != NULL; } +bool +get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32_t * gidret) +{ + struct passwd *pw; + struct __group32 *gr = NULL; + bool ret = false; + + if (group_sid == cygheap->user.groups.pgsid) + *gidret = myself->gid; + else if ((gr = internal_getgrsid (group_sid))) + *gidret = gr->gr_gid; + else + *gidret = ILLEGAL_GID; + + if (owner_sid == cygheap->user.sid ()) + { + *uidret = myself->uid; + if (*gidret == myself->gid) + ret = true; + else + ret = (internal_getgroups (0, NULL, &group_sid) > 0); + } + else if ((pw = internal_getpwsid (owner_sid))) + { + *uidret = pw->pw_uid; + if (gr || (*gidret != ILLEGAL_GID + && (gr = internal_getgrgid (*gidret)))) + for (int idx = 0; gr->gr_mem[idx]; ++idx) + if ((ret = strcasematch (pw->pw_name, gr->gr_mem[idx]))) + break; + } + else + *uidret = ILLEGAL_UID; + + return ret; +} + BOOL is_grp_member (__uid32_t uid, __gid32_t gid) { |