--- cci/usr/src/etc/dump/dumprmt.c 2019/07/28 12:24:19 1.1 +++ cci/usr/src/etc/dump/dumprmt.c 2019/07/28 12:24:33 1.1.1.2 @@ -1,13 +1,25 @@ -static char *sccsid = "@(#)dumprmt.c 1.6 (Berkeley) 7/1/83"; +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)dumprmt.c 5.3 (Berkeley) 9/17/85"; +#endif not lint #include #include #include +#include +#include #include #include +#include #include +#include #define TS_CLOSED 0 #define TS_OPEN 1 @@ -17,6 +29,8 @@ int rmtape; int rmtconnaborted(); char *rmtpeer; +extern int ntrec; /* blocking factor on tape */ + rmthost(host) char *host; { @@ -25,19 +39,23 @@ rmthost(host) signal(SIGPIPE, rmtconnaborted); rmtgetconn(); if (rmtape < 0) - exit(1); + return (0); + return (1); } rmtconnaborted() { - fprintf(stderr, "Lost connection to remote host.\n"); + fprintf(stderr, "rdump: Lost connection to remote host.\n"); exit(1); } rmtgetconn() { static struct servent *sp = 0; + struct passwd *pw; + char *name = "root"; + int size; if (sp == 0) { sp = getservbyname("shell", "tcp"); @@ -46,7 +64,16 @@ rmtgetconn() exit(1); } } - rmtape = rcmd(&rmtpeer, sp->s_port, "root", "root", "/etc/rmt", 0); + pw = getpwuid(getuid()); + if (pw && pw->pw_name) + name = pw->pw_name; + rmtape = rcmd(&rmtpeer, sp->s_port, name, name, "/etc/rmt", 0); +#ifdef notdef /* broken */ + size = ntrec * TP_BSIZE; + while (size > TP_BSIZE && + setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size)) < 0) + size -= TP_BSIZE; +#endif notdef } rmtopen(tape, mode) @@ -56,8 +83,8 @@ rmtopen(tape, mode) char buf[256]; sprintf(buf, "O%s\n%d\n", tape, mode); - rmtcall(tape, buf); rmtstate = TS_OPEN; + return (rmtcall(tape, buf)); } rmtclose()