View | Details | Raw Unified | Return to bug 15830
Collapse All | Expand All

(-)dump/Makefile (-1 / +2 lines)
Lines 17-23 Link Here
17
LINKS=	${BINDIR}/dump ${BINDIR}/rdump
17
LINKS=	${BINDIR}/dump ${BINDIR}/rdump
18
CFLAGS+=-DRDUMP
18
CFLAGS+=-DRDUMP
19
CFLAGS+=-I${.CURDIR}/../../libexec/rlogind
19
CFLAGS+=-I${.CURDIR}/../../libexec/rlogind
20
SRCS=	itime.c main.c optr.c dumprmt.c tape.c traverse.c unctime.c
20
SRCS=	itime.c main.c optr.c dumprmt.c tape.c traverse.c unctime.c \
21
	rshrcmd.c
21
BINGRP=	tty
22
BINGRP=	tty
22
BINMODE=2555
23
BINMODE=2555
23
MAN8=	dump.8
24
MAN8=	dump.8
(-)dump/dump.8 (+8 lines)
Lines 47-52 Link Here
47
.Op Fl d Ar density
47
.Op Fl d Ar density
48
.Op Fl f Ar file
48
.Op Fl f Ar file
49
.Op Fl h Ar level
49
.Op Fl h Ar level
50
.Op Fl P Ar rshcmd
50
.Op Fl s Ar feet
51
.Op Fl s Ar feet
51
.Op Fl T Ar date
52
.Op Fl T Ar date
52
.Ar filesystem
53
.Ar filesystem
Lines 177-182 Link Here
177
.Dq operator
178
.Dq operator
178
by means similar to a
179
by means similar to a
179
.Xr wall 1 .
180
.Xr wall 1 .
181
.It Fl P Ar rshcmd
182
Program to provide
183
.Xr rsh 1 -like Ns
184
transport to the remote tape server.
185
It must provide a binary-transparent path to the remote host
186
and must have a command argument syntax that is compatible with
187
.Xr rsh 1 .
180
.It Fl s Ar feet
188
.It Fl s Ar feet
181
Attempt to calculate the amount of tape needed
189
Attempt to calculate the amount of tape needed
182
at a particular density.
190
at a particular density.
(-)dump/dump.h (-1 / +3 lines)
Lines 102-108 Link Here
102
void	timeest __P((void));
102
void	timeest __P((void));
103
time_t	unctime __P((char *str));
103
time_t	unctime __P((char *str));
104
104
105
/* mapping rouintes */
105
/* mapping routines */
106
struct	dinode;
106
struct	dinode;
107
long	blockest __P((struct dinode *dp));
107
long	blockest __P((struct dinode *dp));
108
int	mapfiles __P((ino_t maxino, long *tapesize));
108
int	mapfiles __P((ino_t maxino, long *tapesize));
Lines 137-142 Link Here
137
int	rmtopen __P((char *tape, int mode));
137
int	rmtopen __P((char *tape, int mode));
138
int	rmtwrite __P((char *buf, int count));
138
int	rmtwrite __P((char *buf, int count));
139
#endif /* RDUMP */
139
#endif /* RDUMP */
140
int	rshrcmd __P((char **ahost, u_short port, char *luser, char *ruser,
141
		     char *cmd, int *fd2p));
140
142
141
void	interrupt __P((int signo));	/* in case operator bangs on console */
143
void	interrupt __P((int signo));	/* in case operator bangs on console */
142
144
(-)dump/dumprmt.c (-1 / +8 lines)
Lines 92-97 Link Here
92
static	int errfd = -1;
92
static	int errfd = -1;
93
extern	int dokerberos;
93
extern	int dokerberos;
94
extern	int ntrec;		/* blocking factor on tape */
94
extern	int ntrec;		/* blocking factor on tape */
95
extern	char *path_rsh;
95
96
96
int
97
int
97
rmthost(host)
98
rmthost(host)
Lines 141-147 Link Here
141
rmtgetconn()
142
rmtgetconn()
142
{
143
{
143
	register char *cp;
144
	register char *cp;
144
	register const char *rmt;
145
	register char *rmt;
145
	static struct servent *sp = NULL;
146
	static struct servent *sp = NULL;
146
	static struct passwd *pwd = NULL;
147
	static struct passwd *pwd = NULL;
147
	char *tuser;
148
	char *tuser;
Lines 173-178 Link Here
173
	if ((rmt = getenv("RMT")) == NULL)
174
	if ((rmt = getenv("RMT")) == NULL)
174
		rmt = _PATH_RMT;
175
		rmt = _PATH_RMT;
175
	msg("");
176
	msg("");
177
	if (path_rsh)
178
		rmtape = rshrcmd(&rmtpeer, (u_short)sp->s_port, pwd->pw_name,
179
				 tuser, rmt, 0);
180
	else
176
#ifdef KERBEROS
181
#ifdef KERBEROS
177
	if (dokerberos)
182
	if (dokerberos)
178
		rmtape = krcmd(&rmtpeer, sp->s_port, tuser, rmt, &errfd,
183
		rmtape = krcmd(&rmtpeer, sp->s_port, tuser, rmt, &errfd,
Lines 186-191 Link Here
186
		return;
191
		return;
187
	}
192
	}
188
	(void)fprintf(stderr, "Connection to %s established.\n", rmtpeer);
193
	(void)fprintf(stderr, "Connection to %s established.\n", rmtpeer);
194
	if (path_rsh)
195
		return;
189
	size = ntrec * TP_BSIZE;
196
	size = ntrec * TP_BSIZE;
190
	if (size > 60 * 1024)		/* XXX */
197
	if (size > 60 * 1024)		/* XXX */
191
		size = 60 * 1024;
198
		size = 60 * 1024;
(-)dump/main.c (-3 / +10 lines)
Lines 86-91 Link Here
86
long	dev_bsize = 1;	/* recalculated below */
86
long	dev_bsize = 1;	/* recalculated below */
87
long	blocksperfile;	/* output blocks per file */
87
long	blocksperfile;	/* output blocks per file */
88
char	*host = NULL;	/* remote host (if any) */
88
char	*host = NULL;	/* remote host (if any) */
89
char	*path_rsh = NULL;	/* rsh (or equiv command) path */
89
90
90
static long numarg __P((char *, long, long));
91
static long numarg __P((char *, long, long));
91
static void obsolete __P((int *, char **[]));
92
static void obsolete __P((int *, char **[]));
Lines 122-130 Link Here
122
123
123
	obsolete(&argc, &argv);
124
	obsolete(&argc, &argv);
124
#ifdef KERBEROS
125
#ifdef KERBEROS
125
#define optstring "0123456789aB:b:cd:f:h:kns:T:uWw"
126
#define optstring "0123456789aB:b:cd:f:h:knP:s:T:uWw"
126
#else
127
#else
127
#define optstring "0123456789aB:b:cd:f:h:ns:T:uWw"
128
#define optstring "0123456789aB:b:cd:f:h:nP:s:T:uWw"
128
#endif
129
#endif
129
	while ((ch = getopt(argc, argv, optstring)) != -1)
130
	while ((ch = getopt(argc, argv, optstring)) != -1)
130
#undef optstring
131
#undef optstring
Lines 177-182 Link Here
177
			notify = 1;
178
			notify = 1;
178
			break;
179
			break;
179
180
181
		case 'P':
182
			path_rsh = optarg;
183
			break;
184
180
		case 's':		/* tape size, feet */
185
		case 's':		/* tape size, feet */
181
			tsize = numarg("tape size", 1L, 0L) * 12 * 10;
186
			tsize = numarg("tape size", 1L, 0L) * 12 * 10;
182
			break;
187
			break;
Lines 491-497 Link Here
491
		"k"
496
		"k"
492
#endif
497
#endif
493
		"nu] [-B records] [-b blocksize] [-d density] [-f file]\n"
498
		"nu] [-B records] [-b blocksize] [-d density] [-f file]\n"
494
		"            [-h level] [-s feet] [-T date] filesystem\n"
499
		"            [-h level] [-P rshcmd] [-s feet] [-T date] "
500
		"filesystem\n"
495
		"       dump [-W | -w]\n");
501
		"       dump [-W | -w]\n");
496
	exit(X_STARTUP);
502
	exit(X_STARTUP);
497
}
503
}
Lines 598-603 Link Here
598
		case 'd':
604
		case 'd':
599
		case 'f':
605
		case 'f':
600
		case 'h':
606
		case 'h':
607
		case 'P':
601
		case 's':
608
		case 's':
602
		case 'T':
609
		case 'T':
603
			if (*argv == NULL) {
610
			if (*argv == NULL) {
(-)dump/rshrcmd.c (+110 lines)
Line 0 Link Here
1
2
/*
3
 * This is an rcmd() replacement originally by 
4
 * Chris Siebenmann <cks@utcc.utoronto.ca>.
5
 */
6
7
#ifndef lint
8
static const char rcsid[] =
9
  "$FreeBSD$";
10
#endif /* not lint */
11
12
#include <sys/param.h>
13
#include <sys/socket.h>
14
#include <sys/types.h>
15
#include <sys/wait.h>
16
#include <errno.h>
17
#include <netdb.h>
18
#include <signal.h>
19
#include <string.h>
20
#include <unistd.h>
21
22
#include "dump.h"
23
24
extern	char *path_rsh;
25
26
static char *
27
xbasename(s)
28
	char *s;
29
{
30
	char *ret;
31
32
	ret = strrchr(s, '/');
33
	if (ret && ret[1])
34
		return (ret + 1);
35
	return s;
36
}
37
38
39
/*
40
 * This is a replacement rcmd() function that uses the rsh(1c)
41
 * program in place of a direct rcmd() function call so as to
42
 * avoid having to be root.
43
 */
44
int
45
rshrcmd(ahost, port, luser, ruser, cmd, fd2p)
46
	char  	**ahost;
47
	u_short	port;
48
	char	*luser, *ruser, *cmd;
49
	int	*fd2p;
50
{
51
	int             cpid;
52
	struct hostent  *hp;
53
	int             sp[2];
54
55
	/* insure that we are indeed being used as we thought. */
56
	if (fd2p != 0)
57
		return -1;
58
	/* validate remote hostname. */
59
	hp = gethostbyname(*ahost);
60
	if (hp == 0) {
61
		msg("%s: unknown host", *ahost);
62
		return -1;
63
	}
64
	*ahost = hp->h_name;	/* This makes me nervous. */
65
66
	/* get a socketpair we'll use for stdin and stdout. */
67
	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) < 0) {
68
		msg("socketpair(AF_UNIX, SOCK_STREAM, 0) failed: %s.", 
69
		    strerror(errno));
70
		return -1;
71
	}
72
73
	cpid = fork();
74
	if (cpid < 0) {
75
		msg("fork failed: %s.", strerror(errno));
76
		return -1;      /* error. */
77
	}
78
	if (cpid == 0) {
79
		/* child. we use sp[1] to be stdin/stdout, and close
80
		   sp[0]. */
81
		(void) close(sp[0]);
82
		if (dup2(sp[1], 0) < 0 || dup2(0,1) < 0) {
83
			msg("dup2 failed: %s.", strerror(errno));
84
			_exit(255);
85
		}
86
		/* fork again to lose parent. */
87
		cpid = fork();
88
		if (cpid < 0) {
89
			msg("fork to lose parent failed: %s.", strerror(errno));
90
			_exit(255);
91
		}
92
		if (cpid > 0)
93
			_exit(0);
94
		/* in grandchild here. */
95
		setpgid(0, getpid());	/* run in background */
96
		execlp(path_rsh, xbasename(path_rsh), 
97
		       *ahost, "-l", ruser, cmd, (char *) NULL);
98
		msg("execlp %s failed: %s.", path_rsh, strerror(errno));
99
		_exit(255);
100
	}
101
	if (cpid > 0) {
102
		/* parent. close sp[1], return sp[0]. */
103
		(void) close(sp[1]);
104
		/* reap child. */
105
		(void) wait(0);
106
		return sp[0];
107
	}
108
	/*NOTREACHED*/
109
	return (-1);
110
}
(-)restore/Makefile (-1 / +1 lines)
Lines 6-12 Link Here
6
CFLAGS+=-DRRESTORE
6
CFLAGS+=-DRRESTORE
7
CFLAGS+=-I${.CURDIR}/../../libexec/rlogind
7
CFLAGS+=-I${.CURDIR}/../../libexec/rlogind
8
SRCS=	main.c interactive.c restore.c dirs.c symtab.c tape.c utilities.c \
8
SRCS=	main.c interactive.c restore.c dirs.c symtab.c tape.c utilities.c \
9
	dumprmt.c
9
	dumprmt.c rshrcmd.c
10
BINGRP=	tty
10
BINGRP=	tty
11
BINMODE=2555
11
BINMODE=2555
12
MAN8=	restore.8
12
MAN8=	restore.8
(-)restore/main.c (-8 / +15 lines)
Lines 74-79 Link Here
74
time_t	dumptime;
74
time_t	dumptime;
75
time_t	dumpdate;
75
time_t	dumpdate;
76
FILE 	*terminal;
76
FILE 	*terminal;
77
char	*path_rsh = NULL;
77
78
78
static void obsolete __P((int *, char **[]));
79
static void obsolete __P((int *, char **[]));
79
static void usage __P((void));
80
static void usage __P((void));
Lines 99-107 Link Here
99
		inputdev = _PATH_DEFTAPE;
100
		inputdev = _PATH_DEFTAPE;
100
	obsolete(&argc, &argv);
101
	obsolete(&argc, &argv);
101
#ifdef KERBEROS
102
#ifdef KERBEROS
102
#define	optlist "b:cdf:hikmNRrs:tuvxy"
103
#define	optlist "b:cdf:hikmNP:Rrs:tuvxy"
103
#else
104
#else
104
#define	optlist "b:cdf:himNRrs:tuvxy"
105
#define	optlist "b:cdf:himNP:Rrs:tuvxy"
105
#endif
106
#endif
106
	while ((ch = getopt(argc, argv, optlist)) != -1)
107
	while ((ch = getopt(argc, argv, optlist)) != -1)
107
		switch(ch) {
108
		switch(ch) {
Lines 148-153 Link Here
148
		case 'N':
149
		case 'N':
149
			Nflag = 1;
150
			Nflag = 1;
150
			break;
151
			break;
152
		case 'P':
153
			path_rsh = optarg;
154
			break;
151
		case 's':
155
		case 's':
152
			/* Dumpnum (skip to) for multifile dump tapes. */
156
			/* Dumpnum (skip to) for multifile dump tapes. */
153
			dumpnum = strtol(optarg, &p, 10);
157
			dumpnum = strtol(optarg, &p, 10);
Lines 292-303 Link Here
292
static void
296
static void
293
usage()
297
usage()
294
{
298
{
295
	(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
299
	(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
296
	  "restore -i [-chkmuvy] [-b blocksize] [-f file] [-s fileno]",
300
	  "restore -i [-chkmuvy] [-b blocksize] [-f file] [-P rshcmd] [-s fileno]",
297
	  "restore -r [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
301
	  "restore -r [-ckuvy] [-b blocksize] [-f file] [-P rshcmd] [-s fileno]",
298
	  "restore -R [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
302
	  "restore -R [-ckuvy] [-b blocksize] [-f file] [-P rshcmd] [-s fileno]",
299
	  "restore -x [-chkmuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
303
	  "restore -x [-chkmuvy] [-b blocksize] [-f file] [-P rshcmd] [-s fileno]",
300
	  "restore -t [-chkuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
304
          "        [file ...]",
305
	  "restore -t [-chkuvy] [-b blocksize] [-f file] [-P rshcmd] [-s fileno]",
306
          "        [file ...]");
301
	done(1);
307
	done(1);
302
}
308
}
303
309
Lines 335-340 Link Here
335
		switch (*ap) {
341
		switch (*ap) {
336
		case 'b':
342
		case 'b':
337
		case 'f':
343
		case 'f':
344
		case 'P':
338
		case 's':
345
		case 's':
339
			if (*argv == NULL) {
346
			if (*argv == NULL) {
340
				warnx("option requires an argument -- %c", *ap);
347
				warnx("option requires an argument -- %c", *ap);
(-)restore/restore.8 (+12 lines)
Lines 44-67 Link Here
44
.Op Fl chkmuvy
44
.Op Fl chkmuvy
45
.Op Fl b Ar blocksize
45
.Op Fl b Ar blocksize
46
.Op Fl f Ar file
46
.Op Fl f Ar file
47
.Op Fl P Ar rshcmd
47
.Op Fl s Ar fileno
48
.Op Fl s Ar fileno
48
.Nm restore
49
.Nm restore
49
.Fl R
50
.Fl R
50
.Op Fl ckuvy
51
.Op Fl ckuvy
51
.Op Fl b Ar blocksize
52
.Op Fl b Ar blocksize
52
.Op Fl f Ar file
53
.Op Fl f Ar file
54
.Op Fl P Ar rshcmd
53
.Op Fl s Ar fileno
55
.Op Fl s Ar fileno
54
.Nm restore
56
.Nm restore
55
.Fl r
57
.Fl r
56
.Op Fl ckuvy
58
.Op Fl ckuvy
57
.Op Fl b Ar blocksize
59
.Op Fl b Ar blocksize
58
.Op Fl f Ar file
60
.Op Fl f Ar file
61
.Op Fl P Ar rshcmd
59
.Op Fl s Ar fileno
62
.Op Fl s Ar fileno
60
.Nm restore
63
.Nm restore
61
.Fl t
64
.Fl t
62
.Op Fl chkuvy
65
.Op Fl chkuvy
63
.Op Fl b Ar blocksize
66
.Op Fl b Ar blocksize
64
.Op Fl f Ar file
67
.Op Fl f Ar file
68
.Op Fl P Ar rshcmd
65
.Op Fl s Ar fileno
69
.Op Fl s Ar fileno
66
.Op file ...
70
.Op file ...
67
.Nm restore
71
.Nm restore
Lines 69-74 Link Here
69
.Op Fl chkmuvy
73
.Op Fl chkmuvy
70
.Op Fl b Ar blocksize
74
.Op Fl b Ar blocksize
71
.Op Fl f Ar file
75
.Op Fl f Ar file
76
.Op Fl P Ar rshcmd
72
.Op Fl s Ar fileno
77
.Op Fl s Ar fileno
73
.Op file ...
78
.Op file ...
74
.Pp
79
.Pp
Lines 311-316 Link Here
311
This is useful if only a few files are being extracted,
316
This is useful if only a few files are being extracted,
312
and one wants to avoid regenerating the complete pathname
317
and one wants to avoid regenerating the complete pathname
313
to the file.
318
to the file.
319
.It Fl P Ar rshcmd
320
Program to provide
321
.Xr rsh 1 -like Ns
322
transport to the remote tape server.
323
It must provide a binary-transparent path to the remote host
324
and must have a command argument syntax that is compatible with
325
.Xr rsh 1 .
314
.It Fl s Ar fileno
326
.It Fl s Ar fileno
315
Read from the specified
327
Read from the specified
316
.Ar fileno
328
.Ar fileno

Return to bug 15830