]>
git.saurik.com Git - apple/securityd.git/blob - src/tokencache.h
2 * Copyright (c) 2004 Apple Computer, 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@
26 // tokencache - persistent (on-disk) hardware token directory
31 #include <security_utilities/refcount.h>
32 #include <Security/cssm.h>
41 Rooted(const char *root
) : mRoot(root
) { }
42 Rooted(const string
&root
) : mRoot(root
) { }
44 string
root() const { return mRoot
; }
45 string
path(const char *sub
) const;
46 string
path(const string
&sub
) const { return path(sub
.c_str()); }
49 void root(const string
&s
);
52 string mRoot
; // root of this tree
57 // An on-disk cache area.
58 // You'll only want a single one, though nothing keeps you from
59 // making multiples if you like.
61 class TokenCache
: public Rooted
{
63 TokenCache(const char *root
);
66 uid_t
tokendUid() const { return mTokendUid
; }
67 gid_t
tokendGid() const { return mTokendGid
; }
70 class Token
: public RefCount
, public Rooted
{
72 friend class TokenCache
;
73 Token(TokenCache
&cache
, const std::string
&uid
);
74 Token(TokenCache
&cache
);
77 enum Type
{ existing
, created
, temporary
};
78 Type
type() const { return mType
; }
81 uint32
subservice() const { return mSubservice
; }
82 string
workPath() const;
83 string
cachePath() const;
85 string
printName() const;
86 void printName(const string
&name
);
88 uid_t
tokendUid() const { return cache
.tokendUid(); }
89 gid_t
tokendGid() const { return cache
.tokendGid(); }
95 uint32 mSubservice
; // subservice id assigned
96 Type mType
; // type of Token cache entry
100 uint32
allocateSubservice();
103 enum Owner
{ securityd
, tokend
};
104 void makedir(const char *path
, int flags
, mode_t mode
, Owner owner
);
105 void makedir(const string
&path
, int flags
, mode_t mode
, Owner owner
)
106 { return makedir(path
.c_str(), flags
, mode
, owner
); }
109 uint32 mLastSubservice
; // last subservice id issued
111 uid_t mTokendUid
; // uid of daemons accessing this token cache
112 gid_t mTokendGid
; // gid of daemons accessing this token cache
116 #endif //_H_TOKENCACHE