Skip to content
Open
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
2 changes: 1 addition & 1 deletion devolutions-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn run() -> anyhow::Result<()> {
// Parse remaining arguments for CLI actions
let action = match remaining_args.first().map(String::as_str) {
Some("--service") => CliAction::Run { service_mode: true },
Some("service") => match args.next().as_deref() {
Some("service") => match remaining_args.get(1).map(String::as_str) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code looks correct. Can you provide more information?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code was calling args.next but the problem is that the args iterator was already consumed and its values pushed to remaining_args earlier on in the code.

I ran into this issue when I was installing the latest RPM on AlmaLinux; the pre and post scripts were failing. Calling /usr/bin/devolutions_gateway service register or /usr/bin/devolutions_gateway service unregister with the original code simply resulted in nothing happening except the execution falling through to CliAction::ShowHelp.

Copy link
Member

@CBenoit Benoît Cortier (CBenoit) Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I see. The bug seems to have been introduced by this commit: 3bcff86
The new code is quite convoluted, so I would rather update the whole parsing logic to something better.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m sending a patch for that.

Some("register") => CliAction::RegisterService,
Some("unregister") => CliAction::UnregisterService,
_ => CliAction::ShowHelp,
Expand Down