]> git.eshelyaron.com Git - emacs.git/commitdiff
Disable process tracing before launching /system/bin/su
authorPo Lu <luangruo@yahoo.com>
Tue, 27 Feb 2024 02:05:56 +0000 (10:05 +0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 28 Feb 2024 17:53:25 +0000 (18:53 +0100)
* lisp/net/tramp-androidsu.el
(tramp-androidsu-maybe-open-connection): Disable process tracing
around start-process, that the setuid su binary may be started
regardless of its status.

(cherry picked from commit 32b4f9d21b14190f1ed1611515751abe4b90fa68)

lisp/net/tramp-androidsu.el

index 06800205f2e46d790ef5469614cb05e3aad0c5bc..cf6b0d7202c91ba6f5c37c735a3e951fb6ee66d6 100644 (file)
@@ -55,6 +55,8 @@
  (add-to-list 'tramp-default-host-alist
               `(,tramp-androidsu-method nil "localhost")))
 
+(defvar android-use-exec-loader) ; androidfns.c.
+
 (defun tramp-androidsu-maybe-open-connection (vec)
   "Open a connection VEC if not already open.
 Mostly identical to `tramp-adb-maybe-open-connection', but also disables
@@ -84,14 +86,17 @@ multibyte mode and waits for the shell prompt to appear."
                          (tramp-file-name-method vec)))
               (let* ((coding-system-for-read 'utf-8-unix)
                      (process-connection-type tramp-process-connection-type)
-                    (p (apply
-                        #'start-process
-                        (tramp-get-connection-name vec)
-                        (tramp-get-connection-buffer vec)
-                        (append
-                         `(,tramp-encoding-shell)
-                         (and tramp-encoding-command-interactive
-                              `(,tramp-encoding-command-interactive)))))
+                     ;; The executable loader cannot execute setuid
+                     ;; binaries, such as su.
+                     (android-use-exec-loader nil)
+                    (p (start-process (tramp-get-connection-name vec)
+                                      (tramp-get-connection-buffer vec)
+                                       ;; Disregard
+                                       ;; tramp-encoding-shell, as
+                                       ;; there's no guarantee that it's
+                                       ;; possible to execute with
+                                       ;; `android-use-exec-loader' off.
+                                      "/system/bin/sh" "-i"))
                     (user (tramp-file-name-user vec))
                      command)
                 ;; Set sentinel.  Initialize variables.