@@ -5,6 +5,7 @@ package tokencmd
5
5
import (
6
6
"net"
7
7
"net/url"
8
+ "runtime"
8
9
"sync"
9
10
"time"
10
11
@@ -158,10 +159,35 @@ func (g *gssapiNegotiator) Release() error {
158
159
func (g * gssapiNegotiator ) loadLib () (* gssapi.Lib , error ) {
159
160
g .loadOnce .Do (func () {
160
161
glog .V (5 ).Infof ("loading gssapi" )
161
- g .lib , g .loadError = gssapi .Load (nil )
162
- if g .loadError != nil {
163
- glog .V (5 ).Infof ("could not load gssapi: %v" , g .loadError )
162
+
163
+ var libPaths []string
164
+ switch runtime .GOOS {
165
+ case "darwin" :
166
+ libPaths = []string {"libgssapi_krb5.dylib" }
167
+ case "linux" :
168
+ // MIT, Heimdal
169
+ libPaths = []string {"libgssapi_krb5.so.2" , "libgssapi.so.3" }
170
+ default :
171
+ // Default search path
172
+ libPaths = []string {"" }
173
+ }
174
+
175
+ var loadErrors []error
176
+ for _ , libPath := range libPaths {
177
+ lib , loadError := gssapi .Load (& gssapi.Options {LibPath : libPath })
178
+
179
+ // If we successfully loaded from this path, return early
180
+ if loadError == nil {
181
+ glog .V (5 ).Infof ("loaded gssapi %s" , libPath )
182
+ g .lib = lib
183
+ return
184
+ }
185
+
186
+ // Otherwise, log and aggregate
187
+ glog .V (5 ).Infof ("%v" , loadError )
188
+ loadErrors = append (loadErrors , loadError )
164
189
}
190
+ g .loadError = utilerrors .NewAggregate (loadErrors )
165
191
})
166
192
return g .lib , g .loadError
167
193
}
0 commit comments