pppd-script

pppd中的script找不到相關的.so 如何解決


更新記錄

item note
20160808 第一版

目錄


PPPD Script

  • pppd定義基本的script路徑及名稱如下
  • pppd/pathnames.h
1
2
3
4
5
6
7
8
9
10
11
12
13
21 #define _PATH_UPAPFILE   _ROOT_PATH "/etc/ppp/pap-secrets"               
22 #define _PATH_CHAPFILE _ROOT_PATH "/etc/ppp/chap-secrets"
23 #define _PATH_SRPFILE _ROOT_PATH "/etc/ppp/srp-secrets"
24 #define _PATH_SYSOPTIONS _ROOT_PATH "/etc/ppp/options"
25 #define _PATH_IPUP _ROOT_PATH "/etc/ppp/ip-up"
26 #define _PATH_IPDOWN _ROOT_PATH "/etc/ppp/ip-down"
27 #define _PATH_IPPREUP _ROOT_PATH "/etc/ppp/ip-pre-up"
28 #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
29 #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
30 #define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
31 #define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors"
32 #define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/"
33 #define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf"

Script List

  • /etc/ppp/ip-up : 當撥接成功時始會執行
  • /etc/ppp/ip-down : 當pppd deamon接收到terminal訊號時會執行
  • 其上面的sciprt將會設定相關的script env如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
PPP_TTY=eth0
IFNAME=ppp2
DNS1=168.95.1.1
DNS2=168.95.192.1
PPPLOGNAME=root
IPLOCAL=1.165.93.79
PPP_REMOTE=168.95.98.254
PPP_IFACE=ppp2
PPP_TTYNAME=eth0
ORIG_UID=0
USEPEERDNS=1
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
IPREMOTE=168.95.98.254
PPP_LOCAL=1.165.93.79
MACREMOTE=60:A4:4C:C7:03:F8
PPP_IPPARAM=
PPPD_PID=1181
PWD=/
PPP_SPEED=0
DEVICE=eth0
  • 注意上面是無設定 LD_LIBRARY_PATH 變數,因此有些so會找不到如下
1
2
3
4
5
6
7
8
uci set network.eth0.dns0=168.95.1.1
uci: error while loading shared libraries: libubox.so: cannot open shared object file: No such file or directory
uci set network.eth0.dns0=168.95.192.1
uci: error while loading shared libraries: libubox.so: cannot open shared object file: No such file or directory
/etc/ppp/ip-up.d/000uci-pppoe <up>, wanIP:1.165.93.79, gateway:168.95.98.254, mState:LINK
uci: error while loading shared libraries: libubox.so: cannot open shared object file: No such file or directory
uci: error while loading shared libraries: libubox.so: cannot open shared object file: No such file or directory
uci: error while loading shared libraries: libubox.so: cannot open shared object file: No such file or directory

新增相關的LD_LIBRARY_PATH

  • /etc/ppp/ip-up
1
2
3
4
5
6
7
# The  environment is cleared before executing this script
# so the path must be reset
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH

LD_LIBRARY_PATH=/lib:/usr/local/lib:/usr/lib:/opt/dvr_board/lib
export LD_LIBRARY_PATH