tmpfiles.c revision bfaf42d22bbd72a286b519ea121dbf8e799b1fe5
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <dirent.h>
#include <grp.h>
#include <pwd.h>
#include "log.h"
#include "util.h"
#include "strv.h"
#include "label.h"
/* This reads all files listed in /etc/tempfiles.d/?*.conf and creates
* them in the file system. This is intended to be used to create
* bootup. */
static void process_line(const char *fname, unsigned line, const char *buffer, const char *prefix) {
char type;
unsigned mode;
int n, fd = -1;
"%c "
"%ms "
"%o "
"%ms "
"%ms ",
&type,
&path,
&mode,
&user,
&group)) < 2) {
goto finish;
}
goto finish;
}
goto finish;
unsigned long lu;
struct passwd *p;
uid = 0;
else {
goto finish;
}
uid_set = true;
}
unsigned long lu;
struct group *g;
gid = 0;
else {
goto finish;
}
gid_set = true;
}
if (n < 3)
if (type == 'f') {
mode_t u;
u = umask(0);
umask(u);
if (fd < 0) {
goto finish;
}
goto finish;
}
goto finish;
}
goto finish;
}
goto finish;
}
}
} else if (type == 'd') {
mode_t u;
int r;
u = umask(0);
umask(u);
goto finish;
}
goto finish;
}
goto finish;
}
goto finish;
}
goto finish;
}
}
}
if (fd >= 0)
}
static int scandir_filter(const struct dirent *d) {
assert(d);
if (ignore_file(d->d_name))
return 0;
return 0;
}
int r = EXIT_FAILURE, n, i;
if (argc > 2) {
log_error("This program takes no more than one argument.");
return EXIT_FAILURE;
} else if (argc > 1)
else
prefix = "/";
log_open();
label_init();
r = EXIT_SUCCESS;
else
log_error("Failed to enumerate /etc/tempfiles.d/ files: %m");
goto finish;
}
r = EXIT_SUCCESS;
for (i = 0; i < n; i++) {
int k;
char *fn;
FILE *f;
unsigned j;
if (k < 0) {
log_error("Failed to allocate file name.");
r = EXIT_FAILURE;
continue;
}
if (!f) {
r = EXIT_FAILURE;
continue;
}
j = 0;
for (;;) {
break;
j++;
if (*l == '#' || *l == 0)
continue;
}
if (ferror(f)) {
r = EXIT_FAILURE;
log_error("Failed to read from file: %m");
}
fclose(f);
}
return r;
}