BUFFALO TERASTATION FIRMWARE + Telnet access ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I have produced modified versions of quite a few of the Buffalo firmware releases, in each case making the same modifications to achieve two aims: - add telnet access - add a new user called 'myroot' that gives you root level access. The steps you need to do to use these firmware versions are: 1) Run the standard Buffalo firmware updater program that is included in the firmware download. Depending on the download you picked this can be either an English or Japanese language updater. The Japanese one is only used where I have not been able to acquire a suitable English one. 2) Select the TeraStation that you want to upgrade. Ignore the fact that it will report you are updating to 1.99 (for the 1.xx releases) or 2.99 (for the 2.xx release) - when finished it will still display the version of firmware that you have just installed. This is just to get around the version check that stops you installing new firmware that is not apparently at a higher version level. 3) Start the upgrade process. You will be prompted for the admin password. Let the process run to completion - this can take several minutes. Make sure you do not interupt the process or you may end up with a damaged TeraStation. 4) When the updated has finished, you should be able to telnet to the TeraStation with a username of 'myroot' that will be added (if not already present). If this is the first time then you will not be prompted for a password. If you already had the myroot user before the firmware upgrade then the previous password will remain valid. 5) If you did not have a password, then you should set a password on the 'myroot' user by using the command: passwd You can now use the myroot user to do anything that you could do as user 'root' as it has been set up with the same UID and GID as root. 6) Have fun! How Was Firmware Created ~~~~~~~~~~~~~~~~~~~~~~~~ 1) The start point was the information on creating new firmware on the TeraStation wiki site http://www.terastation.org. In particular this provided the techniques for unpacking/repacking the disk image firmware and the passwords that protected these images.(as given in the Password.txt file included). 2) The standard firmware was downloaded from the indicated Buffalo site and unpacked into a directory on my LinkStation 1 system. This was running the OpenLink firmware available from http://linkstationwiki.org/ so access was available at the Linux level to run scripts. I actually unpacked the firmware to a directory under the /mnt/share area so that files could easily be manipulated from both the Linux and Windows levels. This was particularly useful in providing the password for the zip/unzip process as it could be copied to the clipboard at the windows level and then pasted as required at the Linux level. 3) Where possible the firmware updater program was replaced with the one most recent english release I could obtain so that the prompts during the upgrade process were in English! In some cases this was not possible and then the original Japanese language updater was retained. The main firmware was already dual language so needed no alteration. 4) The files in the 'newfiles' directory were added. These include some telnet related binaries copies from the firmware used on the Buffalo LinkStation 1 systems. It also included the zip/unzip programs that are the latest info-zip versions compiled for ppc systems. If you want to run the update script on a different system you need to get an appropriate zip/unzip program and amend the script accordingly. 5) The script addtelnet.sh was run (included in the 'newfiles' directory) to update the firmware. Examine this script if you want to see what it does. Where files from the original Buffalo distribution are updated by this script, then the old ones are put into the 'oldfiles' directory for comparison. The requirements to get telnet access working were based on the telnet capability that is active in some firmware versions of the LinkStation. Also needed binaries were taken from there as it is binary compatible with the TeraSation. The script is relatively self expnatory and is as follows: #!/bin/sh # # This script is designed to add root access to a Terastation system # by making minimal mods to the disk image firmware # # It is designed to run on a Linux system - and has been tested # on a LinkStation 1 running the OpenLink version of the firmware # # Author: Dave Walker # Version: 0.2 # Change History: 05 Aug 2005 v0.1 First Version # 19 Mar 2006 v0.2 Added version files 'oldfiles' OLDDIR=oldfiles NEWDIR=newfiles FWDIR=fw # Go up to directory level containing firmware cd .. # Make sure no debris left from last attempt echo "preparing..." rm -fr ${FWDIR} rm -fr ${OLDDIR} rm -fr tmpimage.tgz # Setup some working directories mkdir ${FWDIR} mkdir ${OLDDIR} #Uncompress Disk image software echo "Unzipping..." ./${NEWDIR}/unzip image.dat # Extract all the files from the disk image echo "Unpacking..." cd ${FWDIR} tar -xz --numeric-owner -p -f ../tmpimage.tgz rm ../tmpimage.tgz cd .. # Take copies of any files we intend to change for reference # (plus any it would be useful to have copies of for checking) echo "Backing up files to 'oldfiles'" cp ${FWDIR}/etc/inetd.conf ${OLDDIR}/inetd.conf cp ${FWDIR}/etc/passwd ${OLDDIR}/passwd # cp ${FWDIR}/etc/rc.d/init.d/inetd ${OLDDIR}/inetd cp linkstation_version.txt ${OLDDIR}/linkstation_version.txt cp ${FWDIR}/etc/linkstation_release ${OLDDIR}/linkstation_release # Make changes to the image echo "Adding files..." # Add entry to config file to start telnet daemon cp ${NEWDIR}/inetd.conf ${FWDIR}/etc/inetd.conf # Add file that will add myroot user to password file if not already there cp ${NEWDIR}/S99addmyroot ${FWDIR}/etc/rc.d/rc3.d/S99addmyroot # Add files missing from image cp ${NEWDIR}/in.telnetd ${FWDIR}/usr/sbin/in.telnetd cp ${NEWDIR}/telnetlogin ${FWDIR}/usr/lib/telnetlogin # Recreate the new disk image archive echo "Packing..." cd ${FWDIR} tar -czf ../tmpimage.tgz . cd .. # Recompress the new archive echo "Zipping..." rm -f image.dat ./${NEWDIR}/zip -e image.dat tmpimage.tgz # Cleanup folders no longer required rm -rf ${FWDIR} rm -rf tmpimage.tgz # Finish where we started! cd ${NEWDIR} 6) The file Linkstation_version.txt is amended so that the version number was either 1.99 or 2.99 or appropriate. This is to get around the fact that the Firmware updater program will only update to a later release. Using this approach means that the update is applied regardless of what release you already have installed. After the update the version number of the firmware will display correctly. 7) The hack to get root access is done via the file put into /etc/rc.d/rc3.d/S99addmyroot that contains the following: #! /bin/sh # # addmyroot This script adds the "myroot" user with a UID of 0 # and a blank password file to the /etc/passwd file if # it does not already exist. It then removes itself. path=/bin:/usr/bin:/sbin:/usr/sbin # Add entry if it does not already exist grep "^myroot:" /etc/passwd >/dev/null || echo "myroot::0:0:root:/root:/bin/bash" >>/etc/passwd # Remove file to stop it running in future rm -f /etc/rc.d/rc3.d/S99addmyroot Dave Walker email: terastation@itimpi.freeserve.co.uk Web: http://homepage.ntlworld.com/itimpi/