BuildRequires: pkgconfig(libsyscommon)
BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-session)
+BuildRequires: pkgconfig(cynara-creds-self)
%if 0%{?gcov:1}
BuildRequires: lcov
#include <cynara-client.h>
#include <cynara-session.h>
+#include <cynara-creds-self.h>
#include "util/feedback-privilege.h"
#include "log.h"
bool is_privilege_supported(const char *privilege_name)
{
cynara *cynara = NULL;
- FILE *fp = NULL;
char uid[16];
char *session = NULL;
- char smack_label[BUFF_MAX] = {0, };
+ char *smack_label = NULL;
int ret;
if (cynara_initialize(&cynara, NULL) != CYNARA_API_SUCCESS) {
return false;
}
- fp = fopen("/proc/self/attr/current", "r");
- if (fp != NULL) {
- int ch = 0;
- int idx = 0;
- while (EOF != (ch = fgetc(fp))) {
- smack_label[idx] = ch;
- idx++;
- }
- fclose(fp);
+ ret = cynara_creds_self_get_client(CLIENT_METHOD_DEFAULT, &smack_label);
+ if (ret != CYNARA_API_SUCCESS) {
+ _E("failed to get smack label");
+ return false;
}
pid_t pid = getpid();
uid[15] = '\0';
ret = cynara_check(cynara, smack_label, session, uid, privilege_name);
+ if (smack_label)
+ free(smack_label);
if (session)
free(session);
if (cynara)