From b1557ae5f5eff44b885f5f1368f5963e17f0d86f Mon Sep 17 00:00:00 2001 From: gashapwn Date: Fri, 27 Nov 2020 00:32:04 +0000 Subject: [PATCH] create-user.pl now pulls shell enum from conf file --- perl-script/create-user.pl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/perl-script/create-user.pl b/perl-script/create-user.pl index 2153f54..92742a9 100644 --- a/perl-script/create-user.pl +++ b/perl-script/create-user.pl @@ -2,16 +2,26 @@ use warnings; use strict; +use JSON; my $WORKING_DIR = "/home/gashapwn/lyadmin/"; my $ACCOUNT_DIR = "test/"; my $FULL_PATH = "$WORKING_DIR$ACCOUNT_DIR"; +my $CONF_PATH = $WORKING_DIR."lyadmin.conf.json"; +my $SHELL_ENUM; -my $SHELL_ENUM = { - "SHELL_BASH" => "/usr/local/bin/bash", - "SHELL_KSH" => "/bin/ksh" +open FILE, $CONF_PATH or die "could not open file $CONF_PATH"; +{ + my $conf_str; + my $conf_obj; + local $/=undef; + $conf_str = ; + chomp $conf_str; + $conf_obj = decode_json($conf_str); + $SHELL_ENUM = $conf_obj->{"shell"}; }; +close FILE; my @g; @@ -28,13 +38,16 @@ sub create($){ open FILE, $fn1 or die "could not open file $fn1"; $username = ; chomp $username; - + $user_email = ; chomp $user_email; { my $s0 = ; chomp $s0; + unless($SHELL_ENUM->{$s0}){ + die "invalid shell setting $s0 in file $id.ident"; + } $shell_pref = $SHELL_ENUM->{$s0}; }