Hecate - Web Authoring Assistance

Hecate is a tool that allows a sponsor to access his sponsored accounts' web pages and perform various other functions. It works similar to "su" in that a shell can be invoked running under your sponsored account's UID.

Hecate was originally designed to support the SimpleSite project that allows professors and TAs to manage the web pages associated with their course accounts.

The name Hecate comes from Greek mythology. "She who works from afar"; Goddess of sorcery and witchcraft; abstractly symbolized by the crossroads--spacial or temporal meeting/travelling points; dwells in the Underworld (C&C, obviously!)

Also known as Trivia by the Romans (tri = 3, via = roads), after the crossroads symbol, and redefined as "inconsequential, ordinary, common-place."

Basic Syntax

The basic syntax of the Hecate utility is:

The -a option specifies the initial acting UW NetID. See the ActAs directive below.

The alternate user parameter, -u allows the SimpleSite web interface to act on behalf of its REMOTE_USER's identity. There is a list of accounts that hecate will trust in the file:

Normally a set of directives are read from stdin and responses are sent to stdout. Alternate file descriptors can be specified with the -i and -o parameters. You can only specify file descriptors that are already open with these options. In addition to increasing the raw power of the utility, this limitation, er... feature, simplifies the security requirements (running setuid as "root", I don't need to worry about whether the user is permitted to create/read a file -- it gets opened/created before I start).

It's expected that hecate will be invoked by another utility or web CGI script that will feed it commands and interpret the results. That utility will likely want to open a couple of pipes to be used for hecate's input and output, reserving stdin and stdout for the commands that hecate invokes with its run directive.

The -v option can be used to get a copy of the input directives echoed to the output. Useful if input is read from a file. For example:

Input and Output Format

Directives to hecate are supplied on the input file in the form:

The optional sequence number can be specified to associate responses with individual input directives. Most responses to commands will appear in the output stream in the form:

The numerical value of the response code indicates whether the command succeeded or failed and why. The specific error codes can be found in the file /tulsa/include/gb.h, but in general follow the convention:

In addition to the numerical response code, the ACK will be replace with NAK for response codes greater than 299 or CON for response codes less than 200.

If the -v option is specified on the hecate command line, input directives will appear on the output stream as:

Input Directives

The following directives are supported by the hecate utility:

ActAs UWNetID
The ActAs directive allows you to switch to one of your sponsored UW NetIDs. Subsequent commands will operate on or execute as the specified UW NetID which is referred to below as the acting UW Netid. The initial acting UW NetID can be specified with the -a option on the hecate command line. If so specified, hecate will treat that option as if there was an ActAs uwnetid command at the start of the input with a sequence number of 1000. Any errors to that command will appear on the output stream, but a successful result will not be reported (unless -v was also specified in which case both the command and the successful response will appear).

Help [Keyword]
The Help directive displays the command list and the list of supported keywords for additional information.

List Affiliations [UWNetID]
The List Affiliations directive will generate a list of all of the affiliations associated with the indicated NetID. If the NetID is specified it becomes the new acting UW NetID. If not specified, the current acting UW NetID is used. The response from the list directive is a set of 4-tuples showing: UW NetID, Integer Source, Integer Category, and Text Source and Category. The Help Sources and Help Categories commands will list all the possible source and categories codes.

List Validations
The List Validations directive will generate a list of all of your sponsored validations. The response from the list directive is a set of 3-tuples showing: UW NetID, Validation ID, and Comment. The UW NetID field will be NONE if a UW NetID has not yet been established for that validation.

List WebTypes [UWNetID]
The List WebTypes directive will generate a list of all of the web types associated with the indicated NetID. The response from the list directive is a set of 3-tuples showing: UW NetID, Hex Webtypes, and Text Webtypes. The Help Webtypes command will list all the possible web types and their hexidecimal values.

Run command parameters
The Run directive will execute the specified command under the UID of the acting UW NetID. The command syntax follows the Bourne Shell rules, actually it is executed as:

The invoked command's stdin, stdout and stderr (file descriptors 0, 1, and 2) are the same as those for the hecate command. In addition to those descriptors, file descriptor 3 is directed back to hecate's output stream. Each line of text written to this by the invoked command will be packaged up in the standard way. Thus, the directive:

Would produce the output:

When the command runs, it has at its disposal two environment variables, PUBLIC_HTML and PUBLIC_MEDIA that point to the active UW NetID's directories if they exist. If the active UW NetID is not subscribed to the staff (faculty, courses, or departmental) web publishing service, the student web publishing directory is used. The current working directory will be set to the PUBLIC_HTML directory.

If the executed command exits with a status of zero, the response code will be 202: GB_E_COKAY, for "Child okay". If the exit status is nonzero or the process was terminated by a signal the response code will be 404: CB_E_CEXIT, or 405: CB_E_CSIGNAL.

Status Service
The Status directive will return the status of the acting UW NetID's subscription to the specified service. The numeric service code as defined in Shuksan is required. Any service code between 1 and 255 can be specified (contrast Subscribe below). Possible responses are:

Subscribe [web] Service
The Subscribe directive will attempt to subscribe the acting UW NetID to the specified numeric service code. Only a subset of the valid Shuksan service codes are allowed. The Help directive will produce a list of the currently supported service codes. At the writing of this document, the following service codes were supported:

The optional web parameter gets the response formatted with html tags suitable to be inserted into a web page. The response from the Mango server for the subscribe request is written to the output file descriptor between two normally formatted responses as in:

This is one of the places where the output file will contain lines that are not formatted in the normal ACK/NAK/CON style.

Example Session

The following example session was performed on the cat02 system to demonstrate the root account acting as the krl account to access one of krl's sponsored UW NetIDs, ktest17.

#cat02> whoami
root
#cat02> id
uid=0(root) gid=0(system) groups=0(system),5(tty),6(kmem),30(user),31(guest)
#cat02> cat input_file
1001 status 20
1002 status 115
1003 subscribe 7
1004 run /bin/sh
#cat02> hecate -vi3o6ua krl ktest17 3<input_file 6>output_file
sh-2.04$ id
uid=126311 gid=30(user) groups=30(user)
sh-2.04$ printenv
PWD=/nfs/aesop01/hw10/d28/ktest17
HOSTNAME=cat02
PUBLIC_HTML=/hw10/d28/ktest17
MACHTYPE=i686-pc-linux-gnu
PUBLIC_MEDIA=NONE
SHLVL=2
SHELL=/bin/sh
HOSTTYPE=i686
OSTYPE=linux-gnu
TERM=dumb
PATH=/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.
_=/usr/bin/printenv
sh-2.04$ ls -l
total 4
-rw-r-----   1 126311   www           220 Aug  9 16:46 index.html
sh-2.04$ cat index.html
<HTML>
<HEAD>
<TITLE>K. Lowe's Home Page</TITLE>
</HEAD>
<IMG ALIGN=LEFT SRC="/icons/construct.gif">
<P>This is the home page for ktest17
&LT;<A HREF="mailto:ktest17@u.washington.edu">K. Lowe</A>&GT;.
</P>
<HR>
</BODY>
</HTML>
sh-2.04$ echo "The quick brown fox jumps over the lazy dog" 1>&3
sh-2.04$ exit 13
exit
#cat02> cat output_file
000 INP 1000 ActAs ktest17
200 ACK 1000 Acting as ktest17
000 INP 1001 status 20
211 ACK 1001 Active
000 INP 1002 status 115
212 ACK 1002 Denied
000 INP 1003 subscribe 7
504 ACK 1003 Failed: Not permitted for service
000 INP 1004 run /bin/sh
101 CON 1004 The quick brown fox jumps over the lazy dog
404 NAK 1004 Exit 13


Ken Lowe
Email -- ken@u.washington.edu
Web -- http://staff.washington.edu/krl/