diff options
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/auth_des.c | 10 | ||||
-rw-r--r-- | sunrpc/clnt_tcp.c | 62 | ||||
-rw-r--r-- | sunrpc/clnt_udp.c | 54 | ||||
-rw-r--r-- | sunrpc/netname.c | 1 | ||||
-rw-r--r-- | sunrpc/rpc/auth.h | 3 | ||||
-rw-r--r-- | sunrpc/rpc/clnt.h | 36 | ||||
-rw-r--r-- | sunrpc/svcauth_des.c | 14 |
7 files changed, 151 insertions, 29 deletions
diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c index bd29abd..8536e62 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 82b34b6..d4fd7c4 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 3ce124f..c3545db 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 be6c2f2..176967a 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 9519ca2..aa2c614 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 38f4090..ed12add 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 7160726..c74e06b 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 */ |