-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_pam-qr.sh
executable file
·67 lines (51 loc) · 2.22 KB
/
install_pam-qr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#This script installs pam-qr and restarts the ssh service
# Copyright (C) 2021 Daniel Lowry
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# The license can be found in the root git repo in the LICENSE file.
# if ! command -v gcc &> /dev/null
# then
# echo "Installing GCC..."
# apt install gcc
# fi
# if ! command -v ld &> /dev/null
# then
# echo "Installing bintuils..."
# apt install bintuils
# fi
# if ! command -v libpam0g-dev &> /dev/null
# then
# echo "Installing libpam0g-dev..."
# apt install libpam0g-dev
# fi
# gcc -fPIC -fno-stack-protector -c src/pam-qr.c
# gcc -Wall -Wextra -g -c src/pam-qr.c
# gcc -Wall -Wextra -fPIC -fstack-protector -shared -o pam_qr.so src/pam_qr.c -lqrencode
# sudo rm /lib/x86_64-linux-gnu/security/pam_qr.so
# sudo ld -x --shared -o /lib/x86_64-linux-gnu/security/pam_qr.so pam_qr.so
# sudo chmod 644 /lib/x86_64-linux-gnu/security/pam_qr.so
# rm pam_qr.so
# gcc -Wall -Wextra -fPIC -shared -o pam_qr.so src/qrcodegen.o src/pam_qr.c -L src #-lqrcodegen
# make pam_qr
lxc file push -r src/ pam-test/root/
lxc file push makefile pam-test/root/
# lxc file push src/libqrcodegen.so pam-test/root/
lxc exec pam-test -- make pam_qr
lxc exec pam-test -- chown root pam_qr.so
lxc exec pam-test -- chgrp root pam_qr.so
lxc exec pam-test -- chmod 644 pam_qr.so
# lxc exec pam-test -- chown root libqrcodegen.so
# lxc exec pam-test -- chgrp root libqrcodegen.so
# lxc exec pam-test -- chmod 644 libqrcodegen.so
# lxc exec pam-test -- ld --shared -o /usr/lib/libqrcodegen.so libqrcodegen.so
lxc exec pam-test -- cp lib/pam_qr.so /lib/x86_64-linux-gnu/security/
lxc exec pam-test -- systemctl restart sshd