-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathchkdirs.py
executable file
·44 lines (39 loc) · 1.17 KB
/
chkdirs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import os,sys
passwd="/etc/passwd"
if not os.path.isfile(passwd):
print "Can't open %s." % passwd
sys.exit(1)
format="%-18s %-17s %10s %-9s"
print format % ("", "", "Disk ", "")
print format % ("Username (UID)", "Home Directory",
"Space", "Security")
print "---------------------------------------------\
---------------"
for line in open(passwd).readlines():
(uname, xpass, uid, gid, junk, home_dir, junk2) = line.split(':')
if uname == 'root' or uname == 'nobody' or uname[0:2] == 'uu':
continue
uid = int(uid)
if uid <= 100 and uid > 0:
continue
if uid == 0 and uname != 'root':
warn = "** UID=0"
elif xpass != '!' and xpass != '*' and xpass != 'x':
warn = "** CK PASS"
else:
warn = ""
if os.path.isdir(home_dir) and home_dir != '/':
disk = os.popen("du -s -k %s 2>/dev/null" %
home_dir).read().split('\t')[0]
if disk == '':
disk = "unknown"
else:
disk += "K"
else:
disk = "skipped"
print format % ("%s (%s)" % (uname, uid), home_dir, \
disk, warn)
'''
doc
'''