*/
#ifdef KERBEROS
#include "krb5.h"
+#include "com_err.h"
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#include <sys/types.h>
#include <sys/param.h>
#include <sys/file.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
-#ifdef POSIX
-#include <stdlib.h>
-#endif
#include <pwd.h>
#include <ctype.h>
#include <netdb.h>
#ifdef KERBEROS
#include <krb.h>
#include <krbports.h>
+
+
+void sink(), source(), rsource(), usage();
+/*VARARGS*/
+void error();
+int response();
+#if !defined(HAS_UTIMES)
+int utimes();
+#endif
+
+
#if 0
#include <kstream.h>
#else
kstream krem;
int errs;
-#ifdef POSIX
-void lostconn();
-#else
-int lostconn();
-#endif
-int errno;
-/* Kludge!!!! */
-#if (!defined(__NetBSD__) && !defined(__FreeBSD__))
-extern char *sys_errlist[];
-#endif
+krb5_sigtype lostconn();
int iamremote, targetshouldbedirectory;
int iamrecursive;
int pflag;
#define NULLBUF (struct buffer *) 0
-/*VARARGS*/
-int error();
-
#define ga() (void) kstream_write (krem, "", 1)
-main(argc, argv)
+int main(argc, argv)
int argc;
char **argv;
{
- char *targ, *host, *src;
- char *suser, *tuser, *thost;
- int i;
- char buf[BUFSIZ], cmd[50 + REALM_SZ];
char portarg[20], rcpportarg[20];
#ifdef ATHENA
static char curhost[256];
#endif /* ATHENA */
#ifdef KERBEROS
char realmarg[REALM_SZ + 5];
- long authopts;
- char **orig_argv = save_argv(argc, argv);
#endif /* KERBEROS */
portarg[0] = '\0';
#endif /* KERBEROS */
}
usage();
+ return 1;
}
-verifydir(cp)
+void verifydir(cp)
char *cp;
{
struct stat stb;
return;
errno = ENOTDIR;
}
- error("rcp: %s: %s.\n", cp, sys_errlist[errno]);
+ error("rcp: %s: %s.\n", cp, error_message(errno));
exit(1);
}
-source(argc, argv)
+void source(argc, argv)
int argc;
char **argv;
{
for (x = 0; x < argc; x++) {
name = argv[x];
if ((f = open(name, 0)) < 0) {
- error("rcp: %s: %s\n", name, sys_errlist[errno]);
+ error("rcp: %s: %s\n", name, error_message(errno));
continue;
}
if (fstat(f, &stb) < 0)
}
}
(void) sprintf(buf, "C%04o %ld %s\n",
- stb.st_mode&07777, stb.st_size, last);
+ (unsigned int) stb.st_mode&07777, stb.st_size, last);
kstream_write (krem, buf, strlen (buf));
if (response() < 0) {
(void) close(f);
if (readerr == 0)
ga();
else
- error("rcp: %s: %s\n", name, sys_errlist[readerr]);
+ error("rcp: %s: %s\n", name, error_message(readerr));
(void) response();
}
}
#include <dirent.h>
#endif
-rsource(name, statp)
+void rsource(name, statp)
char *name;
struct stat *statp;
{
#endif
if (d == 0) {
- error("rcp: %s: %s\n", name, sys_errlist[errno]);
+ error("rcp: %s: %s\n", name, error_message(errno));
return;
}
last = strrchr(name, '/');
return;
}
}
- (void) sprintf(buf, "D%04o %d %s\n", statp->st_mode&07777, 0, last);
+ (void) sprintf(buf, "D%04o %d %s\n",
+ (unsigned int) statp->st_mode&07777, 0, last);
kstream_write (krem, buf, strlen (buf));
if (response() < 0) {
closedir(d);
return;
}
- while (dp = readdir(d)) {
+ while ((dp = readdir(d))) {
if (dp->d_ino == 0)
continue;
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
(void) response();
}
-response()
+int response()
{
char resp, c, rbuf[BUFSIZ], *cp = rbuf;
exit(1);
}
/*NOTREACHED*/
+ return -1;
}
-#ifdef POSIX
-void
-#else
-int
-#endif
-lostconn()
+krb5_sigtype lostconn()
{
if (iamremote == 0)
}
#endif
-sink(argc, argv)
+void sink(argc, argv)
int argc;
char **argv;
{
return;
}
-#define getnum(t) (t) = 0; while (isdigit(*cp)) (t) = (t) * 10 + (*cp++ - '0');
+#define getnum(t) (t) = 0; while (isdigit((int) *cp)) (t) = (t) * 10 + (*cp++ - '0');
if (*cp == 'T') {
setimes++;
cp++;
if (*cp++ != ' ')
SCREWUP("mode not delimited");
size = 0;
- while (isdigit(*cp))
+ while (isdigit((int) *cp))
size = size * 10 + (*cp++ - '0');
if (*cp++ != ' ')
SCREWUP("size not delimited");
setimes = 0;
if (utimes(nambuf, tv) < 0)
error("rcp: can't set times on %s: %s\n",
- nambuf, sys_errlist[errno]);
+ nambuf, error_message(errno));
}
continue;
}
if ((of = open(nambuf, O_WRONLY|O_CREAT|O_TRUNC, mode)) < 0) {
bad:
- error("rcp: %s: %s\n", nambuf, sys_errlist[errno]);
+ error("rcp: %s: %s\n", nambuf, error_message(errno));
continue;
}
#ifdef NO_FCHMOD
error("rcp: dropped connection");
else
error("rcp: %s\n",
- sys_errlist[errno]);
+ error_message(errno));
exit(1);
}
amt -= j;
#ifndef __SCO__
if (ftruncate(of, size))
error("rcp: can't truncate %s: %s\n",
- nambuf, sys_errlist[errno]);
+ nambuf, error_message(errno));
#endif
(void) close(of);
(void) response();
setimes = 0;
if (utimes(nambuf, tv) < 0)
error("rcp: can't set times on %s: %s\n",
- nambuf, sys_errlist[errno]);
+ nambuf, error_message(errno));
}
if (wrerr)
- error("rcp: %s: %s\n", nambuf, sys_errlist[errno]);
+ error("rcp: %s: %s\n", nambuf, error_message(errno));
else
ga();
}
struct stat stb;
if (fstat(fd, &stb) < 0) {
- error("rcp: fstat: %s\n", sys_errlist[errno]);
+ error("rcp: fstat: %s\n", error_message(errno));
return (NULLBUF);
}
size = roundup(stb.st_blksize, blksize);
}
/*VARARGS1*/
-error(fmt, a1, a2, a3, a4, a5)
+void error(fmt, a1, a2, a3, a4, a5)
char *fmt;
int a1, a2, a3, a4, a5;
{
(void) write(2, buf+1, strlen(buf+1));
}
-usage()
+void usage()
{
fprintf(stderr,
"v4rcp: this program only acts as a server, and is not for user function.\n");
void
answer_auth()
{
- int sin_len, status;
+ int status;
long authopts = KOPT_DO_MUTUAL;
char instance[INST_SZ];
char version[9];
char *envaddr;
#if 0
+ int sin_len;
+
sin_len = sizeof (struct sockaddr_in);
if (getpeername(rem, &foreign, &sin_len) < 0) {
perror("getpeername");
exit(1);
}
#else
- if (envaddr = getenv("KRB5LOCALADDR")) {
+ if ((envaddr = getenv("KRB5LOCALADDR"))) {
#ifdef HAVE_INET_ATON
inet_aton(envaddr, &local.sin_addr);
#else
fprintf(stderr, "v4rcp: couldn't get local address (KRB5LOCALADDR)\n");
exit(1);
}
- if (envaddr = getenv("KRB5REMOTEADDR")) {
+ if ((envaddr = getenv("KRB5REMOTEADDR"))) {
#ifdef HAVE_INET_ATON
inet_aton(envaddr, &foreign.sin_addr);
#else