gnome-user-share r284 - in trunk: . data src



Author: hadess
Date: Tue Jan 13 12:19:58 2009
New Revision: 284
URL: http://svn.gnome.org/viewvc/gnome-user-share?rev=284&view=rev

Log:
2009-01-13  Bastien Nocera  <hadess hadess net>

	* configure.in:
	* data/dav_user_2.2.conf.in:
	* src/Makefile.am:
	* src/http.c (spawn_httpd), (http_up), (http_down), (http_init):
	Remove loads of code and direct Avahi/Howl dependency by using
	mod_dnssd to advertise the share (Closes: #567442)
	Disable Apache 2.0 support, somebody with access to it will have
	to fix this



Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/data/dav_user_2.2.conf.in
   trunk/src/Makefile.am
   trunk/src/http.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Jan 13 12:19:58 2009
@@ -55,47 +55,22 @@
 	
 AC_SUBST(HTTPD_VERSION)
 
-if test "x$HTTPD_VERSION" != "x2.0" && test "x$HTTPD_VERSION" != "x2.2" ; then
-	AC_MSG_ERROR([Could not detect a supported HTTPD version (2.0 or 2.2)])
-fi
-	
-AM_CONDITIONAL(HAVE_AVAHI, false)
-AM_CONDITIONAL(HAVE_HOWL, false)
-			  
-AC_ARG_ENABLE(avahi, [  --disable-avahi     build without avahi support])
-msg_avahi=no
-if test "x$enable_avahi" != "xno"; then
-	PKG_CHECK_MODULES(AVAHI, avahi-glib >= 0.6 avahi-client >= 0.6,
-		  	[AM_CONDITIONAL(HAVE_AVAHI, true)
-		   	AC_DEFINE(HAVE_AVAHI, [], [Set if we can use avahi])]
-                        msg_avahi=yes,
-	          	[AM_CONDITIONAL(HAVE_AVAHI, false)])
-	AC_SUBST(AVAHI_CFLAGS)
-	AC_SUBST(AVAHI_LIBS)
-fi
-			  
-AC_ARG_ENABLE(howl, [  --disable-howl     build without howl support])
-msg_howl=no
-if test "x$msg_avahi" = "xno" -a "x$enable_howl" != "xno"; then
-	PKG_CHECK_MODULES(HOWL, howl >= 0.9.6,
-		  	[AM_CONDITIONAL(HAVE_HOWL, true)
-		   	AC_DEFINE(HAVE_HOWL, [], [Set if we can use howl])]
-                        msg_howl=yes,
-	          	[AM_CONDITIONAL(HAVE_HOWL, false)])
-	AC_SUBST(HOWL_CFLAGS)
-	AC_SUBST(HOWL_LIBS)
+if test "x$HTTPD_VERSION" != "x2.2" ; then
+	AC_MSG_ERROR([Could not detect a supported HTTPD version (2.2)])
 fi
 
+# FIXME disabled for now, as the configuration for 2.0 hasn't been ported to
+# use mod_dnssd
+#if test "x$HTTPD_VERSION" != "x2.0" && test "x$HTTPD_VERSION" != "x2.2" ; then
+#	AC_MSG_ERROR([Could not detect a supported HTTPD version (2.0 or 2.2)])
+#fi
+	
 PKG_CHECK_EXISTS(dbus-1 >= 1.1.1, have_dbus_1_1=true, have_dbus_1_1=false)
 if $have_dbus_1_1 ; then
    DBUS_MODULES=dbus-1
    AC_DEFINE(HAVE_DBUS_1_1, 1, [Set to true if we have D-BUS 1.1])
 fi
 
-if test "x$msg_avahi" = "xno" -a "x$msg_howl" = "xno"; then
-  AC_MSG_ERROR([Neither avahi nor howl detected. Gnome-user-share needs a mDNS implementation.])
-fi
-
 PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.15.2 gio-2.0 gdk-x11-2.0 gtk+-2.0 gconf-2.0 dbus-glib-1 libnotify $DBUS_MODULES)
 AC_SUBST(USER_SHARE_CFLAGS)
 AC_SUBST(USER_SHARE_LIBS)
@@ -171,6 +146,13 @@
 AC_SUBST(MODULES_PATH)
 
 dnl ==========================================================================
+dnl Check for mod_dnssd
+
+if test ! -f $with_modules_path/mod_dnssd.so ; then
+	AC_MSG_ERROR([mod_dnssd is required to use gnome-user-share])
+fi
+
+dnl ==========================================================================
 
 dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
 

Modified: trunk/data/dav_user_2.2.conf.in
==============================================================================
--- trunk/data/dav_user_2.2.conf.in	(original)
+++ trunk/data/dav_user_2.2.conf.in	Tue Jan 13 12:19:58 2009
@@ -13,33 +13,43 @@
 LoadModule authn_file_module @HTTP_MODULES_PATH@/mod_authn_file.so
 LoadModule auth_digest_module @HTTP_MODULES_PATH@/mod_auth_digest.so
 LoadModule authz_groupfile_module @HTTP_MODULES_PATH@/mod_authz_groupfile.so
+LoadModule dnssd_module @HTTP_MODULES_PATH@/mod_dnssd.so
 
-DocumentRoot ${XDG_PUBLICSHARE_DIR}
-<Directory "${XDG_PUBLICSHARE_DIR}">
-  AllowOverride None
-  DAV On
-
-  AuthType Digest
-  AuthName "Please log in as the user guest"
-  AuthDigestDomain /
-
-  AuthDigestProvider file
-  AuthUserFile ${XDG_CONFIG_HOME}/user-share/passwd
-  AuthGroupFile @DATADIR@/gnome-user-share/dav_groupfile
-
-
-  <IfDefine RequirePasswordAlways>
-    Require user guest
-    Require group guest
-  </IfDefine>
+DNSSDEnable on
+DNSSDAutoRegisterVHosts Off
+DNSSDAutoRegisterUserDir Off
 
-  <IfDefine RequirePasswordOnWrite>
-    <LimitExcept GET OPTIONS PROPFIND>
+<VirtualHost *>
+  DocumentRoot ${XDG_PUBLICSHARE_DIR}
+
+  <Location />
+    AllowOverride None
+    DAV On
+
+    AuthType Digest
+    AuthName "${GUS_LOGIN_LABEL}"
+    AuthDigestDomain /
+
+    AuthDigestProvider file
+    AuthUserFile ${XDG_CONFIG_HOME}/user-share/passwd
+    AuthGroupFile /usr/share/gnome-user-share/dav_groupfile
+
+    <IfDefine RequirePasswordAlways>
       Require user guest
       Require group guest
-    </LimitExcept>
-  </IfDefine>
-</Directory>
+    </IfDefine>
+
+    <IfDefine RequirePasswordOnWrite>
+      <LimitExcept GET OPTIONS PROPFIND>
+        Require user guest
+        Require group guest
+      </LimitExcept>
+    </IfDefine>
+
+    DNSSDServiceName "${GUS_SHARE_NAME}"
+    DNSSDServiceTypes _webdav._tcp
+  </Location>
+</VirtualHost>
 
 StartServers 1
 MaxClients 3

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Jan 13 12:19:58 2009
@@ -25,8 +25,6 @@
 	-DHTTPD_PROGRAM=\""$(HTTPD)"\"	\
 	-I$(top_srcdir) 				\
 	-I$(top_builddir) 				\
-	$(AVAHI_CFLAGS)					\
-	$(HOWL_CFLAGS)					\
 	$(USER_SHARE_CFLAGS)				\
 	$(USER_SHARE_CONFIG_CFLAGS)			\
 	$(X_CFLAGS)
@@ -45,8 +43,6 @@
 	$(MARSHALFILES)
 
 gnome_user_share_LDADD = \
-	$(HOWL_LIBS)	\
-	$(AVAHI_LIBS)	\
 	$(USER_SHARE_LIBS)	\
 	$(SELINUX_LIBS)	\
 	$(X_LIBS) $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)

Modified: trunk/src/http.c
==============================================================================
--- trunk/src/http.c	(original)
+++ trunk/src/http.c	Tue Jan 13 12:19:58 2009
@@ -31,22 +31,6 @@
 #include <dbus/dbus.h>
 #endif
 
-#ifdef HAVE_AVAHI
-#include <avahi-client/client.h>
-#include <avahi-client/publish.h>
-#include <avahi-common/alternative.h>
-#include <avahi-common/error.h>
-#include <avahi-glib/glib-watch.h>
-#include <avahi-glib/glib-malloc.h>
-#endif /* HAVE_AVAHI */
-
-#ifdef HAVE_HOWL
-/* Workaround broken howl installing config.h */
-#undef PACKAGE
-#undef VERSION
-#include <howl.h>
-#endif /* HAVE_HOWL */
-
 #include <gconf/gconf-client.h>
 
 #include <stdarg.h>
@@ -184,246 +168,6 @@
 }
 #endif
 
-#ifdef HAVE_AVAHI
-
-static AvahiClient *avahi_client = NULL;
-static gboolean avahi_should_publish = FALSE;
-static gboolean avahi_running = FALSE;
-static int avahi_port = 0;
-static AvahiEntryGroup *entry_group = NULL;
-static char *avahi_name = NULL;
-
-static AvahiStringList*
-new_text_record_list (const char *first_key,
-		      const char *first_value,
-		      ...)
-{
-	va_list args;
-	const char *k;
-	const char *v;
-	AvahiStringList *list;
-
-	if (first_key == NULL)
-		return NULL;
-
-	list = NULL;
-
-	list = avahi_string_list_add_pair (list, first_key, first_value);
-
-	va_start (args, first_value);
-	k = va_arg (args, const char*);
-	if (k)
-		v = va_arg (args, const char*);
-	while (k != NULL) {
-		list = avahi_string_list_add_pair (list, k, v);
-
-		k = va_arg (args, const char*);
-		if (k)
-			v = va_arg (args, const char*);
-	}
-
-	va_end(args);
-
-	return list;
-}
-
-static gboolean
-create_service (void) {
-	int ret;
-	AvahiStringList *txt_records;
-
-	if (avahi_name == NULL) {
-		avahi_name = g_strdup (get_share_name ());
-	}
-
-	txt_records = new_text_record_list ("u", "guest",
-#ifdef HAVE_DBUS_1_1
-					    /* This must be last */
-					    dbus_session_id != NULL ? "org.freedesktop.od.session" : NULL, dbus_session_id,
-#endif									   
-					    NULL);
-
-	ret = avahi_entry_group_add_service_strlst (entry_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 
-						    AVAHI_PUBLISH_USE_MULTICAST,
-						    avahi_name, "_webdav._tcp", NULL, NULL, 
-						    avahi_port,
-						    txt_records);
-
-	avahi_string_list_free(txt_records);
-
-	if (ret < 0) {
-		return FALSE;
-	}
-
-	ret = avahi_entry_group_commit (entry_group);
-
-	if (ret < 0) {
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-static void 
-entry_group_callback (AvahiEntryGroup *g, 
-		      AvahiEntryGroupState state, 
-		      void *userdata) 
-{
-	if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
-	} else if (state == AVAHI_ENTRY_GROUP_COLLISION) {
-		char *n;
-
-		/* A service name collision happened. Let's pick a new name */
-		n = avahi_alternative_service_name (avahi_name);
-		g_free (avahi_name);
-		avahi_name = n;
-
-		fprintf (stderr, "Service name collision, renaming service to '%s'\n", avahi_name);
-
-		/* And recreate the services */
-		create_service();
-	}
-}
-
-static void
-avahi_client_callback (AvahiClient *client, AvahiClientState state, void *userdata)
-{
-	if (state == AVAHI_CLIENT_S_RUNNING) {
-		avahi_running = TRUE;
-		if (avahi_should_publish) {
-			create_service ();
-		}
-	} else if (state == AVAHI_CLIENT_S_COLLISION) {
-		avahi_entry_group_reset (entry_group);
-	} else if (state == AVAHI_CLIENT_FAILURE) {
-		avahi_running = FALSE;
-	}
-}
-
-static gboolean
-init_avahi (void)
-{
-	AvahiGLibPoll *poll;
-	int error;
-
-	avahi_set_allocator (avahi_glib_allocator ());
-
-	poll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT);
-
-	/* Create a new AvahiClient instance */
-	avahi_client = avahi_client_new (avahi_glib_poll_get (poll),
-					 AVAHI_CLIENT_NO_FAIL,
-					 avahi_client_callback,
-					 NULL,
-					 &error);
-	if (avahi_client == NULL) {
-		return FALSE;
-	}
-
-	entry_group = avahi_entry_group_new (avahi_client, entry_group_callback, NULL);
-	if (entry_group == NULL) {
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-
-static gboolean
-publish_service (int port)
-{
-	avahi_should_publish = TRUE;
-	avahi_port = port;
-	if (avahi_running) {
-		create_service ();
-	}
-	return TRUE;
-}
-
-static void
-stop_publishing (void)
-{
-	avahi_should_publish = FALSE;
-	avahi_entry_group_reset (entry_group);
-}
-#endif
-
-#ifdef HAVE_HOWL
-
-static sw_discovery_publish_id published_id = 0;
-static sw_discovery howl_session;
-
-static gboolean
-howl_input (GIOChannel  *io_channel,
-	    GIOCondition cond,
-	    gpointer     callback_data)
-{
-	sw_discovery session;
-	session = callback_data;
-	sw_salt salt;
-
-	if (sw_discovery_salt (session, &salt) == SW_OKAY) {
-		sw_salt_lock (salt);
-		sw_discovery_read_socket (session);
-		sw_salt_unlock (salt);
-	}
-	return TRUE;
-}
-
-static void
-set_up_howl_session (sw_discovery session)
-{
-	int fd;
-	GIOChannel *channel;
-
-	fd = sw_discovery_socket (session);
-
-	channel = g_io_channel_unix_new (fd);
-	g_io_add_watch (channel,
-			G_IO_IN,
-			howl_input, session);
-	g_io_channel_unref (channel);
-}
-
-static sw_result
-publish_reply (sw_discovery			discovery,
-	       sw_discovery_publish_status	status,
-	       sw_discovery_oid			id,
-	       sw_opaque			extra)
-{
-	return SW_OKAY;
-}
-
-
-static gboolean
-publish_service (int port)
-{
-	sw_result result;
-
-	result = sw_discovery_publish (howl_session, 0,
-				       get_share_name (),
-				       "_webdav._tcp",
-				       NULL, NULL,
-				       port,
-				       /* TODO: should be u=guest */
-				       /* text */ (unsigned char *) "", 0,
-				       publish_reply, NULL, &published_id);
-	if (result != SW_OKAY) {
-		return FALSE;
-	}
-	return TRUE;
-}
-
-static void
-stop_publishing (void)
-{
-	if (published_id != 0)
-		sw_discovery_cancel (howl_session, published_id);
-	published_id = 0;
-}
-#endif /* HAVE_HOWL */
-
-
 static void
 ensure_conf_dir (void)
 {
@@ -455,7 +199,7 @@
 static gboolean
 spawn_httpd (int port, pid_t *pid_out)
 {
-	char *free1, *free2, *free3, *free4;
+	char *free1, *free2, *free3, *free4, *free5, *free6;
 	gboolean res;
 	char *argv[10];
 	char *env[10];
@@ -502,6 +246,8 @@
 	free2 = env[i++] = g_strdup_printf ("HOME=%s", g_get_home_dir());
 	free3 = env[i++] = g_strdup_printf ("XDG_PUBLICSHARE_DIR=%s", public_dir);
 	free4 = env[i++] = g_strdup_printf ("XDG_CONFIG_HOME=%s", g_get_user_config_dir ());
+	free5 = env[i++] = g_strdup_printf ("GUS_SHARE_NAME=%s", get_share_name ());
+	free6 = env[i++] = g_strdup_printf ("GUS_LOGIN_LABEL=%s", _("Please log in as the user guest"));
 	env[i++] = "LANG=C";
 	env[i] = NULL;
 
@@ -521,6 +267,8 @@
 	g_free (free2);
 	g_free (free3);
 	g_free (free4);
+	g_free (free5);
+	g_free (free6);
 	g_free (public_dir);
 
 	if (!res) {
@@ -581,10 +329,6 @@
 	port = get_port ();
 	if (!spawn_httpd (port, &httpd_pid)) {
 		fprintf (stderr, "spawning httpd failed\n");
-	} else {
-		if (!publish_service (port)) {
-			fprintf (stderr, "publishing failed\n");
-		}
 	}
 }
 
@@ -592,7 +336,6 @@
 http_down (void)
 {
 	kill_httpd ();
-	stop_publishing ();
 }
 
 gboolean
@@ -602,21 +345,6 @@
 	init_dbus();
 #endif	
 
-#ifdef HAVE_AVAHI
-	if (!init_avahi ()) {
-		/* Print out the error string */
-		fprintf (stderr, "avahi init failed\n");
-		return FALSE;
-	}
-#endif
-#ifdef HAVE_HOWL
-	if (sw_discovery_init (&howl_session) != SW_OKAY) {
-		fprintf (stderr, "howl init failed\n");
-		return FALSE;
-	}
-	set_up_howl_session (howl_session);
-#endif
-
 	return TRUE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]