diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-06 14:39:12 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-03-15 18:53:23 +0900 |
commit | 8efb042e0cf52ef386651606a2d3e187b69c840d (patch) | |
tree | 66abeb395117335d417ca6d50b5aaf89447b16db /src/libsystemd/sd-id128 | |
parent | 9363e2f4999dd5ccf40af0295b42a888e43c9f66 (diff) | |
download | systemd-8efb042e0cf52ef386651606a2d3e187b69c840d.tar.gz |
sd-id128: split the logic obtaining invocation ID from sd_id128_get_invocation()
Diffstat (limited to 'src/libsystemd/sd-id128')
-rw-r--r-- | src/libsystemd/sd-id128/sd-id128.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c index e72af1593c..6c7165eb93 100644 --- a/src/libsystemd/sd-id128/sd-id128.c +++ b/src/libsystemd/sd-id128/sd-id128.c @@ -215,6 +215,18 @@ static int get_invocation_from_keyring(sd_id128_t *ret) { return 1; } +static int get_invocation_from_environment(sd_id128_t *ret) { + const char *e; + + assert(ret); + + e = secure_getenv("INVOCATION_ID"); + if (!e) + return -ENXIO; + + return sd_id128_from_string(e, ret); +} + _public_ int sd_id128_get_invocation(sd_id128_t *ret) { static thread_local sd_id128_t saved_invocation_id = {}; int r; @@ -237,13 +249,7 @@ _public_ int sd_id128_get_invocation(sd_id128_t *ret) { return r; if (r == 0) { - const char *e; - - e = secure_getenv("INVOCATION_ID"); - if (!e) - return -ENXIO; - - r = sd_id128_from_string(e, &saved_invocation_id); + r = get_invocation_from_environment(&saved_invocation_id); if (r < 0) return r; } |