termux / termux-boot

Termux add-on app allowing programs to be run at boot.
https://f-droid.org/en/packages/com.termux.boot
931 stars 219 forks source link

sshd example not actually running at boot #55

Closed mike-lawrence closed 3 years ago

mike-lawrence commented 3 years ago

Steps to reproduce

  1. install termux from f-droid
  2. launch termux and install openssh via pkg install openssh
  3. set passwd and start the ssh daemon via sshd
  4. confirm that another computer on the LAN can ssh -p 8022 IP
  5. while connected via ssh, run:
    mkdir -p .termux/boot 
    echo -e '#!/data/data/com.termux/files/usr/bin/sh \n termux-wake-lock \n sshd' > .termux/boot/start-sshd
    chmod +x .termux/boot/start-sshd
  6. exit ssh, and go back to device
  7. install termux:boot from f-droid
  8. launch termux:boot
  9. reboot device
  10. observe that even after several minutes, the device is still not accessible via ssh.
  11. lauch termux and confirm that running .termux/boot/start-sshd renders the device accessible via ssh

Expected behavior Device accessible via SSH at boot

Additional information

Grimler91 commented 3 years ago

What does a logcat say?

mike-lawrence commented 3 years ago

Here's logcat after a fresh boot, launching termux to start sshd and logging in remotely:

--------- beginning of main
01-06 10:21:46.905  3383  3383 E com.termux: Not starting debugger since process cannot load the jdwp agent.
01-06 10:21:47.047  3383  3383 W SoundPoolThread: type=1400 audit(0.0:65): avc: denied { read } for name="u:object_r:media_prop:s0" dev="tmpfs" ino=13382 scontext=u:r:untrusted_app:s0:c110,c256,c512,c768 tcontext=u:object_r:media_prop:s0 tclass=file permissive=0
01-06 10:21:47.050  3383  3405 E libc    : Access denied finding property "media.stagefright.extractremote"
01-06 10:21:47.053  3383  3383 D LongScreenshotUtil: register longscreenshotReceiver
01-06 10:21:47.054  3383  3383 D OpenGLRenderer: Skia GL Pipeline
01-06 10:21:47.062  3383  3383 D OpenGLRenderer: textureCacheSize 75497472
01-06 10:21:47.080  3383  3405 D MediaCodec: app porc_name:com.termux mime:audio/vorbis
01-06 10:21:47.088  3383  3432 I MediaCodec: app porc_name:com.termux
01-06 10:21:47.094  3383  3432 I OMXClient: IOmx service obtained
01-06 10:21:47.193  3383  3430 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
01-06 10:21:47.194  3383  3430 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
01-06 10:21:47.194  3383  3430 I OpenGLRenderer: Initialized EGL, version 1.4
01-06 10:21:47.194  3383  3430 D OpenGLRenderer: Swap behavior 2
01-06 10:21:47.206  3383  3432 I ACodec  : 0x7aa9c187e0 err = 0 ExecutingToIdleState sendCommand OMX_CommandStateSet OMX_StateLoaded
01-06 10:21:47.207  3383  3383 W SoundPoolThread: type=1400 audit(0.0:66): avc: denied { read } for name="u:object_r:media_prop:s0" dev="tmpfs" ino=13382 scontext=u:r:untrusted_app:s0:c110,c256,c512,c768 tcontext=u:object_r:media_prop:s0 tclass=file permissive=0
01-06 10:21:47.212  3383  3430 I OpenGLRenderer: queryNativeWindowStatus 0x7aa6887010 query=0 dataspace=0
01-06 10:21:47.213  3383  3405 E libc    : Access denied finding property "media.metrics.enabled"
01-06 10:21:47.216  3383  3393 I com.termux: Background concurrent copying GC freed 8660(2MB) AllocSpace objects, 6(116KB) LOS objects, 51% free, 1458KB/2MB, paused 6.916ms total 84.848ms
01-06 10:21:47.226  3383  3405 W ACodec  : report data to the sprdssense service,---stop
01-06 10:21:47.416  3383  3430 D         : Gralloc Register  w:1200, h:1920, f:0x1101, usage:0xb00, ui64Stamp:1540, sSize:9236480, line = 2106
01-06 10:21:47.507  3383  3430 D OpenGLRenderer: textureCacheSize 75497472
01-06 10:21:47.594  3383  3430 D         : Gralloc Register  w:1200, h:1920, f:0x1101, usage:0xb00, ui64Stamp:1563, sSize:9236480, line = 2106
01-06 10:21:47.630  3383  3430 I OpenGLRenderer: queryNativeWindowStatus 0x7aa69cd010 query=0 dataspace=0
01-06 10:21:47.633  3383  3430 D OpenGLRenderer: textureCacheSize 75497472
01-06 10:21:47.636  3383  3430 D         : Gralloc Register  w:1200, h:1920, f:0x1101, usage:0xb00, ui64Stamp:1582, sSize:9236480, line = 2106
01-06 10:21:47.646  3383  3430 D         : Gralloc Register  w:86, h:112, f:0x1101, usage:0xb00, ui64Stamp:1586, sSize:45056, line = 2106
01-06 10:21:47.658  3383  3430 D         : Gralloc Register  w:86, h:112, f:0x1101, usage:0xb00, ui64Stamp:1596, sSize:45056, line = 2106
01-06 10:21:49.338  3383  3430 D         : Gralloc UnRegister  w:86, h:112, f:0x1101, usage:0xb00, ui64Stamp:1596 line = 2218
01-06 10:21:49.338  3383  3430 D         : Gralloc UnRegister  w:86, h:112, f:0x1101, usage:0xb00, ui64Stamp:1586 line = 2218
01-06 10:21:53.482  3761  3761 I sshd    : Server listening on :: port 8022.
01-06 10:21:53.482  3761  3761 I sshd    : Server listening on 0.0.0.0 port 8022.
01-06 10:21:58.087  3922  3922 I /data/data/com.termux/files/usr/bin/sshd: Accepted password for mike from 192.168.2.10 port 41898 ssh2
mike-lawrence commented 3 years ago

If I run just termux-wake-lock then logcat I see this entry:

01-06 10:43:49.966  6688  6688 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10110 <<<<<<
01-06 10:43:50.153  6688  6688 D AndroidRuntime: Calling main entry com.termux.termuxam.Am
01-06 10:43:50.188  6688  6688 D AndroidRuntime: Shutting down VM
mike-lawrence commented 3 years ago

Got it working!! I needed to go in and turn off all battery optimizations for termux and termux:boot. Sorry for my naïveté!

ghost commented 3 years ago

I needed to go in and turn off all battery optimizations for termux and termux:boot.

Thanks for the information, Termux Wiki page has been updated.