Skip to content

Commit

Permalink
Add admin.repos.* qrexec services
Browse files Browse the repository at this point in the history
This is a prerequisite for QubesOS/qubes-issues#4550.
  • Loading branch information
strugee committed Dec 9, 2018
1 parent 9c3a4e7 commit 197dba1
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qubes-rpc-policy/admin.repos.Disable
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
7 changes: 7 additions & 0 deletions qubes-rpc-policy/admin.repos.Enable
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
7 changes: 7 additions & 0 deletions qubes-rpc-policy/admin.repos.List
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
24 changes: 24 additions & 0 deletions qubes-rpc/admin.repos.Disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python3

# Empty output indicates success; any input indicates error (probably an exception)

import dnf
import iniparse
import sys

base = dnf.Base()

base.read_all_repos()

reponame = sys.stdin.readline()
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, 'w') as fp:
fp.write(str(ini))
24 changes: 24 additions & 0 deletions qubes-rpc/admin.repos.Enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python3

# Empty output indicates success; any input indicates error (probably an exception)

import dnf
import iniparse
import sys

base = dnf.Base()

base.read_all_repos()

reponame = sys.stdin.readline()
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, 'w') as fp:
fp.write(str(ini))
11 changes: 11 additions & 0 deletions qubes-rpc/admin.repos.List
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python3

import dnf

base = dnf.Base()

base.read_all_repos()

for repo in base.repos.all():
l = [repo.id, repo.name, 'enabled' if repo.enabled else 'disabled']
print('\0'.join(l))

0 comments on commit 197dba1

Please sign in to comment.