#include "shadow/gshadow/sgrp.h"
#include "shadowlog.h"
+/*
+ * Structures
+ */
+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 group *gr;
struct group grent;
const struct sgrp *sg;
+ 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;
if (sgr_file_present () == 0) {
exit (0); /* no /etc/gshadow, nothing to do */
}
}
- (void) sgr_close (true); /* was only open O_RDONLY */
+ (void) sgr_close (process_selinux); /* was only open O_RDONLY */
- if (gr_close (true) == 0) {
+ if (gr_close (process_selinux) == 0) {
fprintf (stderr,
_("%s: failure while writing changes to %s\n"),
Prog, gr_dbname ());
fail_exit (3);
}
- if (gr_unlock (true) == 0) {
+ if (gr_unlock (process_selinux) == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
/* continue */
}
- if (sgr_unlock (true) == 0) {
+ if (sgr_unlock (process_selinux) == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
/* continue */