From e8f9ef422303b6366ba21774f10ed8a10d51b78b Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 1 May 2014 15:31:58 +0100 Subject: [PATCH] Implement "bos setrestricted" Signed-off-by: David Howells --- rpc-api/bos.xg | 2 + suite/commands/bos/setrestricted.py | 59 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 suite/commands/bos/setrestricted.py diff --git a/rpc-api/bos.xg b/rpc-api/bos.xg index 443f119..84e02d1 100644 --- a/rpc-api/bos.xg +++ b/rpc-api/bos.xg @@ -234,3 +234,5 @@ GetInstanceStrings (IN string instance, OUT string spare3) = 114; GetRestricted (OUT uint32_t *isrestricted) = 115; + +SetRestricted (IN uint32_t isrestricted) = 116; diff --git a/suite/commands/bos/setrestricted.py b/suite/commands/bos/setrestricted.py new file mode 100644 index 0000000..54c71ff --- /dev/null +++ b/suite/commands/bos/setrestricted.py @@ -0,0 +1,59 @@ +# +# AFS Server management toolkit: Put server into restricted mode +# -*- coding: utf-8 -*- +# + +__copyright__ = """ +Copyright (C) 2014 Red Hat, Inc. All Rights Reserved. +Written by David Howells (dhowells@redhat.com) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public Licence version 2 as +published by the Free Software Foundation. + +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 Licence for more details. + +You should have received a copy of the GNU General Public Licence +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +""" + +from afs.argparse import * +from afs.lib.output import * +import kafs + +help = "Place a server into restricted mode" + +command_arguments = [ + [ "server", get_bosserver, "rs", "" ], + [ "mode", get_string, "rs", "1"], + [ "cell", get_cell, "os", "" ], + [ "noauth", get_auth, "fn" ], + [ "localauth", get_auth, "fn" ], + [ "verbose", get_dummy, "fn" ], + [ "encrypt", get_dummy, "fn" ], +] + +cant_combine_arguments = [ + ( "cell", "localauth" ), + ( "noauth", "localauth" ), +] + +description = r""" +Place a server into restricted mode +""" + +def main(params): + cell = params["cell"] + bos_conn = cell.open_bos_server(params["server"], params) + + if not params["mode"].isnumeric(): + raise AFSArgumentError("The -mode argument takes a numeric value") + + try: + ret = kafs.BOZO_SetRestricted(bos_conn, int(params["mode"])) + except kafs.AbortBZACCESS: + error("failed to set restricted mode (you are not authorized for this operation)\n") -- 2.50.1