diff --git a/twander.py b/twander.py index 6aa23d0..fe2cc69 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ PROGNAME = "twander" -RCSID = "$Id: twander.py,v 1.78 2002/11/24 18:44:51 tundra Exp $" +RCSID = "$Id: twander.py,v 1.79 2002/11/24 19:23:46 tundra Exp $" VERSION = RCSID.split()[2] @@ -152,7 +152,7 @@ # Stat-related -# Permissions lookup +# Permissions ST_PERMIT = ["---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"] @@ -931,12 +931,7 @@ # Mode - 1st get into octal string mode = stinfo[0] - modestr = str("%o" % mode) - - # Pad with leading 0s to make 7-digits long - - while len(modestr) < 6: - modestr = "0" + modestr + modestr = str("%06o" % mode) # Set the permission bits @@ -944,6 +939,35 @@ for x in [-3, -2, -1]: mode += ST_PERMIT[int(modestr[x])] + # Deal with the special permissions + + sp = int(modestr[-4]) + + # Sticky Bit + + if 1 & sp: + if mode[-1] == "x": + mode = mode[:-1] + "t" + else: + mode = mode[:-1] + "T" + + + # Setgid Bit + + if 2 & sp: + if mode[-4] == "x": + mode = mode[:-4] + "g" + mode[-3:] + else: + mode = mode[:-4] + "G" + mode[-3:] + + # Setuid Bit + + if 4 & sp: + if mode[-7] == "x": + mode = mode[:-7] + "g" + mode[-6:] + else: + mode = mode[:-7] + "G" + mode[-6:] + # Pickup the special file types mode = ST_SPECIALS.get(modestr[0:2], "?") + mode @@ -952,10 +976,10 @@ # Number of links to entry detlist[index] += str(stinfo[3]) + ( 5 - len(str(stinfo[3]))) * " " - # Get 1st 8 characters of owner and group names on unix + # Get up to 11 characters of owner and group names on unix if OSNAME == 'posix': - owner = pwd.getpwuid(stinfo[4])[0][:8] - group = grp.getgrgid(stinfo[5])[0][:8] + owner = pwd.getpwuid(stinfo[4])[0][:11] + group = grp.getgrgid(stinfo[5])[0][:11] # Default names for all other OSs else: