# Chirp User's Manual

February 2007

    Chirp is Copyright (C) 2003-2004 Douglas Thain and
    Copyright (C) 2005- The University of Notre Dame.
    All rights reserved.
    This software is distributed under the GNU General Public License.
    See the file COPYING for details.

Please use the following citation for Chirp in a scientific publication::
- Douglas Thain, Christopher Moretti, and Jeffrey Hemmes, Chirp: A Practical Global Filesystem for Cluster and Grid Computing, Journal of Grid Computing, Springer, 2008. DOI: 10.1007/s10723-008-9100-5. (The original is available on http://www.springerlink.com.)

## Overview

Chirp is a system for performing input and output across the Internet. Using Chirp, an ordinary user can share storage space and data with friends and colleagues without requiring any sort of administrator privileges anywhere.

Chirp is like a distributed filesystem (such as NFS) except that it can be run over wide area networks and requires no special privileges on either the client or the server end. Chirp allows the end user to set up fine-grained access control so that data can be shared (or not shared) with the right people.

Chirp is also like a file transfer system (such as FTP) that provides streaming point-to-point data transfer over the Internet. However, Chirp also provides fine-grained Unix-like data access suitable for direct access by ordinary programs.

Chirp also includes advanced features for space allocation and active storage. However, each of these features must be explicitly enabled, so you don't have to worry about them if all you want is simple storage access. Read on below for more details.

Begin by installing the cctools on your system. When you are ready, proceed below.

## Running a Chirp Server

Running a Chirp server is easy. You may run a Chirp server as any ordinary user, and you do not need to install the software or even run the programs as root. To run a Chirp server, you must do three things: pick a storage directory, run the server, and then adjust the access control.

1. Pick a storage directory. The Chirp server will only allow access to the directory that you choose. It could be a scratch directory, your home directory, or even your filesystem root. For now, let's store everything in a temporary directory:

       /tmp/mydata

2. Run the server. Simply run `chirp_server` and direct it to your storage directory:

       % chirp_server -r /tmp/mydata &

3. Adjust the access control. When first started, the Chirp server will allow access only to YOU from the same host. You will probably want to change this to allow access to other people and hosts. To adjust the access control, use the `chirp` tool and the `setacl` command to set the access control list. For example, to also allow other hosts in your domain to read and write the server:

       % chirp localhost
        chirp:localhost:/> setacl . hostname:*.mydomain.edu write

Now that you have a server running on one machine, let's use some tools to move data to and from your server.

## Accessing Chirp Servers

The easiest way to access Chirp servers is by using a tool called Parrot. Parrot is a personal virtual filesystem: it "speaks" remote I/O operations on behalf of ordinary programs. For example, you can use Parrot with your regular shell to list and access Chirp servers like so:

     % parrot tcsh
     % cd /chirp
     % ls
    angband.somewhere.edu:9094
    dustpuppy.somewhere.edu:9094
    peanuts.somewhere.edu:9094
    ...
     % cd /chirp/peanuts.somewhere.edu
     % cp /tmp/bigfile .
     % ls -la
    total 804
    drwx------    2 fred   users          4096 Sep 10 12:40 .
    drwx------    2 fred   users          4096 Sep 10 12:40 ..
    -rw-r--r--    1 fred   users      104857600 Sep 10 12:57 bigfile
    -rw-r--r--    1 fred   users           147 Sep 10 12:39 hosts
     % parrot_getacl
    unix:fred rwlda
    hostname:hedwig rl
    ...

(If you are having difficulting accessing your server, have a look at "debugging hints" below.)

Parrot is certainly the most convenient way to access storage, but it has some limitations: it only works on Linux, and it imposes some performance penalty.

You can also attach to Chirp filesystems by using the FUSE package to attach Chirp as a kernel filesystem module. Unlike Parrot, this requires superuser privileges to install the FUSE package, but will likely work more reliably on a larger number of programs. You can do this with either Linux FUSE or MacFuse. Once you have downloaded and installed FUSE, simply run `chirp_fuse` with the name of a directory on which the filesystem should be mounted. For example:

    % mkdir /tmp/chirp
    % chirp_fuse /tmp/chirp
    % cd /tmp/chirp
    % ls -la
    total 9742
    dr-xr-xr-x   0 fred users    6697 Feb 22 13:54 albus.cse.nd.edu:9094
    dr-xr-xr-x   0 fred users    6780 Feb 22 13:54 aluminum.helios.nd.edu:9094
    dr-xr-xr-x   0 fred users   27956 Feb 22 13:54 angband.cse.nd.edu:9094
    dr-xr-xr-x   0 fred users    6466 Feb 22 13:54 angelico.helios.nd.edu:9094
    ...

For more portable, explicit control of a Chirp server, use the Chirp command line tool. This allows you to connect to a server, copy files, and manage directories, much like an FTP client:

     % chirp
     ...
     chirp::> open myhost.somewhere.edu
     chirp:myhost.somewhere.edu:/> put /tmp/bigfile
    file /tmp/bigfile -> /bigfile (11.01 MB/s)
     chirp:myhost.somewhere.edu:/> ls -la
    dir      4096 .                                        Fri Sep 10 12:40:27 2004
    dir      4096 ..                                       Fri Sep 10 12:40:27 2004
    file      147 hosts                                    Fri Sep 10 12:39:54 2004
    file 104857600 bigfile                                 Fri Sep 10 12:53:21 2004
     chirp:myhost.somewhere.edu:/>

In scripts, you may find it easier to use the standalone commands `chirp_get` and `chirp_put`, which move single files to and from a Chirp server. These commands also allow for streaming data, which can be helpful in a shell pipeline. Also, the -f option to both commands allows you to follow a file, much like the Unix `tail` command:

     % tar cvzf archive.tar.gz ~/mydata
     % chirp_put archive.tar.gz myhost.somewhere.edu archive.tar.gz
     % ...
     % chirp_get myhost.somewhere.edu archive.tar.gz - | tar xvzf
     % ...
     % chirp_get -f myhost.somewhere.edu logfile - |& less
     %

You can also write programs that access the Chirp C interface directly. This interface is relatively self explanatory: programs written to use this library may perform explicit I/O operations in a manner very similar to Unix. For more information, see the HOWTO: Write Code that Uses Chirp

## Finding Chirp Servers

Now that you know how to run and use Chirp servers, you will need a way to keep track of all of the servers that are available for use. For this purpose, consult the Chirp storage catalog. This web page is a list of all known Chirp servers and their locations. Note that this same list appears if you use Parrot to perform an `ls` on `/chirp`

The storage catalog is highly dynamic. By default, each Chirp server makes itself known to the storage catalog every five minutes. The catalog server records and reports all Chirp servers that it knows about, but will discard servers that have not reported for fifteen minutes.

If you do not want your servers to report to a catalog, then run them with this option:

    % chirp_server -u -

Alternatively, you may establish your own catalog server. This can be useful for keeping your systems logically distinct from the main storage pool, but can also help performance and availability if your catalog is close to your Chirp servers. The catalog server is installed in the same place as the Chirp server. Simply run it on any machine that you like and then direct your Chirp servers to update the new catalog with the -u option. The catalog will be published via HTTP on port 9097 of the catalog machine.

For example, suppose that you wish to run a catalog server on a machine named `dopey` and a Chirp server on a machine named `sneezy`:

    dopey% catalog_server
    ...
    sneezy% chirp_server -u dopey [more options]

Finally, point your web browser to:

    http://dopey:9097

Or, set an environment variable and use Parrot:

    % setenv CATALOG_HOST dopey
    % parrot tcsh
    % ls /chirp

And you will see something like this. You may easily run multiple catalogs for either scalability or fault tolerance. Simply give each Chirp server multiple -u options to name each running catalog.

(Hint: If you want to ensure that your chirp and catalog servers run continuously and are automatically restarted after an upgrade, consider using Watchdog.)

## Security

Now that you have an idea how Chirp can be used, let's discuss security in more detail. Different sites require different levels of security and different technological methods of enforcing security. For these reasons, Chirp has a very flexible security system that allows for a range of tools and policies from simple address checks to Kerberos authentiation.

Security really has two aspects: authentication and authorization. Authentication deals with the question "Who are you?" Once your identity has been established, then authorization deals with the question "What are you allowed to do?" Let's deal with each in turn.

### Authentication

Chirp supports the following authentication schemes:

Type | Summary | Regular User? | Root?
|  | (non-root) | (root)
kerberos | Centralized private key system | no | yes (host cert)
globus | Distributed public key system | yes (user cert) | yes (host cert)
unix | Authenticate with local unix user ids. | yes | yes
hostname | Reverse DNS lookup | yes | yes
address | Identify by IP address | yes | yes

The Chirp tools will attempt all of the authentication types that are known and available in the order above until one works. For example, if you have Kerberos installed in your system, Chirp will try that first. If not, Chirp attempts the others.

Once an authentication scheme has succeeded, Chirp assigns the incoming user a subject that describes both the authentication method and the user name within that method. For example, a user that authenticates via Kerberos might have the subject:

        kerberos:dthain@nd.edu

A user authenticating with Globus credentials might be:
(Note that Chirp substitutes underscores for spaces.)

        globus:/O=Cooperative_Computing_Lab/CN=Douglas_L_Thain

While another user authenticating by local unix ids might be:

        unix:dthain

While a user authenticating by simple hostnames might be:

        hostname:pigwidgeon.cse.nd.edu

Take note that Chirp considers all of the subjects as different identities, although some of them might correspond to the same person in varying circumstances.

### Authorization

Once Chirp has authenticated your identity, you are logged into a server. However, when you attempt to read or manipulate files on a server, Chirp checks to see whether you are authorized to do so. This is determined by access control lists or ACLs.

Every directory in a Chirp server has an ACL, much like filesystems such as as AFS or NTFS. To see the ACL for a directory, use the Chirp tool and the `getacl` command:

     chirp:host.mydomain.edu:/> getacl
    unix:dthain rwlda
    hostname:*.mydomain.edu rwl

Or, if you are using Parrot, you can use `parrot_getacl` to examine ACLs in the same way:

    % parrot tcsh
    % cd /chirp/host.mydomain.edu
    % parrot_getacl
    unix:dthain rwlda
    hostname:*.mydomain.edu rwl

This ACL indicates that the subject `unix:dthain` has five access rights, while the subject pattern `hostname:*.mydomain.edu` has only three access rights. The access rights are as follows:

r | - The subject may read items in the directory.
w | - The subject may write items in the directory.
l | - The subject may list the directory contents.
d | - The subject may delete items in the directory.
p | - The subject may put new files into the directory.
a | - The subject may administer the directory, including changing the ACL.
x | - The subject may execute programs in the directory.
v | - The subject may reserve a directory.

Access rights often come in combinations, so there are a few aliases for your convenience:

read | - alias for rl
write | - alias for rwld
admin | - alias for rwlda
none | - delete the entry

To change an access control list on a directory, use the `setacl` command in the Chirp command line tool:

     chirp:host.mydomain.edu:/> setacl / kerberos:dthain@nd.edu write
     chirp:host.mydomain.edu:/> getacl
    unix:dthain rwlda
    hostname:*.mydomain.edu rwl
    kerberos:dthain@nd.edu rwld

Note that for subject names that contain spaces, you should simply substitute underscores. For example, if your subject name is `/O=Univ of Somewhere/CN=Fred Flint`, then you might issue a `setacl` command like this:

     chirp:host.mydomain.edu:/> setacl / /O=Univ_of_Somewhere/CN=Fred_Flint rwlda

Or, you can accomplish the same thing using `parrot_setacl` inside of Parrot:

    % parrot tcsh
    % cd /chirp/host.mydomain.edu
    % parrot_setacl . /O=Univ_of_Somewhere/CN=Fred_Flint rwlda

The meaning of ACLs is fairly obvious, but there are few subtleties you should know:

Rights are generally inherited. When a new directory is created, it automatically gets the ACL of its parent. Exception: read about the reserve right below.

Rights are generally not hierarchical. In order to access a directory, you only need the appropriate permissions on that directory. For example, if you have permission to write to `/data/x/y/z`, you do not need any other permissions on `/data`, `/data/x` and so forth. Of course, it may be difficult to discover a deep directory without rights on the parents, but you can still access it.

The delete right is absolute. If you have permission to delete a directory, then you are able to delete the entire subtree that it contains, regardless of any other ACLs underneath.

Note that it is possible to use Chirp to export an existing directory tree without manually populating every directory with ACLs. Simply create an ACL in an external file, and then use the -A option to tell the Chirp server to use that file as the default ACL.

## Reservation

The v - reserve right is an important concept that deserves its own discussion.

A shared-storage environment such as Chirp aims to allow many people to read and write common storage space. Of course, with many people reading and writing, we need some mechanism to make sure that everybody does not step on each other's toes.

The reserve right allows a user to create what is essentially a fresh workspace for their own use. When a user creates a new directory and has the v right (but not the w right), Chirp will create a new directory with a fresh ACL that gives the creating user restricted rights.

A good way to use the reserve right is with a wildcard at the top directory. Here's an example. Suppose that Fred creates a new Chirp server on the host `bigwig`. Initially, no-one except Fred can access the server. The first time it starts, the Chirp server initializes its root directory with the following ACL:

    unix:fred rwla

Now, Fred wants other users in his organization to be able to use this storage, but doesn't want them messing up his existing data. So, Fred uses the Chirp tool to give the list (l) and reserve (v) rights to anyone calling from any machine in his organization:

     chirp:bigwig:> setacl / hostname:*.somewhere.edu lv(rwlda)
     chirp:bigwig:> getacl /
    unix:fred rwlda
    hostname:*.somewhere.edu lv(rwlda)

Now, any user calling from anywhere in `somewhere.edu` can access this server. But, all that any user can do is issue `ls` or `mkdir` in the root directory. For example, suppose that Betty logs into this server from `ws1.somewhere.edu`. She can not modify the root directory, but she can create her own directory:

     chirp:bigwig:> mkdir /mydata

And, in the new directory, `ws1.somewhere.edu` can do anything, including edit the access control. Here is the new ACL for `/mydata`:

     chirp:bigwig:> getacl /mydata
    hostname:ws1.somewhere.edu rwlda

If Betty wants to authenticate with Globus credentials from here on, she can change the access control as follows:

     chirp:bigwig:> setacl /mydata globus:/O=Univ_of_Somewhere/CN=Betty rwla

And, the new acl will look as follows:

     chirp:bigwig:> getacl /mydata
    hostname:ws1.somewhere.edu rwlda
    globus:/O=Univ_of_Somewhere/CN=Betty rwla

## Notes on Authentication

Each of the authentication types has a few things you should know:

Kerberos: The server will attempt to use the Kerberos identity of the host it is run on. (i.e. host/coral.cs.wisc.edu@CS.WISC.EDU) Thus, it must be run as the superuser in order to access its certificates. Once authentication is complete, there is no need for the server to keep its root access, so it will change to any unprivileged user that you like. Use the `-i` option to select the userid.

Globus: The server and client will attempt to perform client authentication using the Grid Security Infrastructure (GSI)> Both sides will load either user or host credentials, depending on what is available. If the server is running as an ordinary user, then you must give a it a proxy certificate with grid-proxy-init. Or, the server can be run as root and will use host certificates in the usual place.

Unix: This method makes use of a challenge-response in the local Unix filesystem to determine the client's Unix identity. It assumes that both machines share the same conception of the user database and have a common directory which they can read and write. By default, the server will pick a filename in /tmp, and challenge the client to create that file. If it can, then the server will examine the owner of the file to determine the client's username. Naturally, /tmp will only be available to clients on the same machine. However, if a shared filesystem directory is available, give that to the chirp server via the -c option. Then, any authorized client of the filesystem can authenticate to the server. For example, at Notre Dame, we use -c /afs/nd.edu/user37/ccl/software/rendezvous to authenticate via our AFS distributed file system.

Hostname: The server will rely on a reverse DNS lookup to establish the fully-qualified hostname of the calling client. The second field gives the hostname to be accepted. It may contain an asterisk as a wildcard. The third field is ignored. The fourth field is then used to select an appropriate local username.

Address: Like "hostname" authentication, except the server simply looks at the client's IP address.

By default, Chirp and/or Parrot will attempt every authentication type knows until one succeeds. If you wish to restrict or re-order the authentication types used, give one or more -a options to the client, naming the authentication types to be used, in order. For example, to attempt only hostname and kerberos authentication, in that order:

       % chirp -a hostname -a kerberos

## Advanced Topic: Cluster Management

Several tools are available for managing a large cluster of Chirp servers.

First, a Java visual display applet gives a graphical view of all servers in a cluster, as well as active network connections between each client and server. This tool can be used to quickly view whether storage is free or used, whether CPUs are idle or busy, and whether the network is idle or in use. Clicking on individual nodes shows the same detailed data as is avaliable in the catalog page.

Next, it can be helpful to give a single 'superuser' limited access to all servers and directories in a cluster, allowing them to fix broken access controls and solve other problems. To allow this, the `-P user` argument can be given to a Chirp server, and will implicitly give the named user the L and A rights on any directory on that server.

When managing a large system with many users, it is important to keep track of what users are employing the cluster, and how much space they have consumed. We refer to this as auditing the cluster. To audit a single node, use the `audit` command of the Chirp tool. This produces a listing of all users of a single host. (You must have the `A` right in the root directory of the server to run this command.) For example:

    % chirp ccl01.cse.nd.edu audit
       FILES     DIRS      DATA OWNER
       82842       27    5.0 GB globus:/O=UnivNowhere/CN=Fred
        6153      607  503.4 MB unix:fred
           2        2  200.3 MB hostname:laptop.nowhere.edu
          12        2    3.9 MB unix:betty

To audit an entire cluster, run the `chirp_audit_cluster` tool. This will extract the current list of hosts from your catalog, run an audit on all hosts in parallel, and then produce several reports in text files: `audit.users.txt`, `audit.hosts.txt`, `audit.users.hosts.txt`, and `audit.hosts.users.txt`.

Often, users of a cluster will wish to replicate commonly used data across all disks in the system, perhaps to provide fast access to relatively static data. The `chirp_distribute` tool can be used to rapidly move data from one node to all others. Given a source host and path, `chirp_distribute` will create a spanning tree and then move data directly from host to host in parallel. This is much faster than running `cp` or `chirp put` directly. For example, this will copy the `/database` directory from host `server.nd.edu` to all hosts in your cluster:

    % chirp_distribute server.nd.edu /database `chirp_status -s`

Another common problem is cleaning up data that has been copied this way. To delete, simply run `chirp_distribute` again with the `-X` option and the same arguments.

## Advanced Topic: Space Management

When multiple users share a common storage space, there is the danger that one aggressive user can accidentally (or deliberately) consume all available storage and prevent other work from happening. Chirp has two mechanisms available to deal with this problem.

The simpler tool is just a free space limit. If run with the `-F` option, a Chirp server will stop consuming space when the free space on the disk falls below this limit. External users will see a "No space left on device." error. For example, `-F 100MB` will leave a minimum of 100MB free on the local disk. This mechanism imposes little or no performance penalty on the server.

The more complex tool is a user-level quota and allocation system. If run with the `-Q` option, a Chirp server will establish a software quota for all external users. That is, `-Q 2GB` will limit external users to consuming a total of 2 GB of storage within a single Chirp server. This mechanism imposes some run-time performance penalty, and also delays server startup somewhere: the Chirp server must traverse its storage directory to count up the available space.

With the `-Q` option enabled, external users can allocate space before consuming it. Using the Chirp tools, users may use the `mkalloc` command to create new directories with an attached space allocation. For example, `mkalloc /mydata 1GB` will create a new directory `/mydata` with an allocation of 1GB. This allocation is a limit that prevents files in that directory from consuming more than 1GB; it is also a guarantee that other users of the server will not be able to steal the space. Such allocations may also be subdivided by using `mkalloc` to create sub-directories.

Note: Users employing Parrot can also use the `parrot_mkalloc` and `parrot_lsalloc` commands in ordinary scripts to achieve the same effect.

To examine an allocation, use the `lsalloc` command.

To destroy an allocation, simply delete the corresponding directory.

## Advanced Topic: Active Storage

Using Parrot and Chirp, it is easy to run programs that access data remotely over the network. In essence, the data mvoes to wherever the program is executed. However, when the program to the run is smaller than the data to be processed, it makes more sense to send the program to the data. This concept is called active storage.

By default, a Chirp server allows only for data storage. Active storage must be manually enabled through two distinct steps:

- The server must be started with the -X option. Programs cannot be executed without the overall permission of the server owner.
- The X right must be set in the directory containing the program to be run. Programs cannot be executed unless a user is able to also gain the X right.

  To execute a program remotely, create a fresh directory, ensure that you have the X right on the directory, and transfer in a program. Use the `job_run` command from the Chirp tool to run that program. By default, Chirp will store the outputs in `stdout.txt` and `stderr.txt` in the current working directory, and then fetch them when the job completes.

  As a very simple example, suppose that you want to sort some data stored in `/chirp/server.nd.edu/data/records.txt`. Using the Chirp tool, set the X right, send the `sort` binary, and then execute it:

      % chirp server.nd.edu
      connected to server.nd.edu:9094 as unix:fred
      chirp:server.nd.edu> setacl . unix:fred rwlax
      chirp:server.nd.edu> put /bin/sort
      chirp:server.nd.edu> job_run sort -n records.txt >sorted.txt
      jobid 33 created
      jobid 33 submitted.
      jobid 33 completed with exit code 1
      jobid 33 removed.

  Now, the sorted records are found in sorted.txt. You could extract the data for further manipulation, or you could simply dispatch further programs like `grep` to sort it:

      chirp:server.nd.edu> put /bin/grep
      chirp:server.nd.edu> job_run grep needle sorted.txt

  If you have long-running jobs, you may disconnect from the Chirp server, and use the `job_list` command to see the current state of the job. Using the unique job number created when it was submitted, you may use `job_wait` to wait for completion, or `job_kill` to stop a long running job. `job_remove` should be used to remove the record of a completed or killed job.

  The Chirp security model allows for many flexible policies on what programs may be run. The owner of a server can allow a user to run and execute arbitrary code on a server by granting the W and X rights on a directory. If the owner wants to restrict the runnable programs, he/she may provide a directory of programs with only the R and X bits set. This allows users to execute only those programs provided. By constructing ACLs appropriately, various classes of users may be given different policies.

  Note that the same security model is used for both data access as remote execution. Internally, Chirp uses Parrot to run the program in an identity box that ensures it can only access files according to the ACLs as described above. If you were to dispatch the program `whoami` to the remote node, you would see the same identity you used to authenticate to the Chirp server. Thus, it is not necessary for any special accounts to be created for visiting users.

  ## Advanced Topic: Ticket Authentication

  Often a user will want to access a Chirp server storing files for cluster computing jobs but will have difficulty accessing it securely without transferring their credentials with the jobs dispatched to the cluster. To facilitate ease-of-use, users typically solve this by giving rights to a hostname mask (e.g. *.cse.nd.edu) on the Chirp server. However, this level of access can be innappropriate due to sensitive data. Instead, these users are forced to use difficult authentication methods such as Globus or Kerberos for running the Chirp server. They may also use a virtual network solution but users typically lack this amount of control on clusters. To provide an easy solution to this problem, Chirp offers its own ticket based authentication system which is convenient and simple to setup.

  To start, users may create a ticket for authentication using:

  `chirp <host:port> ticket_create -output myticket.ticket -subject unix:user -bits 1024 -duration 86400 / rl /foo rwl`

  This command performs multiple tasks in three stages:

  First, it creates a ticket which is composed of an RSA Private Key with a key (modulus) size of 1024 bits. When we refer to the ticket, we are speaking of this Private Key. By default, the ticket file generated is named ticket.MD5SUM where MD5SUM is the MD5 digest of the Public Key of the ticket.

  Once the ticket is created, it is registered with the Chirp server with a validity period in seconds defined by the duration option (86400, or a day). The `-subject unix:user` switch allows the user to set the ticket for another user; however, only the chirp_server superuser (-P) may set tickets for any subject. For regular users, the -subject option is unnecessary as it is by default the subject you possess when registering the ticket. Users who authenticate using this ticket in the future will become this subject with certain masked rights.

  Once the ticket is created and registered, we give the ticket a set of ACL masks. The ACL mask will mask the rights of the ticket-authenticated user with the rights of the subject that registered the ticket. For example, if a user named foo (subject is `unix:foo`) has rights rwl in the root directory of the Chirp server and if a ticket is registered for foo with the ACL mask `/ rlx`, the effective rights of the ticket-authenticated user is rl in the root directory.

  ACL masks are also inherited from parent directories. So, in the above example, the root directory has the ACL mask rl while the foo directory has the ACL mask rwl. Other nested directories within the root directory also inherit the rl mask. Similarly, nested directories of the foo directory inherit the rwl mask. We emphasize that the ACL mask does not give rights but limits them. If the user that registers a ticket has no rights in a directory, then neither will the ticket authenticated user.

  ### Authenticating with a ticket

  To authenticate using a ticket, it can be as simple as including the ticket file with your job. Tickets that follow the ticket.MD5SUM template are automatically added to the list of tickets to try when authenticating. You can also give specific tickets to authenticate with using a comma-delimited list of ticket filenames in either the CHIRP_CLIENT_TICKETS environment variable or via the -k option. Tickets are tried in the order they are specified.

  `chirp <host:port>`

  The above command will try ticket authentication as a last resort but will use tickets it finds in the current directory following the template.

  `chirp -a ticket -k file.ticket <host:port>`

  The above command forces ticket authentication and only uses the file.ticket ticket to authenticate.

  Authenticating is this simple. It is important to note that tickets are obviously not protected in any way from theft when you distribute the ticket with jobs in a distributed computing environment (no ticket system can give this guarantee). Users may want to protect their tickets in basic ways by setting a restrictive file mode and by giving tickets a limited duration on the server.

  Finally, users should be careful to experiment with small key sizes for a balance of quick authentication and security. Smaller key sizes may be rejected outright by openssl when given a 64 byte challenge to sign. Chirp will not authenticate or use smaller challenge sizes if openssl rejects the ticket.

  ### Manually Registering a Ticket

  A ticket is only useful when registered with a server. The ticket_create command does this for you automatically but you may also wish to register the ticket with multiple servers. To do this, you can manually register a ticket that is already created by using the `ticket_register` command:

  `chirp <host:port> ticket_register myticket.ticket unix:user 86400`

  The first argument to `ticket_register` is the name of the ticket, followed by the subject, and finally the ticket duration. The second option (the subject) is optional. As described earlier, specifying the subject allows you to register a ticket with a user other than yourself. This is only possible if you are authenticated with the server as the super user.

  ### Modifying the Rights of a Ticket

  You may use the `ticket_modify` command to change the rights a ticket has in a directory. You are restricted to giving rights to a ticket you already possess. Recall, however, that the rights are actually a mask that are logically ANDed with the rights the user has at the time.

  `chirp <host:port> ticket_modify myticket.ticket / rl`

  The above command changes the ACL mask of `myticket.ticket` to `rl` in the root directory.

  A ticket identifier as returned by `ticket_list` may also be used instead of a ticket filename.

  ### Deleting a Ticket

  Deleting a ticket unregisters the ticket with the server. Additionally, the ticket on the client is deleted.

  `chirp <host:port> ticket_delete myticket.ticket`

  A ticket identifier as returned by `ticket_list` may also be used instead of a ticket filename.

  ### Listing the Registered Tickets on the Server

  To list the tickets registered on a server, use the `ticket_list` command:

  `chirp <host:port> ticket_list unix:user`

  The subject argument instructs the command to fetch all the tickets belonging to the user. You may also use `ticket_list all` to list all the tickets of all users on the server. The latter command is only executable by the Chirp super user. The output is a list of tickets identifiers. You can query information about a ticket using these identifiers with the `ticket_get` command.

  ### Getting a Registered Ticket's Information from the Server

  To check the status of a ticket on a server, you may use the `ticket_get` command:

  `chirp <host:port> ticket_get myticket.ticket`

  So long as you own the ticket or are authenticated as the super user, the server will return to you information associated with the ticket. The ticket must also exist and must also not have expired. `ticket_get` takes a client side ticket filename as an argument or a ticket identifier as returned by the `ticket_list` command.

  `ticket_get` prints the subject that owns the ticket, the base64 encoded public key of the ticket, the time left until the ticket expires in seconds, and a variable number of directory and ACL masks. For example, we might have the following output:

      $ chirp host:port ticket_get myticket.ticket
      unix:pdonnel3
      LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0Jp
      UUtCZ1FEZVoyZWxKYXdlcHBHK0J4SFlaMmlmWFIzNAovU3RhUElta0lmeit4TDZxN21wS2lnMDJQZ2Z5
      emdKRWFjMk50NzJrUlBpOEJWYWdkOHdvSGhWc25YZ1YvNjFPCjVkaG13STNLYWRlYjNUbkZXUUo3bFhh
      anhmVTZZR1hXb2VNY1BsdjVQUWloWm8yWmFXTUUvQVA4WUtnVVphdXcKelI2RkdZWGd6N2RGZzR6Yk9R
      SURBUUFCCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
      5993
      / rl
      /foo rwl

  Note that the base64 encoded public key above is wrapped to fit an 80 character width. All of the information is new-line-delimited.

  ## Advanced Topic: HDFS Backend Storage for Chirp

  The Chirp server is able to bind to backend filesystems besides the local filesystem. In particular, it is able to act as a frontend for the Hadoop HDFS filesystem. When used on top of Hadoop, Chirp gives you the benefit of a robust system of ACLs, simple userspace access and POSIX semantics (with some limitations, discussed below). Perhaps best of all, client jobs will no longer have any Hadoop or Java (version) dependencies.

  `chirp_server` takes two new options to support HDFS: `-f hdfs` to switch to an HDFS backend instead of local storage and `-x host:port` to set the Hadoop head node.

  To run a Chirp server as a frontend to Hadoop use the `chirp_server_hdfs` command. It acts as a wrapper around the `chirp_server` command to setup environment variables for Hadoop on behalf of the user. `chirp_server_hdfs` also adds the `-f hdfs` for you when invoking `chirp_server`.

  Just like when running Chirp on the local filesystem, you must pick a root storage directory for the server. The root for the server in this case will (naturally) be located in HDFS. For the `chirp_server_hdfs` command, you need only give the location of the HDFS head node. You run the server like so:

      % chirp_server_hdfs -x headnode.hadoop.domain.edu -r /mydata

  After setting up the environment variables, this command expands to:

      % chirp_server -f hdfs -x headnode.hadoop.domain.edu -r /mydata

  ### Temporary Local Storage

  Chirp allows you to setup a location to place temporary files such as those used for Active Storage jobs. You can set this using the `-y path` option. This allows for faster access, POSIX semantics, and less load on HDFS. By default, Chirp assumes the current directory for temporary storage.

  ### Limitations

  Chirp tries to preserve POSIX filesystem semantics where possible despite HDFS violating certain assumptions. For example, random writes are not possible for Chirp on HDFS. When the user requests to open a file for writing, Chirp assumes an implicit `O_APPEND` flag was added. In addition, HDFS does not maintain an execute permission bit for regular files. Chirp assumes all files have the execute bit set.

  Chirp also does not allow using the thirdput command or user space management (`-F`) when using HDFS as a backend.

  ## Debugging Advice

  Debugging a distributed system can be quite difficult because of the sheer number of hosts involved and the mass of information to be collected. If you are having difficulty with Chirp, we recommend that you make good use of the debugging traces built into the tools.

  In all of the Chirp and Parrot tools, the `-d` option allows you to turn on selected debugging messages. The simplest option is `-d all` which will show every event that occurs in the system.

  To best debug a problem, we recommend that you turn on the debugging options on both the client and server that you are operating. For example, if you are having trouble getting Parrot to connect to a Chirp server, then run both as follows:

      % chirp_server -d all [more options] ...
      % parrot -d all tcsh

  Of course, this is likely to show way more information than you will be able to process. Instead, turn on a debugging flags selectively. For example, if you are having a problem with authentication, just show those messages with `-d auth` on both sides.

  There are a large number of debugging flags. Currently, the choices are: syscall notice channel process resolve libcall tcp dns auth local http ftp nest chirp dcap rfio cache poll remote summary debug time pid all. When debugging problems with Chirp and Parrot, we recommend selectively using `-d chirp`, `-d tcp`, `-d auth`, and `-d libcall` as needed.