summaryrefslogtreecommitdiff
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
parentremoved debian dir (diff)
renamed rhdropbox to dropnroll
added support for clang some fixes for Wall
-rw-r--r--.gitignore11
-rw-r--r--AUTHORS2
-rw-r--r--LICENSE12
-rw-r--r--doc/Makefile28
-rw-r--r--doc/dropnroll.8.txt (renamed from doc/rhdropbox.8.txt)55
-rw-r--r--doc/rhdropbox.8195
-rw-r--r--etc/dropnroll/autostart (renamed from etc/rhdropbox/autostart)0
-rw-r--r--etc/dropnroll/sample/config (renamed from etc/rhdropbox/sample/config)6
-rwxr-xr-xetc/dropnroll/sample/newfile.sh15
-rwxr-xr-xetc/rhdropbox/sample/newfile.sh16
-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
32 files changed, 363 insertions, 650 deletions
diff --git a/.gitignore b/.gitignore
index f234018..3a096ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
-*.d
-*.o
-include.mk
-rhdropbox
-doc/rhdropbox.8.xml
-
+src/*.d
+src/*.o
+src/include.mk
+src/dropnroll
+doc/dropnroll.8.xml
diff --git a/AUTHORS b/AUTHORS
index 980ce2f..6762c7c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1 +1 @@
-Christian Pointner <equinox@helsinki.at>
+Christian Pointner <equinox@spreadspace.org>
diff --git a/LICENSE b/LICENSE
index 9c435b6..94d101e 100644
--- a/LICENSE
+++ b/LICENSE
@@ -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/>.
*/
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
diff --git a/doc/Makefile b/doc/Makefile
index f13f4ab..58ce90b 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,39 +1,39 @@
##
-## 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/>.
##
-.PHONY: clean
+.PHONY: clean
all: manpage
-rhdropbox.8: rhdropbox.8.txt
+dropnroll.8: dropnroll.8.txt
a2x -f manpage $<
- @ sed -i -e 's/\[FIXME: source\]/rhdropbox/' $@
- @ sed -i -e 's/\[FIXME: manual\]/rhdropbox user manual/' $@
- @ sed -i -e 's/^rhdropbox$$/\\fBrhdropbox\\fR/' $@
+ @ sed -i -e 's/\[FIXME: source\]/dropnroll/' $@
+ @ sed -i -e 's/\[FIXME: manual\]/dropnroll user manual/' $@
+ @ sed -i -e 's/^dropnroll$$/\\fBdropnroll\\fR/' $@
@ sed -i -e 's/^ \[ \([^ ]*\)/ [ \\fB\1\\fR/' $@
-manpage: rhdropbox.8
+manpage: dropnroll.8
clean:
- rm -f rhdropbox.8.xml
+ rm -f dropnroll.8.xml
realclean:
- rm -f rhdropbox.8 \ No newline at end of file
+ rm -f dropnroll.8
diff --git a/doc/rhdropbox.8.txt b/doc/dropnroll.8.txt
index 6ec25fb..e9e4b86 100644
--- a/doc/rhdropbox.8.txt
+++ b/doc/dropnroll.8.txt
@@ -1,17 +1,17 @@
-rhdropbox(8)
+dropnroll(8)
============
NAME
----
-rhdropbox - radio helsinki dropbox daemon
+dropnroll - drop'n'roll daemon
SYNOPSIS
--------
....
-rhdropbox
+dropnroll
[ -h|--help ]
[ -D|--nodaemonize ]
[ -u|--username <username> ]
@@ -29,23 +29,24 @@ rhdropbox
DESCRIPTION
-----------
-*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.
-Additional directories can be added to the damons watch list using a simple
+*dropnroll* is a small daemon which can be used to watch one or more
+directories for new files. When a new file is detected an external program will
+get started.
+Additional directories can be added to the daemon's watch list using a simple
unix socket based command interface.
OPTIONS
-------
-The following options can be passed to the *rhdropbox* daemon:
+The following options can be passed to the *dropnroll* daemon:
*-D, --nodaemonize*::
- This option instructs *rhdropbox* to run in foreground
+ This option instructs *dropnroll* to run in foreground
instead of becoming a daemon which is the default.
*-u, --username '<username>'*::
- run as this user. If no group is specified (*-g*) the default group of
+ run as this user. If no group is specified (*-g*) the default group of
the user is used. The default is to not drop privileges.
*-g, --groupname '<groupname>'*::
@@ -53,31 +54,31 @@ The following options can be passed to the *rhdropbox* daemon:
The default is to not drop privileges.
*-C, --chroot '<path>'*::
- Instruct *rhdropbox* to run in a chroot jail. The default is
+ Instruct *dropnroll* to run in a chroot jail. The default is
to not run in chroot.
*-P, --write-pid '<filename>'*::
- Instruct *rhdropbox* to write it's pid to this file. The default is
+ Instruct *dropnroll* to write it's pid to this file. The default is
to not create a pid file.
*-L, --log '<target>:<level>[,<param1>[,<param2>[..]]]'*::
add log target to logging system. This can be invoked several times
- in order to log to different targets at the same time. Every target
+ in order to log to different targets at the same time. Every target
hast its own log level which is a number between 0 and 5. Where 0 means
disabling log and 5 means debug messages are enabled. +
The file target can be used more the once with different levels.
- If no target is provided at the command line a single target with the
- config *syslog:3,rhdropbox,daemon* is added. +
+ If no target is provided at the command line a single target with the
+ config *syslog:3,dropnroll,daemon* is added. +
The following targets are supported:
'syslog';; log to syslog daemon, parameters <level>[,<logname>[,<facility>]]
'file';; log to file, parameters <level>[,<path>]
'stdout';; log to standard output, parameters <level>
- 'stderr';; log to standard error, parameters <level>
+ 'stderr';; log to standard error, parameters <level>
*-s|--command-sock '<unix sock>'*::
- *rhdropbox* will listen on this unix socket for incoming commands. See next
- chapter for details. The default is /var/run/rhdropbox/cmd.sock
+ *dropnroll* will listen on this unix socket for incoming commands. See next
+ chapter for details. The default is /var/run/dropnroll/cmd.sock
*-x|--script '<script>'*::
The script which should be called when a new file is found. The following parameter
@@ -100,11 +101,11 @@ The following options can be passed to the *rhdropbox* daemon:
COMMAND INTERFACE
-----------------
-*rhdropbox* is listening for incoming commands at the unix socket speciefied by the
+*dropnroll* is listening for incoming commands at the unix socket speciefied by the
*-s|--command-sock* parameter. You can connect to this socket for example using
socat:
- # socat UNIX-CONNECT:/var/run/rhdropbox/rhdropbox.sock STDIO
+ # socat UNIX-CONNECT:/var/run/dropnroll/dropnroll.sock STDIO
All commands have to end with '\n'. The following commands are supported:
@@ -121,10 +122,10 @@ All commands have to end with '\n'. The following commands are supported:
*listen [request|status|none]*::
Add the client to the status and or request listeners. When no parameter is passed to
- this command the client listens to all messages.
+ this command the client listens to all messages.
A status listener gets a list of all directories whenever somebody else adds or removes
a path to the watch list. It also receives the list when somebody sends a status command
- to the daemon.
+ to the daemon.
A request listener also receives add and remove requests by other clients connected to
the command interface.
@@ -134,20 +135,20 @@ All commands have to end with '\n'. The following commands are supported:
BUGS
----
-Most likely there are some bugs in *rhdropbox*. If you find a bug, please let
-the developers know at equinox@helsinki.at. Of course, patches are preferred.
+Most likely there are some bugs in *dropnroll*. If you find a bug, please let
+the developers know at equinox@spreadspace.org. Of course, patches are preferred.
AUTHORS
-------
-Christian Pointner <equinox@heslinki.at>
+Christian Pointner <equinox@spreadspace.org>
COPYING
-------
-Copyright \(C) 2009 Christian Pointner. 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
+Copyright \(C) 2009-2015 Christian Pointner. 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 any later version.
diff --git a/doc/rhdropbox.8 b/doc/rhdropbox.8
deleted file mode 100644
index 192059d..0000000
--- a/doc/rhdropbox.8
+++ /dev/null
@@ -1,195 +0,0 @@
-'\" t
-.\" Title: rhdropbox
-.\" Author: [see the "AUTHORS" section]
-.\" Generator: DocBook XSL Stylesheets v1.75.1 <http://docbook.sf.net/>
-.\" Date: 02/11/2010
-.\" Manual: rhdropbox user manual
-.\" Source: rhdropbox
-.\" Language: English
-.\"
-.TH "RHDROPBOX" "8" "02/11/2010" "rhdropbox" "rhdropbox user manual"
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
-.\" disable hyphenation
-.nh
-.\" disable justification (adjust text to left margin only)
-.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "NAME"
-rhdropbox \- radio helsinki dropbox daemon
-.SH "SYNOPSIS"
-.sp
-.nf
-\fBrhdropbox\fR
- [ \fB\-h|\-\-help\fR ]
- [ \fB\-D|\-\-nodaemonize\fR ]
- [ \fB\-u|\-\-username\fR <username> ]
- [ \fB\-g|\-\-groupname\fR <groupname> ]
- [ \fB\-C|\-\-chroot\fR <path> ]
- [ \fB\-P|\-\-write\-pid\fR <filename> ]
- [ \fB\-L|\-\-log\fR <target>:<level>[,<param1>[,<param2>[\&.\&.]]] ]
- [ \fB\-s|\-\-command\-sock\fR <unix sock> ]
- [ \fB\-x|\-\-script\fR <script> ]
- [ \fB\-m|\-\-max\-children\fR <#of children> ]
- [ \fB\-d|\-\-dir\fR <path> ]
-.fi
-.SH "DESCRIPTION"
-.sp
-\fBrhdropbox\fR 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\&. Additional directories can be added to the damons watch list using a simple unix socket based command interface\&.
-.SH "OPTIONS"
-.sp
-The following options can be passed to the \fBrhdropbox\fR daemon:
-.PP
-\fB\-D, \-\-nodaemonize\fR
-.RS 4
-This option instructs
-\fBrhdropbox\fR
-to run in foreground instead of becoming a daemon which is the default\&.
-.RE
-.PP
-\fB\-u, \-\-username \fR\fB\fI<username>\fR\fR
-.RS 4
-run as this user\&. If no group is specified (\fB\-g\fR) the default group of the user is used\&. The default is to not drop privileges\&.
-.RE
-.PP
-\fB\-g, \-\-groupname \fR\fB\fI<groupname>\fR\fR
-.RS 4
-run as this group\&. If no username is specified (\fB\-u\fR) this gets ignored\&. The default is to not drop privileges\&.
-.RE
-.PP
-\fB\-C, \-\-chroot \fR\fB\fI<path>\fR\fR
-.RS 4
-Instruct
-\fBrhdropbox\fR
-to run in a chroot jail\&. The default is to not run in chroot\&.
-.RE
-.PP
-\fB\-P, \-\-write\-pid \fR\fB\fI<filename>\fR\fR
-.RS 4
-Instruct
-\fBrhdropbox\fR
-to write it\(cqs pid to this file\&. The default is to not create a pid file\&.
-.RE
-.PP
-\fB\-L, \-\-log \fR\fB\fI<target>:<level>[,<param1>[,<param2>[\&.\&.]]]\fR\fR
-.RS 4
-add log target to logging system\&. This can be invoked several times in order to log to different targets at the same time\&. Every target hast its own log level which is a number between 0 and 5\&. Where 0 means disabling log and 5 means debug messages are enabled\&.
-
-The file target can be used more the once with different levels\&. If no target is provided at the command line a single target with the config
-\fBsyslog:3,rhdropbox,daemon\fR
-is added\&.
-
-The following targets are supported:
-.PP
-\fIsyslog\fR
-.RS 4
-log to syslog daemon, parameters <level>[,<logname>[,<facility>]]
-.RE
-.PP
-\fIfile\fR
-.RS 4
-log to file, parameters <level>[,<path>]
-.RE
-.PP
-\fIstdout\fR
-.RS 4
-log to standard output, parameters <level>
-.RE
-.PP
-\fIstderr\fR
-.RS 4
-log to standard error, parameters <level>
-.RE
-.RE
-.PP
-\fB\-s|\-\-command\-sock \fR\fB\fI<unix sock>\fR\fR
-.RS 4
-
-\fBrhdropbox\fR
-will listen on this unix socket for incoming commands\&. See next chapter for details\&. The default is /var/run/rhdropbox/cmd\&.sock
-.RE
-.PP
-\fB\-x|\-\-script \fR\fB\fI<script>\fR\fR
-.RS 4
-The script which should be called when a new file is found\&. The following parameter are passed to the scipt:
-.PP
-\fI<path>\fR
-.RS 4
-the path to the folder containing the new file
-.RE
-.PP
-\fI<filename>\fR
-.RS 4
-the name of the new file relative to <path>
-.RE
-.PP
-\fI<filesize>\fR
-.RS 4
-the size of the file right after the event was received, this can be used to determine wheter the file is complete\&. The script should consider a file to be complete when it size doesn\(cqt change 3\-5seconds after the event got received\&.
-.RE
-.RE
-.PP
-\fB\-m|\-\-max\-children \fR\fB\fI<#of children>\fR\fR
-.RS 4
-Limits the total concurrent executions of
-\fB\-x|\-\-script\fR\&. A value of 0 means no limit\&.
-.RE
-.PP
-\fB\-d|\-\-dir \fR\fB\fI<path>\fR\fR
-.RS 4
-Add
-\fI<path>\fR
-to the watch list\&. This can be invoked serveral times\&.
-.RE
-.SH "COMMAND INTERFACE"
-.sp
-\fBrhdropbox\fR is listening for incoming commands at the unix socket speciefied by the \fB\-s|\-\-command\-sock\fR parameter\&. You can connect to this socket for example using socat:
-.sp
-.if n \{\
-.RS 4
-.\}
-.nf
-# socat UNIX\-CONNECT:/var/run/rhdropbox/rhdropbox\&.sock STDIO
-.fi
-.if n \{\
-.RE
-.\}
-.sp
-All commands have to end with \fI\en\fR\&. The following commands are supported:
-.PP
-\fBadd <path>\fR
-.RS 4
-Add a path to the list of directories to be watched\&. If the command succeds nothing is returned\&. In case of an error a string of the form "Error: <reason>\en" is returned\&.
-.RE
-.PP
-\fBremove <path>\fR
-.RS 4
-Remove the path from the list of directories\&. If the command succeds nothing is returned\&. In case of an error a string of the form "Error: <reason>\en" is returned\&.
-.RE
-.PP
-\fBstatus\fR
-.RS 4
-Returns the complete list of all directories of the watch list\&.
-.RE
-.PP
-\fBlisten [request|status|none]\fR
-.RS 4
-Add the client to the status and or request listeners\&. When no parameter is passed to this command the client listens to all messages\&. A status listener gets a list of all directories whenever somebody else adds or removes a path to the watch list\&. It also receives the list when somebody sends a status command to the daemon\&. A request listener also receives add and remove requests by other clients connected to the command interface\&.
-.RE
-.PP
-\fBlog <text>\fR
-.RS 4
-Print <text> to the logtargets of the daemon\&.
-.RE
-.SH "BUGS"
-.sp
-Most likely there are some bugs in \fBrhdropbox\fR\&. If you find a bug, please let the developers know at equinox@helsinki\&.at\&. Of course, patches are preferred\&.
-.SH "AUTHORS"
-.sp
-Christian Pointner <equinox@heslinki\&.at>
-.SH "COPYING"
-.sp
-Copyright (C) 2009 Christian Pointner\&. 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 any later version\&.
diff --git a/etc/rhdropbox/autostart b/etc/dropnroll/autostart
index 067d2c0..067d2c0 100644
--- a/etc/rhdropbox/autostart
+++ b/etc/dropnroll/autostart
diff --git a/etc/rhdropbox/sample/config b/etc/dropnroll/sample/config
index 616f9e4..98758be 100644
--- a/etc/rhdropbox/sample/config
+++ b/etc/dropnroll/sample/config
@@ -3,7 +3,7 @@
#############################
## the path to the command socket
-command-sock /var/run/rhdropbox/sample.sock
+command-sock /var/run/dropnroll/sample.sock
## change user and group after init
#username nobody
@@ -26,7 +26,7 @@ command-sock /var/run/rhdropbox/sample.sock
#############################
## log to syslog with a level of 3
-log syslog:3,rhdropbox-sample,daemon
+log syslog:3,dropnroll-sample,daemon
## chroot to users home directory
-#chroot /var/run/rhdropbox
+#chroot /var/run/dropnroll
diff --git a/etc/dropnroll/sample/newfile.sh b/etc/dropnroll/sample/newfile.sh
new file mode 100755
index 0000000..600b5f1
--- /dev/null
+++ b/etc/dropnroll/sample/newfile.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+DIR=$1
+FILENAME=$2
+SIZE=$3
+
+if [ -z "$FILENAME" ]; then
+ exit 1;
+fi
+
+echo "new file of size $SIZE detected: $DIR/$FILENAME" >> /tmp/dropnroll-sample.log
+sleep 5
+rm -f $DIR/$FILENAME >> /tmp/dropnroll-sample.log 2>&1
+
+exit 0
diff --git a/etc/rhdropbox/sample/newfile.sh b/etc/rhdropbox/sample/newfile.sh
deleted file mode 100755
index bef4ea5..0000000
--- a/etc/rhdropbox/sample/newfile.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-DIR=$1
-FILENAME=$2
-SIZE=$3
-
-if [ -z "$FILENAME" ]; then
- exit 1;
-fi
-
-echo "new file of size $SIZE detected: $DIR/$FILENAME" >> /tmp/rhdropbox-sample.log
-sleep 5
-rm -f $DIR/$FILENAME >> /tmp/rhdropbox-sample.log 2>&1
-
-exit 0
-
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_;