Compare commits
	
		
			18 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					66651180a7 | ||
| 
						 | 
					7d63dc928c | ||
| 
						 | 
					8e16828bd3 | ||
| 
						 | 
					3a30710916 | ||
| 
						 | 
					290a91e8e9 | ||
| 
						 | 
					04d94be766 | ||
| 
						 | 
					fa6707e5b3 | ||
| 
						 | 
					3286a98fe6 | ||
| 
						 | 
					dc0ab571a2 | ||
| 
						 | 
					fb37e1aa96 | ||
| 
						 | 
					8769cca710 | ||
| 
						 | 
					506f2887e1 | ||
| 
						 | 
					83223a6e97 | ||
| 
						 | 
					2747f40f82 | ||
| 
						 | 
					933972da53 | ||
| 
						 | 
					dbcb8ba3fe | ||
| 
						 | 
					e462c3223e | ||
| 
						 | 
					06f195ce37 | 
							
								
								
									
										138
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										138
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,3 +1,135 @@
 | 
			
		||||
commit 7d63dc928ca02dc9ab654078c5c1ed0b6bb017d9
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    localmount: Allow users to control whether errors are ignored
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 572138
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572138
 | 
			
		||||
 | 
			
		||||
commit 8e16828bd3d97e6b1e40ded616a54cb8a9e7b403
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    rc: remove use of magic constant and allow OpenVZ to drop to shell
 | 
			
		||||
    
 | 
			
		||||
    OpenVZ has had console support for a long time now; allow them to use it
 | 
			
		||||
    to drop to a shell during interactive boot.
 | 
			
		||||
 | 
			
		||||
commit 3a307109168ac82f37a9a85a81b7b527a57665e5
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: handle rc_sys="prefix" even if we weren't built with a prefix
 | 
			
		||||
    
 | 
			
		||||
    This probably isn't needed, but it mimics old behavior.
 | 
			
		||||
 | 
			
		||||
commit 290a91e8e9242582ee13c7343b630b097e2eeaf2
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: fix handling the nothing special case for rc_sys
 | 
			
		||||
 | 
			
		||||
commit 04d94be766ae2808adc709b0e4e03ce1f3a75d5d
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: move system detection code into rc_sys and use it
 | 
			
		||||
    
 | 
			
		||||
    This fixes an issue where librc code was calling code that only existed
 | 
			
		||||
    in the rc binary.
 | 
			
		||||
    
 | 
			
		||||
    This reverts commits 8addd79 and 9f6e056
 | 
			
		||||
    
 | 
			
		||||
    This fixes #75.
 | 
			
		||||
 | 
			
		||||
commit fa6707e5b33738c3416bfbad661770302aa50212
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix bsd build
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 572068
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572068
 | 
			
		||||
 | 
			
		||||
commit 3286a98fe60d1c2617ec73ef68fc4a18f092d9da
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    start 0.20.3
 | 
			
		||||
 | 
			
		||||
commit dc0ab571a26e4c990559f4222780a26aa84bd463
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update change log
 | 
			
		||||
 | 
			
		||||
commit fb37e1aa96df351b1bf591dc36ef332f86820a2b
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    src/rc/Makefile: fix make depend target
 | 
			
		||||
 | 
			
		||||
commit 8769cca71089983ad8a8a69cec852c6bc169248d
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    include rc.h properly in source files
 | 
			
		||||
    
 | 
			
		||||
    We were attempting to include rc.h in rc-misc.h instead of the source
 | 
			
		||||
    files where it should be included.
 | 
			
		||||
 | 
			
		||||
commit 506f2887e13eb8093bbff0915381644c4c08fc5c
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix selinux build
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 571798
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=571798
 | 
			
		||||
 | 
			
		||||
commit 83223a6e97ff2ed3a8b06c4794b55cdd1c61c657
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    version 0.20.2
 | 
			
		||||
 | 
			
		||||
commit 2747f40f823c2d31b820f0525360532287c70eea
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update changelog
 | 
			
		||||
 | 
			
		||||
commit 933972da532bdf23accaea68bd072fc723a4065d
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix selinux build
 | 
			
		||||
 | 
			
		||||
commit dbcb8ba3fe2ddce1052c6e0037c47e19d7c273aa
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Add LANG, LC_MESSAGES and TERM to the environment whitelist
 | 
			
		||||
 | 
			
		||||
commit e462c3223ec71e4567916c74b7e02ec167d91819
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix seg fault
 | 
			
		||||
 | 
			
		||||
commit 06f195ce37769fda1bbc2cfde13534abeb7f1176
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    increment version number
 | 
			
		||||
 | 
			
		||||
commit 04f05c30d13ec83b85164a536eb570f29a66b275
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update ChangeLog
 | 
			
		||||
 | 
			
		||||
commit 9473ac514cb72663d5c3bac8b5473cced4a20bf7
 | 
			
		||||
Author: joe9 <joe9mail@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
@@ -1323,9 +1455,3 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
    Fix off-by-one error in --test argument printout in start-stop-daemon.
 | 
			
		||||
    
 | 
			
		||||
    Fixes #34.
 | 
			
		||||
 | 
			
		||||
commit 3c5dc0ec7774a72e243da43ac5180ea36a311ad8
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    tmpfiles.dev: pass --boot to tmpfiles.sh so kmod works properly
 | 
			
		||||
 
 | 
			
		||||
@@ -76,13 +76,3 @@ Why: The getline() function was standardized in POSIX.1-2008, so it
 | 
			
		||||
 | 
			
		||||
Who:
 | 
			
		||||
 | 
			
		||||
### rc_sys()
 | 
			
		||||
 | 
			
		||||
When: 1.0
 | 
			
		||||
 | 
			
		||||
Why: The OpenRC code now uses two internal functions, detect_container()
 | 
			
		||||
	 and detect_vm() to handle this. rc_sys() is broken because it
 | 
			
		||||
	 doesn't differentiate between containers and vm's.
 | 
			
		||||
 | 
			
		||||
Who:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
NAME=		openrc
 | 
			
		||||
VERSION=	0.20
 | 
			
		||||
VERSION=	0.20.3
 | 
			
		||||
PKG=		${NAME}-${VERSION}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,9 @@
 | 
			
		||||
# Stop the unmounting of certain points.
 | 
			
		||||
# This could be useful for some NFS related work.
 | 
			
		||||
#no_umounts="/dir1:/var/dir2"
 | 
			
		||||
#
 | 
			
		||||
# Ignore errors when mounting local file systems.
 | 
			
		||||
# This should be left alone unless you know what you are doing. If it is
 | 
			
		||||
# set to yes, not only will we allow mount failures, but we will ignore
 | 
			
		||||
# syntax errors in fstab.
 | 
			
		||||
#ignore_mount_errors="NO"
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,11 @@ start()
 | 
			
		||||
	rc=$?
 | 
			
		||||
	if [ "$RC_UNAME" != Linux ]; then
 | 
			
		||||
		rc=0
 | 
			
		||||
	elif yesno "${ignore_mount_errors:-NO}"; then
 | 
			
		||||
		if [ $rc -ne 0 ]; then
 | 
			
		||||
			ewarn "localmount: errors detected, but ignored"
 | 
			
		||||
		fi
 | 
			
		||||
		rc=0
 | 
			
		||||
	fi
 | 
			
		||||
	return $rc
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,6 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "helpers.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
 | 
			
		||||
#define RC_LEVEL_BOOT           "boot"
 | 
			
		||||
#define RC_LEVEL_DEFAULT        "default"
 | 
			
		||||
@@ -61,10 +60,6 @@ int is_writable(const char *);
 | 
			
		||||
#define service_stop(service)  exec_service(service, "stop");
 | 
			
		||||
 | 
			
		||||
int parse_mode(mode_t *, char *);
 | 
			
		||||
const char *detect_prefix(void);
 | 
			
		||||
const char *get_systype(void);
 | 
			
		||||
const char *detect_container(void);
 | 
			
		||||
const char *detect_vm(void);
 | 
			
		||||
 | 
			
		||||
/* Handy function so we can wrap einfo around our deptree */
 | 
			
		||||
RC_DEPTREE *_rc_deptree_load (int, int *);
 | 
			
		||||
 
 | 
			
		||||
@@ -740,7 +740,7 @@ rc_deptree_update(void)
 | 
			
		||||
	char *depend, *depends, *service, *type, *nosys, *onosys;
 | 
			
		||||
	size_t i, k, l;
 | 
			
		||||
	bool retval = true;
 | 
			
		||||
	const char *sys = NULL;
 | 
			
		||||
	const char *sys = rc_sys();
 | 
			
		||||
	struct utsname uts;
 | 
			
		||||
 | 
			
		||||
	/* Some init scripts need RC_LIBEXECDIR to source stuff
 | 
			
		||||
@@ -847,9 +847,6 @@ rc_deptree_update(void)
 | 
			
		||||
 | 
			
		||||
	/* Phase 2 - if we're a special system, remove services that don't
 | 
			
		||||
	 * work for them. This doesn't stop them from being run directly. */
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
		if (!sys)
 | 
			
		||||
			sys = detect_vm();
 | 
			
		||||
	if (sys) {
 | 
			
		||||
		len = strlen(sys);
 | 
			
		||||
		nosys = xmalloc(len + 2);
 | 
			
		||||
 
 | 
			
		||||
@@ -198,13 +198,9 @@ found:
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
rc_sys(void)
 | 
			
		||||
static const char *
 | 
			
		||||
get_systype(void)
 | 
			
		||||
{
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
	return RC_SYS_PREFIX;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	char *systype = rc_conf_value("rc_sys");
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		char *s = systype;
 | 
			
		||||
@@ -215,10 +211,37 @@ rc_sys(void)
 | 
			
		||||
			s++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return systype;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
detect_prefix(const char *systype)
 | 
			
		||||
{
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
	return RC_SYS_PREFIX;
 | 
			
		||||
#else
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_PREFIX) == 0)
 | 
			
		||||
			return RC_SYS_PREFIX;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
detect_container(const char *systype)
 | 
			
		||||
{
 | 
			
		||||
#ifdef __FreeBSD__
 | 
			
		||||
	if (systype && strcmp(systype, RC_SYS_JAIL) == 0)
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
		       return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_JAIL) == 0)
 | 
			
		||||
			return RC_SYS_JAIL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int jailed = 0;
 | 
			
		||||
	size_t len = sizeof(jailed);
 | 
			
		||||
 | 
			
		||||
@@ -227,25 +250,10 @@ rc_sys(void)
 | 
			
		||||
			return RC_SYS_JAIL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __NetBSD__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if(strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
				return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/kern/xen/privcmd"))
 | 
			
		||||
		return RC_SYS_XEN0;
 | 
			
		||||
	if (exists("/kern/xen"))
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_UML) == 0)
 | 
			
		||||
			return RC_SYS_UML;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_VSERVER) == 0)
 | 
			
		||||
@@ -261,11 +269,7 @@ rc_sys(void)
 | 
			
		||||
		if (strcmp(systype, RC_SYS_DOCKER) == 0)
 | 
			
		||||
				return RC_SYS_DOCKER;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/proc/xen")) {
 | 
			
		||||
		if (file_regex("/proc/xen/capabilities", "control_d"))
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
	} else if (file_regex("/proc/cpuinfo", "UML"))
 | 
			
		||||
	if (file_regex("/proc/cpuinfo", "UML"))
 | 
			
		||||
		return RC_SYS_UML;
 | 
			
		||||
	else if (file_regex("/proc/self/status",
 | 
			
		||||
		"(s_context|VxID):[[:space:]]*[1-9]"))
 | 
			
		||||
@@ -287,6 +291,61 @@ rc_sys(void)
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
detect_vm(const char *systype)
 | 
			
		||||
{
 | 
			
		||||
#ifdef __NetBSD__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/kern/xen/privcmd"))
 | 
			
		||||
		return RC_SYS_XEN0;
 | 
			
		||||
	if (exists("/kern/xen"))
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/proc/xen")) {
 | 
			
		||||
		if (file_regex("/proc/xen/capabilities", "control_d"))
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
rc_sys(void)
 | 
			
		||||
{
 | 
			
		||||
	const char *systype;
 | 
			
		||||
	const char *sys;
 | 
			
		||||
 | 
			
		||||
	systype = get_systype();
 | 
			
		||||
	sys = detect_prefix(systype);
 | 
			
		||||
	if (!sys) {
 | 
			
		||||
		sys = detect_container(systype);
 | 
			
		||||
		if (!sys) {
 | 
			
		||||
			sys = detect_vm(systype);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return sys;
 | 
			
		||||
}
 | 
			
		||||
librc_hidden_def(rc_sys)
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
 
 | 
			
		||||
@@ -318,6 +318,7 @@ bool rc_service_daemons_crashed(const char *);
 | 
			
		||||
 * Some services cannot work in these systems, or we do something else. */
 | 
			
		||||
#define RC_SYS_DOCKER  "DOCKER"
 | 
			
		||||
#define RC_SYS_JAIL    "JAIL"
 | 
			
		||||
#define RC_SYS_NONE    ""
 | 
			
		||||
#define RC_SYS_OPENVZ  "OPENVZ"
 | 
			
		||||
#define RC_SYS_LXC     "LXC"
 | 
			
		||||
#define RC_SYS_PREFIX  "PREFIX"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,9 @@
 | 
			
		||||
SRCS=	rc.c 	rc-logger.c rc-misc.c rc-plugin.c
 | 
			
		||||
SRCS=	checkpath.c do_e.c do_mark_service.c do_service.c \
 | 
			
		||||
		do_value.c fstabinfo.c is_newer_than.c is_older_than.c \
 | 
			
		||||
		mountinfo.c openrc-run.c rc-abort.c rc.c \
 | 
			
		||||
		rc-depend.c rc-logger.c rc-misc.c rc-plugin.c \
 | 
			
		||||
		rc-service.c rc-status.c rc-update.c \
 | 
			
		||||
		shell_var.c start-stop-daemon.c swclock.c _usage.c
 | 
			
		||||
 | 
			
		||||
ifeq (${MKSELINUX},yes)
 | 
			
		||||
SRCS+=		rc-selinux.c
 | 
			
		||||
@@ -75,7 +80,10 @@ check test::
 | 
			
		||||
 | 
			
		||||
all: ${ALL_PROGS}
 | 
			
		||||
 | 
			
		||||
checkpath: checkpath.o _usage.o rc-misc.o rc-selinux.o
 | 
			
		||||
checkpath: checkpath.o _usage.o rc-misc.o
 | 
			
		||||
ifeq (${MKSELINUX},yes)
 | 
			
		||||
checkpath: rc-selinux.o
 | 
			
		||||
endif
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
 | 
			
		||||
@@ -101,10 +109,13 @@ mark_service_hotplugged mark_service_failed: do_mark_service.o rc-misc.o
 | 
			
		||||
mountinfo: mountinfo.o _usage.o rc-misc.o
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o rc-selinux.o _usage.o
 | 
			
		||||
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
 | 
			
		||||
ifeq (${MKSELINUX},yes)
 | 
			
		||||
openrc-run runscript: rc-selinux.o
 | 
			
		||||
endif
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
rc-abort: rc-abort.o
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
@@ -46,10 +47,7 @@ _noreturn void show_version(void)
 | 
			
		||||
	const char *systype = NULL;
 | 
			
		||||
 | 
			
		||||
	printf("%s (OpenRC", applet);
 | 
			
		||||
	systype = detect_container();
 | 
			
		||||
	if (!systype)
 | 
			
		||||
		systype = detect_vm();
 | 
			
		||||
	if (systype)
 | 
			
		||||
	if ((systype = rc_sys()))
 | 
			
		||||
		printf(" [%s]", systype);
 | 
			
		||||
	printf(") %s", VERSION);
 | 
			
		||||
#ifdef BRANDING
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "einfo.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
#include "rc-selinux.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "einfo.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
const char *applet = NULL;
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										165
									
								
								src/rc/rc-misc.c
									
									
									
									
									
								
							
							
						
						
									
										165
									
								
								src/rc/rc-misc.c
									
									
									
									
									
								
							@@ -27,7 +27,6 @@
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#  include <regex.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
@@ -53,6 +52,7 @@ rc_conf_yesno(const char *setting)
 | 
			
		||||
static const char *const env_whitelist[] = {
 | 
			
		||||
	"EERROR_QUIET", "EINFO_QUIET",
 | 
			
		||||
	"IN_BACKGROUND", "IN_HOTPLUG",
 | 
			
		||||
	"LANG", "LC_MESSAGES", "TERM",
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -125,7 +125,7 @@ env_config(void)
 | 
			
		||||
	char *np;
 | 
			
		||||
	char *npp;
 | 
			
		||||
	char *tok;
 | 
			
		||||
	const char *sys = NULL;
 | 
			
		||||
	const char *sys = rc_sys();
 | 
			
		||||
	char buffer[PATH_MAX];
 | 
			
		||||
 | 
			
		||||
	/* Ensure our PATH is prefixed with the system locations first
 | 
			
		||||
@@ -176,9 +176,7 @@ env_config(void)
 | 
			
		||||
	} else
 | 
			
		||||
		setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1);
 | 
			
		||||
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
	if (sys)
 | 
			
		||||
		setenv("RC_SYS", sys, 1);
 | 
			
		||||
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
@@ -335,163 +333,6 @@ is_writable(const char *path)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool file_regex(const char *file, const char *regex)
 | 
			
		||||
{
 | 
			
		||||
	FILE *fp;
 | 
			
		||||
	char *line = NULL;
 | 
			
		||||
	size_t len = 0;
 | 
			
		||||
	regex_t re;
 | 
			
		||||
	bool retval = true;
 | 
			
		||||
	int result;
 | 
			
		||||
 | 
			
		||||
	if (!(fp = fopen(file, "r")))
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
	if ((result = regcomp(&re, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
 | 
			
		||||
		fclose(fp);
 | 
			
		||||
		line = xmalloc(sizeof(char) * BUFSIZ);
 | 
			
		||||
		regerror(result, &re, line, BUFSIZ);
 | 
			
		||||
		fprintf(stderr, "file_regex: %s", line);
 | 
			
		||||
		free(line);
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while ((rc_getline(&line, &len, fp))) {
 | 
			
		||||
		char *str = line;
 | 
			
		||||
		/* some /proc files have \0 separated content so we have to
 | 
			
		||||
		   loop through the 'line' */
 | 
			
		||||
		do {
 | 
			
		||||
			if (regexec(&re, str, 0, NULL, 0) == 0)
 | 
			
		||||
				goto found;
 | 
			
		||||
			str += strlen(str) + 1;
 | 
			
		||||
			/* len is the size of allocated buffer and we don't
 | 
			
		||||
			   want call regexec BUFSIZE times. find next str */
 | 
			
		||||
			while (str < line + len && *str == '\0')
 | 
			
		||||
				str++;
 | 
			
		||||
		} while (str < line + len);
 | 
			
		||||
	}
 | 
			
		||||
	retval = false;
 | 
			
		||||
found:
 | 
			
		||||
	fclose(fp);
 | 
			
		||||
	free(line);
 | 
			
		||||
	regfree(&re);
 | 
			
		||||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *detect_prefix(void)
 | 
			
		||||
{
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
	return RC_SYS_PREFIX;
 | 
			
		||||
#else
 | 
			
		||||
	return NULL;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *get_systype(void)
 | 
			
		||||
{
 | 
			
		||||
	char *systype = rc_conf_value("rc_sys");
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		char *s = systype;
 | 
			
		||||
		/* Convert to uppercase */
 | 
			
		||||
		while (s && *s) {
 | 
			
		||||
			if (islower((unsigned char) *s))
 | 
			
		||||
				*s = toupper((unsigned char) *s);
 | 
			
		||||
			s++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return systype;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *detect_container(void)
 | 
			
		||||
{
 | 
			
		||||
	const char *systype = get_systype();
 | 
			
		||||
 | 
			
		||||
#ifdef __FreeBSD__
 | 
			
		||||
	if (systype && strcmp(systype, RC_SYS_JAIL) == 0)
 | 
			
		||||
		return RC_SYS_JAIL;
 | 
			
		||||
	int jailed = 0;
 | 
			
		||||
	size_t len = sizeof(jailed);
 | 
			
		||||
 | 
			
		||||
	if (sysctlbyname("security.jail.jailed", &jailed, &len, NULL, 0) == 0)
 | 
			
		||||
		if (jailed == 1)
 | 
			
		||||
			return RC_SYS_JAIL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_UML) == 0)
 | 
			
		||||
			return RC_SYS_UML;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_VSERVER) == 0)
 | 
			
		||||
			return RC_SYS_VSERVER;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_OPENVZ) == 0)
 | 
			
		||||
			return RC_SYS_OPENVZ;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_LXC) == 0)
 | 
			
		||||
			return RC_SYS_LXC;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_RKT) == 0)
 | 
			
		||||
				return RC_SYS_RKT;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_SYSTEMD_NSPAWN) == 0)
 | 
			
		||||
				return RC_SYS_SYSTEMD_NSPAWN;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_DOCKER) == 0)
 | 
			
		||||
				return RC_SYS_DOCKER;
 | 
			
		||||
	}
 | 
			
		||||
	if (file_regex("/proc/cpuinfo", "UML"))
 | 
			
		||||
		return RC_SYS_UML;
 | 
			
		||||
	else if (file_regex("/proc/self/status",
 | 
			
		||||
		"(s_context|VxID):[[:space:]]*[1-9]"))
 | 
			
		||||
		return RC_SYS_VSERVER;
 | 
			
		||||
	else if (exists("/proc/vz/veinfo") && !exists("/proc/vz/version"))
 | 
			
		||||
		return RC_SYS_OPENVZ;
 | 
			
		||||
	else if (file_regex("/proc/self/status",
 | 
			
		||||
		"envID:[[:space:]]*[1-9]"))
 | 
			
		||||
		return RC_SYS_OPENVZ; /* old test */
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=lxc"))
 | 
			
		||||
		return RC_SYS_LXC;
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=rkt"))
 | 
			
		||||
		return RC_SYS_RKT;
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
 | 
			
		||||
		return RC_SYS_SYSTEMD_NSPAWN;
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=docker"))
 | 
			
		||||
		return RC_SYS_DOCKER;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *detect_vm(void)
 | 
			
		||||
{
 | 
			
		||||
	const char *systype = get_systype();
 | 
			
		||||
 | 
			
		||||
#ifdef __NetBSD__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if(strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
				return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/kern/xen/privcmd"))
 | 
			
		||||
		return RC_SYS_XEN0;
 | 
			
		||||
	if (exists("/kern/xen"))
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/proc/xen")) {
 | 
			
		||||
		if (file_regex("/proc/xen/capabilities", "control_d"))
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RC_DEPTREE * _rc_deptree_load(int force, int *regen)
 | 
			
		||||
{
 | 
			
		||||
	int fd;
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,6 @@
 | 
			
		||||
 *    except according to the terms contained in the LICENSE file.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_SELINUX
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <dlfcn.h>
 | 
			
		||||
@@ -386,5 +384,3 @@ out:
 | 
			
		||||
	free(run_init_t);
 | 
			
		||||
	free(curr_t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								src/rc/rc.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								src/rc/rc.c
									
									
									
									
									
								
							@@ -281,15 +281,10 @@ open_shell(void)
 | 
			
		||||
	struct passwd *pw;
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	const char *sys = NULL;
 | 
			
		||||
	const char *sys = rc_sys();
 | 
			
		||||
	
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
 | 
			
		||||
	/* VSERVER and OPENVZ systems cannot really drop to shells */
 | 
			
		||||
	if (sys &&
 | 
			
		||||
	    (strcmp(sys, "VSERVER") == 0 || strcmp(sys, "OPENVZ") == 0))
 | 
			
		||||
	/* VSERVER systems cannot really drop to shells */
 | 
			
		||||
	if (sys && strcmp(sys, RC_SYS_VSERVER) == 0)
 | 
			
		||||
	{
 | 
			
		||||
		execl("/sbin/halt", "/sbin/halt", "-f", (char *) NULL);
 | 
			
		||||
		eerrorx("%s: unable to exec `/sbin/halt': %s",
 | 
			
		||||
@@ -491,10 +486,7 @@ do_sysinit()
 | 
			
		||||
	    uts.machine);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
	if (sys)
 | 
			
		||||
	if ((sys = rc_sys()))
 | 
			
		||||
		printf(" [%s]", sys);
 | 
			
		||||
 | 
			
		||||
	printf("%s\n\n", ecolor(ECOLOR_NORMAL));
 | 
			
		||||
@@ -509,10 +501,7 @@ do_sysinit()
 | 
			
		||||
 | 
			
		||||
	/* init may have mounted /proc so we can now detect or real
 | 
			
		||||
	 * sys */
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
	if (sys)
 | 
			
		||||
	if ((sys = rc_sys()))
 | 
			
		||||
		setenv("RC_SYS", sys, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -832,9 +821,7 @@ int main(int argc, char **argv)
 | 
			
		||||
			eerrorx("%s: %s", applet, strerror(errno));
 | 
			
		||||
			/* NOTREACHED */
 | 
			
		||||
		case 'S':
 | 
			
		||||
			systype = detect_container();
 | 
			
		||||
			if (!systype)
 | 
			
		||||
				systype = detect_vm();
 | 
			
		||||
			systype = rc_sys();
 | 
			
		||||
			if (systype)
 | 
			
		||||
				printf("%s\n", systype);
 | 
			
		||||
			exit(EXIT_SUCCESS);
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@
 | 
			
		||||
#include <utime.h>
 | 
			
		||||
 | 
			
		||||
#include "einfo.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user