[FEATURE] Warn when change of home-dir for existing user would fail #67545
Replies: 11 comments
-
I believe the exact functionality you want already exists. Specify "createhome: true" to enable the creation of a new home directory. This setting should allow the home directory to be changed. Without this setting specified, the home directory is immutable. Please try this and let me know if it resolves the issue. |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for the reply!
|
Beta Was this translation helpful? Give feedback.
-
@mirko Just for documentation purposes of this issue, based on your original issue description, where you are wanting to change a user's existing home directory to another new home directory, and you want it to be created, The problem is, as you point out in case (b), there is no way to change a user's home directory to a value without also telling salt to create it. I will investigate the most elegant way to implement the functionality you want. |
Beta Was this translation helpful? Give feedback.
-
@mirko here is what I am thinking. So I am thinking of the possibility of creating a This, to me, seems like a better approach than tweaking We would then have the following states:
Let me know your thoughts. |
Beta Was this translation helpful? Give feedback.
-
@danielfrg I'm so sorry I didn't get back to you and this earlier - thanks for all the effort at this point!
I totally follow and understand the thoughts and concerns here. However I rather to tend to also consider users with non-existent home directories as "valid" and "enabled" users. They come with the biggest linux distributions - even in minimal config - pre-configured. They're valid and enabled users to me and it appears to be valid and common to configure them that way - just without an existing home directory.
..and hence (because of what I wrote above) I personally do not see those user accounts as invalid or disabled. They "just" have a non-existent home dir which neither makes the config invalid nor does it disable the user. I do not feel like a user being "disabled" is the same as a user account with the /valid/ configuration of having a non-existent directory. So while I still understand your hassle with tweaking user.present, to me it feels like being the better approach than labeling such configured users as disabled accounts. It's prone to misunderstandings and will probably lead other issues (user accounts e.g. can be indeed considered disabled, depending on whether you set a |
Beta Was this translation helpful? Give feedback.
-
@mirko |
Beta Was this translation helpful? Give feedback.
-
Hey @mirko, there's definitely something weird happening here. As Sage Yet, you're seeing some screwy behavior so the question is why? We were able to But this should get us the information that we need:
If you can put that right before this line: Line 129 in 5457218 If you don't already know where the file is locally, you should be able to get
That gets the python that is running salt in the form of
So ultimately it's just:
Anyway, if you can put that logging statement in, and re-run your state Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hey, thanks a lot for putting so much effort into this and coming back to me! The good news: I'm still able to reproduce it The issue only occurs, when So, when using Question now is: is it still considered a bug? Even if so, probably with much lower severity, as only triggered in described edge case. Wondering, though, what's exactly (technically) preventing the logged in user from changing his/her home-dir... Do you still need the debug output from above mentioned modifications? Happy to still provide them, though for the moment I'm assuming my findings change the situation a bit. Now you might ask why on earth I'm trying to change salt-ssh's admin user's home-dir to /nonexistent, especially when it's common having the user's ssh-keys lying around in ~/.ssh/authroized_keys: that's exactly what I'm trying to change. The idea is having the public keys moved out of user's home-dirs into For reference: for moving the ssh pub keys out of the user's home-dir to disallow users to edit their authorized_keys, there's another pending ticket: #60045 (comment) as currently the user still has write access to these files which contradicts the idea of preventing users from doing so. |
Beta Was this translation helpful? Give feedback.
-
Hi @mirko
Salt uses
This is what is preventing the logged user to change his home directory. IMHO it should not be considered a bug. |
Beta Was this translation helpful? Give feedback.
-
@piterpunk thanks for weighing in here! That definitely explains it. I don't know if it makes sense for us to do some kind of check within Salt for this -- if someone opened a PR with tests, I feel like that would be a reasonable enhancement, but I don't think that's necessarily Salt(the program)'s responsibility 🤔 |
Beta Was this translation helpful? Give feedback.
-
Ran into this today, whereby the What could be ways forward for this? Create a flag which allows to ignore the home folder is missing? Ignore it when it is a system account? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Within a working sls file for managing users and their home dirs I'm changing the path to a user's homedir to another one.
This fails with:
Setup
Steps to Reproduce the behavior
Managing a user:
Execute sls on host, everything is fine.
Then changing the user's homedir, though, e.g. by changing the whole section from above to (ensuring /tmp/user1 exists and is owned by 'user1'):
fails with:
Expected behavior
Change of home dir successful.
Versions Report
salt --versions-report
Additional context
Even though it's considered expected behaviour, I'd really fancy an override as it was implemented for uid/gid changes (
allow_uid_change=True
).Beta Was this translation helpful? Give feedback.
All reactions