openbsd-ports/archivers/xz/patches/patch-src_xz_main_c

29 lines
1.1 KiB
Plaintext

--- src/xz/main.c.orig Tue Sep 29 12:57:36 2015
+++ src/xz/main.c Fri Aug 12 22:49:04 2016
@@ -163,12 +163,25 @@ main(int argc, char **argv)
// on the command line, thus this must be done before args_parse().
hardware_init();
+ if (pledge("stdio rpath wpath cpath fattr proc", NULL) == -1)
+ message_fatal(_("pledge"));
+
// Parse the command line arguments and get an array of filenames.
// This doesn't return if something is wrong with the command line
// arguments. If there are no arguments, one filename ("-") is still
// returned to indicate stdin.
args_info args;
args_parse(&args, argc, argv);
+
+ // No files on the command line and no --files.
+ if ((args.arg_count == 1 && strcmp(args.arg_names[0], "-") == 0) &&
+ args.files_name == NULL) {
+ if (pledge("stdio proc", NULL) == -1)
+ message_fatal(_("pledge"));
+ } else if (opt_stdout || opt_mode == MODE_LIST) {
+ if (pledge("stdio rpath proc", NULL) == -1)
+ message_fatal(_("pledge"));
+ }
if (opt_mode != MODE_LIST && opt_robot)
message_fatal(_("Compression and decompression with --robot "