freeasabeer

linux tools coming to MCR

Recommended Posts

From your command line I guess that you are trying to connect to 192.168.1.1 from your hero, and 192.168.1.1 has a ssh server set-up that listen on port 7823. On top of that, you want to use your hero private key that is stored in /data/dropbear/.ssh/key

Am I correct ?

that's correct

Now, from the error message I would say that 192.168.1.1 does not allow ssh connection on 7823 or does not allow key authentication.

it only allows key authentication and on port 7823

Btw, shouldn't the key file be named id_rsa.db instead of key? Another check: are /data/dropbear/.ssh permissions set to 700 and /data/dropbear/.ssh/key to 600 ?

I changed the permissions as you instructed for both .ssh and the key and also renamed the key to id_rsa.db

but the result is the same

if I do:

ssh -p 7823 -i /data/dropbear/.ssh/id_rsa.db [email protected]
it logs in perfectly if I do:
ssh -p 7823 [email protected]
I get:
No auth methodes could be used
so it doesn't see id_rsa.db as it's own private key, the -i seems to be needed if I add the working connection to the rsync command:
rsync -avhi 'ssh -p 7823 -i /data/dropbear/.ssh/key' /sdcard/Files/Backup [email protected]:/data/Backup

I get the message:

ssh: exited: Error connecting: Connection refused

rsync: connection unexpectedly closed (0 bytes received so far) [sender]

rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

very strange ;)

Share this post


Link to post
Share on other sites

Regarding ssh uid...

thanks for the reply!

I already tried creating the passwd file manually but now I did exactly as you said but I still get:

I'm using the SUFBS terminal, dunno if this matters

I get the same message when just typing:

ssh
I can see the passwd file in the /system/etc dir and it's chmodded 644
I have the same problem. rsync and ssh works great from a regular shell, but when I try to use the "Android Scripting Environment" I get the "unknown own user" error, because ASE runs the shell under a different (assigned?) UID. According to some reports, it might be possible to hack that bit of the dropbear code to only try to get the uid if a user is not specified on the ssh command. This would be fantastic to have working as ASE enables application level access to scripts (including triggering rsyncs via locale when I get home) --------- Regarding bash/ash...
Which default shell ? Android's one (/system/bin/sh) ? Or busybox's one (/system/xbin/ash) ? For the former, I agree it is pain. For the latter one IMHO it is quite good and enough for our usage: it provides shell completion (tab key) , command line history, etc... So I don't really see the need for bash here. Having said that, I do have a static build of bash ready just waiting to be used ;) I just didn't publish it because I didn't see a real need for it... but if there are some customer for bash, I'll make it available.
Interesting, when I run busybox's ash, I don't get history or tab completion (which is why I asked about bash). Any ideas what's happening? I'm on MCR3.2b2 ...
$ adb shell

# echo $0

echo $0

/system/bin/sh

# busybox ash

busybox ash

# echo $0

echo $0

ash

# which ash

which ash

/system/xbin/ash

#  --tab completion doesn't work here--

Share this post


Link to post
Share on other sites
Regarding ssh uid...

I have the same problem. rsync and ssh works great from a regular shell, but when I try to use the "Android Scripting Environment" I get the "unknown own user" error, because ASE runs the shell under a different (assigned?) UID. According to some reports, it might be possible to hack that bit of the dropbear code to only try to get the uid if a user is not specified on the ssh command. This would be fantastic to have working as ASE enables application level access to scripts (including triggering rsyncs via locale when I get home)

I figured out a way around this. It seems (and correct me if I'm wrong) that an app is assigned a permanent UID when installed (10080 in my case). So, I added another line to /etc/passwd and this fixed the problem with ssh running as that uid...

ase::10080:10080:ase:/data/local:/system/xbin/ash

Share this post


Link to post
Share on other sites
Regarding bash/ash...

Interesting, when I run busybox's ash, I don't get history or tab completion (which is why I asked about bash). Any ideas what's happening? I'm on MCR3.2b2 ...

I have compiled Bash 4.1 including history and tab completion here: http://android.modaco.com/content/software...pp-for-android/

I have also come across a problem when using your linux tools, freeasabeer. Many linux programs such as ls and chmod have dissappeared. Could someone upload their copy of /system/bin for me please? (I'm on a tmobile pulse, but I doubt that matters in this case).

Thanks,

John.

Share this post


Link to post
Share on other sites
(use busybox --install to create the symlinks)

P

Thanks Paul, that was the information I was looking for.

Edit: After trying out busybox --install, I get the following:

**snip**

I'm guessing that's because busybox is trying to install the symlinks where a normal linux distro would put them. Is there a way to specify an alternative directory?

Edit 2: doesn't matter, an adb remount, then busybox --install /system/bin does the trick ;)

Edited by John Hamelink

Share this post


Link to post
Share on other sites

I was testing the Cyanogen for Hero by jnwhiteh and applied the update rsync 3.0 but I get permission denied as normal user and not found as su

is it a problem on my part or is this update only for MCR?

Share this post


Link to post
Share on other sites

hm dropbear doesn't work for me, hadn't time to investigate more, however files and permission should be correct, the binary works too (dropbear -h) but it seems to exit instantly without an error.

Share this post


Link to post
Share on other sites
I was testing the Cyanogen for Hero by jnwhiteh and applied the update rsync 3.0 but I get permission denied as normal user and not found as su

is it a problem on my part or is this update only for MCR?

If Cyanogen for Hero by nwhiteh is similar to Kagudroid 1.2.1 (also a cyanogen based 2.1 Hero rom), then yes there are some incompatibilities with some of the packages...

This is due because cyanogen installs busybox applets in /system/xbin/bb whereas they are in /system/xbin in MCR.

So the busybox package is clearly incompatible as well as some packages that do use some full path to some of the busybox applets (screen and dropbear)

As I'm using Kagudroid, I also maintain packages specifically for Kagudroid (but I expect them to work on jnwhiteh as well). The point is that as of today I have not published these ones.

I expect to have ipkg feeds being set-up (one MCR, and one for cyanogen based roms) within next week so it will be more easier for everybody....

I just tried with the new packages you posted on 5 feb but it has the same result

Yes, same answer.

I have also come across a problem when using your linux tools, freeasabeer. Many linux programs such as ls and chmod have dissappeared. Could someone upload their copy of /system/bin for me please? (I'm on a tmobile pulse, but I doubt that matters in this case).

This is why some of them were provided packaged as update.zip .... as the update-script was designed to recreate all the symlinks!

This is also what the installation script of the newly provided ipk package does.

Share this post


Link to post
Share on other sites
hm dropbear doesn't work for me, hadn't time to investigate more, however files and permission should be correct, the binary works too (dropbear -h) but it seems to exit instantly without an error.

Which dropbear package ?

On which ROM ?

The currently published dropbear packages (either the old one as an update.zip, or the new one as .ipk) won't work on cyanogen based 2.1 roms.

Share this post


Link to post
Share on other sites
Which dropbear package ?

On which ROM ?

The currently published dropbear packages (either the old one as an update.zip, or the new one as .ipk) won't work on cyanogen based 2.1 roms.

sry my fault, dropbear_mcr_0.52-1 on modaco custom rom (3.2 Beta 5) installed through ipk package.

Edited by redcow

Share this post


Link to post
Share on other sites

ipkg feeds for MCR and 2.1 cyanogen based roms have been set-up on a free hosting.

See first post for instructions.

Let me know how it works for you.

Edited by freeasabeer

Share this post


Link to post
Share on other sites

thanks for the fast update!

I installed through adb, manually edited the .conf file (the new line for MCR and Cyanogen weren't present yet)

then I get "okpg not found" through adb

when I use a terminal on my phone I get "opkg: permission denied" and when I run it as root "opkg not found"

Share this post


Link to post
Share on other sites

thanks the ipkg feeds work fine. Regarding my dropbear problem,

sh-4.0# dropbear -A -N root -U 0 -G 0 -C 'testit' -d /data/dropbear/dss_host_key -r /data/dropbear/rsa_host_key -p 2222 -R /data/dropbear authorized_keys -F -E

[3471] Feb 08 19:55:47 Failed listening on '2222': Error listening: Permission denied

[3471] Feb 08 19:55:47 premature exit: No listening ports available.

sh-4.0#

the "modaco" dropbear binary works fine.

Share this post


Link to post
Share on other sites
thanks for the fast update!

I installed through adb, manually edited the .conf file (the new line for MCR and Cyanogen weren't present yet)

then I get "okpg not found" through adb

when I use a terminal on my phone I get "opkg: permission denied" and when I run it as root "opkg not found"

Installed through adb ? What did you do exactly ?

What does "ls -l /data/xbin/opkg" says ?

forgot to mention that I am using Cyanogen..

Yeah I think that with cyanogen the PATH is not setup like it should.

A workaround woud be to:

cd /data/local

ln -s ../xbin bin

as /data/local/bin is set in the PATH

Share this post


Link to post
Share on other sites

while playing with Google Bits 1.9 I accidentally flashed the whole rom again so have to start over ;)

will do this tomorrow

Share this post


Link to post
Share on other sites

Building some linux tools for android from scratch

Without patching programs. Its tuned for moto milestone/droid, but must work on all arm android without optimisation flags.

If you can add something or correct - please do this )

Also if you know how to build any other sources - write this. This howto tested on many platforms and hardware

Also i have compilation tricks for some other programs, but not put here, because untested.

-----------------------------------------------------------------------------------------------------------------------------------------------

All work will be in home directory (/home/xvilka)

create dir build

mkdir build

1. Download the kernel (for android on your version for device) and unpack

make headers_install ARCH=arm INSTALL_HDR_PATH=~/build/kern_h/

For some optimisations you need know, which proccessor (SoC) in your android-system(http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/ARM-Options.html#ARM-Options)

Im have Motorola Milestone - SoC = TI OMAP3430 - ARM Cortex a8 (arch - armv7a)

(http://en.wikipedia.org/wiki/ARM_architecture)

So, if you have OMAP3430-processor - use the config files with -omap3430 suffix

If you have Quallcomm MSM7200A (HTC Hero) - use the config files with -msm7200a suffix

First, we need to define _XXFLAGS, which contain some optimisation options for your compiler:

export _XXCFLAGS=" -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os" (if you have Motorola Milestone/Droid or other device with TI OMAP3430)

export _XXCFLAGS=" -march=armv6j -mtune=arm1136jf-s -O3 -Os" (if you have HTC Hero or other device with Quallcomm MSM 7200A)

................................................................................

...........

If you don't know which chip you have in phone use

export _XXCFLAGS=" -O3 -Os"

2. Download crosstool-ng (http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool),

unpack, build (you must have make,install,bash,cut,sed,grep,gcc,awk,bison,flex,automake,libtool,stat,

wget,cvs,patch,tar,gzip,bzip2,lzma,readlink,ncurses)

.configure

make

make install

3. Create directory toolchain-android, and copy config to this

XVilka-crosstool-<suffix>.config in .config

XVilka-uClibc-<suffix>.config in uClibc-0.9.30.2.config (or later version, if available)

and then run:

ct-ng menuconfig

you may change some options, if needed!

(Also use options from XXCFLAGS:

Target options -> Target optimizations ->

Architecture-level equal -march, use armv7-a

Emit assembly for CPU equal -mcpu, use cortex-a8

Tune for cpu equal -mtune, use cortex-a8

Use specific FPU equal -mfpu, use vfpv3

Floating point use hardware, because it built-in TI OMAP3430

Target CFLAGS - use -O3 -Os

) - for the Motorola Milestone/Droid

(Also use options from _XXCFLAGS:

Target options -> Target optimizations ->

Architecture-level equal -march, use armv6j

Emit assembly for CPU equal -mcpu, use nothing

Tune for cpu equal -mtune, use arm1136jf-s

Floating point use software

Target CFLAGS - use -O3 -Os

) - for the HTC Hero

Save in .config

In file uClibs-0.9.30.2.config

edit this strings:

{

UCLIBC_HAS_FLOATS=y

UCLIBC_HAS_FPU=y

# UCLIBC_HAS_SOFT_FLOAT=y

UCLIBC_EXTRA_CFLAGS=" -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os"

} - for the Motorola Milestone/Droid

{

UCLIBC_HAS_FLOATS=y

#UCLIBC_HAS_FPU=y

UCLIBC_HAS_SOFT_FLOAT=y

UCLIBC_EXTRA_CFLAGS=" -march=armv6j -mtune=arm1136jf-s -O3 -Os"

} - for the HTC Hero

and then run

ct-ng build

4. Ok, done. We have installed cross - toolchain in directory build/x-tools.

And all programs in it with names arm-android-linux-uclibsgnueabi-*

For easy using add this directory in PATH:

PATH=~/build/x-tools/arm-android-linux-uclibcgnueabi/bin:$PATH

so we can run cross-gcc by the command:

arm-android-linux-uclibcgnueabi-gcc

Root directory of target system is:

~/build/x-tools/arm-android-linux-uclibcgnueabi/arm-android-linux-uclibcgnueabi/sys-root

But for the safe - make new root dir and copy files too.

Copy files in ~/build/cross/sys-root

chmod +w sys-root

chmod +w sys-root/usr

5. Building busybox (only static build, but if we have static busybox in any problems with system problems with libs

we can easy use busybox as repair-mode tool)

copy file XVilka-busybox-<suffix>.config in .config

make menuconfig

make ARCH=arm CC="arm-android-linux-uclibcgnueabi-gcc" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -static $_XXFLAGS"

make install CONFIG_PREFIX=~/build/cross/sys-root

Copy ~/build/cross/sys-root/bin/busybox in /system/bin on device

chown root /system/bin/busybox

chmod 755 /system/bin/busybox

ln -s /system/bin/busybox /system/bin/ash

Or in other directory and you can install all programs included in busybox by the command:

busybox --install

7. Building simple but powerful text editor jupp (http://www.mirbsd.org/jupp.htm)

chmod +x configure

./configure --prefix=/system/local --disable-curses --disable-termcap --disable-termidx --host=arm-android-linux-uclibcgnueabi ARCH=arm \

CC="arm-android-linux-uclibcgnueabi-gcc" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" sysconfdir=/system/usr/local/etc sysconfjoesubdir=/joe \

CFLAGS=" -static $_XXFLAGS"

make

arm-android-linux-uclibcgnueabi-strip joe

On device:

copy joe in /system/bin

copy joerc in /system/usr/local/etc/joe

copy jupprc in /system/usr/local/etc/joe

copy jmacsrc in /system/usr/local/etc/joe

copy sintax files in /system/usr/local/etc/joe/syntax

chmod 755 /system/bin/joe

ln -s /system/bin/joe /system/bin/jupp

ln -s /system/bin/joe /system/bin/jmacs

chmod 644 /system/usr/local/etc/joe/joerc

chmod 644 /system/usr/local/etc/joe/jupprc

chmod 644 /system/usr/local/etc/joe/jmacsrc

before running joe we must define TERM

export TERM=ansi

8. How to use dinamic linking and shared libraries

(if we installed programs in local directory in sys-root,

so copy lib from local)

cd ~/build/cross/sys-root

tar -jcf lib.tar.bz2 lib/

And on device:

cd /system/usr/local

busybox tar -xcf /sdcard/lib.tar.bz2

For our programs, wich uses this non-standart library path we may create this script and run your programs by it:

#!/bin/sh

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

exec /usr/bin/local/some_program $*

9. Building libFLAC in shared library, which we can use easy and copy to /system/lib,

which have nothing in NEEDED - just kernel and you, also no any libc (bionic, or uClibc) not used.

Download latest version of libFLAC from the official site, unpack and cd to dir:

./autogen.sh --host=arm --target=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \

AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" LD="arm-android-linux-uclibcgnueabi-ld" \

RANLIB="arm-android-linux-uclibcgnueabi-ranlib" OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" \

NM="arm-android-linux-uclibcgnueabi-nm" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

CXXFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

LDFLAGS=" -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -lm -lc" --prefix="$HOME/build/cross/sys-root/usr" \

--disable-ogg --disable-oggtest --disable-rpath --disable-xmms-plugin --disable-cpplibs --disable-altivec \

--disable-3dnow --disable-thorough-tests --disable-doxygen-docs

cd src/libFLAC

make

cd .libs

arm-android-linux-uclibcgnueabi-ld -shared -s -o libFLAC.so -whole-archive libFLAC.a

And now we have shared library libFLAC.so, lybrary without any dependency, and which we can just copy in /system/lib

on device and use it from any program.

For programming on libFLAC you must see header files of libFLAC

10. Building xvid in shared library, without any dependecy, same as libFLAC.

cd src/build/generic

./configure --host=arm --target=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \

AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" \

LD="arm-android-linux-uclibcgnueabi-ld" RANLIB="arm-android-linux-uclibcgnueabi-ranlib" \

OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" NM="arm-android-linux-uclibcgnueabi-nm" \

CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

CXXFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

LDFLAGS=" -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -lm -lc" --prefix="$HOME/build/cross/sys-root/usr"

cd =build

rm-android-linux-uclibcgnueabi-ld -shared -s -o libxvidcore.so -whole-archive libxvidcore.a

So we have libxvidcore.so, which using very-very simple and copy-only-use too.

11. Building nmap

svn co --username guest --password "" svn://svn.insecure.org/nmap/

cd nmap

./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" CFLAGS=" -static $_XXFLAGS" \

CXXFLAGS=" -static $_XXFLAGS" \

--prefix="$HOME/build/cross/sys-root/system/usr/local" --with-lua=included --with-pcap=included --with-pcre=included --with-dnet=included

make

make install

12. Building dropbear

./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -static $_XXFLAGS" \

--prefix="$HOME/build/cross/sys-root/system/usr/local" --disable-zlib

make

make install

copy dbclient, dropbearconvert and dropbearkey in /system/bin

copy dropbear in /system/sbin

chown root on all copied files

chmod 755 on all copied files

my.tar.gz

Edited by XVilka

Share this post


Link to post
Share on other sites
CFLAGS=" -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os" (use for .configure and make for all programs exclude crosstool and toolchain)

Program compiled with this set of switches won't work on Hero which has an ARM 1136jf-s (armv6j arch).

Share this post


Link to post
Share on other sites
Program compiled with this set of switches won't work on Hero which has an ARM 1136jf-s (armv6j arch).

As you can see i write for this optimisations:

For your processor you must change opt. flags

-march=armv6 -O3 -Os

I use this flags for only cortex-a8.

If you have other arch - set flags CFLAGS=" -march=armv6 -O3 -Os"

Edited by XVilka

Share this post


Link to post
Share on other sites
As you can see i write for this optimisations:

For your processor you must change opt. flags

-march=armv6 -O3 -Os

I use this flags for only cortex-a8.

If you have other arch - set flags CFLAGS=" -march=armv6 -O3 -Os"

Well actually for the Hero it should be: "--with-arch=armv6j --with-tune=arm1136jf-s".

Anyway I didn't read your post very thoroughly hence i didn't see you were also giving some indications for the Hero (which are not the best ones as I just pointed out ;) )

Actually my answer was just to point ou that no Hero user should try your progs as they won't run on it.

On the other side, it may be worth to mention that due to ARM backward compatibility, any prog compiled with Hero optimisations will run on the Milestone.

Share this post


Link to post
Share on other sites
[...]

Also if you know how to build any other sources - write this. This howto tested on many platforms and hardware

Also i have compilation tricks for some other programs, but not put here, because untested.

[...]

OK... let start with the begining...

I also started a few months ago with ct -ng to build the linux tools a do provide here. But the point is that ct-ng just gives you a cross compiler chain... you're then on your own to build the progs you want. It was quite fine and straight forward with busybox, dropbear, bash.... But it started to be a real pain with mc and the libs it depends on. So I rapidly switched to another build environment: buildroot.

Like ct-ng it automates the task of building the cross compiler but it also has a great set of "receipts" to also automate the build of most of the linux tools (ranging from busybox to a X11 server and X11 applications).

All I had to do was either to tweak the existing receipt to:

- build to the prog statically (quite straight forward for busybox, dropbear, quite a pain for those using libtool....)

- add some patches here and there to force the prog to use some android specific file location (e.g. /data/local/xxx instead of /etc/xxx)

or to add brand new receipts and patches for:

- mc + slang2 (ah that one wasn't easy ;) )

- zip

- opkg

As I maintain my own "android buildroot" branch with git, I can easily push my branch to github so that people who are interesting in building more linux tools or just rebuilding those I have already ported fpr their platform can benefit from this work but moreover contribute to it (fixing some of my patches, porting some of existing buildroot receipts, adding some new, etc...)

I really would like to see this happening (collaborative effort towards building and providing android linux tools for a variety of platforms) rather than people reinventing the wheel and re-doing the very same thing just alone.

So, to resume: is there anyone here who wants me to share my buildroot branch on github and willing to contribute to it ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


MoDaCo is part of the MoDaCo.network, © Paul O'Brien 2002-2016. MoDaCo uses IntelliTxt technology.