diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-10-11 13:40:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 13:40:50 -0400 |
commit | b744e8937ce603090a9bf64ac7d8cc2c1a29e4f0 (patch) | |
tree | d6873059fd870c78dae268671ad0e12ac8c493db /src/libsystemd/sd-id128/sd-id128.c | |
parent | 40f45ff0c339971fd088e6f9cc2e61444087685d (diff) | |
parent | a46eac1bbddcdd15e741fc6c8389078db1067f81 (diff) |
Merge pull request #4067 from poettering/invocation-id
Add an "invocation ID" concept to the service manager
Diffstat (limited to 'src/libsystemd/sd-id128/sd-id128.c')
-rw-r--r-- | src/libsystemd/sd-id128/sd-id128.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index 9f47d04e61..d4450c70a0 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -129,6 +129,28 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) { return 0; } +_public_ int sd_id128_get_invocation(sd_id128_t *ret) { + static thread_local sd_id128_t saved_invocation_id = {}; + int r; + + assert_return(ret, -EINVAL); + + if (sd_id128_is_null(saved_invocation_id)) { + const char *e; + + e = secure_getenv("INVOCATION_ID"); + if (!e) + return -ENXIO; + + r = sd_id128_from_string(e, &saved_invocation_id); + if (r < 0) + return r; + } + + *ret = saved_invocation_id; + return 0; +} + static sd_id128_t make_v4_uuid(sd_id128_t id) { /* Stolen from generate_random_uuid() of drivers/char/random.c * in the kernel sources */ |