]> www.infradead.org Git - users/dhowells/kafs-utils.git/commitdiff
Implement "bos setrestricted"
authorDavid Howells <dhowells@redhat.com>
Thu, 1 May 2014 14:31:58 +0000 (15:31 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 1 May 2014 14:31:58 +0000 (15:31 +0100)
Signed-off-by: David Howells <dhowells@redhat.com>
rpc-api/bos.xg
suite/commands/bos/setrestricted.py [new file with mode: 0644]

index 443f11964b071501336ccbead67c74e7a6f2b311..84e02d15054c331c3b9d571d03ff1b0a21edb6ed 100644 (file)
@@ -234,3 +234,5 @@ GetInstanceStrings (IN string instance<BOZO_BSSIZE>,
                    OUT string spare3<BOZO_BSSIZE>) = 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 (file)
index 0000000..54c71ff
--- /dev/null
@@ -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",         "<machine name>" ],
+    [ "mode",           get_string,             "rs",         "1"],
+    [ "cell",           get_cell,               "os",         "<cell name>" ],
+    [ "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")