Changeset 808

Show
Ignore:
Timestamp:
09/08/08 09:35:13 (3 months ago)
Author:
free
Message:

Open SSL ports for IM protocols

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ares/trunk/ares.py

    r803 r808  
    4040            self.root  ='fakeroot/' 
    4141            self.net   = '192.168.1.0/24' 
    42             self.fqdn  = 'ares.clientdomain.com' 
     42            self.fqdn  = 'ares.q1' 
    4343        else: 
    4444            self.root  = '/' 
     45            # TODO: find a way to configure these 
     46            self.net   = '192.168.2.0/24' 
     47            self.fqdn  = 'ares.q1' 
    4548        self.aug   = augeas.Augeas(root=self.root) 
    4649 
     
    9093        self._ares = ares 
    9194        self._cfg  = '/files/etc/ldap/slapd.conf' 
    92         self._lds  = ldap.open('localhost') 
    93         self._lds.simple_bind_s('cn=admin,dc=nodomain', 'admin') 
    9495 
    9596    def _add_schema(self,schema): 
     
    187188            self._add_schema(schema) 
    188189 
     190        # Configure the client 
     191        aug = self._ares.aug 
     192        cfg = '/files/etc/ldap.conf/' 
     193        aug.set(cfg + 'bind_policy','soft') 
     194 
    189195        # Stop here if we not running as root 
    190         aug = self._ares.aug 
    191196        if aug.get('/augeas/root') == 'fakeroot/': 
    192197            return 
     
    198203 
    199204        # Populate the database 
     205        self._lds  = ldap.open('localhost') 
     206        self._lds.simple_bind_s('cn=admin,dc=nodomain', 'admin') 
     207 
    200208        entries = [ 
    201209            self._entry_top('AddressBook'), 
     
    213221            self._add_entry(entry) 
    214222 
     223        # Configure client authentication 
     224        os.chown('/etc', 0, 0) 
     225        os.chown('/usr', 0, 0) 
     226        if os.system('auth-client-config -a -p lac_ldap') != 0: 
     227            raise ErosError('auth-client-config failed') 
     228 
    215229# 
    216230# Setup squid 
     
    226240        cfg = self._cfg 
    227241 
    228         # Add acl 
     242        # Add acl for local network 
    229243        acl_name = 'local_network' 
    230244        if not aug.match(cfg + '/acl/' + acl_name): 
     
    232246            aug.set(key + '/type', 'src') 
    233247            aug.set(key + '/setting', self._ares.net) 
     248 
     249        # Open SSL ports for IM protocolos 
     250        acl_name = 'SSL_ports' 
     251        acl_ports = [ aug.get(key) for key in aug.match(cfg + '/acl/' + acl_name + '/setting') ] 
     252        for port in [ '5050', '5222', '5190' ]: 
     253            if port not in acl_ports: 
     254                key = '%s/acl[%d]/%s' % (cfg, len(aug.match(cfg + '/acl')) + 1, acl_name) 
     255                aug.set(key + '/type', 'port') 
     256                aug.set(key + '/setting', port) 
    234257 
    235258        # Add http access 
     
    294317                key = k.rstrip('/ipaddr') 
    295318        aug.set(key + '/ipaddr', ip) 
    296         aug.set(key + '/canonical', 'ares') 
     319        aug.set(key + '/canonical', self._ares.fqdn) 
     320        aug.set(key + '/alias', 'ares') 
    297321 
    298322# 
     
    496520            aug.set(rec, 'data') 
    497521 
    498         aug.set(rec + '/path', '/srv/data') 
     522        aug.set(rec + '/path', '/srv/nfs/share') 
    499523        aug.set(rec + '/browseable', 'yes') 
    500524        aug.set(rec + '/writeable', 'yes') 
     
    508532            return 
    509533 
    510         data = '/srv/data' 
    511  
    512         if not os.path.exists(data): 
    513             os.mkdir(data) 
     534        data = '/srv/nfs/share' 
    514535 
    515536        os.chown(data, 0, grp.getgrnam('users')[2]) 
     
    535556 
    536557        dirs = [ aug.get(key) for key in aug.match(cfg + '/dir') ] 
    537         for dir in [ '/home', '/srv/data' ]: 
     558 
     559        for dir in [ '/srv/nfs' ]: 
    538560            if dir not in dirs: 
    539                 key = cfg + '/dir[%d]' % (len(dirs)+1) 
     561                key = cfg + '/dir[%d]' % (len(aug.match(cfg + '/dir'))+1) 
    540562                aug.set(key, dir) 
    541563                aug.set(key + '/client', '*')