packweb-apache: Use $SUDO_USER when possible in phpContainer
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
And rollback to $LOGNAME when it isn't. This remove the need to add $LOGNAME to env_keep in the sudoers file. The $SUDO_USER variable is automatically set by sudo when it is used to the user who used it so it fullfill the same role as $LOGNAME do in phpContainer.
This commit is contained in:
parent
039c740ef3
commit
738f2682b0
|
@ -24,13 +24,14 @@ The **patch** part changes is incremented if multiple releases happen the same m
|
|||
* mongodb: Deny the install on Debian 11 « Bullseye » when the version is unsupported
|
||||
* mongodb: Support version 5.0 (for buster)
|
||||
* mongodb: Allow to specify a mongodb version for buster & bullseye
|
||||
* packweb-apache: phpContainer now use $SUDO\_USER when available (so when run through sudo or as an unprivileged user) and $LOGNAME when not.
|
||||
|
||||
### Fixed
|
||||
|
||||
* evolinux-base: fix alert5.service dependency syntax
|
||||
* mysql : Create a default ~root/.my.cnf for compatibility reasons
|
||||
* nginx : fix variable name and debug to actually use nginx-light
|
||||
* packweb-apache : Support php 8.0
|
||||
* packweb-apache : Support php 8.0
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
|
||||
Defaults env_keep += "LOGNAME PWD"
|
||||
Defaults env_keep += "PWD"
|
||||
ALL ALL = NOPASSWD: /usr/local/bin/phpContainer
|
||||
|
|
|
@ -6,10 +6,10 @@ if [ "$EUID" -ne 0 ]; then
|
|||
exit 0;
|
||||
fi;
|
||||
|
||||
PHPVersion=$(grep SetHandler /etc/apache2/sites-enabled/$LOGNAME.conf 2>/dev/null | grep -m 1 -o 'fpm[0-9][0-9]' | head -n 1 | sed 's/php//g' | sed 's/fpm//g')
|
||||
PHPVersion=$(grep SetHandler /etc/apache2/sites-enabled/${SUDO_USER:-${LOGNAME}}.conf 2>/dev/null | grep -m 1 -o 'fpm[0-9][0-9]' | head -n 1 | sed 's/php//g' | sed 's/fpm//g')
|
||||
|
||||
if [ "$PHPVersion" != "" ]; then
|
||||
lxc-attach -n php$PHPVersion -- su - $LOGNAME -c "cd \"${PWD@E}\" && php ${*@Q}"
|
||||
lxc-attach -n php$PHPVersion -- su - ${SUDO_USER:-${LOGNAME}} -c "cd \"${PWD@E}\" && php ${*@Q}"
|
||||
else
|
||||
# TODO: fallback?
|
||||
# command php $*
|
||||
|
|
Loading…
Reference in a new issue