vos: Avoid dumping volume to tty

Add a check to avoid dumping a volume to the user's terminal when an
output file is not specified and the user forgets to pipe or redirect
stdout.

Change-Id: Ifdef6550d37981497ac2e8cb596993c2ed2e58f2
Reviewed-on: https://gerrit.openafs.org/14778
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
Michael Meffie 2021-08-27 09:40:07 -04:00 committed by Andrew Deason
parent 96f1209ea7
commit 55f27294a3

View File

@ -2996,6 +2996,11 @@ DumpVolumeCmd(struct cmd_syndesc *as, void *arock)
if (as->parms[2].items) {
filename = as->parms[2].items->data;
} else {
if (isatty(STDOUT_FILENO)) {
fprintf(STDERR, "Refusing to dump volume to a tty. Either redirect "
"stdout, or specify a path with -file.\n");
exit(1);
}
filename = "";
}