aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-12-24 10:02:52 -0800
committerTrumeet <yuuta@yuuta.moe>2022-12-24 10:02:52 -0800
commitb5b8c19df66710e40791aeae46da53813943c436 (patch)
tree64a4818076ec348dff21535083c38a6a8efd625e
parent244ca6c544511011c6e4e54d0d7eb540a986afc5 (diff)
downloadsecdesk-b5b8c19df66710e40791aeae46da53813943c436.tar
secdesk-b5b8c19df66710e40791aeae46da53813943c436.tar.gz
secdesk-b5b8c19df66710e40791aeae46da53813943c436.tar.bz2
secdesk-b5b8c19df66710e40791aeae46da53813943c436.zip
Use setproctitle(3)HEADmaster
-rw-r--r--main.c7
-rw-r--r--sd.c2
2 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 0be6f54..e8339fb 100644
--- a/main.c
+++ b/main.c
@@ -6,6 +6,7 @@
#include <signal.h>
#include <errno.h>
#include <stdlib.h>
+#include <bsd/unistd.h>
#include <sys/wait.h>
struct auth_env a_env;
@@ -19,7 +20,8 @@ struct proc_env p_env = {
static void interrupt_int(int signum) {
}
-int main(int argc, char **argv) {
+int main(int argc, char **argv, char **envp) {
+ setproctitle_init(argc, argv, envp);
if (argc != 2 && argc != 3) {
fprintf(stderr, "Usage: %s consent|password|auth [prompt]\n",
argv[0]);
@@ -48,6 +50,8 @@ int main(int argc, char **argv) {
a_env.pid = getppid();
a_env.usr = getuid();
+ setproctitle("master");
+
ssize_t len;
snprintf(a_env.exe, sizeof(a_env.exe) - 1, "/proc/%d/exe", a_env.pid);
if ((len = readlink(a_env.exe, a_env.exe, sizeof(a_env.exe) - 1)) == -1) {
@@ -59,6 +63,7 @@ int main(int argc, char **argv) {
pid_t chld;
/* Detach from the current session. */
if (!(chld = fork())) {
+ setproctitle("auth");
/* Because we need to frequently dup(2). */
setbuf(stdout, NULL);
signal(SIGHUP, SIG_IGN);
diff --git a/sd.c b/sd.c
index d1e6730..ad67db5 100644
--- a/sd.c
+++ b/sd.c
@@ -14,6 +14,7 @@ if (ioctl(a, b, __VA_ARGS__) < 0) { LOGFV("ioctl(%d, 0x%x): %m", a, b, errno); r
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
+#include <bsd/unistd.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
@@ -81,6 +82,7 @@ static int find_current_tty(void) {
}
static int main_sak(void) {
+ setproctitle("sak");
/* We have to take the ownership here - otherwise SAK will kill the parent. */
if (setsid() == -1) {
LOGFV("Cannot set session ID: %m.", errno);