回文章列表
作者mantour.bbs@ptt.cc (朱子) 看板: linux
標題Re: [問題] 無法在 .profile 內設置 LD_PRELOAD
時間批踢踢實業 (2008/03/18 Tue 14:18:17)
謝謝,你提供的資訊對我非常有用

我是照[1]裡面的方法

<quote>
    * Nowadays the session manager is started as a child of ssh-agent which
unsets LD_PRELOAD. The /etc/X11/xinit/xinitrc.d/0100.SUNWut script does some
magic to bypass this which doesn't work with Debian. So put the following
line into a new file called /etc/X11/Xsession.d/51SUNWut-preload

      STARTUP="/usr/bin/env LD_PRELOAD=/usr/lib/libc_ut.so $STARTUP"

    * KDE has an extra twist. A while ago, KDE processes were started with
the "kdeinit" wrapper. Now we have "start_kdeinit" which is a SUID-wrapper
around the kdeinit wrapper. "start_kdeinit" does some magic to "prevent
getting killed by bad heuristic in Linux OOM-killer" (quote from the source
code), then drops root privileges and calls kdeinit. And, of course, since it
is a SUID program, it drops LD_PRELOAD.
      Way out: Edit /usr/bin/startkde and replace "start_kdeinit" by
"kdeinit".
<\quote>

不過我發現我的問題好像是出在第一點而不是第二點

在這邊把我的作法寫出來

$kwrite 51Libtrash-preload
加入
STARTUP="/usr/bin/env LD_PRELOAD=/usr/lib/libtrash/libtrash.so.2.4 $STARTUP"

$sudo cp 51Libtrash-preload /etc/X11/Xsession.d/

重新登入之後
測試:
$export | grep LD_PRELOAD
declare -x LD_PRELOAD="/usr/lib/libtrash/libtrash.so.2.4"

再開幾個程式測試之後證實LD_PRELOAD確實有發揮作用

十分感謝

※ 引述《suglwu.bbs@bbs.sayya.org (suglwu)》之銘言:
: ※ 引述《mantour.bbs@ptt.cc (朱子)》之銘言:
: > 謝謝
: > 不過這個我也試過了
: > 不管是 .bash_profile , .bash_login 都試過了
: > system wide 的 /etc/profile , /etc/environment 也都試過了
: > 都是一樣的情況
: > 目前只有設在 .bashrc 的有效,但只對從konsole執行的程式有效
: > 同一個程式如果從圖形介面開啟的話就不會受到LD_PRELOAD的影響
: > 而這不是我想要的結果
: 根據 [1] 的說明
: <quote>
: KDE has an extra twist. A while ago, KDE processes were started with the
: "kdeinit" wrapper. Now we have "start_kdeinit" which is a SUID-wrapper around
: the kdeinit wrapper. "start_kdeinit" does some magic to "prevent getting
: killed by bad heuristic in Linux OOM-killer" (quote from the source code),
: then drops root privileges and calls kdeinit. And, of course, since it is a
: SUID program, it drops LD_PRELOAD.
: Way out: Edit /usr/bin/startkde and replace "start_kdeinit" by "kdeinit".
: </quote>
: 因為安全因素 SUID program 會移除 LD_PRELOAD
: start_kdeinit 這個 wrapper 是個 SUID program 所以移除 LD_PRELOAD 這個變數
: 請試看看 [1] 與 [2] 提到的兩個 workaround
: * 別用 start_kdeinit 這個 wrapper
: * 移除 start_kdeinit 的 SUID
: <quote>
: ------- Additional Comments From l.lunak kde org  2007-06-21 14:17 -------
: Already fixed. Remove suid from $KDEDIR/bin/start_kdeinit as a workaround.
: </quote>
: PS: 還未經驗證。
: [1] http://www.math.uni-leipzig.de/~hellmund/sunray.shtml
: [2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=425741

--
※ 發信站: 批踢踢實業坊(ptt.cc) 
◆ From: 140.112.213.158
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻