Commit Graph

10 Commits

Author SHA1 Message Date
Leonid Pliushch
dc14c12940 apt: prevent usage of certain commands as root
Usage of package manager as root has certain bad effects in Termux such as
messed up SELinux contexts and ownership. Root checks done in 'pkg' wrapper
are not reliable because one can execute 'apt' directly or with third-party
script downloaded from the Internet.

This commit adds user id check and if it found that uid is 0, apt will
refuse to do any work in root session. These checks done in such way so
they cannot be bypassed in any way unless command is executed as non-root
user.

Those who use Termux via ADB root shell should be able to switch to Termux
user id with command 'su' in order to have package manager working.

---

This change also affects the 'termux-info' utility:

 * It will no longer use 'apt policy' to detect subscribed repositories. Each
   source will be checked by script manually.

 * Information will be copied to clipboard only if 'termux-api' is installed.

 * Syntax error in timeout command is fixed: 'timeout' doesn't understand the
   argument '-t'.

 * Minor information entries reordering.
2019-11-13 16:38:40 +02:00
Efreak
63733da336 Don't run apt update if it's been run recently (#4135)
When installing or searching for packages, the `apt update` will run only if it
was not executed within the last 5 minutes. Command `pkg upgrade` will
always execute `apt update` to ensure that latest package versions were
picked during upgrade.
2019-11-10 16:29:05 +02:00
Leonid Pliushch
51cdbe0073 termux-tools: use default shebang in sources
This will allow build system to set shebang according to the
current TERMUX_PREFIX.
2019-09-19 23:41:31 +03:00
Leonid Pliushch
2e28a119ef termux-tools: prevent word-splitting of arguments with space 2019-05-06 23:22:47 +03:00
Leonid Pliushch
14e3026432 termux-tools: handle arguments for "pkg upgrade"
Fix for https://github.com/termux/termux-packages/issues/3758.
2019-05-06 23:21:38 +03:00
Guillermo Robles
78fc1f2328 Correct support of remove command in pkg
Fixes #3681
2019-04-16 17:59:53 +02:00
Jonas L
50e0cb6a8b Add root check to pkg
This prevents users from using "su pkg ..." which breaks permissions
2018-06-13 01:34:48 +02:00
Oliver Schmidhauser
9e77a1160e packages->pkg in help text (#1599)
* packages->pkg in help text

* Fix pkg at a second placec
2017-10-01 21:42:37 +02:00
Fredrik Fornwall
207314894d termux-tools: Add 'pkg add' as alias install 2017-06-13 16:32:24 +02:00
Fredrik Fornwall
700ecf0fbc Use 'pkg' as shorter form of 'packages'
Fixes https://github.com/termux/termux-app/issues/321.
2017-06-12 03:01:09 +02:00