MCPcopy Create free account
hub / github.com/F-Stack/f-stack / auth_timeok

Function auth_timeok

tools/libutil/login_ok.c:218–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 */
217
218int
219auth_timeok(login_cap_t *lc, time_t t)
220{
221 int rc = 1; /* Default is ok */
222
223 if (lc != NULL && t != (time_t)0 && t != (time_t)-1) {
224 struct tm *tptr;
225
226 static int ltimesno = 0;
227 static struct login_time *ltimes = NULL;
228
229 if ((tptr = localtime(&t)) != NULL) {
230 struct login_time *lt;
231
232 lt = login_timelist(lc, "times.allow", &ltimesno, &ltimes);
233 if (lt != NULL && in_ltms(lt, tptr, NULL) == -1)
234 rc = 0; /* not in allowed times list */
235 else {
236
237 lt = login_timelist(lc, "times.deny", &ltimesno, &ltimes);
238 if (lt != NULL && in_ltms(lt, tptr, NULL) != -1)
239 rc = 0; /* in deny times list */
240 }
241 if (ltimes) {
242 free(ltimes);
243 ltimes = NULL;
244 ltimesno = 0;
245 }
246 }
247 }
248
249 return rc;
250}

Callers

nothing calls this directly

Calls 3

login_timelistFunction · 0.85
in_ltmsFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected