Skip to content

omamobile-settings 0.1.4: a Change PIN page - #630

Draft
Somnius wants to merge 4 commits into
derekross:mainfrom
Somnius:settings-pin-1110
Draft

Somnius wants to merge 4 commits into
derekross:mainfrom
Somnius:settings-pin-1110

Conversation

@Somnius

@Somnius Somnius commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

@derekross, @marselnenaj, this is stacked on the Keyboard haptics and Display pages (#628 and the haptics PR): the first two commits are those, only the last one is new.

The lock screen PIN is the account password (the lock checks it with pam_unix), so the page runs the system's own /usr/bin/passwd in a pseudo-terminal and lets it do the checking. The three entries go to the script on stdin, never as an argument or in the environment, and are never logged or printed. The new PIN must be 4 to 8 digits, different from the current one and typed twice; passwd checks the current PIN and anything else. passwd runs with LC_ALL=C and a minimal environment, so its prompts are the English ones the script matches. After 12 seconds passwd is killed: before the retype was sent nothing has changed, after it the message says the PIN may or may not have changed. The page opens with org.omamobile.Settings.Open("pin").

The Change PIN page

Things you should look at, because this one can lock someone out: the entries sit as text in the page until the call returns and are cleared then, but the session's memory isn't wiped. The 4 to 8 digit rule is mine, not PAM's: on my phone the stack is plain pam_unix with no minimum length, and a 4 digit PIN worked as the user, but another setup could refuse short ones, which the page reports as "the system refused the new PIN".

Tested: test/all passes on the phone with a new backend test that runs the script against a stand-in passwd (a wrong current PIN, a refusal that asks again, a hang after the retype, Greek prompts, a check that the script's environment holds no PIN, nothing printed). The page renders. I also ran the final script against the real passwd on my phone: the PIN changed to another one and the lock screen unlocked with it, then I changed it back and it unlocked with the old one again. Not tested on any other phone.

@derekross

Copy link
Copy Markdown
Owner

@Somnius thank you for marking this one as a draft and for pointing me at the parts that matter; a page that handles the PIN deserves that. I read it end to end and tried it against a stand-in on my side, and the core of it is right:

  • The PIN goes from the three fields to the runner's stdin and from there to passwd's terminal, and nowhere else. I checked the process arguments and environment of both processes while a change was running, and what the script prints: nothing. The runner isn't reachable over D-Bus.
  • It calls the system's own passwd as the user, which is what System > PIN (omamobile-set-pin) has always done, so the current PIN is checked by passwd and not by us.
  • I walked every exit of the script for a way to end up locked out and didn't find one: a wrong current PIN, a refused new one and a silent passwd all leave the old PIN; success is only reported for an exit status of 0 after the retype; and the "may or may not have changed, try the new one first" message for a late timeout is honest, since pam_unix swaps the shadow file in one rename.
  • Escape goes back from the page even with a PIN field focused (I tried that separately), and the fields are cleared when the page goes.

Three things before it leaves draft:

  1. The result is lost if the page is left while passwd runs. Back, opening Settings again from the home screen, or Open("display") destroys the page; the change still completes, and nothing ever says so. For this one page the result needs to outlive the page: keep the last result in the runner or the backend and show it on return, or post a notification, or hold Back for the few seconds it takes. Please add a test for it (start a change against the hanging stand-in, navigate away, expect the result).
  2. Phones set to a password. omamobile-set-pin records whether the phone unlocks with a PIN or a password (~/.config/omamobile/credential, and the lock's keypad toggle). On a password phone the "Current PIN" field only takes digits, so the owner can't get past it. Please read omamobile-set-pin --type and, for password, say that this phone unlocks with a password and that System > PIN changes it, with the form disabled. A phone with no PIN yet should get a plain line too; today it waits 12 s for a prompt that never comes.
  3. The stack. omamobile-shell 0.2.117, omamobile-settings 0.1.1: Back goes back one level, and home from an app's top level #643 took omamobile-settings 0.1.1 today, so the three pages move up one: omamobile-settings 0.1.1: a Display page, brightness and refresh rate #628 becomes 0.1.2. The haptics page (omamobile-settings 0.1.3: a Keyboard haptics page #629) is waiting on a decision from me about what "Off" may do, and this page doesn't need it, only omamobile-settings 0.1.1: a Display page, brightness and refresh rate #628's runner. Could you restack this one directly on omamobile-settings 0.1.1: a Display page, brightness and refresh rate #628? git rebase --onto 6a2fb993e0 d46bd9151d settings-pin-1110; the conflicts are the one-line lists (catalog, customPages, the qrc, install, test/all, the runner's tool list).

Smaller things: your description names the PINs you tested with and the one the phone is on now; it's a public thread, so please change that PIN and edit it out (there's also a stray "true" on the first line). The runner could accept stdin input for the pin tool only. The script could be a pin.py next to pin.sh rather than a hundred lines in python's -c argument (no PIN in it, it just shows up in ps). And the page could say, as System > PIN does, that the PIN is also the sudo password.

I'll try it on my Pixel 7 Pro with a root SSH login open as the way back before Settings ships with this page, and report here.

@Somnius Somnius changed the title omamobile-settings 0.1.3: a Change PIN page (draft) omamobile-settings 0.1.4: a Change PIN page Nov 13, 2026
@Somnius
Somnius marked this pull request as draft November 13, 2026 18:30
@Somnius

Somnius commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@derekross, thank you, and for catching the PINs in the description. They are out of it now (and the stray "true" on the first line). I'm changing the phone's PIN as you asked, and that isn't done yet; this PR stays a draft until it is. The branch is restacked directly on #628 with your command and is 0.1.4.

  1. The result outlives the page. The runner keeps what is still running and the last result nobody took, by tool and first argument (change, status), and the signal carries it. A page that is opened again asks for the status first and then finds the change's outcome once. The test starts a change against a stand-in backend that hangs for a moment, leaves the page, runs a status beside it, and checks the result arrives once.
  2. A password phone or a PIN-less phone: pin.sh status reads omamobile-set-pin --type and passwd -S, and the form is enabled only when both say a PIN and one is set. Otherwise the page says where to go ("System, PIN"). Review also found that a status left running by a page that was closed could be taken for the change by the next page and enable the form; that's fixed, and status fails closed when either answer is missing (an error line, no form).
  3. The stack: restacked on omamobile-settings 0.1.1: a Display page, brightness and refresh rate #628 as you asked.

Smaller things: pin.py is a file now, input goes to the pin tool only, and the page says the PIN is also the sudo password. The runner also no longer trusts the environment: bash starts with -p, exported functions, SHELLOPTS and the like are dropped, and PATH is the system's directories plus Omarchy's bin.

What ran: the backend tests (test/pin-backend.sh, haptics and display) locally, a g++ syntax check of the runner and tests, qmllint on the page, and on GitHub both checks pass on this head (1622ba8): Policy, and Tests (tests/all, every package), which builds and runs the Settings tests including the new runner ones. I did not run test/all on my own phone for this head, because the phone is off. The runner change (bash -p, the forced PATH, the extra signal argument that the Display page's three-argument handler now receives) has therefore not run on a phone yet.

@Somnius

Somnius commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Here's the page on my Pixel 8 Pro, empty fields, nothing typed. It stays a draft until I've changed the phone's PIN, as I said above.

@marselnenaj, same as on #629: this page builds on your Settings app from #526, so any feedback from you is welcome.

Change PIN page

Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 18, 2026
…77759-charger

The page runs backends/charge.sh like the Display page does. Setting a value
runs systemctl start --no-ask-password omamobile-charge-limit@N.service (a
polkit rule allows those five instances for the active local user), which runs
libexec/charge-limit as root: start threshold 0 (resume 5 below), then the end
threshold, and only then /etc/omamobile/charge-limit is saved. No writable end
threshold or a failed write: exit 1, nothing saved.

At boot a udev rule on the charger's add pulls in
omamobile-charge-limit-apply.service, which applies the saved value on husky
only (device tree google,zuma-husky). Units have StartLimitIntervalSec=0.

Note: the page is inert on husky today. omamobile-device-husky blacklists
max77759_charger, so there is no max77759-charger power supply and the page
says the limit is not available until that blacklist is lifted.

Version 0.1.3 (to be renumbered at merge; derekross#629 and derekross#630 hold 0.1.3/0.1.4).
Tests: test/charge-backend.sh against a scratch root (backend, helper, a
stand-in systemctl, polkit/unit/udev contents, staged paths and modes), core
tests open BatteryPage and check the runner's charge entry.
@derekross

Copy link
Copy Markdown
Owner

Thanks, Lef. I read this head end to end for where the PIN goes, and it is still clean: fields, the runner's stdin (for the pin tool only, at most 256 characters), bash -p pin.sh, python3 -I pin.py, the pseudo-terminal, passwd with a three-variable environment. It is never an argument or in an environment, nothing prints it, the kept result holds only "changed" or an error, and what the terminal sends back is matched against prompts and thrown away. The result outliving the page and the status check that fails closed are both what I asked for.

Before it leaves draft:

  1. The description's edit history. The current text is fine, but GitHub keeps old versions, and the one from 10 November still has the sentence with the two PINs (the "edited" menu next to the date shows it to anyone). Please open that menu, pick that revision and choose "Delete revision from history", and change the phone's PIN as you planned.

  2. A phone run of this head. As you say, the reworked runner (bash -p, the fixed PATH, the extra signal argument) hasn't run on a phone, and every page goes through it. Please run test/all there, the Display page's rows from the home screen, and one real PIN change and back. Tell me what passwd -S prints as your user (with nothing private in it): if it refuses for a normal user, the page will always say it cannot tell how the phone unlocks.

  3. Rebase. This conflicts with omamobile-settings: a Battery page with a charge limit (80-100 %) for husky #860, omamobile-settings: lock screen timeout, and lock after 30 minutes while a keyboard is connected #866 and omamobile-settings 0.1.3: a Keyboard haptics page #629 in the usual one-line lists. I expect omamobile-settings: a Battery page with a charge limit (80-100 %) for husky #860 first (0.1.3) and omamobile-settings: lock screen timeout, and lock after 30 minutes while a keyboard is connected #866 next (0.1.4); this page takes the number after whatever is in by then. omamobile-settings: lock screen timeout, and lock after 30 minutes while a keyboard is connected #866 adds ActionRunner::setBackendDir() for the tests and you add a constructor argument for the same thing; please keep one.

I still owe you my own run on the Pixel 7 Pro with a root SSH login open, and I'll do it once this is out of draft. I did not run the tests this round; CI is green on this head.

Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 18, 2026
…77759-charger

The page runs backends/charge.sh like the Display page does. Setting a value
runs systemctl start --no-ask-password omamobile-charge-limit@N.service (a
polkit rule allows those five instances for the active local user), which runs
libexec/charge-limit as root: start threshold 0 (resume 5 below), then the end
threshold, and only then /etc/omamobile/charge-limit is saved. No writable end
threshold or a failed write: exit 1, nothing saved.

At boot a udev rule on the charger's add pulls in
omamobile-charge-limit-apply.service, which applies the saved value on husky
only (device tree google,zuma-husky). Units have StartLimitIntervalSec=0.

Note: the page is inert on husky today. omamobile-device-husky blacklists
max77759_charger, so there is no max77759-charger power supply and the page
says the limit is not available until that blacklist is lifted.

Version 0.1.3 (to be renumbered at merge; derekross#629 and derekross#630 hold 0.1.3/0.1.4).
Tests: test/charge-backend.sh against a scratch root (backend, helper, a
stand-in systemctl, polkit/unit/udev contents, staged paths and modes), core
tests open BatteryPage and check the runner's charge entry.
Somnius added a commit to Somnius/omarchy-mobile that referenced this pull request Nov 18, 2026
… keyboard

The Display page gets 30 s, 1, 2, 3, 5 min and Never, plus an on/off for
staying unlocked while a keyboard is connected. The text says that lock and
screen off are the same timer and that Never also keeps the phone awake.
0.1.3 clashes with open derekross#629, derekross#630 and derekross#860; renumber at merge.
The lock screen PIN is the account password (the lock checks it with
pam_unix), so the page runs the system's own /usr/bin/passwd in a
pseudo-terminal and lets it do the checking: three entries on stdin, never
an argument or in the environment, never logged or printed. The new PIN is
digits only, 4 to 8 long, different from the current one and typed twice;
passwd checks the current PIN and anything else. passwd runs with LC_ALL=C
and a minimal environment so its prompts are the English ones the script
matches. A refusal that asks again is reported at once, and a passwd that is
still running after 12 seconds is killed: before the retype was sent nothing
has changed, after it the result says the PIN may or may not have changed.
The fields are cleared when the call returns.

The ActionRunner gets back a stdin input (at most 256 characters) for this
page. Stacked on the Keyboard haptics and Display pages. The backend test
runs the script against a stand-in for passwd, with the path and the
deadline replaced in a copy of the script: a wrong current PIN, a refusal
that asks again, a hang after the retype, Greek prompts, and a check that
the script's own environment holds no PIN.

Signed-off-by: Lef <me@lefteros.com>
…N-less phones, pin.py

The runner keeps a tool that is still running and the last result nobody took,
so a page left while passwd runs finds the outcome when it is opened again
(test: a hanging stand-in backend, no listener, the result is taken once). The
backend directory is a constructor argument for the test, not an environment
switch. Input goes to the pin tool only. pin.sh gets a status verb: the page
reads what omamobile-set-pin records (pin or password) and whether the account
has a password, and offers the form only on a phone that unlocks with a PIN
and has one; a password phone and a PIN-less phone get a plain line. The
script moves from a python -c string to pin.py. The page says the PIN is also
the sudo password. Back test for the page.
… trusts no environment, status fails closed

A request is now named by tool and first argument (change, status) and the
finished signal carries it, so a status started by a page that was left is not
taken for the change by the next one, a running change survives a status, and
the form is enabled only by a status that says a PIN is set. bash runs with -p
and the runner drops exported functions, SHELLOPTS and the like and sets PATH
to the system's; pin.sh finds nothing by name. status answers with an error
instead of guessing when omamobile-set-pin or passwd -S gives no answer, and
omamobile-shell is an optional dependency for that. Tests: a status beside a
running change, the signal's verb, a missing backend, BASH_ENV and PATH; the
backend test uses PINs that do not occur in an ordinary environment.
… it knows about the phone

The status line is now the phone's state, the outcome of a change that finished
while the page was gone, or only the running change, so a late status can no
longer replace a result and a failed status can't wipe it. The runner's PATH
includes Omarchy's own bin directory, for omarchy-hw-display. The environment
test restores what it changes and the status/change ordering test sleeps
longer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants