<< Previous | Home

Gaining root privileges on a FreeBSD server if root's shell is inaccessible

Usually I would never see this, but my line of work requires that I suspend disbelief.

Scooter user has a FreeBSD server and is "doing maintenance". Later I discover they're upgrading from 6.2 to 7.0. Usually this isn't an issue, but they went and changed root's shell to /usr/local/bin/bash. Now, anyone who knows anything about upgrading FreeBSD knows what happens between major versions. Libraries change versions, applications break. Not a pretty sight.

I, being the only FreeBSD admin on the floor at the time with some seasoning, am blessed with the task of cleaning up behind this genius after a couple of other people can't get root. Meanwhile, Scooter has the nerve to start screaming "NOW NOW NOW ASAP OMG BROKED!!!!1!1!!OEN"

Since I have never had to deal with this before, the su(1) had the answer I required. It was, however, not readily apparent that it was the answer. After some twiddling, I was able to get in by using 'su -m' and saved the day. Now all I need to do is take the time to write up some "best practices" stuff to teach folks.

Tags :

Tomcat on Plesk in the DocumentRoot

Needs refining, but here's the quick 'n nasty:

- Enable Tomcat within Plesk for the domain.

- Modify the Context for the domain within /etc/tomcat5/server.xml to
reflect the following:

<Context crossContext="false" reloadable="false" useNaming="true"
debug="0" swallowOutput="false" privileged="true" displayName="domain
name" docBase="/var/www/vhosts/domain.com/httpdocs" COOKIEs="true"
path="" cachingAllowed="true"/>


- Add a vhost.conf to the domain laying down some defaults:

[136914-www1 21:57:04]-(~)# cat
/var/www/vhosts/domain.com/conf/vhost.conf
DocumentRoot /var/www/vhosts/domain.com/httpdocs

<Directory "/var/www/vhosts/domain.com/httpdocs">
Options Indexes FollowSymLinks
DirectoryIndex index.jsp index.html index.htm
</Directory>

JkMount /servlet/* ajp13
JkMount /*.jsp ajp13

<Location "/WEB-INF/*">
AllowOverride None
deny from all
</Location>
<Location "/META-INF/*">
AllowOverride None
deny from all
</Location>


Run websrvmng, bounce Apache, then hit up a JSP file in the document root.

SCSI bus rescan

Here's a good one that I had to deal with recently.  Two drives being removed and one going in its place.  The kicker is that they wanted zero downtime.  Cool, except there's no RAID and it's just a bunch of drives in the box.  Here's what I wound up following in order to re-read the new drive and flush out the old data:


################### TO REMOVE DRIVE

echo "scsi remove-single-device 0 1 2 3" > /proc/scsi/scsi
(replace "0 1 2 3" with your "Host Channel Id Lun")

-- for us:
(SU-recover1)/var/log>cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: FUJITSU Model: MAS3184NC Rev: 5B08
Type: Direct-Access ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 03 Lun: 00
Vendor: SEAGATE Model: ST336753LC Rev: 0006
Type: Direct-Access ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 05 Lun: 00
Vendor: SEAGATE Model: ST336753LC Rev: 0006
Type: Direct-Access ANSI SCSI revision: 03
Host: scsi0 Channel: 00 Id: 06 Lun: 00
Vendor: PE/PV Model: 1x6 SCSI BP Rev: 1.1
Type: Processor ANSI SCSI revision: 02


--- want to remove the first seagate, after disabling in slot

echo "scsi remove-single-device 0 0 3 0" > /proc/scsi/scsi

############## TO RESTART
After you replace the drive and restart it

echo "scsi add-single-device 0 1 2 3" > /proc/scsi/scsi

It's rather straightforward for the technically minded folks.  Shame it requires echoing crap to /proc, since there be dragons in /proc