Skip to content

Fix crash from mixing 'sudo' with 'du' output

Oliver Smith requested to merge fix-du-sudo-crash into master

Do not crash during "pmbootstrap zap" and other actions when the user needs to type in the sudo password before running "du" to calculate the work folder size. We're trying to parse the "du" output as integer, but of course the 'Sorry, try again' message from sudo is not a valid integer.

$ pmbootstrap --details-to-stdout zap
(008707) [14:00:57] Shutdown complete
(008707) [14:00:57] Calculate work folder size
(008707) [14:00:57] % sudo du --summarize --block-size=1 /home/luca/.local/var/pmbootstrap
[sudo] password for luca:
[sudo] password for luca: Sorry, try again.

12966293504     /home/luca/.local/var/pmbootstrap
(008707) [14:01:03] ERROR: invalid literal for int() with base 10: 'Sorry, try again.\n12966293504'

It would be a good idea to separate the sudo output from the process output in general, see #1677 (closed) for a related proposal.


@z3ntu: please review and confirm that this fixes #1766 😉

Merge request reports