1#!/usr/local/bin/perl
2# Validate the OTP for some user
3
4$main::no_acl_check = 1;
5$main::no_referers_check = 1;
6$ENV{'WEBMIN_CONFIG'} = "/etc/webmin";
7$ENV{'WEBMIN_VAR'} = "/var/webmin";
8if ($0 =~ /^(.*\/)[^\/]+$/) {
9        chdir($1);
10        }
11require './acl-lib.pl';
12$module_name eq 'acl' || die "Command must be run with full path";
13
14# Check command-line args
15@ARGV == 5 || die "Usage: $0 user provider id token api-key";
16($user, $provider, $id, $token, $apikey) = @ARGV;
17
18# Call the provider validation function
19&foreign_require("webmin");
20$func = "webmin::validate_twofactor_".$provider;
21$err = &$func($id, $token, $apikey);
22if ($err) {
23	$err =~ s/\r|\n/ /g;
24	print $err,"\n";
25	exit(1);
26	}
27else {
28	exit(0);
29	}
30