예제 #1
0
 def _generate_root_wrap(self):
     if not self.cfg.getboolean("nova", "do_root_wrap"):
         return False
     else:
         lines = list()
         lines.append("%s ALL=(root) NOPASSWD: %s" % (sh.getuser(), self.root_wrap_bin))
         fc = utils.joinlinesep(*lines)
         root_wrap_fn = sh.joinpths(self.distro.get_command_config("sudoers_dir"), "nova-rootwrap")
         self.tracewriter.file_touched(root_wrap_fn)
         with sh.Rooted(True):
             sh.write_file(root_wrap_fn, fc)
             sh.chmod(root_wrap_fn, 0440)
             sh.chown(root_wrap_fn, sh.getuid(sh.ROOT_USER), sh.getgid(sh.ROOT_GROUP))
         return True
예제 #2
0
 def configure(self):
     files = self._configure_files()
     if sh.isdir(self.cfg_dir):
         uid = None
         gid = None
         try:
             uid = sh.getuid(self.name)
             gid = sh.getgid(self.name)
         except (KeyError, AttributeError):
             LOG.warn("Unable to find uid & gid for user & group %s", self.name)
         if uid is not None and gid is not None:
             try:
                 sh.chown_r(self.cfg_dir, uid, gid)
             except Exception as e:
                 LOG.warn("Failed to change the ownership of %s to %s:%s due to: %s",
                          self.cfg_dir, uid, gid, e)
     return files