Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Multi-Minute Startup?
- X-seq: zsh-users 13114
- From: "Aaron Davies" <aaron.davies@xxxxxxxxx>
- To: "Zsh Users" <zsh-users@xxxxxxxxxx>
- Subject: Re: Multi-Minute Startup?
- Date: Fri, 8 Aug 2008 09:32:57 +0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=dxFcQK78Qx813iC7uq3DL7ntmcDpY16/xMBv1rqXg3U=; b=dvy/Tish4DiYlN/JkSmnJu+Tpo6T65d+AkssSlJhMux36ZOtRT1yV6+b/J07EOYuQi af4f6YhyneOpDJx1CSDGFer9aEu08vJUhfEGBFeRyYJm2dvpJBk8gsA+zr78Ffg89aNo WdpIZQ92czUSN3UE0j4iMl3rGC6Tca4lYerJ8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=oAxG5muIjGHXvCqreStnCa6j2auvGplt0nkfSx9MPCYMSpWEXToQ2CmhO9kbZQeqRU 5NJVkOvHDCzlhpdrEV5Rc6NhM5nySD5PwtonuF43l4316ZH4+8fLSzzWHD+jya9FCNHJ lsUkh6oD+/mE5XVbRkoRit8Fb+dPEBdpe9GZc=
- In-reply-to: <alpine.LNX.1.10.0808070509320.26055@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <c4e763ac0808062357g44f7b75amf30db12fc1535409@xxxxxxxxxxxxxx> <alpine.LNX.1.10.0808070254580.26055@xxxxxxxxxxxxxxxxxxxxx> <c4e763ac0808070020r595f3b64u38eeefbc37bc85b6@xxxxxxxxxxxxxx> <alpine.LNX.1.10.0808070327310.26055@xxxxxxxxxxxxxxxxxxxxx> <c4e763ac0808070152k2846913dn4b637fe9ea275ef2@xxxxxxxxxxxxxx> <alpine.LNX.1.10.0808070509320.26055@xxxxxxxxxxxxxxxxxxxxx>
On Thu, Aug 7, 2008 at 5:28 PM, Benjamin R. Haskell <zsh@xxxxxxxxxx> wrote:
> On Thu, 7 Aug 2008, Aaron Davies wrote:
>
>> Looking at compaudit itself, it looks like it's still running "getent
>> group".
>
> Looking at compaudit more closely leads me to think something might be awry
> with your environment variables (either LOGNAME or EGID). On my system
> (Gentoo w/Zsh 4.3.4), the parts of compaudit germane to getent are:
>
>
> ===============================
> [[ -x /usr/bin/getent ]] || getent() {
> if [[ $2 = <-> ]]; then
> grep ":$2:[^:]*$" /etc/$1
> else
> grep "^$2:" /etc/$1
> fi
> }
>
> # ... trimmed
>
> # RedHat Linux "per-user groups" check. This is tricky, because it's very
> # difficult to tell whether the sysadmin has put someone else into your
> # "private" group (e.g., via the default group field in /etc/passwd, or
> # by NFS group sharing with an untrustworthy machine). So we must assume
> # that this has not happened, and pick the best group.
>
> local GROUP GROUPMEM _i_pw _i_gid _i_ulwdirs
> if ((UID == EUID )); then
> getent group $LOGNAME | IFS=: read GROUP _i_pw _i_gid GROUPMEM
> else
> getent group $EGID | IFS=: read GROUP _i_pw _i_gid GROUPMEM
> fi
> ===============================
>
> Is getent installed in /usr/bin on that machine? If not, maybe it's doing a
> grep over a large, generated file? (Three minutes seems excessive, though.)
getent is definitely present, and anyway, /etc/passwd and /etc/group
are tiny stub files on this box--no more than 50 lines each.
> If getent is there, maybe LOGNAME or EGID (whichever path is appropriate) is
> unset. So, instead of (w/ a username of 'aaron'):
LOGNAME appears to be set correctly (adavies).
> getent group aaron | IFS=: read GROUP _i_pw _i_gid GROUPMEM
> (finding a specific group's members, which should be fast, even over a long
> distance -- otherwise many common operations would be annoyingly slow)
>
> it becomes:
>
> getent group | IFS=: read GROUP _i_pw _i_gid GROUPMEM
> (which should be slow, since you're reading all 10,000 groups)
>
>
> Can you find the specific invocation of getent that's slow for you?
The code in my compaudit is
===============================
# RedHat Linux "per-user groups" check. This is tricky, because it's very
# difficult to tell whether the sysadmin has put someone else into your
# "private" group (e.g., via the default group field in /etc/passwd, or
# by NFS group sharing with an untrustworthy machine). So we must assume
# that this has not happened, and pick the best group.
local GROUP GROUPMEM _i_pw _i_gid _i_ulwdirs
while IFS=: read GROUP _i_pw _i_gid GROUPMEM; do
if (( UID == EUID )); then
[[ $GROUP == $LOGNAME ]] && break
else
(( _i_gid == EGID )) && break # Somewhat arbitrary
fi
done <<(getent group)
===============================
which looks to me like it *will* get all groups.
FWIW, "getent group" returns 773 lines and takes about 3.5 minutes to run.
--
Aaron Davies
aaron.davies@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author