Beispiel #1
0
 def runthread(self):
     logger.logV(self.tn, logger.I, _("Copying ISOLINUX to the ISO tree"))
     copyFile("/usr/lib/syslinux/isolinux.bin", isotreel +
              "isolinux/", self.tn, True)
     self.setProgress(self.tn, 20)
     copyFile("/usr/lib/syslinux/vesamenu.c32", isotreel +
              "isolinux/", self.tn, True)
     self.setProgress(self.tn, 40)
     logger.logVV(
         self.tn, logger.I, _("Copying isolinux.cfg to the ISO tree"))
     copyFile(configutils.getValue(configs[configutils.isolinuxfile]), isotreel +
              "isolinux/isolinux.cfg", self.tn, True)
     self.setProgress(self.tn, 50)
     # Edit the isolinux.cfg file to replace the variables
     logger.logV(self.tn, logger.I, _("Editing isolinux.cfg"))
     splash = os.path.basename(
         configutils.getValue(configs[configutils.splash]))
     shutil.copy2(configutils.getValue(configs[configutils.splash]),
                  isotreel + "isolinux/" + splash)
     self.setProgress(self.tn, 70)
     for i in [["LABEL", configutils.getValue(configs[configutils.label])],
               ["SPLASH", splash],
               ["TIMEOUT", configutils.getValue(configs[configutils.timeout])]]:
         fsutil.ife(
             fsutil.ife_getbuffers(isotreel + "isolinux/isolinux.cfg"),
             lambda line: [True, re.sub("\$" + i[0], i[1], line)])
Beispiel #2
0
 def varEditor(self, files, lists, export_str="export "):
     buffers = fsutil.ife_getbuffers(files)
     fsutil.ife(buffers, lambda line: self._varEditor(line, lists, export_str))
     # In case the file is broken, we'll add the lines needed
     buffers = open(files, "a")
     for i in lists:
         if lists[i] is not None:
             buffers.write(export_str + i + "=\"" + lists[i] + "\"\n")
     buffers.close()
Beispiel #3
0
 def varEditor(self, files, lists):
     buffers = fsutil.ife_getbuffers(files)
     fsutil.ife(buffers, lambda line: self._varEditor(line, lists))
     # In case the file is broken, we'll add the lines needed
     buffers = open(files, "a")
     for i in lists:
         if lists[i] is not None:
             buffers.write("export " + i + '="' + lists[i] + '"\n')
     buffers.close()
Beispiel #4
0
 def varEditor(self, files, lists):
     buffers = fsutil.ife_getbuffers(files)
     fsutil.ife(buffers, lambda line: self._varEditor(line, lists))
     # In case the file is broken, we'll add the lines needed
     buffers = open(files, "a")
     for i in lists:
         if lists[i] is not None:
             buffers.write("export " + i + "=\"" + lists[i] + "\"\n")
     buffers.close()
Beispiel #5
0
 def varEditor(self, files, lists, export_str="export ", quote_str="\""):
     buffers = fsutil.ife_getbuffers(files)
     fsutil.ife(
         buffers,
         lambda line: self._varEditor(line, lists, export_str, quote_str))
     # In case the file is broken, we'll add the lines needed
     buffers = open(files, "a")
     for i in lists:
         if lists[i] is not None:
             buffers.write(export_str + i + "=" + quote_str + lists[i] +
                           quote_str + "\n")
     buffers.close()
Beispiel #6
0
 def run(self):
     logger.logV(self.tn, _("Copying ISOLINUX to the ISO tree"))
     copyFile("/usr/lib/syslinux/isolinux.bin", isotreel + "isolinux/", True)
     copyFile("/usr/lib/syslinux/vesamenu.c32", isotreel + "isolinux/", True)
     logger.logVV(self.tn, _("Copying isolinux.cfg to the ISO tree"))
     copyFile(configutils.getValue(configs[configutils.isolinuxfile], isotreel + 
                                   "isolinux/isolinux.cfg", True))
     # Edit the isolinux.cfg file to replace the variables
     logger.logV(_("Editing isolinux.cfg"))
     for i in [["LABEL", configutils.getValue(configs[configutils.label])],
               ["SPLASH", configutils.getValue(configs[configutils.splash])],
               ["TIMEOUT", configutils.getValue(configs[configutils.timeout])]]:
         fsutil.ife(fsutil.ife_getbuffers(isotreel + "isolinux/isolinux.cfg"),
                    lambda line: re.sub("\$" + i[0], i[1], line))
Beispiel #7
0
 def runthread(self):
     # Setup the password and group stuff
     logger.logI(self.tn, logger.I, _("Removing conflicting users"))
     passwdf = tmpsys + "etc/passwd"
     #passwdfile = open(passwdf, "r")
     #passwdstat = fsutil.getStat(passwdf)
     #passwdbuffer = configutils.getBuffer(passwdfile)
     #passwdfile.close()
     #passwdfile = open(passwdf, "w")
     buffers = fsutil.ife_getbuffers(passwdf)
     pe = pwdmanip.parsePasswdEntries(buffers[3])
     buffers[3] = pe
     # Users to "delete" on the live system
     logger.logV(self.tn, logger.I, _("Gathering users to remove"))
     nobody = ""
     for x in pe:
         if x["user"] == "nobody":
             nobody = x
     max_uid = 1999
     sysrange = 500
     if not isinstance(nobody, dict):
         logger.logV(
             self.tn, logger.E, _("User 'nobody' could not be found!"))
     else:
         nuid = int(nobody["uid"])
         if nuid <= 100:
             # nobody has been assigned to the conventional system UID range
             max_uid = 1999
             sysrange = 100
         elif nuid < 500:
             # nobody has been assigned to the RHEL system UID range
             max_uid = 1999
             sysrange = 500
         elif nuid >= 65530 and nuid <= 65535:
             # nobody has been assigned to the highest possible unsigned short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 555
         elif nuid >= 32766:
             # nobody has been assigned to the highest possible signed short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 500
         else:
             max_uid = 1999
             sysrange = 555
     usrs = pwdmanip.getPPByUID(
         numrange.gen_num_range(sysrange, max_uid), pe)
     if config.VVStatus is False:
         logger.logV(self.tn, logger.I, _("Removing them"))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/passwd"))
     fsutil.ife(buffers, lambda line: [True, pwdmanip.PPtoEntry(
         line)] if not line in usrs else [False, ""])
     # Rewrite the password file
     #for i in ppe:
     #    if not i in usrs:
     #        passwdfile.write(pwdmanip.PPtoEntry(i))
     #fsutil.copystat(passwdstat, passwdf)
     #passwdfile.close()
     # Now for the group file
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/group"))
     groupf = tmpsys + "etc/group"
     buffers = fsutil.ife_getbuffers(groupf)
     pe = pwdmanip.parseGroupEntries(buffers[3])
     buffers[3] = pe
     fsutil.ife(buffers, lambda line: self._parseGroup(line, usrs))
     # Work on both shadow files
     shadowf = tmpsys + "etc/shadow"
     gshadowf = tmpsys + "etc/gshadow"
     buffers = fsutil.ife_getbuffers(shadowf)
     gbuffers = fsutil.ife_getbuffers(gshadowf)
     pe = pwdmanip.parseShadowEntries(buffers[3])
     buffers[3] = pe
     # If you look carefully (or just do a quick google search :P), you will notice that gshadow files
     # are very similar to group files, so we can just parse them as if they were group files
     pe = pwdmanip.parseGroupEntries(gbuffers[3])
     gbuffers[3] = pe
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/shadow"))
     fsutil.ife(buffers, lambda line: self._parseShadow(line, usrs))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/gshadow"))
     fsutil.ife(gbuffers, lambda line: self._parseGroup(line, usrs))
     logger.logV(self.tn, logger.I, _("Creating backups"))
     shutil.copy2(tmpsys + "etc/passwd", tmpsys + "etc/passwd-")
     shutil.copy2(tmpsys + "etc/group", tmpsys + "etc/group-")
     shutil.copy2(tmpsys + "etc/shadow", tmpsys + "etc/shadow-")
     shutil.copy2(tmpsys + "etc/gshadow", tmpsys + "etc/gshadow-")
Beispiel #8
0
 def runthread(self):
     # Setup the password and group stuff
     logger.logI(self.tn, logger.I, _("Removing conflicting users"))
     passwdf = tmpsys + "etc/passwd"
     #passwdfile = open(passwdf, "r")
     #passwdstat = fsutil.getStat(passwdf)
     #passwdbuffer = configutils.getBuffer(passwdfile)
     #passwdfile.close()
     #passwdfile = open(passwdf, "w")
     buffers = fsutil.ife_getbuffers(passwdf)
     pe = pwdmanip.parsePasswdEntries(buffers[3])
     buffers[3] = pe
     # Users to "delete" on the live system
     logger.logV(self.tn, logger.I, _("Gathering users to remove"))
     nobody = ""
     for x in pe:
         if x["user"] == "nobody":
             nobody = x
     max_uid = 1999
     sysrange = 500
     if not isinstance(nobody, dict):
         logger.logV(self.tn, logger.E,
                     _("User 'nobody' could not be found!"))
     else:
         nuid = int(nobody["uid"])
         if nuid <= 100:
             # nobody has been assigned to the conventional system UID range
             max_uid = 1999
             sysrange = 100
         elif nuid < 500:
             # nobody has been assigned to the RHEL system UID range
             max_uid = 1999
             sysrange = 500
         elif nuid >= 65530 and nuid <= 65535:
             # nobody has been assigned to the highest possible unsigned short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 555
         elif nuid >= 32766:
             # nobody has been assigned to the highest possible signed short integer (16 bit) range
             max_uid = nuid - 1
             sysrange = 500
         else:
             max_uid = 1999
             sysrange = 555
     usrs = pwdmanip.getPPByUID(numrange.gen_num_range(sysrange, max_uid),
                                pe)
     print(usrs)
     if config.VVStatus is False:
         logger.logV(self.tn, logger.I, _("Removing them"))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/passwd"))
     fsutil.ife(
         buffers, lambda line: [True, pwdmanip.PPtoEntry(line)]
         if not line in usrs else [False, ""])
     # Rewrite the password file
     #for i in ppe:
     #    if not i in usrs:
     #        passwdfile.write(pwdmanip.PPtoEntry(i))
     #fsutil.copystat(passwdstat, passwdf)
     #passwdfile.close()
     # Now for the group file
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/group"))
     groupf = tmpsys + "etc/group"
     buffers = fsutil.ife_getbuffers(groupf)
     pe = pwdmanip.parseGroupEntries(buffers[3])
     buffers[3] = pe
     fsutil.ife(buffers, lambda line: self._parseGroup(line, usrs))
     # Work on both shadow files
     shadowf = tmpsys + "etc/shadow"
     gshadowf = tmpsys + "etc/gshadow"
     buffers = fsutil.ife_getbuffers(shadowf)
     gbuffers = fsutil.ife_getbuffers(gshadowf)
     pe = pwdmanip.parseShadowEntries(buffers[3])
     buffers[3] = pe
     # If you look carefully (or just do a quick google search :P), you will notice that gshadow files
     # are very similar to group files, so we can just parse them as if they were group files
     pe = pwdmanip.parseGroupEntries(gbuffers[3])
     gbuffers[3] = pe
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/shadow"))
     fsutil.ife(buffers, lambda line: self._parseShadow(line, usrs))
     logger.logVV(self.tn, logger.I, _("Removing users in /etc/gshadow"))
     fsutil.ife(gbuffers, lambda line: self._parseGroup(line, usrs))
     logger.logV(self.tn, logger.I, _("Creating backups"))
     shutil.copy2(tmpsys + "etc/passwd", tmpsys + "etc/passwd-")
     shutil.copy2(tmpsys + "etc/group", tmpsys + "etc/group-")
     shutil.copy2(tmpsys + "etc/shadow", tmpsys + "etc/shadow-")
     shutil.copy2(tmpsys + "etc/gshadow", tmpsys + "etc/gshadow-")