summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoru <u@billy>2023-05-29 07:39:55 -0400
committeru <u@billy>2023-05-29 07:46:50 -0400
commitd7a855170d5c11b080ba62d74e583903b708ef37 (patch)
tree6d4ccb89f380d633125a269655502ef5f0aa3458
parent3f7ac1f42b1ae91ec7ea07c0fae562cccd794e0b (diff)
Remove references to user "u". Uses $SUDO_USER.
-rw-r--r--Makefile8
-rwxr-xr-xsrc/AuthorizedKeysCommand8
-rw-r--r--src/fossil-user.conf3
-rw-r--r--src/fossil-user.socket4
4 files changed, 16 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 48079f6..30850b8 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,11 @@ work:
34work/.fslckout: | work $(fossil_database) 34work/.fslckout: | work $(fossil_database)
35 cd work && fossil open ../$(fossil_database) 35 cd work && fossil open ../$(fossil_database)
36else 36else
37ifdef SUDO_USER
38THE_USER=$(SUDO_USER)
39else
40$(error "you must define THE_USER")
41endif
37unitdir = /etc/systemd/system 42unitdir = /etc/systemd/system
38unit_files = $(addprefix src/fossil-user,@.service .socket) 43unit_files = $(addprefix src/fossil-user,@.service .socket)
39units = $(filter-out %@.service,$(notdir $(unit_files))) 44units = $(filter-out %@.service,$(notdir $(unit_files)))
@@ -42,7 +47,8 @@ bindir = /usr/local/bin
42 47
43default: install start follow 48default: install start follow
44install: 49install:
45 install -t /etc/ssh/ -- src/user-d.AnonymousForceCommand src/user-d.AuthorizedKeysCommand 50 install -t /etc/ssh/ -- src/AuthorizedKeysCommand
51 install -T -- src/AnonymousForceCommand /etc/ssh/user-$(THE_USER).AnonymousForceCommand
46 install -m644 -t /etc/ssh/sshd_config.d -- src/fossil-user.conf 52 install -m644 -t /etc/ssh/sshd_config.d -- src/fossil-user.conf
47 install -m644 -t $(unitdir) -- $(unit_files) 53 install -m644 -t $(unitdir) -- $(unit_files)
48 install -t $(bindir) -- $(executables) 54 install -t $(bindir) -- $(executables)
diff --git a/src/AuthorizedKeysCommand b/src/AuthorizedKeysCommand
index 6bf0ec9..de0732a 100755
--- a/src/AuthorizedKeysCommand
+++ b/src/AuthorizedKeysCommand
@@ -1,7 +1,11 @@
1#!/bin/sh 1#!/bin/sh
2cmd=/etc/ssh/user-d.AnonymousForceCommand 2username=$1
3shift
4
5[ "$username" ]
6cmd=/etc/ssh/user-$username.AnonymousForceCommand
3[ -x "$cmd" ] || exit 7[ -x "$cmd" ] || exit
4 8
5key=$1 9key=$1
6shift 10shift
7printf 'restrict,pty,command="%s" %s\n' "$cmd $*" "$key" 11printf 'restrict,pty,command="%s" %s\n' "$cmd" "$key"
diff --git a/src/fossil-user.conf b/src/fossil-user.conf
index f4296fd..86387e7 100644
--- a/src/fossil-user.conf
+++ b/src/fossil-user.conf
@@ -1,4 +1,3 @@
1Match User d
2ExposeAuthInfo=yes 1ExposeAuthInfo=yes
3AuthorizedKeysCommandUser=root 2AuthorizedKeysCommandUser=root
4AuthorizedKeysCommand=/etc/ssh/user-d.AuthorizedKeysCommand "%t %k" "%f" 3AuthorizedKeysCommand=/etc/ssh/AuthorizedKeysCommand "%u" "%t %k"
diff --git a/src/fossil-user.socket b/src/fossil-user.socket
index eab5a51..38914e6 100644
--- a/src/fossil-user.socket
+++ b/src/fossil-user.socket
@@ -1,5 +1,5 @@
1[Socket] 1[Socket]
2Accept = yes 2Accept = yes
3ListenStream = /run/fossil-user.S 3ListenStream = /run/fossil-user.S
4SocketUser = d 4SocketUser = root
5SocketMode = 0600 5SocketMode = 0666