#define _XOPEN_SOURCE 500 #include #include #include #include #include #include #include #include #include #include #include "setuid.h" #include "netutil.h" #include "libsmooth.h" #define noovpndebug // global vars struct keyvalue *kv = NULL; FILE *ifacefile = NULL; char redif[STRING_SIZE]; char blueif[STRING_SIZE]; char orangeif[STRING_SIZE]; char enablered[STRING_SIZE] = "off"; char enableblue[STRING_SIZE] = "off"; char enableorange[STRING_SIZE] = "off"; // consts char OVPNINPUT[STRING_SIZE] = "OVPNINPUT"; char OVPNBLOCK[STRING_SIZE] = "OVPNBLOCK"; char OVPNNAT[STRING_SIZE] = "OVPNNAT"; char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.2.4"; struct connection_struct { char name[STRING_SIZE]; char type[STRING_SIZE]; char proto[STRING_SIZE]; char status[STRING_SIZE]; char local_subnet[STRING_SIZE]; char transfer_subnet[STRING_SIZE]; char role[STRING_SIZE]; char port[STRING_SIZE]; struct connection_struct *next; }; typedef struct connection_struct connection; static int recursive_remove_callback(const char* fpath, const struct stat* sb, int typeflag, struct FTW* ftwbuf) { int rv = remove(fpath); if (rv) perror(fpath); return rv; } static int recursive_remove(const char* path) { return nftw(path, recursive_remove_callback, 64, FTW_DEPTH | FTW_PHYS); } void exithandler(void) { if(kv) freekeyvalues(kv); if (ifacefile) fclose(ifacefile); } void usage(void) { #ifdef ovpndebug printf("Wrapper for OpenVPN %s-debug\n", WRAPPERVERSION); #else printf("Wrapper for OpenVPN %s\n", WRAPPERVERSION); #endif printf("openvpnctrl