Skip to content

Missing logs when cloudstack-setup-agent is run with sudo #10703

Open
@deajan

Description

@deajan

problem

Trying to setup a AlmaLinux 9.5 KVM host with Cloudstack 4.20.

So far, I followed the instructions in the wiki and created a cloudstack user with sudo permissions.
When running sudo -u cloudstack cloudstack-setup-agent, it did spit some strange error message

Please input the Hypervisor type kvm/lxc:[kvm]
DEBUG:root:execute:route -n|awk '/^0.0.0.0/ {print $2,$8}'
Failed to get default route. Please configure your network to have a default route

When running route -n|awk '/^0.0.0.0/ {print $2,$8}' alone it worked well.
So I started hacking into the python code, and added a raise statement.

This time, I got the following error message

PermissionError: [Errno 13] Permission denied: '/bin/sh'

This allowed me to debug and find out that I had Defaults noexec in my /etc/sudoers file set, even when running sudo I wasn't allowed to run /bin/sh.

The problem here is that running cloudstack-setup-agent with sudo doesn't create any error log in /var/log/cloudstack/agent/setup.log file, even if running sudo -u cloudstack echo "Test" >> /var/log/cloudstack/agent/setup.log works.

As a side note, the bash class should perhaps send those exception errors to stderr too

versions

The versions of ACS, hypervisors, storage, network etc..

The steps to reproduce the bug

...

What to do about it?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions