-
Notifications
You must be signed in to change notification settings - Fork 0
/
sag-configuration-file.html
225 lines (225 loc) · 18.3 KB
/
sag-configuration-file.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>4.1. 설정 파일 문법</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="Linux-PAM_SAG.html" title="Linux-PAM 시스템 관리자 안내서"><link rel="up" href="sag-configuration.html" title="4장. Linux-PAM 설정 파일"><link rel="prev" href="sag-configuration.html" title="4장. Linux-PAM 설정 파일"><link rel="next" href="sag-configuration-directory.html" title="4.2. 디렉터리 방식 설정"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.1. 설정 파일 문법</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sag-configuration.html">이전</a> </td><th width="60%" align="center">4장. Linux-PAM 설정 파일</th><td width="20%" align="right"> <a accesskey="n" href="sag-configuration-directory.html">다음</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sag-configuration-file"></a>4.1. 설정 파일 문법</h2></div></div></div><p>
<code class="filename">/etc/pam.conf</code> 설정 파일의 문법은
이렇다. 파일은 규칙들의 목록으로 이뤄져 있다. 각 규칙은 보통
한 행으로 돼 있지만 이스케이프 개행(`\<LF>')으로 연장할
수도 있다. 주석은 `#' 기호로 시작해서 행 끝까지 이어진다.
</p><p>
각 행은 공백으로 구분된 토큰들의 집합 형식으로 돼 있으며, 그 중
처음 세 개는 대소문자를 구별하지 않는다.
</p><p>
<span class="emphasis"><em> service type control module-path module-arguments</em></span>
</p><p>
<code class="filename">/etc/pam.d/</code> 디렉터리에 담긴 파일의
문법은 <span class="emphasis"><em>service</em></span> 필드가 빠져
있다는 점을 빼면 동일하다. 이 경우 <code class="filename">/etc/pam.d/</code>
디렉터리 내의 파일 이름이 <span class="emphasis"><em>service</em></span>가
된다. 이 파일 이름은 소문자여야 한다.
</p><p>
<span class="emphasis"><em>PAM</em></span>의 중요한 특징은 여러 규칙들을
<span class="emphasis"><em>스택처럼 쌓아서</em></span> 해당 인증 작업에
여러 PAM 서비스들을 조합할 수 있다는 점이다.
</p><p>
<span class="emphasis"><em>service</em></span>는 보통 익숙한 해당 응용의
이름이다. <span class="emphasis"><em>login</em></span>과
<span class="emphasis"><em>su</em></span>가 좋은 예다.
<span class="emphasis"><em>service</em></span> 이름
<span class="emphasis"><em>other</em></span>는
<span class="emphasis"><em>기본</em></span> 규칙들을 위해 예약돼 있다.
어떤 서비스 응용이 있을 때 그 서비스가 명시된 행들만 (그런 행이
없는 경우엔 <span class="emphasis"><em>other</em></span> 항목들이)
이용한다.
</p><p>
<span class="emphasis"><em>type</em></span>은 그 규칙이 해당하는
관리 그룹이다. 이를 이용해 이어지는 모듈이 어느 관리 그룹에
연계돼야 하는지 지정한다. 유효한 항목은 다음과 같다.
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">account</span></dt><dd><p>
이 모듈 타입은 인증을 기반으로 하지 않는 계정 관리를
수행한다. 보통 현재 시간이나 현재 가용 시스템 자원
(최대 사용자 수), 신청 사용자의 위치에 따라 ('root'
로그인을 콘솔에서만) 서비스 접근을 제한/허용하는 데 쓴다.
</p></dd><dt><span class="term">auth</span></dt><dd><p>
이 모듈 타입은 사용자 인증의 두 가지 측면을 제공한다.
첫째, 응용에서 사용자에게 암호나 기타 식별 수단을 입력받도록
해서 사용자가 스스로 주장하는 그 사람인지 확인한다. 둘째,
크리덴셜 승인 속성을 통해 그룹 소속이나 기타 권한을
승인할 수 있다.
</p></dd><dt><span class="term">password</span></dt><dd><p>
이 모듈 타입은 사용자와 연계된 인증 토큰을 갱신하는 데
필요하다. 보통 '시험/응답' 기반 인증(auth) 타입마다 모듈이
하나씩 있다.
</p></dd><dt><span class="term">session</span></dt><dd><p>
이 모듈 타입은 사용자가 서비스를 받기 전이나 받은 후에 해야
할 일과 연관돼 있다. 사용자와의 어떤 데이터 교환 개시/종료
관련 정보를 로그로 기록하기, 디렉터리 마운트 등이 포함된다.
</p></dd></dl></div><p>
위 목록에 있는 <span class="emphasis"><em>type</em></span> 값 앞에
<span class="emphasis"><em>-</em></span> 문자가 붙어 있으면 그 모듈이
시스템 내에 없어서 적재할 수 없는 경우에도 PAM 라이브러리가 시스템
로그에 기록을 남기지 않는다. 시스템에 늘 설치돼 있는 건 아니면서
로그인 세션을 올바로 인증하고 인가하는 데 꼭 필요한 건 아닌
모듈에 특히 유용할 수 있다.
</p><p>
세 번째 필드인 <span class="emphasis"><em>control</em></span>은
모듈에서 인증 작업을 성공하지 못했을 때 PAM API의 동작을 나타낸다.
이 control 필드에는 두 가지 문법이 있는데, 단순 문법은 간단한
키워드 하나를 쓰는 것이고, 복잡한 문법은 선정한
<span class="emphasis"><em>value=action</em></span> 짝들을
꺾쇠괄호로 감싸는 방식이다.
</p><p>
(전통적인) 단순 문법에서 유효한 <span class="emphasis"><em>control</em></span>
값은 다음과 같다.
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">required</span></dt><dd><p>
이 PAM 모듈의 실패가 궁극적으로 PAM API의 실패 반환을
일으키되, <span class="emphasis"><em>쌓여 있는</em></span>
(이 <span class="emphasis"><em>service</em></span> 및
<span class="emphasis"><em>type</em></span>에 대한) 나머지
모듈들을 호출한 후에 그렇게 된다.
</p></dd><dt><span class="term">requisite</span></dt><dd><p>
<span class="emphasis"><em>required</em></span>와 비슷하되,
모듈이 실패를 반환하는 경우 바로 응용이나 상위 PAM 스택으로
제어가 반환된다. 실패한 첫 번째 required 내지 requisite 모듈의
반환 값이 반환된다. 참고로 사용자가 안전하지 않은 매체로
패스워드를 입력하게 될 가능성을 막기 위해 이 플래그를 사용할
수 있다. 그런데 이런 동작이 공격자에게 시스템의 유효 계정에
대해 알려 줄 수 있다는 것도 가능한 일이다. 적대적 환경에서
민감한 패스워드 노출에 대한 염려가 무시할 만한 수준이 아닌
경우에 두 가능성의 경중을 따져 볼 필요가 있다.
</p></dd><dt><span class="term">sufficient</span></dt><dd><p>
이 모듈이 성공하고 앞서 실패한 <span class="emphasis"><em>required</em></span>
모듈이 없으면 PAM 프레임워크가 스택의 이후 모듈을 호출하지
않고 즉시 응용이나 상위 PAM 스택으로 성공을 반환한다.
<span class="emphasis"><em>sufficient</em></span> 모듈의
실패는 무시되며 PAM 모듈 스택 처리가 영향 없이 계속 진행된다.
</p></dd><dt><span class="term">optional</span></dt><dd><p>
스택에서 이 <span class="emphasis"><em>service</em></span>+<span class="emphasis"><em>type</em></span>에
연계된 유일한 모듈인 경우에만 이 모듈의 성공 내지 실패가
영향을 준다.
</p></dd><dt><span class="term">include</span></dt><dd><p>
인자로 지정한 설정 파일에서 해당 타입의 행을 모두 가져다
포함시킨다.
</p></dd><dt><span class="term">substack</span></dt><dd><p>
인자로 지정한 설정 파일에서 해당 타입의 행을 모두 가져다
포함시킨다. <span class="emphasis"><em>include</em></span>와의
차이는 하위 스택에서의 <span class="emphasis"><em>done</em></span>
및 <span class="emphasis"><em>die</em></span> 동작이 모듈 스택
전체가 아니라 그 하위 스택의 나머지 부분만 건너뛰게 한다는 점이다.
하위 스택에서의 점프 역시 그 밖으로 평가 위치를 점프하지 못하며,
부모 스택에서 점프가 이뤄질 때는 하위 스택 전체를 모듈 한 개로
센다. <span class="emphasis"><em>reset</em></span> 동작은 모듈
스택의 상태를 하위 스택 평가를 시작할 때의 상태로 재설정한다.
</p></dd></dl></div><p>
복잡한 문법에서 유효한 <span class="emphasis"><em>control</em></span> 값은 다음 형식이다.
</p><pre class="programlisting">
[value1=action1 value2=action2 ...]
</pre><p>
여기서 <span class="emphasis"><em>valueN</em></span>은 그 행에 지정된
모듈의 호출 함수가 반환한 코드에 해당한다. 다음 중 하나를 선택한다:
<span class="emphasis"><em>success</em></span>, <span class="emphasis"><em>open_err</em></span>,
<span class="emphasis"><em>symbol_err</em></span>, <span class="emphasis"><em>service_err</em></span>,
<span class="emphasis"><em>system_err</em></span>, <span class="emphasis"><em>buf_err</em></span>,
<span class="emphasis"><em>perm_denied</em></span>, <span class="emphasis"><em>auth_err</em></span>,
<span class="emphasis"><em>cred_insufficient</em></span>,
<span class="emphasis"><em>authinfo_unavail</em></span>,
<span class="emphasis"><em>user_unknown</em></span>, <span class="emphasis"><em>maxtries</em></span>,
<span class="emphasis"><em>new_authtok_reqd</em></span>,
<span class="emphasis"><em>acct_expired</em></span>, <span class="emphasis"><em>session_err</em></span>,
<span class="emphasis"><em>cred_unavail</em></span>, <span class="emphasis"><em>cred_expired</em></span>,
<span class="emphasis"><em>cred_err</em></span>, <span class="emphasis"><em>no_module_data</em></span>,
<span class="emphasis"><em>conv_err</em></span>, <span class="emphasis"><em>authtok_err</em></span>,
<span class="emphasis"><em>authtok_recover_err</em></span>,
<span class="emphasis"><em>authtok_lock_busy</em></span>,
<span class="emphasis"><em>authtok_disable_aging</em></span>,
<span class="emphasis"><em>try_again</em></span>, <span class="emphasis"><em>ignore</em></span>,
<span class="emphasis"><em>abort</em></span>, <span class="emphasis"><em>authtok_expired</em></span>,
<span class="emphasis"><em>module_unknown</em></span>, <span class="emphasis"><em>bad_item</em></span>,
<span class="emphasis"><em>conv_again</em></span>, <span class="emphasis"><em>incomplete</em></span>,
<span class="emphasis"><em>default</em></span>.
</p><p>
이 중 마지막의 <span class="emphasis"><em>default</em></span>는 명시적으로
언급되지 않은 '모든 <span class="emphasis"><em>valueN</em></span>'을
뜻한다. 참고로 전체 PAM 오류 목록을 <code class="filename">/usr/include/security/_pam_types.h</code>에서
볼 수 있다. <span class="emphasis"><em>actionN</em></span>은 다음 중 한 형태일 수 있다.
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">ignore</span></dt><dd><p>
모듈 스택에서 사용 시 모듈의 반환 상태가 응용이 얻을
반환 코드에 영향을 주지 않게 된다.
</p></dd><dt><span class="term">bad</span></dt><dd><p>
이 동작은 반환 코드를 모듈 실패를 나타내는 것으로 봐야
한다는 뜻이다. 이 모듈이 스택에서 실패한 첫 번째 모듈이면
그 상태 값을 전체 스택의 값으로 쓰게 된다.
모든 반환 코드의 기본 동작이다.
</p></dd><dt><span class="term">die</span></dt><dd><p>
<span class="emphasis"><em>bad</em></span>와 같되,
모듈 스택 처리를 종료하고 즉시 PAM에서 응용으로 반환한다.
</p></dd><dt><span class="term">ok</span></dt><dd><p>
관리자가 보기에 이 반환 코드가 그대로 전체 모듈 스택의 반환
코드가 돼야 한다는 뜻이다. 달리 말해 스택의 이전 상태가
<span class="emphasis"><em>PAM_SUCCESS</em></span> 반환으로
이어질 상태였던 경우에 모듈 반환 코드가 그 값을
오버라이드하게 된다. 참고로 스택의 이전 상태가 모듈 실패를
나타내는 어떤 값이었던 경우에는 이 'ok' 값으로 그 값을
오버라이드하지 않는다.
</p></dd><dt><span class="term">done</span></dt><dd><p>
<span class="emphasis"><em>ok</em></span>와 같되,
앞서 무시되지 않은 모듈 실패가 없었다면
모듈 스택 처리를 종료하고 즉시 PAM에서 응용으로 반환한다.
</p></dd><dt><span class="term">N (부호 없는 정수)</span></dt><dd><p>
스택의 다음 N개 모듈을 건너뛴다.
N을 0으로 하는 건 허용되지 않으며,
그 경우 <span class="emphasis"><em>ignore</em></span>로 취급하게 된다.
PAM 함수 호출에 따라 부대 효과가 달라진다.
<span class="emphasis"><em>pam_authenticate</em></span>,
<span class="emphasis"><em>pam_acct_mgmt</em></span>,
<span class="emphasis"><em>pam_chauthtok</em></span>,
<span class="emphasis"><em>pam_open_session</em></span>에선
<span class="emphasis"><em>ignore</em></span>다.
<span class="emphasis"><em>pam_setcred</em></span>와
<span class="emphasis"><em>pam_close_session</em></span>에선
모듈의 반환 값에 따라 <span class="emphasis"><em>ignore</em></span>
<span class="emphasis"><em>ok</em></span>,
<span class="emphasis"><em>bad</em></span> 중 하나다.
</p></dd><dt><span class="term">reset</span></dt><dd><p>
메모리에서 모듈 스택의 상태를 모두 비우고 스택의 다음
모듈부터 새로 시작한다.
</p></dd></dl></div><p>
반환 코드의 동작을 <span class="emphasis"><em>valueN</em></span> 토큰으로
따로 지정하지 않고 <span class="emphasis"><em>default</em></span> 값도
지정하지 않은 경우에 그 반환 코드의 동작은 <span class="emphasis"><em>bad</em></span>가 된다.
</p></p>
네 가지 키워드(required, requisite, sufficient, optional)를
[...] 문법으로 동등하게 표현할 수 있다. 다음과 같다.
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">required</span></dt><dd><p>
[success=ok new_authtok_reqd=ok ignore=ignore default=bad]
</p></dd><dt><span class="term">requisite</span></dt><dd><p>
[success=ok new_authtok_reqd=ok ignore=ignore default=die]
</p></dd><dt><span class="term">sufficient</span></dt><dd><p>
[success=done new_authtok_reqd=done default=ignore]
</p></dd><dt><span class="term">optional</span></dt><dd><p>
[success=ok new_authtok_reqd=ok default=ignore]
</p></dd></dl></div><p>
<span class="emphasis"><em>module-path</em></span>는 응용에서
이용할 PAM의 전체 파일 이름('/'로 시작)이거나 기본 모듈 위치
기준의 상대 경로명이다. 기본 모듈 위치는 아키텍처에 따라
<code class="filename">/lib/security/</code> 또는
<code class="filename">/lib64/security/</code>다.
</p><p>
<span class="emphasis"><em>module-arguments</em></span>는 해당 PAM의
구체적 동작 방식을 바꾸는 데 쓸 수 있는 공백 구분 토큰 목록이다.
개별 모듈별로 그런 인자들이 문서화돼 있다. 참고로 인자에 공백을
포함시키고 싶다면 그 인자를 꺾쇠괄호로 감싸야 한다.
</p><pre class="programlisting">
squid auth required pam_mysql.so user=passwd_query passwd=mada \
db=eminence [query=select user_name from internet_service \
where user_name='%u' and password=PASSWORD('%p') and \
service='web_proxy']
</pre><p>
이 방식 사용 시에 문자열 안에 `[' 문자를 포함시킬 수 있다.
문자열 안에 `]' 문자를 포함시키면서 인자의 일부로 파싱되게
하고 싶으면 `\]'를 써야 한다. 즉 다음처럼 파싱된다.
</p><pre class="programlisting">
[..[..\]..] --> ..[..]..
</pre><p>
설정 파일(들 중 하나)의 어느 행이라도 올바른 형식이 아니면
일반적으로 (과잉으로 조심하는 쪽을 택해서) 인증 과정이 실패하게
된다. <span class="citerefentry"><span class="refentrytitle">syslog</span>(3)</span>
호출을 이용해 해당 오류를 시스템 로그 파일로 기록한다.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sag-configuration.html">이전</a> </td><td width="20%" align="center"><a accesskey="u" href="sag-configuration.html">위</a></td><td width="40%" align="right"> <a accesskey="n" href="sag-configuration-directory.html">다음</a></td></tr><tr><td width="40%" align="left" valign="top">4장. Linux-PAM 설정 파일 </td><td width="20%" align="center"><a accesskey="h" href="Linux-PAM_SAG.html">대문</a></td><td width="40%" align="right" valign="top"> 4.2. 디렉터리 방식 설정</td></tr></table></div></body></html>