You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.2 KiB

13 years ago
#!/usr/bin/perl -w
package esmith;
use File::Path qw(mkpath rmtree);
use esmith::AccountsDB;
my $a = esmith::AccountsDB->open_ro();
$ENV{'PATH'} = "/bin";
my $setfacl = "/usr/bin/setfacl";
my $event = $ARGV [0];
my $name = $ARGV [1];
die "Event name missing\n" unless (defined $event);
13 years ago
if ($event eq 'user-create'){
mkpath "/home/e-smith/files/scan/$name";
system ("$setfacl",
'-m',
"u:scanner:w,u:$name:rwX,d:u:$name:rw",
'--',
"/home/e-smith/files/scan/$name");
}
elsif ($event eq 'user-delete'){
rmtree "/home/e-smith/files/scan/$name";
}
else {
system ("$setfacl",
'-R',
'--remove-all',
'--remove-default',
'--',
"/home/e-smith/files/scan/");
foreach ($a->users,$a->get('admin')){
$name = $_->key;
if (-d "/home/e-smith/files/scan/$name"){
chmod 0700, "/home/e-smith/files/scan/$name";
}
else {
mkdir "/home/e-smith/files/scan/$name", 0700;
}
13 years ago
system ("$setfacl",
'-R',
13 years ago
'-m',
"u:scanner:w,u:$name:rwX,d:u:$name:rwX",
13 years ago
'--',
"/home/e-smith/files/scan/$name");
}
}
exit (0);