diff options
author | gene <gene@cvs.openbsd.org> | 1998-02-11 04:32:29 +0000 |
---|---|---|
committer | gene <gene@cvs.openbsd.org> | 1998-02-11 04:32:29 +0000 |
commit | ac046051474b0514eef9da30fcb6346034f93bde (patch) | |
tree | 03ea331c1fcd5736c03b69ee34d35d054bdb1a10 /lib/librpcsvc | |
parent | b4c5e4b729c74a1538c4e3e5da63d6625ce97e50 (diff) |
Based on a combination of work from FreeBSD and NetBSD with some tweaks from
me: this fixes lots of casting issues and does a good cleanup. It kills the
bugs found in our 'rusers' binary which didn't grok some servers correctly
due to problems in our xdr.
Thanks to an extensive debug session with A. Emory Lundberg (emory@hellyeah.com)
Diffstat (limited to 'lib/librpcsvc')
-rw-r--r-- | lib/librpcsvc/rnusers.x | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/lib/librpcsvc/rnusers.x b/lib/librpcsvc/rnusers.x index 5b175d75474..88d0bbc4f48 100644 --- a/lib/librpcsvc/rnusers.x +++ b/lib/librpcsvc/rnusers.x @@ -1,4 +1,4 @@ -/* $OpenBSD: rnusers.x,v 1.6 1997/08/19 07:54:49 niklas Exp $ */ +/* $OpenBSD: rnusers.x,v 1.7 1998/02/11 04:32:28 gene Exp $ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -34,10 +34,11 @@ */ #ifndef RPC_HDR +%#include <sys/cdefs.h> %#ifndef lint %/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/ %/*static char sccsid[] = "from: @(#)rnusers.x 2.1 88/08/01 4.0 RPCSRC";*/ -%static char rcsid[] = "$OpenBSD: rnusers.x,v 1.6 1997/08/19 07:54:49 niklas Exp $"; +% static char rcsid[] = "$OpenBSD: rnusers.x,v 1.7 1998/02/11 04:32:28 gene Exp $"; %#endif /* not lint */ #endif @@ -56,25 +57,19 @@ % * This is the structure used in version 2 of the rusersd RPC service. % * It corresponds to the utmp structure for BSD sytems. % */ -% -%#define RNUSERS_MAXUSERLEN 8 -%#define RNUSERS_MAXLINELEN 8 -%#define RNUSERS_MAXHOSTLEN 16 -% %struct ru_utmp { -% char *ut_line; /* tty name */ -% char *ut_name; /* user id */ -% char *ut_host; /* host name, if remote */ -% int ut_time; /* time on */ +% char ut_line[8]; /* tty name */ +% char ut_name[8]; /* user id */ +% char ut_host[16]; /* host name, if remote */ +% time_t ut_time; /* time on */ %}; %typedef struct ru_utmp rutmp; % %struct utmparr { -% struct ru_utmp **uta_arr; +% struct utmp **uta_arr; % int uta_cnt; %}; %typedef struct utmparr utmparr; -%int xdr_utmparr(); % %struct utmpidle { % struct ru_utmp ui_utmp; @@ -86,21 +81,30 @@ % int uia_cnt; %}; %typedef struct utmpidlearr utmpidlearr; -%int xdr_utmpidlearr(); % -%#define RUSERSVERS_1 ((u_long)1) -%#define RUSERSVERS_2 ((u_long)2) +%#include <sys/cdefs.h> +%__BEGIN_DECLS +%bool_t xdr_utmp __P((XDR *, struct ru_utmp *)); +%bool_t xdr_utmpptr __P((XDR *, struct ru_utmp **)); +%bool_t xdr_utmparr __P((XDR *, struct utmparr *)); +%bool_t xdr_utmpidle __P((XDR *, struct utmpidle *)); +%bool_t xdr_utmpidleptr __P((XDR *, struct utmpidle **)); +%bool_t xdr_utmpidlearr __P((XDR *, struct utmpidlearr *)); +%__END_DECLS +% +%#define RUSERSVERS_1 ((u_int32_t)1) +%#define RUSERSVERS_2 ((u_int32_t)2) %#ifndef RUSERSPROG -%#define RUSERSPROG ((u_long)100002) +%#define RUSERSPROG ((u_int32_t)100002) %#endif %#ifndef RUSERSPROC_NUM -%#define RUSERSPROC_NUM ((u_long)1) +%#define RUSERSPROC_NUM ((u_int32_t)1) %#endif %#ifndef RUSERSPROC_NAMES -%#define RUSERSPROC_NAMES ((u_long)2) +%#define RUSERSPROC_NAMES ((u_int32_t)2) %#endif %#ifndef RUSERSPROC_ALLNAMES -%#define RUSERSPROC_ALLNAMES ((u_long)3) +%#define RUSERSPROC_ALLNAMES ((u_int32_t)3) %#endif % #endif /* RPC_HDR */ @@ -111,23 +115,29 @@ % XDR *xdrs; % struct ru_utmp *objp; %{ +% char *ptr; % int size; % -% size = RNUSERS_MAXLINELEN; -% if (!xdr_bytes(xdrs, &objp->ut_line, &size, RNUSERS_MAXLINELEN)) { +% /* +% * We are using a non-malloc allocated array, +% * so we are not supposed to call xdr_free with it. +% */ +% if (xdrs->x_op == XDR_FREE) +% return (TRUE); +% ptr = objp->ut_line; +% size = sizeof(objp->ut_line); +% if (!xdr_bytes(xdrs, &ptr, &size, size)) % return (FALSE); -% } -% size = RNUSERS_MAXUSERLEN; -% if (!xdr_bytes(xdrs, &objp->ut_name, &size, RNUSERS_MAXUSERLEN)) { +% ptr = objp->ut_name; +% size = sizeof(objp->ut_name); +% if (!xdr_bytes(xdrs, &ptr, &size, size)) % return (FALSE); -% } -% size = RNUSERS_MAXHOSTLEN; -% if (!xdr_bytes(xdrs, &objp->ut_host, &size, RNUSERS_MAXHOSTLEN)) { +% ptr = objp->ut_host; +% size = sizeof(objp->ut_host); +% if (!xdr_bytes(xdrs, &ptr, &size, size)) % return (FALSE); -% } -% if (!xdr_int(xdrs, &objp->ut_time)) { +% if (!xdr_long(xdrs, &objp->ut_time)) % return (FALSE); -% } % return (TRUE); %} % @@ -136,10 +146,10 @@ % XDR *xdrs; % struct ru_utmp **objpp; %{ +% % if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp), -% xdr_utmp)) { +% xdr_utmp)) % return (FALSE); -% } % return (TRUE); %} % @@ -148,10 +158,10 @@ % XDR *xdrs; % struct utmparr *objp; %{ +% % if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt, -% MAXUSERS, sizeof(struct ru_utmp *), xdr_utmpptr)) { +% MAXUSERS, sizeof(struct utmp *), xdr_utmpptr)) % return (FALSE); -% } % return (TRUE); %} % @@ -160,12 +170,11 @@ % XDR *xdrs; % struct utmpidle *objp; %{ -% if (!xdr_utmp(xdrs, &objp->ui_utmp)) { +% +% if (!xdr_utmp(xdrs, &objp->ui_utmp)) % return (FALSE); -% } -% if (!xdr_u_int(xdrs, &objp->ui_idle)) { +% if (!xdr_u_int(xdrs, &objp->ui_idle)) % return (FALSE); -% } % return (TRUE); %} % @@ -174,10 +183,10 @@ % XDR *xdrs; % struct utmpidle **objpp; %{ +% % if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle), -% xdr_utmpidle)) { +% xdr_utmpidle)) % return (FALSE); -% } % return (TRUE); %} % @@ -186,10 +195,10 @@ % XDR *xdrs; % struct utmpidlearr *objp; %{ +% % if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt, -% MAXUSERS, sizeof(struct utmpidle *), xdr_utmpidleptr)) { +% MAXUSERS, sizeof(struct utmpidle *), xdr_utmpidleptr)) % return (FALSE); -% } % return (TRUE); %} #endif |