| 121 | } |
| 122 | |
| 123 | static int |
| 124 | find_subid(const char *sub_file, const char *user, int *num_ids) |
| 125 | { |
| 126 | FILE *f = fopen(sub_file, "r"); |
| 127 | if (!f) |
| 128 | die("Cannot open %s: %m", sub_file); |
| 129 | |
| 130 | char *line = NULL; |
| 131 | size_t line_n = 0; |
| 132 | while (getline(&line, &line_n, f) >= 0) |
| 133 | { |
| 134 | char *fields[4]; |
| 135 | char *c = line; |
| 136 | for (uint i=0; i<4; i++) |
| 137 | { |
| 138 | fields[i] = c; |
| 139 | while (*c && *c != '\n' && *c != ':') |
| 140 | c++; |
| 141 | if (*c) |
| 142 | *c++ = 0; |
| 143 | } |
| 144 | |
| 145 | if (!strcmp(fields[0], user)) |
| 146 | { |
| 147 | int start; |
| 148 | if (!parse_ugid(fields[1], &start)) |
| 149 | die("Cannot parse line for user %s in %s: bad range start", user, sub_file); |
| 150 | if (!parse_ugid(fields[2], num_ids)) |
| 151 | die("Cannot parse line for user %s in %s: bad range length", user, sub_file); |
| 152 | fclose(f); |
| 153 | free(line); |
| 154 | return start; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | die("User %s not found in %s", user, sub_file); |
| 159 | } |
| 160 | |
| 161 | static void |
| 162 | cf_find_ids(void) |
no test coverage detected
searching dependent graphs…