# freeradius not reading configuration when started with RC script



## primeroz (Jun 8, 2010)

Hi,

i am having a strange problem with freeradius-2.0.5 running on a freebsd 7.0

When i start the process through the rc script 


```
> $ /usr/local/etc/rc.d/radiusd start
Starting radiusd.
```

The conf file is not parsed and i end up in a strange socket situation as :


```
> $ sockstat -l|grep rad
freeradiusradiusd   47962 4  tcp4   *:*                   *:*
```

while if i just start it by hand everything works perfectly: 


```
> $ /usr/local/sbin/radiusd 

> $ sockstat -l|grep rad
freeradiusradiusd   48006 5  udp4   $MYIP1:1812     *:*
freeradiusradiusd   48006 6  udp4   $MYIP1:1813     *:*
freeradiusradiusd   48006 7  udp4   $MYIP2:1812     *:*
freeradiusradiusd   48006 8  udp4   $MYIP2:1813     *:*
freeradiusradiusd   48006 9  udp4   $MYIP1:1814     *:*
```

i double-checked all permissions on every possible file, and still i can't find a reason for this.

i ended up putting an "echo $_doit" in the rc.subr to check the system was running the same /usr/local/sbin/radiusd as i do ... and it does.

ktraceing the rc.d scripts shows as last stuff:


```
44514 sh       CALL  stat(0x800b29420,0x7fffffffd9e0)
 44514 sh       NAMI  "/usr/local/sbin/radiusd"
 44514 sh       RET   stat 0
 44514 sh       CALL  eaccess(0x800b29420,X_OK)
 44514 sh       NAMI  "/usr/local/sbin/radiusd"
 44514 sh       RET   eaccess 0
 44514 sh       CALL  geteuid
 44514 sh       RET   geteuid 0
 44514 sh       CALL  stat(0x800b294e8,0x7fffffffd020)
 44514 sh       NAMI  "/usr/local/etc/raddb//."
 44514 sh       RET   stat 0
 44514 sh       CALL  stat(0x800b294f8,0x7fffffffd0b0)
 44514 sh       NAMI  "/usr/local/etc/raddb//radiusd.conf"
 44514 sh       RET   stat 0
 44514 sh       CALL  eaccess(0x800b294f8,R_OK)
 44514 sh       NAMI  "/usr/local/etc/raddb//radiusd.conf"
 44514 sh       RET   eaccess 0
 44514 sh       CALL  write(0x1,0x800b11400,0x12)
 44514 sh       GIO   fd 1 wrote 18 bytes
       "Starting radiusd.
       "
 44514 sh       RET   write 18/0x12
 44514 sh       CALL  fork
 44514 sh       RET   fork 44524/0xadec
 44514 sh       CALL  getpgrp
 44514 sh       RET   getpgrp 44514/0xade2
 44514 sh       CALL  wait4(0xffffffff,0x7fffffffd70c,WUNTRACED,0)
 44514 sh       RET   wait4 44524/0xadec
 44514 sh       CALL  read(0xa,0x520ec0,0x3ff)
 44514 sh       GIO   fd 10 read 0 bytes
       ""
 44514 sh       RET   read 0
 44514 sh       CALL  exit(0)
```

so here where it should parse the configuration (as i can see from ktracing a manual start of radiusd) the system just does not do it and start the process in a not usable way.

Please ... help 

Thanks


----------



## SirDice (Jun 8, 2010)

Have a look at the rc script. Maybe there's an option to specify the config file and it's using the wrong one?


----------



## primeroz (Jun 8, 2010)

Hi SirDice,

i checked that. The configuration files are in their default location and indeed when i start the command by hand as /usr/local/sbin/radiusd it manage to parse them properly. 

I tried anyway to add the flag as radiusd_flags="-d $config_dir" but still having the same issues.

I had quite a few issue with freebsd 7.0 in other things ... i am starting to think my only option is to upgrade ... but i rather not if possible.


----------



## ohauer (Jun 8, 2010)

add the following line into /etc/rc.conf.local

```
rc_debug="YES"
```

Now start freeradius and look for the line 

```
DEBUG: run_rc_command: doit ...
```
eval the arguments from this output and try to start freeradius manual with this command line.

The other way is to start this way and inspect the output.

```
# script [FILE]/tmp/foobar[/FILE]
# sh -x /usr/local/etc/rc.d/radiusd start
# exit
# col -xb < [FILE]/tmp/foobar[/FILE] > [FILE]/tmp/foobar_readable[/FILE]
```

This produce a transcript where you can eval the start parameters and return codes

But I agree with you 7.0 is EOL and should be updated at last to 7.3.


----------



## primeroz (Jun 9, 2010)

thanks, this sounds promising. 

I am in the middle of travelling right now so have no chance (neither energy) to test it now but i will as soon as possible.

Yeah i know .... EOL is my personal professional curse


----------



## primeroz (Jul 7, 2010)

got quite a few information from the debugging suggested. Thanks, it will be a valuable knowledge. 

Still not solving my problem ... with rc_debug enabled i can see that 


```
/usr/local/etc/rc.d/radiusd: DEBUG: checkyesno: radiusd_enable is set to YES.
Starting radiusd.
/usr/local/etc/rc.d/radiusd: DEBUG: run_rc_command: doit: /usr/local/sbin/radiusd
```

and still is not working :
s
	
	



```
ockstat -l | grep rad
freeradiusradiusd   91263 4  tcp4   *:*                   *:*
```

if i do 

`eval /usr/local/sbin/radiusd`

i get it to work , listening on correct ip and ports.

The sh -x output of last lines shows:


```
+ eval /usr/local/sbin/radiusd
+ /usr/local/sbin/radiusd
+ _return=0
```

so it look like is running exactly the same command with eval ... but still not working ... i am lost


----------



## ohauer (Jul 8, 2010)

Hm, strange a quick test on my machine and it works there.

Does freeradius start from script with parameter debug instead start
`# /usr/local/etc/rc.d/radiusd debug`

Maybe you see in the output some errors or misconfiguration


----------

