1 /* Copyright (c) 2012-2013 Apple Inc. All Rights Reserved. */
3 #ifndef _SECURITY_AUTH_RULE_H_
4 #define _SECURITY_AUTH_RULE_H_
7 #include <CoreFoundation/CoreFoundation.h>
8 #include <Security/SecRequirement.h>
10 #if defined(__cplusplus)
14 typedef bool (^mechanism_iterator_t
)(mechanism_t mechanism
);
15 typedef bool (^delegate_iterator_t
)(rule_t delegate
);
31 RuleFlagShared
= 1 << 0,
32 RuleFlagAllowRoot
= 1 << 1,
33 RuleFlagSessionOwner
= 1 << 2,
34 RuleFlagAuthenticateUser
= 1 << 3,
35 RuleFlagExtractPassword
= 1 << 4,
36 RuleFlagEntitled
= 1 << 5,
37 RuleFlagEntitledAndGroup
= 1 << 6,
38 RuleFlagRequireAppleSigned
= 1 << 7,
39 RuleFlagVPNEntitledAndGroup
= 1 << 8,
40 RuleFlagPasswordOnly
= 1 << 9
42 typedef uint32_t RuleFlags
;
50 AUTH_WARN_RESULT AUTH_MALLOC AUTH_NONNULL_ALL AUTH_RETURNS_RETAINED
51 rule_t
rule_create_default(void);
53 AUTH_WARN_RESULT AUTH_MALLOC AUTH_NONNULL_ALL AUTH_RETURNS_RETAINED
54 rule_t
rule_create_preauthorization(void);
56 AUTH_WARN_RESULT AUTH_MALLOC AUTH_NONNULL1 AUTH_RETURNS_RETAINED
57 rule_t
rule_create_with_string(const char *,authdb_connection_t
);
59 AUTH_WARN_RESULT AUTH_MALLOC AUTH_NONNULL_ALL AUTH_RETURNS_RETAINED
60 rule_t
rule_create_with_plist(RuleType
,CFStringRef
,CFDictionaryRef
,authdb_connection_t
);
63 size_t rule_get_mechanisms_count(rule_t
);
66 CFArrayRef
rule_get_mechanisms(rule_t
);
69 bool rule_mechanisms_iterator(rule_t
,mechanism_iterator_t iter
);
72 size_t rule_get_delegates_count(rule_t
);
75 bool rule_delegates_iterator(rule_t
,delegate_iterator_t iter
);
78 bool rule_sql_fetch(rule_t
,authdb_connection_t
);
80 AUTH_NONNULL1 AUTH_NONNULL2
81 bool rule_sql_commit(rule_t
,authdb_connection_t
,CFAbsoluteTime
,process_t
);
84 bool rule_sql_remove(rule_t
,authdb_connection_t
,process_t
);
87 CFMutableDictionaryRef
rule_copy_to_cfobject(rule_t
,authdb_connection_t
);
90 int64_t rule_get_id(rule_t
);
93 const char * rule_get_name(rule_t
);
96 RuleType
rule_get_type(rule_t
);
99 RuleClass
rule_get_class(rule_t
);
102 const char * rule_get_group(rule_t
);
105 int64_t rule_get_kofn(rule_t
);
108 int64_t rule_get_timeout(rule_t
);
111 bool rule_check_flags(rule_t
,RuleFlags
);
114 bool rule_get_shared(rule_t
);
117 bool rule_get_allow_root(rule_t
);
120 bool rule_get_session_owner(rule_t
);
123 bool rule_get_authenticate_user(rule_t
);
126 bool rule_get_extract_password(rule_t
);
129 bool rule_get_password_only(rule_t
);
132 int64_t rule_get_tries(rule_t
);
135 const char * rule_get_comment(rule_t
);
138 int64_t rule_get_version(rule_t
);
141 double rule_get_created(rule_t
);
144 double rule_get_modified(rule_t
);
147 const char * rule_get_identifier(rule_t
);
150 CFDataRef
rule_get_requirement_data(rule_t
);
153 SecRequirementRef
rule_get_requirement(rule_t
);
155 AUTH_NONNULL1 AUTH_NONNULL2
156 void rule_log_manipulation(authdb_connection_t dbconn
, rule_t rule
, RuleOperation operation
, process_t source
);
158 #if defined(__cplusplus)
162 #endif /* !_SECURITY_AUTH_RULE_H_ */