-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/pr/48'
* origin/pr/48: Add some comments to qubes.repos.List Don't write a trailing newline in qubes.repos.List Add qubes.repos.* services to the RPMs Print `ok` for repo enable/disable success Use qrexec service arguments Properly set the umask for repo files Enable/disable repos atomically Use Python whitespace conventions Rename admin.repos.* to qubes.repos.* Add admin.repos.* qrexec services
- Loading branch information
Showing
7 changed files
with
114 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,7 @@ | ||
## Note that policy parsing stops at the first match, | ||
## so adding anything below "$anyvm $anyvm action" line will have no effect | ||
|
||
## Please use a single # to start your custom comments | ||
|
||
dom0 dom0 allow | ||
$anyvm $anyvm deny |
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,7 @@ | ||
## Note that policy parsing stops at the first match, | ||
## so adding anything below "$anyvm $anyvm action" line will have no effect | ||
|
||
## Please use a single # to start your custom comments | ||
|
||
dom0 dom0 allow | ||
$anyvm $anyvm deny |
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,7 @@ | ||
## Note that policy parsing stops at the first match, | ||
## so adding anything below "$anyvm $anyvm action" line will have no effect | ||
|
||
## Please use a single # to start your custom comments | ||
|
||
dom0 dom0 allow | ||
$anyvm $anyvm deny |
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,32 @@ | ||
#!/usr/bin/python3 | ||
|
||
# `ok` on stdout indicates success; any stderr output indicates an error | ||
# (probably an exception) | ||
|
||
import dnf | ||
import iniparse | ||
import os | ||
import sys | ||
|
||
os.umask(0o022) | ||
|
||
base = dnf.Base() | ||
|
||
base.read_all_repos() | ||
|
||
reponame = sys.argv[1] | ||
repo = base.repos[reponame] | ||
|
||
# Loosely based on write_raw_configfile() from DNF source code, because | ||
# that method was introduced in DNF 2.0 but Qubes dom0 has DNF 1.x. | ||
with open(repo.repofile) as fp: | ||
ini = iniparse.INIConfig(fp) | ||
|
||
ini[reponame]['enabled'] = 0 | ||
|
||
with open(repo.repofile + '.new', 'w') as fp: | ||
fp.write(str(ini)) | ||
|
||
os.rename(repo.repofile + '.new', repo.repofile) | ||
|
||
print('ok') |
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,32 @@ | ||
#!/usr/bin/python3 | ||
|
||
# `ok` on stdout indicates success; any stderr output indicates an error | ||
# (probably an exception) | ||
|
||
import dnf | ||
import iniparse | ||
import os | ||
import sys | ||
|
||
os.umask(0o022) | ||
|
||
base = dnf.Base() | ||
|
||
base.read_all_repos() | ||
|
||
reponame = sys.argv[1] | ||
repo = base.repos[reponame] | ||
|
||
# Loosely based on write_raw_configfile() from DNF source code, because | ||
# that method was introduced in DNF 2.0 but Qubes dom0 has DNF 1.x. | ||
with open(repo.repofile) as fp: | ||
ini = iniparse.INIConfig(fp) | ||
|
||
ini[reponame]['enabled'] = 1 | ||
|
||
with open(repo.repofile + '.new', 'w') as fp: | ||
fp.write(str(ini)) | ||
|
||
os.rename(repo.repofile + '.new', repo.repofile) | ||
|
||
print('ok') |
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,17 @@ | ||
#!/usr/bin/python3 | ||
|
||
# Records in the output are separated by newlines; fields are separated by \0 | ||
# Each record is unique_id:pretty_name:enabled | ||
|
||
import dnf | ||
|
||
base = dnf.Base() | ||
|
||
base.read_all_repos() | ||
|
||
first = True | ||
for repo in base.repos.all(): | ||
l = [repo.id, repo.name, 'enabled' if repo.enabled else 'disabled'] | ||
if not first: print() | ||
first = False | ||
print('\0'.join(l), end='') |
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