This function takes an account name and checks to see if
the user has a top-level directory of the correct name
(see Section 3.3.5, “WEB_DIR”) that is world-readable
and world-executable. (A former version of this program
looked for a variety of homepage names, but the current
Apache configuration will show a listing of the directory
if there are no files whose names are considered
homepages, so there is no point in looking at the
contents of the directory.)
# - - - h a s H o m e p a g e - - -
def hasHomepage ( uid ):
"""Does this user have an HTML directory?
[ uid is a string ->
if uid is the account name of a user who has a
homepage directory ->
return 1
else ->
return 0 ]
"""
For a user account , their home directory is at path “N/u/”, and
their HTML directory must be a first-level directory
whose name is given by Section 3.3.5, “NWEB_DIR”.
#-- 1 --
# [ webPath := absolute path to the HTML directory for user
# uid ]
webPath = "/u/%s/%s/" % (uid, WEB_DIR)
#-- 2 --
# [ if webPath names an existing path ->
# mode := permissions word (mode bits) for webPath
# else -> return 0 ]
try:
statusTuple = os.stat ( webPath )
mode = statusTuple [ stat.ST_MODE ]
except OSError:
return 0
#-- 3 --
# [ if mode has world read and world execute bits both set ->
# return 1
# else ->
# return 0 ]
return bool ( (mode & stat.S_IROTH) and
(mode & stat.S_IXOTH) )