[improvement] the temp dir used now has a different name if you launch bauh as the root user to avoid permissioning issues

This commit is contained in:
Vinícius Moreira
2020-02-12 14:41:30 -03:00
parent 9d373adfcc
commit 584064f214
7 changed files with 14 additions and 11 deletions

View File

@@ -15,11 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- checking architecture dependencies (x86_64, i686) - checking architecture dependencies (x86_64, i686)
- architecture dependencies are displayed on the info window as well - architecture dependencies are displayed on the info window as well
- optimizations to speed up zst packages building - optimizations to speed up zst packages building
- Web:
- separate temp build folder for standard and root users
- UI: - UI:
- **Settings** available as a tray action as well - **Settings** available as a tray action as well
- minor improvements - minor improvements
- the temp dir used now has a different name if you launch bauh as the root user to avoid permissioning issues ( **/tmp/bauh_root** )
### Fixes ### Fixes
- Web: - Web:

View File

@@ -267,7 +267,7 @@ Priority:
### Files and Logs ### Files and Logs
- Installation logs and temporary files are saved at **/tmp/bauh** - Installation logs and temporary files are saved at **/tmp/bauh** ( or **/tmp/bauh_root** if you launch it as root)
- Some data about your installed applications are stored in **~/.cache/bauh** to load them faster ( default behavior ). - Some data about your installed applications are stored in **~/.cache/bauh** to load them faster ( default behavior ).
### [bauh-files](https://github.com/vinifmor/bauh-files) ### [bauh-files](https://github.com/vinifmor/bauh-files)

View File

@@ -1,5 +1,7 @@
import os
from pathlib import Path from pathlib import Path
CACHE_PATH = '{}/.cache/bauh'.format(Path.home()) CACHE_PATH = '{}/.cache/bauh'.format(Path.home())
CONFIG_PATH = '{}/.config/bauh'.format(Path.home()) CONFIG_PATH = '{}/.config/bauh'.format(Path.home())
DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(Path.home()) DESKTOP_ENTRIES_DIR = '{}/.local/share/applications'.format(Path.home())
TEMP_DIR = '/tmp/bauh{}'.format('_root' if os.getuid() == 0 else '')

View File

@@ -1,10 +1,10 @@
import os import os
from pathlib import Path from pathlib import Path
from bauh.api.constants import CACHE_PATH, CONFIG_PATH from bauh.api.constants import CACHE_PATH, CONFIG_PATH, TEMP_DIR
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
BUILD_DIR = '/tmp/bauh/aur' BUILD_DIR = '{}/aur'.format(TEMP_DIR)
ARCH_CACHE_PATH = CACHE_PATH + '/arch' ARCH_CACHE_PATH = CACHE_PATH + '/arch'
CATEGORIES_CACHE_DIR = ARCH_CACHE_PATH + '/categories' CATEGORIES_CACHE_DIR = ARCH_CACHE_PATH + '/categories'
CATEGORIES_FILE_PATH = CATEGORIES_CACHE_DIR + '/aur.txt' CATEGORIES_FILE_PATH = CATEGORIES_CACHE_DIR + '/aur.txt'

View File

@@ -20,6 +20,7 @@ from bauh.api.abstract.model import PackageUpdate, PackageHistory, SoftwarePacka
SuggestionPriority SuggestionPriority
from bauh.api.abstract.view import MessageType, FormComponent, InputOption, SingleSelectComponent, SelectViewType, \ from bauh.api.abstract.view import MessageType, FormComponent, InputOption, SingleSelectComponent, SelectViewType, \
ViewComponent, PanelComponent ViewComponent, PanelComponent
from bauh.api.constants import TEMP_DIR
from bauh.commons.category import CategoriesDownloader from bauh.commons.category import CategoriesDownloader
from bauh.commons.config import save_config from bauh.commons.config import save_config
from bauh.commons.html import bold from bauh.commons.html import bold
@@ -846,7 +847,7 @@ class ArchManager(SoftwareManager):
return False return False
def _sync_databases(self, root_password: str, handler: ProcessHandler): def _sync_databases(self, root_password: str, handler: ProcessHandler):
sync_path = '/tmp/bauh/arch/sync' sync_path = '{}/arch/sync'.format(TEMP_DIR)
if self.local_config['sync_databases']: if self.local_config['sync_databases']:
if os.path.exists(sync_path): if os.path.exists(sync_path):
@@ -873,8 +874,8 @@ class ArchManager(SoftwareManager):
force=True)) force=True))
if synced: if synced:
try: try:
Path('/tmp/bauh/arch').mkdir(parents=True, exist_ok=True) Path('/'.join(sync_path.split('/')[0:-1])).mkdir(parents=True, exist_ok=True)
with open('/tmp/bauh/arch/sync', 'w+') as f: with open(sync_path, 'w+') as f:
f.write(str(int(time.time()))) f.write(str(int(time.time())))
except: except:
traceback.print_exc() traceback.print_exc()

View File

@@ -1,7 +1,7 @@
import os import os
from pathlib import Path from pathlib import Path
from bauh.api.constants import DESKTOP_ENTRIES_DIR, CONFIG_PATH from bauh.api.constants import DESKTOP_ENTRIES_DIR, CONFIG_PATH, TEMP_DIR
from bauh.commons import user from bauh.commons import user
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -22,7 +22,7 @@ DESKTOP_ENTRY_PATH_PATTERN = DESKTOP_ENTRIES_DIR + '/bauh.web.{name}.desktop'
URL_FIX_PATTERN = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/fix/{url}.js" URL_FIX_PATTERN = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/fix/{url}.js"
URL_SUGGESTIONS = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/suggestions.yml" URL_SUGGESTIONS = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/suggestions.yml"
UA_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' UA_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
TEMP_PATH = '/tmp/bauh{}/web'.format('_root' if user.is_root() else '') TEMP_PATH = '{}/web'.format(TEMP_DIR)
SEARCH_INDEX_FILE = '{}/index.yml'.format(TEMP_PATH) SEARCH_INDEX_FILE = '{}/index.yml'.format(TEMP_PATH)
SUGGESTIONS_CACHE_FILE = '{}/suggestions.txt'.format(TEMP_PATH) SUGGESTIONS_CACHE_FILE = '{}/suggestions.txt'.format(TEMP_PATH)
CONFIG_FILE = '{}/web.yml'.format(CONFIG_PATH) CONFIG_FILE = '{}/web.yml'.format(CONFIG_PATH)

View File

@@ -16,6 +16,7 @@ from bauh.api.abstract.view import MessageType
from bauh.api.http import HttpClient from bauh.api.http import HttpClient
from bauh.commons import user from bauh.commons import user
from bauh.commons.html import bold from bauh.commons.html import bold
from bauh.gems.web import TEMP_PATH
from bauh.view.qt import dialog, commons, qt_utils, root from bauh.view.qt import dialog, commons, qt_utils, root
from bauh.view.qt.about import AboutDialog from bauh.view.qt.about import AboutDialog
from bauh.view.qt.apps_table import AppsTable, UpdateToggleButton from bauh.view.qt.apps_table import AppsTable, UpdateToggleButton
@@ -1113,7 +1114,7 @@ class ManageWindow(QWidget):
console_output = self.textarea_output.toPlainText() console_output = self.textarea_output.toPlainText()
if console_output: if console_output:
log_path = '/tmp/bauh/logs/install/{}/{}'.format(res['pkg'].model.get_type(), res['pkg'].model.name) log_path = '{}/logs/install/{}/{}'.format(TEMP_PATH, res['pkg'].model.get_type(), res['pkg'].model.name)
try: try:
Path(log_path).mkdir(parents=True, exist_ok=True) Path(log_path).mkdir(parents=True, exist_ok=True)