fix(main/nala): prevent usage as root

Same as for apt: package manager usage as root messes up ownership and
SELinux labels which breaks the environment.
This commit is contained in:
Leonid Pliushch 2023-12-15 10:51:58 +02:00
parent a9ae7271ee
commit 6cdcf81823
No known key found for this signature in database
GPG Key ID: 802AB1B71153CBC4
2 changed files with 23 additions and 0 deletions

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Commandline frontend for the apt package manager"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="0.14.0"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://gitlab.com/volian/nala/-/archive/v${TERMUX_PKG_VERSION}/nala-v${TERMUX_PKG_VERSION}.tar.bz2
TERMUX_PKG_SHA256=e9309f3aa269ec274c1250e34c4f7596395a38a90b40ec77d43d09bbbe8dffcf
TERMUX_PKG_DEPENDS="python-apt, python-pip"

View File

@ -0,0 +1,22 @@
diff -uNr nala-v0.14.0/nala/__main__.py nala-v0.14.0.mod/nala/__main__.py
--- nala-v0.14.0/nala/__main__.py 2023-10-11 04:12:17.000000000 +0300
+++ nala-v0.14.0.mod/nala/__main__.py 2023-12-15 10:50:56.463044169 +0200
@@ -26,6 +26,7 @@
import errno
import sys
+import os
# Imports to get all of the subcommands into typer
import nala.fetch as _fetch # pylint: disable=unused-import
@@ -38,6 +39,10 @@
def main() -> None:
"""Nala function to reference from the entry point."""
+ if os.getuid() == 0:
+ print("Ability to run this command as root has been disabled permanently for safety purposes.")
+ sys.exit(1)
+
try:
nala()
except KeyboardInterrupt: