Compare commits
	
		
			29 Commits
		
	
	
		
			openrc-0.2
			...
			openrc-0.2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | b41c864fc3 | ||
|   | c409dd0570 | ||
|   | aaaa0b50d8 | ||
|   | ca6f289c80 | ||
|   | f640ecaebb | ||
|   | 75eff5a86b | ||
|   | eeadc618fb | ||
|   | bb069e1618 | ||
|   | 3a592fa31b | ||
|   | 6b77cc624f | ||
|   | 328215e841 | ||
|   | b03282b901 | ||
|   | 08081f7ef4 | ||
|   | 8ca8e00a89 | ||
|   | 1df3ab05b5 | ||
|   | 775df18a70 | ||
|   | 148caecc7e | ||
|   | d0f7a63487 | ||
|   | b7e598ad91 | ||
|   | 5c114d9430 | ||
|   | f13ea77491 | ||
|   | a89171ee9b | ||
|   | 6d5d655b52 | ||
|   | 0f51f3e863 | ||
|   | be8f8d0ac0 | ||
|   | d667da8e5c | ||
|   | 9894669742 | ||
|   | b732df31ef | ||
|   | 762dc3d197 | 
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
| # All rights reserved. Released under the 2-clause BSD license. | ||||
|  | ||||
| NAME=		openrc | ||||
| VERSION=	0.2.4 | ||||
| VERSION=	0.2.5 | ||||
| PKG=		${NAME}-${VERSION} | ||||
|  | ||||
| SUBDIR=		conf.d doc etc init.d man net sh src | ||||
|   | ||||
							
								
								
									
										1
									
								
								init.d/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								init.d/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -38,3 +38,4 @@ mtab | ||||
| numlock | ||||
| procfs | ||||
| termencoding | ||||
| devdb | ||||
|   | ||||
| @@ -5,7 +5,7 @@ SRCS+=	hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \ | ||||
| 	rpcbind.in savecore.in syslogd.in | ||||
|  | ||||
| # These are NetBSD specific | ||||
| SRCS+=	swap-blk.in ttys.in wscons.in | ||||
| SRCS+=	devdb.in swap-blk.in ttys.in wscons.in | ||||
|  | ||||
| .SUFFIXES:	.BSD.in | ||||
| .BSD.in: | ||||
|   | ||||
| @@ -86,7 +86,7 @@ start() | ||||
|  | ||||
| 		ebegin "Cleaning /var/run" | ||||
| 		for x in $(find /var/run ! -type d ! -name utmp \ | ||||
| 			! -name random-seed \ | ||||
| 			! -name random-seed ! -name dev.db \ | ||||
| 			! -name ld-elf.so.hints ! -name ld.so.hints); | ||||
| 		do	 | ||||
| 			[ ! -f "${x}" ] && continue | ||||
|   | ||||
							
								
								
									
										21
									
								
								init.d/devdb.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								init.d/devdb.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| #!@PREFIX@/sbin/runscript | ||||
| # Copyright 2008 Roy Marples <roy@marples.name> | ||||
| # All rights reserved. Released under the 2-clause BSD license. | ||||
|  | ||||
| description="Creates the dev database" | ||||
|  | ||||
| depend() | ||||
| { | ||||
| 	need localmount | ||||
| } | ||||
|  | ||||
| start() | ||||
| { | ||||
| 	ebegin "Bulding the dev database" | ||||
| 	if [ /var/run/dev.db -nt /dev ]; then | ||||
| 		: | ||||
| 	else | ||||
| 		dev_mkdb | ||||
| 	fi | ||||
| 	eend $? | ||||
| } | ||||
| @@ -3,7 +3,7 @@ | ||||
| # All rights reserved. Released under the 2-clause BSD license. | ||||
|  | ||||
| description="Check and repair filesystems according to /etc/fstab" | ||||
| _ISF=" | ||||
| _IFS=" | ||||
| " | ||||
|  | ||||
| depend() | ||||
| @@ -47,7 +47,7 @@ start() | ||||
| 		case "${p}" in | ||||
| 			[0-9]*) p="=${p}";; | ||||
| 		esac | ||||
| 		set -- "$@" "$(fstabinfo --passno "${p}")" | ||||
| 		set -- "$@" $(fstabinfo --passno "${p}") | ||||
| 		unset IFS | ||||
| 	done | ||||
|  | ||||
| @@ -63,7 +63,7 @@ start() | ||||
| 		reboot_opts="-f" | ||||
| 	fi | ||||
|  | ||||
| 	trap : QUIT | ||||
| 	trap : INT QUIT | ||||
| 	fsck ${fsck_args--p} ${fsck_opts} "$@" | ||||
| 	case $? in | ||||
| 		0)       eend 0; return 0;; | ||||
|   | ||||
| @@ -15,20 +15,41 @@ _config_vars="$_config_vars dhcp dhcpcd" | ||||
|  | ||||
| dhcpcd_start() | ||||
| { | ||||
| 	local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" | ||||
|  | ||||
| 	local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" new=true | ||||
| 	eval args=\$dhcpcd_${IFVAR} | ||||
|  | ||||
| 	# Get our options | ||||
| 	eval opts=\$dhcp_${IFVAR} | ||||
| 	[ -z "${opts}" ] && opts=${dhcp} | ||||
|  | ||||
| 	case "$(dhcpcd --version)" in | ||||
| 		"dhcpcd "[123]*) new=false;; | ||||
| 	esac | ||||
|  | ||||
| 	# Map some generic options to dhcpcd | ||||
| 	for opt in ${opts}; do | ||||
| 		case "${opt}" in | ||||
| 			nodns) args="${args} -R";; | ||||
| 			nontp) args="${args} -N";; | ||||
| 			nonis) args="${args} -Y";; | ||||
| 			nodns) | ||||
| 				if ${new}; then | ||||
| 					args="${args} -C resolv.conf" | ||||
| 				else | ||||
| 					args="${args} -R" | ||||
| 				fi | ||||
| 				;; | ||||
| 			nontp) | ||||
| 				if ${new}; then | ||||
| 					args="${args} -C ntp.conf" | ||||
| 				else | ||||
| 					args="${args} -N" | ||||
| 				fi | ||||
| 				;; | ||||
| 			nonis) | ||||
| 				if ${new}; then | ||||
| 					args="${args} -C yp.conf" | ||||
| 				else | ||||
| 					args="${args} -Y" | ||||
| 				fi | ||||
| 				;; | ||||
| 			nogateway) args="${args} -G";; | ||||
| 			nosendhost) args="${args} -h ''"; | ||||
| 		esac | ||||
|   | ||||
| @@ -235,7 +235,11 @@ _delete_addresses() | ||||
| 	local addr= | ||||
| 	for addr in $(LC_ALL=C ifconfig "${IFACE}" | \ | ||||
| 		sed -n -e 's/^.*\(inet6 addr:\|inet6\) \([^ ]*\) .*\(Scope:[^L]\|scopeid [^<]*<[^l]\).*/\2/p'); do | ||||
| 		[ "${addr}" = "::1/128" -a "${IFACE}" = "lo" ] && continue | ||||
| 		if [ "${IFACE}" = "lo" ]; then | ||||
| 			case "${addr}" in | ||||
| 				"::1/128"|"/128") continue;; | ||||
| 			esac | ||||
| 		fi | ||||
| 		einfo "${addr}" | ||||
| 		ifconfig "${IFACE}" inet6 del "${addr}" | ||||
| 	done | ||||
|   | ||||
| @@ -198,7 +198,7 @@ iproute2_pre_start() | ||||
| 		metric=1000 | ||||
|  | ||||
| 		ebegin "Creating tunnel ${IFVAR}" | ||||
| 		ip tunnel add ${tunnel} name dev "${IFACE}" | ||||
| 		ip tunnel add ${tunnel} name "${IFACE}" | ||||
| 		eend $? || return 1 | ||||
| 		_up	 | ||||
| 	fi | ||||
| @@ -208,6 +208,8 @@ iproute2_pre_start() | ||||
|  | ||||
| _iproute2_ipv6_tentative() | ||||
| { | ||||
| 	# Only check tentative when we have a carrier. | ||||
| 	LC_ALL=C ip link show dev "${IFACE}" | grep -q "NO-CARRIER" && return 1 | ||||
| 	LC_ALL=C ip addr show dev "${IFACE}" | \ | ||||
| 		grep -q "^[[:space:]]*inet6 .* tentative" | ||||
| } | ||||
| @@ -234,7 +236,7 @@ iproute2_post_stop() | ||||
| 	if [ "${IFACE}" != "sit0" ]; then | ||||
| 		if [ -n "$(ip tunnel show "${IFACE}" 2>/dev/null)" ]; then | ||||
| 			ebegin "Destroying tunnel ${IFACE}" | ||||
| 			ip tunnel del dev "${IFACE}" | ||||
| 			ip tunnel del "${IFACE}" | ||||
| 			eend $? | ||||
| 		fi | ||||
| 	fi | ||||
|   | ||||
| @@ -206,9 +206,13 @@ iwconfig_wait_for_association() | ||||
| 		# Use sysfs if we can | ||||
| 		if [ -e /sys/class/net/"${IFACE}"/carrier ]; then | ||||
| 			if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ]; then | ||||
| 				# Double check we have an ssid. This is mainly for buggy | ||||
| 				# prism54 drivers that always set their carrier on :/ | ||||
| 				[ -n "$(iwgetid --raw "${IFACE}")" ] && return 0 | ||||
| 				# Double check we have an ssid and a non-zero | ||||
| 				# mac address.  This is mainly for buggy | ||||
| 				# prism54 drivers that always set their | ||||
| 				# carrier on or buggy madwifi drivers that | ||||
| 				# sometimes have carrier on and ssid set | ||||
| 				# without being associated.  :/ | ||||
| 				[ -n "$(iwgetid --raw "${IFACE}")" ] && [ "$(iwgetid --ap --raw "${IFACE}")" != "00:00:00:00:00:00" ] && return 0 | ||||
| 			fi | ||||
| 		else | ||||
| 			local atest= | ||||
|   | ||||
| @@ -78,11 +78,9 @@ wpa_supplicant_pre_start() | ||||
| 	service_set_value "SSID" "" | ||||
| 	ebegin "Starting wpa_supplicant on ${IFVAR}" | ||||
|  | ||||
| 	if [ -x /sbin/iwconfig ]; then | ||||
| 		local x= | ||||
| 		for x in txpower rate rts frag; do | ||||
| 			iwconfig "${IFACE}" "${x}" auto 2>/dev/null | ||||
| 		done | ||||
| 	if type iwconfig_defaults >/dev/null 2>&1; then | ||||
| 		iwconfig_defaults | ||||
| 		iwconfig_user_config | ||||
| 	fi | ||||
|  | ||||
| 	cfgfile=${opts##* -c} | ||||
|   | ||||
| @@ -2,4 +2,4 @@ | ||||
| BOOT+=		hostid net.lo0 newsyslog savecore syslogd | ||||
|  | ||||
| # NetBSD specific stuff | ||||
| BOOT+=		swap-blk ttys wscons | ||||
| BOOT+=		devdb swap-blk ttys wscons | ||||
|   | ||||
| @@ -431,12 +431,11 @@ static void visit_service(const RC_DEPTREE *deptree, | ||||
| 		TAILQ_FOREACH(service, dt->services, entries) { | ||||
| 			if (!(di = get_depinfo(deptree, service->value))) | ||||
| 				continue; | ||||
|  | ||||
| 			provided = get_provided(di, runlevel, options); | ||||
| 			TAILQ_FOREACH(p, provided, entries) | ||||
| 				if (strcmp (p->value, depinfo->service) == 0) { | ||||
| 					//visit_service (deptree, types, sorted, visited, di, | ||||
| 					//	       runlevel, options | RC_DEP_TRACE); | ||||
| 					visit_service (deptree, types, sorted, visited, di, | ||||
| 						       runlevel, options | RC_DEP_TRACE); | ||||
| 					break; | ||||
| 				} | ||||
| 			rc_stringlist_free(provided); | ||||
|   | ||||
| @@ -31,38 +31,35 @@ | ||||
|  | ||||
| #include "librc.h" | ||||
|  | ||||
| bool rc_yesno (const char *value) | ||||
| bool rc_yesno(const char *value) | ||||
| { | ||||
| 	if (! value) { | ||||
| 	if (!value) { | ||||
| 		errno = ENOENT; | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	if (strcasecmp (value, "yes") == 0 || | ||||
| 	    strcasecmp (value, "y") == 0 || | ||||
| 	    strcasecmp (value, "true") == 0 || | ||||
| 	    strcasecmp (value, "1") == 0) | ||||
| 	if (strcasecmp(value, "yes") == 0 || | ||||
| 	    strcasecmp(value, "y") == 0 || | ||||
| 	    strcasecmp(value, "true") == 0 || | ||||
| 	    strcasecmp(value, "1") == 0) | ||||
| 		return true; | ||||
|  | ||||
| 	if (strcasecmp (value, "no") != 0 && | ||||
| 	    strcasecmp (value, "n") != 0 && | ||||
| 	    strcasecmp (value, "false") != 0 && | ||||
| 	    strcasecmp (value, "0") != 0) | ||||
| 	if (strcasecmp(value, "no") != 0 && | ||||
| 	    strcasecmp(value, "n") != 0 && | ||||
| 	    strcasecmp(value, "false") != 0 && | ||||
| 	    strcasecmp(value, "0") != 0) | ||||
| 		errno = EINVAL; | ||||
|  | ||||
| 	return false; | ||||
| } | ||||
| librc_hidden_def(rc_yesno) | ||||
|  | ||||
| ssize_t rc_getline (char **line, size_t *len, FILE *fp) | ||||
| ssize_t rc_getline(char **line, size_t *len, FILE *fp) | ||||
| { | ||||
| 	char *p; | ||||
| 	size_t last = 0; | ||||
|  | ||||
| 	if (feof(fp)) | ||||
| 		return 0; | ||||
|  | ||||
| 	do { | ||||
| 	while(!feof(fp)) { | ||||
| 		if (*line == NULL || last != 0) { | ||||
| 			*len += BUFSIZ; | ||||
| 			*line = xrealloc(*line, *len); | ||||
| @@ -71,12 +68,11 @@ ssize_t rc_getline (char **line, size_t *len, FILE *fp) | ||||
| 		memset(p, 0, BUFSIZ); | ||||
| 		fgets(p, BUFSIZ, fp); | ||||
| 		last += strlen(p); | ||||
| 	} while (! feof(fp) && (*line)[last - 1] != '\n'); | ||||
|  | ||||
| 	/* Trim the trailing newline */ | ||||
| 	if (**line && (*line)[last - 1] == '\n') | ||||
| 		(*line)[last - 1] = '\0'; | ||||
|  | ||||
| 		if (last && (*line)[last - 1] == '\n') { | ||||
| 			(*line)[last - 1] = '\0'; | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	return last; | ||||
| } | ||||
| librc_hidden_def(rc_getline) | ||||
| @@ -108,7 +104,7 @@ RC_STRINGLIST *rc_config_list(const char *file) | ||||
| 				if (token[strlen(token) - 1] == '\n') | ||||
| 					token[strlen(token) - 1] = 0; | ||||
|  | ||||
| 				if (! list) | ||||
| 				if (!list) | ||||
| 					list = rc_stringlist_new(); | ||||
| 				rc_stringlist_add(list, token); | ||||
| 			} | ||||
| @@ -135,7 +131,7 @@ RC_STRINGLIST *rc_config_load(const char *file) | ||||
| 	char *p; | ||||
|  | ||||
| 	list = rc_config_list(file); | ||||
| 	if (! list) | ||||
| 	if (!list) | ||||
| 		return NULL; | ||||
|  | ||||
| 	config = rc_stringlist_new(); | ||||
| @@ -157,15 +153,15 @@ RC_STRINGLIST *rc_config_load(const char *file) | ||||
|  | ||||
| 		/* Drop a newline if that's all we have */ | ||||
| 		if (token) { | ||||
| 			i = strlen (token) - 1; | ||||
| 			i = strlen(token) - 1; | ||||
| 			if (token[i] == '\n') | ||||
| 				token[i] = 0; | ||||
|  | ||||
| 			i = strlen (entry) + strlen (token) + 2; | ||||
| 			i = strlen(entry) + strlen(token) + 2; | ||||
| 			newline = xmalloc(sizeof(char) * i); | ||||
| 			snprintf(newline, i, "%s=%s", entry, token); | ||||
| 		} else { | ||||
| 			i = strlen (entry) + 2; | ||||
| 			i = strlen(entry) + 2; | ||||
| 			newline = xmalloc(sizeof(char) * i); | ||||
| 			snprintf(newline, i, "%s=", entry); | ||||
| 		} | ||||
| @@ -176,7 +172,7 @@ RC_STRINGLIST *rc_config_load(const char *file) | ||||
| 		TAILQ_FOREACH(cline, config, entries) { | ||||
| 			p = strchr(cline->value, '='); | ||||
| 			if (p && strncmp(entry, cline->value, | ||||
| 					  (size_t) (p - cline->value)) == 0) | ||||
| 					  (size_t)(p - cline->value)) == 0) | ||||
| 			{ | ||||
| 				/* We have a match now - to save time we directly replace it */ | ||||
| 				free(cline->value); | ||||
| @@ -186,7 +182,7 @@ RC_STRINGLIST *rc_config_load(const char *file) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if (! replaced) { | ||||
| 		if (!replaced) { | ||||
| 			rc_stringlist_add(config, newline); | ||||
| 			free(newline); | ||||
| 		} | ||||
|   | ||||
| @@ -55,13 +55,13 @@ install: all | ||||
| 	${INSTALL} -d ${DESTDIR}${SBINDIR} | ||||
| 	${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR} | ||||
| 	${INSTALL} -d ${DESTDIR}${BINDIR} | ||||
| 	for x in ${BINLINKS}; do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done | ||||
| 	for x in ${BINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done | ||||
| 	${INSTALL} -d ${DESTDIR}${SBINDIR} | ||||
| 	for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${SBINDIR}/$$x; done | ||||
| 	${INSTALL} -d ${DESTDIR}${LINKDIR}/bin | ||||
| 	for x in $(RC_BINLINKS); do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done | ||||
| 	for x in $(RC_BINLINKS); do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done | ||||
| 	${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin | ||||
| 	for x in ${RC_SBINLINKS}; do ln -fs ${DESTDIR}${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done | ||||
| 	for x in ${RC_SBINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done | ||||
| 	if test "${MKPAM}" = pam; then \ | ||||
| 		${INSTALL} -d ${DESTDIR}${PAMDIR}; \ | ||||
| 		${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \ | ||||
|   | ||||
| @@ -137,8 +137,8 @@ static const struct option longopts[] = { | ||||
| 	longopts_COMMON | ||||
| }; | ||||
| static const char * const longopts_help[] = { | ||||
| 	"Extract the block device", | ||||
| 	"Mounts the filesytem from the mountpoint", | ||||
| 	"Extract the block device", | ||||
| 	"Show arguments needed to mount the entry", | ||||
| 	"Extract the options field", | ||||
| 	"Extract or query the pass number field", | ||||
| @@ -159,7 +159,7 @@ int fstabinfo(int argc, char **argv) | ||||
| 	struct ENT *ent; | ||||
| 	int result = EXIT_SUCCESS; | ||||
| 	char *token; | ||||
| 	int i; | ||||
| 	int i, p; | ||||
| 	int opt; | ||||
| 	int output = OUTPUT_FILE; | ||||
| 	RC_STRINGLIST *files = rc_stringlist_new(); | ||||
| @@ -200,13 +200,17 @@ int fstabinfo(int argc, char **argv) | ||||
| 						argv[0], optarg + 1); | ||||
|  | ||||
| 				filtered = true; | ||||
| 				opt = optarg[0]; | ||||
| 				START_ENT; | ||||
| 				while ((ent = GET_ENT)) { | ||||
| 					if (((optarg[0] == '=' && i == ENT_PASS(ent)) || | ||||
| 					     (optarg[0] == '<' && i > ENT_PASS(ent)) || | ||||
| 					     (optarg[0] == '>' && i < ENT_PASS(ent))) && | ||||
| 					    strcmp(ENT_FILE(ent), "none") != 0) | ||||
| 						rc_stringlist_add(files, ENT_FILE(ent)); | ||||
| 					if (strcmp(ENT_FILE(ent), "none") == 0) | ||||
| 						continue; | ||||
| 					p = ENT_PASS(ent); | ||||
| 					if ((opt == '=' && i == p) || | ||||
| 					    (opt == '<' && i > p && p != 0) || | ||||
| 					    (opt == '>' && i < p && p != 0)) | ||||
| 						rc_stringlist_add(files, | ||||
| 								  ENT_FILE(ent)); | ||||
| 				} | ||||
| 				END_ENT; | ||||
| 				break; | ||||
|   | ||||
| @@ -801,7 +801,8 @@ static void do_stop_services(const char *newlevel, bool going_down, bool paralle | ||||
| 			tmplist = rc_stringlist_new(); | ||||
| 			rc_stringlist_add(tmplist, service->value); | ||||
| 			deporder = rc_deptree_depends(deptree, types_n, tmplist, | ||||
| 						      runlevel, RC_DEP_STRICT); | ||||
| 						      runlevel, | ||||
| 						      RC_DEP_STRICT | RC_DEP_TRACE); | ||||
| 			rc_stringlist_free(tmplist); | ||||
| 			svc2 = NULL; | ||||
| 			TAILQ_FOREACH (svc1, deporder, entries) { | ||||
|   | ||||
| @@ -877,11 +877,13 @@ static void svc_start(bool deps) | ||||
| 	} | ||||
|  | ||||
| 	/* Do the same for any services we provide */ | ||||
| 	tmplist = rc_deptree_depend(deptree, "iprovide", applet); | ||||
| 	if (tmplist) { | ||||
| 		TAILQ_FOREACH(svc, tmplist, entries) { | ||||
| 			services = rc_services_scheduled(svc->value); | ||||
| 			if (services) { | ||||
| 	if (deptree) { | ||||
| 		tmplist = rc_deptree_depend(deptree, "iprovide", applet); | ||||
| 		if (tmplist) { | ||||
| 			TAILQ_FOREACH(svc, tmplist, entries) { | ||||
| 				services = rc_services_scheduled(svc->value); | ||||
| 				if (! services) | ||||
| 					continue; | ||||
| 				TAILQ_FOREACH(svc2, services, entries) | ||||
| 					if (rc_service_state(svc2->value) & RC_SERVICE_STOPPED) | ||||
| 						service_start(svc2->value); | ||||
| @@ -945,7 +947,6 @@ static void svc_stop(bool deps) | ||||
| 		if (! types_m) | ||||
| 			setup_types(); | ||||
|  | ||||
| 		tmplist = NULL; | ||||
| 		services = rc_deptree_depends(deptree, types_m, applet_list, | ||||
| 					      runlevel, depoptions); | ||||
| 		if (services) { | ||||
|   | ||||
| @@ -308,7 +308,7 @@ static pid_t get_pid(const char *pidfile, bool quiet) | ||||
|  | ||||
| /* return number of processed killed, -1 on error */ | ||||
| static int do_stop(const char *const *argv, const char *cmd, | ||||
| 		   const char *pidfile, uid_t uid,int sig, | ||||
| 		   pid_t pid, uid_t uid,int sig, | ||||
| 		   bool quiet, bool verbose, bool test) | ||||
| { | ||||
| 	RC_PIDLIST *pids; | ||||
| @@ -316,13 +316,10 @@ static int do_stop(const char *const *argv, const char *cmd, | ||||
| 	RC_PID *np; | ||||
| 	bool killed; | ||||
| 	int nkilled = 0; | ||||
| 	pid_t pid = 0; | ||||
|  | ||||
| 	if (pidfile) { | ||||
| 		if ((pid = get_pid(pidfile, quiet)) == -1) | ||||
| 			return quiet ? 0 : -1; | ||||
| 	if (pid) | ||||
| 		pids = rc_find_pids(NULL, NULL, 0, pid); | ||||
| 	} else | ||||
| 	else | ||||
| 		pids = rc_find_pids(argv, cmd, uid, pid); | ||||
|  | ||||
| 	if (! pids) | ||||
| @@ -369,6 +366,7 @@ static int run_stop_schedule(const char *const *argv, const char *cmd, | ||||
| 	int nrunning = 0; | ||||
| 	long nloops; | ||||
| 	struct timespec ts; | ||||
| 	pid_t pid = 0; | ||||
|  | ||||
| 	if (verbose) { | ||||
| 		if (pidfile) | ||||
| @@ -381,6 +379,12 @@ static int run_stop_schedule(const char *const *argv, const char *cmd, | ||||
| 			einfo("Will stop processes called `%s'", cmd); | ||||
| 	} | ||||
|  | ||||
| 	if (pidfile) { | ||||
| 		pid = get_pid(pidfile, quiet); | ||||
| 		if (pid == -1) | ||||
| 			return 0; | ||||
| 	} | ||||
|  | ||||
| 	while (item) { | ||||
| 		switch (item->type) { | ||||
| 		case SC_GOTO: | ||||
| @@ -389,7 +393,7 @@ static int run_stop_schedule(const char *const *argv, const char *cmd, | ||||
|  | ||||
| 		case SC_SIGNAL: | ||||
| 			nrunning = 0; | ||||
| 			nkilled = do_stop(argv, cmd, pidfile, uid, item->value, | ||||
| 			nkilled = do_stop(argv, cmd, pid, uid, item->value, | ||||
| 					  quiet, verbose, test); | ||||
| 			if (nkilled == 0) { | ||||
| 				if (tkilled == 0) { | ||||
| @@ -415,9 +419,9 @@ static int run_stop_schedule(const char *const *argv, const char *cmd, | ||||
| 			ts.tv_nsec = POLL_INTERVAL; | ||||
|  | ||||
| 			while (nloops) { | ||||
| 				if ((nrunning = do_stop(argv, cmd, pidfile, | ||||
| 				if ((nrunning = do_stop(argv, cmd, pid, | ||||
| 							uid, 0, true, false, true)) == 0) | ||||
| 					return true; | ||||
| 					return 0; | ||||
|  | ||||
| 				if (nanosleep(&ts, NULL) == -1) { | ||||
| 					if (errno == EINTR) | ||||
| @@ -852,7 +856,12 @@ int start_stop_daemon(int argc, char **argv) | ||||
| 		exit(EXIT_SUCCESS); | ||||
| 	} | ||||
|  | ||||
| 	if (do_stop((const char * const *)argv, cmd, pidfile, uid, | ||||
| 	if (pidfile) { | ||||
| 		pid = get_pid(pidfile, true); | ||||
| 	} else | ||||
| 		pid = 0; | ||||
|  | ||||
| 	if (do_stop((const char * const *)argv, cmd, pid, uid, | ||||
| 		    0, true, false, true) > 0) | ||||
| 		eerrorx("%s: %s is already running", applet, exec); | ||||
|  | ||||
| @@ -1112,16 +1121,18 @@ int start_stop_daemon(int argc, char **argv) | ||||
| 			} else { | ||||
| 				if (pidfile) { | ||||
| 					/* The pidfile may not have been written yet - give it some time */ | ||||
| 					if (get_pid(pidfile, true) == -1) { | ||||
| 					if ((pid = get_pid(pidfile, true)) == -1) { | ||||
| 						if (! nloopsp) | ||||
| 							eerrorx("%s: did not create a valid pid in `%s'", | ||||
| 								applet, pidfile); | ||||
| 						alive = true; | ||||
| 						pid = 0; | ||||
| 					} else | ||||
| 						nloopsp = 0; | ||||
| 				} | ||||
| 				} else | ||||
| 					pid = 0; | ||||
| 				if (do_stop((const char *const *)argv, cmd, | ||||
| 					    pidfile, uid, 0, true, false, true) > 0) | ||||
| 					    pid, uid, 0, true, false, true) > 0) | ||||
| 					alive = true; | ||||
| 			} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user