cdba-server: add syslog support

Log messages to the syslog when the user opens a board.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
This commit is contained in:
Dmitry Baryshkov
2023-11-08 17:15:27 +03:00
parent b32d98f7a4
commit 43ed93357d
2 changed files with 11 additions and 1 deletions

View File

@@ -38,6 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>
#include "cdba-server.h"
#include "circ_buf.h"
@@ -361,6 +362,8 @@ int main(int argc, char **argv)
if (!username)
username = "nobody";
openlog("cdba-server", 0, LOG_DAEMON);
ret = device_parser(".cdba");
if (ret) {
ret = device_parser("/etc/cdba");

View File

@@ -39,6 +39,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <syslog.h>
#include "cdba-server.h"
#include "device.h"
@@ -127,11 +128,17 @@ struct device *device_open(const char *board,
goto found;
}
syslog(LOG_INFO, "user %s asked for non-existing board %s", username, board);
return NULL;
found:
if (!device_check_access(device, username))
if (!device_check_access(device, username)) {
syslog(LOG_INFO, "user %s access denied to the board %s", username, board);
return NULL;
}
syslog(LOG_INFO, "user %s opening board %s", username, board);
assert(device->console_ops);
assert(device->console_ops->open);