chiark / gitweb /
xfoo => mfoo, add comment
[inn-innduct.git] / samples / nnrpd_auth_wrapper.pl.in
1 #! /usr/bin/perl
2 # fixscript will replace this line with require innshellvars.pl
3
4 # Example wrapper nnrpd_auth.pl for support of old perl authentication
5 # scripts, by Erik Klavon.
6
7 # This file contains a sample perl script which can be used to
8 # duplicate the behavior of the old nnrpperlauth functionality. This
9 # script only supports authentication.
10
11 # How to use this wrapper:
12 # - append your old script to this file with two changes:
13 # - rename the old "auth_init" sub to "old_auth_init"
14 # - rename the old "authenticate" sub to "old_authenticate"
15
16
17 # auth_init
18 # This sub simply calls old_auth_init
19 # Comment this out if you don't need auth_init
20
21 sub auth_init {
22     old_auth_init();
23 }
24
25
26 # authenticate
27 # This sub modifies the global hash attributes so that it has all the
28 # entries required in the old way of doing things, calls
29 # old_authenticate, and transforms the return array into the new
30 # format.
31
32 sub authenticate {
33     $attributes{type} = "authenticate";
34     my @auth_array = old_authenticate();
35     my @return_array;
36
37     # copy return code
38     $return_array[0] = $auth_array[0];
39
40     # simple error report
41     if ($auth_array[0] != 281) {
42         $return_array[1] = "Perl authentication error!";
43         return @return_array;
44     } else {
45         $return_array[1] = "";
46     }
47
48     return @return_array;
49 }