]>
Commit | Line | Data |
---|---|---|
f06261ce | 1 | ; rest of target-pld.patch logic in systemd.spec |
808bb44c JK |
2 | diff -dur -x '*~' -x '*.orig' systemd-208.orig/src/core/hostname-setup.c systemd-208/src/core/hostname-setup.c |
3 | --- systemd-208.orig/src/core/hostname-setup.c 2013-08-13 22:02:46.000000000 +0200 | |
4 | +++ systemd-208/src/core/hostname-setup.c 2014-01-09 15:15:41.000000000 +0100 | |
c75f826c AM |
5 | @@ -23,6 +23,7 @@ |
6 | ||
7 | #include "alloc-util.h" | |
8 | #include "fileio.h" | |
9 | +#include "fd-util.h" | |
10 | #include "hostname-setup.h" | |
11 | #include "hostname-util.h" | |
12 | #include "log.h" | |
808bb44c | 13 | @@ -53,13 +53,84 @@ |
da7cff0c JR |
14 | return 0; |
15 | } | |
4d29e184 | 16 | |
da7cff0c JR |
17 | +static int read_distro_hostname(char **hn) { |
18 | + int r; | |
19 | + _cleanup_fclose_ FILE *f = NULL; | |
20 | + | |
21 | + assert(hn); | |
22 | + | |
23 | + f = fopen("/etc/sysconfig/network", "re"); | |
24 | + if (!f) | |
25 | + return -errno; | |
26 | + | |
27 | + for (;;) { | |
28 | + char line[LINE_MAX]; | |
29 | + char *s, *k; | |
30 | + | |
31 | + if (!fgets(line, sizeof(line), f)) { | |
32 | + if (feof(f)) | |
33 | + break; | |
34 | + | |
35 | + r = -errno; | |
36 | + goto finish; | |
37 | + } | |
38 | + | |
39 | + s = strstrip(line); | |
40 | + | |
41 | + if (!startswith_no_case(s, "HOSTNAME=")) | |
42 | + continue; | |
43 | + | |
44 | + k = strdup(s+9); | |
45 | + if (!k) { | |
46 | + r = -ENOMEM; | |
47 | + goto finish; | |
48 | + } | |
49 | + | |
c75f826c | 50 | + hostname_cleanup(k); |
da7cff0c JR |
51 | + |
52 | + if (isempty(k)) { | |
53 | + free(k); | |
54 | + r = -ENOENT; | |
55 | + goto finish; | |
56 | + } | |
57 | + | |
58 | + *hn = k; | |
59 | + r = 0; | |
60 | + goto finish; | |
61 | + } | |
62 | + | |
63 | + r = -ENOENT; | |
64 | + | |
65 | +finish: | |
66 | + return r; | |
67 | +} | |
68 | + | |
69 | +static int read_hostname(char **hn) { | |
70 | + int r; | |
71 | + | |
72 | + assert(hn); | |
73 | + | |
74 | + /* First, try to load the generic hostname configuration file, | |
75 | + * that we support on all distributions */ | |
76 | + | |
7edc5189 | 77 | + r = read_hostname_config("/etc/hostname", hn); |
da7cff0c JR |
78 | + if (r < 0) { |
79 | + if (r == -ENOENT) | |
80 | + return read_distro_hostname(hn); | |
81 | + | |
82 | + return r; | |
83 | + } | |
84 | + | |
85 | + return 0; | |
86 | +} | |
87 | + | |
88 | int hostname_setup(void) { | |
da7cff0c | 89 | _cleanup_free_ char *b = NULL; |
da7cff0c | 90 | bool enoent = false; |
8e27187e AM |
91 | const char *hn; |
92 | int r; | |
4d29e184 | 93 | |
7edc5189 | 94 | - r = read_hostname_config("/etc/hostname", &b); |
da7cff0c JR |
95 | + r = read_hostname(&b); |
96 | if (r < 0) { | |
97 | if (r == -ENOENT) | |
98 | enoent = true; | |
808bb44c JK |
99 | diff -dur -x '*~' -x '*.orig' systemd-208.orig/src/core/locale-setup.c systemd-208/src/core/locale-setup.c |
100 | --- systemd-208.orig/src/core/locale-setup.c 2013-10-01 00:17:21.000000000 +0200 | |
101 | +++ systemd-208/src/core/locale-setup.c 2014-01-09 15:15:41.000000000 +0100 | |
102 | @@ -76,6 +76,7 @@ | |
4d29e184 | 103 | |
da7cff0c JR |
104 | if (detect_container(NULL) <= 0) { |
105 | r = parse_env_file("/proc/cmdline", WHITESPACE, | |
106 | + "LANG", &variables[VARIABLE_LANG], | |
107 | "locale.LANG", &variables[VARIABLE_LANG], | |
108 | "locale.LANGUAGE", &variables[VARIABLE_LANGUAGE], | |
109 | "locale.LC_CTYPE", &variables[VARIABLE_LC_CTYPE], | |
808bb44c | 110 | @@ -120,6 +121,15 @@ |
4d29e184 BZ |
111 | log_warning("Failed to read /etc/locale.conf: %s", strerror(-r)); |
112 | } | |
113 | ||
da7cff0c JR |
114 | + if (r <= 0 && |
115 | + (r = parse_env_file("/etc/sysconfig/i18n", NEWLINE, | |
116 | + "LANG", &variables[VARIABLE_LANG], | |
117 | + NULL)) < 0) { | |
118 | + | |
119 | + if (r != -ENOENT) | |
120 | + log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r)); | |
121 | + } | |
122 | + | |
3d025d25 | 123 | add = NULL; |
11fa1d33 | 124 | for (i = 0; i < _VARIABLE_MAX; i++) { |
808bb44c | 125 | char *s; |
c75f826c AM |
126 | --- a/src/basic/time-util.c~ 2016-11-03 18:16:42.000000000 +0100 |
127 | +++ b/src/basic/time-util.c 2016-11-12 19:54:28.457197174 +0100 | |
128 | @@ -1290,8 +1290,16 @@ int get_timezone(char **tz) { | |
129 | e = path_startswith(t, "/usr/share/zoneinfo/"); | |
130 | if (!e) | |
131 | e = path_startswith(t, "../usr/share/zoneinfo/"); | |
132 | - if (!e) | |
133 | - return -EINVAL; | |
134 | + if (!e) { | |
135 | + r = parse_env_file("/etc/sysconfig/timezone", NEWLINE, | |
136 | + "TIMEZONE", &e, | |
137 | + NULL); | |
138 | + if (r < 0) { | |
139 | + if (r != -ENOENT) | |
140 | + log_warning("Failed to read /etc/sysconfig/timezone: %s", strerror(-r)); | |
141 | + return -EINVAL; | |
142 | + } | |
143 | + } | |
a2211e27 | 144 | |
c75f826c AM |
145 | if (!timezone_is_valid(e)) |
146 | return -EINVAL; | |
808bb44c JK |
147 | diff -dur -x '*~' -x '*.orig' systemd-208.orig/src/vconsole/vconsole-setup.c systemd-208/src/vconsole/vconsole-setup.c |
148 | --- systemd-208.orig/src/vconsole/vconsole-setup.c 2013-08-13 22:02:47.000000000 +0200 | |
149 | +++ systemd-208/src/vconsole/vconsole-setup.c 2014-01-09 15:17:49.000000000 +0100 | |
abea5afb AM |
150 | @@ -284,6 +284,17 @@ int main(int argc, char **argv) { |
151 | if (r < 0 && r != -ENOENT) | |
152 | log_warning("Failed to read /etc/vconsole.conf: %s", strerror(-r)); | |
808bb44c | 153 | |
d31498aa | 154 | + if (r <= 0) { |
abea5afb AM |
155 | + int r1 = parse_env_file("/etc/sysconfig/console", NEWLINE, |
156 | + "CONSOLEFONT", &vc_font, | |
157 | + "CONSOLEMAP", &vc_font_map, | |
158 | + "CONSOLESCREENFONTMAP", &vc_font_unimap, | |
159 | + "KEYTABLE", &vc_keymap, | |
160 | + NULL); | |
808bb44c JK |
161 | + if (r1 < 0 && r1 != -ENOENT) |
162 | + log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r1)); | |
abea5afb | 163 | + } |
808bb44c | 164 | + |
abea5afb AM |
165 | /* Let the kernel command line override /etc/vconsole.conf */ |
166 | if (detect_container(NULL) <= 0) { | |
167 | r = parse_env_file("/proc/cmdline", WHITESPACE, |