[Checkins] SVN: cipher.googlepam/trunk/ The add-google-users script now reads the pam_google config file.

Marius Gedminas cvs-admin at zope.org
Mon Oct 8 12:20:28 UTC 2012


Log message for revision 127930:
  The add-google-users script now reads the pam_google config file.

Changed:
  U   cipher.googlepam/trunk/CHANGES.txt
  U   cipher.googlepam/trunk/src/cipher/googlepam/addusers.py

-=-
Modified: cipher.googlepam/trunk/CHANGES.txt
===================================================================
--- cipher.googlepam/trunk/CHANGES.txt	2012-10-08 12:20:16 UTC (rev 127929)
+++ cipher.googlepam/trunk/CHANGES.txt	2012-10-08 12:20:24 UTC (rev 127930)
@@ -4,8 +4,13 @@
 1.4.0 (unreleased)
 ------------------
 
-- Add a space after the prompt.
+- Add a space after the PAM prompt.
 
+- The add-google-users script now reads the pam_google config file to get the
+  domain, username, password and group.  You can also use -C/--config-file to
+  specify a different config file.
+
+
 1.3.0 (2012-04-24)
 ------------------
 
@@ -22,11 +27,13 @@
 
 - The package is ready for public release.
 
+
 1.2.0 (2012-04-17)
 ------------------
 
 - Do not fail if the username already exists.
 
+
 1.1.0 (2012-04-17)
 ------------------
 

Modified: cipher.googlepam/trunk/src/cipher/googlepam/addusers.py
===================================================================
--- cipher.googlepam/trunk/src/cipher/googlepam/addusers.py	2012-10-08 12:20:16 UTC (rev 127929)
+++ cipher.googlepam/trunk/src/cipher/googlepam/addusers.py	2012-10-08 12:20:24 UTC (rev 127930)
@@ -14,8 +14,10 @@
 """Add Google users to system."""
 import logging
 import optparse
+import os
 import subprocess
 import sys
+import ConfigParser
 
 from gdata.apps.groups.service import GroupsService
 from gdata.apps.service import AppsService
@@ -25,6 +27,9 @@
 
 log = logging.getLogger("add-google-users")
 
+DEFAULT_CONFIG = os.path.join(os.path.dirname(__file__), 'googlepam.conf')
+SECTION_NAME = 'googlepam'
+
 ADDUSER_CMD = ('adduser --firstuid 2000 --disabled-password '
                '--gecos "%(full_name)s" %(user_name)s')
 ADDADMIN_CMD = 'usermod -a -G %(admin-group)s %(user_name)s'
@@ -106,6 +111,11 @@
         do(ADDADMIN_CMD %user, dry_run=options.dry_run)
 
 parser.add_option(
+    '-C', '--config-file', action='store',
+    dest='config_file', default=DEFAULT_CONFIG,
+    help='The file containing pam_google configuration.')
+
+parser.add_option(
     '-d', '--domain', action='store', dest='domain',
     help='The Google domain in which the users belong.')
 
@@ -119,12 +129,12 @@
 
 parser.add_option(
     '-g', '--group', action='store',
-    dest='group', default='security',
+    dest='group',
     help='The group all users belong to.')
 
 parser.add_option(
     '-a', '--admin-group', action='store',
-    dest='admin_group', default='admin',
+    dest='admin_group',
     help='The group to which the user will be added.')
 
 parser.add_option(
@@ -138,12 +148,12 @@
     help='A flag, when set, does not execute commands.')
 
 parser.add_option(
-    "-q","--quiet", action="store_true",
+    "-q", "--quiet", action="store_true",
     dest="quiet", default=False,
     help="When specified, no messages are displayed.")
 
 parser.add_option(
-    "-v","--verbose", action="store_true",
+    "-v", "--verbose", action="store_true",
     dest="verbose", default=False,
     help="When specified, debug information is created.")
 
@@ -160,4 +170,25 @@
     if options.quiet:
         log.setLevel(logging.FATAL)
 
+    if options.config_file:
+        config = ConfigParser.ConfigParser()
+        config.read(options.config_file)
+        if not options.domain and config.has_option(SECTION_NAME, 'domain'):
+            options.domain = config.get(SECTION_NAME, 'domain')
+        if not options.user and config.has_option(SECTION_NAME, 'admin-username'):
+            options.user = config.get(SECTION_NAME, 'admin-username')
+        if not options.password and config.has_option(SECTION_NAME, 'admin-password'):
+            options.password = config.get(SECTION_NAME, 'admin-password')
+        if not options.group and config.has_option(SECTION_NAME, 'group'):
+            options.group = config.get(SECTION_NAME, 'group')
+
+    if not options.domain:
+        parser.error("please specify a Google-managed domain")
+    if not options.user:
+        parser.error("please specify the Google domain admin username")
+    if not options.password:
+        parser.error("please specify the Google domain admin password")
+    if not options.group:
+        parser.error("please specify the Google group")
+
     addusers(options)



More information about the checkins mailing list