mirror of
https://github.com/systemd/systemd
synced 2025-10-04 11:14:45 +02:00
Compare commits
No commits in common. "43b4e3058c106e663bbd5413e7bd106e55d6fd79" and "c9c4899f4444d9586e541b5e72597a37f949433a" have entirely different histories.
43b4e3058c
...
c9c4899f44
@ -173,11 +173,50 @@
|
|||||||
<citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
|
<citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>Valid partition names follow the <ulink
|
<para>Valid partition names follow the <ulink url="https://systemd.io/DISCOVERABLE_PARTITIONS">Discoverable
|
||||||
url="https://systemd.io/DISCOVERABLE_PARTITIONS">Discoverable Partitions Specification</ulink>:
|
Partitions Specification</ulink>.</para>
|
||||||
<constant>root</constant>, <constant>usr</constant>, <constant>home</constant>, <constant>srv</constant>,
|
|
||||||
<constant>esp</constant>, <constant>xbootldr</constant>, <constant>tmp</constant>,
|
<table>
|
||||||
<constant>var</constant>.</para>
|
<title>Accepted partition names</title>
|
||||||
|
|
||||||
|
<tgroup cols='1'>
|
||||||
|
<colspec colname='partition' />
|
||||||
|
<thead>
|
||||||
|
<row>
|
||||||
|
<entry>Partition Name</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry>root</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>root-secondary</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>home</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>srv</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>esp</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>xbootldr</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>tmp</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>var</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>usr</entry>
|
||||||
|
</row>
|
||||||
|
</tbody>
|
||||||
|
</tgroup>
|
||||||
|
</table>
|
||||||
|
|
||||||
<xi:include href="system-only.xml" xpointer="singular"/></listitem>
|
<xi:include href="system-only.xml" xpointer="singular"/></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -1230,11 +1230,6 @@ int safe_fork_full(
|
|||||||
|
|
||||||
original_pid = getpid_cached();
|
original_pid = getpid_cached();
|
||||||
|
|
||||||
if (flags & FORK_FLUSH_STDIO) {
|
|
||||||
fflush(stdout);
|
|
||||||
fflush(stderr); /* This one shouldn't be necessary, stderr should be unbuffered anyway, but let's better be safe than sorry */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & (FORK_RESET_SIGNALS|FORK_DEATHSIG)) {
|
if (flags & (FORK_RESET_SIGNALS|FORK_DEATHSIG)) {
|
||||||
/* We temporarily block all signals, so that the new child has them blocked initially. This way, we can
|
/* We temporarily block all signals, so that the new child has them blocked initially. This way, we can
|
||||||
* be sure that SIGTERMs are not lost we might send to the child. */
|
* be sure that SIGTERMs are not lost we might send to the child. */
|
||||||
|
@ -162,7 +162,6 @@ typedef enum ForkFlags {
|
|||||||
FORK_MOUNTNS_SLAVE = 1 << 9, /* Make child's mount namespace MS_SLAVE */
|
FORK_MOUNTNS_SLAVE = 1 << 9, /* Make child's mount namespace MS_SLAVE */
|
||||||
FORK_RLIMIT_NOFILE_SAFE = 1 << 10, /* Set RLIMIT_NOFILE soft limit to 1K for select() compat */
|
FORK_RLIMIT_NOFILE_SAFE = 1 << 10, /* Set RLIMIT_NOFILE soft limit to 1K for select() compat */
|
||||||
FORK_STDOUT_TO_STDERR = 1 << 11, /* Make stdout a copy of stderr */
|
FORK_STDOUT_TO_STDERR = 1 << 11, /* Make stdout a copy of stderr */
|
||||||
FORK_FLUSH_STDIO = 1 << 12, /* fflush() stdout (and stderr) before forking */
|
|
||||||
} ForkFlags;
|
} ForkFlags;
|
||||||
|
|
||||||
int safe_fork_full(const char *name, const int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid);
|
int safe_fork_full(const char *name, const int except_fds[], size_t n_except_fds, ForkFlags flags, pid_t *ret_pid);
|
||||||
|
@ -1116,7 +1116,7 @@ static int run_debug(int argc, char **argv, void *userdata) {
|
|||||||
|
|
||||||
fork_name = strjoina("(", debugger_call[0], ")");
|
fork_name = strjoina("(", debugger_call[0], ")");
|
||||||
|
|
||||||
r = safe_fork(fork_name, FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG|FORK_FLUSH_STDIO, &pid);
|
r = safe_fork(fork_name, FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto finish;
|
goto finish;
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
@ -705,31 +705,76 @@ static int is_symlink_with_known_name(const UnitFileInstallInfo *i, const char *
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_symlinks_in_directory(
|
static int find_symlinks_fd(
|
||||||
DIR *dir,
|
|
||||||
const char *dir_path,
|
|
||||||
const char *root_dir,
|
const char *root_dir,
|
||||||
const UnitFileInstallInfo *i,
|
const UnitFileInstallInfo *i,
|
||||||
bool match_aliases,
|
bool match_aliases,
|
||||||
bool ignore_same_name,
|
bool ignore_same_name,
|
||||||
|
int fd,
|
||||||
|
const char *path,
|
||||||
const char *config_path,
|
const char *config_path,
|
||||||
bool *same_name_link) {
|
bool *same_name_link) {
|
||||||
|
|
||||||
|
_cleanup_closedir_ DIR *d = NULL;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
FOREACH_DIRENT(de, dir, return -errno) {
|
assert(i);
|
||||||
_cleanup_free_ char *dest = NULL;
|
assert(fd >= 0);
|
||||||
|
assert(path);
|
||||||
|
assert(config_path);
|
||||||
|
assert(same_name_link);
|
||||||
|
|
||||||
|
d = fdopendir(fd);
|
||||||
|
if (!d) {
|
||||||
|
safe_close(fd);
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH_DIRENT(de, d, return -errno) {
|
||||||
|
|
||||||
|
dirent_ensure_type(d, de);
|
||||||
|
|
||||||
|
if (de->d_type == DT_DIR) {
|
||||||
|
_cleanup_free_ char *p = NULL;
|
||||||
|
int nfd, q;
|
||||||
|
|
||||||
|
nfd = openat(fd, de->d_name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
|
||||||
|
if (nfd < 0) {
|
||||||
|
if (errno == ENOENT)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (r == 0)
|
||||||
|
r = -errno;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = path_make_absolute(de->d_name, path);
|
||||||
|
if (!p) {
|
||||||
|
safe_close(nfd);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This will close nfd, regardless whether it succeeds or not */
|
||||||
|
q = find_symlinks_fd(root_dir, i, match_aliases, ignore_same_name, nfd,
|
||||||
|
p, config_path, same_name_link);
|
||||||
|
if (q > 0)
|
||||||
|
return 1;
|
||||||
|
if (r == 0)
|
||||||
|
r = q;
|
||||||
|
|
||||||
|
} else if (de->d_type == DT_LNK) {
|
||||||
|
_cleanup_free_ char *p = NULL, *dest = NULL;
|
||||||
bool found_path = false, found_dest, b = false;
|
bool found_path = false, found_dest, b = false;
|
||||||
int q;
|
int q;
|
||||||
|
|
||||||
dirent_ensure_type(dir, de);
|
/* Acquire symlink name */
|
||||||
|
p = path_make_absolute(de->d_name, path);
|
||||||
if (de->d_type != DT_LNK)
|
if (!p)
|
||||||
continue;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Acquire symlink destination */
|
/* Acquire symlink destination */
|
||||||
q = readlinkat_malloc(dirfd(dir), de->d_name, &dest);
|
q = readlink_malloc(p, &dest);
|
||||||
if (q == -ENOENT)
|
if (q == -ENOENT)
|
||||||
continue;
|
continue;
|
||||||
if (q < 0) {
|
if (q < 0) {
|
||||||
@ -742,7 +787,7 @@ static int find_symlinks_in_directory(
|
|||||||
if (!path_is_absolute(dest)) {
|
if (!path_is_absolute(dest)) {
|
||||||
char *x;
|
char *x;
|
||||||
|
|
||||||
x = path_join(dir_path, dest);
|
x = path_join(root_dir, dest);
|
||||||
if (!x)
|
if (!x)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -762,17 +807,15 @@ static int find_symlinks_in_directory(
|
|||||||
found_dest = streq(basename(dest), i->name);
|
found_dest = streq(basename(dest), i->name);
|
||||||
|
|
||||||
if (found_path && found_dest) {
|
if (found_path && found_dest) {
|
||||||
_cleanup_free_ char *p = NULL, *t = NULL;
|
_cleanup_free_ char *t = NULL;
|
||||||
|
|
||||||
/* Filter out same name links in the main
|
/* Filter out same name links in the main
|
||||||
* config path */
|
* config path */
|
||||||
p = path_make_absolute(de->d_name, dir_path);
|
|
||||||
t = path_make_absolute(i->name, config_path);
|
t = path_make_absolute(i->name, config_path);
|
||||||
|
if (!t)
|
||||||
if (!p || !t)
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
b = path_equal(p, t);
|
b = path_equal(t, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
@ -789,6 +832,7 @@ static int find_symlinks_in_directory(
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -801,55 +845,22 @@ static int find_symlinks(
|
|||||||
const char *config_path,
|
const char *config_path,
|
||||||
bool *same_name_link) {
|
bool *same_name_link) {
|
||||||
|
|
||||||
_cleanup_closedir_ DIR *config_dir = NULL;
|
int fd;
|
||||||
struct dirent *de;
|
|
||||||
int r = 0;
|
|
||||||
|
|
||||||
assert(i);
|
assert(i);
|
||||||
assert(config_path);
|
assert(config_path);
|
||||||
assert(same_name_link);
|
assert(same_name_link);
|
||||||
|
|
||||||
config_dir = opendir(config_path);
|
fd = open(config_path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC);
|
||||||
if (!config_dir) {
|
if (fd < 0) {
|
||||||
if (IN_SET(errno, ENOENT, ENOTDIR, EACCES))
|
if (IN_SET(errno, ENOENT, ENOTDIR, EACCES))
|
||||||
return 0;
|
return 0;
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
FOREACH_DIRENT(de, config_dir, return -errno) {
|
/* This takes possession of fd and closes it */
|
||||||
const char *suffix;
|
return find_symlinks_fd(root_dir, i, match_name, ignore_same_name, fd,
|
||||||
_cleanup_free_ const char *path = NULL;
|
config_path, config_path, same_name_link);
|
||||||
_cleanup_closedir_ DIR *d = NULL;
|
|
||||||
|
|
||||||
dirent_ensure_type(config_dir, de);
|
|
||||||
|
|
||||||
if (de->d_type != DT_DIR)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
suffix = strrchr(de->d_name, '.');
|
|
||||||
if (!STRPTR_IN_SET(suffix, ".wants", ".requires"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
path = path_join(config_path, de->d_name);
|
|
||||||
if (!path)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
d = opendir(path);
|
|
||||||
if (!d) {
|
|
||||||
log_error_errno(errno, "Failed to open directory '%s' while scanning for symlinks, ignoring: %m", path);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = find_symlinks_in_directory(d, path, root_dir, i, match_name, ignore_same_name, config_path, same_name_link);
|
|
||||||
if (r > 0)
|
|
||||||
return 1;
|
|
||||||
else if (r < 0)
|
|
||||||
log_debug_errno(r, "Failed to lookup for symlinks in '%s': %m", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We didn't find any suitable symlinks in .wants or .requires directories, let's look for linked unit files in this directory. */
|
|
||||||
rewinddir(config_dir);
|
|
||||||
return find_symlinks_in_directory(config_dir, config_path, root_dir, i, match_name, ignore_same_name, config_path, same_name_link);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_symlinks_in_scope(
|
static int find_symlinks_in_scope(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user