2011-05-26 02:21:16 +02:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright 2011 Lennart Poettering
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
2012-04-12 00:20:58 +02:00
|
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
2011-05-26 02:21:16 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2012-04-12 00:20:58 +02:00
|
|
|
Lesser General Public License for more details.
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2012-04-12 00:20:58 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2011-05-26 02:21:16 +02:00
|
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include <errno.h>
|
2011-06-17 15:59:18 +02:00
|
|
|
#include <string.h>
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
#include "strv.h"
|
|
|
|
#include "bus-util.h"
|
2011-05-26 02:21:16 +02:00
|
|
|
#include "logind.h"
|
|
|
|
#include "logind-user.h"
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
static int property_get_display(
|
|
|
|
sd_bus *bus,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
const char *property,
|
|
|
|
sd_bus_message *reply,
|
2013-11-21 19:34:37 +01:00
|
|
|
void *userdata,
|
|
|
|
sd_bus_error *error) {
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
_cleanup_free_ char *p = NULL;
|
|
|
|
User *u = userdata;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(reply);
|
|
|
|
assert(u);
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
p = u->display ? session_bus_path(u->display) : strdup("/");
|
|
|
|
if (!p)
|
2011-05-26 02:21:16 +02:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return sd_bus_message_append(reply, "(so)", u->display ? u->display->id : "", p);
|
2011-05-26 02:21:16 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
static int property_get_state(
|
|
|
|
sd_bus *bus,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
const char *property,
|
|
|
|
sd_bus_message *reply,
|
2013-11-21 19:34:37 +01:00
|
|
|
void *userdata,
|
|
|
|
sd_bus_error *error) {
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
User *u = userdata;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(reply);
|
|
|
|
assert(u);
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return sd_bus_message_append(reply, "s", user_state_to_string(user_get_state(u)));
|
2011-05-26 02:21:16 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
static int property_get_sessions(
|
|
|
|
sd_bus *bus,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
const char *property,
|
|
|
|
sd_bus_message *reply,
|
2013-11-21 19:34:37 +01:00
|
|
|
void *userdata,
|
|
|
|
sd_bus_error *error) {
|
2013-11-05 01:10:21 +01:00
|
|
|
|
|
|
|
User *u = userdata;
|
2011-05-26 02:21:16 +02:00
|
|
|
Session *session;
|
2013-11-05 01:10:21 +01:00
|
|
|
int r;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(reply);
|
2011-05-26 02:21:16 +02:00
|
|
|
assert(u);
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
r = sd_bus_message_open_container(reply, 'a', "(so)");
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
|
|
|
LIST_FOREACH(sessions_by_user, session, u->sessions) {
|
2013-11-05 01:10:21 +01:00
|
|
|
_cleanup_free_ char *p = NULL;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
|
|
|
p = session_bus_path(session);
|
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
r = sd_bus_message_append(reply, "(so)", session->id, p);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
r = sd_bus_message_close_container(reply);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return 1;
|
2011-05-26 02:21:16 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
static int property_get_idle_hint(
|
|
|
|
sd_bus *bus,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
const char *property,
|
|
|
|
sd_bus_message *reply,
|
2013-11-21 19:34:37 +01:00
|
|
|
void *userdata,
|
|
|
|
sd_bus_error *error) {
|
2011-06-17 15:59:18 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
User *u = userdata;
|
2011-06-21 22:29:25 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(reply);
|
|
|
|
assert(u);
|
2011-06-17 15:59:18 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return sd_bus_message_append(reply, "b", user_get_idle_hint(u, NULL) > 0);
|
2011-06-17 15:59:18 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
static int property_get_idle_since_hint(
|
|
|
|
sd_bus *bus,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
const char *property,
|
|
|
|
sd_bus_message *reply,
|
2013-11-21 19:34:37 +01:00
|
|
|
void *userdata,
|
|
|
|
sd_bus_error *error) {
|
2013-11-05 01:10:21 +01:00
|
|
|
|
|
|
|
User *u = userdata;
|
2011-06-17 15:59:18 +02:00
|
|
|
dual_timestamp t;
|
|
|
|
uint64_t k;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(reply);
|
2011-06-17 15:59:18 +02:00
|
|
|
assert(u);
|
|
|
|
|
|
|
|
user_get_idle_hint(u, &t);
|
|
|
|
k = streq(property, "IdleSinceHint") ? t.realtime : t.monotonic;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return sd_bus_message_append(reply, "t", k);
|
2011-06-17 15:59:18 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 01:27:27 +01:00
|
|
|
static int property_get_linger(
|
|
|
|
sd_bus *bus,
|
|
|
|
const char *path,
|
|
|
|
const char *interface,
|
|
|
|
const char *property,
|
|
|
|
sd_bus_message *reply,
|
2013-11-21 19:34:37 +01:00
|
|
|
void *userdata,
|
|
|
|
sd_bus_error *error) {
|
2013-11-05 01:27:27 +01:00
|
|
|
|
|
|
|
User *u = userdata;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(bus);
|
|
|
|
assert(reply);
|
|
|
|
assert(u);
|
|
|
|
|
|
|
|
r = user_check_linger_file(u);
|
|
|
|
|
|
|
|
return sd_bus_message_append(reply, "b", r > 0);
|
|
|
|
}
|
|
|
|
|
2015-02-18 12:55:25 +01:00
|
|
|
int bus_user_method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
2013-11-05 01:10:21 +01:00
|
|
|
User *u = userdata;
|
2011-05-26 02:21:16 +02:00
|
|
|
int r;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(message);
|
|
|
|
assert(u);
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2015-02-18 12:55:25 +01:00
|
|
|
r = bus_verify_polkit_async(
|
|
|
|
message,
|
|
|
|
CAP_KILL,
|
|
|
|
"org.freedesktop.login1.manage",
|
|
|
|
false,
|
|
|
|
u->uid,
|
|
|
|
&u->manager->polkit_registry,
|
|
|
|
error);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
if (r == 0)
|
|
|
|
return 1; /* Will call us back */
|
|
|
|
|
2014-02-09 02:29:56 +01:00
|
|
|
r = user_stop(u, true);
|
2011-05-26 02:21:16 +02:00
|
|
|
if (r < 0)
|
2013-11-21 19:34:37 +01:00
|
|
|
return r;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-21 01:51:16 +01:00
|
|
|
return sd_bus_reply_method_return(message, NULL);
|
2011-05-26 02:21:16 +02:00
|
|
|
}
|
|
|
|
|
2015-02-18 12:55:25 +01:00
|
|
|
int bus_user_method_kill(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
2013-11-05 01:10:21 +01:00
|
|
|
User *u = userdata;
|
|
|
|
int32_t signo;
|
2011-06-17 15:59:18 +02:00
|
|
|
int r;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
2011-05-26 02:21:16 +02:00
|
|
|
assert(message);
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(u);
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2015-02-18 12:55:25 +01:00
|
|
|
r = bus_verify_polkit_async(
|
|
|
|
message,
|
|
|
|
CAP_KILL,
|
|
|
|
"org.freedesktop.login1.manage",
|
|
|
|
false,
|
|
|
|
u->uid,
|
|
|
|
&u->manager->polkit_registry,
|
|
|
|
error);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
if (r == 0)
|
|
|
|
return 1; /* Will call us back */
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
r = sd_bus_message_read(message, "i", &signo);
|
|
|
|
if (r < 0)
|
2013-11-21 19:34:37 +01:00
|
|
|
return r;
|
2011-06-17 15:59:18 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
if (signo <= 0 || signo >= _NSIG)
|
2013-11-21 19:34:37 +01:00
|
|
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid signal %i", signo);
|
2011-06-17 15:59:18 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
r = user_kill(u, signo);
|
|
|
|
if (r < 0)
|
2013-11-21 19:34:37 +01:00
|
|
|
return r;
|
2011-06-17 15:59:18 +02:00
|
|
|
|
2013-11-21 01:51:16 +01:00
|
|
|
return sd_bus_reply_method_return(message, NULL);
|
2011-05-26 02:21:16 +02:00
|
|
|
}
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
const sd_bus_vtable user_vtable[] = {
|
|
|
|
SD_BUS_VTABLE_START(0),
|
|
|
|
|
2013-12-22 02:24:05 +01:00
|
|
|
SD_BUS_PROPERTY("UID", "u", bus_property_get_uid, offsetof(User, uid), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
|
SD_BUS_PROPERTY("GID", "u", bus_property_get_gid, offsetof(User, gid), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
|
SD_BUS_PROPERTY("Name", "s", NULL, offsetof(User, name), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
|
BUS_PROPERTY_DUAL_TIMESTAMP("Timestamp", offsetof(User, timestamp), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
|
SD_BUS_PROPERTY("RuntimePath", "s", NULL, offsetof(User, runtime_path), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
|
SD_BUS_PROPERTY("Service", "s", NULL, offsetof(User, service), SD_BUS_VTABLE_PROPERTY_CONST),
|
|
|
|
SD_BUS_PROPERTY("Slice", "s", NULL, offsetof(User, slice), SD_BUS_VTABLE_PROPERTY_CONST),
|
2014-05-19 02:03:20 +02:00
|
|
|
SD_BUS_PROPERTY("Display", "(so)", property_get_display, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
2013-11-05 01:10:21 +01:00
|
|
|
SD_BUS_PROPERTY("State", "s", property_get_state, 0, 0),
|
|
|
|
SD_BUS_PROPERTY("Sessions", "a(so)", property_get_sessions, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
|
|
SD_BUS_PROPERTY("IdleHint", "b", property_get_idle_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
|
|
SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
|
|
|
SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
2013-11-05 01:27:27 +01:00
|
|
|
SD_BUS_PROPERTY("Linger", "b", property_get_linger, 0, 0),
|
2013-11-05 01:10:21 +01:00
|
|
|
|
2015-02-18 12:55:25 +01:00
|
|
|
SD_BUS_METHOD("Terminate", NULL, NULL, bus_user_method_terminate, SD_BUS_VTABLE_UNPRIVILEGED),
|
|
|
|
SD_BUS_METHOD("Kill", "i", NULL, bus_user_method_kill, SD_BUS_VTABLE_UNPRIVILEGED),
|
2013-11-05 01:10:21 +01:00
|
|
|
|
|
|
|
SD_BUS_VTABLE_END
|
|
|
|
};
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-22 01:14:57 +01:00
|
|
|
int user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
|
2011-05-26 02:21:16 +02:00
|
|
|
Manager *m = userdata;
|
2015-01-09 16:14:19 +01:00
|
|
|
uid_t uid;
|
2013-11-05 01:10:21 +01:00
|
|
|
User *user;
|
2011-05-26 02:21:16 +02:00
|
|
|
int r;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(path);
|
|
|
|
assert(interface);
|
|
|
|
assert(found);
|
|
|
|
assert(m);
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 20:52:39 +01:00
|
|
|
if (streq(path, "/org/freedesktop/login1/user/self")) {
|
2013-11-28 17:50:02 +01:00
|
|
|
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
|
2013-11-05 20:52:39 +01:00
|
|
|
sd_bus_message *message;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2014-05-15 01:15:30 +02:00
|
|
|
message = sd_bus_get_current_message(bus);
|
2013-11-05 20:52:39 +01:00
|
|
|
if (!message)
|
|
|
|
return 0;
|
|
|
|
|
2015-01-09 16:14:19 +01:00
|
|
|
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_OWNER_UID|SD_BUS_CREDS_AUGMENT, &creds);
|
2013-11-05 20:52:39 +01:00
|
|
|
if (r < 0)
|
2013-11-28 17:50:02 +01:00
|
|
|
return r;
|
|
|
|
|
2015-01-09 16:14:19 +01:00
|
|
|
r = sd_bus_creds_get_owner_uid(creds, &uid);
|
2013-11-05 20:52:39 +01:00
|
|
|
} else {
|
|
|
|
const char *p;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 20:52:39 +01:00
|
|
|
p = startswith(path, "/org/freedesktop/login1/user/_");
|
|
|
|
if (!p)
|
|
|
|
return 0;
|
|
|
|
|
2015-01-09 16:14:19 +01:00
|
|
|
r = parse_uid(p, &uid);
|
2013-11-05 20:52:39 +01:00
|
|
|
}
|
2015-01-09 16:14:19 +01:00
|
|
|
if (r < 0)
|
|
|
|
return 0;
|
|
|
|
|
2015-01-09 16:25:47 +01:00
|
|
|
user = hashmap_get(m->users, UID_TO_PTR(uid));
|
2015-01-09 16:14:19 +01:00
|
|
|
if (!user)
|
|
|
|
return 0;
|
2011-05-26 02:21:16 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
*found = user;
|
|
|
|
return 1;
|
2011-05-26 02:21:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
char *user_bus_path(User *u) {
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
assert(u);
|
|
|
|
|
2014-04-25 13:45:15 +02:00
|
|
|
if (asprintf(&s, "/org/freedesktop/login1/user/_"UID_FMT, u->uid) < 0)
|
2011-05-26 02:21:16 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-22 01:14:57 +01:00
|
|
|
int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
|
2013-11-05 01:10:21 +01:00
|
|
|
_cleanup_strv_free_ char **l = NULL;
|
2015-01-18 12:59:39 +01:00
|
|
|
sd_bus_message *message;
|
2013-11-05 01:10:21 +01:00
|
|
|
Manager *m = userdata;
|
|
|
|
User *user;
|
|
|
|
Iterator i;
|
|
|
|
int r;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(bus);
|
|
|
|
assert(path);
|
|
|
|
assert(nodes);
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
HASHMAP_FOREACH(user, m->users, i) {
|
|
|
|
char *p;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
p = user_bus_path(user);
|
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2014-03-04 15:20:51 +01:00
|
|
|
r = strv_consume(&l, p);
|
|
|
|
if (r < 0)
|
2013-11-05 01:10:21 +01:00
|
|
|
return r;
|
|
|
|
}
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2015-01-18 12:59:39 +01:00
|
|
|
message = sd_bus_get_current_message(bus);
|
|
|
|
if (message) {
|
|
|
|
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
|
|
|
|
uid_t uid;
|
|
|
|
|
|
|
|
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_OWNER_UID|SD_BUS_CREDS_AUGMENT, &creds);
|
|
|
|
if (r >= 0) {
|
|
|
|
r = sd_bus_creds_get_owner_uid(creds, &uid);
|
|
|
|
if (r >= 0) {
|
|
|
|
user = hashmap_get(m->users, UID_TO_PTR(uid));
|
|
|
|
if (user) {
|
|
|
|
r = strv_extend(&l, "/org/freedesktop/login1/user/self");
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-09 01:44:40 +01:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
*nodes = l;
|
|
|
|
l = NULL;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int user_send_signal(User *u, bool new_user) {
|
|
|
|
_cleanup_free_ char *p = NULL;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
assert(u);
|
|
|
|
|
|
|
|
p = user_bus_path(u);
|
|
|
|
if (!p)
|
2013-03-19 01:31:21 +01:00
|
|
|
return -ENOMEM;
|
2011-06-21 20:43:34 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return sd_bus_emit_signal(
|
|
|
|
u->manager->bus,
|
|
|
|
"/org/freedesktop/login1",
|
|
|
|
"org.freedesktop.login1.Manager",
|
|
|
|
new_user ? "UserNew" : "UserRemoved",
|
|
|
|
"uo", (uint32_t) u->uid, p);
|
2011-06-21 20:43:34 +02:00
|
|
|
}
|
2011-06-21 21:46:13 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
int user_send_changed(User *u, const char *properties, ...) {
|
2013-03-18 19:38:48 +01:00
|
|
|
_cleanup_free_ char *p = NULL;
|
2013-11-05 01:10:21 +01:00
|
|
|
char **l;
|
2011-06-21 21:46:13 +02:00
|
|
|
|
|
|
|
assert(u);
|
|
|
|
|
2011-06-24 19:42:45 +02:00
|
|
|
if (!u->started)
|
|
|
|
return 0;
|
|
|
|
|
2011-06-21 21:46:13 +02:00
|
|
|
p = user_bus_path(u);
|
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
l = strv_from_stdarg_alloca(properties);
|
2011-06-21 21:46:13 +02:00
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
return sd_bus_emit_properties_changed_strv(u->manager->bus, p, "org.freedesktop.login1.User", l);
|
2011-06-21 21:46:13 +02:00
|
|
|
}
|