[-]
[+]
|
Changed |
guacd.changes
|
|
[-]
[+]
|
Changed |
guacd.spec
^
|
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/ChangeLog
^
|
@@ -1,3 +1,14 @@
+2012-10-22 Michael Jumper <zhangmzike@users.sourceforge.net>
+
+ * Migrate function naming to 0.7.0
+ * Fix log message ordering
+ * Add size preamble instruction handling
+ * Handle audio/video preamble instructions with stubs
+
+2012-09-10 Alex Bligh <alex@alex.org.uk>
+
+ * Fix daemonization (ticket #178, Debian bug #685637)
+
2012-05-24 Michael Jumper <zhangmaike@users.sourceforge.net>
* Update README and manpage
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/Makefile.in
^
|
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -54,6 +54,23 @@
VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -129,6 +146,11 @@
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(guacd_SOURCES)
DIST_SOURCES = $(guacd_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
@@ -286,8 +308,11 @@
$(am__aclocal_m4_deps):
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
- test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \
+ fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p; \
@@ -326,8 +351,11 @@
$(LINK) $(guacd_OBJECTS) $(guacd_LDADD) $(LIBS)
install-initSCRIPTS: $(init_SCRIPTS)
@$(NORMAL_INSTALL)
- test -z "$(initdir)" || $(MKDIR_P) "$(DESTDIR)$(initdir)"
@list='$(init_SCRIPTS)'; test -n "$(initdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(initdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(initdir)" || exit 1; \
+ fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
@@ -424,11 +452,18 @@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o log.obj `if test -f 'src/log.c'; then $(CYGPATH_W) 'src/log.c'; else $(CYGPATH_W) '$(srcdir)/src/log.c'; fi`
install-man8: $(man_MANS)
@$(NORMAL_INSTALL)
- test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
- @list=''; test -n "$(man8dir)" || exit 0; \
- { for i in $$list; do echo "$$i"; done; \
- l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
- sed -n '/\.8[a-z]*$$/p'; \
+ @list1=''; \
+ list2='$(man_MANS)'; \
+ test -n "$(man8dir)" \
+ && test -n "`echo $$list1$$list2`" \
+ || exit 0; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
+ { for i in $$list1; do echo "$$i"; done; \
+ if test -n "$$list2"; then \
+ for i in $$list2; do echo "$$i"; done \
+ | sed -n '/\.8[a-z]*$$/p'; \
+ fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
@@ -622,7 +657,7 @@
*.zip*) \
unzip $(distdir).zip ;;\
esac
- chmod -R a-w $(distdir); chmod a+w $(distdir)
+ chmod -R a-w $(distdir); chmod u+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/aclocal.m4
^
|
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.11.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
@@ -38,7 +38,7 @@
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.11.3], [],
+m4_if([$1], [1.11.6], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -54,7 +54,7 @@
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.3])dnl
+[AM_AUTOMAKE_VERSION([1.11.6])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/configure
^
|
@@ -2579,7 +2579,7 @@
# Define the identity of the package.
PACKAGE=guacd
- VERSION=0.6.1
+ VERSION=0.7.0
cat >>confdefs.h <<_ACEOF
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/configure.in
^
|
@@ -35,7 +35,7 @@
# ***** END LICENSE BLOCK *****
AC_INIT(src/daemon.c)
-AM_INIT_AUTOMAKE(guacd, 0.6.1)
+AM_INIT_AUTOMAKE(guacd, 0.7.0)
# Checks for programs.
AC_PROG_CC
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/depcomp
^
|
@@ -1,10 +1,10 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
-scriptversion=2011-12-04.11; # UTC
+scriptversion=2012-03-27.16; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
-# 2011 Free Software Foundation, Inc.
+# 2011, 2012 Free Software Foundation, Inc.
# 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
@@ -28,7 +28,7 @@
case $1 in
'')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
@@ -40,8 +40,8 @@
Environment variables:
depmode Dependency tracking mode.
- source Source file read by `PROGRAMS ARGS'.
- object Object file output by `PROGRAMS ARGS'.
+ source Source file read by 'PROGRAMS ARGS'.
+ object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
@@ -57,6 +57,12 @@
;;
esac
+# A tabulation character.
+tab=' '
+# A newline character.
+nl='
+'
+
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
@@ -102,6 +108,12 @@
depmode=msvc7
fi
+if test "$depmode" = xlc; then
+ # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
+ gccflag=-qmakedep=gcc,-MF
+ depmode=gcc
+fi
+
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
@@ -156,15 +168,14 @@
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
+## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
+ tr ' ' "$nl" < "$tmpdepfile" |
+## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
@@ -203,18 +214,15 @@
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
+ # the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
+ tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> "$depfile"
+ tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
+ tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
@@ -226,10 +234,17 @@
rm -f "$tmpdepfile"
;;
+xlc)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
- # current directory. Also, the AIX compiler puts `$object:' at the
+ # current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
@@ -259,12 +274,11 @@
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
- # Each line is of the form `foo.o: dependent.h'.
+ # Each line is of the form 'foo.o: dependent.h'.
# Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
+ # '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
@@ -275,23 +289,26 @@
;;
icc)
- # Intel's C compiler understands `-MD -MF file'. However on
- # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
+ # However on
+ # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
- # which is wrong. We want:
+ # which is wrong. We want
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
- # and will wrap long lines using \ :
+ # and will wrap long lines using '\':
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
-
+ # tcc 0.9.26 (FIXME still under development at the moment of writing)
+ # will emit a similar output, but also prepend the continuation lines
+ # with horizontal tabulation characters.
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
@@ -300,15 +317,21 @@
exit $stat
fi
rm -f "$depfile"
- # Each line is of the form `foo.o: dependent.h',
- # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Each line is of the form 'foo.o: dependent.h',
+ # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
# Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
- # Some versions of the HPUX 10.20 sed can't process this invocation
- # correctly. Breaking it into two sed invocations is a workaround.
- sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
- sed -e 's/$/ :/' >> "$depfile"
+ # '$object: dependent.h' and one to simply 'dependent.h:'.
+ sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
+ < "$tmpdepfile" > "$depfile"
+ sed '
+ s/[ '"$tab"'][ '"$tab"']*/ /g
+ s/^ *//
+ s/ *\\*$//
+ s/^[^:]*: *//
+ /^$/d
+ /:$/d
+ s/$/ :/
+ ' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
@@ -344,7 +367,7 @@
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
- # Add `dependent.h:' lines.
+ # Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
@@ -359,9 +382,9 @@
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
+ # dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
@@ -407,8 +430,7 @@
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
@@ -443,11 +465,11 @@
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
-s/\(.*\)/ \1 \\/p
+s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
- s/.*/ /
+ s/.*/'"$tab"'/
G
p
}' >> "$depfile"
@@ -478,7 +500,7 @@
shift
fi
- # Remove `-o $object'.
+ # Remove '-o $object'.
IFS=" "
for arg
do
@@ -498,15 +520,14 @@
done
test -z "$dashmflag" && dashmflag=-M
- # Require at least two characters before searching for `:'
+ # Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
- # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
- sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
+ tr ' ' "$nl" < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@@ -562,8 +583,7 @@
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
+ sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@@ -583,7 +603,7 @@
shift
fi
- # Remove `-o $object'.
+ # Remove '-o $object'.
IFS=" "
for arg
do
@@ -652,8 +672,8 @@
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
- sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
+ sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
+ echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/man/guacd.8
^
|
@@ -1,4 +1,4 @@
-.TH guacd 8 "6 May 2012" "version 0.6.1" "Guacamole"
+.TH guacd 8 "6 May 2012" "version 0.6.2" "Guacamole"
.
.SH NAME
guacd \- Guacamole proxy daemon
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/src/client.c
^
|
@@ -42,6 +42,8 @@
#include <guacamole/socket.h>
#include <guacamole/client.h>
#include <guacamole/error.h>
+#include <guacamole/protocol.h>
+#include <guacamole/timestamp.h>
#include "client.h"
#include "log.h"
@@ -67,13 +69,13 @@
guac_client* client = (guac_client*) data;
guac_socket* socket = client->socket;
- guac_timestamp last_ping_timestamp = guac_protocol_get_timestamp();
+ guac_timestamp last_ping_timestamp = guac_timestamp_current();
/* Guacamole client output loop */
while (client->state == GUAC_CLIENT_RUNNING) {
/* Occasionally ping client with repeat of last sync */
- guac_timestamp timestamp = guac_protocol_get_timestamp();
+ guac_timestamp timestamp = guac_timestamp_current();
if (timestamp - last_ping_timestamp > GUACD_SYNC_FREQUENCY) {
/* Record time of last synnc */
@@ -113,7 +115,7 @@
}
/* Send sync instruction */
- client->last_sent_timestamp = guac_protocol_get_timestamp();
+ client->last_sent_timestamp = guac_timestamp_current();
if (guac_protocol_send_sync(socket, client->last_sent_timestamp)) {
guacd_client_log_guac_error(client,
"Error sending \"sync\" instruction");
@@ -158,7 +160,7 @@
/* Read instruction */
guac_instruction* instruction =
- guac_protocol_read_instruction(socket, GUACD_USEC_TIMEOUT);
+ guac_instruction_read(socket, GUACD_USEC_TIMEOUT);
/* Stop on error */
if (instruction == NULL) {
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/src/daemon.c
^
|
@@ -21,6 +21,7 @@
*
* Contributor(s):
* David PHAM-VAN <d.pham-van@ulteo.com> Ulteo SAS - http://www.ulteo.com
+ * Alex Bligh <alex@alex.org.uk>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -42,6 +43,9 @@
#include <string.h>
#include <signal.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
#include <sys/socket.h>
#include <netdb.h>
@@ -53,22 +57,32 @@
#include <guacamole/client.h>
#include <guacamole/error.h>
+#include <guacamole/instruction.h>
+#include <guacamole/plugin.h>
+#include <guacamole/protocol.h>
#include "client.h"
#include "log.h"
+#define GUACD_DEV_NULL "/dev/null"
+#define GUACD_ROOT "/"
+
void guacd_handle_connection(int fd) {
guac_client* client;
guac_client_plugin* plugin;
guac_instruction* select;
+ guac_instruction* size;
+ guac_instruction* audio;
+ guac_instruction* video;
guac_instruction* connect;
+ int init_result;
/* Open guac_socket */
guac_socket* socket = guac_socket_open(fd);
/* Get protocol from select instruction */
- select = guac_protocol_expect_instruction(
+ select = guac_instruction_expect(
socket, GUACD_USEC_TIMEOUT, "select");
if (select == NULL) {
@@ -76,7 +90,7 @@
guacd_log_guac_error("Error reading \"select\"");
/* Free resources */
- guac_socket_close(socket);
+ guac_socket_free(socket);
return;
}
@@ -88,7 +102,7 @@
select->argc);
/* Free resources */
- guac_socket_close(socket);
+ guac_socket_free(socket);
return;
}
@@ -104,7 +118,7 @@
guacd_log_guac_error("Error loading client plugin");
/* Free resources */
- guac_socket_close(socket);
+ guac_socket_free(socket);
return;
}
@@ -118,12 +132,51 @@
if (guac_client_plugin_close(plugin))
guacd_log_guac_error("Error closing client plugin");
- guac_socket_close(socket);
+ guac_socket_free(socket);
+ return;
+ }
+
+ /* Get optimal screen size */
+ size = guac_instruction_expect(
+ socket, GUACD_USEC_TIMEOUT, "size");
+ if (size == NULL) {
+
+ /* Log error */
+ guacd_log_guac_error("Error reading \"size\"");
+
+ /* Free resources */
+ guac_socket_free(socket);
+ return;
+ }
+
+ /* Get supported audio formats */
+ audio = guac_instruction_expect(
+ socket, GUACD_USEC_TIMEOUT, "audio");
+ if (audio == NULL) {
+
+ /* Log error */
+ guacd_log_guac_error("Error reading \"audio\"");
+
+ /* Free resources */
+ guac_socket_free(socket);
+ return;
+ }
+
+ /* Get supported video formats */
+ video = guac_instruction_expect(
+ socket, GUACD_USEC_TIMEOUT, "video");
+ if (video == NULL) {
+
+ /* Log error */
+ guacd_log_guac_error("Error reading \"video\"");
+
+ /* Free resources */
+ guac_socket_free(socket);
return;
}
/* Get args from connect instruction */
- connect = guac_protocol_expect_instruction(
+ connect = guac_instruction_expect(
socket, GUACD_USEC_TIMEOUT, "connect");
if (connect == NULL) {
@@ -133,25 +186,49 @@
if (guac_client_plugin_close(plugin))
guacd_log_guac_error("Error closing client plugin");
- guac_socket_close(socket);
+ guac_socket_free(socket);
return;
}
- /* Load and init client */
- client = guac_client_plugin_get_client(plugin, socket,
- connect->argc, connect->argv,
- guacd_client_log_info, guacd_client_log_error);
+ /* Get client */
+ client = guac_client_alloc();
+ client->socket = socket;
+ client->log_info_handler = guacd_client_log_info;
+ client->log_error_handler = guacd_client_log_error;
+
+ /* Parse optimal screen dimensions from size instruction */
+ client->info.optimal_width = atoi(size->argv[0]);
+ client->info.optimal_height = atoi(size->argv[1]);
+
+ /* Store audio mimetypes */
+ client->info.audio_mimetypes = malloc(sizeof(char*) * (audio->argc+1));
+ memcpy(client->info.audio_mimetypes, audio->argv,
+ sizeof(char*) * audio->argc);
+ client->info.audio_mimetypes[audio->argc] = NULL;
+
+ /* Store video mimetypes */
+ client->info.video_mimetypes = malloc(sizeof(char*) * (video->argc+1));
+ memcpy(client->info.video_mimetypes, video->argv,
+ sizeof(char*) * video->argc);
+ client->info.video_mimetypes[video->argc] = NULL;
+
+ /* Init client */
+ init_result = guac_client_plugin_init_client(plugin,
+ client, connect->argc, connect->argv);
guac_instruction_free(connect);
- if (client == NULL) {
+ /* If client could not be started, free everything and fail */
+ if (init_result) {
+
+ guac_client_free(client);
guacd_log_guac_error("Error instantiating client");
if (guac_client_plugin_close(plugin))
guacd_log_guac_error("Error closing client plugin");
- guac_socket_close(socket);
+ guac_socket_free(socket);
return;
}
@@ -162,18 +239,101 @@
else
guacd_log_info("Client finished normally");
+ /* Free mimetype lists */
+ free(client->info.audio_mimetypes);
+ free(client->info.video_mimetypes);
+
+ /* Free remaining instructions */
+ guac_instruction_free(audio);
+ guac_instruction_free(video);
+ guac_instruction_free(size);
+
/* Clean up */
guac_client_free(client);
if (guac_client_plugin_close(plugin))
guacd_log_error("Error closing client plugin");
/* Close socket */
- guac_socket_close(socket);
+ guac_socket_free(socket);
+
+}
+
+int redirect_fd(int fd, int flags) {
+
+ /* Attempt to open bit bucket */
+ int new_fd = open(GUACD_DEV_NULL, flags);
+ if (new_fd < 0)
+ return 1;
+
+ /* If descriptor is different, redirect old to new and close new */
+ if (new_fd != fd) {
+ dup2(new_fd, fd);
+ close(new_fd);
+ }
+
+ return 0;
+
+}
+
+int daemonize() {
- return;
+ pid_t pid;
+
+ /* Fork once to ensure we aren't the process group leader */
+ pid = fork();
+ if (pid < 0) {
+ guacd_log_error("Could not fork() parent: %s", strerror(errno));
+ return 1;
+ }
+
+ /* Exit if we are the parent */
+ if (pid > 0) {
+ guacd_log_info("Exiting and passing control to PID %i", pid);
+ _exit(0);
+ }
+
+ /* Start a new session (if not already group leader) */
+ setsid();
+
+ /* Fork again so the session group leader exits */
+ pid = fork();
+ if (pid < 0) {
+ guacd_log_error("Could not fork() group leader: %s", strerror(errno));
+ return 1;
+ }
+
+ /* Exit if we are the parent */
+ if (pid > 0) {
+ guacd_log_info("Exiting and passing control to PID %i", pid);
+ _exit(0);
+ }
+
+ /* Change to root directory */
+ if (chdir(GUACD_ROOT) < 0) {
+ guacd_log_error(
+ "Unable to change working directory to "
+ GUACD_ROOT);
+ return 1;
+ }
+
+ /* Reopen the 3 stdxxx to /dev/null */
+
+ if (redirect_fd(STDIN_FILENO, O_RDONLY)
+ || redirect_fd(STDOUT_FILENO, O_WRONLY)
+ || redirect_fd(STDERR_FILENO, O_WRONLY)) {
+
+ guacd_log_error(
+ "Unable to redirect standard file descriptors to "
+ GUACD_DEV_NULL);
+ return 1;
+ }
+
+ /* Success */
+ return 0;
}
+
int main(int argc, char* argv[]) {
/* Server */
@@ -205,9 +365,6 @@
/* General */
int retval;
- /* Daemon Process */
- pid_t daemon_pid;
-
/* Parse arguments */
while ((opt = getopt(argc, argv, "l:b:p:f")) != -1) {
if (opt == 'l') {
@@ -237,12 +394,20 @@
/* Set up logging prefix */
strncpy(log_prefix, basename(argv[0]), sizeof(log_prefix));
+ /* Open log as early as we can */
+ openlog(NULL, LOG_PID, LOG_DAEMON);
+
+ /* Log start */
+ guacd_log_info("Guacamole proxy daemon (guacd) version " VERSION);
/* Get addresses for binding */
- if ((retval = getaddrinfo(listen_address, listen_port, &hints, &addresses))) {
+ if ((retval = getaddrinfo(listen_address, listen_port,
+ &hints, &addresses))) {
+
guacd_log_error("Error parsing given address or port: %s",
gai_strerror(retval));
exit(EXIT_FAILURE);
+
}
/* Get socket */
@@ -253,8 +418,10 @@
}
/* Allow socket reuse */
- if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, (void*) &opt_on, sizeof(opt_on))) {
- guacd_log_info("Unable to set socket options for reuse: %s", strerror(errno));
+ if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR,
+ (void*) &opt_on, sizeof(opt_on))) {
+ guacd_log_info("Unable to set socket options for reuse: %s",
+ strerror(errno));
}
/* Attempt binding of each address until success */
@@ -301,57 +468,49 @@
exit(EXIT_FAILURE);
}
+ /* Daemonize if requested */
if (!foreground) {
- /* Fork into background */
- daemon_pid = fork();
-
- /* If error, fail */
- if (daemon_pid == -1) {
- guacd_log_error("Error forking daemon process: %s", strerror(errno));
+ /* Attempt to daemonize process */
+ if (daemonize()) {
+ guacd_log_error("Could not become a daemon.");
exit(EXIT_FAILURE);
}
- /* If parent, write PID file and exit */
- else if (daemon_pid != 0) {
-
- if (pidfile != NULL) {
-
- /* Attempt to open pidfile and write PID */
- FILE* pidf = fopen(pidfile, "w");
- if (pidf) {
- fprintf(pidf, "%d\n", daemon_pid);
- fclose(pidf);
- }
-
- /* Warn on failure */
- else {
- guacd_log_error("Could not write PID file: %s", strerror(errno));
- exit(EXIT_FAILURE);
- }
+ }
- }
+ /* Write PID file if requested */
+ if (pidfile != NULL) {
- exit(EXIT_SUCCESS);
+ /* Attempt to open pidfile and write PID */
+ FILE* pidf = fopen(pidfile, "w");
+ if (pidf) {
+ fprintf(pidf, "%d\n", getpid());
+ fclose(pidf);
+ }
+
+ /* Fail if could not write PID file*/
+ else {
+ guacd_log_error("Could not write PID file: %s", strerror(errno));
+ exit(EXIT_FAILURE);
}
- }
- /* Open log */
- openlog(NULL, LOG_PID, LOG_DAEMON);
+ }
/* Ignore SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
- guacd_log_info("Could not set handler for SIGPIPE to ignore. SIGPIPE may cause termination of the daemon.");
+ guacd_log_info("Could not set handler for SIGPIPE to ignore. "
+ "SIGPIPE may cause termination of the daemon.");
}
/* Ignore SIGCHLD (force automatic removal of children) */
if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
- guacd_log_info("Could not set handler for SIGCHLD to ignore. Child processes may pile up in the process table.");
+ guacd_log_info("Could not set handler for SIGCHLD to ignore. "
+ "Child processes may pile up in the process table.");
}
/* Log listening status */
- syslog(LOG_INFO,
- "Listening on host %s, port %s", bound_address, bound_port);
+ guacd_log_info("Listening on host %s, port %s", bound_address, bound_port);
/* Free addresses */
freeaddrinfo(addresses);
@@ -369,9 +528,12 @@
/* Accept connection */
client_addr_len = sizeof(client_addr);
- connected_socket_fd = accept(socket_fd, (struct sockaddr*) &client_addr, &client_addr_len);
+ connected_socket_fd = accept(socket_fd,
+ (struct sockaddr*) &client_addr, &client_addr_len);
+
if (connected_socket_fd < 0) {
- guacd_log_error("Could not accept client connection: %s", strerror(errno));
+ guacd_log_error("Could not accept client connection: %s",
+ strerror(errno));
return 3;
}
@@ -399,7 +561,8 @@
/* If parent, close reference to child's descriptor */
else if (close(connected_socket_fd) < 0) {
- guacd_log_error("Error closing daemon reference to child descriptor: %s", strerror(errno));
+ guacd_log_error("Error closing daemon reference to "
+ "child descriptor: %s", strerror(errno));
}
}
|
[-]
[+]
|
Changed |
guacd-0.7.0.tar.bz2/src/log.c
^
|
@@ -106,8 +106,8 @@
if (guac_error_message != NULL)
guacd_log_error("%s: %s: %s",
message,
- guac_error_message,
- guac_status_string(guac_error));
+ guac_status_string(guac_error),
+ guac_error_message);
/* Otherwise just log with standard status string */
else
@@ -123,8 +123,8 @@
if (guac_error_message != NULL)
guac_client_log_error(client, "%s: %s: %s",
message,
- guac_error_message,
- guac_status_string(guac_error));
+ guac_status_string(guac_error),
+ guac_error_message);
/* Otherwise just log with standard status string */
else
|