Removed Windows specific code

master
Kevin Froman 2020-08-12 17:21:11 -05:00
parent ce63c4cd3b
commit 272d7d7f74
11 changed files with 37 additions and 70 deletions

View File

@ -1,4 +1,3 @@
onionr/data/**/* onionr/data/**/*
onionr/data onionr/data
RUN-WINDOWS.bat
MY-RUN.sh MY-RUN.sh

View File

@ -132,7 +132,7 @@ Everyone is welcome to contribute. Help is wanted for the following:
* Development (Get in touch first) * Development (Get in touch first)
* Creation of a shared lib for use from other languages and faster proof-of-work * Creation of a shared lib for use from other languages and faster proof-of-work
* Android and IOS development * 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 * Bug fixes and development of new features
* Testing * Testing
* Translations/localizations * Translations/localizations

View File

@ -1,6 +1,6 @@
# Onionr Installation # 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/ 1. Verify python3.7+ is installed: if not, see https://www.python.org/downloads/

View File

@ -26,16 +26,6 @@ from onionrexceptions import ArbitraryCodeExec
def block_system(cmd): def block_system(cmd):
"""Prevent os.system except for whitelisted commands+contexts.""" """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('POSSIBLE EXPLOIT DETECTED, SEE LOGS', terminal=True)
logger.warn(f'POSSIBLE EXPLOIT: shell command not in whitelist: {cmd}') logger.warn(f'POSSIBLE EXPLOIT: shell command not in whitelist: {cmd}')
raise ArbitraryCodeExec('os.system command not in whitelist') raise ArbitraryCodeExec('os.system command not in whitelist')

View File

@ -67,10 +67,7 @@ MOTD_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ"
"""Public key that signs update notifications.""" """Public key that signs update notifications."""
UPDATE_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ" UPDATE_SIGN_KEY = "TRH763JURNY47QPBTTQ4LLPYCYQK6Q5YA33R6GANKZK5C5DKCIGQ"
pf = platform.system()
if pf == 'Windows':
SCRIPT_NAME = 'run-windows.bat'
else:
if os.path.exists(filepaths.daemon_mark_file): if os.path.exists(filepaths.daemon_mark_file):
SCRIPT_NAME = 'start-daemon.sh' SCRIPT_NAME = 'start-daemon.sh'
else: else:

View File

@ -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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or 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 You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' """
import os
import mimetypes
from flask import Blueprint, send_from_directory
# Was having some mime type issues on windows, this appeared to fix it. # 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. # 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__) 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') @static_files_bp.route('/onboarding/', endpoint='onboardingIndex')
def onboard(): def onboard():
return send_from_directory(f'{root}onboarding/', "index.html") return send_from_directory(f'{root}onboarding/', "index.html")
@static_files_bp.route('/onboarding/<path:path>', endpoint='onboarding') @static_files_bp.route('/onboarding/<path:path>', endpoint='onboarding')
def onboard_files(path): def onboard_files(path):
return send_from_directory(f'{root}onboarding/', path) return send_from_directory(f'{root}onboarding/', path)
@static_files_bp.route('/chat/', endpoint='chatIndex') @static_files_bp.route('/chat/', endpoint='chatIndex')
def chat_index(): def chat_index():
return send_from_directory(root + 'chat/', "index.html") return send_from_directory(root + 'chat/', "index.html")
@static_files_bp.route('/chat/<path:path>', endpoint='chat') @static_files_bp.route('/chat/<path:path>', endpoint='chat')
def load_chat(path): def load_chat(path):
return send_from_directory(root + 'chat/', path) return send_from_directory(root + 'chat/', path)
@static_files_bp.route('/board/', endpoint='board') @static_files_bp.route('/board/', endpoint='board')
def loadBoard(): def loadBoard():
return send_from_directory(root + 'board/', "index.html") return send_from_directory(root + 'board/', "index.html")
@static_files_bp.route('/mail/<path:path>', endpoint='mail') @static_files_bp.route('/mail/<path:path>', endpoint='mail')
def loadMail(path): def loadMail(path):
return send_from_directory(root + 'mail/', path) return send_from_directory(root + 'mail/', path)
@static_files_bp.route('/mail/', endpoint='mailindex') @static_files_bp.route('/mail/', endpoint='mailindex')
def loadMailIndex(): def loadMailIndex():
return send_from_directory(root + 'mail/', 'index.html') return send_from_directory(root + 'mail/', 'index.html')
@static_files_bp.route('/friends/<path:path>', endpoint='friends') @static_files_bp.route('/friends/<path:path>', endpoint='friends')
def loadContacts(path): def loadContacts(path):
return send_from_directory(root + 'friends/', path) return send_from_directory(root + 'friends/', path)
@static_files_bp.route('/friends/', endpoint='friendsindex') @static_files_bp.route('/friends/', endpoint='friendsindex')
def loadContacts(): def loadContacts():
return send_from_directory(root + 'friends/', 'index.html') return send_from_directory(root + 'friends/', 'index.html')
@static_files_bp.route('/profiles/<path:path>', endpoint='profiles') @static_files_bp.route('/profiles/<path:path>', endpoint='profiles')
def loadContacts(path): def loadContacts(path):
return send_from_directory(root + 'profiles/', path) return send_from_directory(root + 'profiles/', path)
@static_files_bp.route('/profiles/', endpoint='profilesindex') @static_files_bp.route('/profiles/', endpoint='profilesindex')
def loadContacts(): def loadContacts():
return send_from_directory(root + 'profiles/', 'index.html') return send_from_directory(root + 'profiles/', 'index.html')
@static_files_bp.route('/board/<path:path>', endpoint='boardContent') @static_files_bp.route('/board/<path:path>', endpoint='boardContent')
def boardContent(path): def boardContent(path):
return send_from_directory(root + 'board/', path) return send_from_directory(root + 'board/', path)
@static_files_bp.route('/shared/<path:path>', endpoint='sharedContent') @static_files_bp.route('/shared/<path:path>', endpoint='sharedContent')
def sharedContent(path): def sharedContent(path):
return send_from_directory(root + 'shared/', path) return send_from_directory(root + 'shared/', path)
@static_files_bp.route('/', endpoint='onionrhome') @static_files_bp.route('/', endpoint='onionrhome')
def hello(): def hello():
# ui home # ui home
return send_from_directory(root + 'private/', 'index.html') return send_from_directory(root + 'private/', 'index.html')
@static_files_bp.route('/private/<path:path>', endpoint='homedata') @static_files_bp.route('/private/<path:path>', endpoint='homedata')
def homedata(path): def homedata(path):
return send_from_directory(root + 'private/', path) return send_from_directory(root + 'private/', path)

View File

@ -5,7 +5,6 @@ Command to restart Onionr
import time import time
import os import os
import subprocess # nosec import subprocess # nosec
import platform
from etc import onionrvalues from etc import onionrvalues
from etc import cleanup from etc import cleanup
@ -36,10 +35,6 @@ SCRIPT_NAME = os.path.dirname(os.path.realpath(
def restart(): def restart():
"""Tell the Onionr daemon to 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) logger.info('Restarting Onionr', terminal=True)
# On platforms where we can, fork out to prevent locking # On platforms where we can, fork out to prevent locking

View File

@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
from gevent import sleep from gevent import sleep
from psutil import Process, WINDOWS from psutil import Process
import ujson as json import ujson as json
from coredb import blockmetadb from coredb import blockmetadb
@ -49,8 +49,6 @@ class SerializedData:
proc = Process() proc = Process()
def get_open_files(): def get_open_files():
if WINDOWS:
return proc.num_handles()
return proc.num_fds() return proc.num_fds()
try: try:

View File

@ -33,8 +33,6 @@ def identify_home() -> str:
system = platform.system() system = platform.system()
if system == 'Linux': if system == 'Linux':
path = os.path.expanduser('~') + '/.local/share/onionr/' path = os.path.expanduser('~') + '/.local/share/onionr/'
elif system == 'Windows':
path = os.path.expanduser('~') + '\\AppData\\Local\\onionr\\'
elif system == 'Darwin': elif system == 'Darwin':
path = os.path.expanduser('~' + path = os.path.expanduser('~' +
'/Library/Application Support/onionr/') '/Library/Application Support/onionr/')

View File

@ -32,7 +32,6 @@
<script defer src="/private/js/console.js"></script> <script defer src="/private/js/console.js"></script>
<script defer src="/private/js/motd.js"></script> <script defer src="/private/js/motd.js"></script>
<script defer src="/shared/navbar.js"></script> <script defer src="/shared/navbar.js"></script>
<script defer src="/private/js/windows.js"></script>
<script defer src="/shared/sidebar/sidebar.js"></script> <script defer src="/shared/sidebar/sidebar.js"></script>
<script defer src="/shared/main/loadTransport.js"></script> <script defer src="/shared/main/loadTransport.js"></script>
<script>alert("Content security policy appears to not be working. Your browser security is weak!")</script> <script>alert("Content security policy appears to not be working. Your browser security is weak!")</script>

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
var hideRestartIfWindows = function(){
if (onionrNodeOS === 'windows'){
document.getElementById('restartNode').style.display = 'none'
}
}
setTimeout(function(){hideRestartIfWindows()}, 500)