summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/session.c3
-rw-r--r--src/xauth.c18
-rw-r--r--src/xauth.h4
3 files changed, 9 insertions, 16 deletions
diff --git a/src/session.c b/src/session.c
index 0e2bb926..61267f01 100644
--- a/src/session.c
+++ b/src/session.c
@@ -116,7 +116,8 @@ session_start (Session *session, gboolean create_pipe)
if (session->priv->authorization)
{
- session->priv->authorization_file = xauth_write (session->priv->authorization, user_get_name (session->priv->user), session->priv->authorization_path, &error);
+ g_debug ("Writing session authority to %s", session->priv->authorization_path);
+ session->priv->authorization_file = xauth_write (session->priv->authorization, session->priv->user, session->priv->authorization_path, &error);
if (session->priv->authorization_file)
child_process_set_env (CHILD_PROCESS (session), "XAUTHORITY", session->priv->authorization_path);
else
diff --git a/src/xauth.c b/src/xauth.c
index c1db6719..e4593648 100644
--- a/src/xauth.c
+++ b/src/xauth.c
@@ -15,7 +15,6 @@
#include <sys/stat.h>
#include "xauth.h"
-#include "user.h"
struct XAuthorizationPrivate
{
@@ -101,7 +100,7 @@ write_string (GString *string, const gchar *value)
}
GFile *
-xauth_write (XAuthorization *auth, const gchar *username, const gchar *path, GError **error)
+xauth_write (XAuthorization *auth, User *user, const gchar *path, GError **error)
{
GFile *file;
GFileOutputStream *stream;
@@ -121,19 +120,10 @@ xauth_write (XAuthorization *auth, const gchar *username, const gchar *path, GEr
/* NOTE: Would like to do:
* g_file_set_attribute_string (file, G_FILE_ATTRIBUTE_OWNER_USER, username, G_FILE_QUERY_INFO_NONE, NULL, error))
* but not supported. */
- if (username && getuid () == 0)
+ if (user && getuid () == 0)
{
- User *user;
-
- user = user_get_by_name (username);
- if (user)
- {
- if (chown (path, user_get_uid (user), user_get_gid (user)) < 0)
- g_warning ("Failed to set authorization owner: %s", strerror (errno));
- g_object_unref (user);
- }
- else
- g_warning ("Unable to set ownership on Xauth file - unable to get information on user %s", username);
+ if (chown (path, user_get_uid (user), user_get_gid (user)) < 0)
+ g_warning ("Failed to set authorization owner: %s", strerror (errno));
}
data = g_string_sized_new (1024);
diff --git a/src/xauth.h b/src/xauth.h
index 5f21c123..538e1704 100644
--- a/src/xauth.h
+++ b/src/xauth.h
@@ -15,6 +15,8 @@
#include <glib-object.h>
#include <gio/gio.h>
+#include "user.h"
+
G_BEGIN_DECLS
#define XAUTH_TYPE (xauth_get_type())
@@ -47,7 +49,7 @@ guchar *xauth_copy_authorization_data (XAuthorization *auth);
gsize xauth_get_authorization_data_length (XAuthorization *auth);
-GFile *xauth_write (XAuthorization *auth, const gchar *username, const gchar *path, GError **error);
+GFile *xauth_write (XAuthorization *auth, User *user, const gchar *path, GError **error);
G_END_DECLS