Introduce sidfromuid and sidfromgid

* pwdgrp.h (sidfromuid): New inline function.
	(sidfromgid): Ditto.
	* fhandler_disk_file.cc (fhandler_disk_file::fchown): Use sidfromuid.
	* quotactl.cc (quotactl): Use sidfromuid and sidfromgid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2015-04-08 11:00:08 +02:00
parent 0411e86216
commit 0f4510230a
4 changed files with 30 additions and 14 deletions

View File

@@ -254,3 +254,19 @@ inline BOOL cygsid::getfrompw (const struct passwd *pw)
inline BOOL cygsid::getfromgr (const struct group *gr)
{ return (*this = gr ? (PSID) ((pg_grp *) gr)->sid : NO_SID) != NO_SID; }
/* Use these functions if you just need the PSID. */
inline PSID sidfromuid (uid_t uid, cyg_ldap *pldap)
{
struct passwd *pw = internal_getpwuid (uid, pldap);
if (pw)
return (PSID) ((pg_pwd *) pw)->sid;
return NO_SID;
}
inline PSID sidfromgid (gid_t gid, cyg_ldap *pldap)
{
struct group *gr = internal_getgrgid (gid, pldap);
if (gr)
return (PSID) ((pg_grp *) gr)->sid;
return NO_SID;
}