From 6b4596fe0124fe5c5f5bd6e11b0fd3b2d416aa56 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 16 Sep 2015 21:04:43 +0200 Subject: removed debian dir moved source code to src/ dir --- Makefile | 140 ------------ client_list.c | 116 ---------- client_list.h | 41 ---- configure | 162 -------------- daemon.h | 173 --------------- datatypes.h | 49 ----- debian/changelog | 20 -- debian/compat | 1 - debian/control | 17 -- debian/copyright | 28 --- debian/postinst | 10 - debian/postrm | 9 - debian/prerm | 12 - debian/rhdropbox.default | 5 - debian/rhdropbox.init | 139 ------------ debian/rules | 69 ------ log.c | 259 ---------------------- log.h | 90 -------- log_targets.h | 363 ------------------------------ options.c | 282 ------------------------ options.h | 52 ----- rhdropbox.c | 563 ----------------------------------------------- sig_handler.c | 166 -------------- sig_handler.h | 43 ---- src/Makefile | 140 ++++++++++++ src/client_list.c | 116 ++++++++++ src/client_list.h | 41 ++++ src/configure | 162 ++++++++++++++ src/daemon.h | 173 +++++++++++++++ src/datatypes.h | 49 +++++ src/log.c | 259 ++++++++++++++++++++++ src/log.h | 90 ++++++++ src/log_targets.h | 363 ++++++++++++++++++++++++++++++ src/options.c | 282 ++++++++++++++++++++++++ src/options.h | 52 +++++ src/rhdropbox.c | 563 +++++++++++++++++++++++++++++++++++++++++++++++ src/sig_handler.c | 166 ++++++++++++++ src/sig_handler.h | 43 ++++ src/string_list.c | 113 ++++++++++ src/string_list.h | 56 +++++ src/sysexec.c | 371 +++++++++++++++++++++++++++++++ src/sysexec.h | 57 +++++ src/utils.c | 173 +++++++++++++++ src/utils.h | 36 +++ src/watch_list.c | 163 ++++++++++++++ src/watch_list.h | 46 ++++ string_list.c | 113 ---------- string_list.h | 56 ----- sysexec.c | 371 ------------------------------- sysexec.h | 57 ----- utils.c | 173 --------------- utils.h | 36 --- watch_list.c | 163 -------------- watch_list.h | 46 ---- 54 files changed, 3514 insertions(+), 3824 deletions(-) delete mode 100644 Makefile delete mode 100644 client_list.c delete mode 100644 client_list.h delete mode 100755 configure delete mode 100644 daemon.h delete mode 100644 datatypes.h delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100755 debian/postinst delete mode 100755 debian/postrm delete mode 100755 debian/prerm delete mode 100644 debian/rhdropbox.default delete mode 100755 debian/rhdropbox.init delete mode 100755 debian/rules delete mode 100644 log.c delete mode 100644 log.h delete mode 100644 log_targets.h delete mode 100644 options.c delete mode 100644 options.h delete mode 100644 rhdropbox.c delete mode 100644 sig_handler.c delete mode 100644 sig_handler.h create mode 100644 src/Makefile create mode 100644 src/client_list.c create mode 100644 src/client_list.h create mode 100755 src/configure create mode 100644 src/daemon.h create mode 100644 src/datatypes.h create mode 100644 src/log.c create mode 100644 src/log.h create mode 100644 src/log_targets.h create mode 100644 src/options.c create mode 100644 src/options.h create mode 100644 src/rhdropbox.c create mode 100644 src/sig_handler.c create mode 100644 src/sig_handler.h create mode 100644 src/string_list.c create mode 100644 src/string_list.h create mode 100644 src/sysexec.c create mode 100644 src/sysexec.h create mode 100644 src/utils.c create mode 100644 src/utils.h create mode 100644 src/watch_list.c create mode 100644 src/watch_list.h delete mode 100644 string_list.c delete mode 100644 string_list.h delete mode 100644 sysexec.c delete mode 100644 sysexec.h delete mode 100644 utils.c delete mode 100644 utils.h delete mode 100644 watch_list.c delete mode 100644 watch_list.h diff --git a/Makefile b/Makefile deleted file mode 100644 index 02dc4a1..0000000 --- a/Makefile +++ /dev/null @@ -1,140 +0,0 @@ -## -## rhdropbox -## -## Copyright (C) 2009 Christian Pointner -## -## This file is part of rhdropbox. -## -## rhdropbox is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## any later version. -## -## rhdropbox is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with rhdropbox. If not, see . -## - -ifneq ($(MAKECMDGOALS),distclean) -include include.mk -endif - -EXECUTABLE := rhdropbox - -OBJ := log.o \ - sig_handler.o \ - string_list.o \ - utils.o \ - client_list.o \ - watch_list.o \ - options.o \ - sysexec.o \ - rhdropbox.o - -SRC := $(OBJ:%.o=%.c) - -.PHONY: clean distclean - -all: $(EXECUTABLE) - -%.d: %.c - @set -e; rm -f $@; \ - $(CC) -MM $(CFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$; echo '(re)building $@' - -ifneq ($(MAKECMDGOALS),distclean) --include $(SRC:%.c=%.d) -endif - -$(EXECUTABLE): $(OBJ) - $(CC) $(OBJ) -o $@ $(LDFLAGS) - -%.o: %.c - $(CC) $(CFLAGS) -c $< - - -distclean: cleanall - find . -name *.o -exec rm -f {} \; - find . -name "*.\~*" -exec rm -rf {} \; - rm -f include.mk - -clean: - rm -f *.o - rm -f *.d - rm -f *.d.* - rm -f $(EXECUTABLE) - -cleanall: clean - $(MAKE) --directory="doc/" clean - -manpage: - $(MAKE) --directory="doc/" manpage - - -INSTALL_TARGETS := install-bin install-etc -REMOVE_TARGETS := remove-bin remove-etc - -ifdef MANDIR -INSTALL_TARGETS += install-man -REMOVE_TARGETS += remove-man -endif - -ifdef EXAMPLESDIR -INSTALL_TARGETS += install-examples -REMOVE_TARGETS += remove-examples -endif - -install: all $(INSTALL_TARGETS) - -install-bin: $(EXECUTABLE) - $(INSTALL) -d $(DESTDIR)$(BINDIR) - $(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR) - -install-etc: - $(INSTALL) -d $(DESTDIR)$(ETCDIR)/$(EXECUTABLE) - @ echo "example configurations can be found at $(EXAMPLESDIR)/$(EXECUTABLE)" > $(DESTDIR)$(ETCDIR)/$(EXECUTABLE)/README - -install-man: manpage - $(INSTALL) -d $(DESTDIR)$(MANDIR)/man8/ - $(INSTALL) -m 644 doc/rhdropbox.8 $(DESTDIR)$(MANDIR)/man8/$(EXECUTABLE).8 - -install-examples: - $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE) - $(INSTALL) -m 644 etc/rhdropbox/autostart $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE)/autostart - @( cd 'etc/rhdropbox/' ; \ - for dir in `ls`; do \ - if [ -d $$dir ]; then \ - echo "install $$dir configuration" ; \ - cd $$dir ; \ - $(INSTALL) -d $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE)/$$dir ; \ - $(INSTALL) -m 644 config $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE)/$$dir/config ; \ - if [ -e 'newfile.sh' ]; then \ - $(INSTALL) -m 755 newfile.sh $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE)/$$dir/newfile.sh ; \ - fi ; \ - cd .. ; \ - fi ; \ - done \ - ) - -uninstall: remove - -remove: $(REMOVE_TARGETS) - -remove-bin: - rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE) - -remove-etc: - -remove-examples: - rm -rf $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE)/ - -remove-man: - rm -f $(DESTDIR)$(MANDIR)/man8/$(EXECUTABLE).8 - -purge: remove - rm -rf $(DESTDIR)$(ETCDIR)/$(EXECUTABLE)/ diff --git a/client_list.c b/client_list.c deleted file mode 100644 index 8379dd9..0000000 --- a/client_list.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * rhdropbox - * - * Copyright (C) 2009 Christian Pointner - * - * This file is part of rhdropbox. - * - * rhdropbox is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhdropbox is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with rhdropbox. If not, see . - */ - -#include - -#include "client_list.h" -#include "datatypes.h" - -client_t* client_get_last(client_t* first) -{ - if(!first) - return NULL; - - while(first->next) { - first = first->next; - } - - return first; -} - -int client_add(client_t** first, int fd) -{ - if(!first) - return -1; - - client_t* new_client = malloc(sizeof(client_t)); - if(!new_client) - return -2; - - new_client->fd = fd; - new_client->status_listener = 0; - new_client->request_listener = 0; - new_client->next = NULL; - new_client->buffer.offset = 0; - - if(!(*first)) { - *first = new_client; - return 0; - } - - client_get_last(*first)->next = new_client; - - return 0; -} - -void client_remove(client_t** first, int fd) -{ - if(!first || !(*first)) - return; - - client_t* deletee = *first; - if((*first)->fd == fd) { - *first = (*first)->next; - close(deletee->fd); - free(deletee); - return; - } - - client_t* prev = deletee; - deletee = deletee->next; - while(deletee) { - if(deletee->fd == fd) { - prev->next = deletee->next; - close(deletee->fd); - free(deletee); - return; - } - prev = deletee; - deletee = deletee->next; - } -} - -client_t* client_find(client_t* first, int fd) -{ - if(!first) - return NULL; - - while(first) { - if(first->fd == fd) - return first; - - first = first->next; - } - return NULL; -} - -void client_clear(client_t** first) -{ - if(!first || !(*first)) - return; - - while(*first) { - client_t* deletee = *first; - *first = (*first)->next; - close(deletee->fd); - free(deletee); - } -} diff --git a/client_list.h b/client_list.h deleted file mode 100644 index 5cc34ae..0000000 --- a/client_list.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * rhdropbox - * - * Copyright (C) 2009 Christian Pointner - * - * This file is part of rhdropbox. - * - * rhdropbox is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhdropbox is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with rhdropbox. If not, see . - */ - -#ifndef RHDROPBOX_client_list_h_INCLUDED -#define RHDROPBOX_client_list_h_INCLUDED - -#include "datatypes.h" - -struct client_struct { - int fd; - int status_listener; - int request_listener; - struct client_struct* next; - read_buffer_t buffer; -}; -typedef struct client_struct client_t; - -int client_add(client_t** first, int fd); -void client_remove(client_t** first, int fd); -client_t* client_find(client_t* first, int fd); -void client_clear(client_t** first); - -#endif diff --git a/configure b/configure deleted file mode 100755 index 1020c35..0000000 --- a/configure +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/sh -# -# -# rhdropbox -# -# Copyright (C) 2009 Christian Pointner -# -# This file is part of rhdropbox. -# -# rhdropbox is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# rhdropbox is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with rhdropbox. If not, see . -# - -TARGET=`uname -s` - -EBUILD_COMPAT=0 - -CFLAGS='-g -O2' -LDFLAGS='-g -Wall -O2' - -PREFIX='/usr/local' -BINDIR='' -ETCDIR='' -MANDIR='' -INSTALLMANPAGE=1 -EXAMPLESDIR='' -INSTALLEXAMPLES=1 - -print_usage() { - echo "configure --help print this" - echo " --target= build target i.e. Linux (default: autodetect)" - echo " --prefix= the installation prefix (default: /usr/local)" - echo " --bindir= the path to the bin directory (default: $PREFIX/bin)" - echo " --sysconfdir= the path to the system configuration directory (default: $PREFIX/etc" - echo " --mandir= the path to the system man pages (default: $PREFIX/share/man)" - echo " --no-manpage dont't install manpage" - echo " --examplesdir= the path to the examples files (default: $PREFIX/share/examples)" - echo " --no-examples dont't install example files" -} - -for arg -do - case $arg in - --target=*) - TARGET=${arg#--target=} - ;; - --prefix=*) - PREFIX=${arg#--prefix=} - ;; - --bindir=*) - BINDIR=${arg#--bindir=} - ;; - --sysconfdir=*) - ETCDIR=${arg#--sysconfdir=} - ;; - --mandir=*) - MANDIR=${arg#--mandir=} - ;; - --no-manpage) - INSTALLMANPAGE=0 - ;; - --examplesdir=*) - EXAMPLESDIR=${arg#--examplesdir=} - ;; - --no-examples) - INSTALLEXAMPLES=0 - ;; - --ebuild-compat) - EBUILD_COMPAT=1 - ;; - --help) - print_usage - exit 0 - ;; - *) - ERRORS="$ERRORS $arg" - ;; - esac -done - -if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then - for error in $ERRORS; do - echo "Unknown argument: $error" - done - - print_usage - exit 1 -fi - -rm -f include.mk -case $TARGET in - Linux) - echo "Linux specific build options" - ;; - OpenBSD|FreeBSD|NetBSD) - echo "BSD specific build options" - CFLAGS=$CFLAGS' -I/usr/local/include' - LDFLAGS=$LDFLAGS' -L/usr/local/lib' - ;; - *) - echo "Plattform not supported" - exit 1; - ;; -esac - -if [ -z "$BINDIR" ]; then - BINDIR=$PREFIX/bin -fi - -if [ -z "$ETCDIR" ]; then - ETCDIR=$PREFIX/etc -fi - -if [ -z "$MANDIR" ]; then - MANDIR=$PREFIX/share/man -fi - -if [ -z "$EXAMPLESDIR" ]; then - EXAMPLESDIR=$PREFIX/share/examples -fi - -cat >> include.mk <> include.mk - echo "installing manpage" -else - echo "not installing manpage" -fi - -if [ $INSTALLEXAMPLES -eq 1 ]; then - echo "EXAMPLESDIR := $EXAMPLESDIR" >> include.mk - echo "installing example files" -else - echo "not installing example files" -fi - -exit 0 diff --git a/daemon.h b/daemon.h deleted file mode 100644 index 22e0ac0..0000000 --- a/daemon.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * uAnytun - * - * uAnytun is a tiny implementation of SATP. Unlike Anytun which is a full - * featured implementation uAnytun has no support for multiple connections - * or synchronisation. It is a small single threaded implementation intended - * to act as a client on small platforms. - * The secure anycast tunneling protocol (satp) defines a protocol used - * for communication between any combination of unicast and anycast - * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel - * mode and allows tunneling of every ETHER TYPE protocol (e.g. - * ethernet, ip, arp ...). satp directly includes cryptography and - * message authentication based on the methodes used by SRTP. It is - * intended to deliver a generic, scaleable and secure solution for - * tunneling and relaying of packets of any protocol. - * - * - * Copyright (C) 2007-2008 Christian Pointner - * - * This file is part of uAnytun. - * - * uAnytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * uAnytun is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with uAnytun. If not, see . - */ - -#ifndef UANYTUN_daemon_h_INCLUDED -#define UANYTUN_daemon_h_INCLUDED - -#include -#include -#include -#include -#include -#include -#include - -struct priv_info_struct { - struct passwd* pw_; - struct group* gr_; -}; -typedef struct priv_info_struct priv_info_t; - -int priv_init(priv_info_t* priv, const char* username, const char* groupname) -{ - if(!priv) - return -1; - - priv->pw_ = NULL; - priv->gr_ = NULL; - - priv->pw_ = getpwnam(username); - if(!priv->pw_) { - log_printf(ERROR, "unkown user %s", username); - return -1; - } - - if(groupname) - priv->gr_ = getgrnam(groupname); - else - priv->gr_ = getgrgid(priv->pw_->pw_gid); - - if(!priv->gr_) { - log_printf(ERROR, "unkown group %s", groupname); - return -1; - } - - return 0; -} - -int priv_drop(priv_info_t* priv) -{ - if(!priv || !priv->pw_ || !priv->gr_) { - log_printf(ERROR, "privileges not initialized properly"); - return -1; - } - - if(setgid(priv->gr_->gr_gid)) { - log_printf(ERROR, "setgid('%s') failed: %s", priv->gr_->gr_name, strerror(errno)); - return -1; - } - - gid_t gr_list[1]; - gr_list[0] = priv->gr_->gr_gid; - if(setgroups (1, gr_list)) { - log_printf(ERROR, "setgroups(['%s']) failed: %s", priv->gr_->gr_name, strerror(errno)); - return -1; - } - - if(setuid(priv->pw_->pw_uid)) { - log_printf(ERROR, "setuid('%s') failed: %s", priv->pw_->pw_name, strerror(errno)); - return -1; - } - - log_printf(NOTICE, "dropped privileges to %s:%s", priv->pw_->pw_name, priv->gr_->gr_name); - return 0; -} - - -int do_chroot(const char* chrootdir) -{ - if(getuid() != 0) { - log_printf(ERROR, "this programm has to be run as root in order to run in a chroot"); - return -1; - } - - if(chroot(chrootdir)) { - log_printf(ERROR, "can't chroot to %s: %s", chrootdir, strerror(errno)); - return -1; - } - log_printf(NOTICE, "we are in chroot jail (%s) now", chrootdir); - if(chdir("/")) { - log_printf(ERROR, "can't change to /: %s", strerror(errno)); - return -1; - } -} - -void daemonize() -{ - pid_t pid; - - pid = fork(); - if(pid < 0) { - log_printf(ERROR, "daemonizing failed at fork(): %s, exitting", strerror(errno)); - exit(-1); - } - if(pid) exit(0); - - umask(0); - - if(setsid() < 0) { - log_printf(ERROR, "daemonizing failed at setsid(): %s, exitting", strerror(errno)); - exit(-1); - } - - pid = fork(); - if(pid < 0) { - log_printf(ERROR, "daemonizing failed at fork(): %s, exitting", strerror(errno)); - exit(-1); - } - if(pid) exit(0); - - if ((chdir("/")) < 0) { - log_printf(ERROR, "daemonizing failed at chdir(): %s, exitting", strerror(errno)); - exit(-1); - } - - int fd; - for (fd=0;fd<=2;fd++) // close all file descriptors - close(fd); - fd = open("/dev/null",O_RDWR); // stdin - if(fd == -1) - log_printf(WARNING, "can't open stdin (chroot and no link to /dev/null?)"); - else { - if(dup(fd) == -1) // stdout - log_printf(WARNING, "can't open stdout"); - if(dup(fd) == -1) // stderr - log_printf(WARNING, "can't open stderr"); - } - umask(027); -} - -#endif - diff --git a/datatypes.h b/datatypes.h deleted file mode 100644 index 1168ec6..0000000 --- a/datatypes.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * rhdropbox - * - * Copyright (C) 2009 Christian Pointner - * - * This file is part of rhdropbox. - * - * rhdropbox is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhdropbox is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with rhdropbox. If not, see . - */ - -#ifndef RHDROPBOX_datatypes_h_INCLUDED -#define RHDROPBOX_datatypes_h_INCLUDED - -#include -#include - -typedef uint8_t u_int8_t; -typedef uint16_t u_int16_t; -typedef uint32_t u_int32_t; -typedef uint64_t u_int64_t; -/* typedef int8_t int8_t; */ -/* typedef int16_t int16_t; */ -/* typedef int32_t int32_t; */ -/* typedef int64_t int64_t; */ - -struct buffer_struct { - u_int32_t length_; - u_int8_t* buf_; -}; -typedef struct buffer_struct buffer_t; - -struct read_buffer_struct { - u_int32_t offset; - u_int8_t buf[1024]; -}; -typedef struct read_buffer_struct read_buffer_t; - -#endif diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 2088a92..0000000 --- a/debian/changelog +++ /dev/null @@ -1,20 +0,0 @@ -rhdropbox (0.2.1-1) unstable; urgency=low - - * ignoring SIG_CHLD and SIG_PIPE by default - * fixed memory error at client handling - - -- Christian Pointner Mon, 4 Oct 2010 17:19:31 +0200 - -rhdropbox (0.2-1) unstable; urgency=low - - * added -d|--dir argument (initial path list at startup) - * added max-child capability - - -- Christian Pointner Tue, 16 Feb 2010 16:10:31 +0100 - -rhdropbox (0.1-1) unstable; urgency=low - - * Initial release - - -- Christian Pointner Mon, 16 Dec 2009 13:22:45 +0100 - diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/debian/control b/debian/control deleted file mode 100644 index 9f3795c..0000000 --- a/debian/control +++ /dev/null @@ -1,17 +0,0 @@ -Source: rhdropbox -Section: misc -Priority: extra -Maintainer: Christian Pointner -Build-Depends: debhelper (>= 5) -Standards-Version: 3.8.3 -Homepage: http://www.helsinki.at/ - -Package: rhdropbox -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, adduser -Description: Radio Helsinki dropbox daemon using inotify - rhdropbox is a small daemon which can be used to watch one or more - directories for new files. When a new file is detected a external program. - Aditional directories can be added to the damons watch list using a simple - unix socket based command interface. - diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 505b039..0000000 --- a/debian/copyright +++ /dev/null @@ -1,28 +0,0 @@ -This package was debianized by Christian Pointner on -Fri, 29 May 2009 11:23:42 +0200. - -Upstream Author: Christian Pointner - -Copyright: 2009-2010 Christian Pointner - -License: - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this package; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL-3'. - -The Debian packaging is © 2009, Christian Pointner and -is licensed under the GPL, see above. diff --git a/debian/postinst b/debian/postinst deleted file mode 100755 index 672dae8..0000000 --- a/debian/postinst +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# postinst script for rhdropbox - -set -e - -if [ -x "/etc/init.d/rhdropbox" ]; then - update-rc.d rhdropbox defaults >/dev/null -fi - - diff --git a/debian/postrm b/debian/postrm deleted file mode 100755 index dc16a9d..0000000 --- a/debian/postrm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# postrm script for rhdropbox - -set -e - -if [ "$1" = "purge" ] ; then - update-rc.d rhdropbox remove >/dev/null || exit $? -fi - diff --git a/debian/prerm b/debian/prerm deleted file mode 100755 index 9ddebb7..0000000 --- a/debian/prerm +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# prerm script for rhdropbox - -set -e - -if [ -x "/etc/init.d/rhdropbox" ] && [ "$1" = remove ]; then - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d rhdropbox stop || true - else - /etc/init.d/rhdropbox stop || true - fi -fi diff --git a/debian/rhdropbox.default b/debian/rhdropbox.default deleted file mode 100644 index c32d348..0000000 --- a/debian/rhdropbox.default +++ /dev/null @@ -1,5 +0,0 @@ -# Defaults for rhdropbox initscript -# sourced by /etc/init.d/rhdropbox - -# Additional options that are passed to the Daemon. -DAEMONOPTS="" diff --git a/debian/rhdropbox.init b/debian/rhdropbox.init deleted file mode 100755 index 429c682..0000000 --- a/debian/rhdropbox.init +++ /dev/null @@ -1,139 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: rhdropbox -# Required-Start: $syslog -# Required-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start radio helsinki dropbox daemon at boot time -# Description: Enables dropboxes -### END INIT INFO -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/bin/rhdropbox -CONFIG_DIR=/etc/rhdropbox -NAME=rhdropbox -DESC=rhdropbox -VARRUN_DIR=/var/run/$NAME - -test -x $DAEMON || exit 0 - -# Include rhdropbox defaults if available -if [ -f /etc/default/rhdropbox ] ; then - . /etc/default/rhdropbox -fi - -start_db () { - STATUS="OK" - if [ -f $CONFIG_DIR/$DBNAME/config ] ; then - NEWFILE='' - test -f $CONFIG_DIR/$DBNAME/newfile.sh && NEWFILE="-x $CONFIG_DIR/$DBNAME/newfile.sh" - CHROOTDIR=`grep '^chroot' < $CONFIG_DIR/$DBNAME/config | sed 's/chroot\s*//'` - if [ -n "$CHROOTDIR" ] ; then - test -d $CHROOTDIR || mkdir -p $CHROOTDIR - fi - test -d $VARRUN_DIR || mkdir -p $VARRUN_DIR - chmod 777 $VARRUN_DIR - DAEMONARG=`sed 's/#.*//' < $CONFIG_DIR/$DBNAME/config | grep -e '\w' | sed 's/^/--/' | tr '\n' ' '` - $DAEMON --write-pid $VARRUN_DIR/$DBNAME.pid $NEWFILE $DAEMONOPTS $DAEMONARG || STATUS="FAILED" - else - STATUS="no config found" - fi - echo -n "($STATUS)" -} - -stop_db () { - kill `cat $PIDFILE` || true - rm $PIDFILE -} - -set -e -case "$1" in - start) - echo -n "Starting $DESC:" - if test -z "$2" ; then - if [ -f $CONFIG_DIR/autostart ] ; then - for DBNAME in `sed 's/#.*//' < $CONFIG_DIR/autostart | grep -e '\w'`; do - echo -n " $DBNAME" - start_db - done - else - echo " no config found" - exit 1; - fi - else - while shift ; do - [ -z "$1" ] && break - DBNAME=$1 - echo -n " $DBNAME" - start_db - done - fi - echo "." - ;; - stop) - echo -n "Stoping $DESC:" - if test -z "$2" ; then - for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do - DBNAME=`echo $PIDFILE | cut -c20-` - DBNAME=${DBNAME%%.pid} - echo -n " $DBNAME" - stop_db - done - else - while shift ; do - [ -z "$1" ] && break - if test -e $VARRUN_DIR/$1.pid ; then - PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null` - DBNAME=`echo $PIDFILE | cut -c20-` - DBNAME=${DBNAME%%.pid} - echo -n " $DBNAME" - stop_db - else - echo -n " (failure: No such tunnel is running: $1)" - fi - done - fi - echo "." - ;; - reload) - echo -n "Reloading $DESC:" - if test -z "$2" ; then - for PIDFILE in `ls $VARRUN_DIR/*.pid 2> /dev/null`; do - DBNAME=`echo $PIDFILE | cut -c20-` - DBNAME=${DBNAME%%.pid} - echo -n " $DBNAME" - stop_db - start_db - done - else - while shift ; do - [ -z "$1" ] && break - if test -e $VARRUN_DIR/$1.pid ; then - PIDFILE=`ls $VARRUN_DIR/$1.pid 2> /dev/null` - DBNAME=`echo $PIDFILE | cut -c20-` - DBNAME=${DBNAME%%.pid} - echo -n " $DBNAME" - stop_db - start_db - else - echo -n " (failure: No such tunnel is running: $1)" - fi - done - fi - echo "." - ;; - restart) - SCRIPT=$0 - shift - $SCRIPT stop $* - sleep 1 - $SCRIPT start $* - ;; - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/rules b/debian/rules deleted file mode 100755 index b0480fc..0000000 --- a/debian/rules +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -configure: configure-stamp -configure-stamp: - dh_testdir - ./configure --prefix=/usr --sysconfdir=/etc --no-manpage --examplesdir=/usr/share/rhdropbox/examples - touch configure-stamp - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - - $(MAKE) - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - $(MAKE) --directory=$(CURDIR) distclean - dh_clean - -install: build - dh_testdir - dh_testroot - dh_installdirs - - # Add here commands to install the package into debian/rhdropbox. - $(MAKE) DESTDIR=$(CURDIR)/debian/rhdropbox install - # Fix unusual path: - mv debian/rhdropbox/usr/share/rhdropbox/examples/rhdropbox debian/rhdropbox/usr/share/rhdropbox/examples/config - echo "example configurations can be found at /usr/share/rhdropbox/examples/config" > debian/rhdropbox/etc/rhdropbox/README - -# Build architecture-independent files here. -binary-indep: install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: install - dh_testdir - dh_testroot - dh_installdocs - dh_installinit - dh_installman doc/rhdropbox.8 - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/log.c b/log.c deleted file mode 100644 index 43a0a5a..0000000 --- a/log.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * uAnytun - * - * uAnytun is a tiny implementation of SATP. Unlike Anytun which is a full - * featured implementation uAnytun has no support for multiple connections - * or synchronisation. It is a small single threaded implementation intended - * to act as a client on small platforms. - * The secure anycast tunneling protocol (satp) defines a protocol used - * for communication between any combination of unicast and anycast - * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel - * mode and allows tunneling of every ETHER TYPE protocol (e.g. - * ethernet, ip, arp ...). satp directly includes cryptography and - * message authentication based on the methodes used by SRTP. It is - * intended to deliver a generic, scaleable and secure solution for - * tunneling and relaying of packets of any protocol. - * - * - * Copyright (C) 2007-2008 Christian Pointner - * - * This file is part of uAnytun. - * - * uAnytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * uAnytun is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with uAnytun. If not, see . - */ - -#include "datatypes.h" - -#include -#include -#include -#include - -#define SYSLOG_NAMES -#include - -#include "log.h" - -log_t stdlog; - -#include "log_targets.h" - -const char* log_prio_to_string(log_prio_t prio) -{ - switch(prio) { - case ERROR: return "ERROR"; - case WARNING: return "WARNING"; - case NOTICE: return "NOTICE"; - case INFO: return "INFO"; - case DEBUG: return "DEBUG"; - } - return "UNKNOWN"; -} - -log_target_type_t log_target_parse_type(const char* conf) -{ - if(!conf) - return TARGET_UNKNOWN; - - if(!strncmp(conf, "syslog", 6)) return TARGET_SYSLOG; - if(!strncmp(conf, "file", 4)) return TARGET_FILE; - if(!strncmp(conf, "stdout", 6)) return TARGET_STDOUT; - if(!strncmp(conf, "stderr", 6)) return TARGET_STDERR; - - return TARGET_UNKNOWN; -} - -int log_targets_target_exists(log_targets_t* targets, log_target_type_t type) -{ - if(!targets && !targets->first_) - return 0; - - log_target_t* tmp = targets->first_; - while(tmp) { - if(tmp->type_ == type) - return 1; - tmp = tmp->next_; - } - return 0; -} - -int log_targets_add(log_targets_t* targets, const char* conf) -{ - if(!targets) - return -1; - - log_target_t* new_target = NULL; - int duplicates_allowed = 0; - switch(log_target_parse_type(conf)) { - case TARGET_SYSLOG: new_target = log_target_syslog_new(); break; - case TARGET_FILE: new_target = log_target_file_new(); duplicates_allowed = 1; break; - case TARGET_STDOUT: new_target = log_target_stdout_new(); break; - case TARGET_STDERR: new_target = log_target_stderr_new(); break; - default: return -3; - } - if(!new_target) - return -2; - - if(!duplicates_allowed && log_targets_target_exists(targets, new_target->type_)) { - free(new_target); - return -4; - } - - const char* prioptr = strchr(conf, ':'); - if(!prioptr || prioptr[1] == 0) { - free(new_target); - return -1; - } - prioptr++; - if(!isdigit(prioptr[0]) || (prioptr[1] != 0 && prioptr[1] != ',')) { - free(new_target); - return -1; - } - new_target->max_prio_ = prioptr[0] - '0'; - if(new_target->max_prio_ > 0) - new_target->enabled_ = 1; - - if(new_target->init != NULL) { - const char* confptr = NULL; - if(prioptr[1] != 0) - confptr = prioptr+2; - - int ret = (*new_target->init)(new_target, confptr); - if(ret) { - free(new_target); - return ret; - } - } - - if(new_target->open != NULL) - (*new_target->open)(new_target); - - - if(!targets->first_) { - targets->first_ = new_target; - } - else { - log_target_t* tmp = targets->first_; - while(tmp->next_) - tmp = tmp->next_; - - tmp->next_ = new_target; - } - return 0; -} - -void log_targets_log(log_targets_t* targets, log_prio_t prio, const char* msg) -{ - if(!targets) - return; - - log_target_t* tmp = targets->first_; - while(tmp) { - if(tmp->log != NULL && tmp->enabled_ && tmp->max_prio_ >= prio) - (*tmp->log)(tmp, prio, msg); - - tmp = tmp->next_; - } -} - -void log_targets_clear(log_targets_t* targets) -{ - if(!targets) - return; - - while(targets->first_) { - log_target_t* tmp = targets->first_; - targets->first_ = tmp->next_; - if(tmp->close != NULL) - (*tmp->close)(tmp); - if(tmp->clear != NULL) - (*tmp->clear)(tmp); - free(tmp); - } -} - - -void log_init() -{ - stdlog.max_prio_ = 0; - stdlog.targets_.first_ = NULL; -} - -void log_close() -{ - log_targets_clear(&stdlog.targets_); -} - -void update_max_prio() -{ - log_target_t* tmp = stdlog.targets_.first_; - while(tmp) { - if(tmp->enabled_ && tmp->max_prio_ > stdlog.max_prio_) - stdlog.max_prio_ = tmp->max_prio_; - - tmp = tmp->next_; - } -} - -int log_add_target(const char* conf) -{ - if(!conf) - return -1; - - int ret = log_targets_add(&stdlog.targets_, conf); - if(!ret) update_max_prio(); - return ret; -} - -void log_printf(log_prio_t prio, const char* fmt, ...) -{ - if(stdlog.max_prio_ < prio) - return; - - static char msg[MSG_LENGTH_MAX]; - va_list args; - - va_start(args, fmt); - vsnprintf(msg, MSG_LENGTH_MAX, fmt, args); - va_end(args); - - log_targets_log(&stdlog.targets_, prio, msg); -} - -void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len) -{ - if(stdlog.max_prio_ < prio) - return; - - static char msg[MSG_LENGTH_MAX]; - - if(!buf) { - snprintf(msg, MSG_LENGTH_MAX, "(NULL)"); - } - else { - u_int32_t i; - int offset = snprintf(msg, MSG_LENGTH_MAX, "dump(%d): ", len); - if(offset < 0) - return; - u_int8_t* ptr = &msg[offset]; - - for(i=0; i < len; i++) { - if(((i+1)*3) >= (MSG_LENGTH_MAX - offset)) - break; - snprintf(ptr, 3, "%02X ", buf[i]); - ptr+=3; - } - } - log_targets_log(&stdlog.targets_, prio, msg); -} diff --git a/log.h b/log.h deleted file mode 100644 index 2717622..0000000 --- a/log.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * uAnytun - * - * uAnytun is a tiny implementation of SATP. Unlike Anytun which is a full - * featured implementation uAnytun has no support for multiple connections - * or synchronisation. It is a small single threaded implementation intended - * to act as a client on small platforms. - * The secure anycast tunneling protocol (satp) defines a protocol used - * for communication between any combination of unicast and anycast - * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel - * mode and allows tunneling of every ETHER TYPE protocol (e.g. - * ethernet, ip, arp ...). satp directly includes cryptography and - * message authentication based on the methodes used by SRTP. It is - * intended to deliver a generic, scaleable and secure solution for - * tunneling and relaying of packets of any protocol. - * - * - * Copyright (C) 2007-2008 Christian Pointner - * - * This file is part of uAnytun. - * - * uAnytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * uAnytun is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with uAnytun. If not, see . - */ - -#ifndef UANYTUN_log_h_INCLUDED -#define UANYTUN_log_h_INCLUDED - -#define MSG_LENGTH_MAX 150 - -enum log_prio_enum { ERROR = 1, WARNING = 2, NOTICE = 3, - INFO = 4, DEBUG = 5 }; -typedef enum log_prio_enum log_prio_t; - -const char* log_prio_to_string(log_prio_t prio); - -enum log_target_type_enum { TARGET_SYSLOG , TARGET_STDOUT, TARGET_STDERR, TARGET_FILE , TARGET_UNKNOWN }; -typedef enum log_target_type_enum log_target_type_t; - -struct log_target_struct { - log_target_type_t type_; - int (*init)(struct log_target_struct* self, const char* conf); - void (*open)(struct log_target_struct* self); - void (*log)(struct log_target_struct* self, log_prio_t prio, const char* msg); - void (*close)(struct log_target_struct* self); - void (*clear)(struct log_target_struct* self); - int opened_; - int enabled_; - log_prio_t max_prio_; - void* param_; - struct log_target_struct* next_; -}; -typedef struct log_target_struct log_target_t; - - -struct log_targets_struct { - log_target_t* first_; -}; -typedef struct log_targets_struct log_targets_t; - -int log_targets_target_exists(log_targets_t* targets, log_target_type_t type); -int log_targets_add(log_targets_t* targets, const char* conf); -void log_targets_log(log_targets_t* targets, log_prio_t prio, const char* msg); -void log_targets_clear(log_targets_t* targets); - - -struct log_struct { - log_prio_t max_prio_; - log_targets_t targets_; -}; -typedef struct log_struct log_t; - -void log_init(); -void log_close(); -void update_max_prio(); -int log_add_target(const char* conf); -void log_printf(log_prio_t prio, const char* fmt, ...); -void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len); - -#endif diff --git a/log_targets.h b/log_targets.h deleted file mode 100644 index 8db3812..0000000 --- a/log_targets.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * uAnytun - * - * uAnytun is a tiny implementation of SATP. Unlike Anytun which is a full - * featured implementation uAnytun has no support for multiple connections - * or synchronisation. It is a small single threaded implementation intended - * to act as a client on small platforms. - * The secure anycast tunneling protocol (satp) defines a protocol used - * for communication between any combination of unicast and anycast - * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel - * mode and allows tunneling of every ETHER TYPE protocol (e.g. - * ethernet, ip, arp ...). satp directly includes cryptography and - * message authentication based on the methodes used by SRTP. It is - * intended to deliver a generic, scaleable and secure solution for - * tunneling and relaying of packets of any protocol. - * - * - * Copyright (C) 2007-2008 Christian Pointner - * - * This file is part of uAnytun. - * - * uAnytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * uAnytun is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with uAnytun. If not, see . - */ - -#ifndef UANYTUN_log_targets_h_INCLUDED -#define UANYTUN_log_targets_h_INCLUDED - -#include - -static char* get_time_formatted() -{ - char* time_string; - time_t t = time(NULL); - if(t < 0) - time_string = "