LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices

Reply
 
Search this Thread
Old 04-10-2010, 02:14 AM   #1
mn35
LQ Newbie
 
Registered: Apr 2010
Location: Beirut, Lebanon
Distribution: Solaris
Posts: 8

Rep: Reputation: 0
Unhappy Root ShelI Change - changed /etc/passwd /sbin/sh to /sbin/bash and gave No Shell


Dear Sirs,
I was troublshooting something about crontab, and I got carried away and went to /etc/passwd and changed /sbin/sh to /sbin/bash of root...
DUUHHH, /sbin/bash does NOT exist so when i tried to log in again it gave me, No Shell, and exits.

I have a Solaris 8, i have other login but it is NOT Super-User -admin. I wanted to add a script in /sbin named bash that would run /bin/sh just to bypass the issue but no permission on /sbin ( and obviously no permission on /etc/passwd ).

I read how would Solaris 10 fallback to /sbin/sh if 'No Shell' problem. But does Solaris 8 do the same ??

Is there any way to undo that? any way around it??

Please H.E.L.P.

regards.

-----------------------------------------
Life is about relativity of expectations.
 
Old 04-10-2010, 04:20 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,895

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

You should boot from the Solaris cdrom and then mount the / partition, so you can edit /etc/passwd and undo the changes

Regards
 
Old 04-10-2010, 06:17 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by bathory View Post
Hi,

You should boot from the Solaris cdrom and then mount the / partition, so you can edit /etc/passwd and undo the changes

Regards
IDK Solaris but is it not possible to log in as a non-root user and then use su to assume root privileges while continuing to use the non-root user's shell?
 
Old 04-10-2010, 08:59 AM   #4
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Catkin,

Interesting. But I don't think it's going to work. I'm not going to mess up one of my root logins to see, but I did try it on another login. For example, the sasl account has /dev/null as its "shell" on one of my systems (Solaris 9, I don't have any 8 anymore). When I tried (from root) to `su sasl`, I got the reply "su: No shell" and was left at root.
 
Old 04-10-2010, 03:45 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by choogendyk View Post
Catkin,

Interesting. But I don't think it's going to work. I'm not going to mess up one of my root logins to see, but I did try it on another login. For example, the sasl account has /dev/null as its "shell" on one of my systems (Solaris 9, I don't have any 8 anymore). When I tried (from root) to `su sasl`, I got the reply "su: No shell" and was left at root.
Not quite what I was suggesting; I was thinking of logging in as a user that does have a valid shell and then "su"ing to root. AFAIK that simply changes the effective userid without changing the shell as opposed to su - root which simulates logging in as root, including changing to the shell configured for root in /etc/passwd.
 
Old 04-10-2010, 04:45 PM   #6
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Quote:
Originally Posted by catkin View Post
Not quite what I was suggesting; I was thinking of logging in as a user that does have a valid shell and then "su"ing to root. AFAIK that simply changes the effective userid without changing the shell as opposed to su - root which simulates logging in as root, including changing to the shell configured for root in /etc/passwd.
But, `su sasl` is exactly what I tested. Not `su - sasl`.

So, just now I tested another one. I picked a user whose shell is bash. Mine is ksh. If I `su thatuser` (no "-"), I find that my shell is now bash. However, my environment otherwise (current directory, etc) is the same. If I had done `su - thatuser` I would have also gotten their login environment.
 
Old 04-10-2010, 05:36 PM   #7
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,895

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

su to root will not work with a bad shell for root. The procedure to recover from this situation is the one I've described in my port above.

Regards
 
1 members found this post helpful.
Old 04-12-2010, 12:22 AM   #8
mn35
LQ Newbie
 
Registered: Apr 2010
Location: Beirut, Lebanon
Distribution: Solaris
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks all for sharing your ideas.

Bathory, is right. I'll go through the procedure. The only way to do it is from rebooting .. but i still didn't fix it yet.

(When i got to another login and su root [or - root or else ] it still gives me: No Shell . I even tried $ su root -c "vi /etc/passwd" but that didn't work as well)

I have a question, i have FTP running on this box and I have root in /etc/ftpusers being commented

$ cat /etc/ftpusers
# root
daemon
bin

but when i try to FTP in as root it tells me access denied (NB: there is no /etc/ftp/ the / is the ftp folder).

I wanted to use FTP to open /etc/passwd and change it, can you tell me why is it giving me access denied ?



thanks all.
 
Old 04-12-2010, 02:25 AM   #9
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,895

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

Same goes for ftp. Without a valid shell (even /bin/false) you cannot ftp into server.

Regards
 
1 members found this post helpful.
Old 04-12-2010, 07:36 AM   #10
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Sorry if the side discussion confused things. It has always been my understanding that boot off cd, mount the root file system, edit /etc/passwd is the only solution. I should have made that clear when I chased the side discussion. Check the link bathory gave for recovery details.
 
Old 04-13-2010, 12:12 AM   #11
mn35
LQ Newbie
 
Registered: Apr 2010
Location: Beirut, Lebanon
Distribution: Solaris
Posts: 8

Original Poster
Rep: Reputation: 0
Cheegendyk,
At first i also thought of a way which will ask for root credentials and utilize the 'others' shell .. but i couldn't think of anything, i thought about piping, forking, a script ..something .. i couldn't find a solution. Then -as mentioned above- i thought of FTP, i already had the FTP site open from a windows computer but with a different account, i tried FTP via root, but that also didn't work, i think the reason is that the root 'shell' verifies the login of the root; and launches FTP binaries or so - so that didn't work as well.

I have a bigger problem now, i dont have the Solaris 8 CD anymore, i have 9 and 10 .... lucky me.

I'll probably sleep for a couple of days and hope the problem would vanish .. by itself.
 
Old 04-13-2010, 12:19 AM   #12
mn35
LQ Newbie
 
Registered: Apr 2010
Location: Beirut, Lebanon
Distribution: Solaris
Posts: 8

Original Poster
Rep: Reputation: 0
one last thing: if it was my own box and was able to shut it down for a short time, i would have physically pulled of the HardDisk, mounted it on windows system, took ownership of the /etc/passwd and modified it.

(I'll probably do that since i dont have the boot CD of solaris 8)
 
Old 04-13-2010, 02:01 AM   #13
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,895

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Can windows write on a UFS file system? Even linux support for writing on UFS is experimental
You best bet is to get an Opensolaris live-cd and boot from it.

Regards

Last edited by bathory; 04-13-2010 at 02:13 AM.
 
Old 04-13-2010, 04:24 AM   #14
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by mn35 View Post
I have a bigger problem now, i dont have the Solaris 8 CD anymore, i have 9 and 10 .... lucky me.
That's not a problem. A Solaris 9 or 10 CD is bootable and can be used to mount a broken Solaris 8 filesystem in order to fix it.
 
  


Reply

Tags
bash, sbin, sh, solaris


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chkroot scan - /sbin/init & /sbin/ifconfig INFECTED bicoba Linux - Security 4 06-07-2006 09:16 AM
/sbin/rc: line 271: /sbin/devfsd: No such file or directory Alexander.s Linux - General 3 04-22-2005 04:44 PM
Want2use /sbin cmds undr non-root account w/o sudo. Is it safe 2 add /sbin 2 my PATH? kornerr Linux - General 4 02-25-2005 09:29 AM
As root, not seeing /sbin and /usr/sbin in path weghman Linux - Newbie 3 04-25-2004 01:06 PM
/sbin/clock and /sbin/hwclock: out of memory problems victor2000 Linux - General 0 07-29-2003 03:16 PM


All times are GMT -5. The time now is 09:16 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration