summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-03-24 21:15:21 +0000
committerLennart Poettering <lennart@poettering.net>2004-03-24 21:15:21 +0000
commitc174f20109543c0a0bc999369784a8ee52f7141c (patch)
treed8a892a1264831e9829f363c03bf3ae4bf7e5223
parent85b5c5365026f6a49d441e11810e8e3fe1d57ea8 (diff)
initial commit
git-svn-id: file:///home/lennart/svn/public/mod_mime_xattr/trunk@3 f01872de-66d6-0310-9185-fc3b30f50adc
-rw-r--r--LICENSE202
-rw-r--r--Makefile.am38
-rw-r--r--NOTICE1
-rwxr-xr-xbootstrap.sh43
-rw-r--r--configure.ac67
-rw-r--r--doc/Makefile.am34
-rw-r--r--doc/README.html.in283
-rw-r--r--src/Makefile.in64
-rw-r--r--src/mod_mime_xattr.c227
9 files changed, 959 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..d45b20d
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,38 @@
+# $Id$
+
+# Copyright 2004 Lennart Poettering
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you
+# may not use this file except in compliance with the License. You
+# may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+EXTRA_DIST=bootstrap.sh README LICENSE NOTICE
+SUBDIRS=src doc
+
+MAINTAINERCLEANFILES = README
+noinst_DATA = README NOTICE LICENSE
+
+README:
+ rm -f README
+ $(MAKE) -C doc README
+ cd $(srcdir) && ln -s doc/README README
+
+homepage: all dist
+ test -d $$HOME/homepage/private
+ mkdir -p $$HOME/homepage/private/projects/mod_mime_xattr
+ cp *.tar.gz $$HOME/homepage/private/projects/mod_mime_xattr
+ cp doc/README.html doc/style.css $$HOME/homepage/private/projects/mod_mime_xattr
+ cp $$HOME/homepage/private/projects/mod_mime_xattr/README.html $$HOME/homepage/private/projects/mod_mime_xattr/index.html
+
+distcleancheck:
+ @:
+
+.PHONY: homepage distcleancheck
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..9dffac5
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+This software was developed by Lennart Poettering, 2004
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 0000000..f843d46
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# $Id$
+
+# Copyright 2004 Lennart Poettering
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you
+# may not use this file except in compliance with the License. You
+# may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+run_versioned() {
+ local P
+ type -p "$1-$2" &> /dev/null && P="$1-$2" || local P="$1"
+
+ shift 2
+ "$P" "$@"
+}
+
+if [ "x$1" = "xam" ] ; then
+ set -ex
+ run_versioned automake 1.7 -a -c
+ ./config.status
+else
+ set -ex
+ rm -rf autom4te.cache
+ rm -f config.cache
+
+ run_versioned aclocal 1.7
+ autoheader
+ run_versioned automake 1.7 -a -c
+ autoconf -Wall
+
+ ./configure --sysconfdir=/etc "$@"
+
+ make clean
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..e770276
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,67 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+# $Id$
+
+# Copyright 2004 Lennart Poettering
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you
+# may not use this file except in compliance with the License. You
+# may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+AC_PREREQ(2.59)
+AC_INIT([mod_mime_xattr],[0.1],[mzzvzrkngge (at) 0pointer (dot) de])
+AC_CONFIG_SRCDIR([src/mod_mime_xattr.c])
+AC_CONFIG_HEADERS([config.h])
+AM_INIT_AUTOMAKE([foreign -Wall])
+
+AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/mod_mime_xattr/])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+
+AC_ARG_WITH(apxs,
+ AS_HELP_STRING(--with-apxs=PATH,/path/to/apxs),
+ [ AC_PATH_PROG(APXS, apxs, "notfound", "$withval:$PATH") ],
+ [ AC_PATH_PROG(APXS, apxs, "notfound", "/usr/local/apache/bin:/usr/local/bin:/usr/sbin:$PATH")])
+
+if test "x$APXS" = "xnotfound" ; then
+ AC_MSG_ERROR([*** Sorry, could not find apxs ***])
+fi
+
+# Check for libattr
+AC_CHECK_LIB([attr], [getxattr],, [AC_MSG_ERROR([*** Sorry, you have to install libattr ***])])
+AC_CHECK_HEADER([attr/xattr.h],, [AC_MSG_ERROR([*** Sorry, you have to install the libattr headers ***])])
+
+# LYNX documentation generation
+AC_ARG_ENABLE(lynx,
+ AS_HELP_STRING(--disable-lynx,Turn off lynx usage for documentation generation),
+[case "${enableval}" in
+ yes) lynx=yes ;;
+ no) lynx=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-lynx) ;;
+esac],[lynx=yes])
+
+if test x$lynx = xyes ; then
+ AC_CHECK_PROG(have_lynx, lynx, yes, no)
+
+ if test x$have_lynx = xno ; then
+ AC_MSG_ERROR([*** Sorry, you have to install lynx or use --disable-lynx ***])
+ fi
+fi
+
+AM_CONDITIONAL([USE_LYNX], [test "x$lynx" = xyes])
+
+AC_CONFIG_FILES([src/Makefile Makefile doc/Makefile doc/README.html])
+AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..f21e42c
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,34 @@
+# $Id$
+
+# Copyright 2004 Lennart Poettering
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you
+# may not use this file except in compliance with the License. You
+# may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+noinst_DATA = README.html README
+EXTRA_DIST = $(noinst_DATA) style.css README.html.in
+
+MAINTAINERCLEANFILES = README README.html
+CLEANFILES =
+
+if USE_LYNX
+README: README.html
+ lynx --dump $^ | sed 's,file://localhost/.*/doc/README.html,README,' > $@
+
+CLEANFILES += README
+endif
+
+tidy: README.html
+ tidy -e < README.html
+
+.PHONY: tidy
+
diff --git a/doc/README.html.in b/doc/README.html.in
new file mode 100644
index 0000000..7e97387
--- /dev/null
+++ b/doc/README.html.in
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="iso-8859-1"?> <!-- -*-html-helper-*- -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<title>ifplugd @PACKAGE_VERSION@</title>
+<link rel="stylesheet" type="text/css" href="style.css" />
+</head>
+
+<body>
+<h1><a name="top">ifplugd @PACKAGE_VERSION@</a></h1>
+
+<p><i>Copyright 2002-2004 Lennart Poettering &lt;@PACKAGE_BUGREPORT@&gt;</i></p>
+
+<ul class="toc">
+ <li><a href="#license">License</a></li>
+ <li><a href="#news">News</a></li>
+ <li><a href="#overview">Overview</a></li>
+ <li><a href="#status">Status</a></li>
+ <li><a href="#documentation">Documentation</a></li>
+ <li><a href="#requirements">Requirements</a></li>
+ <li><a href="#installation">Installation</a></li>
+ <li><a href="#acks">Acknowledgements</a></li>
+ <li><a href="#download">Download</a></li>
+</ul>
+
+<h2><a name="license">License</a></h2>
+
+<p>Copyright 2004 Lennart Poettering
+
+<p>Licensed under the Apache License, Version 2.0 (the "License"); you
+may not use this file except in compliance with the License. You may
+obtain a copy of the License at</p>
+
+<p>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></p>
+
+<p>Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied. See the License for the specific language governing
+permissions and limitations under the License.</p>
+
+<h2><a name="news">News</a></h2>
+
+<div class="news-date">Mon July 7 2003: </div> <p class="news-text"><a
+href="@PACKAGE_URL@ifplugd-0.14.tar.gz">Version
+0.14</a> released, changes include: autoconf usage, new dependency <a
+href="http://0pointer.de/lennart/projects/libdaemon/"><tt>libdaemon</tt></a>, wireless LAN support, support for
+suspending/resuming, many fixes</p>
+
+<h2><a name="overview">Overview</a></h2>
+
+<p><tt>ifplugd</tt> is a Linux daemon which will automatically
+configure your ethernet device when a cable is plugged in and
+automatically unconfigure it if the cable is pulled. This is useful on
+laptops with onboard network adapters, since it will only configure
+the interface when a cable is really connected.</p>
+
+<p><tt>ifplugd</tt> ifplugd interfaces with your distribution's native network
+ configuration utilities.</p>
+
+<p>Some features:</p>
+
+<ul>
+ <li>Uses your distribution's native <tt>ifup</tt>/<tt>ifdown</tt> programs.</li>
+
+ <li>May beep when the cable is unplugged, plugged, the interface
+ configuration succeeded or failed.</li>
+
+ <li>Supports the Linux <tt>SIOCETHTOOL</tt> (newer, aka <tt>ethtool</tt> API), <tt>SIOCGMIIREG</tt>
+ (older, aka <tt>mii-diag</tt>/<tt>mii-tool</tt> API) and SIOCDEVPRIVATE (oldest, aka
+ <tt>mii-tool</tt> API) <tt>ioctl()</tt>s for getting link status.</li>
+
+ <li>Syslog support</li>
+
+ <li>Small program - the binary is just 19 KB (plus 11 KB for <tt>libdaemon</tt>).</li>
+
+ <li>Multiple ethernet interface support</li>
+
+ <li>Can be configured to ignore short "unplugged" periods
+ (-d option) or short "plugged" periods(<tt>-u</tt>
+ option)</li>
+
+ <li>Support for wireless networking. Whenever an association to an
+AP is detected the network is configured. Have a look on <a
+href="http://0pointer.de/lennart/projects/waproamd/"><tt>waproamd</tt></a>
+if you need a facility to configure WEP keys before AP associations succeed.</li>
+
+ <li>Compatibility mode for network devices which do not support cable detection (<tt>-F</tt> option)</li>
+</ul>
+
+<h2><a name="status">Status</a></h2>
+
+<p>Version @PACKAGE_VERSION@ is stable and has all the sensible features its users could think of.</p>
+
+<h2><a name="documentation">Documentation</a></h2>
+
+<p>Have a look on the man pages <a href="@PACKAGE_URL@ifplugd.8.xml"><tt>ifplugd(8)</tt></a>, <a href="@PACKAGE_URL@ifplugstatus.8.xml"><tt>ifplugstatus(8)</tt></a>, <a href="@PACKAGE_URL@ifplugd.conf.5.xml"><tt>ifplugd.conf(5)</tt></a>. (An XSLT capable browser is required)</p>
+
+<h3>Configuration</h3>
+
+<p>Edit <tt>/etc/ifplugd/ifplugd.conf</tt> for configuration
+changes. This file is a bourne shell script sourced by the init script
+and used to start <tt>ifplugd</tt> with appropriate arguments. You may specify more than
+one ethernet interface in <tt>INTERFACES</tt>. For each interface a
+seperate instance of <tt>ifplugd</tt> is spawned. The arguments specified in
+<tt>ARGS</tt> are append to <tt>ifplugd</tt>'s command line. Have a look on
+<tt>ifplugd -h</tt> or <tt>man ifplugd</tt> for further information
+about the available options.</p>
+
+<p>The network interface which is controlled by <tt>ifplugd</tt>
+should not be configured automatically by your distribution's network
+subsystem, since <tt>ifplugd</tt> will do this for you if needed.</p>
+
+<p>On Debian systems, any interfaces named in ifplugd's
+<tt>INTERFACES</tt> environment variable should not also be listed in
+an "auto" stanza in <tt>/etc/network/interfaces</tt>.</p>
+
+<h3>Troubleshooting</h3>
+
+<p>When you are using the hotplug subsystem (Debian package
+<tt>hotplug</tt>) you may notice that the network device is configured
+even when it is not listed on an <tt>auto</tt> line in
+<tt>/etc/network/interface</tt>. This may be due to <tt>hotplug</tt>
+being configured to <tt>ifup</tt> the network interface when it
+becomes available. This was the default behavior in the Debian
+<tt>hotplug</tt> package prior to release <tt>0.0.20030117-1</tt>, for
+example. To prevent this you should either upgrade your
+<tt>hotplug</tt> package or comment out the <tt>ifup</tt> call in
+<tt>/etc/hotplug/net.agent</tt>.</p>
+
+<p>When using <tt>ifplugd</tt> together with APM (and probably ACPI)
+suspends, strange things may happen: some network devices fail to
+detect the network cable for a short period of time before and after
+the suspend. When using the <tt>-f</tt> switch, this will be treated
+as "no link beat", thus the network is shutdown after a
+timeout. During this timeout the machine changes to suspended
+state. When it is resumed again, the timeout period will have expired
+and so the network is deconfigured, however, as the next cable
+detection succeeds, the network is configured again immediately. To
+fix this problem, <tt>ifplugd</tt> should be disabled before the APM
+suspend and enabled back after the suspend. This may be done by using
+<tt>apmd</tt> and adding a script to
+<tt>/etc/apm/{suspend,resume}.d</tt> which simply calls
+<tt>/etc/init.d/ifplugd suspend</tt>, resp. <tt>/etc/init.d/ifplugd
+resume</tt>. It might even be a good idea to shut down the network
+completely during suspend, this may be achieved by calling
+<tt>/etc/init.d/ifplugd stop</tt> and <tt>/etc/init.d/ifplugd
+start</tt> in the appropriate places. I strongly urge the packagers of
+this software for the Linux distributions to add such scripts to their
+packages.</p>
+
+<h3>FAQ</h3>
+
+<ol>
+ <li><p><b>Q:</b> I want to use <tt>ifplugd</tt> with my PCMCIA device, but <tt>ifplugd</tt> quits
+ when it doesn't find <tt>eth0</tt>, when I have not inserted the
+ card. What can I do?</p>
+
+ <p><b>A:</b> Use the <tt>-f</tt> switch. This is not very clean however,
+ since modprobe is called on each cable detection query of <tt>ifplugd</tt> to
+ load a module for the network device. This is suboptimal. You should
+ probably run <tt>ifplugd</tt> only when the card is really inserted.</p>
+ </li>
+
+ <li><p><b>Q:</b> I am using the <tt>-f</tt> switch, but the kernel logs are getting filled
+ with messages like "<tt>modprobe: modprobe: Can't locate module
+ eth0</tt>". What can I do?</p>
+
+ <p><b>A:</b> Make sure you have a line like <tt>alias eth0 off</tt> in your <tt>/etc/modules.conf</tt></p>
+ </li>
+
+ <li><p><b>Q:</b> When the cable is unplugged and the interface shut down it is
+ still available with <tt>ifconfig</tt> and markes as UP. Why this?</p>
+
+ <p><b>A:</b> <tt>ifplugd</tt> cannot detect the link beat with a shut down interface on
+ certain (most as of kernel 2.4.19) network drivers. Thus <tt>ifplugd</tt>
+ enables the interface before querying the link status. This may
+ be switched off with -a flag. You might want to use it if you
+ have a sane network driver (e.g. <tt>eepro100</tt>). The subdirectory
+ <tt>patches/</tt> in the <tt>ifplugd</tt> distribution includes a patch for the
+ 8139too 0.9.26 driver, which makes the driver compatible with
+ -a. Don't ask me how to apply this patch. If you don't know, you
+ won't need it.</p></li>
+
+ <li><p><b>Q:</b> Does it work with anything else than plain ethernet or wireless LAN?</p>
+
+ <p><b>A:</b> Certainly not, since the <tt>MII</tt> and
+<tt>ETHTOOL</tt> <tt>ioctl()</tt>s and the wireless extension don't
+exist on
+ other network device types.</p></li>
+
+ <li><p><b>Q:</b> I have a Realtek 8139 based network card. Everytime <tt>ifplugd</tt>
+ starts on bootup my machine freezes. What can I do?</p>
+
+ <p><b>A:</b> This is a bug in the <tt>8139too</tt> driver 0.9.25 (at least) shipped
+ with Linux 2.4.19, please upgrade to <tt>8139too</tt> 0.9.26 (Linux 2.4.20
+ or seperately at <a href="http://www.sourceforge.net/projects/gkernel/">http://www.sourceforge.net/projects/gkernel/</a>).</p></li>
+
+
+ <li><p><b>Q:</b> There are already <tt>laptop-net</tt>'s <tt>ifd</tt> and <tt>miid</tt>, why did you write
+ your own daemon?</p>
+
+ <p><b>A:</b> <tt>laptop-net</tt> was too integrated with its profile
+system and didn't work on my hardware when I had a look on it. It
+seemed easier to me to write a simple but feature complete replacement
+than using laptop-net without most of the special features disabled. I
+didn't know about <tt>miid</tt> when I wrote
+ <tt>ifplugd</tt>, but in any case <tt>ifplugd</tt> is much better
+than <tt>miid</tt>. For a
+ comparison of <tt>miid</tt> and <tt>ifplugd</tt>, have a look on
+
+ <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=162763&amp;repeatmerged=yes">http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=162763&amp;repeatmerged=yes</a></p></li>
+</ol>
+
+
+<h2><a name="requirements">Requirements</a></h2>
+
+<p>A newer Linux Kernel (I think 2.2 is good enough, alltough I tested it
+only with 2.4) with a compatible device driver and
+ethernet card. Most modern cards and drivers are compatible, like mine
+which works with the <tt>8139too</tt> driver.</p>
+
+<p><tt>ifplugd</tt> was developed and tested on Debian GNU/Linux
+"testing" from July 2003, it should work on most other Linux
+distributions (and maybe Unix versions) since it uses GNU autoconf and
+GNU libtool for source code configuration and shared library
+management.</p>
+
+<p>The machine used was a Medion 9580-F laptop with a Realtek 8139
+network card and a PRISM1 PCMCIA wireless LAN card.</p>
+
+<p><tt>ifplugd</tt> needs <a
+href="http://0pointer.de/lennart/projects/libdaemon/"><tt>libdaemon</tt></a>.</p>
+
+<h2><a name="installation">Installation</a></h2>
+
+<p>As this package is made with the GNU autotools you should run
+<tt>./configure</tt> inside the distribution directory for configuring
+the source tree. After that you should run <tt>make</tt> for
+compilation and <tt>make install</tt> (as root) for installation of
+<tt>ifplugd</tt>.</p>
+
+<p>The installation scripts create an init script in
+<tt>${sysconfdir}/init.d/ifplugd</tt>, however no <tt>/etc/rc?.d/</tt> links are created
+for it.</p>
+
+<p>Extensive installation instructions for <tt>ifplugd</tt> are available at <a href="http://www.acmc.uq.edu.au/~gbe/linux/installation_of_ifplugd.html">Geoff Ericksson's web site</a>.</p>
+
+<h2><a name="acks">Acknowledgements</a></h2>
+
+<p>For the developers of <tt>mii-diag</tt>, <tt>ethtool</tt> and <tt>laptop-net</tt>, since I looked
+on their source codes for learning how to use the link beat ioctls.</p>
+
+<p>Oliver Kurth for packaging <tt>ifplugd</tt> for Debian and <tt>ifplugd</tt>'s
+manpage</p>
+
+<p>Thomas Hood, Asgeir Nilsen, Sean Reifschneider, R. Steve McKown, David Mitchell, Norbert Preining, Herbert Graeber for patches</p>
+
+<p>Frederic Lepied for integrating <tt>ifplugd</tt> into Mandrake Linux</p>
+
+<h2><a name="download">Download</a></h2>
+
+<p>The newest release is always available from <a href="@PACKAGE_URL@">@PACKAGE_URL@</a></p>
+
+<p>The current release is <a href="@PACKAGE_URL@ifplugd-@PACKAGE_VERSION@.tar.gz">@PACKAGE_VERSION@</a></p>
+
+<p>Get <tt>ifplugd</tt>'s development sources from the <a href="http://subversion.tigris.org/">Subversion</a> <a href="https://seth.intheinter.net:8081/svn/ifplugd/">repository</a>.</p>
+
+<p>You may find an up to date Debian package of <tt>ifplugd</tt> on the <a href="http://packages.debian.org/ifplugd">Debian package repository</a>.</p>
+
+<p>Packages for Mandrake Linux may be found in the Cooker distribution; Gentoo packages are available as well; <a href="http://packman.links2linux.de/">SuSE packages</a> are available courtesy of Herbert Graeber.</p>
+
+<p>If you want to be notified whenever I release a new version of this software use the subscription feature of <a href="http://freshmeat.net/projects/ifplugd/">Freshmeat</a>.</p>
+
+<p><b>New!</b> There is a joint <tt>ifplugd</tt> and <tt>waproamd</tt> <a href="https://seth.intheinter.net/mailman/listinfo/ifplugd-discuss">mailing list</a> available.</p>
+
+<hr/>
+<address class="grey">Lennart Poettering &lt;@PACKAGE_BUGREPORT@&gt;, February 2004</address>
+<div class="grey"><i>$Id$</i></div>
+
+</body>
+</html>
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..0311c0d
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,64 @@
+# $Id$
+
+# Copyright 2004 Lennart Poettering
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you
+# may not use this file except in compliance with the License. You
+# may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+DISTFILES=Makefile.in mod_mime_xattr.c
+APXS=@APXS@
+APACHECTL=apachectl
+
+# additional user defines, includes and libraries
+#DEF=-Dmy_define=my_value
+#INC=-Imy/include/dir
+#LIB=-Lmy/lib/dir -lc -lmylib
+LIB=-lattr
+
+# the default target
+all: mod_mime_xattr.so
+
+# compile the DSO file
+mod_mime_xattr.so: mod_mime_xattr.c
+ $(APXS) -c $(DEF) $(INC) $(LIB) mod_mime_xattr.c
+
+# install the DSO file into the Apache installation
+# and activate it in the Apache configuration
+install: all
+ $(APXS) -i -a -n 'mime_xattr' mod_mime_xattr.so
+
+# cleanup
+clean:
+ -rm -f mod_mime_xattr.o mod_mime_xattr.so
+
+# reload the module by installing and restarting Apache
+reload: install restart
+
+# the general Apache start/restart/stop procedures
+start:
+ $(APACHECTL) start
+restart:
+ $(APACHECTL) restart
+stop:
+ $(APACHECTL) stop
+
+distdir:
+ mkdir -p $(distdir)
+ cp -p $(DISTFILES) $(distdir)
+
+mostlyclean: clean
+distclean: clean
+
+maintainer-clean: clean
+ rm -f Makefile
+
+.PHONY: all clean maintainer-clean mostlyclean distclean distdir install reload start stop restart
diff --git a/src/mod_mime_xattr.c b/src/mod_mime_xattr.c
new file mode 100644
index 0000000..434de4a
--- /dev/null
+++ b/src/mod_mime_xattr.c
@@ -0,0 +1,227 @@
+/* $Id$ */
+
+/***
+
+ Copyright 2004 Lennart Poettering
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you
+ may not use this file except in compliance with the License. You
+ may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+***/
+
+#include <sys/types.h>
+#include <attr/xattr.h>
+#include <ctype.h>
+
+#include "httpd.h"
+#include "http_config.h"
+#include "http_core.h"
+#include "http_log.h"
+#include "http_main.h"
+#include "http_protocol.h"
+#include "http_request.h"
+#include "ap_config.h"
+
+#define XATTR_NAME_MIMETYPE "user.mime-type"
+#define XATTR_NAME_ENCODING "user.mime-encoding"
+#define XATTR_NAME_CHARSET "user.charset"
+#define XATTR_NAME_HANDLER "user.apache-handler"
+
+module MODULE_VAR_EXPORT mime_xattr_module;
+
+struct mime_xattr_dir_config {
+ int enable_mime_type;
+ int enable_handler;
+};
+
+static void* create_mime_xattr_dir_config(pool *p, char*dummy) {
+ struct mime_xattr_dir_config *c = (struct mime_xattr_dir_config*) ap_palloc(p, sizeof(struct mime_xattr_dir_config));
+ c->enable_mime_type = 0;
+ c->enable_handler = 0;
+ return c;
+}
+
+static const char *enable_xattr_mime_type(cmd_parms *parms, void *mconfig, int flag) {
+ struct mime_xattr_dir_config *c = (struct mime_xattr_dir_config*) mconfig;
+ c->enable_mime_type = flag;
+ return NULL;
+}
+
+static const char *enable_xattr_handler(cmd_parms *parms, void *mconfig, int flag) {
+ struct mime_xattr_dir_config *c = (struct mime_xattr_dir_config*) mconfig;
+ c->enable_handler = flag;
+ return NULL;
+}
+
+static const command_rec mime_xattr_cmds[] = {
+ {"XAttrMimeType",
+ enable_xattr_mime_type,
+ NULL,
+ OR_FILEINFO,
+ FLAG,
+ "Requires 'On' or 'Off' for enabling resp. disabling usage of file system extended attribute data for MIME type detection." },
+
+ {"XAttrHandler",
+ enable_xattr_handler,
+ NULL,
+ OR_FILEINFO,
+ FLAG,
+ "Requires 'On' or 'Off' for enabling resp. disabling usage of file system extended attribute data for handler detection." },
+
+ { NULL }
+};
+
+static char* get_xattr(pool *p, const char *fn, const char *attr) {
+ char v[256];
+ ssize_t l;
+
+ if ((l = lgetxattr(fn, attr, v, sizeof(v)-1)) < 0)
+ if ((l = getxattr(fn, attr, v, sizeof(v)-1)) < 0)
+ return NULL;
+
+ v[l] = 0;
+
+ return ap_pstrdup(p, v);
+}
+
+static char* validate_charset(char *f) {
+ char *c;
+
+ for (c = f; *c; c++) {
+ *c = tolower(*c);
+ if (!(*c >= 'a' && *c <= 'z') && !(*c >= '0' && *c <= '9') && *c != '-')
+ return NULL;
+ }
+
+ return c > f ? f : NULL;
+}
+
+#define validate_encoding(f) validate_charset(f)
+#define validate_handler(f) validate_charset(f)
+
+static char* validate_mime_type(char *f) {
+ char *c, *slash = NULL;
+
+ for (c = f; *c; c++) {
+ *c = tolower(*c);
+
+ if (*c == '/') {
+ if (!slash && c > f) {
+ slash = c;
+ continue;
+ } else
+ return NULL;
+ }
+
+ if (!(*c >= 'a' && *c <= 'z') && !(*c >= '0' && *c <= '9') && *c != '-')
+ return NULL;
+ }
+
+ return c > f && slash && slash < c-1 ? f : NULL;
+}
+
+static int find_ct(request_rec *r) {
+ int result = DECLINED;
+ struct mime_xattr_dir_config* c;
+
+ if (r->finfo.st_mode == 0 || !r->filename || !S_ISREG(r->finfo.st_mode))
+ return DECLINED;
+
+ c = (struct mime_xattr_dir_config*) ap_get_module_config(r->per_dir_config, &mime_xattr_module);
+
+ if (c->enable_mime_type) {
+ char *mime_type, *charset, *encoding;
+
+ if ((charset = get_xattr(r->pool, r->filename, XATTR_NAME_CHARSET)))
+ if (!(charset = validate_charset(charset)))
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad charset specification on file <%s>", r->filename);
+
+ if ((mime_type = get_xattr(r->pool, r->filename, XATTR_NAME_MIMETYPE))) {
+ if (!(mime_type = validate_mime_type(mime_type)))
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad mime type specification on file <%s>", r->filename);
+ else {
+ if (charset)
+ mime_type = ap_psprintf(r->pool, "%s; charset=%s", mime_type, charset);
+
+ r->content_type = mime_type;
+ result = OK;
+ }
+ }
+
+ if (charset && !mime_type && r->content_type) {
+ char *a, *ct = ap_pstrdup(r->pool, r->content_type);
+ static const char spec[] = "; charset=";
+
+ if ((a = strstr(ct, spec))) {
+ char *e;
+ e = a+strlen(spec);
+ e += strcspn(e, "; ");
+
+ *a = 0;
+
+ r->content_type = ap_psprintf(r->pool, "%s; charset=%s%s", ct, charset, e);
+ } else
+ r->content_type = ap_psprintf(r->pool, "%s; charset=%s", ct, charset);
+ }
+
+ if ((encoding = get_xattr(r->pool, r->filename, XATTR_NAME_ENCODING))) {
+ if (!(encoding = validate_encoding(encoding)))
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad encoding specification on file <%s>", r->filename);
+ else
+ r->content_encoding = encoding;
+ }
+ }
+
+ if (c->enable_handler) {
+ char *handler;
+
+ if ((handler = get_xattr(r->pool, r->filename, XATTR_NAME_HANDLER))) {
+ if (!(handler = validate_handler(handler)))
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server, "mod_mime_xattr: bad apache handler specification on file <%s>", r->filename);
+ else {
+ r->handler = handler;
+ result = OK;
+ }
+ }
+ }
+
+ return result;
+}
+
+/* Dispatch list for API hooks */
+module MODULE_VAR_EXPORT mime_xattr_module = {
+ STANDARD_MODULE_STUFF,
+ NULL, /* module initializer */
+ create_mime_xattr_dir_config, /* create per-dir config structures */
+ NULL, /* merge per-dir config structures */
+ NULL, /* create per-server config structures */
+ NULL, /* merge per-server config structures */
+ mime_xattr_cmds, /* table of config file commands */
+ NULL, /* [#8] MIME-typed-dispatched handlers */
+ NULL, /* [#1] URI to filename translation */
+ NULL, /* [#4] validate user id from request */
+ NULL, /* [#5] check if the user is ok _here_ */
+ NULL, /* [#3] check access by host address */
+ find_ct, /* [#6] determine MIME type */
+ NULL, /* [#7] pre-run fixups */
+ NULL, /* [#9] log a transaction */
+ NULL, /* [#2] header parser */
+ NULL, /* child_init */
+ NULL, /* child_exit */
+ NULL /* [#0] post read-request */
+#ifdef EAPI
+ ,NULL, /* EAPI: add_module */
+ NULL, /* EAPI: remove_module */
+ NULL, /* EAPI: rewrite_command */
+ NULL /* EAPI: new_connection */
+#endif
+};