After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 792150 - Environment variable DISPLAY and XAUTHORITY equal (null)
Environment variable DISPLAY and XAUTHORITY equal (null)
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
3.26.x
Other Linux
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2018-01-03 07:31 UTC by xiaoguang wang
Modified: 2018-01-08 18:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoiding DISPLAY and XAUTHORITY equal (null) (1.48 KB, patch)
2018-01-03 07:52 UTC, xiaoguang wang
none Details | Review
common: don't run scripts with bogus DISPLAY and XAUTHORITY (3.49 KB, patch)
2018-01-04 16:12 UTC, Ray Strode [halfline]
committed Details | Review

Description xiaoguang wang 2018-01-03 07:31:18 UTC
After commit https://git.gnome.org/browse/gdm/commit/?id=5683e5d, environment variable DISPLAY and XAUTHORITY equal (null) before they get the real value.

For example:
1. add a line in file /etc/gdm/PreSession/Default 
   for i in $(env); do echo PreSession script: $i; done

2. open gdm debug info, change file /etc/gdm/custom.conf
   [debug]
   # Uncomment the line below to turn on debugging
   Enable=true

In journal log you can see:
   gdm-session-worker[1822]: PreSession script: DISPLAY=(null)
   gdm-session-worker[1822]: PreSession script: XAUTHORITY=(null)

This will make some scripts running fail if script depends on these two environment variables.
Comment 1 xiaoguang wang 2018-01-03 07:52:01 UTC
Created attachment 366237 [details] [review]
Avoiding DISPLAY and XAUTHORITY equal (null)
Comment 2 Ray Strode [halfline] 2018-01-03 14:06:03 UTC
Review of attachment 366237 [details] [review]:

hey thanks for the patch! my first question is, is this fixed by commit e3f731c5ef ?  Is this only for wayland sessions?

::: daemon/gdm-session.c
@@ +2253,3 @@
                 g_variant_builder_add_parsed (&details, "{'x11-display-name', <%s>}", self->priv->display_name);
+        else
+                g_variant_builder_add_parsed (&details, "{'x11-display-name', <%s>}", "");

Thing is, we don't want DISPLAY and AUTHORITY set to "" if they're NULL, we really do want them set to NULL.
Comment 3 xiaoguang wang 2018-01-04 02:17:02 UTC
(In reply to Ray Strode [halfline] from comment #2)
> Review of attachment 366237 [details] [review] [review]:
> 
> hey thanks for the patch! my first question is, is this fixed by commit
> e3f731c5ef ?

Commit e3f731c5ef did not fixed this, my test environment has included commit 
e3f731c5ef.

>  Is this only for wayland sessions?

X session and wayland session both have this problem.

> ::: daemon/gdm-session.c
> @@ +2253,3 @@
>                  g_variant_builder_add_parsed (&details,
> "{'x11-display-name', <%s>}", self->priv->display_name);
> +        else
> +                g_variant_builder_add_parsed (&details,
> "{'x11-display-name', <%s>}", "");
> 
> Thing is, we don't want DISPLAY and AUTHORITY set to "" if they're NULL, we
> really do want them set to NULL.

Yes, setting DISPLAY and AUTHORITY to "" is not the best way. I think the better way is, when DISPLAY and AUTHORITY is NULL, don't set environment variable DISPLAY and AUTHORITY, don't let them equal (null). It is weird environment variable equals (null).

This problem really makes some script fail. We add xdm script in PreSession, this makes script fail and login process fail and back to gdm login screen. We want to find a way to solve it from gdm side.
Comment 4 Ray Strode [halfline] 2018-01-04 16:12:20 UTC
Created attachment 366307 [details] [review]
common: don't run scripts with bogus DISPLAY and XAUTHORITY

DISPLAY and XAUTHORITY might not be set if we're starting the
X server as part of the session.

In that case we should ensure the variables aren't set in the
environment of the gdm session scripts.

This commit fixes that.
Comment 5 Ray Strode [halfline] 2018-01-04 16:13:23 UTC
can you give that a try ⬆  ?
Comment 6 xiaoguang wang 2018-01-05 02:02:49 UTC
(In reply to Ray Strode [halfline] from comment #5)
> can you give that a try ⬆  ?

It works. Thanks for your solution.
Comment 7 Ray Strode [halfline] 2018-01-08 18:29:03 UTC
Attachment 366307 [details] pushed as 5dd631c - common: don't run scripts with bogus DISPLAY and XAUTHORITY