def __init__(self, user, subuser, environment, extraDockerFlags=None, entrypoint=None): self.subuser = subuser self.env = environment self.backgroundSuppressOutput = True self.__backgroundCollectStdout = False self.__backgroundCollectStderr = False self.__executionSpoolReader = None if extraDockerFlags is None: self.__extraFlags = [] else: self.__extraFlags = extraDockerFlags if not entrypoint: self.entrypoint = self.subuser.permissions["executable"] else: self.entrypoint = entrypoint self.background = False if not subuserlib.test.testing: self.hostname = binascii.b2a_hex(os.urandom(10)).decode() else: self.hostname = "<random-hostname>" UserOwnedObject.__init__(self, user)
def __init__(self, op): UserOwnedObject.__init__(self, op.user) self.op = op self.__upToDateImageSources = set() self.__outOfDateImageSources = set() self.__outOfDateSubusers = None self.__subusersWhosImagesFailedToBuild = set()
def __init__(self,user,name=None): UserOwnedObject.__init__(self,user) self.proxiedByOtherUser = False self.sudo = False self.name = name try: self.name = self.user.config["user"] self.proxiedByOtherUser = True except KeyError: try: self.name = os.environ["SUDO_USER"] self.sudo = True self.proxiedByOtherUser = True except KeyError: try: self.name = getpass.getuser() except KeyError: # We use a broken setup when generating documentation... self.name = "I have no name!" self.uid = 1000 self.gid = 1000 if not test.testing: if self.sudo: self.uid = int(os.environ.get('SUDO_UID')) self.gid = int(os.environ.get('SUDO_GID')) else: try: self.uid = pwd.getpwnam(self.name)[2] self.gid = pwd.getpwnam(self.name)[3] except KeyError: pass if not self.uid == 0: self.homeDir = os.path.join("/home/",self.name) else: self.homeDir = "/root/"
def __init__(self,user,subuser): self.__subuser = subuser UserOwnedObject.__init__(self,user) if not self.getSubuser().getImageId(): raise NoRuntimeCacheForSubusersWhichDontHaveExistantImagesException self.__pathToRuntimeCacheFile = os.path.join(self.getPathToCurrentImagesRuntimeCacheDir(),self.getSubuser().getPermissions().getHash()+".json") self.load()
def __init__(self,user,imageId,imageSourceName,sourceRepoId,imageSourceHash): self.imageId = imageId self.imageSourceHash = imageSourceHash self.imageSourceName = imageSourceName self.sourceRepoId = sourceRepoId self.__alreadyCheckedForUpdates = None UserOwnedObject.__init__(self,user)
def __init__(self, user, name, imageId, executableShortcutInstalled, locked, serviceSubusers, imageSource=None, imageSourceName=None, repoName=None, entrypointsExposed=False): self.__name = name self.__imageSource = imageSource self.__repoName = repoName self.__imageSourceName = imageSourceName self.__imageId = imageId self.__executableShortcutInstalled = executableShortcutInstalled self.__entryPointsExposed = entrypointsExposed self.__entryPointsExposedThisRun = False self.__locked = locked self.__serviceSubusers = serviceSubusers self.__x11Bridge = None self.__runReadyImage = None self.__runtime = None self.__runtimeCache = None self.__permissions = None self.__permissionsTemplate = None UserOwnedObject.__init__(self, user)
def __init__(self,user): UserOwnedObject.__init__(self,user) self.permissionsAccepter = AcceptPermissionsAtCLI(user) self.prompt = True self.checkForUpdatesExternally=False self.subusers=[] # which subusers are we operating on self.useCache=False self.build=True
def __init__(self,user,subusersToBeUpdatedOrInstalled,checkForUpdatesExternally=False): UserOwnedObject.__init__(self,user) self.__subusersToBeUpdated = subusersToBeUpdatedOrInstalled self.__upToDateImageSources = set() self.__outOfDateImageSources = set() self.__outOfDateSubusers = None self.__subusersWhosImagesFailedToBuild = set() self.checkForUpdatesExternally = checkForUpdatesExternally
def __init__(self, user, imageId, imageSourceName, sourceRepoId, imageSourceHash): self.__imageId = imageId self.__imageSourceHash = imageSourceHash self.__imageSourceName = imageSourceName self.__sourceRepoId = sourceRepoId self.__alreadyCheckedForUpdates = None UserOwnedObject.__init__(self, user)
def __init__(self,user): UserOwnedObject.__init__(self,user) if os.path.exists(self.getUser().getConfig()["locked-subusers-path"]): with open(self.getUser().getConfig()["locked-subusers-path"],"r") as file: self._loadSerializedSubusersDict(json.load(file, object_pairs_hook=collections.OrderedDict),locked=True) if "subusers.json" in self.getUser().getRegistry().getGitRepository().lsFiles(self.getUser().getRegistry().getGitReadHash(),"./"): serializedUnlockedSubusersDict = json.loads(self.getUser().getRegistry().getGitRepository().show(self.getUser().getRegistry().getGitReadHash(),"subusers.json"), object_pairs_hook=collections.OrderedDict) self._loadSerializedSubusersDict(serializedUnlockedSubusersDict,locked=False)
def __init__(self,user): UserOwnedObject.__init__(self,user) if os.path.exists(self.getUser().getConfig()["locked-subusers-path"]): with open(self.getUser().getConfig()["locked-subusers-path"],"r") as fileHandle: self._loadSerializedSubusersDict(json.load(fileHandle, object_pairs_hook=collections.OrderedDict),locked=True) registryFileStructure = self.getUser().getRegistry().getGitRepository().getFileStructureAtCommit(self.getUser().getRegistry().getGitReadHash()) if "subusers.json" in registryFileStructure.lsFiles("./"): serializedUnlockedSubusersDict = json.loads(registryFileStructure.read("subusers.json"), object_pairs_hook=collections.OrderedDict) self._loadSerializedSubusersDict(serializedUnlockedSubusersDict,locked=False)
def __init__(self,user): UserOwnedObject.__init__(self,user) if os.path.exists(self.getUser().getConfig()["locked-subusers-path"]): with open(self.getUser().getConfig()["locked-subusers-path"],"r") as fileHandle: self._loadSerializedSubusersDict(json.load(fileHandle, object_pairs_hook=collections.OrderedDict),locked=True) registryFileStructure = self.getUser().getRegistry().getGitRepository().getFileStructureAtCommit(self.getUser().getRegistry().getGitReadHash()) if self.getUser().getRegistry().initialized and "subusers.json" in registryFileStructure.lsFiles("./"): serializedUnlockedSubusersDict = json.loads(registryFileStructure.read("subusers.json"), object_pairs_hook=collections.OrderedDict) self._loadSerializedSubusersDict(serializedUnlockedSubusersDict,locked=False)
def __init__(self,user): self.systemRepositories = {} # TODO rename and document these variables self.userRepositories = {} UserOwnedObject.__init__(self,user) self.systemRepositoryListPaths = ["/etc/subuser/repositories.json" ,os.path.join(user.homeDir,".subuser","repositories.json") ,subuserlib.paths.getSubuserDataFile("repositories.json")] # TODO how does this work on windows? self.userRepositoryListPath = os.path.join(self.getUser().getConfig()["registry-dir"],"repositories.json") self.reloadRepositoryLists()
def __init__(self,user,subuser): self.__subuser = subuser self.__id = None UserOwnedObject.__init__(self,user) try: self.__id = subuser.getRuntimeCache()["run-ready-image-id"] except KeyError: self.__id = self.build() subuser.getRuntimeCache()["run-ready-image-id"] = self.__id subuser.getRuntimeCache().save()
def __init__(self, user, subuser, environment): self.__subuser = subuser self.__environment = environment self.__extraFlags = [] self.__background = False if not subuserlib.test.testing: self.__hostname = binascii.b2a_hex(os.urandom(10)) else: self.__hostname = b"<random-hostname>" UserOwnedObject.__init__(self, user)
def __init__(self,user,subuser,environment): self.__subuser = subuser self.__environment = environment self.__extraFlags = [] self.__background = False if not subuserlib.test.testing: self.__hostname = binascii.b2a_hex(os.urandom(10)) else: self.__hostname = b"<random-hostname>" UserOwnedObject.__init__(self,user)
def __init__(self,user): self.images = {} self.nextImageId = 1 self.newId = None UserOwnedObject.__init__(self,user) self.imagesPath = os.path.join(user.homeDir,"docker/images.json") self.__load() self.dockerDaemon = subuserlib.classes.docker.dockerDaemon.RealDockerDaemon(user) self.connection = MockConnection(self) self.dockerDaemon.getConnection = self.getConnection self.dockerDaemon.getImageProperties = self.getImageProperties
def __init__(self,user,name,gitOriginURI=None,gitCommitHash=None,temporary=False,sourceDir=None): """ Repositories can either be managed by git, or simply be normal directories on the user's computer. If ``sourceDir`` is not set to None, then ``gitOriginURI`` is ignored and the repository is assumed to be a simple directory. """ self.__name = name self.__gitOriginURI = gitOriginURI self.__lastGitCommitHash = gitCommitHash self.__temporary=temporary self.__sourceDir=sourceDir UserOwnedObject.__init__(self,user) self.__gitRepository = GitRepository(self.getRepoPath()) self.loadProgramSources()
def __init__(self,user): self.images = {} self.nextImageId = 1 UserOwnedObject.__init__(self,user) self.imagesPath = "/root/subuser/test/docker/images.json" if not os.path.exists(self.imagesPath): self.imagesPath = "/home/travis/build/subuser-security/subuser/test/docker/images.json" self.__load() self.dockerDaemon = subuserlib.classes.docker.dockerDaemon.RealDockerDaemon(user) self.connection = MockConnection(self) self.dockerDaemon.getConnection = self.getConnection self.dockerDaemon.getImageProperties = self.getImageProperties
def __init__(self, user): self.images = {} self.nextImageId = 1 UserOwnedObject.__init__(self, user) self.imagesPath = "/root/subuser/test/docker/images.json" if not os.path.exists(self.imagesPath): self.imagesPath = "/home/travis/build/subuser-security/subuser/test/docker/images.json" self.__load() self.dockerDaemon = subuserlib.classes.docker.dockerDaemon.RealDockerDaemon( user) self.connection = MockConnection(self) self.dockerDaemon.getConnection = self.getConnection self.dockerDaemon.getImageProperties = self.getImageProperties
def __init__(self,user,name,imageSource,imageId,executableShortcutInstalled,locked,serviceSubusers): self.__name = name self.__imageSource = imageSource self.__imageId = imageId self.__executableShortcutInstalled = executableShortcutInstalled self.__locked = locked self.__serviceSubusers = serviceSubusers self.__x11Bridge = None self.__runReadyImage = None self.__runtime = None self.__runtimeCache = None self.__permissions = None UserOwnedObject.__init__(self,user)
def __init__(self, user, name, imageSource, imageId, executableShortcutInstalled, locked, serviceSubusers): self.__name = name self.__imageSource = imageSource self.__imageId = imageId self.__executableShortcutInstalled = executableShortcutInstalled self.__locked = locked self.__serviceSubusers = serviceSubusers self.__x11Bridge = None self.__runReadyImage = None self.__runtime = None self.__runtimeCache = None self.__permissions = None self.__permissionsTemplate = None UserOwnedObject.__init__(self, user)
def __init__(self,user,name,gitOriginURI=None,gitCommitHash=None,temporary=False,sourceDir=None): """ Repositories can either be managed by git, or simply be normal directories on the user's computer. If ``sourceDir`` is not set to None, then ``gitOriginURI`` is ignored and the repository is assumed to be a simple directory. """ self.__name = name self.__gitOriginURI = gitOriginURI self.__lastGitCommitHash = gitCommitHash self.__temporary = temporary self.__sourceDir = sourceDir self.__fileStructure = None UserOwnedObject.__init__(self,user) self.__gitRepository = GitRepository(self.getRepoPath()) if not os.path.exists(self.getRepoPath()): self.updateSources(initialUpdate=True) self.__repoConfig = self.loadRepoConfig() self.loadImageSources()
def __init__(self,user,subuser,environment,extraDockerFlags=None): self.__subuser = subuser self.__environment = environment self.__backgroundSuppressOutput = True self.__backgroundCollectStdout = False self.__backgroundCollectStderr = False self.__executionSpoolReader = None if extraDockerFlags is None: self.__extraFlags = [] else: self.__extraFlags = extraDockerFlags self.__background = False if not subuserlib.test.testing: self.__hostname = binascii.b2a_hex(os.urandom(10)) else: self.__hostname = b"<random-hostname>" UserOwnedObject.__init__(self,user)
def __init__(self,user,name,gitOriginURI=None,gitCommitHash=None,temporary=False,sourceDir=None): """ Repositories can either be managed by git, or simply be normal directories on the user's computer. If ``sourceDir`` is not set to None, then ``gitOriginURI`` is ignored and the repository is assumed to be a simple directory. """ self.__name = name self.__gitOriginURI = gitOriginURI self.__lastGitCommitHash = gitCommitHash self.__temporary = temporary self.__sourceDir = sourceDir self.__fileStructure = None UserOwnedObject.__init__(self,user) self.__gitRepository = GitRepository(user,self.getRepoPath()) if not self.isPresent(): self.updateSources(initialUpdate=True) self.__repoConfig = self.loadRepoConfig() if self.isPresent(): self.loadImageSources()
def __init__(self,user,name,imageId,executableShortcutInstalled,locked,serviceSubusers,imageSource=None,imageSourceName=None,repoName=None,entrypointsExposed=False): self.__name = name self.__imageSource = imageSource self.__repoName = repoName self.__imageSourceName = imageSourceName self.__imageId = imageId self.__executableShortcutInstalled = executableShortcutInstalled self.__entryPointsExposed = entrypointsExposed self.__entryPointsExposedThisRun = False self.__locked = locked self.__serviceSubusers = serviceSubusers self.__x11Bridge = None self.__runReadyImage = None self.__runtime = None self.__runtimeCache = None self.__permissions = None self.__permissionsTemplate = None UserOwnedObject.__init__(self,user)
def __init__(self, user, name, gitOriginURI=None, gitCommitHash=None, temporary=False, sourceDir=None): """ Repositories can either be managed by git, or simply be normal directories on the user's computer. If ``sourceDir`` is not set to None, then ``gitOriginURI`` is ignored and the repository is assumed to be a simple directory. """ self.__name = name self.__gitOriginURI = gitOriginURI self.__lastGitCommitHash = gitCommitHash self.__temporary = temporary self.__sourceDir = sourceDir UserOwnedObject.__init__(self, user) self.__gitRepository = GitRepository(self.getRepoPath()) self.loadProgramSources()
def __init__(self, user): UserOwnedObject.__init__(self, user) registryFileStructure = self.user.registry.gitRepository.getFileStructureAtCommit( self.user.registry.gitReadHash) if self.user.registry.initialized and "subusers.json" in registryFileStructure.lsFiles( "./"): serializedUnlockedSubusersDict = json.loads( registryFileStructure.read("subusers.json"), object_pairs_hook=collections.OrderedDict) self._loadSerializedSubusersDict(serializedUnlockedSubusersDict, locked=False) if (not self.user.registry.ignoreVersionLocks) and os.path.exists( self.user.config["locked-subusers-path"]): with open(self.user.config["locked-subusers-path"], "r") as fileHandle: self._loadSerializedSubusersDict(json.load( fileHandle, object_pairs_hook=collections.OrderedDict), locked=True)
def __init__(self,user,subuser,environment,extraDockerFlags=None,entrypoint = None): self.__subuser = subuser self.__environment = environment self.__backgroundSuppressOutput = True self.__backgroundCollectStdout = False self.__backgroundCollectStderr = False self.__executionSpoolReader = None if extraDockerFlags is None: self.__extraFlags = [] else: self.__extraFlags = extraDockerFlags if not entrypoint: self.entrypoint = self.getSubuser().getPermissions()["executable"] else: self.entrypoint = entrypoint self.__background = False if not subuserlib.test.testing: self.__hostname = binascii.b2a_hex(os.urandom(10)).decode() else: self.__hostname = "<random-hostname>" UserOwnedObject.__init__(self,user)
def __init__(self,user): UserOwnedObject.__init__(self,user) self.proxiedByOtherUser = False try: self.name = self.getUser().getConfig()["user"] self.proxiedByOtherUser = True except KeyError: try: self.name = getpass.getuser() except KeyError: # We use a broken setup when generating documentation... self.name = "I have no name!" if test.testing: self.uid = 1000 self.gid = 1000 else: self.uid = pwd.getpwnam(self.name)[2] self.gid = pwd.getpwnam(self.name)[3] if not self.uid == 0: self.homeDir = os.path.join("/home/",self.name) else: self.homeDir = "/root/"
def __init__(self,user): UserOwnedObject.__init__(self,user) self.proxiedByOtherUser = False try: self.name = self.getUser().getConfig()["user"] self.proxiedByOtherUser = True except KeyError: try: self.name = getpass.getuser() except KeyError: # We use a broken setup when generating documentation... self.name = "I have no name!" self.uid = 1000 self.gid = 1000 if not test.testing: try: self.uid = pwd.getpwnam(self.name)[2] self.gid = pwd.getpwnam(self.name)[3] except KeyError: pass if not self.uid == 0: self.homeDir = os.path.join("/home/",self.name) else: self.homeDir = "/root/"
def __init__(self, user, path): UserOwnedObject.__init__(self, user) self.path = path self.__gitExecutable = None
def __init__(self,user): self.__connection = None self.__imagePropertiesCache = {} UserOwnedObject.__init__(self,user)
def __init__(self, user): self.__connection = None self.__imagePropertiesCache = {} UserOwnedObject.__init__(self, user)
def __init__(self, user, alwaysAccept=False): self.__alwaysAccept = alwaysAccept UserOwnedObject.__init__(self, user)
def __init__(self, user, subuser): self.__subuser = subuser UserOwnedObject.__init__(self, user) self.load()
def __init__(self,user,initialPermissions,writePath=None): self.writePath = writePath UserOwnedObject.__init__(self,user) collections.OrderedDict.__init__(self) self.update(initialPermissions)
def __init__(self,user): self.__connection = None UserOwnedObject.__init__(self,user)
def __init__(self, user, subuser): self.__subuser = subuser self.__id = None UserOwnedObject.__init__(self, user)
def __init__(self, user, containerId): self.__containerId = containerId UserOwnedObject.__init__(self, user)
def __init__(self,user): UserOwnedObject.__init__(self,user) super().__init__() self.reloadInstalledImagesList()
def __init__(self,user,repo,name,explicitConfig=None): self.__name = name self.__repo = repo self.__permissions = None self.__explicitConfig = explicitConfig UserOwnedObject.__init__(self,user)
def __init__(self,user,repo,name): self.__name = name self.__repo = repo self.__permissions = None UserOwnedObject.__init__(self,user)
def __init__(self, user, subuser, environment): self.__subuser = subuser self.__environment = environment self.__extraFlags = [] self.__background = False UserOwnedObject.__init__(self, user)
def __init__(self,user): UserOwnedObject.__init__(self,user) self.reloadInstalledImagesList()
def __init__(self,user,alwaysAccept = False): self.__alwaysAccept = alwaysAccept UserOwnedObject.__init__(self,user)
def __init__(self,user,path): UserOwnedObject.__init__(self,user) self.__path = path
def __init__(self, user, initialPermissions, writePath=None): self.__writePath = writePath UserOwnedObject.__init__(self, user) collections.OrderedDict.__init__(self) self.update(initialPermissions)
def __init__(self,user,path): UserOwnedObject.__init__(self,user) self.__path = path self.__gitExecutable = None
def __init__(self, user, repo, name, explicitConfig=None): self.__name = name self.__repo = repo self.__permissions = None self.__explicitConfig = explicitConfig UserOwnedObject.__init__(self, user)