Просмотр исходного кода

create-user.pl - changed to relative file paths. added root check. .gitignore - added vim backup files

tags/release-00
gashapwn 3 лет назад
Родитель
Сommit
72d1bf71f9
2 измененных файлов: 11 добавлений и 6 удалений
  1. +1
    -0
      .gitignore
  2. +10
    -6
      perl-script/create-user.pl

+ 1
- 0
.gitignore Просмотреть файл

@@ -5,3 +5,4 @@ test_*.txt
*/p[0-9].pl */p[0-9].pl
notes.txt notes.txt
user_list.txt user_list.txt
.#*

+ 10
- 6
perl-script/create-user.pl Просмотреть файл

@@ -4,11 +4,11 @@ use warnings;
use strict; use strict;
use JSON; use JSON;


my $WORKING_DIR = "/home/gashapwn/lyadmin/";
my $ACCOUNT_DIR = "req/";


my $FULL_PATH = "$WORKING_DIR$ACCOUNT_DIR";
my $CONF_PATH = $WORKING_DIR."lyadmin.conf.json";
my $working_dir = "./";
my $account_dir = $working_dir."req/";

my $CONF_PATH = $working_dir."lyadmin.conf.json";
my $SHELL_ENUM; my $SHELL_ENUM;


open FILE, $CONF_PATH or die "could not open file $CONF_PATH"; open FILE, $CONF_PATH or die "could not open file $CONF_PATH";
@@ -28,7 +28,7 @@ my @g;
sub create($){ sub create($){
my $id = $_[0]; my $id = $_[0];
my $fn1 = $FULL_PATH.$id.".ident";
my $fn1 = $account_dir.$id.".ident";


my $username; my $username;
my $shell_pref; my $shell_pref;
@@ -77,7 +77,11 @@ sub create($){
close FILE; close FILE;
} }


@g = glob("$FULL_PATH*");
if(!(`id` =~ /uid=0/)){
die "please run this script as root";
}

@g = glob("$account_dir*");
@g = map { s/.*\/([^\/]*).ident$/$1/; $_ } grep {$_ =~ /ident$/} @g; @g = map { s/.*\/([^\/]*).ident$/$1/; $_ } grep {$_ =~ /ident$/} @g;


for my $fn (@g){ for my $fn (@g){


Загрузка…
Отмена
Сохранить