static char *sccsid
= "@(#)main.c 4.3 (Berkeley) 83/10/10";
* 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 vflag
; /* verify only */
int yflag
; /* update iff remote younger than master */
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 */
register struct passwd
*pw
;
arg
= rindex(argv
[0], '/');
if (!strcmp(arg
, "update"))
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 [-f distfile] [-d var=value] [-nqyD] [file ...]\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_next
= cmds
->b_args
= NULL
;
printf("doupdate()\nfiles = ");
dohcmds(files
, hosts
, cmds
);
printf("Usage: update [-nqyD] source [...] machine[:dest]\n");
* Remove temporary files and do any cleanup operations before exiting.
* 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
);