Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/inetcf.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
static struct inet_ent *inet_list = 0; | static struct inet_ent *inet_list = 0; | ||||
static char whitespace[] = " \t\r\n"; | static char whitespace[] = " \t\r\n"; | ||||
/* inet_conf - read in and examine inetd.conf (or tlid.conf) entries */ | /* inet_conf - read in and examine inetd.conf (or tlid.conf) entries */ | ||||
char *inet_cfg(conf) | char *inet_cfg(char *conf) | ||||
char *conf; | |||||
{ | { | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
FILE *fp; | FILE *fp; | ||||
char *service; | char *service; | ||||
char *protocol; | char *protocol; | ||||
char *user; | char *user; | ||||
char *path; | char *path; | ||||
char *arg0; | char *arg0; | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | inet_chk(protocol, path, arg0, arg1); | ||||
} | } | ||||
fclose(fp); | fclose(fp); | ||||
tcpd_context = saved_context; | tcpd_context = saved_context; | ||||
return (conf); | return (conf); | ||||
} | } | ||||
/* inet_chk - examine one inetd.conf (tlid.conf?) entry */ | /* inet_chk - examine one inetd.conf (tlid.conf?) entry */ | ||||
static void inet_chk(protocol, path, arg0, arg1) | static void inet_chk(char *protocol, char *path, char *arg0, char *arg1) | ||||
char *protocol; | |||||
char *path; | |||||
char *arg0; | |||||
char *arg1; | |||||
{ | { | ||||
char daemon[BUFSIZ]; | char daemon[BUFSIZ]; | ||||
struct stat st; | struct stat st; | ||||
int wrap_status = WR_MAYBE; | int wrap_status = WR_MAYBE; | ||||
char *base_name_path = base_name(path); | char *base_name_path = base_name(path); | ||||
char *tcpd_proc_name = (arg0[0] == '/' ? base_name(arg0) : arg0); | char *tcpd_proc_name = (arg0[0] == '/' ? base_name(arg0) : arg0); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | #endif | ||||
if (wrap_status == WR_YES && STR_EQ(protocol, "rpc/tcp")) | if (wrap_status == WR_YES && STR_EQ(protocol, "rpc/tcp")) | ||||
tcpd_warn("%s: cannot wrap rpc/tcp services", tcpd_proc_name); | tcpd_warn("%s: cannot wrap rpc/tcp services", tcpd_proc_name); | ||||
inet_set(tcpd_proc_name, wrap_status); | inet_set(tcpd_proc_name, wrap_status); | ||||
} | } | ||||
/* inet_set - remember service status */ | /* inet_set - remember service status */ | ||||
void inet_set(name, type) | void inet_set(char *name, int type) | ||||
char *name; | |||||
int type; | |||||
{ | { | ||||
struct inet_ent *ip = | struct inet_ent *ip = | ||||
(struct inet_ent *) malloc(sizeof(struct inet_ent) + strlen(name)); | (struct inet_ent *) malloc(sizeof(struct inet_ent) + strlen(name)); | ||||
if (ip == 0) { | if (ip == 0) { | ||||
fprintf(stderr, "out of memory\n"); | fprintf(stderr, "out of memory\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
ip->next = inet_list; | ip->next = inet_list; | ||||
strcpy(ip->name, name); | strcpy(ip->name, name); | ||||
ip->type = type; | ip->type = type; | ||||
inet_list = ip; | inet_list = ip; | ||||
} | } | ||||
/* inet_get - look up service status */ | /* inet_get - look up service status */ | ||||
int inet_get(name) | int inet_get(char *name) | ||||
char *name; | |||||
{ | { | ||||
struct inet_ent *ip; | struct inet_ent *ip; | ||||
if (inet_list == 0) | if (inet_list == 0) | ||||
return (WR_MAYBE); | return (WR_MAYBE); | ||||
for (ip = inet_list; ip; ip = ip->next) | for (ip = inet_list; ip; ip = ip->next) | ||||
if (STR_EQ(ip->name, name)) | if (STR_EQ(ip->name, name)) | ||||
return (ip->type); | return (ip->type); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
/* base_name - compute last pathname component */ | /* base_name - compute last pathname component */ | ||||
static char *base_name(path) | static char *base_name(char *path) | ||||
char *path; | |||||
{ | { | ||||
char *cp; | char *cp; | ||||
if ((cp = strrchr(path, '/')) != 0) | if ((cp = strrchr(path, '/')) != 0) | ||||
path = cp + 1; | path = cp + 1; | ||||
return (path); | return (path); | ||||
} | } |