diff options
author | rmesta <none@none> | 2006-04-04 08:40:43 -0700 |
---|---|---|
committer | rmesta <none@none> | 2006-04-04 08:40:43 -0700 |
commit | 8200fe25ffab8b2032d046c88710a949f361b700 (patch) | |
tree | 6a81f50dd6e46f1826967801d90f77d9ea94a054 /deleted_files | |
parent | 3d50435f68f303099494fc361217f9cea5592dfa (diff) | |
download | illumos-gate-8200fe25ffab8b2032d046c88710a949f361b700.tar.gz |
PSARC 2005/487 sysidtool(1m) Integrated NFSv4 Prompts
6231897 ON changes in support of 5110062: nuke sysidnfs4(1m)
--HG--
rename : usr/src/cmd/fs.d/nfs/sysidnfs4/Makefile => deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/Makefile
rename : usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.c => deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.c
rename : usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.h => deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.h
rename : usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.c => deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.c
rename : usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.h => deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.h
rename : usr/src/pkgdefs/SUNWnfscu/postinstall => deleted_files/usr/src/pkgdefs/SUNWnfscu/postinstall
rename : usr/src/cmd/fs.d/nfs/nfsmapid/nfsmapid_resolv.c => usr/src/lib/libmapid/common/mapid.c
rename : usr/src/cmd/fs.d/nfs/nfsmapid/nfsmapid_resolv.h => usr/src/lib/libmapid/common/mapid.h
Diffstat (limited to 'deleted_files')
6 files changed, 1050 insertions, 0 deletions
diff --git a/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/Makefile b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/Makefile new file mode 100644 index 0000000000..65b71c0eb1 --- /dev/null +++ b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/Makefile @@ -0,0 +1,70 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +#ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2004 Sun Microsystems, Inc. +# All rights reserved. Use is subject to license terms. +# +PROG = sysidnfs4 +POFILE = $(PROG:%=%.po) +SRCS = sysidnfs4.c config_nfs4.c +HDRS += $(SRCS:%.c=%.h) +OBJS = $(SRCS:%.c=%.o) +DEFINES = +CFLAGS += -O $(DEFINES) +CPPFLAGS+= +LDLIBS += + +include ../../../Makefile.cmd + +catalog: $(POFILE) + +$(POFILE): $(SRCS) + $(RM) $@ + $(COMPILE.cpp) $(SRCS) > $(POFILE).i + $(XGETTEXT) $(XGETFLAGS) $(POFILE).i + sed "/^domain/d" messages.po > $@ + $(RM) $(POFILE).i messages.po + +$(PROG): $(OBJS) + $(LINK.c) -o $@ $(OBJS) $(LDLIBS) + $(POST_PROCESS) + +$(OBJS): $(HDRS) + +$(ROOTUSRSBINPROG) := OWNER= root +$(ROOTUSRSBINPROG) := GROUP= sys +$(ROOTUSRSBINPROG) := FILEMODE= 555 + +CLOBBERFILES += $(ROOTUSRSBINPROG) + +all: $(PROG) + +clean: + $(RM) $(OBJS) $(POFILE) $(PROG) + +lint: $(SRCS) lint_SRCS + +install: $(ROOTUSRSBINPROG) + +include ../../../Makefile.targ diff --git a/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.c b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.c new file mode 100644 index 0000000000..ec22e75d0e --- /dev/null +++ b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.c @@ -0,0 +1,414 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <strings.h> +#include <errno.h> +#include <assert.h> +#include "config_nfs4.h" + +#define NFS4_MAX_DOM_LEN 1024 + +static int work_fd; +static int nfs4_fd; +static struct stat n4sb; +char cur_domain[NFS4_MAX_DOM_LEN]; +char nfs4cfg_file[NFS4_MAX_DOM_LEN]; +static char work_file[NFS4_MAX_DOM_LEN]; + +static nfs4cfg_err_t +gen_nfs4_work_fname(char *src, char *dst) +{ + char *t; + char dir[NFS4_MAX_DOM_LEN]; + char *pfx = "mapid"; + + snprintf(dir, strlen(src), "%s", src); + if ((t = strrchr(dir, '/')) != NULL) + *t = '\0'; /* /etc/default */ + else + dir[0] = '\0'; /* P_tmpdir */ + + /* + * Note: tempnam() can still default to P_tmpdir if + * access perms to the 'dir' are incompatible + */ + if ((t = tempnam(dir, pfx)) == NULL) + return (NFS4CFG_ERR_WRK_FNAME); + + snprintf(dst, strlen(t), "%s", t); + return (NFS4CFG_OK); +} + +static nfs4cfg_err_t +open_nfs4_cfg(FILE **n4_fp) +{ + int n4_fd; + int o_flags = (O_CREAT | O_RDWR | O_TRUNC); + + errno = 0; + if (stat(nfs4cfg_file, &n4sb) < 0) { + if (errno != ENOENT) + return (NFS4CFG_ERR_CFG_STAT); + + /* + * config file does not exist, so we create it + */ + if ((n4_fd = open(nfs4cfg_file, o_flags, 0644)) < 0) + return (NFS4CFG_ERR_CFG_OPEN_RW); + + if ((*n4_fp = fdopen(n4_fd, "w")) == NULL) { + close(n4_fd); + unlink(nfs4cfg_file); + return (NFS4CFG_ERR_CFG_FDOPEN); + } + + if (fchown(n4_fd, UID_ROOT, GID_SYS) < 0) { + close(n4_fd); + unlink(nfs4cfg_file); + return (NFS4CFG_ERR_CFG_WCHOWN); + } + return (NFS4CFG_ERR_CFG_CREAT); + } + + /* + * config file exists; open it and + * create the appropriate work file + */ + if ((n4_fd = open(nfs4cfg_file, O_RDONLY)) < 0) + return (NFS4CFG_ERR_CFG_OPEN_RO); + + if ((*n4_fp = fdopen(n4_fd, "r")) == NULL) { + close(n4_fd); + return (NFS4CFG_ERR_CFG_FDOPEN); + } + + nfs4_fd = n4_fd; + return (NFS4CFG_OK); +} + +static nfs4cfg_err_t +open_work_file(FILE **wk_fp) +{ + int wk_fd; + int o_flags = (O_CREAT | O_RDWR | O_TRUNC); + + if ((wk_fd = open(work_file, o_flags, 0644)) < 0) + return (NFS4CFG_ERR_WRK_OPEN); + + if ((*wk_fp = fdopen(wk_fd, "w")) == NULL) { + close(wk_fd); + return (NFS4CFG_ERR_WRK_FDOPEN); + } + + if (fchmod(wk_fd, n4sb.st_mode) < 0) { + fclose(*wk_fp); + unlink(work_file); + return (NFS4CFG_ERR_WRK_WCHMOD); + } + + if (fchown(wk_fd, n4sb.st_uid, n4sb.st_gid) < 0) { + fclose(*wk_fp); + unlink(work_file); + return (NFS4CFG_ERR_WRK_WCHOWN); + } + + work_fd = wk_fd; + return (NFS4CFG_OK); +} + +static nfs4cfg_err_t +open_nfs4_files(FILE **n4_fp, FILE **wk_fp) +{ + nfs4cfg_err_t rv = NFS4CFG_OK; + + if ((rv = open_nfs4_cfg(n4_fp)) != NFS4CFG_OK) + return (rv); + + if ((rv = open_work_file(wk_fp)) != NFS4CFG_OK) + close(nfs4_fd); + + return (rv); +} + +static void +nfs4_comment_setting(FILE *src, FILE *targ, const char *pattern) +{ + char ibuf[NFS4_MAX_DOM_LEN]; + char obuf[NFS4_MAX_DOM_LEN]; + char *iptr; + char *p; + char *wptr; + size_t slen; + + while (!feof(src)) { + bzero(ibuf, NFS4_MAX_DOM_LEN); + bzero(obuf, NFS4_MAX_DOM_LEN); + if ((iptr = fgets(ibuf, NFS4_MAX_DOM_LEN, src)) == NULL) + continue; + + if ((p = strstr(ibuf, pattern)) == NULL) { + /* + * Some other line than the one we're interested + * in. Just write it out and fetch the next line. + */ + wptr = ibuf; + + } else if (p == ibuf || ibuf[0] != '#') { + /* + * If pattern was found at the beginning of the + * line _or_ even if it wasn't, if the first char + * is not a #, go ahead and insert the # and puke + * it out. + */ + slen = strlen(ibuf) + 2; + snprintf(obuf, slen, "#%s", ibuf); + wptr = obuf; + + } else + /* already commented */ + wptr = ibuf; + + (void) fputs(wptr, targ); + } + (void) fflush(targ); +} + +static int +nfs4_check_setting(FILE *src, const char *pattern) +{ + char ibuf[NFS4_MAX_DOM_LEN]; + char *iptr; + char *p; + int rv = 0; + + while (!feof(src)) { + bzero(ibuf, NFS4_MAX_DOM_LEN); + if ((iptr = fgets(ibuf, NFS4_MAX_DOM_LEN, src)) == NULL) + continue; + + if (ibuf[0] == '#' || (p = strstr(ibuf, pattern)) == NULL) + /* + * If the line is commented out or it's some other + * line than the one we're interested in, move on + */ + continue; + + else if (p == ibuf) { + /* + * If pattern is found at the beginning of the line, + * the setting is active. Use this to present to the + * user as the default _iff_ the file does not exist. + */ + extern char *chomp(char *); + + if ((p = strchr(ibuf, '=')) != NULL) { + bzero(cur_domain, NFS4_MAX_DOM_LEN); + p++; + bcopy(chomp(p), cur_domain, strlen(p)); + + /* + * If the sysadmin specified "Auto" from the + * sysidcfg script, then continue to comment + * the entry and we're done. + */ + rv = strcasecmp(cur_domain, "Auto") == 0; + } + break; + } + } + return (rv); +} + +static void +nfs4_config_setting(FILE *src, FILE *targ, const char *pattern, char *value) +{ + char ibuf[NFS4_MAX_DOM_LEN]; + char obuf[NFS4_MAX_DOM_LEN]; + char *iptr; + char *p; + char *wptr; + int done; + size_t slen; + + done = 0; + while (!feof(src)) { + bzero(ibuf, NFS4_MAX_DOM_LEN); + if ((iptr = fgets(ibuf, NFS4_MAX_DOM_LEN, src)) == NULL) + continue; + + if ((p = strstr(ibuf, pattern)) == NULL) { + /* + * Some other line than the one we're interested + * in. Just write it out and fetch the next line. + */ + wptr = ibuf; + + } else if (p == ibuf) { + /* + * pattern found uncommented at the beginning of + * the line, so make sure we set the proper value + * and write it out. + */ + if (!done) { + slen = strlen(pattern) + strlen(value) + 3; + snprintf(obuf, slen, "%s=%s\n", pattern, value); + } else { + /* + * If we've already set the pattern to the + * specified value and we happen to encounter + * additional active line(s), then comment + * them out. + */ + slen = strlen(ibuf) + 2; + snprintf(obuf, slen, "#%s", ibuf); + } + wptr = obuf; + done++; + + } else if (ibuf[0] == '#') { + /* + * pattern was found to be commented. Set to the + * specified value if we haven't already done so. + */ + if (!done) { + slen = strlen(pattern) + strlen(value) + 3; + snprintf(obuf, slen, "%s=%s\n", pattern, value); + wptr = obuf; + + } else { + /* + * Value was set previously and input line + * is already commented; just write it out. + */ + wptr = ibuf; + } + done++; + + } else { + /* + * Found the pattern, but not commented and with + * some garbo at the front. Take the conservative + * approach and comment it out. + */ + slen = strlen(ibuf) + 2; + snprintf(obuf, slen, "#%s", ibuf); + wptr = obuf; + } + (void) fputs(wptr, targ); + } + (void) fflush(targ); +} + +static void +nfs4_create_setting(FILE *targ, const char *pattern, char *value) +{ + char obuf[NFS4_MAX_DOM_LEN]; + size_t slen; + + slen = strlen(pattern) + strlen(value) + 3; + snprintf(obuf, slen, "%s=%s\n", pattern, value); + (void) fputs(obuf, targ); + (void) fflush(targ); +} + +int +config_nfs4(int cmd, const char *pattern, char *value) +{ + FILE *nfs4; + FILE *work; + nfs4cfg_err_t rv = 0; + char c; + + /* + * Make a working copy of the config file. + */ + strncpy(nfs4cfg_file, NFS4CFG_FILE, strlen(NFS4CFG_FILE)); + if (cmd == NFS4CMD_CHECK) { + if ((rv = open_nfs4_cfg(&nfs4)) != NFS4CFG_OK) + return ((int)rv); + } else { + if (rv = gen_nfs4_work_fname(nfs4cfg_file, work_file)) + return ((int)rv); + + if ((rv = open_nfs4_files(&nfs4, &work)) != NFS4CFG_OK) { + if (rv == NFS4CFG_ERR_CFG_CREAT && + cmd == NFS4CMD_CONFIG) { + /* + * revisit if NFS4CMD_UNCOMMENT + * is ever implemented + */ + nfs4_create_setting(nfs4, pattern, value); + fclose(nfs4); + return (0); + } + return ((int)rv); + } + } + + /* + * Make necessary changes to working copy of the file + */ + switch (cmd) { + case NFS4CMD_CHECK: + rv = nfs4_check_setting(nfs4, pattern); + fclose(nfs4); + return (rv); + /* NOTREACHED */ + + case NFS4CMD_CONFIG: + assert(value != NULL); + nfs4_config_setting(nfs4, work, pattern, value); + break; + + case NFS4CMD_UNCONFIG: + /* FALLTHROUGH */ + case NFS4CMD_UNCOMMENT: + break; /* ENOTSUP */ + + case NFS4CMD_COMMENT: + default: + nfs4_comment_setting(nfs4, work, pattern); + break; + } + + /* + * Install working copy (new file) over (old) config file + */ + close(work_fd); + if (rename(work_file, nfs4cfg_file) < 0) { + unlink(work_file); + return (NFS4CFG_ERR_WRK_RENAME); + } + return (0); +} diff --git a/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.h b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.h new file mode 100644 index 0000000000..78b7ac8c75 --- /dev/null +++ b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/config_nfs4.h @@ -0,0 +1,79 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _CONFIG_NFS4_H +#define _CONFIG_NFS4_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef UID_ROOT +#define UID_ROOT 0 +#endif + +#ifndef GID_SYS +#define GID_SYS 3 +#endif + +#define NFS4CFG_FILE "/etc/default/nfs" +#define NFS4STE_FILE "/etc/.NFS4inst_state.domain" + +typedef enum { + NFS4CMD_CHECK = 0, /* check pattern setting in nfs4 cfg */ + NFS4CMD_CONFIG = 1, /* set pattern=value in nfs4 cfg */ + NFS4CMD_UNCONFIG = 2, /* ENOTSUP */ + NFS4CMD_COMMENT = 3, /* comment 'pattern' in nfs4 cfg */ + NFS4CMD_UNCOMMENT = 4 /* ENOTSUP */ +} nfs4cmd_t; + +typedef enum { + NFS4CFG_OK = 0, /* success */ + NFS4CFG_ERR_CFG_STAT = -1, /* error stating /etc/default/nfs */ + NFS4CFG_ERR_CFG_OPEN_RO = -2, /* error opening nfs4 cfg file RO */ + NFS4CFG_ERR_CFG_OPEN_RW = -3, /* error opening nfs4 cfg file RW */ + NFS4CFG_ERR_CFG_CREAT = -4, /* error creating nfs4 cfg file */ + NFS4CFG_ERR_CFG_FDOPEN = -5, /* error assoc. stream to nfs4 fd */ + NFS4CFG_ERR_CFG_WCHMOD = -6, /* error on chmod of nfs4 cfg file */ + NFS4CFG_ERR_CFG_WCHOWN = -7, /* error on chown of nfs4 cfg file */ + NFS4CFG_ERR_WRK_OPEN = -8, /* error opening work file */ + NFS4CFG_ERR_WRK_FDOPEN = -9, /* error assoc. stream to work fd */ + NFS4CFG_ERR_WRK_WCHMOD = -10, /* error on chmod of work file */ + NFS4CFG_ERR_WRK_WCHOWN = -11, /* error on chown of work file */ + NFS4CFG_ERR_WRK_FNAME = -12, /* error generating work file name */ + NFS4CFG_ERR_WRK_RENAME = -13 /* error renaming work -> nfs4 cfg */ +} nfs4cfg_err_t; + +extern int config_nfs4(int, const char *, char *); +extern char cur_domain[]; + +#ifdef __cplusplus +} +#endif + +#endif /* _CONFIG_NFS4_H */ diff --git a/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.c b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.c new file mode 100644 index 0000000000..585b541c3e --- /dev/null +++ b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.c @@ -0,0 +1,312 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "sysidnfs4.h" +#include "config_nfs4.h" + +static char *term; +static char *progname; + +/* + * Validate entered domain using the + * same rules applied by nfsmapid(1m). + */ +static n4err_t +domain_validate(char *ds) +{ + int i; + + for (i = 0; *ds && i < NS_MAXCDNAME; i++, ds++) { + if (!isalpha(*ds) && !isdigit(*ds) && (*ds != '.') && + (*ds != '-') && (*ds != '_')) { + return (NFS4_ERROR_BAD_DOMAIN); + } + } + return (i == NS_MAXCDNAME ? NFS4_ERROR_DOMAIN_LEN : NFS4_SUCCESS); +} + +/* + * set TERM env var to something sane + */ +static int +set_term(void) +{ + if ((term = getenv("TERM")) == NULL) { + if (putenv(TERM_DEFAULT)) { + fprintf(stderr, PUTTERM_ERR, TERM_DEFAULT); + return (1); + } + } + return (0); +} + +static void +clear_state(void) +{ + /* + * remove the state file so the user gets prompted again + */ + (void) unlink(NFS4STE_FILE); +} + +static void +touch_state(void) +{ + int fd; + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + + /* + * create the state file so we don't get prompted again + */ + errno = 0; + if ((fd = creat(NFS4STE_FILE, mode)) < 0) { + if (errno == EDQUOT || errno == ENOSPC || errno == EROFS) + fprintf(stdout, NFS4_STATE_FILE_ERR, strerror(errno), + NFS4STE_FILE); + } else + (void) close(fd); +} + +/* + * Prompt user for whether the default NFSv4 derived domainname + * should be overriden (ie. Manual) or used (ie. Auto). + */ +static n4act_t +prompt_for_action(void) +{ + char ibuf[MAX_IBUF]; + char *p; + + /* + * Issue first prompt for action + */ + fprintf(stdout, NFS4_ACTION_TEXT_OK); + do { + fprintf(stdout, NFS4_ACTION_PROMPT); + + if ((p = fgets(ibuf, MAX_IBUF, stdin)) != NULL) { + if (ibuf[0] == '\n' || ibuf[0] == 'n' || + ibuf[0] == 'N') { + fprintf(stdout, NFS4_ACTION_TEXT_NOTE); + return (NFS4_AUTO); + + } else if (ibuf[0] == 'y' || ibuf[0] == 'Y') + return (NFS4_MANUAL); + } else { + /* + * Ctrl-D + */ + fprintf(stdout, "\n"); + clear_state(); + exit(0); + } + + /* + * Unrecognized value + */ + fprintf(stdout, NFS4_ACTION_ERR_VALUES); + + /* CONSTCOND */ + } while (1); + /* NOTREACHED */ +} + +/* + * Remove any trailing newlines or carriage returns. Note that we _must_ + * make a copy of the working buffer since the one pointed to by str is + * an array w/in the caller's stack and we need to continue using it long + * after our caller has returned. + */ +char * +chomp(char *str) +{ + int i; + int len; + char *cs; + char *p; + + if (str == (char *)NULL) + return (NULL); + + len = strlen(cs = strdup(str)); + for (i = 0, p = cs; *p && i < len; i++, p++) + if (*p == '\n' || *p == '\r') + *p = '\0'; + return (cs); +} + +/* + * Prompt user for the domain to use for inbound and outbound 'owner' + * and 'owner_group' attribute strings. The domain specified is run + * thru validation checks and if valid, the NFSMAPID_DOMAIN setting + * in /etc/default/nfs will be activated/modified with this value. + */ +static char * +prompt_for_domain(void) +{ + char ibuf[NS_MAXCDNAME]; + char *p; + char *domain; + n4err_t rv; + + /* + * Issue first prompt for domain + */ + fprintf(stdout, NFS4_DOMAIN_TEXT_OK); + do { + fprintf(stdout, NFS4_DOMAIN_PROMPT, + cur_domain[0] != '\0' ? cur_domain : ""); + + if ((p = fgets(ibuf, NS_MAXCDNAME, stdin)) == NULL) { + /* + * Ctrl-D + */ + fprintf(stdout, "\n"); + clear_state(); + exit(0); + + } else if (ibuf[0] == '\n' || ibuf[0] == '\r') { + /* + * We're presenting the user with the NFSMAPID_DOMAIN + * value (if available). If user hits <enter> and we + * have a valid cur_domain, we're done. Otherwise, + * we keep on nagging. + */ + if (ibuf[0] == '\n' && cur_domain[0] != '\0') + return (cur_domain); + + } else { + rv = domain_validate(domain = chomp(ibuf)); + if (rv == NFS4_SUCCESS) + return (domain); + } + fprintf(stdout, NFS4_DOMAIN_INVALID); + + /* CONSTCOND */ + } while (1); + /* NOTREACHED */ +} + +void +usage(int es) +{ + fprintf(stderr, USAGE_MSG, progname); + exit(es); +} + +int +main(int argc, char **argv) +{ + const char *pattern = "NFSMAPID_DOMAIN"; + char *dom; + struct stat stb; + int c; + + (void) setlocale(LC_ALL, ""); + (void) textdomain(TEXT_DOMAIN); + (void) set_term(); + + /* + * When called from sysidconfig(1m), the '-c' flag is specified; + * however, to follow a specific ordering after a sys-unconfig + * reboot, '-c' should be no-op'd so that no prompts are emitted + * until after the system has been fully configured. This requires + * sysidnfs4 to be called directly (ie. w/o any flags) from the + * /lib/svc/method/sysidtool-system script for first boot after + * either fresh install _or_ sys-unconfig. + */ + progname = argv[0]; + while ((c = getopt(argc, argv, "cu?h")) != EOF) { + switch (c) { + case 'c': + /* silent no-op */ + exit(0); + /* NOTREACHED */ + + case 'u': + /* + * sysidnfs4 needs to continue to respond to + * the '-u' flag when sys-unconfig is called + * so the NFS4STE_FILE is removed and thus, + * the prompts are re-issued on reboot. + */ + clear_state(); + exit(0); + /* NOTREACHED */ + + case 'h': + case '?': + default: + usage(-1); + /*NOTREACHED*/ + } + } + + /* + * Check config file first. If there is an active NFSMAPID_DOMAIN + * line, we use the value as the default to prompt the user with. + * If by any chance, the value is "Auto", we just comment the line + * and bail. + */ + if (config_nfs4(NFS4CMD_CHECK, pattern, NULL)) { + config_nfs4(NFS4CMD_COMMENT, pattern, NULL); + goto done; + } + + /* + * To prompt or not to prompt... that is the question. If we have + * done this successfully already, the state file should exist ! + */ + errno = 0; + if (stat(NFS4STE_FILE, &stb) == 0 || errno != ENOENT) + exit(0); + + switch (prompt_for_action()) { + case NFS4_AUTO: + config_nfs4(NFS4CMD_COMMENT, pattern, NULL); + break; + + case NFS4_MANUAL: + dom = prompt_for_domain(); + if (strcasecmp(dom, "Auto") == 0) + config_nfs4(NFS4CMD_COMMENT, pattern, NULL); + else + config_nfs4(NFS4CMD_CONFIG, pattern, dom); + + if (cur_domain[0] == '\0') + free(dom); /* alloc'd in chomp() */ + break; + + default: + break; + } + fprintf(stdout, "\n\n"); +done: + touch_state(); + exit(0); +} diff --git a/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.h b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.h new file mode 100644 index 0000000000..4391e026d7 --- /dev/null +++ b/deleted_files/usr/src/cmd/fs.d/nfs/sysidnfs4/sysidnfs4.h @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYSIDNFS4_H +#define _SYSIDNFS4_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include <ctype.h> +#include <errno.h> +#include <locale.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/fcntl.h> +#include <arpa/nameser.h> +#include <unistd.h> + +extern char *optarg; +extern int optind, opterr, optopt; + +#define MAX_IBUF 80 + +typedef enum { + NFS4_SUCCESS = 0, + NFS4_ERROR_BAD_DOMAIN = 1, + NFS4_ERROR_DOMAIN_LEN = 2 +} n4err_t; + +typedef enum { + NFS4_AUTO = 1, + NFS4_MANUAL = 2, + NFS4_BAIL = 3 +} n4act_t; + +#define TERM_DEFAULT "TERM=vt100" +#define PUTTERM_ERR gettext("Unable to set default %s\n") + +#define NFS4_ACTION_TEXT_OK \ + gettext( \ + "\n\n\tThis system is configured with NFS version 4, which uses a " \ + "domain\n\tname that is automatically derived from the system's name "\ + "services.\n\tThe derived domain name is sufficient for most " \ + "configurations. In a\n\tfew cases, mounts that cross different " \ + "domains might cause files to\n\tbe owned by \"nobody\" due to the " \ + "lack of a common domain name.") + +#define NFS4_ACTION_PROMPT \ + gettext( \ + "\n\n\tDo you need to override the system's default NFS version 4 " \ + "domain\n\tname (yes/no) ? [no] : ") + +#define NFS4_ACTION_TEXT_NOTE \ + gettext( \ + "\n\tFor more information about how the NFS version 4 default domain" \ + "\n\tname is derived and its impact, refer to the man pages for nfs(4)"\ + "\n\tand nfsmapid(1m), and the System Administration Guide: Network" \ + "\n\tServices.\n\n") + +#define NFS4_ACTION_ERR_VALUES \ + gettext( \ + "\n\tError: Valid responses are 'y' or 'n' only. Please try again.") + +#define NFS4_DOMAIN_TEXT_OK \ + gettext( \ + "\n\n\tEnter the domain to be used as the NFS version 4 domain " \ + "name.\n") + +#define NFS4_DOMAIN_PROMPT \ + gettext("\n\t\tNFS version 4 domain name [%s]: ") + +#define NFS4_DOMAIN_INVALID \ + gettext( \ + "\n\n\tError: A proper domain name should consist of a combination"\ + "\n\t of alphanumeric characters, underscores, dashes and"\ + "\n\t dots.\n") + +#define NFS4_STATE_FILE_ERR \ + gettext( \ + "\n\tError: %s\n\n\tFailure to create %s. Expect to be "\ + "prompted\n\tagain on your next reboot\n\n") + +#define USAGE_MSG \ + gettext("Usage: %s -c|-u\n") + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSIDNFS4_H */ diff --git a/deleted_files/usr/src/pkgdefs/SUNWnfscu/postinstall b/deleted_files/usr/src/pkgdefs/SUNWnfscu/postinstall new file mode 100644 index 0000000000..e40767e926 --- /dev/null +++ b/deleted_files/usr/src/pkgdefs/SUNWnfscu/postinstall @@ -0,0 +1,55 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# +# +# Copyright 2004 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# +# postinstall - Add sysidnfs4 to sysidconfig app list +# + +# +# Add sysidnfs4 to the sysidconfig fired apps so the user will +# be prompted for NFSv4 id map domain upon first system reboot. +# +# NOTE: This will/should be replaced by a future incantation of +# the sysidtools. +# +if [ -x /usr/sbin/sysidnfs4 ]; then + /usr/sbin/sysidconfig -b "${PKG_INSTALL_ROOT}" -l |\ + /usr/bin/grep -s sysidnfs4 >/dev/null + + if [ $? -ne 0 ]; then + /usr/sbin/sysidconfig -b "${PKG_INSTALL_ROOT}" \ + -a /usr/sbin/sysidnfs4 + fi +else + /usr/bin/grep -s sysidnfs4 ${PKG_INSTALL_ROOT}/etc/.sysidconfig.apps \ + >/dev/null + if [ $? -ne 0 ]; then + echo /usr/sbin/sysidnfs4 >> \ + ${PKG_INSTALL_ROOT}/etc/.sysidconfig.apps + fi +fi +exit 0 |