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.

56 lines
1.4 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:rwX,u:$name:rwX,g:admins:rwX,d:u:$name:rwX,d:g:admins,rwX",
13 years ago
'--',
"/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:rwX,u:$name:rwX,d:u:$name:rwX",
13 years ago
'--',
"/home/e-smith/files/scan/$name");
}
chmod 0755, "/home/e-smith/files/scan/";
system ("$setfacl", "-R", "-m", "g:admins:rwX,d:g:admins:rwX", "/home/e-smith/files/scan/");
13 years ago
}
exit (0);