diff options
| author | Peter Tribble <peter.tribble@gmail.com> | 2017-03-04 16:41:35 +0000 |
|---|---|---|
| committer | Dan McDonald <danmcd@omniti.com> | 2017-03-07 11:40:25 -0500 |
| commit | e961d62d99e2bf66af8058ee2c33ea689e7eafa0 (patch) | |
| tree | 4a003cf5eaf9ec1697e99e9d2302ffd826db1e54 | |
| parent | 78b029b7f02730d3acc32084cd9fc419a0d0fb50 (diff) | |
| download | illumos-joyent-e961d62d99e2bf66af8058ee2c33ea689e7eafa0.tar.gz | |
7936 Remove on and rpc.rexd
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Dale Ghent <daleg@omniti.com>
Approved by: Dan McDonald <danmcd@omniti.com>
29 files changed, 2 insertions, 6114 deletions
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index 1c5318893d..c3040a512a 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -345,7 +345,6 @@ COMMON_SUBDIRS= \ refer \ regcmp \ renice \ - rexd \ rm \ rmdir \ rmformat \ diff --git a/usr/src/cmd/Makefile.check b/usr/src/cmd/Makefile.check index 8c141358e7..fbe01f3b28 100644 --- a/usr/src/cmd/Makefile.check +++ b/usr/src/cmd/Makefile.check @@ -60,7 +60,6 @@ MANIFEST_TOPDIRS= \ oplhpd \ pools \ power \ - rexd \ rmvolmgr \ rpcbind \ rpcsvc \ diff --git a/usr/src/cmd/rexd/Makefile b/usr/src/cmd/rexd/Makefile deleted file mode 100644 index e237e30430..0000000000 --- a/usr/src/cmd/rexd/Makefile +++ /dev/null @@ -1,128 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# 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. -# 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 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# Copyright 2015 RackTop Systems. -# - -PROG= rpc.rexd on -# where under -#RPCGEN= rpcgen -REXDPROG= rpc.rexd -ONPROG = on - -MANIFEST= rex.xml - -include ../Makefile.cmd - -CERRWARN += -_gcc=-Wno-implicit-function-declaration -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-unused-variable -CERRWARN += -_gcc=-Wno-address -CERRWARN += -_gcc=-Wno-unused-function -CERRWARN += -_gcc=-Wno-extra - -ROOTMANIFESTDIR= $(ROOTSVCNETWORKRPC) - -SRCS= $(PROG:%=%.c) - -#OBJS= errprintf.o mount_nfs.o rex_xdr.o unix_login.o mntent.o -TYPEOBJS= nfs_subr.o -OBJS= errprintf.o mount_nfs.o rex.o unix_login.o mntent.o $(TYPEOBJS) -REXDOBJS= rpc.rexd.o errprintf.o mount_nfs.o rex.o unix_login.o mntent.o -ONOBJS= on.o sharetab.o where.o rex.o mntent.o -#WHEREOBJS= sharetab.o where.o where_main.o mntent.o -CLEANOBJS= exportent.o sharetab.o on.o rpc.rexd.o where.o -#under.o where.o where_main.o -#UNDEROBJS= errprintf.o sharetab.o mount_nfs.o - -ROOTREXD= $(ROOTUSRSBIN) -ROOTON= $(ROOTBIN) -ROOTREXDPROG= $(REXDPROG:%=$(ROOTREXD)/%) -ROOTONPROG= $(ONPROG:%=$(ROOTON)/%) - -CPPFLAGS = -I. $(CPPFLAGS.master) - -LDLIBS += -lsocket -lnsl -rpc.rexd := LDLIBS += -lrpcsvc -lbsm -lpam - -TYPESRCS= ../nfs/lib/nfs_subr.c - -# install rule -# don't re-install directories created by Targetdirs -#$(ROOTREXD)/%: % -# $(INS.file) -#$(ROOTON)/%: % -# $(INS.file) - -.KEEP_STATE: - -all: $(PROG) - -rpc.rexd: $$@.o $(OBJS) - $(LINK.c) -o $@ $@.o $(OBJS) $(LDLIBS) - $(POST_PROCESS) - -on: $(ONOBJS) - $(LINK.c) -o $@ $(ONOBJS) $(LDLIBS) - $(POST_PROCESS) - -#under: $$@.o $(UNDEROBJS) -# $(LINK.c) -o $@ $@.o $(UNDEROBJS) $(LDLIBS) -# -#where: $(WHEREOBJS) -# $(LINK.c) -o $@ $(WHEREOBJS) $(LDLIBS) -# -install: all $(ROOTREXDPROG) $(ROOTONPROG) $(ROOTMANIFEST) - -$(ROOTREXD): rpc.rexd - $(INS.dir) -$(ROOTON): on - $(INS.dir) - -check: $(CHKMANIFEST) - -clean: - $(RM) $(OBJS) $(CLEANOBJS) $(PROG) - -lint: lint_SRCS - -include ../Makefile.targ - -# derived source files and explicit dependencies - -#rex_xdr.o \ -#rex_svc.o \ -#rex_clnt.o: rex.h rex.c -# $(LINK.c) -c -o $@ rex.c $(LDLIBS) - -on.o: rex.h - -rpc.rexd.o: rex.h - -unix_login.o: rex.h - -rex.o: rex.h - -nfs_subr.o: ../fs.d/nfs/lib/nfs_subr.c - $(COMPILE.c) ../fs.d/nfs/lib/nfs_subr.c diff --git a/usr/src/cmd/rexd/errprintf.c b/usr/src/cmd/rexd/errprintf.c deleted file mode 100644 index 4dcd0fa1eb..0000000000 --- a/usr/src/cmd/rexd/errprintf.c +++ /dev/null @@ -1,54 +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 2004 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 <stdarg.h> - -/* - * errprintf will print a message to standard error channel, - * and return the same string in the given message buffer. - * We add an extra return character in case the console is in raw mode. - */ -void -errprintf(char *err, char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - - if (err) { - vsprintf(err, fmt, ap); - fprintf(stderr,"%s\r",err); - } else { - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\r"); - } - va_end(ap); -} - diff --git a/usr/src/cmd/rexd/mntent.c b/usr/src/cmd/rexd/mntent.c deleted file mode 100644 index babca4de7d..0000000000 --- a/usr/src/cmd/rexd/mntent.c +++ /dev/null @@ -1,239 +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" - -#define LOCK_EX 1 - -#include <stdio.h> -#include <ctype.h> -#include <sys/mntent.h> -#include <sys/mnttab.h> - -static struct mnttab *mntp = 0; - -int getmntent(FILE *mnttabp, struct mnttab *mp); -static int mntdigit(char **p); -extern char *calloc(); - -struct mnttab * -_mnt() -{ - - if (mntp == 0) - mntp = (struct mnttab *)calloc(1, sizeof (struct mnttab)); - return (mntp); -} - -static char * -mntstr(p) - register char **p; -{ - char *cp = *p; - char *retstr; - - while (*cp && isspace(*cp)) - cp++; - retstr = cp; - while (*cp && !isspace(*cp)) - cp++; - if (*cp) - { - *cp = '\0'; - cp++; - } - *p = cp; - return (retstr); -} - -static int -mntdigit(p) - register char **p; -{ - register int value = 0; - char *cp = *p; - - while (*cp && isspace(*cp)) - cp++; - for (; *cp && isdigit(*cp); cp++) - { - value *= 10; - value += *cp - '0'; - } - while (*cp && !isspace(*cp)) - cp++; - if (*cp) - { - *cp = '\0'; - cp++; - } - *p = cp; - return (value); -} - -static int -mnttabscan(FILE *mnttabp, struct mnttab *mnt) -{ - static char *line = NULL; - char *cp; - - if (line == NULL) - line = (char *)malloc(BUFSIZ+1); - do - { - cp = fgets(line, 256, mnttabp); - if (cp == NULL) - { - return (EOF); - } - } while (*cp == '#'); - mnt->mnt_special = mntstr(&cp); - if (*cp == '\0') - return (1); - mnt->mnt_mountp = mntstr(&cp); - if (*cp == '\0') - return (2); - mnt->mnt_fstype = mntstr(&cp); - if (*cp == '\0') - return (3); - mnt->mnt_mntopts = mntstr(&cp); - if (*cp == '\0') - return (4); - mnt->mnt_time = mntstr(&cp); - return (5); -} - -FILE * -setmntent(fname, flag) - char *fname; - char *flag; -{ - FILE *mnttabp; - - if ((mnttabp = fopen(fname, flag)) == NULL) - { - return (NULL); - } - for (; *flag ; flag++) - { - if (*flag == 'w' || *flag == 'a' || *flag == '+') - { - if (lockf(fileno(mnttabp), LOCK_EX, 0) < 0) - { - fclose(mnttabp); - return (NULL); - } - break; - } - } - return (mnttabp); -} - -int -endmntent(mnttabp) - FILE *mnttabp; -{ - - if (mnttabp) - { - fclose(mnttabp); - } - return (1); -} - -/* - * #ifdef NOWAY - * int getmntent (mnttabp, mp) - * FILE *mnttabp; - * struct mnttab *mp; - * { - * int nfields; - * - * if (mnttabp == 0) - * return (-1); - * - * if (_mnt() == 0) - * return (-1); - * - * nfields = mnttabscan(mnttabp, mntp); - * - * if (nfields == EOF || nfields != 5) - * return (-1); - * - * mp = mntp; - * - * return ( 0 ); - * } - * #endif - * - * - * #ifdef NOWAY - * struct mnttab * - * getmntent(mnttabp) - * FILE *mnttabp; - * { - * int nfields; - * - * if (mnttabp == 0) - * return ((struct mnttab *)0); - * if (_mnt() == 0) - * return ((struct mnttab *)0); - * nfields = mnttabscan(mnttabp, mntp); - * if (nfields == EOF || nfields != 5) - * return ((struct mnttab *)0); - * return (mntp); - * } - * #endif - */ - -/* - * addmntent(mnttabp, mnt) - * FILE *mnttabp; - * register struct mnttab *mnt; - * - * if (fseek(mnttabp, 0L, 2) < 0) - * return (1); - * if (mnt == (struct mnttab *)0) - * return (1); - * if (mnt->mnt_special == NULL || mnt->mnt_mountp == NULL || - * mnt->mnt_fstype == NULL || mnt->mnt_mntopts == NULL) - * return (1); - * - * mntprtent(mnttabp, mnt); - * return (0); - * } - */ - -static int -mntprtent(FILE *mnttabp, struct mnttab *mnt) -{ - fprintf(mnttabp, "%s\t%s\t%s\t%s\t%s\n", - mnt->mnt_special, - mnt->mnt_mountp, - mnt->mnt_fstype, - mnt->mnt_mntopts, - mnt->mnt_time); - return(0); -} diff --git a/usr/src/cmd/rexd/mount_nfs.c b/usr/src/cmd/rexd/mount_nfs.c deleted file mode 100644 index 8f94b04d72..0000000000 --- a/usr/src/cmd/rexd/mount_nfs.c +++ /dev/null @@ -1,895 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * mount_nfs.c - procedural interface to the NFS mount operation - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#define NFSCLIENT -#include <sys/types.h> -#include <memory.h> -#include <netconfig.h> -#include <netdb.h> -#include <netdir.h> -#include <netinet/in.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <syslog.h> - -#include <rpc/rpc.h> -#include <rpc/clnt_soc.h> -#include <rpc/pmap_prot.h> -#include <nfs/nfs.h> -#include <nfs/mount.h> -#include <rpcsvc/mount.h> -#include <errno.h> -#include <sys/mntent.h> -#include <sys/mnttab.h> -#include <sys/mount.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/stat.h> - -#include <deflt.h> - -static struct knetconfig *get_knconf(struct netconfig *nconf); -static int bindudp_resvport(CLIENT *client); -static void free_knconf(struct knetconfig *k); -static void freemnttab(struct mnttab *mnt); -static enum clnt_stat pingnfs(char *hostname, rpcvers_t *versp); -static void netbuf_free(struct netbuf *nb); -static struct netbuf *get_addr(char *hostname, int prog, int vers, - struct netconfig **nconfp); - -extern void set_nfsv4_ephemeral_mount_to(void); - -#define TIME_MAX 16 - -extern int Debug; -extern time_t time_now; - -extern FILE *setmntent(char *, char *); -extern void errprintf(char *, char *, ...); - -FILE *setmntent(char *, char *); -void endmntent(FILE *); -enum clnt_stat pingnfs(char *, rpcvers_t *); -struct netbuf *get_addr(char *, int, int, struct netconfig **); -struct knetconfig *get_knconf(struct netconfig *); -void netbuf_free(struct netbuf *); -void free_knconf(struct knetconfig *); - -/* - * mount_nfs - mount a file system using NFS - * - * Returns: 0 if OK, 1 if error. - * The "error" string returns the error message. - */ -int -mount_nfs(char *fsname, char *dir, char *error) -{ - struct sockaddr_in sin; - struct hostent *hp; - struct fhstatus fhs; - char host[256]; - char *path; - char opts[32]; - struct stat st; - int s = -1; - struct timeval timeout; - CLIENT *client; - enum clnt_stat rpc_stat; - int printed1 = 0; - int printed2 = 0; - unsigned winks = 1; /* seconds of sleep time */ - struct mnttab mnt; - FILE *mnted; - int flags; - struct nfs_args args; - struct netconfig *nconf, *udpnconf; - char tbuf[TIME_MAX]; - rpcvers_t vers; - rpcvers_t nfsvers; - char *fstype; - struct mountres3 res3; - nfs_fh3 fh3; - int *auths; - int count; - - if (Debug) - printf("mount_nfs request: mount %s\tdir %s\n", fsname, dir); - - if (Debug && errno) - printf("ERRNO set on mount_nfs entry: %d\n", errno); - - path = strchr(fsname, ':'); - if (path == NULL) { - errprintf(error, "No host name in %s\n", fsname); - return (1); - } - *path = '\0'; - strcpy(host, fsname); - *path++ = ':'; - if (*path == '\0') { - /* - * handle the special case of importing a root file system - */ - strcpy(path, "/"); - } - - if (Debug) { - printf("mount_nfs:\tpath == %s\n", path); - printf("\t\tdir == %s\n", dir); - printf("\t\tgethostbyname host == %s\n", host); - } - - /* - * Get server's address - */ - if ((hp = gethostbyname(host)) == NULL) { - errprintf(error, "mount %s: %s not in hosts database\n", - fsname, host); - return (1); - } - - if (Debug && errno) - printf("ERRNO set after gethostbyname: %d\n", errno); - - if (Debug) { - fprintf(stderr, "gethostbyname:\n\th_name %s\n\t", hp->h_name); - if (hp->h_aliases[0] && *hp->h_aliases[0]) - fprintf(stderr, "h_aliases %s\n\t", hp->h_aliases[0]); - else - fprintf(stderr, "h_aliases %s\n\t", "<none>"); - if (hp->h_addrtype == AF_INET) - fprintf(stderr, - "h_addrtype AF_INET\n\th_adth_length %u\n\t", - hp->h_length); - else - fprintf(stderr, "h_addrtype %u\n\th_adth_length %u\n\t", - hp->h_addrtype, hp->h_length); - if (hp->h_addr_list[0] && *hp->h_addr_list[0]) - fprintf(stderr, "h_addr_list <apparent list>\n"); - else - fprintf(stderr, "h_addr_list %s\n", "<none>"); - } - - if (pingnfs(host, &nfsvers) != RPC_SUCCESS) { - errprintf(error, "host %s not responding to ping\n", host); - return (1); - } - - if (Debug) - printf("pingnfs: succeeds.\n"); - - vers = nfsvers; - - if (Debug) - printf("clnt_create for mountproc (%d)\n", errno); - - client = clnt_create_vers(host, MOUNTPROG, &vers, MOUNTVERS, vers, - "udp"); - if (client == NULL) { - errprintf(error, "%s %s\n", host, - clnt_spcreateerror("mount server not responding")); - return (1); - } - - if (Debug) - printf("call bindudp_resvport for mountproc (%d)\n", errno); - - if (bindudp_resvport(client) < 0) { - errprintf(error, "mount %s:%s: %s\n", host, path, - "Couldn't bind to reserved port"); - if (Debug) - printf("could not bind to reserved port\n"); - clnt_destroy(client); - return (1); - } - - if (client->cl_auth) - auth_destroy(client->cl_auth); - if ((client->cl_auth = authsys_create_default()) == NULL) { - errprintf(error, "mount %s:%s: %s\n", host, path, - "Couldn't create authsys structure"); - if (Debug) - printf("could not create authsys structure\n"); - clnt_destroy(client); - return (1); - } -/* - * #ifdef NOWAY - * if (Debug) - * printf("authsys_create_default called for mountproc\n"); - * client->cl_auth = authsys_create_default(); - * #endif - */ - - /* set mount args */ - memset(&args, 0, sizeof (args)); - - /* Get fhandle of remote path from server's mountd */ - - timeout.tv_usec = 0; - timeout.tv_sec = 25; - - switch (vers) { - case MOUNTVERS: - case MOUNTVERS_POSIX: - rpc_stat = clnt_call(client, MOUNTPROC_MNT, - xdr_dirpath, (caddr_t)&path, - xdr_fhstatus, (caddr_t)&fhs, timeout); - - if (rpc_stat != RPC_SUCCESS) { - /* - * Given the way "clnt_sperror" works, the "%s" - * following the "not responding" is correct. - */ - errprintf(error, "mount server %s not responding %s\n", - host, clnt_sperror(client, "")); - clnt_destroy(client); - return (1); - } - - clnt_destroy(client); - - if ((errno = fhs.fhs_status) != MNT_OK) { - if (errno == EACCES) { - errprintf(error, - "rexd mount: not in EXPORT list for %s\n", - fsname); - } else { - errprintf(error, "rexd mount: error %d %s\n", - errno, strerror(errno)); - } - return (1); - } - - args.fh = (caddr_t)&fhs.fhstatus_u.fhs_fhandle; - fstype = MNTTYPE_NFS; - break; - case MOUNTVERS3: - memset((char *)&res3, '\0', sizeof (res3)); - rpc_stat = clnt_call(client, MOUNTPROC_MNT, - xdr_dirpath, (char *)&path, - xdr_mountres3, (char *)&res3, timeout); - - if (rpc_stat != RPC_SUCCESS) { - /* - * Given the way "clnt_sperror" works, the "%s" - * following the "not responding" is correct. - */ - errprintf(error, "mount server %s not responding %s\n", - host, clnt_sperror(client, "")); - clnt_destroy(client); - return (1); - } - - clnt_destroy(client); - - if ((errno = res3.fhs_status) != MNT_OK) { - if (errno == EACCES) { - errprintf(error, - "rexd mount: not in EXPORT list for %s\n", - fsname); - } else { - errprintf(error, "rexd mount: error %d %s\n", - errno, strerror(errno)); - } - return (1); - } - - auths = - res3.mountres3_u.mountinfo.auth_flavors.auth_flavors_val; - count = - res3.mountres3_u.mountinfo.auth_flavors.auth_flavors_len; - if (count > 0) { - if (auths[0] == AUTH_DES) - args.flags |= NFSMNT_SECURE; - } - - fh3.fh3_length = - res3.mountres3_u.mountinfo.fhandle.fhandle3_len; - memcpy(fh3.fh3_u.data, - res3.mountres3_u.mountinfo.fhandle.fhandle3_val, - fh3.fh3_length); - args.fh = (caddr_t)&fh3; - fstype = MNTTYPE_NFS3; - break; - default: - errprintf(error, "rexd mount: unknown MOUNT version %ld\n", - vers); - return (1); - } - - - /* - * remote mount the fhandle on the local path. - */ - - args.hostname = host; - args.flags = NFSMNT_HOSTNAME; - args.flags |= NFSMNT_INT; /* default is "intr" */ - - args.addr = get_addr(host, NFS_PROGRAM, nfsvers, &nconf); - if (args.addr == NULL) { - errprintf(error, "%s: no NFS service", host); - return (1); - } - - args.flags |= NFSMNT_KNCONF; - args.knconf = get_knconf(nconf); - if (args.knconf == NULL) { - netbuf_free(args.addr); - return (1); - } - - if (Debug) - printf("start mount system call (%d)\n", errno); - - flags = MS_NOSUID | MS_DATA; - - /* - * And make sure that we have the ephemeral mount_to - * set for this zone. - */ - set_nfsv4_ephemeral_mount_to(); - - /* Provide the mounted resource name when mounting. */ - if (mount(fsname, dir, flags, fstype, &args, sizeof (args)) < 0) { - netbuf_free(args.addr); - free_knconf(args.knconf); - errprintf(error, "unable to mount %s on %s: %s\n", - fsname, dir, strerror(errno)); - return (1); - } - - if (Debug) - printf("end mount system call (%d)\n", errno); - - /* - * stat the new mount and get its dev - */ - if (stat(dir, &st) < 0) { - errprintf(error, "couldn't stat %s\n", dir); - return (1); - } - - if (Debug) - printf("stat of new mount (%d)\n", errno); - - (void) sprintf(opts, "rw,noquota,hard,intr,dev=%x", st.st_dev); - - /* - * update /etc/mtab - */ - - mnt.mnt_special = fsname; - mnt.mnt_mountp = dir; - mnt.mnt_fstype = MNTTYPE_NFS; - mnt.mnt_mntopts = opts; - (void) sprintf(tbuf, "%ld", time(0L)); - mnt.mnt_time = tbuf; - - return (0); -} - -#define UNMOUNTTRIES 6 -/* - * umount_nfs - unmount a file system when finished - */ -int -umount_nfs(char *fsname, char *dir) -{ - char *p; - char *hostname; - int s = -1; - struct timeval timeout; - CLIENT *client; - enum clnt_stat rpc_stat; - int count = 0; - - if (Debug) - printf("umount: fsname %s dir %s\n", fsname, dir); - /* - * Give the filesystem time to become un-busy when unmounting. - * If child aborted and is takes a core dump, we may receive the - * SIGCHLD before the core dump is completed. - */ - while (umount(dir) == -1) { - if (errno != EBUSY) { - perror(dir); - return (1); - } - - if (++count > UNMOUNTTRIES) - return (1); - sleep(10); - } - - if (Debug) - printf("umount_nfs: unmounting %s\n", dir); - - if ((p = strchr(fsname, ':')) == NULL) - return (1); - *p++ = 0; - hostname = fsname; - - - if ((client = clnt_create(hostname, MOUNTPROG, MOUNTVERS, "udp")) - == NULL) { - clnt_spcreateerror("Warning on umount create:"); - fprintf(stderr, "\n\r"); - return (1); - } - if (bindudp_resvport(client) < 0) { - errprintf(NULL, "umount %s:%s:%s", hostname, p, - "Could not bind to reserved port\n"); - clnt_destroy(client); - return (1); - } -/* - * #ifdef NOWAWY - * client->cl_auth = authunix_create_default(); - * #endif - */ - - timeout.tv_usec = 0; - timeout.tv_sec = 25; - - rpc_stat = clnt_call(client, MOUNTPROC_UMNT, xdr_dirpath, (caddr_t)&p, - xdr_void, (char *)NULL, timeout); - - clnt_destroy(client); - - if (rpc_stat != RPC_SUCCESS) { - clnt_perror(client, "Warning: umount:"); - fprintf(stderr, "\n\r"); - return (1); - } - - return (0); -} - -static struct mnttab * -dupmnttab(struct mnttab *mnt) -{ - struct mnttab *new; - void freemnttab(); - - new = (struct mnttab *)malloc(sizeof (*new)); - if (new == NULL) - goto alloc_failed; - memset((char *)new, 0, sizeof (*new)); - new->mnt_special = strdup(mnt->mnt_special); - if (new->mnt_special == NULL) - goto alloc_failed; - new->mnt_mountp = strdup(mnt->mnt_mountp); - if (new->mnt_mountp == NULL) - goto alloc_failed; - new->mnt_fstype = strdup(mnt->mnt_fstype); - if (new->mnt_fstype == NULL) - goto alloc_failed; - if (mnt->mnt_mntopts != NULL) - if ((new->mnt_mntopts = strdup(mnt->mnt_mntopts)) == NULL) - goto alloc_failed; - if (mnt->mnt_time != NULL) - if ((new->mnt_time = strdup(mnt->mnt_time)) == NULL) - goto alloc_failed; - - return (new); - -alloc_failed: - - errprintf(NULL, "dupmnttab: memory allocation failed\n"); - freemnttab(new); - return (NULL); -} - - - -/* - * Free a single mnttab structure - */ -static void -freemnttab(struct mnttab *mnt) -{ - if (mnt) { - if (mnt->mnt_special) - free(mnt->mnt_special); - if (mnt->mnt_mountp) - free(mnt->mnt_mountp); - if (mnt->mnt_fstype) - free(mnt->mnt_fstype); - if (mnt->mnt_mntopts) - free(mnt->mnt_mntopts); - if (mnt->mnt_time) - free(mnt->mnt_time); - free(mnt); - } -} - - -/* the following structure is used to build a list of */ -/* mnttab structures from /etc/mnttab. */ -struct mntlist { - struct mnttab *mntl_mnt; - struct mntlist *mntl_next; -}; - - -/* - * Free a list of mnttab structures - */ -static void -freemntlist(struct mntlist *mntl) -{ - struct mntlist *mntl_tmp; - - while (mntl) { - freemnttab(mntl->mntl_mnt); - mntl_tmp = mntl; - mntl = mntl->mntl_next; - free(mntl_tmp); - } -} - - -/* - * parsefs - given a name of the form host:/path/name/for/file - * connect to the give host and look for the exported file system - * that matches. - * Returns: pointer to string containing the part of the pathname - * within the exported directory. - * Returns NULL on errors. - */ -char * -parsefs(char *fullname, char *error) -{ - char *dir, *subdir; - struct exportnode *ex = NULL; - int err; - int bestlen = 0; - int len, dirlen; - - if (Debug && errno) - printf("parsefs of %s entered with errno %d %s\n", - fullname, errno, strerror(errno)); - - dir = strchr(fullname, ':'); - if (dir == NULL) { - errprintf(error, "No host name in %s\n", fullname); - return (NULL); - } - *dir++ = '\0'; - - if (Debug) - printf("parsefs before rpc_call: ERRNO:%d\n", errno); - - if (err = rpc_call(fullname, MOUNTPROG, MOUNTVERS, MOUNTPROC_EXPORT, - xdr_void, 0, xdr_exports, (char *)&ex, "udp")) { - - if (err == (int)RPC_TIMEDOUT) - errprintf(error, "Host %s is not running mountd\n", - fullname); - else - errprintf(error, "RPC error %d with host %s (%s)\n", - err, fullname, clnt_sperrno(err)); - - if (Debug && errno) { - printf("parsefs: mount call to %s returned %d %s\n", - fullname, err, clnt_sperrno(err)); - printf("with errno %d:\t%s\n", errno, strerror(errno)); - } - return (NULL); - } - - if (Debug) - printf("parsefs after rpc_call: ERRNO:%d\n", errno); - - dirlen = strlen(dir); - - if (Debug && errno) { - printf("parsefs: mount call to %s returned %d %s\n", - fullname, err, clnt_sperrno(err)); - printf("with errno %d:\t%s\n", errno, strerror(errno)); - } - - if (Debug) - printf("parsefs: checking export list:\n"); - - for (; ex; ex = ex->ex_next) { - len = strlen(ex->ex_dir); - if (len > bestlen && len <= dirlen && - strncmp(dir, ex->ex_dir, len) == 0 && - (dir[len] == '/' || dir[len] == '\0')) - bestlen = len; - - if (Debug) - printf("\t%d\t%s\n", bestlen, ex->ex_dir); - } - - if (bestlen == 0) { - errprintf(error, "%s not exported by %s\n", - dir, fullname); - return (NULL); - } - - if (dir[bestlen] == '\0') - subdir = &dir[bestlen]; - else { - dir[bestlen] = '\0'; - subdir = &dir[bestlen+1]; - } - *--dir = ':'; - - return (subdir); -} - -/* - * Get the network address for the service identified by "prog" - * and "vers" on "hostname". The netconfig address is returned - * in the value of "nconfp". - * If the hostname is the same as the last call, then the same - * transport is used as last time (same netconfig entry). - */ -static struct netbuf * -get_addr(char *hostname, int prog, int vers, struct netconfig **nconfp) -{ - static char prevhost[MAXHOSTNAMELEN+1]; - static struct netconfig *nconf; - static NCONF_HANDLE *nc = NULL; - struct netbuf *nb = NULL; - struct t_bind *tbind = NULL; - struct netconfig *getnetconfig(); - struct netconfig *getnetconfigent(); - enum clnt_stat cs; - struct timeval tv; - int fd = -1; - - if (strcmp(hostname, prevhost) != 0) { - if (nc) - endnetconfig(nc); - nc = setnetconfig(); - if (nc == NULL) - goto done; - retry: - /* - * If the port number is specified then UDP is needed. - * Otherwise any connectionless transport will do. - */ - while (nconf = getnetconfig(nc)) { - if ((nconf->nc_flag & NC_VISIBLE) && - nconf->nc_semantics == NC_TPI_CLTS) { - break; - } - } - if (nconf == NULL) - goto done; - (void) strcpy(prevhost, hostname); - } - - fd = t_open(nconf->nc_device, O_RDWR, NULL); - if (fd < 0) - goto done; - - tbind = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR); - if (tbind == NULL) - goto done; - - if (rpcb_getaddr(prog, vers, nconf, &tbind->addr, hostname) == 0) { - t_free((char *)tbind, T_BIND); - tbind = NULL; - goto retry; - } - *nconfp = nconf; - - /* - * Make a copy of the netbuf to return - */ - nb = (struct netbuf *)malloc(sizeof (struct netbuf)); - if (nb == NULL) { - errprintf(NULL, "no memory"); - goto done; - } - *nb = tbind->addr; - nb->buf = (char *)malloc(nb->len); - if (nb->buf == NULL) { - errprintf(NULL, "no memory"); - free(nb); - nb = NULL; - goto done; - } - (void) memcpy(nb->buf, tbind->addr.buf, tbind->addr.len); - -done: - if (tbind) - t_free((char *)tbind, T_BIND); - if (fd >= 0) - (void) t_close(fd); - return (nb); -} - -static struct knetconfig * -get_knconf(struct netconfig *nconf) -{ - struct stat stbuf; - struct knetconfig *k; - - if (stat(nconf->nc_device, &stbuf) < 0) { - errprintf(NULL, "get_knconf: stat %s: %m", nconf->nc_device); - return (NULL); - } - k = (struct knetconfig *)malloc(sizeof (*k)); - if (k == NULL) - goto nomem; - k->knc_semantics = nconf->nc_semantics; - k->knc_protofmly = strdup(nconf->nc_protofmly); - if (k->knc_protofmly == NULL) - goto nomem; - k->knc_proto = strdup(nconf->nc_proto); - if (k->knc_proto == NULL) - goto nomem; - k->knc_rdev = stbuf.st_rdev; - - return (k); - -nomem: - errprintf(NULL, "get_knconf: no memory"); - free_knconf(k); - return (NULL); -} - -static void -free_knconf(struct knetconfig *k) -{ - if (k == NULL) - return; - if (k->knc_protofmly) - free(k->knc_protofmly); - if (k->knc_proto) - free(k->knc_proto); - free(k); -} - -static void -netbuf_free(struct netbuf *nb) -{ - if (nb == NULL) - return; - if (nb->buf) - free(nb->buf); - free(nb); -} - - -static enum clnt_stat -pingnfs(char *hostname, rpcvers_t *versp) -{ - CLIENT *cl; - enum clnt_stat clnt_stat; - static char goodhost[MAXHOSTNAMELEN+1]; - static char deadhost[MAXHOSTNAMELEN+1]; - static time_t goodtime, deadtime; - int cache_time = 60; /* sec */ - - if (goodtime > time_now && strcmp(hostname, goodhost) == 0) - return (RPC_SUCCESS); - if (deadtime > time_now && strcmp(hostname, deadhost) == 0) - return (RPC_TIMEDOUT); - - if (Debug) - printf("ping %s ", hostname); - - /* ping the NFS nullproc on the server */ - - cl = clnt_create_vers(hostname, NFS_PROGRAM, versp, NFS_VERSMIN, - NFS_VERSMAX, "udp"); - if (cl == NULL) { - errprintf(NULL, "pingnfs: %s%s", - hostname, clnt_spcreateerror("")); - if (Debug) - printf("clnt_create failed\n"); - clnt_stat = RPC_TIMEDOUT; - } else { - clnt_stat = RPC_SUCCESS; - clnt_destroy(cl); - } - - if (clnt_stat == RPC_SUCCESS) { - (void) strcpy(goodhost, hostname); - goodtime = time_now + cache_time; - } else { - (void) strcpy(deadhost, hostname); - deadtime = time_now + cache_time; - } - - if (Debug) - (void) printf("%s\n", clnt_stat == RPC_SUCCESS ? - "OK" : "NO RESPONSE"); - - return (clnt_stat); -} - -static int bindudp_resvport(CLIENT *client) -{ - struct netconfig *udpnconf; - int clfd; - int rv; - - /* check for superuser as reserved ports are for superuser only */ - if (geteuid()) { - errno = EACCES; - return (-1); - } - - if (clnt_control(client, CLGET_FD, (char *)&clfd) == FALSE) { - errprintf(NULL, - "Could not get file dscriptor for client handle\n"); - return (-1); - } - - if (Debug) - printf("Clnt_control success, clfd = %d\n", clfd); - - if (t_getstate(clfd) != T_UNBND) { - if (t_unbind(clfd) < 0) { - return (-1); - } - } - - if ((udpnconf = getnetconfigent("udp")) == (struct netconfig *)NULL) { - errprintf(NULL, "no netconfig information about \"udp\"\n"); - return (-1); - } - - if (Debug) { - printf("getnetconfigent success\n"); - } - - if ((rv = netdir_options(udpnconf, ND_SET_RESERVEDPORT, clfd, - (char *)NULL)) == -1) { - if (Debug) { - printf("netdir_options fails rv=%d\n", rv); - } - - errprintf(NULL, netdir_sperror()); - return (-1); - } - - if (Debug) - printf("netdir_options success rv = %d\n", rv); - - freenetconfigent(udpnconf); - return (0); -} diff --git a/usr/src/cmd/rexd/on.c b/usr/src/cmd/rexd/on.c deleted file mode 100644 index f436e71126..0000000000 --- a/usr/src/cmd/rexd/on.c +++ /dev/null @@ -1,762 +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 - */ -/* - * on - user interface program for remote execution service - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#define BSD_COMP - -#include <ctype.h> -#include <errno.h> -#include <netdb.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include <netinet/in.h> -#include <rpc/rpc.h> -#include <rpc/clnt_soc.h> -#include <rpc/key_prot.h> -#include <sys/fcntl.h> -#include <sys/ioctl.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <sys/stat.h> -#include <sys/time.h> - - -#include <sys/ttold.h> - - -#include "rex.h" - -#include <stropts.h> -#include <sys/stream.h> -#include <sys/ttcompat.h> - - -#define bcmp(b1, b2, len) memcmp(b1, b2, len) -#define bzero(b, len) memset(b, '\0', len) -#define bcopy(b1, b2, len) memcpy(b2, b1, len) - -#define CommandName "on" /* given as argv[0] */ -#define AltCommandName "dbon" - -extern int errno; - -/* - * Note - the following must be long enough for at least two portmap - * timeouts on the other side. - */ -struct timeval LongTimeout = { 123, 0 }; -struct timeval testtimeout = { 5, 0 }; - -int Debug = 0; /* print extra debugging information */ -int Only2 = 0; /* stdout and stderr are the same */ -int Interactive = 0; /* use a pty on server */ -int NoInput = 0; /* don't read standard input */ -int child = 0; /* pid of the executed process */ -int ChildDied = 0; /* true when above is valid */ -int HasHelper = 0; /* must kill helpers (interactive mode) */ - -int InOut; /* socket for stdin/stdout */ -int Err; /* socket for stderr */ - -struct sgttyb OldFlags; /* saved tty flags */ -struct sgttyb NewFlags; /* for stop/continue job control */ -CLIENT *Client; /* RPC client handle */ -struct rex_ttysize WindowSize; /* saved window size */ - -static int Argc; -static char **Argv; /* saved argument vector (for ps) */ -static char *LastArgv; /* saved end-of-argument vector */ - -void usage(void); -void Die(int stat); -void doaccept(int *fdp); -u_short makeport(int *fdp); - - -/* - * window change handler - propagate to remote server - */ -void -sigwinch(int junk) -{ - struct winsize newsize; /* the modern way to get row and col */ - struct rex_ttysize size; /* the old way no body */ - /* bothered to change */ - enum clnt_stat clstat; - - ioctl(0, TIOCGWINSZ, &newsize); - - /* - * compensate for the struct change - */ - size.ts_lines = (int)newsize.ws_row; /* typecast important! */ - size.ts_cols = (int)newsize.ws_col; - - if (bcmp(&size, &WindowSize, sizeof (size)) == 0) - return; - - WindowSize = size; - if (clstat = clnt_call(Client, REXPROC_WINCH, - xdr_rex_ttysize, (caddr_t)&size, xdr_void, - NULL, LongTimeout)) { - fprintf(stderr, "on (size): "); - clnt_perrno(clstat); - fprintf(stderr, "\r\n"); - } -} - -/* - * signal handler - propagate to remote server - */ -void -sendsig(int sig) -{ - enum clnt_stat clstat; - - if (clstat = clnt_call(Client, REXPROC_SIGNAL, - xdr_int, (caddr_t) &sig, xdr_void, - NULL, LongTimeout)) { - fprintf(stderr, "on (signal): "); - clnt_perrno(clstat); - fprintf(stderr, "\r\n"); - } -} - - -void -cont(int junk) -{ - /* - * Put tty modes back the way they were and tell the rexd server - * to send the command a SIGCONT signal. - */ - if (Interactive) { - ioctl(0, TIOCSETN, &NewFlags); - (void) send(InOut, "", 1, MSG_OOB); - } -} - -/* - * oob -- called when the command invoked by the rexd server is stopped - * with a SIGTSTP or SIGSTOP signal. - */ -void -oob(int junk) -{ - int atmark; - char waste[BUFSIZ], mark; - - for (;;) { - if (ioctl(InOut, SIOCATMARK, &atmark) < 0) { - perror("ioctl"); - break; - } - if (atmark) - break; - (void) read(InOut, waste, sizeof (waste)); - } - (void) recv(InOut, &mark, 1, MSG_OOB); - /* - * Reset tty modes to something sane and stop myself - */ - if (Interactive) { - ioctl(0, TIOCSETN, &OldFlags); - printf("\r\n"); - } - kill(getpid(), SIGSTOP); -} - - - -int -main(int argc, char **argv) -{ - struct winsize newsize; /* the modern way to get row and col */ - char *rhost, **cmdp; - char curdir[MAXPATHLEN]; - char wdhost[MAXHOSTNAMELEN]; - char fsname[MAXPATHLEN]; - char dirwithin[MAXPATHLEN]; - struct rex_start rst; - struct rex_result result; - extern char **environ; - enum clnt_stat clstat; - struct hostent *hp; - struct sockaddr_in server_addr; - int sock = RPC_ANYSOCK; - fd_set selmask, zmask, remmask; - int nfds, cc; - char *chi, *cho; - int trying_authdes; - char netname[MAXNETNAMELEN+1]; - char hostname[MAXHOSTNAMELEN+1]; - char publickey[HEXKEYBYTES+1]; - int i; - char *domain; - static char buf[4096]; - - /* - * we check the invoked command name to see if it should - * really be a host name. - */ - if ((rhost = strrchr(argv[0], '/')) == NULL) { - rhost = argv[0]; - } else { - rhost++; - } - - /* - * argv start and extent for setproctitle() - */ - Argc = argc; - Argv = argv; - if (argc > 0) - LastArgv = argv[argc-1] + strlen(argv[argc-1]); - else - LastArgv = NULL; - - while (argc > 1 && argv[1][0] == '-') { - switch (argv[1][1]) { - case 'd': Debug = 1; - break; - case 'i': Interactive = 1; - break; - case 'n': NoInput = 1; - break; - default: - printf("Unknown option %s\n", argv[1]); - } - argv++; - argc--; - } - - if (strcmp(rhost, CommandName) && strcmp(rhost, AltCommandName)) { - cmdp = &argv[1]; - Interactive = 1; - } else { - if (argc < 2) - usage(); - rhost = argv[1]; - cmdp = &argv[2]; - } - - /* - * Can only have one of these - */ - if (Interactive && NoInput) - usage(); - - if ((hp = gethostbyname(rhost)) == NULL) { - fprintf(stderr, "on: unknown host %s\n", rhost); - exit(1); - } - - bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr, hp->h_length); - server_addr.sin_family = AF_INET; - server_addr.sin_port = 0; /* use pmapper */ - - if (Debug) - printf("Got the host named %s (%s)\n", - rhost, inet_ntoa(server_addr.sin_addr)); - trying_authdes = 1; - -try_auth_unix: - sock = RPC_ANYSOCK; - - if (Debug) - printf("clnt_create: Server_Addr %u Prog %d Vers %d Sock %d\n", - &server_addr, REXPROG, REXVERS, sock); - - if ((Client = clnttcp_create(&server_addr, REXPROG, REXVERS, &sock, - 0, 0)) == NULL) { - fprintf(stderr, "on: cannot connect to server on %s\n", - rhost); - clnt_pcreateerror("on:"); - exit(1); - } - - if (Debug) - printf("TCP RPC connection created\n"); - - if (trying_authdes) { - yp_get_default_domain(&domain); - - cho = hostname; - *cho = 0; - chi = hp->h_name; - - for (i = 0; (*chi && (i < MAXHOSTNAMELEN)); i++) - { - if (isupper(*chi)) - *cho = tolower(*chi); - else - *cho = *chi; - cho++; - chi++; - } - *cho = 0; - - if (domain != NULL) { - if (host2netname(netname, hostname, domain) == 0) { - trying_authdes = 0; - if (Debug) - printf("host2netname failed %s\n", - hp->h_name); - } - /* #ifdef NOWAY */ - else { - - if (getpublickey(netname, publickey) == 0) { - trying_authdes = 0; - cho = strchr(hostname, '.'); - - if (cho) { - *cho = 0; - - if (!host2netname(netname, - hostname, - domain)) { - if (Debug) - printf("host2netname failed %s\n", hp->h_name); - } else { - if (getpublickey( - netname, - publickey) != 0) - trying_authdes = 1; - } - } - } - } - } else { - trying_authdes = 0; - if (Debug) - printf("yp_get_default_domain failed \n"); - } - } - - if (trying_authdes) { - Client->cl_auth = (AUTH *)authdes_create(netname, 60*60, - &server_addr, NULL); - - if (Client->cl_auth == NULL) { - - if (Debug) - printf("authdes_create failed %s\n", netname); - trying_authdes = 0; - } - } - - - if (trying_authdes == 0) - if ((Client->cl_auth = authsys_create_default()) == NULL) { - clnt_destroy(Client); - fprintf(stderr,"on: can't create authunix structure.\n"); - exit(1); - } - - - /* - * Now that we have created the TCP connection, we do some - * work while the server daemon is being swapped in. - */ - if (getcwd(curdir, MAXPATHLEN) == (char *)NULL) { - fprintf(stderr, "on: can't find . (%s)\n", curdir); - exit(1); - } - - if (findmount(curdir, wdhost, fsname, dirwithin) == 0) { - - if (Debug) { - fprintf(stderr, - "findmount failed: curdir %s\twdhost %s\t", - curdir, wdhost); - fprintf(stderr, "fsname %s\tdirwithin %s\n", - fsname, dirwithin); - } - - fprintf(stderr, "on: can't locate mount point for %s (%s)\n", - curdir, dirwithin); - exit(1); - } - - if (Debug) { - printf("findmount suceeds: cwd= %s, wd host %s, fs %s,", - curdir, wdhost, fsname); - printf("dir within %s\n", dirwithin); - } - - Only2 = samefd(1, 2); - - rst.rst_cmd = (void *)(cmdp); - rst.rst_host = (void *)wdhost; - rst.rst_fsname = (void *)fsname; - rst.rst_dirwithin = (void *)dirwithin; - rst.rst_env = (void *)environ; - rst.rst_port0 = makeport(&InOut); - rst.rst_port1 = rst.rst_port0; /* same port for stdin */ - rst.rst_flags = 0; - - if (Debug) - printf("before Interactive flags\n"); - - if (Interactive) { - rst.rst_flags |= REX_INTERACTIVE; - ioctl(0, TIOCGETP, &OldFlags); - NewFlags = OldFlags; - NewFlags.sg_flags |= (u_int)RAW; - NewFlags.sg_flags &= (u_int)~ECHO; - ioctl(0, TIOCSETN, &NewFlags); - } - - if (Only2) { - rst.rst_port2 = rst.rst_port1; - } else { - rst.rst_port2 = makeport(&Err); - } - - if (Debug) - printf("before client call REXPROC_START\n"); - - (void) memset(&result, '\0', sizeof(result)); - - if (clstat = clnt_call(Client, REXPROC_START, - xdr_rex_start, (caddr_t)&rst, - xdr_rex_result, (caddr_t)&result, LongTimeout)) { - - if (Debug) - printf("Client call failed for REXPROC_START\r\n"); - - if (trying_authdes) { - auth_destroy(Client->cl_auth); - clnt_destroy(Client); - trying_authdes = 0; - if (Interactive) - ioctl(0, TIOCSETN, &OldFlags); - goto try_auth_unix; - } else { - fprintf(stderr, "on %s: ", rhost); - clnt_perrno(clstat); - fprintf(stderr, "\n"); - Die(1); - } - } - - if (result.rlt_stat != 0) { - fprintf(stderr, "on %s: %s\n\r", rhost, result.rlt_message); - Die(1); - } - - clnt_freeres(Client, xdr_rex_result, (caddr_t)&result); - - if (Debug) - printf("Client call suceeded for REXPROC_START\r\n"); - - if (Interactive) { - /* - * Pass the tty modes along to the server - */ - struct rex_ttymode mode; - int err; - - mode.basic.sg_ispeed = OldFlags.sg_ispeed; - mode.basic.sg_ospeed = OldFlags.sg_ospeed; - mode.basic.sg_erase = OldFlags.sg_erase; - mode.basic.sg_kill = OldFlags.sg_kill; - mode.basic.sg_flags = (short) (OldFlags.sg_flags & 0xFFFF); - err = (ioctl(0, TIOCGETC, &mode.more) < 0 || - ioctl(0, TIOCGLTC, &mode.yetmore) < 0 || - ioctl(0, TIOCLGET, &mode.andmore) < 0); - if (Debug) - printf("Before clnt_call(REXPROC_MODES) err=%d\n", err); - - if (!err && (clstat = clnt_call(Client, REXPROC_MODES, - xdr_rex_ttymode, (caddr_t)&mode, - xdr_void, NULL, LongTimeout))) { - - fprintf(stderr, "on (modes) %s: ", rhost); - clnt_perrno(clstat); - fprintf(stderr, "\r\n"); - } - - err = ioctl(0, TIOCGWINSZ, &newsize) < 0; - /* typecast important in following lines */ - WindowSize.ts_lines = (int)newsize.ws_row; - WindowSize.ts_cols = (int)newsize.ws_col; - - if (Debug) - printf("Before client call REXPROC_WINCH\n"); - - if (!err && (clstat = clnt_call(Client, REXPROC_WINCH, - xdr_rex_ttysize, (caddr_t)&WindowSize, - xdr_void, NULL, LongTimeout))) { - - fprintf(stderr, "on (size) %s: ", rhost); - clnt_perrno(clstat); - fprintf(stderr, "\r\n"); - } - - sigset(SIGWINCH, sigwinch); - sigset(SIGINT, sendsig); - sigset(SIGQUIT, sendsig); - sigset(SIGTERM, sendsig); - } - sigset(SIGCONT, cont); - sigset(SIGURG, oob); - doaccept(&InOut); - (void) fcntl(InOut, F_SETOWN, getpid()); - FD_ZERO(&remmask); - FD_SET(InOut, &remmask); - if (Debug) - printf("accept on stdout\r\n"); - - if (!Only2) { - - doaccept(&Err); - shutdown(Err, 1); /* 1=> further sends disallowed */ - if (Debug) - printf("accept on stderr\r\n"); - FD_SET(Err, &remmask); - } - - FD_ZERO(&zmask); - if (NoInput) { - - /* - * no input - simulate end-of-file instead - */ - shutdown(InOut, 1); /* 1=> further sends disallowed */ - } else { - /* - * set up to read standard input, send to remote - */ - FD_SET(0, &zmask); - } - - FD_ZERO(&selmask); - while (FD_ISSET(InOut, &remmask) || FD_ISSET(Err, &remmask)) { - if (FD_ISSET(InOut, &remmask)) - FD_SET(InOut, &selmask); - else - FD_CLR(InOut, &selmask); - if (FD_ISSET(Err, &remmask)) - FD_SET(Err, &selmask); - else - FD_CLR(Err, &selmask); - if (FD_ISSET(0, &zmask)) - FD_SET(0, &selmask); - else - FD_CLR(0, &selmask); - nfds = select(FD_SETSIZE, &selmask, (fd_set *) 0, (fd_set *) 0, - (struct timeval *) 0); - - - if (nfds <= 0) { - if (errno == EINTR) continue; - perror("on: select"); - Die(1); - } - if (FD_ISSET(InOut, &selmask)) { - - cc = read(InOut, buf, sizeof buf); - if (cc > 0) - write(1, buf, cc); - else - FD_CLR(InOut, &remmask); - } - - if (!Only2 && FD_ISSET(Err, &selmask)) { - - cc = read(Err, buf, sizeof buf); - if (cc > 0) - write(2, buf, cc); - else - FD_CLR(Err, &remmask); - } - - if (!NoInput && FD_ISSET(0, &selmask)) { - - cc = read(0, buf, sizeof buf); - if (cc > 0) - write(InOut, buf, cc); - else { - /* - * End of standard input - shutdown outgoing - * direction of the TCP connection. - */ - if (Debug) - printf("Got EOF - shutting down connection\n"); - FD_CLR(0, &zmask); - shutdown(InOut, 1); /* further sends disallowed */ - } - } - } - - close(InOut); - if (!Only2) - close(Err); - - (void) memset(&result, '\0', sizeof(result)); - - if (clstat = clnt_call(Client, REXPROC_WAIT, - xdr_void, 0, xdr_rex_result, (caddr_t)&result, - LongTimeout)) { - - fprintf(stderr, "on: "); - clnt_perrno(clstat); - fprintf(stderr, "\r\n"); - Die(1); - } - Die(result.rlt_stat); - return (0); /* Should never get here. */ -} - -/* - * like exit, but resets the terminal state first - */ -void -Die(int stat) - -{ - if (Interactive) { - ioctl(0, TIOCSETN, &OldFlags); - printf("\r\n"); - } - exit(stat); -} - - -void -remstop() - -{ - Die(23); -} - -/* - * returns true if we can safely say that the two file descriptors - * are the "same" (both are same file). - */ -int -samefd(a, b) -{ - struct stat astat, bstat; - - if (fstat(a, &astat) || fstat(b, &bstat)) - return (0); - if (astat.st_ino == 0 || bstat.st_ino == 0) - return (0); - return (!bcmp(&astat, &bstat, sizeof (astat))); -} - - -/* - * accept the incoming connection on the given - * file descriptor, and return the new file descritpor - */ -void -doaccept(fdp) - int *fdp; -{ - int fd; - - fd = accept(*fdp, 0, 0); - - if (fd < 0) { - perror("accept"); - remstop(); - } - close(*fdp); - *fdp = fd; -} - -/* - * create a socket, and return its the port number. - */ -u_short -makeport(fdp) - int *fdp; -{ - struct sockaddr_in sin; - socklen_t len = (socklen_t)sizeof (sin); - int fd; - - fd = socket(AF_INET, SOCK_STREAM, 0); - - if (fd < 0) { - perror("socket"); - exit(1); - } - - bzero((char *)&sin, sizeof (sin)); - sin.sin_family = AF_INET; - bind(fd, (struct sockaddr *)&sin, sizeof (sin)); - getsockname(fd, (struct sockaddr *)&sin, &len); - listen(fd, 1); - *fdp = fd; - return (htons(sin.sin_port)); -} - -void -usage(void) -{ - fprintf(stderr, "Usage: on [-i|-n] [-d] machine cmd [args]...\n"); - exit(1); -} - -/* - * SETPROCTITLE -- set the title of this process for "ps" - * - * Does nothing if there were not enough arguments on the command - * line for the information. - * - * Side Effects: - * Clobbers argv[] of our main procedure. - */ -void -setproctitle(user, host) - char *user, *host; -{ - register char *tohere; - - tohere = Argv[0]; - if ((int)LastArgv == (int)((char *)NULL) || - (int)(strlen(user) + strlen(host)+3) > (int)(LastArgv - tohere)) - return; - *tohere++ = '-'; /* So ps prints (rpc.rexd) */ - sprintf(tohere, "%s@%s", user, host); - while (*tohere++) /* Skip to end of printf output */ - ; - while (tohere < LastArgv) /* Avoid confusing ps */ - *tohere++ = ' '; -} diff --git a/usr/src/cmd/rexd/rex.c b/usr/src/cmd/rexd/rex.c deleted file mode 100644 index 9ccedde09b..0000000000 --- a/usr/src/cmd/rexd/rex.c +++ /dev/null @@ -1,148 +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 - */ -/* - * rex_xdr - remote execution external data representations - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* XXX - Bad, Bad, Bad.... Fix this. This isn't allowed in the base */ -#define BSD_COMP - -#include <stdio.h> -#include <rpc/rpc.h> -#include <sys/errno.h> -#include <sys/ttold.h> -#include <stropts.h> -#include <sys/stream.h> -#include <sys/tty.h> -#include <sys/ptyvar.h> - -#include "rex.h" - -/* - * xdr_rex_start - process the command start structure - */ -int -xdr_rex_start(XDR *xdrs, struct rex_start *rst) -{ - return - xdr_argv(xdrs, &rst->rst_cmd) && - xdr_string(xdrs, &rst->rst_host, 1024) && - xdr_string(xdrs, &rst->rst_fsname, 1024) && - xdr_string(xdrs, &rst->rst_dirwithin, 1024) && - xdr_argv(xdrs, &rst->rst_env) && - xdr_u_short(xdrs, &rst->rst_port0) && - xdr_u_short(xdrs, &rst->rst_port1) && - xdr_u_short(xdrs, &rst->rst_port2) && - xdr_u_long(xdrs, &rst->rst_flags); -} - -int -xdr_argv(XDR *xdrs, char ***argvp) -{ - register char **argv = *argvp; - register char **ap; - int i, count; - - /* - * find the number of args to encode or free - */ - if ((xdrs->x_op) != XDR_DECODE) - for (count = 0, ap = argv; *ap != 0; ap++) - count++; - /* XDR the count */ - if (!xdr_u_int(xdrs, (unsigned *) &count)) - return (FALSE); - - /* - * now deal with the strings - */ - if (xdrs->x_op == XDR_DECODE) { - *argvp = argv = (char **) - mem_alloc((unsigned)(count+1)*sizeof (char **)); - for (i = 0; i <= count; i++) /* Note: <=, not < */ - argv[i] = 0; - } - - for (i = 0, ap = argv; i < count; i++, ap++) - if (!xdr_string(xdrs, ap, 10240)) - return (FALSE); - - if (xdrs->x_op == XDR_FREE && argv != NULL) { - mem_free((char *) argv, (count+1)*sizeof (char **)); - *argvp = NULL; - } - return (TRUE); -} - -/* - * xdr_rex_result - process the result of a start or wait operation - */ -int -xdr_rex_result(XDR *xdrs, struct rex_result *result) -{ - return - xdr_int(xdrs, &result->rlt_stat) && - xdr_string(xdrs, &result->rlt_message, 1024); - -} - -/* - * xdr_rex_ttymode - process the tty mode information - */ -int -xdr_rex_ttymode(XDR *xdrs, struct rex_ttymode *mode) -{ - u_int six = 6; - u_int four = 4; - char *speedp = NULL; - char *morep = NULL; - char *yetmorep = NULL; - - if (xdrs->x_op != XDR_FREE) { - speedp = &mode->basic.sg_ispeed; - morep = (char *)&mode->more; - yetmorep = (char *)&mode->yetmore; - } - return - xdr_bytes(xdrs, (char **) &speedp, (u_int *)&four, 4) && - xdr_short(xdrs, (short *) &mode->basic.sg_flags) && - xdr_bytes(xdrs, (char **) &morep, (u_int *)&six, 6) && - xdr_bytes(xdrs, (char **) &yetmorep, (u_int *)&six, 6) && - xdr_u_long(xdrs, &mode->andmore); -} - - -/* - * xdr_rex_ttysize - process the tty size information - */ -int -xdr_rex_ttysize(XDR *xdrs, struct ttysize *size) -{ - return - xdr_int(xdrs, &size->ts_lines) && - xdr_int(xdrs, &size->ts_cols); -} diff --git a/usr/src/cmd/rexd/rex.h b/usr/src/cmd/rexd/rex.h deleted file mode 100644 index 1919fd65c0..0000000000 --- a/usr/src/cmd/rexd/rex.h +++ /dev/null @@ -1,108 +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 - */ -/* - * rex - remote execution server definitions - * - * Copyright (c) 1985 Sun Microsystems, Inc. - */ - -#ifndef _RPCSVC_REX_H -#define _RPCSVC_REX_H - -#ident "%Z%%M% %I% %E% SMI" -/* @(#)rex.h 1.7 89/10/02 Copyr 1985 SMI */ - -#define REXPROG 100017 -#define REXPROC_NULL 0 /* no operation */ -#define REXPROC_START 1 /* start a command */ -#define REXPROC_WAIT 2 /* wait for a command to complete */ -#define REXPROC_MODES 3 /* send the tty modes */ -#define REXPROC_WINCH 4 /* signal a window change */ -#define REXPROC_SIGNAL 5 /* other signals */ - -#define REXVERS 1 - -/* flags for rst_flags field */ -#define REX_INTERACTIVE 1 /* Interative mode */ - -struct rex_start { - /* - * Structure passed as parameter to start function - */ - char **rst_cmd; /* list of command and args */ - char *rst_host; /* working directory host name */ - char *rst_fsname; /* working directory file system name */ - char *rst_dirwithin; /* working directory within file system */ - char **rst_env; /* list of environment */ - u_short rst_port0; /* port for stdin */ - u_short rst_port1; /* port for stdin */ - u_short rst_port2; /* port for stdin */ - u_long rst_flags; /* options - see #defines above */ -}; - -bool_t xdr_rex_start(); - -struct rex_result { - /* - * Structure returned from the start function - */ - int rlt_stat; /* integer status code */ - char *rlt_message; /* string message for human consumption */ -}; -bool_t xdr_rex_result(); -bool_t xdr_tchars(); -bool_t xdr_ltchars(); -bool_t xdr_sgttyb(); - -/* - * sgttyb structure changed from BSD to SVR4. Since we send it over the - * protocol, we stick to the old one for compatability - */ -struct bsd_sgttyb { - char sg_ispeed; /* input speed */ - char sg_ospeed; /* output speed */ - char sg_erase; /* erase character */ - char sg_kill; /* kill character */ - short sg_flags; /* mode flags */ -}; - -struct rex_ttymode { - /* - * Structure sent to set-up the tty modes - */ - struct bsd_sgttyb basic; /* standard unix tty flags */ - struct tchars more; /* interrupt, kill characters, etc. */ - struct ltchars yetmore; /* special Bezerkeley characters */ - u_long andmore; /* and Berkeley modes */ -}; - -bool_t xdr_rex_ttymode(); - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; -typedef struct rex_ttysize rex_ttysize; -bool_t xdr_rex_ttysize(); - - -#endif /* _RPCSVC_REX_H */ diff --git a/usr/src/cmd/rexd/rex.x b/usr/src/cmd/rexd/rex.x deleted file mode 100644 index d8fbbf0a4f..0000000000 --- a/usr/src/cmd/rexd/rex.x +++ /dev/null @@ -1,224 +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 1987 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * Remote execution (rex) protocol specification - */ - -const STRINGSIZE = 1024; -typedef string rexstring<1024>; - -/* - * values to pass to REXPROC_SIGNAL - */ -const SIGINT = 2; /* interrupt */ - -/* - * Values for rst_flags, below - */ -const REX_INTERACTIVE = 1; /* interactive mode */ - -struct rex_start { - rexstring rst_cmd<>; /* list of command and args */ - rexstring rst_host; /* working directory host name */ - rexstring rst_fsname; /* working directory file system name */ - rexstring rst_dirwithin;/* working directory within file system */ - rexstring rst_env<>; /* list of environment */ - unsigned int rst_port0; /* port for stdin */ - unsigned int rst_port1; /* port for stdout */ - unsigned int rst_port2; /* port for stderr */ - unsigned int rst_flags; /* options - see const above */ -}; - -struct rex_result { - int rlt_stat; /* integer status code */ - rexstring rlt_message; /* string message for human consumption */ -}; - - -struct sgttyb { - unsigned four; /* always equals 4 */ - opaque chars[4]; - /* chars[0] == input speed */ - /* chars[1] == output speed */ - /* chars[2] == kill character */ - /* chars[3] == erase character */ - unsigned flags; -}; -/* values for speeds above (baud rates) */ -const B0 = 0; -const B50 = 1; -const B75 = 2; -const B110 = 3; -const B134 = 4; -const B150 = 5; -const B200 = 6; -const B300 = 7; -const B600 = 8; -const B1200 = 9; -const B1800 = 10; -const B2400 = 11; -const B4800 = 12; -const B9600 = 13; -const B19200 = 14; -const B38400 = 15; - -/* values for flags above */ -const TANDEM = 0x00000001; /* send stopc on out q full */ -const CBREAK = 0x00000002; /* half-cooked mode */ -const LCASE = 0x00000004; /* simulate lower case */ -const ECHO = 0x00000008; /* echo input */ -const CRMOD = 0x00000010; /* map \r to \r\n on output */ -const RAW = 0x00000020; /* no i/o processing */ -const ODDP = 0x00000040; /* get/send odd parity */ -const EVENP = 0x00000080; /* get/send even parity */ -const ANYP = 0x000000c0; /* get any parity/send none */ -const NLDELAY = 0x00000300; /* \n delay */ -const NL0 = 0x00000000; -const NL1 = 0x00000100; /* tty 37 */ -const NL2 = 0x00000200; /* vt05 */ -const NL3 = 0x00000300; -const TBDELAY = 0x00000c00; /* horizontal tab delay */ -const TAB0 = 0x00000000; -const TAB1 = 0x00000400; /* tty 37 */ -const TAB2 = 0x00000800; -const XTABS = 0x00000c00; /* expand tabs on output */ -const CRDELAY = 0x00003000; /* \r delay */ -const CR0 = 0x00000000; -const CR1 = 0x00001000; /* tn 300 */ -const CR2 = 0x00002000; /* tty 37 */ -const CR3 = 0x00003000; /* concept 100 */ -const VTDELAY = 0x00004000; /* vertical tab delay */ -const FF0 = 0x00000000; -const FF1 = 0x00004000; /* tty 37 */ -const BSDELAY = 0x00008000; /* \b delay */ -const BS0 = 0x00000000; -const BS1 = 0x00008000; -const CRTBS = 0x00010000; /* do backspacing for crt */ -const PRTERA = 0x00020000; /* \ ... / erase */ -const CRTERA = 0x00040000; /* " \b " to wipe out char */ -const TILDE = 0x00080000; /* hazeltine tilde kludge */ -const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ -const LITOUT = 0x00200000; /* literal output */ -const TOSTOP = 0x00400000; /* SIGTTOU on background output */ -const FLUSHO = 0x00800000; /* flush output to terminal */ -const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ -const L001000 = 0x02000000; -const CRTKIL = 0x04000000; /* kill line with " \b " */ -const PASS8 = 0x08000000; -const CTLECH = 0x10000000; /* echo control chars as ^X */ -const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ -const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ -const NOFLSH = 0x80000000; /* no output flush on signal */ - -struct tchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == interrupt char */ - /* chars[1] == quit char */ - /* chars[2] == start output char */ - /* chars[3] == stop output char */ - /* chars[4] == end-of-file char */ - /* chars[5] == input delimeter (like nl) */ -}; - -struct ltchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == stop process signal */ - /* chars[1] == delayed stop process signal */ - /* chars[2] == reprint line */ - /* chars[3] == flush output */ - /* chars[4] == word erase */ - /* chars[5] == literal next character */ - unsigned mode; -}; - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; - -struct rex_ttymode { - sgttyb basic; /* standard unix tty flags */ - tchars more; /* interrupt, kill characters, etc. */ - ltchars yetmore; /* special Berkeley characters */ - unsigned andmore; /* and Berkeley modes */ -}; - -/* values for andmore above */ -const LCRTBS = 0x0001; /* do backspacing for crt */ -const LPRTERA = 0x0002; /* \ ... / erase */ -const LCRTERA = 0x0004; /* " \b " to wipe out char */ -const LTILDE = 0x0008; /* hazeltine tilde kludge */ -const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ -const LLITOUT = 0x0020; /* literal output */ -const LTOSTOP = 0x0040; /* SIGTTOU on background output */ -const LFLUSHO = 0x0080; /* flush output to terminal */ -const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ -const LL001000 = 0x0200; -const LCRTKIL = 0x0400; /* kill line with " \b " */ -const LPASS8 = 0x0800; -const LCTLECH = 0x1000; /* echo control chars as ^X */ -const LPENDIN = 0x2000; /* needs reread */ -const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ -const LNOFLSH = 0x8000; /* no output flush on signal */ - -program REXPROG { - version REXVERS { - - /* - * Start remote execution - */ - rex_result - REXPROC_START(rex_start) = 1; - - /* - * Wait for remote execution to terminate - */ - rex_result - REXPROC_WAIT(void) = 2; - - /* - * Send tty modes - */ - void - REXPROC_MODES(rex_ttymode) = 3; - - /* - * Send window size change - */ - void - REXPROC_WINCH(rex_ttysize) = 4; - - /* - * Send other signal - */ - void - REXPROC_SIGNAL(int) = 5; - } = 1; -} = 100017; diff --git a/usr/src/cmd/rexd/rex.xml b/usr/src/cmd/rexd/rex.xml deleted file mode 100644 index 8b9843328d..0000000000 --- a/usr/src/cmd/rexd/rex.xml +++ /dev/null @@ -1,124 +0,0 @@ -<?xml version='1.0'?> -<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> - -<!-- - Copyright 2009 Sun Microsystems, Inc. All rights reserved. - Use is subject to license terms. - - Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> - - CDDL HEADER START - - The contents of this file are subject to the terms of the - 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. - 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 - - NOTE: This service manifest is not editable; its contents will - be overwritten by package or patch operations, including - operating system upgrade. Make customizations in a different - file. - - Service manifest for rpc.rexd ---> - -<service_bundle type='manifest' name='SUNWnisr:rexd'> - -<service - name='network/rpc/rex' - type='service' - version='1'> - - <create_default_instance enabled='false' /> - - <restarter> - <service_fmri value='svc:/network/inetd:default' /> - </restarter> - - <dependency name='rpcbind' - grouping='require_all' - restart_on='restart' - type='service'> - <service_fmri value='svc:/network/rpc/bind' /> - </dependency> - - <exec_method - type='method' - name='inetd_start' - exec='/usr/sbin/rpc.rexd' - timeout_seconds='0'> - <method_context> - <method_credential user='root' group='root' /> - </method_context> - </exec_method> - - <exec_method - type='method' - name='inetd_offline' - exec=':kill_process' - timeout_seconds='0'> - </exec_method> - - <exec_method - type='method' - name='inetd_disable' - exec=':kill' - timeout_seconds='0'> - </exec_method> - - <property_group name='inetd' type='framework'> - <stability value='Evolving' /> - <propval name='name' type='astring' value='rexd' /> - <propval name='endpoint_type' type='astring' value='tli' /> - <propval name='proto' type='astring' value='tcp' /> - <propval name='isrpc' type='boolean' value='true' /> - <propval name='rpc_low_version' type='integer' value='1' /> - <propval name='rpc_high_version' type='integer' value='1' /> - <propval name='wait' type='boolean' value='true' /> - </property_group> - - <property_group name='firewall_config' type='com.sun,fw_configuration'> - <propval name='policy' type='astring' value='use_global' /> - <propval name='block_policy' type='astring' - value='use_global' /> - <propval name='apply_to' type='astring' value='' /> - <propval name='apply_to_6' type='astring' value='' /> - <propval name='exceptions' type='astring' value='' /> - <propval name='exceptions_6' type='astring' value='' /> - <propval name='target' type='astring' value='' /> - <propval name='target_6' type='astring' value='' /> - <propval name='value_authorization' type='astring' - value='solaris.smf.value.firewall.config' /> - </property_group> - - <stability value='Unstable' /> - - <template> - <common_name> - <loctext xml:lang='C'> - remote execution server - </loctext> - </common_name> - <documentation> - <manpage title='rpc.rexd' section='1M' - manpath='/usr/share/man' /> - <manpage title='rexd' section='1M' - manpath='/usr/share/man' /> - </documentation> - </template> - -</service> - -</service_bundle> diff --git a/usr/src/cmd/rexd/rpc.rexd.c b/usr/src/cmd/rexd/rpc.rexd.c deleted file mode 100644 index c1adface37..0000000000 --- a/usr/src/cmd/rexd/rpc.rexd.c +++ /dev/null @@ -1,1386 +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 - */ -/* - * rexd - a remote execution daemon based on SUN Remote Procedure Calls - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <errno.h> -#include <netdb.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include <netinet/in.h> -#include <rpc/rpc.h> -#include <rpc/svc_soc.h> -#include <rpc/key_prot.h> -#include <sys/fcntl.h> -#include <sys/ioctl.h> -#include <sys/param.h> -#include <sys/socket.h> -#include <sys/sockio.h> -#include <sys/mntent.h> -#include <sys/mnttab.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <wait.h> -#include <sys/systeminfo.h> - -#include <sys/ttold.h> - -#include "rex.h" - -#include <security/pam_appl.h> -#include <stropts.h> -#include <sys/stream.h> -/* #include <sys/termios.h> XXX */ -#include <sys/ttcompat.h> - -#include <bsm/audit.h> - -/* #define stderr stdout */ /* XXX */ - -#define ListnerTimeout 300 /* seconds listner stays alive */ -#define WaitLimit 10 /* seconds to wait after io is closed */ -#define MOUNTED "/etc/mnttab" -#define TempDir "/tmp_rex" /* directory to hold temp mounts */ -static char TempName[] = "/tmp_rex/rexdXXXXXX"; - /* name template for temp mount points */ -#define TempMatch 13 /* unique prefix of above */ - -SVCXPRT *ListnerTransp; /* non-null means still a listner */ - -static char **Argv; /* saved argument vector (for ps) */ -static char *LastArgv; /* saved end-of-argument vector */ -int OutputSocket; /* socket for stop/cont notification */ -int MySocket; /* transport socket */ -int HasHelper = 0; /* must kill helpers (interactive mode) */ -int DesOnly = 0; /* unix credentials too weak */ -int confd; /* console fd */ - -int Debug = 0; - -pam_handle_t *pamh; /* PAM handle */ - -time_t time_now; - -extern int Master; /* half of the pty */ -extern char **environ; - -int child = 0; /* pid of the executed process */ -int ChildStatus = 0; /* saved return status of child */ -int ChildDied = 0; /* true when above is valid */ -char nfsdir[MAXPATHLEN]; /* file system we mounted */ -char *tmpdir; /* where above is mounted, NULL if none */ - -extern void rex_cleanup(void); -extern int ValidUser(char *host, uid_t uid, gid_t gid, - char *error, char *shell, - char *dir, struct rex_start *rst); - -extern void audit_rexd_fail(char *, char *, char *, uid_t, gid_t, - char *, char **); -extern void audit_rexd_success(char *, char *, uid_t, gid_t, - char *, char **); -extern void audit_rexd_setup(); - -extern int audit_settid(int); - -/* process rex requests */ -void dorex(struct svc_req *rqstp, SVCXPRT *transp); -void ListnerTimer(int); /* destroy listener */ -void CatchChild(int); /* handle child signals */ -void oob(int); /* out of band signals */ -void sigwinch(int); /* window change signals -- dummy */ -FILE *setmntent(char *fname, char *flag); -extern void HelperRead(pollfd_t *fdp, int, int *); - -int -main(int argc, char **argv) -{ - /* - * the server is a typical RPC daemon, except that we only - * accept TCP connections. - */ - int pollretval; - int npollfds = 0; - pollfd_t *pollset = NULL; - struct sockaddr_in addr; - int maxrecsz = RPC_MAXDATASIZE; - - audit_rexd_setup(); /* BSM */ - - /* - * Remember the start and extent of argv for setproctitle(). - * Open the console for error printouts, but don't let it be - * our controlling terminal. - */ - if (argc > 1) { - if (strcmp("-s", argv[1]) == 0) - DesOnly = 1; - - if (strcmp("-d", argv[1]) == 0) - Debug = 1; - } - - if (argc > 2) { - if (strcmp("-s", argv[2]) == 0) - DesOnly = 1; - - if (strcmp("-d", argv[2]) == 0) - Debug = 1; - } - - /* - * argv start and extent for setproctitle() - */ - Argv = argv; - if (argc > 0) - LastArgv = argv[argc-1] + strlen(argv[argc-1]); - else - LastArgv = NULL; - - /* - * console open for errors w/o being the controlling terminal - */ - - if ((confd = open("/dev/console", 1)) > 0) { - close(1); - close(2); - confd = dup2(confd, 1); /* console fd copied to stdout */ - dup(1); /* console fd copied to stderr */ - } - - setsid(); /* get rid of controlling terminal */ - - /* - * setup signals - */ - sigset(SIGCHLD, CatchChild); - sigset(SIGPIPE, SIG_IGN); - sigset(SIGALRM, ListnerTimer); - - /* - * Enable non-blocking mode and maximum record size checks for - * connection oriented transports. - */ - if (!rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrecsz)) { - fprintf(stderr, "rexd: unable to set RPC max record size\n"); - } - - /* - * determine how we started to see if we are already in the background - * and get appropriately registered with rpcbind (portmapper) - */ - - if (isfrominetd(0)) { - /* - * Started from inetd: use fd 0 as socket - */ - if (Debug) - printf("Started from inetd\n"); - - if ((ListnerTransp = svctcp_create(0, 0, 0)) == NULL) { - fprintf(stderr, "rexd: svctcp_create error\n"); - exit(1); - } - - if (!svc_register(ListnerTransp, REXPROG, REXVERS, dorex, 0)) { - fprintf(stderr, "rexd: service register error\n"); - exit(1); - } - - alarm(ListnerTimeout); - } else { - - if (Debug) - printf("started from shell\n"); - if (!Debug) { - /* - * Started from shell, background - * thyself and run forever. - */ - - int pid = fork(); - - if (pid < 0) { /* fork error */ - perror("rpc.rexd: can't fork"); - exit(1); - } - - if (pid) { /* parent terminates */ - exit(0); - } - } - - /* - * child process continues to establish connections - */ - - if (Debug) - printf("before svctcp_create() call\n"); - if ((ListnerTransp = svctcp_create(RPC_ANYSOCK, 0, 0)) - == NULL) { - fprintf(stderr, "rexd: svctcp_create: error\n"); - exit(1); - } - - pmap_unset(REXPROG, REXVERS); - - if (!svc_register(ListnerTransp, REXPROG, REXVERS, - dorex, IPPROTO_TCP)) { - fprintf(stderr, "rexd: service rpc register: error\n"); - exit(1); - } - } - - /* - * Create a private temporary directory to hold rexd's mounts - */ - if (mkdir(TempDir, 0777) < 0) - if (errno != EEXIST) { - perror("rexd: mkdir"); - fprintf(stderr, - "rexd: can't create temp directory %s\n", - TempDir); - exit(1); - } - - if (Debug) - printf("created temporary directory\n"); - - - /* - * normally we would call svc_run() at this point, but we need to be - * informed of when the RPC connection is broken, in case the other - * side crashes. - */ - while (TRUE) { - if (Debug) - printf("Entered While loop\n"); - - if (MySocket) { - int i; - char *waste; - - /* try to find MySocket in the pollfd set */ - for (i = 0; i < svc_max_pollfd; i++) - if (svc_pollfd[i].fd == MySocket) - break; - /* - * If we didn't find it, the connection died for - * some random reason, e.g. client crashed. - */ - if (i == svc_max_pollfd) { - if (Debug) - printf("Connection died\n"); - (void) rex_wait(&waste); - rex_cleanup(); - exit(1); - } - } - - /* - * Get existing array of pollfd's, should really compress - * this but it shouldn't get very large (or sparse). - */ - if (npollfds != svc_max_pollfd) { - pollset = realloc(pollset, - sizeof (pollfd_t) * svc_max_pollfd); - npollfds = svc_max_pollfd; - } - - if (npollfds == 0) - break; /* None waiting, hence return */ - - (void) memcpy(pollset, svc_pollfd, - sizeof (pollfd_t) * svc_max_pollfd); - - if (Debug) - printf("Before select readfds\n"); - switch (pollretval = poll(pollset, npollfds, -1)) { - case -1: - if (Debug) - printf("Poll failed\n"); - if (errno == EINTR) - continue; - perror("rexd: poll failed"); - exit(1); - - case 0: - if (Debug) - printf("Poll returned zero\n"); - fprintf(stderr, "rexd: poll returned zero\r\n"); - continue; - - default: - if (Debug) - printf("Before HelperRead\n"); - if (HasHelper) - HelperRead(pollset, npollfds, &pollretval); - if (Debug) - printf("After HelperRead\n"); - time_now = time((time_t *)0); - if (Debug) - printf("before svc_getreq_poll\n"); - svc_getreq_poll(pollset, pollretval); - } - if (Debug) - printf("After switch\n"); - } - return (0); -} - -/* - * This function gets called after the listner has timed out waiting - * for any new connections coming in. - */ -void -ListnerTimer(int junk) -{ - /* - * svc_destroy not done here due to problems with M_ERROR - * on stream head and inetd - */ - exit(0); -} - -struct authunix_parms -*authdes_to_unix(des_cred) -struct authdes_cred *des_cred; -{ - struct authunix_parms *unix_cred; - static struct authunix_parms au; - static uint_t stuff[32]; - char publickey[HEXKEYBYTES+1]; - - - unix_cred = &au; - - unix_cred->aup_gids = (gid_t *)stuff; - - unix_cred->aup_machname = ""; - if (getpublickey(des_cred->adc_fullname.name, publickey) == 0) - return (NULL); - - if (netname2user(des_cred->adc_fullname.name, - &(unix_cred->aup_uid), - &(unix_cred->aup_gid), - (int *)&(unix_cred->aup_len), - unix_cred->aup_gids) == FALSE) - return (NULL); - else - return (unix_cred); -} - -/* - * dorex - handle one of the rex procedure calls, dispatching to the - * correct function. - */ -void -dorex(rqstp, transp) -struct svc_req *rqstp; -SVCXPRT *transp; -{ - struct rex_start *rst; - struct rex_result result; - struct authunix_parms *unix_cred; - struct sockaddr_in *calleraddr; - - - if (ListnerTransp) { - - /* - * First call - fork a server for this connection - */ - int fd, pid, count; - - for (count = 0; (pid = fork()) < 0; count++) { - if (count > 4) - { - perror("rexd: cannot fork"); - break; - } - sleep(5); - } - - if (pid != 0) { - - /* - * Parent - return to service loop to accept further - * connections. - */ - alarm(ListnerTimeout); - svc_destroy(transp); - return; - } - - /* - * child - close listner transport to avoid confusion - * Also need to close all other service transports - * besides the one we are interested in. - * Save ours so that we know when it goes away. - */ - if (Debug) - printf("child server process\n"); - - alarm(0); - - - - if (transp != ListnerTransp) { - - close(ListnerTransp->xp_sock); - xprt_unregister(ListnerTransp); - } - ListnerTransp = NULL; - - MySocket = transp->xp_sock; - - /* temp workaround to restore sanity in TLI state */ - if (transp->xp_sock != 0) - t_close(0); /* opened in parent possibly by inetd */ - - /* - * XXX: svc_pollfd[] is a read-only structure. This - * appears to be dead code, which should be removed. - * However, until it can be clearly understood, leaving - * in. - */ - for (fd = 1; fd < svc_max_pollfd; fd++) { - if (fd != transp->xp_sock && svc_pollfd[fd].fd == fd) { - - printf("close of fd %d\n", fd); - close(fd); - svc_pollfd[fd].fd = -1; - svc_pollfd[fd].events = 0; - svc_pollfd[fd].revents = 0; - } - } - } - - /* - * execute the requested prodcedure - */ - switch (rqstp->rq_proc) { - case NULLPROC: - if (Debug) /* XXX */ - printf("dorex: call to NULLPROC\n"); - - if (svc_sendreply(transp, xdr_void, 0) == FALSE) { - - fprintf(stderr, "rexd: nullproc err"); - exit(1); - } - return; - - case REXPROC_START: - if (Debug) /* XXX */ - printf("dorex: call to REXPROC_START\n"); - - - rst = (struct rex_start *)malloc(sizeof (struct rex_start)); - memset((char *)rst, '\0', sizeof (*rst)); - - if (svc_getargs(transp, xdr_rex_start, (char *)rst) == FALSE) { - - svcerr_decode(transp); - exit(1); - } - if (Debug) - printf("svc_getargs: suceeded\n"); - - if (rqstp->rq_cred.oa_flavor == AUTH_DES) { - - unix_cred = authdes_to_unix(rqstp->rq_clntcred); - - } else if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) { - - if (DesOnly) { - fprintf(stderr, - "Unix too weak auth(DesOnly)!\n"); - unix_cred = NULL; - } else - unix_cred = - (struct authunix_parms *)rqstp->rq_clntcred; - - } else { - - fprintf(stderr, "Unknown weak auth!\n"); - svcerr_weakauth(transp); - sleep(5); - exit(1); - } - - if (unix_cred == NULL) { - - svcerr_weakauth(transp); - sleep(5); - exit(1); - } - - calleraddr = svc_getcaller(transp); - - result.rlt_stat = (int)rex_startup(rst, - unix_cred, - (char **)&result.rlt_message, - calleraddr); - - if (Debug) - printf("rex_startup: completed\n"); - - if (svc_sendreply(transp, xdr_rex_result, (char *)&result) - == FALSE) { - fprintf(stderr, "rexd: reply failed\n"); - rex_cleanup(); - exit(1); - } - - if (Debug) - printf("svc_sendreply: suceeded\n"); - - if (result.rlt_stat) { - - rex_cleanup(); - exit(0); - } - return; - - case REXPROC_MODES: - { - struct rex_ttymode mode; - - if (Debug) /* XXX */ - printf("dorex: call to REXPROC_MODES\n"); - - if (svc_getargs(transp, xdr_rex_ttymode, - (char *)&mode) == FALSE) { - svcerr_decode(transp); - exit(1); - } - if (Debug) - printf("svc_getargs succ REXPROC_MODES call\n"); - - SetPtyMode(&mode); /* XXX Fix? */ - - if (svc_sendreply(transp, xdr_void, 0) == FALSE) { - - fprintf(stderr, "rexd: mode reply failed"); - exit(1); - } - } - return; - - case REXPROC_WINCH: /* XXX Fix? */ - { - struct rex_ttysize size; - - if (Debug) /* XXX */ - printf("dorex: call to REXPROC_WINCH\n"); - - if (svc_getargs(transp, xdr_rex_ttysize, (char *)&size) - == FALSE) { - svcerr_decode(transp); - exit(1); - } - - SetPtySize(&size); - - if (svc_sendreply(transp, xdr_void, 0) == FALSE) { - - fprintf(stderr, - "rexd: window change reply failed"); - exit(1); - } - } - return; - - case REXPROC_SIGNAL: - { - int sigNumber; - - if (Debug) /* XXX */ - printf("dorex: call to REXPROC_SIGNAL\n"); - - if (svc_getargs(transp, xdr_int, - (char *)&sigNumber) == FALSE) { - svcerr_decode(transp); - exit(1); - } - - SendSignal(sigNumber); - - if (svc_sendreply(transp, xdr_void, 0) == FALSE) { - fprintf(stderr, "rexd: signal reply failed"); - exit(1); - } - } - return; - - case REXPROC_WAIT: - if (Debug) /* XXX */ - printf("dorex: call to REXPROC_WAIT\n"); - - result.rlt_stat = rex_wait(&result.rlt_message); - - if (svc_sendreply(transp, xdr_rex_result, (char *)&result) - == FALSE) { - fprintf(stderr, "rexd: reply failed\n"); - exit(1); - } - - rex_cleanup(); - exit(0); - - /* NOTREACHED */ - default: - if (Debug) - printf("dorex: call to bad process!\n"); - - svcerr_noproc(transp); - exit(1); - } -} - -/* - * signal handler for SIGCHLD - called when user process dies or is stopped - */ -void -CatchChild(int junk) -{ - pid_t pid; - int status; - - if (Debug) - printf("Enter Catchild\n"); - - while ((pid = waitpid((pid_t)-1, &status, WNOHANG|WUNTRACED)) > 0) { - - if (Debug) printf("After waitpid\n"); - if (pid == child) { - if (Debug) - printf("pid==child\n"); - if (WIFSTOPPED(status)) { - sigset_t nullsigset; - - if (Debug) - printf("WIFSTOPPED\n"); - /* tell remote client to stop */ - send(OutputSocket, "", 1, MSG_OOB); - - sigemptyset(&nullsigset); - /* port of BSD sigpause(0); */ - sigsuspend(&nullsigset); - /* restart child */ - /* killpg() of SunOS 4.1.1 */ - kill((-child), SIGCONT); - return; - } - - /* - * XXX this probably does not cover all interesting - * exit cases hence reread the man page to determine - * if we need more data or more test cases - */ - - ChildStatus = status; - ChildDied = 1; - - if (HasHelper && svc_pollfd[Master].fd == -1) { - if (Debug) - printf("Within If HasHelper\n"); - KillHelper(child); - HasHelper = 0; - } - } - } -} - -/* - * oob -- called when we should restart the stopped child. - */ -void -oob(int junk) -{ - int atmark; - char waste[BUFSIZ], mark; - - for (;;) { - - if (ioctl(OutputSocket, SIOCATMARK, &atmark) < 0) { - perror("ioctl"); - break; - } - - if (atmark) - break; - - (void) read(OutputSocket, waste, sizeof (waste)); - } - - (void) recv(OutputSocket, &mark, 1, MSG_OOB); -} - -/* - * rex_wait - wait for command to finish, unmount the file system, - * and return the exit status. - * message gets an optional string error message. - */ -int -rex_wait(message) -char **message; -{ - static char error[1024]; - int count; - - *message = error; - strcpy(error, ""); - if (child == 0) { - errprintf(error, "No process to wait for!\n"); - rex_cleanup(); - return (1); - } - - kill(child, SIGHUP); - - for (count = 0; !ChildDied && count < WaitLimit; count++) - sleep(1); - - if (ChildStatus & 0xFF) - return (ChildStatus); - - return (ChildStatus >> 8); -} - - -/* - * cleanup - unmount and remove our temporary directory - */ -void -rex_cleanup() -{ - - if (tmpdir) { - - if (child && !ChildDied) { - - fprintf(stderr, - "rexd: child killed to unmount %s\r\n", - nfsdir); - kill(child, SIGKILL); - } - chdir("/"); - - if (nfsdir[0] && umount_nfs(nfsdir, tmpdir)) - fprintf(stderr, "rexd: couldn't umount %s from %s\r\n", - nfsdir, - tmpdir); - if (rmdir(tmpdir) < 0) - if (errno != EBUSY) - perror("rmdir"); - tmpdir = NULL; - - } - - if (Debug) - printf("rex_cleaup: HasHelper=%d\n", HasHelper); - if (HasHelper) - KillHelper(child); - - HasHelper = 0; -} - - -/* - * This function does the server work to get a command executed - * Returns 0 if OK, nonzero if error - */ -int -rex_startup(rst, ucred, message, calleraddr) -struct rex_start *rst; -struct authunix_parms *ucred; -char **message; -struct sockaddr_in *calleraddr; -{ - char hostname[255]; - char *p, *wdhost, *fsname, *subdir; - char dirbuf[1024]; - static char error[1024]; - char defaultShell[1024]; /* command executed if none given */ - char defaultDir[1024]; /* directory used if none given */ - int len; - int fd0, fd1, fd2; - extern pam_handle_t *pamh; - char *user = NULL; - - if (Debug) - printf("Beginning of Rex_Startup\n"); - - if (child) { /* already started */ - if (Debug) - printf("Killing \"child\" process\n"); - kill((-child), SIGKILL); /* killpg() of SunOS 4.1.1 */ - return (1); - } - - - *message = error; - (void) strcpy(error, ""); -/* sigset(SIGCHLD, CatchChild); */ - - - if (ValidUser(ucred->aup_machname, - (uid_t)ucred->aup_uid, - (gid_t)ucred->aup_gid, - error, - defaultShell, defaultDir, rst)) - return (1); - - if (rst->rst_fsname && strlen(rst->rst_fsname)) { - fsname = rst->rst_fsname; - subdir = rst->rst_dirwithin; - wdhost = rst->rst_host; - } else { - fsname = defaultDir; - subdir = ""; - wdhost = hostname; - } - - sysinfo(SI_HOSTNAME, hostname, 255); - - if (Debug) - printf("rexd: errno %d after gethostname\n", errno); - - if (Debug) { - printf("rex_startup on host %s:\nrequests fsname=%s", - hostname, fsname); - printf("\t\tsubdir=%s\t\twdhost=%s\n", subdir, wdhost); - } - if (strcmp(wdhost, hostname) == 0) { - - /* - * The requested directory is local to our machine, - * so just change to it. - */ - strcpy(dirbuf, fsname); - } else { - - static char wanted[1024]; - static char mountedon[1024]; - - strcpy(wanted, wdhost); - strcat(wanted, ":"); - strcat(wanted, fsname); - - if (AlreadyMounted(wanted, mountedon)) { - - if (Debug) - printf("AlreadyMounted (%d)\n", errno); - - /* - * The requested directory is already mounted. If the - * mount is not by another rexd, just change to it. - * Otherwise, mount it again. If just changing to - * the mounted directy, be careful. It might be mounted - * in a different place. - * (dirbuf is modified in place!) - */ - if (strncmp(mountedon, TempName, TempMatch) == 0) { - tmpdir = mktemp(TempName); - /* - * XXX errno is set to ENOENT on success - * of mktemp because of accesss checks for file - */ - if (errno == ENOENT) - errno = 0; - - if (mkdir(tmpdir, 0777)) { - perror("Already Mounted"); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - - if (Debug) - printf("created %s (%d)\n", - tmpdir, errno); - - strcpy(nfsdir, wanted); - - if (mount_nfs(wanted, tmpdir, error)) { - if (Debug) - printf("mount_nfs:error return\n"); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - if (Debug) - printf("mount_nfs: success return\n"); - - strcpy(dirbuf, tmpdir); - - } else - strcpy(dirbuf, mountedon); - - } else { - if (Debug) - printf("not AlreadyMounted (%d)\n", errno); - /* - * The requested directory is not mounted anywhere, - * so try to mount our own copy of it. We set nfsdir - * so that it gets unmounted later, and tmpdir so that - * it also gets removed when we are done. - */ - tmpdir = mktemp(TempName); - - /* - * XXX errno is set to ENOENT on success of mktemp - * becuase of accesss checks for file - */ - if (errno == ENOENT) - errno = 0; - if (mkdir(tmpdir, 0777)) { - perror("Not Already Mounted"); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - - if (Debug) - printf("created %s (%d)\n", tmpdir, errno); - - strcpy(nfsdir, wanted); - - if (mount_nfs(wanted, tmpdir, error)) { - if (Debug) - printf("mount_nfs:error return\n"); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - if (Debug) - printf("mount_nfs: success return\n"); - strcpy(dirbuf, tmpdir); - } - } - - /* - * "dirbuf" now contains the local mount point, so just tack on - * the subdirectory to get the pathname to which we "chdir" - */ - strcat(dirbuf, subdir); - - - fd0 = socket(AF_INET, SOCK_STREAM, 0); - if (Debug) - printf("Before doconnect\n"); - fd0 = doconnect(calleraddr, rst->rst_port0, fd0); - OutputSocket = fd0; - - /* - * Arrange for fd0 to send the SIGURG signal when out-of-band data - * arrives, which indicates that we should send the stopped child a - * SIGCONT signal so that we can resume work. - */ - (void) fcntl(fd0, F_SETOWN, getpid()); - /* ioctl(fd0, SIOCSPGRP, ?X?); */ - sigset(SIGURG, oob); - - if (Debug) - printf("Before \"use same port\"\n"); - if (rst->rst_port0 == rst->rst_port1) { - /* - * use the same connection for both stdin and stdout - */ - fd1 = fd0; - } - - if (rst->rst_flags & REX_INTERACTIVE) { - /* - * allocate a pseudo-terminal if necessary - */ - if (Debug) - printf("Before AllocatePty call\n"); - - /* AllocatePty has grantpt() call which has bug */ - /* Hence clear SIGCHLD handler setting */ - sigset(SIGCHLD, SIG_DFL); - if (AllocatePty(fd0, fd1)) { - errprintf(error, "rexd: cannot allocate a pty\n"); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - HasHelper = 1; - } - /* - * this sigset()call moved to after AllocatePty() call - * because a bug in waitpid() inside grantpt() - * causes CatchChild() to be invoked. - */ - - sigset(SIGCHLD, CatchChild); - - if (rst->rst_flags & REX_INTERACTIVE) { - sigset(SIGWINCH, sigwinch); /* a dummy signal handler */ - /* block the sigpause until signal in */ - /* child releases the signal */ - sighold(SIGWINCH); - } - - if (Debug) - printf("Before a \"child\" fork\n"); - - child = fork(); - - if (child < 0) { - errprintf(error, "rexd: can't fork\n"); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - - if (child) { - /* - * parent rexd: close network connections if needed, - * then return to the main loop. - */ - if ((rst->rst_flags & REX_INTERACTIVE) == 0) { - close(fd0); - close(fd1); - } - if (Debug) - printf("Parent ret to main loop, child does startup\n"); - if (pamh) { - pam_end(pamh, PAM_SUCCESS); - pamh = NULL; - } - return (0); - } - - /* child rexd */ - - if (Debug) - printf("Child rexd\n"); - - /* setpgrp(0, 0) */ - setsid(); /* make session leader */ - - if (Debug) - printf("After setsid\n"); - - if (rst->rst_flags & REX_INTERACTIVE) { - if (Debug) - printf("Before OpenPtySlave\n"); - /* reopen slave so that child has controlling tty */ - OpenPtySlave(); - if (Debug) - printf("After OpenPtySlave\n"); - } - - if (rst->rst_port0 != rst->rst_port1) { - - if (Debug) - printf("rst_port0 != rst_port1\n"); /* XXX */ - - fd1 = socket(AF_INET, SOCK_STREAM, 0); - shutdown(fd0, 1); /* 1=>further sends disallowed */ - fd1 = doconnect(calleraddr, rst->rst_port1, fd1); - shutdown(fd1, 0); /* 0=>further receives disallowed */ - } - - if (rst->rst_port1 == rst->rst_port2) { - if (Debug) - printf("rst_port1 == rst_port2\n"); /* XXX */ - - /* - * Use the same connection for both stdout and stderr - */ - fd2 = fd1; - } else { - if (Debug) - printf("rst_port1 != rst_port2\n"); /* XXX */ - - fd2 = socket(AF_INET, SOCK_STREAM, 0); - fd2 = doconnect(calleraddr, rst->rst_port2, fd2); - shutdown(fd2, 0); /* 0=>further receives disallowed */ - } - - if (rst->rst_flags & REX_INTERACTIVE) { - - /* - * use ptys instead of sockets in interactive mode - */ - DoHelper(&fd0, &fd1, &fd2); - LoginUser(); - } - - dup2(fd0, 0); - dup2(fd1, 1); - dup2(fd2, 2); - - /* setup terminal ID (use read file descriptor) */ - if (audit_settid(fd0) != 0) { - errprintf("cannot set audit characteristics\n"); - return (1); - } - - closefrom(3); - - if (Debug) - printf("After close-all-fds-loop-- errno=%d\n", errno); - - environ = rst->rst_env; - - if (pam_get_item(pamh, PAM_USER, (void **)&user) != PAM_SUCCESS) { - audit_rexd_fail("user id is not valid", - ucred->aup_machname, - user, - ucred->aup_uid, - ucred->aup_gid, - defaultShell, - rst->rst_cmd); /* BSM */ - fprintf(stderr, "rexd: invalid uid/gid.\n"); - exit(1); - } - - /* set the real (and effective) GID */ - if (setgid(ucred->aup_gid) == -1) { - fprintf(stderr, "rexd: invalid gid.\n"); - exit(1); - } - /* Set the supplementary group access list. */ - if (setgroups(ucred->aup_len, (gid_t *)ucred->aup_gids) == -1) { - fprintf(stderr, "rexd: invalid group list.\n"); - exit(1); - } - - if (pam_setcred(pamh, PAM_ESTABLISH_CRED) != PAM_SUCCESS) { - audit_rexd_fail("user id is not valid", - ucred->aup_machname, - user, - ucred->aup_uid, - ucred->aup_gid, - defaultShell, - rst->rst_cmd); /* BSM */ - fprintf(stderr, "rexd: invalid uid/gid.\n"); - exit(1); - } - - audit_rexd_success(ucred->aup_machname, - user, - ucred->aup_uid, - ucred->aup_gid, - defaultShell, - rst->rst_cmd); /* BSM */ - - /* set the real (and effective) UID */ - if (setuid(ucred->aup_uid) == -1) { - fprintf(stderr, "rexd: invalid uid.\n"); - exit(1); - } - - if (pamh) { - pam_end(pamh, PAM_SUCCESS); - pamh = NULL; - } - - if (Debug) /* XXX */ - fprintf(stderr, "uid %d gid %d (%d)\n", - ucred->aup_uid, ucred->aup_gid, errno); - - if (chdir(dirbuf)) { - fprintf(stderr, "rexd: can't chdir to %s\n", dirbuf); - exit(1); - } - - sigset(SIGINT, SIG_DFL); - sigset(SIGHUP, SIG_DFL); - sigset(SIGQUIT, SIG_DFL); - - if (rst->rst_flags & REX_INTERACTIVE) { - /* pause to sync with first SIGWINCH sent as part of */ - sigpause(SIGWINCH); - /* protocol and handled by parent doing other rex primitves */ - sigrelse(SIGWINCH); - sigset(SIGWINCH, SIG_DFL); - } - - if (rst->rst_cmd == (char **)NULL) { - - /* - * Null command means execute the default shell for this user - */ - char *args[2]; - - args[0] = defaultShell; - args[1] = NULL; - - execvp(defaultShell, args); - - fprintf(stderr, "rexd: can't exec shell %s\n", defaultShell); - exit(1); - } - - if (Debug) - for (len = 0; rst->rst_cmd[len] != (char *)NULL && - *rst->rst_cmd[len] != NULL; len++) - printf("cmds: %s (%d)\n", rst->rst_cmd[len], errno); - - - /* XXX */ - if (Debug) - for (len = 0; rst->rst_env[len] != (char *)NULL && - *rst->rst_env[len] != NULL; len++) - printf("envs: %s\n", rst->rst_env[len]); - - - execvp(rst->rst_cmd[0], rst->rst_cmd); - - /* XXX get rid of errno in parens */ - fprintf(stderr, "rexd: can't exec %s (%d)\n", *rst->rst_cmd, errno); - exit(1); -} - -/* - * Search the mount table to see if the given file system is already - * mounted. If so, return the place that it is mounted on. - */ -int -AlreadyMounted(fsname, mountedon) -char *fsname; -char *mountedon; -{ - FILE *table; - struct mnttab mt; - - table = setmntent(MOUNTED, "r"); - if (table == NULL) - return (0); - - while ((getmntent(table, &mt)) != (-1)) { - - if (strcmp(mt.mnt_special, fsname) == 0) { - strcpy(mountedon, mt.mnt_mountp); - endmntent(table); - return (1); - } - } - endmntent(table); - - return (0); -} - - -/* - * connect to the indicated IP address/port, and return the - * resulting file descriptor. - */ -int -doconnect(sin, port, fd) -struct sockaddr_in *sin; -short port; -int fd; -{ - sin->sin_port = ntohs(port); - - if (connect(fd, (struct sockaddr *)sin, sizeof (*sin))) { - - perror("rexd: connect"); - exit(1); - } - - return (fd); -} - -void -sigwinch(int junk) -{ -} - -/* - * SETPROCTITLE -- set the title of this process for "ps" - * - * Does nothing if there were not enough arguments on the command - * line for the information. - * - * Side Effects: - * Clobbers argv[] of our main procedure. - */ -void -setproctitle(user, host) -char *user, *host; -{ - register char *tohere; - - tohere = Argv[0]; - if ((int)(LastArgv == NULL) || - (int)(strlen(user)+strlen(host)+3) > - (int)(LastArgv - tohere)) - return; - - *tohere++ = '-'; /* So ps prints (rpc.rexd) */ - sprintf(tohere, "%s@%s", user, host); - while (*tohere++) /* Skip to end of printf output */ - ; - while (tohere < LastArgv) /* Avoid confusing ps */ - *tohere++ = ' '; -} - - -/* - * Determine if started from inetd or not - */ - -int -isfrominetd(fd) -int fd; -{ - /* - * If fd looks like a TLI endpoint, we assume - * that we were started by a port monitor. If - * t_getstate fails with TBADF, this is not a - * TLI endpoint. - */ - if (t_getstate(0) != -1 || t_errno != TBADF) - return (1); - return (0); -} diff --git a/usr/src/cmd/rexd/sharetab.c b/usr/src/cmd/rexd/sharetab.c deleted file mode 100644 index fcfa2d0a68..0000000000 --- a/usr/src/cmd/rexd/sharetab.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/types32.h> -#include <sharefs/share.h> -#include "sharetab.h" - -static share_t *sharedup(); -static void sharefree(); - -/* - * Get an entry from the share table. - * There should be at least 4 fields: - * - * pathname resource fstype options [ description ] - * - * A fifth field (description) is optional. - * - * Returns: - * > 1 valid entry - * = 0 end of file - * < 0 error - */ -int -getshare(FILE *fd, share_t **shp) -{ - static char *line = NULL; - static share_t *sh = NULL; - register char *p; - char *w = " \t"; - - if (line == NULL) { - line = (char *)malloc(BUFSIZ+1); - if (line == NULL) - return (-1); - } - if (sh == NULL) { - sh = (share_t *)malloc(sizeof (*sh)); - if (sh == NULL) - return (-1); - } - - p = fgets(line, BUFSIZ, fd); - if (p == NULL) - return (0); - line[strlen(line) - 1] = '\0'; - - sh->sh_path = strtok(p, w); - if (sh->sh_path == NULL) - return (-1); - sh->sh_res = strtok(NULL, w); - if (sh->sh_res == NULL) - return (-1); - sh->sh_fstype = strtok(NULL, w); - if (sh->sh_fstype == NULL) - return (-1); - sh->sh_opts = strtok(NULL, w); - if (sh->sh_opts == NULL) - return (-1); - sh->sh_descr = strtok(NULL, ""); - if (sh->sh_descr == NULL) - sh->sh_descr = ""; - - *shp = sh; - return (1); -} - -static share_t * -sharedup(share_t *sh) -{ - share_t *nsh; - - nsh = (share_t *)calloc(1, sizeof (*nsh)); - if (nsh == NULL) - return (NULL); - - nsh->sh_path = strdup(sh->sh_path); - if (nsh->sh_path == NULL) - goto alloc_failed; - nsh->sh_res = strdup(sh->sh_res); - if (nsh->sh_res == NULL) - goto alloc_failed; - nsh->sh_fstype = strdup(sh->sh_fstype); - if (nsh->sh_fstype == NULL) - goto alloc_failed; - nsh->sh_opts = strdup(sh->sh_opts); - if (nsh->sh_opts == NULL) - goto alloc_failed; - nsh->sh_descr = strdup(sh->sh_descr); - if (nsh->sh_descr == NULL) - goto alloc_failed; - return (nsh); - -alloc_failed: - sharefree(nsh); - return (NULL); -} - -static void -sharefree(share_t *sh) -{ - if (sh == NULL) - return; - if (sh->sh_path != NULL) - free(sh->sh_path); - if (sh->sh_res != NULL) - free(sh->sh_res); - if (sh->sh_fstype != NULL) - free(sh->sh_fstype); - if (sh->sh_opts != NULL) - free(sh->sh_opts); - if (sh->sh_descr != NULL) - free(sh->sh_descr); - free(sh); -} - -/* - * Return the value after "=" for option "opt" - * in option string "optlist". - */ -char * -getshareopt(char *optlist, char *opt) -{ - char *p, *pe; - char *b; - static char *bb; - - if (bb) - free(bb); - b = bb = strdup(optlist); - if (b == NULL) - return (NULL); - - while (p = strtok(b, ",")) { - b = NULL; - if (pe = strchr(p, '=')) { - *pe = '\0'; - if (strcmp(opt, p) == 0) - return (pe + 1); - } - if (strcmp(opt, p) == 0) - return (""); - } - - return (NULL); -} diff --git a/usr/src/cmd/rexd/sharetab.h b/usr/src/cmd/rexd/sharetab.h deleted file mode 100644 index 9e68065d2c..0000000000 --- a/usr/src/cmd/rexd/sharetab.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -/* - * Note: <sharefs/share.h> must be included before this file. - */ - -#ifndef _SHARETAB_H -#define _SHARETAB_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -/* generic options */ -#define SHOPT_RO "ro" -#define SHOPT_RW "rw" - -/* options for nfs */ -#define SHOPT_ROOT "root" -#define SHOPT_ANON "anon" -#define SHOPT_SECURE "secure" -#define SHOPT_WINDOW "window" - -int getshare(); -char *getshareopt(); - -#ifdef __cplusplus -} -#endif - -#endif /* !_SHARETAB_H */ diff --git a/usr/src/cmd/rexd/under.c b/usr/src/cmd/rexd/under.c deleted file mode 100644 index 9a2b2c44e5..0000000000 --- a/usr/src/cmd/rexd/under.c +++ /dev/null @@ -1,223 +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 1985 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - - -/* - * under.c - program to execute a command under a given directory - * - */ - -#include <errno.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <rpc/rpc.h> -#include <nfs/nfs.h> -#include <rpcsvc/mount.h> -#include <sys/time.h> - -static char **Argv; /* saved argument vector (for ps) */ -static char *LastArgv; /* saved end-of-argument vector */ - -int Debug = 0; - -int child = 0; /* pid of the executed process */ -int ChildDied = 0; /* true when above is valid */ -int HasHelper = 0; /* must kill helpers (interactive mode) */ -time_t time_now; -/* - * SETPROCTITLE -- set the title of this process for "ps" - * - * Does nothing if there were not enough arguments on the command - * line for the information. - * - * Side Effects: - * Clobbers argv[] of our main procedure. - */ -void -setproctitle(user, host) - char *user, *host; -{ - register char *tohere; - - tohere = Argv[0]; - if ((int)(LastArgv == (char *)NULL) || - (int)(strlen(user)+strlen(host)+3) > (int)(LastArgv - tohere)) - return; - *tohere++ = '-'; /* So ps prints (rpc.rexd) */ - sprintf(tohere, "%s@%s", user, host); - while (*tohere++) /* Skip to end of printf output */ - ; - while (tohere < LastArgv) /* Avoid confusing ps */ - *tohere++ = ' '; -} - - -void -main(argc, argv) - int argc; - char **argv; -{ - static char usage[] = "Usage: under [-d] dir command...\n"; - char *dir, *p; - char hostname[255]; - char *tmpdir, *subdir, *parsefs(); - char dirbuf[1024]; - char error[1024]; - int status; - int len; - - if (argc < 3) - { - fprintf(stderr, usage); - exit(1); - } - - /* - * argv start and extent for setproctitle() - */ - Argv = argv; - if (argc > 0) - LastArgv = argv[argc-1] + strlen(argv[argc-1]); - else - LastArgv = NULL; - - gethostname(hostname, 255); - strcat(hostname, ":/"); - len = strlen(hostname); - if ( strcmp( argv[1], "-d" ) == 0 ) - { - Debug = 1; - argv++; - } - dir = argv[1]; - if ( (int)strlen(dir) > len && (int)strncmp(dir, hostname, len) == 0) - dir = strchr(dir, ':') + 1; - else if (p = strchr(dir, ':')) - { - if (p[1] != '/') - { - fprintf(stderr, "under: %s invalid name\n", dir); - exit(1); - } - - tmpdir = mktemp("/tmp/underXXXXXX"); - - if ( Debug && errno ) - { - if ( errno != ENOENT ) - printf("mktemp of %s returned %d %s\n", - tmpdir, errno, strerror(errno)); - } - errno = 0; /* XXX access() call in mktemp sets errno = ENOENT */ - - if (mkdir(tmpdir, 0777)) - { - perror(tmpdir); - exit(1); - } - - if ( Debug && errno ) - printf("mkdir of %s returned %d %s\n", - tmpdir, errno, strerror(errno)); - - subdir = parsefs(dir, error); - if (subdir == NULL) - { - exit(1); - } - time_now = time((long *) 0); - if (mount_nfs(dir, tmpdir, error)) - { - exit(1); - } - strcpy(dirbuf, tmpdir); - strcat(dirbuf, "/"); - strcat(dirbuf, subdir); - status = runcmd(dirbuf, argv[2], &argv[2]); - if (umount_nfs(dir, tmpdir)) - fprintf(stderr, "under: couldn't umount %s\n", dir); - rmdir(tmpdir); - exit(status); - } - - setgid(getgid()); - setuid(getuid()); - if (chdir(dir)) - { - perror(dir); - exit(1); - } - execvp(argv[2], &argv[2]); - perror(argv[2]); - exit(1); - /* NOTREACHED */ -} - -typedef void (*sig_t)(); - -int -runcmd(dir, cmd, args) - char *dir; - char *cmd; - char **args; -{ - int pid, child, status; - sig_t sigint, sigquit; - - sigint = sigset(SIGINT, SIG_IGN); - sigquit = sigset(SIGQUIT, SIG_IGN); - pid = fork(); - if (pid == -1) - return (0177); - if (pid == 0) - { - setgid(getgid()); - setuid(getuid()); - if (chdir(dir)) - { - perror(dir); - exit(1); - } - (void) sigset(SIGINT, sigint); - (void) sigset(SIGQUIT, sigquit); - execvp(cmd, args); - perror(cmd); - exit(1); - } - while ((child = wait(&status)) != pid && child != -1) - ; - (void) sigset(SIGINT, sigint); - (void) sigset(SIGQUIT, sigquit); - if (child == -1) - return (0177); - if (status & 0377) - return (status & 0377); - return ((status >> 8) & 0377); -} diff --git a/usr/src/cmd/rexd/unix_login.c b/usr/src/cmd/rexd/unix_login.c deleted file mode 100644 index d21e55757a..0000000000 --- a/usr/src/cmd/rexd/unix_login.c +++ /dev/null @@ -1,647 +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" - -#define BSD_COMP -#include <errno.h> -#include <fcntl.h> -#include <pwd.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include <sac.h> /* for SC_WILDC */ -#include <utmpx.h> - -#include <rpc/rpc.h> -#include <sys/file.h> -#include <sys/filio.h> -#include <sys/ioctl.h> -#include <sys/signal.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/wait.h> - -/* - * # include <sys/label.h> - * # include <sys/audit.h> - * - * - * - * # include <pwdadj.h> - */ - -#include <sys/ttold.h> -#include <stropts.h> -#include <sys/stream.h> - - - -#include "rex.h" - -#include <security/pam_appl.h> -pam_handle_t *pamh; - -#define NTTYDISC 2 /* New ttydiscipline: stolen from ttold.h */ - -/* - * unix_login - hairy junk to simulate logins for Unix - */ - -int Master, Slave; /* sides of the pty */ -int Slave_is_closed_on_master_side; - -static char *slavename; -extern char *ptsname(); - - -int InputSocket, /* Network sockets */ - OutputSocket; -int Helper1, /* pids of the helpers */ - Helper2; -char UserName[256]; /* saves the user name for loging */ -char HostName[256]; /* saves the host name for loging */ - -static int TtySlot; /* slot number in Utmpx */ - -/* - * pseudo-xprts used to add pty fds to svc_pollfd[]. This allows the - * polling for all i/o in one poll(). - */ -SVCXPRT uxprt[2]; - -#define INPUTSOCKET 0 /* InputSocket xprt */ -#define MASTER 1 /* Master xprt */ - - -extern int child; /* pid of the executed process */ -extern int ChildDied; /* flag */ -extern int HasHelper; /* flag */ - -extern void setproctitle(char *user, char *host); -extern int Debug; - -extern void audit_rexd_fail(char *, char *, char *, uid_t, gid_t, - char *, char **); - -#define bzero(s, n) memset((s), 0, (n)) -#define bcopy(a, b, c) memcpy((b), (a), (c)) - -static void LogoutUser(void); - -/* - * Check for user being able to run on this machine. - * returns 0 if OK, TRUE if problem, error message in "error" - * copies name of shell and home directory if user is valid. - */ -int -ValidUser(host, uid, gid, error, shell, dir, rst) - char *host; /* passed in */ - uid_t uid; - gid_t gid; - char *error; /* filled in on return */ - char *shell; /* filled in on return */ - char *dir; /* filled in on return */ - struct rex_start *rst; /* passed in */ -{ - struct passwd *pw, *getpwuid(); - int v; - - pw = getpwuid(uid); - if (pw == NULL || pw->pw_name == NULL) - { - errprintf(error, "rexd: User id %d not valid\n", uid); - audit_rexd_fail("user id is not valid", - host, - NULL, - uid, - gid, - NULL, - rst->rst_cmd); /* BSM */ - return (1); - } - strncpy(UserName, pw->pw_name, sizeof (UserName) - 1); - strncpy(HostName, host, sizeof (HostName) - 1); - strcpy(shell, pw->pw_shell); - strcpy(dir, pw->pw_dir); - setproctitle(pw->pw_name, host); - - if (pam_start("rexd", pw->pw_name, NULL, &pamh) != PAM_SUCCESS || - pam_set_item(pamh, PAM_RHOST, host) != PAM_SUCCESS) { - audit_rexd_fail("user id is not valid", - host, - pw->pw_name, - uid, - gid, - shell, - rst->rst_cmd); /* BSM */ - errprintf(error, "rexd: User id %d not valid\n", uid); - if (pamh) { - pam_end(pamh, PAM_ABORT); - pamh = NULL; - } - return (1); - } - - if ((v = pam_acct_mgmt(pamh, 0)) != PAM_SUCCESS) { - switch (v) { - case PAM_NEW_AUTHTOK_REQD: - errprintf(error, - "rexd: User id %d Password Expired\n", uid); - break; - case PAM_PERM_DENIED: - errprintf(error, - "rexd: User id %d Account Expired\n", uid); - break; - case PAM_AUTHTOK_EXPIRED: - errprintf(error, - "rexd: User id %d Password Expired\n", uid); - break; - default: - errprintf(error, - "rexd: User id %d not valid\n", uid); - break; - } - pam_end(pamh, PAM_ABORT); - pamh = NULL; - - audit_rexd_fail("user account expired", - host, - pw->pw_name, - uid, - gid, - shell, - rst->rst_cmd); /* BSM */ - return (1); - } - - return (0); -} - -/* - * Add an audit record with argv that was pre-set, plus the given string - */ - -/* - * Allocate a pseudo-terminal - * sets the global variables Master and Slave. - * returns 1 on error, 0 if OK - */ -int -AllocatePty(socket0, socket1) - int socket0, socket1; -{ - - int on = 1; - - sigset(SIGHUP, SIG_IGN); - sigset(SIGTTOU, SIG_IGN); - sigset(SIGTTIN, SIG_IGN); - - if ((Master = open("/dev/ptmx", O_RDWR)) == -1) { - if (Debug) - printf("open-ptmx-failure\n"); - perror("AloocatePtyMaster fails"); - return (1); /* error could not open /dev/ptmx */ - } - if (Debug) - printf("open-ptmx success Master =%d\n", Master); - if (Debug) - printf("Before grantpt...Master=%d\n", Master); - - if (grantpt(Master) == -1) { - perror("could not grant slave pty"); - exit(1); - } - if (unlockpt(Master) == -1) { - perror("could not unlock slave pty"); - exit(1); - } - if ((slavename = ptsname(Master)) == NULL) { - perror("could not enable slave pty"); - exit(1); - } - if ((Slave = open(slavename, O_RDWR)) == -1) { - perror("could not open slave pty"); - exit(1); - } - if (ioctl(Slave, I_PUSH, "ptem") == -1) { - perror("ioctl I_PUSH ptem"); - exit(1); - } - if (ioctl(Slave, I_PUSH, "ldterm") == -1) { - perror("ioctl I_PUSH ldterm"); - exit(1); - } - if (ioctl(Slave, I_PUSH, "ttcompat") == -1) { - perror("ioctl I_PUSH ttcompat"); - exit(1); - } - - Slave_is_closed_on_master_side = FALSE; - setsid(); /* get rid of controlling terminal */ - /* LoginUser(); */ - - InputSocket = socket0; - OutputSocket = socket1; - ioctl(Master, FIONBIO, &on); - uxprt[INPUTSOCKET].xp_fd = InputSocket; - xprt_register(&uxprt[INPUTSOCKET]); - uxprt[MASTER].xp_fd = Master; - xprt_register(&uxprt[MASTER]); - return (0); - -} - -void -OpenPtySlave() -{ - close(Slave); - Slave = open(slavename, O_RDWR); - if (Slave < 0) { - perror(slavename); - exit(1); - } -} - - - - /* - * Special processing for interactive operation. - * Given pointers to three standard file descriptors, - * which get set to point to the pty. - */ -void -DoHelper(pfd0, pfd1, pfd2) - int *pfd0, *pfd1, *pfd2; -{ - int pgrp; - - - sigset(SIGINT, SIG_IGN); - close(Master); - close(InputSocket); - close(OutputSocket); - - *pfd0 = Slave; - *pfd1 = Slave; - *pfd2 = Slave; -} - - -/* - * destroy the helpers when the executing process dies - */ -void -KillHelper(int grp) -{ - if (Debug) - printf("Enter KillHelper\n"); - close(Master); - xprt_unregister(&uxprt[MASTER]); - close(InputSocket); - xprt_unregister(&uxprt[INPUTSOCKET]); - close(OutputSocket); - LogoutUser(); - - if (grp) - kill((-grp), SIGKILL); -} - - -/* - * edit the Unix traditional data files that tell who is logged - * into "the system" - */ -unsigned char utid[] = {'o', 'n', SC_WILDC, SC_WILDC}; - -void -LoginUser(void) -{ - - char *user; - char *rhost; - /* the next 4 variables are needed for utmpx mgmt */ - int tmplen; - struct utmpx *u = NULL; - struct utmpx set_utmp; - char *ttyntail; - - /* We're pretty drastic here, exiting if an error is detected */ - if (pam_set_item(pamh, PAM_TTY, slavename) != PAM_SUCCESS || - pam_get_item(pamh, PAM_USER, (void **) &user) != PAM_SUCCESS || - pam_get_item(pamh, PAM_RHOST, (void **) &rhost) != PAM_SUCCESS || - pam_open_session(pamh, 0) != PAM_SUCCESS) { - /* - * XXX should print something but for now we exit - */ - exit(1); - } - - (void) memset((void *)&set_utmp, 0, sizeof (set_utmp)); - (void) time(&set_utmp.ut_tv.tv_sec); - set_utmp.ut_pid = getpid(); - if (rhost != NULL && rhost[0] != '\0') { - (void) strcpy(set_utmp.ut_host, rhost); - tmplen = strlen(rhost) + 1; - if (tmplen < sizeof (set_utmp.ut_host)) - set_utmp.ut_syslen = tmplen; - else - set_utmp.ut_syslen = sizeof (set_utmp.ut_host); - } else { - (void) memset(set_utmp.ut_host, 0, sizeof (set_utmp.ut_host)); - set_utmp.ut_syslen = 0; - } - (void) strcpy(set_utmp.ut_user, user); - - /* - * Copy in the name of the tty minus the "/dev/" if a /dev/ is - * in the path name. - */ - ttyntail = slavename; - if (strstr(ttyntail, "/dev/") != 0) - ttyntail = ttyntail + strlen("/dev/"); - (void) strcpy(set_utmp.ut_line, ttyntail); - - set_utmp.ut_type = USER_PROCESS; - if (utid != NULL) - (void) memcpy(set_utmp.ut_id, utid, sizeof (set_utmp.ut_id)); - /* - * Go through each entry one by one, looking only at INIT, - * LOGIN or USER Processes. Use the entry found if flags == 0 - * and the line name matches, or if the process ID matches if - * the UPDATE_ENTRY flag is set. The UPDATE_ENTRY flag is mainly - * for login which normally only wants to update an entry if - * the pid fields matches. - */ - - if (u == (struct utmpx *)NULL) { - (void) makeutx(&set_utmp); - } else - updwtmpx(WTMPX_FILE, &set_utmp); - -} - -/* - * edit the Unix traditional data files that tell who is logged - * into "the system". - */ -static void -LogoutUser(void) -{ - struct utmpx *up; - struct utmpx ut; - int pid; - char user[sizeof (ut.ut_user) + 1]; - char ttyn[sizeof (ut.ut_line) + 1]; - char rhost[sizeof (ut.ut_host) + 1]; - - sighold(SIGCHLD); /* no disruption during cleanup */ - - if (pamh) { - pam_end(pamh, PAM_SUCCESS); - pamh = NULL; - } - - /* BEGIN RESET UTMP */ - pid = child; - setutxent(); - while (up = getutxent()) { - if (up->ut_pid == pid) { - if (up->ut_type == DEAD_PROCESS) { - /* - * Cleaned up elsewhere. - */ - break; - } - - strncpy(user, up->ut_user, sizeof (up->ut_user)); - user[sizeof (up->ut_user)] = '\0'; - strncpy(ttyn, up->ut_line, sizeof (up->ut_line)); - ttyn[sizeof (up->ut_line)] = '\0'; - strncpy(rhost, up->ut_host, sizeof (up->ut_host)); - rhost[sizeof (up->ut_host)] = '\0'; - - if ((pam_start("rexd", user, NULL, &pamh)) - == PAM_SUCCESS) { - (void) pam_set_item(pamh, PAM_TTY, ttyn); - (void) pam_set_item(pamh, PAM_RHOST, rhost); - (void) pam_close_session(pamh, 0); - (void) pam_end(pamh, PAM_SUCCESS); - pamh = NULL; - } - - up->ut_type = DEAD_PROCESS; - up->ut_exit.e_termination = WTERMSIG(0); - up->ut_exit.e_exit = WEXITSTATUS(0); - (void) time(&up->ut_tv.tv_sec); - if (modutx(up) == NULL) { - /* - * Since modutx failed we'll - * write out the new entry - * ourselves. - */ - (void) pututxline(up); - updwtmpx("wtmpx", up); - } - break; - } - } - endutxent(); - /* END RESET UTMP */ - sigrelse(SIGCHLD); -} - -/* - * set the pty modes to the given values - */ -void -SetPtyMode(mode) - struct rex_ttymode *mode; -{ - struct sgttyb svr4_sgttyb_var; - int ldisc = NTTYDISC; - - if (Debug) - printf("Enter SetPtyMode\n"); - if (Debug) - printf("SetPtyMode:opened slave\n"); - ioctl(Slave, TIOCSETD, &ldisc); - if (Debug) - printf("SetPtyMode:Slave TIOCSETD done\n"); - - /* - * Copy from over-the-net(bsd) to SVR4 format - */ - svr4_sgttyb_var.sg_ispeed = mode->basic.sg_ispeed; - svr4_sgttyb_var.sg_ospeed = mode->basic.sg_ospeed; - svr4_sgttyb_var.sg_erase = mode->basic.sg_erase; - svr4_sgttyb_var.sg_kill = mode->basic.sg_kill; - svr4_sgttyb_var.sg_flags = (int)mode->basic.sg_flags; - /* - * Clear any possible sign extension caused by (int) - * typecast - */ - svr4_sgttyb_var.sg_flags &= 0xFFFF; - - ioctl(Slave, TIOCSETN, &svr4_sgttyb_var); - if (Debug) - printf("SetPtyMode:Slave TIOCSETN done\n"); - ioctl(Slave, TIOCSETC, &mode->more); - if (Debug) - printf("SetPtyMode:Slave TIOCSETC done\n"); - ioctl(Slave, TIOCSLTC, &mode->yetmore); - if (Debug) - printf("SetPtyMode:Slave TIOCSLTC done\n"); - ioctl(Slave, TIOCLSET, &mode->andmore); - if (Debug) - printf("SetPtyMode:Slave TIOCSET done\n"); - - /* Opened in AllocPty for parent, still open in child */ - if (Slave_is_closed_on_master_side == FALSE) { - close(Slave); - Slave_is_closed_on_master_side = TRUE; - } -} - -/* - * set the pty window size to the given value - */ -void -SetPtySize(struct rex_ttysize *sizep) -{ - struct winsize newsize; - - /* if size has changed, this ioctl changes it */ - /* *and* sends SIGWINCH to process group */ - - newsize.ws_row = (unsigned short) sizep->ts_lines; - newsize.ws_col = (unsigned short) sizep->ts_cols; - - (void) ioctl(Master, TIOCSWINSZ, &newsize); - if (Slave_is_closed_on_master_side == FALSE) { - close(Slave); - Slave_is_closed_on_master_side = TRUE; - } -} - - -/* - * send the given signal to the group controlling the terminal - */ -void -SendSignal(int sig) -{ - pid_t pgrp; - - pgrp = getpgid(child); - if (pgrp != (pid_t)-1) - (void) kill((-pgrp), sig); -} - -/* - * called when the main select loop detects that we might want to - * read something. - */ -void -HelperRead(pollfd_t *fdp, int nfds, int *pollretval) -{ - char buf[128]; - int retval; - extern int errno; - int mask; - int master = -1; - int inputsocket = -1; - - /* - * fdp pollset may be compressed. Search for Master and - * InputSocket fds. - */ - int i; - for (i = 0; i < nfds; i++) { - if (fdp[i].fd == Master && fdp[i].revents != 0) - master = i; - if (fdp[i].fd == InputSocket && fdp[i].revents != 0) - inputsocket = i; - } - -/* mask = sigsetmask (sigmask (SIGCHLD)); */ - mask = sighold(SIGCHLD); - retval = 0; - if (master != -1) { - if (!(fdp[master].revents & (POLLERR | POLLHUP | POLLNVAL))) { - retval = read(Master, buf, sizeof (buf)); - if (retval > 0) { - (void) write(OutputSocket, buf, retval); - } else { - if (errno != EINTR && errno != EIO && - errno != EWOULDBLOCK) - perror("pty read"); - /* 1 => further sends disallowed */ - shutdown(OutputSocket, 1); - xprt_unregister(&uxprt[MASTER]); - } - } - - /* clear this event for svc_getreq_poll */ - fdp[master].revents = 0; - *pollretval = *pollretval - 1; - - if (retval <= 0 && ChildDied) { - KillHelper(child); - HasHelper = 0; - if (inputsocket != -1) { - fdp[inputsocket].revents = 0; - *pollretval = *pollretval - 1; - } - goto done; - } - } - - if (inputsocket != -1) { - if (!(fdp[inputsocket].revents & (POLLERR | POLLHUP | - POLLNVAL))) { - retval = read(InputSocket, buf, sizeof (buf)); - if (retval > 0) { - (void) write(Master, buf, retval); - } else { - if (errno != EINTR && errno != EWOULDBLOCK) - perror("socket read"); - xprt_unregister(&uxprt[INPUTSOCKET]); - } - } - - /* clear this event for svc_getreq_poll */ - fdp[inputsocket].revents = 0; - *pollretval = *pollretval - 1; - } - - done: -/* sigsetmask (mask); */ - sigrelse(SIGCHLD); -} diff --git a/usr/src/cmd/rexd/where.c b/usr/src/cmd/rexd/where.c deleted file mode 100644 index 438d658c04..0000000000 --- a/usr/src/cmd/rexd/where.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * 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. - * 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 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* - * where.c - get full pathname including host: - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <netdb.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> - -#include <sys/mntent.h> - -#include <sys/mnttab.h> -#include <sys/param.h> -#include <sys/stat.h> - -#include <sharefs/share.h> -#include "sharetab.h" - -extern FILE *setmntent(); - -FILE *setsharetab(); -void endsharetab(); - - - -extern int Debug; - -/* - * where(pn, host, fsname, within) - * - * pn is the pathname we are looking for, - * host gets the name of the host owning the file system, - * fsname gets the file system name on the host, - * within gets whatever is left from the pathname - * - * Returns: 0 if ERROR, 1 if OK - */ -int -where(pn, host, fsname, within) -char *pn; -char *host; -char *fsname; -char *within; -{ - struct stat sb; - char curdir[MAXPATHLEN]; - char qualpn[MAXPATHLEN]; - char *p; - - if (Debug) - printf("where: pn %s\n", pn); - - if (stat(pn, &sb) < 0) { - char *errstr; - - if ((errstr = strerror(errno)) == NULL) - errstr = "unknown error"; - - if (Debug) - printf("where: stat failed"); - strcpy(within, errstr); - return (0); - } - /* - * first get the working directory, - */ - if (getcwd(curdir, MAXPATHLEN) == NULL) { - sprintf(within, "Unable to get working directory (%s)", - curdir); - return (0); - } - if (chdir(pn) == 0) { - getcwd(qualpn, MAXPATHLEN); - chdir(curdir); - } else { - if (p = strrchr(pn, '/')) { - *p = 0; - chdir(pn); - (void) getcwd(qualpn, MAXPATHLEN); - chdir(curdir); - strcat(qualpn, "/"); - strcat(qualpn, p+1); - } else { - strcpy(qualpn, curdir); - strcat(qualpn, "/"); - strcat(qualpn, pn); - } - } - return (findmount(qualpn, host, fsname, within)); -} - -/* - * findmount(qualpn, host, fsname, within) - * - * Searches the mount table to find the appropriate file system - * for a given absolute path name. - * host gets the name of the host owning the file system, - * fsname gets the file system name on the host, - * within gets whatever is left from the pathname - * - * Returns: 0 on failure, 1 on success. - */ -int -findmount(qualpn, host, fsname, within) -char *qualpn; -char *host; -char *fsname; -char *within; -{ - FILE *mfp; - char bestname[MAXPATHLEN]; - int bestlen = 0, - bestnfs = 0; - struct share *exp; - struct mnttab mp, - *mnt; - char *endhost; /* points past the colon in name */ - int i, - len; - - if (Debug) - printf("findmount: qualpn %s\n", qualpn); - - for (i = 0; i < 10; i++) { - mfp = setmntent("/etc/mnttab", "r"); - if (mfp != NULL) - break; - sleep(1); - } - - if (mfp == NULL) { - sprintf(within, "mount table problem"); - return (0); - } - - bestname[0] = '\0'; - while ((getmntent(mfp, &mp)) == 0) { - if (strcmp(mp.mnt_fstype, "nfs") != 0) - /* - * If it is not nfs filesystem type, skip the - * entry - */ - continue; - - len = preflen(qualpn, mp.mnt_mountp); - - if (Debug) - printf("preflen: %d %s %s", len, qualpn, mp.mnt_mountp); - - if (qualpn[len] != '/' && qualpn[len] != '\0' && len > 1) - /* - * If the last matching character is neither / nor - * the end of the pathname, not a real match - * (except for matching root, len==1) - */ - continue; - - if (len > bestlen) { - bestlen = len; - strncpy(bestname, mp.mnt_special, sizeof (bestname)); - } - if (Debug) - printf(" %s\n", bestname); - } - - endmntent(mfp); - - endhost = strchr(bestname, ':'); - - /* - * If the file system was of type NFS, then there should already - * be a host name, otherwise, use ours. - */ - if (endhost) { - *endhost++ = 0; - strncpy(host, bestname, MAXHOSTNAMELEN); - strncpy(fsname, endhost, MAXPATHLEN); - - /* - * special case to keep the "/" when we match root - */ - if (bestlen == 1) - bestlen = 0; - } else { - gethostname(host, MAXHOSTNAMELEN); - - /* - * If this is our file system, try for an even longer - * match from /etc/xtab. - */ - if (mfp = setsharetab()) { - while (getshare(mfp, &exp) > 0) - if (len = preflen(qualpn, exp->sh_path)) - if (len > bestlen) { - bestlen = len; - strncpy(bestname, exp->sh_path, - sizeof (bestname)); - } - endsharetab(mfp); - } - strncpy(fsname, qualpn, bestlen); - fsname[bestlen] = 0; - } - strncpy(within, qualpn + bestlen, MAXPATHLEN); - - if (Debug) - printf("findmount: qualpn %s\nhost %s\nfsname %s\nwithin %s\n", - qualpn, host, fsname, within); - return (1); -} - -/* - * Returns: length of second argument if it is a prefix of the - * first argument, otherwise zero. - */ -int -preflen(str, pref) -char *str, *pref; -{ - int len; - - len = strlen(pref); - if (strncmp(str, pref, len) == 0) - return (len); - return (0); -} - -FILE -*setsharetab() -{ - FILE *f; - - f = fopen(SHARETAB, "r"); - if (f == NULL) { - return (NULL); - } - - return (f); -} - - -void -endsharetab(f) -FILE *f; -{ - (void) fclose(f); -} diff --git a/usr/src/cmd/rexd/where_main.c b/usr/src/cmd/rexd/where_main.c deleted file mode 100644 index cfb77eb954..0000000000 --- a/usr/src/cmd/rexd/where_main.c +++ /dev/null @@ -1,108 +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 1992 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 <sys/param.h> - -static char **Argv; /* saved argument vector (for ps) */ -static char *LastArgv; /* saved end-of-argument vector */ - -int child = 0; /* pid of the executed process */ -int ChildDied = 0; /* true when above is valid */ -int HasHelper = 0; /* must kill helpers (interactive mode) */ - - -int Debug = 0; - - -void -main(argc, argv) - char **argv; -{ - char host[MAXPATHLEN]; - char fsname[MAXPATHLEN]; - char within[MAXPATHLEN]; - char *pn; - int many; - - /* - * argv start and extent for setproctitle() - */ - Argv = argv; - if (argc > 0) - LastArgv = argv[argc-1] + strlen(argv[argc-1]); - else - LastArgv = NULL; - - many = argc > 2; - while (--argc > 0) { - - if ( strcmp( "-d", *argv ) == 0 ) - { - Debug = 1; - argv++; - continue; - } - pn = *++argv; - where(pn, host, fsname, within); - if (many) - printf("%s:\t", pn); - printf("%s:%s%s\n", host, fsname, within); - } - exit(0); - /* NOTREACHED */ -} - -/* - * SETPROCTITLE -- set the title of this process for "ps" - * - * Does nothing if there were not enough arguments on the command - * line for the information. - * - * Side Effects: - * Clobbers argv[] of our main procedure. - */ -void -setproctitle(user, host) - char *user, *host; -{ - register char *tohere; - - tohere = Argv[0]; - if (LastArgv == NULL || - strlen(user)+strlen(host)+3 > (LastArgv - tohere)) - return; - *tohere++ = '-'; /* So ps prints (rpc.rexd) */ - sprintf(tohere, "%s@%s", user, host); - while (*tohere++) /* Skip to end of printf output */ - ; - while (tohere < LastArgv) /* Avoid confusing ps */ - *tohere++ = ' '; -} diff --git a/usr/src/head/Makefile b/usr/src/head/Makefile index 406377313b..e6397736af 100644 --- a/usr/src/head/Makefile +++ b/usr/src/head/Makefile @@ -275,7 +275,6 @@ RPCSVC_GEN_HDRS = \ nfs_prot.h \ nfs4_prot.h \ nis.h \ - rex.h \ rquota.h \ rstat.h \ rusers.h \ diff --git a/usr/src/head/rpcsvc/rex.x b/usr/src/head/rpcsvc/rex.x deleted file mode 100644 index 8e137ce871..0000000000 --- a/usr/src/head/rpcsvc/rex.x +++ /dev/null @@ -1,230 +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) 1987 by Sun Microsystems, Inc. -% */ - -%/* from rex.x */ - -#ifdef RPC_HDR -% -%#pragma ident "%Z%%M% %I% %E% SMI" -% -#endif - -/* - * Remote execution (rex) protocol specification - */ - -const STRINGSIZE = 1024; -typedef string rexstring<1024>; - -/* - * values to pass to REXPROC_SIGNAL - */ -const SIGINT = 2; /* interrupt */ - -/* - * Values for rst_flags, below - */ -const REX_INTERACTIVE = 1; /* interactive mode */ - -struct rex_start { - rexstring rst_cmd<>; /* list of command and args */ - rexstring rst_host; /* working directory host name */ - rexstring rst_fsname; /* working directory file system name */ - rexstring rst_dirwithin;/* working directory within file system */ - rexstring rst_env<>; /* list of environment */ - unsigned int rst_port0; /* port for stdin */ - unsigned int rst_port1; /* port for stdout */ - unsigned int rst_port2; /* port for stderr */ - unsigned int rst_flags; /* options - see const above */ -}; - -struct rex_result { - int rlt_stat; /* integer status code */ - rexstring rlt_message; /* string message for human consumption */ -}; - - -struct sgttyb { - unsigned four; /* always equals 4 */ - opaque chars[4]; - /* chars[0] == input speed */ - /* chars[1] == output speed */ - /* chars[2] == kill character */ - /* chars[3] == erase character */ - unsigned flags; -}; -/* values for speeds above (baud rates) */ -const B0 = 0; -const B50 = 1; -const B75 = 2; -const B110 = 3; -const B134 = 4; -const B150 = 5; -const B200 = 6; -const B300 = 7; -const B600 = 8; -const B1200 = 9; -const B1800 = 10; -const B2400 = 11; -const B4800 = 12; -const B9600 = 13; -const B19200 = 14; -const B38400 = 15; - -/* values for flags above */ -const TANDEM = 0x00000001; /* send stopc on out q full */ -const CBREAK = 0x00000002; /* half-cooked mode */ -const LCASE = 0x00000004; /* simulate lower case */ -const ECHO = 0x00000008; /* echo input */ -const CRMOD = 0x00000010; /* map \r to \r\n on output */ -const RAW = 0x00000020; /* no i/o processing */ -const ODDP = 0x00000040; /* get/send odd parity */ -const EVENP = 0x00000080; /* get/send even parity */ -const ANYP = 0x000000c0; /* get any parity/send none */ -const NLDELAY = 0x00000300; /* \n delay */ -const NL0 = 0x00000000; -const NL1 = 0x00000100; /* tty 37 */ -const NL2 = 0x00000200; /* vt05 */ -const NL3 = 0x00000300; -const TBDELAY = 0x00000c00; /* horizontal tab delay */ -const TAB0 = 0x00000000; -const TAB1 = 0x00000400; /* tty 37 */ -const TAB2 = 0x00000800; -const XTABS = 0x00000c00; /* expand tabs on output */ -const CRDELAY = 0x00003000; /* \r delay */ -const CR0 = 0x00000000; -const CR1 = 0x00001000; /* tn 300 */ -const CR2 = 0x00002000; /* tty 37 */ -const CR3 = 0x00003000; /* concept 100 */ -const VTDELAY = 0x00004000; /* vertical tab delay */ -const FF0 = 0x00000000; -const FF1 = 0x00004000; /* tty 37 */ -const BSDELAY = 0x00008000; /* \b delay */ -const BS0 = 0x00000000; -const BS1 = 0x00008000; -const CRTBS = 0x00010000; /* do backspacing for crt */ -const PRTERA = 0x00020000; /* \ ... / erase */ -const CRTERA = 0x00040000; /* " \b " to wipe out char */ -const TILDE = 0x00080000; /* hazeltine tilde kludge */ -const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ -const LITOUT = 0x00200000; /* literal output */ -const TOSTOP = 0x00400000; /* SIGTTOU on background output */ -const FLUSHO = 0x00800000; /* flush output to terminal */ -const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ -const L001000 = 0x02000000; -const CRTKIL = 0x04000000; /* kill line with " \b " */ -const PASS8 = 0x08000000; -const CTLECH = 0x10000000; /* echo control chars as ^X */ -const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ -const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ -const NOFLSH = 0x80000000; /* no output flush on signal */ - -struct tchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == interrupt char */ - /* chars[1] == quit char */ - /* chars[2] == start output char */ - /* chars[3] == stop output char */ - /* chars[4] == end-of-file char */ - /* chars[5] == input delimeter (like nl) */ -}; - -struct ltchars { - unsigned six; /* always equals 6 */ - opaque chars[6]; - /* chars[0] == stop process signal */ - /* chars[1] == delayed stop process signal */ - /* chars[2] == reprint line */ - /* chars[3] == flush output */ - /* chars[4] == word erase */ - /* chars[5] == literal next character */ - unsigned mode; -}; - -struct rex_ttysize { - int ts_lines; - int ts_cols; -}; - -struct rex_ttymode { - sgttyb basic; /* standard unix tty flags */ - tchars more; /* interrupt, kill characters, etc. */ - ltchars yetmore; /* special Berkeley characters */ - unsigned andmore; /* and Berkeley modes */ -}; - -/* values for andmore above */ -const LCRTBS = 0x0001; /* do backspacing for crt */ -const LPRTERA = 0x0002; /* \ ... / erase */ -const LCRTERA = 0x0004; /* " \b " to wipe out char */ -const LTILDE = 0x0008; /* hazeltine tilde kludge */ -const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ -const LLITOUT = 0x0020; /* literal output */ -const LTOSTOP = 0x0040; /* SIGTTOU on background output */ -const LFLUSHO = 0x0080; /* flush output to terminal */ -const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ -const LL001000 = 0x0200; -const LCRTKIL = 0x0400; /* kill line with " \b " */ -const LPASS8 = 0x0800; -const LCTLECH = 0x1000; /* echo control chars as ^X */ -const LPENDIN = 0x2000; /* needs reread */ -const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ -const LNOFLSH = 0x8000; /* no output flush on signal */ - -program REXPROG { - version REXVERS { - - /* - * Start remote execution - */ - rex_result - REXPROC_START(rex_start) = 1; - - /* - * Wait for remote execution to terminate - */ - rex_result - REXPROC_WAIT(void) = 2; - - /* - * Send tty modes - */ - void - REXPROC_MODES(rex_ttymode) = 3; - - /* - * Send window size change - */ - void - REXPROC_WINCH(rex_ttysize) = 4; - - /* - * Send other signal - */ - void - REXPROC_SIGNAL(int) = 5; - } = 1; -} = 100017; diff --git a/usr/src/man/man1/Makefile b/usr/src/man/man1/Makefile index ee62253939..b8e90a22d1 100644 --- a/usr/src/man/man1/Makefile +++ b/usr/src/man/man1/Makefile @@ -260,7 +260,6 @@ MANFILES= acctcom.1 \ nohup.1 \ nroff.1 \ od.1 \ - on.1 \ optisa.1 \ pack.1 \ pagesize.1 \ diff --git a/usr/src/man/man1/on.1 b/usr/src/man/man1/on.1 deleted file mode 100644 index a07ed7ca9b..0000000000 --- a/usr/src/man/man1/on.1 +++ /dev/null @@ -1,144 +0,0 @@ -'\" te -.\" Copyright (c) 2003, Sun Microsystems, Inc. -.\" The contents of this file are subject to the terms of the 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. 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] -.TH ON 1 "Oct 8, 2003" -.SH NAME -on \- execute a command on a remote system with the local environment -.SH SYNOPSIS -.LP -.nf -\fBon\fR [\fB-i\fR] [\fB-d\fR] [\fB-n\fR] \fIhost\fR \fIcommand\fR [\fIargument\fR] ... -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBon\fR program is used to execute commands on another system, in an -environment similar to that invoking the program. All environment variables are -passed and the current working directory is preserved. To preserve the working -directory, the working file system must be either already mounted on the host -or be exported to it. Relative path names will only work if they are within the -current file system. Absolute path names may cause problems. -.sp -.LP -The standard input is connected to the standard input of the remote command. -The standard output and the standard error from the remote command are sent to -the corresponding files for the \fBon\fR command. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-d\fR\fR -.ad -.RS 6n -Debug mode. Prints out some messages as work is being done. -.RE - -.sp -.ne 2 -.na -\fB\fB-i\fR\fR -.ad -.RS 6n -Interactive mode. Uses remote echoing and special character processing. This -option is needed for programs that expect to be talking to a terminal. All -terminal modes and window size changes are propagated. -.RE - -.sp -.ne 2 -.na -\fB\fB-n\fR\fR -.ad -.RS 6n -No Input. This option causes the remote program to get EOF when it reads from -the standard input, instead of passing the standard input from the standard -input of the \fBon\fR program. For example, \fB-n\fR is necessary when running -commands in the background with job control. -.RE - -.SH SEE ALSO -.sp -.LP -\fBchkey\fR(1), \fBrlogin\fR(1), \fBrsh\fR(1), \fBtelnet\fR(1), -\fBattributes\fR(5) -.SH DIAGNOSTICS -.sp -.ne 2 -.na -\fB\fBunknown host\fR\fR -.ad -.sp .6 -.RS 4n -Host name not found. -.RE - -.sp -.ne 2 -.na -\fB\fBcannot connect to server\fR\fR -.ad -.sp .6 -.RS 4n -Host down or not running the server. -.RE - -.sp -.ne 2 -.na -\fB\fBcan't find\fR\fR -.ad -.sp .6 -.RS 4n -Problem finding the working directory. -.RE - -.sp -.ne 2 -.na -\fB\fBcan't locate mount point\fR \fR -.ad -.sp .6 -.RS 4n -Problem finding current file system. -.RE - -.sp -.ne 2 -.na -\fB\fBRPC: Authentication error\fR \fR -.ad -.sp .6 -.RS 4n -The server requires \fBDES\fR authentication and you do not have a secret key -registered with keyserv. Perhaps you logged in without a password. Try to -keylogin. If that fails, try to set your publickey with chkey. -.RE - -.sp -.ne 2 -.na -\fB\fBon \fIserver\fR: RPC: can't encode arguments\fR\fR -.ad -.sp .6 -.RS 4n -The \fB10240\fR byte limit for arguments to be encoded and passed from the -sending to the receiving system has been exceeded. -.RE - -.sp -.LP -Other diagnostic messages may be passed back from the server. -.SH BUGS -.sp -.LP -When the working directory is remote mounted over \fBNFS\fR, a Control-Z hangs -the window. -.sp -.LP -Root cannot use \fBon\fR. diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile index b531e7abba..e254dfbbc5 100644 --- a/usr/src/man/man1m/Makefile +++ b/usr/src/man/man1m/Makefile @@ -409,7 +409,6 @@ _MANFILES= 6to4relay.1m \ route.1m \ routeadm.1m \ rpc.bootparamd.1m \ - rpc.rexd.1m \ rpc.rstatd.1m \ rpc.rusersd.1m \ rpc.rwalld.1m \ @@ -610,7 +609,6 @@ MANLINKS= acctcon1.1m \ rdisc.1m \ reject.1m \ restricted_shell.1m \ - rexd.1m \ rexecd.1m \ rlogind.1m \ routed.1m \ @@ -728,7 +726,6 @@ grpck.1m := LINKSRC = pwck.1m quotaoff.1m := LINKSRC = quotaon.1m bootparamd.1m := LINKSRC = rpc.bootparamd.1m -rexd.1m := LINKSRC = rpc.rexd.1m rstatd.1m := LINKSRC = rpc.rstatd.1m rusersd.1m := LINKSRC = rpc.rusersd.1m rwalld.1m := LINKSRC = rpc.rwalld.1m diff --git a/usr/src/man/man1m/rpc.rexd.1m b/usr/src/man/man1m/rpc.rexd.1m deleted file mode 100644 index e4178e9bad..0000000000 --- a/usr/src/man/man1m/rpc.rexd.1m +++ /dev/null @@ -1,151 +0,0 @@ -'\" te -.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved -.\" The contents of this file are subject to the terms of the 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. 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] -.TH RPC.REXD 1M "Nov 5, 2004" -.SH NAME -rpc.rexd, rexd \- RPC-based remote execution server -.SH SYNOPSIS -.LP -.nf -\fB/usr/sbin/rpc.rexd\fR [\fB-s\fR] -.fi - -.SH DESCRIPTION -.sp -.LP -\fBrpc.rexd\fR is the Sun \fBRPC\fR server for remote program execution. This -daemon is started by \fBinetd\fR(1M) whenever a remote execution request is -made. -.sp -.LP -For non-interactive programs, the standard file descriptors are connected -directly to \fBTCP\fR connections. Interactive programs involve -pseudo-terminals, in a fashion that is similar to the login sessions provided -by \fBrlogin\fR(1). This daemon may use \fBNFS\fR to mount file systems -specified in the remote execution request. -.sp -.LP -There is a \fB10240\fR byte limit for arguments to be encoded and passed from -the sending to the receiving system. -.SH OPTIONS -.sp -.LP -The following option is supported: -.sp -.ne 2 -.na -\fB\fB-s\fR\fR -.ad -.RS 6n -Secure. When specified, requests must have valid \fBDES\fR credentials. If the -request does not have a \fBDES\fR credential it is rejected. The default -publickey credential is rejected. Only newer \fBon\fR(1) commands send -\fBDES\fR credentials. -.sp -If access is denied with an authentication error, you may have to set your -publickey with the \fBchkey\fR(1) command. -.sp -Specifying the \fB-s\fR option without presenting secure credentials will -result in an error message: \fBUnix too weak auth (DesONly)!\fR -.RE - -.SH SECURITY -.sp -.LP -\fBrpc.rexd\fR uses \fBpam\fR(3PAM) for account and session management. The -\fBPAM\fR configuration policy, listed through \fB/etc/pam.conf\fR, specifies -the modules to be used for \fBrpc.rexd\fR. Here is a partial \fBpam.conf\fR -file with \fBrpc.rexd\fR entries for account and session management using the -UNIX module. -.sp -.in +2 -.nf -rpc.rexd account requisite pam_roles.so.1 -rpc.rexd account required pam_projects.so.1 -rpc.rexd account required pam_unix_account.so.1 - -rpc.rexd session required pam_unix_session.so.1 -.fi -.in -2 - -.sp -.LP -If there are no entries for the \fBrpc.rexd\fR service, the entries for the -"other" service will be used. \fBrpc.rexd\fR uses the \fBgetpwuid()\fR call to -determine whether the given user is a legal user. -.SH FILES -.sp -.ne 2 -.na -\fB\fB/dev/pts\fIn\fR\fR\fR -.ad -.RS 23n -Pseudo-terminals used for interactive mode -.RE - -.sp -.ne 2 -.na -\fB\fB/etc/passwd\fR\fR -.ad -.RS 23n -Authorized users -.RE - -.sp -.ne 2 -.na -\fB\fB/tmp_rex/rexd??????\fR\fR -.ad -.RS 23n -Temporary mount points for remote file systems -.RE - -.SH SEE ALSO -.sp -.LP -\fBchkey\fR(1), \fBon\fR(1), \fBrlogin\fR(1), \fBsvcs\fR(1), \fBinetadm\fR(1M), -\fBinetd\fR(1M), \fBsvcadm\fR(1M), \fBpam\fR(3PAM), \fBpam.conf\fR(4), -\fBpublickey\fR(4), \fBattributes\fR(5), \fBpam_authtok_check\fR(5), -\fBpam_authtok_get\fR(5), \fBpam_authtok_store\fR(5), \fBpam_dhkeys\fR(5), -\fBpam_passwd_auth\fR(5), \fBpam_unix_account\fR(5), \fBpam_unix_auth\fR(5), -\fBpam_unix_session\fR(5), \fBsmf\fR(5) -.SH DIAGNOSTICS -.sp -.LP -Diagnostic messages are normally printed on the console, and returned to the -requestor. -.SH NOTES -.sp -.LP -Root cannot execute commands using \fBrexd\fR client programs such as -\fBon\fR(1). -.sp -.LP -The \fBpam_unix\fR(5) module is no longer supported. Similar functionality is -provided by \fBpam_authtok_check\fR(5), \fBpam_authtok_get\fR(5), -\fBpam_authtok_store\fR(5), \fBpam_dhkeys\fR(5), \fBpam_passwd_auth\fR(5), -\fBpam_unix_account\fR(5), \fBpam_unix_auth\fR(5), and -\fBpam_unix_session\fR(5). -.sp -.LP -The \fBrpc.rexd\fR service is managed by the service management facility, -\fBsmf\fR(5), under the service identifier: -.sp -.in +2 -.nf -svc:/network/rpc/rex:default -.fi -.in -2 -.sp - -.sp -.LP -Administrative actions on this service, such as enabling, disabling, or -requesting restart, can be performed using \fBsvcadm\fR(1M). Responsibility for -initiating and restarting this service is delegated to \fBinetd\fR(1M). Use -\fBinetadm\fR(1M) to make configuration changes and to view configuration -information for this service. The service's status can be queried using the -\fBsvcs\fR(1) command. diff --git a/usr/src/man/man4/pam.conf.4 b/usr/src/man/man4/pam.conf.4 index 160a79032c..959030f496 100644 --- a/usr/src/man/man4/pam.conf.4 +++ b/usr/src/man/man4/pam.conf.4 @@ -3,7 +3,7 @@ .\" The contents of this file are subject to the terms of the 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. 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] -.TH PAM.CONF 4 "Jun 19, 2006" +.TH PAM.CONF 4 "Mar 4, 2017" .SH NAME pam.conf \- configuration file for pluggable authentication modules .SH SYNOPSIS @@ -441,7 +441,7 @@ The format is Stable. The contents has no stability attributes. .LP \fBlogin\fR(1), \fBpasswd\fR(1), \fBin.rlogind\fR(1M), \fBin.rshd\fR(1M), \fBin.telnetd\fR(1M), \fBin.uucpd\fR(1M), \fBinit\fR(1M), -\fBrpc.rexd\fR(1M), \fBsac\fR(1M), \fBttymon\fR(1M), \fBsu\fR(1M), +\fBsac\fR(1M), \fBttymon\fR(1M), \fBsu\fR(1M), \fBpam\fR(3PAM), \fBsyslog\fR(3C), \fBlibpam\fR(3LIB), \fBattributes\fR(5), \fBenviron\fR(5), \fBpam_authtok_check\fR(5), \fBpam_authtok_get\fR(5), \fBpam_authtok_store\fR(5), \fBpam_dhkeys\fR(5), \fBpam_krb5\fR(5), diff --git a/usr/src/pkg/manifests/service-network-nis.mf b/usr/src/pkg/manifests/service-network-nis.mf index 05de262b4c..6d4578f376 100644 --- a/usr/src/pkg/manifests/service-network-nis.mf +++ b/usr/src/pkg/manifests/service-network-nis.mf @@ -71,7 +71,6 @@ file path=usr/lib/netsvc/yp/ypxfrd mode=0555 file path=usr/sbin/mknetid mode=0555 file path=usr/sbin/revnetgroup mode=0555 file path=usr/share/man/man1m/inityp2l.1m -file path=usr/share/man/man1m/rpc.rexd.1m file path=usr/share/man/man1m/rpc.yppasswdd.1m file path=usr/share/man/man1m/rpc.ypupdated.1m file path=usr/share/man/man1m/ypmake.1m @@ -93,7 +92,6 @@ legacy pkg=SUNWypu desc="NIS Server for Solaris 2.6 and up" \ name="NIS Server for Solaris (usr)" license cr_Sun license=cr_Sun license lic_CDDL license=lic_CDDL -link path=usr/share/man/man1m/rexd.1m target=rpc.rexd.1m link path=usr/share/man/man1m/yppasswdd.1m target=rpc.yppasswdd.1m link path=usr/share/man/man1m/ypupdated.1m target=rpc.ypupdated.1m link path=usr/share/man/man1m/ypxfrd.1m target=ypserv.1m diff --git a/usr/src/pkg/manifests/system-file-system-nfs.mf b/usr/src/pkg/manifests/system-file-system-nfs.mf index 9eb169e1c6..345be4c93a 100644 --- a/usr/src/pkg/manifests/system-file-system-nfs.mf +++ b/usr/src/pkg/manifests/system-file-system-nfs.mf @@ -82,7 +82,6 @@ file path=lib/svc/manifest/network/nfs/status.xml group=sys mode=0444 file path=lib/svc/method/nfs-client mode=0555 file path=lib/svc/method/nlockmgr mode=0555 file path=usr/bin/nfsstat mode=0555 -file path=usr/bin/on mode=0555 file path=usr/lib/fs/nfs/dfmounts mode=0555 file path=usr/lib/fs/nfs/dfshares mode=0555 file path=usr/lib/fs/nfs/nfsfind group=sys mode=0555 @@ -95,7 +94,6 @@ file path=usr/lib/nfs/lockd mode=0555 file path=usr/lib/nfs/nfs4cbd mode=0555 file path=usr/lib/nfs/nfsmapid mode=0555 file path=usr/lib/nfs/statd mode=0555 -file path=usr/share/man/man1/on.1 file path=usr/share/man/man1m/mount_nfs.1m file path=usr/share/man/man1m/nfs4cbd.1m file path=usr/share/man/man1m/nfsmapid.1m diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf index 4ccc84666f..7fec376963 100644 --- a/usr/src/pkg/manifests/system-header.mf +++ b/usr/src/pkg/manifests/system-header.mf @@ -699,8 +699,6 @@ file path=usr/include/rpcsvc/nlm_prot.h file path=usr/include/rpcsvc/nlm_prot.x file path=usr/include/rpcsvc/nsm_addr.h file path=usr/include/rpcsvc/nsm_addr.x -file path=usr/include/rpcsvc/rex.h -file path=usr/include/rpcsvc/rex.x file path=usr/include/rpcsvc/rpc_sztypes.h file path=usr/include/rpcsvc/rpc_sztypes.x file path=usr/include/rpcsvc/rquota.h diff --git a/usr/src/pkg/manifests/system-network-nis.mf b/usr/src/pkg/manifests/system-network-nis.mf index dba3306a19..3d061912ad 100644 --- a/usr/src/pkg/manifests/system-network-nis.mf +++ b/usr/src/pkg/manifests/system-network-nis.mf @@ -58,7 +58,6 @@ dir path=var/yp/binding file path=etc/nsswitch.nis group=sys file path=etc/publickey original_name=SUNWnis:etc/publickey preserve=true file path=lib/svc/manifest/network/nis/client.xml group=sys mode=0444 -file path=lib/svc/manifest/network/rpc/rex.xml group=sys mode=0444 file path=usr/bin/chkey group=sys mode=4555 file path=usr/bin/ldaplist mode=0555 file path=usr/bin/ypcat group=other mode=0555 @@ -75,7 +74,6 @@ file path=usr/lib/netsvc/yp/ypxfr mode=0555 file path=usr/sbin/ldapaddent mode=0555 file path=usr/sbin/ldapclient mode=0555 file path=usr/sbin/newkey group=sys mode=0555 -file path=usr/sbin/rpc.rexd mode=0555 file path=usr/sbin/ypalias mode=0555 file path=usr/sbin/ypinit mode=0555 file path=usr/sbin/yppoll mode=0555 |
