Kill all user procs before unmounting home

This commit is contained in:
Jan Eitzinger 2024-09-16 20:04:34 +02:00
parent 778a2c67ef
commit f0de07c655
Signed by: moebiusband
GPG Key ID: 2574BA29B90D6DD5

View File

@ -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 sub main
{ {
@ -332,6 +345,8 @@ sub main
} }
if ( $stop && is_mounted($impermanence_home) ) { if ( $stop && is_mounted($impermanence_home) ) {
my $uid = get_uid( $opts{u} );
system( "pkill", "-U $uid" );
my $status = system( "umount", $impermanence_home ); my $status = system( "umount", $impermanence_home );
if ( $status != 0 ) { if ( $status != 0 ) {
trap_error("umount did exit with status $status"); trap_error("umount did exit with status $status");