MCPcopy Create free account
hub / github.com/coreutils/coreutils / main

Function main

src/chroot.c:218–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218int
219main (int argc, char **argv)
220{
221 int c;
222
223 /* Input user and groups spec. */
224 char *userspec = NULL;
225 char const *username = NULL;
226 char const *groups = NULL;
227 bool skip_chdir = false;
228
229 /* Parsed user and group IDs. */
230 uid_t uid = -1;
231 gid_t gid = -1;
232 GETGROUPS_T *out_gids = NULL;
233 idx_t n_gids = 0;
234
235 initialize_main (&argc, &argv);
236 set_program_name (argv[0]);
237 setlocale (LC_ALL, "");
238 bindtextdomain (PACKAGE, LOCALEDIR);
239 textdomain (PACKAGE);
240
241 initialize_exit_failure (EXIT_CANCELED);
242 atexit (close_stdout);
243
244 while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1)
245 {
246 switch (c)
247 {
248 case USERSPEC:
249 {
250 userspec = optarg;
251 /* Treat 'user:' just like 'user'
252 as we lookup the primary group by default
253 (and support doing so for UIDs as well as names. */
254 idx_t userlen = strlen (userspec);
255 if (userlen && userspec[userlen - 1] == ':')
256 userspec[userlen - 1] = '\0';
257 break;
258 }
259
260 case GROUPS:
261 groups = optarg;
262 break;
263
264 case SKIP_CHDIR:
265 skip_chdir = true;
266 break;
267
268 case_GETOPT_HELP_CHAR;
269
270 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
271
272 default:
273 usage (EXIT_CANCELED);
274 }
275 }

Callers

nothing calls this directly

Calls 7

initialize_exit_failureFunction · 0.85
is_rootFunction · 0.85
gid_unsetFunction · 0.85
parse_additional_groupsFunction · 0.85
bad_castFunction · 0.85
setgroupsFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected