0

I'd like to set default http proxy for all users under my FreeBSD environment. I modified /etc/login.conf file by adding HTTP_PROXY variable:

default:\
:passwd_format=sha512:\
:copyright=/etc/COPYRIGHT:\
:welcome=/etc/motd:\
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\
:path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\
:nologin=/var/run/nologin:\
:cputime=unlimited:\
:datasize=unlimited:\
:stacksize=unlimited:\
:memorylocked=64K:\
:memoryuse=unlimited:\
:filesize=unlimited:\
:coredumpsize=unlimited:\
:openfiles=unlimited:\
:maxproc=unlimited:\
:sbsize=unlimited:\
:vmemoryuse=unlimited:\
:swapuse=unlimited:\
:pseudoterminals=unlimited:\
:priority=0:\
:ignoretime@:\
:HTTP_PROXY=proxy-chain.server.com\c911:\
:umask=022:

and runned

# cap_mkdb /etc/login.conf

but after next login env command doesn't show me the variable. What am I doing wrong?

Daniel
  • 15
  • 6

1 Answers1

1

There's already an example of how to do this properly in the same file:

:setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\

you need to use the setenv setting, which can be a comma-separated list.

:setenv=MAIL=/var/mail/$,BLOCKSIZE=K\
,HTTP_PROXY=http\c//proxy-chain.server.com\c911:\

I've also edited the proxy URL, since AFAIK, it needs to have the protocol defined.

(sources: here and here)

madeddie
  • 418
  • 2
  • 6
  • 1
    No colon needed after BLOCKSIZE=K :setenv=MAIL=/var/mail/$,BLOCKSIZE=K\ ,HTTP_PROXY=http\c//proxy-chain.server.com\c911:\ And stupid limit doesn't allow me to edit post above: "Edits must be at least 6 characters.." – citrin Aug 12 '16 at 15:32
  • Not quite sure which colon you think is wrong, I read it again, but can't see the error you mean. Maybe you should check the sources to see how it works. – madeddie Aug 12 '16 at 15:34
  • Env vars is comma-separated list. In your post variables BLOCKSIZE and HTTP_PROXY are separated by :, not by just , – citrin Aug 12 '16 at 15:37
  • you are so right, awesome, fixed! – madeddie Aug 12 '16 at 17:23
  • 1
    It turned out that \c for colon is documented. Full list of escape codes can be found in getcap(3) section CGETNUM AND CGETSTR SYNTAX AND SEMANTICS. Not obvious place to look if you try to write value with colon in /etc/login.conf – citrin Aug 13 '16 at 17:07