Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 27 May 2018, 10:11
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Palemoon in Minimal chroot
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [2 Posts]  
Author Message
s243a

Joined: 02 Sep 2014
Posts: 973

PostPosted: Wed 20 Dec 2017, 03:14    Post subject:  Palemoon in Minimal chroot  

I've been experimenting a bit with palemoon on superlupu4. There is an issue where the newer glibc library doesn't play well with the the older libraries and can result in bus errors in some sites like youtube.

What I want to do is set up a very minimal chroot environment where it is almost exactly the same as the underlying system except for some configuration differences.

Basically I want to bind across most stuff except the /etc directory so that I can use the linker with a different cache file. I looked at two palemoon wrapper files:
/usr/local/bin/palemoon-plugin-container.sh
/usr/local/bin/palemoon.sh

Which use the following commands respectively to start palemoon.
Code:

exec /usr/lib/glibc219/lib/ld-linux.so.2 --library-path /usr/lib/glibc219/lib:/usr/lib/glibc219/usr/lib:/usr/lib/glibc219/libstdc++:/usr/X11R7/lib:$PMDIR $PMDIR/plugin-container_exec "$@" #exec avoids segfault after flashplayer

and
Code:

/usr/lib/glibc219/lib/ld-linux.so.2 --library-path /usr/lib/glibc219/lib:/usr/lib/glibc219/usr/lib:/usr/lib/glibc219/libstdc++:/usr/X11R7/lib:$PMDIR $PMDIR/palemoon "$@"


The problem I was having was that the linker was looking for libraries in many other places other than these directories and conflicting verions of glibc libraries seem to be causing bus errors.

I noticed that with ldconfig I can specify a different cache file. So if I create a file called
/usr/lib/glibc219/etc/ld.so.conf
Code:

/usr/lib/glibc219/lib
/usr/lib/glibc219/usr/lib
/usr/lib/glibc219/libstdc++
/usr/X11R7/lib
/opt/palemoon
#/lib
#/usr/lib
#/usr/local/lib
#/usr/X11R7/lib
#/root/my-applications/lib

and then type on the command line
Code:

ldconfig -n -f /usr/lib/glibc219/etc/ld.so.conf -C /usr/lib/glibc219/etc/ld.so.cache


I'm able to create a new cache but I'm not able to use it with the linker at the new location without doing a chroot.

Also note that the lines commented out above in ld.so.conf are causing the bus error. So mabye we just pick what we need from these directories and either rbind it across or symbolically link it across..

Anyway, I haven't tried chroot before but I'll take a guess based on the archwiki article

Code:

cd /usr/lib/glibc219
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
mount --rbind /lib lib/
mount --rbind /usr/lib usr/lib/
mount --rbind /usr/local/lib usr/local/lib/
mount --rbind /usr/X11R7/lib usr/X11R7/lib/
mount --rbind /root/my-applications/lib root/my-applications/lib/
mount --rbind /root/my-applications/lib root/my-applications/lib
mount --rbind /usr/bin usr/bin/
mount --rbind /usr/local/bin usr/local/bin/
mount --rbind /usr/local/bin usr/local/bin/
mount --rbind /usr/X11R7/bin usr/lX11R7/bin
#mount --rbind /run run/ #The wiki mentions this. Do we need it?
mount --rbind root/my-applications/sbin root/my-applications/sbin/
chroot /usr/lib/glibc219 /usr/local/bin/palemoon




I might try this tommorow and see what happens

P.S. The wiki says that I also need to copy the following to use the internet
Code:

cp /etc/resolv.conf /usr/lib/glibc219/etc/resolv.conf


P.S. does the chroot environment get it's own "bus" whatever that means.
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 973

PostPosted: Thu 21 Dec 2017, 03:52    Post subject:  

So I decided I wanted to write a script to set this stuff up so I can make changes easily.

Here is what I have so far

/etc/rc.d/pale_chroot/build-new-root
Code:

#!/bin/bash
DIR=$(dirname "$(readlink -f "$0")") #https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
export ROOT_DIR='/usr/lib/glibc219/'
#chROTT_PREFIX="${chROOT_DIR:-ddot}"
export LIB_PREFIX="${LIB_PREFIX:-ddot/}"
export PATH_PREFIX="${PATH_PREFIX:-ddot/}"
sh -x $DIR/mk-chroot-dirs
#if [ ! "$(ls -A $ROOT_DIR$PATH_PREFIX/lib)" ]; then
  cd "$ROOT_DIR"
  #a_lib=('proc' '/sys' '/dev')
  #b_lib={'proc' 'sys/' 'dev/')
  mount -t proc proc proc/
  mount -o bind /sys sys/
  mount -o bind /dev dev/   
  #Map these ones over with a specail prefix
  a_lib=('/lib' '/usr/lib' '/usr/local/lib')
  b_lib=('lib/' 'usr/lib/' 'usr/local/lib/')   
  #for i in `seq 0 ${#a_lib[@]}-1}`; do
  for (( i=0; i<${#a_lib[@]}; i++ )); do
     mkdir -p "$LIB_PREFIX${b_lib[i]}" 
     mount --rbind "${a_lib[i]}" "$LIB_PREFIX${b_lib[i]}"
  done
  #Map these ones over without a prefix
    a_lib=('/opt/palemoon' '/usr/X11R7/lib')
    b_lib=('opt/palemoon/' 'usr/X11R7/lib/')   
  #for i in `seq 0 ${#a_lib[@]}-1}`; do
  for (( i=0; i<${#a_lib[@]}; i++ )); do
     mkdir -p "${b_lib[i]}" 
     mount --rbind "${a_lib[i]}" "${b_lib[i]}"
  done
  #mount --rbind /opt/palemoon opt/palemoon/
 
 
  #Maybe some items in path we want to compile under a seperate prefix
  #In this case we are putting /usr/local/bin under a new prefix so palemoon doesn't
  #conflict with the nonchroot environment
  a_path=('/usr/local/bin')
  b_path=('usr/local/bin/')
   for (( i=0; i<=${#a_path[@]}; i++ )); do
   mkdir -p "$LIB_PREFIX${b_path[i]}"
    mount --rbind "${a_path[i]}" "$PATH_PREFIX${b_path[i]}"
  done
 
 
 #Maybe these path items over without a seperate prefix.
  a_path=('/bin' '/usr/bin' '/usr/X11R7/bin')
  b_path=('bin/' 'usr/bin/' 'usr/X11R7/bin/')
 # for i in `seq 0 ${#a_path[@]}-1}`;  do
   for (( i=0; i<=${#a_path[@]}; i++ )); do
    mkdir -p "${b_path[i]}"
    mount --rbind "${a_path[i]}" "${b_path[i]}"
  done
 
 
#fi
#ls -sr  /usr/lib/glibc219/local/bin/palemoon
chroot /usr/lib/glibc219 /usr/local/bin/palemoon



/etc/rc.d/pale_chroot/build-new-root/mk-chroot-dirs
Code:

#!/bin/bash
#https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
cd "$ROOT_DIR"
#if [ ! -d usr/local/lib ]; then
  ROOT_DIR="${chROOT_PREFIX:-/usr/lib/glibc219}"
  LIB_PREFIX="${LIB_PREFIX:-ddot/}"
  PATH_PREFIX="${PATH_PREFIX:-ddot/}"
  #chROTT_PREFIX="${chROOT_DIR:-ddot}"
  mkdir -p "$ROOT_DIR$LIB_PREFIX"
  mkdir -p "$ROOT_DIR$PATH_PREFIX"
  declare -a dirs=('etc/' 'usr/local/lib/' 'usr/local/bin' 'usr/local/X11R7/' 'proc/' 'sys/' 'dev/' 'opt/palemoon')
  for d in "${dirs[@]}"; do
    echo "d=$d"
    mkdir -p "$d"
  done
  ln -s ../../../ "$ROOT_DIR/usr/lib/glibc219" #This lets us do ldconfig outside of the chroot env.
  echo "writing palemoon.sh"
  cat > "$ROOT_DIR/usr/local/bin/palemoon.sh" <<EOF
    #!/bin/sh
    PMDIR=/opt/palemoon
    #/usr/lib/glibc219/lib/ld-linux.so.2 --library-path /usr/lib/glibc219/lib:/usr/lib/glibc219/usr/lib:/usr/lib/glibc219/libstdc++:/usr/X11R7/lib:$PMDIR $PMDIR/palemoon "$@"
     /usr/lib/glibc219/lib/ld-linux.so.2 --library-path $PMDIR/palemoon "$@"
EOF
chmod 771 "$ROOT_DIR/usr/local/bin/palemoon.sh"
  echo "palemoon-plugin-cointainer.sh"
   ln -s ./palemoon.sh "$ROOT_DIR/usr/local/bin/palemoon"
   cat > "$ROOT_DIR/usr/local/bin/palemoon-plugin-cointainer.sh" <<EOF
    #!/bin/sh
    PMDIR=/opt/palemoon
    #exec /usr/lib/glibc219/lib/ld-linux.so.2 --library-path /usr/lib/glibc219/lib:/usr/lib/glibc219/usr/lib:/usr/lib/glibc219/libstdc++:/usr/X11R7/lib:$PMDIR $PMDIR/plugin-container_exec "$@" #exec avoids segfault after flashplayer
    exec /usr/lib/glibc219/lib/ld-linux.so.2 --library-path  $PMDIR/plugin-container_exec "$@" #exec avoids segfault after flashplayer
EOF
   ln -s ./palemoon-plugin-cointainer.sh "$ROOT_DIR/usr/local/bin/palemoon-plugin-cointainer"
   
#fi
chmod 771 "$ROOT_DIR/usr/local/bin/palemoon-plugin-cointainer.sh"


I have to link a few more things that I need to link across for the chroot to work. I'll report back when I make more progress.

Edit: I modified some of the scripts above from my orginal post. This may be more ambitious than I originally thought.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [2 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0472s ][ Queries: 11 (0.0109s) ][ GZIP on ]