|
|
7dfda4 |
From c66cee942242a731082f0fac649f3f9569ae99a3 Mon Sep 17 00:00:00 2001
|
|
|
7dfda4 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
7dfda4 |
Date: Wed, 8 Aug 2018 16:11:56 -0400
|
|
|
7dfda4 |
Subject: [PATCH 1/2] user: add new Session/SessionType properties to replace
|
|
|
7dfda4 |
XSession
|
|
|
7dfda4 |
|
|
|
7dfda4 |
Having a property called XSession in the API makes little
|
|
|
7dfda4 |
sense when wayland has taken the world by storm.
|
|
|
7dfda4 |
|
|
|
7dfda4 |
This commit adds new "Session" property without the "X" in the name,
|
|
|
7dfda4 |
and an additional property "SessionType" that can be either
|
|
|
7dfda4 |
"wayland" or "x11".
|
|
|
7dfda4 |
---
|
|
|
7dfda4 |
data/org.freedesktop.Accounts.User.xml | 103 +++++++++++++++++++++
|
|
|
7dfda4 |
src/libaccountsservice/act-user.c | 93 +++++++++++++++++++
|
|
|
7dfda4 |
src/libaccountsservice/act-user.h | 6 ++
|
|
|
7dfda4 |
src/user.c | 121 +++++++++++++++++++++++++
|
|
|
7dfda4 |
4 files changed, 323 insertions(+)
|
|
|
7dfda4 |
|
|
|
7dfda4 |
diff --git a/data/org.freedesktop.Accounts.User.xml b/data/org.freedesktop.Accounts.User.xml
|
|
|
7dfda4 |
index 4ab989a..7fc3c61 100644
|
|
|
7dfda4 |
--- a/data/org.freedesktop.Accounts.User.xml
|
|
|
7dfda4 |
+++ b/data/org.freedesktop.Accounts.User.xml
|
|
|
7dfda4 |
@@ -141,60 +141,143 @@
|
|
|
7dfda4 |
<doc:term>org.freedesktop.accounts.user-administration</doc:term>
|
|
|
7dfda4 |
<doc:definition>To change the language of another user</doc:definition>
|
|
|
7dfda4 |
</doc:item>
|
|
|
7dfda4 |
</doc:list>
|
|
|
7dfda4 |
</doc:permission>
|
|
|
7dfda4 |
<doc:errors>
|
|
|
7dfda4 |
<doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
|
|
7dfda4 |
<doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
|
|
|
7dfda4 |
</doc:errors>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</method>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
<method name="SetXSession">
|
|
|
7dfda4 |
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
|
|
7dfda4 |
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_x_session"/>
|
|
|
7dfda4 |
<arg name="x_session" direction="in" type="s">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:summary>
|
|
|
7dfda4 |
The new xsession to start (e.g. "gnome")
|
|
|
7dfda4 |
</doc:summary>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</arg>
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
Sets the users x session.
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
The expectation is that display managers will log the user in to this
|
|
|
7dfda4 |
specified session, if available.
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ Note this call is deprecated and has been superceded by SetSession since
|
|
|
7dfda4 |
+ not all graphical sessions use X as the display server.
|
|
|
7dfda4 |
+ </doc:para>
|
|
|
7dfda4 |
+ </doc:description>
|
|
|
7dfda4 |
+ <doc:permission>
|
|
|
7dfda4 |
+ The caller needs one of the following PolicyKit authorizations:
|
|
|
7dfda4 |
+ <doc:list>
|
|
|
7dfda4 |
+ <doc:item>
|
|
|
7dfda4 |
+ <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
|
|
|
7dfda4 |
+ <doc:definition>To change his own language</doc:definition>
|
|
|
7dfda4 |
+ </doc:item>
|
|
|
7dfda4 |
+ <doc:item>
|
|
|
7dfda4 |
+ <doc:term>org.freedesktop.accounts.user-administration</doc:term>
|
|
|
7dfda4 |
+ <doc:definition>To change the language of another user</doc:definition>
|
|
|
7dfda4 |
+ </doc:item>
|
|
|
7dfda4 |
+ </doc:list>
|
|
|
7dfda4 |
+ </doc:permission>
|
|
|
7dfda4 |
+ <doc:errors>
|
|
|
7dfda4 |
+ <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
|
|
7dfda4 |
+ <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
|
|
|
7dfda4 |
+ </doc:errors>
|
|
|
7dfda4 |
+ </doc:doc>
|
|
|
7dfda4 |
+ </method>
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ <method name="SetSession">
|
|
|
7dfda4 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
|
|
7dfda4 |
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_session"/>
|
|
|
7dfda4 |
+ <arg name="session" direction="in" type="s">
|
|
|
7dfda4 |
+ <doc:doc>
|
|
|
7dfda4 |
+ <doc:summary>
|
|
|
7dfda4 |
+ The new session to start (e.g. "gnome-xorg")
|
|
|
7dfda4 |
+ </doc:summary>
|
|
|
7dfda4 |
+ </doc:doc>
|
|
|
7dfda4 |
+ </arg>
|
|
|
7dfda4 |
+ <doc:doc>
|
|
|
7dfda4 |
+ <doc:description>
|
|
|
7dfda4 |
+ <doc:para>
|
|
|
7dfda4 |
+ Sets the users wayland or x session.
|
|
|
7dfda4 |
+ </doc:para>
|
|
|
7dfda4 |
+ <doc:para>
|
|
|
7dfda4 |
+ The expectation is that display managers will log the user in to this
|
|
|
7dfda4 |
+ specified session, if available.
|
|
|
7dfda4 |
+ </doc:para>
|
|
|
7dfda4 |
+ </doc:description>
|
|
|
7dfda4 |
+ <doc:permission>
|
|
|
7dfda4 |
+ The caller needs one of the following PolicyKit authorizations:
|
|
|
7dfda4 |
+ <doc:list>
|
|
|
7dfda4 |
+ <doc:item>
|
|
|
7dfda4 |
+ <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
|
|
|
7dfda4 |
+ <doc:definition>To change his own language</doc:definition>
|
|
|
7dfda4 |
+ </doc:item>
|
|
|
7dfda4 |
+ <doc:item>
|
|
|
7dfda4 |
+ <doc:term>org.freedesktop.accounts.user-administration</doc:term>
|
|
|
7dfda4 |
+ <doc:definition>To change the language of another user</doc:definition>
|
|
|
7dfda4 |
+ </doc:item>
|
|
|
7dfda4 |
+ </doc:list>
|
|
|
7dfda4 |
+ </doc:permission>
|
|
|
7dfda4 |
+ <doc:errors>
|
|
|
7dfda4 |
+ <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
|
|
7dfda4 |
+ <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
|
|
|
7dfda4 |
+ </doc:errors>
|
|
|
7dfda4 |
+ </doc:doc>
|
|
|
7dfda4 |
+ </method>
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ <method name="SetSessionType">
|
|
|
7dfda4 |
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
|
|
7dfda4 |
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_session_type"/>
|
|
|
7dfda4 |
+ <arg name="session_type" direction="in" type="s">
|
|
|
7dfda4 |
+ <doc:doc>
|
|
|
7dfda4 |
+ <doc:summary>
|
|
|
7dfda4 |
+ The type of the new session to start (e.g. "wayland" or "x11")
|
|
|
7dfda4 |
+ </doc:summary>
|
|
|
7dfda4 |
+ </doc:doc>
|
|
|
7dfda4 |
+ </arg>
|
|
|
7dfda4 |
+ <doc:doc>
|
|
|
7dfda4 |
+ <doc:description>
|
|
|
7dfda4 |
+ <doc:para>
|
|
|
7dfda4 |
+ Sets the session type of the users session.
|
|
|
7dfda4 |
+ </doc:para>
|
|
|
7dfda4 |
+ <doc:para>
|
|
|
7dfda4 |
+ Display managers may use this property to decide what type of display server to use when
|
|
|
7dfda4 |
+ loading the session
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
<doc:permission>
|
|
|
7dfda4 |
The caller needs one of the following PolicyKit authorizations:
|
|
|
7dfda4 |
<doc:list>
|
|
|
7dfda4 |
<doc:item>
|
|
|
7dfda4 |
<doc:term>org.freedesktop.accounts.change-own-user-data</doc:term>
|
|
|
7dfda4 |
<doc:definition>To change his own language</doc:definition>
|
|
|
7dfda4 |
</doc:item>
|
|
|
7dfda4 |
<doc:item>
|
|
|
7dfda4 |
<doc:term>org.freedesktop.accounts.user-administration</doc:term>
|
|
|
7dfda4 |
<doc:definition>To change the language of another user</doc:definition>
|
|
|
7dfda4 |
</doc:item>
|
|
|
7dfda4 |
</doc:list>
|
|
|
7dfda4 |
</doc:permission>
|
|
|
7dfda4 |
<doc:errors>
|
|
|
7dfda4 |
<doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error>
|
|
|
7dfda4 |
<doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error>
|
|
|
7dfda4 |
</doc:errors>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</method>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
<method name="SetLocation">
|
|
|
7dfda4 |
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
|
|
7dfda4 |
<arg name="location" direction="in" type="s">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:summary>
|
|
|
7dfda4 |
The new location as a freeform string.
|
|
|
7dfda4 |
</doc:summary>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
@@ -641,60 +724,80 @@
|
|
|
7dfda4 |
<property name="Shell" type="s" access="read">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
The users shell.
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</property>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
<property name="Email" type="s" access="read">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
The email address.
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</property>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
<property name="Language" type="s" access="read">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
The users language, as a locale specification like "de_DE.UTF-8".
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</property>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
+ <property name="Session" type="s" access="read">
|
|
|
7dfda4 |
+ <doc:doc>
|
|
|
7dfda4 |
+ <doc:description>
|
|
|
7dfda4 |
+ <doc:para>
|
|
|
7dfda4 |
+ The users Wayland or X session.
|
|
|
7dfda4 |
+ </doc:para>
|
|
|
7dfda4 |
+ </doc:description>
|
|
|
7dfda4 |
+ </doc:doc>
|
|
|
7dfda4 |
+ </property>
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ <property name="SessionType" type="s" access="read">
|
|
|
7dfda4 |
+ <doc:doc>
|
|
|
7dfda4 |
+ <doc:description>
|
|
|
7dfda4 |
+ <doc:para>
|
|
|
7dfda4 |
+ The type of session the user should use (e.g. "wayland" or "x11")
|
|
|
7dfda4 |
+ </doc:para>
|
|
|
7dfda4 |
+ </doc:description>
|
|
|
7dfda4 |
+ </doc:doc>
|
|
|
7dfda4 |
+ </property>
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
<property name="XSession" type="s" access="read">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
The users x session.
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</property>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
<property name="Location" type="s" access="read">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
The users location.
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</property>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
<property name="LoginFrequency" type="t" access="read">
|
|
|
7dfda4 |
<doc:doc>
|
|
|
7dfda4 |
<doc:description>
|
|
|
7dfda4 |
<doc:para>
|
|
|
7dfda4 |
How often the user has logged in.
|
|
|
7dfda4 |
</doc:para>
|
|
|
7dfda4 |
</doc:description>
|
|
|
7dfda4 |
</doc:doc>
|
|
|
7dfda4 |
</property>
|
|
|
7dfda4 |
|
|
|
7dfda4 |
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
|
|
|
7dfda4 |
index 7162221..dd8f81b 100644
|
|
|
7dfda4 |
--- a/src/libaccountsservice/act-user.c
|
|
|
7dfda4 |
+++ b/src/libaccountsservice/act-user.c
|
|
|
7dfda4 |
@@ -999,60 +999,98 @@ act_user_get_icon_file (ActUser *user)
|
|
|
7dfda4 |
const char *
|
|
|
7dfda4 |
act_user_get_language (ActUser *user)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (user->accounts_proxy == NULL)
|
|
|
7dfda4 |
return NULL;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
return accounts_user_get_language (user->accounts_proxy);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
/**
|
|
|
7dfda4 |
* act_user_get_x_session:
|
|
|
7dfda4 |
* @user: a #ActUser
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Returns the path to the configured X session for @user.
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Returns: (transfer none): a path to an icon
|
|
|
7dfda4 |
*/
|
|
|
7dfda4 |
const char *
|
|
|
7dfda4 |
act_user_get_x_session (ActUser *user)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (user->accounts_proxy == NULL)
|
|
|
7dfda4 |
return NULL;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
return accounts_user_get_xsession (user->accounts_proxy);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
+/**
|
|
|
7dfda4 |
+ * act_user_get_session:
|
|
|
7dfda4 |
+ * @user: a #ActUser
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Returns the path to the configured session for @user.
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Returns: (transfer none): a path to an icon
|
|
|
7dfda4 |
+ */
|
|
|
7dfda4 |
+const char *
|
|
|
7dfda4 |
+act_user_get_session (ActUser *user)
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (user->accounts_proxy == NULL)
|
|
|
7dfda4 |
+ return NULL;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ return accounts_user_get_session (user->accounts_proxy);
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+/**
|
|
|
7dfda4 |
+ * act_user_get_session_type:
|
|
|
7dfda4 |
+ * @user: a #ActUser
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Returns the type of the configured session for @user.
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Returns: (transfer none): a path to an icon
|
|
|
7dfda4 |
+ */
|
|
|
7dfda4 |
+const char *
|
|
|
7dfda4 |
+act_user_get_session_type (ActUser *user)
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (user->accounts_proxy == NULL)
|
|
|
7dfda4 |
+ return NULL;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ return accounts_user_get_session_type (user->accounts_proxy);
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
/**
|
|
|
7dfda4 |
* act_user_get_object_path:
|
|
|
7dfda4 |
* @user: a #ActUser
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Returns the user accounts service object path of @user,
|
|
|
7dfda4 |
* or %NULL if @user doesn't have an object path associated
|
|
|
7dfda4 |
* with it.
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Returns: (transfer none): the object path of the user
|
|
|
7dfda4 |
*/
|
|
|
7dfda4 |
const char *
|
|
|
7dfda4 |
act_user_get_object_path (ActUser *user)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_return_val_if_fail (ACT_IS_USER (user), NULL);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (user->accounts_proxy == NULL)
|
|
|
7dfda4 |
return NULL;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
return g_dbus_proxy_get_object_path (G_DBUS_PROXY (user->accounts_proxy));
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
/**
|
|
|
7dfda4 |
* act_user_get_primary_session_id:
|
|
|
7dfda4 |
* @user: a #ActUser
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Returns the id of the primary session of @user, or %NULL if @user
|
|
|
7dfda4 |
* has no primary session. The primary session will always be
|
|
|
7dfda4 |
* graphical and will be chosen from the sessions on the same seat as
|
|
|
7dfda4 |
* the seat of the session of the calling process.
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
@@ -1310,60 +1348,115 @@ act_user_set_language (ActUser *user,
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
/**
|
|
|
7dfda4 |
* act_user_set_x_session:
|
|
|
7dfda4 |
* @user: the user object to alter.
|
|
|
7dfda4 |
* @x_session: an x session (e.g. gnome)
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Assigns a new x session for @user.
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Note this function is synchronous and ignores errors.
|
|
|
7dfda4 |
**/
|
|
|
7dfda4 |
void
|
|
|
7dfda4 |
act_user_set_x_session (ActUser *user,
|
|
|
7dfda4 |
const char *x_session)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_autoptr(GError) error = NULL;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
g_return_if_fail (ACT_IS_USER (user));
|
|
|
7dfda4 |
g_return_if_fail (x_session != NULL);
|
|
|
7dfda4 |
g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (!accounts_user_call_set_xsession_sync (user->accounts_proxy,
|
|
|
7dfda4 |
x_session,
|
|
|
7dfda4 |
NULL,
|
|
|
7dfda4 |
&error)) {
|
|
|
7dfda4 |
g_warning ("SetXSession call failed: %s", error->message);
|
|
|
7dfda4 |
return;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
+/**
|
|
|
7dfda4 |
+ * act_user_set_session:
|
|
|
7dfda4 |
+ * @user: the user object to alter.
|
|
|
7dfda4 |
+ * @session: a session (e.g. gnome)
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Assigns a new session for @user.
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Note this function is synchronous and ignores errors.
|
|
|
7dfda4 |
+ **/
|
|
|
7dfda4 |
+void
|
|
|
7dfda4 |
+act_user_set_session (ActUser *user,
|
|
|
7dfda4 |
+ const char *session)
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ g_autoptr(GError) error = NULL;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ g_return_if_fail (ACT_IS_USER (user));
|
|
|
7dfda4 |
+ g_return_if_fail (session != NULL);
|
|
|
7dfda4 |
+ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (!accounts_user_call_set_session_sync (user->accounts_proxy,
|
|
|
7dfda4 |
+ session,
|
|
|
7dfda4 |
+ NULL,
|
|
|
7dfda4 |
+ &error)) {
|
|
|
7dfda4 |
+ g_warning ("SetSession call failed: %s", error->message);
|
|
|
7dfda4 |
+ return;
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+/**
|
|
|
7dfda4 |
+ * act_user_set_session_type:
|
|
|
7dfda4 |
+ * @user: the user object to alter.
|
|
|
7dfda4 |
+ * @session_type: a type of session (e.g. "wayland" or "x11")
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Assigns a type to the session for @user.
|
|
|
7dfda4 |
+ *
|
|
|
7dfda4 |
+ * Note this function is synchronous and ignores errors.
|
|
|
7dfda4 |
+ **/
|
|
|
7dfda4 |
+void
|
|
|
7dfda4 |
+act_user_set_session_type (ActUser *user,
|
|
|
7dfda4 |
+ const char *session_type)
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ g_autoptr(GError) error = NULL;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ g_return_if_fail (ACT_IS_USER (user));
|
|
|
7dfda4 |
+ g_return_if_fail (session_type != NULL);
|
|
|
7dfda4 |
+ g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (!accounts_user_call_set_session_type_sync (user->accounts_proxy,
|
|
|
7dfda4 |
+ session_type,
|
|
|
7dfda4 |
+ NULL,
|
|
|
7dfda4 |
+ &error)) {
|
|
|
7dfda4 |
+ g_warning ("SetSessionType call failed: %s", error->message);
|
|
|
7dfda4 |
+ return;
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
/**
|
|
|
7dfda4 |
* act_user_set_location:
|
|
|
7dfda4 |
* @user: the user object to alter.
|
|
|
7dfda4 |
* @location: a location
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Assigns a new location for @user.
|
|
|
7dfda4 |
*
|
|
|
7dfda4 |
* Note this function is synchronous and ignores errors.
|
|
|
7dfda4 |
**/
|
|
|
7dfda4 |
void
|
|
|
7dfda4 |
act_user_set_location (ActUser *user,
|
|
|
7dfda4 |
const char *location)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_autoptr(GError) error = NULL;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
g_return_if_fail (ACT_IS_USER (user));
|
|
|
7dfda4 |
g_return_if_fail (location != NULL);
|
|
|
7dfda4 |
g_return_if_fail (ACCOUNTS_IS_USER (user->accounts_proxy));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (!accounts_user_call_set_location_sync (user->accounts_proxy,
|
|
|
7dfda4 |
location,
|
|
|
7dfda4 |
NULL,
|
|
|
7dfda4 |
&error)) {
|
|
|
7dfda4 |
g_warning ("SetLocation call failed: %s", error->message);
|
|
|
7dfda4 |
return;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
/**
|
|
|
7dfda4 |
diff --git a/src/libaccountsservice/act-user.h b/src/libaccountsservice/act-user.h
|
|
|
7dfda4 |
index c685fcc..2ef13b1 100644
|
|
|
7dfda4 |
--- a/src/libaccountsservice/act-user.h
|
|
|
7dfda4 |
+++ b/src/libaccountsservice/act-user.h
|
|
|
7dfda4 |
@@ -51,79 +51,85 @@ typedef struct _ActUserClass ActUserClass;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
GType act_user_get_type (void) G_GNUC_CONST;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
const char *act_user_get_object_path (ActUser *user);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
uid_t act_user_get_uid (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_user_name (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_real_name (ActUser *user);
|
|
|
7dfda4 |
ActUserAccountType act_user_get_account_type (ActUser *user);
|
|
|
7dfda4 |
ActUserPasswordMode act_user_get_password_mode (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_password_hint (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_home_dir (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_shell (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_email (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_location (ActUser *user);
|
|
|
7dfda4 |
guint act_user_get_num_sessions (ActUser *user);
|
|
|
7dfda4 |
guint act_user_get_num_sessions_anywhere (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_is_logged_in (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_is_logged_in_anywhere (ActUser *user);
|
|
|
7dfda4 |
int act_user_get_login_frequency (ActUser *user);
|
|
|
7dfda4 |
gint64 act_user_get_login_time (ActUser *user);
|
|
|
7dfda4 |
const GVariant*act_user_get_login_history (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_get_locked (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_get_automatic_login (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_is_system_account (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_is_local_account (ActUser *user);
|
|
|
7dfda4 |
gboolean act_user_is_nonexistent (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_icon_file (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_language (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_x_session (ActUser *user);
|
|
|
7dfda4 |
+const char *act_user_get_session (ActUser *user);
|
|
|
7dfda4 |
+const char *act_user_get_session_type (ActUser *user);
|
|
|
7dfda4 |
const char *act_user_get_primary_session_id (ActUser *user);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
gint act_user_collate (ActUser *user1,
|
|
|
7dfda4 |
ActUser *user2);
|
|
|
7dfda4 |
gboolean act_user_is_loaded (ActUser *user);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
void act_user_get_password_expiration_policy (ActUser *user,
|
|
|
7dfda4 |
gint64 *expiration_time,
|
|
|
7dfda4 |
gint64 *last_change_time,
|
|
|
7dfda4 |
gint64 *min_days_between_changes,
|
|
|
7dfda4 |
gint64 *max_days_between_changes,
|
|
|
7dfda4 |
gint64 *days_to_warn,
|
|
|
7dfda4 |
gint64 *days_after_expiration_until_lock);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
void act_user_set_email (ActUser *user,
|
|
|
7dfda4 |
const char *email);
|
|
|
7dfda4 |
void act_user_set_language (ActUser *user,
|
|
|
7dfda4 |
const char *language);
|
|
|
7dfda4 |
void act_user_set_x_session (ActUser *user,
|
|
|
7dfda4 |
const char *x_session);
|
|
|
7dfda4 |
+void act_user_set_session (ActUser *user,
|
|
|
7dfda4 |
+ const char *session);
|
|
|
7dfda4 |
+void act_user_set_session_type (ActUser *user,
|
|
|
7dfda4 |
+ const char *session_type);
|
|
|
7dfda4 |
void act_user_set_location (ActUser *user,
|
|
|
7dfda4 |
const char *location);
|
|
|
7dfda4 |
void act_user_set_user_name (ActUser *user,
|
|
|
7dfda4 |
const char *user_name);
|
|
|
7dfda4 |
void act_user_set_real_name (ActUser *user,
|
|
|
7dfda4 |
const char *real_name);
|
|
|
7dfda4 |
void act_user_set_icon_file (ActUser *user,
|
|
|
7dfda4 |
const char *icon_file);
|
|
|
7dfda4 |
void act_user_set_account_type (ActUser *user,
|
|
|
7dfda4 |
ActUserAccountType account_type);
|
|
|
7dfda4 |
void act_user_set_password (ActUser *user,
|
|
|
7dfda4 |
const gchar *password,
|
|
|
7dfda4 |
const gchar *hint);
|
|
|
7dfda4 |
void act_user_set_password_hint (ActUser *user,
|
|
|
7dfda4 |
const gchar *hint);
|
|
|
7dfda4 |
void act_user_set_password_mode (ActUser *user,
|
|
|
7dfda4 |
ActUserPasswordMode password_mode);
|
|
|
7dfda4 |
void act_user_set_locked (ActUser *user,
|
|
|
7dfda4 |
gboolean locked);
|
|
|
7dfda4 |
void act_user_set_automatic_login (ActUser *user,
|
|
|
7dfda4 |
gboolean enabled);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
#if GLIB_CHECK_VERSION(2, 44, 0)
|
|
|
7dfda4 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ActUser, g_object_unref)
|
|
|
7dfda4 |
#endif
|
|
|
7dfda4 |
|
|
|
7dfda4 |
G_END_DECLS
|
|
|
7dfda4 |
|
|
|
7dfda4 |
#endif /* __ACT_USER_H__ */
|
|
|
7dfda4 |
diff --git a/src/user.c b/src/user.c
|
|
|
7dfda4 |
index 174530f..94c0244 100644
|
|
|
7dfda4 |
--- a/src/user.c
|
|
|
7dfda4 |
+++ b/src/user.c
|
|
|
7dfda4 |
@@ -232,60 +232,75 @@ user_update_from_pwent (User *user,
|
|
|
7dfda4 |
user->account_expiration_policy_known = TRUE;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
accounts_user_set_password_mode (ACCOUNTS_USER (user), mode);
|
|
|
7dfda4 |
is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)),
|
|
|
7dfda4 |
accounts_user_get_user_name (ACCOUNTS_USER (user)),
|
|
|
7dfda4 |
accounts_user_get_shell (ACCOUNTS_USER (user)),
|
|
|
7dfda4 |
passwd);
|
|
|
7dfda4 |
accounts_user_set_system_account (ACCOUNTS_USER (user), is_system_account);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
g_object_thaw_notify (G_OBJECT (user));
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
void
|
|
|
7dfda4 |
user_update_from_keyfile (User *user,
|
|
|
7dfda4 |
GKeyFile *keyfile)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
gchar *s;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
g_object_freeze_notify (G_OBJECT (user));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
s = g_key_file_get_string (keyfile, "User", "Language", NULL);
|
|
|
7dfda4 |
if (s != NULL) {
|
|
|
7dfda4 |
accounts_user_set_language (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
s = g_key_file_get_string (keyfile, "User", "XSession", NULL);
|
|
|
7dfda4 |
if (s != NULL) {
|
|
|
7dfda4 |
accounts_user_set_xsession (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ /* for backward compat */
|
|
|
7dfda4 |
+ accounts_user_set_session (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
+ g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ s = g_key_file_get_string (keyfile, "User", "Session", NULL);
|
|
|
7dfda4 |
+ if (s != NULL) {
|
|
|
7dfda4 |
+ accounts_user_set_session (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
+ g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ s = g_key_file_get_string (keyfile, "User", "SessionType", NULL);
|
|
|
7dfda4 |
+ if (s != NULL) {
|
|
|
7dfda4 |
+ accounts_user_set_session_type (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
s = g_key_file_get_string (keyfile, "User", "Email", NULL);
|
|
|
7dfda4 |
if (s != NULL) {
|
|
|
7dfda4 |
accounts_user_set_email (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
s = g_key_file_get_string (keyfile, "User", "Location", NULL);
|
|
|
7dfda4 |
if (s != NULL) {
|
|
|
7dfda4 |
accounts_user_set_location (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
s = g_key_file_get_string (keyfile, "User", "PasswordHint", NULL);
|
|
|
7dfda4 |
if (s != NULL) {
|
|
|
7dfda4 |
accounts_user_set_password_hint (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
s = g_key_file_get_string (keyfile, "User", "Icon", NULL);
|
|
|
7dfda4 |
if (s != NULL) {
|
|
|
7dfda4 |
accounts_user_set_icon_file (ACCOUNTS_USER (user), s);
|
|
|
7dfda4 |
g_clear_pointer (&s, g_free);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (g_key_file_has_key (keyfile, "User", "SystemAccount", NULL)) {
|
|
|
7dfda4 |
gboolean system_account;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
@@ -299,60 +314,66 @@ user_update_from_keyfile (User *user,
|
|
|
7dfda4 |
|
|
|
7dfda4 |
g_object_thaw_notify (G_OBJECT (user));
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
void
|
|
|
7dfda4 |
user_update_local_account_property (User *user,
|
|
|
7dfda4 |
gboolean local)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
accounts_user_set_local_account (ACCOUNTS_USER (user), local);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
void
|
|
|
7dfda4 |
user_update_system_account_property (User *user,
|
|
|
7dfda4 |
gboolean system)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
accounts_user_set_system_account (ACCOUNTS_USER (user), system);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
static void
|
|
|
7dfda4 |
user_save_to_keyfile (User *user,
|
|
|
7dfda4 |
GKeyFile *keyfile)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_key_file_remove_group (keyfile, "User", NULL);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (accounts_user_get_email (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
g_key_file_set_string (keyfile, "User", "Email", accounts_user_get_email (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (accounts_user_get_language (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
g_key_file_set_string (keyfile, "User", "Language", accounts_user_get_language (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
+ if (accounts_user_get_session (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
+ g_key_file_set_string (keyfile, "User", "Session", accounts_user_get_session (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (accounts_user_get_session_type (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
+ g_key_file_set_string (keyfile, "User", "SessionType", accounts_user_get_session_type (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
if (accounts_user_get_xsession (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
g_key_file_set_string (keyfile, "User", "XSession", accounts_user_get_xsession (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (accounts_user_get_location (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
g_key_file_set_string (keyfile, "User", "Location", accounts_user_get_location (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (accounts_user_get_password_hint (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
g_key_file_set_string (keyfile, "User", "PasswordHint", accounts_user_get_password_hint (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (accounts_user_get_icon_file (ACCOUNTS_USER (user)))
|
|
|
7dfda4 |
g_key_file_set_string (keyfile, "User", "Icon", accounts_user_get_icon_file (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
g_key_file_set_boolean (keyfile, "User", "SystemAccount", accounts_user_get_system_account (ACCOUNTS_USER (user)));
|
|
|
7dfda4 |
|
|
|
7dfda4 |
user_set_cached (user, TRUE);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
static void
|
|
|
7dfda4 |
save_extra_data (User *user)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
g_autofree gchar *data = NULL;
|
|
|
7dfda4 |
g_autofree gchar *filename = NULL;
|
|
|
7dfda4 |
g_autoptr(GError) error = NULL;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
user_save_to_keyfile (user, user->keyfile);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
data = g_key_file_to_data (user->keyfile, NULL, &error);
|
|
|
7dfda4 |
if (data == NULL) {
|
|
|
7dfda4 |
g_warning ("Saving data for user %s failed: %s",
|
|
|
7dfda4 |
accounts_user_get_user_name (ACCOUNTS_USER (user)), error->message);
|
|
|
7dfda4 |
@@ -996,60 +1017,158 @@ static gboolean
|
|
|
7dfda4 |
user_set_language (AccountsUser *auser,
|
|
|
7dfda4 |
GDBusMethodInvocation *context,
|
|
|
7dfda4 |
const gchar *language)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
User *user = (User*)auser;
|
|
|
7dfda4 |
int uid;
|
|
|
7dfda4 |
const gchar *action_id;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (!get_caller_uid (context, &uid)) {
|
|
|
7dfda4 |
throw_error (context, ERROR_FAILED, "identifying caller failed");
|
|
|
7dfda4 |
return FALSE;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
|
|
|
7dfda4 |
action_id = "org.freedesktop.accounts.change-own-user-data";
|
|
|
7dfda4 |
else
|
|
|
7dfda4 |
action_id = "org.freedesktop.accounts.user-administration";
|
|
|
7dfda4 |
|
|
|
7dfda4 |
daemon_local_check_auth (user->daemon,
|
|
|
7dfda4 |
user,
|
|
|
7dfda4 |
action_id,
|
|
|
7dfda4 |
TRUE,
|
|
|
7dfda4 |
user_change_language_authorized_cb,
|
|
|
7dfda4 |
context,
|
|
|
7dfda4 |
g_strdup (language),
|
|
|
7dfda4 |
(GDestroyNotify)g_free);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
return TRUE;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
+static void
|
|
|
7dfda4 |
+user_change_session_authorized_cb (Daemon *daemon,
|
|
|
7dfda4 |
+ User *user,
|
|
|
7dfda4 |
+ GDBusMethodInvocation *context,
|
|
|
7dfda4 |
+ gpointer user_data)
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ const gchar *session = user_data;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (g_strcmp0 (accounts_user_get_session (ACCOUNTS_USER (user)), session) != 0) {
|
|
|
7dfda4 |
+ accounts_user_set_session (ACCOUNTS_USER (user), session);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ save_extra_data (user);
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ accounts_user_complete_set_session (ACCOUNTS_USER (user), context);
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+static gboolean
|
|
|
7dfda4 |
+user_set_session (AccountsUser *auser,
|
|
|
7dfda4 |
+ GDBusMethodInvocation *context,
|
|
|
7dfda4 |
+ const gchar *session)
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ User *user = (User*)auser;
|
|
|
7dfda4 |
+ int uid;
|
|
|
7dfda4 |
+ const gchar *action_id;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (!get_caller_uid (context, &uid)) {
|
|
|
7dfda4 |
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
|
|
|
7dfda4 |
+ return FALSE;
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
|
|
|
7dfda4 |
+ action_id = "org.freedesktop.accounts.change-own-user-data";
|
|
|
7dfda4 |
+ else
|
|
|
7dfda4 |
+ action_id = "org.freedesktop.accounts.user-administration";
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ daemon_local_check_auth (user->daemon,
|
|
|
7dfda4 |
+ user,
|
|
|
7dfda4 |
+ action_id,
|
|
|
7dfda4 |
+ TRUE,
|
|
|
7dfda4 |
+ user_change_session_authorized_cb,
|
|
|
7dfda4 |
+ context,
|
|
|
7dfda4 |
+ g_strdup (session),
|
|
|
7dfda4 |
+ (GDestroyNotify) g_free);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ return TRUE;
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+static void
|
|
|
7dfda4 |
+user_change_session_type_authorized_cb (Daemon *daemon,
|
|
|
7dfda4 |
+ User *user,
|
|
|
7dfda4 |
+ GDBusMethodInvocation *context,
|
|
|
7dfda4 |
+ gpointer user_data)
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ const gchar *session_type = user_data;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (g_strcmp0 (accounts_user_get_session_type (ACCOUNTS_USER (user)), session_type) != 0) {
|
|
|
7dfda4 |
+ accounts_user_set_session_type (ACCOUNTS_USER (user), session_type);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ save_extra_data (user);
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ accounts_user_complete_set_session_type (ACCOUNTS_USER (user), context);
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+static gboolean
|
|
|
7dfda4 |
+user_set_session_type (AccountsUser *auser,
|
|
|
7dfda4 |
+ GDBusMethodInvocation *context,
|
|
|
7dfda4 |
+ const gchar *session_type)
|
|
|
7dfda4 |
+{
|
|
|
7dfda4 |
+ User *user = (User*)auser;
|
|
|
7dfda4 |
+ int uid;
|
|
|
7dfda4 |
+ const gchar *action_id;
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (!get_caller_uid (context, &uid)) {
|
|
|
7dfda4 |
+ throw_error (context, ERROR_FAILED, "identifying caller failed");
|
|
|
7dfda4 |
+ return FALSE;
|
|
|
7dfda4 |
+ }
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ if (accounts_user_get_uid (ACCOUNTS_USER (user)) == (uid_t) uid)
|
|
|
7dfda4 |
+ action_id = "org.freedesktop.accounts.change-own-user-data";
|
|
|
7dfda4 |
+ else
|
|
|
7dfda4 |
+ action_id = "org.freedesktop.accounts.user-administration";
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ daemon_local_check_auth (user->daemon,
|
|
|
7dfda4 |
+ user,
|
|
|
7dfda4 |
+ action_id,
|
|
|
7dfda4 |
+ TRUE,
|
|
|
7dfda4 |
+ user_change_session_type_authorized_cb,
|
|
|
7dfda4 |
+ context,
|
|
|
7dfda4 |
+ g_strdup (session_type),
|
|
|
7dfda4 |
+ (GDestroyNotify) g_free);
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
+ return TRUE;
|
|
|
7dfda4 |
+}
|
|
|
7dfda4 |
+
|
|
|
7dfda4 |
static void
|
|
|
7dfda4 |
user_change_x_session_authorized_cb (Daemon *daemon,
|
|
|
7dfda4 |
User *user,
|
|
|
7dfda4 |
GDBusMethodInvocation *context,
|
|
|
7dfda4 |
gpointer data)
|
|
|
7dfda4 |
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
gchar *x_session = data;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (g_strcmp0 (accounts_user_get_xsession (ACCOUNTS_USER (user)), x_session) != 0) {
|
|
|
7dfda4 |
accounts_user_set_xsession (ACCOUNTS_USER (user), x_session);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
save_extra_data (user);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
accounts_user_complete_set_xsession (ACCOUNTS_USER (user), context);
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
static gboolean
|
|
|
7dfda4 |
user_set_x_session (AccountsUser *auser,
|
|
|
7dfda4 |
GDBusMethodInvocation *context,
|
|
|
7dfda4 |
const gchar *x_session)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
User *user = (User*)auser;
|
|
|
7dfda4 |
int uid;
|
|
|
7dfda4 |
const gchar *action_id;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
if (!get_caller_uid (context, &uid)) {
|
|
|
7dfda4 |
throw_error (context, ERROR_FAILED, "identifying caller failed");
|
|
|
7dfda4 |
return FALSE;
|
|
|
7dfda4 |
@@ -1966,41 +2085,43 @@ user_finalize (GObject *object)
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
static void
|
|
|
7dfda4 |
user_class_init (UserClass *class)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
GObjectClass *gobject_class;
|
|
|
7dfda4 |
|
|
|
7dfda4 |
gobject_class = G_OBJECT_CLASS (class);
|
|
|
7dfda4 |
|
|
|
7dfda4 |
gobject_class->finalize = user_finalize;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
static void
|
|
|
7dfda4 |
user_accounts_user_iface_init (AccountsUserIface *iface)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
iface->handle_set_account_type = user_set_account_type;
|
|
|
7dfda4 |
iface->handle_set_automatic_login = user_set_automatic_login;
|
|
|
7dfda4 |
iface->handle_set_email = user_set_email;
|
|
|
7dfda4 |
iface->handle_set_home_directory = user_set_home_directory;
|
|
|
7dfda4 |
iface->handle_set_icon_file = user_set_icon_file;
|
|
|
7dfda4 |
iface->handle_set_language = user_set_language;
|
|
|
7dfda4 |
iface->handle_set_location = user_set_location;
|
|
|
7dfda4 |
iface->handle_set_locked = user_set_locked;
|
|
|
7dfda4 |
iface->handle_set_password = user_set_password;
|
|
|
7dfda4 |
iface->handle_set_password_mode = user_set_password_mode;
|
|
|
7dfda4 |
iface->handle_set_password_hint = user_set_password_hint;
|
|
|
7dfda4 |
iface->handle_set_real_name = user_set_real_name;
|
|
|
7dfda4 |
iface->handle_set_shell = user_set_shell;
|
|
|
7dfda4 |
iface->handle_set_user_name = user_set_user_name;
|
|
|
7dfda4 |
iface->handle_set_xsession = user_set_x_session;
|
|
|
7dfda4 |
+ iface->handle_set_session = user_set_session;
|
|
|
7dfda4 |
+ iface->handle_set_session_type = user_set_session_type;
|
|
|
7dfda4 |
iface->handle_get_password_expiration_policy = user_get_password_expiration_policy;
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
|
|
|
7dfda4 |
static void
|
|
|
7dfda4 |
user_init (User *user)
|
|
|
7dfda4 |
{
|
|
|
7dfda4 |
user->system_bus_connection = NULL;
|
|
|
7dfda4 |
user->default_icon_file = NULL;
|
|
|
7dfda4 |
user->login_history = NULL;
|
|
|
7dfda4 |
user->keyfile = g_key_file_new ();
|
|
|
7dfda4 |
}
|
|
|
7dfda4 |
--
|
|
|
7dfda4 |
2.17.1
|
|
|
7dfda4 |
|