/*
* 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
* 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 <rpc/clnt_soc.h>
#include <rpc/key_prot.h>
#include "rex.h"
#include <stropts.h>
#include <sys/ttcompat.h>
extern int errno;
/*
* Note - the following must be long enough for at least two portmap
* timeouts on the other side.
*/
static int Argc;
void usage(void);
/*
* window change handler - propagate to remote server
*/
void
{
/* bothered to change */
/*
* compensate for the struct change
*/
return;
WindowSize = size;
NULL, LongTimeout)) {
}
}
/*
* signal handler - propagate to remote server
*/
void
{
NULL, LongTimeout)) {
}
}
void
{
/*
* Put tty modes back the way they were and tell the rexd server
* to send the command a SIGCONT signal.
*/
if (Interactive) {
}
}
/*
* oob -- called when the command invoked by the rexd server is stopped
* with a SIGTSTP or SIGSTOP signal.
*/
void
{
int atmark;
for (;;) {
perror("ioctl");
break;
}
if (atmark)
break;
}
/*
* Reset tty modes to something sane and stop myself
*/
if (Interactive) {
printf("\r\n");
}
}
int
{
extern char **environ;
int trying_authdes;
int i;
char *domain;
/*
* we check the invoked command name to see if it should
* really be a host name.
*/
} else {
rhost++;
}
/*
* argv start and extent for setproctitle()
*/
if (argc > 0)
else
break;
break;
break;
default:
}
argv++;
argc--;
}
Interactive = 1;
} else {
if (argc < 2)
usage();
}
/*
* Can only have one of these
*/
if (Interactive && NoInput)
usage();
exit(1);
}
if (Debug)
printf("Got the host named %s (%s)\n",
trying_authdes = 1;
sock = RPC_ANYSOCK;
if (Debug)
printf("clnt_create: Server_Addr %u Prog %d Vers %d Sock %d\n",
0, 0)) == NULL) {
rhost);
clnt_pcreateerror("on:");
exit(1);
}
if (Debug)
printf("TCP RPC connection created\n");
if (trying_authdes) {
*cho = 0;
for (i = 0; (*chi && (i < MAXHOSTNAMELEN)); i++)
{
else
cho++;
chi++;
}
*cho = 0;
trying_authdes = 0;
if (Debug)
printf("host2netname failed %s\n",
}
/* #ifdef NOWAY */
else {
trying_authdes = 0;
if (cho) {
*cho = 0;
if (!host2netname(netname,
domain)) {
if (Debug)
} else {
if (getpublickey(
publickey) != 0)
trying_authdes = 1;
}
}
}
}
} else {
trying_authdes = 0;
if (Debug)
printf("yp_get_default_domain failed \n");
}
}
if (trying_authdes) {
&server_addr, NULL);
if (Debug)
trying_authdes = 0;
}
}
if (trying_authdes == 0)
exit(1);
}
/*
* Now that we have created the TCP connection, we do some
* work while the server daemon is being swapped in.
*/
exit(1);
}
if (Debug) {
"findmount failed: curdir %s\twdhost %s\t",
}
exit(1);
}
if (Debug) {
printf("findmount suceeds: cwd= %s, wd host %s, fs %s,",
}
if (Debug)
printf("before Interactive flags\n");
if (Interactive) {
}
if (Only2) {
} else {
}
if (Debug)
printf("before client call REXPROC_START\n");
if (Debug)
printf("Client call failed for REXPROC_START\r\n");
if (trying_authdes) {
trying_authdes = 0;
if (Interactive)
goto try_auth_unix;
} else {
Die(1);
}
}
Die(1);
}
if (Debug)
printf("Client call suceeded for REXPROC_START\r\n");
if (Interactive) {
/*
* Pass the tty modes along to the server
*/
int err;
if (Debug)
}
/* typecast important in following lines */
if (Debug)
printf("Before client call REXPROC_WINCH\n");
}
}
if (Debug)
printf("accept on stdout\r\n");
if (!Only2) {
if (Debug)
printf("accept on stderr\r\n");
}
if (NoInput) {
/*
* no input - simulate end-of-file instead
*/
} else {
/*
* set up to read standard input, send to remote
*/
}
else
else
else
(struct timeval *) 0);
if (nfds <= 0) {
perror("on: select");
Die(1);
}
if (cc > 0)
else
}
if (cc > 0)
else
}
if (cc > 0)
else {
/*
* End of standard input - shutdown outgoing
* direction of the TCP connection.
*/
if (Debug)
printf("Got EOF - shutting down connection\n");
}
}
}
if (!Only2)
LongTimeout)) {
Die(1);
}
return (0); /* Should never get here. */
}
/*
* like exit, but resets the terminal state first
*/
void
{
if (Interactive) {
printf("\r\n");
}
}
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)
{
return (0);
return (0);
}
/*
* accept the incoming connection on the given
* file descriptor, and return the new file descritpor
*/
void
int *fdp;
{
int fd;
if (fd < 0) {
perror("accept");
remstop();
}
}
/*
* create a socket, and return its the port number.
*/
int *fdp;
{
int fd;
if (fd < 0) {
perror("socket");
exit(1);
}
}
void
usage(void)
{
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
{
register char *tohere;
return;
while (*tohere++) /* Skip to end of printf output */
;
*tohere++ = ' ';
}