mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 23:10:58 +00:00
vos: Check for tty in vos restore
Currently, vos restore assumes the dump stream is provided via stdin when the -file option is not specified and does not check to see if stdin is a tty. When restoring over an existing volume and the -overwrite is not specified, vos will try to prompt the user for the overwrite mode (incremental, full, or abort). Currently, vos will not prompt the user if the -file option is also absent, since the assumption is the dump is to be read from stdin. Instead, read the dump from stdin only when the -file option is absent and stdin is not a tty, and only prompt the user when stdin is a tty. This prevents vos restore from hanging when a dump file was not given with the -file option, a pipeline, or a redirect. This change also removes the use of the dump "afilename" variable to determine if an interactive mode should be used. Change-Id: I33edb69c9c3c6f42fc2270c1c797be862ffa2773 Reviewed-on: https://gerrit.openafs.org/14760 Reviewed-by: Cheyenne Wills <cwills@sinenomine.net> Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
parent
a0b0f4bea9
commit
96f1209ea7
@ -3164,6 +3164,10 @@ RestoreVolumeCmd(struct cmd_syndesc *as, void *arock)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (isatty(STDIN_FILENO)) {
|
||||||
|
fprintf(STDERR, "Can't read dump from tty.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
strcpy(afilename, "");
|
strcpy(afilename, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3225,7 +3229,7 @@ RestoreVolumeCmd(struct cmd_syndesc *as, void *arock)
|
|||||||
vol_elsewhere = 1;
|
vol_elsewhere = 1;
|
||||||
|
|
||||||
if (aoverwrite == OVERWRITE_ASK) {
|
if (aoverwrite == OVERWRITE_ASK) {
|
||||||
if (strcmp(afilename, "") == 0) { /* The file is from standard in */
|
if (!isatty(STDIN_FILENO)) {
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
"Volume exists and no -overwrite option specified; Aborting restore command\n");
|
"Volume exists and no -overwrite option specified; Aborting restore command\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user