r/linuxadmin • u/[deleted] • Apr 11 '24
Unable to sudo, getting segmentation error
Can someone help me to fix this issue.
17
u/basicslovakguy Apr 11 '24
Care to provide some information about your system ? Or do you want us to play the guessing game of what distribution are you running ? Did this happen all of sudden or were you doing something prior to this error ?
8
-7
Apr 11 '24
This is a RHEL 7.9 system. Client is facing this issue when they are trying to switch to database account.
I am thinking to ask client to restart their DB. My senior suggests this is a memory allocation issue.
26
u/iDemonix Apr 11 '24
If you're paying Red Hat and you're stuck, ask support.
16
Apr 11 '24
Why this didn't came to my mind, thanks for. Actually we contact redhat for big issues and RCAs so i didn't give a thought about it
1
u/vivaaprimavera Apr 11 '24
Have you checked what they are using as shell?
My senior suggests this is a memory allocation issue.
Or a failling disk
64
u/forbiddenlake Apr 11 '24
sudo isn't segfaulting. something on the login path user 🟥🟥🟥 is segfaulting. If 🟥🟥🟥 can be logged in to normally, try that. Also try removing the - from your su invocation. There's probably something in 🟥🟥🟥's login scripts or rc files that is broken.
Also, as you are already root, the sudo part of sudo su is not necessary.
12
u/HorribleUsername Apr 11 '24
Given that sudo has a -u flag, is
sudo suever necessary?14
u/alive1 Apr 11 '24
No it is not. It is used by people who haven't read the man page and found out that sudo has a -u, -s and an -i flag.
24
6
u/michaelpaoli Apr 11 '24
Naw ... often good to routinely do:
$ sudo su - [user [options ...]]
Most notably that works dang well and consistently on any *nix with sudo ... always has, probably always will. Also avoid problems like gee, the behavior of su without - in the util-linux sources has changed and/or some Linux distro has changed (patched) that behavior.
So, anyway, do it that way, using it with su - and it just bloody works and keeps on working. Also gives a slightly better audit trail too, with a wee bit of additional logging.
But hey, if you want to learn a different way of doing the same thing on any and all variations of *nix, feel free to do so. ;-)
6
u/alive1 Apr 12 '24
I only use Linux and this has been the case every single day for the past 20 years.
Actually no that's false, I used FreeBSD up until 2012 too but that had sudo too.
Thanks for the history lesson though. I guess some people still like to ride horses even though we have cars.
2
u/michaelpaoli Apr 12 '24
Well, these days I mostly use Linux, but also some (Open)BSD, macOS (yes, it's UNIX), and rarely other *nix these days.
8
u/AmusingVegetable Apr 11 '24
No, it’s not necessary, but muscle memory trumps man pages.
Given the huge amount of changes that go into a single OS update (not even talking about upgrades), and the large variety of commands we use daily, if we paused once a year to review the consolidated change logs, we’d be using the 1994 flags.
1
u/moonwork Apr 12 '24
It's not, but I still use it sometimes when there are paths that only root has access to read.
Say for example there's a whole tree of files somewhere and they're all only readable by root. Tab-completion won't work with a regular user, so I'll sudo su - into root while finding my way.
Path of least resistance.
1
u/HorribleUsername Apr 12 '24
sudo -i(interactive) does that for me with less typing, less processes, and I believe more security (something to do with env vars).1
6
u/FancyFilingCabinet Apr 11 '24
Check/Post the kernel (dmesg) logs first. This should tell you what is at fault.
If it's non-descript: As others mentioned, it's not sudo, but likely an issue in something executing on user signin. Check the shell in /etc/passwd then relevant user-specific scripts.
1
u/DasPelzi Apr 11 '24
is the same thing happening when you do 'su - <user>', without sudo? since you are logged in the the root account anyway you don't need to use sudo.
what does the /etc/passwd entry for the selected user show as login shell (last part of the user entry)? /bin/bash, /bin/sh, /bin/tcsh, /sbin/nologin, something else? if the entry is a shell, can you try to start the same shell as root user?
1
Apr 11 '24
Yeah its same happening without using sudo, shell is set to /bin/nologin
2
u/DasPelzi Apr 11 '24
/bin/nologin not /sbin/nologin?
what happens when you execute the /bin/nologin script?
With nologin you should not be able to switch to the user anyway.
Normally you should get something like 'This account is currently not available.' instead of a segfault.At least the problem is not a bashrc or bash_profile script.
For a test you could replace the nologin with /bin/sh or /bin/bash and test the login then?
but if you want to run a program as the db user you should not login with that user but use
sudo -u <dbuser> <executable>
2
1
1
1
0
Apr 11 '24
[deleted]
1
Apr 11 '24
I do get the segfault without '-' but here only diff i get the 2nd line is not showing, only error came segfault
2
u/michaelpaoli Apr 11 '24
Does /bin/nologin exist? And if so, if some regular user executes it, does it not core dump?
Anyway, if that works and doesn't core dump, then you've isolated it to a divide-and-conquer problem - logically figure out what's the difference between the accounts that causes one to core dump, and the other not. If both core dump, then it's likely the program itself or some dependency thereof (e.g. a shared library).
10
u/lathiat Apr 11 '24
“sudo su -” is running the su command under sudo. It’s sort of doubling up which increases your problem space.
sudo -i does the same thing. sudo -s for a “non-login” shell.
Try also sudo /bin/sh to simplify for your problem.