[Freeipa-devel] [PATCH] Remove multi-value set/add in ipa-usermod

Karl MacMillan kmacmill at redhat.com
Wed Oct 31 20:56:47 UTC 2007


# HG changeset patch
# User "Karl MacMillan <kmacmill at redhat.com>"
# Date 1193864203 14400
# Node ID 6b23756241f05444a54a339aaf5384fc96ad6999
# Parent  5c364bb6ca88b0f4d8c770f97c4d3a81befd7985
Remove multi-value set/add in ipa-usermod.

Calling --add multiple times will accomplish the same
thing without the need for handling splits on ",".

diff -r 5c364bb6ca88 -r 6b23756241f0 ipa-admintools/ipa-usermod
--- a/ipa-admintools/ipa-usermod	Wed Oct 31 16:36:56 2007 -0400
+++ b/ipa-admintools/ipa-usermod	Wed Oct 31 16:56:43 2007 -0400
@@ -31,7 +31,7 @@ import ldap
 import ldap
 
 def usage():
-    print "ipa-usermod [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] [-s|--shell STRING] [--add attribute=value(,value1,..,valuen)] [--del attribute] [--set attribute=value(,value1,..,valuen)] user"
+    print "ipa-usermod [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] [-s|--shell STRING] [--add attribute=value] [--del attribute] [--set attribute=value] user"
     sys.exit(1)
 
 def set_add_usage(which):
@@ -50,7 +50,7 @@ def parse_options():
     parser.add_option("-s", "--shell", dest="shell",
                       help="Set user's login shell to shell")
     parser.add_option("--add", dest="addattr",
-                      help="Adds an attribute or values to that attribute, attr=value(,value1,value2)",
+                      help="Adds an attribute or values to that attribute, attr=value",
                       action="append")
     parser.add_option("--del", dest="delattr",
                       help="Remove an attribute", action="append")
@@ -167,6 +167,7 @@ def main():
                     print "Must be letters, numbers, spaces or '"
                 else:
                     cont = True
+
         cont = False
         if not options.directory:
             while (cont != True):
@@ -210,9 +211,8 @@ def main():
             if len(s) != 2:
                 set_add_usage("set")
                 sys.exit(1)
-            (attr,value) = s            
-            values = value.split(',')
-            user.setValue(attr, values)
+            (attr,value) = s   
+            user.setValue(attr, value)
 
     if options.addattr:
         for a in options.addattr:
@@ -221,13 +221,12 @@ def main():
                 set_add_usage("add")
                 sys.exit(1)
             (attr,value) = a      
-            values = value.split(',')
             cvalue = user.getValue(attr)
             if cvalue:
                 if isinstance(cvalue,str):
                     cvalue = [cvalue]
-                values = cvalue + values
-            user.setValue(attr, values)
+                value = cvalue + [value]
+            user.setValue(attr, value)
 
 
     try:




More information about the Freeipa-devel mailing list