# buxton2d build
-PKG_CHECK_MODULES(D_PKGS REQUIRED libsystemd cynara-client-async gio-2.0)
+PKG_CHECK_MODULES(D_PKGS REQUIRED
+ libsystemd
+ cynara-client-async
+ cynara-creds-pid
+ gio-2.0
+)
FOREACH(flag ${D_PKGS_CFLAGS})
SET(DAEMON_CFLAGS "${DAEMON_CFLAGS} ${flag}")
#include <glib.h>
#include <glib-unix.h>
+#include <cynara-creds-pid.h>
+
#include "common.h"
#include "log.h"
#include "direct.h"
static void update_label(gpointer key, gpointer value, gpointer user_data)
{
- int fd;
int ret;
- char buf[1024];
- char path[1024];
-
struct bxt_client *cli = (struct bxt_client *)value;
int pid = *(int *)user_data;
+ char *client = NULL;
if (cli->cred.pid != pid)
return;
if (is_smack_disabled())
return;
- snprintf(path, sizeof(path), "/proc/%d/attr/current", cli->cred.pid);
- fd = open(path, O_RDONLY);
- if (fd < 0)
+ ret = cynara_creds_pid_get_client(cli->cred.pid, CLIENT_METHOD_DEFAULT, &client);
+ if (ret != CYNARA_API_SUCCESS) {
+ bxt_err("cynara_creds_pid_get_client [pid:%d][%d] failed!", cli->cred.pid, ret);
return;
-
- ret = read(fd, buf, sizeof(buf) - 1);
- if (ret <= 0) {
- close(fd);
- return;
- } else {
- buf[ret] = 0;
}
- close(fd);
-
if (cli->label)
free(cli->label);
- cli->label = strdup(buf);
+ cli->label = client;
}
static int update_client_label(struct bxt_client *cli)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(cynara-client-async)
+BuildRequires: pkgconfig(cynara-creds-pid)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(libtzplatform-config)