• superfluous environment variables

    From Thorsten Glaser@21:1/5 to All on Mon Dec 12 20:00:01 2022
    Hi,

    I’ve noticed that sysvinit/sysv-rc start dæmons with a *lot* of
    superfluous environment variables compared to manual invocation
    with an environment cleaner of mine:

    # cleanenv / env | sort
    HOME=/
    LC_ALL=C.UTF-8
    PATH=/bin:/usr/bin:/sbin:/usr/sbin

    I checked /proc/<pid>/environ for (exemplarily) cron from bootup
    and from a manual 'cleanenv / /etc/init.d/cron st{op,art}' and
    found these:

    --- e1 2022-12-12 18:02:21.549735648 +0000
    +++ e2 2022-12-12 18:02:21.049737965 +0000
    @@ -1,20 +1,5 @@
    -BOOT_IMAGE=/vmlinuz-5.10.0-19-amd64
    -CONSOLE=/dev/console
    HOME=/
    -INIT_VERSION=sysvinit-2.96
    LANG=C.UTF-8
    +LC_ALL=C.UTF-8
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    -PREVLEVEL=N
    -PWD=/
    -RUNLEVEL=2
    -SHELL=/bin/sh
    -SHLVL=1
    -TERM=linux
    -VERBOSE=yes
    _=/sbin/start-stop-daemon
    -drop_caps=
    -init=/sbin/init -ip=xxx.xxx.xxx.xx::xxx.xxx.xxx.1:255.255.255.0:xxxx.xxxxxx.xxx::off:xxx.xxx.xxx.xx:xxx.xxx.x.xx:xxx.xxx.xxx.xx
    -previous=N
    -rootmnt=/root
    -runlevel=2

    This means that, even for a manual invocation, these are added:

    • LANG=C.UTF-8
    • _=/sbin/start-stop-daemon

    The former is set, but not exported, in /etc/default/locale and
    therefore this is (probably) “as expected”, the second is from
    the shell.

    However, sysvinit at boot does extra things:

    • The kernel commandline parameters are added:
    ‣ /proc/cmdline
    BOOT_IMAGE, ip (but not the others!)
    • The pid 1 enviro
  • From Thorsten Glaser@21:1/5 to All on Tue Dec 13 02:30:01 2022
    (this time with the correct address, sorry)

    Hi,

    I’ve noticed that sysvinit/sysv-rc start dæmons with a *lot* of
    superfluous environment variables compared to manual invocation
    with an environment cleaner of mine:

    # cleanenv / env | sort
    HOME=/
    LC_ALL=C.UTF-8
    PATH=/bin:/usr/bin:/sbin:/usr/sbin

    I checked /proc/<pid>/environ for (exemplarily) cron from bootup
    and from a manual 'cleanenv / /etc/init.d/cron st{op,art}' and
    found these:

    --- e1 2022-12-12 18:02:21.549735648 +0000
    +++ e2 2022-12-12 18:02:21.049737965 +0000
    @@ -1,20 +1,5 @@
    -BOOT_IMAGE=/vmlinuz-5.10.0-19-amd64
    -CONSOLE=/dev/console
    HOME=/
    -INIT_VERSION=sysvinit-2.96
    LANG=C.UTF-8
    +LC_ALL=C.UTF-8
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    -PREVLEVEL=N
    -PWD=/
    -RUNLEVEL=2
    -SHELL=/bin/sh
    -SHLVL=1
    -TERM=linux
    -VERBOSE=yes
    _=/sbin/start-stop-daemon
    -drop_caps=
    -init=/sbin/init -ip=xxx.xxx.xxx.xx::xxx.xxx.xxx.1:255.255.255.0:xxxx.xxxxxx.xxx::off:xxx.xxx.xxx.xx:xxx.xxx.x.xx:xxx.xxx.xxx.xx
    -previous=N
    -rootmnt=/root
    -runlevel=2

    This means that, even for a manual invocation, these are added:

    • LANG=C.UTF-8
    • _=/sbin/start-stop-daemon

    The former is set, but not exported, in /etc/default/locale and
    therefore this is (probably) “as expected”, the second is from
    the shell.

    However, sysvinit at boot does extra things:

    • The kernel commandline parameters are added:
    ‣ /proc/cmdline
    BOOT_IMAGE, ip (but not the others!)
    • The pid 1 enviro