unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53026: 27.2; (battery) errors in Android app Termux
@ 2022-01-05 14:08 Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-01-14  8:18 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-05 14:08 UTC (permalink / raw)
  To: 53026


[-- 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 --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#53026: 27.2; (battery) errors in Android app Termux
  2022-01-05 14:08 bug#53026: 27.2; (battery) errors in Android app Termux Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-01-14  8:18 ` Lars Ingebrigtsen
  2022-01-14  8:35   ` Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-14  8:18 UTC (permalink / raw)
  To: Lucien Cartier-Tilet; +Cc: 53026

Lucien Cartier-Tilet <lucien@phundrak.com> writes:

> 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.

The patch makes sense to me, so I've applied it to Emacs 29.

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#53026: 27.2; (battery) errors in Android app Termux
  2022-01-14  8:18 ` 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
  0 siblings, 1 reply; 5+ messages in thread
From: Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-14  8:35 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53026


[-- Attachment #1.1.1: Type: text/plain, Size: 544 bytes --]

> The patch makes sense to me, so I've applied it to Emacs 29.

Great, thank you!

> This change was small enough to apply without assigning copyright to the
> FSF, but for future patches you want to submit, it might make sense to
> get the paperwork started now, so that subsequent patches can be applied
> speedily. Would you be willing to sign such paperwork?

Of course, where should I begin?

--
Lucien “Phundrak” Cartier-Tilet
<https://phundrak.com> (Français)
<https://phundrak.com/en> (English)
Sent from GNU/Emacs

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#53026: 27.2; (battery) errors in Android app Termux
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-14  8:53 UTC (permalink / raw)
  To: Lucien Cartier-Tilet; +Cc: 53026

Lucien Cartier-Tilet <lucien@phundrak.com> writes:

> Of course, where should I begin?

Great; here's the form to get started:


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]
Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]

[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]

[For the copyright registration, what country are you a citizen of?]

[What year were you born?]

[Please write your email address here.]

[Please write your postal address here.]

[Which files have you changed so far, and which new files have you written
so far?]





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#53026: 27.2; (battery) errors in Android app Termux
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-01-14  9:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53026


[-- Attachment #1.1.1: Type: text/plain, Size: 359 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Please email the following information to assign@gnu.org, and we
> will send you the assignment form for your past and future changes.
> […]

Thanks, I sent the email

--
Lucien “Phundrak” Cartier-Tilet
<https://phundrak.com> (Français)
<https://phundrak.com/en> (English)
Sent from GNU/Emacs

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-14  9:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 14:08 bug#53026: 27.2; (battery) errors in Android app Termux Lucien Cartier-Tilet via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-14  8:18 ` 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

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).