mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Perform cleanups to rpc.rusersd:
- Perform whitespace fixes. Use tabs instead of 8 spaces. - Make it build at WARNS=6.
This commit is contained in:
parent
13e403fdea
commit
2de7889ec8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201146
@ -4,6 +4,8 @@ PROG = rpc.rusersd
|
||||
SRCS = rusersd.c rusers_proc.c
|
||||
MAN = rpc.rusersd.8
|
||||
|
||||
WARNS?= 6
|
||||
|
||||
DPADD= ${LIBRPCSVC} ${LIBUTIL}
|
||||
LDADD= -lrpcsvc -lutil
|
||||
|
||||
|
@ -83,18 +83,20 @@ typedef char ut_line_t[UT_LINESIZE+1];
|
||||
typedef char ut_name_t[UT_NAMESIZE+1];
|
||||
typedef char ut_host_t[UT_HOSTSIZE+1];
|
||||
|
||||
utmpidle utmp_idle[MAXUSERS];
|
||||
rutmp old_utmp[MAXUSERS];
|
||||
ut_line_t line[MAXUSERS];
|
||||
ut_name_t name[MAXUSERS];
|
||||
ut_host_t host[MAXUSERS];
|
||||
static utmpidle utmp_idle[MAXUSERS];
|
||||
static rutmp old_utmp[MAXUSERS];
|
||||
static ut_line_t line[MAXUSERS];
|
||||
static ut_name_t name[MAXUSERS];
|
||||
static ut_host_t host[MAXUSERS];
|
||||
|
||||
extern int from_inetd;
|
||||
|
||||
FILE *ufp;
|
||||
void rusers_service(struct svc_req *, SVCXPRT *);
|
||||
|
||||
static FILE *ufp;
|
||||
|
||||
#ifdef XIDLE
|
||||
Display *dpy;
|
||||
static Display *dpy;
|
||||
|
||||
static jmp_buf openAbort;
|
||||
|
||||
@ -121,14 +123,12 @@ XqueryIdle(char *display)
|
||||
syslog(LOG_ERR, "%s: unable to get idle time", display);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
syslog(LOG_ERR, "%s: Xidle extension not loaded", display);
|
||||
return(-1);
|
||||
}
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
syslog(LOG_ERR, "%s: server grabbed for over 10 seconds", display);
|
||||
return(-1);
|
||||
}
|
||||
@ -141,10 +141,10 @@ XqueryIdle(char *display)
|
||||
#endif
|
||||
|
||||
static u_int
|
||||
getidle(char *tty, char *display)
|
||||
getidle(const char *tty, const char *display __unused)
|
||||
{
|
||||
struct stat st;
|
||||
char devname[PATH_MAX];
|
||||
char ttyname[PATH_MAX];
|
||||
time_t now;
|
||||
u_long idle;
|
||||
|
||||
@ -166,30 +166,28 @@ getidle(char *tty, char *display)
|
||||
#endif
|
||||
mouse_idle = getidle("mouse", NULL);
|
||||
idle = (kbd_idle < mouse_idle)?kbd_idle:mouse_idle;
|
||||
}
|
||||
else {
|
||||
sprintf(devname, "%s/%s", _PATH_DEV, tty);
|
||||
if (stat(devname, &st) < 0) {
|
||||
} else {
|
||||
sprintf(ttyname, "%s/%s", _PATH_DEV, tty);
|
||||
if (stat(ttyname, &st) < 0) {
|
||||
#ifdef DEBUG
|
||||
printf("%s: %s\n", devname, strerror(errno));
|
||||
printf("%s: %s\n", ttyname, strerror(errno));
|
||||
#endif
|
||||
return(-1);
|
||||
}
|
||||
time(&now);
|
||||
#ifdef DEBUG
|
||||
printf("%s: now=%d atime=%d\n", devname, now,
|
||||
printf("%s: now=%d atime=%d\n", ttyname, now,
|
||||
st.st_atime);
|
||||
#endif
|
||||
idle = now - st.st_atime;
|
||||
idle = (idle + 30) / 60; /* secs->mins */
|
||||
}
|
||||
if (idle < 0) idle = 0;
|
||||
|
||||
return(idle);
|
||||
}
|
||||
|
||||
static utmpidlearr *
|
||||
do_names_2(int all)
|
||||
do_names_2(void)
|
||||
{
|
||||
static utmpidlearr ut;
|
||||
struct utmp usr;
|
||||
@ -237,8 +235,8 @@ do_names_2(int all)
|
||||
return(&ut);
|
||||
}
|
||||
|
||||
int *
|
||||
rusers_num(void)
|
||||
static int *
|
||||
rusers_num(void *argp __unused, struct svc_req *rqstp __unused)
|
||||
{
|
||||
static int num_users = 0;
|
||||
struct utmp usr;
|
||||
@ -266,15 +264,15 @@ rusers_num(void)
|
||||
}
|
||||
|
||||
static utmparr *
|
||||
do_names_1(int all)
|
||||
do_names_1(void)
|
||||
{
|
||||
utmpidlearr *utidle;
|
||||
static utmparr ut;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
bzero((char *)&ut, sizeof(ut));
|
||||
|
||||
utidle = do_names_2(all);
|
||||
utidle = do_names_2();
|
||||
if (utidle) {
|
||||
ut.utmparr_len = utidle->utmpidlearr_len;
|
||||
ut.utmparr_val = &old_utmp[0];
|
||||
@ -288,29 +286,35 @@ do_names_1(int all)
|
||||
}
|
||||
|
||||
utmpidlearr *
|
||||
rusersproc_names_2_svc(void *argp, struct svc_req *rqstp)
|
||||
rusersproc_names_2_svc(void *argp __unused, struct svc_req *rqstp __unused)
|
||||
{
|
||||
return(do_names_2(0));
|
||||
|
||||
return (do_names_2());
|
||||
}
|
||||
|
||||
utmpidlearr *
|
||||
rusersproc_allnames_2_svc(void *argp, struct svc_req *rqstp)
|
||||
rusersproc_allnames_2_svc(void *argp __unused, struct svc_req *rqstp __unused)
|
||||
{
|
||||
return(do_names_2(1));
|
||||
|
||||
return (do_names_2());
|
||||
}
|
||||
|
||||
utmparr *
|
||||
rusersproc_names_1_svc(void *argp, struct svc_req *rqstp)
|
||||
rusersproc_names_1_svc(void *argp __unused, struct svc_req *rqstp __unused)
|
||||
{
|
||||
return(do_names_1(0));
|
||||
|
||||
return (do_names_1());
|
||||
}
|
||||
|
||||
utmparr *
|
||||
rusersproc_allnames_1_svc(void *argp, struct svc_req *rqstp)
|
||||
rusersproc_allnames_1_svc(void *argp __unused, struct svc_req *rqstp __unused)
|
||||
{
|
||||
return(do_names_1(1));
|
||||
|
||||
return (do_names_1());
|
||||
}
|
||||
|
||||
typedef void *(*rusersproc_t)(void *, struct svc_req *);
|
||||
|
||||
void
|
||||
rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
|
||||
{
|
||||
@ -318,8 +322,8 @@ rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
|
||||
int fill;
|
||||
} argument;
|
||||
char *result;
|
||||
bool_t (*xdr_argument)(), (*xdr_result)();
|
||||
char *(*local)();
|
||||
xdrproc_t xdr_argument, xdr_result;
|
||||
rusersproc_t local;
|
||||
|
||||
switch (rqstp->rq_proc) {
|
||||
case NULLPROC:
|
||||
@ -327,20 +331,20 @@ rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
|
||||
goto leave;
|
||||
|
||||
case RUSERSPROC_NUM:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_int;
|
||||
local = (char *(*)()) rusers_num;
|
||||
xdr_argument = (xdrproc_t)xdr_void;
|
||||
xdr_result = (xdrproc_t)xdr_int;
|
||||
local = (rusersproc_t)rusers_num;
|
||||
break;
|
||||
|
||||
case RUSERSPROC_NAMES:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_utmpidlearr;
|
||||
xdr_argument = (xdrproc_t)xdr_void;
|
||||
xdr_result = (xdrproc_t)xdr_utmpidlearr;
|
||||
switch (rqstp->rq_vers) {
|
||||
case RUSERSVERS_ORIG:
|
||||
local = (char *(*)()) rusersproc_names_1_svc;
|
||||
local = (rusersproc_t)rusersproc_names_1_svc;
|
||||
break;
|
||||
case RUSERSVERS_IDLE:
|
||||
local = (char *(*)()) rusersproc_names_2_svc;
|
||||
local = (rusersproc_t)rusersproc_names_2_svc;
|
||||
break;
|
||||
default:
|
||||
svcerr_progvers(transp, RUSERSVERS_ORIG, RUSERSVERS_IDLE);
|
||||
@ -350,14 +354,14 @@ rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
|
||||
break;
|
||||
|
||||
case RUSERSPROC_ALLNAMES:
|
||||
xdr_argument = xdr_void;
|
||||
xdr_result = xdr_utmpidlearr;
|
||||
xdr_argument = (xdrproc_t)xdr_void;
|
||||
xdr_result = (xdrproc_t)xdr_utmpidlearr;
|
||||
switch (rqstp->rq_vers) {
|
||||
case RUSERSVERS_ORIG:
|
||||
local = (char *(*)()) rusersproc_allnames_1_svc;
|
||||
local = (rusersproc_t)rusersproc_allnames_1_svc;
|
||||
break;
|
||||
case RUSERSVERS_IDLE:
|
||||
local = (char *(*)()) rusersproc_allnames_2_svc;
|
||||
local = (rusersproc_t)rusersproc_allnames_2_svc;
|
||||
break;
|
||||
default:
|
||||
svcerr_progvers(transp, RUSERSVERS_ORIG, RUSERSVERS_IDLE);
|
||||
|
@ -49,7 +49,7 @@ extern void rusers_service(struct svc_req *, SVCXPRT *);
|
||||
|
||||
int from_inetd = 1;
|
||||
|
||||
void
|
||||
static void
|
||||
cleanup(int sig __unused)
|
||||
{
|
||||
(void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
|
||||
@ -58,9 +58,9 @@ cleanup(int sig __unused)
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
main(int argc __unused, char *argv[] __unused)
|
||||
{
|
||||
SVCXPRT *transp;
|
||||
SVCXPRT *transp = NULL; /* Keep compiler happy. */
|
||||
int ok;
|
||||
struct sockaddr_storage from;
|
||||
socklen_t fromlen;
|
||||
|
Loading…
Reference in New Issue
Block a user