From 6d0e275146064dcf0a773e20ea7118a03693b01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20A=CC=81lvaro?= Date: Fri, 22 Jul 2022 08:40:48 +0200 Subject: [PATCH] feat: Remove USERMAP_UID and USERMAP_GID env variables support --- CHANGELOG.md | 1 + README.md | 6 ++--- assets/runtime/env-defaults.sh | 3 +++ assets/runtime/functions.sh | 41 ---------------------------------- 4 files changed, 6 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b219ab9..77a7c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ for the list of changes in SaltStack. - Change Docker base image to `ubuntu:jammy-20220531` - Use `python3` default distro version - Install `python3-pygit2` version `1.6.1` from Ubuntu repositories +- Remove `USERMAP_UID` and `USERMAP_GID` env variables in favor of `PUID` and `PGID`, respectively. - CI(tests): Use `python3` version `3.10` **3004.2** diff --git a/README.md b/README.md index 04df47d..ca08449 100644 --- a/README.md +++ b/README.md @@ -510,6 +510,8 @@ Below you can find a list with the available options that can be used to customi | :------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `DEBUG` | Set this to `True` to enable entrypoint debugging. | | `TIMEZONE` / `TZ` | Set the container timezone. Defaults to `UTC`. Values are expected to be in Canonical format. Example: `Europe/Madrid`. See the list of [acceptable values](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | +| `PUID` | Sets the uid for user `salt` to the specified uid. Default: `1000`. | +| `PGID` | Sets the gid for user `salt` to the specified gid. Default: `1000`. | | `SALT_RESTART_MASTER_ON_CONFIG_CHANGE` | Set this to `True` to restart `salt-master` service when configuration files change. Default: `False` | | [`SALT_LOG_LEVEL`](https://docs.saltproject.io/en/latest/ref/configuration/master.html#log-level) | The level of messages to send to the console. One of 'garbage', 'trace', 'debug', info', 'warning', 'error', 'critical'. Default: `warning` | | `SALT_LOG_ROTATE_FREQUENCY` | Logrotate frequency for salt logs. Available options are 'daily', 'weekly', 'monthly', and 'yearly'. Default: `weekly` | @@ -528,10 +530,6 @@ Below you can find a list with the available options that can be used to customi | `SALT_GITFS_SSH_PUBLIC_KEY` | The name of the ssh public key for gitfs. Default: `gitfs_ssh`.pub` | | [`SALT_REACTOR_WORKER_THREADS`](https://docs.saltproject.io/en/latest/ref/configuration/master.html#reactor-worker-threads) | The number of workers for the runner/wheel in the reactor. Default: `10`. | | [`SALT_WORKER_THREADS`](https://docs.saltproject.io/en/latest/ref/configuration/master.html#worker-threads) | The number of threads to start for receiving commands and replies from minions. Default: `5`. | -| `PUID` | Sets the uid for user `salt` to the specified uid. Default: `1000`. | -| `PGID` | Sets the gid for user `salt` to the specified gid. Default: `1000`. | -| `USERMAP_UID` (**deprecated**) | Same as `PUID`. Support will be removed in Salt 3005 release in favor of `PUID`. | -| `USERMAP_GID` (**deprecated**) | Same as `PGID`. Support will be removed in Salt 3005 release in favor of `PGID`. | Any parameter not listed in the above table and available in the following [link](https://docs.saltproject.io/en/latest/ref/configuration/examples.html#configuration-examples-master), can be set by creating the directory `config` and adding into it a `.conf` file with the desired parameters: diff --git a/assets/runtime/env-defaults.sh b/assets/runtime/env-defaults.sh index c24c3a5..d39303a 100755 --- a/assets/runtime/env-defaults.sh +++ b/assets/runtime/env-defaults.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +PUID=${PUID:-1000} +PGID=${PGID:-1000} + DEBUG=${DEBUG:-False} TIMEZONE=${TIMEZONE:-${TZ:-UTC}} diff --git a/assets/runtime/functions.sh b/assets/runtime/functions.sh index 55c9547..55015ab 100755 --- a/assets/runtime/functions.sh +++ b/assets/runtime/functions.sh @@ -57,53 +57,12 @@ function log_error() (>&2 echo "[ERROR] - $*") } -#--- FUNCTION ------------------------------------------------------------------------------------------------------- -# NAME: __check_puid_pgid_env -# DESCRIPTION: Check if the PUID and PGID environment variables are set correctly. -#---------------------------------------------------------------------------------------------------------------------- -function __check_puid_pgid_env -{ - if [[ "${SALT_VERSION}" -ge "3005" ]]; then - log_error "The USERMAP_UID and USERMAP_GID environment variables are not supported in Salt >= 3005" - exit 1 - fi - - if [[ -n "${USERMAP_UID}" ]]; then - log_warn "The USERMAP_UID environment variable is deprecated. Please use PUID instead." - log_warn "Support for USERMAP_UID will be removed in Salt 3005 release." - if [[ -z "${PUID}" ]]; then - log_warn "Setting PUID to USERMAP_UID (${USERMAP_UID})" - export PUID="${USERMAP_UID}" - else - log_error "The PUID and USERMAP_UID environment variables are set. PUID will be used." - fi - unset USERMAP_UID - fi - - if [[ -n "${USERMAP_GID}" ]]; then - log_warn "The USERMAP_GID environment variable is deprecated. Please use PGID instead." - log_warn "Support for USERMAP_GID will be removed in Salt 3005 release." - if [[ -z "${PGID}" ]]; then - log_info "Setting PGID to USERMAP_GID (${USERMAP_GID})" - export PGID="${USERMAP_GID}" - else - log_error "The PGID and USERMAP_GID environment variables are set. PGID will be used." - fi - unset USERMAP_GID - fi -} - #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: map_uidgid # DESCRIPTION: Map salt user with host user. #---------------------------------------------------------------------------------------------------------------------- function map_uidgid() { - __check_puid_pgid_env - # Move this into env-defaults.sh - [ -z "${PUID}" ] && export PUID=1000 - [ -z "${PGID}" ] && export PGID=1000 - ORIG_PUID=$(id -u "${SALT_USER}") ORIG_PGID=$(id -g "${SALT_USER}") PGID=${PGID:-${PUID:-$ORIG_PGID}}