Changeset 808
- Timestamp:
- 09/08/08 09:35:13 (3 months ago)
- Files:
-
- 1 modified
-
ares/trunk/ares.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ares/trunk/ares.py
r803 r808 40 40 self.root ='fakeroot/' 41 41 self.net = '192.168.1.0/24' 42 self.fqdn = 'ares. clientdomain.com'42 self.fqdn = 'ares.q1' 43 43 else: 44 44 self.root = '/' 45 # TODO: find a way to configure these 46 self.net = '192.168.2.0/24' 47 self.fqdn = 'ares.q1' 45 48 self.aug = augeas.Augeas(root=self.root) 46 49 … … 90 93 self._ares = ares 91 94 self._cfg = '/files/etc/ldap/slapd.conf' 92 self._lds = ldap.open('localhost')93 self._lds.simple_bind_s('cn=admin,dc=nodomain', 'admin')94 95 95 96 def _add_schema(self,schema): … … 187 188 self._add_schema(schema) 188 189 190 # Configure the client 191 aug = self._ares.aug 192 cfg = '/files/etc/ldap.conf/' 193 aug.set(cfg + 'bind_policy','soft') 194 189 195 # Stop here if we not running as root 190 aug = self._ares.aug191 196 if aug.get('/augeas/root') == 'fakeroot/': 192 197 return … … 198 203 199 204 # Populate the database 205 self._lds = ldap.open('localhost') 206 self._lds.simple_bind_s('cn=admin,dc=nodomain', 'admin') 207 200 208 entries = [ 201 209 self._entry_top('AddressBook'), … … 213 221 self._add_entry(entry) 214 222 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 215 229 # 216 230 # Setup squid … … 226 240 cfg = self._cfg 227 241 228 # Add acl 242 # Add acl for local network 229 243 acl_name = 'local_network' 230 244 if not aug.match(cfg + '/acl/' + acl_name): … … 232 246 aug.set(key + '/type', 'src') 233 247 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) 234 257 235 258 # Add http access … … 294 317 key = k.rstrip('/ipaddr') 295 318 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') 297 321 298 322 # … … 496 520 aug.set(rec, 'data') 497 521 498 aug.set(rec + '/path', '/srv/ data')522 aug.set(rec + '/path', '/srv/nfs/share') 499 523 aug.set(rec + '/browseable', 'yes') 500 524 aug.set(rec + '/writeable', 'yes') … … 508 532 return 509 533 510 data = '/srv/data' 511 512 if not os.path.exists(data): 513 os.mkdir(data) 534 data = '/srv/nfs/share' 514 535 515 536 os.chown(data, 0, grp.getgrnam('users')[2]) … … 535 556 536 557 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' ]: 538 560 if dir not in dirs: 539 key = cfg + '/dir[%d]' % (len( dirs)+1)561 key = cfg + '/dir[%d]' % (len(aug.match(cfg + '/dir'))+1) 540 562 aug.set(key, dir) 541 563 aug.set(key + '/client', '*')
