parent
405f74d97e
commit
abb992e9a6
|
@ -51,7 +51,7 @@ being optional:
|
|||
daemon_list : client_list [ : shell_command ]
|
||||
.PP
|
||||
\fIdaemon_list\fR is a list of one or more daemon process names
|
||||
(argv[0] values) or wildcards (see below).
|
||||
(argv[0] values) or server port numbers or wildcards (see below).
|
||||
.PP
|
||||
\fIclient_list\fR is a list
|
||||
of one or more host names, host addresses, patterns or wildcards (see
|
||||
|
|
|
@ -231,6 +231,36 @@ int (*match_fn) ();
|
|||
return (NO);
|
||||
}
|
||||
|
||||
/*
|
||||
* daemon_or_port_match - match server information: if the server endpoint
|
||||
* pattern is a port number, match against port number of connection;
|
||||
* otherwise match against daemon executable name
|
||||
*/
|
||||
|
||||
static int daemon_or_port_match(char *tok, struct request_info *request) {
|
||||
unsigned int port, sin_port;
|
||||
char junk;
|
||||
|
||||
/* daemon name */
|
||||
if (sscanf(tok, "%u%c", &port, &junk) != 1 || port > 65535)
|
||||
return (string_match(tok, eval_daemon(request)));
|
||||
|
||||
/* port number */
|
||||
if (!request->server->sin)
|
||||
return (NO);
|
||||
|
||||
#ifdef INET6
|
||||
sin_port = ntohs(((struct sockaddr_in *)request->server->sin)->sin_port);
|
||||
#else
|
||||
sin_port = ntohs(request->server->sin->sin_port);
|
||||
#endif
|
||||
|
||||
if (port == sin_port)
|
||||
return (YES);
|
||||
else
|
||||
return (NO);
|
||||
}
|
||||
|
||||
/* server_match - match server information */
|
||||
|
||||
static int server_match(tok, request)
|
||||
|
@ -240,9 +270,9 @@ struct request_info *request;
|
|||
char *host;
|
||||
|
||||
if ((host = split_at(tok + 1, '@')) == 0) { /* plain daemon */
|
||||
return (string_match(tok, eval_daemon(request)));
|
||||
return (daemon_or_port_match(tok, request));
|
||||
} else { /* daemon@host */
|
||||
return (string_match(tok, eval_daemon(request))
|
||||
return (daemon_or_port_match(tok, request)
|
||||
&& host_match(host, request->server));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue