aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2023-06-16 18:14:47 +0200
committerMarvin Borner2023-06-16 18:14:47 +0200
commit3b69dbe8d9f0a8942e2baa8d8deddcf041ca183a (patch)
tree18d60080b8ed27971248555fef741a5f05ef48b0
parent921eaa2fceaa132585ef3a2e7b35379e8ea0856f (diff)
Added command to notificationHEADmain
-rwxr-xr-xisbypass10
-rw-r--r--main.c18
2 files changed, 22 insertions, 6 deletions
diff --git a/isbypass b/isbypass
index cd03041..d704112 100755
--- a/isbypass
+++ b/isbypass
@@ -1,9 +1,9 @@
#!/bin/env sh
-(/usr/local/bin/ishome && /usr/local/bin/hasyubi) && (
- notify-send "access bypass" &
+if (/usr/local/bin/ishome && /usr/local/bin/hasyubi); then
+ notify-send "access bypass" "$1" &
exit 0
-) || (
- notify-send "awaiting authentication" &
+else
+ notify-send "awaiting authentication" "$1" &
exit 1
-)
+fi
diff --git a/main.c b/main.c
index df9047d..5a38ac5 100644
--- a/main.c
+++ b/main.c
@@ -7,8 +7,24 @@
PAM_EXTERN int pam_sm_authenticate(pam_handle_t *handle, int flags, int argc,
const char **argv)
{
+ pid_t parent_pid = getppid();
+ char cmdline_file[128]; // this might be dumb lol
+ snprintf(cmdline_file, sizeof(cmdline_file), "/proc/%d/cmdline",
+ parent_pid);
+ FILE *file = fopen(cmdline_file, "r");
+ if (!file) {
+ fprintf(stderr, "Failed to open %s\n", cmdline_file);
+ return PAM_ABORT;
+ }
+
+ char cmdline_buffer[1024] = { 0 };
+ size_t read_size =
+ fread(cmdline_buffer, 1, sizeof(cmdline_buffer) - 1, file);
+ fclose(file);
+ cmdline_buffer[read_size] = 0;
+
if (fork() == 0) {
- execl("/etc/security/isbypass", NULL);
+ execl("/etc/security/isbypass", "", cmdline_buffer, NULL);
} else {
int stat;
wait(&stat);