Skip to content

Commit 43ed933

Browse files
committed
cdba-server: add syslog support
Log messages to the syslog when the user opens a board. Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent b32d98f commit 43ed933

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cdba-server.c

Lines changed: 3 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"
@@ -361,6 +362,8 @@ int main(int argc, char **argv)
361362
if (!username)
362363
username = "nobody";
363364

365+
openlog("cdba-server", 0, LOG_DAEMON);
366+
364367
ret = device_parser(".cdba");
365368
if (ret) {
366369
ret = device_parser("/etc/cdba");

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)