Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-04-08 12:00:08 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-04-08 12:00:08 +0300
commit0f4510230a14ffe3c941e7f17f12a9bb89383383 (patch)
tree2542d71d35eac59ec86b8550baf09ea2321fc8fc /winsup
parent0411e862166cbd3ce6febcf0b9517d1b826befe6 (diff)
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>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc4
-rw-r--r--winsup/cygwin/pwdgrp.h16
-rw-r--r--winsup/cygwin/quotactl.cc17
4 files changed, 30 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 6210391f6..2c170b4fc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,12 @@
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>
+
* sec_acl.cc: Change preceeding comment explaining new-style ACLs.
Describe how to generate deny ACEs in more detail. Accommodate the
fact that a NULL deny ACE is used for {DEF_}CLASS_OBJ, rather than
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 6a425674a..f5edb03de 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -989,10 +989,10 @@ fhandler_disk_file::fchown (uid_t uid, gid_t gid)
the standard UNIX accounts, we're faking success. */
if (res == -1 && pc.fs_is_samba ())
{
- cygsid sid;
+ PSID sid;
if (old_uid == ILLEGAL_UID
- || (sid.getfrompw (internal_getpwuid (old_uid))
+ || ((sid = sidfromuid (old_uid, NULL)) != NO_SID
&& RtlEqualPrefixSid (sid,
well_known_samba_unix_user_fake_sid)))
{
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
index dc718c596..a64cb0f5f 100644
--- a/winsup/cygwin/pwdgrp.h
+++ b/winsup/cygwin/pwdgrp.h
@@ -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;
+ }
diff --git a/winsup/cygwin/quotactl.cc b/winsup/cygwin/quotactl.cc
index 96c6134e8..f4c325bd5 100644
--- a/winsup/cygwin/quotactl.cc
+++ b/winsup/cygwin/quotactl.cc
@@ -1,6 +1,6 @@
/* quotactl.cc: code for manipulating disk quotas
- Copyright 2014 Red Hat, Inc.
+ Copyright 2014, 2015 Red Hat, Inc.
This file is part of Cygwin.
@@ -28,7 +28,7 @@ extern "C" int
quotactl (int cmd, const char *special, int id, caddr_t addr)
{
ACCESS_MASK access = FILE_READ_DATA;
- cygsid sid;
+ PSID sid = NO_SID;
path_conv pc;
tmp_pathbuf tp;
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. */
if (id != -1)
{
- struct passwd *pw = NULL;
- struct group *gr = NULL;
-
if (type == USRQUOTA)
- pw = internal_getpwuid (id);
- else
- gr = internal_getgrgid (id);
- if (pw)
- sid.getfrompw (pw);
- else if (gr)
- sid.getfromgr (gr);
+ sid = sidfromuid (id, NULL);
else
+ sid = sidfromgid (id, NULL);
+ if (sid == NO_SID)
{
set_errno (EINVAL);
return -1;