Ejemplo n.º 1
0
 def __init__(self, opts):
     sec1, sec2 = self._get_security(opts)
     #        authsys1 = rpc.SecAuthSys(0, opts.machinename, opts.uid, opts.gid, [])
     authsys2 = rpc.SecAuthSys(0, opts.machinename, opts.uid + 1,
                               opts.gid + 1, [])
     self.c1 = NFS4Client('client1_pid%i' % os.getpid(),
                          opts.server,
                          opts.port,
                          opts.path,
                          sec_list=[sec1],
                          opts=opts)
     self.c2 = NFS4Client('client2_pid%i' % os.getpid(),
                          opts.server,
                          opts.port,
                          opts.path,
                          sec_list=[authsys2],
                          opts=opts)
     self.longname = "a" * 512
     self.uid = 0
     self.gid = 0
     self.opts = opts
     self.filedata = "This is the file test data."
     self.linkdata = "/etc/X11"
     self.stateid0 = stateid4(0, '')
     self.stateid1 = stateid4(0xffffffff, '\xff' * 12)
Ejemplo n.º 2
0
 def open_file(self, mds_fh):
     seqid=0
     access = const4.OPEN4_SHARE_ACCESS_BOTH
     deny = const4.OPEN4_SHARE_DENY_NONE
     attrs = {const4.FATTR4_MODE: 0777}
     owner = "mds"
     mode = const4.GUARDED4
     verifier = self.sess.c.verifier
     openflag = type4.openflag4(const4.OPEN4_CREATE, type4.createhow4(mode, attrs, verifier))
     name = self.fh_to_name(mds_fh)
     while True:
         if mds_fh in self.filehandles:
             return
         open_op = op4.open(seqid, access, deny,
                           type4.open_owner4(self.sess.client.clientid, owner),
                           openflag, type4.open_claim4(const4.CLAIM_NULL, name))
         res = self._execute(nfs4lib.use_obj(self.path_fh) + [open_op, op4.getfh()], exceptions=[const4.NFS4ERR_EXIST])
         if res.status == const4.NFS4_OK:
              ds_fh = res.resarray[-1].opgetfh.resok4.object
              ds_openstateid = type4.stateid4(0, res.resarray[-2].stateid.other)
              self.filehandles[mds_fh] = (ds_fh, ds_openstateid)
              return
         elif res.status == const4.NFS4ERR_EXIST:
              openflag = type4.openflag4(const4.OPEN4_NOCREATE)
         else:
             raise RuntimeError
Ejemplo n.º 3
0
 def open_file(self, mds_fh):
     seqid = 0
     access = const4.OPEN4_SHARE_ACCESS_BOTH
     deny = const4.OPEN4_SHARE_DENY_NONE
     attrs = {const4.FATTR4_MODE: 0777}
     owner = "mds"
     mode = const4.GUARDED4
     verifier = self.sess.c.verifier
     openflag = type4.openflag4(const4.OPEN4_CREATE,
                                type4.createhow4(mode, attrs, verifier))
     name = self.fh_to_name(mds_fh)
     while True:
         if mds_fh in self.filehandles:
             return
         open_op = op4.open(
             seqid, access, deny,
             type4.open_owner4(self.sess.client.clientid, owner), openflag,
             type4.open_claim4(const4.CLAIM_NULL, name))
         res = self._execute(nfs4lib.use_obj(self.path_fh) +
                             [open_op, op4.getfh()],
                             exceptions=[const4.NFS4ERR_EXIST])
         if res.status == const4.NFS4_OK:
             ds_fh = res.resarray[-1].opgetfh.resok4.object
             ds_openstateid = type4.stateid4(0,
                                             res.resarray[-2].stateid.other)
             self.filehandles[mds_fh] = (ds_fh, ds_openstateid)
             return
         elif res.status == const4.NFS4ERR_EXIST:
             openflag = type4.openflag4(const4.OPEN4_NOCREATE)
         else:
             raise RuntimeError
Ejemplo n.º 4
0
    def __init__(self, opts):
        sec1, sec2 = self._get_security(opts)
#        authsys1 = rpc.SecAuthSys(0, opts.machinename, opts.uid, opts.gid, [])
        authsys2 = rpc.SecAuthSys(0, opts.machinename, opts.uid+1, opts.gid+1, [])
        self.c1 = NFS4Client('client1_pid%i' % os.getpid(),
                             opts.server, opts.port, opts.path,
                             sec_list=[sec1], opts=opts)
        self.c2 = NFS4Client('client2_pid%i' % os.getpid(),
                             opts.server, opts.port, opts.path,
                             sec_list=[authsys2], opts=opts)
        self.longname = "a"*512
        self.uid = 0
        self.gid = 0
        self.opts = opts
        self.filedata = "This is the file test data."
        self.linkdata = "/etc/X11"
        self.stateid0 = stateid4(0, '')
        self.stateid1 = stateid4(0xffffffff, '\xff'*12)
Ejemplo n.º 5
0
def makeBadID(stateid):
    """Given a good stateid, makes it bad

    NOTE this looks into server opaque data, thus is very specific
    to server implementation. Consider this version of the function
    an example.
    """

    boottime = stateid.other[0:4]
    bad = stateid4(stateid.seqid , boottime+"\07\07\07\07\07\07\07\07")
    return bad
Ejemplo n.º 6
0
def makeBadID(stateid):
    """Given a good stateid, makes it bad

    NOTE this looks into server opaque data, thus is very specific
    to server implementation. Consider this version of the function
    an example.
    """

    boottime = stateid.other[0:4]
    bad = stateid4(stateid.seqid, boottime + "\07\07\07\07\07\07\07\07")
    return bad
Ejemplo n.º 7
0
def testBadStateid(t, env):
    """LOCK should return NFS4ERR_BAD_STATEID if use a bad id

    FLAGS: lock badid all
    DEPEND: MKFILE
    CODE: LOCK11
    """
    c = env.c1
    c.init_connection()
    fh, stateid = c.create_confirm(t.word())
    res = c.lock_file(t.word(), fh, stateid4(0, b''))
    check(res, NFS4ERR_BAD_STATEID, "LOCK with a bad stateid")
Ejemplo n.º 8
0
def testBadStateid(t, env):
    """LOCK should return NFS4ERR_BAD_STATEID if use a bad id

    FLAGS: lock badid all
    DEPEND: MKFILE
    CODE: LOCK11
    """
    c = env.c1
    c.init_connection()
    fh, stateid = c.create_confirm(t.code)
    res = c.lock_file(t.code, fh, stateid4(0, ''))
    check(res, NFS4ERR_BAD_STATEID, "LOCK with a bad stateid")
Ejemplo n.º 9
0
def testBadStateid(t, env):
    """OPEN_CONFIRM with a bad state should return NFS4ERR_BAD_STATEID

    FLAGS: openconfirm badid all
    CODE: OPCF5
    """
    c = env.c1
    c.init_connection()
    res = c.create_file(t.code)
    check(res)
    fh = res.resarray[-1].switch.switch.object
    res = _confirm(t, c, fh, stateid4(0, ''))
    check(res, NFS4ERR_BAD_STATEID, "OPEN_CONFIRM with a bad state")
Ejemplo n.º 10
0
def testBadLockStateid(t, env):
    """LOCKU should return NFS4ERR_BAD_STATEID if use a bad id

    FLAGS: locku badid all
    DEPEND: MKFILE
    CODE: LKU8
    """
    c = env.c1
    c.init_connection()
    fh, stateid = c.create_confirm(t.word())
    res1 = c.lock_file(t.word(), fh, stateid)
    check(res1)
    res2 = c.unlock_file(1, fh, stateid4(0, b''))
    check(res2, NFS4ERR_BAD_STATEID, "LOCKU with a bad stateid")
Ejemplo n.º 11
0
def testBadLockStateid(t, env):
    """LOCKU should return NFS4ERR_BAD_STATEID if use a bad id

    FLAGS: locku badid all
    DEPEND: MKFILE
    CODE: LKU8
    """
    c = env.c1
    c.init_connection()
    fh, stateid = c.create_confirm(t.code)
    res1 = c.lock_file(t.code, fh, stateid)
    check(res1)
    res2 = c.unlock_file(1, fh, stateid4(0, ''))
    check(res2, NFS4ERR_BAD_STATEID, "LOCKU with a bad stateid")
Ejemplo n.º 12
0
def makeBadIDganesha(stateid):
    """Given a good stateid, makes it bad

    NOTE this looks into server opaque data, thus is very specific
    to the Ganesha server.  All tests which use this function have
    the flag 'ganesha'
    """

    # Ganesha encodes the clientid into the first 64 bits of the 96 bit
    # other field, and then a 32 bit counter. We set that counter to 0
    # to simulate a bad stateid.

    clientid = stateid.other[0:8]
    bad = stateid4(stateid.seqid , clientid+"\0\0\0\0")
    return bad
Ejemplo n.º 13
0
def makeBadIDganesha(stateid):
    """Given a good stateid, makes it bad

    NOTE this looks into server opaque data, thus is very specific
    to the Ganesha server.  All tests which use this function have
    the flag 'ganesha'
    """

    # Ganesha encodes the clientid into the first 64 bits of the 96 bit
    # other field, and then a 32 bit counter. We set that counter to 0
    # to simulate a bad stateid.

    clientid = stateid.other[0:8]
    bad = stateid4(stateid.seqid, clientid + "\0\0\0\0")
    return bad
Ejemplo n.º 14
0
def makeStaleId(stateid):
    """Given a good stateid, makes it stale

    NOTE this looks into server opaque data, thus is very specific
    to the CITI linux server.  All tests which use this function have
    the flag 'staleid'. This is also valid for Ganesha (and probably
    other server implementations, putting a 32 bit epoch into the
    first 32 bits of the stateid is the easiest way to detect stale
    stateid after reboot).
    """
    # The first 4 bytes of the linux stateid correspond to a time.
    # Choose a value older than any reasonable time, without
    # risking the chance of conflict with the zero-stateid.
    staletime = "\0\0\0\1"
    stale = stateid4(stateid.seqid , staletime+"\0\0\0\0\0\0\0\0")
    return stale
Ejemplo n.º 15
0
def makeStaleId(stateid):
    """Given a good stateid, makes it stale

    NOTE this looks into server opaque data, thus is very specific
    to the CITI linux server.  All tests which use this function have
    the flag 'staleid'. This is also valid for Ganesha (and probably
    other server implementations, putting a 32 bit epoch into the
    first 32 bits of the stateid is the easiest way to detect stale
    stateid after reboot).
    """
    # The first 4 bytes of the linux stateid correspond to a time.
    # Choose a value older than any reasonable time, without
    # risking the chance of conflict with the zero-stateid.
    staletime = "\0\0\0\1"
    stale = stateid4(stateid.seqid, staletime + "\0\0\0\0\0\0\0\0")
    return stale
Ejemplo n.º 16
0
from st_create_session import create_session
from xdrdef.nfs4_const import *

from environment import check, fail, create_file, open_file, close_file
from environment import open_create_file_op, use_obj
from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
from xdrdef.nfs4_type import open_to_lock_owner4
import nfs_ops

op = nfs_ops.NFS4ops()
import threading


current_stateid = stateid4(1, "\0" * 12)


def testOpenAndClose(t, env):
    """test current state id processing by having OPEN and CLOSE
       in a single compound

    FLAGS: currentstateid all
    CODE: CSID1
    """
    sess1 = env.c1.new_client_session(env.testname(t))

    open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE)
    res = sess1.compound(open_op + [op.close(0, current_stateid)])
    check(res, NFS4_OK)

Ejemplo n.º 17
0
from st_create_session import create_session
from xdrdef.nfs4_const import *

from .environment import check, fail, create_file, open_file, close_file
from .environment import open_create_file_op, use_obj
from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
from xdrdef.nfs4_type import open_to_lock_owner4
import nfs_ops
op = nfs_ops.NFS4ops()
import threading


current_stateid = stateid4(1, '\0' * 12)

def testOpenAndClose(t, env):
    """test current state id processing by having OPEN and CLOSE
       in a single compound

    FLAGS: currentstateid all
    CODE: CSID1
    """
    sess1 = env.c1.new_client_session(env.testname(t))

    open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE)
    res = sess1.compound(open_op + [op.close(0, current_stateid)])
    check(res, NFS4_OK)

def testLockLockU(t, env):
    """test current state id processing by having LOCK and LOCKU
       in a single compound
from st_create_session import create_session
from xdrdef.nfs4_const import *

from environment import check, checklist, fail, create_file, open_file, close_file
from environment import open_create_file_op, use_obj
from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
from xdrdef.nfs4_type import open_to_lock_owner4
import nfs_ops
op = nfs_ops.NFS4ops()
import threading

current_stateid = stateid4(1, '\0' * 12)


def testOpenAndClose(t, env):
    """test current state id processing by having OPEN and CLOSE
       in a single compound

    FLAGS: currentstateid all
    CODE: CSID1
    """
    sess1 = env.c1.new_client_session(env.testname(t))

    open_op = open_create_file_op(sess1,
                                  env.testname(t),
                                  open_create=OPEN4_CREATE)
    res = sess1.compound(open_op + [op.close(0, current_stateid)])
    check(res, NFS4_OK)