Starting developer mode on USB connection without unlocking
I would like to be able just connect jolla via USB to my desktop PC and have all jolla files at hand on PC. Right now it almost works:
- "Default USB mode" is set to "Developer mode";
- Whenever PC notices USB connection from Jolla it mounts jolla FS via sshfs
But pretty often manual interaction is required as developer mode does not start while the device is locked.
Is it possible to make developer mode start regardless of locked state? It really does not make much sense to add extra protection as SSH connection requires at least providing proper password.
Solution
USB behaviour is controlled by usb_moded
daemon. According to documentation
When started with -r usb_moded will always enable developer mode (networking) if it can. This is a debug feature and should not be used in production software.
Looks exactly as what I looked for! So how do we force this daemon to run with -r
flag? Service unit file contains following config:
$ grep -FA10 '[Service]' /lib/systemd/system/usb-moded.service
[Service]
Type=notify
TimeoutSec=15
EnvironmentFile=-/var/lib/environment/usb-moded/*.conf
EnvironmentFile=-/run/usb-moded/*.conf
ExecStart=/usr/sbin/usb_moded --systemd --force-syslog $USB_MODED_ARGS
Restart=always
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=basic.target
I decided to create environment file:
$ cat /var/lib/environment/usb-moded/alwaysdevmode.conf
USB_MODED_ARGS=-r
And of course restart daemon with new environment # systemctl daemon-reload && systemctl restart usb-moded.service
And now my Jolla always starts developer USB mode right after attaching to USB port regardless of whether it locked or not. Problem solved :)
Update 2017-06-03: Since SailfishOS 2.1.0.11 (Iijoki) my solution no longer works :(
The extra protection is there to avoid attacks like those : https://github.com/ud2/advisories/tree/master/android/samsung/nocve-2016-0004
Philippe De Swert ( 2016-04-14 13:46:56 +0200 )edit