Commit Graph

59 Commits

Author SHA1 Message Date
Jakob Rieck
b97c0f06eb blue-merle: Fixes shutdown 2023-10-18 15:48:11 +02:00
Tobias Mueller
d4886a54a9 volatile-macs: define the service self-sufficiently
This makes it hopefully a bit easier to see what we're doing because you
don't need to chase the files down. We don't re-use that functionality
anywhere. Neither would we.
A more important change is not restarting the gl-tertf service.
First of all, there seems to be no process attached to gl-tertf. It is
the "Bandwidth Monitor" and part of the kmod-gl-sdk4-tertf package, so
it's kernel module. It does not appear to be holding the clients.db.
There is, however, gl_clients which also makes sense, naming wise.
That service defines that /usr/bin/gl_clients_update ought to be run.
And stracing it shows that it does indeed touch the database:
open("/etc/oui-tertf/client.db",
O_RDWR|O_CREAT|O_LARGEFILE|O_NOFOLLOW|O_CLOEXEC, 0644) = 7

It also appears to be re-creating the file when it's missing.

Anyway, we have the service stopped during installation so that we can
safely delete the file without the process complaining. We also install
our volatile mac service s.t. it runs ahead of the gl-client service so
that the clientdb gets saved in volatile memory.
2023-10-18 14:27:55 +02:00
Tobias Mueller
d47916552d volatile macs: match our service's priority to our dependencies
The value of 20 is probably a copy and paste leftover from the
blue-merle service. The real START value that we care about is 60.
2023-10-18 13:24:47 +02:00
Tobias Mueller
03c262a8c3 blue-merle: generate a temporary IMEI before the the SIM switch
After shutting down the modem and before replacing the SIM, we generate
a temporary random IMEI to prevent accidental disclosure of the new IMSI
under the old IMEI. It should not happen but we do not control the modem
as much as we'd like, e.g. fully power it down. So it may not be
necessary but we consider it defense in depth.
2023-10-18 11:02:28 +02:00
Tobias Mueller
fe4021feb9 blue-merle: restore old scrpit for SSH use
We restore from fa11fc45ca.
We know that this worked well enough the last time as we run out of time
to test new things.
Ideally, though, we manage to consolidate the SSH use and the switch use
(and the Web use) to not have different implementations of the same
functionality so that testing gets much simpler.
2023-10-18 10:43:05 +02:00
Tobias Mueller
f8d35b15d5 mac-wipe: Do not stop terft as it cannot be stopped
The service does not implement stop() as it throws a scary warning when
installing. So we do not even attempt to stop it.
2023-10-18 10:36:33 +02:00
Tobias Mueller
7b64f3aa9b functions: provide SET IMEI capability from shellscripts
It doesn't work for me but I also haven't tried very hard as we do not
migrate off the Python script now.
2023-10-18 10:35:39 +02:00
Tobias Mueller
c8634591b2 added Lua script to generate an IMEI
We currently use a Python script to generate IMEIs. Loading Python is
relatively expensive on our target platform so I hope we can use
something quicker.
2023-10-18 10:31:49 +02:00
Tobias Mueller
512da23200 web: stop spinning when reboot is ready 2023-10-17 22:02:24 +02:00
Tobias Mueller
a0fad3a833 mac-wipe: fix syntax error for argument comparison 2023-10-17 22:02:04 +02:00
Tobias Mueller
9466707119 web: fix syntax error 2023-10-17 20:03:31 +02:00
Tobias Mueller
87c420e2de web: remove unused handleOpkg function
It served as an example of how we could do things. Now we don't need it
any longer as we know what we need to do. Or so we think.
2023-10-17 20:00:41 +02:00
Tobias Mueller
db8de09293 web: remove unused handleRemove function 2023-10-17 19:59:18 +02:00
Tobias Mueller
8b4d371c9f functions: Do not automatically restart the wifi on RESET_BSSIDS
Instead of restarting the service we have the service started *after*
our modification to its configuration.
This makes it slightly more inconvenient to reset the WiFi BSSIDs while
the device is booted but that capability can be restored and made better
through an executable, say, /usr/bin/reset-wifi-bssids or something.

We also split the volatile client MACs into its own service to have
a bit of a clearer separation of duties. This will allow us to eventually
split the package more easily into sub-packages with finer-grained control.
2023-10-17 19:52:11 +02:00
Tobias Mueller
1c3c5f79e1 web: fix syntax error for missing comma 2023-10-17 17:20:26 +02:00
Tobias Mueller
0fbb00612c blue-merle: provide a somewhat interactive way to set a new IMEI via SSH
This can currently only provide a random IMEI only. But we could easily
recover the deleted script. But it'd be nicer to have a central
configuration for the mode.
2023-10-17 17:18:08 +02:00
Tobias Mueller
c88d04003b web: forcefully timout the python script
sometimes it has a hickup.
2023-10-17 16:54:43 +02:00
Tobias Mueller
f7a9494a0c web: logging calls to helper binary 2023-10-17 16:54:18 +02:00
Tobias Mueller
958a0ecc99 web: actually changing the UI when the script returns
When it doesn't time out it seems to be working. Weird.
2023-10-17 16:51:51 +02:00
Tobias Mueller
580d456ed1 web: try calling random-imei
It fails from the "SIM Swap" button, I don't know yet, why.
2023-10-17 16:38:57 +02:00
Tobias Mueller
fa8e630714 web: remove unused functions
they are not referenced from the rest of the file.
2023-10-17 16:37:55 +02:00
Tobias Mueller
242235757a switch: log when stage1 has finished running 2023-10-17 15:49:41 +02:00
Tobias Mueller
0fa4d89602 switch: do not run the lock contention check in the background
It actually prevents out main script from running because the flock
process is still running in the background.
2023-10-17 15:49:25 +02:00
Tobias Mueller
8053d44ce7 switch: removing stale switch file
We have separated it into stages so we don't need the monolith
2023-10-17 15:48:51 +02:00
Tobias Mueller
0b4b04c48b switch: log in stage2
So that we can notice whether our script has successfully run.
You can read the log with something like
logread -l 10000 -e blue
2023-10-17 15:16:49 +02:00
Tobias Mueller
ed6856c490 switch: split the switch action into separate stages
When toggling the switch, a lock is held for a relatively long time,
preventing another toggling of the switch to be noticed. With this
change, I hope we can first shutdown the modem, wait for a toggle, and
then continue.
We're losing the abort function but I currently don't know how we would
be able to keep that functionality given that the toggle is queued and
we don't get the notification.
2023-10-17 15:15:28 +02:00
Tobias Mueller
eab0633ad9 switch: Asynchronously execute blue merle when toggled
I hope that this allows us to use the toggle again to advance the Blue
Merle logic.
If all goes well, the script finishes execution and the switch lock in
/var/lock/gl-switch.lock is released so that the button can be used
again.
2023-10-17 13:51:51 +02:00
Tobias Mueller
db1c0c4c69 switch: limit execution time to 90 seconds
We don't want to let it run forever because it blocks the toggle from
working. But even if it's not, we wouldn't want to have the script run
eternally.
2023-10-17 13:02:40 +02:00
Tobias Mueller
ae40dcec1f web: weeding out the opkg functionality
We don't need any of that but I let the functions live just in case they
are referenced anywhere.
2023-10-17 13:00:35 +02:00
Tobias Mueller
396ff7ea0e switch: shutdown in time
Now it's more in sync with the display.
2023-10-17 10:16:10 +02:00
Tobias Mueller
2cf6495aad switch: re-format messages to appear more nicely on the screen
We cannot control whitespace :(
2023-10-17 10:12:17 +02:00
Tobias Mueller
6b7e11137b switch: send SIM swap script to background
I think we can only toggle while the handler is not active.
I toggled to ON and got the script running. But then I couldn't toggle
OFF, presumingly because the script was still running.
By sending it to the background I hope it will allow me to toggle OFF.
2023-10-17 09:57:47 +02:00
Tobias Mueller
881e9792c7 switch: call blue-merle-switch when toggling the button to on 2023-10-17 09:23:58 +02:00
Tobias Mueller
29db0fab27 switch: show message on v4 MCU 2023-10-17 09:20:36 +02:00
Tobias Mueller
df8578e402 functions: CHECK_ABORT for v4 MCU 2023-10-17 09:18:00 +02:00
Tobias Mueller
11a8afd0a9 python: Added a --generate-only flag to not set the IMEI
We can probably set the IMEI through the gl_modem command.
Currently, the Web interface times out when calling random-imei. I want
to separate the steps so that each step does not take as long.
2023-10-17 09:05:02 +02:00
Tobias Mueller
53bf156fd0 python: only get the IMSI when in deterministic mode
We don't need the IMSI otherwise so let's not spend the time obtaining
it.
2023-10-17 09:01:31 +02:00
Tobias Mueller
4a16277ac2 python: debug print reading IMSI
It seems to timeout somewhere and I want to know where.
2023-10-17 09:00:56 +02:00
Tobias Mueller
6ac26e1a33 web ui: Fix a syntax error by closing the E() 2023-10-16 17:26:46 +02:00
Tobias Mueller
955d0f993e blue-merle: make it return the new IMEI after generating a random IMEI 2023-10-16 16:58:15 +02:00
Tobias Mueller
3b87b1b8f4 web: offer to shutdown on SIM swap
It currently times out when generating an IMEI.
I wonder what the timeouts are.
2023-10-16 16:57:42 +02:00
Tobias Mueller
b02faa7adb web: stab at a Web UI for SIM swap 2023-10-16 16:36:33 +02:00
Tobias Mueller
fa11fc45ca blue-merle: Display a shutdown message before finally halting the system 2023-10-16 16:25:45 +02:00
Tobias Mueller
259bffc515 switch: show a message on toggling the button
To see more easily whether we have control.
2023-10-16 16:10:17 +02:00
Tobias Mueller
4636d77222 web: rename files from opkg2 to blue-merle
This makes it easier to find our own files...
2023-10-16 16:05:58 +02:00
Tobias Mueller
ce77151081 switch: log action on the toggle
It's a bit easier to follow than looking at the generated files.
2023-10-16 16:03:11 +02:00
Tobias Mueller
55a6f8d10f fix syntax error in web interface
I want to see it in the menu before further developing the
functionality.
2023-10-16 15:54:46 +02:00
Tobias Mueller
4f584b4b6c mac-wipe: avoid accumulating mounts
If we mount over and over again we may consume memory unnecessarily.
2023-10-16 15:15:29 +02:00
Tobias Mueller
4beae781a2 mac-wipe: copy existing database into a volatile memory
rather than deleting everything.
It seems that the device stops working when deleting the database. That
is, the connection to the Internet stops working which is very safe as
it does not leak any data but arguably defeats the purpose of the
device.
2023-10-16 14:51:59 +02:00
Tobias Mueller
e02de82dba mac-wipe: log execution to debug where it's stuck
When installing the package, it appears to be stuck somewhere. I want to
know where and why, so I use the logging facilities.
2023-10-16 14:05:09 +02:00