|
|
@ -33,7 +33,7 @@ namespace PolkitTQt
|
|
|
|
// General functions
|
|
|
|
// General functions
|
|
|
|
//--------------------------------------
|
|
|
|
//--------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
Authority *Authority::m_theAuthority = NULL;
|
|
|
|
Authority *Authority::m_theAuthority = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
Authority* Authority::instance(PolkitAuthority *authority)
|
|
|
|
Authority* Authority::instance(PolkitAuthority *authority)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -83,7 +83,7 @@ ActionDescription::List actionsToListAndFree(GList *glist)
|
|
|
|
class Authority::Private
|
|
|
|
class Authority::Private
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
Private(Authority *qq) : q(qq), pkAuthority(NULL), m_hasError(false)
|
|
|
|
Private(Authority *qq) : q(qq), pkAuthority(nullptr), m_hasError(false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -169,11 +169,11 @@ void Authority::Private::init()
|
|
|
|
m_revokeTemporaryAuthorizationsCancellable = g_cancellable_new();
|
|
|
|
m_revokeTemporaryAuthorizationsCancellable = g_cancellable_new();
|
|
|
|
m_revokeTemporaryAuthorizationCancellable = g_cancellable_new();
|
|
|
|
m_revokeTemporaryAuthorizationCancellable = g_cancellable_new();
|
|
|
|
|
|
|
|
|
|
|
|
GError *gerror = NULL;
|
|
|
|
GError *gerror = nullptr;
|
|
|
|
if (pkAuthority == NULL)
|
|
|
|
if (pkAuthority == nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pkAuthority = polkit_authority_get_sync(NULL, &gerror);
|
|
|
|
pkAuthority = polkit_authority_get_sync(nullptr, &gerror);
|
|
|
|
if (gerror != NULL)
|
|
|
|
if (gerror != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setError(E_GetAuthority, gerror->message);
|
|
|
|
setError(E_GetAuthority, gerror->message);
|
|
|
|
g_error_free(gerror);
|
|
|
|
g_error_free(gerror);
|
|
|
@ -181,13 +181,13 @@ void Authority::Private::init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pkAuthority == NULL)
|
|
|
|
if (pkAuthority == nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// connect changed signal
|
|
|
|
// connect changed signal
|
|
|
|
g_signal_connect(G_OBJECT(pkAuthority), "changed", G_CALLBACK(pk_config_changed), NULL);
|
|
|
|
g_signal_connect(G_OBJECT(pkAuthority), "changed", G_CALLBACK(pk_config_changed), nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Authority::Private::setError(Authority::ErrorCode code, const TQString &details, bool recover)
|
|
|
|
void Authority::Private::setError(Authority::ErrorCode code, const TQString &details, bool recover)
|
|
|
@ -271,11 +271,11 @@ Authority::Result Authority::checkAuthorizationSync(const TQString &actionId,
|
|
|
|
return Unknown;
|
|
|
|
return Unknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
PolkitAuthorizationResult *pk_result = polkit_authority_check_authorization_sync(d->pkAuthority,
|
|
|
|
PolkitAuthorizationResult *pk_result = polkit_authority_check_authorization_sync(d->pkAuthority,
|
|
|
|
subject.subject(), actionId.ascii(), NULL, (PolkitCheckAuthorizationFlags)(int)flags,
|
|
|
|
subject.subject(), actionId.ascii(), nullptr, (PolkitCheckAuthorizationFlags)(int)flags,
|
|
|
|
NULL, &error);
|
|
|
|
nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_CheckFailed, error->message);
|
|
|
|
d->setError(E_CheckFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -308,7 +308,7 @@ void Authority::checkAuthorization(const TQString &actionId, const Subject &subj
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
polkit_authority_check_authorization(d->pkAuthority, subject.subject(), actionId.ascii(), NULL,
|
|
|
|
polkit_authority_check_authorization(d->pkAuthority, subject.subject(), actionId.ascii(), nullptr,
|
|
|
|
(PolkitCheckAuthorizationFlags)(int)flags, d->m_checkAuthorizationCancellable,
|
|
|
|
(PolkitCheckAuthorizationFlags)(int)flags, d->m_checkAuthorizationCancellable,
|
|
|
|
d->checkAuthorizationCallback, this);
|
|
|
|
d->checkAuthorizationCallback, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -321,10 +321,10 @@ void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResul
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_finish(
|
|
|
|
PolkitAuthorizationResult *pkResult = polkit_authority_check_authorization_finish(
|
|
|
|
(PolkitAuthority*)object, result, &error);
|
|
|
|
(PolkitAuthority*)object, result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -334,7 +334,7 @@ void Authority::Private::checkAuthorizationCallback(GObject *object, GAsyncResul
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pkResult != NULL)
|
|
|
|
if (pkResult != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit authority->checkAuthorizationFinished(polkitResultToResult(pkResult));
|
|
|
|
emit authority->checkAuthorizationFinished(polkitResultToResult(pkResult));
|
|
|
|
g_object_unref(pkResult);
|
|
|
|
g_object_unref(pkResult);
|
|
|
@ -360,9 +360,9 @@ ActionDescription::List Authority::enumerateActionsSync()
|
|
|
|
return ActionDescription::List();
|
|
|
|
return ActionDescription::List();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, NULL, &error);
|
|
|
|
GList *glist = polkit_authority_enumerate_actions_sync(d->pkAuthority, nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_EnumFailed, error->message);
|
|
|
|
d->setError(E_EnumFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -390,9 +390,9 @@ void Authority::Private::enumerateActionsCallback(GObject *object, GAsyncResult
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
GList *list = polkit_authority_enumerate_actions_finish((PolkitAuthority*)object, result, &error);
|
|
|
|
GList *list = polkit_authority_enumerate_actions_finish((PolkitAuthority*)object, result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -428,9 +428,9 @@ bool Authority::registerAuthenticationAgentSync(const Subject &subject, const TQ
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
gboolean result = polkit_authority_register_authentication_agent_sync(d->pkAuthority,
|
|
|
|
gboolean result = polkit_authority_register_authentication_agent_sync(d->pkAuthority,
|
|
|
|
subject.subject(), locale.ascii(), objectPath.ascii(), NULL, &error);
|
|
|
|
subject.subject(), locale.ascii(), objectPath.ascii(), nullptr, &error);
|
|
|
|
if (error)
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_RegisterFailed, error->message);
|
|
|
|
d->setError(E_RegisterFailed, error->message);
|
|
|
@ -468,9 +468,9 @@ void Authority::Private::registerAuthenticationAgentCallback(GObject *object, GA
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool res = polkit_authority_register_authentication_agent_finish((PolkitAuthority*)object, result, &error);
|
|
|
|
bool res = polkit_authority_register_authentication_agent_finish((PolkitAuthority*)object, result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -505,10 +505,10 @@ bool Authority::unregisterAuthenticationAgentSync(const Subject &subject, const
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority,
|
|
|
|
bool result = polkit_authority_unregister_authentication_agent_sync(d->pkAuthority,
|
|
|
|
subject.subject(), objectPath.utf8().data(), NULL, &error);
|
|
|
|
subject.subject(), objectPath.utf8().data(), nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_UnregisterFailed, error->message);
|
|
|
|
d->setError(E_UnregisterFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -544,10 +544,10 @@ void Authority::Private::unregisterAuthenticationAgentCallback(GObject *object,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool res = polkit_authority_unregister_authentication_agent_finish((PolkitAuthority*)object,
|
|
|
|
bool res = polkit_authority_unregister_authentication_agent_finish((PolkitAuthority*)object,
|
|
|
|
result, &error);
|
|
|
|
result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -582,10 +582,10 @@ bool Authority::authenticationAgentResponseSync(const TQString &cookie, const Id
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority,
|
|
|
|
bool result = polkit_authority_authentication_agent_response_sync(d->pkAuthority,
|
|
|
|
cookie.utf8().data(), identity.identity(), NULL, &error);
|
|
|
|
cookie.utf8().data(), identity.identity(), nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_AgentResponseFailed, error->message);
|
|
|
|
d->setError(E_AgentResponseFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -621,10 +621,10 @@ void Authority::Private::authenticationAgentResponseCallback(GObject *object, GA
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool res = polkit_authority_authentication_agent_response_finish((PolkitAuthority*)object, result,
|
|
|
|
bool res = polkit_authority_authentication_agent_response_finish((PolkitAuthority*)object, result,
|
|
|
|
&error);
|
|
|
|
&error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -650,10 +650,10 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TemporaryAuthorization::List result;
|
|
|
|
TemporaryAuthorization::List result;
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority,
|
|
|
|
GList *glist = polkit_authority_enumerate_temporary_authorizations_sync(d->pkAuthority,
|
|
|
|
subject.subject(), NULL, &error);
|
|
|
|
subject.subject(), nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_EnumFailed, error->message);
|
|
|
|
d->setError(E_EnumFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -661,7 +661,7 @@ TemporaryAuthorization::List Authority::enumerateTemporaryAuthorizationsSync(con
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GList *glist2;
|
|
|
|
GList *glist2;
|
|
|
|
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2))
|
|
|
|
for (glist2 = glist; glist2 != nullptr; glist2 = g_list_next(glist2))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
|
|
|
|
result.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
|
|
|
|
if (glist2->data)
|
|
|
|
if (glist2->data)
|
|
|
@ -682,10 +682,10 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
GList *glist = polkit_authority_enumerate_temporary_authorizations_finish((PolkitAuthority*)object,
|
|
|
|
GList *glist = polkit_authority_enumerate_temporary_authorizations_finish((PolkitAuthority*)object,
|
|
|
|
result, &error);
|
|
|
|
result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -697,7 +697,7 @@ void Authority::Private::enumerateTemporaryAuthorizationsCallback(GObject *objec
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TemporaryAuthorization::List res;
|
|
|
|
TemporaryAuthorization::List res;
|
|
|
|
GList *glist2;
|
|
|
|
GList *glist2;
|
|
|
|
for (glist2 = glist; glist2 != NULL; glist2 = g_list_next(glist2))
|
|
|
|
for (glist2 = glist; glist2 != nullptr; glist2 = g_list_next(glist2))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
|
|
|
|
res.append(TemporaryAuthorization((PolkitTemporaryAuthorization*)glist2->data));
|
|
|
|
if (glist2->data)
|
|
|
|
if (glist2->data)
|
|
|
@ -724,10 +724,10 @@ bool Authority::revokeTemporaryAuthorizationsSync(const Subject &subject)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority,
|
|
|
|
bool result = polkit_authority_revoke_temporary_authorizations_sync(d->pkAuthority,
|
|
|
|
subject.subject(), NULL, &error);
|
|
|
|
subject.subject(), nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_RevokeFailed, error->message);
|
|
|
|
d->setError(E_RevokeFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -757,9 +757,9 @@ void Authority::Private::revokeTemporaryAuthorizationsCallback(GObject *object,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool res = polkit_authority_revoke_temporary_authorizations_finish((PolkitAuthority*)object, result, &error);
|
|
|
|
bool res = polkit_authority_revoke_temporary_authorizations_finish((PolkitAuthority*)object, result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
@ -788,10 +788,10 @@ bool Authority::revokeTemporaryAuthorizationSync(const TQString &id)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority,
|
|
|
|
bool result = polkit_authority_revoke_temporary_authorization_by_id_sync(d->pkAuthority,
|
|
|
|
id.utf8().data(), NULL, &error);
|
|
|
|
id.utf8().data(), nullptr, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d->setError(E_RevokeFailed, error->message);
|
|
|
|
d->setError(E_RevokeFailed, error->message);
|
|
|
|
g_error_free(error);
|
|
|
|
g_error_free(error);
|
|
|
@ -821,10 +821,10 @@ void Authority::Private::revokeTemporaryAuthorizationCallback(GObject *object,
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GError *error = NULL;
|
|
|
|
GError *error = nullptr;
|
|
|
|
bool res = polkit_authority_revoke_temporary_authorization_by_id_finish((PolkitAuthority*)object,
|
|
|
|
bool res = polkit_authority_revoke_temporary_authorization_by_id_finish((PolkitAuthority*)object,
|
|
|
|
result, &error);
|
|
|
|
result, &error);
|
|
|
|
if (error != NULL)
|
|
|
|
if (error != nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
// We don't want to set error if this is cancellation of some action
|
|
|
|
if (error->code != 1)
|
|
|
|
if (error->code != 1)
|
|
|
|