Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add native PAM module #484

Merged
merged 61 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
609b8e9
[WIP]: Add native PAM module
saidsay-so Dec 26, 2020
beee059
Fix the build instructions
saidsay-so Jan 17, 2021
50d52ec
Remove uinput
saidsay-so Jan 18, 2021
322899d
Fix typo in build instructions
saidsay-so Mar 15, 2021
2287bc1
Add C++11 flag for meson
saidsay-so Mar 15, 2021
fce326d
Made python3 absolute, added comments
boltgolt Mar 18, 2021
a2e89f0
More documentation
boltgolt Mar 19, 2021
02a831f
Fix a typo for the login confirmation
saidsay-so Apr 7, 2021
3abc3d5
Add more documentation
saidsay-so Apr 7, 2021
1c25bf0
Fix typo in comments
saidsay-so Apr 7, 2021
1cb38b0
Add instructions for installation
saidsay-so Apr 7, 2021
7ee0f36
Added gettext and more even more comments
boltgolt Apr 7, 2021
d078f81
feat: add workarounds
saidsay-so Jun 30, 2021
3a4b482
fix: fix native and input workarounds
saidsay-so Jul 24, 2021
b8bc325
chore: fix misspell
saidsay-so Jul 24, 2021
5503cfb
chore: add workaround key to config.ini
saidsay-so Jul 24, 2021
0392171
fix: fix possible race condition
saidsay-so Jul 28, 2021
27460c8
build: add boost locale module
saidsay-so Jul 28, 2021
ab4a492
Add python-opencv as a dependency for ArchLinux
jinnko Apr 6, 2021
827f638
Turn subproject as fallback (#1)
supdrewin Jan 19, 2022
9fb3ef5
fix: use atomic type for confirmation type
saidsay-so Jan 20, 2022
fa2607d
fix: add appdata_ptr for conv function
saidsay-so Jan 20, 2022
d77dd94
refactor: add function to format success message
saidsay-so Jan 21, 2022
67fc6f4
fix: fix condition for howdy_error
saidsay-so Jan 21, 2022
d91181f
docs: improve documentation
saidsay-so Jan 21, 2022
c31acec
chore: pin version for subproject
saidsay-so Jan 21, 2022
e8e1624
refactor: build workaround from string
saidsay-so Jan 21, 2022
4858071
refactor: use relaxed ordering for atomics
saidsay-so Jan 21, 2022
bd0d354
fix: let child inherit standard descriptors
saidsay-so Jan 21, 2022
7490705
feat: improve error messages
saidsay-so Jan 21, 2022
ec2461a
chore: use inih subproject from wrapdb
saidsay-so Jan 21, 2022
314c517
chore: add clang-tidy file
saidsay-so Jan 21, 2022
59cbabf
refactor: apply suggestions from clang-tidy
saidsay-so Jan 21, 2022
32a0809
ci: add check workflow
saidsay-so Jan 21, 2022
00c2be2
ci: fix workflow
saidsay-so Jan 21, 2022
add2709
ci: use ninja instead of meson compile
saidsay-so Jan 21, 2022
27287bc
ci: install native ininh
saidsay-so Jan 21, 2022
073aea4
refactor: inline send_message
saidsay-so Jan 21, 2022
a12908e
chore: remove todo lint
saidsay-so Jan 23, 2022
9d61c0b
build: add translation support to build system
saidsay-so Jan 23, 2022
cd11aba
refactor: replace boost locale by gnu gettext
saidsay-so Jan 23, 2022
7729f97
fix: remove absolute path for `posix_spawnp`
saidsay-so Jan 23, 2022
2000df3
refactor: build `packaged_task` in `optional_task`
saidsay-so Jan 23, 2022
b9d678a
refactor: improve structure
saidsay-so Jan 24, 2022
6a39506
feat: send enter input from the module
saidsay-so Jan 24, 2022
8b6b257
ci: add libevdev
saidsay-so Jan 24, 2022
b53d48e
refactor: improve structure
saidsay-so Jan 24, 2022
11762b7
fix: use correct macro for signal number
saidsay-so Jan 25, 2022
9dae2b6
refactor: remove atomic
saidsay-so Jan 25, 2022
5afb748
fix: check non-zero return code for `posix_spawnp`
saidsay-so Jan 25, 2022
d0077ef
refactor: rename reader to config
saidsay-so Jan 25, 2022
42d18c8
refactor: improve error messages
saidsay-so Jan 25, 2022
ab79c5b
fix: use `euidaccess` to check permissions
saidsay-so Jan 26, 2022
b383164
fix: print message when retries limit is reached
saidsay-so Jan 26, 2022
0f39bcc
refactor: remove unused function
saidsay-so Jan 26, 2022
6cddf40
refactor: improve structure
saidsay-so Jan 26, 2022
30760be
fix: fix issues in `optional_task`
saidsay-so Jan 26, 2022
5126a8a
refactor: improve variable names
saidsay-so Jan 26, 2022
b903b42
chore: fix .clang-tidy
saidsay-so Jan 26, 2022
f7aefcd
chore: move to howdy folder
saidsay-so Mar 14, 2022
68f06e8
ci: fix path
saidsay-so Mar 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: check
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install required libraries
run: >
sudo apt-get update && sudo apt-get install -y
python3 python3-pip python3-setuptools python3-wheel ninja-build meson
cmake make build-essential clang-tidy
libpam0g-dev libinih-dev libevdev-dev
python3-dev libopencv-dev

- uses: actions/checkout@v2

- name: Build
run: |
meson setup build howdy/src/pam
ninja -C build

- name: Check source code
run: |
ninja clang-tidy -C build
1 change: 1 addition & 0 deletions howdy/archlinux/howdy/.SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pkgbase = howdy
depends = python3
depends = python-dlib
depends = python-numpy
depends = python-opencv
backup = usr/lib/security/howdy/config.ini
source = howdy-2.6.1.tar.gz::https://github.com/boltgolt/howdy/archive/v2.6.1.tar.gz
source = https://github.com/davisking/dlib-models/raw/master/dlib_face_recognition_resnet_model_v1.dat.bz2
Expand Down
1 change: 0 additions & 1 deletion howdy/src/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from i18n import _
from recorders.video_capture import VideoCapture


def exit(code=None):
"""Exit while closeing howdy-gtk properly"""
global gtk_proc
Expand Down
8 changes: 8 additions & 0 deletions howdy/src/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ disabled = false
# computational power to run, and is meant to be executed on a GPU to attain reasonable speed.
use_cnn = false

# WARNING: Changing this key can lead to unstability
# Set a workaround to confirm the prompt
#
# "off" will disable it, so the user needs to confirm manually
# "input" will send an enter keypress to confirm (the prompt needs to be on focus)
# "native" will stop the prompt at PAM level (DANGEROUS!)
workaround = input

[video]
# The certainty of the detected face belonging to the user of the account
# On a scale from 1 to 10, values above 5 are not recommended
Expand Down
7 changes: 7 additions & 0 deletions howdy/src/pam/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Checks: 'clang-diagnostic-*,clang-analyser-*,-clang-diagnostic-unused-command-line-argument,google-*,bugprone-*,modernize-*,performance-*,portability-*,readability-*,-bugprone-easily-swappable-*,-readability-magic-numbers,-google-readability-todo'
WarningsAsErrors: 'clang-diagnostic-*,clang-analyser-*,-clang-diagnostic-unused-command-line-argument,google-*,bugprone-*,modernize-*,performance-*,portability-*,readability-*,-bugprone-easily-swappable-*,-readability-magic-numbers,-google-readability-todo'
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: '50'

# vim:syntax=yaml
29 changes: 22 additions & 7 deletions howdy/src/pam/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
# Howdy PAM module

## Prepare

This module depends on `INIReader` and `libevdev`.
They can be installed with these packages:

```
Arch Linux - libinih libevdev
Debian - libinih-dev libevdev-dev
Fedora - inih-devel libevdev-devel
OpenSUSE - inih libevdev-devel
```

If your distribution doesn't provide `INIReader`,
it will be automatically pulled from git at the subproject's pinned version.

## Build

```sh
meson setup build -Dinih:with_INIReader=true
``` sh
meson setup build
meson compile -C build
```

## Install

```sh
sudo mv build/libpam_howdy.so /lib/security/pam_howdy.so
``` sh
meson install -C build
```

Change PAM config line to:
Add the following line to your PAM configuration (/etc/pam.d/your-service):

```pam
auth sufficient pam_howdy.so
``` pam
auth sufficient pam_howdy.so
```
48 changes: 48 additions & 0 deletions howdy/src/pam/enter_device.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "enter_device.hh"

#include <cstring>
#include <memory>
#include <stdexcept>

EnterDevice::EnterDevice()
: raw_device(libevdev_new(), &libevdev_free),
raw_uinput_device(nullptr, &libevdev_uinput_destroy) {
auto *dev_ptr = raw_device.get();

libevdev_set_name(dev_ptr, "enter device");
libevdev_enable_event_type(dev_ptr, EV_KEY);
libevdev_enable_event_code(dev_ptr, EV_KEY, KEY_ENTER, nullptr);

int err;
struct libevdev_uinput *uinput_dev_ptr;
if ((err = libevdev_uinput_create_from_device(
dev_ptr, LIBEVDEV_UINPUT_OPEN_MANAGED, &uinput_dev_ptr)) != 0) {
throw std::runtime_error(std::string("Failed to create device: ") +
strerror(-err));
}

raw_uinput_device.reset(uinput_dev_ptr);
};

void EnterDevice::send_enter_press() const {
auto *uinput_dev_ptr = raw_uinput_device.get();

int err;
if ((err = libevdev_uinput_write_event(uinput_dev_ptr, EV_KEY, KEY_ENTER,
1)) != 0) {
throw std::runtime_error(std::string("Failed to write event: ") +
strerror(-err));
}

if ((err = libevdev_uinput_write_event(uinput_dev_ptr, EV_KEY, KEY_ENTER,
0)) != 0) {
throw std::runtime_error(std::string("Failed to write event: ") +
strerror(-err));
}

if ((err = libevdev_uinput_write_event(uinput_dev_ptr, EV_SYN, SYN_REPORT,
0)) != 0) {
throw std::runtime_error(std::string("Failed to write event: ") +
strerror(-err));
};
}
19 changes: 19 additions & 0 deletions howdy/src/pam/enter_device.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef ENTER_DEVICE_H_
#define ENTER_DEVICE_H_

#include <libevdev/libevdev-uinput.h>
#include <libevdev/libevdev.h>
#include <memory>

class EnterDevice {
std::unique_ptr<struct libevdev, decltype(&libevdev_free)> raw_device;
std::unique_ptr<struct libevdev_uinput, decltype(&libevdev_uinput_destroy)>
raw_uinput_device;

public:
EnterDevice();
void send_enter_press() const;
~EnterDevice() = default;
};

#endif // ENTER_DEVICE_H
Loading