diff options
author | Christian Pointner <equinox@helsinki.at> | 2014-09-17 20:16:53 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2014-09-17 20:16:53 (GMT) |
commit | 6d11ef4461929af9708f17dbbd8ce55d3f50a2f6 (patch) | |
tree | 09ecae68b4497ae02b85acd2f03cdaed6cd02dc4 | |
parent | 00fd07f65c4d9d53562bd4510cbf19fc73e1ee50 (diff) |
reading config form rd.conf works now
opening DBI handle
-rwxr-xr-x | authtoken.json | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/authtoken.json b/authtoken.json index 2f00e57..954581d 100755 --- a/authtoken.json +++ b/authtoken.json @@ -3,25 +3,32 @@ use strict; use warnings; use Config::IniFiles; +use DBI; +sub get_token +{ + my $username = shift; -my $RD_CONF = "/etc/rd.conf"; -my $cfg = Config::IniFiles->new(-file => $RD_CONF); -my $dbhost = $cfg->val('mySQL', 'Hostname'); -my $dbname = $cfg->val('mySQL', 'Database'); -my $dbuser = $cfg->val('mySQL', 'Loginname'); -my $dbpasswd = $cfg->val('mySQL', 'Password'); + my $RD_CONF = "rd.conf"; + my $cfg = Config::IniFiles->new(-file => $RD_CONF) or return ('ERROR', "Config File Error: " . join("\n", @Config::IniFiles::errors), ''); + my $dbhost = $cfg->val('mySQL', 'Hostname'); + my $dbname = $cfg->val('mySQL', 'Database'); + my $dbuser = $cfg->val('mySQL', 'Loginname'); + my $dbpasswd = $cfg->val('mySQL', 'Password'); + + my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost","$dbuser","$dbpasswd") or return ('ERROR', "Database Error: $DBI::errstr", ''); + + return ('OK', 'success', 'this is still not the right token but we will get to it!!'); +} my $status = 'ERROR'; my $errorstring = 'unknown'; my $username = ''; my $token = ''; if(defined $ENV{REMOTE_USER}) { - $status = 'OK'; - $errorstring = 'success'; + ($status, $errorstring, $token) = get_token($ENV{REMOTE_USER}); $username = $ENV{REMOTE_USER}; - $token = "this is cool!"; } else { $errorstring = 'no username defined'; } |