-
Notifications
You must be signed in to change notification settings - Fork 3
/
block_user.pl
35 lines (28 loc) · 915 Bytes
/
block_user.pl
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
#!/usr/bin/perl
use strict;
my $block_user = $ARGV[0];
my $block_session = $ARGV[1];
#
# make backup of user.txt file
#
system("cp /opt/ezproxy/user.txt /opt/ezproxy/user_backup/user.txt-" . time);
open(USERTXT, "/opt/ezproxy/user.txt") || die("can't open /opt/ezproxy/user.txt for reading\n");
open(NEWUSERTXT, ">", "/opt/ezproxy/scripts/newuser.txt") || die("can't open /opt/ezproxy/scripts/newuser.txt for writing\n");
#
#
# add block user to ezproxy user.txt file after #####.....#####auto-block-start
#
# #####.....#####auto-block-start
while (my $line = <USERTXT>) {
chomp($line);
print NEWUSERTXT "$line\n";
if ($line eq '#####.....#####auto-block-start') {
print NEWUSERTXT "ifUser $block_user; deny; Stop\n";
}
}
close(USERTXT);
close(NEWUSERTXT);
if ($block_session) {
system("/opt/ezproxy/ezproxy kill $block_session");
}
system("cp /opt/ezproxy/scripts/newuser.txt /opt/ezproxy/user.txt");