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 is not relative to file's location #537
Comments
from: coredns/coredns#1068 |
btw: not trivial to fix because Go lacks a good where is this file located API; you need to work from the process' CWD up to the files opened, keeping track of relative and absolute file names used. |
Yeah don't have a simple way besides keeping track and using |
Can't we just update parseZone to accept and utilize the file parameter that is already provided by - r1, e1 := os.Open(l.token)
+ includePath := l.token
+ if !filepath.IsAbs(includePath) {
+ includePath = filepath.Join(filepath.Dir(f), target)
+ }
+ r1, e1 := os.Open(includePath)
if e1 != nil {
- t <- &Token{Error: &ParseError{f, "failed to open `" + l.token + "'", l}}
+ msg := fmt.Sprintf("failed to open `%s'", l.token)
+ if !filepath.IsAbs(l.token) {
+ msg += fmt.Sprintf(" as `%s'", includePath)
+ }
+ t <- &Token{Error: &ParseError{f, msg, l}}
return
}
if include+1 > 7 {
t <- &Token{Error: &ParseError{f, "too deeply nested $INCLUDE", l}}
return
}
- parseZone(r1, neworigin, defttl, l.token, t, include+1)
+ parseZone(r1, neworigin, defttl, includePath, t, include+1) |
@gibson042 just now seeing your update. I think I tries something like this, but failed. Let me try your patch. |
TL;DR: patch works, I was clearly overthinking it:
@gibson042 want to submit that as a PR? |
I'll like to get this fixed in coredns - meaning fixing it here - I'll submit a PR later today. |
When using a relative file in an $INCLUDE the file is referenced from the cwd from the calling processes; this changes it to be down from the view point where the file exists. Code from #537 (comment) Fixes #537
When using a relative file in an $INCLUDE the file is referenced from the cwd from the calling processes; this changes it to be down from the view point where the file exists. Code from #537 (comment) Fixes #537
It seems like the working/excution directory from coredns is used and not something set in the root mw.
Corefile:
Main zone (example.com):
The text was updated successfully, but these errors were encountered: