Bug 202135

Summary: nscd does not accept a value of zero for negative-time-to-live for passwd nor group
Product: Base System Reporter: Trond Endrestøl <Trond.Endrestol>
Component: binAssignee: Allan Jude <allanjude>
Status: Closed FIXED    
Severity: Affects Many People CC: allanjude, amutu, andrewcobaugh, feld
Priority: ---    
Version: 10.2-STABLE   
Hardware: Any   
OS: Any   
Bug Depends on: 181586    
Bug Blocks:    
Attachments:
Description Flags
patch for check nscd configuration value none

Description Trond Endrestøl 2015-08-06 16:05:47 UTC
System is FreeBSD/i386, stable/10, r286362.

This config is acceptable by nscd:

threads                         8

enable-cache            passwd  yes
positive-time-to-live   passwd  600
negative-time-to-live   passwd  1
check-files             passwd  no

enable-cache            group   yes
positive-time-to-live   group   3600
negative-time-to-live   group   1
check-files             group   no

This config is NOT acceptable by nscd:

threads                         8

enable-cache            passwd  yes
positive-time-to-live   passwd  600
negative-time-to-live   passwd  0
check-files             passwd  no

enable-cache            group   yes
positive-time-to-live   group   3600
negative-time-to-live   group   0
check-files             group   no

nscd simply dies with the latter configuration, although this gets logged:

Aug  6 15:45:35 <kern.info> hostname kernel: pid 730 (nscd), uid 0: exited on signal 6 (core dumped)
Comment 1 Jov 2016-03-09 07:08:22 UTC
Created attachment 167900 [details]
patch for check nscd configuration value

I make a patch for checking the value for nscd config.

the patch check if the config value valid  as follows when parse the /etc/nscd.conf,the condition value come from assert statement in various place from nscd code.

positive-time-to-live > 0
negative-time-to-live > 0
negative-confidence-threshold > 0
suggested-size > 0
keep-hot-count >= 0

the patch against HEAD.
Comment 2 Allan Jude freebsd_committer freebsd_triage 2020-07-11 18:54:54 UTC
I've updated the patch and posted it for review: https://reviews.freebsd.org/D25627
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-07-11 19:44:31 UTC
A commit references this bug:

Author: allanjude
Date: Sat Jul 11 19:44:12 UTC 2020
New revision: 363109
URL: https://svnweb.freebsd.org/changeset/base/363109

Log:
  nscd: does not warn about invalid values what parsing config file

  PR:		202135
  Submitted by:	amutu@amutu.com
  Reported By:	Trond.Endrestol@ximalas.info
  Reviewed by:	markj, freqlabs
  MFC after:	4 weeks
  Sponsored by:	Klara Inc.
  Event:		July 2020 Bugathon
  Differential Revision:	https://reviews.freebsd.org/D25627

Changes:
  head/usr.sbin/nscd/parser.c