Пример #1
0
 def test_getid(self):
     """
     L{getid} returns a two-tuple of integers giving the numeric values of
     the strings it is passed.
     """
     uid = 1234
     gid = 4321
     self.assertEqual(getid(str(uid), str(gid)), (uid, gid))
Пример #2
0
 def test_getid(self):
     """
     L{getid} returns a two-tuple of integers giving the numeric values of
     the strings it is passed.
     """
     uid = 1234
     gid = 4321
     self.assertEqual(getid(str(uid), str(gid)), (uid, gid))
Пример #3
0
def startApplication(config, application):
    process = service.IProcess(application, None)
    if not config["originalname"]:
        launchWithName(process.processName)
    setupEnvironment(config)
    service.IService(application).privilegedStartService()
    uid, gid = mktap.getid(config["uid"], config["gid"])
    if uid is None:
        uid = process.uid
    if gid is None:
        gid = process.gid
    shedPrivileges(config["euid"], uid, gid)
    app.startApplication(application, not config["no_save"])
Пример #4
0
def startApplication(config, application):
    process = service.IProcess(application, None)
    if not config['originalname']:
        launchWithName(process.processName)
    setupEnvironment(config)
    service.IService(application).privilegedStartService()

    uid, gid = mktap.getid(config['uid'], config['gid'])
    if uid is None:
        uid = process.uid
    if gid is None:
        gid = process.gid

    shedPrivileges(config['euid'], uid, gid)
    app.startApplication(application, not config['no_save'])
Пример #5
0
    def checkConfiguration(self):
        uid, gid = None, None

        if self.parent["uid"] or self.parent["gid"]:
            uid, gid = getid(self.parent["uid"], self.parent["gid"])

        def gottaBeRoot():
            if os.getuid() != 0:
                username = getpwuid(os.getuid()).pw_name
                raise UsageError("Only root can drop privileges.  You are: %r"
                                 % (username,))

        if uid and uid != os.getuid():
            gottaBeRoot()

        if gid and gid != os.getgid():
            gottaBeRoot()

        self.parent["pidfile"] = config.PIDFile


        #
        # Verify that server root actually exists
        #
        self.checkDirectory(
            config.ServerRoot,
            "Server root",
            # Require write access because one might not allow editing on /
            access=os.W_OK,
        )
        
        #
        # Verify that other root paths are OK
        #
        if config.DocumentRoot.startswith(config.ServerRoot + os.sep):
            self.checkDirectory(
                config.DocumentRoot,
                "Document root",
                # Don't require write access because one might not allow editing on /
                access=os.R_OK,
                create=(0750, config.UserName, config.GroupName),
            )
        if config.DataRoot.startswith(config.ServerRoot + os.sep):
            self.checkDirectory(
                config.DataRoot,
                "Data root",
                access=os.W_OK,
                create=(0750, config.UserName, config.GroupName),
            )

        if config.ConfigRoot.startswith(config.ServerRoot + os.sep):
            self.checkDirectory(
                config.ConfigRoot,
                "Config root",
                access=os.W_OK,
                create=(0750, config.UserName, config.GroupName),
            )

        if config.LogRoot.startswith(config.ServerRoot + os.sep):
            self.checkDirectory(
                config.LogRoot,
                "Log root",
                access=os.W_OK,
                create=(0750, config.UserName, config.GroupName),
            )

        if config.RunRoot.startswith(config.ServerRoot + os.sep):
            self.checkDirectory(
                config.RunRoot,
                "Run root",
                access=os.W_OK,
                create=(0750, config.UserName, config.GroupName),
            )
            
        #
        # Nuke the file log observer's time format.
        #

        if not config.ErrorLogFile and config.ProcessType == "Slave":
            FileLogObserver.timeFormat = ""

        # Check current umask and warn if changed
        oldmask = os.umask(config.umask)
        if oldmask != config.umask:
            self.log_info("WARNING: changing umask from: 0%03o to 0%03o"
                          % (oldmask, config.umask))