yashsingh1/xdaforums huggingface dataset:
[Android Software Development] svs57:
How to setup correct authorization for sshd?

I tried set key authorization

ls -dl /data/mysysroot/root/.ssh/

drwx------ 2 root root 4096 Jan 4 14:49 /data/mysysroot/root/.ssh/

ls -l /data/mysysroot/root/.ssh/

-rwx------ 1 root root 604 Jan 4 14:49 authorized_keys

Here sshd debug

debug1: Bind to port 22 on 0.0.0.0.

Server listening on 0.0.0.0 port 22.

debug1: Bind to port 22 on ::.

Server listening on :: port 22.

debug1: Server will not fork when running in debugging mode.

debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8

debug1: inetd sockets after dupping: 3, 3

Connection from 192.168.111.101 port 44196

debug1: Client protocol version 2.0; client software version OpenSSH_6.0p1 Debian-3ubuntu1

debug1: match: OpenSSH_6.0p1 Debian-3ubuntu1 pat OpenSSH*

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_5.9

debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: client->server aes128-ctr hmac-md5 none

debug1: kex: server->client aes128-ctr hmac-md5 none

debug1: expecting SSH2_MSG_KEX_ECDH_INIT

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS received

debug1: KEX done

debug1: userauth-request for user root service ssh-connection method none

debug1: attempt 0 failures 0

Invalid user root from 192.168.111.101

debug1: Unable to open the btmp file /var/log/btmp: No such file or directory

input_userauth_request: invalid user root

Failed none for invalid user root from 192.168.111.101 port 44196 ssh2

debug1: userauth-request for user root service ssh-connection method publickey

debug1: attempt 1 failures 0

Failed publickey for invalid user root from 192.168.111.101 port 44196 ssh2

debug1: userauth-request for user root service ssh-connection method keyboard-interactive

debug1: attempt 2 failures 1

debug1: keyboard-interactive devs

debug1: auth2_challenge: user=root devs=

debug1: kbdint_alloc: devices ''

Failed keyboard-interactive for invalid user root from 192.168.111.101 port 44196 ssh2

debug1: Unable to open the btmp file /var/log/btmp: No such file or directory

---------- Post added at 04:04 PM ---------- Previous post was at 03:44 PM ----------

ps

solved

keys should be in /root/.ssh

not in /data/mysysroot/.ssh
[Android Software Development] Val3r10:
I'd like to compile some binaries as static

(I mean for example, zip unzip tar mc ... )

Any news about such option, discussed more than one year ago ?

Thank you
[Android Software Development] Xwang76:
I haven't understand if this script creates the apks for the apps or if it only compiles them for android and so it is necessary to have a rooted device in order to install them.

Can you explain to me, please?

I would like to port a python app to android (Calibre) generating an apk so that to be able to install it without the need to root my device.

Thank you,

Xwang

PS I would like to port only the "server side" of Calibre, not all the graphical part.
[Android Software Development] smitna:
Hello dateno1,

thank you very much for the feedback and your help to find possible errors and sorry for the circumstances.

It's all ok with your installation and all basics (the needed libraries) are compiled fine except one thing. The generated binary gen_lex_hash (should be in folder ./bin) fails on generating the file ./sources/mysql-5.5.19/sql/lex_hash.h

I have now changed some things in the build.sh and the cross-compiler settings script. There is a new version 1.6 on page 1 with a new adb function. Please try it.

For more informations you can have a look at http://nb-no.facebook.com/note.php?note_id=10150093867939362 (it's partly chinese)

It's the same problem, that I have hopefully solved... If there are no generated (executable) binaries comp_err, comp_sql and gen_lex_hash after the first pass in the folder [BUILDROOT]/bin then something is wrong. Could you please check this after updating to 1.6?

Thanks
[Android Software Development] dateno1:
hmm... it not work well yet

i try edit source code but not success (mysql is too complex so i can't understand :( )

attach full log again
[Android Software Development] smitna:
Hello dateno1,

now I detected your problem. I have tested the script with your settings on another machine and was able to log the error.

You haven't cleaned up (completely deleted) first the mysql source folder, right?

The new version checks now the source folder and deletes it first to make sure, that no arm binaries are left from the last build. The MySQL install generates no new host binaries and then the generation of the lex_hash file fails of course.

Please use the new version 1.7 and delete all files and folders first! The MySQL builds fine, I have tested this again and again...

This is a good output (it's always the same position):

Scanning dependencies of target GenServerSource

[ 71%] Generating sql_yacc.cc, sql_yacc.h

[ 71%] Generating lex_hash.h

[ 71%] Built target GenServerSource

Scanning dependencies of target partition

And make sure, that you have bison and yacc installed. The script checks this now.

Nevertheless: Your report was very helpful for me, because there are some other small errors in the script that I discovered while testing.

Thanks!
[Android Software Development] dateno1:
no when i test 1.6 i delete all files and folders (exclude ndk, toolchains) (even prefix folder for android)

now i noticed i'm not install autoconf2.13 (i just installed newest autoconf) (but i think it only for PHP)

i think you will need to edit cmake_toolchain_file

i was edit every time extract newer

/home/daniel/buildroot/

to

my build path
[Android Software Development] smitna:
No, not 1.6, 1.7 is the version you should use!

Yes, autoconf2.13 is mainly for the PHP install.

The cmake_toolchain_file is always new generated with the right paths if you build MySQL. You can delete this file safely.
[Android Software Development] dateno1:
1.7 not work well but...

i attaching full log

i success to built

try to search on google and i was got

cd sql

make gen_lex_hash

./gen_lex_hash > lex_hash.h

but it not worked (screenshot)

i thought need to add

cp -f $BASEDIR/lex_hash.h sql/

chmod 644 sql/lex_hash.h

or

$BASEDIR/sources/mysql-5.5.19/sql/gen_lex_hash > lex_hash.h

but you already add to overwritten gen_lex_hash on build.sh i think it has some problem (/bin/gen_lex_hash binary is fine (after all when i try run it manually it fine)

so i was copied gen_lex_hash and needs libs and run it and pulled lex_hash.h then

cp -f lex_hash.h sources/mysql-5.5.19/sql/lex_hash.h

chmod 644 sources/mysql-5.5.19/sql/lex_hash.h

cd sources/mysql-5.5.19

make

make install

finally it generate mysql :D

but i think you will need to add some share lib path for using each package (code warrior's root lib too huge :( )

so i add it on configuration.conf

TARGET_RPATH="$TARGET_SYSROOT/lib:$TARGET_SYSROOT/usr/lib:/system/lib:/data/sysroot/lib"

to

TARGET_RPATH="$TARGET_SYSROOT/lib:$TARGET_SYSROOT/usr/lib:/system/lib:/data/sysroot/lib:/sddata/share/lib:/sddata/share/usr/lib"

i think it work but not tested

SHARE_RPATH="/sddata/share"

TARGET_RPATH="$TARGET_SYSROOT/lib:$TARGET_SYSROOT/usr/lib:/system/lib:$SHARE_RPATH/lib:$SHARE_RPATH/usr/lib"
[Android Software Development] smitna:
Fine and congratulation!

I check this problem with gen_lex_hash and lex_hash.h again.

Thanks for your help.
[Android Software Development] dateno1:
i think

you will edit setting for mysql :(

finnally i can run mysql well but it need so many work :(

first i strace binary and create symlink for libs

second i create some symlink for other files (prevent error)

then it hasn't default data files so search on goolge and extract it (but i think it not work well)

finally i found mysql_install_db but it not on /bin (it /var/lib/mysql/scripts/mysql_install_db)

also it need some files on /share or /share/mysql (so create symlink from /usr/share/mysql)

and it need to remove bind-address = 127.0.0.1from my.cnf

this is screenshoot :D
[Android Software Development] smitna:
Yes, I know, MySQL is not easy to install and configure. There is a sample starter script and a my.cnf in folder targetscripts. You should disable networking (skip-networking, I don't know why it's not working on the phone) and also disable innodb (skip-innodb) then it's much faster.

If you want, you can create a small ramdisk for the socket and tmp files:

Example for a 8 MB ramdisk:

# create the mount point

mkdir /data/mysql/tmp/ramdisk

# mount the ramdisk (8 MB size):

mount -t tmpfs -o size=8m none /data/mysql/tmp/ramdisk

or dynamic:

mkdir /data/mysql/tmp/ramdisk

mount -t ramfs ramfs /data/mysql/tmp/ramdisk

So you can minimize the write cycles to the sdcard
[Android Software Development] dateno1:
/data/mysql/tmp/ramdisk is '/data/mysql/tmp/ramdisk'? or '$BASE_DIR//data/mysql/tmp/ramdisk'?
[Android Software Development] smitna:
It is the SYSROOT dir on your phone. I saw in your log, that you have this dir in /data/mysql (/data/mysql/bin, /data/mysql/sbin etc.).

You can create a folder /data/mysql/tmp

No matter where you create this ramdisk folder, It's only a mount point.
[Android Software Development] dateno1:
i know that but if i will not set '--tmpdir=' it will try default path value

i try to compile ircd (server) but it failed :(

would you add any ircd on your script?
[Android Software Development] smitna:
If you give me a link I have a look at that - there are many irc servers...
[Android Software Development] dateno1:
i want just basic function so almost server daemon is fine :) (utf-8, file transport, query,etc...)
[Android Software Development] smitna:
I have successful compiled ngIRCd

http://ngircd.barton.de/index.php.en

but I don't know, if this server supports UTF-8 and your other requirements. ngIRCd is active developed and in the Ubuntu repository. There is only one "problem": ngIRCd don't wants to run as root. So you have to create a /system/etc/passwd file with a new user or build.sh must push a little patch to ngircd.c to allow this, but that's not so good...
[Android Software Development] dateno1:
i think almost server daemon don't want to run as root :( (i already saw the source (i think it will run on the chroot) (or easy to pass the root check) )

i already added passwd and sudo, chroot, su(su -c) on my system (so i can run it on root id (su -c "command" id) :D)
[Android Software Development] dateno1:
it so interest

but default source not work well :( (even on my ubuntu)

i try it on the my phone

attach my built folder

already try to use strace -o error.txt make but it too huge (it printing 'out of memory')
[Android Software Development] smitna:
I cannot help you with your Ubuntu installation. But give me your full path (SYSROOT) on the phone and I build you a binary. I have tried it, even with openssl support. ngircd-18 is working fine and it's only one binary without libraries.
[Android Software Development] dancer_69:
I've done this, transfered the 2 tar archives to sdcard, and untar them to /data/sysroot folder as discribed on readme file. But when trying to start mc I get the error below:

# cd /data/sysroot/bin
# ./mc
GLib-WARNING **: getpwuid_r(): failed due to unknown user id (0)
The TERM environment variable is unset!

When first run mc I get an error about access denied when try to create tmp(I don' t remember the exactly error messages).

I tried to run it from android terminal without su rights, but the error is the same.
[Android Software Development] smitna:
You must set the TERM and TMPDIR variable. Look in the folder targetscripts. There is a mc starter. For that rename mc (the binary) to mc.real and edit the paths in the mc script or set all vars in the global bash settings. The term files must also be present.

To suppress the getpwuid_r() warning, create a passwd file in /system/etc and insert the root line as usual.
[Android Software Development] dancer_69:
#!/system/bin/sh
export TMPDIR=/data/local/tmp
if [ ! -e $TMPDIR ]; then
mkdir $TMPDIR
fi
# So that F1, ... works
export TERM=xterm
#export TERM=linux
[PATH_TO_SYSROOT]/bin/mc.real $*

Sorry, I don' t quite understand. Above is the mc binary in foder targetscripts. First I can open it without rename it, is needed to rename it to mc.real?

I suppose that I need to change TMPDIR to /data/sysroot/tmp, for TMPDIR

For TERM I don' t know what to change.

And also, needed to rebuild from the begining? There isn' t a way to change the paths on the device, on already builted folder(I have root rights, so I can make changes on device' s data folder)?

EDIT:

I put the passwd file on system/etc, and now the error I get when run mc changed to:

The TERM environment variable is unset!
[Android Software Development] dateno1:
it don't need any additional libraries from codesourcery or somewhere?

then i want to run it from /system :D (binary on /system/xbin and configure on /system/etc) (and if you can please use old type arm setting for all phone :) )

if it need some libraries from codesourcery i will install it on /sddata/ircd (and you must add lib path /sddata/share/lib (it from codesourcery's /usr/lib) for space)
[Android Software Development] smitna:
You don't need to rebuild, mc is build with all right foldersettings, that you have set in the configuration for the build.sh!

In folder "targetscripts" is the mc starter, a small script. You have to rename the mc binary in the SYSROOT folder/bin (I think for you it's /data/sysroot/bin/mc -> /data/sysroot/bin/mc.real). Now put the mc from targetscripts in /data/sysroot/bin/ and edit it:

export TERM=xterm

export TMPDIR=/data/sysroot/tmp

/data/sysroot/bin/mc.real $*

if you have no global TERMINFO var, then add also a line at the begin

TERMINFO=/data/sysroot/etc/terminfo

(could also be TERMINFO=/data/sysroot/share/terminfo, look at the files). In this folder terminfo are (many) subfolders like 1,2,l,x etc. (x=xterm).

Then make the mc script executable

chmod 755 mc

and start mc with this script

If mc is started without errors, you should set the key bindings in the settings (F1-F12) etc.

Have also a look in the README. There are some hints. For Midnight Commander:

If you get an error "Warning: cannot open [WRONGSYSROOTPATH]/libexec/mc/extfs.d directory"

then change to your home directory on the phone (depends on the used terminal):

cd ~/.mc

make a symlink

ln -s [SYSROOT]/libexec/mc/extfs.d

and all should be ok.

Good luck!
[Android Software Development] dancer_69:
Now it works!!

Thank you very much.

EDIT:

I have one more question.

If I backup sysroot folder from device to pc and then when change roms or wipe data/factory reset, restore this folder to the original position it will work. Is correct?
[Android Software Development] smitna:
I hope I understand your questions.

You should first create a proper sysroot dir on the phone, let's say /data/sysroot

The complete directory branch is then in /data/sysroot

Example:

/data/sysroot/bin

/data/sysroot/lib

/data/sysroot/usr/bin

/data/sysroot/etc

/data/sysroot/share

...

Then copy first the generated cs-sysroot.tar.bz2 in /data/sysroot and extract it with

tar xjf cs-sysroot.tar.bz2

So you have all libraries and files in place (in folder /data/sysroot/lib and some in /data/sysroot/usr/lib)

You have to do this only once because all later added binaries are linked against this libraries.

If you build for example later ircd, then leave the old settings for TARGET_SYSROOT (the existing directory on your phone) and copy the file ircd from your linux PC to /data/sysroot/bin on the phone and it should work without problems.

You can always check the path settings for a library or a binary after a build with

readelf -d [BINARY] on your linux pc or if you have cross-compiled the package binutils also on the phone.

There must be a line rpath (Library rpath), this is the TARGET_SYSROOT path from your configuration to find the CodeSourcery libraries and the CodeSourcery glibc.

In folder targetscript is a helper script ldd. With this script you can easily check all linked libraries. Copy this script to the phone to folder /data/sysroot/sbin (important) and check for example the binary with ldd /data/sysroot/bin/mc.real. If a library is not present, you see it in the path list. But this should not happen, if you have copied the generated android-mysysroot.tar.bz2 and cs-sysroot.tar.bz2 to the phone. In this tars are all necessary files.

Please set the right optimizer settings for your phone. It's a safe example in the configuration.conf and additional informations in the README. But if I preset the safe settings, I must set the "lowest" possible ARM arch like "armv4". I don't want to do this for the users, because I think it's possible and not to hard to find out the own optimizations or if it's not possible to set the safe optimizations itself.
[Android Software Development] smitna:
Yes, that's correct. Restore exactly the same folder structure like before the wipe and it will work again!

Hint (only to be complete): it's also possible to "duplicate" the sysroot folder with a symlink if you are later not so happy with the former set of the sysroot path.

Example:

Your old sysroot path

/data/sysroot

Now you won't have a lot of files in /data/sysroot because you have low space on the /data partition.

So create an ext3 partition on your external sdcard (side by side with the FAT32 partition) and move all the files to this partition.

Now create a symlink /data/sysroot to the mounted new partition, let's say /mnt/external_ext3 and it's also working!

Edit (to be even more complete ;)):

With my script set you create a mini linux distribution (that's not really true, because "linux" is the kernel and we don't build a new kernel). But we have a nearly independent linux system on the phone that is expandable every time if you want to do so. In contrast to other solutions (for example run a Ubuntu or Debian on the phone) we don't boot a new linux system and the "distribution" is full integrated.
[Android Software Development] dateno1:
cs-sysroot.tar.bz2 is huge package so i divide it (/usr/lib + etc) (/usr/lib is over 390Mb :( )

so just overwrite other files and folders (exclude /usr/lib) and add libpath on compiler's setting (my share libraries path is /sddata/share/lib)

if i can i will move all shared files(from cs-sysroot.tar.bz2) and

ZLIB

OPENSSL

CURL

GETTEXT

LIBXML2

READLINE

NCURSES

on /sddata/share (it will decrease package's size) (i want to install and remove individual packages)

then i want to install ircd on /sddata/ircd
[Android Software Development] smitna:
The cs-sysroot.tar.bz2 is the full package with all libraries. If you want to develop with gcc on the phone, you need also the headers. But it's possible to copy only the basic libraries like ld-linux.so.3 (the linker), libc.so.6, libm.so.6, libgcc_s.so.1 (don't ask me for the full list). Then you have only a few MB of sysroot libs + your compiled programs. If you only want to use bash, you don't need the CS libraries, because bash is compiled with NDK for use as a root shell. But for all other programs the big solution is the best and I was able to activate all features (for example for PHP) with OpenSSL, cURL, zlib, ncurses and others.
[Android Software Development] dateno1:
i want to make new method for old phone (2 years+)

so if someone want to create mini server or something for personal he just want to install some function (not all!)

no one can make all possible mix packs (ex : 1,2,3,..10 => 1,2,3,...1+2, 1+3...1+3+5...)

and i not think everyone can compile and fix error and resolve problem (maybe...)

i want to make easy installable individual package (ex : just extract and configure some setting (password, port...) )

sorry for bad english
[Android Software Development] smitna:
Ok, I understand your points. It's possible to reduce the cs-tar, as I wrote to a few MB of size. But most of the packages have a lot of dependencies to other libraries I can't ignore (look in build.sh, the part "RESOLVE DEPENDENCES"). If you want to build for example only OpenSSH, then you need no ncurses etc, only zlib. So start with a fresh build and comment out the "ALWAYS NEEDED" packages, copy the files manually after the build to the phone + the CS basic files. Perhaps later I integrate a switch for a mini build in the configuration to do this automatic. We will see :)...

If have made an update to 1.9 with the ngIRCd IRC server, try it.
[Android Software Development] myn:
One of the best threads of 2012. Great job documenting this :)

Thanks
[Android Software Development] smitna:
Yes, only my english should be polished :o
[Android Software Development] dateno1:
just add /sddata/share/lib on TARGET_RPATH (it will reduce 390Mb for each package) (other files and folders are only 27Mb)

now ALWAYS NEEDED has 100Mb (would you make share pack and add path setting on build.sh&configuration.conf? it will reduce 100Mb for each package)
[Android Software Development] dragonnn:
smitna it's possible to get working libcap on Android device? I will use setcap and getcap binaries on my device (will give some programs extra permissions without changing the user)?
[Android Software Development] iJimaniac:
One question, would air crack work?
[Android Software Development] Smasher816:
Whats possible in the way of compiling the Android SDK?

(Don't quote me on this), I am pretty sure you need a modded kernel that supports monitor mode...
[Android Software Development] smitna:
I am not sure and it needs various patches...

libcap2 need Attr and Attr prints while making an error. A pass-2 compile should be possible (Attr wants to build a binary on the build pc to generate two header files)

But these must also work for the arm/phone..

In the moment I also have not enough information about additional requirements (support by the kernel etc.). Theoretically it's possible to build nearly all if the system allows it...
[Android Software Development] smitna:
I agree, and I think the wifi driver must support this too...
[Android Software Development] Smasher816:
You have an answer to that post of mine you quoted? :P

I might try my luck at it in a little bit.
[Android Software Development] smitna:
No sorry, it was for the question about air crack, I haven't seen your question. What do you mean with the SDK? Cross-compile it for the phone?
[Android Software Development] Smasher816:
Pretty much. The ability to make android apps, on an android phone.

I know terminal IDE, can do this, however it is difficult/impossible with larger projects (multiple files, dependencies, library projects, etc).

Having ant and other SDK tools for eclipse projects would be nice.
[Android Software Development] m2xtreme:
smitna,

Very interesting stuff. There is great potential in this project and I hope to see it bring more of the great wealth of linux software over to android. The one thing that I would **love** to see is a repository hosting linux software packaged for android. Perhaps this is something you could get into the alternative market that Koush and friends are supposedly working on?

Best regards,

-m2xtreme-
[Android Software Development] dateno1:
this is new log

selected package :

IPTABLES

LUA

OPENSSH

named

SAMBA

PUREFTP

ngIRCd

i think it has very critical problem

compiled files has just 37Mb! (compile with only 'ALWAYS NEEDED' is 100Mb)
[Android Software Development] tommytomatoe:
Great work amigo :-) I was just thinking it would be fun to run git on phone. hehe
[Android Software Development] smitna:
There are some missing folders from the sysroot_folders_template.tar.bz2. You have to remove the complete folder ./sysroot (inclusive) with all subfolder to let the build script regenerate it for you. There is no function that checks a partly missing folder structur. Or you can use the script remove_all_files.sh to remove only the files and symlinks in sysroot after a build.