diff options
author | Chris Lumens <clumens@redhat.com> | 2006-03-22 19:43:03 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2006-03-22 19:43:03 +0000 |
commit | 205ad15b10bfdccfad61621ba3b4b7fef392c40f (patch) | |
tree | b0089a49f0f2b34d494f2b28ee43579a1406c959 /flags.py | |
parent | dc78bd8e55b9b59a40b023bbbb43393f38582288 (diff) | |
download | anaconda-205ad15b10bfdccfad61621ba3b4b7fef392c40f.tar.gz anaconda-205ad15b10bfdccfad61621ba3b4b7fef392c40f.tar.xz anaconda-205ad15b10bfdccfad61621ba3b4b7fef392c40f.zip |
Create a dictionary in flags.py for storing /proc/cmdline. Nuke all
references to /proc/cmdline from everywhere else in favor of this dict.
Diffstat (limited to 'flags.py')
-rw-r--r-- | flags.py | 37 |
1 files changed, 25 insertions, 12 deletions
@@ -12,6 +12,7 @@ # import os +import shlex from constants import * # A lot of effort, but it only allows a limited set of flags to be referenced @@ -28,6 +29,22 @@ class Flags: self.__dict__['flags'][attr] = val else: raise AttributeError, attr + + def createCmdlineDict(self): + cmdlineDict = {} + cmdline = open("/proc/cmdline", "r").read() + lst = shlex.split(cmdline) + + for i in lst: + try: + (key, val) = i.split("=", 1) + except: + key = i + val = True + + cmdlineDict[key] = val + + return cmdlineDict def __init__(self): self.__dict__['flags'] = {} @@ -42,26 +59,22 @@ class Flags: self.__dict__['flags']['usevnc'] = 0 self.__dict__['flags']['dmraid'] = 1 self.__dict__['flags']['selinux'] = SELINUX_DEFAULT + self.__dict__['flags']['debug'] = 0 + self.__dict__['flags']['cmdline'] = self.createCmdlineDict() # for non-physical consoles like some ppc and sgi altix, # we need to preserve the console device and not try to # do things like bogl on them. this preserves what that # device is self.__dict__['flags']['virtpconsole'] = None - - # determine if selinux is enabled or not - f = open("/proc/cmdline", "r") - line = f.readline() - f.close() - - tokens = line.split() - for tok in tokens: - if tok == "selinux": + if self.__dict__['flags']['cmdline'].has_key("selinux"): + if self.__dict__['flags']['cmdline']["selinux"]: self.__dict__['flags']['selinux'] = 1 - elif tok == "selinux=0": + else: self.__dict__['flags']['selinux'] = 0 - elif tok == "selinux=1": - self.__dict__['flags']['selinux'] = 1 + + if self.__dict__['flags']['cmdline'].has_key("debug"): + self.__dict__['flags']['debug'] = self.__dict__['flags']['cmdline']['debug'] if not os.path.exists("/selinux/load"): self.__dict__['flags']['selinux'] = 0 |