From 36e852a172cba914383d7341c988128b2c667fbd Mon Sep 17 00:00:00 2001 From: Raja Andra Date: Sun, 6 Dec 2009 01:39:21 -0800 Subject: 6874309 Remove NIS+ from Solaris --- usr/src/cmd/sendmail/Makefile.cmd | 6 +- usr/src/cmd/sendmail/aux/Makefile | 15 +- usr/src/cmd/sendmail/aux/aliasadm.c | 218 ----------- usr/src/cmd/sendmail/aux/nisedit.c | 533 --------------------------- usr/src/cmd/sendmail/aux/nisplus.c | 451 ----------------------- usr/src/cmd/sendmail/aux/nisplus.h | 124 ------- usr/src/cmd/sendmail/cf/sh/check-hostname.sh | 37 +- 7 files changed, 13 insertions(+), 1371 deletions(-) delete mode 100644 usr/src/cmd/sendmail/aux/aliasadm.c delete mode 100644 usr/src/cmd/sendmail/aux/nisedit.c delete mode 100644 usr/src/cmd/sendmail/aux/nisplus.c delete mode 100644 usr/src/cmd/sendmail/aux/nisplus.h (limited to 'usr/src/cmd/sendmail') diff --git a/usr/src/cmd/sendmail/Makefile.cmd b/usr/src/cmd/sendmail/Makefile.cmd index 04ea924717..d633dca0bb 100644 --- a/usr/src/cmd/sendmail/Makefile.cmd +++ b/usr/src/cmd/sendmail/Makefile.cmd @@ -20,12 +20,10 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" -# CPPFLAGS.sm= $(CPPFLAGS.master) -DSOLARIS=2$(RELEASE_MINOR)00 \ -D_FILE_OFFSET_BITS=64 -DBMDEF= -DNDBM -DNEWDB -DNIS -DNISPLUS -DUSERDB -DMAP_REGEX -DLDAPMAP +DBMDEF= -DNDBM -DNEWDB -DNIS -DUSERDB -DMAP_REGEX -DLDAPMAP diff --git a/usr/src/cmd/sendmail/aux/Makefile b/usr/src/cmd/sendmail/aux/Makefile index d33d07e754..e1e9ac24c5 100644 --- a/usr/src/cmd/sendmail/aux/Makefile +++ b/usr/src/cmd/sendmail/aux/Makefile @@ -18,18 +18,16 @@ # # CDDL HEADER END # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" -# # cmd/sendmail/aux/Makefile # include ../../Makefile.cmd include ../Makefile.cmd -PROG= mailstats mconnect vacation mailcompat aliasadm praliases mailq +PROG= mailstats mconnect vacation mailcompat praliases mailq LIBPROG= mail.local smrsh @@ -38,13 +36,12 @@ USRSBINPROG= etrn makemap editmap # $(PROG) by default CLOBBERFILES= $(LIBPROG) $(USRSBINPROG) -OBJS= $(PROG:%=%.o) nisplus.o nisedit.o +OBJS= $(PROG:%=%.o) .PARALLEL: $(OBJS) $(PROG) $(LIBPROG) $(USRSBINPROG) -SRCS= $(PROG:%=%.c) nisplus.c nisedit.c +SRCS= $(PROG:%=%.c) -aliasadm := LDLIBS += -lnsl editmap := LDLIBS += -lldap mail.local := LDLIBS += -lsocket -lnsl -lmail -lldap mailq := LDLIBS += -lsecdb @@ -81,10 +78,6 @@ vacation: vacation.o convtime.o rfc2047.o ../libsm/libsm.a ../libsm/libsm.a $(POST_PROCESS) -aliasadm: aliasadm.o nisplus.o nisedit.o - $(LINK.c) aliasadm.o nisplus.o nisedit.o -o $@ $(LDLIBS) - $(POST_PROCESS) - mail.local: mail.local.o ../libsmutil/libsmutil.a ../libsm/libsm.a $(LINK.c) mail.local.o -o $@ $(LDLIBS) ../libsmutil/libsmutil.a \ ../libsm/libsm.a diff --git a/usr/src/cmd/sendmail/aux/aliasadm.c b/usr/src/cmd/sendmail/aux/aliasadm.c deleted file mode 100644 index 21b1a5a963..0000000000 --- a/usr/src/cmd/sendmail/aux/aliasadm.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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 "nisplus.h" - -#define DEFAULT_ALIAS_MAP "mail_aliases.org_dir" - -static FILE *fp = NULL; -static char *domain, *alias_map; -static char *match_arg; - -static struct nis_mailias alias = {NULL, NULL, NULL, NULL}; - -typedef enum t_mode { - AA_NONE, - AA_ADD, - AA_CHANGE, - AA_DELETE, - AA_EDIT, - AA_MATCH, - AA_LIST, - AA_INIT -} t_mode; - -static t_mode mode; - -static void argparse(); -static void usage(); - -int -main(argc, argv) - int argc; - char **argv; -{ - nis_result *res; - - print_comments = TRUE; - - alias_map = DEFAULT_ALIAS_MAP; - - if ((domain = nis_local_directory()) == NULL) { - fprintf(stderr, "Can't get current domain\n"); - exit(-1); - } - - argparse(argc, argv); - - switch (mode) { - case AA_ADD: - nis_mailias_add(alias, alias_map, domain); - break; - case AA_CHANGE: - nis_mailias_change(alias, alias_map, domain); - break; - case AA_DELETE: - nis_mailias_delete(alias, alias_map, domain); - break; - case AA_MATCH: - res = nis_mailias_match(match_arg, - alias_map, domain, ALIAS_COL); - if (res->status == SUCCESS) { - int i; - for (i = 0; i < res->objects.objects_len; i++) - mailias_print(fp? fp: stdout, - (&res->objects.objects_val[0])+i); - } - break; - case AA_LIST: - nis_mailias_list(fp? fp: stdout, alias_map, domain); - break; - case AA_INIT: - nis_mailias_init(alias_map, domain); - break; - case AA_EDIT: - nis_mailias_edit(fp, alias_map, domain); - break; - case AA_NONE: - default: - usage(argv[0]); - exit(-1); - break; - } - return (0); -} - -static void -argparse(argc, argv) - int argc; - char **argv; -{ - int c; - int narg; - int ind; - - mode = AA_NONE; - - while ((c = getopt(argc, argv, "D:M:f:a:c:d:m:leIn")) != EOF) { - /* - * optind doesn't seem to be recognized as an extern int - * (which it is). For now, cast it. - */ - ind = (int)optind; - switch (c) { - case 'a': - mode = AA_ADD; - narg = argc - ind + 1; - if (narg < 2) { - usage(argv[0]); - fprintf(stderr, "Invalid argument\n"); - exit(-1); - } - alias.name = strdup(optarg); - alias.expn = strdup(argv[ind]); - if (narg >= 3 && *argv[ind + 1] != '-') - alias.comments = strdup(argv[ind + 1]); - if (narg >= 4 && *argv[ind + 1] != '-' && - *argv[ind + 2] != '-') { - alias.options = strdup(argv[ind + 2]); - } - break; - case 'c': - mode = AA_CHANGE; - narg = argc - ind + 1; - if (narg < 2) { - usage(argv[0]); - fprintf(stderr, "Invalid argument\n"); - exit(-1); - } - alias.name = optarg; - alias.expn = strdup(argv[ind]); - if (narg >= 3 && *argv[ind + 1] != '-') - alias.comments = strdup(argv[ind + 1]); - if (narg >= 4 && *argv[ind + 1] != '-' && - *argv[ind + 2] != '-') { - alias.options = strdup(argv[ind + 2]); - } - break; - case 'D': - domain = strdup(optarg); - break; - case 'd': - mode = AA_DELETE; - alias.name = strdup(optarg); - break; - case 'M': - alias_map = strdup(optarg); - break; - case 'm': - - mode = AA_MATCH; - match_arg = strdup(optarg); - break; - case 'n': - print_comments = FALSE; - break; - case 'f': - fp = fopen(optarg, "a+"); - if (fp == NULL) { - fprintf(stderr, "%s:", optarg); - perror("Can not open:"); - exit(-1); - } - break; - case 'e': - mode = AA_EDIT; - break; - case 'l': - mode = AA_LIST; - break; - case 'I': - mode = AA_INIT; - break; - default: - fprintf(stderr, "Invalid argument\n"); - usage(argv[0]); - exit(-1); - break; - } - } -} - -static void -usage(pname) - char *pname; -{ - fprintf(stderr, - "usage:\t%s -a alias expansion [comments] [options]\n", pname); - fprintf(stderr, "\t%s -c alias expansion [comments] [options]\n", - pname); - fprintf(stderr, "\t%s -e\n", pname); - fprintf(stderr, "\t%s -d alias\n", pname); - fprintf(stderr, "\t%s -m alias\n", pname); - fprintf(stderr, "\t%s -l\n", pname); -} diff --git a/usr/src/cmd/sendmail/aux/nisedit.c b/usr/src/cmd/sendmail/aux/nisedit.c deleted file mode 100644 index 25720ec27d..0000000000 --- a/usr/src/cmd/sendmail/aux/nisedit.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * 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 1991-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include "nisplus.h" - -#include -#include - -/* - * These are pointers to trees built from the "old" and "new" versions - * of the alias database when we run in edit mode. - */ - -static void *oroot = NULL; /* pointer to the search table built from nis */ -static void *nroot = NULL; /* pointer to the table built from the editor */ - -static int get_mailias(); -static void *mailias_parse_file(FILE *fp, nis_name map, nis_name domain); - -/* - * mailias_cmp returns 0 if the the ALIAS_COL ONLY of - * an nis alias table entry are the same. Otherwise it - * it returns -1 if obj1 is lexicographically less than obj2 - * it returns 1 if obj1 is lexicographically greater than obj2 - * N.B. This needs to be a function instead of a macro because it's - * passed to the tsearch and tfind family of routines. - */ -static int -mailias_cmp(obj1, obj2) - const void *obj1, *obj2; -{ - char *s1, *s2; -/* basically strcmp inlined for performance */ - s1 = ALIAS(((nis_object *) obj1)); - s2 = ALIAS(((nis_object *) obj2)); - - while (*s1 == *s2++) - if (*s1++ == '\0') - return (0); - return (*s1 - *--s2); -} - -/* - * mailias_eq returns 1 if ALL columns of two alias objects are - * the same. Otherwise it returns 0. - */ -static int -mailias_eq(obj1, obj2) - nis_object *obj1, *obj2; -{ - char *s1, *s2; - - /* check ALIAS column */ - s1 = ALIAS(obj1); - s2 = ALIAS(obj2); - if ((s1 != NULL) && (s2 != NULL)) { - if (strcmp(s1, s2) != 0) - return (FALSE); - } else - if (!((s1 == NULL) && (s2 == NULL))) - return (FALSE); - - /* check EXPN column */ - s1 = EXPN(obj1); - s2 = EXPN(obj2); - if ((s1 != NULL) && (s2 != NULL)) { - if (strcmp(s1, s2) != 0) - return (FALSE); - } else - if (!((s1 == NULL) && (s2 == NULL))) - return (FALSE); - - /* check COMMENTS column */ - s1 = COMMENTS(obj1); - s2 = COMMENTS(obj2); - if ((s1 != NULL) && (s2 != NULL)) { - if (strcmp(s1, s2) != 0) - return (FALSE); - } else - if (!((s1 == NULL) && (s2 == NULL))) - return (FALSE); - - /* check OPTIONS column */ - s1 = OPTIONS(obj1); - s2 = OPTIONS(obj2); - if ((s1 != NULL) && (s2 != NULL)) { - if (strcmp(s1, s2) != 0) - return (FALSE); - } else - if (!((s1 == NULL) && (s2 == NULL))) - return (FALSE); - - /* Done */ - return (TRUE); -} - -/* - * nis_mailias_list(fp, map, domain) - * prints the nis alias map contained in "map" in the domain "domain" - * to the file pointed to by "fp" in format which is human readable. - * The format is "alias: value #options#comments - * Note that unless the -n flag was specified (which turns off the - * print_comments flag) this format will NOT be compatible with the - * /etc/mail/aliases file. - */ - -void -nis_mailias_list(fp, map, domain) - FILE *fp; - nis_name map; - nis_name domain; -{ - nis_result *res; - int i; - char qmap[NIS_MAXNAMELEN]; /* fully qualified map name */ - - (void) snprintf(qmap, sizeof (qmap), "%s.%s", map, domain); - - res = nis_list(qmap, ALL_RESULTS|FOLLOW_PATH, NULL, NULL); - if (res->status == NIS_SUCCESS) { - qsort((void *) res->objects.objects_val, - (unsigned)res->objects.objects_len, - sizeof (nis_object), - mailias_cmp); - for (i = 0; i < res->objects.objects_len; i++) { - mailias_print(fp, &res->objects.objects_val[i]); - } - } -} - -/* - * check_for_deletes(obj, order, level) - * - * when we walk the tree containing the original version of the aliases - * we call this routine. If obj is in the New aliases database we do - * nothing. If obj is NOT found in the new aliases database we - * delete that alias from the nis aliases database. - */ - -/* ARGSUSED2 */ -static void -check_for_deletes(obj, order, level) - const void *obj; - VISIT order; - int level; -{ - nis_mailias a; - nis_object *old; - - /* - * need to check objects only once otherwise we might try and delete - * a deleted object - */ - if (order != preorder && order != leaf) - return; - - old = *((nis_object **)obj); - - /* N.B. obj is really a (nis_object) ** */ - if (tfind((void *)old, &nroot, mailias_cmp) != NULL) - return; - /* fall through and delete the object */ - a.name = ALIAS(old); - a.expn = EXPN(old); - a.comments = COMMENTS(old); - a.options = OPTIONS(old); -#ifdef DEBUG - fprintf(stderr, "deleting "); - mailias_print(stderr, old); -#endif - nis_mailias_delete(a, old->zo_name, old->zo_domain); -} - -/* - * check_for_changes(obj, order, level) - * - * when we walk the tree containing the version of the aliases the user created - * we call this routine. If obj is the same as in the old aliases database - * we do nothing. If obj is NOT found in the old aliases database we - * add that alias to the nis aliases database. If the obj is found in the - * old database but has been changed we change (using the nis_change - * operations) that alias in the database - */ - -/* ARGSUSED2 */ -static void -check_for_changes(obj, order, level) - const void *obj; - VISIT order; - int level; -{ - nis_object *old, *new; - nis_object **result; - nis_mailias a; - - /* - * need to check objects only once otherwise we might try and change - * or add an object that has already been changed or added. - */ - if (order != preorder && order != leaf) - return; - - new = *((nis_object **)obj); - /* N.B. obj is really a (nis_object) ** */ - result = (nis_object **) tfind((void *)new, &oroot, mailias_cmp); - old = (result ? *result : NULL); - - if (old == NULL) { - a.name = ALIAS(new); - a.expn = EXPN(new); - a.comments = COMMENTS(new); - a.options = OPTIONS(new); -#ifdef DEBUG - fprintf(stderr, "adding "); - mailias_print(stderr, new); -#endif - nis_mailias_add(a, new->zo_name, new->zo_domain); - return; - } - if (mailias_eq(old, new)) { - /* alias entry was not changed */ -#ifdef DEBUG - fprintf(stderr, "unchanged "); - mailias_print(stderr, new); -#endif - return; - } - /* i.e. the alias entry has changed */ - a.name = ALIAS(new); - a.expn = EXPN(new); - a.comments = COMMENTS(new); - a.options = OPTIONS(new); -#ifdef DEBUG - fprintf(stderr, "changing "); - mailias_print(stderr, new); -#endif - nis_mailias_change(a, new->zo_name, new->zo_domain); -} - -/* - * nis_mailias_edit(FILE *fp, nis_name map, nis_man domain) - * - * Edit's the alias map "map" in domain "domain". If fp is non-NULL - * The file pointed to by fp contains the new alias map and no - * editor is invoked. - * The method used is to build two search trees and compare them. - * The first tree pointed to by oroot contains the original alias map. - * the second tree pointed to by nroot contains the desired aliases map. - * The old tree is walked first, if any of the aliases in the old tree are - * missing in the new tree those aliases are deleted. The new tree is - * then walked. If the aliases are added or changed the apropriate - * mailias_function is called. - */ - -void -nis_mailias_edit(fp, map, domain) - FILE *fp; - nis_name map; - nis_name domain; -{ - nis_result *res; - char qmap[NIS_MAXNAMELEN]; /* fully qualified map name */ - int i; - char *editor, *cmd, *tmpfname; - size_t cmdsize; - - void *key; - - if (!check_table(map, domain)) { - fprintf(stderr, "Alias table %s.%s does not exist\n", - map, domain); - exit(-1); - } - - (void) snprintf(qmap, sizeof (qmap), "%s.%s", map, domain); - res = nis_list(qmap, ALL_RESULTS|FOLLOW_PATH, NULL, NULL); - if (res->status == NIS_SUCCESS) { - qsort((void *) res->objects.objects_val, - (unsigned)res->objects.objects_len, - sizeof (nis_object), - mailias_cmp); - } - if (fp == NULL) { - tmpfname = tmpnam(NULL); - fp = fopen(tmpfname, "w"); - /* print the aliases into a temporary file */ - if (res -> status == NIS_SUCCESS) { - for (i = 0; i < res->objects.objects_len; i++) { - mailias_print(fp, &res->objects.objects_val[i]); - } - } - fclose(fp); - /* invoke the users editor on that file */ - editor = getenv("VISUAL"); - if (editor == NULL) - editor = getenv("EDITOR"); - if (editor == NULL) - editor = "/usr/bin/vi"; - cmdsize = strlen(editor) + strlen(tmpfname) + 2; - cmd = (char *)malloc(cmdsize); - if (cmd == NULL) { - perror(NULL); - exit(-1); - } - (void) snprintf(cmd, cmdsize, "%s %s", editor, tmpfname); - system(cmd); - fp = fopen(tmpfname, "r"); - nroot = mailias_parse_file(fp, map, domain); - fclose(fp); - unlink(tmpfname); - } else { - /* they used the -f command option to read from a file */ - nroot = mailias_parse_file(fp, map, domain); - } - - /* If there were entries in the existing map */ - if (res -> status == NIS_SUCCESS) { - for (i = 0; i < res->objects.objects_len; i++) { - key = (void *) &(res->objects.objects_val[i]); - (void) tsearch(key, &oroot, mailias_cmp); - } - twalk(oroot, check_for_deletes); - } - twalk(nroot, check_for_changes); -} - -/* - * mailias_parse_file(fp, map, domain) - * - * Returns a pointer to a tsearch(3) style tree which contains nis mail - * alias objects. - */ - -extern void * -mailias_parse_file(fp, map, domain) - FILE *fp; - nis_name map; - nis_name domain; -{ - char lbuf[4*NIS_MAXNAMELEN + MAXLINE]; - int skipping = FALSE; - int next_char; - char *lp = NULL; /* pointer to an alias line */ - char *p; - nis_mailias a; - nis_object *obj; - void *root = NULL; - - - while (fgets(lbuf, sizeof (lbuf), fp) != NULL) { - /* This used to be a strchr but was inlined for performance */ - for (p = lbuf; *p != '\n' && *p != '\0'; p++) - ; - *p = '\0'; /* get rid of \n in the string */ - switch (lbuf[0]) { - case '#': - case '\0': - skipping = FALSE; - continue; - - case ' ': - case '\t': - if (!skipping) - fprintf(stderr, - "Non-continuation line starts with space\n"); - skipping = TRUE; - continue; - } - skipping = FALSE; - - /* - * Find and Read Any lines that start with whitespace - * (continuation lines) - */ - lp = strdup(lbuf); - while ((next_char = getc(fp)) != EOF) { - if (next_char == '\t' || next_char == ' ') { - size_t lpsize = strlen(p) + strlen(lbuf); - /* Read a Continuation line */ - ungetc(next_char, fp); - (void) fgets(lbuf, sizeof (lbuf), fp); - p = lp; - lp = (char *)malloc(lpsize); - if (p != NULL) { - (void) strlcpy(lp, p, lpsize); - free(p); - } - - /* - * used to be a strchr, - * inlined for performance - */ - for (p = lbuf; *p != '\n' && *p != '\0'; p++) - ; - *p = '\0'; - (void) strlcat(lp, lbuf, lpsize); - } else { - ungetc(next_char, fp); - break; - } - } - - /* Find The Alias Name */ - a.name = ""; - a.expn = ""; - a.comments = ""; - a.options = ""; - - (void) get_mailias(&a, lp); - if (lp != NULL) - free(lp); - - - if (strcmp(a.name, "") != 0) { - obj = mailias_make_entry(a, map, domain); - (void) tsearch((void *) obj, &root, mailias_cmp); - } - } - return (root); -} - -/* - * get_mailias(a, lbuf) - * - * put's the mail alias from lbuf into the alias structure a. - * Note that this ISN'T the same format as the /etc/alias file. - * In /etc/aliases #'s (which are used here to separate fields) - * are perfectly legal on the right hand side of an alias (although - * sendmail won't handle that sort of alias) - */ -static int -get_mailias(a, lbuf) - nis_mailias *a; - char *lbuf; -{ - char *ap; /* pointer to the end of the alias field */ - char *ep; /* pointer to the end of the expansion field */ - char *cp; /* pointer to the end of the comment field */ - int cdepth = 0; /* if > 0 we're in a user name comment */ - /* (in parens) */ - - /* Find the ":", all aliases should be of the form alias: value */ - /* There used to be a strchr here that was inlined for performance */ - for (ap = lbuf; *ap != ':' && *ap != '\0'; ap++) - ; - if (ap == '\0') { - fprintf(stderr, "Warning, missing colon in alias\n"); - return (FALSE); - } - - /* Allocate space and copy the alias into a->name */ - a->name = (char *)malloc((ap - lbuf) + 1); - if (a->name == NULL) { - perror(NULL); - return (FALSE); - } - strncpy(a->name, lbuf, ap - lbuf); - a->name[ap - lbuf] = '\0'; /* terminate the string with NUL */ - - /* Read the alias value */ - for (ep = ap; (*ep != '#' || cdepth > 0) && *ep != '\0'; ep++) { - if (*ep == '(') - cdepth++; - if (*ep == ')' && (cdepth > 0)) - cdepth--; - } - a->expn = (char *)malloc((ep - ap) + 1); - if (a->expn == NULL) { - perror(NULL); - return (FALSE); - } - strncpy(a->expn, ap + 1, ep - (ap + 1)); /* this eliminates the : */ - a->expn[ep - (ap + 1)] = '\0'; - - /* i.e. there are no comments or options */ - if (*ep == '\0') - return (TRUE); - - /* Read the comments field value */ - cdepth = 0; - for (cp = ep + 1; (*cp != '#' || cdepth > 0) && *cp != '\0'; cp++) { - /* - * Note that notion of comments in parens inside a comment - * field is a bit strange. It's really just a way to - * embed "#"'s in your comments - */ - if (*cp == '(') - cdepth++; - if (*cp == ')' && (cdepth > 0)) - cdepth--; - } - a->comments = (char *)malloc(cp - ep); - if (a->comments == NULL) { - perror(NULL); - return (FALSE); - } - - /* this eliminates the # */ - strncpy(a->comments, ep + 1, cp - (ep + 1)); - a->comments[cp - (ep + 1)] = '\0'; - - /* i.e. there are no options */ - if (*cp == '\0') - return (TRUE); - - a->options = strdup(cp + 1); /* make sure to skip the # */ - return (TRUE); -} diff --git a/usr/src/cmd/sendmail/aux/nisplus.c b/usr/src/cmd/sendmail/aux/nisplus.c deleted file mode 100644 index 9fc1ad4df4..0000000000 --- a/usr/src/cmd/sendmail/aux/nisplus.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * 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 1994-2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include "nisplus.h" - -#include -#include -#include -#include - -static void space_rm(); -static nis_object *mailias_make_table(nis_name name, nis_name domain); - -/* - * Mailias_print(FILE *fp, nis_object *obj) - * takes an nis_object * which points to an nis mail alias - * object and prints to the file pointed to by fp. - */ - -void -mailias_print(fp, obj) - FILE *fp; - nis_object *obj; -{ - char *val; - char *c, *o; - - /* - * Need to print out an empty comments field if there's no - * comments but there are OPTIONS - */ - - if (obj->zo_data.zo_type != NIS_ENTRY_OBJ) - return; - - if (obj->EN_len != MAILIAS_COLS) { - fprintf(fp, "warning: alias map has %d cols should have %d\n", - obj->EN_len, MAILIAS_COLS); - return; - } - - val = ALIAS(obj); - fprintf(fp, "%s: ", val? val: ""); - - val = EXPN(obj); - fprintf(fp, "%s", val? val: ""); - - c = COMMENTS(obj) ? COMMENTS(obj) : ""; - o = OPTIONS(obj) ? OPTIONS(obj) : ""; - - if (print_comments && !(*c == '\0' && *o == '\0')) { - fprintf(fp, "#%s#%s", c, o); - } - fprintf(fp, "\n"); -} - -nis_result * -nis_mailias_match(name, map, domain, field) - char *name; - nis_name domain; - nis_name map; - int field; -{ - nis_result *res; - - char qbuf[MAXLINE + NIS_MAXNAMELEN]; - - name = strdup(name); - space_rm(name); - - if (!check_table(map, domain)) { - res = (nis_result *)malloc(sizeof (nis_result)); - if (res == NULL) { - perror(NULL); - exit(-1); - } - res->status = NIS_NOTFOUND; - free(name); - return (res); - } - switch (field) { - case EXPANSION_COL: - (void) snprintf(qbuf, sizeof (qbuf), "[expansion=%s],%s.%s", - name, map, domain); - break; - case ALIAS_COL: - default: - (void) snprintf(qbuf, sizeof (qbuf), "[alias=%s],%s.%s", name, - map, domain); - break; - } - res = nis_list(qbuf, FOLLOW_LINKS | FOLLOW_PATH, NULL, NULL); - free(name); - return (res); -} - -/* - * nis_mailias_init(nis_name domain, nis_name map) - * initialiases an alias map in the given domain and gives the map - * the name passed to it in the second parameter. This is usually used - * with the current domain and on the map mail_aliases - */ -void -nis_mailias_init(map, domain) - nis_name domain; - nis_name map; -{ - nis_object *ntable; - nis_result *res; - char name_buf[NIS_MAXNAMELEN]; - - if (check_table(map, domain)) { - fprintf(stderr, "Alias table %s.%s already exists\n", - map, domain); - exit(-1); - } - - ntable = mailias_make_table(map, domain); - (void) snprintf(name_buf, sizeof (name_buf), "%s.%s", map, domain); - res = nis_add(name_buf, ntable); - if (res->status != NIS_SUCCESS) { - fprintf(stderr, "NIS alias map creation failed: %d\n", - res->status); - exit(-1); - } -} - -/* - * nis_mailias_add( nis_mailias a, nis_name alias_map, nis_name domain) - * adds the alias entry a to the map alias_map in domain "domain". - * e.g. nis_mailias_add( a, "mail_aliases", "Eng.Sun.COM."); - */ -void -nis_mailias_add(a, alias_map, domain) - nis_mailias a; - nis_name alias_map; - nis_name domain; -{ - nis_result *res; - nis_object *a_entry; - char name_buf[MAXLINE + NIS_MAXNAMELEN]; - - space_rm(a.name); - - res = nis_mailias_match(a.name, alias_map, domain, ALIAS_COL); - if (res->status == NIS_SUCCESS) { - fprintf(stderr, "alias %s: is already in the map\n", a.name); - exit(-1); - } - a_entry = mailias_make_entry(a, alias_map, domain); - (void) snprintf(name_buf, sizeof (name_buf), "%s.%s", alias_map, - domain); - res = nis_add_entry(name_buf, a_entry, 0); - if (res->status != NIS_SUCCESS) { - fprintf(stderr, "NIS alias add failed: %d\n", res->status); - exit(-1); - } -} - - -/* - * nis_mailias_delete( nis_mailias a, nis_name alias_map, nis_name domain) - * removes the alias entry a from the table alias_map in domain "domain". - * e.g. nis_mailias_delete( a, "mail_aliases", "Eng.Sun.COM."); - */ -void -nis_mailias_delete(a, alias_map, domain) - nis_mailias a; - nis_name alias_map; - nis_name domain; -{ - nis_result *res; - char name_buf[MAXLINE + NIS_MAXNAMELEN]; - - space_rm(a.name); - - res = nis_mailias_match(a.name, alias_map, domain, ALIAS_COL); - if (res->status != NIS_SUCCESS) { - fprintf(stderr, "alias %s: not found in the map\n", a.name); - exit(-1); - } - - (void) snprintf(name_buf, sizeof (name_buf), "%s.%s", alias_map, - domain); - res = nis_remove_entry(name_buf, NIS_RES_OBJECT(res), 0); - if (res->status != NIS_SUCCESS) { - fprintf(stderr, "NIS alias remove failed: %d\n", res->status); - exit(-1); - } - -} - -/* - * nis_mailias_change( nis_mailias a, nis_name alias_map, nis_name domain) - * changes the alias entry a in the table alias_map in domain "domain". - * e.g. nis_mailias_change( a, "mail_aliases", "Eng.Sun.COM."); - */ -void -nis_mailias_change(a, alias_map, domain) - nis_mailias a; - nis_name alias_map; - nis_name domain; -{ - nis_result *res; - char name_buf[MAXLINE + NIS_MAXNAMELEN]; - char *val; - - space_rm(a.name); - - res = nis_mailias_match(a.name, alias_map, domain, ALIAS_COL); - if (res->status != NIS_SUCCESS) { - fprintf(stderr, "alias %s: not found in the map\n", a.name); - exit(-1); - } - - space_rm(a.expn); - - val = a.expn ? a.expn : ""; - NIS_RES_OBJECT(res)->EN_col(EXPANSION_COL) = val; - NIS_RES_OBJECT(res)->EN_col_len(EXPANSION_COL) = strlen(val) + 1; - NIS_RES_OBJECT(res)->EN_col_flags(EXPANSION_COL) = EN_MODIFIED; - - val = a.comments ? a.comments: ""; - - NIS_RES_OBJECT(res)->EN_col(COMMENTS_COL) = val; - NIS_RES_OBJECT(res)->EN_col_len(COMMENTS_COL) = strlen(val) + 1; - NIS_RES_OBJECT(res)->EN_col_flags(COMMENTS_COL) = EN_MODIFIED; - - val = a.options ? a.options : ""; - NIS_RES_OBJECT(res)->EN_col(OPTIONS_COL) = val; - NIS_RES_OBJECT(res)->EN_col_len(OPTIONS_COL) = strlen(val) + 1; - NIS_RES_OBJECT(res)->EN_col_flags(OPTIONS_COL) = EN_MODIFIED; - - (void) snprintf(name_buf, sizeof (name_buf), "[alias=%s],%s.%s", a.name, - alias_map, domain); - res = nis_modify_entry(name_buf, NIS_RES_OBJECT(res), 0); - if (res->status != NIS_SUCCESS) { - fprintf(stderr, "NIS alias modify failed: %d\n", res->status); - exit(-1); - } -} - -/* - * Makes and Nis_alias table entry object, given 4 (possibly NULL) - * values to put in the columns. - */ -nis_object * -mailias_make_entry(a, name, domain) - nis_mailias a; - nis_name name; - nis_name domain; -{ - nis_object *ret; - char name_buf[NIS_MAXNAMELEN]; - - space_rm(a.name); - - ret = (nis_object *)malloc(sizeof (nis_object)); - if (ret == NULL) { - perror(NULL); - exit(-1); - } - ret->zo_name = name; - (void) snprintf(name_buf, sizeof (name_buf), "%s.%s", - (getpwuid(getuid())->pw_name), domain); - ret->zo_owner = strdup(name_buf); - ret->zo_group = ""; - ret->zo_domain = domain; - ret->zo_access = DEFAULT_RIGHTS; - ret->zo_ttl = 24 * 60 * 60; - - ret->zo_data.zo_type = NIS_ENTRY_OBJ; - ret->EN_data.en_type = TABLE_TYPE; - ret->EN_len = MAILIAS_COLS; - - ret->EN_colp = (entry_col *)malloc(MAILIAS_COLS * - sizeof (struct entry_col)); - if (ret->EN_colp == NULL) { - perror(NULL); - exit(-1); - } - ret->EN_col(ALIAS_COL) = a.name ? a.name : ""; - ret->EN_col_len(ALIAS_COL) = strlen(ret->EN_col(ALIAS_COL)) + 1; - - space_rm(a.expn); - - ret->EN_col(EXPANSION_COL) = a.expn ? a.expn : ""; - ret->EN_col_len(EXPANSION_COL) = - strlen(ret->EN_col(EXPANSION_COL)) + 1; - - ret->EN_col(COMMENTS_COL) = a.comments ? a.comments : ""; - ret->EN_col_len(COMMENTS_COL) = strlen(ret->EN_col(COMMENTS_COL)) + 1; - - ret->EN_col(OPTIONS_COL) = a.options ? a.options : ""; - ret->EN_col_len(OPTIONS_COL) = strlen(ret->EN_col(OPTIONS_COL)) + 1; - - return (ret); -} - -/* - * Makes and Nis_alias table entry object, given 4 (possibly NULL) - * values to put in the columns. - */ -nis_object * -mailias_make_table(name, domain) - nis_name name; - nis_name domain; -{ - nis_object *ret; - char name_buf[NIS_MAXNAMELEN]; - - ret = (nis_object *)malloc(sizeof (nis_object)); - if (ret == NULL) { - perror(NULL); - exit(-1); - } - ret->zo_name = strdup(name); - (void) snprintf(name_buf, sizeof (name_buf), "%s.%s", - (getpwuid(getuid())->pw_name), domain); - ret->zo_owner = strdup(name_buf); - ret->zo_group = ""; - ret->zo_domain = strdup(domain); - ret->zo_access = DEFAULT_RIGHTS; - ret->zo_ttl = 24 * 60 * 60; - - ret->zo_data.zo_type = NIS_TABLE_OBJ; - ret->TA_data.ta_type = strdup(TABLE_TYPE); - ret->TA_data.ta_maxcol = MAILIAS_COLS; - - ret->TA_data.ta_sep = ' '; - ret->TA_data.ta_cols.ta_cols_len = MAILIAS_COLS; - ret->TA_data.ta_path = ""; - ret->TA_data.ta_cols.ta_cols_val = - (struct table_col *)malloc(sizeof (table_col) * MAILIAS_COLS); - if (ret->TA_data.ta_cols.ta_cols_val == NULL) { - perror(NULL); - exit(-1); - } - - ret->TA_val(ALIAS_COL).tc_name = "alias"; - ret->TA_val(ALIAS_COL).tc_flags = TA_SEARCHABLE; - ret->TA_val(ALIAS_COL).tc_rights = DEFAULT_RIGHTS; - - ret->TA_val(EXPANSION_COL).tc_name = "expansion"; - ret->TA_val(EXPANSION_COL).tc_flags = TA_SEARCHABLE; - ret->TA_val(EXPANSION_COL).tc_rights = DEFAULT_RIGHTS; - - ret->TA_val(COMMENTS_COL).tc_name = "comments"; - ret->TA_val(COMMENTS_COL).tc_flags = 0; - ret->TA_val(COMMENTS_COL).tc_rights = DEFAULT_RIGHTS; - - ret->TA_val(OPTIONS_COL).tc_name = "options"; - ret->TA_val(OPTIONS_COL).tc_flags = 0; - ret->TA_val(OPTIONS_COL).tc_rights = DEFAULT_RIGHTS; - - return (ret); -} - -#define UNINIT 3 - -/* - * Check to see if the aliases database is initialized/installed in - * the proper format. - * - */ -int -check_table(nis_name mapname, nis_name domain) -{ - nis_result *res = NULL; - static int succeeded = UNINIT; - - char qbuf[MAXLINE + NIS_MAXNAMELEN]; - - if (succeeded != UNINIT) - return (succeeded); - - (void) snprintf(qbuf, sizeof (qbuf), "%s.%s", mapname, domain); - while (res == NULL || res->status != NIS_SUCCESS) { - res = nis_lookup(qbuf, FOLLOW_LINKS); - - switch (res->status) { - - case NIS_SUCCESS: - case NIS_TRYAGAIN: - case NIS_RPCERROR: - break; - default: /* all other nisplus errors */ - succeeded = FALSE; - return (FALSE); - }; - sleep(2); /* try not overwhelm hosed server */ - } - - if (NIS_RES_NUMOBJ(res) != 1 && - (NIS_RES_OBJECT(res)->zo_data.zo_type != NIS_TABLE_OBJ)) { - succeeded = FALSE; - return (FALSE); - } - succeeded = TRUE; - return (TRUE); - -} - -/* - * space_rm -- takes a pointer to a string as its input. It removes - * all spaces and tabs from that string, except for those - * inside double quotes. - */ - -void -space_rm(char *str) -{ - char *t1; - int in_comment = FALSE; - - t1 = str; - while (*str != '\0') { - if (*str == '"') - in_comment = !in_comment; - if (in_comment || !isspace(*str)) - *t1++ = *str++; - else - str++; - } - *t1 = '\0'; -} diff --git a/usr/src/cmd/sendmail/aux/nisplus.h b/usr/src/cmd/sendmail/aux/nisplus.h deleted file mode 100644 index 0997fae6ca..0000000000 --- a/usr/src/cmd/sendmail/aux/nisplus.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 (c) 1994, 1997, 1998 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include - -#undef NIS /* confict in nis.h */ -#undef T_UNSPEC /* symbol conflict in nis.h -> ... -> sys/tiuser.h */ - -#include -#include - -/* - * Defines for Nisplus alias handling functions - */ - -#define TABLE_TYPE "mail_aliases" - -/* - * Operating modes - */ - -struct nis_mailias -{ - char *name; - char *expn; - char *comments; - char *options; -}; - -typedef struct nis_mailias nis_mailias; - -#define FORWARD 0 -#define REVERSE 1 - -#define MAILIAS_COLS 4 /* Number of cols in a mailias entry */ -/* - * These are the the columns in the NIS+ Table. - */ -#define ALIAS_COL 0 /* the name of the alias */ -#define EXPANSION_COL 1 /* what the alias expands to */ -#define COMMENTS_COL 2 /* Human readable comments */ -/* - * Options column, - * This consists of a list of - * VARIABLE=VALUE, or VARIABLE names - */ -#define OPTIONS_COL 3 - -#define MAXLINE 2048 /* max line length */ - -#define EN_len zo_data.objdata_u.en_data.en_cols.en_cols_len -#define EN_colp zo_data.objdata_u.en_data.en_cols.en_cols_val -#define EN_col_len(col) \ - zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_len -#define EN_col_flags(col) \ - zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_flags -#define EN_col(col) \ - zo_data.objdata_u.en_data.en_cols.en_cols_val[(col)].ec_value.ec_value_val - -/* - * Macros which extract the Alias, Expansion, Comments, or Options column - * of an nis alias table object - */ -#define ALIAS(obj) ((obj)->EN_col(ALIAS_COL)) -#define EXPN(obj) ((obj)->EN_col(EXPANSION_COL)) -#define COMMENTS(obj) ((obj)->EN_col(COMMENTS_COL)) -#define OPTIONS(obj) ((obj)->EN_col(OPTIONS_COL)) - -#define TA_val(col) zo_data.objdata_u.ta_data.ta_cols.ta_cols_val[(col)] - -extern int check_table(nis_name mapname, nis_name domain); - -extern void nis_mailias_add(nis_mailias a, nis_name alias_map, nis_name domain); - -extern void nis_mailias_change(nis_mailias a, nis_name alias_map, - nis_name domain); - -extern void nis_mailias_delete(nis_mailias a, nis_name alias_map, - nis_name domain); - -extern void nis_mailias_edit(FILE *fp, nis_name map, nis_name domain); - -extern void nis_mailias_init(nis_name map, nis_name domain); - -extern void nis_mailias_list(FILE *fp, nis_name map, nis_name domain); - -extern nis_result *nis_mailias_match(char *name, nis_name map, - nis_name domain, int qtype); - -extern nis_object *mailias_make_entry(struct nis_mailias a, - nis_name map, nis_name domain); - -extern void mailias_print(FILE *fp, nis_object *obj); - -extern int print_comments; /* Tells us whether to print comments and OPTIONS */ -int print_comments; diff --git a/usr/src/cmd/sendmail/cf/sh/check-hostname.sh b/usr/src/cmd/sendmail/cf/sh/check-hostname.sh index 1354153be6..a5c2c726f5 100644 --- a/usr/src/cmd/sendmail/cf/sh/check-hostname.sh +++ b/usr/src/cmd/sendmail/cf/sh/check-hostname.sh @@ -3,9 +3,8 @@ # 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. +# Common Development and Distribution License (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. @@ -25,11 +24,9 @@ # # See http://www.sendmail.org/sun-specific/migration.html#FQHN for details. # -# Copyright (c) 1997-2000 by Sun Microsystems, Inc. -# All Rights Reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. # -# %W% (Sun) %G% -# ident "%Z%%M% %I% %E% SMI" PATH=/bin:/usr/sbin @@ -86,18 +83,6 @@ check_nis() { done } -# Check the `nismatch $1 hosts` output. Its output is different from ypmatch -# and the hosts file. Field 1 is a cname (i.e., alias), field 2 is the -# proper name, field 3 is the IP address and field 4 is comment. - -check_nisplus() { - for hst in `nismatch $1 hosts.org_dir | \ - awk '{for (f=1; f <= 2; f++) print $f}'` - do - accept_if_fully_qualified $hst - done -} - # Recommend how to reconfigure to get $1.$2 as the FQHN. # $3 is the first entry for hosts in /etc/nsswitch.conf . @@ -129,9 +114,9 @@ suggest_fix_and_exit() { exit 0 } -# Fall back to the NIS[+] domain, minus the first label. If it is non-null, +# Fall back to the NIS domain, minus the first label. If it is non-null, # use it but recommend against it. $2 is just informative, indicating whether -# we're checking the NIS or NIS+ domain. $3 is to pass on. +# we're checking the NIS domain. $3 is to pass on. check_nis_domain() { nisdomain=`domainname` @@ -154,8 +139,7 @@ check_nis_domain() { # * files (parse /etc/hosts directly) # * dns (parse nslookup output) # * nis (parse ypmatch output) -# * nisplus (parse nismatch output) -# 3. fall back to the NIS[+] domain name. +# 3. fall back to the NIS domain name. # If none of the above succeed, give up. Recommend: # a. the domain entry in /etc/resolv.conf, if one exists # b. "pick.some.domain" @@ -181,10 +165,6 @@ do check_nis $myhostname nis_domains="$nis_domains nis" ;; - nisplus) - check_nisplus $myhostname - nis_domains="$nis_domains nisplus" - ;; esac done @@ -194,9 +174,6 @@ do nis) check_nis_domain $myhostname "" $first_hosts_entry ;; - nisplus) - check_nis_domain $myhostname "+" $first_hosts_entry - ;; esac done -- cgit v1.2.3