Bug 130749 - [libc] [patch] nscd(8): nscache.c/nscachedcli.c - return error if string of /etc/group is long
Summary: [libc] [patch] nscd(8): nscache.c/nscachedcli.c - return error if string of /...
Status: Closed DUPLICATE of bug 248932
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 7.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-19 16:00 UTC by Andrey Zonov
Modified: 2021-06-19 00:17 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Zonov 2009-01-19 16:00:09 UTC
nscd return error if string of /etc/group is long and return groups directly from /etc/group, really my problem with NIS long group, but with long group from /etc/group bug as affected.

I thing bug in src/lib/libc/net/nscachedcli.c. safe_read() return rec_error_code=848338984, then try read long group.

Fix: Only workaround.

1. For nscd


2. And for NIS work this patch - http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/96840--uhBI03oGOCHJJniZOWkgwITEoVVion1aydxMz14hWhuNeiNf
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- src/lib/libc/net/nscache.c.orig     2009-01-11 22:30:47.000000000 +0300
+++ src/lib/libc/net/nscache.c  2009-01-12 13:23:45.000000000 +0300
@@ -39,7 +39,7 @@
 #define NSS_CACHE_KEY_INITIAL_SIZE     (256)
 #define NSS_CACHE_KEY_SIZE_LIMIT       (NSS_CACHE_KEY_INITIAL_SIZE << 4)
 
-#define NSS_CACHE_BUFFER_INITIAL_SIZE  (1024)
+#define NSS_CACHE_BUFFER_INITIAL_SIZE  (4096)
 #define NSS_CACHE_BUFFER_SIZE_LIMIT    (NSS_CACHE_BUFFER_INITIAL_SIZE << 8)
 
 #define CACHED_SOCKET_PATH             "/var/run/nscd"
How-To-Repeat: 1. Add in /etc/group:
strangegroup:*:9999:aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar,as,at,au,av,aw,ax,ay,az,ba,bb,bc,bd,be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt,bu,bv,bw,bx,by,bz,ca,cb,cc,cd,ce,cf,cg,ch,ci,cj,ck,cl,cm,cn,co,cp,cq,cr,cs,ct,cu,cv,cw,cx,cy,cz,da,db,dc,dd,de,df,dg,dh,di,dj,dk,dl,dm,dn,do

2. Edit /etc/nsswitch.conf:
group: cache compat

3. $ getent group | wc -l
     378

4. Run "nscd -t -n -s"

5. And run "getent group"
$ getent group | wc -l
     378
$ getent group | wc -l
     442
$ getent group | wc -l
     442

For local groups this is not critical, but for NIS (and other network management) is critical.

nscd show debug:
M1 from main: request agents registered successfully
M2 from cache: cache was successfully initialized
M2 from runtime environment: using socket /var/run/nscd
M2 from runtime environment: successfully initialized
M1 from main: working in single-threaded mode
E3 from on_mp_read_session_read_response_write1: write failed
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2011-10-13 22:27:01 UTC
Responsible Changed
From-To: freebsd-bugs->des

nscd is mine for now
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:01 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 3 Volodymyr Pushkar 2018-02-13 18:54:51 UTC
The similar error is with 11.1-RELEASE and groups from LDAP via nslcd.

# cat /etc/nsswitch.conf | grep ^group
group: cache files ldap

Without nscd:
# getent group | wc -l
    1857

With nscd (1st run):
# getent group | wc -l
    1857

With nscd (2nd run):
# getent group | wc -l
    1891

nscd output:
# nscd -t -n -s
M1 from main: request agents registered successfully
M2 from cache: cache was successfully initialized
M2 from runtime environment: using socket /var/run/nscd
M2 from runtime environment: successfully initialized
M1 from main: working in single-threaded mode
E3 from on_mp_read_session_read_response_write1: write failed
E3 from on_mp_read_session_read_response_write1: write failed

Local groups appears twice in output after nscd errors:
# diff -u /tmp/nscd.off /tmp/nscd.on
--- /tmp/nscd.off       2018-02-13 20:48:31.812740000 +0200
+++ /tmp/nscd.on        2018-02-13 20:46:11.192560000 +0200
@@ -32,6 +32,40 @@
 nogroup:*:65533
 nobody:*:65534
 nslcd:*:928
+wheel:*:0:root
+daemon:*:1
+kmem:*:2
+sys:*:3
+tty:*:4
+operator:*:5:root
+mail:*:6
+bin:*:7
+news:*:8
+man:*:9
+games:*:13
+ftp:*:14
+staff:*:20
+sshd:*:22
+smmsp:*:25
+mailnull:*:26
+guest:*:31
+video:*:44
+bind:*:53
+unbound:*:59
+proxy:*:62
+authpf:*:63
+_pflogd:*:64
+_dhcp:*:65
+uucp:*:66
+dialer:*:68
+network:*:69
+audit:*:77
+www:*:80
+_ypldap:*:160
+hast:*:845
+nogroup:*:65533
+nobody:*:65534
+nslcd:*:928
 recovery:*:2868
Comment 4 Alan Somers freebsd_committer freebsd_triage 2020-08-26 16:46:53 UTC
I'm seeing this too, on 11.4-RELEASE, with this in nswitch.conf:
group: files cache ldap
Comment 5 Alan Somers freebsd_committer freebsd_triage 2021-06-17 21:46:35 UTC
Is this still an issue on current releases?  I can't reproduce it on 14.0-CURRENT or 13.0-RELEASE.
Comment 6 Volodymyr Pushkar 2021-06-18 23:45:41 UTC
Looks like it was fixed somehow as I can't reproduce it anymore in my environment:

root@fbsd13:/etc # /etc/rc.d/nscd stop
Stopping nscd.
Waiting for PIDS: 52168.
root@fbsd13:/etc # getent group | wc -l
    1872
root@fbsd13:/etc # /etc/rc.d/nscd start
Starting nscd.
root@fbsd13:/etc # getent group | wc -l
    1872
root@fbsd13:/etc # getent group | wc -l
    1872
root@fbsd13:/etc # uname -a
FreeBSD fbsd13 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64
Comment 7 Alan Somers freebsd_committer freebsd_triage 2021-06-19 00:17:42 UTC
Since neither of us can reproduce this bug, I'm going to tentatively declare it a duplicate of 248932 and close it.  Anybody please feel free to reopen if you can reproduce on 13.1, 12.3, or a later release.

*** This bug has been marked as a duplicate of bug 248932 ***