~ubuntu-branches/ubuntu/trusty/nss-pam-ldapd/trusty-proposed

« back to all changes in this revision

Viewing changes to pynslcd/alias.py

  • Committer: Bazaar Package Importer
  • Author(s): Arthur de Jong
  • Date: 2011-03-10 22:00:00 UTC
  • mto: (14.1.5 experimental) (16.1.6)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20110310220000-tyhxifj2ovpxnqqm
Tags: 0.8.1
* SECURITY FIX: the PAM module will allow authentication for users that do
                not exist in LDAP, this allows login to local users with an
                incorrect password (CVE-2011-0438)
                the explotability of the problem depends on the details of
                the PAM stack and the use of the minimum_uid PAM option
* add FreeBSD support, partially imported from the FreeBSD port (thanks to
  Jacques Vidrine, Artem Kazakov and Alexander V. Chernikov)
* document how to replace name pam_check_service_attr and
  pam_check_host_attr options in PADL's pam_ldap with with pam_authz_search
  in nss-pam-ldapd (closes: #610925)
* implement a fqdn variable that can be used in pam_authz_search filters
* create the directory to hold the socket and pidfile on startup
* implement host, network and netgroup support in pynslcd

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# alias.py - lookup functions for aliasnet addresses
 
3
#
 
4
# Copyright (C) 2010 Arthur de Jong
 
5
#
 
6
# This library is free software; you can redistribute it and/or
 
7
# modify it under the terms of the GNU Lesser General Public
 
8
# License as published by the Free Software Foundation; either
 
9
# version 2.1 of the License, or (at your option) any later version.
 
10
#
 
11
# This library is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
# Lesser General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU Lesser General Public
 
17
# License along with this library; if not, write to the Free Software
 
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
# 02110-1301 USA
 
20
 
 
21
import constants
 
22
import common
 
23
 
 
24
import ldap
 
25
import ldap.filter
 
26
 
 
27
 
 
28
class AliasRequest(common.Request):
 
29
 
 
30
    filter = '(objectClass=nisMailAlias)'
 
31
 
 
32
    attmap_cn         = 'cn'
 
33
    attmap_rfc822MailMember = 'rfc822MailMember'
 
34
 
 
35
    attributes = ( 'cn', 'rfc822MailMember' )
 
36
 
 
37
    def write(self, entry):
 
38
        dn, attributes = entry
 
39
        # get name and check against requested name
 
40
        names = attributes.get(self.attmap_cn, [])
 
41
        if not names:
 
42
            logging.error('Error: entry %s does not contain %s value', dn, self.attmap_cn)
 
43
            return
 
44
        if self.name:
 
45
            if self.name.lower() not in (x.lower() for x in names):
 
46
                return
 
47
            names = ( self.name, )
 
48
        # get the members of the alias
 
49
        members = attributes.get(self.attmap_rfc822MailMember, [])
 
50
        if not members:
 
51
            logging.error('Error: entry %s does not contain %s value', dn, self.attmap_rfc822MailMember)
 
52
            return
 
53
        # write results
 
54
        for name in names:
 
55
            self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)
 
56
            self.fp.write_string(name)
 
57
            self.fp.write_stringlist(members)
 
58
 
 
59
 
 
60
class AliasByNameRequest(AliasRequest):
 
61
 
 
62
    action = constants.NSLCD_ACTION_ALIAS_BYNAME
 
63
 
 
64
    def read_parameters(self):
 
65
        self.name = self.fp.read_string()
 
66
 
 
67
    def mk_filter(self):
 
68
        return '(&%s(%s=%s))' % ( self.filter,
 
69
                  self.attmap_cn, ldap.filter.escape_filter_chars(self.name) )
 
70
 
 
71
 
 
72
class AliasAllRequest(AliasRequest):
 
73
 
 
74
    action = constants.NSLCD_ACTION_ALIAS_ALL