From a485a218fb4fc1baa0b279314b737ea0e36aa397 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Mon, 17 Jul 2017 17:13:40 +0200 Subject: [PATCH] Prep v233: Add missing updates from upstream in src/basic --- src/basic/cgroup-util.c | 15 +++++---------- src/basic/fileio.c | 6 ++++-- src/basic/fileio.h | 2 ++ src/basic/fs-util.c | 6 ++++-- src/basic/khash.c | 10 +++++----- src/basic/khash.h | 8 ++++---- src/basic/missing_syscall.h | 1 + 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 40e09d6f9..b5b669c0e 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -2483,7 +2483,6 @@ int cg_all_unified(void) { return unified_cache >= CGROUP_UNIFIED_ALL; } -#if 0 /// UNNEEDED by elogind int cg_hybrid_unified(void) { int r; @@ -2500,6 +2499,7 @@ int cg_unified_flush(void) { return cg_unified_update(); } +#if 0 /// UNNEEDED by elogind int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p) { _cleanup_free_ char *fs = NULL; CGroupController c; @@ -2605,19 +2605,14 @@ bool cg_is_hybrid_wanted(void) { * Since checking is expensive, cache a non-error result. */ r = proc_cmdline_get_bool("systemd.legacy_systemd_cgroup_controller", &b); -#else -bool cg_is_legacy_wanted(void) { - return true; /* The meaning of the kernel option is reversed wrt. to the return value * of this function, hence the negation. */ - return (wanted = r > 0 ? !b : false); - return (wanted = r > 0 ? b : false); -} - -bool cg_is_legacy_systemd_controller_wanted(void) { - return cg_is_legacy_wanted() && !cg_is_unified_systemd_controller_wanted(); return (wanted = r > 0 ? !b : is_default); } +#else +bool cg_is_legacy_wanted(void) { + return true; +} #endif // 0 #if 0 /// UNNEEDED by elogind diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 03238151c..822855c9d 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -788,7 +788,9 @@ static int merge_env_file_push( } expanded_value = replace_env(value, *env, - REPLACE_ENV_USE_ENVIRONMENT|REPLACE_ENV_ALLOW_BRACELESS); + REPLACE_ENV_USE_ENVIRONMENT| + REPLACE_ENV_ALLOW_BRACELESS| + REPLACE_ENV_ALLOW_EXTENDED); if (!expanded_value) return -ENOMEM; @@ -803,7 +805,7 @@ int merge_env_file( const char *fname) { /* NOTE: this function supports braceful and braceless variable expansions, - * unlike other exported parsing functions. + * plus "extended" substitutions, unlike other exported parsing functions. */ return parse_env_file_internal(f, fname, NEWLINE, merge_env_file_push, env, NULL); diff --git a/src/basic/fileio.h b/src/basic/fileio.h index 860d9e15d..c380ed9fd 100644 --- a/src/basic/fileio.h +++ b/src/basic/fileio.h @@ -51,6 +51,8 @@ int load_env_file(FILE *f, const char *fname, const char *separator, char ***l); int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l); #if 0 /// UNNEEDED by elogind +int merge_env_file(char ***env, FILE *f, const char *fname); + int write_env_file(const char *fname, char **l); int executable_is_script(const char *path, char **interpreter); diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 6308216de..eefdbb52d 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -805,8 +805,10 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, return -ENOMEM; } - *ret = done; - done = NULL; + if (ret) { + *ret = done; + done = NULL; + } return exists; } diff --git a/src/basic/khash.c b/src/basic/khash.c index c7884207f..84648dc1c 100644 --- a/src/basic/khash.c +++ b/src/basic/khash.c @@ -1,20 +1,20 @@ /*** - This file is part of elogind. + This file is part of systemd. Copyright 2016 Lennart Poettering - elogind is free software; you can redistribute it and/or modify it + 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. - elogind is distributed in the hope that it will be useful, but + 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 elogind; If not, see . + along with systemd; If not, see . ***/ #include @@ -143,7 +143,7 @@ int khash_dup(khash *h, khash **ret) { copy->fd = -1; copy->algorithm = strdup(h->algorithm); - if (!copy) + if (!copy->algorithm) return -ENOMEM; copy->fd = accept4(h->fd, NULL, 0, SOCK_CLOEXEC); diff --git a/src/basic/khash.h b/src/basic/khash.h index c0439b6b1..410f3020e 100644 --- a/src/basic/khash.h +++ b/src/basic/khash.h @@ -1,22 +1,22 @@ #pragma once /*** - This file is part of elogind. + This file is part of systemd. Copyright 2016 Lennart Poettering - elogind is free software; you can redistribute it and/or modify it + 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. - elogind is distributed in the hope that it will be useful, but + 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 elogind; If not, see . + along with systemd; If not, see . ***/ #include diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h index 036b0055b..58423bd55 100644 --- a/src/basic/missing_syscall.h +++ b/src/basic/missing_syscall.h @@ -189,6 +189,7 @@ static inline pid_t raw_getpid(void) { #endif } #endif // 0 + /* ======================================================================= */ #if !HAVE_DECL_RENAMEAT2 -- 2.30.2