Summary: | 'etc-update' doesn't work for files with space in the name | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Vasily <Vasilij.K.Savin> |
Component: | Core | Assignee: | Portage team <dev-portage> |
Status: | CONFIRMED --- | ||
Severity: | normal | CC: | eselect, hlein, pms, Vasilij.K.Savin |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
See Also: |
https://bugs.gentoo.org/show_bug.cgi?id=14983 https://bugs.gentoo.org/show_bug.cgi?id=876193 |
||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Vasily
2018-11-21 10:43:41 UTC
NB: Original file does not exist since it was renamed to 'WindowsAll.conf' and edited: backupserver / # ls -la /etc/bareos/bareos-dir.d/fileset/ total 40 drwxr-xr-x 2 bareos bareos 4096 Nov 21 09:23 . drwxr-xr-x 15 bareos bareos 4096 Jun 28 18:11 .. -rw-r----- 1 bareos bareos 312 Jul 24 14:28 Catalog.conf -rw-r----- 1 root root 362 Nov 20 18:12 '._cfg0000_Windows All Drives.conf' -rw-r--r-- 1 bareos bareos 56 Jul 26 05:53 Empty.conf -rw-r----- 1 bareos bareos 1695 Jul 25 17:51 FS00_Backups.conf -rw-r----- 1 bareos bareos 888 Jul 26 05:59 FullSet.conf -rw-r----- 1 bareos bareos 1612 Jul 26 15:12 LinuxAll.conf -rw-r----- 1 bareos bareos 211 Sep 20 11:42 SelfTest.conf -rw-r----- 1 bareos bareos 421 Nov 21 09:23 WindowsAll.conf The first problem I see is this for loop which uses whitespace to separate values of ${file}:
> for file in $(find "${path}"/ "${find_opts[@]}" |
> sed \
> -e 's://*:/:g' \
> -e "${scan_regexp}" |
> sort -t"$b" -k2,2 -k4,4 -k3,3 |
> LC_ALL=C cut -f1 -d"$b")
> do
We can fix it like this:
while read -r -d ''; do
stuff
done < <(find ... -print0)
This still happens: ... * IMPORTANT: config file '/etc/testssl/DST Root CA X3.txt' needs updating. ... # etc-update Scanning Configuration files... Skipping non-file /etc/testssl/._cfg0000_DST ... Skipping non-file Root ... Skipping non-file CA ... Skipping non-file X3.txt ... Exiting: Nothing left to do; exiting. :) # ls -l /etc/testssl/._cfg0000_DST* -rw-r--r-- 1 root root 1200 Dec 6 02:00 '/etc/testssl/._cfg0000_DST Root CA X3.txt' # equery f testssl | egrep ' ' /etc/testssl/DST Root CA X3.txt # equery b /usr/sbin/etc-update * Searching for /usr/sbin/etc-update ... sys-apps/portage-3.0.56-r1 (/usr/sbin/etc-update) # equery l testssl * Searching for testssl ... [I-O] [ ] net-analyzer/testssl-3.2_rc3_p20231110:0 This is a bump of testssl vs what is in ::gentoo, and in it, that 'DST Root CA X3.txt' has changed in minor/trivial ways, but that's just one example, I think anything w/spaces in the path will fail. (In reply to Zac Medico from comment #2) > We can fix it like this: > > while read -r -d ''; do > stuff > done < <(find ... -print0) I think this is on the right track but that ... is doing a lot of work, bc the logic in the current find pipeline is complex. I don't have enough brain right now to flesh it out. I suppose other problems lurk, for example CONFIG_PROTECT is a space-separated list; how does it handle spaces in paths, and should it? Perhaps etc-update, CONFIG_PROTECT and the like should not try, and spaces in config paths & filename should just be banned; it would be up to ebuilds to rename files and patch things looking for them. I could not find any such rule in an exhaustive 30 seconds of Googling. (In reply to Hank Leininger from comment #3) > I suppose other problems lurk, for example CONFIG_PROTECT is a > space-separated list; how does it handle spaces in paths, and should it? Should work with embedded quotes, since we use the shlex.split function. > Perhaps etc-update, CONFIG_PROTECT and the like should not try, and spaces > in config paths & filename should just be banned; it would be up to ebuilds > to rename files and patch things looking for them. I could not find any such > rule in an exhaustive 30 seconds of Googling. We really need to support it if other package managers do, or else it will be a pain. Looks like rpm supports it: https://rpm-list.redhat.narkive.com/7WUOZXa6/basic-question-space-in-file-name Currently, PMS only says that CONFIG_PROTECT is space-delimited and says nothing about embedded quotes. We can use shlex.split then requote in " ".join(mylist) to support spaces in CONFIG_PROTECT in lib/portage/util/env_update.py here: > for var in space_separated: > mylist = [] > for myconfig in config_list: > if var in myconfig: > for item in myconfig[var].split(): > if item and not item in mylist: > mylist.append(item) > del myconfig[var] # prepare for env.update(myconfig) > if mylist: > env[var] = " ".join(mylist) > specials[var] = mylist I've checked the eselect.env module and it also does not quote spaces within an item here: > elif has ${var} ${SPACE_CLASS}; then > # Space separated > store=$(load_config "${tmpprofile}" ${var}) > if [[ -z ${store} ]]; then > store=$(load_config "${envfile}" ${var}) > else > items=$(load_config "${envfile}" ${var}) > for item in ${items}; do > has ${item} ${store} \ > || store="${store}${store:+ }${item}" > done > fi > else (In reply to Zac Medico from comment #5) > I've checked the eselect.env module and it also does not quote spaces within > an item here: Obviously, the elements of a whitespace delimited list cannot contain whitespace. It is a limit of the spec, so nothing that eselect can do about it. We should really consider limiting names of configuration files to a sane character set, in order to avoid strange problems like this. CONFIG_PROTECT and CONFIG_PROTECT_MASK usually contain directory paths. I think it is rare to specify the full path to individual files. We might therefore consider allowing file names to contain spaces, but ban it for directories. Or we can just live with the fact that there will be paths that are impossible to declare in CONFIG_PROTECT and CONFIG_PROTECT_MASK. Either way, etc-update should be fixed to function properly with any installed file name. |