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:
parent
0411e86216
commit
0f4510230a
|
@ -1,3 +1,10 @@
|
||||||
|
2015-04-08 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2015-04-08 Corinna Vinschen <corinna@vinschen.de>
|
2015-04-08 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* sec_acl.cc: Change preceeding comment explaining new-style ACLs.
|
* sec_acl.cc: Change preceeding comment explaining new-style ACLs.
|
||||||
|
|
|
@ -989,10 +989,10 @@ fhandler_disk_file::fchown (uid_t uid, gid_t gid)
|
||||||
the standard UNIX accounts, we're faking success. */
|
the standard UNIX accounts, we're faking success. */
|
||||||
if (res == -1 && pc.fs_is_samba ())
|
if (res == -1 && pc.fs_is_samba ())
|
||||||
{
|
{
|
||||||
cygsid sid;
|
PSID sid;
|
||||||
|
|
||||||
if (old_uid == ILLEGAL_UID
|
if (old_uid == ILLEGAL_UID
|
||||||
|| (sid.getfrompw (internal_getpwuid (old_uid))
|
|| ((sid = sidfromuid (old_uid, NULL)) != NO_SID
|
||||||
&& RtlEqualPrefixSid (sid,
|
&& RtlEqualPrefixSid (sid,
|
||||||
well_known_samba_unix_user_fake_sid)))
|
well_known_samba_unix_user_fake_sid)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -254,3 +254,19 @@ inline BOOL cygsid::getfrompw (const struct passwd *pw)
|
||||||
|
|
||||||
inline BOOL cygsid::getfromgr (const struct group *gr)
|
inline BOOL cygsid::getfromgr (const struct group *gr)
|
||||||
{ return (*this = gr ? (PSID) ((pg_grp *) gr)->sid : NO_SID) != NO_SID; }
|
{ 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;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* quotactl.cc: code for manipulating disk quotas
|
/* quotactl.cc: code for manipulating disk quotas
|
||||||
|
|
||||||
Copyright 2014 Red Hat, Inc.
|
Copyright 2014, 2015 Red Hat, Inc.
|
||||||
|
|
||||||
This file is part of Cygwin.
|
This file is part of Cygwin.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ extern "C" int
|
||||||
quotactl (int cmd, const char *special, int id, caddr_t addr)
|
quotactl (int cmd, const char *special, int id, caddr_t addr)
|
||||||
{
|
{
|
||||||
ACCESS_MASK access = FILE_READ_DATA;
|
ACCESS_MASK access = FILE_READ_DATA;
|
||||||
cygsid sid;
|
PSID sid = NO_SID;
|
||||||
path_conv pc;
|
path_conv pc;
|
||||||
tmp_pathbuf tp;
|
tmp_pathbuf tp;
|
||||||
UNICODE_STRING path;
|
UNICODE_STRING path;
|
||||||
|
@ -75,18 +75,11 @@ quotactl (int cmd, const char *special, int id, caddr_t addr)
|
||||||
/* Windows feature: Default limits. Get or set them with id == -1. */
|
/* Windows feature: Default limits. Get or set them with id == -1. */
|
||||||
if (id != -1)
|
if (id != -1)
|
||||||
{
|
{
|
||||||
struct passwd *pw = NULL;
|
|
||||||
struct group *gr = NULL;
|
|
||||||
|
|
||||||
if (type == USRQUOTA)
|
if (type == USRQUOTA)
|
||||||
pw = internal_getpwuid (id);
|
sid = sidfromuid (id, NULL);
|
||||||
else
|
|
||||||
gr = internal_getgrgid (id);
|
|
||||||
if (pw)
|
|
||||||
sid.getfrompw (pw);
|
|
||||||
else if (gr)
|
|
||||||
sid.getfromgr (gr);
|
|
||||||
else
|
else
|
||||||
|
sid = sidfromgid (id, NULL);
|
||||||
|
if (sid == NO_SID)
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue