mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Merge pull request #1335 from poettering/some-fixes
A variety of mostly unrelated fixes
This commit is contained in:
commit
d11885c814
27
coccinelle/safe_closedir.cocci
Normal file
27
coccinelle/safe_closedir.cocci
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
@@
|
||||||
|
expression p;
|
||||||
|
@@
|
||||||
|
- if (p) {
|
||||||
|
- closedir(p);
|
||||||
|
- p = NULL;
|
||||||
|
- }
|
||||||
|
+ p = safe_closedir(p);
|
||||||
|
@@
|
||||||
|
expression p;
|
||||||
|
@@
|
||||||
|
- if (p)
|
||||||
|
- closedir(p);
|
||||||
|
- p = NULL;
|
||||||
|
+ p = safe_closedir(p);
|
||||||
|
@@
|
||||||
|
expression p;
|
||||||
|
@@
|
||||||
|
- closedir(p);
|
||||||
|
- p = NULL;
|
||||||
|
+ p = safe_closedir(p);
|
||||||
|
@@
|
||||||
|
expression p;
|
||||||
|
@@
|
||||||
|
- if (p)
|
||||||
|
- closedir(p);
|
||||||
|
+ safe_closedir(p);
|
@ -96,7 +96,6 @@
|
|||||||
|
|
||||||
<para>Use a tool like
|
<para>Use a tool like
|
||||||
<citerefentry project='mankier'><refentrytitle>dnf</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
<citerefentry project='mankier'><refentrytitle>dnf</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||||
<citerefentry project='die-net'><refentrytitle>yum</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
|
||||||
<citerefentry project='die-net'><refentrytitle>debootstrap</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
<citerefentry project='die-net'><refentrytitle>debootstrap</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||||
or
|
or
|
||||||
<citerefentry project='archlinux'><refentrytitle>pacman</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
<citerefentry project='archlinux'><refentrytitle>pacman</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||||
@ -914,7 +913,6 @@
|
|||||||
<citerefentry><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
<citerefentry><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||||
<citerefentry project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
<citerefentry project='man-pages'><refentrytitle>chroot</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
|
||||||
<citerefentry project='mankier'><refentrytitle>dnf</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
<citerefentry project='mankier'><refentrytitle>dnf</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||||
<citerefentry project='die-net'><refentrytitle>yum</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
|
||||||
<citerefentry project='die-net'><refentrytitle>debootstrap</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
<citerefentry project='die-net'><refentrytitle>debootstrap</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||||
<citerefentry project='archlinux'><refentrytitle>pacman</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
<citerefentry project='archlinux'><refentrytitle>pacman</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
|
||||||
<citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
<citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
|
||||||
|
@ -759,9 +759,9 @@ static int list_dependencies_print(const char *name, unsigned int level, unsigne
|
|||||||
|
|
||||||
if (times) {
|
if (times) {
|
||||||
if (times->time)
|
if (times->time)
|
||||||
printf("%s%s @%s +%s%s", ANSI_HIGHLIGHT_RED_ON, name,
|
printf("%s%s @%s +%s%s", ANSI_HIGHLIGHT_RED, name,
|
||||||
format_timespan(ts, sizeof(ts), times->activating - boot->userspace_time, USEC_PER_MSEC),
|
format_timespan(ts, sizeof(ts), times->activating - boot->userspace_time, USEC_PER_MSEC),
|
||||||
format_timespan(ts2, sizeof(ts2), times->time, USEC_PER_MSEC), ANSI_HIGHLIGHT_OFF);
|
format_timespan(ts2, sizeof(ts2), times->time, USEC_PER_MSEC), ANSI_NORMAL);
|
||||||
else if (times->activated > boot->userspace_time)
|
else if (times->activated > boot->userspace_time)
|
||||||
printf("%s @%s", name, format_timespan(ts, sizeof(ts), times->activated - boot->userspace_time, USEC_PER_MSEC));
|
printf("%s @%s", name, format_timespan(ts, sizeof(ts), times->activated - boot->userspace_time, USEC_PER_MSEC));
|
||||||
else
|
else
|
||||||
@ -927,8 +927,8 @@ static int list_dependencies(sd_bus *bus, const char *name) {
|
|||||||
|
|
||||||
if (times) {
|
if (times) {
|
||||||
if (times->time)
|
if (times->time)
|
||||||
printf("%s%s +%s%s\n", ANSI_HIGHLIGHT_RED_ON, id,
|
printf("%s%s +%s%s\n", ANSI_HIGHLIGHT_RED, id,
|
||||||
format_timespan(ts, sizeof(ts), times->time, USEC_PER_MSEC), ANSI_HIGHLIGHT_OFF);
|
format_timespan(ts, sizeof(ts), times->time, USEC_PER_MSEC), ANSI_NORMAL);
|
||||||
else if (times->activated > boot->userspace_time)
|
else if (times->activated > boot->userspace_time)
|
||||||
printf("%s @%s\n", id, format_timespan(ts, sizeof(ts), times->activated - boot->userspace_time, USEC_PER_MSEC));
|
printf("%s @%s\n", id, format_timespan(ts, sizeof(ts), times->activated - boot->userspace_time, USEC_PER_MSEC));
|
||||||
else
|
else
|
||||||
|
@ -37,10 +37,14 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
|
|||||||
assert(fdt >= 0);
|
assert(fdt >= 0);
|
||||||
|
|
||||||
/* Try btrfs reflinks first. */
|
/* Try btrfs reflinks first. */
|
||||||
if (try_reflink && max_bytes == (uint64_t) -1) {
|
if (try_reflink &&
|
||||||
|
max_bytes == (uint64_t) -1 &&
|
||||||
|
lseek(fdf, 0, SEEK_CUR) == 0 &&
|
||||||
|
lseek(fdt, 0, SEEK_CUR) == 0) {
|
||||||
|
|
||||||
r = btrfs_reflink(fdf, fdt);
|
r = btrfs_reflink(fdf, fdt);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
return r;
|
return 0; /* we copied the whole thing, hence hit EOF, return 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -50,7 +54,7 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
|
|||||||
if (max_bytes != (uint64_t) -1) {
|
if (max_bytes != (uint64_t) -1) {
|
||||||
|
|
||||||
if (max_bytes <= 0)
|
if (max_bytes <= 0)
|
||||||
return -EFBIG;
|
return 1; /* return > 0 if we hit the max_bytes limit */
|
||||||
|
|
||||||
if ((uint64_t) m > max_bytes)
|
if ((uint64_t) m > max_bytes)
|
||||||
m = (size_t) max_bytes;
|
m = (size_t) max_bytes;
|
||||||
@ -75,7 +79,7 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
|
|||||||
|
|
||||||
/* The try splice, unless we already tried */
|
/* The try splice, unless we already tried */
|
||||||
if (try_splice) {
|
if (try_splice) {
|
||||||
n = splice(fdf, NULL, fdt, NULL, m, 0);
|
n = splice(fdf, NULL, fdt, NULL, m, 0);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno != EINVAL && errno != ENOSYS)
|
if (errno != EINVAL && errno != ENOSYS)
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -91,7 +95,7 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
|
|||||||
|
|
||||||
/* As a fallback just copy bits by hand */
|
/* As a fallback just copy bits by hand */
|
||||||
{
|
{
|
||||||
char buf[m];
|
uint8_t buf[m];
|
||||||
|
|
||||||
n = read(fdf, buf, m);
|
n = read(fdf, buf, m);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
@ -111,7 +115,7 @@ int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0; /* return 0 if we hit EOF earlier than the size limit */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_copy_symlink(int df, const char *from, const struct stat *st, int dt, const char *to) {
|
static int fd_copy_symlink(int df, const char *from, const struct stat *st, int dt, const char *to) {
|
||||||
|
@ -340,10 +340,10 @@ static int write_to_console(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (highlight)
|
if (highlight)
|
||||||
IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_RED_ON);
|
IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_RED);
|
||||||
IOVEC_SET_STRING(iovec[n++], buffer);
|
IOVEC_SET_STRING(iovec[n++], buffer);
|
||||||
if (highlight)
|
if (highlight)
|
||||||
IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_OFF);
|
IOVEC_SET_STRING(iovec[n++], ANSI_NORMAL);
|
||||||
IOVEC_SET_STRING(iovec[n++], "\n");
|
IOVEC_SET_STRING(iovec[n++], "\n");
|
||||||
|
|
||||||
if (writev(console_fd, iovec, n) < 0) {
|
if (writev(console_fd, iovec, n) < 0) {
|
||||||
|
@ -470,18 +470,6 @@ do { \
|
|||||||
#define GID_INVALID ((gid_t) -1)
|
#define GID_INVALID ((gid_t) -1)
|
||||||
#define MODE_INVALID ((mode_t) -1)
|
#define MODE_INVALID ((mode_t) -1)
|
||||||
|
|
||||||
static inline bool UID_IS_INVALID(uid_t uid) {
|
|
||||||
/* We consider both the old 16bit -1 user and the newer 32bit
|
|
||||||
* -1 user invalid, since they are or used to be incompatible
|
|
||||||
* with syscalls such as setresuid() or chown(). */
|
|
||||||
|
|
||||||
return uid == (uid_t) ((uint32_t) -1) || uid == (uid_t) ((uint16_t) -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool GID_IS_INVALID(gid_t gid) {
|
|
||||||
return gid == (gid_t) ((uint32_t) -1) || gid == (gid_t) ((uint16_t) -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
|
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
|
||||||
static inline void func##p(type *p) { \
|
static inline void func##p(type *p) { \
|
||||||
if (*p) \
|
if (*p) \
|
||||||
|
@ -139,14 +139,14 @@ int ask_char(char *ret, const char *replies, const char *text, ...) {
|
|||||||
bool need_nl = true;
|
bool need_nl = true;
|
||||||
|
|
||||||
if (on_tty())
|
if (on_tty())
|
||||||
fputs(ANSI_HIGHLIGHT_ON, stdout);
|
fputs(ANSI_HIGHLIGHT, stdout);
|
||||||
|
|
||||||
va_start(ap, text);
|
va_start(ap, text);
|
||||||
vprintf(text, ap);
|
vprintf(text, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (on_tty())
|
if (on_tty())
|
||||||
fputs(ANSI_HIGHLIGHT_OFF, stdout);
|
fputs(ANSI_NORMAL, stdout);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -183,14 +183,14 @@ int ask_string(char **ret, const char *text, ...) {
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (on_tty())
|
if (on_tty())
|
||||||
fputs(ANSI_HIGHLIGHT_ON, stdout);
|
fputs(ANSI_HIGHLIGHT, stdout);
|
||||||
|
|
||||||
va_start(ap, text);
|
va_start(ap, text);
|
||||||
vprintf(text, ap);
|
vprintf(text, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (on_tty())
|
if (on_tty())
|
||||||
fputs(ANSI_HIGHLIGHT_OFF, stdout);
|
fputs(ANSI_NORMAL, stdout);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
@ -26,16 +26,22 @@
|
|||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
|
|
||||||
#define ANSI_HIGHLIGHT_ON "\x1B[1;39m"
|
#define ANSI_RED "\x1B[0;31m"
|
||||||
#define ANSI_RED_ON "\x1B[31m"
|
#define ANSI_GREEN "\x1B[0;32m"
|
||||||
#define ANSI_HIGHLIGHT_RED_ON "\x1B[1;31m"
|
#define ANSI_UNDERLINE "\x1B[0;4m"
|
||||||
#define ANSI_GREEN_ON "\x1B[32m"
|
#define ANSI_HIGHLIGHT "\x1B[0;1;39m"
|
||||||
#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
|
#define ANSI_HIGHLIGHT_RED "\x1B[0;1;31m"
|
||||||
#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
|
#define ANSI_HIGHLIGHT_GREEN "\x1B[0;1;32m"
|
||||||
#define ANSI_HIGHLIGHT_BLUE_ON "\x1B[1;34m"
|
#define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;33m"
|
||||||
#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
|
#define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m"
|
||||||
|
#define ANSI_HIGHLIGHT_UNDERLINE "\x1B[0;1;4m"
|
||||||
|
#define ANSI_NORMAL "\x1B[0m"
|
||||||
|
|
||||||
#define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
|
#define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
|
||||||
|
|
||||||
|
/* Set cursor to top left corner and clear screen */
|
||||||
|
#define ANSI_HOME_CLEAR "\x1B[H\x1B[2J"
|
||||||
|
|
||||||
int reset_terminal_fd(int fd, bool switch_to_text);
|
int reset_terminal_fd(int fd, bool switch_to_text);
|
||||||
int reset_terminal(const char *name);
|
int reset_terminal(const char *name);
|
||||||
|
|
||||||
@ -78,28 +84,36 @@ void columns_lines_cache_reset(int _unused_ signum);
|
|||||||
|
|
||||||
bool on_tty(void);
|
bool on_tty(void);
|
||||||
|
|
||||||
|
static inline const char *ansi_underline(void) {
|
||||||
|
return on_tty() ? ANSI_UNDERLINE : "";
|
||||||
|
}
|
||||||
|
|
||||||
static inline const char *ansi_highlight(void) {
|
static inline const char *ansi_highlight(void) {
|
||||||
return on_tty() ? ANSI_HIGHLIGHT_ON : "";
|
return on_tty() ? ANSI_HIGHLIGHT : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline const char *ansi_highlight_underline(void) {
|
||||||
|
return on_tty() ? ANSI_HIGHLIGHT_UNDERLINE : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *ansi_highlight_red(void) {
|
static inline const char *ansi_highlight_red(void) {
|
||||||
return on_tty() ? ANSI_HIGHLIGHT_RED_ON : "";
|
return on_tty() ? ANSI_HIGHLIGHT_RED : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *ansi_highlight_green(void) {
|
static inline const char *ansi_highlight_green(void) {
|
||||||
return on_tty() ? ANSI_HIGHLIGHT_GREEN_ON : "";
|
return on_tty() ? ANSI_HIGHLIGHT_GREEN : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *ansi_highlight_yellow(void) {
|
static inline const char *ansi_highlight_yellow(void) {
|
||||||
return on_tty() ? ANSI_HIGHLIGHT_YELLOW_ON : "";
|
return on_tty() ? ANSI_HIGHLIGHT_YELLOW : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *ansi_highlight_blue(void) {
|
static inline const char *ansi_highlight_blue(void) {
|
||||||
return on_tty() ? ANSI_HIGHLIGHT_BLUE_ON : "";
|
return on_tty() ? ANSI_HIGHLIGHT_BLUE : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *ansi_highlight_off(void) {
|
static inline const char *ansi_normal(void) {
|
||||||
return on_tty() ? ANSI_HIGHLIGHT_OFF : "";
|
return on_tty() ? ANSI_NORMAL : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_ctty_devnr(pid_t pid, dev_t *d);
|
int get_ctty_devnr(pid_t pid, dev_t *d);
|
||||||
|
147
src/basic/util.c
147
src/basic/util.c
@ -19,49 +19,48 @@
|
|||||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <libintl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <linux/sched.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <poll.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/prctl.h>
|
#include <dirent.h>
|
||||||
#include <sys/utsname.h>
|
#include <errno.h>
|
||||||
#include <pwd.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/ip.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/vfs.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <linux/magic.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
#include <libintl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <linux/magic.h>
|
||||||
|
#include <linux/sched.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <sys/personality.h>
|
#include <netinet/ip.h>
|
||||||
#include <sys/xattr.h>
|
#include <poll.h>
|
||||||
#include <sys/statvfs.h>
|
#include <pwd.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <linux/fs.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/personality.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/vfs.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <sys/xattr.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/* When we include libgen.h because we need dirname() we immediately
|
/* When we include libgen.h because we need dirname() we immediately
|
||||||
* undefine basename() since libgen.h defines it as a macro to the POSIX
|
* undefine basename() since libgen.h defines it as a macro to the
|
||||||
* version which is really broken. We prefer GNU basename(). */
|
* POSIX version which is really broken. We prefer GNU basename(). */
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#undef basename
|
#undef basename
|
||||||
|
|
||||||
@ -69,31 +68,34 @@
|
|||||||
#include <sys/auxv.h>
|
#include <sys/auxv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
/* We include linux/fs.h as last of the system headers, as it
|
||||||
#include "macro.h"
|
* otherwise conflicts with sys/mount.h. Yay, Linux is great! */
|
||||||
#include "util.h"
|
#include <linux/fs.h>
|
||||||
|
|
||||||
|
#include "def.h"
|
||||||
|
#include "device-nodes.h"
|
||||||
|
#include "env-util.h"
|
||||||
|
#include "exit-status.h"
|
||||||
|
#include "fileio.h"
|
||||||
|
#include "formats-util.h"
|
||||||
|
#include "gunicode.h"
|
||||||
|
#include "hashmap.h"
|
||||||
|
#include "hostname-util.h"
|
||||||
#include "ioprio.h"
|
#include "ioprio.h"
|
||||||
#include "missing.h"
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "strv.h"
|
#include "macro.h"
|
||||||
|
#include "missing.h"
|
||||||
#include "mkdir.h"
|
#include "mkdir.h"
|
||||||
#include "path-util.h"
|
#include "path-util.h"
|
||||||
#include "exit-status.h"
|
|
||||||
#include "hashmap.h"
|
|
||||||
#include "env-util.h"
|
|
||||||
#include "fileio.h"
|
|
||||||
#include "device-nodes.h"
|
|
||||||
#include "utf8.h"
|
|
||||||
#include "gunicode.h"
|
|
||||||
#include "virt.h"
|
|
||||||
#include "def.h"
|
|
||||||
#include "sparse-endian.h"
|
|
||||||
#include "formats-util.h"
|
|
||||||
#include "process-util.h"
|
#include "process-util.h"
|
||||||
#include "random-util.h"
|
#include "random-util.h"
|
||||||
#include "terminal-util.h"
|
|
||||||
#include "hostname-util.h"
|
|
||||||
#include "signal-util.h"
|
#include "signal-util.h"
|
||||||
|
#include "sparse-endian.h"
|
||||||
|
#include "strv.h"
|
||||||
|
#include "terminal-util.h"
|
||||||
|
#include "utf8.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "virt.h"
|
||||||
|
|
||||||
/* Put this test here for a lack of better place */
|
/* Put this test here for a lack of better place */
|
||||||
assert_cc(EAGAIN == EWOULDBLOCK);
|
assert_cc(EAGAIN == EWOULDBLOCK);
|
||||||
@ -354,6 +356,17 @@ FILE* safe_fclose(FILE *f) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DIR* safe_closedir(DIR *d) {
|
||||||
|
|
||||||
|
if (d) {
|
||||||
|
PROTECT_ERRNO;
|
||||||
|
|
||||||
|
assert_se(closedir(d) >= 0 || errno != EBADF);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int unlink_noerrno(const char *path) {
|
int unlink_noerrno(const char *path) {
|
||||||
PROTECT_ERRNO;
|
PROTECT_ERRNO;
|
||||||
int r;
|
int r;
|
||||||
@ -2133,7 +2146,13 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(buf);
|
assert(buf);
|
||||||
|
|
||||||
while (nbytes > 0) {
|
/* If called with nbytes == 0, let's call read() at least
|
||||||
|
* once, to validate the operation */
|
||||||
|
|
||||||
|
if (nbytes > (size_t) SSIZE_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
do {
|
||||||
ssize_t k;
|
ssize_t k;
|
||||||
|
|
||||||
k = read(fd, p, nbytes);
|
k = read(fd, p, nbytes);
|
||||||
@ -2147,7 +2166,7 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
|
|||||||
* and expect that any error/EOF is reported
|
* and expect that any error/EOF is reported
|
||||||
* via read() */
|
* via read() */
|
||||||
|
|
||||||
fd_wait_for_event(fd, POLLIN, USEC_INFINITY);
|
(void) fd_wait_for_event(fd, POLLIN, USEC_INFINITY);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2157,10 +2176,12 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
|
|||||||
if (k == 0)
|
if (k == 0)
|
||||||
return n;
|
return n;
|
||||||
|
|
||||||
|
assert((size_t) k <= nbytes);
|
||||||
|
|
||||||
p += k;
|
p += k;
|
||||||
nbytes -= k;
|
nbytes -= k;
|
||||||
n += k;
|
n += k;
|
||||||
}
|
} while (nbytes > 0);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -2170,9 +2191,10 @@ int loop_read_exact(int fd, void *buf, size_t nbytes, bool do_poll) {
|
|||||||
|
|
||||||
n = loop_read(fd, buf, nbytes, do_poll);
|
n = loop_read(fd, buf, nbytes, do_poll);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return n;
|
return (int) n;
|
||||||
if ((size_t) n != nbytes)
|
if ((size_t) n != nbytes)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2182,7 +2204,8 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
|
|||||||
assert(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert(buf);
|
assert(buf);
|
||||||
|
|
||||||
errno = 0;
|
if (nbytes > (size_t) SSIZE_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ssize_t k;
|
ssize_t k;
|
||||||
@ -2197,16 +2220,18 @@ int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
|
|||||||
* and expect that any error/EOF is reported
|
* and expect that any error/EOF is reported
|
||||||
* via write() */
|
* via write() */
|
||||||
|
|
||||||
fd_wait_for_event(fd, POLLOUT, USEC_INFINITY);
|
(void) fd_wait_for_event(fd, POLLOUT, USEC_INFINITY);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbytes > 0 && k == 0) /* Can't really happen */
|
if (_unlikely_(nbytes > 0 && k == 0)) /* Can't really happen */
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
|
assert((size_t) k <= nbytes);
|
||||||
|
|
||||||
p += k;
|
p += k;
|
||||||
nbytes -= k;
|
nbytes -= k;
|
||||||
} while (nbytes > 0);
|
} while (nbytes > 0);
|
||||||
@ -6538,7 +6563,7 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
|
|||||||
|
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
if (streq_ptr(table[i], key))
|
if (streq_ptr(table[i], key))
|
||||||
return (ssize_t)i;
|
return (ssize_t) i;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -22,30 +22,30 @@
|
|||||||
***/
|
***/
|
||||||
|
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
#include <dirent.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <time.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/statfs.h>
|
#include <sys/statfs.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "formats-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "missing.h"
|
#include "missing.h"
|
||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
#include "formats-util.h"
|
|
||||||
|
|
||||||
/* What is interpreted as whitespace? */
|
/* What is interpreted as whitespace? */
|
||||||
#define WHITESPACE " \t\n\r"
|
#define WHITESPACE " \t\n\r"
|
||||||
@ -151,6 +151,7 @@ void close_many(const int fds[], unsigned n_fd);
|
|||||||
|
|
||||||
int fclose_nointr(FILE *f);
|
int fclose_nointr(FILE *f);
|
||||||
FILE* safe_fclose(FILE *f);
|
FILE* safe_fclose(FILE *f);
|
||||||
|
DIR* safe_closedir(DIR *f);
|
||||||
|
|
||||||
int parse_size(const char *t, uint64_t base, uint64_t *size);
|
int parse_size(const char *t, uint64_t base, uint64_t *size);
|
||||||
|
|
||||||
@ -160,7 +161,10 @@ int parse_uid(const char *s, uid_t* ret_uid);
|
|||||||
#define parse_gid(s, ret_gid) parse_uid(s, ret_gid)
|
#define parse_gid(s, ret_gid) parse_uid(s, ret_gid)
|
||||||
|
|
||||||
bool uid_is_valid(uid_t uid);
|
bool uid_is_valid(uid_t uid);
|
||||||
#define gid_is_valid(gid) uid_is_valid(gid)
|
|
||||||
|
static inline bool gid_is_valid(gid_t gid) {
|
||||||
|
return uid_is_valid((uid_t) gid);
|
||||||
|
}
|
||||||
|
|
||||||
int safe_atou(const char *s, unsigned *ret_u);
|
int safe_atou(const char *s, unsigned *ret_u);
|
||||||
int safe_atoi(const char *s, int *ret_i);
|
int safe_atoi(const char *s, int *ret_i);
|
||||||
@ -289,9 +293,9 @@ bool chars_intersect(const char *a, const char *b) _pure_;
|
|||||||
|
|
||||||
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key);
|
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key);
|
||||||
|
|
||||||
#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
|
#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \
|
||||||
scope inline type name##_from_string(const char *s) { \
|
scope type name##_from_string(const char *s) { \
|
||||||
return (type)string_table_lookup(name##_table, ELEMENTSOF(name##_table), s); \
|
return (type) string_table_lookup(name##_table, ELEMENTSOF(name##_table), s); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
|
#define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
|
||||||
@ -308,17 +312,15 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
|
|||||||
#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \
|
#define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \
|
||||||
int name##_to_string_alloc(type i, char **str) { \
|
int name##_to_string_alloc(type i, char **str) { \
|
||||||
char *s; \
|
char *s; \
|
||||||
int r; \
|
|
||||||
if (i < 0 || i > max) \
|
if (i < 0 || i > max) \
|
||||||
return -ERANGE; \
|
return -ERANGE; \
|
||||||
if (i < (type) ELEMENTSOF(name##_table)) { \
|
if (i < (type) ELEMENTSOF(name##_table)) { \
|
||||||
s = strdup(name##_table[i]); \
|
s = strdup(name##_table[i]); \
|
||||||
if (!s) \
|
if (!s) \
|
||||||
return log_oom(); \
|
return -ENOMEM; \
|
||||||
} else { \
|
} else { \
|
||||||
r = asprintf(&s, "%i", i); \
|
if (asprintf(&s, "%i", i) < 0) \
|
||||||
if (r < 0) \
|
return -ENOMEM; \
|
||||||
return log_oom(); \
|
|
||||||
} \
|
} \
|
||||||
*str = s; \
|
*str = s; \
|
||||||
return 0; \
|
return 0; \
|
||||||
@ -326,10 +328,10 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
|
|||||||
type name##_from_string(const char *s) { \
|
type name##_from_string(const char *s) { \
|
||||||
type i; \
|
type i; \
|
||||||
unsigned u = 0; \
|
unsigned u = 0; \
|
||||||
assert(s); \
|
if (!s) \
|
||||||
for (i = 0; i < (type)ELEMENTSOF(name##_table); i++) \
|
return (type) -1; \
|
||||||
if (name##_table[i] && \
|
for (i = 0; i < (type) ELEMENTSOF(name##_table); i++) \
|
||||||
streq(name##_table[i], s)) \
|
if (streq_ptr(name##_table[i], s)) \
|
||||||
return i; \
|
return i; \
|
||||||
if (safe_atou(s, &u) >= 0 && u <= max) \
|
if (safe_atou(s, &u) >= 0 && u <= max) \
|
||||||
return (type) u; \
|
return (type) u; \
|
||||||
|
@ -528,9 +528,6 @@ static int group_compare(const void*a, const void *b) {
|
|||||||
return path_compare(x->path, y->path);
|
return path_compare(x->path, y->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ON ANSI_HIGHLIGHT_ON
|
|
||||||
#define OFF ANSI_HIGHLIGHT_OFF
|
|
||||||
|
|
||||||
static void display(Hashmap *a) {
|
static void display(Hashmap *a) {
|
||||||
Iterator i;
|
Iterator i;
|
||||||
Group *g;
|
Group *g;
|
||||||
@ -541,10 +538,8 @@ static void display(Hashmap *a) {
|
|||||||
|
|
||||||
assert(a);
|
assert(a);
|
||||||
|
|
||||||
/* Set cursor to top left corner and clear screen */
|
|
||||||
if (on_tty())
|
if (on_tty())
|
||||||
fputs("\033[H"
|
fputs(ANSI_HOME_CLEAR, stdout);
|
||||||
"\033[2J", stdout);
|
|
||||||
|
|
||||||
array = alloca(sizeof(Group*) * hashmap_size(a));
|
array = alloca(sizeof(Group*) * hashmap_size(a));
|
||||||
|
|
||||||
@ -576,23 +571,30 @@ static void display(Hashmap *a) {
|
|||||||
rows = 10;
|
rows = 10;
|
||||||
|
|
||||||
if (on_tty()) {
|
if (on_tty()) {
|
||||||
|
const char *on, *off;
|
||||||
|
|
||||||
path_columns = columns() - 36 - strlen(buffer);
|
path_columns = columns() - 36 - strlen(buffer);
|
||||||
if (path_columns < 10)
|
if (path_columns < 10)
|
||||||
path_columns = 10;
|
path_columns = 10;
|
||||||
|
|
||||||
printf("%s%-*s%s %s%7s%s %s%s%s %s%8s%s %s%8s%s %s%8s%s\n\n",
|
on = ansi_highlight_underline();
|
||||||
arg_order == ORDER_PATH ? ON : "", path_columns, "Control Group",
|
off = ansi_underline();
|
||||||
arg_order == ORDER_PATH ? OFF : "",
|
|
||||||
arg_order == ORDER_TASKS ? ON : "", arg_count == COUNT_PIDS ? "Tasks" : arg_count == COUNT_USERSPACE_PROCESSES ? "Procs" : "Proc+",
|
printf("%s%s%-*s%s %s%7s%s %s%s%s %s%8s%s %s%8s%s %s%8s%s%s\n",
|
||||||
arg_order == ORDER_TASKS ? OFF : "",
|
ansi_underline(),
|
||||||
arg_order == ORDER_CPU ? ON : "", buffer,
|
arg_order == ORDER_PATH ? on : "", path_columns, "Control Group",
|
||||||
arg_order == ORDER_CPU ? OFF : "",
|
arg_order == ORDER_PATH ? off : "",
|
||||||
arg_order == ORDER_MEMORY ? ON : "", "Memory",
|
arg_order == ORDER_TASKS ? on : "", arg_count == COUNT_PIDS ? "Tasks" : arg_count == COUNT_USERSPACE_PROCESSES ? "Procs" : "Proc+",
|
||||||
arg_order == ORDER_MEMORY ? OFF : "",
|
arg_order == ORDER_TASKS ? off : "",
|
||||||
arg_order == ORDER_IO ? ON : "", "Input/s",
|
arg_order == ORDER_CPU ? on : "", buffer,
|
||||||
arg_order == ORDER_IO ? OFF : "",
|
arg_order == ORDER_CPU ? off : "",
|
||||||
arg_order == ORDER_IO ? ON : "", "Output/s",
|
arg_order == ORDER_MEMORY ? on : "", "Memory",
|
||||||
arg_order == ORDER_IO ? OFF : "");
|
arg_order == ORDER_MEMORY ? off : "",
|
||||||
|
arg_order == ORDER_IO ? on : "", "Input/s",
|
||||||
|
arg_order == ORDER_IO ? off : "",
|
||||||
|
arg_order == ORDER_IO ? on : "", "Output/s",
|
||||||
|
arg_order == ORDER_IO ? off : "",
|
||||||
|
ansi_normal());
|
||||||
} else
|
} else
|
||||||
path_columns = maxtpath;
|
path_columns = maxtpath;
|
||||||
|
|
||||||
@ -600,7 +602,7 @@ static void display(Hashmap *a) {
|
|||||||
_cleanup_free_ char *ellipsized = NULL;
|
_cleanup_free_ char *ellipsized = NULL;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (on_tty() && j + 5 > rows)
|
if (on_tty() && j + 6 > rows)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
g = array[j];
|
g = array[j];
|
||||||
@ -1061,6 +1063,10 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
||||||
|
#define ON ANSI_HIGHLIGHT
|
||||||
|
#define OFF ANSI_NORMAL
|
||||||
|
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"\t<" ON "p" OFF "> By path; <" ON "t" OFF "> By tasks/procs; <" ON "c" OFF "> By CPU; <" ON "m" OFF "> By memory; <" ON "i" OFF "> By I/O\n"
|
"\t<" ON "p" OFF "> By path; <" ON "t" OFF "> By tasks/procs; <" ON "c" OFF "> By CPU; <" ON "m" OFF "> By memory; <" ON "i" OFF "> By I/O\n"
|
||||||
"\t<" ON "+" OFF "> Inc. delay; <" ON "-" OFF "> Dec. delay; <" ON "%%" OFF "> Toggle time; <" ON "SPACE" OFF "> Refresh\n"
|
"\t<" ON "+" OFF "> Inc. delay; <" ON "-" OFF "> Dec. delay; <" ON "%%" OFF "> Toggle time; <" ON "SPACE" OFF "> Refresh\n"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
static void log_and_status(Manager *m, const char *message) {
|
static void log_and_status(Manager *m, const char *message) {
|
||||||
log_warning("%s", message);
|
log_warning("%s", message);
|
||||||
manager_status_printf(m, STATUS_TYPE_EMERGENCY,
|
manager_status_printf(m, STATUS_TYPE_EMERGENCY,
|
||||||
ANSI_HIGHLIGHT_RED_ON " !! " ANSI_HIGHLIGHT_OFF,
|
ANSI_HIGHLIGHT_RED " !! " ANSI_NORMAL,
|
||||||
"%s", message);
|
"%s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,13 +670,13 @@ _pure_ static const char *job_get_status_message_format(Unit *u, JobType t, JobR
|
|||||||
static void job_print_status_message(Unit *u, JobType t, JobResult result) {
|
static void job_print_status_message(Unit *u, JobType t, JobResult result) {
|
||||||
const char *format;
|
const char *format;
|
||||||
static const char* const job_result_status_table[_JOB_RESULT_MAX] = {
|
static const char* const job_result_status_table[_JOB_RESULT_MAX] = {
|
||||||
[JOB_DONE] = ANSI_GREEN_ON " OK " ANSI_HIGHLIGHT_OFF,
|
[JOB_DONE] = ANSI_GREEN " OK " ANSI_NORMAL,
|
||||||
[JOB_TIMEOUT] = ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF,
|
[JOB_TIMEOUT] = ANSI_HIGHLIGHT_RED " TIME " ANSI_NORMAL,
|
||||||
[JOB_FAILED] = ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF,
|
[JOB_FAILED] = ANSI_HIGHLIGHT_RED "FAILED" ANSI_NORMAL,
|
||||||
[JOB_DEPENDENCY] = ANSI_HIGHLIGHT_YELLOW_ON "DEPEND" ANSI_HIGHLIGHT_OFF,
|
[JOB_DEPENDENCY] = ANSI_HIGHLIGHT_YELLOW "DEPEND" ANSI_NORMAL,
|
||||||
[JOB_SKIPPED] = ANSI_HIGHLIGHT_ON " INFO " ANSI_HIGHLIGHT_OFF,
|
[JOB_SKIPPED] = ANSI_HIGHLIGHT " INFO " ANSI_NORMAL,
|
||||||
[JOB_ASSERT] = ANSI_HIGHLIGHT_YELLOW_ON "ASSERT" ANSI_HIGHLIGHT_OFF,
|
[JOB_ASSERT] = ANSI_HIGHLIGHT_YELLOW "ASSERT" ANSI_NORMAL,
|
||||||
[JOB_UNSUPPORTED] = ANSI_HIGHLIGHT_YELLOW_ON "UNSUPP" ANSI_HIGHLIGHT_OFF,
|
[JOB_UNSUPPORTED] = ANSI_HIGHLIGHT_YELLOW "UNSUPP" ANSI_NORMAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
|
@ -2053,7 +2053,7 @@ finish:
|
|||||||
if (getpid() == 1) {
|
if (getpid() == 1) {
|
||||||
if (error_message)
|
if (error_message)
|
||||||
manager_status_printf(NULL, STATUS_TYPE_EMERGENCY,
|
manager_status_printf(NULL, STATUS_TYPE_EMERGENCY,
|
||||||
ANSI_HIGHLIGHT_RED_ON "!!!!!!" ANSI_HIGHLIGHT_OFF,
|
ANSI_HIGHLIGHT_RED "!!!!!!" ANSI_NORMAL,
|
||||||
"%s, freezing.", error_message);
|
"%s, freezing.", error_message);
|
||||||
freeze();
|
freeze();
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ static void manager_watch_jobs_in_progress(Manager *m) {
|
|||||||
(void) sd_event_source_set_description(m->jobs_in_progress_event_source, "manager-jobs-in-progress");
|
(void) sd_event_source_set_description(m->jobs_in_progress_event_source, "manager-jobs-in-progress");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1))
|
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED)-1) + sizeof(ANSI_HIGHLIGHT_RED)-1 + 2*(sizeof(ANSI_NORMAL)-1))
|
||||||
|
|
||||||
static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos) {
|
static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos) {
|
||||||
char *p = buffer;
|
char *p = buffer;
|
||||||
@ -122,23 +122,23 @@ static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned po
|
|||||||
if (pos > 1) {
|
if (pos > 1) {
|
||||||
if (pos > 2)
|
if (pos > 2)
|
||||||
p = mempset(p, ' ', pos-2);
|
p = mempset(p, ' ', pos-2);
|
||||||
p = stpcpy(p, ANSI_RED_ON);
|
p = stpcpy(p, ANSI_RED);
|
||||||
*p++ = '*';
|
*p++ = '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos > 0 && pos <= width) {
|
if (pos > 0 && pos <= width) {
|
||||||
p = stpcpy(p, ANSI_HIGHLIGHT_RED_ON);
|
p = stpcpy(p, ANSI_HIGHLIGHT_RED);
|
||||||
*p++ = '*';
|
*p++ = '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
|
p = stpcpy(p, ANSI_NORMAL);
|
||||||
|
|
||||||
if (pos < width) {
|
if (pos < width) {
|
||||||
p = stpcpy(p, ANSI_RED_ON);
|
p = stpcpy(p, ANSI_RED);
|
||||||
*p++ = '*';
|
*p++ = '*';
|
||||||
if (pos < width-1)
|
if (pos < width-1)
|
||||||
p = mempset(p, ' ', width-1-pos);
|
p = mempset(p, ' ', width-1-pos);
|
||||||
strcpy(p, ANSI_HIGHLIGHT_OFF);
|
strcpy(p, ANSI_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1071,8 +1071,7 @@ static void manager_build_unit_path_cache(Manager *m) {
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(d);
|
d = safe_closedir(d);
|
||||||
d = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -401,7 +401,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
|
|||||||
"Job %s/%s deleted to break ordering cycle starting with %s/%s",
|
"Job %s/%s deleted to break ordering cycle starting with %s/%s",
|
||||||
delete->unit->id, job_type_to_string(delete->type),
|
delete->unit->id, job_type_to_string(delete->type),
|
||||||
j->unit->id, job_type_to_string(j->type));
|
j->unit->id, job_type_to_string(j->type));
|
||||||
unit_status_printf(delete->unit, ANSI_HIGHLIGHT_RED_ON " SKIP " ANSI_HIGHLIGHT_OFF,
|
unit_status_printf(delete->unit, ANSI_HIGHLIGHT_RED " SKIP " ANSI_NORMAL,
|
||||||
"Ordering cycle found, skipping %s");
|
"Ordering cycle found, skipping %s");
|
||||||
transaction_delete_unit(tr, delete->unit);
|
transaction_delete_unit(tr, delete->unit);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
@ -107,7 +107,7 @@ static int notify_override_masked(const char *top, const char *bottom) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight_red(), "[MASKED]", ansi_highlight_off(),
|
ansi_highlight_red(), "[MASKED]", ansi_normal(),
|
||||||
top, draw_special_char(DRAW_ARROW), bottom);
|
top, draw_special_char(DRAW_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ static int notify_override_equivalent(const char *top, const char *bottom) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight_off(),
|
ansi_highlight_green(), "[EQUIVALENT]", ansi_normal(),
|
||||||
top, draw_special_char(DRAW_ARROW), bottom);
|
top, draw_special_char(DRAW_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ static int notify_override_redirected(const char *top, const char *bottom) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(),
|
ansi_highlight(), "[REDIRECTED]", ansi_normal(),
|
||||||
top, draw_special_char(DRAW_ARROW), bottom);
|
top, draw_special_char(DRAW_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ static int notify_override_overridden(const char *top, const char *bottom) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(),
|
ansi_highlight(), "[OVERRIDDEN]", ansi_normal(),
|
||||||
top, draw_special_char(DRAW_ARROW), bottom);
|
top, draw_special_char(DRAW_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ static int notify_override_extended(const char *top, const char *bottom) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("%s%s%s %s %s %s\n",
|
printf("%s%s%s %s %s %s\n",
|
||||||
ansi_highlight(), "[EXTENDED]", ansi_highlight_off(),
|
ansi_highlight(), "[EXTENDED]", ansi_normal(),
|
||||||
top, draw_special_char(DRAW_ARROW), bottom);
|
top, draw_special_char(DRAW_ARROW), bottom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
|
|||||||
t->type = _TRANSFER_TYPE_INVALID;
|
t->type = _TRANSFER_TYPE_INVALID;
|
||||||
t->log_fd = -1;
|
t->log_fd = -1;
|
||||||
t->stdin_fd = -1;
|
t->stdin_fd = -1;
|
||||||
|
t->stdout_fd = -1;
|
||||||
t->verify = _IMPORT_VERIFY_INVALID;
|
t->verify = _IMPORT_VERIFY_INVALID;
|
||||||
|
|
||||||
id = m->current_transfer_id + 1;
|
id = m->current_transfer_id + 1;
|
||||||
|
@ -402,11 +402,11 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
|
|||||||
if (comm)
|
if (comm)
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
" PID: %s%s%s (%s)\n",
|
" PID: %s%s%s (%s)\n",
|
||||||
ansi_highlight(), strna(pid), ansi_highlight_off(), comm);
|
ansi_highlight(), strna(pid), ansi_normal(), comm);
|
||||||
else
|
else
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
" PID: %s%s%s\n",
|
" PID: %s%s%s\n",
|
||||||
ansi_highlight(), strna(pid), ansi_highlight_off());
|
ansi_highlight(), strna(pid), ansi_normal());
|
||||||
|
|
||||||
if (uid) {
|
if (uid) {
|
||||||
uid_t n;
|
uid_t n;
|
||||||
@ -470,7 +470,7 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) {
|
|||||||
if (cmdline)
|
if (cmdline)
|
||||||
fprintf(file, " Command Line: %s\n", cmdline);
|
fprintf(file, " Command Line: %s\n", cmdline);
|
||||||
if (exe)
|
if (exe)
|
||||||
fprintf(file, " Executable: %s%s%s\n", ansi_highlight(), exe, ansi_highlight_off());
|
fprintf(file, " Executable: %s%s%s\n", ansi_highlight(), exe, ansi_normal());
|
||||||
if (cgroup)
|
if (cgroup)
|
||||||
fprintf(file, " Control Group: %s\n", cgroup);
|
fprintf(file, " Control Group: %s\n", cgroup);
|
||||||
if (unit)
|
if (unit)
|
||||||
|
@ -53,12 +53,12 @@ static void draw_progress(uint64_t p, usec_t *last_usec) {
|
|||||||
j = (n * (unsigned) p) / 65535ULL;
|
j = (n * (unsigned) p) / 65535ULL;
|
||||||
k = n - j;
|
k = n - j;
|
||||||
|
|
||||||
fputs("\r\x1B[?25l" ANSI_HIGHLIGHT_GREEN_ON, stdout);
|
fputs("\r\x1B[?25l" ANSI_HIGHLIGHT_GREEN, stdout);
|
||||||
|
|
||||||
for (i = 0; i < j; i++)
|
for (i = 0; i < j; i++)
|
||||||
fputs("\xe2\x96\x88", stdout);
|
fputs("\xe2\x96\x88", stdout);
|
||||||
|
|
||||||
fputs(ANSI_HIGHLIGHT_OFF, stdout);
|
fputs(ANSI_NORMAL, stdout);
|
||||||
|
|
||||||
for (i = 0; i < k; i++)
|
for (i = 0; i < k; i++)
|
||||||
fputs("\xe2\x96\x91", stdout);
|
fputs("\xe2\x96\x91", stdout);
|
||||||
|
@ -1493,15 +1493,15 @@ static int setup_keys(void) {
|
|||||||
if (on_tty()) {
|
if (on_tty()) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n"
|
"\n"
|
||||||
"The new key pair has been generated. The " ANSI_HIGHLIGHT_ON "secret sealing key" ANSI_HIGHLIGHT_OFF " has been written to\n"
|
"The new key pair has been generated. The " ANSI_HIGHLIGHT "secret sealing key" ANSI_NORMAL " has been written to\n"
|
||||||
"the following local file. This key file is automatically updated when the\n"
|
"the following local file. This key file is automatically updated when the\n"
|
||||||
"sealing key is advanced. It should not be used on multiple hosts.\n"
|
"sealing key is advanced. It should not be used on multiple hosts.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"\t%s\n"
|
"\t%s\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Please write down the following " ANSI_HIGHLIGHT_ON "secret verification key" ANSI_HIGHLIGHT_OFF ". It should be stored\n"
|
"Please write down the following " ANSI_HIGHLIGHT "secret verification key" ANSI_NORMAL ". It should be stored\n"
|
||||||
"at a safe location and should not be saved locally on disk.\n"
|
"at a safe location and should not be saved locally on disk.\n"
|
||||||
"\n\t" ANSI_HIGHLIGHT_RED_ON, p);
|
"\n\t" ANSI_HIGHLIGHT_RED, p);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
for (i = 0; i < seed_size; i++) {
|
for (i = 0; i < seed_size; i++) {
|
||||||
@ -1516,7 +1516,7 @@ static int setup_keys(void) {
|
|||||||
char tsb[FORMAT_TIMESPAN_MAX], *hn;
|
char tsb[FORMAT_TIMESPAN_MAX], *hn;
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
ANSI_HIGHLIGHT_OFF "\n"
|
ANSI_NORMAL "\n"
|
||||||
"The sealing key is automatically changed every %s.\n",
|
"The sealing key is automatically changed every %s.\n",
|
||||||
format_timespan(tsb, sizeof(tsb), arg_interval, 0));
|
format_timespan(tsb, sizeof(tsb), arg_interval, 0));
|
||||||
|
|
||||||
@ -2144,7 +2144,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (previous_boot_id_valid &&
|
if (previous_boot_id_valid &&
|
||||||
!sd_id128_equal(boot_id, previous_boot_id))
|
!sd_id128_equal(boot_id, previous_boot_id))
|
||||||
printf("%s-- Reboot --%s\n",
|
printf("%s-- Reboot --%s\n",
|
||||||
ansi_highlight(), ansi_highlight_off());
|
ansi_highlight(), ansi_normal());
|
||||||
|
|
||||||
previous_boot_id = boot_id;
|
previous_boot_id = boot_id;
|
||||||
previous_boot_id_valid = true;
|
previous_boot_id_valid = true;
|
||||||
|
@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
|
|||||||
log_info("[ %"PRIu64"+%"PRIu64"]", p / 8, p % 8);
|
log_info("[ %"PRIu64"+%"PRIu64"]", p / 8, p % 8);
|
||||||
|
|
||||||
if (raw_verify("test.journal", verification_key) >= 0)
|
if (raw_verify("test.journal", verification_key) >= 0)
|
||||||
log_notice(ANSI_HIGHLIGHT_RED_ON ">>>> %"PRIu64" (bit %"PRIu64") can be toggled without detection." ANSI_HIGHLIGHT_OFF, p / 8, p % 8);
|
log_notice(ANSI_HIGHLIGHT_RED ">>>> %"PRIu64" (bit %"PRIu64") can be toggled without detection." ANSI_NORMAL, p / 8, p % 8);
|
||||||
|
|
||||||
bit_toggle("test.journal", p);
|
bit_toggle("test.journal", p);
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
|
|||||||
"%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%"PRIi64,
|
"%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%"PRIi64,
|
||||||
m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
|
m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
|
||||||
m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
|
m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
|
||||||
m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_highlight_off(),
|
m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_normal(),
|
||||||
ansi_highlight(), bus_message_type_to_string(m->header->type), ansi_highlight_off(),
|
ansi_highlight(), bus_message_type_to_string(m->header->type), ansi_normal(),
|
||||||
m->header->endian,
|
m->header->endian,
|
||||||
m->header->flags,
|
m->header->flags,
|
||||||
m->header->version,
|
m->header->version,
|
||||||
@ -93,15 +93,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
|
|||||||
fputs("\n", f);
|
fputs("\n", f);
|
||||||
|
|
||||||
if (m->sender)
|
if (m->sender)
|
||||||
fprintf(f, " Sender=%s%s%s", ansi_highlight(), m->sender, ansi_highlight_off());
|
fprintf(f, " Sender=%s%s%s", ansi_highlight(), m->sender, ansi_normal());
|
||||||
if (m->destination)
|
if (m->destination)
|
||||||
fprintf(f, " Destination=%s%s%s", ansi_highlight(), m->destination, ansi_highlight_off());
|
fprintf(f, " Destination=%s%s%s", ansi_highlight(), m->destination, ansi_normal());
|
||||||
if (m->path)
|
if (m->path)
|
||||||
fprintf(f, " Path=%s%s%s", ansi_highlight(), m->path, ansi_highlight_off());
|
fprintf(f, " Path=%s%s%s", ansi_highlight(), m->path, ansi_normal());
|
||||||
if (m->interface)
|
if (m->interface)
|
||||||
fprintf(f, " Interface=%s%s%s", ansi_highlight(), m->interface, ansi_highlight_off());
|
fprintf(f, " Interface=%s%s%s", ansi_highlight(), m->interface, ansi_normal());
|
||||||
if (m->member)
|
if (m->member)
|
||||||
fprintf(f, " Member=%s%s%s", ansi_highlight(), m->member, ansi_highlight_off());
|
fprintf(f, " Member=%s%s%s", ansi_highlight(), m->member, ansi_normal());
|
||||||
|
|
||||||
if (m->sender || m->destination || m->path || m->interface || m->member)
|
if (m->sender || m->destination || m->path || m->interface || m->member)
|
||||||
fputs("\n", f);
|
fputs("\n", f);
|
||||||
@ -110,8 +110,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
|
|||||||
fprintf(f,
|
fprintf(f,
|
||||||
" ErrorName=%s%s%s"
|
" ErrorName=%s%s%s"
|
||||||
" ErrorMessage=%s\"%s\"%s\n",
|
" ErrorMessage=%s\"%s\"%s\n",
|
||||||
ansi_highlight_red(), strna(m->error.name), ansi_highlight_off(),
|
ansi_highlight_red(), strna(m->error.name), ansi_normal(),
|
||||||
ansi_highlight_red(), strna(m->error.message), ansi_highlight_off());
|
ansi_highlight_red(), strna(m->error.message), ansi_normal());
|
||||||
|
|
||||||
if (m->monotonic != 0)
|
if (m->monotonic != 0)
|
||||||
fprintf(f, " Monotonic="USEC_FMT, m->monotonic);
|
fprintf(f, " Monotonic="USEC_FMT, m->monotonic);
|
||||||
@ -211,55 +211,55 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
case SD_BUS_TYPE_BYTE:
|
case SD_BUS_TYPE_BYTE:
|
||||||
fprintf(f, "%sBYTE %s%u%s;\n", prefix, ansi_highlight(), basic.u8, ansi_highlight_off());
|
fprintf(f, "%sBYTE %s%u%s;\n", prefix, ansi_highlight(), basic.u8, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_BOOLEAN:
|
case SD_BUS_TYPE_BOOLEAN:
|
||||||
fprintf(f, "%sBOOLEAN %s%s%s;\n", prefix, ansi_highlight(), true_false(basic.i), ansi_highlight_off());
|
fprintf(f, "%sBOOLEAN %s%s%s;\n", prefix, ansi_highlight(), true_false(basic.i), ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_INT16:
|
case SD_BUS_TYPE_INT16:
|
||||||
fprintf(f, "%sINT16 %s%i%s;\n", prefix, ansi_highlight(), basic.s16, ansi_highlight_off());
|
fprintf(f, "%sINT16 %s%i%s;\n", prefix, ansi_highlight(), basic.s16, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_UINT16:
|
case SD_BUS_TYPE_UINT16:
|
||||||
fprintf(f, "%sUINT16 %s%u%s;\n", prefix, ansi_highlight(), basic.u16, ansi_highlight_off());
|
fprintf(f, "%sUINT16 %s%u%s;\n", prefix, ansi_highlight(), basic.u16, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_INT32:
|
case SD_BUS_TYPE_INT32:
|
||||||
fprintf(f, "%sINT32 %s%i%s;\n", prefix, ansi_highlight(), basic.s32, ansi_highlight_off());
|
fprintf(f, "%sINT32 %s%i%s;\n", prefix, ansi_highlight(), basic.s32, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_UINT32:
|
case SD_BUS_TYPE_UINT32:
|
||||||
fprintf(f, "%sUINT32 %s%u%s;\n", prefix, ansi_highlight(), basic.u32, ansi_highlight_off());
|
fprintf(f, "%sUINT32 %s%u%s;\n", prefix, ansi_highlight(), basic.u32, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_INT64:
|
case SD_BUS_TYPE_INT64:
|
||||||
fprintf(f, "%sINT64 %s%"PRIi64"%s;\n", prefix, ansi_highlight(), basic.s64, ansi_highlight_off());
|
fprintf(f, "%sINT64 %s%"PRIi64"%s;\n", prefix, ansi_highlight(), basic.s64, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_UINT64:
|
case SD_BUS_TYPE_UINT64:
|
||||||
fprintf(f, "%sUINT64 %s%"PRIu64"%s;\n", prefix, ansi_highlight(), basic.u64, ansi_highlight_off());
|
fprintf(f, "%sUINT64 %s%"PRIu64"%s;\n", prefix, ansi_highlight(), basic.u64, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_DOUBLE:
|
case SD_BUS_TYPE_DOUBLE:
|
||||||
fprintf(f, "%sDOUBLE %s%g%s;\n", prefix, ansi_highlight(), basic.d64, ansi_highlight_off());
|
fprintf(f, "%sDOUBLE %s%g%s;\n", prefix, ansi_highlight(), basic.d64, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_STRING:
|
case SD_BUS_TYPE_STRING:
|
||||||
fprintf(f, "%sSTRING \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
|
fprintf(f, "%sSTRING \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_OBJECT_PATH:
|
case SD_BUS_TYPE_OBJECT_PATH:
|
||||||
fprintf(f, "%sOBJECT_PATH \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
|
fprintf(f, "%sOBJECT_PATH \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_SIGNATURE:
|
case SD_BUS_TYPE_SIGNATURE:
|
||||||
fprintf(f, "%sSIGNATURE \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_highlight_off());
|
fprintf(f, "%sSIGNATURE \"%s%s%s\";\n", prefix, ansi_highlight(), basic.string, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SD_BUS_TYPE_UNIX_FD:
|
case SD_BUS_TYPE_UNIX_FD:
|
||||||
fprintf(f, "%sUNIX_FD %s%i%s;\n", prefix, ansi_highlight(), basic.i, ansi_highlight_off());
|
fprintf(f, "%sUNIX_FD %s%i%s;\n", prefix, ansi_highlight(), basic.i, ansi_normal());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -327,7 +327,7 @@ static void dump_capabilities(
|
|||||||
fputs("\n", f);
|
fputs("\n", f);
|
||||||
|
|
||||||
if (!terse)
|
if (!terse)
|
||||||
fputs(ansi_highlight_off(), f);
|
fputs(ansi_normal(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
|
int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
|
||||||
@ -352,7 +352,7 @@ int bus_creds_dump(sd_bus_creds *c, FILE *f, bool terse) {
|
|||||||
prefix = "";
|
prefix = "";
|
||||||
color = ansi_highlight();
|
color = ansi_highlight();
|
||||||
|
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
suffix = strjoina(off, "\n");
|
suffix = strjoina(off, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ static int tree(sd_bus *bus, char **argv) {
|
|||||||
if (not_first)
|
if (not_first)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_highlight_off());
|
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
|
||||||
|
|
||||||
q = tree_one(bus, *i, NULL, true);
|
q = tree_one(bus, *i, NULL, true);
|
||||||
if (q < 0 && r >= 0)
|
if (q < 0 && r >= 0)
|
||||||
@ -466,7 +466,7 @@ static int tree(sd_bus *bus, char **argv) {
|
|||||||
|
|
||||||
if (argv[2]) {
|
if (argv[2]) {
|
||||||
pager_open_if_enabled();
|
pager_open_if_enabled();
|
||||||
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_highlight_off());
|
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
|
||||||
}
|
}
|
||||||
|
|
||||||
q = tree_one(bus, *i, NULL, !!argv[2]);
|
q = tree_one(bus, *i, NULL, !!argv[2]);
|
||||||
@ -1052,7 +1052,7 @@ static int introspect(sd_bus *bus, char **argv) {
|
|||||||
is_interface ? ansi_highlight() : "",
|
is_interface ? ansi_highlight() : "",
|
||||||
is_interface ? "" : ".",
|
is_interface ? "" : ".",
|
||||||
- !is_interface + (int) name_width, strdash(streq_ptr(m->type, "interface") ? m->interface : m->name),
|
- !is_interface + (int) name_width, strdash(streq_ptr(m->type, "interface") ? m->interface : m->name),
|
||||||
is_interface ? ansi_highlight_off() : "",
|
is_interface ? ansi_normal() : "",
|
||||||
(int) type_width, strdash(m->type),
|
(int) type_width, strdash(m->type),
|
||||||
(int) signature_width, strdash(m->signature),
|
(int) signature_width, strdash(m->signature),
|
||||||
(int) result_width, rv,
|
(int) result_width, rv,
|
||||||
@ -1196,15 +1196,15 @@ static int status(sd_bus *bus, char *argv[]) {
|
|||||||
|
|
||||||
r = sd_bus_get_address(bus, &address);
|
r = sd_bus_get_address(bus, &address);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
printf("BusAddress=%s%s%s\n", ansi_highlight(), address, ansi_highlight_off());
|
printf("BusAddress=%s%s%s\n", ansi_highlight(), address, ansi_normal());
|
||||||
|
|
||||||
r = sd_bus_get_scope(bus, &scope);
|
r = sd_bus_get_scope(bus, &scope);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
printf("BusScope=%s%s%s\n", ansi_highlight(), scope, ansi_highlight_off());
|
printf("BusScope=%s%s%s\n", ansi_highlight(), scope, ansi_normal());
|
||||||
|
|
||||||
r = sd_bus_get_bus_id(bus, &bus_id);
|
r = sd_bus_get_bus_id(bus, &bus_id);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
printf("BusID=%s" SD_ID128_FORMAT_STR "%s\n", ansi_highlight(), SD_ID128_FORMAT_VAL(bus_id), ansi_highlight_off());
|
printf("BusID=%s" SD_ID128_FORMAT_STR "%s\n", ansi_highlight(), SD_ID128_FORMAT_VAL(bus_id), ansi_normal());
|
||||||
|
|
||||||
r = sd_bus_get_owner_creds(
|
r = sd_bus_get_owner_creds(
|
||||||
bus,
|
bus,
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "sd-id128.h"
|
#include "sd-id128.h"
|
||||||
#include "random-util.h"
|
#include "random-util.h"
|
||||||
|
|
||||||
_public_ char *sd_id128_to_string(sd_id128_t id, char s[33]) {
|
_public_ char *sd_id128_to_string(sd_id128_t id, char s[SD_ID128_STRING_MAX]) {
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
assert_return(s, NULL);
|
assert_return(s, NULL);
|
||||||
|
@ -720,7 +720,7 @@ static int print_property(const char *name, sd_bus_message *m, const char *conte
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return bus_log_parse_error(r);
|
return bus_log_parse_error(r);
|
||||||
|
|
||||||
if (UID_IS_INVALID(uid)) {
|
if (!uid_is_valid(uid)) {
|
||||||
log_error("Invalid user ID: " UID_FMT, uid);
|
log_error("Invalid user ID: " UID_FMT, uid);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
|||||||
printf("%-*s %-*s %s%-3s%s %-*s %-*s %-*s\n",
|
printf("%-*s %-*s %s%-3s%s %-*s %-*s %-*s\n",
|
||||||
(int) max_name, images[j].name,
|
(int) max_name, images[j].name,
|
||||||
(int) max_type, images[j].type,
|
(int) max_type, images[j].type,
|
||||||
images[j].read_only ? ansi_highlight_red() : "", yes_no(images[j].read_only), images[j].read_only ? ansi_highlight_off() : "",
|
images[j].read_only ? ansi_highlight_red() : "", yes_no(images[j].read_only), images[j].read_only ? ansi_normal() : "",
|
||||||
(int) max_size, strna(format_bytes(size_buf, sizeof(size_buf), images[j].size)),
|
(int) max_size, strna(format_bytes(size_buf, sizeof(size_buf), images[j].size)),
|
||||||
(int) max_crtime, strna(format_timestamp(crtime_buf, sizeof(crtime_buf), images[j].crtime)),
|
(int) max_crtime, strna(format_timestamp(crtime_buf, sizeof(crtime_buf), images[j].crtime)),
|
||||||
(int) max_mtime, strna(format_timestamp(mtime_buf, sizeof(mtime_buf), images[j].mtime)));
|
(int) max_mtime, strna(format_timestamp(mtime_buf, sizeof(mtime_buf), images[j].mtime)));
|
||||||
@ -793,7 +793,7 @@ static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) {
|
|||||||
printf("\t RO: %s%s%s\n",
|
printf("\t RO: %s%s%s\n",
|
||||||
i->read_only ? ansi_highlight_red() : "",
|
i->read_only ? ansi_highlight_red() : "",
|
||||||
i->read_only ? "read-only" : "writable",
|
i->read_only ? "read-only" : "writable",
|
||||||
i->read_only ? ansi_highlight_off() : "");
|
i->read_only ? ansi_normal() : "");
|
||||||
|
|
||||||
s1 = format_timestamp_relative(ts_relative, sizeof(ts_relative), i->crtime);
|
s1 = format_timestamp_relative(ts_relative, sizeof(ts_relative), i->crtime);
|
||||||
s2 = format_timestamp(ts_absolute, sizeof(ts_absolute), i->crtime);
|
s2 = format_timestamp(ts_absolute, sizeof(ts_absolute), i->crtime);
|
||||||
|
@ -876,7 +876,7 @@ static int method_map_from_machine_user(sd_bus_message *message, void *userdata,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (UID_IS_INVALID(uid))
|
if (!uid_is_valid(uid))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
||||||
|
|
||||||
machine = hashmap_get(m->machines, name);
|
machine = hashmap_get(m->machines, name);
|
||||||
@ -910,7 +910,7 @@ static int method_map_from_machine_user(sd_bus_message *message, void *userdata,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
converted = uid - uid_base + uid_shift;
|
converted = uid - uid_base + uid_shift;
|
||||||
if (UID_IS_INVALID(converted))
|
if (!uid_is_valid(converted))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
||||||
|
|
||||||
return sd_bus_reply_method_return(message, "u", (uint32_t) converted);
|
return sd_bus_reply_method_return(message, "u", (uint32_t) converted);
|
||||||
@ -929,7 +929,7 @@ static int method_map_to_machine_user(sd_bus_message *message, void *userdata, s
|
|||||||
r = sd_bus_message_read(message, "u", &uid);
|
r = sd_bus_message_read(message, "u", &uid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (UID_IS_INVALID(uid))
|
if (!uid_is_valid(uid))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
||||||
if (uid < 0x10000)
|
if (uid < 0x10000)
|
||||||
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER_MAPPING, "User " UID_FMT " belongs to host UID range", uid);
|
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_USER_MAPPING, "User " UID_FMT " belongs to host UID range", uid);
|
||||||
@ -968,7 +968,7 @@ static int method_map_to_machine_user(sd_bus_message *message, void *userdata, s
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
converted = (uid - uid_shift + uid_base);
|
converted = (uid - uid_shift + uid_base);
|
||||||
if (UID_IS_INVALID(converted))
|
if (!uid_is_valid(converted))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid user ID " UID_FMT, uid);
|
||||||
|
|
||||||
o = machine_bus_path(machine);
|
o = machine_bus_path(machine);
|
||||||
@ -994,7 +994,7 @@ static int method_map_from_machine_group(sd_bus_message *message, void *groupdat
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (GID_IS_INVALID(gid))
|
if (!gid_is_valid(gid))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
||||||
|
|
||||||
machine = hashmap_get(m->machines, name);
|
machine = hashmap_get(m->machines, name);
|
||||||
@ -1028,7 +1028,7 @@ static int method_map_from_machine_group(sd_bus_message *message, void *groupdat
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
converted = gid - gid_base + gid_shift;
|
converted = gid - gid_base + gid_shift;
|
||||||
if (GID_IS_INVALID(converted))
|
if (!gid_is_valid(converted))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
||||||
|
|
||||||
return sd_bus_reply_method_return(message, "u", (uint32_t) converted);
|
return sd_bus_reply_method_return(message, "u", (uint32_t) converted);
|
||||||
@ -1047,7 +1047,7 @@ static int method_map_to_machine_group(sd_bus_message *message, void *groupdata,
|
|||||||
r = sd_bus_message_read(message, "u", &gid);
|
r = sd_bus_message_read(message, "u", &gid);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
if (GID_IS_INVALID(gid))
|
if (!gid_is_valid(gid))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
||||||
if (gid < 0x10000)
|
if (gid < 0x10000)
|
||||||
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_GROUP_MAPPING, "Group " GID_FMT " belongs to host GID range", gid);
|
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_GROUP_MAPPING, "Group " GID_FMT " belongs to host GID range", gid);
|
||||||
@ -1086,7 +1086,7 @@ static int method_map_to_machine_group(sd_bus_message *message, void *groupdata,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
converted = (gid - gid_shift + gid_base);
|
converted = (gid - gid_shift + gid_base);
|
||||||
if (GID_IS_INVALID(converted))
|
if (!gid_is_valid(converted))
|
||||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid group ID " GID_FMT, gid);
|
||||||
|
|
||||||
o = machine_bus_path(machine);
|
o = machine_bus_path(machine);
|
||||||
|
@ -166,10 +166,10 @@ static void operational_state_to_color(const char *state, const char **on, const
|
|||||||
|
|
||||||
if (streq_ptr(state, "routable")) {
|
if (streq_ptr(state, "routable")) {
|
||||||
*on = ansi_highlight_green();
|
*on = ansi_highlight_green();
|
||||||
*off = ansi_highlight_off();
|
*off = ansi_normal();
|
||||||
} else if (streq_ptr(state, "degraded")) {
|
} else if (streq_ptr(state, "degraded")) {
|
||||||
*on = ansi_highlight_yellow();
|
*on = ansi_highlight_yellow();
|
||||||
*off = ansi_highlight_off();
|
*off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
*on = *off = "";
|
*on = *off = "";
|
||||||
}
|
}
|
||||||
@ -180,13 +180,13 @@ static void setup_state_to_color(const char *state, const char **on, const char
|
|||||||
|
|
||||||
if (streq_ptr(state, "configured")) {
|
if (streq_ptr(state, "configured")) {
|
||||||
*on = ansi_highlight_green();
|
*on = ansi_highlight_green();
|
||||||
*off = ansi_highlight_off();
|
*off = ansi_normal();
|
||||||
} else if (streq_ptr(state, "configuring")) {
|
} else if (streq_ptr(state, "configuring")) {
|
||||||
*on = ansi_highlight_yellow();
|
*on = ansi_highlight_yellow();
|
||||||
*off = ansi_highlight_off();
|
*off = ansi_normal();
|
||||||
} else if (streq_ptr(state, "failed") || streq_ptr(state, "linger")) {
|
} else if (streq_ptr(state, "failed") || streq_ptr(state, "linger")) {
|
||||||
*on = ansi_highlight_red();
|
*on = ansi_highlight_red();
|
||||||
*off = ansi_highlight_off();
|
*off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
*on = *off = "";
|
*on = *off = "";
|
||||||
}
|
}
|
||||||
|
@ -19,20 +19,20 @@
|
|||||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <getopt.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "systemd/sd-daemon.h"
|
#include "sd-daemon.h"
|
||||||
|
|
||||||
#include "strv.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "log.h"
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "env-util.h"
|
#include "env-util.h"
|
||||||
#include "formats-util.h"
|
#include "formats-util.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "strv.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static bool arg_ready = false;
|
static bool arg_ready = false;
|
||||||
static pid_t arg_pid = 0;
|
static pid_t arg_pid = 0;
|
||||||
|
@ -485,7 +485,7 @@ enum nss_status _nss_mymachines_getpwuid_r(
|
|||||||
uint32_t mapped;
|
uint32_t mapped;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (UID_IS_INVALID(uid)) {
|
if (!uid_is_valid(uid)) {
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -640,7 +640,7 @@ enum nss_status _nss_mymachines_getgrgid_r(
|
|||||||
uint32_t mapped;
|
uint32_t mapped;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (GID_IS_INVALID(gid)) {
|
if (!gid_is_valid(gid)) {
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,10 @@ int ask_password_tty(
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop_write(ttyfd, ANSI_HIGHLIGHT_ON, sizeof(ANSI_HIGHLIGHT_ON)-1, false);
|
loop_write(ttyfd, ANSI_HIGHLIGHT, sizeof(ANSI_HIGHLIGHT)-1, false);
|
||||||
loop_write(ttyfd, message, strlen(message), false);
|
loop_write(ttyfd, message, strlen(message), false);
|
||||||
loop_write(ttyfd, " ", 1, false);
|
loop_write(ttyfd, " ", 1, false);
|
||||||
loop_write(ttyfd, ANSI_HIGHLIGHT_OFF, sizeof(ANSI_HIGHLIGHT_OFF)-1, false);
|
loop_write(ttyfd, ANSI_NORMAL, sizeof(ANSI_NORMAL)-1, false);
|
||||||
|
|
||||||
new_termios = old_termios;
|
new_termios = old_termios;
|
||||||
new_termios.c_lflag &= ~(ICANON|ECHO);
|
new_termios.c_lflag &= ~(ICANON|ECHO);
|
||||||
|
@ -117,11 +117,11 @@ static bool print_multiline(FILE *f, unsigned prefix, unsigned n_columns, Output
|
|||||||
|
|
||||||
if (flags & OUTPUT_COLOR) {
|
if (flags & OUTPUT_COLOR) {
|
||||||
if (priority <= LOG_ERR) {
|
if (priority <= LOG_ERR) {
|
||||||
color_on = ANSI_HIGHLIGHT_RED_ON;
|
color_on = ANSI_HIGHLIGHT_RED;
|
||||||
color_off = ANSI_HIGHLIGHT_OFF;
|
color_off = ANSI_NORMAL;
|
||||||
} else if (priority <= LOG_NOTICE) {
|
} else if (priority <= LOG_NOTICE) {
|
||||||
color_on = ANSI_HIGHLIGHT_ON;
|
color_on = ANSI_HIGHLIGHT;
|
||||||
color_off = ANSI_HIGHLIGHT_OFF;
|
color_off = ANSI_NORMAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,8 +455,8 @@ static int output_verbose(
|
|||||||
fieldlen = c - (const char*) data;
|
fieldlen = c - (const char*) data;
|
||||||
|
|
||||||
if (flags & OUTPUT_COLOR && startswith(data, "MESSAGE=")) {
|
if (flags & OUTPUT_COLOR && startswith(data, "MESSAGE=")) {
|
||||||
on = ANSI_HIGHLIGHT_ON;
|
on = ANSI_HIGHLIGHT;
|
||||||
off = ANSI_HIGHLIGHT_OFF;
|
off = ANSI_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & OUTPUT_SHOW_ALL ||
|
if (flags & OUTPUT_SHOW_ALL ||
|
||||||
|
@ -431,11 +431,11 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
|
|||||||
if (STR_IN_SET(u->load_state, "error", "not-found", "masked") && !arg_plain) {
|
if (STR_IN_SET(u->load_state, "error", "not-found", "masked") && !arg_plain) {
|
||||||
on_loaded = ansi_highlight_red();
|
on_loaded = ansi_highlight_red();
|
||||||
on_circle = ansi_highlight_yellow();
|
on_circle = ansi_highlight_yellow();
|
||||||
off_loaded = off_circle = ansi_highlight_off();
|
off_loaded = off_circle = ansi_normal();
|
||||||
circle = true;
|
circle = true;
|
||||||
} else if (streq(u->active_state, "failed") && !arg_plain) {
|
} else if (streq(u->active_state, "failed") && !arg_plain) {
|
||||||
on_circle = on_active = ansi_highlight_red();
|
on_circle = on_active = ansi_highlight_red();
|
||||||
off_circle = off_active = ansi_highlight_off();
|
off_circle = off_active = ansi_normal();
|
||||||
circle = true;
|
circle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,10 +482,10 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
|
|||||||
"SUB = The low-level unit activation state, values depend on unit type.");
|
"SUB = The low-level unit activation state, values depend on unit type.");
|
||||||
puts(job_count ? "JOB = Pending job for the unit.\n" : "");
|
puts(job_count ? "JOB = Pending job for the unit.\n" : "");
|
||||||
on = ansi_highlight();
|
on = ansi_highlight();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else {
|
} else {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_all)
|
if (arg_all)
|
||||||
@ -836,12 +836,12 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on = ansi_highlight();
|
on = ansi_highlight();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
if (!arg_no_legend)
|
if (!arg_no_legend)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
} else {
|
} else {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arg_no_legend) {
|
if (!arg_no_legend) {
|
||||||
@ -1118,12 +1118,12 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on = ansi_highlight();
|
on = ansi_highlight();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
if (!arg_no_legend)
|
if (!arg_no_legend)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
} else {
|
} else {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arg_no_legend) {
|
if (!arg_no_legend) {
|
||||||
@ -1306,10 +1306,10 @@ static void output_unit_file_list(const UnitFileList *units, unsigned c) {
|
|||||||
UNIT_FILE_DISABLED,
|
UNIT_FILE_DISABLED,
|
||||||
UNIT_FILE_INVALID)) {
|
UNIT_FILE_INVALID)) {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else if (u->state == UNIT_FILE_ENABLED) {
|
} else if (u->state == UNIT_FILE_ENABLED) {
|
||||||
on = ansi_highlight_green();
|
on = ansi_highlight_green();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
on = off = "";
|
on = off = "";
|
||||||
|
|
||||||
@ -1618,7 +1618,7 @@ static int list_dependencies_one(
|
|||||||
|
|
||||||
state = check_one_unit(bus, *c, "activating\0active\0reloading\0", true);
|
state = check_one_unit(bus, *c, "activating\0active\0reloading\0", true);
|
||||||
on = state > 0 ? ansi_highlight_green() : ansi_highlight_red();
|
on = state > 0 ? ansi_highlight_green() : ansi_highlight_red();
|
||||||
printf("%s%s%s ", on, draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
|
printf("%s%s%s ", on, draw_special_char(DRAW_BLACK_CIRCLE), ansi_normal());
|
||||||
}
|
}
|
||||||
|
|
||||||
r = list_dependencies_print(*c, level, branches, c[1] == NULL);
|
r = list_dependencies_print(*c, level, branches, c[1] == NULL);
|
||||||
@ -1837,17 +1837,17 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n)
|
|||||||
|
|
||||||
if (streq_ptr(m->state, "degraded")) {
|
if (streq_ptr(m->state, "degraded")) {
|
||||||
on_state = ansi_highlight_red();
|
on_state = ansi_highlight_red();
|
||||||
off_state = ansi_highlight_off();
|
off_state = ansi_normal();
|
||||||
circle = true;
|
circle = true;
|
||||||
} else if (!streq_ptr(m->state, "running")) {
|
} else if (!streq_ptr(m->state, "running")) {
|
||||||
on_state = ansi_highlight_yellow();
|
on_state = ansi_highlight_yellow();
|
||||||
off_state = ansi_highlight_off();
|
off_state = ansi_normal();
|
||||||
circle = true;
|
circle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->n_failed_units > 0) {
|
if (m->n_failed_units > 0) {
|
||||||
on_failed = ansi_highlight_red();
|
on_failed = ansi_highlight_red();
|
||||||
off_failed = ansi_highlight_off();
|
off_failed = ansi_normal();
|
||||||
} else
|
} else
|
||||||
on_failed = off_failed = "";
|
on_failed = off_failed = "";
|
||||||
|
|
||||||
@ -2020,7 +2020,7 @@ static void output_jobs_list(const struct job_info* jobs, unsigned n, bool skipp
|
|||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
if (!arg_no_legend) {
|
if (!arg_no_legend) {
|
||||||
on = ansi_highlight_green();
|
on = ansi_highlight_green();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
|
|
||||||
printf("%sNo jobs %s.%s\n", on, skipped ? "listed" : "running", off);
|
printf("%sNo jobs %s.%s\n", on, skipped ? "listed" : "running", off);
|
||||||
}
|
}
|
||||||
@ -2061,7 +2061,7 @@ static void output_jobs_list(const struct job_info* jobs, unsigned n, bool skipp
|
|||||||
|
|
||||||
if (streq(j->state, "running")) {
|
if (streq(j->state, "running")) {
|
||||||
on = ansi_highlight();
|
on = ansi_highlight();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
on = off = "";
|
on = off = "";
|
||||||
|
|
||||||
@ -2075,7 +2075,7 @@ static void output_jobs_list(const struct job_info* jobs, unsigned n, bool skipp
|
|||||||
|
|
||||||
if (!arg_no_legend) {
|
if (!arg_no_legend) {
|
||||||
on = ansi_highlight();
|
on = ansi_highlight();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
|
|
||||||
printf("\n%s%u jobs listed%s.\n", on, n, off);
|
printf("\n%s%u jobs listed%s.\n", on, n, off);
|
||||||
}
|
}
|
||||||
@ -2221,7 +2221,7 @@ static int need_daemon_reload(sd_bus *bus, const char *unit) {
|
|||||||
static void warn_unit_file_changed(const char *name) {
|
static void warn_unit_file_changed(const char *name) {
|
||||||
log_warning("%sWarning:%s %s changed on disk. Run 'systemctl%s daemon-reload' to reload units.",
|
log_warning("%sWarning:%s %s changed on disk. Run 'systemctl%s daemon-reload' to reload units.",
|
||||||
ansi_highlight_red(),
|
ansi_highlight_red(),
|
||||||
ansi_highlight_off(),
|
ansi_normal(),
|
||||||
name,
|
name,
|
||||||
arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
|
arg_scope == UNIT_FILE_SYSTEM ? "" : " --user");
|
||||||
}
|
}
|
||||||
@ -3355,10 +3355,10 @@ static void print_status_info(
|
|||||||
|
|
||||||
if (streq_ptr(i->active_state, "failed")) {
|
if (streq_ptr(i->active_state, "failed")) {
|
||||||
active_on = ansi_highlight_red();
|
active_on = ansi_highlight_red();
|
||||||
active_off = ansi_highlight_off();
|
active_off = ansi_normal();
|
||||||
} else if (streq_ptr(i->active_state, "active") || streq_ptr(i->active_state, "reloading")) {
|
} else if (streq_ptr(i->active_state, "active") || streq_ptr(i->active_state, "reloading")) {
|
||||||
active_on = ansi_highlight_green();
|
active_on = ansi_highlight_green();
|
||||||
active_off = ansi_highlight_off();
|
active_off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
active_on = active_off = "";
|
active_on = active_off = "";
|
||||||
|
|
||||||
@ -3374,7 +3374,7 @@ static void print_status_info(
|
|||||||
|
|
||||||
if (streq_ptr(i->load_state, "error")) {
|
if (streq_ptr(i->load_state, "error")) {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
on = off = "";
|
on = off = "";
|
||||||
|
|
||||||
@ -3455,7 +3455,7 @@ static void print_status_info(
|
|||||||
s2 = format_timestamp(since2, sizeof(since2), i->condition_timestamp);
|
s2 = format_timestamp(since2, sizeof(since2), i->condition_timestamp);
|
||||||
|
|
||||||
printf("Condition: start %scondition failed%s at %s%s%s\n",
|
printf("Condition: start %scondition failed%s at %s%s%s\n",
|
||||||
ansi_highlight_yellow(), ansi_highlight_off(),
|
ansi_highlight_yellow(), ansi_normal(),
|
||||||
s2, s1 ? "; " : "", s1 ? s1 : "");
|
s2, s1 ? "; " : "", s1 ? s1 : "");
|
||||||
if (i->failed_condition_trigger)
|
if (i->failed_condition_trigger)
|
||||||
printf(" none of the trigger conditions were met\n");
|
printf(" none of the trigger conditions were met\n");
|
||||||
@ -3471,7 +3471,7 @@ static void print_status_info(
|
|||||||
s2 = format_timestamp(since2, sizeof(since2), i->assert_timestamp);
|
s2 = format_timestamp(since2, sizeof(since2), i->assert_timestamp);
|
||||||
|
|
||||||
printf(" Assert: start %sassertion failed%s at %s%s%s\n",
|
printf(" Assert: start %sassertion failed%s at %s%s%s\n",
|
||||||
ansi_highlight_red(), ansi_highlight_off(),
|
ansi_highlight_red(), ansi_normal(),
|
||||||
s2, s1 ? "; " : "", s1 ? s1 : "");
|
s2, s1 ? "; " : "", s1 ? s1 : "");
|
||||||
if (i->failed_assert_trigger)
|
if (i->failed_assert_trigger)
|
||||||
printf(" none of the trigger assertions were met\n");
|
printf(" none of the trigger assertions were met\n");
|
||||||
@ -3512,7 +3512,7 @@ static void print_status_info(
|
|||||||
good = is_clean_exit_lsb(p->code, p->status, NULL);
|
good = is_clean_exit_lsb(p->code, p->status, NULL);
|
||||||
if (!good) {
|
if (!good) {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
on = off = "";
|
on = off = "";
|
||||||
|
|
||||||
@ -4513,10 +4513,10 @@ static int show_system_status(sd_bus *bus) {
|
|||||||
|
|
||||||
if (streq_ptr(mi.state, "degraded")) {
|
if (streq_ptr(mi.state, "degraded")) {
|
||||||
on = ansi_highlight_red();
|
on = ansi_highlight_red();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else if (!streq_ptr(mi.state, "running")) {
|
} else if (!streq_ptr(mi.state, "running")) {
|
||||||
on = ansi_highlight_yellow();
|
on = ansi_highlight_yellow();
|
||||||
off = ansi_highlight_off();
|
off = ansi_normal();
|
||||||
} else
|
} else
|
||||||
on = off = "";
|
on = off = "";
|
||||||
|
|
||||||
@ -4688,7 +4688,7 @@ static int cat_file(const char *filename, bool newline) {
|
|||||||
newline ? "\n" : "",
|
newline ? "\n" : "",
|
||||||
ansi_highlight_blue(),
|
ansi_highlight_blue(),
|
||||||
filename,
|
filename,
|
||||||
ansi_highlight_off());
|
ansi_normal());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, false);
|
return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, false);
|
||||||
|
@ -806,8 +806,7 @@ static int set_dependencies_from_rcnd(const LookupPaths *lp, Hashmap *all_servic
|
|||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (d)
|
safe_closedir(d);
|
||||||
closedir(d);
|
|
||||||
|
|
||||||
d = opendir(path);
|
d = opendir(path);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
|
@ -33,13 +33,13 @@ int main(int argc, char *argv[]) {
|
|||||||
assert_se(streq(p, " Foobar bar waldo "));
|
assert_se(streq(p, " Foobar bar waldo "));
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
assert_se(p = strdup(ANSI_HIGHLIGHT_ON "Hello" ANSI_HIGHLIGHT_OFF ANSI_HIGHLIGHT_RED_ON " world!" ANSI_HIGHLIGHT_OFF));
|
assert_se(p = strdup(ANSI_HIGHLIGHT "Hello" ANSI_NORMAL ANSI_HIGHLIGHT_RED " world!" ANSI_NORMAL));
|
||||||
assert_se(strip_tab_ansi(&p, NULL));
|
assert_se(strip_tab_ansi(&p, NULL));
|
||||||
fprintf(stdout, "<%s>\n", p);
|
fprintf(stdout, "<%s>\n", p);
|
||||||
assert_se(streq(p, "Hello world!"));
|
assert_se(streq(p, "Hello world!"));
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
assert_se(p = strdup("\x1B[\x1B[\t\x1B[" ANSI_HIGHLIGHT_ON "\x1B[" "Hello" ANSI_HIGHLIGHT_OFF ANSI_HIGHLIGHT_RED_ON " world!" ANSI_HIGHLIGHT_OFF));
|
assert_se(p = strdup("\x1B[\x1B[\t\x1B[" ANSI_HIGHLIGHT "\x1B[" "Hello" ANSI_NORMAL ANSI_HIGHLIGHT_RED " world!" ANSI_NORMAL));
|
||||||
assert_se(strip_tab_ansi(&p, NULL));
|
assert_se(strip_tab_ansi(&p, NULL));
|
||||||
assert_se(streq(p, "\x1B[\x1B[ \x1B[\x1B[Hello world!"));
|
assert_se(streq(p, "\x1B[\x1B[ \x1B[\x1B[Hello world!"));
|
||||||
free(p);
|
free(p);
|
||||||
|
@ -153,13 +153,13 @@ static void print_status_info(const StatusInfo *i) {
|
|||||||
yes_no(i->rtc_local));
|
yes_no(i->rtc_local));
|
||||||
|
|
||||||
if (i->rtc_local)
|
if (i->rtc_local)
|
||||||
fputs("\n" ANSI_HIGHLIGHT_ON
|
fputs("\n" ANSI_HIGHLIGHT
|
||||||
"Warning: The system is configured to read the RTC time in the local time zone.\n"
|
"Warning: The system is configured to read the RTC time in the local time zone.\n"
|
||||||
" This mode can not be fully supported. It will create various problems\n"
|
" This mode can not be fully supported. It will create various problems\n"
|
||||||
" with time zone changes and daylight saving time adjustments. The RTC\n"
|
" with time zone changes and daylight saving time adjustments. The RTC\n"
|
||||||
" time is never updated, it relies on external facilities to maintain it.\n"
|
" time is never updated, it relies on external facilities to maintain it.\n"
|
||||||
" If at all possible, use RTC in UTC by calling\n"
|
" If at all possible, use RTC in UTC by calling\n"
|
||||||
" 'timedatectl set-local-rtc 0'" ANSI_HIGHLIGHT_OFF ".\n", stdout);
|
" 'timedatectl set-local-rtc 0'." ANSI_NORMAL "\n", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_status(sd_bus *bus, char **args, unsigned n) {
|
static int show_status(sd_bus *bus, char **args, unsigned n) {
|
||||||
|
Loading…
Reference in New Issue
Block a user