On 2018-01-23, Raimo Niskanen <raimo+open...@erix.ericsson.se> wrote: > On Mon, Jan 22, 2018 at 08:22:34PM -0500, trondd wrote: >> On Mon, January 22, 2018 2:36 am, Raimo Niskanen wrote: >> > On Fri, Jan 19, 2018 at 10:47:15AM -0500, trondd wrote: >> >> On Fri, January 19, 2018 4:29 am, Raimo Niskanen wrote: >> >> > I have some machines behind a squid proxy and have set the http_proxy >> >> > and >> >> > ftp_proxy environment variables both in /etc/profile and in >> >> > /etc/login.conf >> >> > for the default login class. This works well. >> >> > >> >> > But after an upgrade when rc.firsttime calls fw_update and checks for >> >> > binary patches the proxy is not used, so I have to wait for that to time >> >> > out or break it with Ctrl-C and call fw_update manually. >> >> > >> >> > So I just wonder if anybody have an idea of how to set the http_proxy >> >> > and >> >> > ftp_proxy environment variables so they are picked up by rc.firsttime? >> >> >> >> I submitted a patch for this: >> >> https://marc.info/?l=openbsd-tech&m=151260860105270&w=2 >> > >> > That sure looks like an improvement! But should maybe $http_proxy be >> > placed between single quotes? >> > >> > Unfortunately I fetch the sets into /var/OpenBSD/`machine` and >> > verify them before rebooting into /bsd62.rd, so it would not work >> > for me... >> >> Ah, I see. Yeah, I only acconted for the obvious case when a net >> install was done. >> >> Having thought about it again, an easier solution will be to write your >> http_proxy export to /etc/rc.firsttime before rebooting into bsd.rd. If >> you have your update process scripted already, it's an easy additional >> line. The installer only appends commands so anything you have in >> rc.firsttime will be preserved. > > In my case it would work if rc.firsttime sourced /etc/profile, but I do not > know if that is a generally good idea...,
I think this is probably not a good idea, profile may not be squeaky-clean or it might not work correctly before system startup. > in particular since I can not > find any way to set environment variables for /etc/rc to pass to system and > package daemons. It doesn't help for rc.firsttime, but the canonical way to do this is via a class in login.conf - rc.d(8) automatically handles this: "daemon_class is a special read-only variable. It is set to "daemon" unless there is a login class configured in login.conf(5) with the same name as the rc.d script itself, in which case it will be set to that login class. This allows setting many initial process properties, for example environment variables, scheduling priority, and process limits such as maximum memory use and number of files." For example: daemonname:setenv=FOO=bar:tc=daemon: If you need a : in the definition, use \c. daemonname:setenv=PATH=/usr/local/bin\c/usr/bin:tc=daemon: