summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-09-16 22:23:07 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-09-16 22:23:07 +0200
commitf821dd3b4fda69f82ebefd2684b7d7c893340918 (patch)
tree62f037ca8fa3816858e07dd61712ac57f7ff423c /src
parentremoved debian dir (diff)
renamed rhdropbox to dropnroll
added support for clang some fixes for Wall
Diffstat (limited to 'src')
-rw-r--r--src/Makefile22
-rw-r--r--src/client_list.c23
-rw-r--r--src/client_list.h16
-rwxr-xr-xsrc/configure33
-rw-r--r--src/daemon.h39
-rw-r--r--src/datatypes.h16
-rw-r--r--src/dropnroll.c (renamed from src/rhdropbox.c)76
-rw-r--r--src/log.c35
-rw-r--r--src/log.h30
-rw-r--r--src/log_targets.h46
-rw-r--r--src/options.c26
-rw-r--r--src/options.h16
-rw-r--r--src/sig_handler.c27
-rw-r--r--src/sig_handler.h30
-rw-r--r--src/string_list.c30
-rw-r--r--src/string_list.h30
-rw-r--r--src/sysexec.c51
-rw-r--r--src/sysexec.h16
-rw-r--r--src/utils.c48
-rw-r--r--src/utils.h17
-rw-r--r--src/watch_list.c30
-rw-r--r--src/watch_list.h16
22 files changed, 291 insertions, 382 deletions
diff --git a/src/Makefile b/src/Makefile
index 15670ce..77619cf 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,29 +1,29 @@
##
-## rhdropbox
+## dropnroll
##
-## Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+## Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
##
-## This file is part of rhdropbox.
+## This file is part of dropnroll.
##
-## rhdropbox is free software: you can redistribute it and/or modify
+## dropnroll 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,
+## dropnroll 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 <http://www.gnu.org/licenses/>.
+## along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
##
ifneq ($(MAKECMDGOALS),distclean)
include include.mk
endif
-EXECUTABLE := rhdropbox
+EXECUTABLE := dropnroll
OBJ := log.o \
sig_handler.o \
@@ -33,7 +33,7 @@ OBJ := log.o \
watch_list.o \
options.o \
sysexec.o \
- rhdropbox.o
+ dropnroll.o
SRC := $(OBJ:%.o=%.c)
@@ -101,12 +101,12 @@ install-etc:
install-man: manpage
$(INSTALL) -d $(DESTDIR)$(MANDIR)/man8/
- $(INSTALL) -m 644 ../doc/rhdropbox.8 $(DESTDIR)$(MANDIR)/man8/$(EXECUTABLE).8
+ $(INSTALL) -m 644 ../doc/dropnroll.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/' ; \
+ $(INSTALL) -m 644 etc/dropnroll/autostart $(DESTDIR)$(EXAMPLESDIR)/$(EXECUTABLE)/autostart
+ @( cd 'etc/dropnroll/' ; \
for dir in `ls`; do \
if [ -d $$dir ]; then \
echo "install $$dir configuration" ; \
diff --git a/src/client_list.c b/src/client_list.c
index 8379dd9..55e0044 100644
--- a/src/client_list.c
+++ b/src/client_list.c
@@ -1,32 +1,33 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
+#include <unistd.h>
#include "client_list.h"
#include "datatypes.h"
client_t* client_get_last(client_t* first)
{
- if(!first)
+ if(!first)
return NULL;
while(first->next) {
@@ -55,7 +56,7 @@ int client_add(client_t** first, int fd)
*first = new_client;
return 0;
}
-
+
client_get_last(*first)->next = new_client;
return 0;
@@ -63,7 +64,7 @@ int client_add(client_t** first, int fd)
void client_remove(client_t** first, int fd)
{
- if(!first || !(*first))
+ if(!first || !(*first))
return;
client_t* deletee = *first;
@@ -92,7 +93,7 @@ client_t* client_find(client_t* first, int fd)
{
if(!first)
return NULL;
-
+
while(first) {
if(first->fd == fd)
return first;
@@ -104,7 +105,7 @@ client_t* client_find(client_t* first, int fd)
void client_clear(client_t** first)
{
- if(!first || !(*first))
+ if(!first || !(*first))
return;
while(*first) {
diff --git a/src/client_list.h b/src/client_list.h
index 5cc34ae..dd322de 100644
--- a/src/client_list.h
+++ b/src/client_list.h
@@ -1,26 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RHDROPBOX_client_list_h_INCLUDED
-#define RHDROPBOX_client_list_h_INCLUDED
+#ifndef DROPNROLL_client_list_h_INCLUDED
+#define DROPNROLL_client_list_h_INCLUDED
#include "datatypes.h"
diff --git a/src/configure b/src/configure
index 4b93d79..b90061f 100755
--- a/src/configure
+++ b/src/configure
@@ -1,30 +1,31 @@
#!/bin/sh
#
#
-# rhdropbox
+# dropnroll
#
-# Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+# Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
#
-# This file is part of rhdropbox.
+# This file is part of dropnroll.
#
-# rhdropbox is free software: you can redistribute it and/or modify
+# dropnroll 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,
+# dropnroll 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 <http://www.gnu.org/licenses/>.
+# along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
#
TARGET=`uname -s`
-
EBUILD_COMPAT=0
+USE_CLANG=0
+
CFLAGS='-g -O2'
LDFLAGS='-g -Wall -O2'
@@ -54,6 +55,9 @@ do
--target=*)
TARGET=${arg#--target=}
;;
+ --use-clang)
+ USE_CLANG=1
+ ;;
--prefix=*)
PREFIX=${arg#--prefix=}
;;
@@ -97,6 +101,17 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
exit 1
fi
+if [ $USE_CLANG -eq 0 ]; then
+ CFLAGS='-g -Wall -O2'
+ LDFLAGS='-g -Wall -O2'
+ COMPILER='gcc'
+else
+ CFLAGS='-g -O2'
+ LDFLAGS='-g -O2'
+ COMPILER='clang'
+fi
+
+rm -f version.h
rm -f include.mk
case $TARGET in
Linux)
@@ -129,13 +144,13 @@ if [ -z "$EXAMPLESDIR" ]; then
EXAMPLESDIR=$PREFIX/share/examples
fi
-cat >> include.mk <<EOF
+cat > include.mk <<EOF
# this file was created automatically
# do not edit this file directly
# use ./configure instead
TARGET := $TARGET
-CC := gcc
+CC := $COMPILER
CFLAGS := $CFLAGS
LDFLAGS := $LDFLAGS
INSTALL := install
diff --git a/src/daemon.h b/src/daemon.h
index 22e0ac0..5daa62b 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -1,40 +1,26 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UANYTUN_daemon_h_INCLUDED
-#define UANYTUN_daemon_h_INCLUDED
+#ifndef DROPNROLL_daemon_h_INCLUDED
+#define DROPNROLL_daemon_h_INCLUDED
#include <poll.h>
#include <fcntl.h>
@@ -60,7 +46,7 @@ int priv_init(priv_info_t* priv, const char* username, const char* groupname)
priv->pw_ = getpwnam(username);
if(!priv->pw_) {
- log_printf(ERROR, "unkown user %s", username);
+ log_printf(ERROR, "unknown user %s", username);
return -1;
}
@@ -70,7 +56,7 @@ int priv_init(priv_info_t* priv, const char* username, const char* groupname)
priv->gr_ = getgrgid(priv->pw_->pw_gid);
if(!priv->gr_) {
- log_printf(ERROR, "unkown group %s", groupname);
+ log_printf(ERROR, "unknown group %s", groupname);
return -1;
}
@@ -109,7 +95,7 @@ int priv_drop(priv_info_t* priv)
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");
+ log_printf(ERROR, "this program has to be run as root in order to run in a chroot");
return -1;
}
@@ -122,6 +108,8 @@ int do_chroot(const char* chrootdir)
log_printf(ERROR, "can't change to /: %s", strerror(errno));
return -1;
}
+
+ return 0;
}
void daemonize()
@@ -170,4 +158,3 @@ void daemonize()
}
#endif
-
diff --git a/src/datatypes.h b/src/datatypes.h
index 1168ec6..3220758 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -1,26 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RHDROPBOX_datatypes_h_INCLUDED
-#define RHDROPBOX_datatypes_h_INCLUDED
+#ifndef DROPNROLL_datatypes_h_INCLUDED
+#define DROPNROLL_datatypes_h_INCLUDED
#include <stdint.h>
#include <arpa/inet.h>
diff --git a/src/rhdropbox.c b/src/dropnroll.c
index 3503fd2..f629414 100644
--- a/src/rhdropbox.c
+++ b/src/dropnroll.c
@@ -1,24 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
+#define _GNU_SOURCE
+
#include "datatypes.h"
#include <stdlib.h>
@@ -87,7 +89,7 @@ int process_watch(int inotify_fd, read_buffer_t* buffer, watch_list_t* watch_lst
u_int32_t len = sizeof(struct inotify_event) + event->len;
if(buffer->offset >= len) {
char* path = watch_list_find_path(watch_lst, event->wd);
- log_printf(DEBUG, "received event for %d (mask=0x%08X, cookie=0x%08X name[%u]='%s')",
+ log_printf(DEBUG, "received event for %d (mask=0x%08X, cookie=0x%08X name[%u]='%s')",
event->wd, event->mask, event->cookie, event->len, event->len > 0 ? event->name : "");
if(event->mask & IN_DELETE_SELF || event->mask & IN_MOVE_SELF) {
@@ -187,7 +189,7 @@ void process_cmd_add_remove(cmd_id_t cmd_id, const char* path, int fd, int inoti
else {
log_printf(DEBUG, "cmd_add_remove: path already in watch list");
return;
- }
+ }
}
else if(cmd_id == REMOVE) {
if(tmp_fd >= 0)
@@ -209,7 +211,7 @@ void process_cmd_add_remove(cmd_id_t cmd_id, const char* path, int fd, int inoti
send_response(fd, "Error: add/remove failed");
return;
}
-
+
int ret = 0;
if(cmd_id == ADD) {
ret = watch_list_add(watch_lst, wd, path);
@@ -222,7 +224,7 @@ void process_cmd_add_remove(cmd_id_t cmd_id, const char* path, int fd, int inoti
else {
watch_list_rm(watch_lst, path);
}
-
+
if(!ret) {
send_status_watch_list(-1, watch_lst, client_lst);
log_printf(NOTICE, "inotify %s '%s'", cmd_id == ADD ? "added" : "removed", path);
@@ -272,7 +274,7 @@ int process_cmd(const char* cmd, int fd, int inotify_fd, watch_list_t* watch_lst
if(!cmd)
return -1;
-
+
cmd_id_t cmd_id;
if(!strncmp(cmd, "add", 3))
cmd_id = ADD;
@@ -291,13 +293,13 @@ int process_cmd(const char* cmd, int fd, int inotify_fd, watch_list_t* watch_lst
return 0;
}
char* param = strchr(cmd, ' ');
- if(param)
+ if(param)
param++;
if(cmd_id == ADD || cmd_id == REMOVE) {
char* resp;
- asprintf(&resp, "Request: %s", cmd);
- if(resp) {
+ int len = asprintf(&resp, "Request: %s", cmd);
+ if(len != -1) {
char* linefeed = strchr(resp, '\n');
if(linefeed) linefeed[0] = 0;
client_t* client;
@@ -314,22 +316,52 @@ int process_cmd(const char* cmd, int fd, int inotify_fd, watch_list_t* watch_lst
}
switch(cmd_id) {
- case ADD:
+ case ADD:
case REMOVE: process_cmd_add_remove(cmd_id, param, fd, inotify_fd, watch_lst, client_lst); break;
case STATUS: process_cmd_status(fd, watch_lst, client_lst); break;
case LOG: {
if(param && param[0])
- log_printf(NOTICE, "ext msg: %s", param);
+ log_printf(NOTICE, "ext msg: %s", param);
else
log_printf(DEBUG, "ignoring empty ext log message");
break;
}
case LISTEN: process_cmd_listen(param, fd, client_lst); break;
}
-
+
return 0;
}
+int nonblock_recvline(read_buffer_t* buffer, int fd, int inotify_fd, watch_list_t* watch_lst, client_t* client_lst, options_t* opt)
+{
+ int ret = 0;
+ for(;;) {
+ ret = recv(fd, &buffer->buf[buffer->offset], 1, 0);
+ if(!ret)
+ return 2;
+ if(ret == -1 && errno == EAGAIN)
+ return 0;
+ else if(ret < 0)
+ return 2;
+
+ if(buffer->buf[buffer->offset] == '\n') {
+ buffer->buf[buffer->offset] = 0;
+ ret = process_cmd((char*)(buffer->buf), fd, inotify_fd, watch_lst, client_lst, opt);
+ buffer->offset = 0;
+ break;
+ }
+
+ buffer->offset++;
+ if(buffer->offset >= sizeof(buffer->buf)) {
+ log_printf(DEBUG, "string too long (fd=%d)", fd);
+ buffer->offset = 0;
+ return 0;
+ }
+ }
+
+ return ret;
+}
+
int main_loop(int cmd_listen_fd, int inotify_fd, options_t* opt)
{
log_printf(NOTICE, "entering main loop");
@@ -386,7 +418,7 @@ int main_loop(int cmd_listen_fd, int inotify_fd, options_t* opt)
break;
}
}
-
+
if(FD_ISSET(inotify_fd, &tmpfds)) {
return_value = process_watch(inotify_fd, &event_buffer, &watch_lst, opt, client_lst, &child_lst);
if(return_value)
@@ -399,7 +431,7 @@ int main_loop(int cmd_listen_fd, int inotify_fd, options_t* opt)
log_printf(ERROR, "accept returned with error: %s", strerror(errno));
return_value = -1;
break;
- }
+ }
log_printf(DEBUG, "new command connection (fd=%d)", new_fd);
FD_SET(new_fd, &readfds);
max_fd = (max_fd < new_fd) ? new_fd : max_fd;
@@ -461,7 +493,7 @@ int main(int argc, char* argv[])
}
string_list_element_t* tmp = opt.log_targets_.first_;
if(!tmp) {
- log_add_target("syslog:3,rhdropbox,daemon");
+ log_add_target("syslog:3,dropnroll,daemon");
}
else {
while(tmp) {
@@ -473,7 +505,7 @@ int main(int argc, char* argv[])
case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", tmp->string_); break;
default: fprintf(stderr, "syntax error near: '%s', exitting\n", tmp->string_); break;
}
-
+
options_clear(&opt);
log_close();
exit(ret);
@@ -542,7 +574,7 @@ int main(int argc, char* argv[])
options_clear(&opt);
log_close();
exit(-1);
- }
+ }
ret = main_loop(cmd_listen_fd, inotify_fd, &opt);
diff --git a/src/log.c b/src/log.c
index 43a0a5a..86eb266 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,40 +1,27 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include "datatypes.h"
+#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -84,7 +71,7 @@ int log_targets_target_exists(log_targets_t* targets, log_target_type_t type)
if(tmp->type_ == type)
return 1;
tmp = tmp->next_;
- }
+ }
return 0;
}
@@ -147,7 +134,7 @@ int log_targets_add(log_targets_t* targets, const char* conf)
log_target_t* tmp = targets->first_;
while(tmp->next_)
tmp = tmp->next_;
-
+
tmp->next_ = new_target;
}
return 0;
@@ -246,8 +233,8 @@ void log_print_hex_dump(log_prio_t prio, const u_int8_t* buf, u_int32_t len)
int offset = snprintf(msg, MSG_LENGTH_MAX, "dump(%d): ", len);
if(offset < 0)
return;
- u_int8_t* ptr = &msg[offset];
-
+ char* ptr = &msg[offset];
+
for(i=0; i < len; i++) {
if(((i+1)*3) >= (MSG_LENGTH_MAX - offset))
break;
diff --git a/src/log.h b/src/log.h
index 2717622..bba0406 100644
--- a/src/log.h
+++ b/src/log.h
@@ -1,40 +1,26 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UANYTUN_log_h_INCLUDED
-#define UANYTUN_log_h_INCLUDED
+#ifndef DROPNROLL_log_h_INCLUDED
+#define DROPNROLL_log_h_INCLUDED
#define MSG_LENGTH_MAX 150
diff --git a/src/log_targets.h b/src/log_targets.h
index 8db3812..4ee2d73 100644
--- a/src/log_targets.h
+++ b/src/log_targets.h
@@ -1,40 +1,26 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UANYTUN_log_targets_h_INCLUDED
-#define UANYTUN_log_targets_h_INCLUDED
+#ifndef DROPNROLL_log_targets_h_INCLUDED
+#define DROPNROLL_log_targets_h_INCLUDED
#include <time.h>
@@ -42,7 +28,7 @@ static char* get_time_formatted()
{
char* time_string;
time_t t = time(NULL);
- if(t < 0)
+ if(t < 0)
time_string = "<time read error>";
else {
time_string = ctime(&t);
@@ -79,7 +65,7 @@ int log_target_syslog_init(log_target_t* self, const char* conf)
{
if(!self || (conf && conf[0] == 0))
return -1;
-
+
self->param_ = malloc(sizeof(log_target_syslog_param_t));
if(!self->param_)
return -2;
@@ -95,7 +81,7 @@ int log_target_syslog_init(log_target_t* self, const char* conf)
if(!len) {
free(self->param_);
return -1;
- }
+ }
logname = malloc(len+1);
if(logname) {
strncpy(logname, conf, len);
@@ -116,13 +102,13 @@ int log_target_syslog_init(log_target_t* self, const char* conf)
((log_target_syslog_param_t*)(self->param_))->facility_ = DAEMON;
return 0;
}
-
+
if(end[1] == 0 || end[1] == ',') {
free(logname);
free(self->param_);
return -1;
}
-
+
const char* start = end + 1;
end = strchr(start, ',');
int i;
@@ -157,7 +143,7 @@ void log_target_syslog_log(log_target_t* self, log_prio_t prio, const char* msg)
if(!self || !self->param_ || !self->opened_)
return;
- syslog((prio + 2) | ((log_target_syslog_param_t*)(self->param_))->facility_, "%s", msg);
+ syslog((prio + 2) | ((log_target_syslog_param_t*)(self->param_))->facility_, "%s", msg);
}
void log_target_syslog_close(log_target_t* self)
@@ -209,7 +195,7 @@ int log_target_file_init(log_target_t* self, const char* conf)
{
if(!self || (conf && conf[0] == 0))
return -1;
-
+
self->param_ = malloc(sizeof(log_target_file_param_t));
if(!self->param_)
return -2;
@@ -224,7 +210,7 @@ int log_target_file_init(log_target_t* self, const char* conf)
if(!len) {
free(self->param_);
return -1;
- }
+ }
logfilename = malloc(len+1);
if(logfilename) {
strncpy(logfilename, conf, len);
diff --git a/src/options.c b/src/options.c
index 6298f9d..f74445b 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1,22 +1,22 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include "datatypes.h"
@@ -119,9 +119,9 @@ int options_parse_hex_string(const char* hex, buffer_t* buffer)
if(hex_len%2)
return 1;
- if(buffer->buf_)
+ if(buffer->buf_)
free(buffer->buf_);
-
+
buffer->length_ = hex_len/2;
buffer->buf_ = malloc(buffer->length_);
if(!buffer->buf_) {
@@ -176,7 +176,7 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_STRING_PARAM("-x","--script", opt->script_)
PARSE_INT_PARAM("-m","--max-children", opt->max_children_)
PARSE_STRING_LIST("-d","--dir", opt->dirs_)
- else
+ else
return i;
}
@@ -204,7 +204,7 @@ void options_default(options_t* opt)
if(!opt)
return;
- opt->progname_ = strdup("rhdropbox");
+ opt->progname_ = strdup("dropnroll");
opt->daemonize_ = 1;
opt->username_ = NULL;
@@ -213,7 +213,7 @@ void options_default(options_t* opt)
opt->pid_file_ = NULL;
string_list_init(&opt->log_targets_);
- opt->command_sock_ = strdup("/var/run/rhdropbox/cmd.sock");
+ opt->command_sock_ = strdup("/var/run/dropnroll/cmd.sock");
opt->script_ = strdup("newfile.sh");
opt->max_children_ = 8;
string_list_init(&opt->dirs_);
@@ -246,7 +246,7 @@ void options_clear(options_t* opt)
void options_print_usage()
{
printf("USAGE:\n");
- printf("rhdropbox\n");
+ printf("dropnroll\n");
printf(" [-h|--help] prints this...\n");
printf(" [-D|--nodaemonize] don't run in background\n");
printf(" [-u|--username] <username> change to this user\n");
@@ -255,7 +255,7 @@ void options_print_usage()
printf(" [-P|--write-pid] <path> write pid to this file\n");
printf(" [-L|--log] <target>:<level>[,<param1>[,<param2>..]]\n");
printf(" add a log target, can be invoked several times\n");
- printf(" [-s|--command-sock] <unix sock> the command socket e.g. /var/run/rhdropbox/cmd.sock\n");
+ printf(" [-s|--command-sock] <unix sock> the command socket e.g. /var/run/dropnroll/cmd.sock\n");
printf(" [-x|--script] <script> the command socket e.g. newfile.sh\n");
printf(" [-m|--max-children] <#of children> limit of children to be started e.g. 8\n");
printf(" [-d|--dir] <path> add a path to the watch list, can be invoked several times\n");
diff --git a/src/options.h b/src/options.h
index e98655b..d98983a 100644
--- a/src/options.h
+++ b/src/options.h
@@ -1,26 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RHDROPBOX_options_h_INCLUDED
-#define RHDROPBOX_options_h_INCLUDED
+#ifndef DROPNROLL_options_h_INCLUDED
+#define DROPNROLL_options_h_INCLUDED
#include "string_list.h"
diff --git a/src/sig_handler.c b/src/sig_handler.c
index efb6ee6..9e9e3e7 100644
--- a/src/sig_handler.c
+++ b/src/sig_handler.c
@@ -1,36 +1,22 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include "datatypes.h"
@@ -41,6 +27,7 @@
#include <fcntl.h>
#include <sys/select.h>
#include <errno.h>
+#include <string.h>
#include "sig_handler.h"
diff --git a/src/sig_handler.h b/src/sig_handler.h
index 1995e1a..6ea5cc1 100644
--- a/src/sig_handler.h
+++ b/src/sig_handler.h
@@ -1,40 +1,26 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UANYTUN_sig_handler_h_INCLUDED
-#define UANYTUN_sig_handler_h_INCLUDED
+#ifndef DROPNROLL_sig_handler_h_INCLUDED
+#define DROPNROLL_sig_handler_h_INCLUDED
int signal_init();
int signal_handle();
diff --git a/src/string_list.c b/src/string_list.c
index a4f4ab8..d8e5dbb 100644
--- a/src/string_list.c
+++ b/src/string_list.c
@@ -1,36 +1,22 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
@@ -43,7 +29,7 @@ void string_list_init(string_list_t* list)
{
if(!list)
return;
-
+
list->first_ = NULL;
}
@@ -104,7 +90,7 @@ void string_list_print(string_list_t* list, const char* head, const char* tail)
{
if(!list)
return;
-
+
string_list_element_t* tmp = list->first_;
while(tmp) {
printf("%s%s%s", head, tmp->string_, tail);
diff --git a/src/string_list.h b/src/string_list.h
index cd054cb..d33cf5f 100644
--- a/src/string_list.h
+++ b/src/string_list.h
@@ -1,40 +1,26 @@
/*
- * uAnytun
+ * dropnroll
*
- * 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) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * Copyright (C) 2007-2008 Christian Pointner <equinox@anytun.org>
+ * This file is part of dropnroll.
*
- * This file is part of uAnytun.
- *
- * uAnytun is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef UANYTUN_string_list_h_INCLUDED
-#define UANYTUN_string_list_h_INCLUDED
+#ifndef DROPNROLL_string_list_h_INCLUDED
+#define DROPNROLL_string_list_h_INCLUDED
struct string_list_element_struct {
char* string_;
diff --git a/src/sysexec.c b/src/sysexec.c
index 79f4e74..abfd6f8 100644
--- a/src/sysexec.c
+++ b/src/sysexec.c
@@ -1,26 +1,27 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include "datatypes.h"
+#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -49,12 +50,12 @@ char** dup_ptrptr(char* const ptrptr[])
int i;
for(i = 0; i < n; ++i) {
- my_ptrptr[i] = strdup(ptrptr[i]);
+ my_ptrptr[i] = strdup(ptrptr[i]);
if(!my_ptrptr[i]) {
i--;
for(; i >= 0; --i)
free(my_ptrptr[i]);
-
+
free(my_ptrptr);
return NULL;
}
@@ -73,7 +74,7 @@ void free_ptrptr(char** ptrptr)
int i;
for(i = 0; ptrptr[i]; ++i)
free(ptrptr[i]);
-
+
free(ptrptr);
}
@@ -81,7 +82,7 @@ void child_list_init(child_list_t* list)
{
if(!list)
return;
-
+
list->first_ = NULL;
}
@@ -107,7 +108,7 @@ child_list_element_t* child_list_new(const char* script, char* const argv[], cha
new_child = malloc(sizeof(child_list_element_t));
if(!new_child)
return NULL;
-
+
new_child->next_ = 0;
new_child->pid_ = -1;
new_child->err_fd_ = -1;
@@ -117,15 +118,15 @@ child_list_element_t* child_list_new(const char* script, char* const argv[], cha
free(new_child);
return NULL;
}
-
+
new_child->argv_ = dup_ptrptr(argv);
if(!new_child->argv_) {
free(new_child->script_);
free(new_child);
return NULL;
-
+
}
-
+
new_child->evp_ = dup_ptrptr(evp);
if(!new_child->evp_) {
free_ptrptr(new_child->argv_);
@@ -190,12 +191,12 @@ void child_list_rm_pid(child_list_t* list, pid_t pid)
{
if(!list)
return;
-
+
child_list_element_t* tmp = NULL;
if(list->first_->pid_ == pid) {
tmp = list->first_;
list->first_ = list->first_->next_;
-
+
free_ptrptr(tmp->argv_);
free_ptrptr(tmp->evp_);
if(tmp->script_)
@@ -215,7 +216,7 @@ void child_list_rm_pid(child_list_t* list, pid_t pid)
if(tmp->script_)
free(tmp->script_);
free(tmp);
- return;
+ return;
}
prev = tmp;
tmp = tmp->next_;
@@ -226,14 +227,14 @@ child_list_element_t* child_list_find(child_list_t* list, pid_t pid)
{
if(!list)
return NULL;
-
+
child_list_element_t* tmp = list->first_;
while(tmp) {
if(tmp->pid_ == pid)
return tmp;
tmp = tmp->next_;
}
-
+
return NULL;
}
@@ -243,11 +244,11 @@ int child_list_num_running(child_list_t* list)
if(!list)
return 0;
-
+
child_list_element_t* tmp = list->first_;
for(;tmp;tmp=tmp->next_)
if(tmp->running_) num++;
-
+
return num;
}
@@ -305,10 +306,11 @@ int rh_exec_child(child_list_element_t* child)
log_printf(WARNING, "can't open stderr");
}
execve(child->script_, child->argv_, child->evp_);
- // if execve returns, an error occurred, but logging doesn't work
+ // if execve returns, an error occurred, but logging doesn't work
// because we closed all file descriptors, so just write errno to
// pipe and call exit
- write(pipefd[1], (void*)(&errno), sizeof(errno));
+ int ret = write(pipefd[1], (void*)(&errno), sizeof(errno));
+ if(ret == -1) exit(-1);
exit(-1);
}
close(pipefd[1]);
@@ -365,7 +367,6 @@ int rh_waitpid(child_list_t* child_lst, options_t* opt)
if(child_list_num_running(child_lst) < opt->max_children_)
rh_exec_child(child_list_find(child_lst, -1));
-
+
return status;
}
-
diff --git a/src/sysexec.h b/src/sysexec.h
index 8954622..67dbda2 100644
--- a/src/sysexec.h
+++ b/src/sysexec.h
@@ -1,26 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RHDROPBOX_sysexec_h_INCLUDED
-#define RHDROPBOX_sysexec_h_INCLUDED
+#ifndef DROPNROLL_sysexec_h_INCLUDED
+#define DROPNROLL_sysexec_h_INCLUDED
#include <sys/types.h>
#include "options.h"
diff --git a/src/utils.c b/src/utils.c
index a61ca1c..ed3eea5 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,22 +1,22 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include "datatypes.h"
@@ -53,7 +53,7 @@ int init_command_socket(const char* path)
log_printf(ERROR, "unable to bind to '%s': %s", local.sun_path, strerror(errno));
return -1;
}
-
+
ret = listen(fd, 4);
if(ret) {
log_printf(ERROR, "unable to listen on command socket: %s", local.sun_path, strerror(errno));
@@ -61,7 +61,7 @@ int init_command_socket(const char* path)
}
log_printf(INFO, "now listening on %s for incoming commands", path);
-
+
return fd;
}
@@ -111,36 +111,6 @@ int send_string(int fd, const char* string)
return ret;
}
-int nonblock_recvline(read_buffer_t* buffer, int fd, int inotify_fd, watch_list_t* watch_lst, client_t* client_lst, options_t* opt)
-{
- int ret = 0;
- for(;;) {
- ret = recv(fd, &buffer->buf[buffer->offset], 1, 0);
- if(!ret)
- return 2;
- if(ret == -1 && errno == EAGAIN)
- return 0;
- else if(ret < 0)
- return 2;
-
- if(buffer->buf[buffer->offset] == '\n') {
- buffer->buf[buffer->offset] = 0;
- ret = process_cmd(buffer->buf, fd, inotify_fd, watch_lst, client_lst, opt);
- buffer->offset = 0;
- break;
- }
-
- buffer->offset++;
- if(buffer->offset >= sizeof(buffer->buf)) {
- log_printf(DEBUG, "string too long (fd=%d)", fd);
- buffer->offset = 0;
- return 0;
- }
- }
-
- return ret;
-}
-
int create_inotify()
{
int fd = inotify_init();
@@ -148,7 +118,7 @@ int create_inotify()
log_printf(ERROR, "error at inotify_init: %s", strerror(errno));
return -1;
}
-
+
int fs_flags = fcntl(fd, F_GETFL);
if(fs_flags == -1) {
log_printf(ERROR, "inotify init failed (fcntl read flags error: %s)", strerror(errno));
diff --git a/src/utils.h b/src/utils.h
index b3cebc1..17ebed2 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,26 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RHDROPBOX_utils_h_INCLUDED
-#define RHDROPBOX_utils_h_INCLUDED
+#ifndef DROPNROLL_utils_h_INCLUDED
+#define DROPNROLL_utils_h_INCLUDED
#include "client_list.h"
#include "watch_list.h"
@@ -30,7 +30,6 @@
int init_command_socket(const char* path);
int connect_command_socket(const char* path);
int send_string(int fd, const char* string);
-int nonblock_recvline(read_buffer_t* buffer, int fd, int inotify_fd, watch_list_t* watch_lst, client_t* client_lst, options_t* opt);
int create_inotify();
#endif
diff --git a/src/watch_list.c b/src/watch_list.c
index 39c61f2..35f2302 100644
--- a/src/watch_list.c
+++ b/src/watch_list.c
@@ -1,22 +1,22 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
@@ -29,7 +29,7 @@ void watch_list_init(watch_list_t* list)
{
if(!list)
return;
-
+
list->first_ = NULL;
}
@@ -92,12 +92,12 @@ void watch_list_rm(watch_list_t* list, const char* path)
{
if(!list || !path)
return;
-
+
watch_list_element_t* tmp = NULL;
if(list->first_->path_ && !strcmp(path, list->first_->path_)) {
tmp = list->first_;
list->first_ = list->first_->next_;
-
+
if(tmp->path_)
free(tmp->path_);
free(tmp);
@@ -113,7 +113,7 @@ void watch_list_rm(watch_list_t* list, const char* path)
if(tmp->path_)
free(tmp->path_);
free(tmp);
- return;
+ return;
}
prev = tmp;
tmp = tmp->next_;
@@ -124,14 +124,14 @@ char* watch_list_find_path(watch_list_t* list, int watch_fd)
{
if(!list)
return NULL;
-
+
watch_list_element_t* tmp = list->first_;
while(tmp) {
if(tmp->watch_fd_ == watch_fd)
return tmp->path_;
tmp = tmp->next_;
}
-
+
return NULL;
}
@@ -139,14 +139,14 @@ int watch_list_find_fd(watch_list_t* list, const char* path)
{
if(!list || !path)
return -1;
-
+
watch_list_element_t* tmp = list->first_;
while(tmp) {
if(tmp->path_ && !strcmp(path, tmp->path_))
return tmp->watch_fd_;
tmp = tmp->next_;
}
-
+
return -1;
}
@@ -154,7 +154,7 @@ void watch_list_print(watch_list_t* list, const char* head, const char* sep, con
{
if(!list)
return;
-
+
watch_list_element_t* tmp = list->first_;
while(tmp) {
printf("%s%d%s%s%s", head, tmp->watch_fd_, sep, tmp->path_, tail);
diff --git a/src/watch_list.h b/src/watch_list.h
index bd428ab..5e482bd 100644
--- a/src/watch_list.h
+++ b/src/watch_list.h
@@ -1,26 +1,26 @@
/*
- * rhdropbox
+ * dropnroll
*
- * Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2009-2015 Christian Pointner <equinox@spreadspace.org>
*
- * This file is part of rhdropbox.
+ * This file is part of dropnroll.
*
- * rhdropbox is free software: you can redistribute it and/or modify
+ * dropnroll 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,
+ * dropnroll 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 <http://www.gnu.org/licenses/>.
+ * along with dropnroll. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RHDROPBOX_watch_list_h_INCLUDED
-#define RHDROPBOX_watch_list_h_INCLUDED
+#ifndef DROPNROLL_watch_list_h_INCLUDED
+#define DROPNROLL_watch_list_h_INCLUDED
struct watch_list_element_struct {
char* path_;