[systemd-commits] 6 commits - Makefile.am src/core src/rc-local-generator src/shared src/systemctl src/vconsole
Lennart Poettering
lennart at kemper.freedesktop.org
Thu May 3 07:31:11 PDT 2012
Makefile.am | 16 -
src/core/dbus-manager.c | 14 -
src/rc-local-generator/rc-local-generator.c | 20 +
src/shared/util.c | 3
src/systemctl/systemctl.c | 19 +
src/vconsole/vconsole-setup.c | 285 +++++++++++++---------------
6 files changed, 172 insertions(+), 185 deletions(-)
New commits:
commit 3beddc7861783347eb0aaf5fa492e8b2aef9e691
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 3 16:29:15 2012 +0200
systemctl: allow 'systemctl reboot -ff' to succeed even without D-Bus
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index cbe6848..681ad8c 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1783,7 +1783,6 @@ static int start_special(DBusConnection *bus, char **args) {
enum action a;
int r;
- assert(bus);
assert(args);
a = verb_to_action(args[0]);
@@ -5204,7 +5203,9 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
return 0;
}
- if (!bus) {
+ if (((!streq(verbs[i].verb, "reboot") &&
+ !streq(verbs[i].verb, "halt") &&
+ !streq(verbs[i].verb, "reboot")) || arg_force <= 0) && !bus) {
log_error("Failed to get D-Bus connection: %s",
dbus_error_is_set(error) ? error->message : "No connection to service manager.");
return -EIO;
commit c32b90dec78afe0db51ff0afa6448c01524105fa
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 3 16:17:58 2012 +0200
systemctl: print a nice error message if an unprivileged user calls systemctl reboot -ff
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index e2550ad..cbe6848 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1788,6 +1788,11 @@ static int start_special(DBusConnection *bus, char **args) {
a = verb_to_action(args[0]);
+ if (arg_force >= 2 && geteuid() != 0) {
+ log_error("Must be root.");
+ return -EPERM;
+ }
+
if (arg_force >= 2 &&
(a == ACTION_HALT ||
a == ACTION_POWEROFF ||
commit 65491fd8c993a0e5cbc275613babcac98f4cd7bd
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 3 16:17:39 2012 +0200
systemctl: get rid of arg_immediate and fold it into arg_force
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index d57e093..e2550ad 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -67,7 +67,6 @@ static char **arg_property = NULL;
static bool arg_all = false;
static const char *arg_job_mode = "replace";
static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
-static bool arg_immediate = false;
static bool arg_no_block = false;
static bool arg_no_legend = false;
static bool arg_no_pager = false;
@@ -4525,7 +4524,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
if (utmp_get_runlevel(&runlevel, NULL) >= 0)
if (runlevel == '0' || runlevel == '6')
- arg_immediate = true;
+ arg_force = 2;
while ((c = getopt_long(argc, argv, "pfwdnih", options, NULL)) >= 0) {
switch (c) {
@@ -4548,7 +4547,7 @@ static int halt_parse_argv(int argc, char *argv[]) {
break;
case 'f':
- arg_immediate = true;
+ arg_force = 2;
break;
case 'w':
@@ -5350,7 +5349,7 @@ static int halt_main(DBusConnection *bus) {
if (arg_when <= 0 &&
!arg_dry &&
- !arg_immediate &&
+ !arg_force &&
(arg_action == ACTION_POWEROFF ||
arg_action == ACTION_REBOOT)) {
r = reboot_with_logind(bus, arg_action);
@@ -5387,7 +5386,7 @@ static int halt_main(DBusConnection *bus) {
}
}
- if (!arg_dry && !arg_immediate)
+ if (!arg_dry && !arg_force)
return start_with_fallback(bus);
if (!arg_no_wtmp) {
commit 04b6f7c1a7ba7e7baef99b2b0db9842864c0ff82
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 3 15:55:38 2012 +0200
rc-local-generator: hook halt-local in based on generator too
diff --git a/Makefile.am b/Makefile.am
index e1501ae..fd08001 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3166,10 +3166,6 @@ if TARGET_MEEGO
endif
if TARGET_FEDORA
- $(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
- ( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
- rm -f halt-local.service && \
- $(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
( cd $(DESTDIR)$(systemunitdir) && \
rm -f display-manager.service single.service && \
$(LN_S) prefdm.service display-manager.service && \
@@ -3180,10 +3176,6 @@ if TARGET_FEDORA
endif
if TARGET_MANDRIVA
- $(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
- ( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
- rm -f halt-local.service && \
- $(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
( cd $(DESTDIR)$(systemunitdir) && \
rm -f display-manager.service dm.service single.service && \
$(LN_S) prefdm.service display-manager.service && \
@@ -3201,20 +3193,12 @@ if TARGET_DEBIAN_OR_UBUNTU
endif
if TARGET_SUSE
- $(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
( cd $(DESTDIR)$(systemunitdir) && \
rm -f local.service && \
$(LN_S) rc-local.service local.service )
- ( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
- rm -f halt-local.service && \
- $(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
endif
if TARGET_MAGEIA
- $(MKDIR_P) -m 0755 $(DESTDIR)$(systemunitdir)/final.target.wants
- ( cd $(DESTDIR)$(systemunitdir)/final.target.wants && \
- rm -f halt-local.service && \
- $(LN_S) $(systemunitdir)/halt-local.service halt-local.service )
( cd $(DESTDIR)$(systemunitdir) && \
rm -f display-manager.service && \
$(LN_S) prefdm.service display-manager.service && \
diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c
index 42d7ae4..a5987f9 100644
--- a/src/rc-local-generator/rc-local-generator.c
+++ b/src/rc-local-generator/rc-local-generator.c
@@ -29,21 +29,23 @@
#include "mkdir.h"
#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA)
-#define SCRIPT_PATH "/etc/rc.d/rc.local"
+#define SCRIPT_PATH_START "/etc/rc.d/rc.local"
#elif defined(TARGET_SUSE)
-#define SCRIPT_PATH "/etc/init.d/boot.local"
+#define SCRIPT_PATH_START "/etc/init.d/boot.local"
#endif
+#define SCRIPT_PATH_STOP "/sbin/halt.local"
+
const char *arg_dest = "/tmp";
-static int add_symlink(const char *service) {
+static int add_symlink(const char *service, const char *where) {
char *from = NULL, *to = NULL;
int r;
assert(service);
asprintf(&from, SYSTEM_DATA_UNIT_PATH "/%s", service);
- asprintf(&to, "%s/multi-user.target.wants/%s", arg_dest, service);
+ asprintf(&to, "%s/%s.wants/%s", arg_dest, where, service);
if (!from || !to) {
log_error("Out of memory");
@@ -96,12 +98,18 @@ int main(int argc, char *argv[]) {
if (argc > 1)
arg_dest = argv[1];
- if (file_is_executable(SCRIPT_PATH)) {
+ if (file_is_executable(SCRIPT_PATH_START)) {
log_debug("Automatically adding rc-local.service.");
- if (add_symlink("rc-local.service") < 0)
+ if (add_symlink("rc-local.service", "multi-user.target") < 0)
r = EXIT_FAILURE;
+ }
+ if (file_is_executable(SCRIPT_PATH_STOP)) {
+ log_debug("Automatically adding halt-local.service.");
+
+ if (add_symlink("halt-local.service", "final.target") < 0)
+ r = EXIT_FAILURE;
}
return r;
commit e677bf7ef610acdc5068b9d5d4c79556a236e52f
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 3 15:46:04 2012 +0200
hwclock: add taint flag for non-local hwclock
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 770fce1..6655f29 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -294,17 +294,23 @@ static int bus_manager_append_tainted(DBusMessageIter *i, const char *property,
assert(m);
if (m->taint_usr)
- e = stpcpy(e, "usr-separate-fs ");
+ e = stpcpy(e, "split-usr:");
if (readlink_malloc("/etc/mtab", &p) < 0)
- e = stpcpy(e, "etc-mtab-not-symlink ");
+ e = stpcpy(e, "mtab-not-symlink:");
else
free(p);
if (access("/proc/cgroups", F_OK) < 0)
- stpcpy(e, "cgroups-missing ");
+ stpcpy(e, "cgroups-missing:");
- t = strstrip(buf);
+ if (hwclock_is_localtime() > 0)
+ stpcpy(e, "local-hwclock:");
+
+ if (endswith(buf, ":"))
+ buf[strlen(buf)-1] = 0;
+
+ t = buf;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
return -ENOMEM;
diff --git a/src/shared/util.c b/src/shared/util.c
index ba24562..fd2c5b0 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5001,7 +5001,6 @@ int hwclock_is_localtime(void) {
if (!b)
return -EIO;
-
truncate_nl(line);
local = streq(line, "LOCAL");
@@ -5136,7 +5135,7 @@ int hwclock_get_time(struct tm *tm) {
if (ioctl(fd, RTC_RD_TIME, tm) < 0)
err = -errno;
- /* We don't now daylight saving, so we reset this in order not
+ /* We don't know daylight saving, so we reset this in order not
* to confused mktime(). */
tm->tm_isdst = -1;
commit 741f8cf6b986ef21bbdf88d538a1d40449ef21ae
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu May 3 15:10:09 2012 +0200
vconsole: fix some error messages
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index b750050..d04fab4 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -70,11 +70,12 @@ static int disable_utf8(int fd) {
if (loop_write(fd, "\033%@", 3, false) < 0)
r = -errno;
- if ((k = write_one_line_file("/sys/module/vt/parameters/default_utf8", "0")) < 0)
+ k = write_one_line_file("/sys/module/vt/parameters/default_utf8", "0");
+ if (k < 0)
r = k;
if (r < 0)
- log_warning("Failed to disable UTF-8: %s", strerror(errno));
+ log_warning("Failed to disable UTF-8: %s", strerror(-r));
return r;
}
@@ -101,7 +102,8 @@ static int load_keymap(const char *vc, const char *map, const char *map_toggle,
args[i++] = map_toggle;
args[i++] = NULL;
- if ((pid = fork()) < 0) {
+ pid = fork();
+ if (pid < 0) {
log_error("Failed to fork: %m");
return -errno;
} else if (pid == 0) {
@@ -138,7 +140,8 @@ static int load_font(const char *vc, const char *font, const char *map, const ch
}
args[i++] = NULL;
- if ((pid = fork()) < 0) {
+ pid = fork();
+ if (pid < 0) {
log_error("Failed to fork: %m");
return -errno;
} else if (pid == 0) {
@@ -179,7 +182,8 @@ int main(int argc, char **argv) {
else
vc = "/dev/tty0";
- if ((fd = open_terminal(vc, O_RDWR|O_CLOEXEC)) < 0) {
+ fd = open_terminal(vc, O_RDWR|O_CLOEXEC);
+ if (fd < 0) {
log_error("Failed to open %s: %m", vc);
goto finish;
}
@@ -201,59 +205,56 @@ int main(int argc, char **argv) {
r = 0;
- if (detect_container(NULL) <= 0)
- if ((r = parse_env_file("/proc/cmdline", WHITESPACE,
- "vconsole.keymap", &vc_keymap,
- "vconsole.keymap.toggle", &vc_keymap_toggle,
- "vconsole.font", &vc_font,
- "vconsole.font.map", &vc_font_map,
- "vconsole.font.unimap", &vc_font_unimap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
- }
+ if (detect_container(NULL) <= 0) {
+ r = parse_env_file("/proc/cmdline", WHITESPACE,
+ "vconsole.keymap", &vc_keymap,
+ "vconsole.keymap.toggle", &vc_keymap_toggle,
+ "vconsole.font", &vc_font,
+ "vconsole.font.map", &vc_font_map,
+ "vconsole.font.unimap", &vc_font_unimap,
+ NULL);
+
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /proc/cmdline: %s", strerror(-r));
+ }
/* Hmm, nothing set on the kernel cmd line? Then let's
* try /etc/vconsole.conf */
- if (r <= 0 &&
- (r = parse_env_file("/etc/vconsole.conf", NEWLINE,
- "KEYMAP", &vc_keymap,
- "KEYMAP_TOGGLE", &vc_keymap_toggle,
- "FONT", &vc_font,
- "FONT_MAP", &vc_font_map,
- "FONT_UNIMAP", &vc_font_unimap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
+ if (r <= 0) {
+ r = parse_env_file("/etc/vconsole.conf", NEWLINE,
+ "KEYMAP", &vc_keymap,
+ "KEYMAP_TOGGLE", &vc_keymap_toggle,
+ "FONT", &vc_font,
+ "FONT_MAP", &vc_font_map,
+ "FONT_UNIMAP", &vc_font_unimap,
+ NULL);
+
+ if (r < 0 && r != -ENOENT)
log_warning("Failed to read /etc/vconsole.conf: %s", strerror(-r));
}
if (r <= 0) {
#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
- if ((r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
- "SYSFONT", &vc_font,
- "SYSFONTACM", &vc_font_map,
- "UNIMAP", &vc_font_unimap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
- }
-
- if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
- "KEYTABLE", &vc_keymap,
- "KEYMAP", &vc_keymap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
+ "SYSFONT", &vc_font,
+ "SYSFONTACM", &vc_font_map,
+ "UNIMAP", &vc_font_unimap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
+
+ r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
+ "KEYTABLE", &vc_keymap,
+ "KEYMAP", &vc_keymap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
if (access("/etc/sysconfig/console/default.kmap", F_OK) >= 0) {
char *t;
- if (!(t = strdup("/etc/sysconfig/console/default.kmap"))) {
+ t = strdup("/etc/sysconfig/console/default.kmap");
+ if (!t) {
log_error("Out of memory.");
goto finish;
}
@@ -263,79 +264,68 @@ int main(int argc, char **argv) {
}
#elif defined(TARGET_SUSE)
- if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
- "KEYTABLE", &vc_keymap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
- }
-
- if ((r = parse_env_file("/etc/sysconfig/console", NEWLINE,
- "CONSOLE_FONT", &vc_font,
- "CONSOLE_SCREENMAP", &vc_font_map,
- "CONSOLE_UNICODEMAP", &vc_font_unimap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
+ "KEYTABLE", &vc_keymap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
+
+ r = parse_env_file("/etc/sysconfig/console", NEWLINE,
+ "CONSOLE_FONT", &vc_font,
+ "CONSOLE_SCREENMAP", &vc_font_map,
+ "CONSOLE_UNICODEMAP", &vc_font_unimap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r));
#elif defined(TARGET_ARCH)
- if ((r = parse_env_file("/etc/rc.conf", NEWLINE,
- "KEYMAP", &vc_keymap,
- "CONSOLEFONT", &vc_font,
- "CONSOLEMAP", &vc_font_map,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/rc.conf: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/rc.conf", NEWLINE,
+ "KEYMAP", &vc_keymap,
+ "CONSOLEFONT", &vc_font,
+ "CONSOLEMAP", &vc_font_map,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/rc.conf: %s", strerror(-r));
#elif defined(TARGET_FRUGALWARE)
- if ((r = parse_env_file("/etc/sysconfig/keymap", NEWLINE,
- "keymap", &vc_keymap,
- NULL)) < 0) {
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/keymap: %s", strerror(-r));
- }
- if ((r = parse_env_file("/etc/sysconfig/font", NEWLINE,
- "font", &vc_font,
- NULL)) < 0) {
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/font: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/sysconfig/keymap", NEWLINE,
+ "keymap", &vc_keymap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/keymap: %s", strerror(-r));
+
+ r = parse_env_file("/etc/sysconfig/font", NEWLINE,
+ "font", &vc_font,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/font: %s", strerror(-r));
#elif defined(TARGET_ALTLINUX)
- if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
- "KEYTABLE", &vc_keymap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
- }
-
- if ((r = parse_env_file("/etc/sysconfig/consolefont", NEWLINE,
- "SYSFONT", &vc_font,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/consolefont: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
+ "KEYTABLE", &vc_keymap,
+ NULL)
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
+
+ r = parse_env_file("/etc/sysconfig/consolefont", NEWLINE,
+ "SYSFONT", &vc_font,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/consolefont: %s", strerror(-r));
#elif defined(TARGET_GENTOO)
- if ((r = parse_env_file("/etc/rc.conf", NEWLINE,
- "unicode", &vc_unicode,
- NULL)) < 0) {
- if (r != -ENOENT)
- log_warning("Failed to read /etc/rc.conf: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/rc.conf", NEWLINE,
+ "unicode", &vc_unicode,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/rc.conf: %s", strerror(-r));
if (vc_unicode) {
int rc_unicode;
- if ((rc_unicode = parse_boolean(vc_unicode)) < 0)
- log_error("Unknown value for /etc/rc.conf unicode=%s", vc_unicode);
+ rc_unicode = parse_boolean(vc_unicode);
+ if (rc_unicode < 0)
+ log_warning("Unknown value for /etc/rc.conf unicode=%s", vc_unicode);
else {
if (rc_unicode && !utf8)
log_warning("/etc/rc.conf wants unicode, but current locale is not UTF-8 capable!");
@@ -351,58 +341,52 @@ int main(int argc, char **argv) {
* contents are lowercase. the existing
* /etc/init.d/consolefont tries both
*/
- if ((r = parse_env_file("/etc/conf.d/consolefont", NEWLINE,
- "CONSOLEFONT", &vc_font,
- "consolefont", &vc_font,
- "consoletranslation", &vc_font_map,
- "CONSOLETRANSLATION", &vc_font_map,
- "unicodemap", &vc_font_unimap,
- "UNICODEMAP", &vc_font_unimap,
- NULL)) < 0) {
- if (r != -ENOENT)
- log_warning("Failed to read /etc/conf.d/consolefont: %s", strerror(-r));
- }
-
- if ((r = parse_env_file("/etc/conf.d/keymaps", NEWLINE,
- "keymap", &vc_keymap,
- "KEYMAP", &vc_keymap,
- NULL)) < 0) {
- if (r != -ENOENT)
- log_warning("Failed to read /etc/conf.d/keymaps: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/conf.d/consolefont", NEWLINE,
+ "CONSOLEFONT", &vc_font,
+ "consolefont", &vc_font,
+ "consoletranslation", &vc_font_map,
+ "CONSOLETRANSLATION", &vc_font_map,
+ "unicodemap", &vc_font_unimap,
+ "UNICODEMAP", &vc_font_unimap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/conf.d/consolefont: %s", strerror(-r));
+
+ r = parse_env_file("/etc/conf.d/keymaps", NEWLINE,
+ "keymap", &vc_keymap,
+ "KEYMAP", &vc_keymap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/conf.d/keymaps: %s", strerror(-r));
#elif defined(TARGET_MANDRIVA) || defined (TARGET_MAGEIA)
- if ((r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
- "SYSFONT", &vc_font,
- "SYSFONTACM", &vc_font_map,
- "UNIMAP", &vc_font_unimap,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
- }
-
- if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
- "KEYTABLE", &vc_keytable,
- "KEYMAP", &vc_keymap,
- "UNIKEYTABLE", &vc_keymap,
- "GRP_TOGGLE", &vc_keymap_toggle,
- NULL)) < 0) {
-
- if (r != -ENOENT)
- log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
- }
+ r = parse_env_file("/etc/sysconfig/i18n", NEWLINE,
+ "SYSFONT", &vc_font,
+ "SYSFONTACM", &vc_font_map,
+ "UNIMAP", &vc_font_unimap,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/i18n: %s", strerror(-r));
+
+ r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
+ "KEYTABLE", &vc_keytable,
+ "KEYMAP", &vc_keymap,
+ "UNIKEYTABLE", &vc_keymap,
+ "GRP_TOGGLE", &vc_keymap_toggle,
+ NULL);
+ if (r < 0 && r != -ENOENT)
+ log_warning("Failed to read /etc/sysconfig/keyboard: %s", strerror(-r));
if (vc_keytable) {
- if (vc_keymap)
- free(vc_keymap);
+ free(vc_keymap);
if (utf8) {
if (endswith(vc_keytable, ".uni") || strstr(vc_keytable, ".uni."))
vc_keymap = strdup(vc_keytable);
else {
char *s;
- if ((s = strstr(vc_keytable, ".map")))
+ s = strstr(vc_keytable, ".map");
+ if (s)
vc_keytable[s-vc_keytable+1] = '\0';
vc_keymap = strappend(vc_keytable, ".uni");
}
@@ -420,7 +404,8 @@ int main(int argc, char **argv) {
if (access("/etc/sysconfig/console/default.kmap", F_OK) >= 0) {
char *t;
- if (!(t = strdup("/etc/sysconfig/console/default.kmap"))) {
+ t = strdup("/etc/sysconfig/console/default.kmap");
+ if (!t) {
log_error("Out of memory.");
goto finish;
}
More information about the systemd-commits
mailing list