summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-16 21:54:17 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-16 21:54:17 +0200
commit5b6319dceedd81f3f1ce7eb70ea5defaef43bcec (patch)
tree0298a9a610482956971a07830f66b8dd051f4bee /src/util.c
parent04aa0cb9c46f0a5cd0cf5b4a4e378460423d2635 (diff)
service: optionally call into PAM when dropping priviliges
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 71409034a4..ed0991a68b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -43,6 +43,7 @@
#include <sys/poll.h>
#include <libgen.h>
#include <ctype.h>
+#include <sys/prctl.h>
#include "macro.h"
#include "util.h"
@@ -222,6 +223,13 @@ void close_nointr_nofail(int fd) {
errno = saved_errno;
}
+void close_many(const int fds[], unsigned n_fd) {
+ unsigned i;
+
+ for (i = 0; i < n_fd; i++)
+ close_nointr_nofail(fds[i]);
+}
+
int parse_boolean(const char *v) {
assert(v);
@@ -2161,6 +2169,19 @@ fallback:
return random() * RAND_MAX + random();
}
+void rename_process(const char name[8]) {
+ assert(name);
+
+ prctl(PR_SET_NAME, name);
+
+ /* This is a like a poor man's setproctitle(). The string
+ * passed should fit in 7 chars (i.e. the length of
+ * "systemd") */
+
+ if (program_invocation_name)
+ strncpy(program_invocation_name, name, strlen(program_invocation_name));
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",