Exemplo n.º 1
0
    def apply_profile (self):
        argv = APPLY_TOOL_ARGV + [ "-s", self.profile_file,
                                   ("--admin-log-config=%s" % util.get_admin_log_config_filename ()),
                                   ("--readable-log-config=%s" % util.get_readable_log_config_filename ()) ]
        mprint ("Running sabayon-apply: %s" % argv)

        try:
            pipe = subprocess.Popen (argv,
                                     stderr = subprocess.PIPE,
                                     env = os.environ)
        except Exception, e:
            raise errors.FatalApplyErrorException (("Could not create the 'sabayon-apply' process: %s\n" +
                                                    "The command used is '%s'\n" +
                                                    "Child traceback:\n%s") %
                                                   (e.message,
                                                    " ".join (argv),
                                                    e.child_traceback))
Exemplo n.º 2
0
    def start(self):
        self.user_profile_path = self.__copy_to_user(self.profile_path)
        protosession.clobber_user_processes(self.username)
        self.temp_homedir = protosession.setup_shell_and_homedir(self.username)

        display_number = protosession.find_free_display()

        self.temp_xauth_path = self.__copy_xauthority()

        def child_setup_fn(self):
            os.setgid(self.pw.pw_gid)
            os.setuid(self.pw.pw_uid)
            os.setsid()
            os.umask(022)

        # FIXME: get_readable_log_config_filename() doesn't work here.
        # Create a temporary copy of the log config file and use *that*.
        argv = SESSION_TOOL_ARGV + [
            ("--admin-log-config=%s" % util.get_admin_log_config_filename()),
            ("--readable-log-config=%s" % util.get_readable_log_config_filename()),
            self.profile_name,
            self.user_profile_path,
            str(display_number),
        ]
        envp = self.build_envp_for_child()
        cwd = self.temp_homedir

        # FIXME: do we need any special processing if this throws an exception?
        # We'll catch it in the toplevel and exit with a fatal error code, anyway.
        (pid, oink, oink, oink) = gobject.spawn_async(
            argv, envp, cwd, gobject.SPAWN_DO_NOT_REAP_CHILD, child_setup_fn, self, None, None, None
        )  # stdin, stdout, stderr

        self.session_pid = pid
        # self.session_stderr = os.fdopen (stderr_fd)
        # self.session_stderr_watch_id = gobject.io_add_watch (stderr_fd,
        #                                                     gobject.IO_IN | gobject.IO_HUP,
        #                                                     self.session_stderr_io_cb, self)
        self.session_child_watch = gobject.child_watch_add(self.session_pid, self.__session_child_watch_handler)