+ CFRetain(info);
+
+ done :
+
+ if (dict) CFRelease(dict);
+ return info;
+}
+
+
+Boolean
+SCDynamicStoreSetConsoleInformation(SCDynamicStoreRef store,
+ const char *user,
+ uid_t uid,
+ gid_t gid,
+ CFArrayRef sessions)
+{
+ CFStringRef consoleUser;
+ CFMutableDictionaryRef dict = NULL;
+ CFStringRef key = SCDynamicStoreKeyCreateConsoleUser(NULL);
+ Boolean ok = FALSE;
+
+ if ((user == NULL) && (sessions == NULL)) {
+ ok = SCDynamicStoreRemoveValue(store, key);
+ goto done;
+ }
+
+ dict = CFDictionaryCreateMutable(NULL,
+ 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+
+ if (user != NULL) {
+ CFNumberRef num;
+
+ consoleUser = CFStringCreateWithCString(NULL, user, kCFStringEncodingMacRoman);
+ CFDictionarySetValue(dict, kSCPropUsersConsoleUserName, consoleUser);
+ CFRelease(consoleUser);
+
+ num = CFNumberCreate(NULL, kCFNumberSInt32Type, (SInt32 *)&uid);
+ CFDictionarySetValue(dict, kSCPropUsersConsoleUserUID, num);
+ CFRelease(num);
+
+ num = CFNumberCreate(NULL, kCFNumberSInt32Type, (SInt32 *)&gid);
+ CFDictionarySetValue(dict, kSCPropUsersConsoleUserGID, num);
+ CFRelease(num);
+ }
+
+ if (sessions != NULL) {
+ CFDictionarySetValue(dict, kSCPropUsersConsoleSessionInfo, sessions);
+ }
+
+ ok = SCDynamicStoreSetValue(store, key, dict);
+
+ done :
+
+ if (dict) CFRelease(dict);
+ if (key) CFRelease(key);
+ return ok;