From patchwork Mon Nov 28 17:33:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 128027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "rcsinet15.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id EFDC3B6F7C for ; Tue, 29 Nov 2011 04:33:54 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pASHXoM6005464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 28 Nov 2011 17:33:51 GMT Received: from oss.oracle.com (oss.oracle.com [141.146.12.120]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pASHXnDL028252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Nov 2011 17:33:50 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RV55M-0000S1-Ql; Mon, 28 Nov 2011 09:33:44 -0800 Received: from acsinet13.oracle.com ([141.146.126.235]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1RV55K-0000Ru-RA for fedfs-utils-devel@oss.oracle.com; Mon, 28 Nov 2011 09:33:42 -0800 Received: from mail-iy0-f171.google.com (mail-iy0-f171.google.com [209.85.210.171]) by acsinet13.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pASHXXJd022680 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 28 Nov 2011 17:33:42 GMT Received: by mail-iy0-f171.google.com with SMTP id y12so10949330iab.2 for ; Mon, 28 Nov 2011 09:33:42 -0800 (PST) Received: by 10.231.60.212 with SMTP id q20mr662937ibh.14.1322501622056; Mon, 28 Nov 2011 09:33:42 -0800 (PST) Received: from degas.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id eh34sm48145874ibb.5.2011.11.28.09.33.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Nov 2011 09:33:41 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Mon, 28 Nov 2011 12:33:40 -0500 Message-ID: <20111128173339.1136.62042.stgit@degas.1015granger.net> In-Reply-To: <20111128172546.1136.92618.stgit@degas.1015granger.net> References: <20111128172546.1136.92618.stgit@degas.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=ISPs ip=209.85.210.171 ct-class=G1 ct-vol1=0 ct-vol2=0 ct-vol3=0 ct-risk=0 ct-spam1=0 ct-spam2=0 ct-bulk=0 rcpts=1 size=26325 Subject: [fedfs-utils] [PATCH 4/9] nsdbc: Specify manadatory arguments as positional parameters (nsdb-*-fsn) X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-CT-RefId: str=0001.0A090201.4ED3C5FF.0090:SCFSTAT1119972, ss=1, re=-6.300, fgs=0 X-Auth-Type: Internal IP 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 --- 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); }