diff options
| author | Greg Steuck <gnezdo@google.com> | 2018-12-11 14:30:49 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-12-13 09:44:24 +0100 |
| commit | f3d9d5948cad441ab08e763c8ed86efe79f4198b (patch) | |
| tree | 6e1c38fcb434a2aa74928a1a9871a77e406c273f /pkg/csource/csource.go | |
| parent | ec0147d47fb25d0efdc677000312db1919ea0086 (diff) | |
pkg/csource: support tun and setuid repros on {free,open}bsd
* expose procid on BSD for tun, always declare loop()
* deal with terrible bsd includes
* replicate loop() declaration
Diffstat (limited to 'pkg/csource/csource.go')
| -rw-r--r-- | pkg/csource/csource.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index aa5f615e1..91e66e1cd 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -430,21 +430,23 @@ func (ctx *context) hoistIncludes(result []byte) []byte { includes[string(match)] = true } result = includeRe.ReplaceAll(result, nil) - // Linux headers are broken, so we have to move all linux includes to the bottom. - var sorted, sortedLinux []string + // Certain linux and bsd headers are broken and go to the bottom. + var sorted, sortedBottom []string for include := range includes { if strings.Contains(include, "<linux/") { - sortedLinux = append(sortedLinux, include) + sortedBottom = append(sortedBottom, include) + } else if strings.Contains(include, "<netinet/if_ether.h>") { + sortedBottom = append(sortedBottom, include) } else { sorted = append(sorted, include) } } sort.Strings(sorted) - sort.Strings(sortedLinux) + sort.Strings(sortedBottom) newResult := append([]byte{}, result[:includesStart]...) newResult = append(newResult, strings.Join(sorted, "")...) newResult = append(newResult, '\n') - newResult = append(newResult, strings.Join(sortedLinux, "")...) + newResult = append(newResult, strings.Join(sortedBottom, "")...) newResult = append(newResult, result[includesStart:]...) return newResult } |
