コード例 #1
0
ファイル: fileUtilTests.py プロジェクト: rexhsu/vdsm-ubuntu
 def test(self):
     targetId = 666
     srcFd, srcPath = tempfile.mkstemp()
     os.close(srcFd)
     fileUtils.chown(srcPath, targetId, targetId)
     stat = os.stat(srcPath)
     self.assertTrue(stat.st_uid == stat.st_gid == targetId)
     os.unlink(srcPath)
コード例 #2
0
 def test(self):
     targetId = 666
     srcFd, srcPath = tempfile.mkstemp()
     os.close(srcFd)
     fileUtils.chown(srcPath, targetId, targetId)
     stat = os.stat(srcPath)
     self.assertTrue(stat.st_uid == stat.st_gid == targetId)
     os.unlink(srcPath)
コード例 #3
0
ファイル: supervdsmServer.py プロジェクト: vikas-lamba/vdsm
def main():
    try:
        logging.config.fileConfig(LOG_CONF_PATH)
    except:
        logging.basicConfig(filename='/dev/stdout',
                            filemode='w+',
                            level=logging.DEBUG)
        log = logging.getLogger("SuperVdsm.Server")
        log.warn("Could not init proper logging", exc_info=True)

    log = logging.getLogger("SuperVdsm.Server")
    try:
        log.debug("Making sure I'm root")
        if os.geteuid() != 0:
            sys.exit(errno.EPERM)

        log.debug("Parsing cmd args")
        authkey, parentPid = sys.argv[1:]

        log.debug("Creating PID file")
        with open(PIDFILE, "w") as f:
            f.write(str(os.getpid()) + "\n")

        log.debug("Cleaning old socket")
        if os.path.exists(ADDRESS):
            os.unlink(ADDRESS)

        log.debug("Setting up keep alive thread")
        monThread = threading.Thread(target=__pokeParent,
                                     args=[int(parentPid)])
        monThread.setDaemon(True)
        monThread.start()

        log.debug("Creating remote object manager")
        manager = _SuperVdsmManager(address=ADDRESS, authkey=authkey)
        manager.register('instance', callable=_SuperVdsm)

        server = manager.get_server()
        servThread = threading.Thread(target=server.serve_forever)
        servThread.setDaemon(True)
        servThread.start()

        chown(ADDRESS, METADATA_USER, METADATA_GROUP)

        log.debug("Started serving super vdsm object")
        servThread.join()
    except Exception:
        log.error("Could not start Super Vdsm", exc_info=True)
        sys.exit(1)
    finally:
        try:
            os.unlink(ADDRESS)
        except OSError:
            pass
コード例 #4
0
ファイル: fileUtilTests.py プロジェクト: doronunu/vdsm
    def testNames(self):
        # I convert to some id because I have no
        # idea what users are defined and what
        # there IDs are apart from root
        tmpId = 666
        with temporaryPath() as srcPath:
            fileUtils.chown(srcPath, tmpId, tmpId)
            stat = os.stat(srcPath)
            self.assertTrue(stat.st_uid == stat.st_gid == tmpId)

            fileUtils.chown(srcPath, "root", "root")
            stat = os.stat(srcPath)
            self.assertTrue(stat.st_uid == stat.st_gid == 0)
コード例 #5
0
    def testNames(self):
        # I convert to some id because I have no
        # idea what users are defined and what
        # there IDs are apart from root
        tmpId = 666
        with temporaryPath() as srcPath:
            fileUtils.chown(srcPath, tmpId, tmpId)
            stat = os.stat(srcPath)
            self.assertTrue(stat.st_uid == stat.st_gid == tmpId)

            fileUtils.chown(srcPath, "root", "root")
            stat = os.stat(srcPath)
            self.assertTrue(stat.st_uid == stat.st_gid == 0)
コード例 #6
0
ファイル: supervdsmServer.py プロジェクト: openSUSE/vdsm
def main():
    try:
        logging.config.fileConfig(LOG_CONF_PATH)
    except:
        logging.basicConfig(filename='/dev/stdout', filemode='w+', level=logging.DEBUG)
        log = logging.getLogger("SuperVdsm.Server")
        log.warn("Could not init proper logging", exc_info=True)

    log = logging.getLogger("SuperVdsm.Server")
    try:
        log.debug("Making sure I'm root")
        if os.geteuid() != 0:
            sys.exit(errno.EPERM)

        log.debug("Parsing cmd args")
        authkey, parentPid = sys.argv[1:]

        log.debug("Creating PID file")
        with open(PIDFILE, "w") as f:
            f.write(str(os.getpid()) + "\n")

        log.debug("Cleaning old socket")
        if os.path.exists(ADDRESS):
            os.unlink(ADDRESS)

        log.debug("Setting up keep alive thread")
        monThread = threading.Thread(target=__pokeParent, args=[int(parentPid)])
        monThread.setDaemon(True)
        monThread.start()

        log.debug("Creating remote object manager")
        manager = _SuperVdsmManager(address=ADDRESS, authkey=authkey)
        manager.register('instance', callable=_SuperVdsm)

        server = manager.get_server()
        servThread = threading.Thread(target=server.serve_forever)
        servThread.setDaemon(True)
        servThread.start()

        chown(ADDRESS, METADATA_USER, METADATA_GROUP)

        log.debug("Started serving super vdsm object")
        servThread.join()
    except Exception:
        log.error("Could not start Super Vdsm", exc_info=True)
        sys.exit(1)
    finally:
        try:
            os.unlink(ADDRESS)
        except OSError:
            pass
コード例 #7
0
ファイル: fileUtilTests.py プロジェクト: rexhsu/vdsm-ubuntu
    def testNames(self):
        # I convert to some id because I have no
        # idea what users are defined and what
        # there IDs are apart from root
        tmpId = 666
        srcFd, srcPath = tempfile.mkstemp()
        os.close(srcFd)
        fileUtils.chown(srcPath, tmpId, tmpId)
        stat = os.stat(srcPath)
        self.assertTrue(stat.st_uid == stat.st_gid == tmpId)

        fileUtils.chown(srcPath, "root", "root")
        stat = os.stat(srcPath)
        self.assertTrue(stat.st_uid == stat.st_gid == 0)
コード例 #8
0
    def testNames(self):
        # I convert to some id because I have no
        # idea what users are defined and what
        # there IDs are apart from root
        tmpId = 666
        srcFd, srcPath = tempfile.mkstemp()
        os.close(srcFd)
        fileUtils.chown(srcPath, tmpId, tmpId)
        stat = os.stat(srcPath)
        self.assertTrue(stat.st_uid == stat.st_gid == tmpId)

        fileUtils.chown(srcPath, "root", "root")
        stat = os.stat(srcPath)
        self.assertTrue(stat.st_uid == stat.st_gid == 0)
コード例 #9
0
ファイル: upgrade.py プロジェクト: vinzenz/vdsm
 def __init__(self, upgradeName):
     self._upgradeName = upgradeName
     self._upgradeFilePath = os.path.join(P_VDSM_LIB, 'upgrade',
                                          self._upgradeName)
     try:
         # First load normal VDSM loggers, then the upgrade logger.
         # This will override VDSM's root logger but will keep the other
         # loggers intact. During an upgrade we add the update handler
         # to all loggers.
         logging.config.fileConfig(P_VDSM_CONF + 'logger.conf',
                                   disable_existing_loggers=False)
         logging.config.fileConfig(P_VDSM_CONF + 'upgrade.logger.conf',
                                   disable_existing_loggers=False)
         chown(os.path.join(P_VDSM_LOG, 'upgrade.log'), VDSM_USER,
               VDSM_GROUP)
     except Exception:
         logging.getLogger('upgrade').addHandler(SysLogHandler('/dev/log'))
         logging.exception("Could not init proper logging")
     finally:
         self.log = logging.getLogger('upgrade')
コード例 #10
0
ファイル: upgrade.py プロジェクト: therealmik/vdsm
 def __init__(self, upgradeName):
     self._upgradeName = upgradeName
     self._upgradeFilePath = os.path.join(P_VDSM_LIB,
                                          'upgrade', self._upgradeName)
     try:
         # First load normal VDSM loggers, then the upgrade logger.
         # This will override VDSM's root logger but will keep the other
         # loggers intact. During an upgrade we add the update handler
         # to all loggers.
         logging.config.fileConfig(P_VDSM_CONF + 'logger.conf')
         logging.config.fileConfig(P_VDSM_CONF + 'upgrade.logger.conf',
                                   disable_existing_loggers=False)
         chown(
             os.path.join(P_VDSM_LOG, 'upgrade.log'),
             VDSM_USER,
             VDSM_GROUP)
     except Exception:
         logging.getLogger('upgrade').addHandler(SysLogHandler('/dev/log'))
         logging.exception("Could not init proper logging")
     finally:
         self.log = logging.getLogger('upgrade')
コード例 #11
0
ファイル: fileUtilTests.py プロジェクト: doronunu/vdsm
 def test(self):
     targetId = 666
     with temporaryPath() as srcPath:
         fileUtils.chown(srcPath, targetId, targetId)
         stat = os.stat(srcPath)
         self.assertTrue(stat.st_uid == stat.st_gid == targetId)
コード例 #12
0
 def test(self):
     targetId = 666
     with temporaryPath() as srcPath:
         fileUtils.chown(srcPath, targetId, targetId)
         stat = os.stat(srcPath)
         self.assertTrue(stat.st_uid == stat.st_gid == targetId)
コード例 #13
0
ファイル: supervdsmServer.py プロジェクト: hackxay/vdsm
def main():
    def bind(func):
        def wrapper(_SuperVdsm, *args, **kwargs):
            return func(*args, **kwargs)
        return wrapper

    for name, func in listPublicFunctions():
        setattr(_SuperVdsm, name, logDecorator(bind(func)))

    try:
        logging.config.fileConfig(LOG_CONF_PATH)
    except:
        logging.basicConfig(filename='/dev/stdout', filemode='w+',
                            level=logging.DEBUG)
        log = logging.getLogger("SuperVdsm.Server")
        log.warn("Could not init proper logging", exc_info=True)

    log = logging.getLogger("SuperVdsm.Server")

    try:
        log.debug("Making sure I'm root - SuperVdsm")
        if os.geteuid() != 0:
            sys.exit(errno.EPERM)

        pidfile = P_VDSM_RUN + 'supervdsmd.pid'
        pid = str(os.getpid())
        with open(pidfile, 'w') as f:
            f.write(pid + "\n")

        log.debug("Parsing cmd args")
        address = sys.argv[1]

        log.debug("Cleaning old socket %s", address)
        if os.path.exists(address):
            os.unlink(address)

        log.debug("Setting up keep alive thread")

        try:
            log.debug("Creating remote object manager")
            manager = _SuperVdsmManager(address=address, authkey='')
            manager.register('instance', callable=_SuperVdsm)

            server = manager.get_server()
            servThread = threading.Thread(target=server.serve_forever)
            servThread.setDaemon(True)
            servThread.start()

            chown(address, getpwnam(VDSM_USER).pw_uid, METADATA_GROUP)

            log.debug("Started serving super vdsm object")

            threading.Thread(target=sourceRouteThread.subscribeToInotifyLoop(),
                             name='sourceRoute').start()

            # Python bug of thread.join() will block signal
            # http://bugs.python.org/issue1167930
            while servThread.isAlive():
                servThread.join(5)
        finally:
            if os.path.exists(address):
                utils.rmFile(address)

    except Exception:
        log.error("Could not start Super Vdsm", exc_info=True)
        sys.exit(1)