[sysadmin-bin] Don't allow the usage of the cleanup script on hosts different than git.gnome.org



commit 1024c90952ae4c13e183680b8110668a6cec92a2
Author: Andrea Veri <av gnome org>
Date:   Tue Mar 25 00:29:54 2014 +0100

    Don't allow the usage of the cleanup script on hosts different than git.gnome.org

 cleanup-inactive-ldap-accounts.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/cleanup-inactive-ldap-accounts.py b/cleanup-inactive-ldap-accounts.py
index 6870540..10fc987 100755
--- a/cleanup-inactive-ldap-accounts.py
+++ b/cleanup-inactive-ldap-accounts.py
@@ -7,6 +7,7 @@ import calendar
 import time
 import ldap
 import ldap.filter
+import socket
 from optparse import OptionParser
 
 LDAP_USER_BASE='ou=people,dc=gnome,dc=org'
@@ -21,6 +22,10 @@ parser.add_option("--verbose",
 
 (options, args) = parser.parse_args()
 
+if socket.gethostname() != 'git.gnome.org':
+    print ("You are not allowed to run this script on a different host than git.gnome.org, exiting...", 
end='')
+    sys.exit(1)
+
 infrastructure_folders = 'archive', 'cgit', 'empty-description', 'repositories.txt', 'repositories.doap'
 repositories = filter( lambda f: not f.startswith(infrastructure_folders), os.listdir('/git'))
 last_pushed_times = {}
@@ -97,7 +102,7 @@ ftpbasic_users = (get_uids_from_group('ftpbasic'))
 for gnomecvs_user in gnomecvs_users:
     if not user_is_current(gnomecvs_user):
        if options.verbose:
-                   print ("Removing user %s from gnomecvs" % gnomecvs_user, end='\n') 
+                   print ("Removing user %s from gnomecvs" % gnomecvs_user, end='\n')
         remove_members = [ (ldap.MOD_DELETE, 'memberUid','%s' % gnomecvs_user) ]
         l.modify_s('cn=gnomecvs,ou=groups,dc=gnome,dc=org', remove_members)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]