sendmail_path in LXC, and better op_del #85

Merged
whirigoyen merged 10 commits from unstable into master 2023-11-30 15:53:09 +01:00
Owner
  • Fix missing ITK admin link for multi PHP
  • Prevent op_del to fail and able to remove web account when part of it is already removed
  • Add sendmail_path and open_basedir in LXC PHP pool configs

Tested on test-www01

* Fix missing ITK admin link for multi PHP * Prevent op_del to fail and able to remove web account when part of it is already removed * Add sendmail_path and open_basedir in LXC PHP pool configs Tested on test-www01
whirigoyen added 4 commits 2023-11-09 17:13:39 +01:00
whirigoyen changed title from unstable to ITK 4 all, sendmail_path in LXC, and better op_del 2023-11-09 17:16:40 +01:00
whirigoyen added 1 commit 2023-11-09 17:21:40 +01:00
Owner

Fix missing ITK admin link for multi PHP

This was intentional.

Curently, this (via web-add.sh enable-user-itk & disable-user-itk) will only toggle the AssignUserID value in the Apache vhost file of the account (adding or removing the www- prefix

While in mono-PHP setup this is enough, in multi-PHP setup it's only missleading because the user of execution of the PHP code will the be the one defined in the PHP-FPM pool config. Toggling it in that case will only create confusion.

So 2fd65724f7 (+ c385c102c5 ) should be reverted as long as web-add.sh does not do the change to FPM Pool config

> Fix missing ITK admin link for multi PHP This was intentional. Curently, this (via web-add.sh enable-user-itk & disable-user-itk) will only toggle the `AssignUserID` value in the Apache vhost file of the account (adding or removing the `www-` prefix While in mono-PHP setup this is enough, in multi-PHP setup it's only missleading because the user of execution of the PHP code will the be the one defined in the PHP-FPM pool config. Toggling it in that case will only create confusion. So 2fd65724f7f316c79b9d376af5ebcb06956963e9 (+ c385c102c5fc7de0fe0799b4744803e929ac13fe ) should be reverted as long as web-add.sh does not do the change to FPM Pool config
Owner

Prevent op_del to fail and able to remove web account when part of it is already removed
Add sendmail_path and open_basedir in LXC PHP pool configs

Sounds good, looking forward to test this :)

>Prevent op_del to fail and able to remove web account when part of it is already removed > Add sendmail_path and open_basedir in LXC PHP pool configs Sounds good, looking forward to test this :)
mtrossevin requested changes 2023-11-10 10:03:31 +01:00
@ -109,4 +109,2 @@
if(is_multiphp()) {
printf('<a href="/webadmin/%s/php/">PHP</a> - ', $vhost_info['owner']);
} else {
printf('<a href="/webadmin/%s/itk/">ITK</a> - ', $vhost_info['owner']);
Owner

From @lpoujol :

Fix missing ITK admin link for multi PHP

This was intentional.

Curently, this (via web-add.sh enable-user-itk & disable-user-itk) will only toggle the AssignUserID value in the Apache vhost file of the account (adding or removing the www- prefix

While in mono-PHP setup this is enough, in multi-PHP setup it's only missleading because the user of execution of the PHP code will the be the one defined in the PHP-FPM pool config. Toggling it in that case will only create confusion.

So 2fd65724f7 (+ c385c102c5 ) should be reverted as long as web-add.sh does not do the change to FPM Pool config

From @lpoujol : > > Fix missing ITK admin link for multi PHP > > This was intentional. > > Curently, this (via web-add.sh enable-user-itk & disable-user-itk) will only toggle the `AssignUserID` value in the Apache vhost file of the account (adding or removing the `www-` prefix > > While in mono-PHP setup this is enough, in multi-PHP setup it's only missleading because the user of execution of the PHP code will the be the one defined in the PHP-FPM pool config. Toggling it in that case will only create confusion. > > So 2fd65724f7f316c79b9d376af5ebcb06956963e9 (+ c385c102c5fc7de0fe0799b4744803e929ac13fe ) should be reverted as long as web-add.sh does not do the change to FPM Pool config
mtrossevin marked this conversation as resolved
mtrossevin requested changes 2023-11-10 10:19:16 +01:00
mtrossevin left a comment
Owner

While I do agree with @lpoujol that it would be better not to fail if the web-account was already (partially) removed, the implementation doesn't seems to be correct.

While I do agree with @lpoujol that it would be better not to fail if the web-account was already (partially) removed, the implementation doesn't seems to be correct.
@ -807,3 +810,3 @@
if [ "$WEB_SERVER" == "apache" ]; then
if id www-"$login" &> /dev/null; then
userdel -f www-"$login"
userdel -f www-"$login" || true
Owner

Considering the if id www-"$login" means that www-"$login" do exist for the system root, failure on this userdel seems to be a real problem (it is already bypassed if the user doesn't exists).

Considering the `if id www-"$login"` means that `www-"$login"` do exist for the system root, failure on this userdel seems to be a real problem (it is already bypassed if the user doesn't exists).
mtrossevin marked this conversation as resolved
@ -812,3 +815,3 @@
for php_version in "${PHP_VERSIONS[@]}"; do
if lxc-attach -n php"${php_version}" -- id www-"$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
lxc-attach -n php"${php_version}" -- userdel -f www-"$login" || true
Owner

Wouldn't it be better to check for the user existence in the container instead of silencing all errors ?

I would do something like this :

lxc-attach -n php"${php_version}" -- sh -c "getent passwd 'www-$login' && userdel -f 'www-$login'"

or

lxc-attach -n php"${php_version}" -- getent passwd www-"$login" && lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
Wouldn't it be better to check for the user existence in the container instead of silencing all errors ? I would do something like this : ```sh lxc-attach -n php"${php_version}" -- sh -c "getent passwd 'www-$login' && userdel -f 'www-$login'" ``` or ```sh lxc-attach -n php"${php_version}" -- getent passwd www-"$login" && lxc-attach -n php"${php_version}" -- userdel -f www-"$login" ```
mtrossevin marked this conversation as resolved
@ -815,2 +817,3 @@
lxc-attach -n php"${php_version}" -- userdel -f www-"$login" || true
fi
lxc-attach -n php"${php_version}" -- userdel -f "$login"
lxc-attach -n php"${php_version}" -- userdel -f "$login" || true
Owner

Wouldn't it be better to check for the user existence in the container instead of silencing all errors ?

I would do something like this :

lxc-attach -n php"${php_version}" -- sh -c "getent passwd '$login' && userdel -f '$login'"

or

lxc-attach -n php"${php_version}" -- getent passwd "$login" && lxc-attach -n php"${php_version}" -- userdel -f "$login"
Wouldn't it be better to check for the user existence in the container instead of silencing all errors ? I would do something like this : ```sh lxc-attach -n php"${php_version}" -- sh -c "getent passwd '$login' && userdel -f '$login'" ``` or ```sh lxc-attach -n php"${php_version}" -- getent passwd "$login" && lxc-attach -n php"${php_version}" -- userdel -f "$login" ```
mtrossevin marked this conversation as resolved
@ -818,3 +821,3 @@
fi
userdel -f "$login"
userdel -f "$login" || true
Owner

Wouldn't it be better to check for the user existence in the container instead of silencing all errors ?

I would do something like this :

getent passwd "$login" && userdel -f "$login"

(or use an if block)

Wouldn't it be better to check for the user existence in the container instead of silencing all errors ? I would do something like this : ```sh getent passwd "$login" && userdel -f "$login" ``` (or use an if block)
mtrossevin marked this conversation as resolved
mtrossevin approved these changes 2023-11-10 10:24:09 +01:00
mtrossevin left a comment
Owner

On sendmail_path and open_basedir, it looks good.

On `sendmail_path` and `open_basedir`, it looks good.
CHANGELOG.md Outdated
@ -17,2 +21,4 @@
### Fixed
* Fix sendmail_path hostname (missing domain / FQDN)
Owner

Since sendmail_path wasn't defined before this PR, should we really have this in the changelog ?

Since `sendmail_path` wasn't defined before this PR, should we really have this in the changelog ?
Owner

@mtrossevin : For sendmail_path, it is already defined in the vhost template for php mod, but was missing for FPM in the containers.

Perhaps, but the change seems to only affect what was added in this PR. At least according to the diffs.

> @mtrossevin : For `sendmail_path`, it is already defined in the vhost template for php mod, but was missing for FPM in the containers. Perhaps, but the change seems to only affect what was added in this PR. At least according to the diffs.
Author
Owner

Your right, it was a commit that fixed my previous commit, but this should'nt be in the changlog.

Your right, it was a commit that fixed my previous commit, but this should'nt be in the changlog.
mtrossevin marked this conversation as resolved
@ -457,2 +458,4 @@
php_admin_value[error_log] = /home/${in_login}/log/php.log
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f www-${in_login}@${HOST}"
php_admin_value[open_basedir] = "/usr/share/php:/home/${in_login}:/tmp"
Owner

Seems good.

Seems good.
mtrossevin marked this conversation as resolved
mtrossevin requested changes 2023-11-10 10:25:06 +01:00
mtrossevin left a comment
Owner

Oops, should have just left a comment, see above

Oops, should have just left a comment, see above
Author
Owner

@lpoujol @mtrossevin : Thanks for your remarks.

  • I'll implement ITK for multiPHP in another PR (shouldn't be too complicated, with sed in the containers). I revert the present change.

  • @mtrossevin : For getent passwd <LOGIN>, I'd rather use getent passwd <LOGIN> > /dev/null, don't you think ?

  • @mtrossevin : For sendmail_path, it is already defined in the vhost template for php mod, but was missing for FPM in the containers.

@lpoujol @mtrossevin : Thanks for your remarks. * I'll implement ITK for multiPHP in another PR (shouldn't be too complicated, with sed in the containers). I revert the present change. * @mtrossevin : For `getent passwd <LOGIN>`, I'd rather use `getent passwd <LOGIN> > /dev/null`, don't you think ? * @mtrossevin : For `sendmail_path`, it is already defined in the vhost template for php mod, but was missing for FPM in the containers.
whirigoyen added 2 commits 2023-11-10 10:54:45 +01:00
whirigoyen added 1 commit 2023-11-10 11:12:00 +01:00
Author
Owner

Done !
(and account removal tested on test-www01)

Done ! (and account removal tested on test-www01)
mtrossevin approved these changes 2023-11-10 12:02:02 +01:00
mtrossevin left a comment
Owner

All good for me.

All good for me.
whirigoyen added 1 commit 2023-11-13 14:30:04 +01:00
Author
Owner
@mtrossevin ^
mtrossevin approved these changes 2023-11-13 15:05:16 +01:00
mtrossevin left a comment
Owner

lgtm

lgtm
whirigoyen requested review from mtrossevin 2023-11-13 15:08:12 +01:00
mtrossevin approved these changes 2023-11-13 15:25:33 +01:00
mtrossevin changed title from ITK 4 all, sendmail_path in LXC, and better op_del to sendmail_path in LXC, and better op_del 2023-11-13 16:09:19 +01:00
mtrossevin added 1 commit 2023-11-16 11:04:33 +01:00
whirigoyen merged commit 93c9e450ff into master 2023-11-30 15:53:09 +01:00
Sign in to join this conversation.
No description provided.