Skip to content

Commit

Permalink
socket: refuse socket activation for SysV services
Browse files Browse the repository at this point in the history
Make sure that when a .socket unit is installed without its matching
.service we don't end up activating a legacy SysV/LSB service with the
same name. SysV/LSB style services do not support passing sockets and we
don't want to extend SysV/LSB to ensure we don't break compatibility
with other systems.
  • Loading branch information
poettering committed Feb 14, 2011
1 parent a4c24ff commit 7b4bf06
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ static int socket_instantiate_service(Socket *s) {
if (r < 0)
return r;

#ifdef HAVE_SYSV_COMPAT
if (SERVICE(u)->sysv_path) {
log_error("Using SysV services for socket activation is not supported. Refusing.");
return -ENOENT;
}
#endif

u->meta.no_gc = true;
s->service = SERVICE(u);
return 0;
Expand Down Expand Up @@ -1354,12 +1361,19 @@ static int socket_start(Unit *u) {
if (s->service->meta.load_state != UNIT_LOADED)
return -ENOENT;

/* If the service is alredy actvie we cannot start the
/* If the service is alredy active we cannot start the
* socket */
if (s->service->state != SERVICE_DEAD &&
s->service->state != SERVICE_FAILED &&
s->service->state != SERVICE_AUTO_RESTART)
return -EBUSY;

#ifdef HAVE_SYSV_COMPAT
if (s->service->sysv_path) {
log_error("Using SysV services for socket activation is not supported. Refusing.");
return -ENOENT;
}
#endif
}

assert(s->state == SOCKET_DEAD || s->state == SOCKET_FAILED);
Expand Down

0 comments on commit 7b4bf06

Please sign in to comment.