[prev in list] [next in list] [prev in thread] [next in thread] 

List:       klik-devel
Subject:    [klik-devel] How to launch efficiently an application from a cmg
From:       Lionel Tricon <lionel.tricon () free ! fr>
Date:       2007-03-03 15:19:43
Message-ID: 200703031619.43564.lionel.tricon () free ! fr
[Download RAW message or body]

Hello,

Playing with an openoffice cmg file with klikutils, i realized that the binary 
running was different with the one launching by the wrapper script.

I mean, the /usr/bin/oowriter script launch 
the  /usr/lib/ooo-2.0/program/soffice.bin binary.

So, to prevent this, i have prepared new wrapper scripts and i will be very 
curious and interrested to get some feedback about them (for those who have 
skills about bash programming). Maybe, there is a better way to achieve the 
same result and i am not aware of what was done for the actual  KLIK.

My idea was to use the inode application information to check if the good 
program is running in memory and not only a grep on a process list.

So, the first script "wrapper" call chroot (in reality, faechroot) to jail the 
fuseiso mount point :

#!/bin/bash
DIRNAME=`cd \`dirname $0\` && pwd`
export FAKECHROOT_EXCLUDE_PATHS=/tmp:/proc:/dev:/var/run
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/klikutils/lib/fakechroot
export LD_PRELOAD=$LD_PRELOAD:libfakechroot.so
/opt/klikutils/bin/chroot $DIRNAME /wrapper.chroot
if [ "$?" = "0" ]; then
  sleep 1
  fuser -k $DIRNAME
  exit 0
fi
exit 1

The second script "wrapper.chroot' run inside the chroot jail :

#!/bin/bash
. /wrapper.env
export PATH=${PATH}${KLIK_APPPATH}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}${KLIK_APPLIBRARY}
export KDE_FORK_SLAVES=1
test -x ${KLIK_APPNAME} || exit 1
${KLIK_APPNAME} $ARGS "$@" &
if [ "$?" != "0" ]; then exit 1; fi
APPINODE=`ls -i ${KLIK_APPRUN}| awk '{print $1}'`
COUNT=0
while [ $COUNT != 5 ]; do
  APPPID=`(ls -i -L /proc/*/exe 2>/dev/null)|grep ${APPINODE}|tail -1|
awk '{print $2}'|awk -F"/" '{print $3}'`
  if [ "${APPPID}" != "" ]; then break; fi
  COUNT=$(($COUNT+1))
  sleep 1
done
while test -L /proc/${APPPID}/exe >/dev/null; do sleep 1; done
exit 0

The last script "wrapper.env" is called by wrapper.chroot to assign some 
environment variables :

KLIK_APPNAME="/usr/bin/oowriter"
KLIK_APPRUN="/usr/lib/ooo-2.0/program/soffice.bin"
KLIK_APPPATH=":/usr/bin"
KLIK_APPLIBRARY=""

The first two scripts would be fixed and created by fuseiso (the cmg file 
won't contain physicaly any of them). Maybe, they could be put inside 
the /opt/klikutils/sh directory (or similar) to be read by fuseiso and 
included inside the fuseiso filesystem.

The last script would be created by the xml informations (or similar) located 
into the cmg file. For the moment, we need the path of the script or binary 
to launch, the path of the real binary which would be running into memory and 
at least the PATH and LD_LIBRARY_PATH environment variables.

Maybe we could create a section into the wiki pages if some people are 
interrested to discuss with me about the above.

My webpage contains the new scripts and a kdissert cmg file updated. Notice 
that i have tested them with kdissert and openoffice and that it works pretty 
well.

Lionel
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic