def chown(self, cpioinfo, cpiogetpath):
"""Set owner of cpiogetpath according to cpioinfo.
"""
if PWD and hasattr(os, "geteuid") and os.geteuid() == 0:
# We have to be root to do so.
try:
g = GRP.getgrgid(cpioinfo.gid)[2]
except KeyError:
g = os.getgid()
try:
u = PWD.getpwuid(cpioinfo.uid)[2]
except KeyError:
u = os.getuid()
try:
if cpioinfo.issym() and hasattr(os, "lchown"):
os.lchown(cpiogetpath, u, g)
else:
if sys.platform != "os2emx":
os.chown(cpiogetpath, u, g)
except EnvironmentError:
raise ExtractError("could not change owner")
评论列表
文章目录