Process a command-line file name. */
| 161 | |
| 162 | /* Process a command-line file name. */ |
| 163 | static int |
| 164 | process_dir (char *dir, struct savewd *wd, void *options) |
| 165 | { |
| 166 | struct mkdir_options const *o = options; |
| 167 | |
| 168 | /* If possible set context before DIR created. */ |
| 169 | if (o->set_security_context) |
| 170 | { |
| 171 | if (! o->make_ancestor_function |
| 172 | && defaultcon (o->set_security_context, dir, S_IFDIR) < 0 |
| 173 | && ! ignorable_ctx_err (errno)) |
| 174 | error (0, errno, _("failed to set default creation context for %s"), |
| 175 | quoteaf (dir)); |
| 176 | } |
| 177 | |
| 178 | int ret = (make_dir_parents (dir, wd, o->make_ancestor_function, options, |
| 179 | o->mode, announce_mkdir, |
| 180 | o->mode_bits, (uid_t) -1, (gid_t) -1, true) |
| 181 | ? EXIT_SUCCESS |
| 182 | : EXIT_FAILURE); |
| 183 | |
| 184 | /* FIXME: Due to the current structure of make_dir_parents() |
| 185 | we don't have the facility to call defaultcon() before the |
| 186 | final component of DIR is created. So for now, create the |
| 187 | final component with the context from previous component |
| 188 | and here we set the context for the final component. */ |
| 189 | if (ret == EXIT_SUCCESS && o->set_security_context |
| 190 | && o->make_ancestor_function) |
| 191 | { |
| 192 | if (! restorecon (o->set_security_context, last_component (dir), false) |
| 193 | && ! ignorable_ctx_err (errno)) |
| 194 | error (0, errno, _("failed to restore context for %s"), |
| 195 | quoteaf (dir)); |
| 196 | } |
| 197 | |
| 198 | return ret; |
| 199 | } |
| 200 | |
| 201 | int |
| 202 | main (int argc, char **argv) |
nothing calls this directly
no test coverage detected