# Bash failure after upgrade



## jaro (May 14, 2011)

Hello,

I recently upgraded a FreeBSD box from 6.3 to 7.4, I made sure to uninstall/install the ports and libraries after the first attempt, however, I didn't realise the requirement of compat6x before the final upgrade install on the second attempt.

It leaves bash broken because of a failed dependency 
	
	



```
"/libexec/ld-elf.so.1: Shared object "libncurses.so.6" not found, required by "bash""
```
 plus many others.

Which means I can't login either at the console or via SSH because it dumps me out immediately after logging in. The same result for SFTP login. I am the only wheel user with my default shell set as bash. I know /bin/sh is unaffected by this because I can login via the console as root and roll back the upgrade. Second time of upgrading the same problem, but this time I will have no access to the console for maybe a week to roll it back!

How can I log in via SSH using a different shell from bash so I won't be dumped out? I can't log in as root via SSH because of the security and I am the only member of the wheel group.

Any help will be very useful.


----------



## da1 (May 14, 2011)

Go to single user mode and modify the ssh user's default shell to something else than bash.


----------



## aragon (May 14, 2011)

Also, in future I recommend installing shells/bash-static instead.


----------



## jaro (May 14, 2011)

Those suggestions are very useful and thanks, but in the immediate position how can I login via SSH as I will have no physical access to console/terminal for several days?

I have tried the obvious [cmd=]$ ssh -l user domain.ac.uk /bin/sh[/cmd] and I still get dumped out because bash is my default shell to begin with.


----------



## da1 (May 14, 2011)

> I have tried the obvious `$ ssh -l user domain.ac.uk /bin/sh`


That won't work because the command specified at the end gets executed after the shell is loaded
PS: use `for commands ;).


A quick look in the ssh manual turned out option "[FILE]SendEnv[/FILE]". [code]ssh -o SetEnv <...> user@host[/code]With that, you can send some local environment variables (I think you can also send the SHELL env) but there are some things to consider:

1) The server needs to support ssh v2
2) The server needs to have [FILE]AcceptEnv[/FILE] set in [FILE]sshd_config[/FILE]
3) Personally, I never tried it and after a fast test, it didn't work for me but I'm tired and I will try again tomorrow.

For more info:
[CMD=""]man sshd_config`
[CMD=""]man ssh[/CMD]


----------



## aragon (May 15, 2011)

If, per chance, you've enabled root logins you can try SCP/SFTP into your system and replace your password databases...


----------



## jaro (May 15, 2011)

I can't login in at all via SFTP, it dumps me out regardless of user, there are many more libraries affected by the lack of compat6x. Referring to da1's suggestion, please can someone tell me what the correct syntax would be to select a shell other than bash, specifically shell (/bin/sh), passing a SendEnv via SSH?

I have tried, but I'm not sure whether I am getting the syntax wrong or the server doesn't allow AcceptEnv.

Thanks
Will


----------



## SirDice (May 16, 2011)

You can't. It would be somewhat of a security risk if it would work. 

The only way to fix it is to log in as root directly (assuming you didn't change root's shell). If you did change root's shell you'll need to boot to single user mode to fix it.


----------



## jaro (May 16, 2011)

Thank you for your replies.

Can someone confirm that, when I get to roll back the install and begin the upgrade process again, to prevent this from happening again I need to install compat6x?

I thought I had rebuilt all third party software and the libraries following the instructions in the FreeBSD handbook. Is there a way of returning the results of the rebuild to list those that failed? Is it compat6x is simply missing or is there anything else I have to be aware of or should do to avoid shared libraries from failing?


----------



## SirDice (May 16, 2011)

When you upgrade to the next major version of FreeBSD you can either install one of the compat libraries or rebuild all your ports. The rebuilding obviously must be done _after_ the upgrade.


----------



## jaro (May 16, 2011)

I'm a little confused. Are you saying that if the ports upgrade was successful then I would not need compat6x?

Also the timing of when to rebuild the ports is a little confusing, according to the FreeBSD handbook it states after the second call of *freebsd-update install* is when to update third-party software and ports and this is when I used both portmanager and portupgrade. The handbook also says to then issue a third call of *freebsd-update install* after the ports rebuild. Should I not invoke *freebsd-update install* after upgrading the ports?


----------



## SirDice (May 16, 2011)

The final call to *freebsd-update install* removes the old libraries. Which aren't needed anymore if you rebuilt _all_ ports.

And I do admit, it's a bit confusingly written. Probably in an effort to prevent situations like yours.


----------



## DutchDaemon (May 16, 2011)

Also: don't mix portmaster and portupgrade. Stick with one or the other.


----------



## wblock@ (May 16, 2011)

I've had no problems using both portmaster and portupgrade.  Possibly it depends on what you're doing.

Seems like the real lesson of this thread is that using a non-base shell can cause problems.  Elsewhere I've suggested running bash from .cshrc so if there's a problem you just drop out into csh(1).


----------



## jb_fvwm2 (May 16, 2011)

jaro said:
			
		

> I'm a little confused. Are you saying that if the ports upgrade was successful then I would not need compat6x?
> 
> Also the timing of when to rebuild the ports is a little confusing, according to the FreeBSD handbook it states after the second call of *freebsd-update install* is when to update third-party software and ports and this is when I used both portmanager and portupgrade. The handbook also says to then issue a third call of *freebsd-update install* after the ports rebuild. Should I not invoke *freebsd-update install* after upgrading the ports?



FWIW, I upgraded v8 >> v9 and many ports still worked out-of-the-box.  One can run ldd on the binaries and rebuild them one by one if "compat" is listed in the paths, if need be.  Just then, upgrading perl5.10 to perl5.12 and of the huge list of +REQUIRED_BY, only the p5 (problematic, but that is another topic), and several others needed upgrading (maybe 1/5 of the aforementioned file). I in this case would take copious notes during the upgrade for the next time, and slowly take care of the gotcha's (make.conf etc) one-by-one.  (Ignoring freebsd-update in this answer, never used it, but I've too many ports to ever rebuild even most of them, even after a major upgrade, vs in
the past when major version bumps seemed to break things...)
And to answer the above, try to avoid removing compat6x (kernal option and port) unless there is a good reason...


----------



## jaro (May 18, 2011)

Thank you for all your help.

I'll bear all this in mind and see how it goes when I next try. One thing for certain is to have a basic shell as your default!


----------

