From 272d7d7f74bde3b607295302257b09b2b5125180 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 12 Aug 2020 17:21:11 -0500 Subject: [PATCH] Removed Windows specific code --- .dockerignore | 1 - README.md | 2 +- docs/usage/install.md | 2 +- src/bigbrother/ministry/ofexec.py | 16 ++-------- src/etc/onionrvalues.py | 11 +++---- src/httpapi/miscclientapi/staticfiles.py | 37 +++++++++++++++++------- src/onionrcommands/restartonionr.py | 5 ---- src/onionrstatistics/serializeddata.py | 4 +-- src/utils/identifyhome.py | 2 -- static-data/www/private/index.html | 1 - static-data/www/private/js/windows.js | 26 ----------------- 11 files changed, 37 insertions(+), 70 deletions(-) delete mode 100644 static-data/www/private/js/windows.js diff --git a/.dockerignore b/.dockerignore index 4a0c253e..b45826ec 100755 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ onionr/data/**/* onionr/data -RUN-WINDOWS.bat MY-RUN.sh diff --git a/README.md b/README.md index 2a4c44a4..3049c33b 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ Everyone is welcome to contribute. Help is wanted for the following: * Development (Get in touch first) * Creation of a shared lib for use from other languages and faster proof-of-work * Android and IOS development - * Windows and Mac support (already partially supported, testers needed) + * Mac support (already partially supported, testers needed) * Bug fixes and development of new features * Testing * Translations/localizations diff --git a/docs/usage/install.md b/docs/usage/install.md index 9bda7b21..e126b5c0 100644 --- a/docs/usage/install.md +++ b/docs/usage/install.md @@ -1,6 +1,6 @@ # Onionr Installation -The following steps work broadly speaking for Windows, Mac, and Linux. +The following steps work broadly speaking for WSL, Mac, and Linux. 1. Verify python3.7+ is installed: if not, see https://www.python.org/downloads/ diff --git a/src/bigbrother/ministry/ofexec.py b/src/bigbrother/ministry/ofexec.py index 613b0fef..b1ff5843 100644 --- a/src/bigbrother/ministry/ofexec.py +++ b/src/bigbrother/ministry/ofexec.py @@ -26,19 +26,9 @@ from onionrexceptions import ArbitraryCodeExec def block_system(cmd): """Prevent os.system except for whitelisted commands+contexts.""" - allowed = 'taskkill /PID ' - is_ok = False - if platform.system() == 'Windows': - if cmd.startswith(allowed): - for c in cmd.split(allowed)[1]: - if not c.isalnum() or c not in ('/', 'F', ' '): - break - else: - is_ok = True - if not is_ok: - logger.warn('POSSIBLE EXPLOIT DETECTED, SEE LOGS', terminal=True) - logger.warn(f'POSSIBLE EXPLOIT: shell command not in whitelist: {cmd}') - raise ArbitraryCodeExec('os.system command not in whitelist') + logger.warn('POSSIBLE EXPLOIT DETECTED, SEE LOGS', terminal=True) + logger.warn(f'POSSIBLE EXPLOIT: shell command not in whitelist: {cmd}') + raise ArbitraryCodeExec('os.system command not in whitelist') def block_exec(event, info): diff --git a/src/etc/onionrvalues.py b/src/etc/onionrvalues.py index 45544f50..bc8ba59e 100755 --- a/src/etc/onionrvalues.py +++ b/src/etc/onionrvalues.py @@ -67,13 +67,10 @@ MOTD_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ" """Public key that signs update notifications.""" UPDATE_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ" -pf = platform.system() -if pf == 'Windows': - SCRIPT_NAME = 'run-windows.bat' + +if os.path.exists(filepaths.daemon_mark_file): + SCRIPT_NAME = 'start-daemon.sh' else: - if os.path.exists(filepaths.daemon_mark_file): - SCRIPT_NAME = 'start-daemon.sh' - else: - SCRIPT_NAME = 'onionr.sh' + SCRIPT_NAME = 'onionr.sh' if 'qubes' in platform.release().lower(): IS_QUBES = True diff --git a/src/httpapi/miscclientapi/staticfiles.py b/src/httpapi/miscclientapi/staticfiles.py index 4640d8af..644274aa 100644 --- a/src/httpapi/miscclientapi/staticfiles.py +++ b/src/httpapi/miscclientapi/staticfiles.py @@ -1,9 +1,11 @@ -''' - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication - Register static file routes -''' -''' +Register static file routes +""" +import os +import mimetypes +from flask import Blueprint, send_from_directory +""" This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -16,10 +18,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -''' -import os -import mimetypes -from flask import Blueprint, send_from_directory +""" + # Was having some mime type issues on windows, this appeared to fix it. # we have no-sniff set, so if the mime types are invalid sripts can't load. @@ -28,65 +28,82 @@ mimetypes.add_type('text/css', '.css') static_files_bp = Blueprint('staticfiles', __name__) -root = os.path.dirname(os.path.realpath(__file__)) + '/../../../static-data/www/' # should be set to onionr install directory from onionr startup +# should be set to onionr install directory from onionr startup +root = os.path.dirname(os.path.realpath(__file__)) + \ + '/../../../static-data/www/' + @static_files_bp.route('/onboarding/', endpoint='onboardingIndex') def onboard(): return send_from_directory(f'{root}onboarding/', "index.html") + @static_files_bp.route('/onboarding/', endpoint='onboarding') def onboard_files(path): return send_from_directory(f'{root}onboarding/', path) + @static_files_bp.route('/chat/', endpoint='chatIndex') def chat_index(): return send_from_directory(root + 'chat/', "index.html") + @static_files_bp.route('/chat/', endpoint='chat') def load_chat(path): return send_from_directory(root + 'chat/', path) + @static_files_bp.route('/board/', endpoint='board') def loadBoard(): return send_from_directory(root + 'board/', "index.html") + @static_files_bp.route('/mail/', endpoint='mail') def loadMail(path): return send_from_directory(root + 'mail/', path) + @static_files_bp.route('/mail/', endpoint='mailindex') def loadMailIndex(): return send_from_directory(root + 'mail/', 'index.html') + @static_files_bp.route('/friends/', endpoint='friends') def loadContacts(path): return send_from_directory(root + 'friends/', path) + @static_files_bp.route('/friends/', endpoint='friendsindex') def loadContacts(): return send_from_directory(root + 'friends/', 'index.html') + @static_files_bp.route('/profiles/', endpoint='profiles') def loadContacts(path): return send_from_directory(root + 'profiles/', path) + @static_files_bp.route('/profiles/', endpoint='profilesindex') def loadContacts(): return send_from_directory(root + 'profiles/', 'index.html') + @static_files_bp.route('/board/', endpoint='boardContent') def boardContent(path): return send_from_directory(root + 'board/', path) + @static_files_bp.route('/shared/', endpoint='sharedContent') def sharedContent(path): return send_from_directory(root + 'shared/', path) + @static_files_bp.route('/', endpoint='onionrhome') def hello(): # ui home return send_from_directory(root + 'private/', 'index.html') + @static_files_bp.route('/private/', endpoint='homedata') def homedata(path): return send_from_directory(root + 'private/', path) \ No newline at end of file diff --git a/src/onionrcommands/restartonionr.py b/src/onionrcommands/restartonionr.py index c58913af..692a6b61 100644 --- a/src/onionrcommands/restartonionr.py +++ b/src/onionrcommands/restartonionr.py @@ -5,7 +5,6 @@ Command to restart Onionr import time import os import subprocess # nosec -import platform from etc import onionrvalues from etc import cleanup @@ -36,10 +35,6 @@ SCRIPT_NAME = os.path.dirname(os.path.realpath( def restart(): """Tell the Onionr daemon to restart.""" - if platform.system() == 'Windows': - logger.warn('Cannot restart Onionr on Windows. Run stop and manually restart.', terminal=True) - return - logger.info('Restarting Onionr', terminal=True) # On platforms where we can, fork out to prevent locking diff --git a/src/onionrstatistics/serializeddata.py b/src/onionrstatistics/serializeddata.py index fece1d14..1e8c29ef 100755 --- a/src/onionrstatistics/serializeddata.py +++ b/src/onionrstatistics/serializeddata.py @@ -6,7 +6,7 @@ from typing import TYPE_CHECKING from gevent import sleep -from psutil import Process, WINDOWS +from psutil import Process import ujson as json from coredb import blockmetadb @@ -49,8 +49,6 @@ class SerializedData: proc = Process() def get_open_files(): - if WINDOWS: - return proc.num_handles() return proc.num_fds() try: diff --git a/src/utils/identifyhome.py b/src/utils/identifyhome.py index a73663e0..366a17d0 100644 --- a/src/utils/identifyhome.py +++ b/src/utils/identifyhome.py @@ -33,8 +33,6 @@ def identify_home() -> str: system = platform.system() if system == 'Linux': path = os.path.expanduser('~') + '/.local/share/onionr/' - elif system == 'Windows': - path = os.path.expanduser('~') + '\\AppData\\Local\\onionr\\' elif system == 'Darwin': path = os.path.expanduser('~' + '/Library/Application Support/onionr/') diff --git a/static-data/www/private/index.html b/static-data/www/private/index.html index 9153a32c..0cb16ad8 100755 --- a/static-data/www/private/index.html +++ b/static-data/www/private/index.html @@ -32,7 +32,6 @@ - diff --git a/static-data/www/private/js/windows.js b/static-data/www/private/js/windows.js deleted file mode 100644 index 5a6dabf2..00000000 --- a/static-data/www/private/js/windows.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - Onionr - Private P2P Communication - - Hide restart button if node OS is windows - since restart is broken on windows - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -var hideRestartIfWindows = function(){ - if (onionrNodeOS === 'windows'){ - document.getElementById('restartNode').style.display = 'none' - } -} - -setTimeout(function(){hideRestartIfWindows()}, 500)