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

Function get_ids

src/install.c:547–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545/* Initialize the user and group ownership of the files to install. */
546
547static void
548get_ids (void)
549{
550 if (owner_name)
551 {
552 struct passwd *pw = getpwnam (owner_name);
553 if (pw == NULL)
554 {
555 uintmax_t tmp;
556 if (xstrtoumax (owner_name, NULL, 0, &tmp, "") != LONGINT_OK
557 || ckd_add (&owner_id, tmp, 0))
558 error (EXIT_FAILURE, 0, _("invalid user %s"),
559 quoteaf (owner_name));
560 }
561 else
562 owner_id = pw->pw_uid;
563 endpwent ();
564 }
565 else
566 owner_id = (uid_t) -1;
567
568 if (group_name)
569 {
570 struct group *gr = getgrnam (group_name);
571 if (gr == NULL)
572 {
573 uintmax_t tmp;
574 if (xstrtoumax (group_name, NULL, 0, &tmp, "") != LONGINT_OK
575 || ckd_add (&group_id, tmp, 0))
576 error (EXIT_FAILURE, 0, _("invalid group %s"),
577 quoteaf (group_name));
578 }
579 else
580 group_id = gr->gr_gid;
581 endgrent ();
582 }
583 else
584 group_id = (gid_t) -1;
585}
586
587void
588usage (int status)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected