On 25/09/2023 12:42, Greg Wooledge wrote:
On Mon, Sep 25, 2023 at 11:58:13AM +0900, John Crawley wrote:
adduser tmp
adduser tmp sudo

Log in to tmp (no graphical session set up), and the results are the same: 
behaviour in a bash shell is wrong, everything else works.

I simply can't reproduce your results at all.

This is so weird. There's probably some simple explanation somewhere...

I have a freshly installed Bookworm netinstall CLI system among my VMs. Only 
"standard system utilities" added during the install process. Restored the 
just-after-install snapshot, did an apt update/upgrade, and:

$ id
uid=1000(john) gid=1000(john) 
groups=1000(john),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev)

Is there a hint here? Those are the default groups I was put in by the Debian 
Installer, but it's a much longer list than yours.

Anyway 'errors=$(sudo apt-get install mirage 2>&1 1>/dev/tty)' wrote a long 
list of dependencies (of course) but then aborted as usual.

This leaves me very confused.  There's something different about your
systems compared to mine (and the other person who also could not
reproduce your results), but damned if I can guess *what*.

The only other experiment I can think of at this time would be:

4) In a bash shell as root (e.g. "su" or "sudo -s"), do:

    errors=$(apt-get install mirage 2>&1 1>/dev/tty)

-bash: syntax error near unexpected token `2'

So bash as root has a problem with the redirection.

But this worked OK in the same root shell:

exec 3>1
errors=$( apt-get install mirage 2>&1 1>&3 )
exec 3>&-

If 'mirage' is replaced with 'mirag' then $errors holds the error message.

So at least something is working!

Maybe it is an issue with sudo?

I can generate the *message* that you get by redirecting stdin:

But there's nothing you've shown that's redirecting stdin, so I don't
know whether this is what's causing your problem or not.  If it *is*
what's causing your problem, I still don't have a clue what's *doing*
it.

Is there any unusual configuration of sudo on your system?  Sudo
configuration is utterly baffling, and about 2 orders of magnitude more
stupidly complex than it should be, so I don't even know what kind of
atrocities are *possible* in sudoers, let alone which of them might be
capable of doing something insane like closing stdin on commands run
via sudo.  But if you've changed anything in sudoers or sudoers.d you
might want to report on those changes.

No. Those last tests were done on a freshly installed Bookworm netinstall VM, 
no changes apart from apt updating.

(But why would this only happen when sudo's parent is bash?  None of
this makes *any* sense.)

I just hope I haven't been making an awful stupid mistake all along...

--
John

Reply via email to