Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.auth.smb_mount.SMBMount Class Reference
Inheritance diagram for MoinMoin.auth.smb_mount.SMBMount:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.auth.smb_mount.SMBMount:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def do_smb
def login
def logout
def request
def login_hint

Public Attributes

 server
 share
 mountpoint_fn
 dir_user
 domain
 dir_mode
 file_mode
 iocharset
 log
 coding

Static Public Attributes

 name = None
list login_inputs = []
 logout_possible = False

Detailed Description

auth plugin for (un)mounting an smb share,
    this is a wrapper around mount.cifs -o <options> //server/share mountpoint

    See man mount.cifs for details.

Definition at line 19 of file smb_mount.py.


Constructor & Destructor Documentation

def MoinMoin.auth.smb_mount.SMBMount.__init__ (   self,
  server,
  share,
  mountpoint_fn,
  dir_user,
  domain,
  dir_mode = '0700',
  file_mode = '0600',
  iocharset = 'utf-8',
  coding = 'utf-8',
  log = '/dev/null' 
)

Definition at line 37 of file smb_mount.py.

00037 
00038         ):
00039         BaseAuth.__init__(self)
00040         self.server = server
00041         self.share = share
00042         self.mountpoint_fn = mountpoint_fn
00043         self.dir_user = dir_user
00044         self.domain = domain
00045         self.dir_mode = dir_mode
00046         self.file_mode = file_mode
00047         self.iocharset = iocharset
00048         self.log = log
00049         self.coding = coding


Member Function Documentation

def MoinMoin.auth.smb_mount.SMBMount.do_smb (   self,
  request,
  username,
  password,
  login 
)

Definition at line 50 of file smb_mount.py.

00050 
00051     def do_smb(self, request, username, password, login):
00052         logging.debug("login=%s logout=%s: got name=%s" % (login, not login, username))
00053 
00054         import os, pwd, subprocess
00055         web_username = self.dir_user
00056         web_uid = pwd.getpwnam(web_username)[2] # XXX better just use current uid?
00057 
00058         mountpoint = self.mountpoint_fn(username)
00059         if login:
00060             cmd = u"sudo mount -t cifs -o user=%(user)s,domain=%(domain)s,uid=%(uid)d,dir_mode=%(dir_mode)s,file_mode=%(file_mode)s,iocharset=%(iocharset)s //%(server)s/%(share)s %(mountpoint)s >>%(log)s 2>&1"
00061         else:
00062             cmd = u"sudo umount %(mountpoint)s >>%(log)s 2>&1"
00063 
00064         cmd = cmd % {
00065             'user': username,
00066             'uid': web_uid,
00067             'domain': self.domain,
00068             'server': self.server,
00069             'share': self.share,
00070             'mountpoint': mountpoint,
00071             'dir_mode': self.dir_mode,
00072             'file_mode': self.file_mode,
00073             'iocharset': self.iocharset,
00074             'log': self.log,
00075         }
00076         env = os.environ.copy()
00077         if login:
00078             try:
00079                 if not os.path.exists(mountpoint):
00080                     os.makedirs(mountpoint) # the dir containing the mountpoint must be writeable for us!
00081             except OSError:
00082                 pass
00083             env['PASSWD'] = password.encode(self.coding)
00084         subprocess.call(cmd.encode(self.coding), env=env, shell=True)

Here is the caller graph for this function:

def MoinMoin.auth.smb_mount.SMBMount.login (   self,
  request,
  user_obj,
  kw 
)

Reimplemented from MoinMoin.auth.BaseAuth.

Definition at line 85 of file smb_mount.py.

00085 
00086     def login(self, request, user_obj, **kw):
00087         username = kw.get('username')
00088         password = kw.get('password')
00089         if user_obj and user_obj.valid:
00090             self.do_smb(request, username, password, True)
00091         return ContinueLogin(user_obj)

Here is the call graph for this function:

def MoinMoin.auth.BaseAuth.login_hint (   self,
  request 
) [inherited]

Reimplemented in MoinMoin.auth.openidrp.OpenIDAuth, and MoinMoin.auth.MoinAuth.

Definition at line 213 of file __init__.py.

00213 
00214     def login_hint(self, request):
00215         return None

def MoinMoin.auth.smb_mount.SMBMount.logout (   self,
  request,
  user_obj,
  kw 
)

Reimplemented from MoinMoin.auth.BaseAuth.

Definition at line 92 of file smb_mount.py.

00092 
00093     def logout(self, request, user_obj, **kw):
00094         if user_obj and not user_obj.valid:
00095             self.do_smb(request, user_obj.name, None, False)
00096         return user_obj, True
00097 

Here is the call graph for this function:

def MoinMoin.auth.BaseAuth.request (   self,
  request,
  user_obj,
  kw 
) [inherited]

Member Data Documentation

Definition at line 48 of file smb_mount.py.

Definition at line 44 of file smb_mount.py.

Definition at line 42 of file smb_mount.py.

Definition at line 43 of file smb_mount.py.

Definition at line 45 of file smb_mount.py.

Definition at line 46 of file smb_mount.py.

Definition at line 47 of file smb_mount.py.

list MoinMoin.auth.BaseAuth.login_inputs = [] [static, inherited]
MoinMoin.auth.BaseAuth.logout_possible = False [static, inherited]

Definition at line 41 of file smb_mount.py.

MoinMoin.auth.BaseAuth.name = None [static, inherited]

Definition at line 39 of file smb_mount.py.

Definition at line 40 of file smb_mount.py.


The documentation for this class was generated from the following file: