X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=omf_keys%2Fkey_fs.py;h=383b43252bcb5f7d2d0b9bad21041dcebb7d6f35;hb=4f4b6a83adff080c491ebf3d186f3e9205d61e46;hp=80cdc429bcf9654fe517f355e9c95693744d628c;hpb=ebd3b79100d211ed27c4fb8ed80cb40533b0fc36;p=playground.git diff --git a/omf_keys/key_fs.py b/omf_keys/key_fs.py index 80cdc42..383b432 100644 --- a/omf_keys/key_fs.py +++ b/omf_keys/key_fs.py @@ -3,11 +3,23 @@ # A FUSE filesystem implementation to provide a file interface for # vsys_publickeys VSYS script. To be used by OMF Resource Controller. +# Usage: ./keys_fs.py /keys +# ls /keys +# cat /keys/all + +# NOTE: +# Sliver has to have following ccapabilities set. +# SECURE_MOUNT +# BINARY_MOUNT + + import os +import sys import stat import errno import fuse -import sys +import fcntl +import select from fuse import Fuse fuse.fuse_python_api = (0, 2) @@ -15,9 +27,20 @@ fuse.fuse_python_api = (0, 2) keys_dir = "/keys" keys_file = os.path.join(keys_dir, "all") -# TODO: for Giovanni def read_keys(): - return "reading PLC users' public keys\n" + fin = os.open("/vsys/publickeys.in", os.O_NONBLOCK | os.O_WRONLY) + fout = os.open("/vsys/publickeys.out", os.O_NONBLOCK | os.O_RDONLY) + + in_flags = fcntl.fcntl(fin, fcntl.F_GETFL) + out_flags = fcntl.fcntl(fin, fcntl.F_GETFL) + + res = select.select([fout], [], []) + + fcntl.fcntl(fin, fcntl.F_SETFL, in_flags & ~os.O_NONBLOCK) + fcntl.fcntl(fout, fcntl.F_SETFL, out_flags & ~os.O_NONBLOCK) + + f = os.fdopen(fout, "r") + return f.read() class MyStat(fuse.Stat): def __init__(self):