aboutsummaryrefslogtreecommitdiff
path: root/utils/byobu/patches/007-count-dropbear-users.patch
blob: 357270e2738ea08b2cc939842082592b684cbadf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
--- a/usr/lib/byobu/users
+++ b/usr/lib/byobu/users
@@ -26,7 +26,12 @@ __users_detail() {
 }
 
 __users() {
-	local count=0
+	local count=0 f pid
+	for f in /var/run/dropbear.*.pid; do
+		read pid < "$f"
+		count=$(($count + $(pgrep -P "$pid" | wc -l)))
+	done
+	if [ $count -eq 0 ]; then
 	if [ "$USERS_DISTINCT" = "1" ]; then
 		count=$(pgrep -fl 'sshd:.*@' | cut -f3 -d\ | cut -f1 -d@ | sort -u | wc -l)
 	else
@@ -34,6 +39,7 @@ __users() {
 		# busybox and some distro's pgrep (and it doesn't exit non-zero).
 		count=$(pgrep -f "^sshd:.*@|^/usr/sbin/sshd -i" | wc -l) || return
 	fi
+	fi
 	if [ $count -gt 0 ]; then
 		color b w r; printf "%d" "$count"; color -; color w r; printf "##"; color --
 	else