From 1697c8cde45d76b2e35f728d0769c4a849db21e6 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Wed, 26 Apr 2017 18:57:18 +0200 Subject: meson: drop libiptc link dependencies from libshared The only place where libiptc is needed is in libfirewall, which already takes care of linking against libiptc. --- src/network/meson.build | 2 +- src/shared/meson.build | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/network/meson.build b/src/network/meson.build index 94bbb156aa..4d76902ef1 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -130,7 +130,7 @@ if conf.get('ENABLE_NETWORKD', 0) == 1 libsystemd_network, libshared, libfirewall], - [libiptc]], + []], [['src/network/test-network-tables.c', 'src/network/test-network-tables.c', diff --git a/src/shared/meson.build b/src/shared/meson.build index 8968127d3f..7d51e99487 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -132,7 +132,6 @@ libshared = shared_library( libacl, libcryptsetup, libgcrypt, - libiptc, libseccomp, libselinux, libidn, @@ -152,7 +151,6 @@ libshared_static = static_library( libcap, libacl, libcryptsetup, - libiptc, libseccomp, libselinux, libidn, -- cgit v1.2.3-54-g00ecf From c3045943c4ea2f63e62f85e64fcf1a862b82ac7d Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Wed, 26 Apr 2017 22:14:23 +0200 Subject: meson: get rid of libfirewall --- meson.build | 4 +--- src/network/meson.build | 6 ++---- src/shared/meson.build | 17 ++++++----------- src/test/meson.build | 3 +-- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/meson.build b/meson.build index b18e645d39..0d61ce19ab 100644 --- a/meson.build +++ b/meson.build @@ -2146,8 +2146,7 @@ exe = executable('systemd-nspawn', 'src/core/loopback-setup.c', 'src/core/loopback-setup.h', include_directories : [includes, include_directories('src/nspawn')], - link_with : [libfirewall, - libshared, + link_with : [libshared, libudev], dependencies : [libacl, libblkid, @@ -2162,7 +2161,6 @@ if conf.get('ENABLE_NETWORKD', 0) == 1 systemd_networkd_sources, include_directories : includes, link_with : [libnetworkd_core, - libfirewall, libsystemd_network, libudev_internal, libshared], diff --git a/src/network/meson.build b/src/network/meson.build index 4d76902ef1..771aa68ec1 100644 --- a/src/network/meson.build +++ b/src/network/meson.build @@ -128,8 +128,7 @@ if conf.get('ENABLE_NETWORKD', 0) == 1 [libnetworkd_core, libudev_internal, libsystemd_network, - libshared, - libfirewall], + libshared], []], [['src/network/test-network-tables.c', @@ -139,8 +138,7 @@ if conf.get('ENABLE_NETWORKD', 0) == 1 libudev_internal, libudev_core, libsystemd_network, - libshared, - libfirewall], + libshared], [], '', '', [], [network_include_dir] + libudev_core_includes], diff --git a/src/shared/meson.build b/src/shared/meson.build index 7d51e99487..0747f76649 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -34,6 +34,7 @@ shared_sources = ''' efivars.h fdset.c fdset.h + firewall-util.h fstab-util.c fstab-util.h gcrypt-util.c @@ -114,6 +115,10 @@ if conf.get('HAVE_SECCOMP', 0) == 1 shared_sources += ['seccomp-util.c'] endif +if conf.get('HAVE_LIBIPTC', 0) == 1 + shared_sources += ['firewall-util.c'] +endif + libshared_name = 'systemd-shared-@0@'.format(meson.project_version()) libshared = shared_library( @@ -132,6 +137,7 @@ libshared = shared_library( libacl, libcryptsetup, libgcrypt, + libiptc, libseccomp, libselinux, libidn, @@ -157,14 +163,3 @@ libshared_static = static_library( libxz, liblz4, libblkid]) - -if conf.get('HAVE_LIBIPTC', 0) == 1 - libfirewall = static_library( - 'firewall', - 'firewall-util.h', - 'firewall-util.c', - include_directories : includes, - dependencies : [libiptc]) -else - libfirewall = [] -endif diff --git a/src/test/meson.build b/src/test/meson.build index 6c0fd4dca9..bbb525d6fe 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -415,8 +415,7 @@ tests += [ [['src/test/test-firewall-util.c'], - [libfirewall, - libshared], + [libshared], [], 'HAVE_LIBIPTC'], -- cgit v1.2.3-54-g00ecf From 5a1d67639d8d3c25f817cf2958348c3f3193a573 Mon Sep 17 00:00:00 2001 From: codekipper Date: Thu, 27 Apr 2017 01:49:06 +0200 Subject: update-done: Create using a temporary file (#5789) '/etc/.updated' is created without using a temporary file, this can be problematic with filesystems that cache writes. Modify so that the timestamp is written to a temporary file and then use an atomic move to move it to its correct place. --- src/update-done/update-done.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/update-done/update-done.c b/src/update-done/update-done.c index d466e1b759..06e2d7b71b 100644 --- a/src/update-done/update-done.c +++ b/src/update-done/update-done.c @@ -17,8 +17,10 @@ along with systemd; If not, see . ***/ +#include "alloc-util.h" #include "fd-util.h" #include "fileio.h" +#include "fs-util.h" #include "io-util.h" #include "selinux-util.h" #include "util.h" @@ -36,6 +38,7 @@ static int apply_timestamp(const char *path, struct timespec *ts) { _cleanup_fclose_ FILE *f = NULL; int fd = -1; int r; + _cleanup_(unlink_and_freep) char *tmp = NULL; assert(path); assert(ts); @@ -50,20 +53,20 @@ static int apply_timestamp(const char *path, struct timespec *ts) { if (r < 0) return log_error_errno(r, "Failed to set SELinux context for %s: %m", path); - fd = open(path, O_CREAT|O_WRONLY|O_TRUNC|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644); + fd = open_tmpfile_linkable(path, O_WRONLY|O_CLOEXEC, &tmp); mac_selinux_create_file_clear(); if (fd < 0) { if (errno == EROFS) - return log_debug("Can't create timestamp file %s, file system is read-only.", path); + return log_debug("Can't create temporary timestamp file %s, file system is read-only.", tmp); - return log_error_errno(errno, "Failed to create/open timestamp file %s: %m", path); + return log_error_errno(errno, "Failed to create/open temporary timestamp file %s: %m", tmp); } f = fdopen(fd, "we"); if (!f) { safe_close(fd); - return log_error_errno(errno, "Failed to fdopen() timestamp file %s: %m", path); + return log_error_errno(errno, "Failed to fdopen() timestamp file %s: %m", tmp); } (void) fprintf(f, @@ -76,7 +79,15 @@ static int apply_timestamp(const char *path, struct timespec *ts) { return log_error_errno(r, "Failed to write timestamp file: %m"); if (futimens(fd, twice) < 0) - return log_error_errno(errno, "Failed to update timestamp on %s: %m", path); + return log_error_errno(errno, "Failed to update timestamp on %s: %m", tmp); + + /* fix permissions */ + (void) fchmod(fd, 0644); + r = link_tmpfile(fd, tmp, path); + if (r < 0) + return log_error_errno(r, "Failed to move \"%s\" to \"%s\": %m", tmp, path); + + tmp = mfree(tmp); return 0; } -- cgit v1.2.3-54-g00ecf From 77018a8c267c08ee8f70f51963e7fcc3bca70ba8 Mon Sep 17 00:00:00 2001 From: Matija Skala Date: Thu, 27 Apr 2017 02:08:52 +0200 Subject: improve readability (#5814) --- src/shared/pager.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/shared/pager.c b/src/shared/pager.c index 22d7603ec6..4d7b02c63c 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -176,12 +176,14 @@ void pager_close(void) { /* Inform pager that we are done */ (void) fflush(stdout); - if (stdout_redirected && ((stored_stdout < 0) || (dup2(stored_stdout, STDOUT_FILENO) < 0))) - (void) close(STDOUT_FILENO); + if (stdout_redirected) + if (stored_stdout < 0 || dup2(stored_stdout, STDOUT_FILENO) < 0) + (void) close(STDOUT_FILENO); stored_stdout = safe_close(stored_stdout); (void) fflush(stderr); - if (stderr_redirected && ((stored_stderr < 0) || (dup2(stored_stderr, STDERR_FILENO) < 0))) - (void) close(STDERR_FILENO); + if (stderr_redirected) + if (stored_stderr < 0 || dup2(stored_stderr, STDERR_FILENO) < 0) + (void) close(STDERR_FILENO); stored_stderr = safe_close(stored_stderr); stdout_redirected = stderr_redirected = false; -- cgit v1.2.3-54-g00ecf From d8431fc3f4f49f4420f7afe3e0363092563378a3 Mon Sep 17 00:00:00 2001 From: userwithuid Date: Thu, 27 Apr 2017 17:22:40 +0000 Subject: build-sys: only install libexecdir/resolv.conf if resolved is enabled (#5826) as mentioned in https://github.com/systemd/systemd/pull/5811 --- Makefile.am | 6 +++--- src/resolve/meson.build | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8339625a62..f5f2793f5b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5599,6 +5599,9 @@ GENERAL_ALIASES += \ nodist_pkgsysconf_DATA += \ src/resolve/resolved.conf +dist_rootlibexec_DATA += \ + src/resolve/resolv.conf + libnss_resolve_la_SOURCES = \ src/nss-resolve/nss-resolve.sym \ src/nss-resolve/nss-resolve.c @@ -5737,9 +5740,6 @@ EXTRA_DIST += \ units/systemd-resolved.service.m4.in \ src/resolve/resolved.conf.in -dist_rootlibexec_DATA += \ - src/resolve/resolv.conf - # ------------------------------------------------------------------------------ if ENABLE_NETWORKD rootlibexec_PROGRAMS += \ diff --git a/src/resolve/meson.build b/src/resolve/meson.build index 46a417e766..347ffaaeca 100644 --- a/src/resolve/meson.build +++ b/src/resolve/meson.build @@ -135,10 +135,10 @@ if conf.get('ENABLE_RESOLVED', 0) == 1 configuration : substs) install_data(resolved_conf, install_dir : pkgsysconfdir) -endif -install_data('resolv.conf', - install_dir : rootlibexecdir) + install_data('resolv.conf', + install_dir : rootlibexecdir) +endif tests += [ [['src/resolve/test-resolve-tables.c', -- cgit v1.2.3-54-g00ecf