#include "pager.h"
#include "set.h"
#include "path-util.h"
+#include "utf8.h"
static bool arg_no_pager = false;
static enum transport {
const char *interface = "";
int r;
DBusMessageIter iter, sub, sub2, sub3;
- StatusInfo info;
+ StatusInfo info = {};
assert(args);
return -EIO;
}
- zero(info);
dbus_message_iter_recurse(&iter, &sub);
while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
if (e[i].locrec_offset == 0)
continue;
+ if (!utf8_is_valid((char*) p + e[i].name_offset))
+ continue;
+
z = strdup((char*) p + e[i].name_offset);
if (!z) {
r = log_oom();
goto finish;
}
- r = set_put(locales, z);
+ r = set_consume(locales, z);
if (r < 0) {
- free(z);
log_error("Failed to add locale: %s", strerror(-r));
goto finish;
}
}
static int add_locales_from_libdir (Set *locales) {
- DIR _cleanup_closedir_ *dir;
+ _cleanup_closedir_ DIR *dir;
struct dirent *entry;
int r;
if (!z)
return log_oom();
- r = set_put(locales, z);
- if (r < 0) {
- free(z);
-
- if (r != -EEXIST) {
- log_error("Failed to add locale: %s", strerror(-r));
- return r;
- }
+ r = set_consume(locales, z);
+ if (r < 0 && r != -EEXIST) {
+ log_error("Failed to add locale: %s", strerror(-r));
+ return r;
}
errno = 0;
if (e)
*e = 0;
- r = set_put(keymaps, p);
- if (r == -EEXIST)
- free(p);
- else if (r < 0) {
+ r = set_consume(keymaps, p);
+ if (r < 0 && r != -EEXIST) {
log_error("Can't add keymap: %s", strerror(-r));
- free(p);
return r;
}
}
static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) {
- char _cleanup_strv_free_ **l = NULL;
+ _cleanup_strv_free_ char **l = NULL;
keymaps = set_new(string_hash_func, string_compare_func);
if (!keymaps)
static int list_x11_keymaps(DBusConnection *bus, char **args, unsigned n) {
_cleanup_fclose_ FILE *f = NULL;
- char _cleanup_strv_free_ **list = NULL;
+ _cleanup_strv_free_ char **list = NULL;
char line[LINE_MAX];
enum {
NONE,
return -EINVAL;
}
- f = fopen("/usr/share/X11/xkb/rules/xorg.lst", "re");
+ f = fopen("/usr/share/X11/xkb/rules/base.lst", "re");
if (!f) {
log_error("Failed to open keyboard mapping list. %m");
return -errno;
" --version Show package version\n"
" --no-convert Don't convert keyboard mappings\n"
" --no-pager Do not pipe output into a pager\n"
+ " -P --privileged Acquire privileges before execution\n"
" --no-ask-password Do not prompt for password\n"
" -H --host=[USER@]HOST Operate on remote host\n\n"
"Commands:\n"