nfsmapid_test.c revision dd5829d1456ba00e6f704e6a88e7eaae608e3c1b
c0c79a3f09914f35651895ffc111883455b7f62dtz * CDDL HEADER START
c0c79a3f09914f35651895ffc111883455b7f62dtz * The contents of this file are subject to the terms of the
c0c79a3f09914f35651895ffc111883455b7f62dtz * Common Development and Distribution License (the "License").
c0c79a3f09914f35651895ffc111883455b7f62dtz * You may not use this file except in compliance with the License.
c0c79a3f09914f35651895ffc111883455b7f62dtz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c0c79a3f09914f35651895ffc111883455b7f62dtz * See the License for the specific language governing permissions
c0c79a3f09914f35651895ffc111883455b7f62dtz * and limitations under the License.
c0c79a3f09914f35651895ffc111883455b7f62dtz * When distributing Covered Code, include this CDDL HEADER in each
c0c79a3f09914f35651895ffc111883455b7f62dtz * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c0c79a3f09914f35651895ffc111883455b7f62dtz * If applicable, add the following below this CDDL HEADER, with the
c0c79a3f09914f35651895ffc111883455b7f62dtz * fields enclosed by brackets "[]" replaced with your own identifying
c0c79a3f09914f35651895ffc111883455b7f62dtz * information: Portions Copyright [yyyy] [name of copyright owner]
c0c79a3f09914f35651895ffc111883455b7f62dtz * CDDL HEADER END
c0c79a3f09914f35651895ffc111883455b7f62dtz * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
cd3e933325e68e23516a196a8fea7f49b1e497c3Ali Bahrami * Use is subject to license terms.
c0c79a3f09914f35651895ffc111883455b7f62dtz#pragma ident "%Z%%M% %I% %E% SMI"
c0c79a3f09914f35651895ffc111883455b7f62dtz * Test nfsmapid. This program is not shipped on the binary release.
c0c79a3f09914f35651895ffc111883455b7f62dtzstatic void
c0c79a3f09914f35651895ffc111883455b7f62dtz "\nUsage:\tstr2uid string\n"
c0c79a3f09914f35651895ffc111883455b7f62dtz "\tstr2gid string\n"
c0c79a3f09914f35651895ffc111883455b7f62dtz "\tuid2str uid\n"
c0c79a3f09914f35651895ffc111883455b7f62dtz "\tgid2str gid\n"
c0c79a3f09914f35651895ffc111883455b7f62dtz "\techo string\n"
c0c79a3f09914f35651895ffc111883455b7f62dtz "\texit|quit\n"));
c0c79a3f09914f35651895ffc111883455b7f62dtz /* read the next line. If cntl-d, return with zero char count */
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtzparse_input_line(char *input_line, int *argc, char ***argv)
c0c79a3f09914f35651895ffc111883455b7f62dtz /* Count the arguments in the input_line string */
c0c79a3f09914f35651895ffc111883455b7f62dtz } /* minus trailing spaces */
c0c79a3f09914f35651895ffc111883455b7f62dtz /* Now that we know how many args calloc the argv array */
c0c79a3f09914f35651895ffc111883455b7f62dtz switch (stat) {
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_OK");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_NUMSTR");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_UNMAPPABLE");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_INVALID");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_INTERNAL");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_BADDOMAIN");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_BADID");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("NFSMAPID_NOTFOUND");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("EINVAL");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("ECOMM");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("ENOMEM");
c0c79a3f09914f35651895ffc111883455b7f62dtz return ("...");
c0c79a3f09914f35651895ffc111883455b7f62dtz return (1);
c0c79a3f09914f35651895ffc111883455b7f62dtz * remember argv_array address, which is memory calloc'd by
c0c79a3f09914f35651895ffc111883455b7f62dtz * parse_input_line, so it can be free'd at the end of the loop.
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtz return (1);
c0c79a3f09914f35651895ffc111883455b7f62dtz /* free argv array */
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtz * Loop, repeatedly calling parse_input_line() to get the
c0c79a3f09914f35651895ffc111883455b7f62dtz * next line and parse it into argc and argv. Act on the
c0c79a3f09914f35651895ffc111883455b7f62dtz * arguements found on the line.
c0c79a3f09914f35651895ffc111883455b7f62dtz } while (!ret);
c0c79a3f09914f35651895ffc111883455b7f62dtz return (0);
c0c79a3f09914f35651895ffc111883455b7f62dtz * Gen the door handle for connecting to the nfsmapid process.
c0c79a3f09914f35651895ffc111883455b7f62dtz * Keep the door cached. This call may be made quite often.
c0c79a3f09914f35651895ffc111883455b7f62dtz * Convert a user utf-8 string identifier into its local uid.
c0c79a3f09914f35651895ffc111883455b7f62dtz static int msg_done = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (!u8s || !u8s->utf8string_val || !u8s->utf8string_len ||
c0c79a3f09914f35651895ffc111883455b7f62dtz * If "nobody", just short circuit and bail
c0c79a3f09914f35651895ffc111883455b7f62dtz if ((mapargp = malloc(MAPID_ARG_LEN(u8s->utf8string_len))) == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) bcopy(u8s->utf8string_val, mapargp->str, mapargp->u_arg.len);
c0c79a3f09914f35651895ffc111883455b7f62dtz * call to the nfsmapid daemon
c0c79a3f09914f35651895ffc111883455b7f62dtz " with mapping daemon nfsmapid\n");
c0c79a3f09914f35651895ffc111883455b7f62dtz * Convert a uid into its utf-8 string representation.
c0c79a3f09914f35651895ffc111883455b7f62dtz static int msg_done = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz * Daemon call...
c0c79a3f09914f35651895ffc111883455b7f62dtz "communicate with mapping daemon nfsmapid\n");
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) fprintf(stderr, "Incorrect length %d expected %d\n",
c0c79a3f09914f35651895ffc111883455b7f62dtz bcopy(resp->str, u8s->utf8string_val, u8s->utf8string_len);
c0c79a3f09914f35651895ffc111883455b7f62dtz * Convert a group utf-8 string identifier into its local gid.
c0c79a3f09914f35651895ffc111883455b7f62dtz static int msg_done = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz if (!u8s || !u8s->utf8string_val || !u8s->utf8string_len ||
c0c79a3f09914f35651895ffc111883455b7f62dtz * If "nobody", just short circuit and bail
c0c79a3f09914f35651895ffc111883455b7f62dtz if ((mapargp = malloc(MAPID_ARG_LEN(u8s->utf8string_len))) == NULL) {
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) bcopy(u8s->utf8string_val, mapargp->str, mapargp->u_arg.len);
c0c79a3f09914f35651895ffc111883455b7f62dtz * call to the nfsmapid daemon
c0c79a3f09914f35651895ffc111883455b7f62dtz " with mapping daemon nfsmapid\n");
c0c79a3f09914f35651895ffc111883455b7f62dtz * Convert a gid into its utf-8 string representation.
c0c79a3f09914f35651895ffc111883455b7f62dtz static int msg_done = 0;
c0c79a3f09914f35651895ffc111883455b7f62dtz * Daemon call...
c0c79a3f09914f35651895ffc111883455b7f62dtz "communicate with mapping daemon nfsmapid\n");
c0c79a3f09914f35651895ffc111883455b7f62dtz (void) fprintf(stderr, "Incorrect length %d expected %d\n",