$ENV{HOSTNAME} on debian hosts

Fred fred.maison at gmail.com
Thu Sep 29 12:10:41 CEST 2011


I use squeeze.
echo "SHELL:$SHELL HOSTNAME:$HOSTNAME"
SHELL:/bin/bash HOSTNAME:radius3.nsslab
My shell seems to be bash and hostname is present en my interactive
environment but absent form a program environment.

Try this  code :
#include <stdlib.h>
#include <stdio.h>

int main()
{
	const char *hostname	= getenv( "HOSTNAME" );
	const char *shell	= getenv( "SHELL" );
	const char *pwd		= getenv( "PWD" );
	const char *path	= getenv( "PATH" );
	const char *user	= getenv( "USER" );
	const char *shlvl	= getenv( "SHLVL" );

	printf( "PWD		(%s)\n", (pwd		?	pwd		: "not defined!") );
	printf( "PATH		(%s)\n", (path		?	path		: "not defined!") );
	printf( "SHELL		(%s)\n", (shell		?	shell		: "not defined!") );
	printf( "SHLVL		(%s)\n", (shell		?	shlvl		: "not defined!") );
	printf( "HOSTNAME	(%s)\n", (hostname	?	hostname	: "not defined!") );

  return 0;
}

Here is the result I got :
 ./getenv
PWD		(/home/support/src/getenv)
PATH		(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
SHELL		(/bin/bash)
SHLVL		(2)
HOSTNAME	(not defined!)

HOSTNAME=`hostname` ./getenv
PWD		(/home/support/src/getenv)
PATH		(/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
SHELL		(/bin/bash)
SHLVL		(2)
HOSTNAME	(radius3.nsslab)

Best regards,
Fred

2011/9/29 Ben Brown <bbrown at plus.net>:
>> It seems environment passed to freeradius at startup does not have
>> HOSTNAME defined.
>
> Which version of debian are you using?
>
> In squeeze /bin/sh is provided by dash, rather than bash, which doesn't
> seem to set HOSTNAME.
>
> Is HOSTNAME used in the default debian freeradius config? If so I would
> suggest raising a bug to the maintainer of the debian freeradius
> package.
>
> Ben
>
> --
> | Ben Brown                                     Broadband Solutions for
> | Infrastructure Engineer                              Home & Business@
> | Plusnet Plc                                              www.plus.net
> | Registered Office: Internet House, 2 Tenter Street, Sheffield, S1 4BY
> | Registered in England no: 3279013
> + --------------- Plusnet - ISPA Best Consumer ISP 2008 ---------------
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
>




More information about the Freeradius-Users mailing list