URI: 
       tutil.make_dir: 0o700 permissions on folders (#4357) - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 9b7a449057eb897cb2fa8f609d43f71e15646015
   DIR parent dbec3af810851666ba16e3c9b9e966974fcb0aa5
  HTML Author: ghost43 <somber.night@protonmail.com>
       Date:   Mon, 28 May 2018 14:22:54 +0200
       
       util.make_dir: 0o700 permissions on folders (#4357)
       
       
       Diffstat:
         M lib/blockchain.py                   |       3 +--
         M lib/exchange_rate.py                |       5 ++---
         M lib/network.py                      |       4 +---
         M lib/simple_config.py                |      22 +++++-----------------
         M lib/util.py                         |      10 ++++++++++
         M plugins/revealer/qt.py              |       5 ++---
       
       6 files changed, 21 insertions(+), 28 deletions(-)
       ---
   DIR diff --git a/lib/blockchain.py b/lib/blockchain.py
       t@@ -68,8 +68,7 @@ blockchains = {}
        def read_blockchains(config):
            blockchains[0] = Blockchain(config, 0, None)
            fdir = os.path.join(util.get_headers_dir(config), 'forks')
       -    if not os.path.exists(fdir):
       -        os.mkdir(fdir)
       +    util.make_dir(fdir)
            l = filter(lambda x: x.startswith('fork_'), os.listdir(fdir))
            l = sorted(l, key = lambda x: int(x.split('_')[1]))
            for filename in l:
   DIR diff --git a/lib/exchange_rate.py b/lib/exchange_rate.py
       t@@ -12,7 +12,7 @@ from decimal import Decimal
        
        from .bitcoin import COIN
        from .i18n import _
       -from .util import PrintError, ThreadJob
       +from .util import PrintError, ThreadJob, make_dir
        
        
        # See https://en.wikipedia.org/wiki/ISO_4217
       t@@ -432,8 +432,7 @@ class FxThread(ThreadJob):
                self.hist_checkbox = None
                self.cache_dir = os.path.join(config.path, 'cache')
                self.set_exchange(self.config_exchange())
       -        if not os.path.exists(self.cache_dir):
       -            os.mkdir(self.cache_dir)
       +        make_dir(self.cache_dir)
        
            def get_currencies(self, h):
                d = get_exchanges_by_ccy(h)
   DIR diff --git a/lib/network.py b/lib/network.py
       t@@ -202,9 +202,7 @@ class Network(util.DaemonThread):
                self.callbacks = defaultdict(list)
        
                dir_path = os.path.join( self.config.path, 'certs')
       -        if not os.path.exists(dir_path):
       -            os.mkdir(dir_path)
       -            os.chmod(dir_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
       +        util.make_dir(dir_path)
        
                # subscriptions and requests
                self.subscribed_addresses = set()
   DIR diff --git a/lib/simple_config.py b/lib/simple_config.py
       t@@ -8,7 +8,7 @@ from decimal import Decimal
        from copy import deepcopy
        
        from . import util
       -from .util import (user_dir, print_error, PrintError,
       +from .util import (user_dir, print_error, PrintError, make_dir,
                           NoDynamicFeeEstimates, format_fee_satoshis, quantize_feerate)
        from .i18n import _
        
       t@@ -105,21 +105,13 @@ class SimpleConfig(PrintError):
                if path is None:
                    path = self.user_dir()
        
       -        def make_dir(path):
       -            # Make directory if it does not yet exist.
       -            if not os.path.exists(path):
       -                if os.path.islink(path):
       -                    raise Exception('Dangling link: ' + path)
       -                os.mkdir(path)
       -                os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
       -
       -        make_dir(path)
       +        make_dir(path, allow_symlink=False)
                if self.get('testnet'):
                    path = os.path.join(path, 'testnet')
       -            make_dir(path)
       +            make_dir(path, allow_symlink=False)
                elif self.get('regtest'):
                    path = os.path.join(path, 'regtest')
       -            make_dir(path)
       +            make_dir(path, allow_symlink=False)
        
                self.print_error("electrum directory", path)
                return path
       t@@ -240,11 +232,7 @@ class SimpleConfig(PrintError):
                # default path
                util.assert_datadir_available(self.path)
                dirpath = os.path.join(self.path, "wallets")
       -        if not os.path.exists(dirpath):
       -            if os.path.islink(dirpath):
       -                raise Exception('Dangling link: ' + dirpath)
       -            os.mkdir(dirpath)
       -            os.chmod(dirpath, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
       +        make_dir(dirpath, allow_symlink=False)
        
                new_path = os.path.join(self.path, "wallets", "default_wallet")
        
   DIR diff --git a/lib/util.py b/lib/util.py
       t@@ -30,6 +30,7 @@ import traceback
        import urllib
        import threading
        import hmac
       +import stat
        
        from .i18n import _
        
       t@@ -880,3 +881,12 @@ def export_meta(meta, fileName):
            except (IOError, os.error) as e:
                traceback.print_exc(file=sys.stderr)
                raise FileExportFailed(e)
       +
       +
       +def make_dir(path, allow_symlink=True):
       +    """Make directory if it does not yet exist."""
       +    if not os.path.exists(path):
       +        if not allow_symlink and os.path.islink(path):
       +            raise Exception('Dangling link: ' + path)
       +        os.mkdir(path)
       +        os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
   DIR diff --git a/plugins/revealer/qt.py b/plugins/revealer/qt.py
       t@@ -28,7 +28,7 @@ from electrum.plugins import BasePlugin, hook
        from electrum.i18n import _
        from electrum_gui.qt.util import *
        from electrum_gui.qt.qrtextedit import ScanQRTextEdit
       -from electrum.util import to_bytes
       +from electrum.util import to_bytes, make_dir
        
        
        class Plugin(BasePlugin):
       t@@ -52,8 +52,7 @@ class Plugin(BasePlugin):
                self.abstand_v = 34
                self.calibration_noise = int('10' * 128)
                self.rawnoise = False
       -        if not os.path.exists(self.base_dir):
       -            os.mkdir(self.base_dir)
       +        make_dir(self.base_dir)
        
            @hook
            def set_seed(self, seed, parent):