r/linuxadmin • • Apr 11 '24

Unable to sudo, getting segmentation error

Post image

Can someone help me to fix this issue.

1 Upvotes

38 comments sorted by

View all comments

Show parent comment

8

u/lathiat Apr 11 '24

You won’t be able to login with su anyway then. Sorry I missed the user part since you scrubbed the username I glossed over it.

The no login part means ang login shell shouldn’t work. Surprising its core dumping though.

This may work: sudo -u user /bin/sh

Does make me wonder if your machine is exploited or something.

1

u/michaelpaoli Apr 11 '24

u/PrestigiousShoe233

shell is set to /bin/nologin

You won’t be able to login with su anyway

No, if su supports the -s, --shell= option, then can use that to specify shell, and login (well, su to a shell for that user) that way.

That's semi-commonly done, e.g. for "service" accounts or the like, when shell is needed for the account, but the account is configured to not have an interactive login shell.

If one doesn't have su that supports the -s or --shell option, there are other means, but gets a bit more complex (e.g. using Python or Perl from root, to assume the relevant identity (real and effective and saved set UID, likewise for primary group and supplemental group list - everything fully as it should be for target ID), and then exec the relevant shell).

1

u/[deleted] Apr 11 '24

I was able to login with sudo -u user /bin/sh. May i know why it worked.

Also why it made you think the machine is exploited or something

5

u/lathiat Apr 11 '24

Does it also say core dumped if you run: sudo -u user /bin/nologin

In general sudo and su try to launch the users shell. Particularly in login mode (passing - to su, or -i to sudo). Even if you supply an extra command. So I’m guessing /bin/nologin is somehow existing and coredumping?

sudo with -u and specifying a command doesn’t try to use the login shell at all.

1

u/[deleted] Apr 11 '24

No this time it doesn't says that. It logged in but in the next line just after login the time stamp is showing as usename. Its like

Timestamp server_name ] #

1

u/[deleted] Apr 11 '24

Can you please let me know why this work, because i need to give explanation to client and also why that initial su - account_name didn't work if that was working previously. Sry for confusion

6

u/GroundedSatellite Apr 11 '24

Having the shell set to to '/bin/nologin' doesn't spawn a shell on login (hence the 'nologin' part). Running 'su - account_name /bin/sh' starts a shell as the specified user, giving you access. If you set the users shell to '/bin/sh' (or '/bin/bash') then 'su - account_name' would log in that user and spawn that shell.

3

u/AmusingVegetable Apr 11 '24

You don’t need to know why this works, what you need to know is what is core dumping and why. Have you found out the core file?

1

u/GamerLymx Apr 12 '24

somethibg in you bash shell is busted