| | 432 | |
| | 433 | # |
| | 434 | # Fetchmail |
| | 435 | # |
| | 436 | class _Fetchmail: |
| | 437 | |
| | 438 | def __init__(self, ares): |
| | 439 | self._ares = ares |
| | 440 | self._cfg = '/files/etc/default/fetchmail' |
| | 441 | |
| | 442 | def setup(self): |
| | 443 | |
| | 444 | aug = self._ares.aug |
| | 445 | cfg = self._cfg |
| | 446 | |
| | 447 | aug.set(cfg + '/START_DAEMON', 'yes') |
| | 448 | aug.set(cfg + '/OPTIONS', '"-d %d"' % 30) |
| | 449 | |
| | 450 | # |
| | 451 | # Samba |
| | 452 | # |
| | 453 | class _Samba: |
| | 454 | |
| | 455 | def __init__(self, ares): |
| | 456 | self._ares = ares |
| | 457 | self._cfg = '/files/etc/samba/smb.conf' |
| | 458 | |
| | 459 | # Search a record |
| | 460 | def _rec(self, name): |
| | 461 | cfg = self._cfg |
| | 462 | aug = self._ares.aug |
| | 463 | for rec in aug.match(cfg + '/target'): |
| | 464 | if aug.get(rec) == name: |
| | 465 | return rec |
| | 466 | raise ErosError('%s record not found' % (name)) |
| | 467 | |
| | 468 | def setup(self): |
| | 469 | |
| | 470 | aug = self._ares.aug |
| | 471 | cfg = self._cfg |
| | 472 | rec = self._rec('global') |
| | 473 | |
| | 474 | # TODO: fix augeas uncommenting |
| | 475 | if not aug.match(rec + '/security'): |
| | 476 | for key in aug.match(rec + '/#comment'): |
| | 477 | if aug.get(key) == 'security = user': |
| | 478 | aug.insert(key, 'security', before=False) |
| | 479 | break |
| | 480 | |
| | 481 | aug.set(rec + '/security', 'user') |
| | 482 | aug.set(rec + '/passdb backend', 'ldapsam:ldap://localhost') |
| | 483 | aug.set(rec + '/ldap suffix', 'dc=nodomain') |
| | 484 | aug.set(rec + '/ldap user suffix', 'ou=People') |
| | 485 | aug.set(rec + '/ldap group suffix', 'ou=Group') |
| | 486 | aug.set(rec + '/ldap admin dn', 'cn=admin,dc=nodomain') |
| | 487 | |
| | 488 | try: |
| | 489 | rec = self._rec('data') |
| | 490 | except: |
| | 491 | rec = cfg + '/target[%d]' % (len(aug.match(cfg + '/target')) + 1) |
| | 492 | aug.set(rec, 'data') |
| | 493 | |
| | 494 | aug.set(rec + '/path', '/srv/data') |
| | 495 | aug.set(rec + '/browseable', 'yes') |
| | 496 | aug.set(rec + '/writeable', 'yes') |
| | 497 | aug.set(rec + '/admin users', 'manager') |
| | 498 | aug.set(rec + '/create mask', '0664') |
| | 499 | aug.set(rec + '/directory mask', '0775') |
| | 500 | |
| | 501 | data = '/srv/data' |
| | 502 | if not os.path.exists(data): |
| | 503 | os.mkdir(data) |
| | 504 | os.chown(data, 0, grp.getgrnam('users')[2]) |
| | 505 | os.chmod(data,0775) |
| | 506 | cmd = 'chmod g+s %s' % data |
| | 507 | if os.system(cmd) != 0: |
| | 508 | raise AresError('F: %s' % cmd) |
| | 509 | |
| | 510 | # |
| | 511 | # Postconfig |
| | 512 | # |
| | 513 | class _Postconfig: |
| | 514 | |
| | 515 | def __init__(self, ares): |
| | 516 | self._ares = ares |
| | 517 | |
| | 518 | def setup(self): |
| | 519 | |
| | 520 | # Stop here if we not running as root |
| | 521 | aug = self._ares.aug |
| | 522 | if aug.get('/augeas/root') == 'fakeroot/': |
| | 523 | return |
| | 524 | |
| | 525 | cmd = 'smbpasswd -w admin' |
| | 526 | if os.system(cmd) != 0: |
| | 527 | raise AresError('F: %s' % cmd) |
| | 528 | |