| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/group-list.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | extern | - | ||||||||||||
| 6 | _Bool | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 | print_group_list (const char *username, | - | ||||||||||||
| 9 | uid_t ruid, gid_t rgid, gid_t egid, | - | ||||||||||||
| 10 | - | |||||||||||||
| 11 | _Bool | - | ||||||||||||
| 12 | use_names, char delim) | - | ||||||||||||
| 13 | { | - | ||||||||||||
| 14 | - | |||||||||||||
| 15 | _Bool | - | ||||||||||||
| 16 | ok = | - | ||||||||||||
| 17 | 1 | - | ||||||||||||
| 18 | ; | - | ||||||||||||
| 19 | struct passwd *pwd = | - | ||||||||||||
| 20 | ((void *)0) | - | ||||||||||||
| 21 | ; | - | ||||||||||||
| 22 | - | |||||||||||||
| 23 | if (username
| 15-35 | ||||||||||||
| 24 | { | - | ||||||||||||
| 25 | pwd = getpwuid (ruid); | - | ||||||||||||
| 26 | if (pwd ==
| 0-35 | ||||||||||||
| 27 | ((void *)0)
| 0-35 | ||||||||||||
| 28 | ) | - | ||||||||||||
| 29 | ok = never executed: ok = 0 ; | 0 | ||||||||||||
| 30 | 0 never executed: ok = 0 ; | 0 | ||||||||||||
| 31 | ; never executed: ok = 0 ; | 0 | ||||||||||||
| 32 | } executed 35 times by 1 test: end of blockExecuted by:
| 35 | ||||||||||||
| 33 | - | |||||||||||||
| 34 | if (!print_group (rgid, use_names)
| 0-50 | ||||||||||||
| 35 | ok = never executed: ok = 0 ; | 0 | ||||||||||||
| 36 | 0 never executed: ok = 0 ; | 0 | ||||||||||||
| 37 | ; never executed: ok = 0 ; | 0 | ||||||||||||
| 38 | - | |||||||||||||
| 39 | if (egid != rgid
| 0-50 | ||||||||||||
| 40 | { | - | ||||||||||||
| 41 | putchar_unlocked (delim); | - | ||||||||||||
| 42 | if (!print_group (egid, use_names)
| 0 | ||||||||||||
| 43 | ok = never executed: ok = 0 ; | 0 | ||||||||||||
| 44 | 0 never executed: ok = 0 ; | 0 | ||||||||||||
| 45 | ; never executed: ok = 0 ; | 0 | ||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||
| 47 | - | |||||||||||||
| 48 | { | - | ||||||||||||
| 49 | gid_t *groups; | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : egid), &groups); | - | ||||||||||||
| 52 | if (n_groups < 0
| 0-50 | ||||||||||||
| 53 | { | - | ||||||||||||
| 54 | if (username
| 0 | ||||||||||||
| 55 | { | - | ||||||||||||
| 56 | error (0, | - | ||||||||||||
| 57 | (*__errno_location ()) | - | ||||||||||||
| 58 | , | - | ||||||||||||
| 59 | dcgettext (((void *)0), | - | ||||||||||||
| 60 | "failed to get groups for user %s" | - | ||||||||||||
| 61 | , 5) | - | ||||||||||||
| 62 | , | - | ||||||||||||
| 63 | quote (username)); | - | ||||||||||||
| 64 | } never executed: end of block | 0 | ||||||||||||
| 65 | else | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | error (0, | - | ||||||||||||
| 68 | (*__errno_location ()) | - | ||||||||||||
| 69 | , | - | ||||||||||||
| 70 | dcgettext (((void *)0), | - | ||||||||||||
| 71 | "failed to get groups for the current process" | - | ||||||||||||
| 72 | , 5) | - | ||||||||||||
| 73 | ); | - | ||||||||||||
| 74 | } never executed: end of block | 0 | ||||||||||||
| 75 | return never executed: return 0 ;never executed: return 0 ; | 0 | ||||||||||||
| 76 | 0 never executed: return 0 ; | 0 | ||||||||||||
| 77 | ; never executed: return 0 ; | 0 | ||||||||||||
| 78 | } | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | for (int i = 0; i < n_groups
| 50-310 | ||||||||||||
| 81 | if (groups[i] != rgid
| 0-260 | ||||||||||||
| 82 | { | - | ||||||||||||
| 83 | putchar_unlocked (delim); | - | ||||||||||||
| 84 | if (!print_group (groups[i], use_names)
| 0-260 | ||||||||||||
| 85 | ok = never executed: ok = 0 ; | 0 | ||||||||||||
| 86 | 0 never executed: ok = 0 ; | 0 | ||||||||||||
| 87 | ; never executed: ok = 0 ; | 0 | ||||||||||||
| 88 | } executed 260 times by 1 test: end of blockExecuted by:
| 260 | ||||||||||||
| 89 | free (groups); | - | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | return executed 50 times by 1 test: ok;return ok;Executed by:
executed 50 times by 1 test: return ok;Executed by:
| 50 | ||||||||||||
| 92 | } | - | ||||||||||||
| 93 | - | |||||||||||||
| 94 | - | |||||||||||||
| 95 | - | |||||||||||||
| 96 | - | |||||||||||||
| 97 | static char * | - | ||||||||||||
| 98 | gidtostr_ptr (gid_t const *gid) | - | ||||||||||||
| 99 | { | - | ||||||||||||
| 100 | static char buf[((((((sizeof (uintmax_t) * 8) - (! ((__typeof__ (uintmax_t)) 0 < (__typeof__ (uintmax_t)) -1))) * 146 + 484) / 485) + (! ((__typeof__ (uintmax_t)) 0 < (__typeof__ (uintmax_t)) -1))) + 1)]; | - | ||||||||||||
| 101 | return executed 237 times by 1 test: umaxtostr (*gid, buf);return umaxtostr (*gid, buf);Executed by:
executed 237 times by 1 test: return umaxtostr (*gid, buf);Executed by:
| 237 | ||||||||||||
| 102 | } | - | ||||||||||||
| 103 | - | |||||||||||||
| 104 | - | |||||||||||||
| 105 | - | |||||||||||||
| 106 | extern | - | ||||||||||||
| 107 | _Bool | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | print_group (gid_t gid, | - | ||||||||||||
| 110 | _Bool | - | ||||||||||||
| 111 | use_name) | - | ||||||||||||
| 112 | { | - | ||||||||||||
| 113 | struct group *grp = | - | ||||||||||||
| 114 | ((void *)0) | - | ||||||||||||
| 115 | ; | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | _Bool | - | ||||||||||||
| 118 | ok = | - | ||||||||||||
| 119 | 1 | - | ||||||||||||
| 120 | ; | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | if (use_name
| 121-237 | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | grp = getgrgid (gid); | - | ||||||||||||
| 125 | if (grp ==
| 0-121 | ||||||||||||
| 126 | ((void *)0)
| 0-121 | ||||||||||||
| 127 | ) | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | error (0, 0, | - | ||||||||||||
| 130 | dcgettext (((void *)0), | - | ||||||||||||
| 131 | "cannot find name for group ID %lu" | - | ||||||||||||
| 132 | , 5) | - | ||||||||||||
| 133 | , | - | ||||||||||||
| 134 | (unsigned long int) gid); | - | ||||||||||||
| 135 | ok = | - | ||||||||||||
| 136 | 0 | - | ||||||||||||
| 137 | ; | - | ||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||
| 139 | } executed 121 times by 1 test: end of blockExecuted by:
| 121 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | char *s = grp
| 121-237 | ||||||||||||
| 142 | fputs_unlocked (s, | - | ||||||||||||
| 143 | stdout | - | ||||||||||||
| 144 | ); | - | ||||||||||||
| 145 | return executed 358 times by 1 test: ok;return ok;Executed by:
executed 358 times by 1 test: return ok;Executed by:
| 358 | ||||||||||||
| 146 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |