if (cg_path_get_unit(c, &t) >= 0) {
x = strappenda("_SYSTEMD_UNIT=", t);
free(t);
- } else if (cg_path_get_user_unit(c, &t) >= 0) {
+ IOVEC_SET_STRING(iovec[n++], x);
+ } else if (unit_id && !session) {
+ x = strappenda("_SYSTEMD_UNIT=", unit_id);
+ IOVEC_SET_STRING(iovec[n++], x);
+ }
+
+ if (cg_path_get_user_unit(c, &t) >= 0) {
x = strappenda("_SYSTEMD_USER_UNIT=", t);
free(t);
- } else if (unit_id) {
- if (session)
- x = strappenda("_SYSTEMD_USER_UNIT=", unit_id);
- else
- x = strappenda("_SYSTEMD_UNIT=", unit_id);
- } else
- x = NULL;
-
- if (x)
IOVEC_SET_STRING(iovec[n++], x);
+ } else if (unit_id && session) {
+ x = strappenda("_SYSTEMD_USER_UNIT=", unit_id);
+ IOVEC_SET_STRING(iovec[n++], x);
+ }
free(c);
}
if (cg_path_get_unit(c, &t) >= 0) {
x = strappenda("OBJECT_SYSTEMD_UNIT=", t);
free(t);
- } else if (cg_path_get_user_unit(c, &t) >= 0) {
+ IOVEC_SET_STRING(iovec[n++], x);
+ }
+
+ if (cg_path_get_user_unit(c, &t) >= 0) {
x = strappenda("OBJECT_SYSTEMD_USER_UNIT=", t);
free(t);
- } else
- x = NULL;
-
- if (x)
IOVEC_SET_STRING(iovec[n++], x);
+ }
free(c);
}