Add access() test to KISS device configuration

Add access() test to KISS device configuration, providing a formatted
error message to present upon failure
This commit is contained in:
XANTRONIX Development 2021-05-31 22:03:27 -04:00 committed by XANTRONIX Industrial
parent d2fc96a777
commit 595a58f32a

View file

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include <patty/ax25.h> #include <patty/ax25.h>
@ -62,6 +63,11 @@ static patty_ax25_if *create_kiss(struct context *ctx, int argc, char **argv) {
for (i=0; i<argc; i++) { for (i=0; i<argc; i++) {
switch (mode) { switch (mode) {
case MODE_KISS_DEVICE: case MODE_KISS_DEVICE:
if (access(argv[i], R_OK | W_OK) < 0) {
patty_error_fmt(ctx->err, "Unable to access device %s: %s",
argv[i], strerror(errno));
}
info.flags |= PATTY_KISS_TNC_DEVICE; info.flags |= PATTY_KISS_TNC_DEVICE;
info.device = argv[i]; info.device = argv[i];