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

Fixes #14916: Use umask defined in /etc/login.defs in Technique "SSH authorized keys" for creating missing home dir #1445

Conversation

ncharles
Copy link
Member

# read the /etc/login.defs to get umask for home creation if home dir is not there
"nb_line_read" int => readstringarray("login_defs_content", "/etc/login.defs","#[^\n]*", "\s+", "99999", "9999999");
# Use the umask to get the value
"homedir_mode_real" string => eval("777-${login_defs_content[UMASK][1]}}", "math", "infix");
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo }} instead of }

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch

"homedir_mode_real" string => eval("777-${login_defs_content[UMASK][1]}}", "math", "infix");
# Format to int
"homedir_mode_int" string => format("%0.0f", ${homedir_mode_real});
"homedir_mode_to_use" string => "${homedir_mode_int}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not doing this in one line?
"homedir_mode_to_use" string => format("%0.0f", ${homedir_mode_real});

Copy link
Member Author

Choose a reason for hiding this comment

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

because homedir_mode_real may not exist, in this case, the format is not evaluated, and i use the default home_dir_to_use (line 65)
i'm not sure that doing it in one step may not cancel the actual value

… authorized keys\" for creating missing home dir
@ncharles ncharles force-pushed the bug_14916/use_umask_defined_in_etc_login_defs_in_technique_ssh_authorized_keys_for_creating_missing_home_dir branch from 4877ac7 to 9639c15 Compare June 3, 2019 13:12
@ncharles
Copy link
Member Author

ncharles commented Jun 3, 2019

Commit modified

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 9639c15 into Normation:branches/rudder/4.1 Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants