Skip to content

Commit

Permalink
sort.py: line-wrap and improve comments
Browse files Browse the repository at this point in the history
Changes:

* Line-wrap comments at 79 characters (PEP-8)
* Make comments clearer
  • Loading branch information
kmk3 committed Oct 18, 2022
1 parent aa17ca5 commit 2be6e6f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions contrib/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
# Copyright (C) 2014-2022 Firejail Authors
# License GPL v2
"""
Sort the items of multi-item options in profiles, the following options are supported:
private-bin, private-etc, private-lib, caps.drop, caps.keep, seccomp.drop, seccomp.drop, protocol
Sort the arguments of the commands that support multiple arguments in profiles;
the following commands are supported:
private-bin, private-etc, private-lib, caps.drop, caps.keep, seccomp.drop,
seccomp.drop, protocol
Usage:
$ ./sort.py /path/to/profile [ /path/to/profile2 /path/to/profile3 ... ]
Keep in mind that this will overwrite your profile(s).
Examples:
Expand All @@ -16,10 +20,10 @@
$ ./sort.py ~/.config/firejail/*.{profile,inc,local}
$ sudo ./sort.py /etc/firejail/*.{profile,inc,local}
Exit-Codes:
0: No Error; No Profile Fixed.
1: Error, one or more profiles were not processed correctly.
101: No Error; One or more profile were fixed.
Exit Codes:
0: Success: No profiles needed fixing.
1: Error: One or more profiles could not be processed correctly.
101: Warning: One or more profile were fixed.
"""

# Requirements:
Expand All @@ -34,7 +38,11 @@ def sort_alphabetical(original_items):


def sort_protocol(original_protocols):
"""sort the given protocols into this scheme: unix,inet,inet6,netlink,packet,bluetooth"""
"""
Sort the given protocols into the following order:
unix,inet,inet6,netlink,packet,bluetooth
"""

# shortcut for common protocol lines
if original_protocols in ("unix", "unix,inet,inet6"):
Expand Down

0 comments on commit 2be6e6f

Please sign in to comment.