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-03-18 19:15:27 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-03-18 19:15:27 +0300
commit4a9636b1d6d3380eaff53621498445f6adcfc18e (patch)
tree1fa05c56734c5f4e600e7e71362dcd0bac39b522 /winsup
parent1d91d469ee534fab47fdb710a037378c103fee23 (diff)
Implmenet faster getfrompw/getfromgr
* grp.cc (pwdgrp::parse_group): Call cygsid::getfromgr_passwd. * passwd.cc (pwdgrp::parse_passwd): Call cygsid::getfrompw_gecos. * pwdgrp.h (cygsid::getfrompw): Implement as inline method here, accessing pg_pwd's sid member directly. (cygsid::getfromgr): Implement as inline method here, accessing pg_grp's sid member directly. * sec_auth.cc (extract_nt_dom_user): Call cygsid::getfrompw_gecos. Explain why. * sec_helper.cc (cygsid::getfrompw): Drop implementation. (cygsid::getfromgr): Ditto. * security.h (cygsid::getfrompw_gecos): Implement former getfrompw inline here. (cygsid::getfromgr_passwd): Implement former getfromgr inline here. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog16
-rw-r--r--winsup/cygwin/grp.cc2
-rw-r--r--winsup/cygwin/passwd.cc2
-rw-r--r--winsup/cygwin/pwdgrp.h8
-rw-r--r--winsup/cygwin/sec_auth.cc5
-rw-r--r--winsup/cygwin/sec_helper.cc16
-rw-r--r--winsup/cygwin/security.h12
7 files changed, 43 insertions, 18 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index d6e94f0c5..bd9e71ffa 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,21 @@
2015-03-18 Corinna Vinschen <corinna@vinschen.de>
+ * grp.cc (pwdgrp::parse_group): Call cygsid::getfromgr_passwd.
+ * passwd.cc (pwdgrp::parse_passwd): Call cygsid::getfrompw_gecos.
+ * pwdgrp.h (cygsid::getfrompw): Implement as inline method here,
+ accessing pg_pwd's sid member directly.
+ (cygsid::getfromgr): Implement as inline method here, accessing
+ pg_grp's sid member directly.
+ * sec_auth.cc (extract_nt_dom_user): Call cygsid::getfrompw_gecos.
+ Explain why.
+ * sec_helper.cc (cygsid::getfrompw): Drop implementation.
+ (cygsid::getfromgr): Ditto.
+ * security.h (cygsid::getfrompw_gecos): Implement former getfrompw
+ inline here.
+ (cygsid::getfromgr_passwd): Implement former getfromgr inline here.
+
+2015-03-18 Corinna Vinschen <corinna@vinschen.de>
+
* sec_auth.cc (get_server_groups): Drop unused passwd argument. Adjust
calls throughout.
(get_initgroups_sidlist): Ditto.
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 53551161a..ea20e926c 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -47,7 +47,7 @@ pwdgrp::parse_group ()
return false;
/* Don't generate gr_mem entries. */
grp.g.gr_mem = &null_ptr;
- grp.sid.getfromgr (&grp.g);
+ grp.sid.getfromgr_passwd (&grp.g);
return true;
}
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 825b2e0a8..7493aa443 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -40,7 +40,7 @@ pwdgrp::parse_passwd ()
res.p.pw_gecos = next_str (':');
res.p.pw_dir = next_str (':');
res.p.pw_shell = next_str (':');
- res.sid.getfrompw (&res.p);
+ res.sid.getfrompw_gecos (&res.p);
/* lptr points to the \0 after pw_shell. Increment by one to get the correct
required buffer len in getpw_cp. */
res.len = lptr - res.p.pw_name + 1;
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
index 8a78d305f..dc718c596 100644
--- a/winsup/cygwin/pwdgrp.h
+++ b/winsup/cygwin/pwdgrp.h
@@ -246,3 +246,11 @@ public:
struct group *getgrent ();
inline void endgrent () { endent (true); }
};
+
+/* These inline methods have to be defined here so that pg_pwd and pg_grp
+ are defined. */
+inline BOOL cygsid::getfrompw (const struct passwd *pw)
+ { return (*this = pw ? (PSID) ((pg_pwd *) pw)->sid : NO_SID) != NO_SID; }
+
+inline BOOL cygsid::getfromgr (const struct group *gr)
+ { return (*this = gr ? (PSID) ((pg_grp *) gr)->sid : NO_SID) != NO_SID; }
diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc
index aeb571de6..d5fa76def 100644
--- a/winsup/cygwin/sec_auth.cc
+++ b/winsup/cygwin/sec_auth.cc
@@ -119,7 +119,10 @@ extract_nt_dom_user (const struct passwd *pw, PWCHAR domain, PWCHAR user)
debug_printf ("pw_gecos %p (%s)", pw->pw_gecos, pw->pw_gecos);
- if (psid.getfrompw (pw)
+ /* The incoming passwd entry is not necessarily a pointer to the
+ internal passwd buffers, thus we must not rely on being able to
+ cast it to pg_pwd. */
+ if (psid.getfrompw_gecos (pw)
&& LookupAccountSidW (NULL, psid, user, &ulen, domain, &dlen, &use))
return;
diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc
index 946e78a8e..679f3a858 100644
--- a/winsup/cygwin/sec_helper.cc
+++ b/winsup/cygwin/sec_helper.cc
@@ -1,7 +1,7 @@
/* sec_helper.cc: NT security helper functions
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
- 2011, 2012, 2013, 2014 Red Hat, Inc.
+ 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
Written by Corinna Vinschen <corinna@vinschen.de>
@@ -279,20 +279,6 @@ cygsid::getfromstr (const char *nsidstr, bool well_known)
return psid = NO_SID;
}
-BOOL
-cygsid::getfrompw (const struct passwd *pw)
-{
- char *sp = (pw && pw->pw_gecos) ? strrchr (pw->pw_gecos, ',') : NULL;
- return (*this = sp ? sp + 1 : sp) != NULL;
-}
-
-BOOL
-cygsid::getfromgr (const struct group *gr)
-{
- char *sp = (gr && gr->gr_passwd) ? gr->gr_passwd : NULL;
- return (*this = sp) != NULL;
-}
-
cygsid *
cygsidlist::alloc_sids (int n)
{
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index 6af87e0d4..867345774 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -237,6 +237,18 @@ public:
inline PSID set () { return psid = (PSID) sbuf; }
+ inline BOOL getfrompw_gecos (const struct passwd *pw)
+ {
+ char *sp = (pw && pw->pw_gecos) ? strrchr (pw->pw_gecos, ',') : NULL;
+ return (*this = sp ? sp + 1 : sp) != NO_SID;
+ }
+ inline BOOL getfromgr_passwd (const struct group *gr)
+ {
+ char *sp = (gr && gr->gr_passwd) ? gr->gr_passwd : NULL;
+ return (*this = sp) != NO_SID;
+ }
+
+ /* Implemented in pwdgrp.h. */
BOOL getfrompw (const struct passwd *pw);
BOOL getfromgr (const struct group *gr);