Lines Matching refs:set
24 void restrict_access_init(struct restrict_access_settings *set)
26 i_zero(set);
28 set->uid = (uid_t)-1;
29 set->gid = (gid_t)-1;
30 set->privileged_gid = (gid_t)-1;
68 /* everything is already set */
81 "process group set to %s instead of %s)",
136 static void drop_restricted_groups(const struct restrict_access_settings *set,
144 if (gid_list[i] >= set->first_valid_gid &&
145 (set->last_valid_gid == 0 ||
146 gid_list[i] <= set->last_valid_gid)) {
173 static void fix_groups_list(const struct restrict_access_settings *set,
186 tmp = set->extra_groups == NULL ? &empty :
187 t_strsplit_spaces(set->extra_groups, ", ");
191 drop_restricted_groups(set, gid_list, &gid_count,
230 set->extra_groups == NULL ? "" :
231 set->extra_groups);
239 get_setuid_error_str(const struct restrict_access_settings *set, uid_t target_uid)
244 if (set->uid_source != NULL)
245 str_printfa(str, " from %s", set->uid_source);
252 "process user set to %s instead of %s)",
258 void restrict_access(const struct restrict_access_settings *set,
264 uid_t target_uid = set->uid;
269 !set->allow_setuid_root &&
282 /* set the primary/privileged group */
283 process_primary_gid = set->gid;
284 process_privileged_gid = set->privileged_gid;
296 process_privileged_gid, set->gid_source);
302 /* set system user's groups */
303 if (set->system_groups_user != NULL && is_root) {
304 if (initgroups(set->system_groups_user,
307 set->system_groups_user,
313 /* add extra groups. if we set system user's groups, drop the
316 fix_groups_list(set, preserve_groups,
321 if (set->chroot_dir != NULL) {
327 if (chroot(set->chroot_dir) != 0)
328 i_fatal("chroot(%s) failed: %m", set->chroot_dir);
333 chroot_dir = i_strdup(set->chroot_dir);
345 i_fatal("%s", get_setuid_error_str(set, target_uid));
359 if (set->first_valid_gid != 0)
379 void restrict_access_set_env(const struct restrict_access_settings *set)
381 if (set->system_groups_user != NULL &&
382 *set->system_groups_user != '\0') {
384 set->system_groups_user, NULL));
386 if (set->chroot_dir != NULL && *set->chroot_dir != '\0')
387 env_put(t_strconcat("RESTRICT_CHROOT=", set->chroot_dir, NULL));
389 if (set->uid != (uid_t)-1) {
391 dec2str(set->uid)));
393 if (set->gid != (gid_t)-1) {
395 dec2str(set->gid)));
397 if (set->privileged_gid != (gid_t)-1) {
399 dec2str(set->privileged_gid)));
401 if (set->extra_groups != NULL && *set->extra_groups != '\0') {
403 set->extra_groups, NULL));
406 if (set->first_valid_gid != 0) {
408 dec2str(set->first_valid_gid)));
410 if (set->last_valid_gid != 0) {
412 dec2str(set->last_valid_gid)));
454 struct restrict_access_settings set;
456 restrict_access_get_env(&set);
457 restrict_access(&set, flags, home);
463 a privileged group is set, the groups must be fixed