#!/usr/bin/env python
#
# Tool to setup a program into a RSBAC JAIL
# The information about the jail setup must be placed in /etc/rsbac/jail/{config_name}.json.
# 
# Usage: rsbac-run-jail --help
#
# Copyright (C) 2008-2014 Jens Kasten <jens@kasten-edv.de>
#
# 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 3 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, see <http://www.gnu.org/licenses/>
#

import argparse

from rsbactools import jail

def main():
    parser = argparse.ArgumentParser(
        description="Set a given program into a RSBAC JAIL.")

    parser.add_argument("-v", "--verbose", default=False, action="store_true",
        help="enabled verbosity")
    parser.add_argument("-d", "--dry-run", default=False, action="store_true",
        help="do not execute the command")
    parser.add_argument("-c", "--config-file",
        metavar="config-file",
        help="config-file except as a valid json file in '%s'" %
            jail.RSBAC_JAIL_CONFIG_DIR)
    parser.add_argument("program", default=[], nargs=argparse.REMAINDER, 
        help="program with arguments to execute")
   
    args = parser.parse_args()
    
    if not args.program:
        parser.print_usage()
        return

    jail.RunJail(vars(args)).run()


if __name__ == "__main__":
    main()
