def write_script_file(self, script_file, filename, shell, code, uid, gid): # Chown and chmod it before we write the data in it - the script may # have sensitive content # It would be nice to use fchown(2) and fchmod(2), but they're not # available in python and using it with ctypes is pretty tedious, not # to mention we can't get errno. os.chmod(filename, 0700) if uid is not None: os.chown(filename, uid, gid) script_file.write(build_script(shell, code)) script_file.close()
def test_concatenate(self): self.assertEqual(build_script(u"/bin/sh", u"echo 1.0\n"), "#!/bin/sh\necho 1.0\n")
def test_concatenate_null_strings(self): self.assertEqual(build_script(None, None), "#!\n")