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

display-managers: Fix the xsession parameters #25138

Merged
merged 1 commit into from Apr 28, 2017

Conversation

primeos
Copy link
Member

@primeos primeos commented Apr 23, 2017

From the specification: "Quoting must be done by enclosing the argument
between double quotes" 0.

Tested with:
  • SDDM
  • LightDM
  • SLiM
  • GDM (fails to build on master and seems to be broken on 17.03)
  • auto (ignores the desktop entry files (i.e. doesn't provide any parameters to the script))

On nixos-unstable (with a VirtualBox VM).

Note: I've run into some very strange bugs.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS

@mention-bot
Copy link

@primeos, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @nbp and @vcunat to be potential reviewers.

@Mic92
Copy link
Member

Mic92 commented Apr 23, 2017

This does not fix the problem with sddm. I actually find the current display-manager script too complex and would actually prefer to have a script per desktop file instead of relying on shell scripts parsing.

@primeos
Copy link
Member Author

primeos commented Apr 23, 2017

@Mic92 Are you running NixOS 17.03? On nixos-unstable it seems like the xsession script doesn't actually get any parameters (at least that's the case on both of my GUI systems...).

I actually find the current display-manager script too complex

Agreed 😄

would actually prefer to have a script per desktop file instead of relying on shell scripts parsing.

I'd rather improve the documentation/comments and refactor the code. Normally I would expect that the xsession script is getting called like this: /nix/store/XXX-xsession none\ +\ i3 which shouldn't be that problematic to parse ($1=none\ +\ i3 or $2, if $0=$1 which seems to be the case).

@Mic92
Copy link
Member

Mic92 commented Apr 25, 2017

Here is what I get:

Apr 25 20:56:15 turingmachine xsession[29898]: first: none
Apr 25 20:56:15 turingmachine xsession[29898]: second: +
Apr 25 20:56:15 turingmachine xsession[29898]: third: awesome
Apr 25 20:56:15 turingmachine xsession[29898]: forth:
Apr 25 20:56:15 turingmachine xsession[29898]: fifth:
Apr 25 20:56:15 turingmachine xsession[29898]: first: none
Apr 25 20:56:15 turingmachine xsession[29898]: second:
Apr 25 20:56:15 turingmachine xsession[29898]: third:
Apr 25 20:56:15 turingmachine xsession[29898]: forth:
Apr 25 20:56:15 turingmachine xsession[29898]: fifth:
Apr 25 20:56:15 turingmachine xsession[29898]: 28

I added the following:

  # Handle being called by SDDM.
   if test "''${1:0:1}" = / ; then eval exec $1 $2 ; fi
+ echo "first: $1"
+ echo "second: $2"
+ echo "third: $3"
+ echo "forth: $4"
+ echo "fifth: $5"

it is rexeced twice. It may work for you because you are using a desktop manager rather then a window manager.

@primeos
Copy link
Member Author

primeos commented Apr 28, 2017

It may work for you because you are using a desktop manager rather then a window manager.

It actually doesn't but looking at the specification I hoped it would. I expected that $1 would contain "DM + WM" but the specifications unfortunately doesn't say if the double quotes actually escape the spaces... :o This actually fixes lightdm but breaks slim and sddm. The current situation seems to be horribly broken -> I'll update this PR and change " + " to "+" (no spaces). This should fix everything for sddm and lightdm but will most likely break slim (I'll add a workaround if it doesn't work).

@primeos primeos force-pushed the display-manager branch 2 times, most recently from be0c338 to 52821f9 Compare April 28, 2017 17:12
@primeos primeos changed the title [WIP] display-managers: Fix Exec key quoting display-managers: Fix the xsession parameters Apr 28, 2017
@primeos primeos added 0.kind: enhancement 9.needs: port to stable A PR needs a backport to the stable release. labels Apr 28, 2017
@primeos
Copy link
Member Author

primeos commented Apr 28, 2017

This should fix "everything". I'll run some final tests and merge this in ~1-2h. If it doesn't cause any problems on nixos-unstable (I'll wait 1-2 weeks) I'll test this on 17.03 and backport it to stable if it doesn't cause any problems.

@primeos primeos self-assigned this Apr 28, 2017
@primeos primeos force-pushed the display-manager branch 2 times, most recently from b04dbf6 to 9a72550 Compare April 28, 2017 19:56
The xsession script was called with inconsistent (depending on the
display managers) and wrong parameters. The main reason for this where
the spaces the parameter syntax. In order to fix this the old syntax:
$1 = '<desktop-manager> + <window-manager>'
Will be replaced with a new syntax:
$1 = "<desktop-manager>+<window-manager>"

This assumes that neither "<desktop-manager>" nor "<window-manager>"
contain the "+" character but this shouldn't be a problem.

This patch also fixes the quoting by using double quotes (") instead of
single quotes (') [0].

Last but not least this'll add some comments for the better
understanding of the script.

[0]: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
@primeos primeos merged commit 1273f41 into NixOS:master Apr 28, 2017
@primeos
Copy link
Member Author

primeos commented Apr 28, 2017

Let's hope that this doesn't break anything :D
But it should be pretty save (tested with all login/display managers) and after I realized that it's a bad Idea to assume that stderr output won't be redirected to /dev/null everything made sense again (that's also why it looked like SDDM wasn't providing any parameters).

@primeos primeos mentioned this pull request Apr 29, 2017
7 tasks
@primeos
Copy link
Member Author

primeos commented May 6, 2017

Backported to 17.03 (c893d7a and 9283310) and tested with SDDM, LightDM and SLiM.

@samueldr samueldr removed the 9.needs: port to stable A PR needs a backport to the stable release. label Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants