mirror of
https://github.com/troglobit/finit.git
synced 2026-11-20 19:41:51 +00:00
inetd: Fix naming of built-in service on custom port.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
231539cd7d
commit
0de4fb0cbf
3 files changed
+11
-10
No files matched your search
@@ -468,7 +468,7 @@ int inetd_filter_str(inetd_t *inetd, char *str, size_t len)
|
|||||||
* If equivalent service exists already service_register() will instead call
|
* If equivalent service exists already service_register() will instead call
|
||||||
* inetd_allow().
|
* inetd_allow().
|
||||||
*/
|
*/
|
||||||
int inetd_new(inetd_t *inetd, char *service, char *proto, int forking, void *arg)
|
int inetd_new(inetd_t *inetd, char *name, char *service, char *proto, int forking, void *arg)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
struct servent *sv = NULL;
|
struct servent *sv = NULL;
|
||||||
@@ -486,7 +486,9 @@ int inetd_new(inetd_t *inetd, char *service, char *proto, int forking, void *arg
|
|||||||
inetd->port = ntohs(sv->s_port);
|
inetd->port = ntohs(sv->s_port);
|
||||||
inetd->proto = pv->p_proto;
|
inetd->proto = pv->p_proto;
|
||||||
inetd->forking = !!forking;
|
inetd->forking = !!forking;
|
||||||
strlcpy(inetd->name, service, sizeof(inetd->name));
|
if (!name)
|
||||||
|
name = service;
|
||||||
|
strlcpy(inetd->name, name, sizeof(inetd->name));
|
||||||
|
|
||||||
/* Naïve mapping tcp->stream, udp->dgram, other->dgram */
|
/* Naïve mapping tcp->stream, udp->dgram, other->dgram */
|
||||||
if (!strcasecmp(sv->s_proto, "tcp"))
|
if (!strcasecmp(sv->s_proto, "tcp"))
|
||||||
@@ -500,7 +502,7 @@ int inetd_new(inetd_t *inetd, char *service, char *proto, int forking, void *arg
|
|||||||
/* Setup socket callback argument */
|
/* Setup socket callback argument */
|
||||||
inetd->arg = arg;
|
inetd->arg = arg;
|
||||||
|
|
||||||
_d("New service %s (default port %d proto %s:%d)", service, inetd->port, sv->s_proto, pv->p_proto);
|
_d("New service %s (default port %d proto %s:%d)", name, inetd->port, sv->s_proto, pv->p_proto);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ void inetd_stop (inetd_t *inetd);
|
|||||||
|
|
||||||
int inetd_respawn (pid_t pid);
|
int inetd_respawn (pid_t pid);
|
||||||
|
|
||||||
int inetd_new (inetd_t *inetd, char *service, char *proto, int forking, void *arg);
|
int inetd_new (inetd_t *inetd, char *name, char *service, char *proto, int forking, void *arg);
|
||||||
int inetd_del (inetd_t *inetd);
|
int inetd_del (inetd_t *inetd);
|
||||||
|
|
||||||
int inetd_match (inetd_t *inetd, char *service, char *proto);
|
int inetd_match (inetd_t *inetd, char *service, char *proto);
|
||||||
|
|||||||
@@ -671,11 +671,12 @@ int service_register(int type, char *line, time_t mtime, char *username)
|
|||||||
|
|
||||||
#ifndef INETD_DISABLED
|
#ifndef INETD_DISABLED
|
||||||
if (svc_is_inetd(svc)) {
|
if (svc_is_inetd(svc)) {
|
||||||
char *iface;
|
char *iface, *name = service;
|
||||||
|
|
||||||
_d("Creating new svc job %d inetd %s proto %s iface %s",
|
if (svc->inetd.cmd && plugin)
|
||||||
svc->job, service, proto, ifaces);
|
name = plugin->name;
|
||||||
if (inetd_new(&svc->inetd, service, proto, forking, svc)) {
|
|
||||||
|
if (inetd_new(&svc->inetd, name, service, proto, forking, svc)) {
|
||||||
_e("Failed registering new inetd service %s.", service);
|
_e("Failed registering new inetd service %s.", service);
|
||||||
inetd_del(&svc->inetd);
|
inetd_del(&svc->inetd);
|
||||||
return svc_del(svc);
|
return svc_del(svc);
|
||||||
@@ -687,9 +688,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
|
|||||||
return inetd_allow(&svc->inetd, NULL);
|
return inetd_allow(&svc->inetd, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
_d("Setting up interface filters for inetd service %s ...", service);
|
|
||||||
for (iface = strtok(ifaces, ","); iface; iface = strtok(NULL, ",")) {
|
for (iface = strtok(ifaces, ","); iface; iface = strtok(NULL, ",")) {
|
||||||
_d("Checking interface name %s ...", iface);
|
|
||||||
if (iface[0] == '!')
|
if (iface[0] == '!')
|
||||||
inetd_deny(&svc->inetd, &iface[1]);
|
inetd_deny(&svc->inetd, &iface[1]);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user