static char *sccsid
= "@(#)main.c 4.8 (Berkeley) 83/11/01";
* Remote distribution program.
char *distfile
= "distfile";
char tmpfile
[] = "/tmp/rdistAXXXXXX";
char *tmpname
= &tmpfile
[5];
char *tmpinc
= &tmpfile
[10];
int debug
; /* debugging flag */
int nflag
; /* NOP flag, just print commands without executing */
int qflag
; /* Quiet. Don't print messages */
int options
; /* global options */
int iamremote
; /* act as remote server for transfering files */
int filec
; /* number of files to update */
char **filev
; /* list of files/directories to update */
FILE *fin
= NULL
; /* input file pointer */
int rem
= 0; /* file descriptor to remote source/sink process */
char host
[32]; /* host name */
int errs
; /* number of errors while sending/receiving */
char user
[10]; /* user's name */
char homedir
[128]; /* user's home directory */
int userid
; /* user's user ID */
int groupid
; /* user's group ID */
struct passwd
*pw
; /* pointer to static area used by getpwent */
struct group
*gr
; /* pointer to static area used by getgrent */
pw
= getpwuid(userid
= getuid());
fprintf(stderr
, "%s: Who are you?\n", argv
[0]);
strcpy(user
, pw
->pw_name
);
strcpy(homedir
, pw
->pw_dir
);
gethostname(host
, sizeof(host
));
if ((arg
= *++argv
)[0] != '-')
if (!strcmp(arg
, "-Server"))
if (distfile
[0] == '-' && distfile
[1] == '\0')
signal(SIGPIPE
, lostconn
);
signal(SIGQUIT
, cleanup
);
signal(SIGTERM
, cleanup
);
if (fin
== NULL
&& (fin
= fopen(distfile
, "r")) == NULL
) {
printf("Usage: rdist [-nqbrvwyD] [-f distfile] [-d var=value] [file ...]\n");
printf("or: rdist [-nqbrvwyD] -c source [...] machine[:dest]\n");
* rcp like interface for distributing files.
struct block
*bp
, *files
, *hosts
, *cmds
, *prev
;
bp
= files
= ALLOC(block
);
for (i
= 0; i
< nargs
- 1; bp
= ALLOC(block
), i
++) {
bp
->b_next
= bp
->b_args
= NULL
;
hosts
->b_next
= hosts
->b_args
= NULL
;
if ((pos
= index(hosts
->b_name
, ':')) != NULL
) {
hosts
= expand(hosts
, 0);
cmds
->b_options
= options
;
cmds
->b_next
= cmds
->b_args
= NULL
;
printf("docmdargs()\nfiles = ");
dohcmds(files
, hosts
, cmds
);
* Remove temporary files and do any cleanup operations before exiting.
} while (*tmpinc
>= 'A');
* Print a list of NAME blocks (mostly for debugging).
register struct block
*bp
;
printf("%s ", bp
->b_name
);
fprintf(stderr
, "rdist: line %d: Warning: ", yylineno
);
fprintf(stderr
, fmt
, a1
, a2
, a3
);