DouglasNeuroInformatics / ansible-playbooks

Playbooks for configuring CIC Workstations and Servers
4 stars 11 forks source link

Xsession error file path redirect #75

Closed thomasbeaudry closed 11 months ago

thomasbeaudry commented 11 months ago

I don't know how to artificially test this! I've spent too long trying to figure out how. Maybe we just test it in action. This PR addresses #71

gdevenyi commented 11 months ago

Your machine is always acceptable as a test bed, you can limit the playbook to test new things.

gdevenyi commented 11 months ago

This file is generated on any graphical login, so you can push, logout/login and see what happens.

gdevenyi commented 11 months ago

Success?

thomasbeaudry commented 11 months ago

No.

if I modify the Xsession file directly it works though. I also added a debug message to the Xsession.d file and i see the it runs, so the ERRFILE path is getting set somewhere else downstream

thomasbeaudry commented 11 months ago

I just read the Xsession file, and essentially the Xsession.d config files get read at the end of it. The default ERRFILE path is used before these config files are ever used, so for instance, it creates the .xsession-error file if it doesn't exist.

So the only way to know if the Xsession.d config file really works is to use the system and wait for an error to occur to see if it writes the error to the new path. If we keep this setup, we will have 2 .xsession-error files though.

gdevenyi commented 11 months ago

My read of the file: image

ERRFILE is defined, and then all files in Xsession.d are loaded. Your file should redefined ERRFILE successfully.

Then the ERRFILE is created. image

As for testing, .xsession-errors is logging the stdout and stderr of the Xsession, which immediately at login has content.

thomasbeaudry commented 11 months ago

Xsession.d is defined here:

image

and then used here at the end of the file:

image
gdevenyi commented 11 months ago

Got it. I was reading the code for /etc/X11/Xsession.options.d which is different.

The solution here is https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html

Which has a REGEX feature for reliably finding/replacing a line. We can directly replace this line:

ERRFILE=$HOME/.xsession-errors

With the rewritten one.

Going to close this PR as it'll be a completely different implementation.