From: Lucien Cartier-Tilet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 53026@debbugs.gnu.org
Subject: bug#53026: 27.2; (battery) errors in Android app Termux
Date: Wed, 05 Jan 2022 15:08:33 +0100 [thread overview]
Message-ID: <871r1mxlpo.fsf@phundrak.com> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 4386 bytes --]
In the Termux application on Android, evaluating `(battery)' results in
an error due to `/sys/' not being readable on non-rooted phones.
Steps to reproduce:
1. In termux, install Emacs with `pkg install emacs'.
2. Launch Emacs with `emacs -Q'
3. In the `*scratch*' buffer, type and evaluate `(battery)'
4. The expected output due to `/sys/' being unreadable should be the
text `Battery status not available', however it errors with the
attached backtrace.
I made a patch I attached to this message in an attempt to prevent
this issue, but I have not had the time to test it yet on my own
phone. It is made from the current `master' branch.
Text automatically generated by Emacs on Termux using
`report-emacs-bug':
In GNU Emacs 27.2 (build 1, aarch64-unknown-linux-android)
of 2022-01-05 built on localhost
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Entering debugger...
Making completion list...
Configured using:
'configure --disable-dependency-tracking
--prefix=/data/data/com.termux/files/usr
--libdir=/data/data/com.termux/files/usr/lib
--sbindir=/data/data/com.termux/files/usr/bin --disable-rpath
--disable-rpath-hack --host=aarch64-linux-android --disable-autodepend
--with-gif=no --with-gnutls --with-jpeg=no --without-gconf
--without-gsettings --without-lcms2 --without-x --with-png=no
--with-tiff=no --with-xml2 --with-xpm=no --without-dbus
--without-selinux --with-modules --with-pdumper=yes --with-dumping=none
emacs_cv_sanitize_address=yes emacs_cv_prog_cc_no_pie=no
ac_cv_lib_elf_elf_begin=no gl_cv_func_dup2_works=no
ac_cv_func_setrlimit=no --disable-nls --enable-shared --enable-static
--libexecdir=/data/data/com.termux/files/usr/libexec 'CFLAGS=
-fstack-protector-strong -Oz' 'CPPFLAGS=
-I/data/data/com.termux/files/usr/include'
'LDFLAGS=-L/data/data/com.termux/files/usr/lib
-Wl,-rpath=/data/data/com.termux/files/usr/lib -fopenmp -static-openmp
-Wl,--enable-new-dtags -Wl,--as-needed -Wl,-z,relro,-z,now''
Configured features:
NOTIFY INOTIFY GNUTLS LIBXML2 ZLIB MODULES THREADS PDUMPER GMP
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix:
Major mode: Debugger
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow regexp-opt sort mail-extr emacsbug message rmc puny dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail tool-bar rmail-loaddefs
text-property-search time-date subr-x seq mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-fns radix-tree
cl-print debug backtrace help-mode easymenu find-func cl-loaddefs cl-lib
term/xterm xterm byte-opt gv bytecomp byte-compile cconv tooltip eldoc
electric uniquify ediff-hook vc-hooks lisp-float-type tabulated-list
replace newcomment text-mode elisp-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch timer select mouse jit-lock
font-lock syntax facemenu font-core term/tty-colors frame minibuffer
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese composite
charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev
obarray cl-preloaded nadvice loaddefs button faces cus-face macroexp
files text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads inotify
multi-tty make-network-process emacs)
Memory information:
((conses 16 56686 6907)
(symbols 48 6421 1)
(strings 32 17408 1595)
(string-bytes 1 567066)
(vectors 16 8161)
(vector-slots 8 90784 8674)
(floats 8 29 697)
(intervals 56 728 124)
(buffers 1000 13))
--
Lucien “Phundrak” Cartier-Tilet
<https://phundrak.com> (Français)
<https://phundrak.com/en> (English)
Sent from GNU/Emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-lisp-battery.el-battery-status-function-Fix-errors-i.patch --]
[-- Type: text/x-patch, Size: 1288 bytes --]
From a6ea372e02c5f8e583ea216743cf238854a8fc90 Mon Sep 17 00:00:00 2001
From: Lucien Cartier-Tilet <lucien@phundrak.com>
Date: Wed, 5 Jan 2022 15:59:33 +0100
Subject: [PATCH] ; * lisp/battery.el (battery-status-function) Fix errors in
Termux
In Termux, neither /sys/ or /proc/ are readable on phones that are not
rooted. This patch makes Emacs verify if they are readable before it
attemps reading them.
---
lisp/battery.el | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lisp/battery.el b/lisp/battery.el
index 45334163fa..b7b81a11a1 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -96,12 +96,14 @@ Value does not include \".\" or \"..\"."
(cond ((member battery-upower-service (dbus-list-activatable-names))
#'battery-upower)
((and (eq system-type 'gnu/linux)
+ (file-readable-p "/sys/")
(battery--find-linux-sysfs-batteries))
#'battery-linux-sysfs)
((and (eq system-type 'gnu/linux)
(file-directory-p "/proc/acpi/battery"))
#'battery-linux-proc-acpi)
((and (eq system-type 'gnu/linux)
+ (file-readable-p "/proc/")
(file-readable-p "/proc/apm"))
#'battery-linux-proc-apm)
((and (eq system-type 'berkeley-unix)
--
2.34.1
[-- Attachment #1.1.3: backtrace --]
[-- Type: text/plain, Size: 4328 bytes --]
Debugger entered--Lisp error: (file-error "Opening directory" "Permission denied" "/sys/class/power_supply")
directory-files("/sys/class/power_supply/" t)
battery--find-linux-sysfs-batteries()
(and (eq system-type 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries))
(cond ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (condition-case nil (with-temp-buffer (and (eq (call-process "pmset" nil t nil "-g" "ps") 0) (> (buffer-size) 0))) (error nil))) #'battery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status))
eval((cond ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (condition-case nil (with-temp-buffer (and (eq ... 0) (> ... 0))) (error nil))) #'battery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status)))
custom-initialize-reset(battery-status-function (cond ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (condition-case nil (with-temp-buffer (and (eq ... 0) (> ... 0))) (error nil))) #'battery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status)))
custom-declare-variable(battery-status-function (cond ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (condition-case nil (with-temp-buffer (and (eq ... 0) (> ... 0))) (error nil))) #'battery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status)) "Function for getting battery status information.\nT..." :type (choice (const nil) function) :group battery)
byte-code("\300\301\302\303\304\305\306\307&\7\210\300\310\311\312\304\313\306\307&\7\207" [custom-declare-variable battery-status-function (cond ((and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (condition-case nil (with-temp-buffer (and ... ...)) (error nil))) #'battery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status)) "Function for getting battery status information.\nT..." :type (choice (const nil) function) :group battery battery-echo-area-format "Power %L, battery %B (%p%% load, remaining time %t..." "Control string formatting the string to display in..." (choice string (const nil))] 8)
(battery)
(progn (battery))
eval((progn (battery)) t)
elisp--eval-last-sexp(nil)
eval-last-sexp(nil)
funcall-interactively(eval-last-sexp nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]
next reply other threads:[~2022-01-05 14:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-05 14:08 Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-01-14 8:18 ` bug#53026: 27.2; (battery) errors in Android app Termux Lars Ingebrigtsen
2022-01-14 8:35 ` Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-14 8:53 ` Lars Ingebrigtsen
2022-01-14 9:02 ` Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871r1mxlpo.fsf@phundrak.com \
--to=bug-gnu-emacs@gnu.org \
--cc=53026@debbugs.gnu.org \
--cc=lucien@phundrak.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).