[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

one global way to set environment variables - xdm patch



this is a patch for xdm (and kdm) to read /etc/environment.

bad features :
 - hardcoded filename "/etc/environment"
	(sorry, i tried to change that, but i don't understand the
	 xdmcp protocoll and failed ...)
 - no dupe checking for variables (xdm sets some variables himself,
   	so PATH or such things could be set twice).

but i think there should realy be one global way to set environment
variables for login, xdm, telnet and ssh sessions.
currently there is none as x11 doesn't import /etc/environment.
sourceing the file does not help, as the variables should be exported.
(e.g. PATH or LANG must be set for applications called by the
windowmanager and in xterms).

andreas
---

This way kdm will read /etc/environment (like ssh and login do), and set
the environment accourding. sorry, i couldn't get the filename
configurable.

notes :
a) PATH is set in the xdm-config file
b) PS1 will not reach an xterm. i don't know why.

--- verify.c	Thu Nov 20 14:08:18 1997
+++ verify.c.new	Mon Feb  2 21:28:16 1998
@@ -88,6 +88,8 @@
     char	**envvar;
     char	*str;
     extern char **defaultEnv (), **setEnv ();
+    FILE *     fd;
+    char       buffer[1024];
     
     env = defaultEnv ();
     env = setEnv (env, "DISPLAY", d->name);
@@ -103,6 +105,24 @@
 	if ( (str = getenv(*envvar)))
 	    env = setEnv (env, *envvar, str);
     }
+    if (fd = fopen("/etc/environment","r"))
+    {
+       while (fgets(buffer,sizeof(buffer),fd)==buffer)
+       {
+           char *cp;
+            cp = strchr(buffer, '\n');
+           if (!cp) break;
+            *cp = '\0';
+           cp = strchr(buffer,'=');
+           if (cp)
+            {
+               *cp=0;
+               env = setEnv(env, buffer, ++cp);
+            }
+       }
+       fclose(fd);
+    }
+
     return env;
 }
 



--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: