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.
47 lines
1.1 KiB
47 lines
1.1 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];
|
||
|
|
||
|
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')){
|
||
|
my $name = $_->key;
|
||
|
mkdir "/home/e-smith/files/scan/$name", 0700
|
||
|
unless (-d "/home/e-smith/files/scan/$name");
|
||
|
system ("$setfacl",
|
||
|
'-m',
|
||
|
"u:scanner:rwX,u:$name:rwX,d:u:$name:rwX",
|
||
|
'--',
|
||
|
"/home/e-smith/files/scan/$name");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
exit (0);
|