Changing UID/GID breaks file creation - What to do about UGID?

I have an old server that had Virtualmin running ONLY as a Webmin module with a completely different LAMP stack and repository. I am building a new server using Virtualmin from the ground up (clean install of OS and running instal.sh).

However, the old config is too broken to use the Virtualmin migration tools (a previous admin extensively edited httpd.conf by hand and Virtualmin is very confused). As a result, I am rsyncing files manually from one server to another. From previous experience I've learned that rsync doesn't map usernames reliably (at least I don't know how to make it reliable), so I went ahead and changed the UID and GID of the new server to match the old server using usermod, groupmod, chgrp, and chown before running rsync.

Virtualmin is now unable to create files in the home directory, which is causing lots of issues (like being unable to upload an SSL certificate). All other services are happy with the changed UID/GID, but not Virtualmin.

Doing a lot of digging, I've discovered that Virtualmin appears to cache UID and GID in /etc/webmin/virtual-server/domains/ and that these values do not match the new UID/GID of the domain user. I've changed the UID and GID lines in the file, and things appear to be working correctly.

However, I don't know what to do for the UGID value. On my old server UID and GID do not match, so I don't have a UGID. Unfortunately, the old server is still live, so changing that side to match is not really an option. And since rsync needs them to match between the machines, they can't match on the new server either.

How does Virtualmin use UGID? Can I leave this value blank in the domain file? or will this break something? Should I set it to the new UID or GID?

Lastly, is there a "Virtualmin-way" to change the UID/GID for a virtual server? I couldn't find one, which is why I did it by hand from the command line.

Thanks, Josh

Status: 
Active

Comments

I'm not sure if this idea is too trivial, and there are probably good reasons why it doesn't work, but still here it is. :)

What about creating the domains freshly on the new server, individually rsync the public_html contents over, ignoring the temporarily incorrect U/GIDs, and then do a chown -R newuser:newgroup * in the public_html.

If it's not too many domains, you'd have a clean slate with proper new user and group IDs.

The ugid should be the same as gid in 99.9% of cases - the only time it differs is if you want the domain owner's primary group to be different from the group used for mailboxes in the domain.

Editing those files is the recommended solution - there isn't any more user-friendly or API-supported way to make a UID or GID change. But editing the files will work fine..

Thanks for the response Jamie. It's good to understand how this works.

I was concerned that I would break something important, which is why I was changing the UID/GID in the first place.

I actually read Locutus response before you replied and tried reverting back to his method without changing the UID/GID, but I'm glad I can change it if this I run into an issue.

Sometimes you see a problem and think, "I know how to fix that" without considering why you're doing it. That's pretty much what I was doing with the UID/GID change. I didn't think about other things it might affect.

Anyway, thanks again for your help. I'm making progress on getting this running.

Josh