diff --git a/impermanence.pl b/impermanence.pl index 09ac409..e8d54f9 100755 --- a/impermanence.pl +++ b/impermanence.pl @@ -245,6 +245,19 @@ sub call_chezmoi } } +sub get_uid +{ + my $user = shift; + my $s = `userinfo $user`; + + if ( $s =~ /uid\t([0-9]+)/s ) { + my $uid = $1; + return $uid; + } else { + trap_error("ERROR: userinfo did not return uid"); + } +} + sub main { @@ -332,6 +345,8 @@ sub main } if ( $stop && is_mounted($impermanence_home) ) { + my $uid = get_uid( $opts{u} ); + system( "pkill", "-U $uid" ); my $status = system( "umount", $impermanence_home ); if ( $status != 0 ) { trap_error("umount did exit with status $status");