We have moved to a new Sailfish OS Forum. Please start new discussions there.
4

Starting developer mode on USB connection without unlocking

asked 2015-11-09 15:07:36 +0300

Self-Perfection gravatar image

updated 2017-08-08 18:52:03 +0300

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:

  1. "Default USB mode" is set to "Developer mode";
  2. 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 :(

edit retag flag offensive close delete

Comments

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 +0300 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2015-11-09 15:25:34 +0300

coderus gravatar image

Yes you need to unlock device every time before inserting usb cable.

edit flag offensive delete publish link more

Comments

Suppose I'm not afraid of writing custom udev rules.

For instance I could probably hook detection of power supply and trigger custom shell script to manually setup rndis0 interface. This is crude and cumbersome, but should work.

I'd like to find more straightforward solution. What's the proper way to intercept USB connection? How can i trigger manually starting developer mode instead of implementing it myself?

Self-Perfection ( 2015-11-09 16:36:02 +0300 )edit

And by the way order if cable insertion and device unlocking does not matter. Unlocking after cable insertion starts dev. mode as well.

Self-Perfection ( 2015-11-09 16:41:57 +0300 )edit
1

devmode is not a process to start and stop it. you talking about ssh so check it.

coderus ( 2015-11-09 16:43:12 +0300 )edit
1

Nope. SSH socket is available all the time while devel "Remote connection" is ticked in "Developer mode" settings. E.g. I can always connect via Wi-Fi.

The problem is that usb network interface (rndis0) on jolla does not even exist until device is unlocked. And this is a tricky part.

Self-Perfection ( 2015-11-09 17:32:56 +0300 )edit
0

answered 2016-03-06 09:32:51 +0300

coderus gravatar image
pkcon install usb-moded-systemd-rescue-mode

is just for you :)

edit flag offensive delete publish link more

Comments

I gave it a shot and it does not work for me. I've installed package, rebooted the phone, waited until it boots to "locked" screen, attached to USB and usbnet has not appeared. And I'll tell you why:

$ rpm -ql usb-moded-systemd-rescue-mode
/lib/systemd/system/graphical.target.wants/usb-rescue-mode-off.service
/lib/systemd/system/usb-rescue-mode-off.service
/usr/bin/turn-usb-rescue-mode-off
/var/lib/environment/usb-moded/usb-moded-args.conf

Why does it starts usb-rescue-mode-off.service in graphical.target hereby disabling what I need right after boot? What is the purpose of this package?

As an offtopic, @coderus you are cool, you have made bunch of cool apps for SFOS, you definitely know a lot about SFOS entrails and I've seen many enlightening answers from you to other SFOS users issues. But somehow not a single answer from you to me was useful/appropriate/correct. I am astonished. It looks like you try to help but it always turns out to be a shot in the dark. Is it s startling coincidence or do you by any chance hate me?

Self-Perfection ( 2016-03-06 11:42:03 +0300 )edit
1

because it's rescue. it allow you to conenct usb first and then turn on device and you will get networking before device boots, in case something wrong or lockscreen not loading, and if device booted correctly it exiting recue mode and let you to choose usb mode again :)

coderus ( 2016-03-06 11:58:01 +0300 )edit
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2015-11-09 15:07:36 +0300

Seen: 1,259 times

Last updated: Aug 08 '17