/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "defs.h"
#include <string.h>
#include <setjmp.h>
#include <netdb.h>
#include <signal.h>
#include <krb5defs.h>
#ifndef RDIST
#ifdef SYSV
/*
* Historically, the rdist program has had the following hard-coded
* pathname. Some operating systems attempt to "improve" the
* directory layout, in the process re-locating the rdist binary
* to some other location. However, the first original implementation
* sets a standard of sorts. In order to interoperate with other
* systems, our implementation must do two things: It must provide
* the an rdist binary at the pathname below, and it must use this
* pathname when executing rdist on remote systems via the rcmd()
* library. Thus the hard-coded path name below can never be changed.
*/
#endif /* SYSV */
#endif
void cleanup();
void lostconn();
static int init_service(int);
static void closeconn(void);
#ifdef SYSV
#include <libgen.h>
static char *recomp;
char *
re_comp(s)
char *s;
{
if ((int)recomp != 0)
return (errstring);
else
return ((char *)0);
}
static int
re_exec(s)
char *s;
{
if ((int)recomp == 0)
return (-1);
return (0);
else
return (1);
}
#endif /* SYSV */
/*
* Do the commands in cmds (initialized by yyparse).
*/
void
char **dhosts;
int argc;
char **argv;
{
register struct cmd *c;
register struct namelist *f;
register char **cpp;
/* protect backgrounded rdist */
/* ... and running via nohup(1) */
if (debug)
if (!cmds)
printf("docmds: cmds == NULL\n");
else {
printf("docmds: cmds ");
}
goto fndhost;
continue;
}
if (argc) {
goto found;
}
goto found;
}
continue;
} else
switch (c->c_type) {
case ARROW:
break;
case DCOLON:
break;
default:
}
}
closeconn();
}
/*
* Process commands for sending files to other machines.
*/
static void
char **filev;
char *rhost;
{
register struct namelist *f;
register char **cpp;
if (debug)
error("no files to be updated\n");
return;
}
if (nflag)
else {
goto done;
return;
if (!nflag)
exit(1);
}
}
if (filev) {
goto found;
continue;
}
n = 0;
continue;
n++;
}
if (n == 0)
}
done:
if (!nflag) {
}
if (!nflag) {
continue;
}
}
}
static int
{
if (krb5flag > 0) {
} else {
}
} else {
exit(1);
} else {
}
}
return (success);
}
/*
* Create a connection to the rdist server on the machine rhost.
*/
static int
char *rhost;
{
int n;
extern char user[];
if (debug)
return (1);
closeconn();
}
char c = *cp;
*cp = '\0';
*cp = c;
if (*ruser == '\0')
return (0);
} else
if (!qflag)
if (port < 0) {
if (debug_port == 0) {
krb5auth_flag = encrypt_flag = 0;
(void) init_service(krb5auth_flag);
}
} else {
port = debug_port;
}
}
if (debug) {
}
if (krb5auth_flag > 0) {
if ((encrypt_flag > 0) && (!krb5_privacy_allowed())) {
" not supported.\n"));
exit(1);
}
&cred,
0, /* No need for sequence number */
0, /* No need for server seq # */
1, /* Always set anyport */
&kcmd_proto);
if (status) {
/*
* If new protocol requested, we dont
* fallback to less secure ones.
*/
if (kcmd_proto == KCMD_NEW_PROTOCOL) {
"to host %s failed - %s\n"
"Fallback to normal rdist denied."),
exit(1);
}
/* check NO_TKT_FILE or equivalent... */
if (status != -1) {
"kcmd to host %s failed - %s\n"
"trying normal rdist...\n\n"),
} else {
gettext("trying normal rdist...\n"));
}
/*
* kcmd() failed, so we now fallback to normal rdist
*/
krb5auth_flag = encrypt_flag = 0;
(void) init_service(krb5auth_flag);
goto do_rcmd;
}
#ifdef DEBUG
else {
"session, port %d in use "), port);
if (kcmd_proto == KCMD_OLD_PROTOCOL)
gettext("[kcmd ver.1].\n"));
else
gettext("[kcmd ver.2].\n"));
}
#endif /* DEBUG */
if (kcmd_proto == KCMD_NEW_PROTOCOL) {
&session_key);
if (status) {
"determining subkey for session");
exit(1);
}
if (!session_key) {
com_err("rdist", 0,
"no subkey negotiated for connection");
exit(1);
}
}
if (encrypt_flag > 0) {
char *s = gettext("This rdist session is using "
"encryption for all data transmissions.\r\n");
}
}
else
{
}
if (rem < 0)
return (0);
lostconn();
if (*cp == 'V') {
do {
lostconn();
*--cp = '\0';
n = 0;
return (1);
error("connection failed: version numbers don't match"
" (local %d, remote %d)\n", VERSION, n);
} else {
error("connection failed: version numbers don't match\n");
}
closeconn();
return (0);
}
/*
* Signal end of previous connection.
*/
static void
closeconn(void)
{
if (debug)
printf("closeconn()\n");
if (rem >= 0) {
rem = -1;
}
}
void
lostconn()
{
if (iamremote)
cleanup();
}
static int
register char *name;
{
register int c;
do {
c = *cp;
if (c & 0200)
goto bad;
goto bad;
cp++;
} while (*cp);
return (1);
bad:
return (0);
}
/*
* Process commands for comparing files to time stamp files.
*/
static void
char **filev;
char *stamp;
{
register struct namelist *f;
register char **cpp;
if (debug)
printf("dodcolon()\n");
error("no files to be updated\n");
return;
}
return;
}
if (debug)
else {
return;
}
}
if (filev) {
goto found;
continue;
}
}
}
/*
* Compare the mtime of file to the list of time stamps.
*/
static void
char *name;
{
if (debug)
return;
if (nflag) {
return;
}
/*
* first time cmptime() is called?
*/
return;
while (*tp)
tp++;
}
return;
}
case S_IFREG:
break;
case S_IFDIR:
return;
default:
return;
}
}
static void
{
register DIR *d;
register char *cp;
char *otp;
int len;
if (debug)
return;
}
continue;
continue;
}
*tp++ = '/';
;
tp--;
}
closedir(d);
*tp = '\0';
}
/*
* Notify the list of people the changes that were made.
* rhost == NULL if we are mailing a list of changes compared to at time
* stamp file.
*/
static void
{
return;
if (!qflag) {
printf("notify ");
if (rhost)
}
if (nflag)
return;
return;
}
return;
}
return;
}
/*
* Create a pipe to mailling program.
*/
return;
}
/*
* Output the proper header information.
*/
else
else
}
else
}
/*
* Return true if name is in the list.
*/
int
char *file;
{
return (1);
return (0);
}
/*
* Return TRUE if file is in the exception list.
*/
int
char *file;
{
if (debug)
continue;
return (1);
continue;
}
return (1);
}
}
return (0);
}
char *
register char *cp;
{
while (*cp) {
if (*cp == ':')
return (cp);
if (*cp == '/')
return (0);
cp++;
}
return (0);
}