Ejemplo n.º 1
0
def set_export_ok(config):
    global_enable = util.getConfigDefaultBoolean(config, 'defaults', 'daemon', False)
    log.debug(
        'Global default is %r',
        {True: 'allow', False: 'deny'}.get(global_enable),
        )

    enable_if_all = util.getConfigDefaultBoolean(config, 'defaults', 'daemon-if-all', False)
    if enable_if_all:
        access_table = access.getAccessTable(config)
    log.debug(
        'If accessible to @all: %r',
        {True: 'allow', False: 'unchanged'}.get(enable_if_all),
        )

    for (dirpath, repo, name) in walk_repos(config):
        try:
            enable = config.getboolean('repo %s' % name, 'daemon')
        except (NoSectionError, NoOptionError):
            enable = global_enable
            if not enable and enable_if_all:
                (users,groups,all_refs) = access.getAllAccess(config,access_table,name)
                enable = ('@all' in all_refs)

        if enable:
            log.debug('Allow %r', name)
            allow_export(os.path.join(dirpath, repo))
        else:
            log.debug('Deny %r', name)
            deny_export(os.path.join(dirpath, repo))
Ejemplo n.º 2
0
def gen_htaccess(config):
    table = access.getAccessTable(config)

    for (dirpath, repo, name) in gitdaemon.walk_repos(config):
        (users, groups, all_refs) = access.getAllAccess(config,table,name)

        if '@all' in all_refs:
            log.debug('Allow all for %r', name)
            remove_htaccess(os.path.join(dirpath, repo))
        else:
            write_htaccess(os.path.join(dirpath, repo), users, groups)
Ejemplo n.º 3
0
def test_list_all():
    cfg = RawConfigParser()
    cfg.add_section('group fooers')
    cfg.set('group fooers', 'members', 'jdoe')
    cfg.set('group fooers', 'map writable foo/bar', 'baz/quux/thud')
    cfg.add_section('group mooers')
    cfg.set('group mooers', 'members', '@fooers')
    cfg.set('group mooers', 'readonly', 'baz/quux/thud')
    table = access.getAccessTable(cfg)
    (users, groups, all_refs) = access.getAllAccess(cfg,table,'baz/quux/thud',['readonly'])
    eq(sorted(users), [])
    eq(sorted(groups), ['mooers'])
    eq(sorted(all_refs), ['@fooers','@mooers','jdoe'])
Ejemplo n.º 4
0
def set_export_ok(config):
    try:
        global_enable = config.getboolean('gitosis', 'daemon')
    except (NoSectionError, NoOptionError):
        global_enable = False
    log.debug(
        'Global default is %r',
        {
            True: 'allow',
            False: 'deny'
        }.get(global_enable),
    )

    try:
        enable_if_all = config.getboolean('gitosis', 'daemon-if-all')
    except (NoSectionError, NoOptionError):
        enable_if_all = False
    log.debug(
        'If accessible to @all: %r',
        {
            True: 'allow',
            False: 'unchanged'
        }.get(enable_if_all),
    )

    for (dirpath, repo, name) in walk_repos(config):
        try:
            enable = config.getboolean('repo %s' % name, 'daemon')
        except (NoSectionError, NoOptionError):
            enable = global_enable
            if not enable and enable_if_all:
                (users, groups, all_refs) = access.getAllAccess(config, name)
                enable = ('@all' in all_refs)

        if enable:
            log.debug('Allow %r', name)
            allow_export(os.path.join(dirpath, repo))
        else:
            log.debug('Deny %r', name)
            deny_export(os.path.join(dirpath, repo))