Skip to content
Snippets Groups Projects
Commit b5005e00 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Automatically determine users CN

parent 5911e2bf
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ if (!eval {require Term::ReadKey; 1;}) {
print STDERR "You're missing Term::ReadKey, try 'apt-get install libterm-readkey-perl'\n";
exit 1;
}
use User::pwent;
my $VERSION = "0.0.1";
......@@ -103,9 +103,16 @@ if (defined(my $knock = $optctl{'knock'})) {
print STDERR "success\n";
}
print STDERR "Your LDAP CN : ";
my $username = <STDIN>;
# Try get name automatically
my $pwent = getpwnam($ENV{'USER'});
(my $username) = split(/,/,$pwent->gecos);
if (!defined($username) || $username eq "") {
print STDERR "WARNING: Cannot determine your name, set your gecos field.\n\n";
print STDERR "Your LDAP CN : ";
$username = <STDIN>;
} else {
print STDERR "Your LDAP CN : $username\n";
}
print STDERR "Your LDAP Password: ";
# Don't echo password
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment