When using pam_mount to mount a crypto-home, calling e.g. 'sudo echo blarz' produces weird behaviour. pmvarrun increases root's session counter by 1 and decreases user's session counter by 1 - leading to an erroneous unmount attempt. The reason seems to be that pam is called with uid 0 for login procedure and with the user's uid for the logout.
Is this a pam_mount or a sudo fail? How could it be fixed? As this seems to be a common setup, it would be nice to have at least a workaround.