Skip to content

Commit 5edc55c

Browse files
authored
Merge pull request #52 from lumag/syslog
Syslog sypport
2 parents 3269b8b + 43ed933 commit 5edc55c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cdba-server.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <stdio.h>
3939
#include <string.h>
4040
#include <unistd.h>
41+
#include <syslog.h>
4142

4243
#include "cdba-server.h"
4344
#include "circ_buf.h"
@@ -356,6 +357,12 @@ int main(int argc, char **argv)
356357
signal(SIGPIPE, sigpipe_handler);
357358

358359
username = getenv("CDBA_USER");
360+
if (!username)
361+
username = getenv("USER");
362+
if (!username)
363+
username = "nobody";
364+
365+
openlog("cdba-server", 0, LOG_DAEMON);
359366

360367
ret = device_parser(".cdba");
361368
if (ret) {

device.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <string.h>
4040
#include <unistd.h>
4141
#include <fcntl.h>
42+
#include <syslog.h>
4243

4344
#include "cdba-server.h"
4445
#include "device.h"
@@ -127,11 +128,17 @@ struct device *device_open(const char *board,
127128
goto found;
128129
}
129130

131+
syslog(LOG_INFO, "user %s asked for non-existing board %s", username, board);
130132
return NULL;
131133

132134
found:
133-
if (!device_check_access(device, username))
135+
if (!device_check_access(device, username)) {
136+
syslog(LOG_INFO, "user %s access denied to the board %s", username, board);
137+
134138
return NULL;
139+
}
140+
141+
syslog(LOG_INFO, "user %s opening board %s", username, board);
135142

136143
assert(device->console_ops);
137144
assert(device->console_ops->open);

0 commit comments

Comments
 (0)