From: Sven Eden Date: Fri, 1 Jun 2018 18:21:25 +0000 (+0200) Subject: Prep v238: Applied some upstream updates to src/basic (3/5) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a05f6a92978ad6d37d4f334ab175384290f251a5;p=elogind.git Prep v238: Applied some upstream updates to src/basic (3/5) --- diff --git a/src/basic/build.h b/src/basic/build.h index 61968d59e..cbc638c8c 100644 --- a/src/basic/build.h +++ b/src/basic/build.h @@ -143,6 +143,9 @@ #if HAVE_LIBIDN #define _IDN_FEATURE_ "+IDN" +#else +#define _IDN_FEATURE_ "-IDN" +#endif #if HAVE_PCRE2 #define _PCRE2_FEATURE_ "+PCRE2" diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 452a8e2f7..302fc95dd 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -1076,13 +1076,11 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) { continue; *e = 0; - FOREACH_WORD_SEPARATOR(word, k, l, ",", state) { + FOREACH_WORD_SEPARATOR(word, k, l, ",", state) if (k == cs && memcmp(word, controller_str, cs) == 0) { found = true; break; } - } - if (!found) continue; } diff --git a/src/basic/label.c b/src/basic/label.c index 0bea2aa39..50cdd8c73 100644 --- a/src/basic/label.c +++ b/src/basic/label.c @@ -22,6 +22,7 @@ #include #include +//#include "btrfs-util.h" #include "label.h" #include "macro.h" #include "selinux-util.h" @@ -63,4 +64,22 @@ int symlink_label(const char *old_path, const char *new_path) { return mac_smack_fix(new_path, false, false); } + +int btrfs_subvol_make_label(const char *path) { + int r; + + assert(path); + + r = mac_selinux_create_file_prepare(path, S_IFDIR); + if (r < 0) + return r; + + r = btrfs_subvol_make(path); + mac_selinux_create_file_clear(); + + if (r < 0) + return r; + + return mac_smack_fix(path, false, false); +} #endif // 0 diff --git a/src/basic/label.h b/src/basic/label.h index df25d8baf..4bfcfe39f 100644 --- a/src/basic/label.h +++ b/src/basic/label.h @@ -28,6 +28,6 @@ int label_fix(const char *path, bool ignore_enoent, bool ignore_erofs); int mkdir_label(const char *path, mode_t mode); #if 0 /// UNNEEDED by elogind int symlink_label(const char *old_path, const char *new_path); -#endif // 0 int btrfs_subvol_make_label(const char *path); +#endif // 0 diff --git a/src/basic/meson.build b/src/basic/meson.build index 33cfe8e53..1f2386355 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -233,7 +233,7 @@ # xml.h # '''.split()) #else -basic_sources_plain = files(''' +basic_sources = files(''' alloc-util.c alloc-util.h audit-util.c @@ -475,18 +475,20 @@ libbasic = static_library( libcap, #if 0 /// no blkid in elogind # libblkid, +# libmount, #endif // 0 - libmount, libselinux], c_args : ['-fvisibility=default'], install : false) -# A convenience library that is separate from libbasic to avoid -# unnecessary linking to libgcrypt. -libbasic_gcrypt = static_library( - 'basic-gcrypt', - 'gcrypt-util.c', - 'gcrypt-util.h', - include_directories : includes, - dependencies : [libgcrypt], - c_args : ['-fvisibility=default']) +#if 0 /// elogind does not need gcrypt +# # A convenience library that is separate from libbasic to avoid +# # unnecessary linking to libgcrypt. +# libbasic_gcrypt = static_library( +# 'basic-gcrypt', +# 'gcrypt-util.c', +# 'gcrypt-util.h', +# include_directories : includes, +# dependencies : [libgcrypt], +# c_args : ['-fvisibility=default']) +#endif // 0 diff --git a/src/basic/raw-reboot.h b/src/basic/raw-reboot.h deleted file mode 100644 index 3f7f63b4b..000000000 --- a/src/basic/raw-reboot.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1+ */ -#pragma once - -//#include -//#include -//#include - -/* glibc defines the reboot() API call, which is a wrapper around the system call of the same name, but without the - * extra "arg" parameter. Since we need that parameter for some calls, let's add a "raw" wrapper that is defined the - * same way, except it takes the additional argument. */ - -static inline int raw_reboot(int cmd, const void *arg) { - return (int) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, arg); -} diff --git a/src/basic/reboot-util.c b/src/basic/reboot-util.c deleted file mode 100644 index 2528d9bbe..000000000 --- a/src/basic/reboot-util.c +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1+ */ - -//#include -//#include - -//#include "fileio.h" -//#include "log.h" -//#include "reboot-util.h" -//#include "string-util.h" -//#include "umask-util.h" - -int update_reboot_parameter_and_warn(const char *parameter) { - int r; - - if (isempty(parameter)) { - if (unlink("/run/systemd/reboot-param") < 0) { - if (errno == ENOENT) - return 0; - - return log_warning_errno(errno, "Failed to unlink reboot parameter file: %m"); - } - - return 0; - } - - RUN_WITH_UMASK(0022) { - r = write_string_file("/run/systemd/reboot-param", parameter, - WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC); - if (r < 0) - return log_warning_errno(r, "Failed to write reboot parameter file: %m"); - } - - return 0; -} diff --git a/src/basic/reboot-util.h b/src/basic/reboot-util.h deleted file mode 100644 index 6f1d24c1f..000000000 --- a/src/basic/reboot-util.h +++ /dev/null @@ -1,4 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1+ */ -#pragma once - -int update_reboot_parameter_and_warn(const char *parameter); diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 007b302e7..7e68a672e 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -52,7 +52,7 @@ #if 0 /// UNNEEDED by elogind #if ENABLE_IDN -# define IDN_FLAGS (NI_IDN|NI_IDN_USE_STD3_ASCII_RULES) +# define IDN_FLAGS NI_IDN #else # define IDN_FLAGS 0 #endif diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index 3c41a5b97..667424c0a 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -28,21 +28,45 @@ #include "macro.h" #include "time-util.h" -#define ANSI_RED "\x1B[0;31m" -#define ANSI_GREEN "\x1B[0;32m" +/* Regular colors */ +#define ANSI_BLACK "\x1B[0;30m" +#define ANSI_RED "\x1B[0;31m" +#define ANSI_GREEN "\x1B[0;32m" +#define ANSI_YELLOW "\x1B[0;33m" +#define ANSI_BLUE "\x1B[0;34m" +#define ANSI_MAGENTA "\x1B[0;35m" +#define ANSI_CYAN "\x1B[0;36m" +#define ANSI_WHITE "\x1B[0;37m" + +/* Bold/highlighted */ +#define ANSI_HIGHLIGHT_BLACK "\x1B[0;1;30m" +#define ANSI_HIGHLIGHT_RED "\x1B[0;1;31m" +#define ANSI_HIGHLIGHT_GREEN "\x1B[0;1;32m" +#define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;33m" +#define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m" +#define ANSI_HIGHLIGHT_MAGENTA "\x1B[0;1;35m" +#define ANSI_HIGHLIGHT_CYAN "\x1B[0;1;36m" +#define ANSI_HIGHLIGHT_WHITE "\x1B[0;1;37m" + +/* Underlined */ +#define ANSI_HIGHLIGHT_BLACK_UNDERLINE "\x1B[0;1;4;30m" +#define ANSI_HIGHLIGHT_RED_UNDERLINE "\x1B[0;1;4;31m" +#define ANSI_HIGHLIGHT_GREEN_UNDERLINE "\x1B[0;1;4;32m" +#define ANSI_HIGHLIGHT_YELLOW_UNDERLINE "\x1B[0;1;4;33m" +#define ANSI_HIGHLIGHT_BLUE_UNDERLINE "\x1B[0;1;4;34m" +#define ANSI_HIGHLIGHT_MAGENTA_UNDERLINE "\x1B[0;1;4;35m" +#define ANSI_HIGHLIGHT_CYAN_UNDERLINE "\x1B[0;1;4;36m" +#define ANSI_HIGHLIGHT_WHITE_UNDERLINE "\x1B[0;1;4;37m" + +/* Other ANSI codes */ #define ANSI_UNDERLINE "\x1B[0;4m" #define ANSI_HIGHLIGHT "\x1B[0;1;39m" -#define ANSI_HIGHLIGHT_RED "\x1B[0;1;31m" -#define ANSI_HIGHLIGHT_GREEN "\x1B[0;1;32m" -#define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;33m" -#define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m" #define ANSI_HIGHLIGHT_UNDERLINE "\x1B[0;1;4m" -#define ANSI_HIGHLIGHT_RED_UNDERLINE "\x1B[0;1;4;31m" -#define ANSI_HIGHLIGHT_GREEN_UNDERLINE "\x1B[0;1;4;32m" -#define ANSI_HIGHLIGHT_YELLOW_UNDERLINE "\x1B[0;1;4;33m" -#define ANSI_HIGHLIGHT_BLUE_UNDERLINE "\x1B[0;1;4;34m" + +/* Reset/clear ANSI styles */ #define ANSI_NORMAL "\x1B[0m" +/* Erase characters until the end of the line */ #define ANSI_ERASE_TO_END_OF_LINE "\x1B[K" /* Set cursor to top left corner and clear screen */