코드를 컴파일한 후에는 컴파일된 버전의 코드를 포함하는 공유 라이브러리를 생성하십시오. apisamples 디렉터리에는 이 프로세스를 보여 주는 샘플 함수와 메이크파일이 포함되어 있습니다. 공유 라이브러리용으로 컴파일하려면 일반적으로 위치 독립적인 코드를 생성하기 위한 추가 컴파일러 매개 변수가 필요합니다. 특정 시스템에서 공유 라이브러리를 생성하는 방법은 컴파일러 또는 링커 설명서를 참조하십시오.
코드를 작성하고 공유 라이브러리를 생성한 후에는 코드를 연결할 프로그램과 관련된 "주문형" 공유 라이브러리에 해당 공유 라이브러리를 추가하십시오.
다음 데몬 또는 프로그램 중 하나에 대한 공유 라이브러리를 작성한 경우 관련 파일에 공유 라이브러리를 추가하십시오. apisamples 디렉터리에 있는 예제를 사용하여 이러한 .ext 파일을 생성해야 할 수도 있습니다.
각 파일에는 드라이버 이름과 공유 라이브러리 경로를 나타내는 두 개의 열이 있습니다. 규칙에 따라 드라이버 이름은 대상 유형과 동일한 이름을 갖는 문자열이지만 유효한 C 언어 기호일 수도 있습니다.
예를 들어 Pager를 구현하는 코드를 작성한 경우 대상 이름은 pager여야 하며 전체 파일 항목은 다음과 같이 됩니다.
pager /usr/local/lib/libseospager.so
이 파일 항목은 seosd 데몬이 시작 시 다음 공유 라이브러리를 로드하고 해당 함수를 호출함을 의미합니다.
/usr/local/lib/libseospager.so
일부 시스템은 _init라는 미리 정의된 함수를 지원하지만 대신 driver_RegisterDestination 함수를 사용하는 것이 좋습니다. 이 함수가 공유 라이브러리에서 실제로 호출되는 첫 번째 함수입니다. driver_RegisterDestination 함수는 새 대상 유형을 등록합니다.
데몬 종료 시에는 미리 정의된 _fini 함수 대신 driver_UnregisterDestination 함수를 사용하는 것이 좋습니다.
참고: 미리 정의된 시스템 함수 대신 CA ControlMinder 함수를 사용하면 코드의 이식성을 향상시킬 수 있습니다.
seosd 데몬은 sepass와 동일한 파일 구성 형식을 사용합니다.
코드를 컴파일한 후에는 컴파일된 버전의 코드를 포함하는 동적 연결 라이브러리를 생성하십시오. SDK 디렉터리에는 이 프로세스를 보여 주는 샘플 함수와 메이크파일이 포함되어 있습니다. 동적 연결 라이브러리용으로 컴파일하려면 일반적으로 추가 컴파일러 매개 변수가 필요합니다. 특정 시스템에서 동적 연결 라이브러리를 생성하는 방법은 컴파일러 또는 링커 설명서를 참조하십시오.
코드를 작성하고 동적 연결 라이브러리를 생성한 후에는 이를 다음과 같이 CA ControlMinder 레지스트리에 설치해야 합니다.
HKEY_LOCAL_MACHINE\Software\ComputerAssociates\AccessControl\Exits\Engine
값: 종료 동적 연결 라이브러리의 전체 경로
값: 유효한 모든 C 언어 기호
예: 접두사가 "TEMP"인 경우 동적 연결 라이브러리의 등록 함수 이름은 TEMP_RegisterExit입니다.
CA ControlMinder가 운영 체제 호출을 차단하므로 권한 부여 작업 중에 일부 시스템 작업이 허용되지 않을 수 있습니다. 다음 함수는 seosd의 종료 API 함수에서 호출할 수 없습니다.
|
사용 환경 |
사용하지 않는 함수 |
|---|---|
|
CA ControlMinder를 실행 중인 NIS 또는 DNS 서버 및 Solaris 2.5.x 이상 |
getgrent getgrgid etgrnam gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent |
|
CA ControlMinder를 실행 중인 스테이션 |
getrpcbyname getrpcbynumber getrpcent |
CA ControlMinder는 정수로 정의되고 2 바이트로 구성된 오류 코드를 사용합니다. MSB에는 계층 코드가 포함되고 LSB에는 해당 계층과 관련된 오류 코드가 포함됩니다. 따라서 256가지의 오류 코드가 있는 최대 256가지의 계층을 사용할 수 있습니다. 오류 코드 관리를 단순화하기 위해 CA ControlMinder는 _SEOS_RC 매크로를 사용합니다. 종료 API도 AUTHXAPI_MODULE 매크로를 사용하여 계층 코드를 정의합니다. 코드에 직접 이러한 매크로를 사용하지 마십시오. 그렇지 않으면 컴파일 문제가 발생할 수 있습니다.
CA ControlMinder는 반환 코드에 다음과 같은 규칙을 사용합니다. 반환 값 0은 성공을 의미하고, 그 밖의 다른 값은 오류를 의미합니다.
CA ControlMinder 패키지에는 종료 API의 사용을 보여 주는 다음과 같은 두 개의 예제 프로그램이 포함되어 있습니다.
apisamples 디렉터리에는 include 하위 디렉터리에 있는 API 헤더 파일과 lib 하위 디렉터리에 있는 라이브러리 함수가 포함되어 있습니다.
다음 프로그램은 seosd 데몬이 수행하는 작업에 따라 특정 사용자가 정의한 종료 함수를 호출합니다. 이 함수는 각 작업이 실행된 횟수에 대한 통계를 유지합니다. 사용자 root의 로그인이 감지될 경우 이 함수는 단순히 수집된 정보를 출력합니다. 이 함수의 주요 사항에 대한 자세한 설명은 소스 코드 다음에 나옵니다.
/*=========================================================
Project : eTrust
Module : eTrust
Version : 8.0
File : seosdexits.c
Purpose : eTrust daemon exits sample.
===========================================================
Copyright :
Copyright 2004 Computer Associates International, Inc.
===========================================================*/
#define __SEOSEXIT_C
/* System headers :
* sys/types.h : we cust using uid_t
* stdio.h : printf
* string.h & memory.h : memcpy
*/
#include sys/types.h
#include stdio.h
#include string.h
#include memory.h
/* authx API header file */
#include authxapi.h
/* This a sample program for making an exit module
* for Access Control.
* The module only 'printf' the information and
* gathers statistics on the # of events.
* When the 'root' user logs in the statistics
* are printed.
*/
typedef struct
{ int nPreRes;
int nPostRes;
int nPreLogin;
int nPostLogin;
int nPreInet;
int nPostInet;
} EXIT_CALLS_COUNTERS;
static EXIT_CALLS_COUNTERS counters;
static void print_my_statistics(void)
{
printf("General Resource ... Pre %6d Post %6d\n"
"Login .............. Pre %6d Post %6d\n"
"Internet TCP ....... Pre %6d Post %6d\n",
counters.nPreRes, counters.nPostRes,
counters.nPreLogin, counters.nPostLogin,
counters.nPreInet, counters.nPostInet);
}
static int ExitFunc_PreResource(void *data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITGENR *ptr;
ptr = (SEOS_EXITGENR *)data;
counters.nPreRes++;
printf("Pre General Resource Class %s\n", ptr‑>szClass);
return 0;
}
static int ExitFunc_PostResource(void *data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITGENR *ptr;
ptr = (SEOS_EXITGENR *)data;
counters.nPostRes++;
printf("Post General Resource Class %s\n", ptr‑>szClass);
return 0;
}
static int ExitFunc_PreLogin(void *data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITLOGIN *p_sexl;
char buff[20];
char const *p;
p_sexl = (SEOS_EXITLOGIN *)data;
counters.nPreLogin++;
if (p_sexl‑>szUname == NULL)
{p = buff; sprintf(buff, "UID=%u", p_sexl‑>luid);}
else
p = p_sexl‑>szUname;
printf("Pre Login For %s\n", p);
/* For ROOT print some statistics */
if (p_sexl‑>luid == (uid_t)0)
print_my_statistics();
return 0;
}
static int ExitFunc_PostLogin(void *data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITLOGIN *p_sexl;
char buff[20];
char const *p;
p_sexl = (SEOS_EXITLOGIN *)data;
counters.nPostLogin++;
if (p_sexl‑>szUname == NULL)
{p = buff; sprintf(buff, "UID=%u", p_sexl‑>luid);}
else
p = p_sexl‑>szUname;
printf("Post Login For %s\n", p);
/* For ROOT print some statistics */
if (p_sexl‑>luid == (uid_t)0)
print_my_statistics();
return 0;
}
static int ExitFunc_PreInet(void *data, SEOS_EXITRES *p_sexr)
{
/* Don't do too much work on TCP */
counters.nPreInet++;
return 0;
}
static int ExitFunc_PostInet(void *data, SEOS_EXITRES *p_sexr)
{
/* Don't do too much work on TCP */
counters.nPostInet++;
return 0;
}
int sample_RegisterExit(void)
{
int rc;
memset(&counters, 0, sizeof(counters));
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_PREGNRES,
ExitFunc_PreResource);
if (rc) return rc;
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_POSTGNRES,
ExitFunc_PostResource);
if (rc) return rc;
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_PRELOGIN,
ExitFunc_PreLogin);
if (rc) return rc;
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_POSTLOGIN,
ExitFunc_PostLogin);
if (rc) return rc;
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_PREINET,
ExitFunc_PreInet);
if (rc) return rc;
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_POSTINET,
ExitFunc_PostInet);
return rc;
}
void sample_UnregisterExit(void)
{
/* We don't have anything to do in this example */
}
authxapi.h 헤더 파일에는 API를 사용하는 데 필요한 프로토타입 및 정의가 포함되어 있습니다. 이 코드는 새로운 EXIT_CALLS_COUNTER 유형을 선언합니다. 이 구조는 API가 등록하는 각 이벤트에 대한 카운터로 구성됩니다. 이 새 로컬 유형의 정적 변수가 선언됩니다. 나열된 일반 리소스 검사 및 TCP/IP 요청 함수는 예제 카운터입니다. 로그인 함수에도 동일한 카운터가 있으며 로그인된 사용자의 사용자 ID를 0과 비교합니다. 로그인 함수는 UNIX root 사용자의 ID가 0임을 이용하여 시스템 데이터베이스에서 실제 사용자 정보를 가져오지 못하도록 합니다.
참고: 이 예제는 화면에 출력합니다. CA ControlMinder 데몬은 화면 출력을 사용하지 않아야 합니다. 그렇지 않으면 성능이 크게 저하될 수 있습니다.
SDK 디렉터리에는 include 하위 디렉터리에 있는 API 헤더 파일과 lib 하위 디렉터리에 있는 라이브러리 함수가 포함되어 있습니다.
다음 프로그램은 seosd 서비스가 수행하는 작업에 따라 특정 사용자가 정의한 종료 함수를 호출합니다. 이 함수는 각 작업이 실행된 횟수에 대한 통계를 유지합니다. 사용자 Administrator의 로그인이 감지될 경우 이 함수는 단순히 수집된 정보를 출력합니다. 이 함수의 주요 사항에 대한 자세한 설명은 소스 코드 다음에 나옵니다.
/*========================================================================
Project: eTrust Access Control 8.0 for Windows NT/2000
Module: eTrust Engine Exits sample.
File: main.c
Purpose: Sample for eTrust Engine Exits DLL to demonstrate how user
can use eTrust Engine authorization in Pre and Post checks.
Usage: Build ExitsExample.dll and use eTrust Access Control 8.0 for
Windows NT/2000 documentation to config your registry and file
system.
========================================================================
Copyright 2004 Computer Associates International, Inc.
======================================================================== */
#include <stdio.h>
#include <authxapi.h>
typedef struct
{
int nPreRes;
int nPostRes;
int nPreLogin;
int nPostLogin;
} EXIT_CALLS_COUNTERS;
EXIT_CALLS_COUNTERS counters = { 0 };
static void print_my_statistics(void)
{
//
// print statistic check counters
//
printf("General Resource ... Pre %6d Post %6d \n"
"Login................Pre %6d Post %6d \n",
counters.nPreRes, counters.nPostRes,
counters.nPreLogin, counters.nPostLogin);
}
static int ExitFunc_PreResource(void* data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITGENR *ptr;
ptr = (SEOS_EXITGENR *) data;
counters.nPreRes++;
//
// Pre check: Print eTrust Class name of the resource
//
printf("Pre General Resource %s of Class %s\n", ptr->szRes, ptr->szClass);
return 0;
}
static int ExitFunc_PostResource(void* data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITGENR *ptr;
ptr = (SEOS_EXITGENR *) data;
counters.nPostRes++;
//
// Post check: Print eTrust Class name of the resource
//
printf("Post General Resource %s of Class %s\n", ptr->szRes, ptr->szClass);
return 0;
}
static int ExitFunc_PreLogin(void* data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITLOGIN *p_sexl;
char buff[20];
char const *p;
p_sexl = (SEOS_EXITLOGIN*) data;
counters.nPreLogin++;
if(p_sexl->szUname == NULL)
{
p = buff;
sprintf(buff, "UID = %u", p_sexl->luid);
}
else
p = p_sexl->szUname;
//
// For Pre Login check: print the Login User name
//
printf("Pre Login For %s from terminal %s\n", p, p_sexl->szTerm);
if(strstr(p_sexl->szUname, "Administrator") != NULL)
{
print_my_statistics();
}
return 0;
}
static int ExitFunc_PostLogin(void* data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITLOGIN *p_sexl;
char buff[20];
char const *p;
p_sexl = (SEOS_EXITLOGIN*) data;
counters.nPostLogin++;
if(p_sexl->szUname == NULL)
{
p = buff;
sprintf(buff, "UID = %u", p_sexl->luid);
}
else
p = p_sexl->szUname;
//
// For Post Login check: print the Login User name
//
printf("Post Login For %s from terminal %s\n", p, p_sexl->szTerm);
if(strstr(p_sexl->szUname, "Administrator") != NULL)
{
print_my_statistics();
}
return 0;
}
typedef int(*PFNEXIT)(void);
// Function name: SM_RegisterExit
// Description: Export exits function
// Return type: int 0
// Argument: IN/OUT PFNEXIT pfnExit[] - array of user defined functions
// Argument: IN/OUT DWORD *pdwType - array of Engine events
_declspec(dllexport) int __stdcall SM_RegisterExit(PFNEXIT pfnExit[], PDWORD pdwType)
{
pfnExit[0] = (PFNEXIT)ExitFunc_PreLogin;
pfnExit[1] = (PFNEXIT)ExitFunc_PostLogin;
pfnExit[2] = (PFNEXIT)ExitFunc_PreResource;
pfnExit[3] = (PFNEXIT)ExitFunc_PostResource;
pdwType[0] = AUTHXAPI_EV_PRELOGIN;
pdwType[1] = AUTHXAPI_EV_POSTLOGIN;
pdwType[2] = AUTHXAPI_EV_PREGNRES;
pdwType[3] = AUTHXAPI_EV_POSTGNRES;
return 0;
}
또한 다음이 포함된 프로젝트에는 또 다른 .def 파일이 필요합니다.
authxapi.h 헤더 파일에는 API를 사용하는 데 필요한 프로토타입 및 정의가 포함되어 있습니다. 이 코드는 새로운 EXIT_CALLS_COUNTER 유형을 선언합니다. 이 구조는 API가 등록하는 각 이벤트에 대한 카운터로 구성됩니다. 이 새 로컬 유형의 정적 변수가 선언됩니다. 나열된 일반 리소스 검사 함수는 예제 카운터입니다. 로그인 함수에도 동일한 카운터가 있으며 로그인된 사용자의 사용자 이름을 Administrator와 비교합니다.
참고: 이 예제는 화면에 출력합니다. CA ControlMinder 서비스는 콘솔 응용 프로그램이 아니므로 화면 출력을 사용하지 않아야 합니다.
다음 코드에서는 암호 확인을 위한 단순 사용자 종료 함수를 보여 줍니다. 이 코드는 잠재적인 암호를 문자열 암호화 비교하고 일치하는 경우 암호를 선택하기 위한 사용 권한을 거부합니다.
/*=========================================================
Project : eTrust
Module : eTrust
Version : 8.0
File : exit.c
Purpose : Example of exit function for passwords utilities
===========================================================
Copyright :
Copyright 2004 Computer Associates International, Inc.
===========================================================*/
/* Example for using password library to extend password rules*/
/* This function verifies the password before Access Control */
/* does. To override Access Control checks, use result */
/* SEOS_EXITR_PASS. */
/* Look at Makefile.exits for compilation options. */
#include API/authxapi.h
/* This function does not allow user to use the word "password"*/
/* as the new password. */
int ExitFunc_PreVerify(void *sexp, SEOS_EXITRES *sexr)
{
if (strcmp(((SEOS_EXITPASS *) sexp)‑>szPass,"password") == 0)
{
printf("new password is refused by exit function\n");
sexr‑>result = SEOS_EXITR_DENY;
/* Do not allow that password */
}
else
sexr‑>result = SEOS_EXITR_CHECK;
/* Continue with Access Control checks */
return 0;
}
/* must register the above exit function */
int sample_RegisterExit(void)
{
int rc;
rc = authxapi_RegisterExitFunction(AUTHXAPI_EV_PREVERPWD,
ExitFunc_PreVerify);
if (rc) return rc;
}
void sample_UnregisterExit(void)
{
/* Nothing to do really in this case */
}
다음 코드에서는 암호 확인을 위한 단순 사용자 종료 함수를 보여 줍니다. 이 코드는 잠재적인 암호를 문자열 암호화 비교하고 일치하는 경우 암호를 선택하기 위한 사용 권한을 거부합니다.
/* ========================================================================
Project: eTrust Access Control 8.0 for Windows NT/2000
Module: eTrust Password Exits sample.
File: main.c
Purpose: Sample for eTrust Password Exits DLL to demonstrate how user
an
use eTrust Password authorization in Pre and Post checks.
Usage: Build PasswordExitsExample.dll and use eTrust Access Control
.0 for
Windows NT/2000 documentation to config your registry and file
system.
=======================================================================
Copyright 2004 Computer Associates International, Inc.
======================================================================= */
#include <stdio.h>
#include <authxapi.h>
static int ExitFunc_PreVerifyPassword(void* data, SEOS_EXITRES *p_sexr)
{
SEOS_EXITPASS *ptr;
ptr = (SEOS_EXITPASS *) data;
if (strcmp(ptr->szPass, "password") == 0)
{
p_sexr->result = SEOS_EXITR_DENY;
/* Do not allow that password */
}
else
{
/* Continue with Access Control checks */
p_sexr->result = SEOS_EXITR_CHECK;
}
return 0;
}
typedef int(*PFNEXIT)(void);
// Function name: PWD_RegisterExit
// Description: Export exits function
// Return type: int 0
// Argument: IN/OUT PFNEXIT pfnExit[] - array of user defined functions
// Argument: IN/OUT DWORD *pdwType - array of Engine events
_declspec(dllexport) int __stdcall PWD_RegisterExit(PFNEXIT pfnExit[],
DWORD pdwType)
{
pfnExit[0] = (PFNEXIT)ExitFunc_PreVerifyPassword;
pdwType[0] = AUTHXAPI_EV_PREVERPWD;
return 0;
}
참고: 암호 관련 종료를 사용하려면 레지스트리에 종료 동적 연결 라이브러리를 설치한 후 컴퓨터를 다시 부팅해야 합니다. CA ControlMinder 암호 확인을 처리하는 pwdchange 동적 연결 라이브러리는 컴퓨터가 시작될 때만 로드되므로 이 작업이 반드시 필요합니다.
CA ControlMinder가 제공하는 종료 API 함수는 다음 범주에 따라 그룹화됩니다.
특정 이벤트에 대한 종료 API 함수가 CA ControlMinder에 등록되었는지 여부를 확인합니다.
새 종료 API 함수를 CA ControlMinder에 등록합니다.
CA ControlMinder에 이전에 등록한 종료 API 함수를 제거합니다.
이전에 authxapi_GetObjectListValue 함수를 호출할 때 할당된 메모리를 해제합니다.
데이터베이스 개체에서 목록 값 속성의 값을 검색합니다.
데이터베이스 개체에서 단일 값 속성의 값을 검색합니다.
사용자 핸들이 지정된 경우 종료 API 함수에서 사용자 이름을 검색합니다.
확장에 의해 제공되고 프로그램 시작 시 호출됩니다.
확장에 의해 제공되고 프로그램 종료 시 호출됩니다.
|
Copyright © 2013 CA.
All rights reserved.
|
|