summaryrefslogtreecommitdiff
path: root/sunrpc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-01 13:10:54 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-01 13:10:54 +0000
commit26a60f90c7a143e29793cddc721b8e5427fa2a6c (patch)
tree7f0f18f83e947b927358bd86768652cd4362aa84 /sunrpc
parent6e607d847cc9ad50610238da03a92c4b01eb577a (diff)
downloadglibc-26a60f90c7a143e29793cddc721b8e5427fa2a6c.tar.gz
Update.
1998-06-01 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/nis_call.c: Make directory search faster. * nis/nis_callback.c: Insert public key of user in callback data. * nis/nis_clone_obj.c: Make size from type u_long, not u_int. * nis/nis_creategroup.c: Check for NULL pointer, fill in more fields. * nis/nis_findserv.c: Rename __pmap_getport to __pmap_getnisport. * nis/nis_intern.h: Remove duplicated prototype. 1998-06-01 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * sunrpc/auth_des.c: Move prototypes from here ... * sunrpc/rpc/auth.h: ... to here. * sunrpc/clnt_tcp.c: Add more control flags. * sunrpc/clnt_udp.c: Likewise. * sunrpc/netname.c (host2netname): Remove prefixing dot from domainname. * sunrpc/rpc/clnt.h: Document, which control flags are not implementable. * sunrpc/svcauth_des.c: Use key_decryptsession_pk to avoid deadlock.
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/auth_des.c10
-rw-r--r--sunrpc/clnt_tcp.c62
-rw-r--r--sunrpc/clnt_udp.c54
-rw-r--r--sunrpc/netname.c1
-rw-r--r--sunrpc/rpc/auth.h3
-rw-r--r--sunrpc/rpc/clnt.h36
-rw-r--r--sunrpc/svcauth_des.c14
7 files changed, 151 insertions, 29 deletions
diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c
index bd29abd3bc..8536e62b79 100644
--- a/sunrpc/auth_des.c
+++ b/sunrpc/auth_des.c
@@ -62,10 +62,6 @@ extern bool_t xdr_authdes_verf (XDR *, struct authdes_verf *);
/*
* DES authenticator operations vector
*/
-AUTH *authdes_create (const char *, u_int, struct sockaddr *,
- des_block *);
-AUTH *authdes_pk_create (const char *, netobj *, u_int,
- struct sockaddr *, des_block *);
static void authdes_nextverf (AUTH *);
static bool_t authdes_marshal (AUTH *, XDR *);
static bool_t authdes_validate (AUTH *, struct opaque_auth *);
@@ -111,7 +107,7 @@ struct ad_private
*/
AUTH *
authdes_create (const char *servername, u_int window,
- struct sockaddr *syncaddr, des_block * ckey)
+ struct sockaddr *syncaddr, des_block *ckey)
/* servername - network name of server */
/* window - time to live */
/* syncaddr - optional addr of host to sync with */
@@ -129,8 +125,8 @@ authdes_create (const char *servername, u_int window,
}
AUTH *
-authdes_pk_create (const char *servername, netobj * pkey, u_int window,
- struct sockaddr * syncaddr, des_block * ckey)
+authdes_pk_create (const char *servername, netobj *pkey, u_int window,
+ struct sockaddr *syncaddr, des_block *ckey)
{
AUTH *auth;
struct ad_private *ad;
diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c
index 82b34b6259..d4fd7c448c 100644
--- a/sunrpc/clnt_tcp.c
+++ b/sunrpc/clnt_tcp.c
@@ -365,15 +365,19 @@ clnttcp_abort ()
}
static bool_t
-clnttcp_control (cl, request, info)
- CLIENT *cl;
- int request;
- char *info;
+clnttcp_control (CLIENT *cl, int request, char *info)
{
struct ct_data *ct = (struct ct_data *) cl->cl_private;
+
switch (request)
{
+ case CLSET_FD_CLOSE:
+ ct->ct_closeit = TRUE;
+ break;
+ case CLSET_FD_NCLOSE:
+ ct->ct_closeit = FALSE;
+ break;
case CLSET_TIMEOUT:
ct->ct_wait = *(struct timeval *) info;
ct->ct_waitset = TRUE;
@@ -384,6 +388,56 @@ clnttcp_control (cl, request, info)
case CLGET_SERVER_ADDR:
*(struct sockaddr_in *) info = ct->ct_addr;
break;
+ case CLGET_FD:
+ *(int *)info = ct->ct_sock;
+ break;
+ case CLGET_XID:
+ /*
+ * use the knowledge that xid is the
+ * first element in the call structure *.
+ * This will get the xid of the PREVIOUS call
+ */
+ *(u_long *)info = ntohl (*(u_long *)ct->ct_mcall);
+ break;
+ case CLSET_XID:
+ /* This will set the xid of the NEXT call */
+ *(u_long *)ct->ct_mcall = htonl (*(u_long *)info - 1);
+ /* decrement by 1 as clnttcp_call() increments once */
+ case CLGET_VERS:
+ /*
+ * This RELIES on the information that, in the call body,
+ * the version number field is the fifth field from the
+ * begining of the RPC header. MUST be changed if the
+ * call_struct is changed
+ */
+ *(u_long *)info = ntohl (*(u_long *)(ct->ct_mcall +
+ 4 * BYTES_PER_XDR_UNIT));
+ break;
+ case CLSET_VERS:
+ *(u_long *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT)
+ = htonl (*(u_long *)info);
+ break;
+ case CLGET_PROG:
+ /*
+ * This RELIES on the information that, in the call body,
+ * the program number field is the field from the
+ * begining of the RPC header. MUST be changed if the
+ * call_struct is changed
+ */
+ *(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall +
+ 3 * BYTES_PER_XDR_UNIT));
+ break;
+ case CLSET_PROG:
+ *(u_long *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT)
+ = htonl(*(u_long *)info);
+ break;
+ /* The following are only possible with TI-RPC */
+ case CLGET_RETRY_TIMEOUT:
+ case CLSET_RETRY_TIMEOUT:
+ case CLGET_SVC_ADDR:
+ case CLSET_SVC_ADDR:
+ case CLSET_PUSH_TIMOD:
+ case CLSET_POP_TIMOD:
default:
return FALSE;
}
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index 3ce124f5d7..c3545db65a 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -439,6 +439,12 @@ clntudp_control (CLIENT *cl, int request, char *info)
switch (request)
{
+ case CLSET_FD_CLOSE:
+ cu->cu_closeit = TRUE;
+ break;
+ case CLSET_FD_NCLOSE:
+ cu->cu_closeit = FALSE;
+ break;
case CLSET_TIMEOUT:
cu->cu_total = *(struct timeval *) info;
break;
@@ -454,6 +460,54 @@ clntudp_control (CLIENT *cl, int request, char *info)
case CLGET_SERVER_ADDR:
*(struct sockaddr_in *) info = cu->cu_raddr;
break;
+ case CLGET_FD:
+ *(int *)info = cu->cu_sock;
+ break;
+ case CLGET_XID:
+ /*
+ * use the knowledge that xid is the
+ * first element in the call structure *.
+ * This will get the xid of the PREVIOUS call
+ */
+ *(u_long *)info = ntohl(*(u_long *)cu->cu_outbuf);
+ break;
+ case CLSET_XID:
+ /* This will set the xid of the NEXT call */
+ *(u_long *)cu->cu_outbuf = htonl(*(u_long *)info - 1);
+ /* decrement by 1 as clntudp_call() increments once */
+ case CLGET_VERS:
+ /*
+ * This RELIES on the information that, in the call body,
+ * the version number field is the fifth field from the
+ * begining of the RPC header. MUST be changed if the
+ * call_struct is changed
+ */
+ *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
+ 4 * BYTES_PER_XDR_UNIT));
+ break;
+ case CLSET_VERS:
+ *(u_long *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT)
+ = htonl(*(u_long *)info);
+ break;
+ case CLGET_PROG:
+ /*
+ * This RELIES on the information that, in the call body,
+ * the program number field is the field from the
+ * begining of the RPC header. MUST be changed if the
+ * call_struct is changed
+ */
+ *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf +
+ 3 * BYTES_PER_XDR_UNIT));
+ break;
+ case CLSET_PROG:
+ *(u_long *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT)
+ = htonl(*(u_long *)info);
+ break;
+ /* The following are only possible with TI-RPC */
+ case CLGET_SVC_ADDR:
+ case CLSET_SVC_ADDR:
+ case CLSET_PUSH_TIMOD:
+ case CLSET_POP_TIMOD:
default:
return FALSE;
}
diff --git a/sunrpc/netname.c b/sunrpc/netname.c
index be6c2f2ae1..176967a905 100644
--- a/sunrpc/netname.c
+++ b/sunrpc/netname.c
@@ -82,6 +82,7 @@ host2netname (char netname[MAXNETNAMELEN + 1], const char *host,
p = dot_in_host;
if (p)
{
+ ++p;
strncpy (domainname, p, MAXHOSTNAMELEN);
domainname[MAXHOSTNAMELEN] = '\0';
}
diff --git a/sunrpc/rpc/auth.h b/sunrpc/rpc/auth.h
index 9519ca27f4..aa2c6144a1 100644
--- a/sunrpc/rpc/auth.h
+++ b/sunrpc/rpc/auth.h
@@ -166,6 +166,9 @@ extern AUTH *authnone_create __P ((void));
extern AUTH *authdes_create __P ((const char *__servername, u_int __window,
struct sockaddr *__syncaddr,
des_block *__ckey));
+extern AUTH *authdes_pk_create __P ((const char *, netobj *, u_int,
+ struct sockaddr *, des_block *));
+
#define AUTH_NONE 0 /* no authentication */
#define AUTH_NULL 0 /* backward compatibility */
diff --git a/sunrpc/rpc/clnt.h b/sunrpc/rpc/clnt.h
index 38f40909dc..ed12add102 100644
--- a/sunrpc/rpc/clnt.h
+++ b/sunrpc/rpc/clnt.h
@@ -211,23 +211,27 @@ struct CLIENT {
/*
* control operations that apply to all transports
+ *
+ * Note: options marked XXX are no-ops in this implementation of RPC.
+ * The are present in TI-RPC but can't be implemented here since they
+ * depend on the presence of STREAMS/TLI, which we don't have.
*/
-#define CLSET_TIMEOUT 1 /* set timeout (timeval) */
-#define CLGET_TIMEOUT 2 /* get timeout (timeval) */
-#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
-#define CLGET_FD 6 /* get connections file descriptor */
-#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */
-#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
-#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy*/
-#define CLGET_XID 10 /* Get xid */
-#define CLSET_XID 11 /* Set xid */
-#define CLGET_VERS 12 /* Get version number */
-#define CLSET_VERS 13 /* Set version number */
-#define CLGET_PROG 14 /* Get program number */
-#define CLSET_PROG 15 /* Set program number */
-#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */
-#define CLSET_PUSH_TIMOD 17 /* push timod if not already present */
-#define CLSET_POP_TIMOD 18 /* pop timod */
+#define CLSET_TIMEOUT 1 /* set timeout (timeval) */
+#define CLGET_TIMEOUT 2 /* get timeout (timeval) */
+#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */
+#define CLGET_FD 6 /* get connections file descriptor */
+#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */
+#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */
+#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy*/
+#define CLGET_XID 10 /* Get xid */
+#define CLSET_XID 11 /* Set xid */
+#define CLGET_VERS 12 /* Get version number */
+#define CLSET_VERS 13 /* Set version number */
+#define CLGET_PROG 14 /* Get program number */
+#define CLSET_PROG 15 /* Set program number */
+#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */
+#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */
+#define CLSET_POP_TIMOD 18 /* pop timod XXX */
/*
* Connectionless only control operations
*/
diff --git a/sunrpc/svcauth_des.c b/sunrpc/svcauth_des.c
index 7160726e86..c74e06b5c1 100644
--- a/sunrpc/svcauth_des.c
+++ b/sunrpc/svcauth_des.c
@@ -174,9 +174,19 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg)
*/
if (cred->adc_namekind == ADN_FULLNAME)
{
+ netobj pkey;
+ char pkey_data[1024];
+
sessionkey = &cred->adc_fullname.key;
- if (key_decryptsession (cred->adc_fullname.name,
- sessionkey) < 0)
+ if (!getpublickey (cred->adc_fullname.name, pkey_data))
+ {
+ debug("getpublickey");
+ return AUTH_BADCRED;
+ }
+ pkey.n_bytes = pkey_data;
+ pkey.n_len = strlen (pkey_data) + 1;
+ if (key_decryptsession_pk (cred->adc_fullname.name, &pkey,
+ sessionkey) < 0)
{
debug ("decryptsessionkey");
return AUTH_BADCRED; /* key not found */