Can't find $HOME.

Jonathan Buzzard jonathan at buzzard.org.uk
Sun Nov 10 23:55:01 CET 2002


relson at osagesoftware.com said:
> In Linux where the code was developed, environment variable HOME
> points to  the users home directory.  Bogofilter 0.8.0 looks for
> configuration files  in /etc/bogofilter and then in ~/.bogofilter.
> The code for resolving  ~/.bogofilter currently _requires_ that
> environment variable HOME be present. 

Surely the correct approach to this, which does not rely on $HOME
being present is something like this, which is snipped from one
of my programs. Obviously you need to define config and pw somewhere
else.

	/* get the path of the tuxtimerc file */

	pw = getpwuid(getuid());
	config = (char *) malloc(strlen(pw->pw_dir)+12);
	if (config==NULL) {
		fprintf(stderr, "wmtuxtime: unable to allocate sufficent "
			"memory, exiting\n");
		exit(1);
		}
	strcpy(config, pw->pw_dir);
	strcat(config, "/.tuxtimerc");

JAB.

-- 
Jonathan A. Buzzard                 Email: jonathan at buzzard.org.uk
Northumberland, United Kingdom.       Tel: +44(0)1661-832195






More information about the Bogofilter mailing list