{"id":26,"date":"2010-04-17T17:26:45","date_gmt":"2010-04-18T02:26:45","guid":{"rendered":"\/blog\/?p=26"},"modified":"2023-09-21T09:41:24","modified_gmt":"2023-09-21T00:41:24","slug":"ld_lirbrary_path-ld_run_path","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=26","title":{"rendered":"LD_LIRBRARY_PATH &#038; LD_RUN_PATH"},"content":{"rendered":"\n1. \uc18c\ucf13\ud568\uc218 (SunOS\uc5d0\uc11c \uac1c\ubc1c\ud560\ub54c)<br \/>#include <SYS types.h><br \/>#include <SYS socket.h><br \/><br \/>int socket(int domain, int type, int protocol);<br \/>cc [flag ... ] file ... -lsocket -lnsl [library]<br \/><br \/>type\uc740 SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM \uc774 \uc788\ub294\ub370<br \/>SOCK_RAW \uc0dd\uc18c\ucf13 \ud639\uc740 \ub0a0\uc18c\ucf13\uc774\ub77c\uace0\ud558\uba70 \uc800\uc218\uc900 \ud504\ub85c\ud1a0\ucf5c\uc744 \uc774\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 root \uad8c\ud55c\uc744<br \/>\uac00\uc9c0\uace0\uc788\uc5b4\uc57c \ud55c\ub2e4.<br \/>\uc774\ub807\uac8c \ucef4\ud30c\uc77c\ud55c \ubc14\uc774\ub108\ub9ac \ud30c\uc77c\uc740 setuid\ub97c \uac78\uc5b4\uc8fc\uace0 \uc77c\ubc18\uacc4\uc815 \uad8c\ud55c\uc73c\ub85c \uc2e4\ud589\ud558\uba74 \uae30\ubcf8 \ub77c\uc774\ube0c\ub7ec\ub9ac \uc774\uc678\uc758 \ud328\uc2a4\uc5d0\uc11c<br \/>\ub9c1\ud06c\ud55c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ubabb\ucc3e\ub294\ub2e4\uace0 \ub098\uc628\ub2e4. \ud574\uacb0\ubc95\uc740 \ub2e4\uc74c\uacfc \uac19\ub2e4.<br \/><br \/>Compile it with the -R flag, or with LD_RUN_PATH set.<br \/><br \/>It is a security hole for setuid executables to obey LD_LIBRARY_PATH, so they<br \/>don't.<br \/><br \/>Davin.<br \/><br \/>\ucef4\ud30c\uc77c\uc2dc -R\uc635\uc158\uc73c\ub85c \ub77c\uc774\ube0c\ub7ec\ub9ac\uacbd\ub85c\ub97c \uc9c0\uc815\ud574\uc8fc\uac70\ub098<br \/>LD_RUN_PATH \ud658\uacbd\ubcc0\uc218\uc5d0 \uc801\uc5b4\uc900\ub2e4.<br \/><br \/>LD_LIBRARY_PATH has two uses. You can use it to tell ld how to look<br \/>LD_LIBRARY_PATH\ub294 \ub450\uac00\uc9c0\ub85c \uc0ac\uc6a9\ud55c\ub2e4. ld\uc5d0\uac8c \uc2e4\ud589\ud30c\uc77c\uc744 \uc704\ud574 \uc5b4\ub514\uc5d0 \uc788\ub294<br \/>for libraries when linking an executable. You can also use it to tell<br \/>\ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ub9c1\ud06c\ud560\uc9c0 \uac00\ub974\uccd0\uc8fc\ub294\ub370 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4. \ub610\ud55c \ub3d9\uc801\ub9c1\ucee4\uc5d0\uac8c \uc2e4\ud589<br \/>the dynamic linker where to find libraries when you run an executable.<br \/>\ud30c\uc77c\uc774 \uc2e4\ud589\ub420\ub54c \uc5b4\ub514\uc11c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ucc3e\uc544\uc57c\ud558\ub294\uc9c0 \uac00\ub974\uccd0\uc904\ub54c \uc0ac\uc6a9\ud55c\ub2e4.<br \/>For security reasons, LD_LIBRARY_PATH is ignored by the dynamic linker<br \/>\ubcf4\uc548\uc744 \uc704\ud574\uc11c, LD_LIBRARY_PATH\ub294 \ub3d9\uc801\ub9c1\ucee4\uc5d0 \uc758\ud574 \ubb34\uc2dc\ub41c\ub2e4.<br \/>when a setuid or setgid file is executed.<br \/>setuid \ub098 setgid \uac00 \uac78\ub9b0 \uc2e4\ud589\ud30c\uc77c\uc77c\ub54c<br \/><br \/>LD_RUN_PATH is used to make ld compile a library search path into an<br \/>LD_RUN_PATH \ub294 ld \ucef4\ud30c\uc77c\ub7ec\uc5d0\uac8c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ucc3e\uc744 \uc704\uce58\ub97c \uac00\ub974\uccd0\uc900\ub2e4.<br \/>executable. This is what you use for setuid or setgid executables.<br \/>\uc774\uac83\uc740 setuid \ub098 setgid\uac00 \uac78\ub9b0 \ud30c\uc77c\uc744 \uc2e4\ud589\ud560\ub54c \uc0ac\uc6a9\ud55c\ub2e4.<br \/>There's a detailed discussion of the use of the two in the SVR4<br \/>\uc790\uc138\ud55c \ub450\uac00\uc9c0 \uc774\uc720\ub294 SVR4\uc5d0\uc11c <br \/>\"Programmer's Guide: ANSI C and Programming Support Tools\" Manual.<br \/>\"Programmer's Guide: ANSI C and Porgramming Support Tools\" \uba54\ub274\uc5bc\uc744 \ucc38\uace0\ud558\ub77c.<br \/><br \/>\ud655\uc778\ud558\ub294 \ubc29\ubc95<br \/>ldd -s filename<br \/>dump -Lv filename&nbsp;\n","protected":false},"excerpt":{"rendered":"<p>1. \uc18c\ucf13\ud568\uc218 (SunOS\uc5d0\uc11c \uac1c\ubc1c\ud560\ub54c)#include #include int socket(int domain, int type, int protocol);cc [flag &#8230; ] file &#8230; -lsocket -lnsl [library] type\uc740 SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET, SOCK_RDM \uc774 \uc788\ub294\ub370SOCK_RAW \uc0dd\uc18c\ucf13 \ud639\uc740 \ub0a0\uc18c\ucf13\uc774\ub77c\uace0\ud558\uba70 \uc800\uc218\uc900 \ud504\ub85c\ud1a0\ucf5c\uc744 \uc774\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 root \uad8c\ud55c\uc744\uac00\uc9c0\uace0\uc788\uc5b4\uc57c \ud55c\ub2e4.\uc774\ub807\uac8c \ucef4\ud30c\uc77c\ud55c \ubc14\uc774\ub108\ub9ac \ud30c\uc77c\uc740 setuid\ub97c \uac78\uc5b4\uc8fc\uace0 \uc77c\ubc18\uacc4\uc815 \uad8c\ud55c\uc73c\ub85c \uc2e4\ud589\ud558\uba74 \uae30\ubcf8 \ub77c\uc774\ube0c\ub7ec\ub9ac \uc774\uc678\uc758 \ud328\uc2a4\uc5d0\uc11c\ub9c1\ud06c\ud55c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ubabb\ucc3e\ub294\ub2e4\uace0 \ub098\uc628\ub2e4. \ud574\uacb0\ubc95\uc740 \ub2e4\uc74c\uacfc [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[39],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-os_linux_unix_macos"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}