MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / network_apply_bashrc_exports

Function network_apply_bashrc_exports

Scripts/Settings.py:7306–7386  ·  view source on GitHub ↗

Write VPN/Tor proxy exports and a new-session guard into bash.bashrc. New shells cannot inherit variables from the already-running Settings.py process, so this writes the current proxy state into bash.bashrc. It also installs a small shell guard that quietly starts Tor again when Tor is

()

Source from the content-addressed store, hash-verified

7304 return
7305 if route == '/api/fs/write':
7306 path = safe_realpath(payload.get('path'), must_exist=True)
7307 if os.path.isdir(path):
7308 raise IsADirectoryError('Cannot write to a directory.')
7309 write_text_file(path, payload.get('content', ''))
7310 send_json(self, 200, {'ok': True, 'path': path})
7311 return
7312 if route == '/api/fs/mkdir':
7313 target = safe_target_path(payload.get('path'))
7314 os.makedirs(target, exist_ok=False)
7315 send_json(self, 200, {'ok': True, 'path': target})
7316 return
7317 if route == '/api/fs/newfile':
7318 target = safe_target_path(payload.get('path'))
7319 if os.path.exists(target):
7320 raise FileExistsError('File already exists: ' + target)
7321 write_text_file(target, payload.get('content', ''))
7322 send_json(self, 200, {'ok': True, 'path': target})
7323 return
7324 if route == '/api/fs/delete':
7325 path = safe_realpath(payload.get('path'), must_exist=True)
7326 if path == os.path.realpath(HOME_DIR):
7327 raise ValueError('Refusing to delete the Termux home directory.')
7328 if os.path.isdir(path):
7329 shutil.rmtree(path)
7330 else:
7331 os.remove(path)
7332 send_json(self, 200, {'ok': True})
7333 return
7334 if route == '/api/fs/copy':
7335 source = safe_realpath(payload.get('source'), must_exist=True)
7336 destination = safe_target_path(payload.get('destination'))
7337 if os.path.exists(destination):
7338 raise FileExistsError('Destination already exists: ' + destination)
7339 if os.path.isdir(source):
7340 shutil.copytree(source, destination)
7341 else:
7342 shutil.copy2(source, destination)
7343 send_json(self, 200, {'ok': True, 'destination': destination})
7344 return
7345 if route == '/api/fs/move':
7346 source = safe_realpath(payload.get('source'), must_exist=True)
7347 destination = safe_target_path(payload.get('destination'))
7348 if os.path.exists(destination):
7349 raise FileExistsError('Destination already exists: ' + destination)
7350 shutil.move(source, destination)
7351 send_json(self, 200, {'ok': True, 'destination': destination})
7352 return
7353 if route == '/api/jobs/stop':
7354 job = stop_job(payload.get('session_id'), bool(payload.get('close_only')))
7355 send_json(self, 200, {'ok': True, 'session': job})
7356 return
7357 if route == '/api/system/exit':
7358 send_json(self, 200, {'ok': True, **request_system_exit()})
7359 return
7360 if route == '/api/programs/install':
7361 job = run_store_program(payload.get('program_id'), 'install')
7362 send_json(self, 200, {'ok': True, 'session': job})
7363 return

Callers 7

network_enable_torFunction · 0.70
network_disable_torFunction · 0.70
network_enable_vpnFunction · 0.70
network_disable_vpnFunction · 0.70
network_session_guardFunction · 0.70

Calls 5

printFunction · 0.85
network_load_configFunction · 0.70
network_tor_proxyFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected