#include "sssd.h"
#include "string/strcmp/streq.h"
+struct option_flags {
+ bool chroot;
+};
/*
* Global variables
/* local function prototypes */
static void fail_exit (int status);
static void usage (int status);
-static void process_flags (int argc, char **argv);
+static void process_flags (int argc, char **argv, struct option_flags *flags);
static void fail_exit (int status)
{
*
* It will not return if an error is encountered.
*/
-static void process_flags (int argc, char **argv)
+static void process_flags (int argc, char **argv, struct option_flags *flags)
{
/*
* Parse the command line options.
usage (E_SUCCESS);
/*@notreached@*/break;
case 'R': /* no-op, handled in process_root_flag () */
+ flags->chroot = true;
break;
default:
usage (E_USAGE);
const struct passwd *pw;
struct passwd pwent;
const struct spwd *spwd;
+ struct option_flags flags;
+ bool process_selinux;
log_set_progname(Prog);
log_set_logfd(stderr);
OPENLOG (Prog);
- process_flags (argc, argv);
+ process_flags (argc, argv, &flags);
+ process_selinux = !flags.chroot;
#ifdef WITH_TCB
if (getdef_bool("USE_TCB")) {
}
}
- (void) spw_close (true); /* was only open O_RDONLY */
+ (void) spw_close (process_selinux); /* was only open O_RDONLY */
- if (pw_close (true) == 0) {
+ if (pw_close (process_selinux) == 0) {
fprintf (stderr,
_("%s: failure while writing changes to %s\n"),
Prog, pw_dbname ());
fail_exit (3);
}
- if (spw_unlock (true) == 0) {
+ if (spw_unlock (process_selinux) == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
/* continue */
}
- if (pw_unlock (true) == 0) {
+ if (pw_unlock (process_selinux) == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
/* continue */