| 1 |
<html> |
| 2 |
<body> |
| 3 |
|
| 4 |
<h2><a href="cvm.html">CVM</a></h2> |
| 5 |
|
| 6 |
<h1>CVM Version 2 Client Library</h1> |
| 7 |
|
| 8 |
<p>The CVM version 2 client library defines the following functions:</p> |
| 9 |
|
| 10 |
<dl> |
| 11 |
|
| 12 |
<dt><tt>int cvm_client_authenticate(const char* module, unsigned count, |
| 13 |
struct cvm_credential* credentials)</tt> <dd><p>This is the main entry |
| 14 |
point to the library. Set up the credentials as an array and call |
| 15 |
<tt>cvm_client_authenticate</tt>. The credentials must contain a |
| 16 |
<tt>CVM_CRED_ACCOUNT</tt> entry. The function will return 0 if |
| 17 |
authentication succeeded and an <a href="errors.html">error code</a> |
| 18 |
otherwise. The credentials have the following structure: <pre>struct |
| 19 |
cvm_credential { unsigned type; str value; }</pre></p> |
| 20 |
|
| 21 |
<p>If <tt>$CVM_LOOKUP_SECRET</tt> is set, and no |
| 22 |
<tt>CVM_CRED_SECRET</tt> credential is present in the |
| 23 |
<tt>credentials</tt>, its value is added to the set of outgoing |
| 24 |
credentials automatically to assist with the workings of lookup |
| 25 |
modules.</p> |
| 26 |
|
| 27 |
<p>If authentication succeeds, this routine automatically retrieves |
| 28 |
<tt>cvm_fact_username</tt>, <tt>cvm_fact_userid</tt>, |
| 29 |
<tt>cvm_fact_groupid</tt>, <tt>cvm_fact_directory</tt>, and |
| 30 |
<tt>cvm_fact_shell</tt>. <tt>cvm_fact_realname</tt>, |
| 31 |
<tt>cvm_fact_groupname</tt>, <tt>cvm_fact_sys_username</tt>, |
| 32 |
<tt>cvm_fact_sys_directory</tt>, and <tt>cvm_fact_domain</tt> are also |
| 33 |
set if they were present in the results.</p> |
| 34 |
|
| 35 |
<p>The client should change directory to the named home directory and |
| 36 |
drop root priviledges as soon as possible after successful |
| 37 |
authentication. Where reasonable, the client should also chroot to |
| 38 |
the directory for added protection.</p> |
| 39 |
|
| 40 |
<p>A random tag is added to the transmitted data to prevent spoofing |
| 41 |
when a remote module is being contacted (UDP mode). Its size is set |
| 42 |
by <tt>$CVM_RANDOM_BYTES</tt>, and defaults to 8 bytes.</p> |
| 43 |
|
| 44 |
<dt><tt>int cvm_client_split_account(str* account, str* domain)</tt> |
| 45 |
<dd><p>This function splits a domain name, if present, from of the |
| 46 |
account name. It searches for the last instance of any character from |
| 47 |
<tt>cvm_client_account_split_chars</tt> in <tt>account</tt>. If found, |
| 48 |
<tt>domain</tt> is replaced with the portion of <tt>account</tt> |
| 49 |
following that character, and <tt>account</tt> is truncated before that |
| 50 |
character. <tt>cvm_client_account_split_chars</tt> defaults to |
| 51 |
"<tt>@</tt>", which may be overridden by either setting it to a |
| 52 |
different string from the client program or by setting the |
| 53 |
<tt>$CVM_ACCOUNT_SPLIT_CHARS</tt> environment variable. Setting it to |
| 54 |
an empty string will effectively prevent parsing of the account |
| 55 |
name.</p> |
| 56 |
|
| 57 |
<dt><tt>int cvm_client_authenticate_password(const char* module, const |
| 58 |
char* account, const char* domain, const char* password, int |
| 59 |
split_account)</tt> <dd><p>This is a convenience wrapper function for |
| 60 |
the <tt>cvm_authenticate</tt> and <tt>cvm_split_account</tt> functions. |
| 61 |
The <tt>domain</tt> and <tt>password</tt> credentials are only sent if |
| 62 |
they are not <tt>NULL</tt> and not empty.</p> |
| 63 |
|
| 64 |
<dt><tt>int cvm_client_fact_str(unsigned number, const char** data)</tt> |
| 65 |
<dd><p>Retrieves a <a href="facts.html">fact</a> from the data returned |
| 66 |
by the module as a NUL-terminated string. Returns zero if the fact was |
| 67 |
present, and <tt>CVME_NOFACT</tt> otherwise. Successive calls to this |
| 68 |
function with the same <tt>number</tt> return subsequent facts if more |
| 69 |
than one instance of the fact was present.</p> |
| 70 |
|
| 71 |
<dt><tt>int cvm_client_fact_uint(unsigned number, unsigned long* |
| 72 |
data)</tt> <dd><p>Retrieves a <a href="facts.html">fact</a> from the |
| 73 |
data returned by the module as an unsigned integer. Returns zero if the |
| 74 |
fact was present and was an unsigned integer. Returns |
| 75 |
<tt>CVME_BAD_MODDATA</tt> if the fact was present but was not an |
| 76 |
unsigned integer. Successive calls to this function with the same |
| 77 |
<tt>number</tt> return subsequent facts if more than one instance of the |
| 78 |
fact was present.</p> |
| 79 |
|
| 80 |
<dt><tt>const char* cvm_client_ucspi_domain(void)</tt> <dd><p>Retrieves |
| 81 |
the UCSPI local domain from the environment variable named |
| 82 |
<tt>${PROTO}LOCALHOST</tt>. Use this as the <tt>domain</tt> paramenter |
| 83 |
to <tt>cvm_authenticate</tt> in all UCSPI servers that have no other |
| 84 |
means of determining the domain name.</p> |
| 85 |
|
| 86 |
<dt><tt>int cvm_client_setenv(void)</tt> <dd><p>Exports the following |
| 87 |
environment variables based on their associated CVM fact. If the fact |
| 88 |
was optional and was not present in the results from the module, the |
| 89 |
environment variable will not be set or unset.</p> |
| 90 |
|
| 91 |
<table border=1> |
| 92 |
|
| 93 |
<tr> <th>Variable</th> <th>CVM Fact</th> </tr> |
| 94 |
|
| 95 |
<tr> <td><tt>USER</tt></td> <td><tt>CVM_FACT_USERNAME</tt></td> </tr> |
| 96 |
|
| 97 |
<tr> <td><tt>UID</tt></td> <td><tt>CVM_FACT_USERID</tt></td> </tr> |
| 98 |
|
| 99 |
<tr> <td><tt>GID</tt></td> <td><tt>CVM_FACT_GROUPID</tt></td> </tr> |
| 100 |
|
| 101 |
<tr> <td><tt>NAME</tt></td> <td><tt>CVM_FACT_REALNAME</tt></td> </tr> |
| 102 |
|
| 103 |
<tr> <td><tt>HOME</tt></td> <td><tt>CVM_FACT_DIRECTORY</tt></td> </tr> |
| 104 |
|
| 105 |
<tr> <td><tt>SHELL</tt></td> <td><tt>CVM_FACT_SHELL</tt></td> </tr> |
| 106 |
|
| 107 |
<tr> <td><tt>GROUP</tt></td> <td><tt>CVM_FACT_GROUPNAME</tt></td> </tr> |
| 108 |
|
| 109 |
<tr> <td><tt>DOMAIN</tt></td> <td><tt>CVM_FACT_DOMAIN</tt></td> </tr> |
| 110 |
|
| 111 |
<tr> <td><tt>MAIL</tt></td> <td><tt>CVM_FACT_MAILBOX</tt></td> </tr> |
| 112 |
|
| 113 |
<tr> <td><tt>MAILBOX</tt></td> <td><tt>CVM_FACT_MAILBOX</tt></td> </tr> |
| 114 |
|
| 115 |
<tr> <td><tt>MAILDIR</tt></td> <td><tt>CVM_FACT_MAILBOX</tt></td> </tr> |
| 116 |
|
| 117 |
</table> |
| 118 |
|
| 119 |
<dt><tt>int cvm_client_setugid(void)</tt> <dd><p>Calls <tt>chdir</tt>, |
| 120 |
<tt>setgid</tt> and <tt>setuid</tt> with appropriate values based on the |
| 121 |
data returned from the authentication. Returns zero if any of the calls |
| 122 |
failed.</p> |
| 123 |
|
| 124 |
</dl> |
| 125 |
|
| 126 |
</body> |
| 127 |
</html> |
| 128 |
|