Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 910560 - sys-apps/portage-3.0.49-r1: dispatch-conf diff doesn't work
Summary: sys-apps/portage-3.0.49-r1: dispatch-conf diff doesn't work
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on: 933499
Blocks:
  Show dependency tree
 
Reported: 2023-07-19 18:28 UTC by Sotir Danailov
Modified: 2024-09-11 01:30 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed fix for issue (0001-bin-dispatch-conf-Avoid-nologin-shell.patch,966 bytes, patch)
2024-08-10 18:21 UTC, Jacob Abel
Details | Diff
Resubmition of the proposed fix for the issue (0001-RESUBMIT-bin-dispatch-conf-Avoid-nologin-shell.patch,950 bytes, patch)
2024-08-10 18:29 UTC, Jacob Abel
Details | Diff
v3 Proposed Fix (0001-bin-dispatch-conf-Avoid-nologin-shell.patch,879 bytes, patch)
2024-08-10 21:28 UTC, Jacob Abel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sotir Danailov 2023-07-19 18:28:16 UTC
When trying to use the diff command on any config file for which there was a change during an update, it doesn't do anything. I have to manually diff the ._cfg file and the current config always and replace them that way.

Reproducible: Always
Comment 1 Mike Gilbert gentoo-dev 2023-07-20 17:27:37 UTC
dispatch-conf does not have a "diff" command. Do you mean "merge" (m)?
Comment 2 Sotir Danailov 2023-07-21 13:41:16 UTC
(In reply to Mike Gilbert from comment #1)
> dispatch-conf does not have a "diff" command. Do you mean "merge" (m)?

https://gitweb.gentoo.org/proj/portage.git/tree/bin/dispatch-conf#n512
Comment 3 Mike Gilbert gentoo-dev 2023-07-21 14:26:30 UTC
Ah, so the "l" command. It works fine for me.

Have you customized /etc/dispatch-conf.conf at all?

Any strange pager settings (LESS env var)?
Comment 4 Sotir Danailov 2023-07-22 20:19:13 UTC
> Have you customized /etc/dispatch-conf.conf at all?

No I haven't.

> Any strange pager settings (LESS env var)?

These are my less settings from the env var "-R -M --shift 5".

Also is my assumption about the "l" command correct? I expect it to show me the diff between ._cfg0000_filename and filename.
Comment 5 Mike Gilbert gentoo-dev 2023-07-22 21:11:31 UTC
I think the "l" command is only useful after you have run the "m" (merge) command.

Running "l" after "m" should produce output like this:

> --- /etc/._cfg0000_mlocate-cron.conf    2023-07-21 10:24:26.783493956 -0400
> +++ /etc/._mrg0000_mlocate-cron.conf    2023-07-22 17:08:44.085754978 -0400
> @@ -3,7 +3,7 @@
>  
>  # ionice class to run at: see -c in ionice(1)
>  # you have to install sys-apps/util-linux manually
> -IONICE_CLASS="4"
> +IONICE_CLASS="2"
>  
>  # ionice priority to run at: see -n in ionice(1)
>  IONICE_PRIORITY="7"
> 
> >> (1 of 1) -- /etc/mlocate-cron.conf
> >> q quit, h help, n next, e edit-new, z zap-new, u use-new
>    m merge, t toggle-merge, l look-merge:
Comment 6 Mike Gilbert gentoo-dev 2023-07-22 21:17:11 UTC
Also, dispatch-conf should immediately show you a diff as soon as you run it. No explicit command is requited. That output should look like this:

> --- /etc/mlocate-cron.conf      2020-04-12 12:00:36.143350196 -0400
> +++ /etc/._cfg0000_mlocate-cron.conf    2023-07-22 17:15:07.618235065 -0400
> @@ -5,5 +5,7 @@
>  # you have to install sys-apps/util-linux manually
>  IONICE_CLASS="2"
>  
> +# some new setting
> +
>  # ionice priority to run at: see -n in ionice(1)
>  IONICE_PRIORITY="7"
> 
> >> (1 of 1) -- /etc/mlocate-cron.conf
> >> q quit, h help, n next, e edit-new, z zap-new, u use-new
>    m merge, t toggle-merge, l look-merge:
Comment 7 Sotir Danailov 2023-07-22 21:21:22 UTC
> Also, dispatch-conf should immediately show you a diff as soon as you run it.

Interesting, this doesn't happen in my case. I just directly get the output:

> >> (1 of 1) -- /etc/mlocate-cron.conf
> >> q quit, h help, n next, e edit-new, z zap-new, u use-new
>    m merge, t toggle-merge, l look-merge:

and nothing else.
Comment 8 Mike Gilbert gentoo-dev 2023-07-22 21:31:34 UTC
Does it work if you bypass less by setting PAGER=cat?

eg. PAGER=cat dispatch-conf
Comment 9 Sotir Danailov 2023-07-22 21:43:56 UTC
> Does it work if you bypass less by setting PAGER=cat?

It doesn't and changing the setting as pager="cat" in /etc/dispatch-conf.conf doesn't do anything either.
Comment 10 Jacob Abel 2024-08-09 17:36:59 UTC
As someone who has also been running into this issue I might have a lead? I think the issue is because dispatch-conf is invoking the pager with root's default shell (which for many is /sbin/nologin) here:

https://github.com/gentoo/portage/blob/9e6451c88e3da11e0eb7b0bd6b1497c5ca4fb67f/bin/dispatch-conf#L328

And that's causing dispatch-conf to print out an unassuming little nologin message at the top with the pager silently failing.

> This account is currently not available.
> 
> >> (1 of 1) -- /etc/rsyncd.conf
> >> q quit, h help, n next, e edit-new, z zap-new, u use-new
>   m merge, t toggle-merge, l look-merge:
Comment 11 Jacob Abel 2024-08-10 04:04:20 UTC
I just got a chance to try temporarily changing the default shell for root and it does seem to work with the default shell set to bash or anything other than nologin or false. 

Now I get the diff upon running dispatch-conf and when I set it back to nologin, it no longer works again. So it seems to be an issue with python's spawn() function (only the pager uses it and the other subshells use os.system()) using the default login shell (which for root is often /sbin/nologin).
Comment 12 Emanuel Czirai 2024-08-10 06:06:07 UTC
(In reply to Jacob Abel from comment #11)
> I just got a chance to try temporarily changing the default shell for root
> and it does seem to work with the default shell set to bash or anything
> other than nologin or false. 
> 
> Now I get the diff upon running dispatch-conf and when I set it back to
> nologin, it no longer works again. So it seems to be an issue with python's
> spawn() function (only the pager uses it and the other subshells use
> os.system()) using the default login shell (which for root is often
> /sbin/nologin).

it makes sense as per their own-made spawn_shell() func here: https://github.com/gentoo/portage/blob/9e6451c88e3da11e0eb7b0bd6b1497c5ca4fb67f/bin/dispatch-conf#L577-L587

as it seems to be by design, but clearly didn't consider the /sbin/nologin case.

Thanks for your work looking into this!
Comment 13 Jacob Abel 2024-08-10 18:21:54 UTC
Created attachment 899815 [details, diff]
Proposed fix for issue

I slapped this patch together today. It seems to resolve the issue for me. Let me know if it helps.
Comment 14 Jacob Abel 2024-08-10 18:29:36 UTC
Created attachment 899818 [details, diff]
Resubmition of the proposed fix for the issue

Please ignore the previous patch. I accidentally submitted a slightly older revision since I forgot to commit my updated change.

This has the up-to-date patch in it.
Comment 15 Zac Medico gentoo-dev 2024-08-10 19:14:49 UTC
(In reply to Jacob Abel from comment #14)
> Created attachment 899818 [details, diff] [details, diff]
> Resubmition of the proposed fix for the issue
> 
> Please ignore the previous patch. I accidentally submitted a slightly older
> revision since I forgot to commit my updated change.
> 
> This has the up-to-date patch in it.

Looks good, but more compact like this:

if shell_basename in ("nologin",  "false"):
Comment 16 Jacob Abel 2024-08-10 21:28:47 UTC
Created attachment 899823 [details, diff]
v3 Proposed Fix

Ah good catch, that is far cleaner. I've updated it.
Comment 17 Mike Gilbert gentoo-dev 2024-08-11 14:25:18 UTC
I don't understand why we are looking at the SHELL environment variable in the first place.

I think we should instead call "/bin/sh" unconditionally to match the behavior of os.system(). What benefit is there to calling some alternative shell?
Comment 18 Jacob Abel 2024-08-11 15:00:44 UTC
(In reply to Mike Gilbert from comment #17)
> I don't understand why we are looking at the SHELL environment variable in
> the first place.
> 
> I think we should instead call "/bin/sh" unconditionally to match the
> behavior of os.system(). What benefit is there to calling some alternative
> shell?

Based on the blame that appears to have been the original behavior but was changed to explicitly use spawn().

https://github.com/gentoo/portage/commit/d11c0ac819a7509332f5277099ad2b6e969c8414
Comment 19 Zac Medico gentoo-dev 2024-08-11 16:28:31 UTC
(In reply to Mike Gilbert from comment #17)
> I don't understand why we are looking at the SHELL environment variable in
> the first place.
> 
> I think we should instead call "/bin/sh" unconditionally to match the
> behavior of os.system(). What benefit is there to calling some alternative
> shell?

In retrospect I suppose using "/bin/sh" unconditionally is probably reasonable here. This shell is mainly used to pipe the user's diff command to their pager command.
Comment 20 Larry the Git Cow gentoo-dev 2024-08-14 14:44:01 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=892f5408a6ff1aa899cc62a10ec07af57001f5d0

commit 892f5408a6ff1aa899cc62a10ec07af57001f5d0
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2024-08-13 01:14:14 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2024-08-14 14:43:09 +0000

    dispatch-conf: ignore SHELL in spawn_shell
    
    There is no need to use SHELL here, and this can actually cause problems
    when SHELL is set to "nologin" or "false".
    
    Look for sh in PATH instead.
    
    Bug: https://bugs.gentoo.org/910560
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 bin/dispatch-conf | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)
Comment 21 Larry the Git Cow gentoo-dev 2024-09-11 01:30:54 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02d0e00a1ba811b39140d10e17488f7fc3916534

commit 02d0e00a1ba811b39140d10e17488f7fc3916534
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-09-11 01:30:10 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-09-11 01:30:30 +0000

    sys-apps/portage: add 3.0.66
    
    Closes: https://bugs.gentoo.org/435066
    Closes: https://bugs.gentoo.org/907061
    Closes: https://bugs.gentoo.org/910560
    Closes: https://bugs.gentoo.org/933433
    Closes: https://bugs.gentoo.org/934220
    Closes: https://bugs.gentoo.org/934514
    Closes: https://bugs.gentoo.org/934784
    Closes: https://bugs.gentoo.org/935830
    Closes: https://bugs.gentoo.org/936273
    Closes: https://bugs.gentoo.org/937384
    Closes: https://bugs.gentoo.org/937485
    Closes: https://bugs.gentoo.org/937740
    Closes: https://bugs.gentoo.org/937888
    Closes: https://bugs.gentoo.org/937891
    Closes: https://bugs.gentoo.org/938127
    Closes: https://bugs.gentoo.org/933499
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.66.ebuild | 227 +++++++++++++++++++++++++++++++++
 2 files changed, 228 insertions(+)