LD_LIRBRARY_PATH & LD_RUN_PATH

1. 소켓함수 (SunOS에서 개발할때)
#include
#include

int socket(int domain, int type, int protocol);
cc [flag ... ] file ... -lsocket -lnsl [library]

type은 SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM 이 있는데
SOCK_RAW 생소켓 혹은 날소켓이라고하며 저수준 프로토콜을 이용하기 위해서는 root 권한을
가지고있어야 한다.
이렇게 컴파일한 바이너리 파일은 setuid를 걸어주고 일반계정 권한으로 실행하면 기본 라이브러리 이외의 패스에서
링크한 라이브러리를 못찾는다고 나온다. 해결법은 다음과 같다.

Compile it with the -R flag, or with LD_RUN_PATH set.

It is a security hole for setuid executables to obey LD_LIBRARY_PATH, so they
don't.

Davin.

컴파일시 -R옵션으로 라이브러리경로를 지정해주거나
LD_RUN_PATH 환경변수에 적어준다.

LD_LIBRARY_PATH has two uses. You can use it to tell ld how to look
LD_LIBRARY_PATH는 두가지로 사용한다. ld에게 실행파일을 위해 어디에 있는
for libraries when linking an executable. You can also use it to tell
라이브러리를 링크할지 가르쳐주는데 사용할 수 있다. 또한 동적링커에게 실행
the dynamic linker where to find libraries when you run an executable.
파일이 실행될때 어디서 라이브러리를 찾아야하는지 가르쳐줄때 사용한다.
For security reasons, LD_LIBRARY_PATH is ignored by the dynamic linker
보안을 위해서, LD_LIBRARY_PATH는 동적링커에 의해 무시된다.
when a setuid or setgid file is executed.
setuid 나 setgid 가 걸린 실행파일일때

LD_RUN_PATH is used to make ld compile a library search path into an
LD_RUN_PATH 는 ld 컴파일러에게 라이브러리를 찾을 위치를 가르쳐준다.
executable. This is what you use for setuid or setgid executables.
이것은 setuid 나 setgid가 걸린 파일을 실행할때 사용한다.
There's a detailed discussion of the use of the two in the SVR4
자세한 두가지 이유는 SVR4에서
"Programmer's Guide: ANSI C and Programming Support Tools" Manual.
"Programmer's Guide: ANSI C and Porgramming Support Tools" 메뉴얼을 참고하라.

확인하는 방법
ldd -s filename
dump -Lv filename 
위로 스크롤