[ SEA-GHOST MINI SHELL]

Path : /proc/2/cwd/proc/2/cwd/proc/2/cwd/proc/2/root/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/2/cwd/proc/2/cwd/proc/2/cwd/proc/2/root/var/lib/zabbix/multihomes.py

#!/usr/bin/env python2.7
import commands
import pwd
import os

ps = commands.getoutput('ps ax| grep rsync')

def get_pwuid(uid):
  try:
    return pwd.getpwuid(uid)[0]
  except:
    return "User with id %d not found" % uid

def get_mountpoints():
  """Return the list of system mount points"""
  mount = commands.getoutput('df -Ph')
  mntlines = mount.split('\n')[1::] # [1::] trims the first line (column names)
  return map(lambda line: line.split()[5], mntlines)


def get_subdirectories(a_dir):
  """Return all subdirectores of given directory (excluding symbolic links)."""
  return (name for name in os.listdir(a_dir)
    if os.path.isdir(os.path.join(a_dir, name)) and
    not os.path.islink(os.path.join(a_dir, name)))

def get_multihomes():
  """Return the directory of usernames which have multiple home dirs"""
  users = []

  for mount in get_mountpoints():
    if '/home' in mount:
      homes = get_subdirectories(mount)
      for home in homes:
        ps_number = ps.count(home)
        if ps_number < 1:
          stat = os.stat(os.path.join(mount, home))
          users.append(stat.st_uid)

  count = dict((i, users.count(i)) for i in users)
  return dict((get_pwuid(k), v) for k, v in count.items()
    if v > 1 and get_pwuid(k) != 'root')

if __name__ == "__main__":
  output = get_multihomes()
  print ', '.join('%s: %d' % (k,v) for k,v in sorted(output.iteritems()))

SEA-GHOST - SHELL CODING BY SEA-GHOST