*i = (Inhibitor) {
.manager = m,
+ .id = strdup(id),
+ .state_file = path_join("/run/systemd/inhibit/", id),
.what = _INHIBIT_WHAT_INVALID,
.mode = _INHIBIT_MODE_INVALID,
.uid = UID_INVALID,
.pid = PIDREF_NULL,
};
- i->state_file = path_join("/run/systemd/inhibit", id);
- if (!i->state_file)
+ if (!i->id || !i->state_file)
return -ENOMEM;
- i->id = basename(i->state_file);
-
r = hashmap_put(m->inhibitors, i->id, i);
if (r < 0)
return r;
/* Note that we don't remove neither the state file nor the fifo path here, since we want both to
* survive daemon restarts */
- free(i->state_file);
free(i->fifo_path);
+ free(i->state_file);
+ free(i->id);
pidref_done(&i->pid);