mirror of
https://github.com/systemd/systemd.git
synced 2024-11-28 12:53:36 +08:00
Merge pull request #3151 from keszybz/pr3149-2
Assorted fixes #3149 + one commit tacked on top
This commit is contained in:
commit
26ccc1d087
@ -73,6 +73,12 @@
|
||||
<filename>foo.timer</filename> activates a matching service
|
||||
<filename>foo.service</filename>. The unit to activate may be
|
||||
controlled by <varname>Unit=</varname> (see below).</para>
|
||||
|
||||
<para>Note that in case the unit to activate is already active at the time the timer elapses it is not restarted,
|
||||
but simply left running. There is no concept of spawning new service instances in this case. Due to this, services
|
||||
with <varname>RemainAfterExit=</varname> set (which stay around continously even after the service's main process
|
||||
exited) are usually not suitable for activation via repetitive timers, as they will only be activated once, and
|
||||
then stay around forever.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -364,7 +364,7 @@ static int fd_copy_directory(
|
||||
q = fd_copy_symlink(dirfd(d), de->d_name, &buf, fdt, de->d_name);
|
||||
else if (S_ISFIFO(buf.st_mode))
|
||||
q = fd_copy_fifo(dirfd(d), de->d_name, &buf, fdt, de->d_name);
|
||||
else if (S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode))
|
||||
else if (S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode) || S_ISSOCK(buf.st_mode))
|
||||
q = fd_copy_node(dirfd(d), de->d_name, &buf, fdt, de->d_name);
|
||||
else
|
||||
q = -EOPNOTSUPP;
|
||||
@ -396,7 +396,7 @@ int copy_tree_at(int fdf, const char *from, int fdt, const char *to, bool merge)
|
||||
return fd_copy_symlink(fdf, from, &st, fdt, to);
|
||||
else if (S_ISFIFO(st.st_mode))
|
||||
return fd_copy_fifo(fdf, from, &st, fdt, to);
|
||||
else if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))
|
||||
else if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode) || S_ISSOCK(st.st_mode))
|
||||
return fd_copy_node(fdf, from, &st, fdt, to);
|
||||
else
|
||||
return -EOPNOTSUPP;
|
||||
|
@ -772,6 +772,19 @@ bool hidden_or_backup_file(const char *filename) {
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
/* Please, let's not add more entries to the list below. If external projects think it's a good idea to come up
|
||||
* with always new suffixes and that everybody else should just adjust to that, then it really should be on
|
||||
* them. Hence, in future, let's not add any more entries. Instead, let's ask those packages to instead adopt
|
||||
* one of the generic suffixes/prefixes for hidden files or backups, possibly augmented with an additional
|
||||
* string. Specifically: there's now:
|
||||
*
|
||||
* The generic suffixes "~" and ".bak" for backup files
|
||||
* The generic prefix "." for hidden files
|
||||
*
|
||||
* Thus, if a new package manager "foopkg" wants its own set of ".foopkg-new", ".foopkg-old", ".foopkg-dist"
|
||||
* or so registered, let's refuse that and ask them to use ".foopkg.new", ".foopkg.old" or ".foopkg~" instead.
|
||||
*/
|
||||
|
||||
return STR_IN_SET(p + 1,
|
||||
"rpmnew",
|
||||
"rpmsave",
|
||||
@ -786,7 +799,10 @@ bool hidden_or_backup_file(const char *filename) {
|
||||
"ucf-new",
|
||||
"ucf-old",
|
||||
"ucf-dist",
|
||||
"swp");
|
||||
"swp",
|
||||
"bak",
|
||||
"old",
|
||||
"new");
|
||||
}
|
||||
|
||||
bool is_device_path(const char *path) {
|
||||
|
@ -95,6 +95,8 @@ static void test_copy_tree(void) {
|
||||
char **links = STRV_MAKE("link", "file",
|
||||
"link2", "dir1/file");
|
||||
char **p, **link;
|
||||
const char *unixsockp;
|
||||
struct stat st;
|
||||
|
||||
log_info("%s", __func__);
|
||||
|
||||
@ -102,26 +104,34 @@ static void test_copy_tree(void) {
|
||||
(void) rm_rf(original_dir, REMOVE_ROOT|REMOVE_PHYSICAL);
|
||||
|
||||
STRV_FOREACH(p, files) {
|
||||
char *f = strjoina(original_dir, *p);
|
||||
_cleanup_free_ char *f;
|
||||
|
||||
assert_se(f = strappend(original_dir, *p));
|
||||
|
||||
assert_se(mkdir_parents(f, 0755) >= 0);
|
||||
assert_se(write_string_file(f, "file", WRITE_STRING_FILE_CREATE) == 0);
|
||||
}
|
||||
|
||||
STRV_FOREACH_PAIR(link, p, links) {
|
||||
char *f = strjoina(original_dir, *p);
|
||||
char *l = strjoina(original_dir, *link);
|
||||
_cleanup_free_ char *f, *l;
|
||||
|
||||
assert_se(f = strappend(original_dir, *p));
|
||||
assert_se(l = strappend(original_dir, *link));
|
||||
|
||||
assert_se(mkdir_parents(l, 0755) >= 0);
|
||||
assert_se(symlink(f, l) == 0);
|
||||
}
|
||||
|
||||
unixsockp = strjoina(original_dir, "unixsock");
|
||||
assert_se(mknod(unixsockp, S_IFSOCK|0644, 0) >= 0);
|
||||
|
||||
assert_se(copy_tree(original_dir, copy_dir, true) == 0);
|
||||
|
||||
STRV_FOREACH(p, files) {
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
_cleanup_free_ char *buf = NULL, *f;
|
||||
size_t sz = 0;
|
||||
char *f = strjoina(copy_dir, *p);
|
||||
|
||||
assert_se(f = strappend(copy_dir, *p));
|
||||
|
||||
assert_se(access(f, F_OK) == 0);
|
||||
assert_se(read_full_file(f, &buf, &sz) == 0);
|
||||
@ -129,14 +139,19 @@ static void test_copy_tree(void) {
|
||||
}
|
||||
|
||||
STRV_FOREACH_PAIR(link, p, links) {
|
||||
_cleanup_free_ char *target = NULL;
|
||||
char *f = strjoina(original_dir, *p);
|
||||
char *l = strjoina(copy_dir, *link);
|
||||
_cleanup_free_ char *target = NULL, *f, *l;
|
||||
|
||||
assert_se(f = strjoin(original_dir, *p, NULL));
|
||||
assert_se(l = strjoin(copy_dir, *link, NULL));
|
||||
|
||||
assert_se(readlink_and_canonicalize(l, &target) == 0);
|
||||
assert_se(path_equal(f, target));
|
||||
}
|
||||
|
||||
unixsockp = strjoina(copy_dir, "unixsock");
|
||||
assert_se(stat(unixsockp, &st) >= 0);
|
||||
assert_se(S_ISSOCK(st.st_mode));
|
||||
|
||||
assert_se(copy_tree(original_dir, copy_dir, false) < 0);
|
||||
assert_se(copy_tree("/tmp/inexistent/foo/bar/fsdoi", copy_dir, false) < 0);
|
||||
|
||||
|
@ -397,11 +397,12 @@ class SysvGeneratorTest(unittest.TestCase):
|
||||
# backup files (not enabled in rcN.d/)
|
||||
shutil.copy(script, script + '.bak')
|
||||
shutil.copy(script, script + '.old')
|
||||
shutil.copy(script, script + '.tmp')
|
||||
shutil.copy(script, script + '.new')
|
||||
|
||||
err, results = self.run_generator()
|
||||
print(err)
|
||||
self.assertEqual(sorted(results),
|
||||
['foo.bak.service', 'foo.old.service', 'foo.service'])
|
||||
self.assertEqual(sorted(results), ['foo.service', 'foo.tmp.service'])
|
||||
|
||||
# ensure we don't try to create a symlink to itself
|
||||
self.assertNotIn('itself', err)
|
||||
|
Loading…
Reference in New Issue
Block a user