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