Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
(연관된 글이 2개 있습니다.)
Internet_Zone 하위에 새로운 코드 그룹을 추가하는 예제


특히나 스마트 클라이언트 프로그램을 해보신 분들이 한번쯤 도전해 보셨을 것 같은데요. 아래의 그림을 보시면 기본적으로 "Internet_Zone" 이 있고, 그 하위에 여러분들의 스마트 클라이언트 DLL/EXE 가 존재하는 코드 그룹을 생성하려고 해보셨을 것입니다.

Internet_Zone 코드 그룹

대개의 경우, 다음과 같은 식으로 코딩을 하지요.

01:     IMembershipCondition memberShipCondition = new UrlMembershipCondition("http://127.0.0.1/webapp/*");
02: 
03:     UnionCodeGroup smartClientGroup = new UnionCodeGroup( new AllMembershipCondition(), null );
04:     smartClientGroup.MembershipCondition = memberShipCondition;
05:     smartClientGroup.Name = "InternetSmartClient_Zone";
06:     smartClientGroup.Description = "InternetSmartClient_Zone Codegroup";
07: 
08:     PolicyStatement policyStatement = new PolicyStatement(permSet, PolicyStatementAttribute.Nothing);
09:     smartClientGroup.PolicyStatement = policyStatement;
10: 
11:     object internetZone = null;
12:     foreach (CodeGroup cg in machinePolicyLevel.RootCodeGroup.Children)
13:     {
14:         if (cg.Name == "Internet_Zone")
15:         {
16:             internetZone = cg;
17:             break;
18:         }
19:     }
20: 
21:     if (internetZone != null)
22:     {
23:         ((CodeGroup)internetZone).AddChild(smartClientGroup);
24:		    SecurityManager.SavePolicy();
25:     }

물론, 위와 같이 코딩을 하시면 100% 장담하건데... 변경 사항이 저장되지 않습니다. 저도 예전에 이 단계에서 그냥 포기하고 Internet_Zone 과 동일한 레벨에서 새로운 코드 그룹을 생성하는 것으로 마무리를 지었었는데요.

추석 연휴이다 보니 ^^ 여유도 있고 해서 한번 이 문제를 도전해봤습니다. 일단 위의 방법외에 뭔가 추가적인 방법이 있을 것 같은데, Google 신 조차도 저에게 아무런 메시지를 내려주지 않아서 애가 타더군요. 그러다가 문득, caspol.exe 에서는 정상적으로 동작하던 기억이 나서,... 통째로 역어셈블을 한 다음에 분석하기 시작했습니다.

결론은, ... SavePolicy 하기 전에 코드 그룹을 재구성해야 한다는 것을 찾아냈고 그 부분의 소스 코드만을 분리해 내어 간단한 예제로 제작해 보았습니다. 그것이 바로 첨부한 "AddCodeGroup.zip" 파일입니다. 아울러, "caspol.zip" 파일을 같이 첨부를 했는데요. 그것은 .NET 2.0 에 포함된 caspol.exe 를 .NET Reflector 로 역어셈블하여 VS.NET 2005 로 컴파일/디버그 가능한 프로젝트로 실어 놓은 것입니다. [2006.10.09 내용 추가 : caspol 소스는 SSCLI20 에도 포함되어져 있습니다. 경로: /clr/src/toolbox/caspol

따라서, 위의 소스는 다음과 같이 바뀌게 됩니다.

21: if (internetZone != null)
22: {
23:     ((CodeGroup)internetZone).AddChild(smartClientGroup);
24:     ReplaceLabel("Internet_Zone", (CodeGroup)internetZone);
25:     SecurityManager.SavePolicy();
26: }

  // 이하 ReplaceLabel 의 소스는 첨부된 AddCodeGroup.zip 에 실려 있습니다.

첨부된 AddCodeGroup.zip 프로젝트로 컴파일된 소스를 실행하고 나면 다음과 같은 보안 설정이 이뤄지게 됩니다. 새로운 코드 그룹이 Internet_Zone 하위에 추가되고, 해당 코드 그룹이 사용하는 전용 보안 집합이 생성된 것을 볼 수 있습니다.

새로운 코드 그룹과 보안집합 생성





[이 토픽에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 10/9/2006]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2006-10-09 09시27분
[이승용] 이야 ~~~
유용한 정보 정말 감사합니다..~
[guest]
2006-10-09 09시31분
^^
kevin25
2006-10-12 10시06분
[맞춰보세요] 닷넷 프레임워크 1.1 버전에서는 RootCodeGroup의 Children 속성이 반환하는 컬렉션이
원본이 아니라 복사본 이였습니다. 따라서 복사본 컬렉션에 포함된 Internet_Zone 밑에 하위 코드그룹을
AddChild 해 봤자 저장이 안되는 것이였죠. 그래서 저는 복사본 컬렉션을 다시 RootCodeGroup의
Children 속성에 set 하는 방식을 썼습니다.
노트북 켜기 대략 귀찮아서... 의사 코드로 하자면...

collection c = machinePolicyLevel.RootCodeGroup.Children // 복사본 컬렉션이 반환됨
foreach(CodeGroup g in c) {
   // 조낸 Internet_Zone 찾음
}
// Internet_Zone에 코드 그룹을 추가함
machinePolicyLevel.RootCodeGroup.Children = c;
SecurityManager.SavePolicy();

2.0에서도 작동한 것으로 기억납니다만...
(텨텨텨~~~~)
[guest]
2006-10-13 07시51분
당근 유수석님... ^^ 이시죠!

설명해 주신 것이 정확한 것 같습니다. ReplaceLabel 함수에서도 실제로는 RootCodeGroup.Children 에 결국 다시 set 하는 코드를 본 것 같습니다. ^^ 제가 너무 caspol.exe 에서 제공되는 ReplaceLabel 코드를 대단하게 생각한 것이 문제였던 것 같습니다. ^^; 사실... 그 함수 내부를 자세히 들여다 보지도 않았거든요. (저는 절대 귀차니즘 때문이 아니라... "필요할 때 본다" 라는 주의이기 때문에. ^^)
kevin25

... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...
NoWriterDateCnt.TitleFile(s)
12203정성태3/18/202022770오류 유형: 612. warning: 'C:\ProgramData/Git/config' has a dubious owner: '...'.
12202정성태3/18/202026158개발 환경 구성: 486. .NET Framework 프로젝트를 위한 GitLab CI/CD Runner 구성
12201정성태3/18/202022700오류 유형: 611. git-credential-manager.exe: Using credentials for username "Personal Access Token". [1]
12200정성태3/18/202022692VS.NET IDE: 145. NuGet + Github 라이브러리 디버깅 관련 옵션 3가지 - "Enable Just My Code" / "Enable Source Link support" / "Suppress JIT optimization on module load (Managed only)"
12199정성태3/17/202020871오류 유형: 610. C# - CodeDomProvider 사용 시 Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path '...\f2_6uod0.tmp'.
12198정성태3/17/202024280오류 유형: 609. SQL 서버 접속 시 "Cannot open user default database. Login failed."
12197정성태3/17/202023714VS.NET IDE: 144. .NET Core 콘솔 응용 프로그램을 배포(publish) 시 docker image 자동 생성 - 두 번째 이야기 [1]
12196정성태3/17/202020237오류 유형: 608. The ServicedComponent being invoked is not correctly configured (Use regsvcs to re-register).
12195정성태3/16/202022504.NET Framework: 902. C# - 프로세스의 모든 핸들을 열람 - 세 번째 이야기
12194정성태3/16/202025781오류 유형: 607. PostgreSQL - Npgsql.NpgsqlException: sorry, too many clients already
12193정성태3/16/202023094개발 환경 구성: 485. docker - SAP Adaptive Server Enterprise 컨테이너 실행 [1]
12192정성태3/14/202023675개발 환경 구성: 484. docker - Sybase Anywhere 16 컨테이너 실행
12191정성태3/14/202025207개발 환경 구성: 483. docker - OracleXE 컨테이너 실행 [1]
12190정성태3/14/202019691오류 유형: 606. Docker Desktop 업그레이드 시 "The process cannot access the file 'C:\Program Files\Docker\Docker\resources\dockerd.exe' because it is being used by another process."
12189정성태3/13/202025047개발 환경 구성: 482. Facebook OAuth 처리 시 상태 정보 전달 방법과 "유효한 OAuth 리디렉션 URI" 설정 규칙
12188정성태3/13/202033272Windows: 169. 부팅 시점에 실행되는 chkdsk 결과를 확인하는 방법
12187정성태3/12/202020451오류 유형: 605. NtpClient was unable to set a manual peer to use as a time source because of duplicate error on '...'.
12186정성태3/12/202021358오류 유형: 604. The SysVol Permissions for one or more GPOs on this domain controller and not in sync with the permissions for the GPOs on the Baseline domain controller.
12185정성태3/11/202022554오류 유형: 603. The browser service was unable to retrieve a list of servers from the browser master...
12184정성태3/11/202024876오류 유형: 602. Automatic certificate enrollment for local system failed (0x800706ba) The RPC server is unavailable. [3]
12183정성태3/11/202021158오류 유형: 601. Warning: DsGetDcName returned information for \\[...], when we were trying to reach [...].
12182정성태3/11/202023061.NET Framework: 901. C# Windows Forms - Vista/7 이후의 Progress Bar 업데이트가 느린 문제파일 다운로드1
12181정성태3/11/202023514기타: 76. 재현 가능한 최소한의 예제 프로젝트란? - 두 번째 예제파일 다운로드1
12180정성태3/10/202020219오류 유형: 600. "Docker Desktop for Windows" - EXPOSE 포트가 LISTENING 되지 않는 문제
12179정성태3/10/202030856개발 환경 구성: 481. docker - PostgreSQL 컨테이너 실행
12178정성태3/10/202024755개발 환경 구성: 480. Linux 운영체제의 docker를 위한 tcp 바인딩 추가 [1]
... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...