diff options
Diffstat (limited to 'meta/recipes-extended/shadow/files/0001-useradd.c-create-parent-directories-when-necessary.patch')
-rw-r--r-- | meta/recipes-extended/shadow/files/0001-useradd.c-create-parent-directories-when-necessary.patch | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/meta/recipes-extended/shadow/files/0001-useradd.c-create-parent-directories-when-necessary.patch b/meta/recipes-extended/shadow/files/0001-useradd.c-create-parent-directories-when-necessary.patch deleted file mode 100644 index faa6f68ebe..0000000000 --- a/meta/recipes-extended/shadow/files/0001-useradd.c-create-parent-directories-when-necessary.patch +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | Subject: [PATCH] useradd.c: create parent directories when necessary | ||
2 | |||
3 | Upstream-Status: Inappropriate [OE specific] | ||
4 | |||
5 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
6 | --- | ||
7 | src/useradd.c | 80 +++++++++++++++++++++++++++++++++++++++-------------------- | ||
8 | 1 file changed, 53 insertions(+), 27 deletions(-) | ||
9 | |||
10 | diff --git a/src/useradd.c b/src/useradd.c | ||
11 | index 00a3c30..9ecbb58 100644 | ||
12 | --- a/src/useradd.c | ||
13 | +++ b/src/useradd.c | ||
14 | @@ -2021,6 +2021,35 @@ static void usr_update (void) | ||
15 | } | ||
16 | |||
17 | /* | ||
18 | + * mkdir_p - create directories, including parent directories when needed | ||
19 | + * | ||
20 | + * similar to `mkdir -p' | ||
21 | + */ | ||
22 | +void mkdir_p(const char *path) { | ||
23 | + int len = strlen(path); | ||
24 | + char newdir[len + 1]; | ||
25 | + mode_t mode = 0755; | ||
26 | + int i = 0; | ||
27 | + | ||
28 | + if (path[i] == '\0') { | ||
29 | + return; | ||
30 | + } | ||
31 | + | ||
32 | + /* skip the leading '/' */ | ||
33 | + i++; | ||
34 | + | ||
35 | + while(path[i] != '\0') { | ||
36 | + if (path[i] == '/') { | ||
37 | + strncpy(newdir, path, i); | ||
38 | + newdir[i] = '\0'; | ||
39 | + mkdir(newdir, mode); | ||
40 | + } | ||
41 | + i++; | ||
42 | + } | ||
43 | + mkdir(path, mode); | ||
44 | +} | ||
45 | + | ||
46 | +/* | ||
47 | * create_home - create the user's home directory | ||
48 | * | ||
49 | * create_home() creates the user's home directory if it does not | ||
50 | @@ -2038,39 +2067,36 @@ static void create_home (void) | ||
51 | fail_exit (E_HOMEDIR); | ||
52 | } | ||
53 | #endif | ||
54 | - /* XXX - create missing parent directories. --marekm */ | ||
55 | - if (mkdir (prefix_user_home, 0) != 0) { | ||
56 | - fprintf (stderr, | ||
57 | - _("%s: cannot create directory %s\n"), | ||
58 | - Prog, prefix_user_home); | ||
59 | + mkdir_p(user_home); | ||
60 | + } | ||
61 | + if (access (prefix_user_home, F_OK) != 0) { | ||
62 | #ifdef WITH_AUDIT | ||
63 | - audit_logger (AUDIT_ADD_USER, Prog, | ||
64 | - "adding home directory", | ||
65 | - user_name, (unsigned int) user_id, | ||
66 | - SHADOW_AUDIT_FAILURE); | ||
67 | + audit_logger (AUDIT_ADD_USER, Prog, | ||
68 | + "adding home directory", | ||
69 | + user_name, (unsigned int) user_id, | ||
70 | + SHADOW_AUDIT_FAILURE); | ||
71 | #endif | ||
72 | - fail_exit (E_HOMEDIR); | ||
73 | - } | ||
74 | - (void) chown (prefix_user_home, user_id, user_gid); | ||
75 | - chmod (prefix_user_home, | ||
76 | - 0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK)); | ||
77 | - home_added = true; | ||
78 | + fail_exit (E_HOMEDIR); | ||
79 | + } | ||
80 | + (void) chown (prefix_user_home, user_id, user_gid); | ||
81 | + chmod (prefix_user_home, | ||
82 | + 0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK)); | ||
83 | + home_added = true; | ||
84 | #ifdef WITH_AUDIT | ||
85 | - audit_logger (AUDIT_ADD_USER, Prog, | ||
86 | - "adding home directory", | ||
87 | - user_name, (unsigned int) user_id, | ||
88 | - SHADOW_AUDIT_SUCCESS); | ||
89 | + audit_logger (AUDIT_ADD_USER, Prog, | ||
90 | + "adding home directory", | ||
91 | + user_name, (unsigned int) user_id, | ||
92 | + SHADOW_AUDIT_SUCCESS); | ||
93 | #endif | ||
94 | #ifdef WITH_SELINUX | ||
95 | - /* Reset SELinux to create files with default contexts */ | ||
96 | - if (reset_selinux_file_context () != 0) { | ||
97 | - fprintf (stderr, | ||
98 | - _("%s: cannot reset SELinux file creation context\n"), | ||
99 | - Prog); | ||
100 | - fail_exit (E_HOMEDIR); | ||
101 | - } | ||
102 | -#endif | ||
103 | + /* Reset SELinux to create files with default contexts */ | ||
104 | + if (reset_selinux_file_context () != 0) { | ||
105 | + fprintf (stderr, | ||
106 | + _("%s: cannot reset SELinux file creation context\n"), | ||
107 | + Prog); | ||
108 | + fail_exit (E_HOMEDIR); | ||
109 | } | ||
110 | +#endif | ||
111 | } | ||
112 | |||
113 | /* | ||
114 | -- | ||
115 | 2.11.0 | ||
116 | |||