-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4389 from rusty-snake/profcleaner.sh
Create profcleaner.sh
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2021 Firejail Authors | ||
# | ||
# This file is part of firejail project | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
if [[ $1 == --help ]]; then | ||
cat <<-EOM | ||
USAGE: | ||
profcleaner.sh --help Show this help message and exit | ||
profcleaner.sh --system Clean all profiles in /etc/firejail | ||
profcleaner.sh --user Clean all profiles in ~/.config/firejail | ||
profcleaner.sh /path/to/profile1 /path/to/profile2 ... | ||
EOM | ||
exit 0 | ||
fi | ||
|
||
if [[ $1 == --system ]]; then | ||
profiles=(/etc/firejail/*.{inc,local,profile}) | ||
elif [[ $1 == --user ]]; then | ||
profiles=("$HOME"/.config/firejail/*.{inc,local,profile}) | ||
else | ||
profiles=("$@") | ||
fi | ||
|
||
sed -i \ | ||
-e "s/^blacklist/deny/" \ | ||
-e "s/^noblacklist/nodeny/" \ | ||
-e "s/^whitelist/allow/" \ | ||
-e "s/^nowhitelist/noallow/" \ | ||
"${profiles[@]}" |
00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, wouldn't it be better to remove the caret in the sed lines? Right now commented lines with blacklist/noblacklist/whitelist/nowhitelist instructions will not be handled by this script. Example: lines 29 + 30 in firefox.profile
00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, think of
include whitelist-common.inc
for example. However we can extend it to also change#whitelist
and# whitelist
(and so on).00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right - I missed that. And yes, extending the script to include those other cases would make sense, indeed.
00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"s/^(# |#)?whitelist/\1allow/"
what do you think (requires-E
)?00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should work.
One question: Is there a reason why the whitelist-*.inc files have not been renamed?
00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4379
00cb8b6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 0b31c41