semanage_migrate_store: add -r <root> option for migrating inside chroots

-r, --root
  Set an alternative root for the migration (default: /)

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
This commit is contained in:
Petr Lautrbach 2015-07-30 16:22:34 +02:00 committed by Stephen Smalley
parent 1874317293
commit 3c3006f791

View File

@ -180,7 +180,7 @@ def rebuild_policy():
def oldroot_path():
return "/etc/selinux"
return "%s/etc/selinux" % ROOT
def oldstore_path(store):
return "%s/%s/modules/active" % (oldroot_path(), store)
@ -192,7 +192,7 @@ def disabledmodules_path(store):
return "%s/disabled" % newmodules_path(store)
def newroot_path():
return PATH
return "%s%s" % (ROOT, PATH)
def newstore_path(store):
return "%s/%s/active" % (newroot_path(), store)
@ -219,6 +219,8 @@ if __name__ == "__main__":
help="Disable rebuilding policy after migration (default: no)")
parser.add_option("-P", "--path", dest="path",
help="Set path for the policy store (default: /var/lib/selinux)")
parser.add_option("-r", "--root", dest="root",
help="Set an alternative root for the migration (default: /)")
(options, args) = parser.parse_args()
@ -231,6 +233,10 @@ if __name__ == "__main__":
if PATH is None:
PATH = "/var/lib/selinux"
ROOT = options.root
if ROOT is None:
ROOT = ""
# List of paths that go in the active 'root'
TOPPATHS = [
"commit_num",