요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
=========================================
Linux Secure Attention Key (SAK) handling
=========================================
:Date: 18 March 2001
:Author: Andrew Morton
An operating system's Secure Attention Key is a security tool which is
provided as protection against trojan password capturing programs. It
is an undefeatable way of killing all programs which could be
masquerading as login applications. Users need to be taught to enter
this key sequence before they log in to the system.
From the PC keyboard, Linux has two similar but different ways of
providing SAK. One is the ALT-SYSRQ-K sequence. You shouldn't use
this sequence. It is only available if the kernel was compiled with
sysrq support.
The proper way of generating a SAK is to define the key sequence using
``loadkeys``. This will work whether or not sysrq support is compiled
into the kernel.
SAK works correctly when the keyboard is in raw mode. This means that
once defined, SAK will kill a running X server. If the system is in
run level 5, the X server will restart. This is what you want to
happen.
What key sequence should you use? Well, CTRL-ALT-DEL is used to reboot
the machine. CTRL-ALT-BACKSPACE is magical to the X server. We'll
choose CTRL-ALT-PAUSE.
In your rc.sysinit (or rc.local) file, add the command::
echo "control alt keycode 101 = SAK" | /bin/loadkeys
And that's it! Only the superuser may reprogram the SAK key.
.. note::
1. Linux SAK is said to be not a "true SAK" as is required by
systems which implement C2 level security. This author does not
know why.
2. On the PC keyboard, SAK kills all applications which have
/dev/console opened.
Unfortunately this includes a number of things which you don't
actually want killed. This is because these applications are
incorrectly holding /dev/console open. Be sure to complain to your
Linux distributor about this!
You can identify processes which will be killed by SAK with the
command::
# ls -l /proc/[0-9]*/fd/* | grep console
l-wx------ 1 root root 64 Mar 18 00:46 /proc/579/fd/0 -> /dev/console
Then::
# ps aux|grep 579
root 579 0.0 0.1 1088 436 ? S 00:43 0:00 gpm -t ps/2
So ``gpm`` will be killed by SAK. This is a bug in gpm. It should
be closing standard input. You can work around this by finding the
initscript which launches gpm and changing it thusly:
Old::
daemon gpm
New::
daemon gpm < /dev/null
Vixie cron also seems to have this problem, and needs the same treatment.
Also, one prominent Linux distribution has the following three
lines in its rc.sysinit and rc scripts::
exec 3<&0
exec 4>&1
exec 5>&2
These commands cause **all** daemons which are launched by the
initscripts to have file descriptors 3, 4 and 5 attached to
/dev/console. So SAK kills them all. A workaround is to simply
delete these lines, but this may cause system management
applications to malfunction - test everything well.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
SAK 목적과 설정
1-37운영체제의 Secure Attention Key(SAK)는 Trojan password capture 프로그램을 방어하는 보안 수단이다. login 응용 프로그램으로 위장할 수 있는 모든 프로그램을 확실히 종료하며, 사용자는 시스템에 로그인하기 전에 이 키 조합을 누르도록 교육받아야 한다.
PC keyboard에서 Linux는 비슷하지만 다른 두 방법을 제공한다. `ALT-SYSRQ-K`는 sysrq 지원을 넣어 커널을 빌드했을 때만 사용할 수 있으므로 사용하지 말아야 한다. 올바른 방법은 `loadkeys`로 SAK key sequence를 정의하는 것이며, 이 방식은 커널의 sysrq 지원 여부와 관계없이 동작한다.
SAK는 keyboard raw mode에서도 올바르게 동작하므로 정의된 SAK는 실행 중인 X server를 종료한다. run level 5에서는 X server가 다시 시작하며 이것이 의도한 결과다. `CTRL-ALT-DEL`은 재부팅에, `CTRL-ALT-BACKSPACE`는 X server 기능에 쓰이므로 예제는 `CTRL-ALT-PAUSE`를 선택한다.
`rc.sysinit` 또는 `rc.local`에 `echo "control alt keycode 101 = SAK" | /bin/loadkeys`를 추가한다. SAK key를 다시 프로그래밍할 수 있는 주체는 superuser뿐이다.
로그인 전 신뢰할 수 있는 입력 경로를 확보한다.
=========================================
Linux Secure Attention Key (SAK) handling
=========================================
:Date: 18 March 2001
:Author: Andrew Morton
An operating system's Secure Attention Key is a security tool which is
provided as protection against trojan password capturing programs. It
is an undefeatable way of killing all programs which could be
masquerading as login applications. Users need to be taught to enter
this key sequence before they log in to the system.
From the PC keyboard, Linux has two similar but different ways of
providing SAK. One is the ALT-SYSRQ-K sequence. You shouldn't use
this sequence. It is only available if the kernel was compiled with
sysrq support.
The proper way of generating a SAK is to define the key sequence using
``loadkeys``. This will work whether or not sysrq support is compiled
into the kernel.
SAK works correctly when the keyboard is in raw mode. This means that
once defined, SAK will kill a running X server. If the system is in
run level 5, the X server will restart. This is what you want to
happen.
What key sequence should you use? Well, CTRL-ALT-DEL is used to reboot
the machine. CTRL-ALT-BACKSPACE is magical to the X server. We'll
choose CTRL-ALT-PAUSE.
In your rc.sysinit (or rc.local) file, add the command::
echo "control alt keycode 101 = SAK" | /bin/loadkeys
And that's it! Only the superuser may reprogram the SAK key.
한계와 종료 대상 확인
38-65문서는 Linux SAK가 C2 수준 보안 시스템이 요구하는 ‘true SAK’가 아니라고 알려져 있지만 저자는 그 이유를 모른다고 적는다. PC keyboard의 SAK는 `/dev/console`을 열어 둔 모든 응용 프로그램을 종료한다.
문제는 종료할 필요가 없는 프로그램도 `/dev/console`을 잘못 열어 둔 경우 함께 종료된다는 점이다. `ls -l /proc/[0-9]*/fd/* | grep console`로 console을 가리키는 파일 설명자를 찾고, 이어 `ps aux|grep PID`로 해당 프로세스를 식별할 수 있다. 예제에서는 `gpm -t ps/2` 프로세스가 표준 입력으로 `/dev/console`을 열어 두어 SAK로 종료된다.
프로세스의 console 파일 설명자를 PID와 연결한다.
.. note::
1. Linux SAK is said to be not a "true SAK" as is required by
systems which implement C2 level security. This author does not
know why.
2. On the PC keyboard, SAK kills all applications which have
/dev/console opened.
Unfortunately this includes a number of things which you don't
actually want killed. This is because these applications are
incorrectly holding /dev/console open. Be sure to complain to your
Linux distributor about this!
You can identify processes which will be killed by SAK with the
command::
# ls -l /proc/[0-9]*/fd/* | grep console
l-wx------ 1 root root 64 Mar 18 00:46 /proc/579/fd/0 -> /dev/console
Then::
# ps aux|grep 579
root 579 0.0 0.1 1088 436 ? S 00:43 0:00 gpm -t ps/2
So ``gpm`` will be killed by SAK. This is a bug in gpm. It should
gpm과 cron의 console 상속 수정
66-78`gpm`은 표준 입력을 닫아야 한다. gpm을 시작하는 init script의 기존 `daemon gpm`을 `daemon gpm < /dev/null`로 바꾸면 `/dev/console` 대신 `/dev/null`을 표준 입력으로 사용해 의도치 않은 SAK 종료를 피할 수 있다. Vixie cron도 같은 문제가 있어 동일한 처리가 필요하다.
불필요하게 상속된 console 입력을 끊는다.
be closing standard input. You can work around this by finding the
initscript which launches gpm and changing it thusly:
Old::
daemon gpm
New::
daemon gpm < /dev/null
Vixie cron also seems to have this problem, and needs the same treatment.
init script의 추가 파일 설명자 문제
79-91한 주요 Linux 배포판은 `rc.sysinit`과 rc script에 `exec 3<&0`, `exec 4>&1`, `exec 5>&2`를 넣었다. 이 명령은 init script가 실행하는 모든 daemon의 파일 설명자 3, 4, 5를 `/dev/console`에 연결하므로 SAK가 그 daemon을 모두 종료하게 한다.
단순한 우회책은 세 줄을 삭제하는 것이지만 시스템 관리 응용 프로그램이 오작동할 수 있다. 따라서 변경 뒤 관련 관리 기능과 daemon 동작을 모두 충분히 시험해야 한다.
rc script의 복제가 모든 하위 daemon에 console 연결을 전파한다.
Also, one prominent Linux distribution has the following three
lines in its rc.sysinit and rc scripts::
exec 3<&0
exec 4>&1
exec 5>&2
These commands cause **all** daemons which are launched by the
initscripts to have file descriptors 3, 4 and 5 attached to
/dev/console. So SAK kills them all. A workaround is to simply
delete these lines, but this may cause system management
applications to malfunction - test everything well.
요약·해설
sak.rst:1-91Linux SAK의 목적과 loadkeys 설정, /dev/console 보유 프로세스 종료 범위 및 daemon 파일 설명자 문제를 설명합니다.