Skip to content

Commit 7d6d791

Browse files
author
root
committed
Allow users to set location of .xsession-errors
1 parent f043bfd commit 7d6d791

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

common/configuration.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ config_init (Configuration *config)
346346
g_hash_table_insert (config->priv->lightdm_keys, "greeters-directory", GINT_TO_POINTER (KEY_SUPPORTED));
347347
g_hash_table_insert (config->priv->lightdm_keys, "backup-logs", GINT_TO_POINTER (KEY_SUPPORTED));
348348
g_hash_table_insert (config->priv->lightdm_keys, "dbus-service", GINT_TO_POINTER (KEY_SUPPORTED));
349+
g_hash_table_insert (config->priv->lightdm_keys, "xsession-errors-path", GINT_TO_POINTER (KEY_SUPPORTED));
349350
g_hash_table_insert (config->priv->lightdm_keys, "logind-load-seats", GINT_TO_POINTER (KEY_DEPRECATED));
350351

351352
g_hash_table_insert (config->priv->seat_keys, "type", GINT_TO_POINTER (KEY_SUPPORTED));

data/lightdm.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# greeters-directory = Directory to find greeters
1818
# backup-logs = True to move add a .old suffix to old log files when opening new ones
1919
# dbus-service = True if LightDM provides a D-Bus service to control it
20+
# xsession-errors-path = Log file for X session errors, relative to $HOME. Supports environment expansion.
2021
#
2122
[LightDM]
2223
#start-default-seat=true
@@ -35,6 +36,7 @@
3536
#greeters-directory=$XDG_DATA_DIRS/lightdm/greeters:$XDG_DATA_DIRS/xgreeters
3637
#backup-logs=true
3738
#dbus-service=true
39+
#xsession-errors-path=.xsession-errors
3840

3941
#
4042
# Seat configuration

src/lightdm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,8 @@ main (int argc, char **argv)
773773
config_set_boolean (config_get_instance (), "LightDM", "backup-logs", TRUE);
774774
if (!config_has_key (config_get_instance (), "LightDM", "dbus-service"))
775775
config_set_boolean (config_get_instance (), "LightDM", "dbus-service", TRUE);
776+
if (!config_has_key (config_get_instance (), "LightDM", "xsession-errors-path"))
777+
config_set_string (config_get_instance (), "LightDM", "xsession-errors-path", ".xsession-errors");
776778
if (!config_has_key (config_get_instance (), "Seat:*", "type"))
777779
config_set_string (config_get_instance (), "Seat:*", "type", "local");
778780
if (!config_has_key (config_get_instance (), "Seat:*", "pam-service"))

src/session.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <unistd.h>
1818
#include <sys/wait.h>
1919
#include <fcntl.h>
20+
#include <glib.h>
2021
#include <glib/gstdio.h>
2122
#include <grp.h>
2223
#include <pwd.h>
@@ -995,12 +996,41 @@ session_get_is_stopping (Session *session)
995996
return priv->stopping;
996997
}
997998

999+
static gboolean
1000+
expand_cb (const GMatchInfo *info, GString *result, gpointer data)
1001+
{
1002+
gchar *match;
1003+
const gchar *env_text;
1004+
1005+
match = g_match_info_fetch (info, 1);
1006+
env_text = g_getenv (match);
1007+
if (env_text)
1008+
{
1009+
g_string_append (result, env_text);
1010+
};
1011+
g_free (match);
1012+
1013+
return FALSE;
1014+
}
1015+
1016+
static gchar *
1017+
expand_environment (const gchar *text)
1018+
{
1019+
GRegex *pattern;
1020+
gchar *result;
1021+
1022+
pattern = g_regex_new("\\$(?|\\{([a-zA-Z_][a-zA-Z_0-9]*)\\}|([a-zA-Z_][a-zA-Z_0-9]*))", G_REGEX_RAW, G_REGEX_MATCH_DEFAULT, NULL);
1023+
result = g_regex_replace_eval (pattern, text, -1, 0, 0, expand_cb, NULL, NULL);
1024+
1025+
return result;
1026+
}
1027+
9981028
static void
9991029
session_init (Session *session)
10001030
{
10011031
SessionPrivate *priv = session_get_instance_private (session);
10021032

1003-
priv->log_filename = g_strdup (".xsession-errors");
1033+
priv->log_filename = expand_environment (config_get_string (config_get_instance(), "LightDM", "xsession-errors-path"));
10041034
priv->log_mode = LOG_MODE_BACKUP_AND_TRUNCATE;
10051035
priv->to_child_input = -1;
10061036
priv->from_child_output = -1;

0 commit comments

Comments
 (0)