Features:
+* fix CUPS .path unit for globbing
+
* move PAM code into its own binary
* logind: ensure ACLs are updated on login and logout
static int get_group_creds(const char *groupname, gid_t *gid) {
struct group *g;
- unsigned long lu;
+ gid_t id;
assert(groupname);
assert(gid);
return 0;
}
- if (safe_atolu(groupname, &lu) >= 0) {
+ if (parse_gid(groupname, &id) >= 0) {
errno = 0;
- g = getgrgid((gid_t) lu);
+ g = getgrgid(id);
} else {
errno = 0;
g = getgrnam(groupname);
}
} else if (strstr(args[0], "user")) {
- uint32_t uid;
+ uid_t uid;
+ uint32_t u;
- if (safe_atou(args[i], &uid) < 0) {
+ if (parse_uid(args[i], &uid) < 0) {
struct passwd *pw;
pw = getpwnam(args[i]);
goto finish;
}
+ u = (uint32_t) uid;
if (!dbus_message_append_args(m,
- DBUS_TYPE_UINT32, &uid,
+ DBUS_TYPE_UINT32, &u,
DBUS_TYPE_INVALID)) {
log_error("Could not append arguments to message.");
ret = -ENOMEM;
b = streq(args[0], "enable-linger");
for (i = 1; i < n; i++) {
- uint32_t uid;
+ uint32_t u;
+ uid_t uid;
m = dbus_message_new_method_call(
"org.freedesktop.login1",
goto finish;
}
- if (safe_atou32(args[i], &uid) < 0) {
+ if (parse_uid(args[i], &uid) < 0) {
struct passwd *pw;
errno = 0;
uid = pw->pw_uid;
}
+ u = (uint32_t) uid;
if (!dbus_message_append_args(m,
- DBUS_TYPE_UINT32, &uid,
+ DBUS_TYPE_UINT32, &u,
DBUS_TYPE_BOOLEAN, &b,
DBUS_TYPE_BOOLEAN, &interactive,
DBUS_TYPE_INVALID)) {
for (i = 1; i < n; i++) {
uint32_t u;
+ uid_t uid;
m = dbus_message_new_method_call(
"org.freedesktop.login1",
goto finish;
}
- if (safe_atou32(args[i], &u) < 0) {
+ if (parse_uid(args[i], &uid) < 0) {
struct passwd *pw;
errno = 0;
goto finish;
}
- u = pw->pw_uid;
+ uid = pw->pw_uid;
}
+ u = (uint32_t) uid;
if (!dbus_message_append_args(m,
DBUS_TYPE_UINT32, &u,
DBUS_TYPE_INVALID)) {
arg_kill_who = "all";
for (i = 1; i < n; i++) {
+ uid_t uid;
uint32_t u;
m = dbus_message_new_method_call(
goto finish;
}
- if (safe_atou32(args[i], &u) < 0) {
+ if (parse_uid(args[i], &uid) < 0) {
struct passwd *pw;
errno = 0;
goto finish;
}
- u = pw->pw_uid;
+ uid = pw->pw_uid;
}
+ u = (uint32_t) uid;
if (!dbus_message_append_args(m,
DBUS_TYPE_UINT32, &u,
DBUS_TYPE_INT32, arg_signal,
}
while ((de = readdir(d))) {
- unsigned long ul;
+ uid_t uid;
User *u;
if (!dirent_is_file(de))
continue;
- k = safe_atolu(de->d_name, &ul);
+ k = parse_uid(de->d_name, &uid);
if (k < 0) {
log_error("Failed to parse file name %s: %s", de->d_name, strerror(-k));
continue;
}
- u = hashmap_get(m->users, ULONG_TO_PTR(ul));
+ u = hashmap_get(m->users, ULONG_TO_PTR(uid));
if (!u) {
unlinkat(dirfd(d), de->d_name, 0);
continue;
* it probably contains a uid of the host system. */
if (read_one_line_file("/proc/self/loginuid", &s) >= 0) {
- uint32_t u;
+ uid_t uid;
- r = safe_atou32(s, &u);
+ r = parse_uid(s, &uid);
free(s);
- if (r >= 0 && u != (uint32_t) -1 && u > 0) {
+ if (r >= 0 && uid != (uint32_t) -1) {
have_loginuid = true;
- pw = pam_modutil_getpwuid(handle, u);
+ pw = pam_modutil_getpwuid(handle, uid);
}
}
}
}
STRV_FOREACH(l, kill_exclude_users) {
- uint32_t id;
+ uid_t u;
- if (safe_atou32(*l, &id) >= 0)
- if ((uid_t) id == uid)
+ if (parse_uid(*l, &u) >= 0)
+ if (u == uid)
return false;
if (name && streq(name, *l))
return true;
STRV_FOREACH(l, kill_only_users) {
- uint32_t id;
+ uid_t u;
- if (safe_atou32(*l, &id) >= 0)
- if ((uid_t) id == uid)
+ if (parse_uid(*l, &u) >= 0)
+ if (u == uid)
return true;
if (name && streq(name, *l))
if (!s)
return -EIO;
- r = safe_atolu(s, &ul);
+ r = parse_uid(s, uid);
free(s);
- if (r < 0)
- return r;
-
- *uid = (uid_t) ul;
- return 0;
+ return r;
}
_public_ int sd_session_get_seat(const char *session, char **seat) {
}
if (user && !streq(user, "-")) {
- unsigned long lu;
+ uid_t uid;
struct passwd *p;
if (streq(user, "root") || streq(user, "0"))
i->uid = 0;
- else if (safe_atolu(user, &lu) >= 0)
- i->uid = (uid_t) lu;
+ else if (parse_uid(user, &uid) >= 0)
+ i->uid = uid;
else if ((p = getpwnam(user)))
i->uid = p->pw_uid;
else {
}
if (group && !streq(group, "-")) {
- unsigned long lu;
+ gid_t gid;
struct group *g;
if (streq(group, "root") || streq(group, "0"))
i->gid = 0;
- else if (safe_atolu(group, &lu) >= 0)
- i->gid = (gid_t) lu;
+ else if (parse_gid(group, &gid) >= 0)
+ i->gid = gid;
else if ((g = getgrnam(group)))
i->gid = g->gr_gid;
else {
int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home) {
struct passwd *p;
- unsigned long lu;
+ uid_t u;
assert(username);
assert(*username);
return 0;
}
- if (safe_atolu(*username, &lu) >= 0) {
+ if (parse_uid(*username, &u) >= 0) {
errno = 0;
- p = getpwuid((uid_t) lu);
+ p = getpwuid(u);
/* If there are multiple users with the same id, make
* sure to leave $USER to the configured value instead