OBS-URL: https://build.opensuse.org/package/show/security/physlock?expand=0&rev=11
75 lines
1.8 KiB
Diff
75 lines
1.8 KiB
Diff
From f8b0bdcd76b7dc1eca50217bd7cd29f1802f9727 Mon Sep 17 00:00:00 2001
|
|
From: xxc3nsoredxx <xxc3ncoredxx@gmail.com>
|
|
Date: Thu, 4 Mar 2021 14:32:29 -0600
|
|
Subject: [PATCH] Set PAM_TTY
|
|
|
|
Closes #110
|
|
---
|
|
main.c | 7 +++++++
|
|
physlock.h | 1 +
|
|
vt.c | 6 ++++++
|
|
3 files changed, 14 insertions(+)
|
|
|
|
--- main.c
|
|
+++ main.c 2024-09-11 11:33:25.063878564 +0000
|
|
@@ -28,6 +28,7 @@
|
|
#include <signal.h>
|
|
#include <sys/wait.h>
|
|
#include <security/pam_misc.h>
|
|
+#include <security/pam_modules.h>
|
|
|
|
static int oldvt;
|
|
static vt_t vt;
|
|
@@ -214,6 +215,12 @@ int main(int argc, char **argv) {
|
|
}
|
|
vt_secure(&vt);
|
|
|
|
+ /* Attempt to set PAM_TTY to the current VT, fixes #110 */
|
|
+ u->pam_status = pam_set_item(u->pamh, PAM_TTY, vt.vt_name);
|
|
+ if (u->pam_status != PAM_SUCCESS) {
|
|
+ error(EXIT_FAILURE, 0, "Unable to set PAM_TTY: %s", pam_strerror(u->pamh, u->pam_status));
|
|
+ }
|
|
+
|
|
dup2(vt.fd, 0);
|
|
dup2(vt.fd, 1);
|
|
dup2(vt.fd, 2);
|
|
--- physlock.h
|
|
+++ physlock.h 2024-09-11 11:33:25.063878564 +0000
|
|
@@ -89,6 +89,7 @@ typedef struct vt_s {
|
|
int nr;
|
|
FILE *ios;
|
|
int fd;
|
|
+ char *vt_name;
|
|
struct termios term;
|
|
struct termios term_orig;
|
|
} vt_t;
|
|
--- vt.c
|
|
+++ vt.c 2024-09-11 11:33:25.063878564 +0000
|
|
@@ -79,6 +79,7 @@ void vt_acquire(vt_t *vt) {
|
|
vt->nr = -1;
|
|
vt->ios = NULL;
|
|
vt->fd = -1;
|
|
+ vt->vt_name = NULL;
|
|
|
|
while ((ret = ioctl(fd, VT_OPENQRY, &vt->nr)) == -1 && errno == EINTR);
|
|
if (ret == -1)
|
|
@@ -89,6 +90,7 @@ void vt_acquire(vt_t *vt) {
|
|
if (vt->ios == NULL)
|
|
error(EXIT_FAILURE, errno, "%s", filename);
|
|
vt->fd = fileno(vt->ios);
|
|
+ vt->vt_name = estrdup(filename);
|
|
|
|
while ((ret = ioctl(fd, VT_ACTIVATE, vt->nr)) == -1 && errno == EINTR);
|
|
if (ret == -1)
|
|
@@ -139,6 +141,10 @@ CLEANUP int vt_release(vt_t *vt, int nr)
|
|
}
|
|
vt->nr = -1;
|
|
}
|
|
+
|
|
+ if (vt->vt_name != NULL) {
|
|
+ free(vt->vt_name);
|
|
+ }
|
|
return 0;
|
|
}
|
|
|