Declare read-only parameters const
Signal callers arguments are not going to be modified and allow passing const pointers.
This commit is contained in:
		
				
					committed by
					
						
						Serge Hallyn
					
				
			
			
				
	
			
			
			
						parent
						
							0fe4128ee6
						
					
				
				
					commit
					e32b4a9a81
				
			@@ -98,7 +98,7 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id,
 | 
			
		||||
static int check_gid (const gid_t gid,
 | 
			
		||||
		      const gid_t gid_min,
 | 
			
		||||
		      const gid_t gid_max,
 | 
			
		||||
		      bool *used_gids)
 | 
			
		||||
		      const bool *used_gids)
 | 
			
		||||
{
 | 
			
		||||
	/* First test that the preferred ID is in the range */
 | 
			
		||||
	if (gid < gid_min || gid > gid_max) {
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id,
 | 
			
		||||
static int check_uid(const uid_t uid,
 | 
			
		||||
		     const uid_t uid_min,
 | 
			
		||||
		     const uid_t uid_max,
 | 
			
		||||
		     bool *used_uids)
 | 
			
		||||
		     const bool *used_uids)
 | 
			
		||||
{
 | 
			
		||||
	/* First test that the preferred ID is in the range */
 | 
			
		||||
	if (uid < uid_min || uid > uid_max) {
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@
 | 
			
		||||
 * If the range is valid, getrange returns 1.
 | 
			
		||||
 * If the range is not valid, getrange returns 0.
 | 
			
		||||
 */
 | 
			
		||||
int getrange (char *range,
 | 
			
		||||
int getrange (const char *range,
 | 
			
		||||
              unsigned long *min, bool *has_min,
 | 
			
		||||
              unsigned long *max, bool *has_max)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -102,10 +102,10 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
 | 
			
		||||
#define ULONG_DIGITS ((((sizeof(unsigned long) * CHAR_BIT) + 9)/10)*3)
 | 
			
		||||
 | 
			
		||||
#if HAVE_SYS_CAPABILITY_H
 | 
			
		||||
static inline bool maps_lower_root(int cap, int ranges, struct map_range *mappings)
 | 
			
		||||
static inline bool maps_lower_root(int cap, int ranges, const struct map_range *mappings)
 | 
			
		||||
{
 | 
			
		||||
	int idx;
 | 
			
		||||
	struct map_range *mapping;
 | 
			
		||||
	const struct map_range *mapping;
 | 
			
		||||
 | 
			
		||||
	if (cap != CAP_SETUID)
 | 
			
		||||
		return false;
 | 
			
		||||
@@ -135,11 +135,11 @@ static inline bool maps_lower_root(int cap, int ranges, struct map_range *mappin
 | 
			
		||||
 * when the root user calls the new{g,u}idmap binary for an unprivileged user.
 | 
			
		||||
 * If this is wanted: use file capabilities!
 | 
			
		||||
 */
 | 
			
		||||
void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings,
 | 
			
		||||
void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings,
 | 
			
		||||
	const char *map_file, uid_t ruid)
 | 
			
		||||
{
 | 
			
		||||
	int idx;
 | 
			
		||||
	struct map_range *mapping;
 | 
			
		||||
	const struct map_range *mapping;
 | 
			
		||||
	size_t bufsize;
 | 
			
		||||
	char *buf, *pos;
 | 
			
		||||
	int fd;
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ struct map_range {
 | 
			
		||||
 | 
			
		||||
extern struct map_range *get_map_ranges(int ranges, int argc, char **argv);
 | 
			
		||||
extern void write_mapping(int proc_dir_fd, int ranges,
 | 
			
		||||
	struct map_range *mappings, const char *map_file, uid_t ruid);
 | 
			
		||||
	const struct map_range *mappings, const char *map_file, uid_t ruid);
 | 
			
		||||
 | 
			
		||||
#endif /* _ID_MAPPING_H_ */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user