Problem executing post-conf on RHEL 8.8

Questions about WAPT Server / Requests and help related to the WAPT server
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
silica
Messages: 24
Registration: Nov 18, 2024 - 11:02

November 18, 2024 - 2:30 PM

Good morning,

I am following the documentation below: https://www.wapt.fr/fr/doc-2.5/wapt-ser ... er-install

And I'm encountering a problem running the post-installation on RHEL 8.8:

Code: Select all

[user@srvwapt ~]$ sudo /opt/wapt/waptserver/scripts/postconf.sh --cspn-toe
Waptserver
    Version: 2.5.5.15697-20422a0b


Traceback (most recent call last):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 1316, in <module>
    main()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 885, in main
    ensure_postgresql_db(db_name=server_config['db_name'], db_owner=server_config['db_name'], db_password=server_config['db_password'])
  File "/opt/wapt/waptserver/scripts/postconf.py", line 592, in ensure_postgresql_db
    migrate_db_if_needed()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 514, in migrate_db_if_needed
    if get_current_running_postgresql_version() < Version('10'):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 71, in get_current_running_postgresql_version
    version = run("sudo -iu postgres psql -t -c 'SHOW server_version;'").split('(',1)[0].strip()
  File "/opt/wapt/waptutils.py", line 2177, in run
    raise CalledProcessErrorOutput(proc.returncode, cmd, ''.join(output))
waptutils.CalledProcessErrorOutput: Command b"sudo -iu postgres psql -t -c 'SHOW server_version;'" returned non-zero exit status 126.
Output:/etc/profile: line 31: /usr/bin/id: Permission denied
/etc/profile.d/colorgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorxzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied   ┌────────────────────────────┐
/etc/profile.d/lang.sh: line 11: /usr/bin/sed: Permission denied                                      │ SELinux correctly          │
/etc/profile.d/which2.sh: line 4: /bin/readlink: Permission denied                                    │ configured for Nginx       │
/etc/profile.d/which2.sh: line 4: /bin/basename: Permission denied                                    │ reverse proxy              │
/etc/profile: line 31: /usr/bin/id: Permission denied                                                 │                            │
/etc/profile.d/colorgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied    │                            │
/etc/profile.d/colorxzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied  ├────────────────────────────┤
/etc/profile.d/colorzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied   │         <  OK  >           │
/etc/profile.d/lang.sh: line 11: /usr/bin/sed: Permission denied                                      └────────────────────────────┘
/etc/profile.d/which2.sh: line 4: /bin/readlink: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/basename: Permission denied
-bash: /bin/psql: Permission denied
However, when I manually execute the problematic command, I get the following:

Code: Select all

[user@srvwapt ~]$ sudo -iu postgres psql -t -c 'SHOW server_version;'
 10.23
Could you enlighten me?

Thank you in advance
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

November 19, 2024 - 1:45 PM

Hello,

I'm not certain, but I believe this problem sometimes occurs when using `sudo` within another `sudo` command.

Try launching `postconf` directly as root without sudo privileges?
silica
Messages: 24
Registration: Nov 18, 2024 - 11:02

November 19, 2024 - 2:38 PM

Good morning,

Thank you for your reply, I hadn't thought of that.

Unfortunately, I have the same problem when launching the post-configuration directly as root without sudo :( :

Code: Select all

[root@srvwapt /]# /opt/wapt/waptserver/scripts/postconf.sh --cspn-toe
Waptserver
    Version: 2.5.5.15697-20422a0b


Traceback (most recent call last):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 1316, in <module>
    main()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 885, in main
    ensure_postgresql_db(db_name=server_config['db_name'], db_owner=server_config['db_name'], db_password=server_config['db_password'])
  File "/opt/wapt/waptserver/scripts/postconf.py", line 592, in ensure_postgresql_db
    migrate_db_if_needed()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 514, in migrate_db_if_needed
    if get_current_running_postgresql_version() < Version('10'):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 71, in get_current_running_postgresql_version
    version = run("sudo -iu postgres psql -t -c 'SHOW server_version;'").split('(',1)[0].strip()
  File "/opt/wapt/waptutils.py", line 2177, in run
    raise CalledProcessErrorOutput(proc.returncode, cmd, ''.join(output))
waptutils.CalledProcessErrorOutput: Command b"sudo -iu postgres psql -t -c 'SHOW server_version;'" returned non-zero exit status 126.
Output:/etc/profile: line 31: /usr/bin/id: Permission denied
/etc/profile.d/colorgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorxzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/lang.sh: line 11: /usr/bin/sed: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/readlink: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/basename: Permission denied
/etc/profile: line 31: /usr/bin/id: Permission denied
/etc/profile.d/colorgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorxzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/lang.sh: line 11: /usr/bin/sed: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/readlink: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/basename: Permission denied
-bash: /bin/psql: Permission denied
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

November 19, 2024 - 3:05 PM

In your case, it's the command:

Code: Select all

sudo -iu postgres psql -t -c 'SHOW server_version;'
That doesn't work in your case. Can you launch it manually?
silica
Messages: 24
Registration: Nov 18, 2024 - 11:02

November 19, 2024 - 3:19 PM

Effectively.

As stated in my initial post, when I launch it manually (as a user), it returns:

Code: Select all

[user@srvwapt /]$ sudo -iu postgres psql -t -c 'SHOW server_version;'
 10.23
But the post-conference approach doesn't work either.

I just tried it as root (but leaving "sudo" as in the script):

Code: Select all

[root@srvwapt /]# sudo -iu postgres psql -t -c 'SHOW server_version;'
/etc/profile: line 31: /usr/bin/id: Permission denied
/etc/profile.d/colorgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorls.sh: line 26: /usr/bin/tty: Permission denied
/etc/profile.d/colorxzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/lang.sh: line 11: /usr/bin/sed: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/readlink: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/basename: Permission denied
/etc/profile: line 31: /usr/bin/id: Permission denied
/etc/profile.d/colorgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorls.sh: line 26: /usr/bin/tty: Permission denied
/etc/profile.d/colorxzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/colorzgrep.sh: /usr/libexec/grepconf.sh: /bin/sh: bad interpreter: Permission denied
/etc/profile.d/lang.sh: line 11: /usr/bin/sed: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/readlink: Permission denied
/etc/profile.d/which2.sh: line 4: /bin/basename: Permission denied
-bash: /bin/psql: Permission denied


This test leads me to try launching the post-configuration as a user without sudo (since there are sudo commands in the script), and I get a different error:

Code: Select all

[user@srvwapt /]$ /opt/wapt/waptserver/scripts/postconf.sh --cspn-toe
Waptserver
    Version: 2.5.5.15697-20422a0b


Traceback (most recent call last):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 1316, in <module>
    main()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 858, in main
    selinux_rules()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 126, in selinux_rules
    run('setsebool -P httpd_can_network_connect 1')
  File "/opt/wapt/waptutils.py", line 2177, in run
    raise CalledProcessErrorOutput(proc.returncode, cmd, ''.join(output))
waptutils.CalledProcessErrorOutput: Command b'setsebool -P httpd_can_network_connect 1' returned non-zero exit status 255.
Output:Cannot set persistent booleans, please try as root.
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

November 19, 2024 - 3:31 PM

Hi Kevin,

in your first message, it seems you have a very restrictive SELinux configuration. Do you have a public SELinux profile so we can apply it and see how to handle this scenario?

Regarding your last problem, you can add `sudo` before `setsebool`; this is precisely to add some SELinux configuration between the waptserver service and the nginx server.

Regards,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
silica
Messages: 24
Registration: Nov 18, 2024 - 11:02

November 19, 2024 - 4:29 PM

I'm using RHEL 8.8 with a post-installation mandated by my organization's security department. It's possible there are some rather restrictive configurations.

My SELinux skills are limited; is this a result of the command? export week Who are you interested in?

Regarding your last suggestion, I added `sudo` before the two `setsebool` commands in postconf.py

Code: Select all

def selinux_rules():
    """ SELinux httpd security rules """
    run('sudo setsebool -P httpd_can_network_connect 1')
    run('sudo setsebool -P httpd_setrlimit on')
    for sepath in ('wapt', 'wapt-host', 'waptwua','wads'):
        try:
            run('semanage fcontext -a -t httpd_sys_content_t "/var/www/html/%s(/.*)?"' % sepath)
        except:
            pass
        run('restorecon -R -v /var/www/html/%s' % sepath)
But the result is no better :(

Code: Select all

[user@srvwapt /]$ /opt/wapt/waptserver/scripts/postconf.sh --cspn-toe
Waptserver
    Version: 2.5.5.15697-20422a0b


Traceback (most recent call last):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 1316, in <module>
    main()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 885, in main
    ensure_postgresql_db(db_name=server_config['db_name'], db_owner=server_config['db_name'], db_password=server_config['db_password'])
  File "/opt/wapt/waptserver/scripts/postconf.py", line 598, in ensure_postgresql_db
    run('systemctl start %s' % PGSQL_SVC)
  File "/opt/wapt/waptutils.py", line 2177, in run
    raise CalledProcessErrorOutput(proc.returncode, cmd, ''.join(output))
waptutils.CalledProcessErrorOutput: Command b'systemctl start postgresql' returned non-zero exit status 1.
Output:Failed to start postgresql.service: Interactive authentication required.
See system logs and 'systemctl status postgresql.service' for details.
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

November 19, 2024 - 5:46 PM

Hi Kevin,

it seems your user doesn't have the necessary permissions to restart the systemd service. You can also add `sudo` before it.

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
silica
Messages: 24
Registration: Nov 18, 2024 - 11:02

November 20, 2024 - 12:29

Good morning,

I added a sudo in front of all systemctl commands.

We're making progress, but I'm now stuck at this step... my user doesn't have write access to the PostgreSQL configuration file:

Code: Select all

[user@srvwapt ~]$ /opt/wapt/waptserver/scripts/postconf.sh --cspn-toe
[*] postgresql - we suppose that the db does not exist either (or the installation has been screwed up)
[*] postgresql - creating db wapt
[ ] postgresql jsquery extension is not available. This is not mandatory. Check if a package like postgresql-11-jsquery is available for your distribution
Upgrading DB structure.
[*] postgresql changing max_connections parameter in postgres config file /var/lib/pgsql/data/postgresql.conf
Waptserver
    Version: 2.5.5.15697-20422a0b


Traceback (most recent call last):
  File "/opt/wapt/waptserver/scripts/postconf.py", line 1316, in <module>
    main()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 889, in main
    configure_max_connections()
  File "/opt/wapt/waptserver/scripts/postconf.py", line 716, in configure_max_connections
    with open(config_file_path, "r+") as config_file:
PermissionError: [Errno 13] Permission denied: '/var/lib/pgsql/data/postgresql.conf'
silica
Messages: 24
Registration: Nov 18, 2024 - 11:02

November 27, 2024 - 12:24

Hello,

do you have any ideas on how to resolve this situation?

Should I contact Wapt Support?

Regards
Answer