/*
- * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005, 2009, 2011, 2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <SystemConfiguration/SCPrivate.h>
-#ifndef kSCPropUsersConsoleUserName
+#undef kSCPropUsersConsoleUserName
#define kSCPropUsersConsoleUserName CFSTR("Name")
-#endif
-#ifndef kSCPropUsersConsoleUserUID
+#undef kSCPropUsersConsoleUserUID
#define kSCPropUsersConsoleUserUID CFSTR("UID")
-#endif
-#ifndef kSCPropUsersConsoleUserGID
+#undef kSCPropUsersConsoleUserGID
#define kSCPropUsersConsoleUserGID CFSTR("GID")
-#endif
-#ifndef kSCPropUsersConsoleSessionInfo
+#undef kSCPropUsersConsoleSessionInfo
#define kSCPropUsersConsoleSessionInfo CFSTR("SessionInfo")
-#endif
// from CoreGraphics (CGSession.h)
// from CoreGraphics (CGSSession.h)
const CFStringRef kSCConsoleSessionID = CFSTR("kCGSSessionIDKey"); /* value is CFNumber */
-// from loginwindow
+// for loginwindow
const CFStringRef kSCConsoleSessionSystemSafeBoot = CFSTR("kCGSSessionSystemSafeBoot"); /* value is CFBoolean */
const CFStringRef kSCConsoleSessionLoginwindowSafeLogin = CFSTR("kCGSSessionLoginwindowSafeLogin"); /* value is CFBoolean */
CFStringRef consoleUser = NULL;
CFDictionaryRef dict = NULL;
CFStringRef key;
- Boolean tempSession = FALSE;
-
- if (store == NULL) {
- store = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreCopyConsoleUser"),
- NULL,
- NULL);
- if (store == NULL) {
- return NULL;
- }
- tempSession = TRUE;
- }
key = SCDynamicStoreKeyCreateConsoleUser(NULL);
dict = SCDynamicStoreCopyValue(store, key);
done :
- if (tempSession) CFRelease(store);
if (dict) CFRelease(dict);
return consoleUser;
}
CFDictionaryRef dict = NULL;
CFArrayRef info = NULL;
CFStringRef key;
- Boolean tempSession = FALSE;
-
- if (store == NULL) {
- store = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreCopyConsoleUser"),
- NULL,
- NULL);
- if (store == NULL) {
- return NULL;
- }
- tempSession = TRUE;
- }
key = SCDynamicStoreKeyCreateConsoleUser(NULL);
dict = SCDynamicStoreCopyValue(store, key);
info = CFDictionaryGetValue(dict, kSCPropUsersConsoleSessionInfo);
info = isA_CFArray(info);
- if (!info) {
+ if (info == NULL) {
_SCErrorSet(kSCStatusNoKey);
goto done;
}
done :
- if (tempSession) CFRelease(store);
if (dict) CFRelease(dict);
return info;
}
CFStringRef consoleUser;
CFMutableDictionaryRef dict = NULL;
CFStringRef key = SCDynamicStoreKeyCreateConsoleUser(NULL);
- Boolean ok = TRUE;
- Boolean tempSession = FALSE;
-
- if (store == NULL) {
- store = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreSetConsoleUser"),
- NULL,
- NULL);
- if (store == NULL) {
- return FALSE;
- }
- tempSession = TRUE;
- }
+ Boolean ok = FALSE;
if ((user == NULL) && (sessions == NULL)) {
- (void) SCDynamicStoreRemoveValue(store, key);
+ ok = SCDynamicStoreRemoveValue(store, key);
goto done;
}
if (dict) CFRelease(dict);
if (key) CFRelease(key);
- if (tempSession) CFRelease(store);
return ok;
}
CFMutableDictionaryRef dict = NULL;
CFStringRef key = SCDynamicStoreKeyCreateConsoleUser(NULL);
CFNumberRef num;
- Boolean ok = TRUE;
- Boolean tempSession = FALSE;
-
- if (store == NULL) {
- store = SCDynamicStoreCreate(NULL,
- CFSTR("SCDynamicStoreSetConsoleUser"),
- NULL,
- NULL);
- if (store == NULL) {
- return FALSE;
- }
- tempSession = TRUE;
- }
+ Boolean ok = FALSE;
if (user == NULL) {
- (void) SCDynamicStoreRemoveValue(store, key);
+ ok = SCDynamicStoreRemoveValue(store, key);
goto done;
}
if (dict) CFRelease(dict);
if (key) CFRelease(key);
- if (tempSession) CFRelease(store);
return ok;
}