You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

  1. --- a/usr/lib/byobu/users
  2. +++ b/usr/lib/byobu/users
  3. @@ -22,20 +22,26 @@
  4. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5. __users_detail() {
  6. - ps -ef | grep "sshd:.*@" | grep -v grep
  7. + ps -ef 2>/dev/null | grep "sshd:.*@" | grep -v grep
  8. }
  9. __users() {
  10. - local count=0
  11. + local count=0 f pid
  12. + for f in /var/run/dropbear.*.pid; do
  13. + read pid < "$f"
  14. + count=$(($count + $(pgrep -P "$pid" | wc -l)))
  15. + done
  16. + if [ $count -eq 0 ]; then
  17. if [ "$USERS_DISTINCT" = "1" ]; then
  18. count=$(pgrep -fl 'sshd:.*@' | cut -f3 -d\ | cut -f1 -d@ | sort -u | wc -l)
  19. else
  20. # Note: we'd like to use pgrep -c, however, this isn't available in
  21. # busybox and some distro's pgrep (and it doesn't exit non-zero).
  22. - count=$(pgrep -f "^sshd:.*@|^/usr/sbin/sshd -i" | wc -l) || return
  23. + count=$(pgrep -f "^sshd:.*@|^/usr/sbin/sshd -i" | wc -l)
  24. + fi
  25. fi
  26. if [ $count -gt 0 ]; then
  27. - color b w r; printf "%d" "$count"; color -; color w r; printf "#"; color --
  28. + color b w r; printf "%d" "$count"; color -; color w r; printf "##"; color --
  29. else
  30. rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/users"*
  31. fi