forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsetfacl.cgi
executable file
·45 lines (43 loc) · 904 Bytes
/
setfacl.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/local/bin/perl
# setfacl.cgi
# Sets the ACLs for some file
require './file-lib.pl';
$disallowed_buttons{'acl'} && &error($text{'ebutton'});
&ReadParse();
&webmin_log("acl", undef, $in{'file'}, \%in);
&switch_acl_uid_and_chroot();
print "Content-type: text/plain\n\n";
if ($access{'ro'} || !&can_access($in{'file'})) {
print $text{'facl_eaccess'},"\n";
}
else {
pipe(ACLINr, ACLINw);
pipe(ACLOUTr, ACLOUTw);
$pid = fork();
if (!$pid) {
untie(*STDIN);
untie(*STDOUT);
untie(*STDERR);
open(STDIN, "<&ACLINr");
open(STDOUT, ">&ACLOUTw");
open(STDERR, ">&ACLOUTw");
close(ACLINw);
close(ACLOUTr);
exec("$config{'setfacl'} '$in{'file'}'");
print "Exec failed : $!\n";
exit(1);
}
close(ACLINr);
close(ACLOUTw);
print ACLINw $in{'acl'},"\n";
close(ACLINw);
waitpid($pid, 0);
$rv = <ACLOUTr>;
close(ACLOUTr);
if ($rv) {
print $rv;
}
else {
print "\n";
}
}