If I have nscd running, and I emerge ntp-4.2.0-r2 (or presumably anything that adds users/groups), the pkg_preinst stage fails. It adds the group successfully, but due to caching of the nss data by nscd, the adduser script fails. Subsequent runs of emerge ntp fail, then finally succeed. If nscd is not running, it succeeds first time. I know similar bugs have been lodged, but they have all been resolved and this one seems to still persist. This one also seems to be rather different. Reproducible: Always Steps to Reproduce: 1. have nscd running 2. emerge net-misc/ntp-4.2.0-r2 3. Actual Results: The build process completes, but when the emerge processes the pkg_preinst() stage the following happens: * Adding group 'ntp' to your system ... * - Groupid: 123 * Adding user 'ntp' to your system ... * - Userid: 123 * - Shell: /bin/false * - Home: /dev/null * You must add group ntp to the system first The group has been created correctly however: #grep ntp /etc/group ntp:x:123: #grep ntp /etc/passwd # A subsequent emerge directly afterwards dies at the same point, however: >>> Merging net-misc/ntp-4.2.0-r2 to / * Adding user 'ntp' to your system ... * - Userid: 123 * - Shell: /bin/false * - Home: /dev/null * - Groups: ntp useradd: name ntp is not unique !!! ERROR: net-misc/ntp-4.2.0-r2 failed. !!! Function enewuser, Line 760, Exitcode 9 !!! enewuser failed !!! FAILED preinst: 1 # grep ntp /etc/group ntp:x:123: # grep ntp /etc/passwd ntp:x:123:123:added by portage for ntp:/dev/null:/bin/false A third emerge directly afterwards succeeds. Expected Results: It should add the group and user correctly. I'm not sure of the best way to deal with this. Stopping and starting nscd from within the ebuild sounds bad. Some glibcs support sending a SIGHUP to nscd, but I believe that to be a redhat-specific patch. I couldn't find any mention of it in the glibc source, other than in an init script that sent it a HUP, but there didn't seem to be a handler for it. If there were no concurrency issues /sideeffects with sending a SIGHUP to flush the nscd cache, then that would be an good fix. emerge info Portage 2.0.50-r11 (default-x86-2004.0, gcc-3.3.4, glibc-2.3.3.20040420-r1, 2.6.8-gentoo-r3-1) ================================================================= System uname: 2.6.8-gentoo-r3-1 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz Gentoo Base System version 1.4.16 ccache version 2.3 [enabled] Autoconf: sys-devel/autoconf-2.59-r4 Automake: sys-devel/automake-1.8.5-r1 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-O2 -march=pentium4 -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" COMPILER="" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/bind /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O2 -march=pentium4 -fomit-frame-pointer" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs ccache sandbox" GENTOO_MIRRORS="http://gentoo.osuosl.org" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.au.gentoo.org/gentoo-portage" USE="apache2 apm arts avi berkdb bitmap-fonts crypt cups dnsdb drac encode exiscan-acl foomaticdb gdbm gif gpm imap imlib ipv6 jpeg ldap libg++ libwww lmtp mad maildir mikmod motif mpeg msn mysql ncurses nls oggvorbis opengl oscar oss pam pdflib perl png postgres python quicktime readline sasl sdl slang snmp spell ssl svga tcpd truetype vhosts wildsearch x86 xml2 xmms xprint yahoo zlib" ---- cat /etc/nscd.conf # # /etc/nscd.conf # # An example Name Service Cache config file. This file is needed by nscd. # # Legal entries are: # # logfile <file> # debug-level <level> # threads <#threads to use> # server-user <user to run server as instead of root> # server-user is ignored if nscd is started with -S parameters # # enable-cache <service> <yes|no> # positive-time-to-live <service> <time in seconds> # negative-time-to-live <service> <time in seconds> # suggested-size <service> <prime number> # check-files <service> <yes|no> # # Currently supported cache names (services): passwd, group, hosts # # logfile /var/log/nscd.log # threads 6 # server-user nobody debug-level 0 enable-cache passwd yes positive-time-to-live passwd 600 negative-time-to-live passwd 20 suggested-size passwd 211 check-files passwd yes enable-cache group yes positive-time-to-live group 3600 negative-time-to-live group 60 suggested-size group 211 check-files group yes enable-cache hosts no positive-time-to-live hosts 3600 negative-time-to-live hosts 20 suggested-size hosts 211 check-files hosts yes
not a ntp bug is there a way to tell nscd to refresh its cache ?
After a bit more investigation, it seems the solution is fairly easy after all: nscd -i <tablename> will cause nscd to invalidate that table (eg, passwd, group, hosts) So it seems that the correct way forward is for the enewgroup / enewuser functions to call nscd -i group/passwd as appropriate. This could also be implemented as part of the init script, either as a 'flush' command to flush all tables, or flush-<table> for each of passwd, group, hosts
fixed in cvs, thanks