summaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-30 20:21:00 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-05 15:06:42 -0700
commit7410616cd9dbbec97cf98d75324da5cda2b2f7a2 (patch)
tree6d968995b3bdf961603ab4853bf078c0dbdce27c /src/core/socket.c
parent6442185ab674cc202d63c18605057b9a51ca2722 (diff)
core: rework unit name validation and manipulation logic
A variety of changes: - Make sure all our calls distuingish OOM from other errors if OOM is not the only error possible. - Be much stricter when parsing escaped paths, do not accept trailing or leading escaped slashes. - Change unit validation to take a bit mask for allowing plain names, instance names or template names or an combination thereof. - Refuse manipulating invalid unit name
Diffstat (limited to 'src/core/socket.c')
-rw-r--r--src/core/socket.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 67beda44d6..55334e4a54 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -196,12 +196,15 @@ int socket_instantiate_service(Socket *s) {
* here. For Accept=no this is mostly a NOP since the service
* is figured out at load time anyway. */
- if (UNIT_DEREF(s->service) || !s->accept)
+ if (UNIT_DEREF(s->service))
return 0;
- prefix = unit_name_to_prefix(UNIT(s)->id);
- if (!prefix)
- return -ENOMEM;
+ if (!s->accept)
+ return 0;
+
+ r = unit_name_to_prefix(UNIT(s)->id, &prefix);
+ if (r < 0)
+ return r;
if (asprintf(&name, "%s@%u.service", prefix, s->n_accepted) < 0)
return -ENOMEM;
@@ -1836,17 +1839,13 @@ static void socket_enter_running(Socket *s, int cfd) {
return;
}
- prefix = unit_name_to_prefix(UNIT(s)->id);
- if (!prefix) {
- r = -ENOMEM;
+ r = unit_name_to_prefix(UNIT(s)->id, &prefix);
+ if (r < 0)
goto fail;
- }
- name = unit_name_build(prefix, instance, ".service");
- if (!name) {
- r = -ENOMEM;
+ r = unit_name_build(prefix, instance, ".service", &name);
+ if (r < 0)
goto fail;
- }
r = unit_add_name(UNIT_DEREF(s->service), name);
if (r < 0)