#include "config.h"
#include "macro.h"
#include "util.h"
-#include "ioprio.h"
+// #include "ioprio.h"
// #include "missing.h"
// #include "log.h"
#include "strv.h"
#include "mkdir.h"
#include "path-util.h"
// #include "exit-status.h"
-// #include "hashmap.h"
+#include "hashmap.h"
+#include "set.h"
// #include "env-util.h"
#include "fileio.h"
// #include "device-nodes.h"
return 0;
}
+bool uid_is_valid(uid_t uid) {
+
+ /* Some libc APIs use UID_INVALID as special placeholder */
+ if (uid == (uid_t) 0xFFFFFFFF)
+ return false;
+
+ /* A long time ago UIDs where 16bit, hence explicitly avoid the 16bit -1 too */
+ if (uid == (uid_t) 0xFFFF)
+ return false;
+
+ return true;
+}
+
int parse_uid(const char *s, uid_t* ret_uid) {
unsigned long ul = 0;
uid_t uid;
if ((unsigned long) uid != ul)
return -ERANGE;
- /* Some libc APIs use UID_INVALID as special placeholder */
- if (uid == (uid_t) 0xFFFFFFFF)
- return -ENXIO;
-
- /* A long time ago UIDs where 16bit, hence explicitly avoid the 16bit -1 too */
- if (uid == (uid_t) 0xFFFF)
- return -ENXIO;
+ if (!uid_is_valid(uid))
+ return -ENXIO; /* we return ENXIO instead of EINVAL
+ * here, to make it easy to distuingish
+ * invalid numeric uids invalid
+ * strings. */
if (ret_uid)
*ret_uid = uid;
a.st_ino == b.st_ino;
}
-/// UNNEEDED by elogind
-#if 0
int running_in_chroot(void) {
int ret;
return ret == 0;
}
-#endif // 0
static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent) {
size_t x;
return endswith(de->d_name, suffix);
}
-/// UNNEEDED by elogind
-#if 0
static int do_execute(char **directories, usec_t timeout, char *argv[]) {
_cleanup_hashmap_free_free_ Hashmap *pids = NULL;
_cleanup_set_free_free_ Set *seen = NULL;
wait_for_terminate_and_warn(name, executor_pid, true);
}
-#endif // 0
bool nulstr_contains(const char*nulstr, const char *needle) {
const char *i;
return -ENOENT;
}
-#endif // 0
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
};
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ioprio_class, int, INT_MAX);
+#endif // 0
static const char *const sigchld_code_table[] = {
[CLD_EXITED] = "exited",
if (master < 0)
_exit(EXIT_FAILURE);
+ if (unlockpt(master) < 0)
+ _exit(EXIT_FAILURE);
+
cmsg = CMSG_FIRSTHDR(&mh);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
return 0;
}
-#endif // 0
static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) {
assert(bad);
return r;
}
+#endif // 0
int parse_mode(const char *s, mode_t *ret) {
char *x;