core: use SYNTHETIC_ERRNO() macro
This commit is contained in:
+16
-32
@@ -402,35 +402,23 @@ static int socket_verify(Socket *s) {
|
||||
assert(s);
|
||||
assert(UNIT(s)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!s->ports) {
|
||||
log_unit_error(UNIT(s), "Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
if (!s->ports)
|
||||
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.");
|
||||
|
||||
if (s->accept && have_non_accept_socket(s)) {
|
||||
log_unit_error(UNIT(s), "Unit configured for accepting sockets, but sockets are non-accepting. Refusing.");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
if (s->accept && have_non_accept_socket(s))
|
||||
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit configured for accepting sockets, but sockets are non-accepting. Refusing.");
|
||||
|
||||
if (s->accept && s->max_connections <= 0) {
|
||||
log_unit_error(UNIT(s), "MaxConnection= setting too small. Refusing.");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
if (s->accept && s->max_connections <= 0)
|
||||
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "MaxConnection= setting too small. Refusing.");
|
||||
|
||||
if (s->accept && UNIT_DEREF(s->service)) {
|
||||
log_unit_error(UNIT(s), "Explicit service configuration for accepting socket units not supported. Refusing.");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
if (s->accept && UNIT_DEREF(s->service))
|
||||
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Explicit service configuration for accepting socket units not supported. Refusing.");
|
||||
|
||||
if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
|
||||
log_unit_error(UNIT(s), "Unit has PAM enabled. Kill mode must be set to 'control-group'. Refusing.");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP)
|
||||
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has PAM enabled. Kill mode must be set to 'control-group'. Refusing.");
|
||||
|
||||
if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s)) {
|
||||
log_unit_error(UNIT(s), "Unit has symlinks set but none or more than one node in the file system. Refusing.");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s))
|
||||
return log_unit_error_errno(UNIT(s), SYNTHETIC_ERRNO(ENOEXEC), "Unit has symlinks set but none or more than one node in the file system. Refusing.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2507,17 +2495,13 @@ static int socket_start(Unit *u) {
|
||||
|
||||
service = SERVICE(UNIT_DEREF(s->service));
|
||||
|
||||
if (UNIT(service)->load_state != UNIT_LOADED) {
|
||||
log_unit_error(u, "Socket service %s not loaded, refusing.", UNIT(service)->id);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (UNIT(service)->load_state != UNIT_LOADED)
|
||||
return log_unit_error_errno(u, SYNTHETIC_ERRNO(ENOENT), "Socket service %s not loaded, refusing.", UNIT(service)->id);
|
||||
|
||||
/* If the service is already active we cannot start the
|
||||
* socket */
|
||||
if (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED, SERVICE_AUTO_RESTART)) {
|
||||
log_unit_error(u, "Socket service %s already active, refusing.", UNIT(service)->id);
|
||||
return -EBUSY;
|
||||
}
|
||||
if (!IN_SET(service->state, SERVICE_DEAD, SERVICE_FAILED, SERVICE_AUTO_RESTART))
|
||||
return log_unit_error_errno(u, SYNTHETIC_ERRNO(EBUSY), "Socket service %s already active, refusing.", UNIT(service)->id);
|
||||
}
|
||||
|
||||
assert(IN_SET(s->state, SOCKET_DEAD, SOCKET_FAILED));
|
||||
|
||||
Reference in New Issue
Block a user