Systemd/src/shared/path-lookup.h
Zbigniew Jędrzejewski-Szmek 12ed81d9c8 Make systemctl --root look for files in the proper places
Running systemctl enable/disable/set-default/... with the --root
option under strace reveals that it accessed various files and
directories in the main fs, and not underneath the specified root.
This can lead to correct results only when the layout and
configuration in the container are identical, which often is not the
case. Fix this by adding the specified root to all file access
operations.

This patch does not handle some corner cases: symlinks which point
outside of the specified root might be interpreted differently than
they would be by the kernel if the specified root was the real root.
But systemctl does not create such symlinks by itself, and I think
this is enough of a corner case not to be worth the additional
complexity of reimplementing link chasing in systemd.

Also, simplify the code in a few places and remove an hypothetical
memory leak on error.
2014-05-15 15:29:58 +02:00

54 lines
1.7 KiB
C

/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
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/>.
***/
typedef struct LookupPaths {
char **unit_path;
#ifdef HAVE_SYSV_COMPAT
char **sysvinit_path;
char **sysvrcnd_path;
#endif
} LookupPaths;
typedef enum SystemdRunningAs {
SYSTEMD_SYSTEM,
SYSTEMD_USER,
_SYSTEMD_RUNNING_AS_MAX,
_SYSTEMD_RUNNING_AS_INVALID = -1
} SystemdRunningAs;
#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
const char* systemd_running_as_to_string(SystemdRunningAs i) _const_;
SystemdRunningAs systemd_running_as_from_string(const char *s) _pure_;
int user_config_home(char **config_home);
int lookup_paths_init(LookupPaths *p,
SystemdRunningAs running_as,
bool personal,
const char *root_dir,
const char *generator,
const char *generator_early,
const char *generator_late);
void lookup_paths_free(LookupPaths *p);