This file is indexed.

/usr/sbin/login.radius is in radiusclient1 0.3.2-14build1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/usr/bin/perl
#
# login program to invoke PPP.
# RADIUS accounting is NOT handled by this; it is handled by /etc/ppp/
# ip-up and ip-down which are invoked when the TCP/IP connection is up.

# version 0.1   November 5 1996
# clean up the code, minor features.

# version 0.02  May 8 1996
#
# start implementing other types of logins, not only Framed.
# Also honor static IP addresses.
#
# version 0.01  April 1 1996
#
# - ignore RADIUS server requests for Framed-User, just
#   do PPP.  Later, this should be honored.  For now,
#   just use RADIUS for authentication; it's much simpler.
#   Always use dynamic addresses.
#

use strict;
use GDBM_File;

#### CONFIGURATION SECTION ##################################################

# Local IP address for the PPP connection.
my $ip_address_local = "203.176.0.3";

# First IP address for this terminal server, if dynamic addressing
# is requested, or if nothing is specified for Framed-IP-Address.
my $ip_address_begin = "203.176.0.161";

# IP translation factor; subtract this value from radclient before adding
# the beginning IP address.
my $ip_translate_factor = 32;

# Debugging to screen?
my $debug = 1;

# PPP parameters:

# Async map - this one escapes only XON and XOFF characters.
my $asyncmap = "0x000A0000";

# MTU and MRU. 296 is good for interactive performance,
# but larger ones will lead to less overhead for file transfers.
# Maximum is 1500.
my ($mtu, $mru) = (296, 296);

# If we're using proxy ARP, set this to "proxyarp", else leave it blank.
# my $proxyarp = "proxyarp";
my $proxyarp = "";

# Login host for non-framed connections.
# This should only be an IP address, since that's what
# Login-IP-Host should be.
my $login_host = "203.176.0.4"; # marikit.iphil.net

# Programs and files.
my $prog_pppd     = "/usr/sbin/pppd";
my $prog_radacct  = "/usr/local/lib/radiusclient/radacct";
my $prog_rlogin   = "/usr/bin/rlogin";
my $prog_telnet   = "/bin/telnet";
my $prog_tcpclear = "/bin/telnet -e ''";
my $prog_tty      = "/usr/bin/tty";
my $prog_who      = "/usr/bin/who";

my $path_portinfo         = "/var/ipoint/acct/portinfo";
my $path_radiusclient_map = "/etc/radclient/port-id-map";

#############################################################################

# Main program.

print "Starting.\n" if ($debug);

# Run 'who am i' to determine the current port.
my $port = `$prog_tty`;
chomp ($port);

# Translate port numbers to numbers for RADIUS.
# This translation is done again by radacct, but it may be useful here.
# Remove if CPU time is a problem.

my ($portid, $line);
open (H, $path_radiusclient_map);
while (($line = <H>) && (!$portid))
{
    my @info = split (/\s+/, $line);
    $portid = $info[1] if ($info[0] eq $port);
}
close (H);

if ($debug)
{
    # Print out all the RADIUS variables.
    my @el = grep (/^RADIUS/, keys (%ENV));
    my $e;
    foreach $e (@el)
    {
	print "$e = " . $ENV{$e} . "\n";
    }
}

# If the service type is Framed, then give them PPP.
# SLIP is not implemented (and will probably never be).

my $username = $ENV{"RADIUS_USER_NAME"};

# Generate a "unique" string for the session ID.
my $sessionid = "$$" . time ();

if ($ENV{"RADIUS_SERVICE_TYPE"} =~ /^Framed$/)
{
   
# Use the specified IP address, or generate one if none is specified,
# or a dynamic one requested.  Or, let the user negotiate the address.

    my $ip_address = $ENV{"RADIUS_FRAMED_IP_ADDRESS"};

    if (!$ip_address || ($ip_address eq "255.255.255.254"))
    {
	my @ipn = split (/\./, $ip_address_begin);
	$ipn[3] += $portid - $ip_translate_factor;
	$ip_address = join ('.', @ipn);

	if ($debug)
	{
	    print "port: $port\n";
	    print "portid: $portid\n";
	    print "ip_translate_factor: $ip_translate_factor\n";
	    print "ip_address: $ip_address\n";
	    print "mru: $mru\n";
	}

    }
    elsif ($ip_address eq "255.255.255.255")
    {
	# Clear it out so that pppd will let the remote end specify the
	# IP address.
	$ip_address = "";
    }

    # Override the specified MTU.
    $mtu = $ENV{"RADIUS_FRAMED_MTU"} if $ENV{"RADIUS_FRAMED_MTU"};

    # If no compression is specified, turn it off.
    my $compress;
    if (!$ENV{"RADIUS_FRAMED_COMPRESSION"})
    {
	$compress = "-vj";
    }

# Fix up the parameters to be passed to ip-up.  Include Framed-Route.
# Escape spaces with %20's.

    # Split up the framed route into multiple parts.
    # Separate the different given routes with bars.
    my $routelist = join ("@", map {$ENV{$_}}
			     grep {/^RADIUS_FRAMED_ROUTE/} keys (%ENV)
			    );
    $routelist =~ s/ /%20/g;

    my $param = join (':', $sessionid, $username, $port, $portid,
		      $ENV{"RADIUS_SESSION_TIMEOUT"}, $routelist);

		      
# Run pppd through exec, so that it grabs hold of the terminal
# and catches disconnections.

    # Portmaster-style prompt.
    if ($ENV{"RADIUS_SESSION_TIMEOUT"})
    {
	print "Session timeout: " . $ENV{"RADIUS_SESSION_TIMEOUT"} .
	    " seconds.\n";
    }
    print "PPP session from ($ip_address_local) to $ip_address beginning....";
    my $pppdcmd =
	"$prog_pppd $ip_address_local:$ip_address modem crtscts " .
	"asyncmap $asyncmap lock -detach $compress " .
	"ipparam $param mtu $mtu mru $mru $proxyarp";

    exec ($pppdcmd);
}
elsif ($ENV{"RADIUS_SERVICE_TYPE"} =~ /Login/)
{
    # Warning:  This code has not been tested as well as the PPP version,
    # as of now (19961107).

    # Determine what host to connect to.
    if (($ENV{"RADIUS_LOGIN_IP_HOST"} eq "0.0.0.0") ||
	!defined ($ENV{"RADIUS_LOGIN_IP_HOST"}))
    {
	# Do nothing, it's already specified above in the config section.
    }
    elsif ($ENV{"RADIUS_LOGIN_IP_HOST"} eq "255.255.255.255")
    {
	# The user should be able to choose.  Prompt the user.
	print "Host to connect to?  ";
	$login_host = <STDIN>;
	chomp ($login_host);
    }
    else
    {
	# Use what's specified by the RADIUS server.
	$login_host = $ENV{"RADIUS_LOGIN_IP_HOST"};
    }
    
    # Log into a host.  Default to telnet.  Do the accounting
    # now, since the target of the login wouldn't know how to
    # account for it.

    # Start accounting.  Send the record.
    open  (H, "| $prog_radacct") || die ("Cannot run $prog_radacct");

    my $login_service = $ENV{"RADIUS_LOGIN_SERVICE"};

    my $cmd =
	"Acct-Session-ID = \"$sessionid\"\n" .
	"User-Name = \"$username\"\n" .
	"Acct-Status-Type = Start\n" .
        "Acct-Authentic = RADIUS\n" .
        "Service-Type = Login\n" .
        "Login-Service = " . $login_service . "\n" .
        "Login-IP-Host = $login_host\n";

    print H $cmd;
    close (H);

    # Time.
    my $timestart = time ();

    # What protocol are we running?
    my ($prog_run, $login_port);

    if ($login_service eq "Rlogin")
    {
	$prog_run = $prog_rlogin;
    }
    elsif ($login_service eq "Telnet")
    {
	$prog_run = $prog_telnet;
	$login_port = $ENV{"RADIUS_LOGIN_PORT"};
    }
    elsif ($login_service eq "TCP-Clear")
    {
	$prog_run = $prog_tcpclear;
	$login_port = $ENV{"RADIUS_LOGIN_PORT"};
    }

    # Store the user information into portinfo.  We need to
    # manually fork, since we have to know the PID of the program.

    my $pid = fork ();
    if ($pid == 0)
    {
	# Child.  Run the program.
	# print "Connecting to $login_host:\n";
	my $cmd = "$prog_run $login_host $login_port";
	exec ("$cmd");
    }
    else
    {
	# Parent.  
	# Create the portinfo record, which needs the pid of the program
	# to kill.
	# The IP address is all zero, as it is not applicable here.
	# Store the time now, and the Session-Timeout.

	my %db_portinfo;

	tie (%db_portinfo, "GDBM_File", $path_portinfo, GDBM_WRCREAT, 0600);
	$db_portinfo{$portid} =
	    join (':', $username, "Login/$login_service",
		  "0.0.0.0", $pid, $timestart, $ENV{"RADIUS_SESSION_TIMEOUT"});
	untie (%db_portinfo);

	# Wait for the session to finish.
	waitpid ($pid, 0);
    }
    # Stop.  Send the record.
    open  (H, "| $prog_radacct") || die ("Cannot run $prog_radacct");

    my $timespent = time () - $timestart;

    my $cmd =
	"Acct-Session-ID = \"$sessionid\"\n" .
	"User-Name = \"$username\"\n" .
	"Acct-Status-Type = Stop\n" .
        "Acct-Authentic = RADIUS\n" .
        "Service-Type = Login\n" .
        "Login-Service = " . $login_service . "\n" .
        "Login-IP-Host = $login_host\n" .
        "Acct-Session-Time = $timespent\n";

    print H $cmd;
    close (H);

    # Remove the record from portinfo.
    my %db_portinfo;
    tie (%db_portinfo, "GDBM_File", $path_portinfo, GDBM_WRCREAT, 0600);
    delete $db_portinfo{$portid};
    untie (%db_portinfo);
}

### END ####