lxc-attach.sgml.in revision aef119a3fa1054044f405c660008cb7ababbba08
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholeslxc: linux Container library
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes(C) Copyright IBM Corp. 2007, 2008
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesDaniel Lezcano <daniel.lezcano at free.fr>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesThis library is free software; you can redistribute it and/or
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesmodify it under the terms of the GNU Lesser General Public
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesLicense as published by the Free Software Foundation; either
0662ed52e814f8f08ef0e09956413a792584eddffuankgversion 2.1 of the License, or (at your option) any later version.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesThis library is distributed in the hope that it will be useful,
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesbut WITHOUT ANY WARRANTY; without even the implied warranty of
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesLesser General Public License for more details.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesYou should have received a copy of the GNU Lesser General Public
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesLicense along with this library; if not, write to the Free Software
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesTranslated into Korean
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholesby Sungbae Yoo <sungbae.yoo at samsung.com>
16b55a35cff91315d261d1baa776138af465c4e4fuankg<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <refnamediv>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <refpurpose>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes start a process inside a running container.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 실행 중인 컨테이너 내에 프로세스를 실행
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes </refpurpose>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes </refnamediv>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <refsynopsisdiv>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <cmdsynopsis>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <arg choice="req">-n <replaceable>name</replaceable></arg>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <arg choice="opt">-a <replaceable>arch</replaceable></arg>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <arg choice="opt">-s <replaceable>namespaces</replaceable></arg>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <arg choice="opt">-- <replaceable>command</replaceable></arg>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes </cmdsynopsis>
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg </refsynopsisdiv>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <command>lxc-attach</command> runs the specified
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>command</replaceable> inside the container
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes specified by <replaceable>name</replaceable>. The container
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes has to be running already.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <command>lxc-attach</command>는 <replaceable>name</replaceable>으로 지정한 컨테이너 내에 <replaceable>command</replaceable>를 실행한다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 해당 컨테이너는 실행중이어야 한다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes If no <replaceable>command</replaceable> is specified, the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes current default shell of the user running
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <command>lxc-attach</command> will be looked up inside the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes container and executed. This will fail if no such user exists
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes inside the container or the container does not have a working
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes nsswitch mechanism.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 만약 <replaceable>command</replaceable>가 지정되지 않았다면, <command>lxc-attach</command>가 현재 실행 중인 쉘이 컨테이너 안에도 있는지 검사하고 이를 실행한다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 만약 컨테이너 안에 사용자가 존재하지 않거나, nsswitch가 제대로 동작하지 않는 경우에는 이 명령이 실패하게 된다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes Previous versions of <command>lxc-attach</command> simply attached to the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes specified namespaces of a container and ran a shell or the specified command
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes without first allocating a pseudo terminal. This made them vulnerable to
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes input faking via a TIOCSTI <command>ioctl</command> call after switching
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes between userspace execution contexts with different privilege levels. Newer
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes versions of <command>lxc-attach</command> will try to allocate a pseudo
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes terminal master/slave pair on the host and attach any standard file
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg descriptors which refer to a terminal to the slave side of the pseudo
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes terminal before executing a shell or command. Note, that if none of the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes standard file descriptors refer to a terminal <command>lxc-attach</command>
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg will not try to allocate a pseudo terminal. Instead it will simply attach
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes to the containers namespaces and run a shell or the specified command.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 이전 버전의 <command>lxc-attach</command>는 단순히 컨테이너의 특정 네임스페이스에 붙어, 쉘을 실행하거나 첫 번째 pseudo 터미널 할당 없이 특정 명령어를 실행하였다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 이는 다른 특권 수준을 갖는 사용자 영역 컨텍스트 간의 전환후 TIOCSTI <command>ioctl</command>를 호출하여 입력을 가로챌 수 있는 취약점이 있다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 새로운 버전의 <command>lxc-attach</command>는 쉘이나 명령어를 실행하기 전에, pseudo 터미널 마스터/슬레이브 쌍을 호스트에 할당하고 터미널을 가리키고 있던 표준 입출력 파일 디스크립터들은 슬레이브 pseudo 터미널로 붙인다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 터미널을 가리키고 있던 표준 입출력 파일 디스크립터가 아예 없었다면, <command>lxc-attach</command>는 pseudo 터미널 할당을 시도하지 않음에 주의해야 한다. 단순히 컨테이너 네임스페이스에 붙어 쉘이나 지정한 명령어만 실행할 뿐이다.
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg <variablelist>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <varlistentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <option>-a, --arch <replaceable>arch</replaceable></option>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes Specify the architecture which the kernel should appear to be
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes running as to the command executed. This option will accept the
0662ed52e814f8f08ef0e09956413a792584eddffuankg same settings as the <option>lxc.arch</option> option in
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes container configuration files, see
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <citerefentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <refentrytitle><filename>lxc.conf</filename></refentrytitle>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <manvolnum>5</manvolnum>
0662ed52e814f8f08ef0e09956413a792584eddffuankg </citerefentry>. By default, the current archictecture of the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes running container will be used.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 명령어를 실행하는 컨테이너의 아키텍처를 지정한다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 이 옵션은 컨테이너의 설정파일에서 지정한 <option>lxc.arch</option> 옵션과 같은 것만 사용할 수 있다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <citerefentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <refentrytitle><filename>lxc.conf</filename></refentrytitle>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes </citerefentry>를 참조 바란다. 기본값은 실행 중인 컨테이너의 아키텍처이다.
0662ed52e814f8f08ef0e09956413a792584eddffuankg </listitem>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes </varlistentry>
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg <varlistentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes -e, --elevated-privileges <replaceable>privileges</replaceable>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes Do not drop privileges when running
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>command</replaceable> inside the container. If
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes this option is specified, the new process will
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <emphasis>not</emphasis> be added to the container's cgroup(s)
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes and it will not drop its capabilities before executing.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 컨테이너 내부에서 <replaceable>command</replaceable>를 실행할 때 privilege를 제거하지 않는다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 만약 이 옵션이 지정되었다면, 새로운 프로세스는 컨테이너의 cgroup에 추가되지 <emphasis>않는다</emphasis>. 그리고 실행 전 capability도 제거하지 않는다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes You may specify privileges, in case you do not want to elevate all of
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes them, as a pipe-separated list, e.g.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>CGROUP|LSM</replaceable>. Allowed values are
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>CGROUP</replaceable>, <replaceable>CAP</replaceable> and
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>LSM</replaceable> representing cgroup, capabilities and
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes restriction privileges respectively. (The pipe symbol needs to be escaped,
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes e.g. <replaceable>CGROUP\|LSM</replaceable> or quoted, e.g.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>"CGROUP|LSM"</replaceable>.)
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 만약 모든 privilege를 얻고 싶지 않을 경우에는 <replaceable>CGROUP|LSM</replaceable>와 같이 파이프(|)로 구분된 리스트를 사용할 수 있다. 허용되는 값은 <replaceable>CGROUP</replaceable>、<replaceable>CAP</replaceable>、<replaceable>LSM</replaceable>이다. 각각 cgroup, capability, MAC label을 나타낸다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes (파이프 기호는 <replaceable>CGROUP\|LSM</replaceable>처럼 \로 처리를 해주거나, <replaceable>"CGROUP|LSM"</replaceable>처럼 따옴표를 붙여야 한다.)
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <emphasis>Warning:</emphasis> This may leak privileges into the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes container if the command starts subprocesses that remain active
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes after the main process that was attached is terminated. The
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes (re-)starting of daemons inside the container is problematic,
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes especially if the daemon starts a lot of subprocesses such as
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <command>cron</command> or <command>sshd</command>.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <emphasis>Use with great care.</emphasis>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 만약 명령어가 attach된 메인프로세스가 종료된 후에, 실행 상태로 남아있는 서브프로세스를 시작하려고 한다면, 컨테이너 내부로 privilege 누수가 발생할 수 있다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 컨테이너 내에서 데몬을 시작(또는 재시작)하는 것은 문제가 될 수 있다. 특히 만약 데몬이 많은 서브프로세스 를 실행하는 경우라면, 예를 들어 <command>cron</command>와 <command>sshd</command>와 같은 경우는 문제가 될 수 있다.
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg </varlistentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <varlistentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <option>-s, --namespaces <replaceable>namespaces</replaceable></option>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes Specify the namespaces to attach to, as a pipe-separated list,
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes e.g. <replaceable>NETWORK|IPC</replaceable>. Allowed values are
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>MOUNT</replaceable>, <replaceable>PID</replaceable>,
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>UTSNAME</replaceable>, <replaceable>IPC</replaceable>,
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>USER </replaceable> and
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>NETWORK</replaceable>. This allows one to change
8ffac2c334103c0336602aaede650cb578611151fuankg the context of the process to e.g. the network namespace of the
8ffac2c334103c0336602aaede650cb578611151fuankg container while retaining the other namespaces as those of the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes host. (The pipe symbol needs to be escaped, e.g.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <replaceable>MOUNT\|PID</replaceable> or quoted, e.g.
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg <replaceable>"MOUNT|PID"</replaceable>.)
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 붙일 네임스페이스를 지정한다. <replaceable>NETWORK|IPC</replaceable>와 같이 파이프(|)로 구분된 리스트를 사용할 수 있다. 허용되는 값은 <replaceable>MOUNT</replaceable>, <replaceable>PID</replaceable>, <replaceable>UTSNAME</replaceable>, <replaceable>IPC</replaceable>, <replaceable>USER </replaceable>, <replaceable>NETWORK</replaceable>이다. 이를 사용하여, 컨테이너의 네트워크 네임스페이스를 사용하면서도 다른 네임스페이스는 호스트의 것을 그대로 사용하는 등의 조작이 가능하다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes (파이프 기호는 <replaceable>MOUNT\|PID</replaceable>처럼 \로 처리를 해주거나, <replaceable>"MOUNT|PID"</replaceable>처럼 따옴표를 붙여야 한다.)
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg <emphasis>Important:</emphasis> This option implies
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg <option>-e</option>.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <emphasis>중요 :</emphasis> 이 옵션은 <option>-e</option> 옵션을 포함하고 있다.
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg </varlistentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes <varlistentry>
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes When using <option>-s</option> and the mount namespace is not
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes included, this flag will cause <command>lxc-attach</command>
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg to remount <replaceable>/proc</replaceable> and
0662ed52e814f8f08ef0e09956413a792584eddffuankg <replaceable>/sys</replaceable> to reflect the current other
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes namespace contexts.
0662ed52e814f8f08ef0e09956413a792584eddffuankg <option>-s</option>를 사용하여 마운트 네임스페이스를 포함하지 않았을 때, 이 플래그는 <command>lxc-attach</command>가 <replaceable>/proc</replaceable>와 <replaceable>/sys</replaceable>를 remount 하게 만든다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes 이는 현재와 다른 네임스페이스 컨텍스트를 반영시키기 위함이다.
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes Please see the <emphasis>Notes</emphasis> section for more
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes This option will be ignored if one tries to attach to the
d3fc1a9aec53a772142e2909441b213f3ae8102abnicholes mount namespace anyway.
현재의 환경변수를 attach될 프로그램에도 그대로 적용한다. 이것은 현재 기본 동작이지만 (버전 0.9에서), 향후에 충분히 바뀔 수도 있다. 왜냐하면, 이것은 컨테이너에게 바람직하지 않은 정보를 넘겨줄 수 있는 위험성이 있기 때문이다. 따라서 이 기능에 의존하고 있다면, 향후에도 이를 보장할 수 있도록 이 옵션을 사용하는 것이 좋다. 또한 현재 환경 변수와 더불어, container=lxc도 설정된다.
NET_ADMIN capability없이 실행중인 컨테이너의 네트워크 링크 eth1을 비활성화하였다. <option>-e</option> 옵션을 사용하여 capability를 높였고, <command>ip</command> 툴이 설치되어있다고 가정하였다.
(pid와 마운트 네임스페이스를 포함한) attach가 동작하기 위해서는 커널의 버전이 3.8 이상이거나 패치가 적용된 커널이어야 한다. 좀더 자세히 보려면 lxc 웹사이트를 참고하면 된다. <command>lxc-attach</command>는 패치되지 않은 커널 버전 3.7 이하면 실패된다.
그러나 <option>-s</option>를 사용하여 <replaceable>NETWORK</replaceable>, <replaceable>IPC</replaceable>, <replaceable>UTSNAME</replaceable> 네임스페이스 들만 지정한다면, 패치되지 않은 커널 3.0 이상에서도 성공적으로 동작한다.
리눅스의 <replaceable>/proc</replaceable>와 <replaceable>/sys</replaceable> 파일시스템은 네임스페이스의해 영향받는 몇가지 정보들을 포함하고 있다. 예를 들어 <replaceable>/proc</replaceable>의 프로세스 id로 된 폴더들이나 <replaceable>/sys/class/net</replaceable>의 네트워크 인터페이스 정보 등이다.
의사파일시스템을 마운트하는 프로세스의 네임스페이스가 여기에 어떤 정보를 표시할지 결정하는 것이지, <replaceable>/proc</replaceable> 또는 <replaceable>/sys</replaceable>에 접근하는 프로세스의 네임스페이스가 결정하는 것은 <emphasis>아니다.</emphasis>
<option>-s</option> 를 사용하여 컨테이너의 pid 네임스페이스에만 attach 시키고 마운트 네임스페이스(컨테이너의 <replaceable>/proc</replaceable>는 포함하고, 호스트의 것은 포함하지 않는)는 attach 시키지 않는 경우, <option>/proc</option>의 내용은 컨테이너의 것이 아닌 호스트의 것이 된다.
이러한 문제를 해결하기 위해, <option>-R</option> 옵션이 제공된다. 해당 옵션은 attach되는 프로세스의 네트워크/pid 네임스페이스를 반영하기 위해 <replaceable>/proc</replaceable>와 <replaceable>/sys</replaceable>를 다시 마운트한다.
호스트의 실제 파일시스템에 방해가 되지 않기 위해 마운트 네임스페이스는 공유되지 않는다(<command>lxc-unshare</command>의 동작과 비슷). <replaceable>/proc</replaceable>와 <replaceable>/sys</replaceable> 파일시스템을 제외하고 호스트 마운트 네임스페이스와 동일한 새로운 마운트 네임스페이스가 주어지게 된다.
thus fail unexpectedly for some users (E.g. on systems where an
이전 버전의 <command>lxc-attach</command>는 몇몇 중요한 서브시스템에 쓰기가 가능한 cgroup 내에 없더라도, 사용자가 컨테이너의 네임스페이스에 연결할 수 있는 버그가 있었다.
새로운 버전의 <command>lxc-attach</command>는 현재 사용자가 몇몇 중요한 서브시스템에 쓰기 권한이 있는 cgroup에 속하는지 여부를 검사한다. 그러므로 <command>lxc-attach</command>는 사용자에 따라 실패하는 경우도 있다. (예를 들어, 로그인 시 비특권 사용자가 중요 서브시스템에 쓰기가 가능한 cgroup에 위치하지 않은 경우) 하지만 이러한 동작은 정확한 것이고 더 안전한 것이다.