[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hebrew Workshop Summary
> Shalom.
>
> ...
>
> Therefore it is of the highest priority to package the LD_PRELOAD hack for
> Dov's gtkbiditext widget, which allows using logical Hebrew in most GTK
> applications. The following people volunteered for the taskforce that will
> handle this: Ilya, Shaul, Tzafrir, Yonni, Adi.
>
Package the LD_PRELOAD hack for LD_PRELOAD hack for Dov's gtkbiditext widget?
Didn't Dov created a lib of his own? Why we need the LD_PRELOAD for in the first place? Is there a problem with putting Dov's lib in the usual places?
Let me present a study case:
The case of the dante-clients (socksify) package.
The problem: For machines behind a firewall there might be a need to wrap the networking-related system calls for some programs (like ftp).
Follows is what this package has to say about replacing one lib with another (README.usage) and then its solution to the LD_PRELOAD problem (README.socksify + $(which socksify)).
[22:02:06 dante-client]$ cat README.usage
$Id: README.usage,v 1.5 1999/12/22 09:29:17 karls Exp $
The socks package can be used in two ways.
Dynamically
The simplest way to add socks support to an already
(dynamically) complied application is to use the LD_PRELOAD facility
to replace the standard library functions with socksified ones. The
libdsocksd library is provided for this purpose. See the
README.socksify file for more information. This will probably only
work with non-setuid applications since LD_PRELOAD is usually ignored
otherwise. If setting LD_PRELOAD is not possible, compilation is
another possibility.
If the application can be compiled dynamically socks support
can be added explicitly by linking with libdsocksd (usually done by adding
'-ldsocksd'). This will automagically give the application socks
support without making any code changes.
Static Compilation
If the source code for an application is available it can be
changed to use socks, even if it is not linked dynamically.
Several systemcalls must be changed to use the socksified versions
instead of the standard ones. The application is then linked with
the libsocksd library in the distribution (-lsocksd, not -ldsocksd).
These system calls can be found in the socks library:
Rconnect
Rbind
Rgetsockname
Rgetpeername
Raccept
Rrresvport
Rbindresvport
Rgethostbyname
Rgethostbyname2
Rsendto
Rrecvfrom
Rrecvfrom
Rwrite
Rwritev
Rsend
Rsendmsg
Rread
Rreadv
Rrecv
Rrecvmsg
These calls currently does nothing and are only provided for
compatibility with programs which use them.
Rlisten
Rselect
SOCKSinit
The source can either be modified directly, or by using defines to
change the source during compilation.
Either add this line to the command line:
-Dconnect=Rconnect -Dbind=Rbind -Dgetsockname=Rgetsockname -Dgetpeername=Rgetpeername -Daccept=Raccept -Drresvport=Rrresvport -Dbindresvport=Rbindresvport -Dgethostbyname=Rgethostbyname -Dgethostbyname2=Rgethostbyname2 -Dsendto=Rsendto -Drecvfrom=Rrecvfrom -Drecvfrom=Rrecvfrom -Dwrite=Rwrite -Dwritev=Rwritev -Dsend=Rsend -Dsendmsg=Rsendmsg -Dread=Rread -Dreadv=Rreadv -Drecv=Rrecv -Drecvmsg=Rrecvmsg
or add "#include <socks.h>" to all relevant source files.
Libraries
In total there are three libraries distributed with this package:
libsocksd.so - standard shared library, contains Rfoo type functions.
libsocksd.a - static version of the above.
libdsocksd.so - shared library which does socksification through the
runtime linker. Contains wrappers for standard I/O
calls.
[22:02:13 dante-client]$
[21:36:44 dante-client]$ cat README.socksify
$Id: README.socksify,v 1.4 1999/04/26 13:52:33 michaels Exp $
The shell script socksify in the bin directory is meant to aid in
using socks with already compiled dynamic binaries. This works by
setting the LD_PRELOAD environment variable to libdsocksd. It will
then wrap all networking-related system calls.
When used the script can socksify a program by simply giving it as a
parameter to socksify:
socksify ftp
A more permanent solution would be to add the LD_PRELOAD environment
value to the shell startup files. Then all non-set[ug]id applications
that are linked dynamically would be socksified.
[21:37:01 dante-client]$
[21:37:45 /tmp]$ cat $(which socksify)
#!/bin/sh -
#
# Copyright (c) 1997, 1998
# Inferno Nettverk A/S, Norway. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. The above copyright notice, this list of conditions and the following
# disclaimer must appear in all copies of the software, derivative works
# or modified versions, and any portions thereof, aswell as in all
# supporting documentation.
# 2. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by
# Inferno Nettverk A/S, Norway.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Inferno Nettverk A/S requests users of this software to return to
#
# Software Distribution Coordinator or sdc@inet.no
# Inferno Nettverk A/S
# Oslo Research Park
# Gaustadaléen 21
# N-0349 Oslo
# Norway
#
# any improvements or extensions that they make and grant Inferno Nettverk A/S
# the rights to redistribute these changes.
#
# $Id: socksify.in,v 1.20 1999/11/19 09:55:10 karls Exp $
#On systems where a supported preloading mechanism is used, you can
#do "socksify <program>" and <program> will use socks without having
#been relinked or recompiled. This will not work on statically linked
#binaries.
SOCKSIFY_PRELOAD_LIBS=" /lib/libdl.so.2"
LIBDIR="/usr/lib"
#XXX shared library name should be generated too (possibly including version)
LIBRARY="${SOCKS_LIBRARY-${LIBDIR}/libdsocksd.so.0}"
PRELOAD_SEPERATOR=" "
PRELOAD_POSTFIX=""
LD_PRELOAD="${LIBRARY}${SOCKSIFY_PRELOAD_LIBS:+${PRELOAD_SEPERATOR}}${SOCKSIFY_PRELOAD_LIBS}${PRELOAD_POSTFIX:+${PRELOAD_SEPERATOR}}${PRELOAD_POSTFIX}"
export LD_PRELOAD
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}${LIBDIR}"
export LD_LIBRARY_PATH
exec "$@"
[21:37:55 /tmp]$
Conclusions:
1) All that is needed is to modify the above socksify script. In particular, put in the correct lib names and paths, and change some var names to make it readable.
2) Much like this script is distributed with the dante-clients package, the modified script should be distributed with the programs in Dov's package.
--
-- Shaul Karl <shaulk@israsrv.net.il>
[00:41:32 /tmp]$ echo; zgrep -A15 Introduction \
> /usr/share/doc/autoconf/autoconf.html.gz | tail -n12
A physicist, an engineer, and a computer scientist were
discussing the nature of God. Surely a Physicist, said the
physicist, because early in the Creation, God made Light; and you
know, Maxwell's equations, the dual nature of electro-magnetic
waves, the relativist consequences... An Engineer!, said the
engineer, because before making Light, God split the Chaos into
Land and Water; it takes a hell of an engineer to handle that big
amount of mud, and orderly separation of solids from
liquids... The computer scientist shouted: And the Chaos,
where do you think it was coming from, hmm?
---Anonymous
[00:41:36 /tmp]$
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il