import errno
import wizard
-from wizard import shell, util
+from wizard import shell, util, user
def deploy_web(dir):
# try the directory
except shell.CallError:
pass
return None
+
+def user_email(name):
+ # XXX: simplistic strategy which doesn't work most of the time
+ return "%s@scripts.mit.edu" % name
+
+def user_operator():
+ """
+ Returns username of the person operating this script based
+ off of the :envvar:`SSH_GSSAPI_NAME` environment variable.
+
+ .. note::
+
+ :envvar:`SSH_GSSAPI_NAME` is not set by a vanilla OpenSSH
+ distributions. Scripts servers are patched to support this
+ environment variable.
+ """
+ principal = os.getenv("SSH_GSSAPI_NAME")
+ if not principal:
+ return None
+ instance, _, _ = principal.partition("@")
+ if instance.endswith("/root"):
+ username, _, _ = principal.partition("/")
+ else:
+ username = instance
+ return username
+
+def user_passwd(dir, uid):
+ # XXX: simplistic heuristic for detecting AFS. The correct thing to
+ # is either to statfs and match magic number, use one of the
+ # vos tools or check mounted directories.
+ if not dir.startswith("/afs/"):
+ return None
+ try:
+ result = shell.eval("hesinfo %d uid", uid)
+ except shell.CallError:
+ return None
+ name, password, uid, gid, gecos, homedir, shell = result.split(":")
+ realname = gecos.split(",")[0]
+ return user.Info(name, uid, gid, realname, homedir, shell)