Repository: paritytech/parity-bitcoin (language: rust)

Issue:
Unable to use custom data-dir
To reproduce:

1. Install parity-bitcoin using snap.
2. Make sure that the directory `/home/myusername/blockchains/bitcoin/segwit/` exists and has the same owner and group as the current user account.
2. Run `parity-bitcoin --segwit --jsonrpc-port 8332 --data-dir /home/myusername/blockchains/bitcoin/segwit/`

Error stack trace:

```
thread 'main' panicked at 'Failed to get app dir: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', libcore/result.rs:945:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:380
   3: std::panicking::default_hook
             at libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:576
   5: std::panicking::begin_panic
             at libstd/panicking.rs:537
   6: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:521
   7: rust_begin_unwind
             at libstd/panicking.rs:497
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   9: <unknown>
             at /checkout/src/libcore/macros.rs:23
Aborted
```


Discussion / hints:
Can reproduce. It's probably related to how snapcraft confines the application process. From `gdb`:

```
Starting program: /snap/bin/parity-bitcoin --segwit --data-dir /home/user/Desktop/
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 4808 is executing new program: /usr/lib/snapd/snap-confine
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
need to run as root or suid
[Inferior 1 (process 4808) exited with code 01]
```

cc @General-Beck @elopio 

Fix patch:
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index fa5d7473d..d8c0e5b53 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -10,7 +10,7 @@ confinement: strict
 apps:
   parity-bitcoin:
     command: pbtc
-    plugs: [network, network-bind]
+    plugs: [home, network, network-bind]
 
 parts:
   parity-bitcoin:


Test patch: