dropin.c revision 3ffd4af22052963e7a29431721ee204e634bea75
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "conf-files.h"
#include "dropin.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio-label.h"
#include "mkdir.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
_cleanup_free_ char *b = NULL;
char *p, *q;
char prefix[DECIMAL_STR_MAX(unsigned)];
if (!b)
return -ENOMEM;
if (!filename_is_valid(b))
return -EINVAL;
if (!p)
return -ENOMEM;
if (!q) {
free(p);
return -ENOMEM;
}
*_p = p;
*_q = q;
return 0;
}
int r;
if (r < 0)
return r;
(void) mkdir_p(p, 0755);
return write_string_file_atomic_label(q, data);
}
_cleanup_free_ char *p = NULL;
int r;
if (r < 0)
return -ENOMEM;
}
static int iterate_dir(
const char *path,
void *arg,
char ***strv) {
int r;
/* The config directories are special, since the order of the
* drop-ins matters */
if (dependency < 0) {
if (r < 0)
return log_oom();
return 0;
}
if (!d) {
return 0;
}
for (;;) {
_cleanup_free_ char *f = NULL;
errno = 0;
if (!de)
break;
continue;
if (!f)
return log_oom();
if (r < 0)
return r;
}
return 0;
}
const char *unit_path,
const char *name,
const char *suffix,
void *arg,
char ***strv) {
int r;
if (!path)
return log_oom();
/* Also try the template dir */
if (r < 0)
return log_error_errno(r, "Failed to generate template from unit name: %m");
if (!p)
return log_oom();
}
return 0;
}
char **lookup_path,
char ***paths) {
Iterator i;
char *t;
int r;
SET_FOREACH(t, names, i) {
char **p;
}
if (strv_isempty(strv))
return 0;
if (r < 0)
return log_warning_errno(r, "Failed to get list of configuration files: %m");
return 1;
}