Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid segfault in sudo execution #71

Closed
wants to merge 1 commit into from

Conversation

alerque
Copy link
Member

@alerque alerque commented Sep 20, 2021

For weeks now I have been struggling with a weird problem on 2 machines (not all of my Arch boxes, only some of them). It started with staging-x86_64-build not working (while other variants worked) then it spread to be custom makechrootpkg invocations, then to extra-x86_64-build, and lastly to another machine. I've tried blowing away the chroots and rebuilting them, reinstalled the tooling, etc. and nothing seems to touch the problem. The manifestation is simple. Right after integrity checks, I get a sefgault as it transitions to running makepkg in the chroot:

/chrootbuild: line 3:     3 Segmentation fault      (core dumped) sudo --preserve-env=SOURCE_DATE_EPOCH -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@"

Every time. Any package. Any chroot.

I tried messing around with this line with just generic sudo commands like sudo true and found either -i or -u work fine in isolation, it is the combination of them that causes sudo to segfault (e.g. sudo -iu builduser true will segfault). Since -u is required here and I could not figure out why -i is required, I just removed it and found my builds all work fine.

I don't know if this is needed for some edge cases, hence this might be the wrong fix, but I'm at least opening this Draft for comment to bring attention to the problem.

@jelly
Copy link
Member

jelly commented Sep 20, 2021

What sudo version do you have in and outside the chroot? And do you have any custom sudo configuration in /etc/sudoers

Alternatively, do you have a coredump?

@foutrelis
Copy link
Member

Good news! This is a bug in sudo that has already been resolved by upstream. I'll push a new package to testing with the fix.

@Foxboron
Copy link
Member

That is an amazingly specific failure mode.

@alerque
Copy link
Member Author

alerque commented Sep 20, 2021

Amazingly specific yes, but at the same time I don't understand why for weeks I've been the only one having this problem with Arch tooling. I've been using normal up to date Arch systems and freshly minted chroots and the default tooling. Why did this just hit me when everyone else was fine?

About this PR, even if the bug is fixed in sudo upstream I have to wonder whether the interactive flag should be here. Given the use case inside a chroot inside a scripted built, if the interactive flag makes a difference for some builds that something else might be amiss. Would it be wrong to drop this anyway?

@klausenbusk
Copy link
Member

devtools has been migrated to our GitLab, closing..

Migrated to: https://gitlab.archlinux.org/archlinux/devtools/-/merge_requests/71

@alerque alerque deleted the no-segfault branch January 25, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants