__package_yum is locale-dependent; should not #190

Closed
opened 2021-11-20 15:21:06 +00:00 by ungleich-gitea · 2 comments

Created by: jonmz

cdist/conf/type/__package_yum/gencode-remote tries to detect the current state of a package by looking for the string "no package provides" in the output of rpm -q --whatprovides:

not_installed="^no package provides"

if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
    state_is="absent"
else
    state_is="present"
fi

But this effectively fails if the system in question is providing its output in another language:

[root@xeon ~]# rpm -q --whatprovides pssh
Kein Paket bietet pssh

As as result, having __package pssh --state present in a manifest in fact doesn't install the package because the missing "no package provides" output leads to the false assumption that the package in question is installed. cdist succeeds with "Finished successful run".

Even if the target host is set to en_US, many sshd_configs have AcceptEnv LANG set (e.g. CentOS 6 by default), so the functionality of __package_yum effectively depends on the language configuration of the client running cdist which doesn't seem like a good idea at all.

Is there any reason why the check doesn't simply check the exit code of the rpm call?

[root@xeon ~]# rpm -q --whatprovides bash >/dev/null ; echo $?
0
[root@xeon ~]# rpm -q --whatprovides pssh >/dev/null ; echo $?
1

I've seen other explorers like __package_apt also rely on output like "Status: install ok installed" from dpkg which might be also locale-dependent.

*Created by: jonmz* `cdist/conf/type/__package_yum/gencode-remote` tries to detect the current state of a package by looking for the string "no package provides" in the output of `rpm -q --whatprovides`: ``` not_installed="^no package provides" if grep -q "$not_installed" "$__object/explorer/pkg_version"; then state_is="absent" else state_is="present" fi ``` But this effectively fails if the system in question is providing its output in another language: ``` [root@xeon ~]# rpm -q --whatprovides pssh Kein Paket bietet pssh ``` As as result, having `__package pssh --state present` in a manifest in fact doesn't install the package because the missing "no package provides" output leads to the false assumption that the package in question _is_ installed. cdist succeeds with "Finished successful run". Even if the target host is set to `en_US`, many `sshd_config`s have `AcceptEnv LANG` set (e.g. CentOS 6 by default), so the functionality of __package_yum effectively depends on the language configuration of the _client_ running cdist which doesn't seem like a good idea at all. Is there any reason why the check doesn't simply check the _exit code_ of the rpm call? ``` [root@xeon ~]# rpm -q --whatprovides bash >/dev/null ; echo $? 0 [root@xeon ~]# rpm -q --whatprovides pssh >/dev/null ; echo $? 1 ``` I've seen other explorers like __package_apt also rely on output like "Status: install ok installed" from dpkg which might be also locale-dependent.
ungleich-gitea added the
Stale
label 2021-11-20 15:21:06 +00:00
Author
Owner

closed

closed
Author
Owner

Created by: telmich

I think wherever possible, we should stick to the return code.

However, if I remember correctly the *bsd package managers do not provide us with sensible return codes (i.e. always exit 0).

I think where possible, we should change to the return code and in all other cases setup the locale to C.

@asteven Comments?

*Created by: telmich* I think wherever possible, we should stick to the return code. However, if I remember correctly the *bsd package managers do not provide us with sensible return codes (i.e. always exit 0). I think where possible, we should change to the return code and in all other cases setup the locale to C. @asteven Comments?
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#190
No description provided.