This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 186803 - nscd cache make groupadd error in scripts
nscd cache make groupadd error in scripts
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: shadow-utils (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Peter Vrabec
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-03-26 12:06 EST by Kazutoshi Morioka
Modified: 2007-11-30 17:11 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-04-05 07:45:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Kazutoshi Morioka 2006-03-26 12:06:18 EST
Description of problem:
While nscd is running, chgrp after groupadd fails with group does not exist.
For example, preinstall script of screen does groupadd to make "screen" group,
and then, /usr/bin/screen and /var/run/screen/ is created with the "screen".
but this is sometimes fail, and screen do not work.

Version-Release number of selected component (if applicable):
# rpm -q glibc
glibc-2.4-4
# rpm -q screen
screen-4.0.2-12

How reproducible:
sometimes

Steps to Reproduce:
1. service nscd start
2. groupadd foogroup ; groupdel foogroup ; sleep 1
3. repeat 2 some times. 
  
Actual results:
[root@myhost ~]# groupadd foogroup ; groupdel foogroup ; sleep 1
[root@myhost ~]# groupadd foogroup ; groupdel foogroup ; sleep 1
[root@myhost ~]# groupadd foogroup ; groupdel foogroup ; sleep 1
[root@myhost ~]# groupadd foogroup ; groupdel foogroup ; sleep 1
[root@myhost ~]# groupadd foogroup ; groupdel foogroup ; sleep 1
groupdel: group foogroup does not exist

Expected results:
No error reported.

Additional info:
This is another example of this problem:

[root@myhost ~]# yum -y install screen
Loading "installonlyn" plugin
Setting up Remove Process

         snip

Running Transaction
  Installing: screen                                                
[1/1]warning: group screen does not exist - using root
  Installing: screen                       ######################## 
[1/1]warning: group screen does not exist - using root
  Installing: screen                       ######################### [1/1]

Installed: screen.i386 0:4.0.2-12
Complete!
[root@myhost ~]# ls -ld /usr/bin/screen /var/run/screen
-rwxr-xr-x 1 root root 346612  2月 27 18:10 /usr/bin/screen
drwxrwxr-x 2 root root   4096  2月 27 18:10 /var/run/screen
Comment 1 Jakub Jelinek 2006-04-03 09:45:49 EDT
That's a bug in shadow-utils, it doesn't properly notify nscd that it needs
to flush its cache.
shadow-4.0.14/lib/nscd.c has:
int nscd_flush_cache (char *service)
{
        int sock = nscd_open_socket ();
        request_header req;
        struct iovec iov[2];
        ssize_t nbytes;

        if (sock == -1)
                return -1;

        req.version = NSCD_VERSION;
        req.type = INVALIDATE;
        req.key_len = strlen (service);

        iov[0].iov_base = &req;
        iov[0].iov_len = sizeof (req);
        iov[1].iov_base = service;
        iov[1].iov_len = req.key_len;

        nbytes = writev (sock, iov, 2);

        close (sock);
        return (nbytes != iov[0].iov_len + iov[1].iov_len ? (-1) : 0);
}

which is wrong, the INVALIDATE request's key is supposed to contain the trailing
'\0' character and req.key_len is supposed to include that as well.
Compare that to what nscd does for nscd -i:
          if (strcmp (arg, "passwd") == 0)
            req.key_len = sizeof "passwd";
          else if (strcmp (arg, "group") == 0)
            req.key_len = sizeof "group";
          else if (strcmp (arg, "hosts") == 0)
            req.key_len = sizeof "hosts";
          else
            return ARGP_ERR_UNKNOWN;

          req.version = NSCD_VERSION;
          req.type = INVALIDATE;

So, shadow-utils needs to change the
req.key_len = strlen (service);
line in lib/nscd.c to:
req.key_len = strlen (service) + 1;
Comment 2 Peter Vrabec 2006-04-05 07:45:51 EDT
fixed in FC5(shadow-utils-4.0.14-6.FC5) and devel 

Note You need to log in before you can comment on or make changes to this bug.