/etc/environment was added in current for a short period of time when sudo was complaining about its absence, but that bug got fixed and Pat removed it again.
I wrote this quick and dirty C program to get xdm to support /etc/environment on a non-pam system:
envrun.c:
Code:
// Load environment from /etc/environment and run command.
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int set_env_from_file( FILE *infile )
{
int status = 1;
char *linebuf;
size_t linebuf_size = 0;
ssize_t length = 0;
errno = 0;
while ( (length = getline(&linebuf, &linebuf_size, infile)) != -1 )
{
if ( length > 1 && linebuf[0] != '#' )
{
if ( linebuf[length - 1] == '\n' )
linebuf[--length] = '\0'; /* remove a trailing '\n' */
putenv(strdup(linebuf));
}
}
if ( errno != 0 )
status = 0;
free(linebuf);
return status;
}
int main( int argc, char *argv[] )
{
int status = EXIT_FAILURE;
char const envfilename[] = "/etc/environment";
FILE *infile;
if ( (infile = fopen(envfilename, "r")) != NULL ) {
set_env_from_file(infile);
fclose(infile);
}
execv(argv[1], &argv[1]);
return status;
}
Just compile it and stick it in /usr/local/bin and you can replace the
#!/bin/bash at the top of /etc/X11/xdm/Xsession with
#!/usr/local/bin/envrun /bin/bash and Bob's your teapot!
Alternatively, you can wait for PAM to come along and do the job for you.