Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
awit-ssh-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
allworldit
awit-ssh-client
Commits
2f32ba7f
Commit
2f32ba7f
authored
8 years ago
by
Robert Spencer
Browse files
Options
Downloads
Patches
Plain Diff
Add support for a configuration file
parent
14f0dce2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Add support for a configuration file
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
awit-ssh
+19
-4
19 additions, 4 deletions
awit-ssh
with
19 additions
and
4 deletions
awit-ssh
+
19
−
4
View file @
2f32ba7f
...
...
@@ -22,6 +22,11 @@ use warnings;
use
Term::
ANSIColor
;
use
Getopt::
Long
;
# Check Config::IniFiles
if
(
!
eval
{
require
Config::
IniFiles
;
1
;})
{
print
STDERR
"
You're missing Config::IniFiles, try 'apt-get install libconfig-inifiles-perl'
\n
";
exit
1
;
}
# Check IO::Socket::INET6
if
(
!
eval
{
require
IO::Socket::
INET6
;
1
;})
{
print
STDERR
"
You're missing IO::Socket::INET6, try 'apt-get install libio-socket-inet6-perl'
\n
";
...
...
@@ -70,6 +75,16 @@ if (defined($optctl{'version'})) {
exit
0
;
}
# Check for config and read
my
$configFile
=
$ENV
{"
HOME
"}
.
'
/.awit-ssh.conf
';
if
(
!
-
f
$configFile
)
{
print
STDERR
sprintf
("
Your configuration file '%s' is missing!
\n
",
$configFile
);
exit
1
;
}
my
$config
=
Config::
IniFiles
->
new
(
-
file
=>
$configFile
);
my
$ldapURL
=
$config
->
val
("
ldap
","
url
");
my
$ldapDC
=
$config
->
val
("
ldap
","
dc
");
# Pull in hostname
my
$hostSpec
=
shift
(
@ARGV
)
//
"";
my
(
$host
,
$port
)
=
split
('
:
',
$hostSpec
);
...
...
@@ -127,7 +142,7 @@ print STDERR "\n";
my
$ldap
=
Net::
LDAP
->
new
(
'
ldap
s://XXX
'
,
my
$ldap
=
Net::
LDAP
->
new
(
$
ldap
URL
,
# 'debug' => 15
);
if
(
!
defined
(
$ldap
))
{
...
...
@@ -136,11 +151,11 @@ if (!defined($ldap)) {
}
# Bind
my
$mesg
=
$ldap
->
bind
("
cn=
$username
,ou=Users,
YYY
",
password
=>
$password
);
my
$mesg
=
$ldap
->
bind
("
cn=
$username
,ou=Users,
$ldapDC
",
password
=>
$password
);
# Search
$mesg
=
$ldap
->
search
(
base
=>
"
ou=Servers,
ZZZ
",
base
=>
"
ou=Servers,
$ldapDC
",
filter
=>
"
(|(cn=
$host
)(awitLoginHost=
$host
)(awitLoginHostAlias=
$host
))
",
);
# Check for error
...
...
@@ -226,7 +241,7 @@ if ($ldapEntry) {
# TODO for for
a
warding
# TODO for forwarding
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment