NULL, /* close_hook */
};
-static /*@observer@*/ /*@null*/const struct subordinate_range *subordinate_next(struct commonio_db *db)
-{
- return (const struct subordinate_range *)commonio_next (db);
-}
-
/*
* range_exists: Check whether @owner owns any ranges
*
* subuid @val.
*
* @db: database to query
- * @owner: owning uid being queuried
+ * @owner: owning uid being queried
* @val: subuid being searched for.
*
* Returns a range of subuids belonging to @owner and including the subuid
/*
* Search loop above did not produce any result. Let's rerun it,
- * but this time try to matcha actual UIDs. The first entry that
+ * but this time try to match actual UIDs. The first entry that
* matches is considered a success.
* (It may be specified as literal UID or as another username which
* has the same UID as the username we are looking for.)
unsigned long first = range->start;
unsigned long last = first + range->count - 1;
+ /* For performance reasons check range before using getpwnam() */
+ if ((val < first) || (val > last)) {
+ continue;
+ }
+
/*
- * First check if range owner is specified as numeric UID
- * and if it matches.
+ * Range matches. Check if range owner is specified
+ * as numeric UID and if it matches.
*/
- if (0 != strcmp(range->owner, owner_uid_string)) {
- /*
- * Ok, this range owner is not specified as numeric UID
- * we are looking for. It may be specified as another
- * UID or as a literal username.
- *
- * If specified as another UID, the call to getpwnam()
- * will return NULL.
- *
- * If specified as literal username, we will get its
- * UID and compare that to UID we are looking for.
- */
- const struct passwd *range_owner_pwd;
-
- range_owner_pwd = getpwnam(range->owner);
- if (NULL == range_owner_pwd) {
- continue;
- }
-
- if (owner_uid != range_owner_pwd->pw_uid) {
- continue;
- }
+ if (0 == strcmp(range->owner, owner_uid_string)) {
+ return range;
+ }
+
+ /*
+ * Ok, this range owner is not specified as numeric UID
+ * we are looking for. It may be specified as another
+ * UID or as a literal username.
+ *
+ * If specified as another UID, the call to getpwnam()
+ * will return NULL.
+ *
+ * If specified as literal username, we will get its
+ * UID and compare that to UID we are looking for.
+ */
+ const struct passwd *range_owner_pwd;
+
+ range_owner_pwd = getpwnam(range->owner);
+ if (NULL == range_owner_pwd) {
+ continue;
}
- /* Owner matches, now let us check this UID/GID range */
- if ((val >= first) && (val <= last)) {
+ if (owner_uid == range_owner_pwd->pw_uid) {
return range;
}
}
* @start: the first uid in the owned range
* @count: the number of uids in the range
*
- * Return 1 if the range is already present or on succcess. On error
+ * Return 1 if the range is already present or on success. On error
* return 0 and set errno appropriately.
*/
static int add_range(struct commonio_db *db,
#ifdef WITH_SELINUX
NULL, /* scontext */
#endif
+ 0644, /* st_mode */
+ 0, /* st_uid */
+ 0, /* st_gid */
NULL, /* head */
NULL, /* tail */
NULL, /* cursor */
false, /* changed */
false, /* isopen */
false, /* locked */
- false /* readonly */
+ false, /* readonly */
+ false /* setname */
};
int sub_uid_setdbname (const char *filename)
#ifdef WITH_SELINUX
NULL, /* scontext */
#endif
+ 0644, /* st_mode */
+ 0, /* st_uid */
+ 0, /* st_gid */
NULL, /* head */
NULL, /* tail */
NULL, /* cursor */
false, /* changed */
false, /* isopen */
false, /* locked */
- false /* readonly */
+ false, /* readonly */
+ false /* setname */
};
int sub_gid_setdbname (const char *filename)