mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-02 18:11:59 +00:00
wgengine/router: also accept exit code 254 from ip rule del.
iproute2 3.16.0-2 from Debian Jessie (oldoldstable) doesn't return exit code 2 when deleting a non-existent IP rule. Fixes #434 Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
484b7fc9a3
commit
5a32f8e181
@@ -61,21 +61,31 @@ func (o osCommandRunner) output(args ...string) ([]byte, error) {
|
||||
}
|
||||
|
||||
type runGroup struct {
|
||||
OkCode int // an error code that is acceptable, other than 0, if any
|
||||
OkCode []int // error codes that are acceptable, other than 0, if any
|
||||
Runner commandRunner // the runner that actually runs our commands
|
||||
ErrAcc error // first error encountered, if any
|
||||
}
|
||||
|
||||
func newRunGroup(okCode int, runner commandRunner) *runGroup {
|
||||
func newRunGroup(okCode []int, runner commandRunner) *runGroup {
|
||||
return &runGroup{
|
||||
OkCode: okCode,
|
||||
Runner: runner,
|
||||
}
|
||||
}
|
||||
|
||||
func (rg *runGroup) okCode(err error) bool {
|
||||
got := errCode(err)
|
||||
for _, want := range rg.OkCode {
|
||||
if got == want {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (rg *runGroup) Output(args ...string) []byte {
|
||||
b, err := rg.Runner.output(args...)
|
||||
if rg.ErrAcc == nil && err != nil && errCode(err) != rg.OkCode {
|
||||
if rg.ErrAcc == nil && err != nil && !rg.okCode(err) {
|
||||
rg.ErrAcc = err
|
||||
}
|
||||
return b
|
||||
@@ -83,7 +93,7 @@ func (rg *runGroup) Output(args ...string) []byte {
|
||||
|
||||
func (rg *runGroup) Run(args ...string) {
|
||||
err := rg.Runner.run(args...)
|
||||
if rg.ErrAcc == nil && err != nil && errCode(err) != rg.OkCode {
|
||||
if rg.ErrAcc == nil && err != nil && !rg.okCode(err) {
|
||||
rg.ErrAcc = err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user