Skip to content
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

Warn user and keep executing if Event Log Service is stopped #442

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions cmd/win-sshproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"context"
"errors"
"fmt"
"net/url"
"os"
Expand All @@ -24,8 +25,9 @@ import (
)

const (
ERR_BAD_ARGS = 0x000A
WM_QUIT = 0x12
ERR_BAD_ARGS = 0x000A
WM_QUIT = 0x12
RPC_S_SERVER_UNAVAILABLE syscall.Errno = 1722
)

var (
Expand Down Expand Up @@ -54,11 +56,23 @@ func main() {
os.Exit(ERR_BAD_ARGS)
}

// Attempt to set up logging with the event log service.
// If it fails because the Windows Event Log Service is not running, show a warning
// and continue execution. There could be a reason why user disabled the Event Log.
log, err := setupLogging(args[0])
if err != nil {
os.Exit(1)
if errors.Is(err, syscall.Errno(RPC_S_SERVER_UNAVAILABLE)) {
logrus.Warn("RPC server is unavailable, continuing without event log")
} else {
logrus.Errorf("Error setting up logging: %v", err)
os.Exit(1)
}
}

// Defer closing the log if setup was successful
if log != nil {
defer log.Close()
}
defer log.Close()

stateDir = args[1]

Expand Down
Loading