mirror of
https://github.com/systemd/systemd.git
synced 2025-01-25 10:04:04 +03:00
Merge pull request #13567 from keszybz/logind-two-refactoring-patches
Logind two refactoring patches
This commit is contained in:
commit
67ad633b58
@ -75,7 +75,7 @@ int manager_parse_config_file(Manager *m) {
|
||||
CONFIG_PARSE_WARN, m);
|
||||
}
|
||||
|
||||
int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device) {
|
||||
int manager_add_device(Manager *m, const char *sysfs, bool master, Device **ret_device) {
|
||||
Device *d;
|
||||
|
||||
assert(m);
|
||||
@ -91,13 +91,13 @@ int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_dev
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (_device)
|
||||
*_device = d;
|
||||
if (ret_device)
|
||||
*ret_device = d;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int manager_add_seat(Manager *m, const char *id, Seat **_seat) {
|
||||
int manager_add_seat(Manager *m, const char *id, Seat **ret_seat) {
|
||||
Seat *s;
|
||||
int r;
|
||||
|
||||
@ -111,13 +111,13 @@ int manager_add_seat(Manager *m, const char *id, Seat **_seat) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (_seat)
|
||||
*_seat = s;
|
||||
if (ret_seat)
|
||||
*ret_seat = s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int manager_add_session(Manager *m, const char *id, Session **_session) {
|
||||
int manager_add_session(Manager *m, const char *id, Session **ret_session) {
|
||||
Session *s;
|
||||
int r;
|
||||
|
||||
@ -131,8 +131,8 @@ int manager_add_session(Manager *m, const char *id, Session **_session) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (_session)
|
||||
*_session = s;
|
||||
if (ret_session)
|
||||
*ret_session = s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -143,7 +143,7 @@ int manager_add_user(
|
||||
gid_t gid,
|
||||
const char *name,
|
||||
const char *home,
|
||||
User **_user) {
|
||||
User **ret_user) {
|
||||
|
||||
User *u;
|
||||
int r;
|
||||
@ -158,8 +158,8 @@ int manager_add_user(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (_user)
|
||||
*_user = u;
|
||||
if (ret_user)
|
||||
*ret_user = u;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -167,7 +167,7 @@ int manager_add_user(
|
||||
int manager_add_user_by_name(
|
||||
Manager *m,
|
||||
const char *name,
|
||||
User **_user) {
|
||||
User **ret_user) {
|
||||
|
||||
const char *home = NULL;
|
||||
uid_t uid;
|
||||
@ -181,10 +181,10 @@ int manager_add_user_by_name(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return manager_add_user(m, uid, gid, name, home, _user);
|
||||
return manager_add_user(m, uid, gid, name, home, ret_user);
|
||||
}
|
||||
|
||||
int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user) {
|
||||
int manager_add_user_by_uid(Manager *m, uid_t uid, User **ret_user) {
|
||||
struct passwd *p;
|
||||
|
||||
assert(m);
|
||||
@ -194,7 +194,7 @@ int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user) {
|
||||
if (!p)
|
||||
return errno_or_else(ENOENT);
|
||||
|
||||
return manager_add_user(m, uid, p->pw_gid, p->pw_name, p->pw_dir, _user);
|
||||
return manager_add_user(m, uid, p->pw_gid, p->pw_name, p->pw_dir, ret_user);
|
||||
}
|
||||
|
||||
int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **ret) {
|
||||
@ -217,7 +217,7 @@ int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int manager_add_button(Manager *m, const char *name, Button **_button) {
|
||||
int manager_add_button(Manager *m, const char *name, Button **ret_button) {
|
||||
Button *b;
|
||||
|
||||
assert(m);
|
||||
@ -230,8 +230,8 @@ int manager_add_button(Manager *m, const char *name, Button **_button) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (_button)
|
||||
*_button = b;
|
||||
if (ret_button)
|
||||
*ret_button = b;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -354,28 +354,19 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **ret) {
|
||||
s = hashmap_get(m->sessions_by_leader, PID_TO_PTR(pid));
|
||||
if (!s) {
|
||||
r = cg_pid_get_unit(pid, &unit);
|
||||
if (r < 0)
|
||||
goto not_found;
|
||||
|
||||
s = hashmap_get(m->session_units, unit);
|
||||
if (!s)
|
||||
goto not_found;
|
||||
if (r >= 0)
|
||||
s = hashmap_get(m->session_units, unit);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
*ret = s;
|
||||
|
||||
return 1;
|
||||
|
||||
not_found:
|
||||
if (ret)
|
||||
*ret = NULL;
|
||||
return 0;
|
||||
return !!s;
|
||||
}
|
||||
|
||||
int manager_get_user_by_pid(Manager *m, pid_t pid, User **ret) {
|
||||
_cleanup_free_ char *unit = NULL;
|
||||
User *u;
|
||||
User *u = NULL;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
@ -384,23 +375,13 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **ret) {
|
||||
return -EINVAL;
|
||||
|
||||
r = cg_pid_get_slice(pid, &unit);
|
||||
if (r < 0)
|
||||
goto not_found;
|
||||
|
||||
u = hashmap_get(m->user_units, unit);
|
||||
if (!u)
|
||||
goto not_found;
|
||||
if (r >= 0)
|
||||
u = hashmap_get(m->user_units, unit);
|
||||
|
||||
if (ret)
|
||||
*ret = u;
|
||||
|
||||
return 1;
|
||||
|
||||
not_found:
|
||||
if (ret)
|
||||
*ret = NULL;
|
||||
|
||||
return 0;
|
||||
return !!u;
|
||||
}
|
||||
|
||||
int manager_get_idle_hint(Manager *m, dual_timestamp *t) {
|
||||
|
@ -127,14 +127,14 @@ struct Manager {
|
||||
void manager_reset_config(Manager *m);
|
||||
int manager_parse_config_file(Manager *m);
|
||||
|
||||
int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device);
|
||||
int manager_add_button(Manager *m, const char *name, Button **_button);
|
||||
int manager_add_seat(Manager *m, const char *id, Seat **_seat);
|
||||
int manager_add_session(Manager *m, const char *id, Session **_session);
|
||||
int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, const char *home, User **_user);
|
||||
int manager_add_user_by_name(Manager *m, const char *name, User **_user);
|
||||
int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
|
||||
int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor);
|
||||
int manager_add_device(Manager *m, const char *sysfs, bool master, Device **ret_device);
|
||||
int manager_add_button(Manager *m, const char *name, Button **ret_button);
|
||||
int manager_add_seat(Manager *m, const char *id, Seat **ret_seat);
|
||||
int manager_add_session(Manager *m, const char *id, Session **ret_session);
|
||||
int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, const char *home, User **ret_user);
|
||||
int manager_add_user_by_name(Manager *m, const char *name, User **ret_user);
|
||||
int manager_add_user_by_uid(Manager *m, uid_t uid, User **ret_user);
|
||||
int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **ret_inhibitor);
|
||||
|
||||
int manager_process_seat_device(Manager *m, sd_device *d);
|
||||
int manager_process_button_device(Manager *m, sd_device *d);
|
||||
|
Loading…
x
Reference in New Issue
Block a user