Skip to content

Commit

Permalink
Merge pull request #52 from lumag/syslog
Browse files Browse the repository at this point in the history
Syslog sypport
  • Loading branch information
lumag authored Nov 29, 2023
2 parents 3269b8b + 43ed933 commit 5edc55c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cdba-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>

#include "cdba-server.h"
#include "circ_buf.h"
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion device.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <syslog.h>

#include "cdba-server.h"
#include "device.h"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5edc55c

Please sign in to comment.