I need to set global environment variables HTTP_PROXY, HTTPS_PROXY and FTP_PROXY so that anything that needs to connect to the internet can do so via the squid proxy on this network, regardless of the logged in user.
The most effective way of doing this I've found in FreeBSD is via the setenv capability in /etc/login.conf, however the GhostBSD desktop environment (Xfce) doesn't appear to respect that (i.e. the variables set this way aren't visible in a user shell when logged in)
The other way I expected might work was to export the variables in /etc/profile, however that doesn't appear to work either (either with sh or fish shells).
So how/where is one expected to set global environment variables like this? TIA
How/where to set global environment variables?
-
- Posts: 40
- Joined: Sun Aug 20, 2017 10:08 am
Re: How/where to set global environment variables?
Seems to work for me when I put them in /etc/profile:
After I log out any existing user and log in again, the environment variables are accessible in a (fish) shell under Xfce as root or a user
Using GhostBSD 11.1 ALPHA1
Richard
Code: Select all
HTTP_PROXY=blabla; export HTTP_PROXY
Code: Select all
root@ghostbsd:~ # echo $HTTP_PROXY
blabla
root@ghostbsd:~ # su rherman
rherman@ghostbsd /root> echo $HTTP_PROXY
blabla
Richard
Re: How/where to set global environment variables?
Thanks for the followup. I'm glad the /etc/profile approach works for you, but it doesn't work for me in either 11.1alpha1 or 10.3
Re: How/where to set global environment variables?
/etc/profile is the global profile for the default shell /bin/sh, other shells usually make use of the same profile for compatibility, some shell probably don't.
I would suggest, for a test, to make use of the default shell /bin/sh (please see man chsh for details).
I would suggest, for a test, to make use of the default shell /bin/sh (please see man chsh for details).
Re: How/where to set global environment variables?
I get the same behaviour with /bin/sh
Re: How/where to set global environment variables?
can you copy &paste here your /etc/profile ?WytWun wrote:I get the same behaviour with /bin/sh
Re: How/where to set global environment variables?
Code: Select all
# $FreeBSD: releng/11.1/etc/profile 208116 2010-05-15 17:49:56Z jilles $
#
# System-wide .profile file for sh(1).
#
# Uncomment this to give you the default 4.2 behavior, where disk
# information is shown in K-Blocks
# BLOCKSIZE=K; export BLOCKSIZE
#
# For the setting of languages and character sets please see
# login.conf(5) and in particular the charset and lang options.
# For full locales list check /usr/share/locale/*
# You should also read the setlocale(3) man page for information
# on how to achieve more precise control of locale settings.
#
# Check system messages
# msgs -q
# Allow terminal messages
# mesg y
CHARSET=UTF-8; export CHARSET
LANG=en_US.UTF-8; export LANG
GDM_LANG=en_US.UTF-8; export GDM_LANG
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
HTTP_PROXY=http://192.168.3.1:3128/; export HTTP_PROXY
HTTPS_PROXY=$HTTP_PROXY; export HTTPS_PROXY
Re: How/where to set global environment variables?
As far as I know that's what ~/.xprofile is for - but I think SLiM does not use this file. You can also try /usr/local/etc/X11/xinit/xinitrc or ~/.xinitrc for defining environment variables. Does that maybe do the trick?
Re: How/where to set global environment variables?
I would rather not rely on X related scripts as I want these environment variables set for SSH logins as well as local desktop sessions.
Re: How/where to set global environment variables?
I'm starting to think you have come across that FreeBSD cap_mkdb(1) obscenity:
from login.conf(5) manpage:
from login.conf(5) manpage:
The default /etc/login.conf shipped with FreeBSD is an out of the box
configuration. Whenever changes to this, or the user's ~/.login_conf,
file are made, the modifications will not be picked up until cap_mkdb(1)
is used to compile the file into a database. This database file will
have a .db extension and is accessed through cgetent(3). See getcap(3)
for a more in-depth description of the format of a capability database.