zsh-workers
 help / color / mirror / code / Atom feed
From: Danek Duvall <duvall@emufarm.org>
To: zsh-workers@sunsite.dk
Subject: compaudit slow with many groups
Date: Fri, 19 Mar 2004 13:57:24 -0800	[thread overview]
Message-ID: <20040319215724.GB23658@lorien.emufarm.org> (raw)

At work, we have 1168 groups defined in NIS, and the entire database
dumped via "getent group" is over 100kB.  This makes compaudit very slow
on startup if the groups are not all cached locally, and makes it a drag
logging in to a machine with zsh as my shell.

The code to blame is on line 85:

    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 seems somewhat inefficient.  Would something along the lines of

    local GROUP GROUPMEM _i_pw _i_gid _i_ulwdirs
    if (( UID == EUID )); then
    	getent group $UID | IFS=: read GROUP _i_pw _i_gid GROUPMEM
	[[ $GROUP == $LOGNAME ]] || unset GROUP GROUPMEM
    else
    	getent group $EGID | IFS=: read GROUP _i_pw _i_gid GROUPMEM
	(( _i_gid == EGID )) || unset GROUP GROUPMEM
    fi

work?  I'm not positive this is the right set of tests, but if not,
there ought to be some similar way of reducing the overhead of the
function.  Is there any system where getent can't take two arguments?

Or perhaps it ought to be conditional on some style being set or unset.

Thanks,
Danek


             reply	other threads:[~2004-03-19 21:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-19 21:57 Danek Duvall [this message]
2004-03-21 18:46 ` Danek Duvall
2004-03-22 20:12   ` Peter Stephenson
2004-03-30 14:28 ` Oliver Kiddle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040319215724.GB23658@lorien.emufarm.org \
    --to=duvall@emufarm.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).