you are viewing a single comment's thread
view the rest of the comments
[–] 8 points 5 months ago (2 children)

What I don't get is why deny the execution of a command because the lack of sudo instead of just notice that it needs elevated privilege and ask for password

  • source
  • hideshow 4 child comments
  • [–] 9 points 5 months ago*

    It's kind of bad for scripts, where it can be either annoying or genuinely problematic, when your script hangs on a password prompt. You typically do want it to just fail right away, because if you have monitoring, then you'll be able to spot it failing.

    These days, it is (largely reliably) possible to detect whether a command is being run interactively or as part of an unattended script, so you do see some commands that trigger a sudo password prompt only for interactive use, for example systemctl does this. But this adds quite a bit of complexity to each individual program, so it isn't really something that's going to be implemented universally.

    I also have to say that systemctl kind of gets on my tits when it does that, because it throws up a GUI dialog for grabbing the password, which is quite jarring.

  • source
  • parent
  • [–] 4 points 5 months ago*

    Besides what Ephera@lemmy.ml said, you would also need to handle the escalation at every place you might have a permission related error. Unless your command alwaysneeds to run as root, so you can check once in the beginning, it would be cumbersome and error prone.

    Also, sometimes in multi users environments, you might want to execute as 3rd user, not root or your own, if something fails.

  • source
  • parent