chiark / gitweb /
[1/5] Apply missing fixes from upstream
authorSven Eden <yamakuzure@gmx.net>
Wed, 29 Mar 2017 08:05:39 +0000 (10:05 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 29 Mar 2017 08:46:30 +0000 (10:46 +0200)
15 files changed:
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/copy.c
src/basic/copy.h
src/basic/fileio.c
src/basic/fileio.h
src/basic/hashmap.c
src/basic/hashmap.h
src/basic/log.c
src/basic/log.h
src/basic/macro.h
src/basic/missing.h
src/basic/prioq.c
src/basic/process-util.c
src/basic/time-util.h

index 5cbe45a7e65d3a515e439687cf3cedd16dc97966..a0a61d8874c79c0d0d1d5430633503afa21d4ec6 100644 (file)
@@ -2073,9 +2073,10 @@ int cg_mask_supported(CGroupMask *ret) {
                         mask |= CGROUP_CONTROLLER_TO_MASK(v);
         }
 
-                /* Currently, we only support the memory controller in
-                 * the unified hierarchy, mask everything else off. */
-                mask &= CGROUP_MASK_MEMORY;
+                /* Currently, we only support the memory and pids
+                 * controller in the unified hierarchy, mask
+                 * everything else off. */
+                mask &= CGROUP_MASK_MEMORY | CGROUP_MASK_PIDS;
 
         } else {
                 CGroupController c;
@@ -2280,12 +2281,54 @@ bool cg_is_legacy_wanted(void) {
 }
 #endif // 0
 
+int cg_cpu_shares_parse(const char *s, uint64_t *ret) {
+        uint64_t u;
+        int r;
+
+        if (isempty(s)) {
+                *ret = CGROUP_CPU_SHARES_INVALID;
+                return 0;
+        }
+
+        r = safe_atou64(s, &u);
+        if (r < 0)
+                return r;
+
+        if (u < CGROUP_CPU_SHARES_MIN || u > CGROUP_CPU_SHARES_MAX)
+                return -ERANGE;
+
+        *ret = u;
+        return 0;
+}
+
+int cg_blkio_weight_parse(const char *s, uint64_t *ret) {
+        uint64_t u;
+        int r;
+
+        if (isempty(s)) {
+                *ret = CGROUP_BLKIO_WEIGHT_INVALID;
+                return 0;
+        }
+
+        r = safe_atou64(s, &u);
+        if (r < 0)
+                return r;
+
+        if (u < CGROUP_BLKIO_WEIGHT_MIN || u > CGROUP_BLKIO_WEIGHT_MAX)
+                return -ERANGE;
+
+        *ret = u;
+        return 0;
+ }
+
 static const char *cgroup_controller_table[_CGROUP_CONTROLLER_MAX] = {
         [CGROUP_CONTROLLER_CPU] = "cpu",
         [CGROUP_CONTROLLER_CPUACCT] = "cpuacct",
         [CGROUP_CONTROLLER_BLKIO] = "blkio",
         [CGROUP_CONTROLLER_MEMORY] = "memory",
-        [CGROUP_CONTROLLER_DEVICE] = "devices",
+        [CGROUP_CONTROLLER_DEVICES] = "devices",
+        [CGROUP_CONTROLLER_PIDS] = "pids",
+        [CGROUP_CONTROLLER_NET_CLS] = "net_cls",
 };
 
 DEFINE_STRING_TABLE_LOOKUP(cgroup_controller, CGroupController);
index 9743559579df9f8861d9b430ba01dba0b7555289..820d07985fb7ca070bd77c48254983085751835e 100644 (file)
@@ -34,7 +34,9 @@ typedef enum CGroupController {
         CGROUP_CONTROLLER_CPUACCT,
         CGROUP_CONTROLLER_BLKIO,
         CGROUP_CONTROLLER_MEMORY,
-        CGROUP_CONTROLLER_DEVICE,
+        CGROUP_CONTROLLER_DEVICES,
+        CGROUP_CONTROLLER_PIDS,
+        CGROUP_CONTROLLER_NET_CLS,
         _CGROUP_CONTROLLER_MAX,
         _CGROUP_CONTROLLER_INVALID = -1,
 } CGroupController;
@@ -47,10 +49,36 @@ typedef enum CGroupMask {
         CGROUP_MASK_CPUACCT = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_CPUACCT),
         CGROUP_MASK_BLKIO = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BLKIO),
         CGROUP_MASK_MEMORY = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_MEMORY),
-        CGROUP_MASK_DEVICE = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_DEVICE),
+        CGROUP_MASK_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_DEVICES),
+        CGROUP_MASK_PIDS = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_PIDS),
+        CGROUP_MASK_NET_CLS = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_NET_CLS),
         _CGROUP_MASK_ALL = CGROUP_CONTROLLER_TO_MASK(_CGROUP_CONTROLLER_MAX) - 1
 } CGroupMask;
 
+/* Special values for the cpu.shares attribute */
+#define CGROUP_CPU_SHARES_INVALID ((uint64_t) -1)
+#define CGROUP_CPU_SHARES_MIN UINT64_C(2)
+#define CGROUP_CPU_SHARES_MAX UINT64_C(262144)
+#define CGROUP_CPU_SHARES_DEFAULT UINT64_C(1024)
+
+static inline bool CGROUP_CPU_SHARES_IS_OK(uint64_t x) {
+        return
+            x == CGROUP_CPU_SHARES_INVALID ||
+            (x >= CGROUP_CPU_SHARES_MIN && x <= CGROUP_CPU_SHARES_MAX);
+}
+
+/* Special values for the blkio.weight attribute */
+#define CGROUP_BLKIO_WEIGHT_INVALID ((uint64_t) -1)
+#define CGROUP_BLKIO_WEIGHT_MIN UINT64_C(10)
+#define CGROUP_BLKIO_WEIGHT_MAX UINT64_C(1000)
+#define CGROUP_BLKIO_WEIGHT_DEFAULT UINT64_C(500)
+
+static inline bool CGROUP_BLKIO_WEIGHT_IS_OK(uint64_t x) {
+        return
+            x == CGROUP_BLKIO_WEIGHT_INVALID ||
+            (x >= CGROUP_BLKIO_WEIGHT_MIN && x <= CGROUP_BLKIO_WEIGHT_MAX);
+}
+
 /*
  * General rules:
  *
@@ -159,3 +187,6 @@ bool cg_is_legacy_wanted(void);
 
 const char* cgroup_controller_to_string(CGroupController c) _const_;
 CGroupController cgroup_controller_from_string(const char *s) _pure_;
+
+int cg_cpu_shares_parse(const char *s, uint64_t *ret);
+int cg_blkio_weight_parse(const char *s, uint64_t *ret);
index 163bbf7c7a7ee24cb66fb325f2ee5e0df0d2bd6d..3c02fd41ea22710e27788a9fcc37b689cb020dc8 100644 (file)
@@ -29,7 +29,7 @@
 
 #define COPY_BUFFER_SIZE (16*1024)
 
-int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
+int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink) {
         bool try_sendfile = true, try_splice = true;
         int r;
 
@@ -37,22 +37,26 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
         assert(fdt >= 0);
 #if 0
         /* Try btrfs reflinks first. */
-        if (try_reflink && max_bytes == (off_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);
                 if (r >= 0)
-                        return r;
+                        return 0; /* we copied the whole thing, hence hit EOF, return 0 */
         }
 #endif // 0
         for (;;) {
                 size_t m = COPY_BUFFER_SIZE;
                 ssize_t n;
 
-                if (max_bytes != (off_t) -1) {
+                if (max_bytes != (uint64_t) -1) {
 
                         if (max_bytes <= 0)
                                 return -EFBIG;
 
-                        if ((off_t) m > max_bytes)
+                        if ((uint64_t) m > max_bytes)
                                 m = (size_t) max_bytes;
                 }
 
@@ -91,7 +95,7 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
 
                 /* As a fallback just copy bits by hand */
                 {
-                        char buf[m];
+                        uint8_t buf[m];
 
                         n = read(fdf, buf, m);
                         if (n < 0)
@@ -105,13 +109,13 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink) {
                 }
 
         next:
-                if (max_bytes != (off_t) -1) {
-                        assert(max_bytes >= n);
+                if (max_bytes != (uint64_t) -1) {
+                        assert(max_bytes >= (uint64_t) n);
                         max_bytes -= n;
                 }
         }
 
-        return 0;
+        return 0; /* return 0 if we hit EOF earlier than the size limit */
 }
 
 // UNNEEDED by elogind
@@ -154,7 +158,7 @@ static int fd_copy_regular(int df, const char *from, const struct stat *st, int
         if (fdt < 0)
                 return -errno;
 
-        r = copy_bytes(fdf, fdt, (off_t) -1, true);
+        r = copy_bytes(fdf, fdt, (uint64_t) -1, true);
         if (r < 0) {
                 unlinkat(dt, to, 0);
                 return r;
@@ -373,7 +377,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
         if (fdf < 0)
                 return -errno;
 
-        r = copy_bytes(fdf, fdt, (off_t) -1, try_reflink);
+        r = copy_bytes(fdf, fdt, (uint64_t) -1, try_reflink);
 
         (void) copy_times(fdf, fdt);
         (void) copy_xattr(fdf, fdt);
index 1909de4b884bbfafe57896e0871a9467a6a3dece..0cb8cf766cf4027a8affc4db7dc0e9292e02767b 100644 (file)
@@ -30,6 +30,6 @@
 // UNNEEDED int copy_tree(const char *from, const char *to, bool merge);
 // UNNEEDED int copy_tree_at(int fdf, const char *from, int fdt, const char *to, bool merge);
 // UNNEEDED int copy_directory_fd(int dirfd, const char *to, bool merge);
-int copy_bytes(int fdf, int fdt, off_t max_bytes, bool try_reflink);
+int copy_bytes(int fdf, int fdt, uint64_t max_bytes, bool try_reflink);
 // UNNEEDED int copy_times(int fdf, int fdt);
 // UNNEEDED int copy_xattr(int fdf, int fdt);
index f666380a414e8f5554c9f2511d932aca3c5519bd..a3f8d42f5edb9e9d32dacbbb59cdf76b85ad5099 100644 (file)
@@ -784,15 +784,19 @@ int executable_is_script(const char *path, char **interpreter) {
 
 /**
  * Retrieve one field from a file like /proc/self/status.  pattern
- * should start with '\n' and end with a ':'. Whitespace and zeros
- * after the ':' will be skipped. field must be freed afterwards.
+ * should not include whitespace or the delimiter (':'). pattern matches only
+ * the beginning of a line. Whitespace before ':' is skipped. Whitespace and
+ * zeros after the ':' will be skipped. field must be freed afterwards.
+ * terminator specifies the terminating characters of the field value (not
+ * included in the value).
  */
-int get_status_field(const char *filename, const char *pattern, char **field) {
+int get_proc_field(const char *filename, const char *pattern, const char *terminator, char **field) {
         _cleanup_free_ char *status = NULL;
         char *t, *f;
         size_t len;
         int r;
 
+        assert(terminator);
         assert(filename);
         assert(pattern);
         assert(field);
@@ -801,11 +805,31 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
         if (r < 0)
                 return r;
 
-        t = strstr(status, pattern);
+        t = status;
+
+        do {
+                bool pattern_ok;
+
+                do {
+                        t = strstr(t, pattern);
         if (!t)
                 return -ENOENT;
 
+                        /* Check that pattern occurs in beginning of line. */
+                        pattern_ok = (t == status || t[-1] == '\n');
+
         t += strlen(pattern);
+
+                } while (!pattern_ok);
+
+                t += strspn(t, " \t");
+                if (!*t)
+                        return -ENOENT;
+
+        } while (*t != ':');
+
+        t++;
+
         if (*t) {
                 t += strspn(t, " \t");
 
@@ -821,7 +845,7 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
                         t --;
         }
 
-        len = strcspn(t, WHITESPACE);
+        len = strcspn(t, terminator);
 
         f = strndup(t, len);
         if (!f)
index edae438e4fc973f1ad6e9bb48a41be3f0fa2513f..e071bea3a04fc30df28d714a07c21f3eec37f6c8 100644 (file)
@@ -48,4 +48,4 @@ int write_env_file(const char *fname, char **l);
 
 // UNNEEDED int executable_is_script(const char *path, char **interpreter);
 
-int get_status_field(const char *filename, const char *pattern, char **field);
+int get_proc_field(const char *filename, const char *pattern, const char *terminator, char **field);
index 83c76ae0dd4435ddfcdcdb3feb6ece240466a2e2..3c0e70b9c0180d79615172f85973e4a27a43ace4 100644 (file)
@@ -276,10 +276,8 @@ static const struct hashmap_type_info hashmap_type_info[_HASHMAP_TYPE_MAX] = {
         },
 };
 
-unsigned long string_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
-        uint64_t u;
-        siphash24((uint8_t*) &u, p, strlen(p), hash_key);
-        return (unsigned long) u;
+void string_hash_func(const void *p, struct siphash *state) {
+        siphash24_compress(p, strlen(p) + 1, state);
 }
 
 int string_compare_func(const void *a, const void *b) {
@@ -291,10 +289,8 @@ const struct hash_ops string_hash_ops = {
         .compare = string_compare_func
 };
 
-unsigned long trivial_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
-        uint64_t u;
-        siphash24((uint8_t*) &u, &p, sizeof(p), hash_key);
-        return (unsigned long) u;
+void trivial_hash_func(const void *p, struct siphash *state) {
+        siphash24_compress(&p, sizeof(p), state);
 }
 
 int trivial_compare_func(const void *a, const void *b) {
@@ -306,10 +302,8 @@ const struct hash_ops trivial_hash_ops = {
         .compare = trivial_compare_func
 };
 
-unsigned long uint64_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
-        uint64_t u;
-        siphash24((uint8_t*) &u, p, sizeof(uint64_t), hash_key);
-        return (unsigned long) u;
+void uint64_hash_func(const void *p, struct siphash *state) {
+        siphash24_compress(p, sizeof(uint64_t), state);
 }
 
 int uint64_compare_func(const void *_a, const void *_b) {
@@ -325,10 +319,8 @@ const struct hash_ops uint64_hash_ops = {
 };
 
 #if SIZEOF_DEV_T != 8
-unsigned long devt_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) {
-        uint64_t u;
-        siphash24((uint8_t*) &u, p, sizeof(dev_t), hash_key);
-        return (unsigned long) u;
+void devt_hash_func(const void *p, struct siphash *state) {
+        siphash24_compress(p, sizeof(dev_t), state);
 }
 
 int devt_compare_func(const void *_a, const void *_b) {
@@ -379,7 +371,16 @@ static uint8_t *hash_key(HashmapBase *h) {
 }
 
 static unsigned base_bucket_hash(HashmapBase *h, const void *p) {
-        return (unsigned) (h->hash_ops->hash(p, hash_key(h)) % n_buckets(h));
+        struct siphash state;
+        uint64_t hash;
+
+        siphash24_init(&state, hash_key(h));
+
+        h->hash_ops->hash(p, &state);
+
+        siphash24_finalize((uint8_t*)&hash, &state);
+
+        return (unsigned) (hash % n_buckets(h));
 }
 #define bucket_hash(h, p) base_bucket_hash(HASHMAP_BASE(h), p)
 
@@ -1823,6 +1824,7 @@ void *ordered_hashmap_next(OrderedHashmap *h, const void *key) {
         return ordered_bucket_at(h, e->iterate_next)->p.value;
 }
 #endif // 0
+
 int set_consume(Set *s, void *value) {
         int r;
 
index 03c8ae1c52d22512975d1ba008d9f1918ba66940..54f60258d0364a4a89836c696ca7c3aa25c6dce7 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdbool.h>
 
 #include "macro.h"
+#include "siphash24.h"
 #include "util.h"
 
 /*
@@ -67,7 +68,7 @@ typedef struct {
 #define _IDX_ITERATOR_FIRST (UINT_MAX - 1)
 #define ITERATOR_FIRST ((Iterator) { .idx = _IDX_ITERATOR_FIRST, .next_key = NULL })
 
-typedef unsigned long (*hash_func_t)(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]);
+typedef void (*hash_func_t)(const void *p, struct siphash *state);
 typedef int (*compare_func_t)(const void *a, const void *b);
 
 struct hash_ops {
@@ -75,28 +76,28 @@ struct hash_ops {
         compare_func_t compare;
 };
 
-unsigned long string_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
+void string_hash_func(const void *p, struct siphash *state);
 int string_compare_func(const void *a, const void *b) _pure_;
 extern const struct hash_ops string_hash_ops;
 
 /* This will compare the passed pointers directly, and will not
  * dereference them. This is hence not useful for strings or
  * suchlike. */
-unsigned long trivial_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
+void trivial_hash_func(const void *p, struct siphash *state);
 int trivial_compare_func(const void *a, const void *b) _const_;
 extern const struct hash_ops trivial_hash_ops;
 
 /* 32bit values we can always just embedd in the pointer itself, but
  * in order to support 32bit archs we need store 64bit values
  * indirectly, since they don't fit in a pointer. */
-unsigned long uint64_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
+void uint64_hash_func(const void *p, struct siphash *state);
 int uint64_compare_func(const void *a, const void *b) _pure_;
 extern const struct hash_ops uint64_hash_ops;
 
 /* On some archs dev_t is 32bit, and on others 64bit. And sometimes
  * it's 64bit on 32bit archs, and sometimes 32bit on 64bit archs. Yuck! */
 #if SIZEOF_DEV_T != 8
-unsigned long devt_hash_func(const void *p, const uint8_t hash_key[HASH_KEY_SIZE]) _pure_;
+void devt_hash_func(const void *p, struct siphash *state) _pure_;
 int devt_compare_func(const void *a, const void *b) _pure_;
 extern const struct hash_ops devt_hash_ops = {
         .hash = devt_hash_func,
index 69977f15d69ba657ea9faa01f7eea45f62e7f0ae..c6f70a1878f0f139a8423b8e01428265142ad405 100644 (file)
@@ -351,10 +351,10 @@ static int write_to_console(
         }
 
         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);
         if (highlight)
-                IOVEC_SET_STRING(iovec[n++], ANSI_HIGHLIGHT_OFF);
+                IOVEC_SET_STRING(iovec[n++], ANSI_NORMAL);
         IOVEC_SET_STRING(iovec[n++], "\n");
 
         if (writev(console_fd, iovec, n) < 0) {
index 5fb223de5a7a3742ef47e55d0a3180f37160fd3c..fe59fb0ad9746157c4eaa4e14cfd2cfa7408e9d7 100644 (file)
@@ -236,3 +236,15 @@ int log_syntax_internal(
                         ? log_syntax_internal(unit, _level, config_file, config_line, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
                         : -abs(_e);                                     \
         })
+
+#define log_syntax_invalid_utf8(unit, level, config_file, config_line, rvalue) \
+        ({                                                              \
+                int _level = (level);                                   \
+                if (log_get_max_level() >= LOG_PRI(_level)) {           \
+                        _cleanup_free_ char *_p = NULL;                 \
+                        _p = utf8_escape_invalid(rvalue);               \
+                        log_syntax_internal(unit, _level, config_file, config_line, 0, __FILE__, __LINE__, __func__, \
+                                            "String is not UTF-8 clean, ignoring assignment: %s", strna(_p)); \
+                }                                                       \
+                -EINVAL;                                                \
+        })
index e93d7f155273a8a8618eaed8df429a03b88bbcfe..53d7f9bafa989eb8e2babda486ef51602f782639 100644 (file)
@@ -471,18 +471,6 @@ do {                                                                    \
 #define GID_INVALID ((gid_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)                 \
         static inline void func##p(type *p) {                   \
                 if (*p)                                         \
index cad7aa633a5b2e12eb9af7fc99c382678f0c33de..7ba1c68e81292f6ed54d365a0ab6965077cd7ff0 100644 (file)
 
 #include "musl_missing.h"
 
+#ifdef HAVE_AUDIT
+#include <libaudit.h>
+#endif
+
 #ifdef ARCH_MIPS
 #include <asm/sgidefs.h>
 #endif
@@ -1061,3 +1065,48 @@ static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, uns
 #ifndef INPUT_PROP_ACCELEROMETER
 #define INPUT_PROP_ACCELEROMETER  0x06
 #endif
+
+#if !HAVE_DECL_KEY_SERIAL_T
+typedef int32_t key_serial_t;
+#endif
+
+#if !HAVE_DECL_KEYCTL
+static inline long keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) {
+#if defined(__NR_keyctl)
+        return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+
+static inline key_serial_t add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) {
+#if defined (__NR_add_key)
+        return syscall(__NR_add_key, type, description, payload, plen, ringid);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+
+static inline key_serial_t request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) {
+#if defined (__NR_request_key)
+        return syscall(__NR_request_key, type, description, callout_info, destringid);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+#endif
+
+#ifndef KEYCTL_READ
+#define KEYCTL_READ 11
+#endif
+
+#ifndef KEYCTL_SET_TIMEOUT
+#define KEYCTL_SET_TIMEOUT 15
+#endif
+
+#ifndef KEY_SPEC_USER_KEYRING
+#define KEY_SPEC_USER_KEYRING -4
+#endif
index 5e567b181d3ae1e6e6d5ded2201e35ae86b82489..d55b348c22f2ec82d13d2dacff33dcc3f808abb7 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+/*
+ * Priority Queue
+ * The prioq object implements a priority queue. That is, it orders objects by
+ * their priority and allows O(1) access to the object with the highest
+ * priority. Insertion and removal are Θ(log n). Optionally, the caller can
+ * provide a pointer to an index which will be kept up-to-date by the prioq.
+ *
+ * The underlying algorithm used in this implementation is a Heap.
+ */
+
 #include "util.h"
 #include "prioq.h"
 
index 0fc9ba4633273cf820f4a1e59bda880df90afde1..25044dfaa7bc916bb4768307c082d1fa337d691f 100644 (file)
@@ -217,7 +217,7 @@ int get_process_capeff(pid_t pid, char **capeff) {
 
         p = procfs_file_alloca(pid, "status");
 
-        r = get_status_field(p, "\nCapEff:", capeff);
+        r = get_proc_field(p, "CapEff", WHITESPACE, capeff);
         if (r == -ENOENT)
                 return -ESRCH;
 
index a0c850b08386b23c8a6527e223f1c44bc357350b..ef49343a8211e964341959cb5b86a56d9823f20b 100644 (file)
@@ -112,6 +112,8 @@ int parse_sec(const char *t, usec_t *usec);
 
 // UNNEEDED clockid_t clock_boottime_or_monotonic(void);
 
-#define xstrftime(buf, fmt, tm) assert_se(strftime(buf, ELEMENTSOF(buf), fmt, tm) > 0)
+#define xstrftime(buf, fmt, tm) \
+        assert_message_se(strftime(buf, ELEMENTSOF(buf), fmt, tm) > 0, \
+                          "xstrftime: " #buf "[] must be big enough")
 
 // UNNEEDED int get_timezone(char **timezone);