本文整理汇总了Python中nis.match函数的典型用法代码示例。如果您正苦于以下问题:Python match函数的具体用法?Python match怎么用?Python match使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了match函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,login,passwd=None):
"""get user profile from NIS"""
try:
p = nis.match(login, 'passwd.byname').split(":")
except:
raise NISAUTHError('username')
# check user password using crypt and 2 character salt from passwd file
if p[1] == crypt.crypt(passwd, p[1][:2]):
# check to see if user is in valid support groups
# will have to include these groups in a settings file eventually
if not login in nis.match(AUTHORIZED_GROUP, 'group.byname').split(':')[-1].split(',') and p[3] != nis.match(AUTHORIZED_GROUP, 'group.byname').split(':')[2]:
raise NISAUTHError('group')
self.uid = p[2]
else:
raise NISAUTHError('password')
开发者ID:AgarFu,项目名称:bcfg2,代码行数:15,代码来源:nisauth.py
示例2: get_or_create_user
def get_or_create_user(self, username, request, passwd=None):
import nis
username = username.strip()
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
try:
if not passwd:
passwd = nis.match(username, 'passwd').split(':')
names = passwd[4].split(',')[0].split(' ', 1)
first_name = names[0]
last_name = None
if len(names) > 1:
last_name = names[1]
email = '%[email protected]%s' % (username, settings.NIS_EMAIL_DOMAIN)
user = User(username=username,
password='',
first_name=first_name,
last_name=last_name or '',
email=email)
user.is_staff = False
user.is_superuser = False
user.set_unusable_password()
user.save()
except nis.error:
pass
return user
开发者ID:abhijo89,项目名称:reviewboard,代码行数:32,代码来源:backends.py
示例3: authenticate
def authenticate(self, username, password):
"""Authenticate the user.
This will authenticate the username and return the appropriate User
object, or None.
"""
import crypt
import nis
username = username.strip()
try:
passwd = nis.match(username, 'passwd').split(':')
original_crypted = passwd[1]
new_crypted = crypt.crypt(password, original_crypted)
if original_crypted == new_crypted:
return self.get_or_create_user(username, None, passwd)
except nis.error:
# FIXME I'm not sure under what situations this would fail (maybe
# if their NIS server is down), but it'd be nice to inform the
# user.
pass
return None
开发者ID:CharanKamal-CLI,项目名称:reviewboard,代码行数:25,代码来源:backends.py
示例4: realname
def realname(host):
try:
import nis
except ImportError:
return host
try:
response = nis.match(host, 'hosts.byaddr')
words = string.split(response)
return words[1]
except nis.error:
return host
开发者ID:asottile,项目名称:ancient-pythons,代码行数:11,代码来源:logsumm.py
示例5: _listOneNISUser
def _listOneNISUser(self,username):
roles=[self.default_role]
try:
nis_user=nis.match(username,'passwd.byname')
username,passwd,other=string.split(nis_user,':',2)
data={'username':username,
'password':passwd,
'roles':roles}
except nis.error:
data=None
return data
开发者ID:denys-duchier,项目名称:Scolar,代码行数:11,代码来源:nisAuthSource.py
示例6: authenticate
def authenticate(self, username, password):
import crypt
import nis
username = username.strip()
try:
passwd = nis.match(username, 'passwd').split(':')
original_crypted = passwd[1]
new_crypted = crypt.crypt(password, original_crypted)
if original_crypted == new_crypted:
return self.get_or_create_user(username, passwd)
except nis.error:
# FIXME I'm not sure under what situations this would fail (maybe if
# their NIS server is down), but it'd be nice to inform the user.
pass
开发者ID:cortextual,项目名称:reviewboard,代码行数:17,代码来源:backends.py
示例7: nischeck
def nischeck(username,password):
if username:
try:
un=nis.match(username,"passwd").split(":")[1]
if un.__len__()> 16:
if crypt.crypt(password,un[0:12])==un:
return 1
else:
return 0
else:
if crypt.crypt(password,un)==un:
return 1
else:
return 0
except:
return 0
开发者ID:ylzmax,项目名称:vncmanager,代码行数:17,代码来源:views.py
示例8: get_nis_info
def get_nis_info(username):
try:
p = pwd.getpwnam(username)
except KeyError:
return (None, None, None)
if p.pw_passwd == "*GONE*":
return (None, None, None)
s = string.split(p.pw_gecos, ' ')
if(len(s) < 2):
s.append('')
em = ""
try:
em = nis.match(username, 'mail.aliases').partition('@')[0] + "@windriver.com"
except KeyError:
em = ""
return (s[0], s[1], em)
开发者ID:benoitl,项目名称:askbot-devel,代码行数:19,代码来源:util.py
示例9:
print 'nis.maps()'
try:
maps = nis.maps()
except nis.error, msg:
# NIS is probably not active, so this test isn't useful
if verbose:
raise TestFailed, msg
# only do this if running under the regression suite
raise TestSkipped, msg
done = 0
for nismap in maps:
if verbose:
print nismap
mapping = nis.cat(nismap)
for k, v in mapping.items():
if verbose:
print ' ', k, v
if not k:
continue
if nis.match(k, nismap) <> v:
print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
else:
# just test the one key, otherwise this test could take a
# very long time
done = 1
break
if done:
break
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:29,代码来源:test_nis.py
示例10:
raise TestFailed, msg
# only do this if running under the regression suite
raise TestSkipped, msg
try:
# On some systems, this map is only accessible to the
# super user
maps.remove("passwd.adjunct.byname")
except ValueError:
pass
done = 0
for nismap in maps:
if verbose:
print nismap
mapping = nis.cat(nismap)
for k, v in mapping.items():
if verbose:
print " ", k, v
if not k:
continue
if nis.match(k, nismap) != v:
print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
else:
# just test the one key, otherwise this test could take a
# very long time
done = 1
break
if done:
break
开发者ID:thecodemaiden,项目名称:breve,代码行数:30,代码来源:test_nis.py
示例11: min
#pylint: disable-msg=E1101
print AP2.O_SHLOCK, AP2.O_EXLOCK
#pylint: disable-msg=E1101
print AP3.rpc_paths
#pylint: disable-msg=E1101
print AP4.rpc_paths
print AP5.subversion
print AP6.family
print AP6.type
print AP6.proto
print heapq.nsmallest(1, ['a', 'b'], key=lambda x: 'your mom')
print heapq.nlargest(1, ['a', 'b'], key=lambda x: 'your mom')
print min([], key=lambda x: 'your mom')
print max([], key=lambda x: 'your mom')
print match('foo', domain='lalala')
print maps('foo', domain='lalala')
webbrowser.open(autoraise=True)
######### This is not detectable using pylint machinery, I think.
# try:
# print 'foo'
# except IOError, e:
# print 'bar'
# else:
# print 'baz'
# finally:
# print 'zoinks'
######### This crashes pylint, so... no.
# def generator_func():
开发者ID:jedwing,项目名称:PyVersionLint,代码行数:31,代码来源:p24.py
示例12:
from test_support import verbose, TestFailed, TestSkipped
import nis
print 'nis.maps()'
try:
maps = nis.maps()
except nis.error, msg:
# NIS is probably not active, so this test isn't useful
if verbose:
raise TestFailed, msg
# only do this if running under the regression suite
raise TestSkipped, msg
done = 0
for nismap in maps:
if verbose:
print nismap
mapping = nis.cat(nismap)
for k, v in mapping.items():
if verbose:
print ' ', k, v
if not k:
continue
if nis.match(k, nismap) != v:
print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
else:
# just test the one key, otherwise this test could take a
# very long time
done = 1
break
if done:
break
开发者ID:mcyril,项目名称:ravel-ftn,代码行数:30,代码来源:test_nis.py
示例13:
import nis
import string
print nis.cat("ypservers")
print string.split(nis.match("bacon", "hosts.byname"))
## {'bacon.spam.egg': 'bacon.spam.egg'}
## ['194.18.155.250', 'bacon.spam.egg', 'bacon', 'spam-010']
开发者ID:mtslong,项目名称:demo,代码行数:8,代码来源:nis-example-1.py
注:本文中的nis.match函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论