Chris Staub wrote:
> The Chapter 6 ncurses instructions in the LFS dev book have this
> construction:
> 
> for lib in curses ncurses form panel menu ; do \
>         rm -vf /usr/lib/lib${lib}.so ; \
>         echo "INPUT(-l${lib}w)" >/usr/lib/lib${lib}.so ; \
>         ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a ; \
> done
> 
> That "rm /usr/lib/lib..." line is not needed. If any of those files
> exist, they will be replaced on the next command (echo "INPUT"...) anyway.

This is NOT safe if either of those library files are currently linked
into any process that's running!

As a test, I used libX11.so.6* from /usr/X11R6/lib, and xcalc, because I
could control when xcalc ran code inside that library (by moving my
mouse into the window that xcalc brought up).

Here's the test.  In one xterm:

cd /tmp
cp -a /usr/X11R6/lib/libX11.so.6* .
export LD_LIBRARY_PATH=/tmp
xcalc

Then, in a second xterm:

cd /tmp
echo "INPUT(-l/usr/X11R6/lib/libX11.so.6)" >libX11.so.6.2

Then, move the mouse over the xcalc window.  (If you're recreating the
test, you might have to actually click on the window to give it the
focus, depending on which WM you're using.)  At this point, xcalc gives
a "bus error", i.e. a segfault, because its in-memory copy of
libX11.so.6.2 has been overwritten in place.

If a file is in use, it is NOT safe to just truncate and overwrite it.
You have to remove it, then recreate it.  (If I rm libX11.so.6.2 first,
everything works fine.)

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to