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 602403 - I can't get $USER $USERNAME $LOGNAME from /etc/gdm/PostLogin/Default
I can't get $USER $USERNAME $LOGNAME from /etc/gdm/PostLogin/Default
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: GDM maintainers
GDM maintainers
: 612982 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-11-19 13:00 UTC by ericlesoll
Modified: 2010-03-15 21:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch fixing problem (2.25 KB, patch)
2010-01-12 05:53 UTC, Brian Cameron
committed Details | Review
new patch for bug #602403 (3.95 KB, patch)
2010-01-13 08:22 UTC, Halton Huo
reviewed Details | Review

Description ericlesoll 2009-11-19 13:00:11 UTC
on Ubuntu Karmic Koala and Fedora 12
After a fresh install on some machines and update from Jaunty on another one, we can't catch $USER $USERNAME $LOGNAME
from /etc/gdm/PostLogin/Default, we get "gdm" for all variables instead of real login name. It was working since 7.04 version.
If in a terminal we run : echo $USER, we get the real login name.

example below :

If I put those 3 lines in /etc/gdm/PostLogin/Default:

echo $USER > /tmp/aaa.txt
echo $USERNAME >> /tmp/aaa.txt
echo $LOGNAME >> /tmp/aaa.txt

after every login I get this result:

$ cat /tmp/aaa.txt
gdm
gdm
gdm

I would expect to get my real login name in those 3 variables instead of "gdm", which is of no use to take specific action based on which user is logging in. This was working as expected with at least the 3 previous versions of Ubuntu.
Comment 1 Emmanuele Bassi (:ebassi) 2009-11-19 14:21:35 UTC
re-assign to the right product.
Comment 2 RobertC 2009-12-24 21:17:19 UTC
I can confirm the report sent by ericlesoll; I did the same test with the same result, using Ubuntu Karmic with gdm 2.28.1.


With Ubuntu Jaunty and several older Ubuntu releases we could get the real username in the $USER variable from /etc/gdm/PostLogin/Default, which is no more possible in Karmic where the returned value is always "gdm".

We need this in our school environment to take different action if a student or a teacher is logging in, especially to connect to Netware servers using the proper account and restore mandatory user profiles.
Comment 3 Manuel Iglesias 2010-01-02 15:01:33 UTC
I can also confirm the report, this is the environment variables for Postlogin/Default in Karmic with gdm 2.28 {
DISPLAY=:0
HOME=/var/lib/gdm
LOGNAME=gdm
PWD=/
RUNNING_UNDER_GDM=true
SHELL=/bin/false
SHLVL=1
USER=gdm
USERNAME=gdm
XAUTHORITY=/var/run/gdm/auth-for-gdm-VGUUzf/database
X_SERVERS=/var/gdm/:0.Xservers
_=/usr/bin/env
}

"$@" is empty too.

You can not write anything useful with this information :-(

Why is the status of this bug UNCONFIRMED?

Please take action to correct this soon!

Best regards,
Manolo.
Comment 4 Brian Cameron 2010-01-12 05:53:41 UTC
Created attachment 151224 [details] [review]
patch fixing problem


This patch fixes the problem.  The fix is pretty simple.  In daemon/gdm-simple-slave.c it just needs to call gdm_slave_run_script with the username instead of 
GDM_USERNAME.  It does make more sense for the PostLogin script to be passed the username instead of the "gdm" user.  This is how the old GDM worked.

This patch also fixes the following issues:

1) In daemon/gdm-slave.c it now sets PATH to GDM_SESSION_DEFAULT_PATH so that
   the scripts have the system normal PATH when run. 

   This is much better than hardcoding the PATH in the scripts themselves, 
   especially since the Init, PreSession, PostSession, and PostLogin scripts
   are designed to run per-display and it makes things just complicated if
   users need to add the common system path to any per-display script they
   might want to use.

2) The Init and PreSession scripts are fixed to set the PATH to "@X_PATH:$PATH"
   and not add "/bin:/usr/bin" since this isn't neeed since PATH is already
   set to GDM_SESSION_DEFAULT_PATH before running the script.
Comment 5 Manuel Iglesias 2010-01-12 10:13:25 UTC
Hi Brian!
Thank you for your help.
Your patch is for gdm-2.29.4, which version will have the problem fixed without applying a patch?
All of us, bug reporters, seem to be using Ubuntu9.10 Karmic, with gdm-28.X.
Wouldn't it be better to create backports so we, users, not gdm developers, can update our systems?

Best regards,
Manolo.
Comment 6 Halton Huo 2010-01-13 08:22:50 UTC
Created attachment 151316 [details] [review]
new patch for bug #602403

The previous patch #151224 will introduce another issue - gdm-simple-slave won't quit if gdm-binary died when no use selected.

After investigate, I found gdm_session_direct_get_username() is NULL when no user is choose or entered.

So I rework this patch to check whether user is NULL. If NULL, run PostLogin script as GDM, otherwise run as the entered user.

diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index b59976d..b94c84d 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -339,6 +339,8 @@ try_migrate_session (GdmSimpleSlave *slave)
 static void
 stop_greeter (GdmSimpleSlave *slave)
 {
+        char *username;
+
         g_debug ("GdmSimpleSlave: Stopping greeter");

         if (slave->priv->greeter == NULL) {
@@ -347,7 +349,12 @@ stop_greeter (GdmSimpleSlave *slave)
         }

         /* Run the PostLogin script. gdmslave suspends until script has terminated */
-        gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostLogin", GDM_USERNAME);
+        username = gdm_session_direct_get_username (slave->priv->session);
+        g_debug ("GdmSimpleGreeter: run script %s for %s", GDMCONFDIR "/PostLogin", username);
+        if (username)
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostLogin", username);
+        else
+                gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR "/PostLogin", GDM_USERNAME);

         gdm_welcome_session_stop (GDM_WELCOME_SESSION (slave->priv->greeter));
         gdm_greeter_server_stop (slave->priv->greeter_server);
Comment 7 Manuel Iglesias 2010-01-13 09:07:33 UTC
Thank you Brian and Halton,
The problem with patches is that we, users, have to compile the modified sources. I downloaded the source package for gdm-28.1, modified gdm-simple-slave.c source code and tried to compile: I could not run 'configure' without failure: There are many necessary packages missing in my system and some of them are not available in the usual Ubuntu repositories.

The ideal solution would be:

1) Admit this is a real bug and solve it in the current gdm version and all future versions. You say (In http://library.gnome.org/admin/gdm/2.29/configuration.html.en): "GDM will run the PostLogin script ... This script is useful for doing any session initialization that needs to happen before the session starts. For example, you might setup the user's $HOME directory if needed".
How can you setup the user's $HOME directory without knowing which user has just logged in?

2) Supply, platform specific, versions of the modified gdm-simple-slave binary for all previous versions with the bug (gdm-28.1) to the package maintainers.

3) Ask package maintainers to issue 'security updates' (or whatever they are called) for all versions with the bug, so that users of all Linux distributions that use gdm can update their systems.

Best regards,
Manolo.
Comment 8 Brian Cameron 2010-01-13 13:28:31 UTC
Manuel, I think everyone is happy to admit that this is a real bug.  Note that the upstream GNOME community does not provide platform specific binaries.  It is each distros responsibility to deliver the built source code to end-users.  

Have you filed this as a bug with Ubuntu yet?  There is no reason why Ubuntu cannot apply this patch to the latest 2.28 released version and ensure that the version of GDM provided to Ubuntu users has this fix.  It is not really necessary to release a new upstream 2.28 version of GDM with this fix for this to happen. 

If the Ubuntu release team feels strongly that a new release of GDM would help to facilitate this, then it would  make more sense to do a new GDM 2.28 release.

So, if you haven't already, I'd file a bug with Ubuntu and point towards this bug and the patch.  Since, as you say, it is a significant interface regression compared with the old GDM (2.20), I'd think they would be agreeable to ensuring that this patch is included in their future builds.
Comment 9 Manuel Iglesias 2010-01-13 14:05:52 UTC
Thanks Brian,
Sorry I did not know about the proper procedure.
Have reported bug to bugs.launchpad.net/ubuntu:
https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/506972

Best regards,
Manolo.
Comment 10 Ray Strode [halfline] 2010-01-13 17:31:06 UTC
Review of attachment 151224 [details] [review]:

Thanks, commited
Comment 11 Ray Strode [halfline] 2010-01-13 17:32:44 UTC
Comment on attachment 151316 [details] [review]
new patch for bug #602403

Hey, I don't think we want to run the script at all in that case.  I've commited a fix to that effect.  Thanks for spotting that!
Comment 12 Sebastien Bacher 2010-01-14 11:04:06 UTC
should the bug be closed if the change has been commited to git?
Comment 13 Brian Cameron 2010-01-21 22:15:22 UTC
I think so.  Ray, since you committed this fix can you confirm that this is fixed upstream and close the bug?
Comment 14 Brian Cameron 2010-03-15 21:18:41 UTC
*** Bug 612982 has been marked as a duplicate of this bug. ***