Package: update-info-dir
Version: 6.8-6+b1

After an "apt-get upgrade", I got this output:
```
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up install-info (6.8-6+b1) ...
/usr/sbin/update-info-dir: 4: /etc/environment: help: not found
dpkg: error processing package install-info (--configure):
installed install-info package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)
```


The script /usr/sbin/update-info-dir sources /etc/environment, but /etc/environment is not a shell script.
Usually, this file is loaded by pam_env, from the man page PAM_ENV(7):
Second a file (/etc/environment by default) with simple KEY=VAL pairs on separate lines will be read

Please note that /etc/environment does not contain any form of quoting or escaping, nor can it contain comments. Because the script /usr/sbin/update-info-dir sources /etc/environment, if any of the values contains a space, it'll try executing part of it as a command, which is not desirable.

Loading this file in a script correctly can be quiet tricky. I'm not sure why it's done here at all, but I think the following should work:
```
exec 9<&0 </etc/environment
while read -r env
do if [ -n "$env" ]
  then export "$env"
fi; done
exec 0<&9 9<&-
```

There is one more thing to consider. Some packages seam to distribute config files stored in /etc/environment.d/. On my system, they do not seam to get loaded, although I'm pretty sure on distros where pam_env is built with econf support, they usually do get loaded. I also don't know where else /etc/environment and /etc/environment.d/ may get loaded nowadays, it's quiet possible other scripts may have similar issues. And I think the inconsistent use of /etc/environment.d/ in debian is a bigger issue, a decision should be made what to do about it.

Reply via email to