~ubuntu-branches/ubuntu/precise/denyhosts/precise-updates

« back to all changes in this revision

Viewing changes to .pc/12_fix_bin_env_location.patch/scripts/restricted_from_passwd.py

  • Committer: Bazaar Package Importer
  • Author(s): Kyle Willmon
  • Date: 2011-04-13 10:23:11 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110413102311-t4skxepflm8f7cqj
* New Maintainer (Closes: #614581)
* debian/denyhosts.logrotate: Do not source /etc/denyhosts.conf since it may
  not be a valid shell script (Closes: #608672)
* debian/dh_reenable: Added reasonable error message when script is not run
  as root (Closes: #619390)
* debian/denyhosts.init:
  - Added support for the "status" action (Closes: #547036)
  - Fixed messages in "restart" and "force-reload" actions which were being
    output incorrectly.
* Updated Vcs tags to recommended format
* Added a patch to correct /bin/env to /usr/bin/env
* debian/denyhosts.doc-base: Added to register FAQ with doc-base
* Fixed postinst script to make /var/lib/denyhosts 0750 instead of 0200

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/env python
 
2
#
 
3
############################################################################
 
4
# this script will read the /etc/passwd file and extract usernames
 
5
# that have one of the RESTRICTED_SHELLS.  The ouput of this
 
6
# script is a list of these restricted usernames suitable for
 
7
# use in WORK_DIR/restricted-usernames
 
8
#
 
9
# such as: python restricted_from_passwd > $WORK_DIR/restricted-usernames
 
10
# where $WORK_DIR is your DenyHosts WORK_DIR parameter
 
11
#
 
12
############################################################################
 
13
 
 
14
RESTRICTED_SHELLS = ("/sbin/nologin",
 
15
                     "/sbin/shutdown",
 
16
                     "/sbin/halt")
 
17
 
 
18
from pwd import getpwall
 
19
 
 
20
passwd = getpwall()
 
21
 
 
22
usernames = []
 
23
for pw_tuple in passwd:
 
24
    if pw_tuple[6] in RESTRICTED_SHELLS:
 
25
        usernames.append(pw_tuple[0])
 
26
 
 
27
usernames.sort()
 
28
for username in usernames:
 
29
    print username
 
30
    
 
31