Beispiel #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(0xffffffffL, '\xff' * 12)
Beispiel #2
0
def testStolenStateid(t, env):
    """READ with incorrect permissions and somebody else's stateid

    FLAGS: read
    DEPEND: MKFILE
    CODE: RD12
    """
    c = env.c1
    c.init_connection()
    res = c.create_file(t.code, attrs={FATTR4_MODE: 0600})
    fh, stateid = c.confirm(t.code, res)
    security = c.security
    c.security = rpc.SecAuthSys(0, "whatever", 3912, 2422, [])
    res = c.read_file(fh, stateid=stateid)
    c.security = security
    checklist(res, [NFS4ERR_ACCESS, NFS4ERR_PERM], "READ with stolen stateid")
Beispiel #3
0
#!/usr/bin/env python
# nfs3lib.py - NFS3_PROTOCOL library for python

import rpc
from xdrlib import Error as XDRError
from nfs3_const import *
from nfs3_type import *
from nfs3_pack import *
import time
import struct
import socket
import sys

AuthSys = rpc.SecAuthSys(0, 'jupiter', 103558, 100, [])


class NFS3Exception(rpc.RPCError):
    pass


#An NFS procedure returned an error
class BadNFS3Res(NFS3Exception):
    def __init__(self, errcode, msg=None):
        self.errcode = errcode
        if msg:
            self.msg = msg + ': '
        else:
            self.msg = ''

    def __str__(self):
        return self.msg + "should return NFS3_OK, instead got %s" % \
Beispiel #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, [])
        authsys4 = rpc.SecAuthSys(0, opts.machinename, 10, 10, [])
        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)
        # Same auth/UID as c1, different client name.
        self.c3 = NFS4Client('client3_pid%i' % os.getpid(),
                             opts.server,
                             opts.port,
                             opts.path,
                             sec_list=[sec1],
                             opts=opts)
        # Connection for admin. Used in st_idmap.py
        self.c4 = NFS4Client('client4_pid%i' % os.getpid(),
                             opts.server,
                             opts.port,
                             opts.path,
                             sec_list=[authsys4],
                             opts=opts)

        if opts.secondserver:
            print "Using secondserver = %s" % opts.secondserver
            self.c1node2 = NFS4Client('client1_pid%i' % os.getpid(),
                                      opts.secondserver,
                                      opts.port,
                                      opts.path,
                                      sec_list=[sec1],
                                      opts=opts)
            self.c3node2 = NFS4Client('client3_pid%i' % os.getpid(),
                                      opts.secondserver,
                                      opts.port,
                                      opts.path,
                                      sec_list=[sec1],
                                      opts=opts)
            self.secondconns = [("clientid3", self.c3),
                                ("clientid3-node2", self.c3node2)]
            self.secondconn = None
        else:
            self.secondconns = [("clientid3", self.c3)]
            #self.secondconns = []
            self.secondconn = None

        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(0xffffffffL, '\xff' * 12)