root/alternc/tags/0.9.6/src/mem_add

Revision 1745, 0.6 kB (checked in by anarcat, 2 years ago)

use same regexp for allowed usernames as in the php code
(m_admin::add_mem())

do not quote_meta in shell command, since all variables are now
considered safe

see #998
see #427

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2
3 use strict;
4
5 my ($name,$uid) = @ARGV;
6
7 if (!$name || !$uid) {
8     print "Usage: mem_add <name> <uid>\n";
9     print " Create the AlternC account <name> having uid number <uid>\n";
10     exit(1);
11 }
12
13 $ENV{PATH} = "";
14 delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
15
16 if (!($name =~ /^([a-z0-9]+)$/)) {
17     die "Account name is incorrect.";
18 }
19 $name=$1;
20 if (!($uid =~ /^([0-9]+)$/)) {
21     die "uid is incorrect.";
22 }
23 $uid=$1;
24
25 $< = $>;
26 $( = $);
27
28 my $PTH="/var/alternc/html/".substr($name,0,1)."/".$name;
29
30 mkdir($PTH);
31 system("/bin/chown 33:$uid '$PTH'");
32 system("/bin/chmod 02770 '$PTH'");
33
34 0;
35
Note: See TracBrowser for help on using the browser.