resp->val = val;
}
-static int update_label(struct bxt_client *cli)
+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;
+
+ if (cli->cred.pid != pid)
+ return;
+
snprintf(path, sizeof(path), "/proc/%d/attr/current", cli->cred.pid);
fd = open(path, O_RDONLY);
if (fd < 0)
- return -1;
+ return;
ret = read(fd, buf, sizeof(buf) - 1);
if (ret <= 0) {
close(fd);
- return -1;
+ return;
} else {
buf[ret] = 0;
}
if (cli->label)
free(cli->label);
cli->label = strdup(buf);
+}
+static int update_client_label(struct bxt_client *cli)
+{
+ g_hash_table_foreach(cli->bxtd->clients, (GHFunc)update_label,
+ &(cli->cred.pid));
return 0;
}
resp->res = 0;
return;
} else if (!strcmp(rqst->key, "update_client_label")) {
- resp->res = update_label(cli);
+ resp->res = update_client_label(cli);
return;
}
resp->res = ENOTSUP;