[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apt-get aborts in subshell with redirections on Debian 12



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.

unicorn:~$ sudo adduser test2
[...]
unicorn:~$ sudo adduser test2 sudo
[...]
unicorn:~$ su - test2
Password: 
test2@unicorn:~$ id
uid=1001(test2) gid=1001(test2) groups=1001(test2),27(sudo),100(users)
test2@unicorn:~$ errors=$(sudo apt-get install mirage 2>&1 1>/dev/tty)
[sudo] password for test2: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  gir1.2-gexiv2-0.10 gir1.2-gtk-3.0 libexiv2-27 libgexiv2-2 python3-cairo
  python3-gi python3-gi-cairo
Suggested packages:
  exiv2 gimp
The following NEW packages will be installed:
  gir1.2-gexiv2-0.10 gir1.2-gtk-3.0 libexiv2-27 libgexiv2-2 mirage
  python3-cairo python3-gi python3-gi-cairo
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,249 kB of archives.
After this operation, 10.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
test2@unicorn:~$ 

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)

This removes sudo from the picture.  But I don't know what the results
will tell us.

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

unicorn:~$ sudo apt-get install mirage 0</dev/null
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  gir1.2-gexiv2-0.10 gir1.2-gtk-3.0 libexiv2-27 libgexiv2-2 python3-cairo
  python3-gi python3-gi-cairo
Suggested packages:
  exiv2 gimp
The following NEW packages will be installed:
  gir1.2-gexiv2-0.10 gir1.2-gtk-3.0 libexiv2-27 libgexiv2-2 mirage
  python3-cairo python3-gi python3-gi-cairo
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,249 kB of archives.
After this operation, 10.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.

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.

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


Reply to: