Weblog entry #30 for dkg

GNOME and libpam-mount
Posted by dkg on Sat 10 May 2008 at 00:49
Tags: none.
So i've been struggling with an Ubuntu 8.04 networked workstation. It uses libpam-mount to mount the user's homedir (actually, the mountpoint is one level up from the homedir) automatically at login over CIFS.

One of the problems i ran into with this arrangement happened because i was following the pam_mount configuration instructions too literally. In particular, README.Debian.gz says:

For every application used for logging in, there is a file of the form /etc/pam.d/xyz, add the following line at the end of the file:
@include common-pammount
In particular, ubuntu's /etc/pam.d/gdm defaults to:
#%PAM-1.0                                                                                                                                                               
auth    requisite       pam_nologin.so
auth    required        pam_env.so readenv=1
auth    required        pam_env.so readenv=1 envfile=/etc/default/locale
@include common-auth
auth    optional        pam_gnome_keyring.so
@include common-account
session required        pam_limits.so
@include common-session
session optional        pam_gnome_keyring.so auto_start
@include common-password
When i added the @include common-pammount directive to the bottom of this file when using pam_mount, new GNOME sessions failed badly: the gnome-panel didn't appear (which means that the user couldn't log out conveniently), and two error messages popped up at each login with nasty details like:
No database available to save your configuration: Unable to store a value at [...], as the configuration server has no writable databases.

The problem seems to be that libpam-gnome-keyring actually kicks off gconfd-2 during its PAM session invocation. If that comes before libpam-mount's PAM session invocation, then the home directory isn't mounted for the keyring, and gconfd-2 decides that it is unable to save any settings. Since gconfd then persists for the rest of the session, further GNOME session components try to talk to it and it refuses, even though the gconf db is now available (via the mounted homedir).

Since the order of the lines in a /etc/pam.d/* are semantically relevant, i'm usually very reluctant to tamper with the defaults. However, i think the correct /etc/pam.d/gdm for this scenario (or any pam-mount scenario using GNOME where the homedir might not be present at all before the session) is actually:

#%PAM-1.0                                                                                                                                                               
auth    requisite       pam_nologin.so
auth    required        pam_env.so readenv=1
auth    required        pam_env.so readenv=1 envfile=/etc/default/locale
@include common-auth
@include common-account
session required        pam_limits.so
@include common-session
@include common-password
@include common-pammount
auth    optional        pam_gnome_keyring.so
session optional        pam_gnome_keyring.so auto_start
With this configuration in place, i can successfully log in with a test user, anyway (and move on to the next problem, which appears to be SQLite over CIFS, ugh).

These sorts of problems are tough to nail down:

  • Is this overall problem due to a bug in the documentation for libpam-mount?
  • In gdm for its default weirdly-ordered PAM config?
  • In libpam-gnome-keyring for launching gconf-d-2 in the first place?
  • In libgconf2-4 for gconfd-2 not being able to notice when the directories it wants become available?
Or maybe it's just a configuration detail that i should have known about and expected to deal with in the first place. Ah, well.

 

Comments on this Entry

Posted by Anonymous (87.194.xx.xx) on Sat 10 May 2008 at 11:22
Argh, I setup libpam-mount to decrypt a LUKS device recently. I did it using one version first, in a test environment, and I had to put the relevant line at the bottom of the pam file. When I came to do it on the end system, I had to use a different version of libpam-mount. Not only did the entire config file syntax change to some monsterous XML, but now I had to stick the line at the top instead. I still can't figure out why. unmounting on logout doesn't work half the time either.

[ Parent | Reply to this comment ]

Posted by dkg (166.84.xx.xx) on Sun 11 May 2008 at 23:10
[ Send Message | View dkg's Scratchpad | View Weblogs ]
Unmounting on logout is the problem i plan to deal with after i get a handle on the sqlite-over-cifs business. For a simple terminal session (from a getty on VT's 1 through 6 in the normal config), unmounting on logout works reliably.

But an X11 login -- or rather, i should say, a GNOME login -- fails far more often than not. FWICT, this is because many of the GNOME daemons deliberately detach and orphan themselves from the session. Since they're children of PID 1, they can't be easily cleaned up or signaled by session shutdown. So the session closes, and things like tracker, gconf-d, and bonobo-activation-server persist, if only for a minute or two.

Well, that minute is long enough to make it so that pam_mount can't unmount the home directory. If you've got an encrypted home directory, that's a security concern. If you're mounting a network-offered directory with multiple home directories on it (but only mounting one at a time, depending on who's logged in at the console), you've got other problems, because the previous user's permissions will be set on the mountpoint when the next user tries to log in.

[ Parent | Reply to this comment ]

Posted by lool (88.166.xx.xx) on Mon 12 May 2008 at 10:25
[ Send Message ]
I'm sceptic that shuffling the lines around helps; didn't it simply work because a gconfd was still running from a previous session?

Changing:
@include common-auth
gnome-keyring auth
@include common-session
gnome-keyring session

Into:
@include common-auth
@include common-session
gnome-keyring auth
gnome-keyring session

really shouldn't change anything, or that looks like a PAM bug.

I'm happy to update the PAM config if I can understand how it helps. :)

--
Loic Minier

[ Parent | Reply to this comment ]

Posted by dkg (216.254.xx.xx) on Mon 12 May 2008 at 17:09
[ Send Message | View dkg's Scratchpad | View Weblogs ]
I think the key insight was that the gnome-keyring pam modules do something to trigger/kick off gconfd-2, so they shouldn't be loaded until after the user's home directory is properly mounted. I'm quite sure that gconfd was not still running from a previous session, because this happened immediately after boot.

/etc/pam.d/common-pammount includes both auth and session directives. So with the initial ordering of the /etc/pam.d/gdm, there's no way to cleanly insert the @include line such that it's after the common-auth and common-session, but before the gnome-keyring business.

I think so, anyway. Even better would be if gnome-keyring wouldn't need access to the user's homedir, or if gconfd-2 would be able to recover more gracefully from such a sequence of events, since not everyone will use pam_mount to mount their homedir, e.g. some crypted-homedir arrangements.

Thanks for thinking about this, Loic. If i can do other debugging, let me know.

[ Parent | Reply to this comment ]

Posted by lool (88.166.xx.xx) on Mon 12 May 2008 at 17:23
[ Send Message ]
Oh ok, I went too fast over your blog post: I thought you were adding pam-mount to the common-*.

Instead of touching gdm, could you try adding @include common-pammount to the end of both common-auth and common-session?

--
Loic Minier

[ Parent | Reply to this comment ]

Posted by dkg (216.254.xx.xx) on Mon 12 May 2008 at 17:49
[ Send Message | View dkg's Scratchpad | View Weblogs ]
Thanks for the recommendation, Loic, but i'm not sure that's the right thing either. For one thing, i want pam_mount to only fire for graphical logins -- there are other accounts that need access to this machine over the network, for example, which should not have pam_mount try to mount any homedirs.

What's more, /etc/pam.d/common-pammount contains both auth and session directives, so even if i did want pam_mount to trigger for every type of PAM-triggered connection, if it was included in common-auth and common-session, those directives would be duplicated (which would try to mount the homedir twice, afacit):

0 root@mew:~# grep '^[^#]' /etc/pam.d/common-pammount
auth       required   pam_mount.so try_first_pass
session    required   pam_mount.so try_first_pass
0 root@mew:~# 

[ Parent | Reply to this comment ]

Posted by lool (88.166.xx.xx) on Mon 12 May 2008 at 18:09
[ Send Message ]
I think it makes sense to group directives by type (auth or session for example) in the gdm and other configs; the issue is a consequence of the fact that common-pammount is a single file, would it be two files e.g. pammount-auth and pammount-session, we wouldn't be discussing this.

So while I could shuffle lines around in the gdm PAM configs, I think we should avoid it as:
- it would cause a conffile prompt for all systems where the gdm config was touched, probably more systems than systems with pammount
- it would be less readable than the current one

If this makes sense, then perhaps you should request that common-pammount be split in two files; on your side, you could simply copy-paste its contents in the proper place of the gdm PAM config in the mean time.

What do you think?

--
Loic Minier

[ Parent | Reply to this comment ]

Posted by dkg (216.254.xx.xx) on Mon 12 May 2008 at 19:23
[ Send Message | View dkg's Scratchpad | View Weblogs ]
I agree that this is a reasonable interpretation of where to "fix" this piece of the problem. If you break out common-pammount into two files, though, each one would only have a single line of configuration. So it might just be better to remove /etc/pam.d/common-pammount altogether, and to clean up the documentation to explain exactly what to add (and where to add it) for the most common use cases. (e.g. in common-auth and common-session for the "work with everything" case, and how to specifically enable it for select PAM services).

I'll file a bug against libpam-mount about its documentation and default config later today. Approaching this from the other angle, is there anything that could be done to make the GNOME side of things more robust in the face of a not-yet-mounted homedir during PAM session initiation?

For example, should i be filing a bug against libpam-gnome-keyring for kicking off gconfd-2 when $HOME isn't present? or against libgconf2-4 for gconfd-2's inability to cope with a $HOME that is created or mounted after gconfd-2 is started? Or is there some other way GNOME could address this?

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search