Turn the rows that only reported things into controls
Autostart entries showed "Enabled" or "Disabled" as plain text. The row did toggle on click the whole time, so this is an affordance rather than a missing capability -- but a control that reads as static text is one nobody knows they have. It is a switch now, with removal alongside it behind a confirmation: disabling writes Hidden=true and can be undone, deleting the file cannot. remove-autostart is confined to files the autostart directory owns. It resolves the path and compares the parent, so a name like "../../.bashrc" cannot escape, and it refuses symlinks rather than following them -- deleting through one would remove whatever it points at, which is somewhere else and not ours. Each refusal was tested against a fixture directory, including a symlink aimed at /etc/hostname, which survived. Sharing says who is signed in from another machine: user, origin and since when. An empty list on this machine proves nothing, so the parser was checked against sample `who` output -- it picks out remote sessions and leaves out local seats and the :0 display, which would otherwise report the person at the keyboard as a remote login. Media sharing was "Available" and nothing else: rygel installed, rygel.service disabled, no way to change that from here. It is a switch now, and it says what it does before you touch it rather than afterwards -- turning it on publishes media folders to every device on the network with no password in front of them. Per-application camera and microphone permissions come from the portal's permission store, which is where an application that asked through the portal has its answer recorded. The page states the limit plainly instead of implying a protection that does not exist: a program installed outside the portal opens the device directly and nothing here stands in its way. Anything that is not an explicit "yes" is treated as withheld, because guessing generously about a camera is the wrong way to be wrong. The first version of the write silently did nothing -- SetPermission takes an array of strings and was being handed one string -- and the test did not notice, because it discarded the helper's output and only checked that state was unchanged afterwards, which was trivially true. The contract now requires the value to move, and was proven to fail by putting that exact bug back. Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
@@ -352,6 +352,38 @@ def update_hidden(path: Path, *, hidden: bool) -> None:
|
||||
write_atomic(path, with_hidden(original, hidden=hidden), mode=mode)
|
||||
|
||||
|
||||
def remove_autostart(desktop_id: str) -> None:
|
||||
"""Delete a user autostart entry.
|
||||
|
||||
Disabling writes Hidden=true and is reversible; this is not, so it is
|
||||
confined to files this directory owns. A symlink is refused rather than
|
||||
followed, because deleting through one would remove whatever it points at --
|
||||
which is somewhere else entirely, and not ours.
|
||||
"""
|
||||
if not DESKTOP_ID.fullmatch(desktop_id):
|
||||
raise BoundaryError("That is not an autostart entry name.")
|
||||
|
||||
directory = autostart_directory()
|
||||
target = directory / desktop_id
|
||||
|
||||
# Resolved and compared, so a name like "../../.bashrc" cannot escape.
|
||||
try:
|
||||
resolved = target.resolve(strict=True)
|
||||
except OSError as error:
|
||||
raise BoundaryError("That autostart entry no longer exists.") from error
|
||||
if resolved.parent != directory.resolve(strict=False):
|
||||
raise BoundaryError("That autostart entry is not in the autostart directory.")
|
||||
if target.is_symlink() or not target.is_file():
|
||||
raise BoundaryError("That autostart entry is not a file this can remove.")
|
||||
if target.suffix != ".desktop":
|
||||
raise BoundaryError("That autostart entry is not a desktop file.")
|
||||
|
||||
try:
|
||||
target.unlink()
|
||||
except OSError as error:
|
||||
raise BoundaryError("That autostart entry could not be removed.") from error
|
||||
|
||||
|
||||
def add_autostart(desktop_id: str) -> None:
|
||||
desktop_files = discovered_desktop_files()
|
||||
require_desktop_id(desktop_id, discovered=set(desktop_files))
|
||||
@@ -406,6 +438,8 @@ def main(arguments: list[str]) -> int:
|
||||
set_default(arguments[1], arguments[2])
|
||||
elif len(arguments) == 3 and arguments[0] == "set-autostart":
|
||||
set_autostart(arguments[1], arguments[2])
|
||||
elif len(arguments) == 2 and arguments[0] == "remove-autostart":
|
||||
remove_autostart(arguments[1])
|
||||
elif len(arguments) == 2 and arguments[0] == "add-autostart":
|
||||
add_autostart(arguments[1])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user