X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Funit.c;h=211704e230603882f78490ee314df5163a469252;hp=be554dac2082840297d88602a5afb14ae94f0e43;hb=b42defe3b8ed3947d85db654a6cdb1b9999f394d;hpb=8e2af478402414f060bbc16e1b4bbe7de1779c13 diff --git a/src/core/unit.c b/src/core/unit.c index be554dac2..211704e23 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2691,6 +2691,8 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co int r; assert(u); + assert(name); + assert(data); if (!(mode & (UNIT_PERSISTENT|UNIT_RUNTIME))) return 0; @@ -2703,6 +2705,23 @@ int unit_write_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name, co return write_string_file_atomic_label(q, data); } +int unit_write_drop_in_private_section(Unit *u, UnitSetPropertiesMode mode, const char *name, const char *data) { + _cleanup_free_ char *ndata = NULL; + + assert(u); + assert(name); + assert(data); + + if (!UNIT_VTABLE(u)->private_section) + return -EINVAL; + + ndata = strjoin("[", UNIT_VTABLE(u)->private_section, "]\n", data, NULL); + if (!ndata) + return -ENOMEM; + + return unit_write_drop_in(u, mode, name, ndata); +} + int unit_remove_drop_in(Unit *u, UnitSetPropertiesMode mode, const char *name) { _cleanup_free_ char *p = NULL, *q = NULL; int r;