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

pam_mkhomedir: add copymode option to keep the mode of each subfiles/subfolders from skeleton #512

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

keentux
Copy link
Contributor

@keentux keentux commented Nov 25, 2022

With the command mkhomedir_helper $new_user $u_mask $skeleton_path, the new user home directory is created from the skeleton, but without same permissions on sub directories.

Fix #497

Signed-off-by: Valentin Lefebvre valentin.lefebvre@suse.com

@ldv-alt
Copy link
Member

ldv-alt commented Nov 30, 2022

Why do you suggest copying directory permissions from the skeleton directory?
How would this interact with umask option?

@keentux
Copy link
Contributor Author

keentux commented Dec 5, 2022

I made a mistake by wanting to copy sub-directories permissions from the default skeleton, directory.
I was trying to fix the issue #497. As explained in this one, we could have a use case where we could want to copy an existing home directory for a new user. And so, we could think to keep same permissions.

May I suggest checking if skeleton_path has been changed by arguments and so, keep same permissions of sub-directories ? Keeping the umask option effective to let the possibility to adapt default permissions.

Do you agree with that @ldv-alt ? In that case I will change my PR 👍

@ldv-alt
Copy link
Member

ldv-alt commented Dec 11, 2022

I don't feel comfortable with changing a traditional behaviour like this. What do you think about adding a new option? Anyway, please make sure this new mode interacts with umask option in a sensible way. I suppose this interaction would have to be described in the documentation, too.

@keentux
Copy link
Contributor Author

keentux commented Dec 15, 2022

Tanks for your comment ! I fully agree to add a new option.
I was thinking of adding a sixth option called "dir_mode", dealing with the value "copymode" (a not mandatory one). For umask, I will keep the same previous behavior: compute with all sub-directories.

I am going to update this request and add this new option following by this man documentation.

@keentux keentux force-pushed the mkhomedir-helper-permissions branch 2 times, most recently from d2bc420 to c2e78c2 Compare December 16, 2022 09:29
modules/pam_mkhomedir/mkhomedir_helper.8.xml Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.8.xml Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.8.xml Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
@keentux
Copy link
Contributor Author

keentux commented Dec 19, 2022

Thank you for the review, and sorry for these mistakes, I was not able to see straight. I update the documentation and change the correct chmod().

@ldv-alt
Copy link
Member

ldv-alt commented Dec 28, 2022

Sorry, I don't understand your latest changes. Why do you want to change umask every time create_homedir is called?

Also, why do you change just the helper? Don't you think pam_mkhomedir needs an option, too?

@keentux
Copy link
Contributor Author

keentux commented Jan 3, 2023

I was basing to what it was done for files. Especially here: https://github.com/linux-pam/linux-pam/blob/master/modules/pam_mkhomedir/mkhomedir_helper.c#L266. Where it keeps the same access permissions to the new file from the original one in the skeleton.
As create_homedir is called recursively for each sub-folders, I thought it would be a good idea to update the chmod() call in this function. And keep the same access permission from the skeleton tree if copymode is selected for the current folder (home directory's access permission will be changed after the call of the function into create_homedir_helper).

Initially, I wanted to fix the linked issue. However, your are right, I should also expend this update to the pam_mkhomedir. If you agree with my latest changes, I will do the job to update mkhome_dir module.

Comment on lines 55 to 60
<replaceable>dir_mode</replaceable> defines the mode option for all
home directory's subfolders. Put "<emphasis>copymode</emphasis>" to keep
the same access permission as <replaceable>path-to-skel</replaceable>'s
subfolders, otherwise it will keep the default value 0777. All directories
access permissions are computed from the value of
<replaceable>umask</replaceable>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, this description looks confusing to me. It's not clear whether this parameter can be set yo anything besides copymode, and how it interacts with umask.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I try to simplify this one with the last modifications

modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
@keentux keentux force-pushed the mkhomedir-helper-permissions branch from 17fb201 to 40f328f Compare January 15, 2024 16:27
@keentux keentux changed the title pam_mkhomedir helper: fix not copying permissions of skeleton pam_mkhomedir: add copymode option to keep the mode of each subfiles/subfolders from skeleton Jan 15, 2024
@keentux keentux force-pushed the mkhomedir-helper-permissions branch 3 times, most recently from bcb2216 to 3092c3b Compare January 16, 2024 11:23
@keentux keentux requested a review from ldv-alt January 16, 2024 11:23
@keentux keentux force-pushed the mkhomedir-helper-permissions branch from 3092c3b to 49fae9f Compare January 18, 2024 09:39
Copy link
Contributor

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor style notes.

modules/pam_mkhomedir/pam_mkhomedir.c Outdated Show resolved Hide resolved
modules/pam_mkhomedir/mkhomedir_helper.c Outdated Show resolved Hide resolved
@keentux keentux force-pushed the mkhomedir-helper-permissions branch from 49fae9f to 35380d8 Compare January 30, 2024 17:08
* Option to keep same mode from all skeleton's subfiles to home's dir subfiles.
* Add an usage example to the man of this helper.

Signed-off-by: Valentin Lefebvre <valentin.lefebvre@suse.com>
* Use copymode option from the mkhomedir helper.

Signed-off-by: Valentin Lefebvre <valentin.lefebvre@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pam_mkhomedir not copying permissions of skeleton content - is ist a bug or a feature
3 participants