UID, pwd.getpwnam() ile alınır; GID ise grp.getgrnam() ile.

This commit is contained in:
Bahadır Kandemir
2005-10-13 19:32:23 +00:00
parent 687a3302ad
commit 57aaa870c6
+2 -1
View File
@@ -15,6 +15,7 @@ import os
import glob
import shutil
import pwd
import grp
import gettext
__trans = gettext.translation('pisi', fallback=True)
@@ -69,7 +70,7 @@ def chown(sourceFile, uid = "root", gid = "root"):
'''change the owner and group id of sourceFile to uid and gid'''
if can_access_file(sourceFile):
try:
os.chown(sourceFile, pwd.getpwnam(uid)[2], pwd.getpwnam(gid)[3])
os.chown(sourceFile, pwd.getpwnam(uid)[2], grp.getgrnam(gid)[2])
except OSError:
ctx.ui.error(_(' ActionsAPI [chown]: Operation not permitted: %s (uid: %s, gid: %s)') \
% (sourceFile, uid, gid))