diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-26 15:24:44 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-07-26 15:24:44 +0200 |
commit | cf96dfe155e4c8b2f04068efee96178e4f0a59cf (patch) | |
tree | 476c78a7fbc8475e9db5b27edc3127beb4667019 | |
parent | Trying with random passwords (diff) | |
download | joe-scripts-cf96dfe155e4c8b2f04068efee96178e4f0a59cf.tar.gz joe-scripts-cf96dfe155e4c8b2f04068efee96178e4f0a59cf.tar.bz2 joe-scripts-cf96dfe155e4c8b2f04068efee96178e4f0a59cf.tar.xz joe-scripts-cf96dfe155e4c8b2f04068efee96178e4f0a59cf.tar.zst joe-scripts-cf96dfe155e4c8b2f04068efee96178e4f0a59cf.zip |
Cleaner
-rwxr-xr-x | src/gitjoe/adduser.pl | 17 | ||||
-rwxr-xr-x | src/gitjoe/rmuser.pl | 8 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/gitjoe/adduser.pl b/src/gitjoe/adduser.pl index 844000e..8107155 100755 --- a/src/gitjoe/adduser.pl +++ b/src/gitjoe/adduser.pl @@ -3,25 +3,28 @@ use strict; use warnings; use Term::ANSIColor; +use constant { + DASH_PATH => '/usr/local/bin/dash', + ADDUSER_PATH => '/usr/sbin/adduser', +}; sub main { my $argc = $#ARGV + 1; - if ($argc < 3) { + if ($argc < 2) { print colored("Failed!\n", 'bold red') - . "Missing argument, 3 needed " - . colored("[user - password - ssh public key]", 'bold') + . "Missing argument, 2 needed " + . colored("[user - ssh public key]", 'bold') . "\n"; exit 1; } my $usr = $ARGV[0]; - my $pass = $ARGV[1]; my $sshkey = "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty "; - $sshkey = $sshkey . $ARGV[2]; + $sshkey = $sshkey . $ARGV[1]; my $home_dir = '/usr/home/' . $usr . '/'; system( - '/usr/local/bin/dash', + DASH_PATH, '-c', - "adduser << EOF + ADDUSER_PATH . " << EOF " . $usr . " diff --git a/src/gitjoe/rmuser.pl b/src/gitjoe/rmuser.pl index d9b056d..2840c65 100755 --- a/src/gitjoe/rmuser.pl +++ b/src/gitjoe/rmuser.pl @@ -3,6 +3,10 @@ use strict; use warnings; use Term::ANSIColor; +use constant { + DASH_PATH => '/usr/local/bin/dash', + RMUSER_PATH => '/usr/sbin/rmuser', +}; sub main { my $argc = $#ARGV + 1; @@ -15,9 +19,9 @@ sub main { } my $usr = $ARGV[0]; system( - '/usr/local/bin/dash', + DASH_PATH, '-c', - "rmuser << EOF + RMUSER_PATH . " << EOF " . $usr . " y y |