Lines Matching +full:user +full:- +full:selected
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
59 static USRT **usrtb = NULL; /* user selection table */
84 * User/group selection routines
86 * Routines to handle user selection of files based on the file uid/gid. To
87 * add an entry, the user supplies either the name or the uid/gid starting with
93 * add a user match to the user match hash table
95 * 0 if added ok, -1 otherwise;
110 return(-1); in usr_add()
113 paxwarn(1, "Unable to allocate memory for user selection table"); in usr_add()
114 return(-1); in usr_add()
118 * figure out user spec in usr_add()
122 * it is a user name, \# escapes # as first char in user name in usr_add()
127 paxwarn(1, "Unable to find uid for user: %s", str); in usr_add()
128 return(-1); in usr_add()
130 uid = (uid_t)pw->pw_uid; in usr_add()
141 if (pt->uid == uid) in usr_add()
143 pt = pt->fow; in usr_add()
151 pt->uid = uid; in usr_add()
152 pt->fow = usrtb[indx]; in usr_add()
156 paxwarn(1, "User selection table out of memory"); in usr_add()
157 return(-1); in usr_add()
162 * check if this files uid matches a selected uid.
175 pt = usrtb[((unsigned)arcn->sb.st_uid) % USR_TB_SZ]; in usr_match()
177 if (pt->uid == arcn->sb.st_uid) in usr_match()
179 pt = pt->fow; in usr_match()
192 * 0 if added ok, -1 otherwise;
207 return(-1); in grp_add()
211 return(-1); in grp_add()
215 * figure out user spec in grp_add()
225 return(-1); in grp_add()
227 gid = gr->gr_gid; in grp_add()
238 if (pt->gid == gid) in grp_add()
240 pt = pt->fow; in grp_add()
248 pt->gid = gid; in grp_add()
249 pt->fow = grptb[indx]; in grp_add()
254 return(-1); in grp_add()
259 * check if this files gid matches a selected gid.
272 pt = grptb[((unsigned)arcn->sb.st_gid) % GRP_TB_SZ]; in grp_match()
274 if (pt->gid == arcn->sb.st_gid) in grp_match()
276 pt = pt->fow; in grp_match()
288 * Routines to handle user selection of files based on the modification and/or
289 * inode change time falling within a specified time range (the non-standard
290 * -T flag). The user may specify any number of different file time ranges.
293 * ranges, the file is selected. Time ranges may have a lower and/or an upper
295 * with the -T option, all members in the archive will be selected by the time
297 * mtime (and/or ctime) equal to or younger are selected. When only an upper
299 * are selected. When the lower time range is equal to the upper time range,
300 * only files with a mtime (or ctime) of exactly that time are selected.
306 * This is a non-standard pax option. Lower and upper ranges are in the
311 * 0 if the time range was added to the list, -1 otherwise
328 return(-1); in trng_add()
363 return(-1); in trng_add()
367 * by default we only will check file mtime, but the user can specify in trng_add()
371 pt->flgs = CMPMTME; in trng_add()
373 pt->flgs = 0; in trng_add()
378 pt->flgs |= CMPMTME; in trng_add()
382 pt->flgs |= CMPCTME; in trng_add()
397 pt->low_time = pt->high_time = time(NULL); in trng_add()
402 if (str_sec(str, &(pt->low_time)) < 0) { in trng_add()
407 pt->flgs |= HASLOW; in trng_add()
414 if (str_sec(up_pt, &(pt->high_time)) < 0) { in trng_add()
419 pt->flgs |= HASHIGH; in trng_add()
424 if (pt->flgs & HASLOW) { in trng_add()
425 if (pt->low_time > pt->high_time) { in trng_add()
429 return(-1); in trng_add()
434 pt->fow = NULL; in trng_add()
439 trtail->fow = pt; in trng_add()
445 return(-1); in trng_add()
466 switch(pt->flgs & CMPBOTH) { in trng_match()
469 * user wants both mtime and ctime checked for this in trng_match()
472 if (((pt->flgs & HASLOW) && in trng_match()
473 (arcn->sb.st_mtime < pt->low_time) && in trng_match()
474 (arcn->sb.st_ctime < pt->low_time)) || in trng_match()
475 ((pt->flgs & HASHIGH) && in trng_match()
476 (arcn->sb.st_mtime > pt->high_time) && in trng_match()
477 (arcn->sb.st_ctime > pt->high_time))) { in trng_match()
478 pt = pt->fow; in trng_match()
484 * user wants only ctime checked for this time range in trng_match()
486 if (((pt->flgs & HASLOW) && in trng_match()
487 (arcn->sb.st_ctime < pt->low_time)) || in trng_match()
488 ((pt->flgs & HASHIGH) && in trng_match()
489 (arcn->sb.st_ctime > pt->high_time))) { in trng_match()
490 pt = pt->fow; in trng_match()
497 * user wants only mtime checked for this time range in trng_match()
499 if (((pt->flgs & HASLOW) && in trng_match()
500 (arcn->sb.st_mtime < pt->low_time)) || in trng_match()
501 ((pt->flgs & HASHIGH) && in trng_match()
502 (arcn->sb.st_mtime > pt->high_time))) { in trng_match()
503 pt = pt->fow; in trng_match()
521 * 0 if converted ok, -1 otherwise
543 return(-1); in str_sec()
550 return(-1); in str_sec()
551 lt->tm_sec = ATOI2(dot); in str_sec()
552 if (lt->tm_sec > 61) in str_sec()
553 return(-1); in str_sec()
554 len -= 3; in str_sec()
556 lt->tm_sec = 0; in str_sec()
561 lt->tm_year = (bigyear * 100) - 1900; in str_sec()
566 lt->tm_year += ATOI2(p); in str_sec()
568 lt->tm_year = ATOI2(p); in str_sec()
569 if (lt->tm_year < 69) /* hack for 2000 ;-} */ in str_sec()
570 lt->tm_year += (2000 - 1900); in str_sec()
574 lt->tm_mon = ATOI2(p); in str_sec()
575 if ((lt->tm_mon > 12) || !lt->tm_mon) in str_sec()
576 return(-1); in str_sec()
577 --lt->tm_mon; /* time struct is 0 - 11 */ in str_sec()
580 lt->tm_mday = ATOI2(p); in str_sec()
581 if ((lt->tm_mday > 31) || !lt->tm_mday) in str_sec()
582 return(-1); in str_sec()
585 lt->tm_hour = ATOI2(p); in str_sec()
586 if (lt->tm_hour > 23) in str_sec()
587 return(-1); in str_sec()
590 lt->tm_min = ATOI2(p); in str_sec()
591 if (lt->tm_min > 59) in str_sec()
592 return(-1); in str_sec()
595 return(-1); in str_sec()
598 /* convert broken-down time to UTC clock time seconds */ in str_sec()
599 if ((*tval = mktime(lt)) == -1) in str_sec()
600 return(-1); in str_sec()