#!/bin/sh # $Id: check-logins 1855 2010-10-16 10:57:24Z gillow $ filter="(evolution-data-server|gconfd-2|ssh-agent|bonobo-activation-server|artsd|dbus-daemon|gvfsd|gnome-vfs-daemon|acroread|gnome-keyring-daemon|npviewer.bin|couch|heart|wnck-applet|trashapplet|pulseaudio)" # Look for non-system users running processes other than the filtered ones for uid in `ps -eo uid,cmd --no-heading | egrep -v "$filter" |awk '{print $1}' |sort -n |uniq`; do if [ $uid -ge 500 ]; then uname=`getent passwd $uid |cut -d: -f1` if [ -z $uname ]; then users="${users} $uid" else users="${users} $uname" fi fi done #Look for logged in root user users="$users `w -h| grep root | awk '{print $1}'`" #Get live SSH connections (again mainly to pick up root connections) users="$users `pgrep -u root -f '^sshd:' |xargs -i{} ps --no-heading -o command {} | sed -n 's/sshd: \([a-z0-9]*\).*/\1/p' | grep -v -E ^nx$`" #Tidy up the list users=`echo $users |sed -e 's/ /\n/g' |sort |uniq` if [ -z "$users" ]; then exit 0 else echo $users |sed -e 's/ /\n/g' exit 1 fi