| Index: tools/telemetry/telemetry/util/mac/determine_if_keychain_is_locked.c
|
| diff --git a/tools/telemetry/telemetry/util/mac/determine_if_keychain_is_locked.c b/tools/telemetry/telemetry/util/mac/determine_if_keychain_is_locked.c
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ddf0aff473a06f4e1451046362f3f46b1943e8bc
|
| --- /dev/null
|
| +++ b/tools/telemetry/telemetry/util/mac/determine_if_keychain_is_locked.c
|
| @@ -0,0 +1,25 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +//
|
| +// This program determines whether the default OSX Keychain is unlocked without
|
| +// causing a user interaction prompt.
|
| +// Return values:
|
| +// 0 - The default keychain is unlocked.
|
| +// 1 - The default keychain is locked.
|
| +// 2 - Unexpected error.
|
| +//
|
| +// To compile, run: "clang -framework Security
|
| +// -o determine_if_keychain_is_locked
|
| +// determine_if_keychain_is_locked.c"
|
| +
|
| +#include <Security/Security.h>
|
| +
|
| +int main() {
|
| + SecKeychainStatus keychain_status;
|
| + OSStatus os_status = SecKeychainGetStatus(NULL, &keychain_status);
|
| + if (os_status != errSecSuccess)
|
| + return 2;
|
| +
|
| + return (keychain_status & kSecUnlockStateStatus) ? 0 : 1;
|
| +}
|
|
|