본문 바로가기

Linux & Unix

Linux-PAM control_flag 이해

# 한글로 표현하면 헷갈리는 부분도 있는 듯 하여, 원문도 같이 붙여 넣음.

required, requisite, sufficient, optional 설명
-----------------------------------------------------------------------------------------------------------------------------------

- required

The module result must be successful for authentication to continue.  
If the test fails at this point, the user is not notified until the results of all module tests that reference that interface are complete. 
failure of such a PAM will ultimately lead to the PAM-API returning failure  
but only after the remaining stacked modules (for this service and type) have been invoked. 
module_type(interface) 이 성공하려면, 반드시 이 라인의 module 결과가 성공이어야함 
하나의 required 라인이라도 실패하면, 응용프로그램에 failure 전달 (바로 전달하지는 않음) 
모듈의 결과가 fail 되도라도, 현재 module_type 의 모든 모듈(이후 라인들)이 확인된 후 응용프로그램에 failure 결과 전달 
[success=ok new_authtok_reqd=ok ignore=ignore default=bad]

- requisite

The module result must be successful for authentication to continue.  
However, if a test fails at this point, the user is notified immediately with a message reflecting the first failed required or requisite module test. 

like required, however, in the case that such a module returns a failure, control is directly returned to the application or to the superior PAM stack.  
The return value is that associated with the first required or requisite module to fail. Note, this flag can be used to protect against the possibility of a user getting the opportunity to enter a password over an unsafe medium.  
It is conceivable that such behavior might inform an attacker of valid accounts on a system.  
This possibility should be weighed against the not insignificant concerns of exposing a sensitive password in a hostile environment. 
module_type(interface) 이 성공하려면, 반드시 이 라인의 module 결과가 성공이어야함 
하나의 required 라인이라도 실패하면, 응용프로그램에 failure 전달 
모듈의 결과가 fail 되는 시점에, 바로 응용프로그램에 failure 결과 전달 
[success=ok new_authtok_reqd=ok ignore=ignore default=die] 

- sufficient

The module result is ignored if it fails.  
However, if the result of a module flagged sufficient is successful and no previous modules flagged required have failed, then no other results are required and the user is authenticated to the service. 
if such a module succeeds and no prior required module has failed the PAM framework returns success to the application or to the superior PAM stack immediately without calling any further modules in the stack.  
A failure of a sufficient module is ignored and processing of the PAM module stack continues unaffected. 
모듈의 결과가 fail 인 경우, 이 라인은 무시하고, 다음 라인의 모듈 검사 진행.
이 모듈의 결과가 성공일 때, 그 이전의 모듈(위 라인)의 결과에 fail 이 없다면, 바로 인증을 완료시킴.
[success=done new_authtok_reqd=done default=ignore] 

- optional 

The module result is ignored. 
A module flagged as optional only becomes necessary for successful authentication when no other modules reference the interface. 
the success or failure of this module is only important if it is the only module in the stack associated with this service+type.
다른 control_flag 모듈이 있는 경우, 이 라인의 결과는 무시됨.
module_interface 에 유일한 모듈인 경우만 결과값이 영향을 미침
[success=ok new_authtok_reqd=ok default=ignore]

- include 

Unlike the other controls, this does not relate to how the module result is handled. 
This flag pulls in all lines in the configuration file which match the given parameter and appends them as an argument to the module. 
include all lines of given type from the configuration file specified as an argument to this control.
지정된 파일에서 module_type 과 일치하는 라인을 모두 포함

-----------------------------------------------------------------------------------------------------------------------------------

각 control_flag 는 [value1=action1 value2=action2 ..] 형식으로 표현할 수 있다.
- value 는 모듈에서 실행된 함수의 return code
- return code 가 명시된 value 와 매치되면 해당 action 수행
- return code 에 매치되는 value 가 명시되어 있지 않은 경우 default 의 action 수행 (default 는

action 의 설명

ignore when used with a stack of modules, the module's return status will not contribute to the return code the application obtains. 

해당 value(return code) 는 무시
bad this action indicates that the return code should be thought of as indicative of the module failing. If this module is the first in the stack to fail, its status value will be used for that of the whole stack. 

모듈을 fail 로 간주. 스택의 첫 모듈인 경우, 상태값을 전체 스택에서 사용. required 의 default 값
die equivalent to bad with the side effect of terminating the module stack and PAM immediately returning to the application. 

모듈을 fail 로 간주. 즉시 module stack 종료시키고 애플리케이션에 값 전달. requisite 의 default 값

ok this tells PAM that the administrator thinks this return code should contribute directly to the return code of the full stack of modules. In other words, if the former state of the stack would lead to a return of PAM_SUCCESS, the module's return code will override this value. Note, if the former state of the stack holds some value that is indicative of a modules failure, this 'ok' value will not be used to override that value. 

full stack 의 return code 에 바로 값을 바로 값을 전달(?). 기존 값이 PAM_SUCCESS 이면 덮어쓰고, failure 이면 덮어쓰지 않는다. required 의 success 값
  done equivalent to ok with the side effect of terminating the module stack and PAM immediately returning to the application.

ok 와 같으면서, module stack 종료시키고 애플리케이션에 바로 값 전달. requisite 의 success 값

 

참조 문서

Linux-PAM_SAG (/usr/share/doc/pam-1.1.8/Linux-PAM_SAG.txt)
Linux-PAM_SAG 번역 : https://blog.naver.com/hymne/220971024337
RHEL 메뉴얼