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

omd restore fails: home directory not owned by sitename #208

Open
rubaducks opened this issue Nov 6, 2024 · 8 comments
Open

omd restore fails: home directory not owned by sitename #208

rubaducks opened this issue Nov 6, 2024 · 8 comments

Comments

@rubaducks
Copy link

rubaducks commented Nov 6, 2024

Hello,

When executing the omd restore command, I get the following error:
"ERROR: home directory (/omd/sites/test) is not owned by user test and group test"
After the error, the command stops running.

Full command:
omd restore --kill --reuse test /tmp/site_test.tgz

ll /omd/sites/ shows that the dir of my site is owned by user "test" and group "omd".

When manually setting the group of the site home dir to the sitename/user with command:
chgrp test /omd/sites/test
And then executing the omd restore command again
I first get the following Python error, but the restore works for the most part:
Traceback (most recent call last):
File "/usr/bin/omd", line 5368, in
cmd_spec.fn(main_args, args)
File "/usr/bin/omd", line 4360, in main_restore
if not site_is_stopped(g_sitename):
File "/usr/bin/omd", line 575, in site_is_stopped
return call_as_forked_site_user(site_is_stopped, [sitename], {}) == 1
File "/usr/bin/omd", line 5186, in call_as_forked_site_user
set_environment()
File "/usr/bin/omd", line 2712, in set_environment
create_config_environment()
File "/usr/bin/omd", line 2192, in create_config_environment
for varname, value in list(g_site_conf.items()):
AttributeError: 'NoneType' object has no attribute 'items'

@lausser
Copy link
Contributor

lausser commented Nov 6, 2024 via email

@rubaducks
Copy link
Author

rubaducks commented Nov 6, 2024

@lausser Yes that mitigates the Python error I am getting, but that is not the root cause of the problem. In previous OMD versions, the site dir (/omd/sites/) was owned by siteuser:siteuser. Now, the site dir is owned by siteuser:omd.
At line 504:
if not file_owner_verify(site_dir(name), user.pw_uid, user.pw_gid):
This check will fail because user.pw_gid returns "test" (or the "sitename") instead of "omd".
I think the line should be something like:
if not file_owner_verify(site_dir(name), user.pw_uid, "omd"):
or
if not file_owner_verify(site_dir(name), user.pw_uid, group_id("omd")):

@sni
Copy link
Contributor

sni commented Nov 6, 2024

that's not the case, the site folder has always been owned by the sitename and the sites group. All site users have the "omd" group, but the site folders group is not "omd".

@rubaducks
Copy link
Author

rubaducks commented Nov 6, 2024

These are my two sites:
image
My version is 5.41.20240923-labs-edition

@sni
Copy link
Contributor

sni commented Nov 6, 2024

that's not how they were created initially:

https://github.com/ConSol-Monitoring/omd/blob/labs/packages/omd/omd#L3245-L3247

Initially they have 0755 permissions with owner siteuser and group sitegroup.

@ketra
Copy link

ketra commented Nov 6, 2024

this is the status after creation, the site test is created in an earlier version
image

@rubaducks
Copy link
Author

@sni
Copy link
Contributor

sni commented Nov 6, 2024

thanks for pointing that out, seems like we changed that earlier this year. I totally forgot. Seems like we forgot to adopt the restart/reuse part handling the new permissions/owners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants