From f0de07c6554a06d38a5df955ce568509740cf10d Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 16 Sep 2024 20:04:34 +0200 Subject: [PATCH] Kill all user procs before unmounting home --- impermanence.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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");