#!/usr/bin/perl
use strict;

my %opts = @ARGV;

my $username = $opts{user};

exit 1 if length $username == 0;

my $pw = getpwnam($username);
exit 1 unless defined $pw;

my $min_uid = `/usr/sbin/cagefsctl --get-min-uid`;
exit 0 if $pw < $min_uid;

my @params = ( '/usr/sbin/cagefsctl', '--unmount', $username );
exec @params;

