diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-02-11 15:51:29 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-02-11 15:51:29 +0400 |
commit | 7fa5cbbfcdb4ff064ccc17d7fb514d3ff1ad8d2d (patch) | |
tree | c4e396629da24101629123b291c579a71e220415 /winsup/cygwin/cygheap.h | |
parent | 026a2445d17e937996ae582f6875fb66b6ac7186 (diff) |
* autoload.cc (NetLocalGroupGetInfo): Replace NetGroupGetInfo.
* cygheap.h (class cygheap_ugid_cache): Move ugid_cache_t type here
and rename.
(struct init_cygheap): Add cygheap_ugid_cache member "ugid_cache".
* pwdgrp.h (class ugid_cache_t): Remove here.
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Accommodate
move of ugid_cache to cygheap.
* sec_helper.cc (get_sids_info): Ditto.
* uinfo.cc (ugid_cache): Remove.
(pwdgrp::fetch_account_from_windows): Define id_val globally.
Move SidTypeAlias handling into SidTypeUser/SidTypeGroup branch since
aliases are handled like groups in SAM. Accommodate move of ugid_cache
to cygheap. Consolidate code reading SAM comments into a single branch
for both, SidTypeUser and SidTypeAlias. For SidTypeAlias, fix thinko
and call NetLocalGroupGetInfo rather than NetGroupGetInfo. Simplify
code setting Cygwin primary group for SAM accounts. Add code to handle
UNIX uid/gid from SAM comment.
Diffstat (limited to 'winsup/cygwin/cygheap.h')
-rw-r--r-- | winsup/cygwin/cygheap.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index a6cfd9d44..9596161f3 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -434,6 +434,43 @@ public: inline bool nss_db_caching () const { return caching; } }; +class cygheap_ugid_cache +{ + struct idmap { + uint32_t nfs_id; + uint32_t cyg_id; + }; + class idmaps { + uint32_t _cnt; + uint32_t _max; + idmap *_map; + public: + uint32_t get (uint32_t id) const + { + for (uint32_t i = 0; i < _cnt; ++i) + if (_map[i].nfs_id == id) + return _map[i].cyg_id; + return (uint32_t) -1; + } + void add (uint32_t nfs_id, uint32_t cyg_id) + { + if (_cnt >= _max) + _map = (idmap *) crealloc (_map, (_max += 10) * sizeof (*_map)); + _map[_cnt].nfs_id = nfs_id; + _map[_cnt].cyg_id = cyg_id; + ++_cnt; + } + }; + idmaps uids; + idmaps gids; + +public: + uid_t get_uid (uid_t uid) const { return uids.get (uid); } + gid_t get_gid (gid_t gid) const { return gids.get (gid); } + void add_uid (uid_t nfs_uid, uid_t cyg_uid) { uids.add (nfs_uid, cyg_uid); } + void add_gid (gid_t nfs_gid, gid_t cyg_gid) { gids.add (nfs_gid, cyg_gid); } +}; + struct hook_chain { void **loc; @@ -459,6 +496,7 @@ struct init_cygheap: public mini_cygheap cygheap_root root; cygheap_domain_info dom; cygheap_pwdgrp pg; + cygheap_ugid_cache ugid_cache; cygheap_user user; user_heap_info user_heap; mode_t umask; |