MCPcopy Create free account
hub / github.com/ioi/isolate / find_subid

Function find_subid

config.c:123–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123static int
124find_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
161static void
162cf_find_ids(void)

Callers 1

cf_find_idsFunction · 0.85

Calls 1

parse_ugidFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…