def testLinuxChown(self): basefile = os.path.join(self.basedir, "foo") f = open(basefile, "w") f.write("foo") f.close OSUtils.chown(self.basedir, uid=100, gid=100) st = os.stat(self.basedir) self.assertEqual(100, st.st_uid) self.assertEqual(100, st.st_gid) st = os.stat(basefile) self.assertEqual(100, st.st_uid) self.assertEqual(100, st.st_gid) import pwd pwo = pwd.getpwnam("nobody") uid = pwo.pw_uid gid = pwo.pw_gid OSUtils.chown(self.basedir, username="******") st = os.stat(self.basedir) self.assertEqual(uid, st.st_uid) self.assertEqual(gid, st.st_gid) st = os.stat(basefile) self.assertEqual(uid, st.st_uid) self.assertEqual(gid, st.st_gid)
def testLinuxChown(self): basefile = os.path.join(self.basedir, "foo") f = open(basefile, "w") f.write("foo") f.close OSUtils.chown(self.basedir, uid=100, gid=100) st = os.stat(self.basedir) self.assertEqual(100, st.st_uid) self.assertEqual(100, st.st_gid) st = os.stat(basefile) self.assertEqual(100, st.st_uid) self.assertEqual(100, st.st_gid) import pwd pwo = pwd.getpwnam("nobody") uid = pwo.pw_uid gid = pwo.pw_gid OSUtils.chown(self.basedir, username="******") st = os.stat(self.basedir) self.assertEqual(uid, st.st_uid) self.assertEqual(gid, st.st_gid) st = os.stat(basefile) self.assertEqual(uid, st.st_uid) self.assertEqual(gid, st.st_gid)
def testWindowsChown(self): basefile = os.path.join(self.basedir, "foo") f = open(basefile, "w") f.write("foo") f.close OSUtils.chown(self.basedir, username="******") null = open(OSUtils.null_file(), 'w') tfile = tempfile.TemporaryFile() popen = subprocess.Popen(["icacls", self.basedir], stdout=tfile, stderr=null) popen.wait() tfile.seek(0) c = tfile.read() self.assertNotEqual(1, len(re.findall(".*mmorsi.*(F).*\n.*", c))) tfile.close() tfile = tempfile.TemporaryFile() popen = subprocess.Popen(["icacls", basefile], stdout=tfile, stderr=null) popen.wait() tfile.seek(0) c = tfile.read() self.assertNotEqual(1, len(re.findall(".*mmorsi.*(F).*\n.*", c))) tfile.close()
def testWindowsChown(self): basefile = os.path.join(self.basedir, "foo") f = open(basefile, "w") f.write("foo") f.close OSUtils.chown(self.basedir, username="******") null = open(OSUtils.null_file(), 'w') tfile = tempfile.TemporaryFile() popen = subprocess.Popen(["icacls", self.basedir], stdout=tfile, stderr=null) popen.wait() tfile.seek(0) c = tfile.read() self.assertNotEqual(1, len(re.findall(".*mmorsi.*(F).*\n.*", c))) tfile.close() tfile = tempfile.TemporaryFile() popen = subprocess.Popen(["icacls", basefile], stdout=tfile, stderr=null) popen.wait() tfile.seek(0) c = tfile.read() self.assertNotEqual(1, len(re.findall(".*mmorsi.*(F).*\n.*", c))) tfile.close()