Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#36 Proposal of small modification to <logout> behaviour.

pam-mount
closed
pam-mount (40)
5
2010-05-25
2010-05-08
Anonymous
No

Currently after final logout the behavior is as follows:

void umount_final(struct config *config)
{
struct vol *vol;

if (config->sig_hup)
HXlist_for_each_entry_rev(vol, &config->volume_list, list)
ofl(vol->mountpoint, SIGHUP);
if (config->sig_term) {
usleep(config->sig_wait);
HXlist_for_each_entry_rev(vol, &config->volume_list, list)
ofl(vol->mountpoint, SIGTERM);
}
if (config->sig_kill) {
usleep(config->sig_wait);
HXlist_for_each_entry_rev(vol, &config->volume_list, list)
ofl(vol->mountpoint, SIGKILL);
}
HXlist_for_each_entry_rev(vol, &config->volume_list, list) {
w4rn("going to unmount\n");
if (!mount_op(do_unmount, config, vol, NULL))
l0g("unmount of %s failed\n",
vol->volume);
}
}

I suggest changing it to:

void umount_final(struct config *config)
{
struct vol *vol;

usleep(config->sig_wait);

if (config->sig_hup)
HXlist_for_each_entry_rev(vol, &config->volume_list, list)
ofl(vol->mountpoint, SIGHUP);
usleep(config->sig_wait);
if (config->sig_term) {
HXlist_for_each_entry_rev(vol, &config->volume_list, list)
ofl(vol->mountpoint, SIGTERM);
usleep(config->sig_wait);
}
if (config->sig_kill) {
HXlist_for_each_entry_rev(vol, &config->volume_list, list)
ofl(vol->mountpoint, SIGKILL);
usleep(config->sig_wait);
}
HXlist_for_each_entry_rev(vol, &config->volume_list, list) {
w4rn("going to unmount\n");
if (!mount_op(do_unmount, config, vol, NULL))
l0g("unmount of %s failed\n",
vol->volume);
}
}

It looks much more natural to me. Firstly we give to processes the opportunity to finish by themselves waiting a while. Then we send SIGHUP and wait again to give them some time to react. Then SIGTERM and wait again (they may need sometime to close), and then SIGKILL and wait (maybe in this case it is not necessary). This behavior looks more reasonable to me.

Also, in current implementation there is no way to configure pam-mount to only wait a few seconds before trying to umount. This is very useful for me. I want pam-mount to try umounting after 3s, but give up if there are still some processes. This way one can leave some process in a screen or something. With the change suggested above that would be possible.

Please consider this small modification! I'm currently using locally modified and built version but it would be nice to incorporate this into some official release.

Thanks,
Bartek

Discussion

  • Jan Engelhardt
    Jan Engelhardt
    2010-05-08

    Your change would ultimately penalize people who don't have any kill signals configured.
    Also, by the time the PAM session close is called, processes should have really stopped already (I wonder when KDE/GNOME will ever get this right).
    Furthermore, pam_mount just does the exact same thing as a shell: send SIGHUP when things close. The program then has time to gracefully do any backgrounding if it has not done so earlier.
    Wait after SIGKILL is not necessary since the process is generally terminated after that (minus uninterruptible sleep/kernel mode).

     
  • Jan Engelhardt
    Jan Engelhardt
    2010-05-10

    • status: open --> pending
     
  • This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
    • status: pending --> closed