From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lucien Cartier-Tilet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#53026: 27.2; (battery) errors in Android app Termux Date: Wed, 05 Jan 2022 15:08:33 +0100 Message-ID: <871r1mxlpo.fsf@phundrak.com> Reply-To: Lucien Cartier-Tilet Mime-Version: 1.0 Content-Type: multipart/signed; boundary="===-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="583"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 29.0.50 To: 53026@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 05 16:57:48 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n58fb-000AYJ-IZ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 16:57:47 +0100 Original-Received: from localhost ([::1]:42222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n58fa-0008Cs-KM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 10:57:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n58et-0008Ac-AC for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:57:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58236) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n58et-0008HX-0z for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:57:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n58et-0007uo-0m for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:57:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lucien Cartier-Tilet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Jan 2022 15:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 53026 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.164139819030298 (code B ref -1); Wed, 05 Jan 2022 15:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Jan 2022 15:56:30 +0000 Original-Received: from localhost ([127.0.0.1]:41528 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n58eM-0007sc-6O for submit@debbugs.gnu.org; Wed, 05 Jan 2022 10:56:30 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:54822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n583M-0006o2-No for submit@debbugs.gnu.org; Wed, 05 Jan 2022 10:18:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n583M-0000WG-Iv for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:18:16 -0500 Original-Received: from 105.ip-51-83-47.eu ([51.83.47.105]:40808 helo=mail.phundrak.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n583K-0007I3-Ci for bug-gnu-emacs@gnu.org; Wed, 05 Jan 2022 10:18:16 -0500 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3A558C0F29 for ; Wed, 5 Jan 2022 16:10:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=phundrak.com; s=dkim; t=1641395415; h=from:subject:date:message-id:to:mime-version:content-type; bh=F7aO0hZOx8Uc20rMluU6xqCSe2JF3Xa/NfalNfc8Mew=; b=TcIPZAXgivShC22iI5DMcN+4RsqZRhbZeSthrmeIEd5OXEBeHBPNyzy0bgX8HqJxMtu9kU Wo/GUjXkOm9gPGRwEEicyXOTAWpyxxd8U1LFITpuTqda3jjrnZZGG2G4M1R8/bIQXaSGF3 8LEyptIXeca2++U327wF6zjVR9Cx3Qs= X-Last-TLS-Session-Version: TLSv1.3 Received-SPF: pass client-ip=51.83.47.105; envelope-from=lucien@phundrak.com; helo=mail.phundrak.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_RDNS_DYNAMIC_FP=0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 05 Jan 2022 10:56:29 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223697 Archived-At: --===-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: multipart/mixed; boundary="==-=-=" --==-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=3D/data/data/com.termux/files/usr --libdir=3D/data/data/com.termux/files/usr/lib --sbindir=3D/data/data/com.termux/files/usr/bin --disable-rpath --disable-rpath-hack --host=3Daarch64-linux-android --disable-autodepend --with-gif=3Dno --with-gnutls --with-jpeg=3Dno --without-gconf --without-gsettings --without-lcms2 --without-x --with-png=3Dno --with-tiff=3Dno --with-xml2 --with-xpm=3Dno --without-dbus --without-selinux --with-modules --with-pdumper=3Dyes --with-dumping=3Dnone emacs_cv_sanitize_address=3Dyes emacs_cv_prog_cc_no_pie=3Dno ac_cv_lib_elf_elf_begin=3Dno gl_cv_func_dup2_works=3Dno ac_cv_func_setrlimit=3Dno --disable-nls --enable-shared --enable-static --libexecdir=3D/data/data/com.termux/files/usr/libexec 'CFLAGS=3D -fstack-protector-strong -Oz' 'CPPFLAGS=3D -I/data/data/com.termux/files/usr/include' 'LDFLAGS=3D-L/data/data/com.termux/files/usr/lib -Wl,-rpath=3D/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)) =2D- Lucien =E2=80=9CPhundrak=E2=80=9D Cartier-Tilet (Fran=C3=A7ais) (English) Sent from GNU/Emacs --==-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-battery.el-battery-status-function-Fix-errors-i.patch Content-Transfer-Encoding: quoted-printable From=20a6ea372e02c5f8e583ea216743cf238854a8fc90 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet 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. =2D-- lisp/battery.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/battery.el b/lisp/battery.el index 45334163fa..b7b81a11a1 100644 =2D-- 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) =2D-=20 2.34.1 --==-=-= Content-Type: text/plain Content-Disposition: attachment; filename=backtrace Content-Transfer-Encoding: quoted-printable Debugger entered--Lisp error: (file-error "Opening directory" "Permission d= enied" "/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_supp= ly/") (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 'g= nu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find-linu= x-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-= unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (eq sys= tem-type 'darwin) (condition-case nil (with-temp-buffer (and (eq (call-proc= ess "pmset" nil t nil "-g" "ps") 0) (> (buffer-size) 0))) (error nil))) #'b= attery-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-direct= ory-p "/proc/acpi/battery")) #'battery-linux-proc-acpi) ((and (eq system-ty= pe 'gnu/linux) (file-directory-p "/sys/class/power_supply/") (battery--find= -linux-sysfs-batteries)) #'battery-linux-sysfs) ((and (eq system-type 'berk= eley-unix) (file-executable-p "/usr/sbin/apm")) #'battery-bsd-apm) ((and (e= q 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-ty= pe 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((a= nd (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'b= attery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p= "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'batte= ry-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/= usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (conditio= n-case nil (with-temp-buffer (and (eq ... 0) (> ... 0))) (error nil))) #'ba= ttery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status))) custom-declare-variable(battery-status-function (cond ((and (eq system-ty= pe 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-linux-proc-apm) ((a= nd (eq system-type 'gnu/linux) (file-directory-p "/proc/acpi/battery")) #'b= attery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) (file-directory-p= "/sys/class/power_supply/") (battery--find-linux-sysfs-batteries)) #'batte= ry-linux-sysfs) ((and (eq system-type 'berkeley-unix) (file-executable-p "/= usr/sbin/apm")) #'battery-bsd-apm) ((and (eq system-type 'darwin) (conditio= n-case nil (with-temp-buffer (and (eq ... 0) (> ... 0))) (error nil))) #'ba= ttery-pmset) ((fboundp 'w32-battery-status) #'w32-battery-status)) "Functio= n 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\31= 3\306\307&\7\207" [custom-declare-variable battery-status-function (cond ((= and (eq system-type 'gnu/linux) (file-readable-p "/proc/apm")) #'battery-li= nux-proc-apm) ((and (eq system-type 'gnu/linux) (file-directory-p "/proc/ac= pi/battery")) #'battery-linux-proc-acpi) ((and (eq system-type 'gnu/linux) = (file-directory-p "/sys/class/power_supply/") (battery--find-linux-sysfs-ba= tteries)) #'battery-linux-sysfs) ((and (eq system-type 'berkeley-unix) (fil= e-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)) "Fun= ction for getting battery status information.\nT..." :type (choice (const n= il) 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) --==-=-=-- --=-=-=-- --===-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCAAyFiEEViv9D3b9mE+uAC3AvXeJ5wXLjcoFAmHVtNMUHGx1Y2llbkBw aHVuZHJhay5jb20ACgkQvXeJ5wXLjcq9Yg/+Ks8H6YoywApt1sXjzMGuJZNW3/oA juX7G+2QkdAdaaTmVpPbgU7LbKm5YXiA3jHukn/W8B8sSSh6vQJRzCQz82p+p+xH eIdgvqm5Cb70q+J7P1vBzUylb6Q9UzCpzdKZ1R8DXTEY7Vnpv4WKaaX0J170yev3 x+oWGoOMMV3CMavbD4/bB87e5Qu/Oo2i5JuofFyJ9L2H/tYjlixlYTjdTSX/pXW4 iJu7meFZylK6XnShC9T+4He+ieKAIBIM5HCkbhIXGq8FGt2fc6yk4PYqEfU2DfkB 0xJfmewH8h801hSfT4B44OIA1BHESDaJJnpy4HbBKteT9bhXRNzlbTKi42/fPWzm VDsvz4gzYkhKoIRjJBm7Q4HQDBD9KejaYCOeZkezUvHUySXXX3JakQBoqCUKeJp9 2Llg54CjjkTNSfG6y6Y+HqZ3Was1r6yUIBpHdk17Frku5ScjY+O6ZmIy320706Ra fHD9kof55eE8088XRw1KUgyUDuCum1S78xiVnq3UlvEbOv7BA3kmaEyU+fpXZ6y7 r+JVpqn/KdDPxJRULHkZUMCjv4+6q8/s2k2D4FUcmiYMJGjIOC1/c4G3boUcCaIi VdI/OAZ9mQBp0iSnFOC+jsGue3cHxvfD29sJXHM9lWmWCUpaMcrVykZuPtW3REjs a887XbB9blxPxfE= =Itjm -----END PGP SIGNATURE----- --===-=-=--