Fix most of the warnings given by WARNS=2.
This commit is contained in:
parent
b55c34215e
commit
670077b10f
@ -52,8 +52,21 @@
|
||||
|
||||
#include "inetd.h"
|
||||
|
||||
extern int debug;
|
||||
extern struct servtab *servtab;
|
||||
void chargen_dg __P((int, struct servtab *));
|
||||
void chargen_stream __P((int, struct servtab *));
|
||||
void daytime_dg __P((int, struct servtab *));
|
||||
void daytime_stream __P((int, struct servtab *));
|
||||
void discard_dg __P((int, struct servtab *));
|
||||
void discard_stream __P((int, struct servtab *));
|
||||
void echo_dg __P((int, struct servtab *));
|
||||
void echo_stream __P((int, struct servtab *));
|
||||
static int getline __P((int, char *, int));
|
||||
void iderror __P((int, int, int, const char *));
|
||||
void ident_stream __P((int, struct servtab *));
|
||||
void initring __P((void));
|
||||
unsigned long machtime __P((void));
|
||||
void machtime_dg __P((int, struct servtab *));
|
||||
void machtime_stream __P((int, struct servtab *));
|
||||
|
||||
char ring[128];
|
||||
char *endring;
|
||||
@ -80,11 +93,11 @@ struct biltin biltins[] = {
|
||||
{ "chargen", SOCK_STREAM, 1, -1, chargen_stream },
|
||||
{ "chargen", SOCK_DGRAM, 0, 1, chargen_dg },
|
||||
|
||||
{ "tcpmux", SOCK_STREAM, 1, -1, (void (*)())tcpmux },
|
||||
{ "tcpmux", SOCK_STREAM, 1, -1, (bi_fn_t *)tcpmux },
|
||||
|
||||
{ "auth", SOCK_STREAM, 1, -1, ident_stream },
|
||||
|
||||
{ NULL }
|
||||
{ NULL, 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
@ -187,11 +200,11 @@ daytime_dg(s, sep) /* Return human-readable time of day */
|
||||
struct servtab *sep;
|
||||
{
|
||||
char buffer[256];
|
||||
time_t clock;
|
||||
time_t now;
|
||||
struct sockaddr_storage ss;
|
||||
socklen_t size;
|
||||
|
||||
clock = time((time_t *) 0);
|
||||
now = time((time_t *) 0);
|
||||
|
||||
size = sizeof(ss);
|
||||
if (recvfrom(s, buffer, sizeof(buffer), 0,
|
||||
@ -201,7 +214,7 @@ daytime_dg(s, sep) /* Return human-readable time of day */
|
||||
if (check_loop((struct sockaddr *)&ss, sep))
|
||||
return;
|
||||
|
||||
(void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
|
||||
(void) sprintf(buffer, "%.24s\r\n", ctime(&now));
|
||||
(void) sendto(s, buffer, strlen(buffer), 0,
|
||||
(struct sockaddr *)&ss, size);
|
||||
}
|
||||
@ -213,11 +226,11 @@ daytime_stream(s, sep) /* Return human-readable time of day */
|
||||
struct servtab *sep;
|
||||
{
|
||||
char buffer[256];
|
||||
time_t clock;
|
||||
time_t now;
|
||||
|
||||
clock = time((time_t *) 0);
|
||||
now = time((time_t *) 0);
|
||||
|
||||
(void) sprintf(buffer, "%.24s\r\n", ctime(&clock));
|
||||
(void) sprintf(buffer, "%.24s\r\n", ctime(&now));
|
||||
(void) send(s, buffer, strlen(buffer), MSG_EOF);
|
||||
}
|
||||
|
||||
@ -316,7 +329,7 @@ echo_stream(s, sep) /* Echo service -- echo data back */
|
||||
void
|
||||
iderror(lport, fport, s, er) /* Generic ident_stream error-sending func */
|
||||
int lport, fport, s;
|
||||
char *er;
|
||||
const char *er;
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -339,7 +352,7 @@ ident_stream(s, sep) /* Ident service (AKA "auth") */
|
||||
{
|
||||
struct utsname un;
|
||||
struct stat sb;
|
||||
struct sockaddr_in sin[2];
|
||||
struct sockaddr_in sin4[2];
|
||||
#ifdef INET6
|
||||
struct sockaddr_in6 sin6[2];
|
||||
#endif
|
||||
@ -377,7 +390,7 @@ ident_stream(s, sep) /* Ident service (AKA "auth") */
|
||||
if (argc) {
|
||||
int sec, usec;
|
||||
size_t i;
|
||||
u_int32_t random;
|
||||
u_int32_t rnd32;
|
||||
|
||||
while ((c = getopt(argc, sep->se_argv, "d:fFgino:rt:")) != -1)
|
||||
switch (c) {
|
||||
@ -394,9 +407,9 @@ ident_stream(s, sep) /* Ident service (AKA "auth") */
|
||||
break;
|
||||
case 'g':
|
||||
gflag = 1;
|
||||
random = 0; /* Shush, compiler. */
|
||||
rnd32 = 0; /* Shush, compiler. */
|
||||
/*
|
||||
* The number of bits in "random" divided
|
||||
* The number of bits in "rnd32" divided
|
||||
* by the number of bits needed per iteration
|
||||
* gives a more optimal way to reload the
|
||||
* random number only when necessary.
|
||||
@ -409,9 +422,9 @@ ident_stream(s, sep) /* Ident service (AKA "auth") */
|
||||
"0123456789"
|
||||
"abcdefghijklmnopqrstuvwxyz";
|
||||
if (i % 6 == 0)
|
||||
random = arc4random();
|
||||
idbuf[i] = base36[random % 36];
|
||||
random /= 36;
|
||||
rnd32 = arc4random();
|
||||
idbuf[i] = base36[rnd32 % 36];
|
||||
rnd32 /= 36;
|
||||
}
|
||||
idbuf[i] = '\0';
|
||||
break;
|
||||
@ -483,7 +496,7 @@ ident_stream(s, sep) /* Ident service (AKA "auth") */
|
||||
iderror(0, 0, s, ID_UNKNOWN);
|
||||
if (ioctl(s, FIONREAD, &onreadlen) == -1)
|
||||
iderror(0, 0, s, ID_UNKNOWN);
|
||||
if (onreadlen > bufsiz)
|
||||
if ((size_t)onreadlen > bufsiz)
|
||||
onreadlen = bufsiz;
|
||||
ssize = read(s, &buf[size], (size_t)onreadlen);
|
||||
if (ssize == -1)
|
||||
@ -533,12 +546,12 @@ ident_stream(s, sep) /* Ident service (AKA "auth") */
|
||||
size = sizeof(uc);
|
||||
switch (ss[0].ss_family) {
|
||||
case AF_INET:
|
||||
sin[0] = *(struct sockaddr_in *)&ss[0];
|
||||
sin[0].sin_port = htons(lport);
|
||||
sin[1] = *(struct sockaddr_in *)&ss[1];
|
||||
sin[1].sin_port = htons(fport);
|
||||
if (sysctlbyname("net.inet.tcp.getcred", &uc, &size, sin,
|
||||
sizeof(sin)) == -1)
|
||||
sin4[0] = *(struct sockaddr_in *)&ss[0];
|
||||
sin4[0].sin_port = htons(lport);
|
||||
sin4[1] = *(struct sockaddr_in *)&ss[1];
|
||||
sin4[1].sin_port = htons(fport);
|
||||
if (sysctlbyname("net.inet.tcp.getcred", &uc, &size, sin4,
|
||||
sizeof(sin4)) == -1)
|
||||
getcredfail = errno;
|
||||
break;
|
||||
#ifdef INET6
|
||||
|
@ -204,6 +204,31 @@ static const char rcsid[] =
|
||||
|
||||
#define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM))
|
||||
|
||||
void close_sep __P((struct servtab *));
|
||||
void flag_signal __P((int));
|
||||
void flag_config __P((int));
|
||||
void config __P((void));
|
||||
int cpmip __P((const struct servtab *, int));
|
||||
void endconfig __P((void));
|
||||
struct servtab *enter __P((struct servtab *));
|
||||
void freeconfig __P((struct servtab *));
|
||||
struct servtab *getconfigent __P((void));
|
||||
int matchservent __P((const char *, const char *, const char *));
|
||||
char *nextline __P((FILE *));
|
||||
void addchild __P((struct servtab *, int));
|
||||
void flag_reapchild __P((int));
|
||||
void reapchild __P((void));
|
||||
void enable __P((struct servtab *));
|
||||
void disable __P((struct servtab *));
|
||||
void flag_retry __P((int));
|
||||
void retry __P((void));
|
||||
int setconfig __P((void));
|
||||
void setup __P((struct servtab *));
|
||||
#ifdef IPSEC
|
||||
void ipsecsetup __P((struct servtab *));
|
||||
#endif
|
||||
void unregisterrpc __P((register struct servtab *sep));
|
||||
|
||||
int allow_severity;
|
||||
int deny_severity;
|
||||
int wrap_ex = 0;
|
||||
@ -239,8 +264,8 @@ struct servtab *servtab;
|
||||
extern struct biltin biltins[];
|
||||
|
||||
#define NUMINT (sizeof(intab) / sizeof(struct inent))
|
||||
char *CONFIG = _PATH_INETDCONF;
|
||||
char *pid_file = _PATH_INETDPID;
|
||||
const char *CONFIG = _PATH_INETDCONF;
|
||||
const char *pid_file = _PATH_INETDPID;
|
||||
|
||||
#ifdef OLD_SETPROCTITLE
|
||||
char **Argv;
|
||||
@ -249,7 +274,7 @@ char *LastArg;
|
||||
|
||||
int
|
||||
getvalue(arg, value, whine)
|
||||
char *arg, *whine;
|
||||
const char *arg, *whine;
|
||||
int *value;
|
||||
{
|
||||
int tmp;
|
||||
@ -294,7 +319,7 @@ main(argc, argv, envp)
|
||||
#define peermax p_un.peer_max
|
||||
int i;
|
||||
struct addrinfo hints, *res;
|
||||
char *servname;
|
||||
const char *servname;
|
||||
int error;
|
||||
|
||||
|
||||
@ -654,7 +679,7 @@ main(argc, argv, envp)
|
||||
* Call tcpmux to find the real service to exec.
|
||||
*/
|
||||
if (sep->se_bi &&
|
||||
sep->se_bi->bi_fn == (void (*)()) tcpmux) {
|
||||
sep->se_bi->bi_fn == (bi_fn_t *) tcpmux) {
|
||||
sep = tcpmux(ctrl);
|
||||
if (sep == NULL) {
|
||||
close(ctrl);
|
||||
@ -791,8 +816,9 @@ main(argc, argv, envp)
|
||||
* Add a signal flag to the signal flag queue for later handling
|
||||
*/
|
||||
|
||||
void flag_signal(c)
|
||||
int c;
|
||||
void
|
||||
flag_signal(c)
|
||||
int c;
|
||||
{
|
||||
char ch = c;
|
||||
|
||||
@ -873,7 +899,8 @@ flag_config(signo)
|
||||
flag_signal('H');
|
||||
}
|
||||
|
||||
void config()
|
||||
void
|
||||
config()
|
||||
{
|
||||
struct servtab *sep, *new, **sepp;
|
||||
long omask;
|
||||
@ -1070,7 +1097,7 @@ void
|
||||
unregisterrpc(sep)
|
||||
struct servtab *sep;
|
||||
{
|
||||
int i;
|
||||
u_int i;
|
||||
struct servtab *sepp;
|
||||
long omask;
|
||||
|
||||
@ -1198,7 +1225,7 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
|
||||
umask(mask);
|
||||
}
|
||||
if (sep->se_rpc) {
|
||||
int i;
|
||||
u_int i;
|
||||
socklen_t len = sep->se_ctrladdr_size;
|
||||
|
||||
if (sep->se_family != AF_INET) {
|
||||
@ -1263,8 +1290,9 @@ ipsecsetup(sep)
|
||||
}
|
||||
|
||||
if (!sep->se_policy || sep->se_policy[0] == '\0') {
|
||||
policy_in = "in entrust";
|
||||
policy_out = "out entrust";
|
||||
static char def_in[] = "in entrust", def_out[] = "out entrust";
|
||||
policy_in = def_in;
|
||||
policy_out = def_out;
|
||||
} else {
|
||||
if (!strncmp("in", sep->se_policy, 2))
|
||||
policy_in = sep->se_policy;
|
||||
@ -1327,7 +1355,7 @@ close_sep(sep)
|
||||
|
||||
int
|
||||
matchservent(name1, name2, proto)
|
||||
char *name1, *name2, *proto;
|
||||
const char *name1, *name2, *proto;
|
||||
{
|
||||
char **alias, *p;
|
||||
struct servent *se;
|
||||
@ -1931,10 +1959,12 @@ nextline(fd)
|
||||
|
||||
char *
|
||||
newstr(cp)
|
||||
char *cp;
|
||||
const char *cp;
|
||||
{
|
||||
if ((cp = strdup(cp ? cp : "")))
|
||||
return (cp);
|
||||
char *cr;
|
||||
|
||||
if ((cr = strdup(cp != NULL ? cp : "")))
|
||||
return (cr);
|
||||
syslog(LOG_ERR, "strdup: %m");
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
@ -1942,7 +1972,7 @@ newstr(cp)
|
||||
#ifdef OLD_SETPROCTITLE
|
||||
void
|
||||
inetd_setproctitle(a, s)
|
||||
char *a;
|
||||
const char *a;
|
||||
int s;
|
||||
{
|
||||
int size;
|
||||
@ -1966,7 +1996,7 @@ inetd_setproctitle(a, s)
|
||||
#else
|
||||
void
|
||||
inetd_setproctitle(a, s)
|
||||
char *a;
|
||||
const char *a;
|
||||
int s;
|
||||
{
|
||||
socklen_t size;
|
||||
@ -1985,13 +2015,10 @@ inetd_setproctitle(a, s)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Internet services provided internally by inetd:
|
||||
*/
|
||||
|
||||
int check_loop(sa, sep)
|
||||
struct sockaddr *sa;
|
||||
struct servtab *sep;
|
||||
int
|
||||
check_loop(sa, sep)
|
||||
const struct sockaddr *sa;
|
||||
const struct servtab *sep;
|
||||
{
|
||||
struct servtab *se2;
|
||||
char pname[INET6_ADDRSTRLEN];
|
||||
@ -2002,13 +2029,13 @@ int check_loop(sa, sep)
|
||||
|
||||
switch (se2->se_family) {
|
||||
case AF_INET:
|
||||
if (((struct sockaddr_in *)sa)->sin_port ==
|
||||
if (((const struct sockaddr_in *)sa)->sin_port ==
|
||||
se2->se_ctrladdr4.sin_port)
|
||||
goto isloop;
|
||||
continue;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
if (((struct sockaddr_in *)sa)->sin_port ==
|
||||
if (((const struct sockaddr_in *)sa)->sin_port ==
|
||||
se2->se_ctrladdr4.sin_port)
|
||||
goto isloop;
|
||||
continue;
|
||||
@ -2034,8 +2061,8 @@ int check_loop(sa, sep)
|
||||
*/
|
||||
void
|
||||
print_service(action, sep)
|
||||
char *action;
|
||||
struct servtab *sep;
|
||||
const char *action;
|
||||
const struct servtab *sep;
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: %s proto=%s accept=%d max=%d user=%s group=%s"
|
||||
@ -2086,7 +2113,7 @@ CHash CHashAry[CPMHSIZE];
|
||||
|
||||
int
|
||||
cpmip(sep, ctrl)
|
||||
struct servtab *sep;
|
||||
const struct servtab *sep;
|
||||
int ctrl;
|
||||
{
|
||||
struct sockaddr_storage rss;
|
||||
@ -2106,22 +2133,22 @@ cpmip(sep, ctrl)
|
||||
int cnt = 0;
|
||||
CHash *chBest = NULL;
|
||||
unsigned int ticks = t / CHTGRAN;
|
||||
struct sockaddr_in *sin;
|
||||
struct sockaddr_in *sin4;
|
||||
#ifdef INET6
|
||||
struct sockaddr_in6 *sin6;
|
||||
#endif
|
||||
|
||||
sin = (struct sockaddr_in *)&rss;
|
||||
sin4 = (struct sockaddr_in *)&rss;
|
||||
#ifdef INET6
|
||||
sin6 = (struct sockaddr_in6 *)&rss;
|
||||
#endif
|
||||
{
|
||||
char *p;
|
||||
int i, addrlen;
|
||||
int addrlen;
|
||||
|
||||
switch (rss.ss_family) {
|
||||
case AF_INET:
|
||||
p = (char *)&sin->sin_addr;
|
||||
p = (char *)&sin4->sin_addr;
|
||||
addrlen = sizeof(struct in_addr);
|
||||
break;
|
||||
#ifdef INET6
|
||||
@ -2145,7 +2172,7 @@ cpmip(sep, ctrl)
|
||||
|
||||
if (rss.ss_family == AF_INET &&
|
||||
ch->ch_Family == AF_INET &&
|
||||
sin->sin_addr.s_addr == ch->ch_Addr4.s_addr &&
|
||||
sin4->sin_addr.s_addr == ch->ch_Addr4.s_addr &&
|
||||
ch->ch_Service && strcmp(sep->se_service,
|
||||
ch->ch_Service) == 0) {
|
||||
chBest = ch;
|
||||
@ -2169,11 +2196,11 @@ cpmip(sep, ctrl)
|
||||
}
|
||||
if ((rss.ss_family == AF_INET &&
|
||||
(chBest->ch_Family != AF_INET ||
|
||||
sin->sin_addr.s_addr != chBest->ch_Addr4.s_addr)) ||
|
||||
sin4->sin_addr.s_addr != chBest->ch_Addr4.s_addr)) ||
|
||||
chBest->ch_Service == NULL ||
|
||||
strcmp(sep->se_service, chBest->ch_Service) != 0) {
|
||||
chBest->ch_Family = sin->sin_family;
|
||||
chBest->ch_Addr4 = sin->sin_addr;
|
||||
chBest->ch_Family = sin4->sin_family;
|
||||
chBest->ch_Addr4 = sin4->sin_addr;
|
||||
if (chBest->ch_Service)
|
||||
free(chBest->ch_Service);
|
||||
chBest->ch_Service = strdup(sep->se_service);
|
||||
|
@ -110,55 +110,24 @@ struct servtab {
|
||||
#define se_nomapped se_flags.se_nomapped
|
||||
#define se_reset se_flags.se_reset
|
||||
|
||||
void chargen_dg __P((int, struct servtab *));
|
||||
void chargen_stream __P((int, struct servtab *));
|
||||
void close_sep __P((struct servtab *));
|
||||
void flag_signal __P((int));
|
||||
void flag_config __P((int));
|
||||
void config __P((void));
|
||||
void daytime_dg __P((int, struct servtab *));
|
||||
void daytime_stream __P((int, struct servtab *));
|
||||
void discard_dg __P((int, struct servtab *));
|
||||
void discard_stream __P((int, struct servtab *));
|
||||
void echo_dg __P((int, struct servtab *));
|
||||
void echo_stream __P((int, struct servtab *));
|
||||
void endconfig __P((void));
|
||||
struct servtab *enter __P((struct servtab *));
|
||||
void freeconfig __P((struct servtab *));
|
||||
struct servtab *getconfigent __P((void));
|
||||
void iderror __P((int, int, int, char *));
|
||||
void ident_stream __P((int, struct servtab *));
|
||||
void machtime_dg __P((int, struct servtab *));
|
||||
void machtime_stream __P((int, struct servtab *));
|
||||
int matchservent __P((char *, char *, char *));
|
||||
char *newstr __P((char *));
|
||||
char *nextline __P((FILE *));
|
||||
void print_service __P((char *, struct servtab *));
|
||||
void addchild __P((struct servtab *, int));
|
||||
void flag_reapchild __P((int));
|
||||
void reapchild __P((void));
|
||||
void enable __P((struct servtab *));
|
||||
void disable __P((struct servtab *));
|
||||
void flag_retry __P((int));
|
||||
void retry __P((void));
|
||||
int setconfig __P((void));
|
||||
void setup __P((struct servtab *));
|
||||
#ifdef IPSEC
|
||||
void ipsecsetup __P((struct servtab *));
|
||||
#endif
|
||||
int check_loop __P((const struct sockaddr *, const struct servtab *sep));
|
||||
int getvalue __P((const char *, int *, const char *));
|
||||
char *newstr __P((const char *));
|
||||
void inetd_setproctitle __P((const char *, int));
|
||||
void print_service __P((const char *, const struct servtab *));
|
||||
char *sskip __P((char **));
|
||||
char *skip __P((char **));
|
||||
struct servtab *tcpmux __P((int));
|
||||
int cpmip __P((struct servtab *, int));
|
||||
void inetd_setproctitle __P((char *, int));
|
||||
int check_loop __P((struct sockaddr *, struct servtab *sep));
|
||||
|
||||
void unregisterrpc __P((register struct servtab *sep));
|
||||
extern int debug;
|
||||
extern struct servtab *servtab;
|
||||
|
||||
typedef void (bi_fn_t) __P((int, struct servtab *));
|
||||
|
||||
struct biltin {
|
||||
char *bi_service; /* internally provided service name */
|
||||
const char *bi_service; /* internally provided service name */
|
||||
int bi_socktype; /* type of socket supported */
|
||||
short bi_fork; /* 1 if should fork before call */
|
||||
int bi_maxchild; /* max number of children, -1=default */
|
||||
void (*bi_fn)(); /* function which performs it */
|
||||
bi_fn_t *bi_fn; /* function which performs it */
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user