Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include directive broken when using wildcards for directory components #1472

Closed
SlowFox71 opened this issue Jun 16, 2022 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@SlowFox71
Copy link

What I Did

My configuration used the following include statement:

Include /var/www/*/custom/config/proftpd.conf

The included configuration files contain <VirtualHost> clauses, but the virutal hosts are not available. Log file shows nothing at initialization and Unknown host '$FOO.domain.example' requested on $IP#21, refusing HOST command upon connection attempts to $FOO.

What I Expected/Wanted

Virtual hosts should be available, i.e. config files should be included.

How to fix it

Please be kind, I am not a developer. It took me a couple of hours to nail this down, but finally I can say that the problem is in src/parser.c parse_wildcard_config_path(). Lines 1032ff concatenate parent paths up to the first wildcard:

    if (parent_path != NULL) {
      parent_path = pdircat(tmp_pool, parent_path,
        pstrndup(tmp_pool, component, component_len), NULL);

    } else {
      parent_path = pstrndup(tmp_pool, "/", 1);
    }

But they do so only if parent_path is initialized, which is not the case at the first iteration. Thus the first component is silently dropped and config files are searched (but not found) in www/*/custom/config/proftpd.conf instead. Adding a leading dummy path component serves as a workaround for the problem - seems like nobody ever has tried such a configuration.

I'd suggest dropping lines 1021-1023 and 1036-1038 (initializing parent_path) and instead do the initialization at line 1014 (before checking for wildcards); however I am not sure if this might result in unwanted behavior for other inputs as I am not at all familiar with the bigger picture of this logic.

ProFTPD Version and Configuration

Originally 1.3.7a, but the bug is reproducible in the master branch as well.

During debugging I reduced my configuration to the single include line stated above. This should be sufficient to reproduce the problem.

@Castaglia
Copy link
Member

In your configuration using:

Include /var/www/*/custom/config/proftpd.conf

What is the actual path to the config file that be being included (and isn't)? This will help me locally reproduce this behavior.

@Castaglia Castaglia self-assigned this Jun 18, 2022
@Castaglia
Copy link
Member

Never mind; I was able to reproduce the behavior locally; I should have a fix up shortly.

@Castaglia Castaglia added the bug label Jun 18, 2022
@Castaglia Castaglia added this to the 1.3.8 milestone Jun 18, 2022
@Castaglia Castaglia changed the title "Include" broken when using wildcards for directory components Include directive broken when using wildcards for directory components Jun 18, 2022
Castaglia added a commit that referenced this issue Jun 18, 2022
… that the initial directory component is not inadvertently ignored.
Castaglia added a commit that referenced this issue Jun 18, 2022
Issue #1472: Fix the handling of `Include` paths with wildcards, such…
@Castaglia
Copy link
Member

This should now be fixed in master. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants