network_restart script should catch exactly where it requires running as root

Bug #1066094 reported by Marc Tardif
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox Provider - Base
Invalid
Low
Unassigned

Bug Description

The network_restart script checks for root permissions at the top of the main function:

    # Verify that script is run as root
    if os.getuid():
        sys.stderr.write(
            'This script needs superuser permissions to run correctly\n')
        return 1

The problem is that it's unclear why the script can't run as root. What if the script is refactored one day so that it doesn't really need to run as root anymore? Unfortunately, there's no way to know what parts of the script make any assumption about running as root. The script is therefore doomed to always require running as root whether it's actually required or not.

The right solution would be to properly check the return value exactly where the script might encounter an error when not running as root. Then, when that error is caught, report an error to the user.

Related branches

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

Agreed, although I don't see this causing any huge issues even in the long run

Changed in checkbox:
assignee: nobody → Brendan Donegan (brendan-donegan)
importance: Undecided → Low
status: New → In Progress
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

To be clear, the branch above is almost done, but I'm currently not working on fixing it.

Changed in checkbox:
status: In Progress → Triaged
assignee: Brendan Donegan (brendan-donegan) → nobody
Zygmunt Krynicki (zyga)
affects: checkbox → plainbox-provider-checkbox
Changed in plainbox-provider-checkbox:
milestone: none → future
Changed in plainbox-provider-checkbox:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.