Skip to content

Commit 6cc3713

Browse files
committed
HADOOP-18136. Verify FileUtils.unTar() handling of missing .tar files.
remove surplus params from tarhardened and update readme
1 parent 64d9bbd commit 6cc3713

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,36 @@ information to disable it if so.
729729

730730
See [safeprefetch](src/main/site/safeprefetch.md)
731731

732+
## Command `tarhardened`
733+
734+
Verify the hadoop release has had its untar command hardened and will
735+
not evaluate commands passed in as filenames.
736+
737+
```bash
738+
bin/hadoop jar $CLOUDSTORE tarhardened "file.tar; true"
739+
```
740+
741+
*Bad*
742+
743+
```
744+
Attempting to untar file with name "file.tar; true"
745+
untar operation reported success
746+
747+
2023-01-27 16:42:35,931 [main] INFO util.ExitUtil (ExitUtil.java:terminate(124)) - Exiting with status 0
748+
```
749+
750+
Although the file doesn't exist, the bash "true" command was executed after the untar, so
751+
the operation was reported as a success.
752+
753+
*Good*
754+
755+
```
756+
2023-01-27 16:48:44,461 [main] INFO util.ExitUtil (ExitUtil.java:terminate(210)) - Exiting with status -1: ExitCodeException exitCode=1: tar: Error opening archive: Failed to open 'file.tar; true'
757+
758+
```
759+
760+
The file `file.tar; true` was attempted to be opened; as it is not present the operation failed.
761+
Expect a stack trace in the report
732762
## Command `tlsinfo`
733763

734764
Print out tls information. The `storediag` command prints the same information;

src/main/java/org/apache/hadoop/fs/store/commands/TarHardened.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
import org.apache.hadoop.fs.store.diag.DiagnosticsEntryPoint;
2929
import org.apache.hadoop.util.ToolRunner;
3030

31-
import static org.apache.hadoop.fs.store.CommonParameters.DEFINE;
32-
import static org.apache.hadoop.fs.store.CommonParameters.VERBOSE;
33-
import static org.apache.hadoop.fs.store.CommonParameters.XMLFILE;
3431
import static org.apache.hadoop.fs.store.StoreExitCodes.E_USAGE;
3532

3633
/**
@@ -42,14 +39,10 @@ public class TarHardened extends DiagnosticsEntryPoint {
4239
private static final Logger LOG = LoggerFactory.getLogger(TarHardened.class);
4340

4441
public static final String USAGE
45-
= "Usage: tarhardened [filename]\n"
46-
+ optusage(DEFINE, "key=value", "Define a property")
47-
+ optusage(XMLFILE, "file", "XML config file to load")
48-
+ optusage(VERBOSE, "verbose output");
42+
= "Usage: tarhardened [filename]";
4943

5044
public TarHardened() {
51-
createCommandFormat(1, 1, VERBOSE);
52-
addValueOptions(XMLFILE, DEFINE);
45+
createCommandFormat(0, 1);
5346
}
5447

5548
@Override

0 commit comments

Comments
 (0)