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

Chuck Lever chuck.lever at oracle.com
Mon Nov 28 09:33:40 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 FSN
records.

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

 doc/man/nsdb-create-fsn.8    |   81 +++++++++++++++++++-----------------------
 doc/man/nsdb-delete-fsn.8    |   67 +++++++++++++++++------------------
 doc/man/nsdb-resolve-fsn.8   |   42 +++++++++-------------
 src/nsdbc/nsdb-create-fsn.c  |   47 ++++++++++++++----------
 src/nsdbc/nsdb-delete-fsn.c  |   49 +++++++++++++++----------
 src/nsdbc/nsdb-resolve-fsn.c |   33 ++++++++---------
 6 files changed, 159 insertions(+), 160 deletions(-)

diff --git a/doc/man/nsdb-create-fsn.8 b/doc/man/nsdb-create-fsn.8
index 7099846..a037d22 100644
--- a/doc/man/nsdb-create-fsn.8
+++ b/doc/man/nsdb-create-fsn.8
@@ -39,7 +39,6 @@ nsdb-create-fsn \- create a fileset name (FSN) record on an NSDB
 .IR nsdbport ]
 .RB [ \-w
 .IR bindpw ]
-.B \-u
 .I fsn-uuid
 .SH INTRODUCTION
 RFC 5716 introduces the Federated File System (FedFS, for short).
@@ -64,9 +63,9 @@ about file sets contained in a FedFS domain name space.
 .SH DESCRIPTION
 The
 .BR nsdb-create-fsn (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.
-This command creates a FedFS
+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.
+It creates a FedFS
 .I fileset name
 (FSN) record on an NSDB.
 .P
@@ -86,30 +85,30 @@ The
 .BR nsdb-create-fsn (8)
 command creates an FSN record on the named NSDB
 in preparation for use in FedFS junctions.
-It does not create FedFS junctions; to create a junction, use
-.BR fedfs-create-junction (8).
-It does not create any FSL children records; to create an FSL record, use
-.BR nsdb-create-fsl (8).
+It does not create FedFS junctions.
+To create a junction, use the
+.BR fedfs-create-junction (8)
+command.
+It does not create any FSL children records.
+To create an FSL record, use the
+.BR nsdb-create-fsl (8)
+command.
+.P
+This command has one positional parameter which specifies
+the UUID of the new FSN record.
 .SH OPTIONS
 .IP "\fB\-d, \-\-debug"
-Specifies that debugging messages be produced during operation.
-.IP "\fB\-u, \-\-fsnuuid=\fIuuid\fP"
-Specifies the FSN UUID to insert into the new FSN record.
-If the
-.B -u
-option is not specified, the
-.BR nsdb-create-fsn (8)
-command fails.
+Enables debugging messages during operation.
 .IP "\fB\-?, \-\-help"
-Prints an
+Displays
 .BR nsdb-create-fsn (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,
@@ -120,10 +119,10 @@ of the server's DIT, the
 .BR nsdb-create-fsn (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 FSN 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,
@@ -134,29 +133,30 @@ command fails.
 .IP "\fB\-l, \-\-nsdbname=\fINSDB-host-name\fP"
 Specifies the hostname of the NSDB where the new FSN 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-fsn (8)
 command fails.
 .IP "\fB\-r, \-\-nsdbport=\fINSDB-port\fP"
 Specifies the IP port of the NSDB where the new FSN 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-create-fsn (8)
 command asks for a password on
@@ -265,21 +265,21 @@ The new FSN might look 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 .
 To create a corresponding FSN record, you might use:
 .RS
 .sp
 $ nsdb-create-fsn -D cn=Manager -e o=fedfs \\
 .br
-	-u 8e246ddc-7b46-11e0-8252-000c297fd679
+	-l nsdb.example.net \\
 .br
-	-l ldap.example.net
+	8e246ddc-7b46-11e0-8252-000c297fd679
 .br
 Enter NSDB password:
 .br
@@ -287,15 +287,8 @@ Successfully created FSN record
   fedfsFsnUuid=8e246ddc-7b46-11e0-8252-000c297fd679,o=fedfs
 .sp
 .RE
-The new FSN is specified using the
-.B -l
-and the
-.B -u
-(and optionally, the
-.BR -r )
-options.
 A new FSN record is created on
-.I ldap.example.net:389
+.I nsdb.example.net:389
 with a distinguished name of
 .RS
 .sp
@@ -307,7 +300,7 @@ To see the new FSN record, use
 or
 .BR nsdb-resolve-fsn (8).
 .SH SECURITY
-Modify access to the LDAP's DIT is required to create a new FSN record.
+Permission to modify the LDAP's DIT is required to create a new FSN record.
 The
 .BR nsdb-create-fsn (8)
 command must bind as an entity permitted to modify the DIT
diff --git a/doc/man/nsdb-delete-fsn.8 b/doc/man/nsdb-delete-fsn.8
index f4b7750..565a187 100644
--- a/doc/man/nsdb-delete-fsn.8
+++ b/doc/man/nsdb-delete-fsn.8
@@ -39,7 +39,6 @@ nsdb-delete-fsn \- delete a fileset name (FSN) record from an NSDB
 .IR nsdbport ]
 .RB [ \-w
 .IR bindpw ]
-.B \-u
 .I fsn-uuid
 .SH INTRODUCTION
 RFC 5716 introduces the Federated File System (FedFS, for short).
@@ -86,38 +85,36 @@ The
 .BR nsdb-delete-fsn (8)
 command removes an FSN record from the named NSDB
 after it is no longer used in FedFS junctions.
-It does not remove FedFS junctions; to remove a junction, use
-.BR fedfs-delete-junction (8).
+It does not remove FedFS junctions.
+To remove a junction, use the
+.BR fedfs-delete-junction (8)
+command
 .P
 The default behavior, if the
-.B -y
+.B \-\-delete
 option is not specified,
 removes the specified FSN record and all of its FSL children records.
 If the
-.B -y
+.B \-\-delete
 option is specified,
 all FSL child records of the specified FSN record are removed,
 but the specified FSN record is left in place.
+.P
+This command has one positional parameter which specifies
+the UUID of the FSN record to modify or remove.
 .SH OPTIONS
 .IP "\fB\-d, \-\-debug"
-Specifies that debugging messages be produced during operation.
-.IP "\fB\-u, \-\-fsnuuid=\fIuuid\fP"
-Specifies the FSN UUID of the doomed FSN record.
-If the
-.B -u
-option is not specified, the
-.BR nsdb-delete-fsn (8)
-command fails.
+Enables debugging messages during operation.
 .IP "\fB\-?, \-\-help"
-Prints an
+Displays
 .BR nsdb-delete-fsn (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,
@@ -128,10 +125,10 @@ of the server's DIT, the
 .BR nsdb-delete-fsn (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 the doomed FSN record exists.
 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,
@@ -142,29 +139,30 @@ command fails.
 .IP "\fB\-l, \-\-nsdbname=\fINSDB-host-name\fP"
 Specifies the hostname of the NSDB where the doomed FSN 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-delete-fsn (8)
 command fails.
 .IP "\fB\-r, \-\-nsdbport=\fINSDB-port\fP"
 Specifies the IP port of the NSDB where the doomed FSN 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.
 .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 th 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-fsn (8)
 command asks for a password on
@@ -275,21 +273,21 @@ FedFS domain and that you want to remove the FSN record for this FSN:
 .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 .
 To delete the corresponding FSN record, you might use:
 .RS
 .sp
 $ nsdb-delete-fsn -D cn=Manager -e o=fedfs \\
 .br
-	-u 8e246ddc-7b46-11e0-8252-000c297fd679
+	-l nsdb.example.net \\
 .br
-	-l ldap.example.net
+	8e246ddc-7b46-11e0-8252-000c297fd679
 .br
 Enter NSDB password:
 .br
@@ -297,9 +295,10 @@ Successfully deleted FSN record
   fedfsFsnUuid=8e246ddc-7b46-11e0-8252-000c297fd679,o=fedfs
 .sp
 .RE
-All FSL child records for this FSN record are also removed.
+In this example,
+all FSL child records for this FSN record are also removed.
 .SH SECURITY
-Modify access to the LDAP's DIT is required to delete an FSN record.
+Permission to modify the LDAP's DIT is required to delete an FSN record.
 The
 .BR nsdb-delete-fsn (8)
 command must bind as an entity permitted to modify the DIT
diff --git a/doc/man/nsdb-resolve-fsn.8 b/doc/man/nsdb-resolve-fsn.8
index 84bddb3..41204ae 100644
--- a/doc/man/nsdb-resolve-fsn.8
+++ b/doc/man/nsdb-resolve-fsn.8
@@ -35,7 +35,6 @@ nsdb-resolve-fsn \- resolve a fileset name (FSN) record on an NSDB
 .IR nsdbname ]
 .RB [ \-r
 .IR nsdbport ]
-.B \-u
 .I fsn-uuid
 .SH INTRODUCTION
 RFC 5716 introduces the Federated File System (FedFS, for short).
@@ -84,27 +83,22 @@ command looks up an FSN record on the named NSDB
 and returns the set of FSL records that are its children.
 This is the same operation that FedFS-enabled file servers perform
 when resolving the FSN contained in a FedFS junction.
+.P
+This command has one positional parameter which specifies
+the UUID of the FSN record to resolve.
 .SH OPTIONS
 .IP "\fB\-d, \-\-debug"
-Specifies that debugging messages be produced during operation.
-.IP "\fB\-u, \-\-fsnuuid=\fIuuid\fP"
-Specifies the FSN UUID to resolve.
-If the
-.B -u
-option is not specified, the
-.BR nsdb-resolve-fsn (8)
-command fails.
+Enables debugging messages during operation.
 .IP "\fB\-?, \-\-help"
-Prints an
+Displays
 .BR nsdb-resolve-fsn (8)
-version and usage message on
-.IR stderr ,
-then exits.
+version information and a usage message on
+.IR stderr .
 .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 FSN 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,
@@ -115,18 +109,18 @@ command searches the NSDB's naming contexts to discover its NCEs.
 .IP "\fB\-l, \-\-nsdbname=\fINSDB-host-name\fP"
 Specifies the NSDB hostname portion of the FSN to resolve.
 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-resolve-fsn (8)
 command fails.
 .IP "\fB\-r, \-\-nsdbport=\fINSDB-port\fP"
 Specifies the NSDB IP port portion of the FSN to resolve.
 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.
@@ -237,12 +231,12 @@ FedFS domain and that you have created a new 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 ,
 and that the FSN has a single FSL child record.
 To resolve the FSN, you might use:
@@ -250,9 +244,9 @@ To resolve the FSN, you might use:
 .sp
 $ nsdb-resolve-fsn -e o=fedfs \\
 .br
-	-u 8e246ddc-7b46-11e0-8252-000c297fd679 \\
+	-l nsdb.example.net \\
 .br
-	-l ldap.example.net
+	8e246ddc-7b46-11e0-8252-000c297fd679
 .sp
 For FSN UUID 8e246ddc-7b46-11e0-8252-000c297fd679
 .br
@@ -264,7 +258,7 @@ dn: fedfsFslUuid=323c5068-7c11-11e0-8d38-000c297fd679,
 .br
  FSL UUID:		323c5068-7c11-11e0-8d38-000c297fd679
 .br
- NSDB:			ldap.example.net
+ NSDB:			nsdb.example.net
 .br
  FSL host:		fileserver.example.net
 .br
diff --git a/src/nsdbc/nsdb-create-fsn.c b/src/nsdbc/nsdb-create-fsn.c
index a3d76fd..90aef0c 100644
--- a/src/nsdbc/nsdb-create-fsn.c
+++ b/src/nsdbc/nsdb-create-fsn.c
@@ -50,7 +50,7 @@
 /**
  * Short form command line options
  */
-static const char nsdb_create_fsn_opts[] = "?dD:e:l:r:w:u:";
+static const char nsdb_create_fsn_opts[] = "?dD:e:l:r:w:";
 
 /**
  * Long form command line options
@@ -58,7 +58,6 @@ static const char nsdb_create_fsn_opts[] = "?dD:e:l:r:w:u:";
 static const struct option nsdb_create_fsn_longopts[] = {
 	{ "binddn", 1, NULL, 'D', },
 	{ "debug", 0, NULL, 'd', },
-	{ "fsnuuid", 1, NULL, 'u', },
 	{ "help", 0, NULL, '?', },
 	{ "nce", 1, NULL, 'e', },
 	{ "nsdbname", 1, NULL, 'l', },
@@ -78,7 +77,7 @@ nsdb_create_fsn_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\n\n",
+			"fsn-uuid\n\n",
 			progname);
 
 	fprintf(stderr, "\t-?, --help           Print this help\n");
@@ -88,7 +87,6 @@ nsdb_create_fsn_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-u, --fsnuuid        New FSN UUID\n");
 
 	fprintf(stderr, "%s", fedfs_gpl_boilerplate);
 
@@ -111,7 +109,6 @@ main(int argc, char **argv)
 	char *nce, *fsn_uuid;
 	FedFsStatus retval;
 	nsdb_t host;
-	uuid_t uu;
 	int arg;
 
 	(void)umask(S_IRWXO);
@@ -136,7 +133,6 @@ main(int argc, char **argv)
 
 	nsdb_env(&nsdbname, &nsdbport, &binddn, &nce, &bindpw);
 
-	fsn_uuid = NULL;
 	while ((arg = getopt_long(argc, argv, nsdb_create_fsn_opts,
 			nsdb_create_fsn_longopts, NULL)) != -1) {
 		switch (arg) {
@@ -162,13 +158,6 @@ main(int argc, char **argv)
 		case 'w':
 			bindpw = optarg;
 			break;
-		case 'u':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid uuid: %s\n", optarg);
-				nsdb_create_fsn_usage(progname);
-			}
-			fsn_uuid = optarg;
-			break;
 		default:
 			fprintf(stderr, "Invalid command line "
 				"argument: %c\n", (char)arg);
@@ -176,12 +165,22 @@ main(int argc, char **argv)
 			nsdb_create_fsn_usage(progname);
 		}
 	}
-	if (optind != argc) {
-		fprintf(stderr, "Unrecognized command line argument\n");
+	if (argc == optind + 1) {
+		uuid_t uu;
+		fsn_uuid = argv[optind];
+		if (uuid_parse(fsn_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSN UUID was specified\n");
+			nsdb_create_fsn_usage(progname);
+		}
+	} else if (argc > optind + 1) {
+		fprintf(stderr, "Unrecognized positional parameters\n");
+		nsdb_create_fsn_usage(progname);
+	} else {
+		fprintf(stderr, "No FSN UUID was specified\n");
 		nsdb_create_fsn_usage(progname);
 	}
-	if (nce == NULL || nsdbname == NULL || fsn_uuid == NULL) {
-		fprintf(stderr, "Missing required command line argument\n");
+	if (nsdbname == NULL) {
+		fprintf(stderr, "No NSDB hostname was specified\n");
 		nsdb_create_fsn_usage(progname);
 	}
 
@@ -199,9 +198,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:
@@ -225,8 +234,6 @@ main(int argc, char **argv)
 		goto out_free;
 	}
 
-	if (nce == NULL)
-		nce = (char *)nsdb_default_nce(host);
 	retval = nsdb_create_fsn_s(host, nce, fsn_uuid,
 					nsdbname, nsdbport, &ldap_err);
 	switch (retval) {
diff --git a/src/nsdbc/nsdb-delete-fsn.c b/src/nsdbc/nsdb-delete-fsn.c
index 969b098..fcd6c20 100644
--- a/src/nsdbc/nsdb-delete-fsn.c
+++ b/src/nsdbc/nsdb-delete-fsn.c
@@ -50,7 +50,7 @@
 /**
  * Short form command line options
  */
-static const char nsdb_delete_fsn_opts[] = "?dD:e:l:r:w:u:y";
+static const char nsdb_delete_fsn_opts[] = "?dD:e:l:r:w:y";
 
 /**
  * Long form command line options
@@ -58,7 +58,6 @@ static const char nsdb_delete_fsn_opts[] = "?dD:e:l:r:w:u:y";
 static const struct option nsdb_delete_fsn_longopts[] = {
 	{ "binddn", 1, NULL, 'D', },
 	{ "debug", 0, NULL, 'd', },
-	{ "fsnuuid", 1, NULL, 'u', },
 	{ "help", 0, NULL, '?', },
 	{ "leavefsn", 0, NULL, 'y', },
 	{ "nce", 1, NULL, 'e', },
@@ -78,8 +77,8 @@ nsdb_delete_fsn_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 ] "
-			"[-y] -u fsn-uuid\n\n", progname);
+			"[ -l nsdbname ] [ -r nsdbport ] [ -e nce ] [-y] "
+			"fsn-uuid\n\n", progname);
 
 	fprintf(stderr, "\t-?, --help           Print this help\n");
 	fprintf(stderr, "\t-d, --debug          Enable debug messages\n");
@@ -88,7 +87,6 @@ nsdb_delete_fsn_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-u, --fsnuuid        FSN UUID to remove\n");
 	fprintf(stderr, "\t-y, --leavefsn       Delete FSLs but leave FSN\n");
 
 	fprintf(stderr, "%s", fedfs_gpl_boilerplate);
@@ -113,7 +111,6 @@ main(int argc, char **argv)
 	FedFsStatus retval;
 	_Bool leave_fsn;
 	nsdb_t host;
-	uuid_t uu;
 	int arg;
 
 	(void)umask(S_IRWXO);
@@ -139,7 +136,6 @@ main(int argc, char **argv)
 	nsdb_env(&nsdbname, &nsdbport, &binddn, &nce, &bindpw);
 
 	leave_fsn = false;
-	fsn_uuid = NULL;
 	while ((arg = getopt_long(argc, argv, nsdb_delete_fsn_opts,
 			nsdb_delete_fsn_longopts, NULL)) != -1) {
 		switch (arg) {
@@ -165,13 +161,6 @@ main(int argc, char **argv)
 		case 'w':
 			bindpw = optarg;
 			break;
-		case 'u':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid FSN UUID: %s\n", optarg);
-				nsdb_delete_fsn_usage(progname);
-			}
-			fsn_uuid = optarg;
-			break;
 		case 'y':
 			leave_fsn = true;
 			break;
@@ -182,12 +171,22 @@ main(int argc, char **argv)
 			nsdb_delete_fsn_usage(progname);
 		}
 	}
-	if (optind != argc) {
-		fprintf(stderr, "Unrecognized command line argument\n");
+	if (argc == optind + 1) {
+		uuid_t uu;
+		fsn_uuid = argv[optind];
+		if (uuid_parse(fsn_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSN UUID was specified\n");
+			nsdb_delete_fsn_usage(progname);
+		}
+	} else if (argc > optind + 1) {
+		fprintf(stderr, "Unrecognized positional parameters\n");
+		nsdb_delete_fsn_usage(progname);
+	} else {
+		fprintf(stderr, "No FSN UUID was specified\n");
 		nsdb_delete_fsn_usage(progname);
 	}
-	if (nce == NULL || nsdbname == NULL || fsn_uuid == NULL) {
-		fprintf(stderr, "Missing required command line argument\n");
+	if (nsdbname == NULL) {
+		fprintf(stderr, "No NSDB hostname specified\n");
 		nsdb_delete_fsn_usage(progname);
 	}
 
@@ -205,9 +204,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:
@@ -231,8 +240,6 @@ main(int argc, char **argv)
 		goto out_free;
 	}
 
-	if (nce == NULL)
-		nce = (char *)nsdb_default_nce(host);
 	retval = nsdb_delete_fsn_s(host, nce, fsn_uuid, leave_fsn, &ldap_err);
 	switch (retval) {
 	case FEDFS_OK:
diff --git a/src/nsdbc/nsdb-resolve-fsn.c b/src/nsdbc/nsdb-resolve-fsn.c
index 622adc3..d317575 100644
--- a/src/nsdbc/nsdb-resolve-fsn.c
+++ b/src/nsdbc/nsdb-resolve-fsn.c
@@ -50,14 +50,13 @@
 /**
  * Short form command line options
  */
-static const char nsdb_resolve_fsn_opts[] = "?de:l:r:u:";
+static const char nsdb_resolve_fsn_opts[] = "?de:l:r:";
 
 /**
  * Long form command line options
  */
 static const struct option nsdb_resolve_fsn_longopts[] = {
 	{ "debug", 0, NULL, 'd', },
-	{ "fsnuuid", 1, NULL, 'u', },
 	{ "help", 0, NULL, '?', },
 	{ "nce", 1, NULL, 'e', },
 	{ "nsdbname", 1, NULL, 'l', },
@@ -76,14 +75,13 @@ nsdb_resolve_fsn_usage(const char *progname)
 	fprintf(stderr, "\n%s version " VERSION "\n", progname);
 	fprintf(stderr, "Usage: %s [ -d ] "
 			"[ -l nsdbname ] [ -r nsdbport ] [ -e nce ] "
-			"-u fsn-uuid\n\n", progname);
+			"fsn-uuid\n\n", progname);
 
 	fprintf(stderr, "\t-?, --help           Print this help\n");
 	fprintf(stderr, "\t-d, --debug          Enable debug messages\n");
 	fprintf(stderr, "\t-e, --nce            DN of NSDB container entry\n");
 	fprintf(stderr, "\t-l, --nsdbname       NSDB hostname\n");
 	fprintf(stderr, "\t-r, --nsdbport       NSDB port\n");
-	fprintf(stderr, "\t-u, --fsnuuid        FSN UUID to resolve\n");
 
 	fprintf(stderr, "%s", fedfs_gpl_boilerplate);
 
@@ -203,7 +201,6 @@ main(int argc, char **argv)
 	char *nce, *fsn_uuid;
 	FedFsStatus retval;
 	nsdb_t host;
-	uuid_t uu;
 	int arg;
 
 	(void)umask(S_IRWXO);
@@ -248,14 +245,6 @@ main(int argc, char **argv)
 				nsdb_resolve_fsn_usage(progname);
 			}
 			break;
-		case 'u':
-			if (uuid_parse(optarg, uu) == -1) {
-				fprintf(stderr, "Invalid FSN UUID: %s\n",
-					optarg);
-				nsdb_resolve_fsn_usage(progname);
-			}
-			fsn_uuid = optarg;
-			break;
 		default:
 			fprintf(stderr, "Invalid command line "
 				"argument: %c\n", (char)arg);
@@ -263,12 +252,22 @@ main(int argc, char **argv)
 			nsdb_resolve_fsn_usage(progname);
 		}
 	}
-	if (optind != argc) {
-		fprintf(stderr, "Unrecognized command line argument\n");
+	if (argc == optind + 1) {
+		uuid_t uu;
+		fsn_uuid = argv[optind];
+		if (uuid_parse(fsn_uuid, uu) == -1) {
+			fprintf(stderr, "Invalid FSN UUID was specified\n");
+			nsdb_resolve_fsn_usage(progname);
+		}
+	} else if (argc >  optind + 1) {
+		fprintf(stderr, "Unrecognized positional parameters\n");
+		nsdb_resolve_fsn_usage(progname);
+	} else {
+		fprintf(stderr, "No FSN UUID was specified\n");
 		nsdb_resolve_fsn_usage(progname);
 	}
-	if (nsdbname == NULL || fsn_uuid == NULL) {
-		fprintf(stderr, "Missing required command line argument\n");
+	if (nsdbname == NULL) {
+		fprintf(stderr, "No NSDB hostname was specified\n");
 		nsdb_resolve_fsn_usage(progname);
 	}
 




More information about the fedfs-utils-devel mailing list