Skip to content

Commit 52f4ed6

Browse files
changed-the-exit-code
1 parent 838a3dc commit 52f4ed6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

internal/wrappers/client.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ func kerberosProxyClient(timeout uint, proxyStr string) *http.Client {
214214
Timeout: defaultDialerDuration,
215215
KeepAlive: defaultDialerDuration,
216216
}
217+
218+
if proxyStr == "" {
219+
logger.PrintIfVerbose("Error: Proxy string is required for Kerberos proxy authentication.")
220+
logger.Print("Error: Proxy string is required for Kerberos proxy authentication.")
221+
logger.PrintIfVerbose("Please provide Proxy string using: --proxy 'http://proxy.example.com' or set CX_PROXY environment variable")
222+
os.Exit(1)
223+
}
224+
217225
u, _ := url.Parse(proxyStr)
218226

219227
// Get Kerberos configuration from viper
@@ -224,8 +232,7 @@ func kerberosProxyClient(timeout uint, proxyStr string) *http.Client {
224232
logger.PrintIfVerbose("Error: Kerberos SPN is required for Kerberos proxy authentication.")
225233
logger.Print("Error: Kerberos SPN is required for Kerberos proxy authentication.")
226234
logger.PrintIfVerbose("Please provide SPN using: --proxy-kerberos-spn 'HTTP/proxy.example.com' or set CX_PROXY_KERBEROS_SPN environment variable")
227-
228-
os.Exit(0)
235+
os.Exit(1)
229236
}
230237

231238
// Use gokrb5 for all platforms (standard Kerberos)
@@ -237,8 +244,7 @@ func kerberosNativeProxyClient(timeout uint, proxyStr string) *http.Client {
237244
if runtime.GOOS != "windows" {
238245
logger.PrintIfVerbose("Error: --proxy-auth-type kerberos-native is only supported on Windows")
239246
logger.Print("Error: --proxy-auth-type kerberos-native is only supported on Windows")
240-
241-
os.Exit(0)
247+
os.Exit(1)
242248
}
243249

244250
dialer := &net.Dialer{
@@ -252,14 +258,14 @@ func kerberosNativeProxyClient(timeout uint, proxyStr string) *http.Client {
252258
if proxySPN == "" {
253259
logger.PrintIfVerbose("ERROR: Kerberos SPN is required for windows native kerberos authentication")
254260
logger.Print("Error: Kerberos SPN is required for windows native kerberos authentication")
255-
os.Exit(0)
261+
os.Exit(1)
256262
}
257263

258264
// Validate SSPI setup
259265
if err := kerberos.ValidateSSPISetup(proxySPN); err != nil {
260266
logger.PrintIfVerbose("Error: Failed to generate a token for the specified SPN." + err.Error())
261267
logger.Print("Error: Failed to generate a token for the specified SPN.")
262-
os.Exit(0)
268+
os.Exit(1)
263269
}
264270

265271
logger.PrintIfVerbose("Creating HTTP client using Windows native Kerberos (SSPI)")

0 commit comments

Comments
 (0)