mirror of
https://github.com/systemd/systemd.git
synced 2025-08-31 09:49:54 +03:00
container: skip a few things when we are run in a container such as accessing /proc/cmdline
This commit is contained in:
@ -67,6 +67,9 @@ static bool test_kernel_command_line(const char *parameter) {
|
|||||||
|
|
||||||
assert(parameter);
|
assert(parameter);
|
||||||
|
|
||||||
|
if (detect_virtualization(NULL) > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
|
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
|
||||||
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
|
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
|
||||||
return false;
|
return false;
|
||||||
|
@ -106,6 +106,9 @@ static int parse_proc_cmdline(void) {
|
|||||||
int r;
|
int r;
|
||||||
size_t l;
|
size_t l;
|
||||||
|
|
||||||
|
if (detect_virtualization(NULL) > 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
|
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
|
||||||
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
|
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -69,6 +69,7 @@ int locale_setup(void) {
|
|||||||
|
|
||||||
zero(variables);
|
zero(variables);
|
||||||
|
|
||||||
|
if (detect_virtualization(NULL) <= 0)
|
||||||
if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
|
if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
|
||||||
#ifdef TARGET_FEDORA
|
#ifdef TARGET_FEDORA
|
||||||
"LANG", &variables[VARIABLE_LANG],
|
"LANG", &variables[VARIABLE_LANG],
|
||||||
|
@ -35,6 +35,9 @@ static int parse_proc_cmdline(void) {
|
|||||||
int r;
|
int r;
|
||||||
size_t l;
|
size_t l;
|
||||||
|
|
||||||
|
if (detect_virtualization(NULL) > 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
|
if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
|
||||||
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
|
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,6 +92,9 @@ static int target_add_getty_dependencies(Target *t) {
|
|||||||
if (!unit_has_name(UNIT(t), SPECIAL_GETTY_TARGET))
|
if (!unit_has_name(UNIT(t), SPECIAL_GETTY_TARGET))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (detect_container(NULL) > 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
|
if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
|
||||||
const char *tty;
|
const char *tty;
|
||||||
|
|
||||||
|
@ -176,6 +176,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
utf8 = is_locale_utf8();
|
utf8 = is_locale_utf8();
|
||||||
|
|
||||||
|
if (detect_virtualization(NULL) <= 0)
|
||||||
if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
|
if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
|
||||||
#ifdef TARGET_FEDORA
|
#ifdef TARGET_FEDORA
|
||||||
"SYSFONT", &vc_font,
|
"SYSFONT", &vc_font,
|
||||||
|
Reference in New Issue
Block a user