diff options
author | Steve Dickson <steved@redhat.com> | 2015-04-29 15:14:54 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2015-04-30 08:35:04 -0400 |
commit | 3b6edd428fcf952b893a5b7cc298cb91613a054e (patch) | |
tree | b18af42ff6ff98ec3d4d9e7c0307ecdf9e4ac573 | |
parent | ddf99776a7a9b10d17f7cdaa8a6c15f26815c5f1 (diff) | |
download | ti-rpc-3b6edd428fcf952b893a5b7cc298cb91613a054e.tar.gz |
Makefile.am: Removed unsupported c-fileslibtirpc-0-2-6-rc4
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/getpublickey.c | 168 | ||||
-rw-r--r-- | src/key_call.c | 446 | ||||
-rw-r--r-- | src/key_prot_xdr.c | 170 | ||||
-rw-r--r-- | src/netname.c | 143 | ||||
-rw-r--r-- | src/netnamer.c | 320 | ||||
-rw-r--r-- | src/rpcdname.c | 72 | ||||
-rw-r--r-- | src/rtime.c | 153 |
8 files changed, 0 insertions, 1477 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index af0e42f..f5c99e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,10 +71,5 @@ if AUTHDES endif -## libtirpc_a_SOURCES += key_call.c key_prot_xdr.c getpublickey.c -## libtirpc_a_SOURCES += netname.c netnamer.c rpcdname.c \ -## libtirpc_a_SOURCES += rtime.c \ -## auth_time.c auth_des.c authdes_prot.c - CLEANFILES = cscope.* *~ DISTCLEANFILES = Makefile.in diff --git a/src/getpublickey.c b/src/getpublickey.c deleted file mode 100644 index 764a5f9..0000000 --- a/src/getpublickey.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * publickey.c - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -/* - * Public key lookup routines - */ -#include <stdio.h> -#include <pwd.h> -#include <rpc/rpc.h> -#include <rpc/key_prot.h> -#include <rpcsvc/yp_prot.h> -#include <rpcsvc/ypclnt.h> -#include <string.h> -#include <stdlib.h> - -#include "debug.h" - -#define PKFILE "/etc/publickey" - -/* - * Hack to let ypserv/rpc.nisd use AUTH_DES. - */ -int (*__getpublickey_LOCAL)() = 0; - -/* - * Get somebody's public key - */ -int -__getpublickey_real(netname, publickey) - char *netname; - char *publickey; -{ - char lookup[3 * HEXKEYBYTES]; - char *p; - - if (publickey == NULL) - return (0); - if (!getpublicandprivatekey(netname, lookup)) - return (0); - p = strchr(lookup, ':'); - if (p == NULL) { - return (0); - } - *p = '\0'; - (void) strncpy(publickey, lookup, HEXKEYBYTES); - publickey[HEXKEYBYTES] = '\0'; - return (1); -} - -/* - * reads the file /etc/publickey looking for a + to optionally go to the - * yellow pages - */ - -int -getpublicandprivatekey(key, ret) - char *key; - char *ret; -{ - char buf[1024]; /* big enough */ - char *res; - FILE *fd; - char *mkey; - char *mval; - - fd = fopen(PKFILE, "r"); - if (fd == NULL) - return (0); - for (;;) { - res = fgets(buf, sizeof(buf), fd); - if (res == NULL) { - fclose(fd); - return (0); - } - if (res[0] == '#') - continue; - else if (res[0] == '+') { -#ifdef YP - char *PKMAP = "publickey.byname"; - char *lookup; - char *domain; - int err; - int len; - - err = yp_get_default_domain(&domain); - if (err) { - continue; - } - lookup = NULL; - err = yp_match(domain, PKMAP, key, strlen(key), &lookup, &len); - if (err) { - LIBTIRPC_DEBUG(1, - ("getpublicandprivatekey: match failed error %d\n", err)); - continue; - } - lookup[len] = 0; - strcpy(ret, lookup); - fclose(fd); - free(lookup); - return (2); -#else /* YP */ - LIBTIRPC_DEBUG(1, -("Bad record in %s '+' -- NIS not supported in this library copy\n", PKFILE)); - continue; -#endif /* YP */ - } else { - mkey = strsep(&res, "\t "); - if (mkey == NULL) { - fprintf(stderr, - "Bad record in %s -- %s", PKFILE, buf); - continue; - } - do { - mval = strsep(&res, " \t#\n"); - } while (mval != NULL && !*mval); - if (mval == NULL) { - fprintf(stderr, - "Bad record in %s val problem - %s", PKFILE, buf); - continue; - } - if (strcmp(mkey, key) == 0) { - strcpy(ret, mval); - fclose(fd); - return (1); - } - } - } -} - -int getpublickey(netname, publickey) - const char *netname; - char *publickey; -{ - if (__getpublickey_LOCAL != NULL) - return(__getpublickey_LOCAL(netname, publickey)); - else - return(__getpublickey_real(netname, publickey)); -} diff --git a/src/key_call.c b/src/key_call.c deleted file mode 100644 index 589fd6f..0000000 --- a/src/key_call.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1986-1991 by Sun Microsystems Inc. - */ - - - -/* - * key_call.c, Interface to keyserver - * - * setsecretkey(key) - set your secret key - * encryptsessionkey(agent, deskey) - encrypt a session key to talk to agent - * decryptsessionkey(agent, deskey) - decrypt ditto - * gendeskey(deskey) - generate a secure des key - */ - -#include <pthread.h> -#include <reentrant.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <rpc/rpc.h> -#include <rpc/auth.h> -#include <rpc/auth_unix.h> -#include <rpc/key_prot.h> -#include <string.h> -#include <netconfig.h> -#include <sys/utsname.h> -#include <stdlib.h> -#include <signal.h> -#include <sys/wait.h> -#include <fcntl.h> - -#include "dump.h" - -#define KEY_TIMEOUT 5 /* per-try timeout in seconds */ -#define KEY_NRETRY 12 /* number of retries */ - -/* - * Hack to allow the keyserver to use AUTH_DES (for authenticated - * NIS+ calls, for example). The only functions that get called - * are key_encryptsession_pk, key_decryptsession_pk, and key_gendes. - * - * The approach is to have the keyserver fill in pointers to local - * implementations of these functions, and to call those in key_call(). - */ - -cryptkeyres *(*__key_encryptsession_pk_LOCAL)() = 0; -cryptkeyres *(*__key_decryptsession_pk_LOCAL)() = 0; -des_block *(*__key_gendes_LOCAL)() = 0; - -static int key_call( u_long, xdrproc_t, void *, xdrproc_t, void *); - -int -key_setsecret(secretkey) - const char *secretkey; -{ - keystatus status; - - if (!key_call((u_long) KEY_SET, (xdrproc_t)xdr_keybuf, - (void *)secretkey, - (xdrproc_t)xdr_keystatus, &status)) { - return (-1); - } - if (status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_setsecret: set status is nonzero")); - return (-1); - } - return (0); -} - - -/* key_secretkey_is_set() returns 1 if the keyserver has a secret key - * stored for the caller's effective uid; it returns 0 otherwise - * - * N.B.: The KEY_NET_GET key call is undocumented. Applications shouldn't - * be using it, because it allows them to get the user's secret key. - */ - -int -key_secretkey_is_set(void) -{ - struct key_netstres kres; - - memset((void*)&kres, 0, sizeof (kres)); - if (key_call((u_long) KEY_NET_GET, (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_key_netstres, &kres) && - (kres.status == KEY_SUCCESS) && - (kres.key_netstres_u.knet.st_priv_key[0] != 0)) { - /* avoid leaving secret key in memory */ - memset(kres.key_netstres_u.knet.st_priv_key, 0, HEXKEYBYTES); - return (1); - } - return (0); -} - -int -key_encryptsession_pk(remotename, remotekey, deskey) - char *remotename; - netobj *remotekey; - des_block *deskey; -{ - cryptkeyarg2 arg; - cryptkeyres res; - - arg.remotename = remotename; - arg.remotekey = *remotekey; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_ENCRYPT_PK, (xdrproc_t)xdr_cryptkeyarg2, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_encryptsession_pk: encrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_decryptsession_pk(remotename, remotekey, deskey) - char *remotename; - netobj *remotekey; - des_block *deskey; -{ - cryptkeyarg2 arg; - cryptkeyres res; - - arg.remotename = remotename; - arg.remotekey = *remotekey; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_DECRYPT_PK, (xdrproc_t)xdr_cryptkeyarg2, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_decryptsession_pk: decrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_encryptsession(remotename, deskey) - const char *remotename; - des_block *deskey; -{ - cryptkeyarg arg; - cryptkeyres res; - - arg.remotename = (char *) remotename; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_ENCRYPT, (xdrproc_t)xdr_cryptkeyarg, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_encryptsession: encrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_decryptsession(remotename, deskey) - const char *remotename; - des_block *deskey; -{ - cryptkeyarg arg; - cryptkeyres res; - - arg.remotename = (char *) remotename; - arg.deskey = *deskey; - if (!key_call((u_long)KEY_DECRYPT, (xdrproc_t)xdr_cryptkeyarg, &arg, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_decryptsession: decrypt status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -int -key_gendes(key) - des_block *key; -{ - if (!key_call((u_long)KEY_GEN, (xdrproc_t)xdr_void, NULL, - (xdrproc_t)xdr_des_block, key)) { - return (-1); - } - return (0); -} - -int -key_setnet(arg) -struct key_netstarg *arg; -{ - keystatus status; - - - if (!key_call((u_long) KEY_NET_PUT, (xdrproc_t)xdr_key_netstarg, arg, - (xdrproc_t)xdr_keystatus, &status)){ - return (-1); - } - - if (status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_setnet: key_setnet status is nonzero")); - return (-1); - } - return (1); -} - - -int -key_get_conv(pkey, deskey) - char *pkey; - des_block *deskey; -{ - cryptkeyres res; - - if (!key_call((u_long) KEY_GET_CONV, (xdrproc_t)xdr_keybuf, pkey, - (xdrproc_t)xdr_cryptkeyres, &res)) { - return (-1); - } - if (res.status != KEY_SUCCESS) { - LIBTIRPC_DEBUG(1, ("key_get_conv: get_conv status is nonzero")); - return (-1); - } - *deskey = res.cryptkeyres_u.deskey; - return (0); -} - -struct key_call_private { - CLIENT *client; /* Client handle */ - pid_t pid; /* process-id at moment of creation */ - uid_t uid; /* user-id at last authorization */ -}; -static struct key_call_private *key_call_private_main = NULL; - -static void -key_call_destroy(void *vp) -{ - struct key_call_private *kcp = (struct key_call_private *)vp; - - if (kcp) { - if (kcp->client) - clnt_destroy(kcp->client); - free(kcp); - } -} - -/* - * Keep the handle cached. This call may be made quite often. - */ -static CLIENT * -getkeyserv_handle(vers) -int vers; -{ - void *localhandle; - struct netconfig *nconf; - struct netconfig *tpconf; - struct key_call_private *kcp = key_call_private_main; - struct timeval wait_time; - struct utsname u; - int fd; - extern thread_key_t key_call_key; - extern mutex_t tsd_lock; - -#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */ -#define TOTAL_TRIES 5 /* Number of tries */ - - if (key_call_key == -1) { - mutex_lock(&tsd_lock); - if (key_call_key == -1) - thr_keycreate(&key_call_key, key_call_destroy); - mutex_unlock(&tsd_lock); - } - kcp = (struct key_call_private *)thr_getspecific(key_call_key); - if (kcp == (struct key_call_private *)NULL) { - kcp = (struct key_call_private *)malloc(sizeof (*kcp)); - if (kcp == (struct key_call_private *)NULL) { - return ((CLIENT *) NULL); - } - thr_setspecific(key_call_key, (void *) kcp); - kcp->client = NULL; - } - - /* if pid has changed, destroy client and rebuild */ - if (kcp->client != NULL && kcp->pid != getpid()) { - clnt_destroy(kcp->client); - kcp->client = NULL; - } - - if (kcp->client != NULL) { - /* if uid has changed, build client handle again */ - if (kcp->uid != geteuid()) { - kcp->uid = geteuid(); - auth_destroy(kcp->client->cl_auth); - kcp->client->cl_auth = - authsys_create("", kcp->uid, 0, 0, NULL); - if (kcp->client->cl_auth == NULL) { - clnt_destroy(kcp->client); - kcp->client = NULL; - return ((CLIENT *) NULL); - } - } - /* Change the version number to the new one */ - clnt_control(kcp->client, CLSET_VERS, (void *)&vers); - return (kcp->client); - } - if (!(localhandle = setnetconfig())) { - return ((CLIENT *) NULL); - } - tpconf = NULL; - if (uname(&u) == -1) { - endnetconfig(localhandle); - return ((CLIENT *) NULL); - } - while ((nconf = getnetconfig(localhandle)) != NULL) { - if (strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) { - /* - * We use COTS_ORD here so that the caller can - * find out immediately if the server is dead. - */ - if (nconf->nc_semantics == NC_TPI_COTS_ORD) { - kcp->client = clnt_tp_create(u.nodename, - KEY_PROG, vers, nconf); - if (kcp->client) - break; - } else { - tpconf = nconf; - } - } - } - if ((kcp->client == (CLIENT *) NULL) && (tpconf)) - /* Now, try the CLTS or COTS loopback transport */ - kcp->client = clnt_tp_create(u.nodename, - KEY_PROG, vers, tpconf); - endnetconfig(localhandle); - - if (kcp->client == (CLIENT *) NULL) { - return ((CLIENT *) NULL); - } - kcp->uid = geteuid(); - kcp->pid = getpid(); - kcp->client->cl_auth = authsys_create("", kcp->uid, 0, 0, NULL); - if (kcp->client->cl_auth == NULL) { - clnt_destroy(kcp->client); - kcp->client = NULL; - return ((CLIENT *) NULL); - } - - wait_time.tv_sec = TOTAL_TIMEOUT/TOTAL_TRIES; - wait_time.tv_usec = 0; - (void) clnt_control(kcp->client, CLSET_RETRY_TIMEOUT, - (char *)&wait_time); - if (clnt_control(kcp->client, CLGET_FD, (char *)&fd)) - fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ - - return (kcp->client); -} - -/* returns 0 on failure, 1 on success */ - -static int -key_call(proc, xdr_arg, arg, xdr_rslt, rslt) - u_long proc; - xdrproc_t xdr_arg; - void *arg; - xdrproc_t xdr_rslt; - void *rslt; -{ - CLIENT *clnt; - struct timeval wait_time; - - if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL) { - cryptkeyres *res; - res = (*__key_encryptsession_pk_LOCAL)(geteuid(), arg); - *(cryptkeyres*)rslt = *res; - return (1); - } else if (proc == KEY_DECRYPT_PK && __key_decryptsession_pk_LOCAL) { - cryptkeyres *res; - res = (*__key_decryptsession_pk_LOCAL)(geteuid(), arg); - *(cryptkeyres*)rslt = *res; - return (1); - } else if (proc == KEY_GEN && __key_gendes_LOCAL) { - des_block *res; - res = (*__key_gendes_LOCAL)(geteuid(), 0); - *(des_block*)rslt = *res; - return (1); - } - - if ((proc == KEY_ENCRYPT_PK) || (proc == KEY_DECRYPT_PK) || - (proc == KEY_NET_GET) || (proc == KEY_NET_PUT) || - (proc == KEY_GET_CONV)) - clnt = getkeyserv_handle(2); /* talk to version 2 */ - else - clnt = getkeyserv_handle(1); /* talk to version 1 */ - - if (clnt == NULL) { - return (0); - } - - wait_time.tv_sec = TOTAL_TIMEOUT; - wait_time.tv_usec = 0; - - if (clnt_call(clnt, proc, xdr_arg, arg, xdr_rslt, rslt, - wait_time) == RPC_SUCCESS) { - return (1); - } else { - return (0); - } -} diff --git a/src/key_prot_xdr.c b/src/key_prot_xdr.c deleted file mode 100644 index 772f582..0000000 --- a/src/key_prot_xdr.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#include <rpc/key_prot.h> -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ - - -/* - * Compiled from key_prot.x using rpcgen. - * DO NOT EDIT THIS FILE! - * This is NOT source code! - */ - -bool_t -xdr_keystatus(register XDR *xdrs, keystatus *objp) -{ - - if (!xdr_enum(xdrs, (enum_t *)objp)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_keybuf(register XDR *xdrs, keybuf objp) -{ - - if (!xdr_opaque(xdrs, objp, HEXKEYBYTES)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_netnamestr(register XDR *xdrs, netnamestr *objp) -{ - - if (!xdr_string(xdrs, objp, MAXNETNAMELEN)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_cryptkeyarg(register XDR *xdrs, cryptkeyarg *objp) -{ - - if (!xdr_netnamestr(xdrs, &objp->remotename)) - return (FALSE); - if (!xdr_des_block(xdrs, &objp->deskey)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_cryptkeyarg2(register XDR *xdrs, cryptkeyarg2 *objp) -{ - - if (!xdr_netnamestr(xdrs, &objp->remotename)) - return (FALSE); - if (!xdr_netobj(xdrs, &objp->remotekey)) - return (FALSE); - if (!xdr_des_block(xdrs, &objp->deskey)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_cryptkeyres(register XDR *xdrs, cryptkeyres *objp) -{ - - if (!xdr_keystatus(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_des_block(xdrs, &objp->cryptkeyres_u.deskey)) - return (FALSE); - break; - default: - break; - } - return (TRUE); -} - -bool_t -xdr_unixcred(register XDR *xdrs, unixcred *objp) -{ - - if (!xdr_u_int(xdrs, &objp->uid)) - return (FALSE); - if (!xdr_u_int(xdrs, &objp->gid)) - return (FALSE); - if (!xdr_array(xdrs, (char **)&objp->gids.gids_val, (u_int *) &objp->gids.gids_len, MAXGIDS, - sizeof (u_int), (xdrproc_t) xdr_u_int)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_getcredres(register XDR *xdrs, getcredres *objp) -{ - - if (!xdr_keystatus(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_unixcred(xdrs, &objp->getcredres_u.cred)) - return (FALSE); - break; - default: - break; - } - return (TRUE); -} - -bool_t -xdr_key_netstarg(register XDR *xdrs, key_netstarg *objp) -{ - - if (!xdr_keybuf(xdrs, objp->st_priv_key)) - return (FALSE); - if (!xdr_keybuf(xdrs, objp->st_pub_key)) - return (FALSE); - if (!xdr_netnamestr(xdrs, &objp->st_netname)) - return (FALSE); - return (TRUE); -} - -bool_t -xdr_key_netstres(register XDR *xdrs, key_netstres *objp) -{ - - if (!xdr_keystatus(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case KEY_SUCCESS: - if (!xdr_key_netstarg(xdrs, &objp->key_netstres_u.knet)) - return (FALSE); - break; - default: - break; - } - return (TRUE); -} diff --git a/src/netname.c b/src/netname.c deleted file mode 100644 index ea61b1a..0000000 --- a/src/netname.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * netname utility routines - * convert from unix names to network names and vice-versa - * This module is operating system dependent! - * What we define here will work with any unix system that has adopted - * the sun NIS domain architecture. - */ - -#include <sys/param.h> -#include <rpc/rpc.h> -#include "rpc_com.h" -#ifdef YP -#include <rpcsvc/yp_prot.h> -#include <rpcsvc/ypclnt.h> -#endif -#include <ctype.h> -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 256 -#endif -#ifndef NGROUPS -#define NGROUPS 16 -#endif - -#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) - -#define TYPE_SIGNED(type) (((type) -1) < 0) - -/* -** 302 / 1000 is log10(2.0) rounded up. -** Subtract one for the sign bit if the type is signed; -** add one for integer division truncation; -** add one more for a minus sign if the type is signed. -*/ -#define INT_STRLEN_MAXIMUM(type) \ - ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) - -static char *OPSYS = "unix"; - -/* - * Figure out my fully qualified network name - */ -int -getnetname(name) - char name[MAXNETNAMELEN+1]; -{ - uid_t uid; - - uid = geteuid(); - if (uid == 0) { - return (host2netname(name, (char *) NULL, (char *) NULL)); - } else { - return (user2netname(name, uid, (char *) NULL)); - } -} - - -/* - * Convert unix cred to network-name - */ -int -user2netname(netname, uid, domain) - char netname[MAXNETNAMELEN + 1]; - const uid_t uid; - const char *domain; -{ - char *dfltdom; - - if (domain == NULL) { - if (__rpc_get_default_domain(&dfltdom) != 0) { - return (0); - } - domain = dfltdom; - } - if (strlen(domain) + 1 + INT_STRLEN_MAXIMUM(u_long) + 1 + strlen(OPSYS) > MAXNETNAMELEN) { - return (0); - } - (void) sprintf(netname, "%s.%ld@%s", OPSYS, (u_long)uid, domain); - return (1); -} - - -/* - * Convert host to network-name - */ -int -host2netname(netname, host, domain) - char netname[MAXNETNAMELEN + 1]; - const char *host; - const char *domain; -{ - char *dfltdom; - char hostname[MAXHOSTNAMELEN+1]; - - if (domain == NULL) { - if (__rpc_get_default_domain(&dfltdom) != 0) { - return (0); - } - domain = dfltdom; - } - if (host == NULL) { - (void) gethostname(hostname, sizeof(hostname)); - host = hostname; - } - if (strlen(domain) + 1 + strlen(host) + 1 + strlen(OPSYS) > MAXNETNAMELEN) { - return (0); - } - (void) sprintf(netname, "%s.%s@%s", OPSYS, host, domain); - return (1); -} diff --git a/src/netnamer.c b/src/netnamer.c deleted file mode 100644 index 53ba73b..0000000 --- a/src/netnamer.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * netname utility routines convert from unix names to network names and - * vice-versa This module is operating system dependent! What we define here - * will work with any unix system that has adopted the sun NIS domain - * architecture. - */ -#include <sys/param.h> -#include <rpc/rpc.h> -#include "rpc_com.h" -#ifdef YP -#include <rpcsvc/yp_prot.h> -#include <rpcsvc/ypclnt.h> -#endif -#include <ctype.h> -#include <stdio.h> -#include <grp.h> -#include <pwd.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#include "debug.h" - -static char *OPSYS = "unix"; -static char *NETID = "netid.byname"; -static char *NETIDFILE = "/etc/netid"; - -static int getnetid( char *, char * ); -static int _getgroups( char *, gid_t * ); - -#ifndef NGROUPS -#define NGROUPS 16 -#endif - -/* - * Convert network-name into unix credential - */ -int -netname2user(netname, uidp, gidp, gidlenp, gidlist) - char netname[MAXNETNAMELEN + 1]; - uid_t *uidp; - gid_t *gidp; - int *gidlenp; - gid_t *gidlist; -{ - char *p; - int gidlen; - uid_t uid; - long luid; - struct passwd *pwd; - char val[1024]; - char *val1, *val2; - char *domain; - int vallen; - int err; - - if (getnetid(netname, val)) { - char *res = val; - - p = strsep(&res, ":"); - if (p == NULL) - return (0); - *uidp = (uid_t) atol(p); - p = strsep(&res, "\n,"); - if (p == NULL) { - return (0); - } - *gidp = (gid_t) atol(p); - gidlen = 0; - for (gidlen = 0; gidlen < NGROUPS; gidlen++) { - p = strsep(&res, "\n,"); - if (p == NULL) - break; - gidlist[gidlen] = (gid_t) atol(p); - } - *gidlenp = gidlen; - - return (1); - } - val1 = strchr(netname, '.'); - if (val1 == NULL) - return (0); - if (strncmp(netname, OPSYS, (val1-netname))) - return (0); - val1++; - val2 = strchr(val1, '@'); - if (val2 == NULL) - return (0); - vallen = val2 - val1; - if (vallen > (1024 - 1)) - vallen = 1024 - 1; - (void) strncpy(val, val1, 1024); - val[vallen] = 0; - - err = __rpc_get_default_domain(&domain); /* change to rpc */ - if (err) - return (0); - - if (strcmp(val2 + 1, domain)) - return (0); /* wrong domain */ - - if (sscanf(val, "%ld", &luid) != 1) - return (0); - uid = luid; - - /* use initgroups method */ - pwd = getpwuid(uid); - if (pwd == NULL) - return (0); - *uidp = pwd->pw_uid; - *gidp = pwd->pw_gid; - *gidlenp = _getgroups(pwd->pw_name, gidlist); - return (1); -} - -/* - * initgroups - */ - -static int -_getgroups(uname, groups) - char *uname; - gid_t groups[NGROUPS]; -{ - gid_t ngroups = 0; - struct group *grp; - int i; - int j; - int filter; - - setgrent(); - while ((grp = getgrent())) { - for (i = 0; grp->gr_mem[i]; i++) - if (!strcmp(grp->gr_mem[i], uname)) { - if (ngroups == NGROUPS) { - LIBTIRPC_DEBUG(1, - ("_getgroups: %s is in too many groups\n", uname)); - goto toomany; - } - /* filter out duplicate group entries */ - filter = 0; - for (j = 0; j < ngroups; j++) - if (groups[j] == grp->gr_gid) { - filter++; - break; - } - if (!filter) - groups[ngroups++] = grp->gr_gid; - } - } -toomany: - endgrent(); - return (ngroups); -} - -/* - * Convert network-name to hostname - */ -int -netname2host(netname, hostname, hostlen) - char netname[MAXNETNAMELEN + 1]; - char *hostname; - int hostlen; -{ - int err; - char valbuf[1024]; - char *val; - char *val2; - int vallen; - char *domain; - - if (getnetid(netname, valbuf)) { - val = valbuf; - if ((*val == '0') && (val[1] == ':')) { - (void) strncpy(hostname, val + 2, hostlen); - return (1); - } - } - val = strchr(netname, '.'); - if (val == NULL) - return (0); - if (strncmp(netname, OPSYS, (val - netname))) - return (0); - val++; - val2 = strchr(val, '@'); - if (val2 == NULL) - return (0); - vallen = val2 - val; - if (vallen > (hostlen - 1)) - vallen = hostlen - 1; - (void) strncpy(hostname, val, vallen); - hostname[vallen] = 0; - - err = __rpc_get_default_domain(&domain); /* change to rpc */ - if (err) - return (0); - - if (strcmp(val2 + 1, domain)) - return (0); /* wrong domain */ - else - return (1); -} - -/* - * reads the file /etc/netid looking for a + to optionally go to the - * network information service. - */ -int -getnetid(key, ret) - char *key, *ret; -{ - char buf[1024]; /* big enough */ - char *res; - char *mkey; - char *mval; - FILE *fd; -#ifdef YP - char *domain; - int err; - char *lookup; - int len; -#endif - - fd = fopen(NETIDFILE, "r"); - if (fd == NULL) { -#ifdef YP - res = "+"; - goto getnetidyp; -#else - return (0); -#endif - } - for (;;) { - if (fd == NULL) - return (0); /* getnetidyp brings us here */ - res = fgets(buf, sizeof(buf), fd); - if (res == NULL) { - fclose(fd); - return (0); - } - if (res[0] == '#') - continue; - else if (res[0] == '+') { -#ifdef YP - getnetidyp: - err = yp_get_default_domain(&domain); - if (err) { - continue; - } - lookup = NULL; - err = yp_match(domain, NETID, key, - strlen(key), &lookup, &len); - if (err) { - LIBTIRPC_DEBUG(1, ("getnetid: match failed error %d", err)); - continue; - } - lookup[len] = 0; - strcpy(ret, lookup); - free(lookup); - if (fd != NULL) - fclose(fd); - return (2); -#else /* YP */ - LIBTIRPC_DEBUG(1, -("Bad record in %s '+' -- NIS not supported in this library copy\n", - NETIDFILE)); - continue; -#endif /* YP */ - } else { - mkey = strsep(&res, "\t "); - if (mkey == NULL) { - fprintf(stderr, - "Bad record in %s -- %s", NETIDFILE, buf); - continue; - } - do { - mval = strsep(&res, " \t#\n"); - } while (mval != NULL && !*mval); - if (mval == NULL) { - fprintf(stderr, - "Bad record in %s val problem - %s", NETIDFILE, buf); - continue; - } - if (strcmp(mkey, key) == 0) { - strcpy(ret, mval); - fclose(fd); - return (1); - - } - } - } -} diff --git a/src/rpcdname.c b/src/rpcdname.c deleted file mode 100644 index 3e6a988..0000000 --- a/src/rpcdname.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * rpcdname.c - * Gets the default domain name - */ - -#include <stdlib.h> -#include <unistd.h> -#include <string.h> - -static char *default_domain = 0; - -static char * -get_default_domain() -{ - char temp[256]; - - if (default_domain) - return (default_domain); - if (getdomainname(temp, sizeof(temp)) < 0) - return (0); - if ((int) strlen(temp) > 0) { - default_domain = (char *)malloc((strlen(temp)+(unsigned)1)); - if (default_domain == 0) - return (0); - (void) strcpy(default_domain, temp); - return (default_domain); - } - return (0); -} - -/* - * This is a wrapper for the system call getdomainname which returns a - * ypclnt.h error code in the failure case. It also checks to see that - * the domain name is non-null, knowing that the null string is going to - * get rejected elsewhere in the NIS client package. - */ -int -__rpc_get_default_domain(domain) - char **domain; -{ - if ((*domain = get_default_domain()) != 0) - return (0); - return (-1); -} diff --git a/src/rtime.c b/src/rtime.c deleted file mode 100644 index 2624998..0000000 --- a/src/rtime.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1988 by Sun Microsystems, Inc. - - */ - -/* - * rtime - get time from remote machine - * - * gets time, obtaining value from host - * on the udp/time socket. Since timeserver returns - * with time of day in seconds since Jan 1, 1900, must - * subtract seconds before Jan 1, 1970 to get - * what unix uses. - */ -#include <pthread.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/time.h> -#include <netinet/in.h> -#include <stdio.h> -#include <netdb.h> -#include <sys/select.h> - -extern int _rpc_dtablesize( void ); - -#define NYEARS (unsigned long)(1970 - 1900) -#define TOFFSET (unsigned long)(60*60*24*(365*NYEARS + (NYEARS/4))) - -static void do_close( int ); - -int -rtime(addrp, timep, timeout) - struct sockaddr_in *addrp; - struct timeval *timep; - struct timeval *timeout; -{ - int s; - fd_set readfds; - int res; - unsigned long thetime; - struct sockaddr_in from; - int fromlen; - int type; - struct servent *serv; - - if (timeout == NULL) { - type = SOCK_STREAM; - } else { - type = SOCK_DGRAM; - } - s = socket(AF_INET, type, 0); - if (s < 0) { - return(-1); - } - addrp->sin_family = AF_INET; - - /* TCP and UDP port are the same in this case */ - if ((serv = getservbyname("time", "tcp")) == NULL) { - return(-1); - } - - addrp->sin_port = serv->s_port; - - if (type == SOCK_DGRAM) { - res = sendto(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)addrp, sizeof(*addrp)); - if (res < 0) { - do_close(s); - return(-1); - } - do { - FD_ZERO(&readfds); - FD_SET(s, &readfds); - res = select(_rpc_dtablesize(), &readfds, - (fd_set *)NULL, (fd_set *)NULL, timeout); - } while (res < 0 && errno == EINTR); - if (res <= 0) { - if (res == 0) { - errno = ETIMEDOUT; - } - do_close(s); - return(-1); - } - fromlen = sizeof(from); - res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0, - (struct sockaddr *)&from, &fromlen); - do_close(s); - if (res < 0) { - return(-1); - } - } else { - if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) < 0) { - do_close(s); - return(-1); - } - res = read(s, (char *)&thetime, sizeof(thetime)); - do_close(s); - if (res < 0) { - return(-1); - } - } - if (res != sizeof(thetime)) { - errno = EIO; - return(-1); - } - thetime = ntohl(thetime); - timep->tv_sec = thetime - TOFFSET; - timep->tv_usec = 0; - return(0); -} - -static void -do_close(s) - int s; -{ - int save; - - save = errno; - (void)close(s); - errno = save; -} |