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 356869 - gdm sometimes ignores ~/.dmrc
gdm sometimes ignores ~/.dmrc
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
2.14.x
Other All
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2006-09-20 09:40 UTC by Jerzy Borkowski
Modified: 2006-09-22 22:58 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
patch against gdm-2.14.9 which adds 'SupportAutomount' cfg option (4.42 KB, patch)
2006-09-22 15:42 UTC, Jerzy Borkowski
none Details | Review

Description Jerzy Borkowski 2006-09-20 09:40:51 UTC
Please describe the problem:
gdm ignores ~/.dmrc whenever home dir
is automounted and __NOT__ mounted at the
time user tries to login.

The bug is at least in gdm-2.8.0.x, gdm-2.14.x, gdm-2.16.x

note: automounter is using the --ghost option.


Steps to reproduce:
1. login via gdm selecting some language, then logout
2. make sure your home dir is not automounted (umount /home/xxxx,
   or wait for automounter to umount it)
3. login via gdm without selecting language.


Actual results:
gdm (incorrectly) selects 'C' locale instead of most recently used

Expected results:
gdm should use most recently used locale

Does this happen every time?
yes

Other information:
the fix is to replace (daemon/filecheck.c:58)
   VE_IGNORE_EINTR (r = g_stat (dir, &statbuf));
with, say :
    gchar *dirautofs;
    dirautofs = g_strconcat(dir, "/.", NULL);
    VE_IGNORE_EINTR (r = stat (dirautofs, &statbuf));
    g_free(dirautofs);
Comment 1 Brian Cameron 2006-09-20 23:07:46 UTC
Yes, this is annoying.  How do you propose that GDM should know what is in the users $HOME/.dmrc file if the directory is not accessible?

I suppose the file could be stored somewhere other than the user's $HOME directory, but most users want their configurations to work on multiple machines so if they have a shared $HOME directory, things just work on all machines.  The user's $HOME directory seems a sensible place for this sort of functionality.

The behavior that you describe is how I'd expect GDM to work if it can't access
your personal settings in your personal $HOME directory.

Perhaps you need to fix your system configuration so that the user's home directories are mounted before the user is logged in?
Comment 2 Jerzy Borkowski 2006-09-21 09:28:53 UTC
(In reply to comment #1)
> Yes, this is annoying.  How do you propose that GDM should know what is in the
> users $HOME/.dmrc file if the directory is not accessible?
> 
> I suppose the file could be stored somewhere other than the user's $HOME
> directory, but most users want their configurations to work on multiple
> machines so if they have a shared $HOME directory, things just work on all
> machines.  The user's $HOME directory seems a sensible place for this sort of
> functionality.
> 
> The behavior that you describe is how I'd expect GDM to work if it can't access
> your personal settings in your personal $HOME directory.
> 
> Perhaps you need to fix your system configuration so that the user's home
> directories are mounted before the user is logged in?
> 

Thanks for the reply. I think my system configuration is ok.
IMHO, GDM accesses personal settings in my personal $HOME directory
in a way which is incompatible with the Linux automounter
kernel module (and which is easy to fix).

Let me explain the issue and the proposed fix (from
my previous report) in more detail.

The Linux automounter (Solaris version works in a similar way) 
mounts/unmounts subdirectories  under /home directory __on__demand__. 
So, if /home/xxx is not mounted, and the user is 
logging via gdm, and gdm is accessing anything under /home/xxx, 
the automounter _will_ automagically (in kernel)
mount (NFS or local disk) /home/xxx. Thus ~/.dmrc shall be
read without any problems. When /home/xxx is not accessed anymore
for more then TBD (tunable) minutes, the automounter automatically
unmounts /home/xxx. This setup is commonly used
when number of user accounts is large, and the home dirs are mounted
via NFS (to avoid having hundreds of NFS mounted directories).
Usually several directory trees like: /home, /scratch, /work,
/applications etc ... are managed this way.

When using the '--ghost' command line option to 
the automount process (==> man(8) automount), for instance :

/usr/sbin/automount --ghost --timeout 60 /home \
  ldap nisMapName=auto_home,dc=xxxxx,dc=yyyy \
  rw,nosuid,hard,intr,tcp

the automounter always shows all available subdirectories under /home.
The list of available subdirectories is read from respective
LDAP/NIS/NIS+/FILES automount table (from auto_home LDAP map in the above case).
Those subdirectories are shown irrespective whether 
they are actually mounted or not. And here is the subtle problem :

The non-mounted directory (but managed by automounter with the --ghost
option) has root as the owner (simply because kernel does not 
know the owner before actually mounting the filesystem). 
Of course, once mounted the ownership of say /home/xxx 
is immediately set to xxx by the kernel (and back to root
once unmounted). Furthermore, stat(/home/xxx) does __not__ force
automounter to mount /home/xxx (if it is not mounted), since
the traversal of directory tree up to /home/xxx is not needed
(the leaf under /home is analysed, so the traversal stops at /home).
If one wants to force automounter to actually mount /home/xxx
upon stat(), it must append '/.' to the directory name, so
it should call stat(/home/xxx/.). This is what I was proposing
in my previous email.

Now, in daemon/filecheck.c, the gdm_file_check() routine first
calls stat() on directory, then it checks the ownership of that directory.
If everyting seems ok, only then it calls stat() on the file.
Since it appears that the very first access to /home/xxx
from gdm is when it looks for /home/xxx/.dmrc, gdm ignores
~/.dmrc with a message :

.dmrc file ignored since ownership/permission of the file are incorrect.

because the ownership of directory is incorrect, because
automounter did not mount it during stat(/home/xxx), and
stat() reported root as the owner of that directory and 
gdm_file_check() returned without even calling stat() on the file
itself (thus /home/xxx is still not mounted).
GDM continues anyway, accessing some configuration
files in /home/xxx directly (without calling gdm_file_check() first),
thus forcing automounter to mount /home/xxx.
The user is logged and can R/W access his home dir, albeit
locale is the to C (and not to the most recently used).

Comment 3 Brian Cameron 2006-09-21 18:57:54 UTC
Note that the GDM config file supports RelaxPermissions.  Does setting this to 1 or 2 make it work better for you?  This might be the best approach to fix this issue.
Comment 4 Jerzy Borkowski 2006-09-21 21:05:55 UTC
(In reply to comment #3)
> Note that the GDM config file supports RelaxPermissions.  Does setting this to
> 1 or 2 make it work better for you?  This might be the best approach to fix
> this issue.
> 


Setting RelaxPermissions=2 does indeed solve the issue,
however, IMHO, this method merely hides the problem
instead of actually fixing it.

Even worse, it does not solve the issue when Linux 
automounter is run __without__ the '--ghost'
option. This is because, when /home/xxx is not
mounted, then the /home/xxx entry does not exist
at all, therefore stat(/home/xxx) returns 
with an error 'No_Such_Directory'

AFAIK, the Linux kernel automounter magic works on 
the assumption, that if the application wants to, say, 
open a file, it should supply either :

1) full path       /a/path/to/some/file
2) partial path    ./some/file
3) filename        file

Further to the above, for 1) and 2), application should 
neither check whether directories in the path actually
exist, nor check their permissions, as both, the
missing directories and their permissions, will be
atomically adjusted by kernel during open() or stat()
on the file. 

The above requirement is violated in gdm_file_check()
routine.

If the application really has to check/traverse the path,
it should make sure symbolic links and/or automountpoints
are always dereferenced, for instance :

stat(/a/.)
stat(/a/path/.)
stat(/a/path/to/.)
stat(/a/path/to/some/.)

This works correctly on automounter managed directories,
as well as avoids problems when /home/xxx is a symbolic
link owned by root, and not by xxx and RelaxPermissions!=2 
(ok, I agree, a very strange setup).
Comment 5 Brian Cameron 2006-09-21 21:18:47 UTC
GDM is a bit strict about making sure the user's $HOME directory is set up properly.  

If there are some special configurations where it makes sense for the checking to be different, I'd be happy to accept a patch that would allow users to configure GDM to work in this environment.  Perhaps adding a configuration option like "GdmSupportAutomount" or something, if set to true, would change the way that
GDM does the file checking, or avoid doing certain checking.  Although I guess I'm not sure why RelaxPermissions isn't already meeting this need.

I'd accept a patch to make it work this way, but I think the current behavior is correct for default/normal use.

I guess the question is whether we really want/need to support automounting wihtout the --ghost option.  Is there a real need to support this configuration.
Comment 6 Jerzy Borkowski 2006-09-22 15:42:00 UTC
Created attachment 73219 [details] [review]
patch against gdm-2.14.9 which adds 'SupportAutomount' cfg option
Comment 7 Jerzy Borkowski 2006-09-22 16:05:41 UTC
(In reply to comment #5)
> I'd be happy to accept a patch that would allow users to
> configure GDM to work in this environment.  Perhaps adding a configuration
> option like "GdmSupportAutomount" or something, if set to true, would change

I've just submitted patch id=73219, which adds the 'SupportAutomount'
config option. The default value is false, so by default gdm behaves
as before. Let me know if you can accept it.

The patch works for me on x86 and amd64 architectures
(kernel 2.6.17/SMP/PREEMPT, gcc4.1.1). Didnt check others.

As for the question :

> I guess the question is whether we really want/need to support automounting
> wihtout the --ghost option.  Is there a real need to support this
> configuration.

I'd say yes. All major distros have autofs package, and  
the --ghost option was added to the Linux automounter
only recently.
Comment 8 Brian Cameron 2006-09-22 18:12:45 UTC
Looks very well done.  Nice comments, you didn't forget to add documentation.
Please commit.  If you don't have commit permissions, let me know and I'll put it in for you.
Comment 9 Jerzy Borkowski 2006-09-22 20:27:53 UTC
(In reply to comment #8)
> Please commit.  If you don't have commit permissions, let me know and I'll put
> it in for you.

I don't have commit perms. Please commit the patch for me.

Comment 10 Brian Cameron 2006-09-22 22:58:50 UTC
Fixed in CVS head.  Thanks