Skip to content

Commit

Permalink
Added warning to alert that user is not in disk group
Browse files Browse the repository at this point in the history
  • Loading branch information
il-palmi committed Oct 18, 2024
1 parent 70308a6 commit c605fd0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions basilico.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,20 @@ def run_command_on_partition(dev: str, cmd: str) -> bool:
return False


def user_groups_checks():
try:
res = subprocess.getoutput("groups $USER")
except FileNotFoundError as _:
logging.error("Unknown subprocess error in init_checks()")
return
if not "disk" in res.split(":")[1]:
user = os.getenv("USER")
logging.warning(f" User {user} is not in disk group and it may not have sufficient permissions to use smartctl.\n"
f"You can add it in with the command\n\n"
f"\tsudo usermod -a -G disk $USER\n\n"
f"and restarting the user session (logout and login).")


TARALLO = None
CLOSE_AT_END = False
CLOSE_AT_END_LOCK = threading.Lock()
Expand All @@ -1496,6 +1510,7 @@ def run_command_on_partition(dev: str, cmd: str) -> bool:


if __name__ == "__main__":
user_groups_checks()
load_settings()
if bool(os.getenv("DAEMONIZE", False)):
import daemon
Expand Down

0 comments on commit c605fd0

Please sign in to comment.