php and reply accounting request

Pezhman Lali pezhman_lali at yahoo.com
Mon Feb 27 17:06:07 CET 2006


hi
for accounting, I want to use external php scripts
too.
following the  exec_program_wait, I set my acct_users
like this:

DEFAULT Acct-Status-Type == Start
	Exec-Program = "php -f test.php"

DEFAULT Acct-Status-Type == Stop
	Exec-Program = "php -f test.php"
and add "files",to preacct's section, to read
acct_users.

and my accounting's section in radiusd.conf is empty.

I dont have any problem with auth, and reply back
right attr,
but for accounting packets has a problem, I use
ntradping,config it for true accounting port, and
accounting-start,
in freeradius side, the accounting-start packets
recieved by php scripts(I know it from saved
env_variables) ,but my script doesn't reply any
accounting-response.
how I can reply back accounting-response to
NAS(ntradping) from php script?

now for test I use a php script,for auth and
accounting, and defined it in radiusd.conf :

exec authphp {
                wait = yes
                program = "${raddbdir}/test.php "
	       input_pairs = request
                output_pairs = reply
		packet_type = Access-Request
        }
and this is php script:
#!/usr/bin/php -f
<?php
ob_start();
$f = fopen('./php.log','w');
fwrite($f,print_r($_ENV,TRUE));
fclose($f);
print "Accounting-Response";
$mtu=100;
$ip="10.0.0.1";

exit(0) ;
?>
and this is radiusd -X's output:

 
[root at radius raddb]# radiusd -X
Starting - reading configuration files ...
reread_config:  reading radiusd.conf
Config:   including file:
/usr/local/etc/raddb/proxy.conf
Config:   including file:
/usr/local/etc/raddb/clients.conf
Config:   including file:
/usr/local/etc/raddb/snmp.conf
Config:   including file:
/usr/local/etc/raddb/eap.conf
Config:   including file:
/usr/local/etc/raddb/sql.conf
 main: prefix = "/usr/local"
 main: localstatedir = "/usr/local/var"
 main: logdir = "/usr/local/var/log/radius"
 main: libdir = "/usr/local/lib"
 main: radacctdir =
"/usr/local/var/log/radius/radacct"
 main: hostname_lookups = yes
 main: max_request_time = 30
 main: cleanup_delay = 5
 main: max_requests = 1024
 main: delete_blocked_requests = 0
 main: port = 1812
 main: allow_core_dumps = no
 main: log_stripped_names = no
 main: log_file =
"/usr/local/var/log/radius/radius.log"
 main: log_auth = yes
 main: log_auth_badpass = yes
 main: log_auth_goodpass = yes
 main: pidfile =
"/usr/local/var/run/radiusd/radiusd.pid"
 main: bind_address = 217.218.95.126 IP address
[217.218.95.126]
 main: user = "(null)"
 main: group = "(null)"
 main: usercollide = no
 main: lower_user = "no"
 main: lower_pass = "no"
 main: nospace_user = "no"
 main: nospace_pass = "no"
 main: checkrad = "/usr/local/sbin/checkrad"
 main: proxy_requests = yes
 proxy: retry_delay = 5
 proxy: retry_count = 3
 proxy: synchronous = no
 proxy: default_fallback = yes
 proxy: dead_time = 120
 proxy: post_proxy_authorize = yes
 proxy: wake_all_if_all_dead = no
 security: max_attributes = 200
 security: reject_delay = 3
 security: status_server = no
 main: debug_level = 0
read_config_files:  reading dictionary
read_config_files:  reading naslist
Using deprecated naslist file.  Support for this will
go away soon.
read_config_files:  reading clients
read_config_files:  reading realms
radiusd:  entering modules setup
Module: Library search path is /usr/local/lib
Module: Loaded expr
Module: Instantiated expr (expr)
Module: Loaded PAP
 pap: encryption_scheme = "crypt"
Module: Instantiated pap (pap)
Module: Loaded CHAP
Module: Instantiated chap (chap)
Module: Loaded MS-CHAP
 mschap: use_mppe = yes
 mschap: require_encryption = no
 mschap: require_strong = no
 mschap: with_ntdomain_hack = no
 mschap: passwd = "(null)"
 mschap: authtype = "MS-CHAP"
 mschap: ntlm_auth = "(null)"
Module: Instantiated mschap (mschap)
Module: Loaded System
 unix: cache = no
 unix: passwd = "(null)"
 unix: shadow = "(null)"
 unix: group = "(null)"
 unix: radwtmp = "/usr/local/var/log/radius/radwtmp"
 unix: usegroup = no
 unix: cache_reload = 600
Module: Instantiated unix (unix)
Module: Loaded eap
 eap: default_eap_type = "md5"
 eap: timer_expire = 60
 eap: ignore_unknown_eap_types = no
 eap: cisco_accounting_username_bug = no
rlm_eap: Loaded and initialized type md5
rlm_eap: Loaded and initialized type leap
 gtc: challenge = "Password: "
 gtc: auth_type = "PAP"
rlm_eap: Loaded and initialized type gtc
 mschapv2: with_ntdomain_hack = no
rlm_eap: Loaded and initialized type mschapv2
Module: Instantiated eap (eap)
Module: Loaded preprocess
 preprocess: huntgroups =
"/usr/local/etc/raddb/huntgroups"
 preprocess: hints = "/usr/local/etc/raddb/hints"
 preprocess: with_ascend_hack = no
 preprocess: ascend_channels_per_line = 23
 preprocess: with_ntdomain_hack = no
 preprocess: with_specialix_jetstream_hack = no
 preprocess: with_cisco_vsa_hack = no
Module: Instantiated preprocess (preprocess)
Module: Loaded files
 files: usersfile = "/usr/local/etc/raddb/users"
 files: acctusersfile =
"/usr/local/etc/raddb/acct_users"
 files: preproxy_usersfile =
"/usr/local/etc/raddb/preproxy_users"
 files: compat = "no"
Module: Instantiated files (files)
Module: Loaded exec
 exec: wait = yes
 exec: program = "/usr/local/etc/raddb/test.php "
 exec: input_pairs = "request"
 exec: output_pairs = "reply"
 exec: packet_type = "Access-Request"
Module: Instantiated exec (authphp)
Module: Loaded radutmp
 radutmp: filename =
"/usr/local/var/log/radius/radutmp"
 radutmp: username = "%{User-Name}"
 radutmp: case_sensitive = yes
 radutmp: check_with_nas = yes
 radutmp: perm = 384
 radutmp: callerid = yes
Module: Instantiated radutmp (radutmp)
Listening on authentication 217.218.95.126:1812
Listening on accounting 217.218.95.126:1813
Ready to process requests.
rad_recv: Accounting-Request packet from host
217.218.95.123:4919, id=28, length=38
        User-Name = "reza"
        Acct-Status-Type = Start
        Acct-Session-Id = "2096"
  Processing the preacct section of radiusd.conf
modcall: entering group preacct for request 0
  modcall[preacct]: module "preprocess" returns noop
for request 0
    acct_users: Matched entry DEFAULT at line 7
  modcall[preacct]: module "files" returns ok for
request 0
modcall: group preacct returns ok for request 0
radius_xlat:  'php -f test.php'
Exec-Program: php -f test.php
Finished request 0
Going to the next request
--- Walking the entire request list ---
Cleaning up request 0 ID 28 with timestamp 442b27bd
Nothing to do.  Sleeping until we see a request.
 
at last this is ntradping's output:
"could not receive a response from the server"

tanx for everything
Best
Pezhman

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Freeradius-Devel mailing list