mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-20 01:19:49 +00:00
util.make_dir: 0o700 permissions on folders (#4357)
This commit is contained in:
parent
dbec3af810
commit
9b7a449057
6 changed files with 21 additions and 28 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 _
|
||||
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
||||
|
|
10
lib/util.py
10
lib/util.py
|
@ -30,6 +30,7 @@ import traceback
|
|||
import urllib
|
||||
import threading
|
||||
import hmac
|
||||
import stat
|
||||
|
||||
from .i18n import _
|
||||
|
||||
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue