|
Bugzilla – Full Text Bug Listing |
| Summary: | sudoedit: editor doesn't become foreground process of the terminal | ||
|---|---|---|---|
| Product: | Sudo | Reporter: | maksym.telychko |
| Component: | Sudo | Assignee: | Todd C. Miller <Todd.Miller> |
| Status: | ASSIGNED --- | ||
| Severity: | normal | ||
| Priority: | low | ||
| Version: | 1.9.15 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | strace | ||
What happens if you run nvim without sudoedit the same way, does it run as the foreground process? The problem is that you are trying to run the editor with standard input from the pipe. If you run sudoedit with standard input connected to the terminal it should work. (In reply to Todd C. Miller from comment #1) > What happens if you run nvim without sudoedit the same way, does it > run as the foreground process? Without sudoedit, it runs without any problem. (In reply to Todd C. Miller from comment #2) > The problem is that you are trying to run the editor with standard > input from the pipe. If you run sudoedit with standard input > connected to the terminal it should work. When I run it from an interactive shell in the terminal, it works good. E.g. if I type `bash -c 'echo /etc/fstab | { FILE="$(cat)" ; EDITOR=nvim sudoedit "$FILE" ; }'` in a terminal, works everything fine. One more thing. If you extend the example with the `less` pager, it starts working.
STEPS TO CHECK:
1. run sway window manager as previously described
2. less pager will show the file
3. press `v` (default keybinding) to edit the file
4. enter your password
file `~/.config/sway/config`:
exec_always alacritty -e bash -c 'echo /etc/fstab | { FILE="$(cat)" ; SUDO_EDITOR="nvim" LESSEDIT="%E %g" EDITOR="sudoedit" less "$FILE" ; }'
P.S.: I would be appreciated for any approach how to run sudo within pipe
I have more refined steps to reproduce. No graphical environment is required. Just bash and sudo. I short, when you run sudo from the login shell at profile source file. 1. Make the .profile file in your home directory with following content: #>>>.profile exec bash -c 'echo 123 | sudo nvim' 2. Run bash --login from the any terminal |
Created attachment 577 [details] strace PREREQUISITES: 1. Simple window manager like i3wm or sway (weston also OK). 2. Terminal emulator (uxterm or alacritty). STEPS TO REPRODUCE: 1. Prepare config file for sway wm (~/.config/sway/config): exec_always alacritty -e bash -c 'echo /etc/fstab | { FILE="$(cat)" ; EDITOR=nvim sudoedit "$FILE" ; }' There one line of config is enough. 2. Run window manager from the linux console (not terminal emulator). Just type "sway" and press enter. ACTUAL RESULTS: After password in entered, editor doesn't get a focus, so terminal looks like when arrows pressed: ^[OC^[OB^[OCormation about the filesystems. # See fstab(5) for details. IMPORTANT NOTES: It doesn't work if it run from a nested terminal or nested window manager session. It works only when run from the linux console and not from interactive shell. ATTACHMENTS: syscall trace