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

Bug: action with command that exits with errorcode ! 0 is reported as OK #316

Closed
Blizzke opened this issue Jan 31, 2023 · 4 comments · Fixed by #387
Closed

Bug: action with command that exits with errorcode ! 0 is reported as OK #316

Blizzke opened this issue Jan 31, 2023 · 4 comments · Fixed by #387

Comments

@Blizzke
Copy link

Blizzke commented Jan 31, 2023

Description
While trying to use cp to copy a file to /etc (since file.copy doesn't support privilege elevation at this point) comtrya reports a completed execution, no errors.

If you run it in trace mode however, you see that the command failed with exit code 1,

Steps to reproduce

actions:
  - action: command.run
    command: cp
    args:
      - -f
      - manifests/tools/zsh/files/zshenv
      - /etc/zsh/

The above action tries to copy a file into /etc without sudo.
Trace will show:

TRACE execute:{manifest="manifests.etc"}:{action=command.run}: exit code: 1
TRACE execute:{manifest="manifests.etc"}:{action=command.run}: stdout: 
TRACE execute:{manifest="manifests.etc"}:{action=command.run}: stderr: cp: cannot remove '/etc/zsh/zshenv': Permission denied
INFO execute:{manifest="manifests.etc"}: Completed

Expected behaviour
Visible error

Environment

  • OS: manjaro
  • Version: 0.8.3
@airtonix
Copy link
Contributor

btw there's a proper file copy and directory copy action that needs more than just me complaining about :>

@Blizzke
Copy link
Author

Blizzke commented Feb 20, 2023

Well aware, but since the privileged/sudo was not documented I was trying it this way (hence /etc as target).
I have since moved on to using copy.

Original remark stands though, the exit code should be evaluated.

@rawkode
Copy link
Member

rawkode commented Dec 29, 2023

@Blizzke I'll fix the error propagation, no problem.

@airtonix I'm not really sure how we could support privilege elevation for file.* actions, as a running process cannot elevate its privilege. Instead, you'd need to run sudo comtrya ...

In-order for us to elevate privileges, we'd need to shell out to execute commands on the host and I don't feel like that's a very good solution.

I'd really love to learn more about sudo comtrya vs comtrya and how you're using the tool.

@rawkode
Copy link
Member

rawkode commented Dec 29, 2023

@Blizzke PR submitted with a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants