* 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.
This commit is contained in:
Corinna Vinschen
2014-02-11 11:51:29 +00:00
parent 026a2445d1
commit 7fa5cbbfcd
7 changed files with 189 additions and 178 deletions

View File

@ -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;