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>
This commit is contained in:
parent
1d91d469ee
commit
4a9636b1d6
|
@ -1,3 +1,19 @@
|
||||||
|
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>
|
2015-03-18 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* sec_auth.cc (get_server_groups): Drop unused passwd argument. Adjust
|
* sec_auth.cc (get_server_groups): Drop unused passwd argument. Adjust
|
||||||
|
|
|
@ -47,7 +47,7 @@ pwdgrp::parse_group ()
|
||||||
return false;
|
return false;
|
||||||
/* Don't generate gr_mem entries. */
|
/* Don't generate gr_mem entries. */
|
||||||
grp.g.gr_mem = &null_ptr;
|
grp.g.gr_mem = &null_ptr;
|
||||||
grp.sid.getfromgr (&grp.g);
|
grp.sid.getfromgr_passwd (&grp.g);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ pwdgrp::parse_passwd ()
|
||||||
res.p.pw_gecos = next_str (':');
|
res.p.pw_gecos = next_str (':');
|
||||||
res.p.pw_dir = next_str (':');
|
res.p.pw_dir = next_str (':');
|
||||||
res.p.pw_shell = 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
|
/* lptr points to the \0 after pw_shell. Increment by one to get the correct
|
||||||
required buffer len in getpw_cp. */
|
required buffer len in getpw_cp. */
|
||||||
res.len = lptr - res.p.pw_name + 1;
|
res.len = lptr - res.p.pw_name + 1;
|
||||||
|
|
|
@ -246,3 +246,11 @@ public:
|
||||||
struct group *getgrent ();
|
struct group *getgrent ();
|
||||||
inline void endgrent () { endent (true); }
|
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; }
|
||||||
|
|
|
@ -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);
|
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))
|
&& LookupAccountSidW (NULL, psid, user, &ulen, domain, &dlen, &use))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* sec_helper.cc: NT security helper functions
|
/* sec_helper.cc: NT security helper functions
|
||||||
|
|
||||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
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>
|
Written by Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
@ -279,20 +279,6 @@ cygsid::getfromstr (const char *nsidstr, bool well_known)
|
||||||
return psid = NO_SID;
|
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 *
|
cygsid *
|
||||||
cygsidlist::alloc_sids (int n)
|
cygsidlist::alloc_sids (int n)
|
||||||
{
|
{
|
||||||
|
|
|
@ -237,6 +237,18 @@ public:
|
||||||
|
|
||||||
inline PSID set () { return psid = (PSID) sbuf; }
|
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 getfrompw (const struct passwd *pw);
|
||||||
BOOL getfromgr (const struct group *gr);
|
BOOL getfromgr (const struct group *gr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue