Merge pull request #52 from lumag/syslog

Syslog sypport
This commit is contained in:
Dmitry Baryshkov
2023-11-29 15:22:45 +02:00
committed by GitHub
2 changed files with 15 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"
@@ -356,6 +357,12 @@ int main(int argc, char **argv)
signal(SIGPIPE, sigpipe_handler);
username = getenv("CDBA_USER");
if (!username)
username = getenv("USER");
if (!username)
username = "nobody";
openlog("cdba-server", 0, LOG_DAEMON);
ret = device_parser(".cdba");
if (ret) {

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);