Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to set location of .xsession-errors #390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ config_init (Configuration *config)
g_hash_table_insert (config->priv->lightdm_keys, "greeters-directory", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->lightdm_keys, "backup-logs", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->lightdm_keys, "dbus-service", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->lightdm_keys, "xsession-errors-path", GINT_TO_POINTER (KEY_SUPPORTED));
g_hash_table_insert (config->priv->lightdm_keys, "logind-load-seats", GINT_TO_POINTER (KEY_DEPRECATED));

g_hash_table_insert (config->priv->seat_keys, "type", GINT_TO_POINTER (KEY_SUPPORTED));
Expand Down
2 changes: 2 additions & 0 deletions data/lightdm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# greeters-directory = Directory to find greeters
# backup-logs = True to move add a .old suffix to old log files when opening new ones
# dbus-service = True if LightDM provides a D-Bus service to control it
# xsession-errors-path = Log file for X session errors, relative to $HOME. Supports environment expansion.
#
[LightDM]
#start-default-seat=true
Expand All @@ -35,6 +36,7 @@
#greeters-directory=$XDG_DATA_DIRS/lightdm/greeters:$XDG_DATA_DIRS/xgreeters
#backup-logs=true
#dbus-service=true
#xsession-errors-path=.xsession-errors

#
# Seat configuration
Expand Down
2 changes: 2 additions & 0 deletions src/lightdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ main (int argc, char **argv)
config_set_boolean (config_get_instance (), "LightDM", "backup-logs", TRUE);
if (!config_has_key (config_get_instance (), "LightDM", "dbus-service"))
config_set_boolean (config_get_instance (), "LightDM", "dbus-service", TRUE);
if (!config_has_key (config_get_instance (), "LightDM", "xsession-errors-path"))
config_set_string (config_get_instance (), "LightDM", "xsession-errors-path", ".xsession-errors");
if (!config_has_key (config_get_instance (), "Seat:*", "type"))
config_set_string (config_get_instance (), "Seat:*", "type", "local");
if (!config_has_key (config_get_instance (), "Seat:*", "pam-service"))
Expand Down
32 changes: 31 additions & 1 deletion src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <grp.h>
#include <pwd.h>
Expand Down Expand Up @@ -995,12 +996,41 @@ session_get_is_stopping (Session *session)
return priv->stopping;
}

static gboolean
expand_cb (const GMatchInfo *info, GString *result, gpointer data)
{
gchar *match;
const gchar *env_text;

match = g_match_info_fetch (info, 1);
env_text = g_getenv (match);
if (env_text)
{
g_string_append (result, env_text);
};
g_free (match);

return FALSE;
}

static gchar *
expand_environment (const gchar *text)
{
GRegex *pattern;
gchar *result;

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);
result = g_regex_replace_eval (pattern, text, -1, 0, 0, expand_cb, NULL, NULL);

return result;
}

static void
session_init (Session *session)
{
SessionPrivate *priv = session_get_instance_private (session);

priv->log_filename = g_strdup (".xsession-errors");
priv->log_filename = expand_environment (config_get_string (config_get_instance(), "LightDM", "xsession-errors-path"));
priv->log_mode = LOG_MODE_BACKUP_AND_TRUNCATE;
priv->to_child_input = -1;
priv->from_child_output = -1;
Expand Down
Loading