-
Notifications
You must be signed in to change notification settings - Fork 5
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 #1 from alptugay/development
firewallbuilder ile farkli fwbuilder kurulumlari ile farkli firewalla…
- Loading branch information
Showing
3 changed files
with
42 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
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,36 @@ | ||
#!/usr/bin/python | ||
import re | ||
import sys | ||
import os | ||
master_fwb = False | ||
fname="/etc/fw/editable_objects" | ||
if not os.path.isfile(fname): | ||
sys.exit(0) | ||
if os.stat(fname).st_size <= 1: | ||
master_fwb = True | ||
|
||
with open(sys.argv[1]) as fwb: | ||
fwb_content = fwb.readlines() | ||
|
||
with open(fname) as rw_objects: | ||
rw_object_list = rw_objects.readlines() | ||
|
||
rw_object_set = set(map(str.strip, rw_object_list)) | ||
new_fwb = [] | ||
for line in fwb_content: | ||
if master_fwb: | ||
line = line.replace("ro=\"True\"","ro=\"False\"") | ||
else: | ||
match = re.search(r'\<Firewall.*name=\"(.*?)\".*',line) | ||
if match: | ||
name = match.group(1) | ||
if name not in rw_object_set: | ||
line = line.replace("ro=\"False\"","ro=\"True\"") | ||
else: | ||
line = line.replace("ro=\"True\"","ro=\"False\"") | ||
new_fwb.append(line) | ||
|
||
with open(sys.argv[1],'w') as new_fwb_f: | ||
for line in new_fwb: | ||
new_fwb_f.write("%s" % line) | ||
|
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