Browse Source

get_parent_directories_that_are_not_listable_by_everybody

master
forest 3 months ago
parent
commit
b3a1aef7d0
3 changed files with 42 additions and 7 deletions
  1. +2
    -1
      requirements/linux.txt
  2. +40
    -5
      src/main/python/main.py
  3. +0
    -1
      src/main/resources/mac/install_daemon.sh

+ 2
- 1
requirements/linux.txt View File

@ -1,4 +1,5 @@
-r base.txt
qtwidgets==0.18
pyqtspinner==0.1.1
requests==2.25.1
requests==2.25.1
elevate==0.1.3

+ 40
- 5
src/main/python/main.py View File

@ -5,9 +5,11 @@ from PyQt5.QtWidgets import QStyleFactory, QWidget, QDialog, QLabel, QLineEdit,
from qtwidgets import PasswordEdit
import pyqtspinner
from pyqtspinner.spinner import WaitingSpinner
from elevate import elevate
from typing import Callable, Tuple, Dict, Union
import os
import platform
import webbrowser
import subprocess
@ -20,7 +22,7 @@ import sip
import json
import hashlib
import re
from pathlib import Path
from threadpool import ThreadPool
# remove unverified TLS warning
@ -32,6 +34,24 @@ daemon_api_port = 9572
def my_exec_info_message(exec_info):
return "{}: {}".format(".".join([exec_info[0].__module__, exec_info[0].__name__]), exec_info[1])
def get_parent_directories_that_are_not_listable_by_everybody(path):
to_return = []
while True:
# if the folder at path is not "executable" (can be listed) by "others" (everybody)
if not os.stat.S_IXOTH(os.stat(path).st_mode):
to_return.append(path)
path_obj = Path(path)
parent_path = path.parent.absolute()
# if we are at the root path which has no parent (like '/' for example) then we are done, return the results so far
if path == parent_path:
return to_return
# walk path upwards to parent directory and repeat
path = parent_path
class InstallerSignals(QObject):
log_line = pyqtSignal(object)
@ -1148,6 +1168,11 @@ class MainWindow(QWidget):
selected_path = QFileDialog.getExistingDirectory(self, caption="Select a Folder to Publish...", directory=currentDirectory)
if selected_path is not None and selected_path != "":
if platform.system() != "Windows"
changes_needed = get_parent_directories_that_are_not_listable_by_everybody(selected_path)
if len(changes_needed) > 0:
print(changes_needed)
folder_field.setText(selected_path)
tunnel['destination_folder_path'] = selected_path
self.set_config_dirty()
@ -1670,10 +1695,20 @@ if __name__ == '__main__':
app_context = ApplicationContext()
if sys.argv[len(sys.argv)-1] == "run_macos_background_service_installer":
from elevate import elevate
import os
if "prompt_chmod" in sys.argv:
sys.argv[len(sys.argv)-1]
elevate(graphical=True)
if os.getuid() != 0:
print(f"elevate() failed: not running as root. uid={os.getuid()}")
sys.exit(1)
elif "run_macos_background_service_installer" in sys.argv:
elevate(graphical=True)
if os.getuid() != 0:


+ 0
- 1
src/main/resources/mac/install_daemon.sh View File

@ -146,7 +146,6 @@ if ! id -u _greenhouse-daemon > /dev/null 2>&1 ; then
dscl . -create /Users/_greenhouse-daemon UniqueID "$unused_user_id"
dscl . -create /Users/_greenhouse-daemon PrimaryGroupID "$unused_group_id"
dscl . -create /Users/_greenhouse-daemon UserShell /usr/bin/false
fi
mkdir -p /opt/greenhouse-daemon


Loading…
Cancel
Save