• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Permission Problems passwd adduser addgroup usermod etc.

Hello.

I found that a lot of people have problems like:

usermod: failure while writing changes to /etc/group

or

passwd: u:r:init:s0 is not authorized to change the password of ubuntu

or

Authentication token manipulation error

or

groupadd: failure while writing changes to /etc/group
adduser: `/usr/sbin/groupadd -g 1001 ich' returned error code 10. Exiting.

And the problem, in my case, was one line in the "bootscript.sh":

$bbox mount -o bind /sys/fs/selinux $mnt/selinux.

You don't need that line.

$bbox mount -o bind /sys/fs $mnt/sys/fs
if [ $? -ne 0 ];then error_exit "Unable to mount $mnt/sys/fs!"; fi

is enough.

There is nothing in the /selinux- or /sys/fs/selinux-directory (on the Linux-side), but now it works. More or less. There are still other problems to fix, e.g. "sudo [user] [command]". There is still this problem:

sudo: PERM_ROOT: setresuid(0, -1, -1): Permission denied

But that was the solution for the permission (SELinux???) problems named above.
 
Last edited:
Here is my bootscript.sh, that goes to /data/data/com.zpwebsites.linuxonandroid/files:
https://mega.nz/#!PoRHzIJJ!J0McQVv3Dp1gNgrgKMl1DdHqoUQEH-EWseHbySQhQkE

Erase the existing bootscript.sh first!

My init.sh, that goes to the Ubuntu-folder: ~/:
https://mega.nz/#!qtZTVSyA!WcOoOO7bpAGfJh-oqZ6PJOoOzPnyGw9LteDWO0s-Ez4

Do this:

Code:
sudo rm -rf ~/init.sh
Code:
cp -av /path/to/init.sh ~
Code:
chmod a+xrw ~/init.sh

And my sources.list, that goes to the Ubuntu-folder: /etc/apt:
https://mega.nz/#!mooDCI7Q!ZKcI9Fj5UDWAcv0Dw7IrIyonQOQzzC-wnbar2aNh-fE

Do this:

Code:
sudo rm -rf /etc/apt/sources.list
Code:
cp -av /path/to/sources.list /etc/apt
Code:
sudo apt-get clean
Code:
sudo apt-get autoclean
Code:
sudo apt-get autoremove
Code:
sudo apt-get update
Code:
sudo dpkg -P tightvncserver
Code:
sudo apt-get install vnc4server

Then you can connect to the VNC-Server with e.g.: DesktopVNC

Operating System: Linux
IP Address: localhost
Password: ubuntu
Port: 5900

But first restart your phone and repeat the Linux boot procedure!

Then do this:

Code:
deluser ubuntu
Code:
kill pid

with pid that is meant in the error message that comes.

Code:
useradd -ou 0 -g 0 ubuntu
Code:
addgroup --gid 1000 ubuntu
Code:
adduser ubuntu ubuntu
Code:
adduser ubuntu sudo
Code:
vi /etc/passwd

and make following changes to the last line:

Code:
,,,

between :: in the last line

and

Code:
ba

before sh in the last line.

Now:

Code:
cd /etc/xdg/menus
Code:
ln -s kde4-applications.menu applications.menu
Code:
chmod +x applications.menu
Code:
kbuildsycoca4 --noincremental

When you get an error message about owning cache folder do this:

Code:
chown -R root.root /path/to/folder

or

Code:
chown -R ubuntu.ubuntu /path/to/folder

You can copy the file libandroid-shmem.so (https://mega.nz/#!W0YRDawb!spIy8N43lg2z-Q2Ap0CkfYJKIjihgprrxMTWgD6DQF4) to /opt folder like this:

Code:
cp -av /path/to/libandroid-shmem.so /opt

Then you can start programs that need shared memory like Firefox like this:

Code:
env LD_PRELOAD="/opt/libandroid-shmem.so" firefox

And you can set timezone like this:

Code:
dpkg-reconfigure tzdata

And repeat the boot procedure after eventually restarting your phone.
 
Last edited:
Kernel compilation for my rooted Samsung SM-A300FU (with Ubuntu 14.04):



1. You will need a rooted phone.



I did it this way:



Download: Odin (this only works with: Windows and installed: Samsung-USB-Drivers from here:



https://mega.nz/#!jxAU0CwR!hYbYXZx76j70hlPEEzudLTNkaCWORoQI2jp_EyeWgto



) here:



https://mega.nz/#!rxZmDaAb!tM4eNzJbaB8jaFvQQ77jBp64qTCrqXbERwcQhZF_Zco



(There is an Ubuntu alternative called: heimdall-flash (information here:



https://wiki.ubuntuusers.de/Heimdall (in German, but i think you will find enough information in english about it on the internet)).)



and: TWRP-Recovery here:



https://mega.nz/#!K1B0jIrJ!Dur0dXJ41vRIXKOtG2OL1bwIDKfMsuO44rRb9vqehGQ



and: hadesKernel here:



https://mega.nz/#!GtIU2YzB!onjH4qeYGTSYW5uVwAlYbLenH6TRo8ngO4W1nOSqd5Q



At first you have to flash the: TWRP-Recovery (you can get back the original: recovery.img by downloading the: Firmware for you're phone.



For my phone it is called: A300FUXXU1CPH3_DBT1CPI1_Germany_6.0.1.zip (in the: *.zip you will find the file: recovery.img, which can later, when the phone is rooted, be flashed back to your phone with: Rashr).



Now install the: Samsung-USB-Drivers from the link above.



Open: Odin on a: Windows-PC.



Then start your phone in: Download mode by restarting the phone and pressing: Volume down and Home button together (when the phone boots again).



This works as long as the phone is on.



When the telephone is off, press: Volume down, Home button and Power button together, until you see the: Warning!!-screen.



Press: Volume Up to enter: Download mode or restart your phone with: Volume down.



You can get out of the: Download mode anytime by pressing: Volume down and Power button until the phone restarts.



When: Odin has started you should see: Added!! in the: Log window, when you now connect your phone via: USB-Cable to your: Windows-PC.



Please ensure, that only: F. Reset Time is activated in the: Options window.



Now click: AP and choose the: twrp_3.0.2-1_sm-a300.tar that you've downloaded from the link above.



Then click: Start, and when everything works well you should see: PASS!



If not try again.



When it fails again, try another: TWRP.



Otherwise this will not work for your phone, but there are other: Recoveries available on the internet.



Now get out of: Download mode, like mentioned above and restart your phone.



Connect it with an: USB-Cable to your: Ubuntu- or Windows-PC and copy the file: A300FU-hadesKernel-v2.6.zip via: MTP mode to a folder you like.



You will have to permit: MTP access on your phone.



Of course you also can use: Bluetooth for this. (There are other methods to copy it to your phone, like the Android app: WiFi File Transfer Pro)



Next get into: Recovery mode by restarting your phone and pressing: Volume up and Home button together (when the telephone boots again).



When the telephone is off, press: Volume up, Home button and Power button together, until the: TWRP-Recovery starts.



At the first start it may ask you, if the: system partition should be: mounted read only.



You should allow to read and write this partition.



Now in the Recovery select: Settings.



Under: General I have activated: Skip MD5 generation during backup and: Use 24-hour clock.



Everything else is deactivated.



Other things you can set to your needs.



Now go back and choose: Install.



Select the path you copied the: A300FU-hadesKernel-v2.6.zip to.



With: Select Storage you can switch between: Internal Strorage and: Micro SDCard.



Select it and: Swipe to confirm Flash.



Then click: Next, I agree with these Terms of Use, Next, Next.



Deactivate: hadesKernel and choose: SuperSU.



Then follow the remaining steps until the end.



When everything worked well, your telephone is rooted now.



2. Kernel compilation.



The: binfmt_misc support, as for me, only comes with a self compiled kernel (with: CONFIG_BINFMT_ELF=y, CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y, CONFIG_HAVE_AOUT=y, CONFIG_BINFMT_MISC=y compiled into it).



First download the source: SM-A300FU_EUR_MM_Opensource_A300FUXXU1CPH3.zip from: opensource.samsung.com



Search for: sm-a300fu



Then extract the: Kernel.tar.gz from inside the: *.zip to a folder you like.



Now do:



Code:
sudo chmod -R a+xrw



on the folder you extracted the: Kernel.tar.gz to.



Then download the: arm-eabi-4.9-Toolchain from here:



https://mega.nz/#!K151nQCI!v78s1QY2fD-ZPIwdHd7VESjnwrfipvyK-IagOAu7lWA



and extract it to a folder you like.



And again a:



Code:
sudo chmod -R a+xrw



on the folder you extracted the: Toolchain to.



At next replace the: configs in the: Kernel/arch/arm/configs/-folder with these:



https://mega.nz/#!awphRQJB!hKjkrsY8YmqiyhF3hTp4jOS2INpWlRq04PReTE_EIec



https://mega.nz/#!ewonmQZK!v1lh5pINzpqjZKJXGn5-bh6uQiy2qggvrLdpTo6CWHI



https://mega.nz/#!SgwhHACY!eKA5tH1N1wJ7llin_GO1LKEfaiJQ4DjBpWCMW7dqQ7s



Then replace the: Kconfig in the: Kernel/drivers/misc-folder with this one:



https://mega.nz/#!Tk4RmCYb!lR4ZF9txs-52pjlIJsMu9mdkQ_g5IIoo2-SDAobHpZE



And replace the: Makefile in the: Kernel-folder with this one:



https://mega.nz/#!ekpFwI5I!a3ZOitQWtXTuZt5z9JhAcV-NJXK7WBS9dSS5Dec2ZaM



(or add the: EXTRAVERSION of your phone's kernel, if it differs from mine, found in your: Settings->About device->Kernel version.



It is the number after the: Kernel version number.



For me the Kernel version is: 3.10.49. With the: EXTRAVERSION: -8987886.



Look how i did it in my: Makefile.)



Now replace the: build_kernel.sh in the: Kernel-folder with mine:



https://mega.nz/#!v4on0SAK!oHhuYmkOrAoHk7Y6Jeu0pLX2CjTfk5ABz1tcuUH2Wb8



In the: build_kernel.sh change the path after: export CROSS_COMPILE= to the folder you extracted the: Toolchain to.



Then change the line: chmod -R a+xrw /media/anwender/EXT4/samsunga3/Kernel/output to: chmod -R a+xrw /your/Kernel/folder/output.



And then change the line: make -j64 -C $(pwd) O=output V=2 INSTALL_MOD_PATH=/home/anwender/Schreibtisch/module modules_install to: make -j64 -C $(pwd) O=output V=2 INSTALL_MOD_PATH=/the/folder/you/like/module modules_install.



The compiled modules: *.ko will be installed to this folder.



As for me, i don't need them, because everything i added to the kernel is built-in and not as modules.



And my kernel works with the original stock modules.



Otherwise copy your modules to the: /system/lib/modules-folder on your phone [i don't know if this works, because everything i added is built-in, as mentioned above].



And finally change the line: chmod -R a+xrw /media/anwender/EXT4/samsunga3/Kernel/output to: chmod -R a+xrw /your/Kernel/folder/output.



Again do:



Code:
sudo chmod -R a+xrw



on the folder you extracted the: Kernel.tar.gz to.



Now you're ready to go.



Open a: Terminal in your: Kernel-folder.



At first do:



Code:
sudo make clean



Code:
sudo make autoclean



Code:
sudo make mrproper
.



Now you can start compiling with a:



Code:
sudo ./build_kernel.sh
.



This will take a while (about one hour for me).



You will find the compiled: zImage in the: Kernel/output/arch/arm/boot-folder.



3. Unpacking, Packing and Flashing the kernel image



I used this tool to unpack and repack the: boot.img:



https://mega.nz/#!m9wBHSBR!udMbNLJ7pR-9sZ9SZsee4Q1qMq3D1XgpVw19RkFcSss



Now you need the original: boot.img of your phone.



This can be done with the: Android app: Rashr (at first start it will ask you to make a backup of your: boot.img) or with: adb:



First install: adb with:



Code:
sudo apt-get install android-tools-adb
or with: synaptic.



Now add these lines to your: /lib/udev/rules.d/70-android-tools-adb.rules:



Code:
ACTION=="add|change", SUBSYSTEM=="usb", \
  ATTRS{idVendor}=="04e8", \
  ATTRS{idProduct}=="685e|6860|6864|6866|6866", \
  TAG+="uaccess"


and make sure the file has all permissions.



Otherwise do a:



Code:
sudo chmod a+xrw /lib/udev/rules.d/70-android-tools-adb.rules



Next enable: USB debugging on your phone.



Go to: Settings->About device and tab: 7 times on: Build number to unlock: Developer mode.



Go back to: Settings, enter: Developer options and enable: USB debugging.



Now connect your phone via: USB-Cable with your: Ubuntu-PC.



Open a: Terminal and enter:



Code:
adb devices



Maybe you have to allow it on your phone.



And then (in: Terminal) enter:



Code:
adb shell



Now go to a folder with enough free space on your phone like this:



Code:
cd /sdcard



Next make a backup of your: boot partition like this:



Code:
su



Code:
dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/boot.img
.



Unpack the: bootimagetool.zip to a folder you like and do a:



Code:
sudo chmod -R a+xrw
on this folder.



Copy the original: boot.img to your: Ubuntu-PC with methods mentioned above, but in the other way of course =-).



Next follow the steps in the: README.md that comes with the: bootimagetool.



When you're done, the finished: image-new.img has to be copied to your phone.



With: Rashr you can now flash this image to your boot partition.



Or use: dd, like this:



Code:
adb shell



Code:
cd /sdcard



Code:
su



Code:
dd if=/sdcard/boot.img of=/dev/block/bootdevice/by-name/boot



When the phone has booted successfully go to: Settings->About device.



Under: Kernel-Version you should now see, that the: compilation date and time and user and desktop-name have changed.



You can add other things to your kernel with: CONFIG_* in the config files mentioned above, as long as their dependencies are fulfilled.



You will find help on the internet for this.



Congratulations.



4. Execute x86-binaries on your phone:



For this you'll have to mount an: Ubuntu-Image e.g.: ubuntu-13.10.LARGE.x86.ext2.v1.zip to a folder you like.



For this you'll have to add following lines to your: bootscript.sh (under the: Mount all required partitions section, or erase the: #s in the lines, when some things are already there):




Code:
$bbox echo -n "Checking loop device..."
if [ -b /dev/block/loop256 ]
then
  $bbox echo "FOUND"
else
  $bbox echo "MISSING"
  $bbox echo -n "Creating loop device..."
  $bbox mknod /dev/block/loop256 b 7 256
  if [ -b /dev/block/loop256 ]
  then
    $bbox echo "OK"
  else
    $bbox echo "FAILED"
    error_exit "Unable to create loop device!"
  fi
fi
$bbox losetup /dev/block/loop256 /path/to/your/ubuntu-13.10.LARGE.x86.ext2.img
if [ $? -ne 0 ]
then
  error_exit "Unable to attach image to loop device! (Image = ubuntu-13.10.LARGE.x86.ext2.img)"
fi
$bbox mount -t ext2 -o suid,sync,users,acl,rw,dev,exec,user_xattr,dirsync,mand /dev/block/loop256 $mnt/mnt
if [ $? -ne 0 ]
then
  error_exit "Unable to mount Ubuntux86.img to $mnt/mnt!"
fi



As for me this only works with the image laying in a folder on the external SD-Card.



Now do this:



Code:
sudo dpkg --add-architecture i386



Then go to: https://packages.ubuntu.com, click on: xenial, then: Administratorwerkzeuge, then: 0install.



Now search for: libc6 in the searchbar and click on: xenial (16.04LTS).



Then click on: i386 under: libc6 herunterladen.



(You will have to do this, because the file:



Code:
/lib/ld-linux.so.2



is missing.)



There you will find, where the: libc6-package can be found.



In this case it's: pool/main/g/glibc.



At next go to: http://old-releases.ubuntu.com/ubuntu and go to the folder where the package is.



Now look which version of: libc6 you have installed like this:



Code:
sudo dpkg -l | grep libc6
.



In my case it's: 2.17-93ubuntu1.



This is an old version, so install a newer one with:



Code:
sudo apt-get install libc6



And install: libgcc1 like this:



Code:
sudo apt-get install libgcc1



Now install: binfmt-support and qemu-user-static.



And do a:



Code:
update-binfmts --enable && update-binfmts --display



You should see, that everything is: (enabled).



You now have installed this versions:



Code:
libc6     2.17-93ubuntu4
libgcc1     4.8.1-10ubuntu8
gcc-4.8-base     4.8.1-10ubuntu8



You'll have to download the same versions of the i386-packages like mentioned above.



Now install this packages with:



Code:
sudo dpkg -i /path/to/libc6_2.17-93ubuntu4_i386.deb /path/to/libgcc1_4.8.1-10ubuntu8_i386.deb /path/to/gcc-4.8-base_4.8.1-10ubuntu8_i386.deb



Now go to /mnt/usr/bin-folder like this:



Code:
cd /mnt/usr/bin



And execute:



Code:
./whoami



It should say:



Code:
root



You executed an i386-binary =-).



I will update this tutorial (to be more exactly and contain more steps) later.



Have Fun. =-)
 
Last edited:
There are failures in the bootscript.sh. It should be: resolv.conf, not resov.conf and:


Code:
$bbox mount -t ext2 -o suid,sync,users,acl,rw,dev,exec,user_xattr,dirsync,mand /dev/block/loop255 $mnt


Sorry for that.
 
Last edited:
Now i've found a solution for the:


Code:
sudo: PERM_ROOT: setresuid(0, -1, -1): Permission denied


-problem.


Compile the: Kernel like mentioned above, with (in the:


msm8916_sec_defconfig
):


Code:
CONFIG_SEC_RESTRICT_ROOTING=n
CONFIG_SEC_RESTRICT_SETUID=n
CONFIG_SEC_RESTRICT_FORK=n
CONFIG_SEC_RESTRICT_ROOTING_LOG=n


Than you can use:
Code:
sudo
.


But first change your: /etc/passwd like this:


Code:
vi /etc/passwd


Then (with your: arrow keys) go to the line with the user: ubuntu!


Press:


Code:
i


to: insert something and change:


Code:
:0:0:


to


Code:
:1000:1000:


Now press:


Code:
Esc


and:


Code:
:x


and save it with:


Code:
Enter


Now:


Code:
su ubuntu


and, e.g.:


Code:
sudo blkid


it should work!


When your: home-directory isn't there, create it with (as user: root):


Code:
mkdir /home/ubuntu
cd ~
tar cf - .vnc |(cd /home/ubuntu ; tar xf -)
chown -R ubuntu.ubuntu /home/ubuntu


Change your: password with:


Code:
passwd ubuntu
 
Last edited:
You can use the: activity manager (am): from within the: chroot environment like this:


First do this in an: Android-Terminal:


Code:
su
setenforce 0


Mount your: /sdcard-directory and /system-directory to the: chroot environment like this:


In: Android create the file: ubuntu.img.mounts in the folder where your: ubuntu-


Image
lies and insert this before you start the: chroot environment:


Code:
/sdcard;sdcard
/system;system


Then in the: chroot environment do this:


Code:
sudo ln -s /android/system /system


Now download this file:


https://mega.nz/#!qhhR0ZBT!vpKYsPNt-YsZRDfA1KviAY8IUaAlynhMpHrSk9PiMpc


and copy it to your: /sdcard-directory


Now do this in the: chroot environment:


Code:
sudo cp -av /android/sdcard/am /bin
sudo chmod a+xrw am


The following is optional, when i try it now, i don't have to do this anymore (i don't know why):


[


Now, in: Android do this:


Code:
su
cd /system/lib
ln -s libc.so libc.so.6
chmod a+xrw libc.so.6
ln -s libc.so libpthread.so.0
chmod a+xrw libpthread.so.0


Now download this file:


https://mega.nz/#!a1gjWIxC!cNkSJrpqVfPPUSE8drR7_G6U-va8T2BMzoio1M9QFFw


and do this:


Code:
su
cp -av /path/to/libgcc_s.so.1 /system/lib
chmod a+xrw /system/lib/libgcc_s.so.1


]



Now you can use: am in the: chroot environment like this:


e.g.


Code:
am view *.wav


(choose your: Sound-Player or whatever)


or:


Code:
am start com.android.settings/.TetherSettings


If you have a problem with: libandroid-shmem.so, put a: # in front of the:


Code:
export LD_PRELOAD=/opt/libandroid-shmem.so


in the: init.sh-script and restart to disable it permanently, or do a:


Code:
unset LD_PRELOAD


to disable it temporarily.
 
Last edited:
I still cannot use: aplay, speaker-test or: tinyplay on the android-side.


I get this error messages:

Code:
speaker-test 1.0.27.1

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 128 to 49152
Period size range from 64 to 6144
Using max buffer size 49152
Periods = 4
Unable to set hw params for playback: Invalid argument
Setting of hwparams failed: Invalid argument

Code:
Playing WAVE 'Noise.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
aplay: set_params:1297: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: 48000
PERIOD_TIME: 125000
PERIOD_SIZE: 6000
PERIOD_BYTES: 12000
PERIODS: 4
BUFFER_TIME: 500000
BUFFER_SIZE: 24000
BUFFER_BYTES: 48000
TICK_TIME: 0

Code:
# dmesg | grep aplay
[ 2854.239099]  [0:          aplay:30875]  MSM8X16 Media1: ASoC: no backend DAIs enabled for MSM8X16 Media1
[ 2854.244859]  [2:          aplay:30875] __q6asm_cmd: DSP returned error[-5] opcode 68557

I think this is a Kernel-problem, but i cannot solve this.

Any help would be appreciated.
 
Last edited:
Hello again. I now found a solution to play sound with: aplay from the: chroot-environment.


Many many thanks to the thread starter:


https://groups.google.com/forum/m/#!topic/maru-os-dev/HzqAdt2bpNw


First download this files:


asound.conf:
https://mega.nz/file/i0R2EY6D#lJUc-x-qFoBQQvHBagJu8URdaC2SFFHJweBHGtZNYr4


debian_sound.tar.gz:
https://mega.nz/file/7hBEgQBS#nWPPzzzmTUf77R3btNUqPt9wfpF4LCLOq8f77yAciKw


Now extract the: debian_sound.tar.gz to a folder on your phone.


Then from the: chroot-environment:


Code:
cp -av /path/to/asound.conf /etc
alsa reload
cp -av /path/to/sound /opt
chmod a+xrw /opt/sound
cd /opt
./sound


At next, install the play.apk and start it. It shows a: "Hello world!".


When you've started the: sound-binary you should see a: Server Started. And when you've launched the: play.apk you should see: "connected 127.0.0.1:xxxxx".


Now do this in a: Terminal in the: chroot-environment:


Code:
aplay /usr/share/sounds/alsa/Front_Center.wav


It should work! =)
 
Back
Top Bottom