mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
implemented rudimentary copy protection
This commit is contained in:
parent
68648f03a1
commit
19786b0917
5 changed files with 59 additions and 9 deletions
|
@ -15,15 +15,13 @@ LDLIBS = -pthread -lrt -lm -lconfig
|
|||
CFLAGS = -std=gnu99 -Iinclude/ -MMD -Wall -O3
|
||||
CFLAGS += -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DV=$(V)
|
||||
|
||||
# Add git commit hash
|
||||
ifneq (,$(shell which git))
|
||||
CFLAGS += -D_GIT_REV='"$(shell git rev-parse --short HEAD)"'
|
||||
endif
|
||||
|
||||
# Conditional debug flags
|
||||
# Add more compiler flags
|
||||
ifdef DEBUG
|
||||
CFLAGS += -O0 -g
|
||||
endif
|
||||
ifneq (,$(shell which git))
|
||||
CFLAGS += -D_GIT_REV='"$(shell git rev-parse --short HEAD)"'
|
||||
endif
|
||||
|
||||
# Enabled GTFPGA support when libpci is available
|
||||
ifneq (,$(wildcard /usr/include/pci/pci.h))
|
||||
|
@ -42,7 +40,7 @@ ifneq (,$(wildcard $(OPALDIR)/include_target/AsyncApi.h))
|
|||
override OBJS += opal.o
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
.PHONY: all clean strip protected
|
||||
|
||||
# Default target: build everything
|
||||
all: $(TARGETS)
|
||||
|
@ -54,10 +52,14 @@ receive: receive.o $(OBJS)
|
|||
random: random.o $(OBJS)
|
||||
test: test.o $(OBJS)
|
||||
|
||||
protected: CFLAGS += -DPROTECT -DVALID_UNTIL=$(shell date -d "now +5months" +%s) -s -O3 -fvisibility=hidden
|
||||
protected: clean strip
|
||||
|
||||
strip: $(TARGETS)
|
||||
strip --remove-section=.comment \
|
||||
--remove-section=.note \
|
||||
--strip-unneeded \
|
||||
--strip-debug \
|
||||
--strip-all \
|
||||
$(TARGETS)
|
||||
|
||||
|
||||
|
|
43
server/include/license.h
Normal file
43
server/include/license.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifdef PROTECT
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
/** Check for correct license */
|
||||
static inline __attribute__((always_inline)) int check_license()
|
||||
{
|
||||
const struct {
|
||||
char *file, *content;
|
||||
off_t offset;
|
||||
} checks[] = {
|
||||
{ "/sys/class/dmi/id/product_uuid", "5002E503-4904-EB05-7406-0C0700080009" },
|
||||
{ "/sys/class/net/eth0/address" , "50:e5:49:eb:74:0c" },
|
||||
{ "/etc/machine-id", "0d8399d0216314f083b9ed2053a354a8" },
|
||||
{ "/dev/sda2", "\x53\xf6\xb5\xeb\x8b\x16\x46\xdc\x8d\x8f\x5b\x70\xb8\xc9\x1a\x2a", 0x468 }, /* EXT4 UUID */
|
||||
};
|
||||
|
||||
if (time(NULL) > VALID_UNTIL)
|
||||
return -1;
|
||||
|
||||
FILE *f;
|
||||
char buf[128];
|
||||
|
||||
for (int i = 0; i < ARRAY_LEN(checks); i++) {
|
||||
f = fopen(checks[i].file, "r");
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
fseek(f, checks[i].offset, SEEK_SET);
|
||||
fgets(buf, sizeof(buf), f);
|
||||
fclose(f);
|
||||
|
||||
if (strncmp(buf, checks[i].content, strlen(checks[i].content)))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#define check_license()
|
||||
#endif
|
|
@ -14,6 +14,7 @@
|
|||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "log.h"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "cfg.h"
|
||||
#include "path.h"
|
||||
#include "node.h"
|
||||
#include "license.h"
|
||||
|
||||
#ifdef ENABLE_OPAL_ASYNC
|
||||
#include "opal.h"
|
||||
|
@ -128,6 +129,9 @@ int main(int argc, char *argv[])
|
|||
if (getuid() != 0)
|
||||
error("The server requires superuser privileges!");
|
||||
|
||||
if (check_license())
|
||||
error("You're not allowed to use this software!");
|
||||
|
||||
/* Initialize lists */
|
||||
list_init(&nodes, (dtor_cb_t) node_destroy);
|
||||
list_init(&paths, (dtor_cb_t) path_destroy);
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#include <fstab.h>
|
||||
|
||||
#ifdef ENABLE_OPAL_ASYNC
|
||||
#define RTLAB
|
||||
|
|
Loading…
Add table
Reference in a new issue