chiark / gitweb /
Fix HOSTNAME thing in configure.in
[inn-innduct.git] / samples / nnrpd_access_wrapper.pl.in
1 #! /usr/bin/perl
2 # fixscript will replace this line with require innshellvars.pl
3
4 # Example wrapper nnrpd_access.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 access control.
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 # access
18 # This sub modifies the global hash attributes so that it has all the
19 # entries required in the old way of doing things, calls
20 # old_authenticate, and creates a return hash with the right attributes.
21
22 sub access {
23     # Comment this out if you don't need auth_init.
24     old_auth_init();
25
26     $attributes{type} = "connect";
27     my @connect_array = old_authenticate();
28     my %hash;
29
30     # handle max rate
31     if ($connect_array[4]) {
32         # Force perl to make a C string out of this integer, 
33         # or else bad things will happen. Sigh.
34         $hash{"max_rate"} = $connect_array[4] . "\0"; 
35     }
36
37     # handle read boolean, set to wildmat
38     if ($connect_array[1]) {
39         $hash{"read"} = $connect_array[3];
40     }
41
42     # handle post boolean, set to wildmat
43     if ($connect_array[2]) {
44         $hash{"post"} = $connect_array[3];
45     }
46
47     return %hash;    
48 }