Menu

#21 incorrect chmod in init.py

open
nobody
None
5
2005-12-31
2005-12-31
Dan Busarow
No

in the function checkfile the code intended to fix
a file mode instead resets the mode to the incorrect
value.

Here's the corrected code

def checkfile(fn, perm):
global found_error
try: st = os.stat(fn)
except: return
mode = stat.S_IMODE(st[stat.ST_MODE])
owner = st[stat.ST_UID]
user = os.getuid()
group = os.getgid()
if mode != perm or owner != user:
try:
os.chmod(fn, perm) # WAS os.chmod(fn, mode)
os.chown(fn, user, group)
return

the os.chmod is on line 29 of init.py

Dan

Discussion


Log in to post a comment.