Test package paths ownership
(
install_salt,
pkg_paths,
pkg_paths_salt_user,
pkg_paths_salt_user_exclusions,
salt_call_cli,
)
| 176 | |
| 177 | |
| 178 | def test_pkg_paths( |
| 179 | install_salt, |
| 180 | pkg_paths, |
| 181 | pkg_paths_salt_user, |
| 182 | pkg_paths_salt_user_exclusions, |
| 183 | salt_call_cli, |
| 184 | ): |
| 185 | """ |
| 186 | Test package paths ownership |
| 187 | """ |
| 188 | if packaging.version.parse(install_salt.version) <= packaging.version.parse( |
| 189 | "3006.4" |
| 190 | ): |
| 191 | pytest.skip("Package path ownership was changed in salt 3006.4") |
| 192 | |
| 193 | if install_salt.prev_version == "3007.1": |
| 194 | pytest.xfail("Fails due to syndic permissions bug") |
| 195 | |
| 196 | if install_salt.distro_name == "photon" and install_salt.distro_version == "5": |
| 197 | # Fails on upgrade tests but there is no way to check that we are running an upgrade test. |
| 198 | pytest.skip("Package path ownership fails on photon 5") |
| 199 | |
| 200 | # Determine the expected owner for the minion and installation directory. |
| 201 | # We check the minion configuration to see if a specific user is set. |
| 202 | expected_minion_user = "root" |
| 203 | ret = salt_call_cli.run("--local", "config.get", "user") |
| 204 | if ret.returncode == 0 and ret.data: |
| 205 | expected_minion_user = ret.data |
| 206 | |
| 207 | def _is_excluded(path): |
| 208 | path_str = str(path) |
| 209 | for excluded in pkg_paths_salt_user_exclusions: |
| 210 | if path_str == excluded or path_str.startswith(f"{excluded}/"): |
| 211 | return True |
| 212 | return False |
| 213 | |
| 214 | def _is_minion_runtime_path(path): |
| 215 | path_str = str(path) |
| 216 | return any( |
| 217 | path_str.startswith(prefix) |
| 218 | for prefix in ( |
| 219 | "/etc/salt/minion", |
| 220 | "/var/cache/salt/minion", |
| 221 | "/var/log/salt/minion", |
| 222 | "/var/run/salt/minion", |
| 223 | "/run/salt/minion", |
| 224 | ) |
| 225 | ) |
| 226 | |
| 227 | def _deb_downgrade_legacy_salt_paths_allow_root(): |
| 228 | """ |
| 229 | Pre-3007 .deb layouts often left master/cache log trees root-owned. After a |
| 230 | downgrade to 3006.x, those paths match ``pkg_paths_salt_user`` but are not |
| 231 | salt:salt like current packages. |
| 232 | """ |
| 233 | return ( |
| 234 | install_salt.use_prev_version |
| 235 | and install_salt.distro_id in ("debian", "ubuntu") |
nothing calls this directly
no test coverage detected