Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 307203 Details for
Bug 449006
ipa-adduser options
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
add options to ipa-adduser and ipa-addgroup
freeipa-33-options.patch (text/x-patch), 8.92 KB, created by
Rob Crittenden
on 2008-05-30 14:27:11 UTC
(
hide
)
Description:
add options to ipa-adduser and ipa-addgroup
Filename:
MIME Type:
Creator:
Rob Crittenden
Created:
2008-05-30 14:27:11 UTC
Size:
8.92 KB
patch
obsolete
>From b1ebaea67c7dce63eae98c081982449c95b1738a Mon Sep 17 00:00:00 2001 >From: Rob Crittenden <rcritten@redhat.com> >Date: Fri, 30 May 2008 10:19:08 -0400 >Subject: [PATCH] Add two now options, --addattr and --setattr, to allow arbitrary attributes > to be added and set when a new user or group is created. > >Make the user password not mandatory and add new option, -P, to prompt >for a password interactively. > >449006 >--- > ipa-admintools/ipa-addgroup | 34 ++++++++++++++++++++++++++++++++- > ipa-admintools/ipa-adduser | 38 +++++++++++++++++++++++++++++++++++- > ipa-admintools/man/ipa-addgroup.1 | 6 +++++ > ipa-admintools/man/ipa-adduser.1 | 13 +++++++++++- > 4 files changed, 87 insertions(+), 4 deletions(-) > >diff --git a/ipa-admintools/ipa-addgroup b/ipa-admintools/ipa-addgroup >index fea8428..89f7630 100644 >--- a/ipa-admintools/ipa-addgroup >+++ b/ipa-admintools/ipa-addgroup >@@ -43,9 +43,12 @@ error was: > sys.exit(1) > > def usage(): >- print "ipa-addgroup [-d|--description STRING] [-g|--gid GID] [-v|--verbose] group" >+ print "ipa-addgroup [-d|--description STRING] [-g|--gid GID] [--addattr attribute=value] [--setattr attribute=value] [-v|--verbose] group" > sys.exit(1) > >+def set_add_usage(which): >+ print "%s option usage: --%s NAME=VALUE" % (which, which) >+ > def parse_options(): > parser = OptionParser() > parser.add_option("-d", "--description", dest="desc", >@@ -54,6 +57,12 @@ def parse_options(): > help="The gid to use for this group. If not included one is automatically set.") > parser.add_option("-v", "--verbose", action="store_true", dest="verbose", > help="Verbose output of the XML-RPC connection") >+ parser.add_option("--addattr", dest="addattr", >+ help="Adds an attribute or values to that attribute, attr=value", >+ action="append") >+ parser.add_option("--setattr", dest="setattr", >+ help="Set an attribute, dropping any existing values that may exist", >+ action="append") > parser.add_option("--usage", action="store_true", > help="Program usage") > >@@ -107,6 +116,29 @@ def main(): > group.setValue('cn', cn) > group.setValue('description', desc) > >+ if options.setattr: >+ for s in options.setattr: >+ s = s.split('=') >+ if len(s) != 2: >+ set_add_usage("set") >+ sys.exit(1) >+ (attr,value) = s >+ group.setValue(attr, value) >+ >+ if options.addattr: >+ for a in options.addattr: >+ a = a.split('=') >+ if len(a) != 2: >+ set_add_usage("add") >+ sys.exit(1) >+ (attr,value) = a >+ cvalue = group.getValue(attr) >+ if cvalue: >+ if isinstance(cvalue,str): >+ cvalue = [cvalue] >+ value = cvalue + [value] >+ group.setValue(attr, value) >+ > client = ipaclient.IPAClient(verbose=options.verbose) > client.add_group(group) > print cn + " successfully added" >diff --git a/ipa-admintools/ipa-adduser b/ipa-admintools/ipa-adduser >index 131c8a7..09f5c75 100644 >--- a/ipa-admintools/ipa-adduser >+++ b/ipa-admintools/ipa-adduser >@@ -44,9 +44,12 @@ error was: > sys.exit(1) > > def usage(): >- print "ipa-adduser [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] [-s|--shell] [-g|--groups] [-k|krb-principal [-M|mailAddress] [-v|--verbose] user" >+ print "ipa-adduser [-c|--gecos STRING] [-d|--directory STRING] [-f|--firstname STRING] [-l|--lastname STRING] [-s|--shell] [-g|--groups] [-k|krb-principal [-M|mailAddress] [--addattr attribute=value] [--setattr attribute=value] [-v|--verbose] user" > sys.exit(1) > >+def set_add_usage(which): >+ print "%s option usage: --%s NAME=VALUE" % (which, which) >+ > def parse_options(): > parser = OptionParser() > parser.add_option("-c", "--gecos", dest="gecos", >@@ -59,6 +62,8 @@ def parse_options(): > help="User's last name") > parser.add_option("-p", "--password", dest="password", > help="Set user's password") >+ parser.add_option("-P", dest="password_prompt", action="store_true", >+ help="Prompt on the command-line for the user's password") > parser.add_option("-s", "--shell", dest="shell", > help="Set user's login shell to shell") > parser.add_option("-G", "--groups", dest="groups", >@@ -71,6 +76,12 @@ def parse_options(): > help="Program usage") > parser.add_option("-v", "--verbose", action="store_true", dest="verbose", > help="Verbose output of the XML-RPC connection") >+ parser.add_option("--addattr", dest="addattr", >+ help="Adds an attribute or values to that attribute, attr=value", >+ action="append") >+ parser.add_option("--setattr", dest="setattr", >+ help="Set an attribute, dropping any existing values that may exist", >+ action="append") > > args = ipa.config.init_config(sys.argv) > options, args = parser.parse_args(args) >@@ -145,7 +156,7 @@ def main(): > print "Username is required and may only include letters and numbers" > return 1 > >- if not options.password: >+ if options.password_prompt: > while (match != True): > password = getpass.getpass(" Password: ") > confirm = getpass.getpass(" Password (again): ") >@@ -221,6 +232,29 @@ def main(): > if shell: > user.setValue('loginshell', shell) > >+ if options.setattr: >+ for s in options.setattr: >+ s = s.split('=') >+ if len(s) != 2: >+ set_add_usage("set") >+ sys.exit(1) >+ (attr,value) = s >+ user.setValue(attr, value) >+ >+ if options.addattr: >+ for a in options.addattr: >+ a = a.split('=') >+ if len(a) != 2: >+ set_add_usage("add") >+ sys.exit(1) >+ (attr,value) = a >+ cvalue = user.getValue(attr) >+ if cvalue: >+ if isinstance(cvalue,str): >+ cvalue = [cvalue] >+ value = cvalue + [value] >+ user.setValue(attr, value) >+ > client = ipaclient.IPAClient(verbose=options.verbose) > client.add_user(user) > >diff --git a/ipa-admintools/man/ipa-addgroup.1 b/ipa-admintools/man/ipa-addgroup.1 >index 5cc417d..03fee1b 100644 >--- a/ipa-admintools/man/ipa-addgroup.1 >+++ b/ipa-admintools/man/ipa-addgroup.1 >@@ -34,6 +34,12 @@ Set the description of the group to \fIdescription\fR. > Set the gid for this group to \fIgid\fR. > If this option is not present, one is created automatically > by \fBfreeIPA\fR. >+.TP >+\fB\-\-addattr\fR \fIattr=value\fR >+Adds \fIvalue\fR to attribute \fIattr\fR. Attributes set this way are done after other options. If an attribute is listed more than once or already exists in the entry, it is considered a multi\-valued attribute and a list of the values is created. >+.TP >+\fB\-\-setattr\fR \fIattr=value\fR >+Set attribute \fIattr\fR to \fIvalue\fR. Any existing value will be replaced with \fIvalue\fR. > .PP > The group name and description are mandatory fields. If either of these are not included on the command line you will be asked interactively. > >diff --git a/ipa-admintools/man/ipa-adduser.1 b/ipa-admintools/man/ipa-adduser.1 >index abf1485..b08fe70 100644 >--- a/ipa-admintools/man/ipa-adduser.1 >+++ b/ipa-admintools/man/ipa-adduser.1 >@@ -46,6 +46,9 @@ Set user's last name to \fIfamilyName\fR. > \fB\-p\fR, \fB\-\-password\fR=\fIpassword\fR > Set user's password to \fIpassword\fR. > .TP >+\fB\-P\fR >+Prompt for the user's password. >+.TP > \fB\-s\fR, \fB\-\-shell\fR=\fIshell\fR > Set the user's login shell to \fIshell\fR. > If this option is not present, a default specified by the >@@ -62,8 +65,16 @@ By default the principal is set to \fBuser\fR. > .TP > \fB\-M\fR, \fB\-\-mailAddress\fR=\fImail\fR > Set this user's e\-mail address to \fImail\fR. >+.TP >+\fB\-\-addattr\fR \fIattr=value\fR >+Adds \fIvalue\fR to attribute \fIattr\fR. Attributes set this way are done after other options. If an attribute is listed more than once or already exists in the entry, it is considered a multi\-valued attribute and a list of the values is created. >+.TP >+\fB\-\-setattr\fR \fIattr=value\fR >+Set attribute \fIattr\fR to \fIvalue\fR. Any existing value will be replaced with \fIvalue\fR. > .PP >-The mandatory fields are: user, first name, last name and password. If any of these are not included on the command line you will be asked interactively. >+The mandatory fields are: user, first name and last name. If any of these are not included on the command line you will be asked interactively. >+ >+The password is asked interactively if not passed on the command\-line but it isn't mandatory. Leaving both values blank will leave the password unset on the account. > > If no options are passed then all questions are asked. > .SH "EXIT STATUS" >-- >1.5.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 449006
: 307203