" <property name=\"Remote\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"RemoteHost\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"RemoteUser\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"Service\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Leader\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Audit\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Type\" type=\"s\" access=\"read\"/>\n" \
static int bus_session_append_active(DBusMessageIter *i, const char *property, void *data) {
Session *s = data;
- bool b;
+ dbus_bool_t b;
assert(i);
assert(property);
static int bus_session_append_idle_hint(DBusMessageIter *i, const char *property, void *data) {
Session *s = data;
- bool b;
+ int b;
assert(i);
assert(property);
assert(s);
- b = session_get_idle_hint(s, NULL);
+ b = session_get_idle_hint(s, NULL) > 0;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
{ "org.freedesktop.login1.Session", "Remote", bus_property_append_bool, "b", &s->remote },
{ "org.freedesktop.login1.Session", "RemoteUser", bus_property_append_string, "s", s->remote_user },
{ "org.freedesktop.login1.Session", "RemoteHost", bus_property_append_string, "s", s->remote_host },
+ { "org.freedesktop.login1.Session", "Service", bus_property_append_string, "s", s->service },
{ "org.freedesktop.login1.Session", "Leader", bus_property_append_pid, "u", &s->leader },
{ "org.freedesktop.login1.Session", "Audit", bus_property_append_uint32, "u", &s->audit_id },
{ "org.freedesktop.login1.Session", "Type", bus_session_append_type, "s", &s->type },
} else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Session", "SetIdleHint")) {
dbus_bool_t b;
+ unsigned long ul;
if (!dbus_message_get_args(
message,
DBUS_TYPE_INVALID))
return bus_send_error_reply(connection, message, &error, -EINVAL);
+ ul = dbus_bus_get_unix_user(connection, dbus_message_get_sender(message), &error);
+ if (ul == (unsigned long) -1)
+ return bus_send_error_reply(connection, message, &error, -EIO);
+
+ if (ul != 0 && ul != s->user->uid)
+ return bus_send_error_reply(connection, message, NULL, -EPERM);
+
session_set_idle_hint(s, b);
reply = dbus_message_new_method_return(message);
assert(s);
+ if (!s->started)
+ return 0;
+
p = session_bus_path(s);
if (!p)
return -ENOMEM;