core: pass the socket cookie to invoked per-connection service instances as $SO_COOKIE env var
The socket cookie is just too useful for identifying connections, let's emphasize this a bit and pass it as environment variable.
This commit is contained in:
+9
-1
@@ -1749,7 +1749,7 @@ static int service_spawn_internal(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
our_env = new0(char*, 15);
|
||||
our_env = new0(char*, 16);
|
||||
if (!our_env)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1821,6 +1821,14 @@ static int service_spawn_internal(
|
||||
our_env[n_env++] = t;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t cookie;
|
||||
if (socket_get_cookie(s->socket_fd, &cookie) >= 0) {
|
||||
char *t;
|
||||
if (asprintf(&t, "SO_COOKIE=%" PRIu64, cookie) < 0)
|
||||
return -ENOMEM;
|
||||
our_env[n_env++] = t;
|
||||
}
|
||||
}
|
||||
|
||||
Service *env_source = NULL;
|
||||
|
||||
Reference in New Issue
Block a user