[master 3/5] Fix the parsing of selinux=0 (#1258569)
dashea
installerbot-noreply at redhat.com
Fri Oct 16 21:01:43 UTC 2015
From: David Shea <dshea at redhat.com>
The selinux and noselinux options are supposed to act like
store_true/store_false pair, but the values they need to store are not
True and False. Use a custom argparse action to convert the arguments to
--selinux into the appropriate value.
---
pyanaconda/anaconda_argparse.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/anaconda_argparse.py b/pyanaconda/anaconda_argparse.py
index e6ba3f5..351bc0a 100644
--- a/pyanaconda/anaconda_argparse.py
+++ b/pyanaconda/anaconda_argparse.py
@@ -30,7 +30,7 @@
import termios
import struct
-from argparse import ArgumentParser, ArgumentError, HelpFormatter, Namespace
+from argparse import ArgumentParser, ArgumentError, HelpFormatter, Namespace, Action
from pyanaconda.flags import BootArgs
from pyanaconda.iutil import open # pylint: disable=redefined-builtin
@@ -451,8 +451,17 @@ def getArgumentParser(version_string, boot_cmdline=None):
ap.add_argument("--noselinux", dest="selinux", action="store_const",
const=SELINUX_DISABLED, default=SELINUX_DEFAULT,
help=help_parser.help_text("noselinux"))
- ap.add_argument("--selinux", action="store_const",
- const=SELINUX_ENFORCING, help=help_parser.help_text("selinux"))
+
+ # Use a custom action to convert --selinux=0 and --selinux=1 into the
+ # appropriate constants
+ class ParseSelinux(Action):
+ def __call__(self, parser, namespace, values, option_string=None):
+ if values == "0":
+ setattr(namespace, self.dest, SELINUX_DISABLED)
+ else:
+ setattr(namespace, self.dest, SELINUX_ENFORCING)
+
+ ap.add_argument("--selinux", action=ParseSelinux, nargs="?", help=help_parser.help_text("selinux"))
ap.add_argument("--nompath", dest="mpath", action="store_false", default=True,
help=help_parser.help_text("nompath"))
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/8bab8a6ef0570a2f12936129c50dc63da254642a
More information about the anaconda-patches
mailing list