summaryrefslogtreecommitdiffstats
path: root/src/utils/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/include')
-rw-r--r--src/utils/include/c.h54
-rw-r--r--src/utils/include/carefulputc.h96
-rw-r--r--src/utils/include/closestream.h2
-rw-r--r--src/utils/include/fileutils.h27
-rw-r--r--src/utils/include/jsonwrt.h20
-rw-r--r--src/utils/include/path.h19
-rw-r--r--src/utils/include/pathnames.h26
-rw-r--r--src/utils/include/pty-session.h2
-rw-r--r--src/utils/include/strutils.h34
-rw-r--r--src/utils/include/strv.h7
-rw-r--r--src/utils/include/ttyutils.h9
11 files changed, 171 insertions, 125 deletions
diff --git a/src/utils/include/c.h b/src/utils/include/c.h
index ae08131..354b59e 100644
--- a/src/utils/include/c.h
+++ b/src/utils/include/c.h
@@ -16,6 +16,8 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <sys/types.h>
+#include <grp.h>
#include <assert.h>
@@ -64,6 +66,21 @@
# define ignore_result(x) ((void) (x))
#endif /* !__GNUC__ */
+
+/* "restrict" keyword fallback */
+#if __STDC__ != 1
+# define restrict __restrict /* use implementation __ format */
+#else
+# ifndef __STDC_VERSION__
+# define restrict __restrict /* use implementation __ format */
+# else
+# if __STDC_VERSION__ < 199901L
+# define restrict __restrict /* use implementation __ format */
+# endif
+# endif
+#endif
+
+
/*
* It evaluates to 1 if the attribute/feature is supported by the current
* compilation target. Fallback for old compilers.
@@ -202,7 +219,7 @@ prog_inv_sh_nm_from_file(char *f, char stripext)
#ifndef HAVE_ERR_H
-static inline void
+static inline void __attribute__ ((__format__ (__printf__, 4, 5)))
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
{
fprintf(stderr, "%s: ", program_invocation_short_name);
@@ -320,6 +337,24 @@ static inline size_t get_hostname_max(void)
return 64;
}
+
+static inline int drop_permissions(void)
+{
+ errno = 0;
+
+ /* drop GID */
+ if (setgid(getgid()) < 0)
+ goto fail;
+
+ /* drop UID */
+ if (setuid(getuid()) < 0)
+ goto fail;
+
+ return 0;
+fail:
+ return errno ? -errno : -1;
+}
+
/*
* The usleep function was marked obsolete in POSIX.1-2001 and was removed
* in POSIX.1-2008. It was replaced with nanosleep() that provides more
@@ -396,6 +431,23 @@ static inline int xusleep(useconds_t usec)
#define stringify_value(s) stringify(s)
#define stringify(s) #s
+/* Detect if we're compiled with Address Sanitizer
+ * - gcc (__SANITIZE_ADDRESS__)
+ * - clang (__has_feature(address_sanitizer))
+ */
+#if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
+# ifdef __SANITIZE_ADDRESS__
+# define HAS_FEATURE_ADDRESS_SANITIZER 1
+# elif defined(__has_feature)
+# if __has_feature(address_sanitizer)
+# define HAS_FEATURE_ADDRESS_SANITIZER 1
+# endif
+# endif
+# if !defined(HAS_FEATURE_ADDRESS_SANITIZER)
+# define HAS_FEATURE_ADDRESS_SANITIZER 0
+# endif
+#endif
+
/*
* UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
* instrumentation shipped with Clang and GCC) to not instrument the
diff --git a/src/utils/include/carefulputc.h b/src/utils/include/carefulputc.h
index f1c0356..66a0f15 100644
--- a/src/utils/include/carefulputc.h
+++ b/src/utils/include/carefulputc.h
@@ -28,82 +28,6 @@ static inline int fputc_careful(int c, FILE *fp, const char fail)
return (ret < 0) ? EOF : 0;
}
-/*
- * Requirements enumerated via testing (V8, Firefox, IE11):
- *
- * var charsToEscape = [];
- * for (var i = 0; i < 65535; i += 1) {
- * try {
- * JSON.parse('{"sample": "' + String.fromCodePoint(i) + '"}');
- * } catch (e) {
- * charsToEscape.push(i);
- * }
- * }
- */
-static inline void fputs_quoted_case_json(const char *data, FILE *out, int dir)
-{
- const char *p;
-
- fputc('"', out);
- for (p = data; p && *p; p++) {
-
- const unsigned char c = (unsigned char) *p;
-
- /* From http://www.json.org
- *
- * The double-quote and backslashes would break out a string or
- * init an escape sequence if not escaped.
- *
- * Note that single-quotes and forward slashes, while they're
- * in the JSON spec, don't break double-quoted strings.
- */
- if (c == '"' || c == '\\') {
- fputc('\\', out);
- fputc(c, out);
- continue;
- }
-
- /* All non-control characters OK; do the case swap as required. */
- if (c >= 0x20) {
- fputc(dir == 1 ? toupper(c) :
- dir == -1 ? tolower(c) : *p, out);
- continue;
- }
-
- /* In addition, all chars under ' ' break Node's/V8/Chrome's, and
- * Firefox's JSON.parse function
- */
- switch (c) {
- /* Handle short-hand cases to reduce output size. C
- * has most of the same stuff here, so if there's an
- * "Escape for C" function somewhere in the STL, we
- * should probably be using it.
- */
- case '\b':
- fputs("\\b", out);
- break;
- case '\t':
- fputs("\\t", out);
- break;
- case '\n':
- fputs("\\n", out);
- break;
- case '\f':
- fputs("\\f", out);
- break;
- case '\r':
- fputs("\\r", out);
- break;
- default:
- /* Other assorted control characters */
- fprintf(out, "\\u00%02x", c);
- break;
- }
- }
- fputc('"', out);
-}
-
-
static inline void fputs_quoted_case(const char *data, FILE *out, int dir)
{
const char *p;
@@ -130,10 +54,6 @@ static inline void fputs_quoted_case(const char *data, FILE *out, int dir)
#define fputs_quoted_upper(_d, _o) fputs_quoted_case(_d, _o, 1)
#define fputs_quoted_lower(_d, _o) fputs_quoted_case(_d, _o, -1)
-#define fputs_quoted_json(_d, _o) fputs_quoted_case_json(_d, _o, 0)
-#define fputs_quoted_json_upper(_d, _o) fputs_quoted_case_json(_d, _o, 1)
-#define fputs_quoted_json_lower(_d, _o) fputs_quoted_case_json(_d, _o, -1)
-
static inline void fputs_nonblank(const char *data, FILE *out)
{
const char *p;
@@ -151,5 +71,21 @@ static inline void fputs_nonblank(const char *data, FILE *out)
}
}
+static inline void fputs_shell_ident(const char *data, FILE *out)
+{
+ const char *p = data;
+
+ /* convert "1FOO" to "_1FOO" */
+ if (p && !isalpha(*p))
+ fputc('_', out);
+
+ /* replace all "bad" chars with "_" */
+ for (p = data; p && *p; p++) {
+ if (!isalnum(*p))
+ fputc('_', out);
+ else
+ fputc(*p, out);
+ }
+}
#endif /* _CAREFULPUTC_H */
diff --git a/src/utils/include/closestream.h b/src/utils/include/closestream.h
index 41afbe2..8e5d18d 100644
--- a/src/utils/include/closestream.h
+++ b/src/utils/include/closestream.h
@@ -83,7 +83,7 @@ close_stdout_atexit(void)
/*
* Note that close stdout at exit disables ASAN to report memory leaks
*/
-#if !defined(__SANITIZE_ADDRESS__)
+#if !HAS_FEATURE_ADDRESS_SANITIZER
atexit(close_stdout);
#endif
}
diff --git a/src/utils/include/fileutils.h b/src/utils/include/fileutils.h
index 618bf39..17ad429 100644
--- a/src/utils/include/fileutils.h
+++ b/src/utils/include/fileutils.h
@@ -34,10 +34,15 @@ static inline FILE *fopen_at(int dir, const char *filename,
int flags, const char *mode)
{
int fd = openat(dir, filename, flags);
+ FILE *ret;
+
if (fd < 0)
return NULL;
- return fdopen(fd, mode);
+ ret = fdopen(fd, mode);
+ if (!ret)
+ close(fd);
+ return ret;
}
#endif
@@ -53,9 +58,9 @@ static inline int is_same_inode(const int fd, const struct stat *st)
}
extern int dup_fd_cloexec(int oldfd, int lowfd);
-extern int get_fd_tabsize(void);
+extern unsigned int get_fd_tabsize(void);
-extern int mkdir_p(const char *path, mode_t mode);
+extern int ul_mkdir_p(const char *path, mode_t mode);
extern char *stripoff_last_component(char *path);
/* This is readdir()-like function, but skips "." and ".." directory entries */
@@ -72,7 +77,21 @@ static inline struct dirent *xreaddir(DIR *dp)
return d;
}
-extern void close_all_fds(const int exclude[], size_t exsz);
+#if defined(__linux__)
+# include <sys/syscall.h>
+# if defined(SYS_close_range)
+# include <sys/types.h>
+# ifndef HAVE_CLOSE_RANGE
+static inline int close_range(unsigned int first, unsigned int last, int flags)
+{
+ return syscall(SYS_close_range, first, last, flags);
+}
+# endif
+# define HAVE_CLOSE_RANGE 1
+# endif /* SYS_close_range */
+#endif /* __linux__ */
+
+extern void ul_close_all_fds(unsigned int first, unsigned int last);
#define UL_COPY_READ_ERROR (-1)
#define UL_COPY_WRITE_ERROR (-2)
diff --git a/src/utils/include/jsonwrt.h b/src/utils/include/jsonwrt.h
index 04ef49e..5be2d70 100644
--- a/src/utils/include/jsonwrt.h
+++ b/src/utils/include/jsonwrt.h
@@ -11,34 +11,34 @@ struct ul_jsonwrt {
FILE *out;
int indent;
- unsigned int postponed_break :1;
+ unsigned int after_close :1;
};
void ul_jsonwrt_init(struct ul_jsonwrt *fmt, FILE *out, int indent);
void ul_jsonwrt_indent(struct ul_jsonwrt *fmt);
void ul_jsonwrt_open(struct ul_jsonwrt *fmt, const char *name, int type);
-void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type, int islast);
+void ul_jsonwrt_close(struct ul_jsonwrt *fmt, int type);
#define ul_jsonwrt_root_open(_f) ul_jsonwrt_open(_f, NULL, UL_JSON_OBJECT)
-#define ul_jsonwrt_root_close(_f) ul_jsonwrt_close(_f, UL_JSON_OBJECT, 1)
+#define ul_jsonwrt_root_close(_f) ul_jsonwrt_close(_f, UL_JSON_OBJECT)
#define ul_jsonwrt_array_open(_f, _n) ul_jsonwrt_open(_f, _n, UL_JSON_ARRAY)
-#define ul_jsonwrt_array_close(_f, _l) ul_jsonwrt_close(_f, UL_JSON_ARRAY, _l)
+#define ul_jsonwrt_array_close(_f) ul_jsonwrt_close(_f, UL_JSON_ARRAY)
#define ul_jsonwrt_object_open(_f, _n) ul_jsonwrt_open(_f, _n, UL_JSON_OBJECT)
-#define ul_jsonwrt_object_close(_f, _l) ul_jsonwrt_close(_f, UL_JSON_OBJECT, _l)
+#define ul_jsonwrt_object_close(_f) ul_jsonwrt_close(_f, UL_JSON_OBJECT)
#define ul_jsonwrt_value_open(_f, _n) ul_jsonwrt_open(_f, _n, UL_JSON_VALUE)
-#define ul_jsonwrt_value_close(_f, _l) ul_jsonwrt_close(_f, UL_JSON_VALUE, _l)
+#define ul_jsonwrt_value_close(_f) ul_jsonwrt_close(_f, UL_JSON_VALUE)
void ul_jsonwrt_value_raw(struct ul_jsonwrt *fmt,
- const char *name, const char *data, int islast);
+ const char *name, const char *data);
void ul_jsonwrt_value_s(struct ul_jsonwrt *fmt,
- const char *name, const char *data, int islast);
+ const char *name, const char *data);
void ul_jsonwrt_value_u64(struct ul_jsonwrt *fmt,
- const char *name, uint64_t data, int islast);
+ const char *name, uint64_t data);
void ul_jsonwrt_value_boolean(struct ul_jsonwrt *fmt,
- const char *name, int data, int islast);
+ const char *name, int data);
#endif /* UTIL_LINUX_JSONWRT_H */
diff --git a/src/utils/include/path.h b/src/utils/include/path.h
index 2a4f80e..e720893 100644
--- a/src/utils/include/path.h
+++ b/src/utils/include/path.h
@@ -23,7 +23,8 @@ struct path_cxt {
int (*redirect_on_enoent)(struct path_cxt *, const char *, int *);
};
-struct path_cxt *ul_new_path(const char *dir, ...);
+struct path_cxt *ul_new_path(const char *dir, ...)
+ __attribute__ ((__format__ (__printf__, 1, 2)));
void ul_unref_path(struct path_cxt *pc);
void ul_ref_path(struct path_cxt *pc);
@@ -55,15 +56,18 @@ int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
int ul_path_open(struct path_cxt *pc, int flags, const char *path);
int ul_path_openf(struct path_cxt *pc, int flags, const char *path, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
-int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap);
+int ul_path_vopenf(struct path_cxt *pc, int flags, const char *path, va_list ap)
+ __attribute__ ((__format__ (__printf__, 3, 0)));
FILE *ul_path_fopen(struct path_cxt *pc, const char *mode, const char *path);
FILE *ul_path_fopenf(struct path_cxt *pc, const char *mode, const char *path, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
-FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap);
+FILE *ul_path_vfopenf(struct path_cxt *pc, const char *mode, const char *path, va_list ap)
+ __attribute__ ((__format__ (__printf__, 3, 0)));
DIR *ul_path_opendir(struct path_cxt *pc, const char *path);
-DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap);
+DIR *ul_path_vopendirf(struct path_cxt *pc, const char *path, va_list ap)
+ __attribute__ ((__format__ (__printf__, 2, 0)));
DIR *ul_path_opendirf(struct path_cxt *pc, const char *path, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
@@ -72,7 +76,8 @@ ssize_t ul_path_readlinkf(struct path_cxt *pc, char *buf, size_t bufsiz, const c
__attribute__ ((__format__ (__printf__, 4, 5)));
int ul_path_read(struct path_cxt *pc, char *buf, size_t len, const char *path);
-int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap);
+int ul_path_vreadf(struct path_cxt *pc, char *buf, size_t len, const char *path, va_list ap)
+ __attribute__ ((__format__ (__printf__, 4, 0)));
int ul_path_readf(struct path_cxt *pc, char *buf, size_t len, const char *path, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
@@ -84,8 +89,10 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char
int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
-int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...);
+int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...)
+ __attribute__ ((__format__ (__scanf__, 3, 4)));
int ul_path_scanff(struct path_cxt *pc, const char *path, va_list ap, const char *fmt, ...)
+ __attribute__ ((__format__ (__printf__, 2, 0)))
__attribute__ ((__format__ (__scanf__, 4, 5)));
int ul_path_read_majmin(struct path_cxt *pc, dev_t *res, const char *path);
diff --git a/src/utils/include/pathnames.h b/src/utils/include/pathnames.h
index 8f1bb56..9be2baa 100644
--- a/src/utils/include/pathnames.h
+++ b/src/utils/include/pathnames.h
@@ -144,8 +144,8 @@
#define _PATH_DEV_MEM "/dev/mem"
-#define _PATH_DEV_LOOP "/dev/xloop"
-#define _PATH_DEV_LOOPCTL "/dev/xloop-control"
+#define _PATH_DEV_LOOP "/dev/loop"
+#define _PATH_DEV_LOOPCTL "/dev/loop-control"
/* udev paths */
#define _PATH_DEV_BYLABEL "/dev/disk/by-label"
@@ -174,17 +174,23 @@
/* deprecated */
#define _PATH_RAWDEVCTL_OLD "/dev/rawctl"
+#define _PATH_PROC_KERNEL "/proc/sys/kernel"
+
/* ipc paths */
#define _PATH_PROC_SYSV_MSG "/proc/sysvipc/msg"
#define _PATH_PROC_SYSV_SEM "/proc/sysvipc/sem"
#define _PATH_PROC_SYSV_SHM "/proc/sysvipc/shm"
-#define _PATH_PROC_IPC_MSGMAX "/proc/sys/kernel/msgmax"
-#define _PATH_PROC_IPC_MSGMNB "/proc/sys/kernel/msgmnb"
-#define _PATH_PROC_IPC_MSGMNI "/proc/sys/kernel/msgmni"
-#define _PATH_PROC_IPC_SEM "/proc/sys/kernel/sem"
-#define _PATH_PROC_IPC_SHMALL "/proc/sys/kernel/shmall"
-#define _PATH_PROC_IPC_SHMMAX "/proc/sys/kernel/shmmax"
-#define _PATH_PROC_IPC_SHMMNI "/proc/sys/kernel/shmmni"
+#define _PATH_PROC_IPC_MSGMAX _PATH_PROC_KERNEL "/msgmax"
+#define _PATH_PROC_IPC_MSGMNB _PATH_PROC_KERNEL "/msgmnb"
+#define _PATH_PROC_IPC_MSGMNI _PATH_PROC_KERNEL "/msgmni"
+#define _PATH_PROC_IPC_SEM _PATH_PROC_KERNEL "/sem"
+#define _PATH_PROC_IPC_SHMALL _PATH_PROC_KERNEL "/shmall"
+#define _PATH_PROC_IPC_SHMMAX _PATH_PROC_KERNEL "/shmmax"
+#define _PATH_PROC_IPC_SHMMNI _PATH_PROC_KERNEL "/shmmni"
+
+/* util clamp */
+#define _PATH_PROC_UCLAMP_MIN _PATH_PROC_KERNEL "/sched_util_clamp_min"
+#define _PATH_PROC_UCLAMP_MAX _PATH_PROC_KERNEL "/sched_util_clamp_max"
/* irqtop paths */
#define _PATH_PROC_INTERRUPTS "/proc/interrupts"
@@ -194,6 +200,7 @@
/* kernel command line */
#define _PATH_PROC_CMDLINE "/proc/cmdline"
+
/* logger paths */
#define _PATH_DEVLOG "/dev/log"
@@ -207,4 +214,5 @@
#define _PATH_DEV_RFKILL "/dev/rfkill"
#define _PATH_SYS_RFKILL "/sys/class/rfkill"
+
#endif /* PATHNAMES_H */
diff --git a/src/utils/include/pty-session.h b/src/utils/include/pty-session.h
index 0c9ccc6..09eff43 100644
--- a/src/utils/include/pty-session.h
+++ b/src/utils/include/pty-session.h
@@ -10,6 +10,7 @@
#include <termios.h>
#include <signal.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <sys/signalfd.h>
@@ -98,6 +99,7 @@ struct ul_pty_callbacks *ul_pty_get_callbacks(struct ul_pty *pty);
int ul_pty_is_running(struct ul_pty *pty);
int ul_pty_setup(struct ul_pty *pty);
void ul_pty_cleanup(struct ul_pty *pty);
+int ul_pty_chownmod_slave(struct ul_pty *pty, uid_t uid, gid_t gid, mode_t mode);
void ul_pty_init_slave(struct ul_pty *pty);
int ul_pty_proxy_master(struct ul_pty *pty);
diff --git a/src/utils/include/strutils.h b/src/utils/include/strutils.h
index 09cc35e..6e95707 100644
--- a/src/utils/include/strutils.h
+++ b/src/utils/include/strutils.h
@@ -8,6 +8,7 @@
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
+#include <time.h>
#include "c.h"
@@ -18,25 +19,35 @@ extern int parse_size(const char *str, uintmax_t *res, int *power);
extern int strtosize(const char *str, uintmax_t *res);
extern uintmax_t strtosize_or_err(const char *str, const char *errmesg);
-extern int16_t strtos16_or_err(const char *str, const char *errmesg);
-extern uint16_t strtou16_or_err(const char *str, const char *errmesg);
-extern uint16_t strtox16_or_err(const char *str, const char *errmesg);
+extern int ul_strtos64(const char *str, int64_t *num, int base);
+extern int ul_strtou64(const char *str, uint64_t *num, int base);
+extern int ul_strtos32(const char *str, int32_t *num, int base);
+extern int ul_strtou32(const char *str, uint32_t *num, int base);
-extern int32_t strtos32_or_err(const char *str, const char *errmesg);
-extern uint32_t strtou32_or_err(const char *str, const char *errmesg);
-extern uint32_t strtox32_or_err(const char *str, const char *errmesg);
+extern int64_t str2num_or_err(const char *str, int base, const char *errmesg, int64_t low, int64_t up);
+extern uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, uint64_t up);
-extern int64_t strtos64_or_err(const char *str, const char *errmesg);
-extern uint64_t strtou64_or_err(const char *str, const char *errmesg);
-extern uint64_t strtox64_or_err(const char *str, const char *errmesg);
+#define strtos64_or_err(_s, _e) str2num_or_err(_s, 10, _e, 0, 0)
+#define strtou64_or_err(_s, _e) str2unum_or_err(_s, 10, _e, 0)
+#define strtox64_or_err(_s, _e) str2unum_or_err(_s, 16, _e, 0)
+
+#define strtos32_or_err(_s, _e) (int32_t) str2num_or_err(_s, 10, _e, INT32_MIN, INT32_MAX)
+#define strtou32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 10, _e, UINT32_MAX)
+#define strtox32_or_err(_s, _e) (uint32_t) str2unum_or_err(_s, 16, _e, UINT32_MAX)
+
+#define strtos16_or_err(_s, _e) (int16_t) str2num_or_err(_s, 10, _e, INT16_MIN, INT16_MAX)
+#define strtou16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 10, _e, UINT16_MAX)
+#define strtox16_or_err(_s, _e) (uint16_t) str2unum_or_err(_s, 16, _e, UINT16_MAX)
extern double strtod_or_err(const char *str, const char *errmesg);
+extern long double strtold_or_err(const char *str, const char *errmesg);
extern long strtol_or_err(const char *str, const char *errmesg);
extern unsigned long strtoul_or_err(const char *str, const char *errmesg);
extern void strtotimeval_or_err(const char *str, struct timeval *tv,
const char *errmesg);
+extern time_t strtotime_or_err(const char *str, const char *errmesg);
extern int isdigit_strend(const char *str, const char **end);
#define isdigit_string(_s) isdigit_strend(_s, NULL)
@@ -331,7 +342,7 @@ static inline size_t normalize_whitespace(unsigned char *str)
else
str[x++] = str[i++];
}
- if (nsp) /* tailing space */
+ if (nsp && x > 0) /* tailing space */
x--;
str[x] = '\0';
return x;
@@ -359,9 +370,10 @@ static inline void strrem(char *s, int rem)
extern char *strnappend(const char *s, const char *suffix, size_t b);
extern char *strappend(const char *s, const char *suffix);
extern char *strfappend(const char *s, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 3)));
extern const char *split(const char **state, size_t *l, const char *separator, int quoted);
extern int skip_fline(FILE *fp);
+extern int ul_stralnumcmp(const char *p1, const char *p2);
#endif
diff --git a/src/utils/include/strv.h b/src/utils/include/strv.h
index 260ad12..6382532 100644
--- a/src/utils/include/strv.h
+++ b/src/utils/include/strv.h
@@ -13,9 +13,12 @@ unsigned strv_length(char * const *l);
int strv_extend_strv(char ***a, char **b);
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
int strv_extend(char ***l, const char *value);
-int strv_extendv(char ***l, const char *format, va_list ap);
+
+int strv_extendv(char ***l, const char *format, va_list ap)
+ __attribute__ ((__format__ (__printf__, 2, 0)));
int strv_extendf(char ***l, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 2, 0)));
+ __attribute__ ((__format__ (__printf__, 2, 3)));
+
int strv_push(char ***l, char *value);
int strv_push_prepend(char ***l, char *value);
int strv_consume(char ***l, char *value);
diff --git a/src/utils/include/ttyutils.h b/src/utils/include/ttyutils.h
index f164a58..e28a2b0 100644
--- a/src/utils/include/ttyutils.h
+++ b/src/utils/include/ttyutils.h
@@ -17,6 +17,13 @@
#include <sys/ttydefaults.h>
#endif
+#ifdef USE_TTY_GROUP
+# define TTY_MODE 0620
+#else
+# define TTY_MODE 0600
+#endif
+#define TTYGRPNAME "tty" /* name of group to own ttys */
+
/* Some shorthands for control characters. */
#define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */
#define CR CTL('M') /* carriage return */
@@ -73,7 +80,7 @@ struct chardata {
#define INIT_CHARDATA(ptr) do { \
(ptr)->erase = DEF_ERASE; \
(ptr)->kill = DEF_KILL; \
- (ptr)->eol = CTRL('r'); \
+ (ptr)->eol = CR; \
(ptr)->parity = 0; \
(ptr)->capslock = 0; \
} while (0)