|
Bugzilla – Full Text Bug Listing |
| Summary: | Symlinked states not found after fix-cve-2024-22231-and-cve-2024-22232-bsc-1219430-bs.patch | ||
|---|---|---|---|
| Product: | [openSUSE] openSUSE Distribution | Reporter: | Georg Pfuetzenreuter <georg.pfuetzenreuter> |
| Component: | Salt | Assignee: | E-Mail List <salt-maintainers> |
| Status: | CONFIRMED --- | QA Contact: | E-mail List <qa-bugs> |
| Severity: | Normal | ||
| Priority: | P2 - High | CC: | artem.shiliaev, georg.pfuetzenreuter, pablo.suarezhernandez, suse-beta |
| Version: | Leap 15.5 | Flags: | pablo.suarezhernandez:
needinfo?
(georg.pfuetzenreuter) |
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | openSUSE Leap 15.5 | ||
| URL: | https://github.com/SUSE/spacewalk/issues/24798 | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
|
Description
Georg Pfuetzenreuter
2024-02-15 20:05:14 UTC
Upstream discussion: https://github.com/saltstack/salt/issues/65977. Due to the CVE fixes, for security reasons the symlinks would ONLY work if the targetted file is part of the same "file_root".
By default, the "file_roots" for a Salt Master (and also for salt-call --local execution) are:
base:
- /srv/salt
- /srv/spm/salt
If you have formulas in other directories that you want to expose in the Salt fileserver, then maybe what you would need is to add it to the "file_roots" in Salt Master configuration (i.a. /etc/salt/master.d/custom.conf or minion configuration). Something like this:
file_roots:
base:
- /srv/salt/
- /srv/spm/salt
- /srv/formula/
Then you could remove the symlinks as the formulas will be exposed in the Salt fileserver as they are part of the file roots.
Would that work for you?
Hi Pablo,
thanks for getting back. We use the following roots:
```
file_roots:
production:
- /srv/salt
- /usr/share/salt-formulas/states
- /srv/formula
```
Inside `/srv/formula`, we locate symlinks such as the following:
```
# ls -al /srv/formula
total 88
drwxr-xr-x 1 root root 362 Dec 23 18:37 .
drwxr-xr-x 1 root root 98 Dec 26 22:56 ..
lrwxrwxrwx 1 root root 38 Oct 15 19:54 chrony -> /srv/formula-src/chrony-formula/chrony
lrwxrwxrwx 1 root root 52 Oct 15 19:54 elasticsearch -> /srv/formula-src/elasticsearch-formula/elasticsearch
lrwxrwxrwx 1 root root 44 Oct 15 19:54 firewalld -> /srv/formula-src/firewalld-formula/firewalld
lrwxrwxrwx 1 root root 40 Oct 15 19:54 haproxy -> /srv/formula-src/haproxy-formula/haproxy
lrwxrwxrwx 1 root root 44 Oct 26 21:17 hostsfile -> /srv/formula-src/hostsfile-formula/hostsfile
lrwxrwxrwx 1 root root 46 Oct 15 19:54 keepalived -> /srv/formula-src/keepalived-formula/keepalived
lrwxrwxrwx 1 root root 38 Oct 15 19:54 limits -> /srv/formula-src/limits-formula/limits
lrwxrwxrwx 1 root root 38 Oct 15 19:54 locale -> /srv/formula-src/locale-formula/locale
lrwxrwxrwx 1 root root 48 Oct 15 19:54 mirrorcache -> /srv/formula-src/mirrorcache-formula/mirrorcache
drwxr-xr-x 1 root root 0 Oct 15 19:54 _modules
lrwxrwxrwx 1 root root 36 Oct 15 19:54 mysql -> /srv/formula-src/mysql-formula/mysql
lrwxrwxrwx 1 root root 36 Oct 15 19:54 nginx -> /srv/formula-src/nginx-formula/nginx
lrwxrwxrwx 1 root root 42 Oct 15 19:54 openldap -> /srv/formula-src/openldap-formula/openldap
lrwxrwxrwx 1 root root 40 Oct 15 19:54 openssh -> /srv/formula-src/openssh-formula/openssh
lrwxrwxrwx 1 root root 42 Oct 15 19:54 powerdns -> /srv/formula-src/powerdns-formula/powerdns
lrwxrwxrwx 1 root root 46 Nov 26 21:14 prometheus -> /srv/formula-src/prometheus-formula/prometheus
lrwxrwxrwx 1 root root 40 Oct 15 19:54 rsyslog -> /srv/formula-src/rsyslog-formula/rsyslog
lrwxrwxrwx 1 root root 34 Oct 15 19:54 salt -> /srv/formula-src/salt-formula/salt
lrwxrwxrwx 1 root root 34 Oct 15 19:54 sssd -> /srv/formula-src/sssd-formula/sssd
drwxr-xr-x 1 root root 0 Oct 15 19:54 _states
lrwxrwxrwx 1 root root 40 Oct 15 19:54 sudoers -> /srv/formula-src/sudoers-formula/sudoers
lrwxrwxrwx 1 root root 38 Oct 15 19:54 sysctl -> /srv/formula-src/sysctl-formula/sysctl
drwxr-xr-x 1 root root 54 Oct 26 18:19 tayga
lrwxrwxrwx 1 root root 42 Oct 15 19:54 timezone -> /srv/formula-src/timezone-formula/timezone
lrwxrwxrwx 1 root root 36 Dec 23 18:37 users -> /srv/formula-src/users-formula/users
```
This allows us to enable and disable formulas dynamically.
If we were to list all directories as `file_roots` directly, this would on one hand require changing all our tooling (the links and configuration are all managed by carefully curated Salt states), but on the other hand, and probably more critically, any change (enabling/disabling formulas) would then require a full restart of the Salt Master, which I think is a feature decrease.
It's a bit odd to me how the patch does not cover the `fileserver_followsymlinks` configuration option. I think instead of blanket ignoring all links, one could have changed the default of this option to `False`, then our use case could have simply been facilitated with a `fileserver_followsymlinks: True`. But of course, I might be missing other considerations. (In reply to Georg Pfuetzenreuter from comment #3) > > Inside `/srv/formula`, we locate symlinks such as the following: > > ``` > # ls -al /srv/formula > total 88 > drwxr-xr-x 1 root root 362 Dec 23 18:37 . > drwxr-xr-x 1 root root 98 Dec 26 22:56 .. > lrwxrwxrwx 1 root root 38 Oct 15 19:54 chrony -> > /srv/formula-src/chrony-formula/chrony > lrwxrwxrwx 1 root root 52 Oct 15 19:54 elasticsearch -> > /srv/formula-src/elasticsearch-formula/elasticsearch > lrwxrwxrwx 1 root root 44 Oct 15 19:54 firewalld -> > /srv/formula-src/firewalld-formula/firewalld > lrwxrwxrwx 1 root root 40 Oct 15 19:54 haproxy -> > /srv/formula-src/haproxy-formula/haproxy > lrwxrwxrwx 1 root root 44 Oct 26 21:17 hostsfile -> > /srv/formula-src/hostsfile-formula/hostsfile > lrwxrwxrwx 1 root root 46 Oct 15 19:54 keepalived -> > /srv/formula-src/keepalived-formula/keepalived > lrwxrwxrwx 1 root root 38 Oct 15 19:54 limits -> > /srv/formula-src/limits-formula/limits > lrwxrwxrwx 1 root root 38 Oct 15 19:54 locale -> > /srv/formula-src/locale-formula/locale > lrwxrwxrwx 1 root root 48 Oct 15 19:54 mirrorcache -> > /srv/formula-src/mirrorcache-formula/mirrorcache > drwxr-xr-x 1 root root 0 Oct 15 19:54 _modules > lrwxrwxrwx 1 root root 36 Oct 15 19:54 mysql -> > /srv/formula-src/mysql-formula/mysql > lrwxrwxrwx 1 root root 36 Oct 15 19:54 nginx -> > /srv/formula-src/nginx-formula/nginx > lrwxrwxrwx 1 root root 42 Oct 15 19:54 openldap -> > /srv/formula-src/openldap-formula/openldap > lrwxrwxrwx 1 root root 40 Oct 15 19:54 openssh -> > /srv/formula-src/openssh-formula/openssh > lrwxrwxrwx 1 root root 42 Oct 15 19:54 powerdns -> > /srv/formula-src/powerdns-formula/powerdns > lrwxrwxrwx 1 root root 46 Nov 26 21:14 prometheus -> > /srv/formula-src/prometheus-formula/prometheus > lrwxrwxrwx 1 root root 40 Oct 15 19:54 rsyslog -> > /srv/formula-src/rsyslog-formula/rsyslog > lrwxrwxrwx 1 root root 34 Oct 15 19:54 salt -> > /srv/formula-src/salt-formula/salt > lrwxrwxrwx 1 root root 34 Oct 15 19:54 sssd -> > /srv/formula-src/sssd-formula/sssd > drwxr-xr-x 1 root root 0 Oct 15 19:54 _states > lrwxrwxrwx 1 root root 40 Oct 15 19:54 sudoers -> > /srv/formula-src/sudoers-formula/sudoers > lrwxrwxrwx 1 root root 38 Oct 15 19:54 sysctl -> > /srv/formula-src/sysctl-formula/sysctl > drwxr-xr-x 1 root root 54 Oct 26 18:19 tayga > lrwxrwxrwx 1 root root 42 Oct 15 19:54 timezone -> > /srv/formula-src/timezone-formula/timezone > lrwxrwxrwx 1 root root 36 Dec 23 18:37 users -> > /srv/formula-src/users-formula/users > ``` So, you have "/srv/formula" in "file_roots" containing symlinks to "/srv/formula-src" (which is NOT part of your file_roots, therefore symlinks fail) If you add "/srv/formula-src" directory to your current "file_roots", and then you create the shortcut symlinks inside "/srv/formula-src" (instead of /srv/formula/") then the symlinks should work. This does not require you restart the Salt Master on every new formula, as you would only add "/srv/formula-src" once, then all the formulas would be available. Hi Pablo, I understand what you mean now. Unfortunately, I am not quite confident with it - `/srv/formula-src` is a Git repository. Installing untracked symlinks there is somewhat ugly. We could think of tracking the links as part of the repository. (In reply to Georg Pfuetzenreuter from comment #4) > It's a bit odd to me how the patch does not cover the > `fileserver_followsymlinks` configuration option. I think instead of blanket > ignoring all links, one could have changed the default of this option to > `False`, then our use case could have simply been facilitated with a > `fileserver_followsymlinks: True`. But of course, I might be missing other > considerations. Hey Georg, IIUC "fileserver_followsymlinks" would still affect symlinks that are targetting files which are part of the same file root. I now tried your suggestion.
This works:
```
c0c6bbd75dbf:/srv/formula-src # ls -ld chrony
lrwxrwxrwx 1 root root 21 Feb 16 13:24 chrony -> chrony-formula/chrony
c0c6bbd75dbf:/srv/formula-src # more /etc/salt/minion.d/roots.conf
file_roots:
base:
- /srv/salt
- /usr/share/salt-formulas/states
- /srv/formula-src
c0c6bbd75dbf:/srv/formula-src # salt-call --local state.show_sls chrony
local:
----------
chrony-package-install-pkg-installed:
....
```
However this, in my opinion slightly cleaner variant, does not:
```
c0c6bbd75dbf:/srv/formula-src # ls -ld states/chrony
lrwxrwxrwx 1 root root 24 Feb 16 13:23 states/chrony -> ../chrony-formula/chrony
c0c6bbd75dbf:/srv/formula-src # more /etc/salt/minion.d/roots.conf
file_roots:
base:
- /srv/salt
- /usr/share/salt-formulas/states
- /srv/formula-src/states
c0c6bbd75dbf:/srv/formula-src # salt-call --local state.show_sls chrony
local:
- No matching sls found for 'chrony' in env 'base'
```
Then again, this variant does:
```
c0c6bbd75dbf:/srv/formula-src # ls -ld chrony
lrwxrwxrwx 1 root root 34 Feb 16 13:32 chrony -> repositories/chrony-formula/chrony
c0c6bbd75dbf:/srv/formula-src # more /etc/salt/minion.d/roots.conf
file_roots:
base:
- /srv/salt
- /usr/share/salt-formulas/states
- /srv/formula-src
c0c6bbd75dbf:/srv/formula-src # salt-call --local state.show_sls chrony
local:
----------
chrony-package-install-pkg-installed:
----------
...
```
I think I will opt for this last variant as to not clutter our repository top level with both, submodules and symlinks.
> would still affect symlinks that are targetting files which are part of the same file root.
Thanks, makes sense.
Some big refactoring in our Salt setup later, we now have an operational setup again: https://code.opensuse.org/heroes/salt/c/37c6d020e8e6e154717503d8bddacafb3be6aef9?branch=production https://code.opensuse.org/heroes/salt-formulas-git/c/7e7a1d137c46d24ea8362faeb1b7b9fb0b83428b?branch=production Now I can think of at least two other Salt infrastructures I maintain where the problematic symlink setup is used .. assuming this new behavior is now expected, I guess I will have to do the refactoring work there as well. Thank you for the help. |