static bool is_valid_user_list (const char *users);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (int argc, int opt_index);
-static void open_files (void);
+static void open_files(const struct option_flags *flags);
static void close_files(const struct option_flags *flags);
#ifdef SHADOWGRP
static void get_group(struct group *gr, struct sgrp *sg, const struct option_flags *flags);
*
* It will call exit in case of error.
*/
-static void open_files (void)
+static void open_files(const struct option_flags *flags)
{
+ static bool process_selinux;
+
+ process_selinux = !flags->chroot;
+
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
exit (E_NOPERM);
}
- add_cleanup (cleanup_unlock_group, NULL);
+ add_cleanup (cleanup_unlock_group, &process_selinux);
#ifdef SHADOWGRP
if (is_shadowgrp) {
Prog, sgr_dbname ());
exit (E_NOPERM);
}
- add_cleanup (cleanup_unlock_gshadow, NULL);
+ add_cleanup (cleanup_unlock_gshadow, &process_selinux);
}
#endif /* SHADOWGRP */
add_cleanup (log_gpasswd_success_group, NULL);
del_cleanup (log_gpasswd_failure_group);
- cleanup_unlock_group (NULL);
+ cleanup_unlock_group (&process_selinux);
del_cleanup (cleanup_unlock_group);
#ifdef SHADOWGRP
}
del_cleanup (log_gpasswd_failure_gshadow);
- cleanup_unlock_gshadow (NULL);
+ cleanup_unlock_gshadow (&process_selinux);
del_cleanup (cleanup_unlock_gshadow);
}
#endif /* SHADOWGRP */
}
pwd_init ();
- open_files ();
+ open_files (&flags);
#ifdef SHADOWGRP
update_group (&grent, &sgent);