coreutils: date: don't fail with 'Bad system call' on settime

Notify user that only root can modify system time.
This commit is contained in:
Leonid Pliushch 2021-07-30 18:09:15 +03:00
parent f7045ad7c5
commit a47d342818
No known key found for this signature in database
GPG Key ID: 45F2964132545795
2 changed files with 15 additions and 1 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Basic file, shell and text manipulation utilities from t
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=8.32
TERMUX_PKG_REVISION=7
TERMUX_PKG_REVISION=8
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/coreutils/coreutils-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=4458d8de7849df44ccab15e16b1548b285224dbba5f08fac070c1c0e0bcc4cfa
TERMUX_PKG_DEPENDS="libandroid-support, libgmp, libiconv"

View File

@ -0,0 +1,14 @@
diff -uNr coreutils-8.32/src/date.c coreutils-8.32.mod/src/date.c
--- coreutils-8.32/src/date.c 2020-01-01 16:13:12.000000000 +0200
+++ coreutils-8.32.mod/src/date.c 2021-07-30 17:57:00.571867917 +0300
@@ -559,6 +559,10 @@
if (set_date)
{
+ if (getuid() != 0)
+ {
+ die (EXIT_FAILURE, 0, "only root user can change date/time");
+ }
/* Set the system clock to the specified date, then regardless of
the success of that operation, format and print that date. */
if (settime (&when) != 0)