Skip to content

feat: toggle-bluetooth rewrite in python with systemd run0 sandboxing#1215

Merged
RoyalOughtness merged 66 commits intosecureblue:livefrom
ShadowSlayer1441:bluetooth_python
Sep 8, 2025
Merged

feat: toggle-bluetooth rewrite in python with systemd run0 sandboxing#1215
RoyalOughtness merged 66 commits intosecureblue:livefrom
ShadowSlayer1441:bluetooth_python

Conversation

@ShadowSlayer1441
Copy link
Copy Markdown
Collaborator

Script functionality tested in vm.

@ShadowSlayer1441 ShadowSlayer1441 changed the title [feat] toggle-bluetooth rewrite in python with systemd run0 sandboxing feat: toggle-bluetooth rewrite in python with systemd run0 sandboxing Jul 31, 2025
Copy link
Copy Markdown
Collaborator

@HastD HastD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just have some minor suggestions to improve error handling and code clarity/style.

RoyalOughtness
RoyalOughtness previously approved these changes Sep 7, 2025
RoyalOughtness
RoyalOughtness previously approved these changes Sep 7, 2025
@RoyalOughtness
Copy link
Copy Markdown
Collaborator

#1206

RoyalOughtness
RoyalOughtness previously approved these changes Sep 8, 2025
@RoyalOughtness RoyalOughtness enabled auto-merge (squash) September 8, 2025 19:29
@RoyalOughtness RoyalOughtness merged commit 3b8985f into secureblue:live Sep 8, 2025
12 checks passed
@ShadowSlayer1441 ShadowSlayer1441 deleted the bluetooth_python branch October 6, 2025 23:21
cur_status: str = "enabled" if bluetooth_currently_enabled else "disabled"
file_status: str = "enabled" if enabled_by_file else "disabled"

print(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider use logger instead of print?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a merged PR

file_status: str = "enabled" if enabled_by_file else "disabled"

print(
f"Bluetooth is currently {cur_status}, and after a reboot will {file_matches_sys}be {file_status}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space after {file_matches_sys} and 'be'

state_already_set = target_state_enabled == enabled_by_file
if state_already_set:
print_status(enabled_by_file)
else:
Copy link
Copy Markdown

@ghost ghost Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else not needed can directly return

"""


def main():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a type and return hints, so we can see what type is returned from the function?

A class that wraps a function to be run in a sandbox
"""

import dataclasses
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import dataclasses.dataclass

import dataclasses


@dataclasses.dataclass
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Copyright (C) 2025 Daniel Hast
# Systemd sandboxing of run0 invocation adapted from run0edit, originally licensed
# under MIT OR Apache-2.0. Used here under the terms of the Apache License 2.0.
system_calls_to_deny: list[str] = [
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to constant values

@HastD
Copy link
Copy Markdown
Collaborator

HastD commented Oct 16, 2025

@klorishow32 This PR has already been merged—if you want to make changes to this script, you can make a separate PR for it.

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.

3 participants