summaryrefslogtreecommitdiff
path: root/sys-libs/glibc/files/nscd-1
blob: f69c8e2eacd00a9b186279658fb6257cae6a8ef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

description="The 'Name Service Cache Daemon' is a daemon that provides a cache"
description="${description} for the most common name service requests"

extra_started_commands="flush_all flush_hosts flush_group flush_passwd flush_netgroup flush_services"

description_flush_all="Will invalidate hosts, group, passwd, netgroup and services cache"
description_flush_hosts="Will invalidate hosts cache"
description_flush_group="Will invalidate group cache"
description_flush_passwd="Will invalidate passwd cache"
description_flush_netgroup="Will invalidate netgroup cache"
description_flush_services="Will invalidate services cache"

pidfile="/run/nscd/nscd.pid"
command="/usr/sbin/nscd"

depend() {
	use dns ldap net slapd logger
}

checkconfig() {
	if [ ! -d /run/nscd ] ; then
		checkpath -d -m 755 /run/nscd
	fi

	if [ -z "${NSCD_PERMS_OK}" ] && [ "$(stat -c %a /run/nscd)" != "755" ] ; then
		ewarn "nscd run dir is not world readable, you should reset the perms:"
		ewarn "chmod 755 /run/nscd"
		ewarn "chmod a+rw /run/nscd/socket"
		ewarn "To disable this warning, set 'NSCD_PERMS_OK' in /etc/conf.d/nscd"
	fi

	if grep -qs '^[[:space:]]*persistent\>' /etc/nscd.conf ; then
		checkpath -d -m 700 /var/db/nscd
	fi
}

_flush() {
	local table=$1

	ebegin "Flushing ${table} table"
	${command} --invalidate ${table}
	eend $?
}

flush_all() {
	local has_errors=0

	ebegin "Flushing all caches"

	local table=
	for table in passwd group hosts netgroup services; do
		${command} --invalidate ${table}
		[ $? -ne 0 ] && has_errors=1
	done

	eend ${has_errors}
}

flush_hosts() {
	_flush hosts
}

flush_group() {
	_flush group
}

flush_passwd() {
        _flush passwd
}

flush_netgroup() {
	_flush netgroup
}

flush_services() {
	_flush services
}

start_pre() {
	checkconfig
}