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

Deal with absolute paths to log files #1756

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

mikhailnov
Copy link

@mikhailnov mikhailnov commented Jul 6, 2023

If path begins with "/", consider it to be an absolute path, not relative to $HOME

Example: SessionLogFile=/dev/null

Co-authored-by: Artem Proskurnev ProskurnevAS@edu.mos.ru (@temaps)
Signed-off-by: Mikhail Novosyolov m.novosyolov@rosalinux.ru

? mainConfig.X11.SessionLogFile.get()
: mainConfig.Wayland.SessionLogFile.get());
QString sessionLog;
if ( (sessionType == QLatin1String("x11")) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can invert this and check for wayland instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A colleague of mine noted that this is session type (x11 or wayland), not x11/x11-user/wayland, sorry. I've fixed the code and the commit message.

@Vogtinator
Copy link
Contributor

LGTM but I wonder whether there is any use for absolute paths other than /dev/null. All users would end up with the same absolute path to the log file so they would just overwrite each other.

@mikhailnov
Copy link
Author

LGTM but I wonder whether there is any use for absolute paths other than /dev/null. All users would end up with the same absolute path to the log file so they would just overwrite each other.

It's a good question, but maybe someone would want to configure autologin and write logs to somewhere ouside of user home directory.

Actually I did all that to set X11.SessionCommand "/usr/bin/systemd-cat /usr/share/X11/xdm/Xsession" by default in ROSA Linux package (https://abf.io/import/sddm). I dislike logging into files and want logs to be stored in systemd-journald as in gdm.

@Vogtinator
Copy link
Contributor

Actually I did all that to set X11.SessionCommand "/usr/bin/systemd-cat /usr/share/X11/xdm/Xsession" by default in ROSA Linux package (https://abf.io/import/sddm). I dislike logging into files and want logs to be stored in systemd-journald as in gdm.

Sounds like a better feature. Just not redirecting at all should do the trick, because sddm already outputs into the journal.

@mikhailnov
Copy link
Author

Hm, thanks for noting this, I did not notice that sddm already outputs into the journal even without systemd-cat, maybe I tried an old version

@Vogtinator
Copy link
Contributor

Vogtinator commented Jul 6, 2023

Hm, thanks for noting this, I did not notice that sddm already outputs into the journal even without systemd-cat, maybe I tried an old version

SDDM itself does, but for the session it redirects the output to a file so that is lost. It could be configurable whether it redirects at all.

Or sddm-helper could learn how to communicate with systemd to log into the user journal. Not sure how involved that would be.

@mikhailnov
Copy link
Author

Seems that my mind is messed up. systemd-cat does not make stderr in e.g. openbox to appear in journald. Byt it appears both with and wihtout it in KDE, probably because KDE does it itself (or by running apps via systemd).

@Vogtinator
Copy link
Contributor

Byt it appears both with and wihtout it in KDE, probably because KDE does it itself (or by running apps via systemd).

Yes, Plasma itself and everything started by it runs as/within systemd units

@mikhailnov
Copy link
Author

Which DE can it be tested with? I tried openbox, SessionLogFile (not /dev/null) is empty...

If path begins with "/", consider it to be an absolute path, not relative to $HOME

Example: SessionLogFile=/dev/null

Co-authored-by: Artem Proskurnev <ProskurnevAS@edu.mos.ru> (@temaps)
Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
@Vogtinator
Copy link
Contributor

Which DE can it be tested with? I tried openbox, SessionLogFile (not /dev/null) is empty...

Most small DEs should work, there any started application should have that as stdout+stderr

@evelikov
Copy link
Contributor

Thinking out loud:

On my Arch box sddm-helper is running as root. So I wonder if allowing for absolute path can backfire in some odd way - say my mistake you set /home/user/some/path/file where you effectively destroy some semi-meaningful file that belongs to others.

Does that make sense? Or I guess the proper way forward is to run all sddm programs as non-root?

@Vogtinator
Copy link
Contributor

Thinking out loud:

On my Arch box sddm-helper is running as root. So I wonder if allowing for absolute path can backfire in some odd way - say my mistake you set /home/user/some/path/file where you effectively destroy some semi-meaningful file that belongs to others.

That's basically #1756 (comment)

Does that make sense? Or I guess the proper way forward is to run all sddm programs as non-root?

The logfile is opened after setuid, so permission checks are done as the target user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants