]>
git.saurik.com Git - apple/libsecurity_codesigning.git/blob - lib/bundlediskrep.h
b4e201ef3afeaafdac8c4b0f0aafe788c4d58994
2 * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 // bundlediskrep - bundle directory disk representation
27 #ifndef _H_BUNDLEDISKREP
28 #define _H_BUNDLEDISKREP
34 namespace CodeSigning
{
37 #define BUNDLEDISKREP_DIRECTORY "_CodeSignature"
41 // A BundleDiskRep represents a standard Mac OS X bundle on disk.
42 // The bundle is expected to have an Info.plist, and a "main executable file"
43 // of some sort (as indicated therein).
44 // The BundleDiskRep stores the necessary components in the main executable
45 // if it is in Mach-O format, or in Contents files if not.
46 // This DiskRep supports resource sealing.
48 class BundleDiskRep
: public DiskRep
{
50 BundleDiskRep(const char *path
, const Context
*ctx
= NULL
);
51 BundleDiskRep(CFBundleRef ref
, const Context
*ctx
= NULL
);
53 CFDataRef
component(CodeDirectory::SpecialSlot slot
);
54 CFDataRef
identification();
55 std::string
mainExecutablePath();
56 CFURLRef
canonicalPath();
57 std::string
recommendedIdentifier();
58 std::string
resourcesRootPath();
59 CFDictionaryRef
defaultResourceRules();
60 void adjustResources(ResourceBuilder
&builder
);
61 const Requirements
*defaultRequirements(const Architecture
*arch
);
62 Universal
*mainExecutableImage();
65 size_t signingLimit();
67 CFArrayRef
modifiedFiles();
68 UnixPlusPlus::FileDesc
&fd();
71 CFBundleRef
bundle() const { return mBundle
; }
79 std::string
metaPath(const char *name
);
80 CFDataRef
metaData(const char *name
) { return cfLoadFile(CFTempURL(metaPath(name
))); }
81 void createMeta(); // (try to) create the meta-file directory
84 void checkModifiedFile(CFMutableArrayRef files
, CodeDirectory::SpecialSlot slot
);
87 CFRef
<CFBundleRef
> mBundle
;
88 std::string mMetaPath
; // path to directory containing signing files
89 bool mMetaExists
; // separate meta-file directory exists
90 RefPointer
<DiskRep
> mExecRep
; // DiskRep for main executable file
98 class BundleDiskRep::Writer
: public DiskRep::Writer
{
99 friend class BundleDiskRep
;
101 Writer(BundleDiskRep
*r
);
103 void component(CodeDirectory::SpecialSlot slot
, CFDataRef data
);
108 DiskRep
*execRep() { return rep
->mExecRep
; }
109 void remove(CodeDirectory::SpecialSlot slot
);
112 RefPointer
<BundleDiskRep
> rep
;
113 RefPointer
<DiskRep::Writer
> execWriter
;
114 bool mMadeMetaDirectory
;
118 } // end namespace CodeSigning
119 } // end namespace Security
121 #endif // !_H_BUNDLEDISKREP