[fedfs-utils] [PATCH 5/9] nsdbc: Specify manadatory arguments as positional parameters (nsdb-*-fsl)

Chuck Lever chuck.lever at oracle.com
Mon Nov 28 09:33:49 PST 2011


We're trying to keep the Solaris and Linux administrative interfaces
roughly the same, to make it easy for admins to use either one without
separate learning curves.

Rob Thurlow mentions that Solaris user interface guidelines require
that mandatory command line options must be specified as positional
parameters rather than by using dash switches.  The only reason I used
dash switches for all the options was sheer laziness.

This commit updates the NSDB client tools that are concerned with FSL
records.

Signed-off-by: Chuck Lever <chuck.lever at oracle.com>
---

 doc/man/nsdb-create-fsl.8   |  128 +++++++++++++++++++------------------------
 doc/man/nsdb-delete-fsl.8   |   89 ++++++++++++++----------------
 doc/man/nsdb-update-fsl.8   |   98 ++++++++++++++-------------------
 src/nsdbc/nsdb-create-fsl.c |   78 ++++++++++++--------------
 src/nsdbc/nsdb-delete-fsl.c |   47 +++++++++-------
 src/nsdbc/nsdb-update-fsl.c |   47 +++++++---------
 6 files changed, 224 insertions(+), 263 deletions(-)

diff --git a/doc/man/nsdb-create-fsl.8 b/doc/man/nsdb-create-fsl.8
index 734723e..24f29f6 100644
--- a/doc/man/nsdb-create-fsl.8
+++ b/doc/man/nsdb-create-fsl.8
@@ -35,20 +35,16 @@ nsdb-create-fsl \- create a fileset location (FSL) record on an NSDB
 .IR nce ]
 .RB [ \-l
 .IR nsdbname ]
+.RB [ \-o
+.IR serverport ]
 .RB [ \-r
 .IR nsdbport ]
 .RB [ \-w
 .IR bindpw ]
-.B \-u
 .I fsn-uuid
-.B \-x
 .I fsl-uuid
-.B \-s
 .I servername
-.RB [ \-o
-.IR serverport ]
-.RB [ \-p
-.IR serverpath ]
+.I serverpath
 .SH INTRODUCTION
 RFC 5716 introduces the Federated File System (FedFS, for short).
 FedFS is an extensible standardized mechanism
@@ -72,8 +68,8 @@ about file sets contained in a FedFS domain name space.
 .SH DESCRIPTION
 The
 .BR nsdb-create-fsl (8)
-command is part of a collection of low-level single-use programs that are
-intended for testing the NSDB protocol or for use in scripts.
+command is part of a collection of low-level single-use programs
+that is intended for testing the NSDB protocol or for use in scripts.
 This command creates a FedFS
 .I fileset location
 (FSL) record on an NSDB.
@@ -86,47 +82,49 @@ The meaning of these items is described in more detail in
 .BR fedfs (7).
 .P
 FSLs are stored in records on an NSDB.
-These records are stored as children of FSN records.
+FSL records are stored as children of FSN records.
 Replicas of these records can exist on more than one LDAP server.
 .P
 The
 .BR nsdb-create-fsl (8)
 command creates an FSL record on the named NSDB.
-It does not create parent FSN records;
-to create FSN records, use
-.BR nsdb-create-fsn (8).
-It does not create a replica of a fileset;
-to create a fileset replica,
+It does not create parent FSN records.
+To create FSN records, use the
+.BR nsdb-create-fsn (8)
+command.
+It does not create a replica of a fileset.
+To create a fileset replica,
 use appropriate file server administrative commands.
-.SH OPTIONS
-.IP "\fB\-d, \-\-debug"
-Specifies that debugging messages be produced during operation.
-.IP "\fB\-x, \-\-fsluuid=\fIuuid\fP"
-Specifies the FSL UUID to insert into the new FSL record.
-If the
-.B -x
-option is not specified, the
-.BR nsdb-create-fsl (8)
+.P
+This command has four positional parameters.  The first parameter
+specifies the target FSN UUID.  If a record for this FSN does not
+already exist, the
+.BR nsdb-create-fsn (8)
 command fails.
-.IP "\fB\-u, \-\-fsnuuid=\fIuuid\fP"
-Specifies the FSN UUID to insert into the new FSL record.
-If the
-.B -u
-option is not specified,
-or an FSN record for this FSN UUID does not already exist
-on the specified NSDB, the
-.BR nsdb-create-fsl (8)
+The second parameter specifies the
+UUID of the new FSL record.  If a record for this FSL already
+exists, the
+.BR nsdb-create-fsn (8)
 command fails.
+.P
+The third parameter specifies the
+hostname of the fileserver where the fileset replica resides.
+The fourth parameter specifies the export path of that replica.
+The
+.BR nsdb-create-fsn (8)
+command does not verify that a replica exists at that location.
+.SH OPTIONS
+.IP "\fB\-d, \-\-debug"
+Enables debugging messages during operation.
 .IP "\fB\-?, \-\-help"
-Prints an
+Displays
 .BR nsdb-create-fsl (8)
-version and usage message on
-.IR stderr ,
-then exits.
+version information and a usage message on
+.IR stderr .
 .IP "\fB-D, \-\-binddn=\fIbind-distinguished-name\fP"
-Specifies a distinguished name of an entity used to bind to this LDAP server.
-If the
-.B -D
+Specifies a distinguished name of an entity used to bind to the LDAP server
+where the NSDB resides.  If the
+.B \-\-binddn
 option is not specified,
 the value of the FEDFS_NSDB_ADMIN environment variable is consulted.
 If this variable is not set,
@@ -137,10 +135,10 @@ of the server's DIT, the
 .BR nsdb-create-fsl (8)
 command fails.
 .IP "\fB-e, \-\-nce=\fINSDB-container-entry-distinguished-name\fP"
-Specifies the distinguished name of the NSDB container entry
+Specifies the distinguished name of the NSDB Container Entry
 under which this FSL record is to be created.
 If the
-.B -e
+.B \-\-nce
 option is not specified,
 the value of the FEDFS_NSDB_NCE environment variable is consulted.
 If this variable is not set,
@@ -151,48 +149,34 @@ command fails.
 .IP "\fB\-l, \-\-nsdbname=\fINSDB-hostname\fP"
 Specifies the hostname of the NSDB where the new FSL record should reside.
 If the
-.B -l
+.B \-\-nsdbname
 option is not specified,
 the value of the FEDFS_NSDB_HOST environment variable is consulted.
 If the variable is not set and the
-.B -l
+.B \-\-nsdbname
 option is not specified, the
 .BR nsdb-create-fsl (8)
 command fails.
 .IP "\fB\-r, \-\-nsdbport=\fINSDB-port\fP"
 Specifies the IP port of the NSDB where the new FSL record should reside.
 If the
-.B -r
+.B \-\-nsdbport
 option is not specified,
 the value of the FEDFS_NSDB_PORT environment variable is consulted.
 The default value if the variable is not set is 389.
-.IP "\fB\-s, \-\-servername=\fIfile-server-hostname\fP"
-Specifies the hostname of the file server a client should mount to access
-this fileset location.
-If the
-.B -s
-option is not specified, the
-.BR nsdb-create-fsl (8)
-command fails.
-.IP "\fB\-p, \-\-serverpath=\fIserver-export-path\fP"
-Specifies the export path a client should mount to access this fileset location.
-If the
-.B -p
-option is not specified, the
-.BR nsdb-create-fsl (8)
-command fails.
 .IP "\fB\-o, \-\-serverport=\fIfile-server-port\fP"
 Specifies the IP port of the file server a client should mount to access
 this fileset location.
 The default value if this option is not specified is 2049.
 .IP "\fB\-w, \-\-bindpw=\fIbinddn-password\fP"
-Specifies the password used for simple authentication to this LDAP server.
+Specifies the password used for simple authentication to the LDAP server
+where the NSDB resides.
 If the
-.B -w
+.B \-\-bindpw
 option is not specified,
 the value of the FEDFS_NSDB_PASSWD environment variable is consulted.
 If the variable is not set and the
-.B -w
+.B \-\-bindpw
 option is not specified, the
 .BR nsdb-create-fsl (8)
 command asks for a password on
@@ -307,28 +291,28 @@ The new FSN looks like:
 .sp
 	FSN UUID: 8e246ddc-7b46-11e0-8252-000c297fd679
 .br
-	NSDB: ldap.example.net:389
+	NSDB: nsdb.example.net:389
 .sp
 .RE
 Further suppose the NSDB
-.I ldap.example.net:389
-has an NSDB container entry whose distinguished name is
+.I nsdb.example.net:389
+has an NSDB Container Entry whose distinguished name is
 .IR o=fedfs ,
 and that an FSN record for the above UUID already exists.
 Finally, a replica of this fileset exists at
-.IR fileserver.example.net:/path .
+.IR fileserver.example.net:/export/path .
 To create a corresponding FSL record, you might use:
 .RS
 .sp
 $ nsdb-create-fsl -D cn=Manager -e o=fedfs \\
 .br
-	-u 8e246ddc-7b46-11e0-8252-000c297fd679
+	-l nsdb.example.net \\
 .br
-	-x 323c5068-7c11-11e0-8d38-000c297fd679
+	8e246ddc-7b46-11e0-8252-000c297fd679 \\
 .br
-	-l ldap.example.net
+	323c5068-7c11-11e0-8d38-000c297fd679 \\
 .br
-	-s fileserver.example.net -p path
+	fileserver.example.net /export/path
 .br
 Enter NSDB password:
 .br
@@ -338,7 +322,7 @@ Successfully created FSL record
 .sp
 .RE
 A new unpopulated NFS FSL record is created on
-.I ldap.example.net:389
+.I nsdb.example.net:389
 as a child of the FSN record with a distinguished name of
 .RS
 .sp
@@ -352,7 +336,7 @@ or
 To update individual attributes in the new FSL record, use
 .BR nsdb-update-fsl (8).
 .SH SECURITY
-Modify access to the LDAP's DIT is required to create a new FSL record.
+Permission to modify the LDAP's DIT is required to create a new FSL record.
 The
 .BR nsdb-create-fsl (8)
 command must bind as an entity permitted to modify the DIT
diff --git a/doc/man/nsdb-delete-fsl.8 b/doc/man/nsdb-delete-fsl.8
index 2d0516c..f3229e0 100644
--- a/doc/man/nsdb-delete-fsl.8
+++ b/doc/man/nsdb-delete-fsl.8
@@ -39,9 +39,6 @@ nsdb-delete-fsl \- delete a fileset location (FSL) record from an NSDB
 .IR nsdbport ]
 .RB [ \-w
 .IR bindpw ]
-.B \-u
-.I fsn-uuid
-.B \-x
 .I fsl-uuid
 .SH INTRODUCTION
 RFC 5716 introduces the Federated File System (FedFS, for short).
@@ -66,8 +63,8 @@ about file sets contained in a FedFS domain name space.
 .SH DESCRIPTION
 The
 .BR nsdb-delete-fsl (8)
-command is part of a collection of low-level single-use programs that are
-intended for testing the NSDB protocol or for use in scripts.
+command is part of a collection of low-level single-use programs
+that is intended for testing the NSDB protocol or for use in scripts.
 This command deletes a FedFS
 .I fileset location
 (FSL) record from an NSDB.
@@ -86,41 +83,36 @@ Replicas of these records can exist on more than one LDAP server.
 The
 .BR nsdb-delete-fsl (8)
 command removes an FSL record from the named NSDB.
-It does not remove parent FSN records;
-to remove FSN records, use
-.BR nsdb-delete-fsn (8).
-It does not remove a replica of a fileset;
-to remove fileset replicas,
+It does not remove parent FSN records.
+To remove FSN records, use the
+.BR nsdb-delete-fsn (8)
+command.
+It does not remove a replica of a fileset.
+To remove fileset replicas,
 use appropriate file server administrative commands.
+.P
+This command has two positional parameters.
+The first parameter specifies the target FSN UUID.
+If a record for this FSN does not already exist, the
+.BR nsdb-delete-fsn (8)
+command  fails.
+The second  parameter specifies the UUID of the FSL record to remove.
+If a record for this FSL does not exist, the
+.B nsdb-delete-fsn (8)
+command fails.
 .SH OPTIONS
 .IP "\fB\-d, \-\-debug"
-Specifies that debugging messages be produced during operation.
-.IP "\fB\-x, \-\-fsluuid=\fIuuid\fP"
-Specifies the FSL UUID of the doomed FSL record.
-If the
-.B -x
-option is not specified, the
-.BR nsdb-delete-fsl (8)
-command fails.
-.IP "\fB\-u, \-\-fsnuuid=\fIuuid\fP"
-Specifies the FSN UUID of the doomed FSL record's parent FSN record.
-If the
-.B -u
-option is not specified,
-or an FSN record for this FSN UUID does not already exist
-on the specified NSDB, the
-.BR nsdb-delete-fsl (8)
-command fails.
+Enables debugging messages during operation.
 .IP "\fB\-?, \-\-help"
-Prints an
+Displays
 .BR nsdb-delete-fsl (8)
-version and usage message on
-.IR stderr ,
-then exits.
+version information and a usage message on
+.IR stderr .
 .IP "\fB-D, \-\-binddn=\fIbind-distinguished-name\fP"
-Specifies a distinguished name of an entity used to bind to this LDAP server.
+Specifies a distinguished name of an entity used to bind to the LDAP server
+where the NSDB resides.
 If the
-.B -D
+.B \-\-binddn
 option is not specified,
 the value of the FEDFS_NSDB_ADMIN environment variable is consulted.
 If this variable is not set,
@@ -131,10 +123,10 @@ of the server's DIT, the
 .BR nsdb-delete-fsl (8)
 command fails.
 .IP "\fB-e, \-\-nce=\fINSDB-container-entry-distinguished-name\fP"
-Specifies the distinguished name of the NSDB container entry
+Specifies the distinguished name of the NSDB Container Entry
 under which this FSL is to be created.
 If the
-.B -e
+.B \-\-nce
 option is not specified,
 the value of the FEDFS_NSDB_NCE environment variable is consulted.
 If this variable is not set,
@@ -145,29 +137,30 @@ command fails.
 .IP "\fB\-l, \-\-nsdbname=\fINSDB-hostname\fP"
 Specifies the hostname of the NSDB where the new FSL record should reside.
 If the
-.B -l
+.B \-\-nsdbname
 option is not specified,
 the value of the FEDFS_NSDB_HOST environment variable is consulted.
 If the variable is not set and the
-.B -l
+.B \-\-nsdbname
 option is not specified, the
 .BR nsdb-delete-fsl (8)
 command fails.
 .IP "\fB\-r, \-\-nsdbport=\fINSDB-port\fP"
 Specifies the IP port of the NSDB where the new FSL record should reside.
 If the
-.B -r
+.B \-\-nsdbport
 option is not specified,
 the value of the FEDFS_NSDB_PORT environment variable is consulted.
 The default value if the variable is not set is 389.
 .IP "\fB\-w, \-\-bindpw=\fIbinddn-password\fP"
-Specifies the password used for simple authentication to this LDAP server.
+Specifies the password used for simple authentication to the LDAP server
+where the NSDB resides.
 If the
-.B -w
+.B \-\-bindpw
 option is not specified,
 the value of the FEDFS_NSDB_PASSWD environment variable is consulted.
 If the variable is not set and the
-.B -w
+.B \-\-bindpw
 option is not specified, the
 .BR nsdb-delete-fsl (8)
 command asks for a password on
@@ -281,12 +274,12 @@ FedFS domain and that you have an FSN that looks like:
 .sp
 	FSN UUID: 8e246ddc-7b46-11e0-8252-000c297fd679
 .br
-	NSDB: ldap.example.net:389
+	NSDB: nsdb.example.net:389
 .sp
 .RE
 Further suppose the NSDB
-.I ldap.example.net:389
-has an NSDB container entry whose distinguished name is
+.I nsdb.example.net:389
+has an NSDB Container Entry whose distinguished name is
 .IR o=fedfs .
 The replica of this fileset that exists at
 .I fileserver.example.net:/path
@@ -297,11 +290,11 @@ To delete the corresponding FSL record, you might use:
 .sp
 $ nsdb-delete-fsl -D cn=Manager -e o=fedfs \\
 .br
-	-u 8e246ddc-7b46-11e0-8252-000c297fd679
+	-l nsdb.example.net \\
 .br
-	-x 323c5068-7c11-11e0-8d38-000c297fd679
+	8e246ddc-7b46-11e0-8252-000c297fd679
 .br
-	-l ldap.example.net
+	323c5068-7c11-11e0-8d38-000c297fd679
 .br
 Enter NSDB password:
 .br
@@ -314,7 +307,7 @@ The FSL record for the specified replica is removed,
 leaving possibly other FSL records for this fileset,
 and leaving the parent FSN record intact.
 .SH SECURITY
-Modify access to the LDAP's DIT is required to delete an FSL record.
+Permission to modify the LDAP's DIT is required to delete an FSL record.
 The
 .BR nsdb-delete-fsl (8)
 command must bind as an entity permitted to modify the DIT
diff --git a/doc/man/nsdb-update-fsl.8 b/doc/man/nsdb-update-fsl.8
index 461c48e..87db8f3 100644
--- a/doc/man/nsdb-update-fsl.8
+++ b/doc/man/nsdb-update-fsl.8
@@ -39,14 +39,10 @@ nsdb-update-fsl \- update attributes of a fileset location (FSL) record
 .IR nsdbport ]
 .RB [ \-w
 .IR bindpw ]
-.B \-u
-.I fsn-uuid
-.B \-x
-.I fsl-uuid
-.B \-a
-.I attribute
 .RB [ \-v
 .IR value ]
+.I fsl-uuid
+.I attribute
 .SH INTRODUCTION
 RFC 5716 introduces the Federated File System (FedFS, for short).
 FedFS is an extensible standardized mechanism
@@ -70,8 +66,8 @@ about file sets contained in a FedFS domain name space.
 .SH DESCRIPTION
 The
 .BR nsdb-update-fsl (8)
-command is part of a collection of low-level single-use programs that are
-intended for testing the NSDB protocol or for use in scripts.
+command is part of a collection of low-level single-use programs
+that is intended for testing the NSDB protocol or for use in scripts.
 This command modifies attributes contained in
 .I fileset location
 (FSL) records on an NSDB.
@@ -90,11 +86,12 @@ Replicas of these records can exist on more than one LDAP server.
 The
 .BR nsdb-update-fsl (8)
 command can modify certain attributes of an FSL record.
-It does not create FSL records;
-to create FSL records, use
-.BR nsdb-create-fsl (8).
-It does not update base FSL attributes, such as the servername;
-to modify those attributes, a new FSL record must be created.
+It does not create FSL records.
+To create FSL records, use the
+.BR nsdb-create-fsl (8)
+command.
+It does not update base FSL attributes, such as the servername.
+To modify those attributes, a new FSL record must be created.
 .P
 The
 .IR fedfsAnnotation " and"
@@ -103,42 +100,28 @@ attributes are multi-value attributes.
 To modify them, use
 .BR nsdb-annotate "(8) and"
 .BR nsdb-describe "(8), respectively."
-.SH OPTIONS
-.IP "\fB-a, \-\-attribute=\fILDAP-attribute\fP"
-Specifies which attribute to update.
-If the
-.B -a
-option is not specified, the
+.P
+This command has two positional parameters.
+The first parameter specifies the UUID of the FSL record to modify.
+If a record for this FSL does not already exist, the
 .BR nsdb-update-fsl (8)
 command fails.
+The second parameter specifies the name of the attribute to update.
+If that attribute does not already exist,
+it is added to the target FSL record.
+.SH OPTIONS
 .IP "\fB\-d, \-\-debug"
-Specifies that debugging messages be produced during operation.
-.IP "\fB\-x, \-\-fsluuid=\fIuuid\fP"
-Specifies the FSL UUID of the FSL record to update.
-If the
-.B -x
-option is not specified, the
-.BR nsdb-update-fsl (8)
-command fails.
-.IP "\fB\-u, \-\-fsnuuid=\fIuuid\fP"
-Specifies the FSN UUID under which the FSL record resides.
-If the
-.B -u
-option is not specified,
-or an FSN record for this FSN UUID does not already exist
-on the specified NSDB, the
-.BR nsdb-update-fsl (8)
-command fails.
+Enables debugging messages during operation.
 .IP "\fB\-?, \-\-help"
-Prints an
+Displays
 .BR nsdb-update-fsl (8)
-version and usage message on
-.IR stderr ,
-then exits.
+version information and a usage message on
+.IR stderr.
 .IP "\fB-D, \-\-binddn=\fIbind-distinguished-name\fP"
-Specifies a distinguished name of an entity used to bind to this LDAP server.
+Specifies a distinguished name of an entity used to bind to the LDAP server
+where the NSDB resides.
 If the
-.B -D
+.B \-\-binddn
 option is not specified,
 the value of the FEDFS_NSDB_ADMIN environment variable is consulted.
 If this variable is not set,
@@ -152,7 +135,7 @@ command fails.
 Specifies the distinguished name of the NSDB container entry
 under which the specified FSL record resides.
 If the
-.B -e
+.B \-\-nce
 option is not specified,
 the value of the FEDFS_NSDB_NCE environment variable is consulted.
 If this variable is not set,
@@ -163,18 +146,18 @@ command fails.
 .IP "\fB\-l, \-\-nsdbname=\fINSDB-hostname\fP"
 Specifies the hostname of the NSDB where the specified FSL record resides.
 If the
-.B -l
+.B \-\-nsdbname
 option is not specified,
 the value of the FEDFS_NSDB_HOST environment variable is consulted.
 If the variable is not set and the
-.B -l
+.B \-\-nsdbname
 option is not specified, the
 .BR nsdb-update-fsl (8)
 command fails.
 .IP "\fB\-r, \-\-nsdbport=\fINSDB-port\fP"
 Specifies the IP port of the NSDB where the specified FSL record resides.
 If the
-.B -r
+.B \-\-nsdbport
 option is not specified,
 the value of the FEDFS_NSDB_PORT environment variable is consulted.
 The default value if the variable is not set is 389.
@@ -184,18 +167,19 @@ If the specified attribute does not exist, it is created and assigned
 the specified value.
 Otherwise the existing value is replaced.
 If the
-.B -v
+.B \-\-value
 option is not specified, the
 .BR nsdb-update-fsl (8)
 command attempts to delete the specified attribute.
 .IP "\fB\-w, \-\-bindpw=\fIbinddn-password\fP"
-Specifies the password used for simple authentication to this LDAP server.
+Specifies the password used for simple authentication to the LDAP server
+where the NSDB resides.
 If the
-.B -w
+.B \-\-bindpw
 option is not specified,
 the value of the FEDFS_NSDB_PASSWD environment variable is consulted.
 If the variable is not set and the
-.B -w
+.B \-\-bindpw
 option is not specified, the
 .BR nsdb-update-fsl (8)
 command asks for a password on
@@ -310,11 +294,11 @@ The new FSN looks like:
 .sp
 	FSN UUID: 8e246ddc-7b46-11e0-8252-000c297fd679
 .br
-	NSDB: ldap.example.net:389
+	NSDB: nsdb.example.net:389
 .sp
 .RE
 Further suppose the NSDB
-.I ldap.example.net:389
+.I nsdb.example.net:389
 has an NSDB container entry whose distinguished name is
 .IR o=fedfs ,
 and that an FSL child record with the UUID
@@ -327,13 +311,13 @@ from zero to one, you might use:
 .sp
 $ nsdb-update-fsl -D cn=Manager -e o=fedfs \\
 .br
-	-u 8e246ddc-7b46-11e0-8252-000c297fd679
+	-x 323c5068-7c11-11e0-8d38-000c297fd679 \\
 .br
-	-x 323c5068-7c11-11e0-8d38-000c297fd679
+	-l nsdb.example.net \\
 .br
-	-l ldap.example.net
+	8e246ddc-7b46-11e0-8252-000c297fd679 \\
 .br
-	-a fedfsNfsMinorVer -v 1
+	fedfsNfsMinorVer -v 1
 .br
 Enter NSDB password:
 .br
@@ -345,7 +329,7 @@ Successfully updated FSL record
 To see the contents of the updated FSL record, use
 .BR nsdb-resolve-fsn (8).
 .SH SECURITY
-Modify access to the LDAP's DIT is required to update an FSL record.
+Permission to modify the LDAP's DIT is required to update an FSL record.
 The
 .BR nsdb-update-fsl (8)
 command must bind as an entity permitted to modify the DIT
diff --git a/src/nsdbc/nsdb-create-fsl.c b/src/nsdbc/nsdb-create-fsl.c
index 1dfbc56..7398ded 100644
--- a/src/nsdbc/nsdb-create-fsl.c
+++ b/src/nsdbc/nsdb-create-fsl.c
@@ -50,7 +50,7 @@
 /**
  * Short form command line options
  */
-static const char nsdb_create_fsl_opts[] = "?dD:e:l:o:p:r:s:w:u:x:";
+static const char nsdb_create_fsl_opts[] = "?dD:e:l:o:r:w:";
 
 /**
  * Long form command line options
@@ -58,14 +58,10 @@ static const char nsdb_create_fsl_opts[] = "?dD:e:l:o:p:r:s:w:u:x:";
 static const struct option nsdb_create_fsl_longopts[] = {
 	{ "binddn", 1, NULL, 'D', },
 	{ "debug", 0, NULL, 'd', },
-	{ "fsluuid", 1, NULL, 'x', },
-	{ "fsnuuid", 1, NULL, 'u', },
 	{ "help", 0, NULL, '?', },
 	{ "nce", 1, NULL, 'e', },
 	{ "nsdbname", 1, NULL, 'l', },
 	{ "nsdbport", 1, NULL, 'r', },
-	{ "servername", 1, NULL, 's', },
-	{ "serverpath", 1, NULL, 'p', },
 	{ "serverport", 1, NULL, 'o', },
 	{ "bindpw", 1, NULL, 'w', },
 	{ NULL, 0, NULL, 0, },
@@ -82,8 +78,8 @@ nsdb_create_fsl_usage(const char *progname)
 	fprintf(stderr, "\n%s version " VERSION "\n", progname);
 	fprintf(stderr, "Usage: %s [ -d ] [ -D binddn ] [ -w bindpw ] "
 			"[ -l nsdbname ] [ -r nsdbport ] [ -e nce ] "
-			"-u fsn-uuid -x fsl-uuid -s servername "
-			"[ -o serverport ] -p serverpath\n\n",
+			"[ -o serverport ] "
+			"fsn-uuid fsl-uuid servername serverpath\n\n",
 			progname);
 
 	fprintf(stderr, "\t-?, --help           Print this help\n");
@@ -91,13 +87,9 @@ nsdb_create_fsl_usage(const char *progname)
 	fprintf(stderr, "\t-D, --binddn         Bind DN\n");
 	fprintf(stderr, "\t-e, --nce            DN of NSDB container entry\n");
 	fprintf(stderr, "\t-l, --nsdbname       NSDB hostname\n");
-	fprintf(stderr, "\t-p, --serverpath     File server export path\n");
 	fprintf(stderr, "\t-r, --nsdbport       NSDB port\n");
-	fprintf(stderr, "\t-s, --servername     File server hostname to set\n");
 	fprintf(stderr, "\t-o, --serverport     File server port to set\n");
 	fprintf(stderr, "\t-w, --bindpw         Bind password\n");
-	fprintf(stderr, "\t-u, --fsnuuid        FSN UUID of FSL's parent\n");
-	fprintf(stderr, "\t-x, --fsluuid        New FSL UUID\n");
 
 	fprintf(stderr, "%s", fedfs_gpl_boilerplate);
 
@@ -120,7 +112,6 @@ main(int argc, char **argv)
 	unsigned int ldap_err;
 	FedFsStatus retval;
 	nsdb_t host;
-	uuid_t uu;
 	int arg;
 
 	(void)umask(S_IRWXO);
@@ -146,7 +137,6 @@ main(int argc, char **argv)
 	nsdb_env(&nsdbname, &nsdbport, &binddn, &nce, &bindpw);
 
 	serverport = 0;
-	fsn_uuid = fsl_uuid = servername = serverpath = NULL;
 	while ((arg = getopt_long(argc, argv, nsdb_create_fsl_opts,
 			nsdb_create_fsl_longopts, NULL)) != -1) {
 		switch (arg) {
@@ -169,9 +159,6 @@ main(int argc, char **argv)
 				nsdb_create_fsl_usage(progname);
 			}
 			break;
-		case 'p':
-			serverpath = optarg;
-			break;
 		case 'r':
 			if (!nsdb_parse_port_string(optarg, &nsdbport)) {
 				fprintf(stderr, "Bad port number: %s\n",
@@ -179,26 +166,9 @@ main(int argc, char **argv)
 				nsdb_create_fsl_usage(progname);
 			}
 			break;
-		case 's':
-			servername = optarg;
-			break;
 		case 'w':
 			bindpw = optarg;
 			break;
-		case 'u':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid FSN UUID: %s\n", optarg);
-				nsdb_create_fsl_usage(progname);
-			}
-			fsn_uuid = optarg;
-			break;
-		case 'x':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid FSL UUID: %s\n", optarg);
-				nsdb_create_fsl_usage(progname);
-			}
-			fsl_uuid = optarg;
-			break;
 		default:
 			fprintf(stderr, "Invalid command line "
 				"argument: %c\n", (char)arg);
@@ -206,13 +176,31 @@ main(int argc, char **argv)
 			nsdb_create_fsl_usage(progname);
 		}
 	}
-	if (optind != argc) {
-		fprintf(stderr, "Unrecognized command line argument\n");
+	if (argc == optind + 4) {
+		uuid_t uu;
+		fsn_uuid = argv[optind];
+		if (uuid_parse(fsn_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSN UUID was specified\n");
+			nsdb_create_fsl_usage(progname);
+		}
+		fsl_uuid = argv[optind + 1];
+		if (uuid_parse(fsl_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSL UUID was specified\n");
+			nsdb_create_fsl_usage(progname);
+		}
+		servername = argv[optind + 2];
+		if (!nsdb_is_hostname_utf8(servername)) {
+			fprintf(stderr, "NSDB name %s is "
+				"not a UTF-8 hostname\n", servername);
+			nsdb_create_fsl_usage(progname);
+		}
+		serverpath = argv[optind + 3];
+	} else {
+		fprintf(stderr, "Ambiguous positional parameters\n");
 		nsdb_create_fsl_usage(progname);
 	}
-	if (nce == NULL || fsn_uuid == NULL || fsl_uuid == NULL ||
-	    nsdbname == NULL || servername == NULL || serverpath == NULL) {
-		fprintf(stderr, "Missing required command line argument\n");
+	if (nsdbname == NULL) {
+		fprintf(stderr, "No NSDB hostname was specified\n");
 		nsdb_create_fsl_usage(progname);
 	}
 
@@ -230,9 +218,19 @@ main(int argc, char **argv)
 			nsdb_display_fedfsstatus(retval));
 		goto out;
 	}
-
 	if (binddn == NULL)
 		binddn = (char *)nsdb_default_binddn(host);
+	if (binddn == NULL) {
+		fprintf(stderr, "No NDSB bind DN was specified\n");
+		goto out_free;
+	}
+	if (nce == NULL)
+		nce = (char *)nsdb_default_nce(host);
+	if (nce == NULL) {
+		fprintf(stderr, "No NCE was specified\n");
+		goto out_free;
+	}
+
 	retval = nsdb_open_nsdb(host, binddn, bindpw, &ldap_err);
 	switch (retval) {
 	case FEDFS_OK:
@@ -256,8 +254,6 @@ main(int argc, char **argv)
 		goto out_free;
 	}
 
-	if (nce == NULL)
-		nce = (char *)nsdb_default_nce(host);
 	retval = nsdb_create_fsl_s(host, nce, fsn_uuid, fsl_uuid, nsdbname, nsdbport,
 					servername, serverport, serverpath, &ldap_err);
 	switch (retval) {
diff --git a/src/nsdbc/nsdb-delete-fsl.c b/src/nsdbc/nsdb-delete-fsl.c
index 51d0eda..5fc191e 100644
--- a/src/nsdbc/nsdb-delete-fsl.c
+++ b/src/nsdbc/nsdb-delete-fsl.c
@@ -54,7 +54,7 @@
 /**
  * Short form command line options
  */
-static const char nsdb_delete_fsl_opts[] = "?dD:e:l:r:w:x:";
+static const char nsdb_delete_fsl_opts[] = "?dD:e:l:r:w:";
 
 /**
  * Long form command line options
@@ -62,7 +62,6 @@ static const char nsdb_delete_fsl_opts[] = "?dD:e:l:r:w:x:";
 static const struct option nsdb_delete_fsl_longopts[] = {
 	{ "binddn", 1, NULL, 'D', },
 	{ "debug", 0, NULL, 'd', },
-	{ "fsluuid", 1, NULL, 'x', },
 	{ "help", 0, NULL, '?', },
 	{ "nce", 1, NULL, 'e', },
 	{ "nsdbname", 1, NULL, 'l', },
@@ -82,7 +81,7 @@ nsdb_delete_fsl_usage(const char *progname)
 	fprintf(stderr, "\n%s version " VERSION "\n", progname);
 	fprintf(stderr, "Usage: %s [ -d ] [ -D binddn ] [ -w bindpw ] "
 			"[ -l nsdbname ] [ -r nsdbport ] [ -e nce ] "
-			"-x fsl-uuid\n\n",
+			"fsl-uuid\n\n",
 			progname);
 
 	fprintf(stderr, "\t-?, --help           Print this help\n");
@@ -92,7 +91,6 @@ nsdb_delete_fsl_usage(const char *progname)
 	fprintf(stderr, "\t-l, --nsdbname       NSDB hostname\n");
 	fprintf(stderr, "\t-r, --nsdbport       NSDB port\n");
 	fprintf(stderr, "\t-w, --bindpw         Bind password\n");
-	fprintf(stderr, "\t-x, --fsluuid        FSL UUID to remove\n");
 
 	fprintf(stderr, "%s", fedfs_gpl_boilerplate);
 
@@ -115,7 +113,6 @@ main(int argc, char **argv)
 	unsigned int ldap_err;
 	FedFsStatus retval;
 	nsdb_t host;
-	uuid_t uu;
 	int arg;
 
 	(void)umask(S_IRWXO);
@@ -140,7 +137,6 @@ main(int argc, char **argv)
 
 	nsdb_env(&nsdbname, &nsdbport, &binddn, &nce, &bindpw);
 
-	fsl_uuid = NULL;
 	while ((arg = getopt_long(argc, argv, nsdb_delete_fsl_opts,
 			nsdb_delete_fsl_longopts, NULL)) != -1) {
 		switch (arg) {
@@ -166,13 +162,6 @@ main(int argc, char **argv)
 		case 'w':
 			bindpw = optarg;
 			break;
-		case 'x':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid FSL UUID: %s\n", optarg);
-				nsdb_delete_fsl_usage(progname);
-			}
-			fsl_uuid = optarg;
-			break;
 		default:
 			fprintf(stderr, "Invalid command line "
 				"argument: %c\n", (char)arg);
@@ -180,12 +169,22 @@ main(int argc, char **argv)
 			nsdb_delete_fsl_usage(progname);
 		}
 	}
-	if (optind != argc) {
-		fprintf(stderr, "Unrecognized command line argument\n");
+	if (argc == optind + 1) {
+		uuid_t uu;
+		fsl_uuid = argv[optind];
+		if (uuid_parse(fsl_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSL UUID was specified\n");
+			nsdb_delete_fsl_usage(progname);
+		}
+	} else if (argc > optind + 1) {
+		fprintf(stderr, "Unrecognized positional parameters\n");
+		nsdb_delete_fsl_usage(progname);
+	} else {
+		fprintf(stderr, "No FSL UUID was specified\n");
 		nsdb_delete_fsl_usage(progname);
 	}
-	if (nce == NULL || nsdbname == NULL || fsl_uuid == NULL) {
-		fprintf(stderr, "Missing required command line argument\n");
+	if (nsdbname == NULL) {
+		fprintf(stderr, "No NSDB hostname was specified\n");
 		nsdb_delete_fsl_usage(progname);
 	}
 
@@ -203,9 +202,19 @@ main(int argc, char **argv)
 			nsdb_display_fedfsstatus(retval));
 		goto out;
 	}
-
 	if (binddn == NULL)
 		binddn = (char *)nsdb_default_binddn(host);
+	if (binddn == NULL) {
+		fprintf(stderr, "No NDSB bind DN was specified\n");
+		goto out_free;
+	}
+	if (nce == NULL)
+		nce = (char *)nsdb_default_nce(host);
+	if (nce == NULL) {
+		fprintf(stderr, "No NCE was specified\n");
+		goto out_free;
+	}
+
 	retval = nsdb_open_nsdb(host, binddn, bindpw, &ldap_err);
 	switch (retval) {
 	case FEDFS_OK:
@@ -229,8 +238,6 @@ main(int argc, char **argv)
 		goto out_free;
 	}
 
-	if (nce == NULL)
-		nce = (char *)nsdb_default_nce(host);
 	retval = nsdb_delete_fsl_s(host, nce, fsl_uuid, &ldap_err);
 	switch (retval) {
 	case FEDFS_OK:
diff --git a/src/nsdbc/nsdb-update-fsl.c b/src/nsdbc/nsdb-update-fsl.c
index de21ac1..ff0db80 100644
--- a/src/nsdbc/nsdb-update-fsl.c
+++ b/src/nsdbc/nsdb-update-fsl.c
@@ -54,16 +54,14 @@
 /**
  * Short form command line options
  */
-static const char nsdb_update_fsl_opts[] = "?a:dD:e:l:r:v:w:x:";
+static const char nsdb_update_fsl_opts[] = "?dD:e:l:r:v:w:";
 
 /**
  * Long form command line options
  */
 static const struct option nsdb_update_fsl_longopts[] = {
-	{ "attribute", 1, NULL, 'a', },
 	{ "binddn", 1, NULL, 'D', },
 	{ "debug", 0, NULL, 'd', },
-	{ "fsluuid", 1, NULL, 'x', },
 	{ "help", 0, NULL, '?', },
 	{ "nce", 1, NULL, 'e', },
 	{ "nsdbname", 1, NULL, 'l', },
@@ -84,11 +82,10 @@ nsdb_update_fsl_usage(const char *progname)
 	fprintf(stderr, "\n%s version " VERSION "\n", progname);
 	fprintf(stderr, "Usage: %s [ -d ] [ -D binddn ] [ -w bindpw ] "
 			"[ -l nsdbname ] [ -r nsdbport ] [ -e nce ] [ -v value ] "
-			"-a attribute -x fsl-uuid\n\n",
+			"fsl-uuid attribute\n\n",
 			progname);
 
 	fprintf(stderr, "\t-?, --help           Print this help\n");
-	fprintf(stderr, "\t-a, --attribute      LDAP attribute name\n");
 	fprintf(stderr, "\t-d, --debug          Enable debug messages\n");
 	fprintf(stderr, "\t-D, --binddn         Bind DN\n");
 	fprintf(stderr, "\t-e, --nce            DN of NSDB container entry\n");
@@ -96,7 +93,6 @@ nsdb_update_fsl_usage(const char *progname)
 	fprintf(stderr, "\t-r, --nsdbport       NSDB port\n");
 	fprintf(stderr, "\t-v, --value          New attribute value\n");
 	fprintf(stderr, "\t-w, --bindpw         Bind password\n");
-	fprintf(stderr, "\t-x, --fsluuid        FSL UUID of FSL to update\n");
 
 	fprintf(stderr, "%s", fedfs_gpl_boilerplate);
 
@@ -119,7 +115,6 @@ main(int argc, char **argv)
 	unsigned int ldap_err;
 	FedFsStatus retval;
 	nsdb_t host;
-	uuid_t uu;
 	int arg;
 
 	(void)umask(S_IRWXO);
@@ -144,13 +139,10 @@ main(int argc, char **argv)
 
 	nsdb_env(&nsdbname, &nsdbport, &binddn, &nce, &bindpw);
 
-	fsl_uuid = attribute = value = NULL;
+	value = NULL;
 	while ((arg = getopt_long(argc, argv, nsdb_update_fsl_opts,
 			nsdb_update_fsl_longopts, NULL)) != -1) {
 		switch (arg) {
-		case 'a':
-			attribute = optarg;
-			break;
 		case 'd':
 			xlog_config(D_ALL, 1);
 			break;
@@ -176,13 +168,6 @@ main(int argc, char **argv)
 		case 'v':
 			value = optarg;
 			break;
-		case 'x':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid FSL UUID: %s\n", optarg);
-				nsdb_update_fsl_usage(progname);
-			}
-			fsl_uuid = optarg;
-			break;
 		default:
 			fprintf(stderr, "Invalid command line "
 				"argument: %c\n", (char)arg);
@@ -190,12 +175,20 @@ main(int argc, char **argv)
 			nsdb_update_fsl_usage(progname);
 		}
 	}
-	if (optind != argc) {
-		fprintf(stderr, "Unrecognized command line argument\n");
+	if (argc == optind + 2) {
+		uuid_t uu;
+		fsl_uuid = argv[optind];
+		if (uuid_parse(fsl_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSL UUID was specified\n");
+			nsdb_update_fsl_usage(progname);
+		}
+		attribute = argv[optind + 1];
+	} else {
+		fprintf(stderr, "Ambiguous positional parameters\n");
 		nsdb_update_fsl_usage(progname);
 	}
-	if (nsdbname == NULL || attribute == NULL || fsl_uuid == NULL) {
-		fprintf(stderr, "Missing required command line argument\n");
+	if (nsdbname == NULL) {
+		fprintf(stderr, "No NSDB hostname was specified\n");
 		nsdb_update_fsl_usage(progname);
 	}
 
@@ -213,9 +206,15 @@ main(int argc, char **argv)
 			nsdb_display_fedfsstatus(retval));
 		goto out;
 	}
-
 	if (binddn == NULL)
 		binddn = (char *)nsdb_default_binddn(host);
+	if (binddn == NULL) {
+		fprintf(stderr, "No NDSB bind DN was specified\n");
+		goto out_free;
+	}
+	if (nce == NULL)
+		nce = (char *)nsdb_default_nce(host);
+
 	retval = nsdb_open_nsdb(host, binddn, bindpw, &ldap_err);
 	switch (retval) {
 	case FEDFS_OK:
@@ -239,8 +238,6 @@ main(int argc, char **argv)
 		goto out_free;
 	}
 
-	if (nce == NULL)
-		nce = (char *)nsdb_default_nce(host);
 	retval = nsdb_update_fsl_s(host, nce, fsl_uuid, attribute,
 							value, &ldap_err);
 	switch (retval) {




More information about the fedfs-utils-devel mailing list