-static const char* get_security_cookie()
-{
- static char *cookie = NULL;
- static GMutex cookie_mutex;
- ctx::scope_mutex sm(&cookie_mutex);
-
- if (cookie == NULL) {
- int raw_size = security_server_get_cookie_size();
- IF_FAIL_RETURN_TAG(raw_size > 0, NULL, _E, "Invalid cookie size");
-
- int ret;
- char raw_cookie[raw_size];
-
- ret = security_server_request_cookie(raw_cookie, raw_size);
- IF_FAIL_RETURN_TAG(ret >= 0, NULL, _E, "Failed to get the security cookie");
-
- cookie = g_base64_encode(reinterpret_cast<guchar*>(raw_cookie), raw_size);
- IF_FAIL_RETURN_TAG(cookie, NULL, _E, "Failed to encode the cookie");
- }
-
- return cookie;
-}
-