Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemVM template upgrade fails on security hardened management servers #10029

Open
rajujith opened this issue Dec 3, 2024 · 4 comments · May be fixed by #10263
Open

SystemVM template upgrade fails on security hardened management servers #10029

rajujith opened this issue Dec 3, 2024 · 4 comments · May be fixed by #10263

Comments

@rajujith
Copy link
Collaborator

rajujith commented Dec 3, 2024

ISSUE TYPE
  • Improvement Request
COMPONENT NAME
Upgrade, systemVM template
CLOUDSTACK VERSION
4.19.1.3
CONFIGURATION

Upgrade from 4.18.2.3 to 4.19.1.3

OS / ENVIRONMENT

EL

SUMMARY

On management servers with security hardening implemented for example umask set to 0027 the systemVM template upgrade fails. Script 'setup-sysvm-tmplt' creates directory with 'sudo' but attempts to find the template without sudo. This fails in the secured operating systems.

[cloud@mgmt1 ~]$ umask 0027
[cloud@mgmt1 ~]$ sudo mkdir -p /tmp/tmp10896605671384965986/template/tmpl/1/8
[cloud@mgmt1 ~]$ find /tmp/tmp10896605671384965986/template/tmpl/1/8 -name '*.ova'
find: ‘/tmp/tmp10896605671384965986/template/tmpl/1/8’: Permission denied

STEPS TO REPRODUCE
1. Set umask to 0027 
2. Upgrade cloudstack from 4.18.2.3 to 4.19.1.3
EXPECTED RESULTS
SystemVM templates are upgraded.
ACTUAL RESULTS
SystemVM templates are not upgraded.
@DaanHoogland
Copy link
Contributor

@rajujith @Pearl1594 , should this be documented as an upgrade requirement (set the umask to 0022 at most), or can we search with sudo as well?

@Pearl1594
Copy link
Contributor

I think it would be nice if we could try and see how we can adapt the template registration script to run on a hardened system. And if that is not straightforward, we can document a workaround that the template needs to be pre-registered before upgrade to prevent the script from running.

@sureshanaparti sureshanaparti moved this from Todo to Dev In Progress in Apache CloudStack BugFest - Issues Jan 23, 2025
@sureshanaparti sureshanaparti linked a pull request Jan 24, 2025 that will close this issue
14 tasks
@sureshanaparti
Copy link
Contributor

During system vm template registration, currently mount and unmount store is done with sudo.

private static final String UMOUNT_COMMAND = "sudo umount %s";

Without sudo, mount fails with error error: [mount: only root can use "--types" option] (to fix this, appropriate permissions to be set for the cloud user). so, in security hardened system (where umask set to 0027), when a dir created with sudo in setup-sysvm-tmplt script, other cmds (find, ls , df -P, qemu-img) on it without sudo fails.

[cloud@mgmt1 ~]$ umask
0027
[cloud@mgmt1 ~]$ sudo mkdir -p /tmp/test/template/tmpl/1/8
[cloud@mgmt1 ~]$ ls -lrt /tmp/test/template/tmpl/1/8
ls: cannot access '/tmp/test/template/tmpl/1/8': Permission denied
[cloud@mgmt1 ~]$ find /tmp/test/template/tmpl/1/8/ -name '*.ova'
find: '/tmp/test/template/tmpl/1/8/': Permission denied
[cloud@mgmt1 ~]$ df -P /tmp/test/template/tmpl/1/8/
df: /tmp/test/template/tmpl/1/8/: Permission denied
[cloud@mgmt1 ~]$ sudo touch /tmp/test/template/tmpl/1/8/test-template.ova
[cloud@mgmt1 ~]$ qemu-img info /tmp/test/template/tmpl/1/8/test-template.ova
qemu-img: Could not open '/tmp/test/template/tmpl/1/8/test-template.ova': Could not open '/tmp/test/template/tmpl/1/8/test-template.ova': Permission denied

Either these cmds have to be run with sudo in the script, or add the cloudstack service user ('cloud') to sudoers list. What is best fix here, any other idea/thoughts @rajujith @andrijapanicsb @NuxRo @DaanHoogland @rohityadavcloud & others.

@weizhouapache
Copy link
Member

Either these cmds have to be run with sudo in the script, or add the cloudstack service user ('cloud') to sudoers list.

IMHO both are needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Dev In Progress
Development

Successfully merging a pull request may close this issue.

5 participants