Browse Source

shred_file(): add `cfg`, `iterations` params

The MMGen Project 5 months ago
parent
commit
2df03306f2
4 changed files with 8 additions and 8 deletions
  1. 3 3
      mmgen/autosign.py
  2. 3 3
      mmgen/fileutil.py
  3. 1 1
      mmgen/main_wallet.py
  4. 1 1
      mmgen/xmrwallet/ops/create.py

+ 3 - 3
mmgen/autosign.py

@@ -242,7 +242,7 @@ class Signable:
 					do_exit = True)
 			for fn in files:
 				msg(f'Shredding file ‘{fn}’')
-				shred_file(fn)
+				shred_file(self.cfg, fn, iterations=15)
 			sys.exit(0)
 
 		async def get_last_created(self):
@@ -694,7 +694,7 @@ class Autosign:
 	def wipe_encryption_key(self):
 		if self.keyfile.exists():
 			ymsg(f'Shredding wallet encryption key ‘{self.keyfile}’')
-			shred_file(self.keyfile, verbose=self.cfg.verbose)
+			shred_file(self.cfg, self.keyfile)
 		else:
 			gmsg('No wallet encryption key on removable device')
 
@@ -820,7 +820,7 @@ class Autosign:
 		def do_shred(fn):
 			nonlocal count
 			msg_r('.')
-			shred_file(fn, verbose=self.cfg.verbose)
+			shred_file(self.cfg, fn, iterations=15)
 			count += 1
 
 		def clean_dir(s_name):

+ 3 - 3
mmgen/fileutil.py

@@ -57,12 +57,12 @@ def check_binary(args):
 		die(2, f'{args[0]!r} binary missing, not in path, or not executable')
 	set_vt100()
 
-def shred_file(fn, *, verbose=False):
+def shred_file(cfg, fn, *, iterations=30):
 	check_binary(['shred', '--version'])
 	from subprocess import run
 	run(
-		['shred', '--force', '--iterations=30', '--zero', '--remove=wipesync']
-		+ (['--verbose'] if verbose else [])
+		['shred', '--force', f'--iterations={iterations}', '--zero', '--remove=wipesync']
+		+ (['--verbose'] if cfg.verbose else [])
 		+ [str(fn)],
 		check=True)
 	set_vt100()

+ 1 - 1
mmgen/main_wallet.py

@@ -241,7 +241,7 @@ if invoked_as == 'passchg':
 	def secure_delete(fn):
 		bmsg('Securely deleting old wallet')
 		from .fileutil import shred_file
-		shred_file(fn, verbose = cfg.verbose)
+		shred_file(cfg, fn)
 
 	def rename_old_wallet_maybe(silent):
 		# though very unlikely, old and new wallets could have same Key ID and thus same filename.

+ 1 - 1
mmgen/xmrwallet/ops/create.py

@@ -79,6 +79,6 @@ class OpCreateOffline(OpCreate):
 			if f.name.endswith(vkf.ext):
 				from ...fileutil import shred_file
 				msg(f'\nShredding old viewkey-address file ‘{f}’')
-				shred_file(f, verbose=self.cfg.verbose)
+				shred_file(self.cfg, f, iterations=15)
 
 		vkf.write(outdir=self.asi.xmr_dir)