]> arthur.barton.de Git - netatalk.git/commitdiff
Merge master
authorFrank Lahm <franklahm@googlemail.com>
Wed, 31 Aug 2011 17:37:18 +0000 (19:37 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 31 Aug 2011 17:37:18 +0000 (19:37 +0200)
35 files changed:
NEWS
bin/afile/.gitignore [deleted file]
configure.in
contrib/macusers/macusers.in
contrib/shell_utils/apple_dump.in
contrib/shell_utils/asip-status.pl.in
distrib/initscripts/.gitignore
distrib/initscripts/Makefile.am
distrib/initscripts/rc.afpd.netbsd.tmpl
distrib/initscripts/rc.atalk.bsd.tmpl
distrib/initscripts/rc.atalk.debian.tmpl
distrib/initscripts/rc.atalk.gentoo.tmpl
distrib/initscripts/rc.atalk.redhat-systemd.tmpl [new file with mode: 0644]
distrib/initscripts/rc.atalk.redhat-sysv.tmpl [new file with mode: 0644]
distrib/initscripts/rc.atalk.redhat.tmpl [deleted file]
distrib/initscripts/rc.atalk.suse.tmpl
distrib/initscripts/rc.atalk.sysv.tmpl
distrib/initscripts/rc.atalk.tru64.tmpl
distrib/initscripts/rc.atalkd.netbsd.tmpl
distrib/initscripts/rc.cnid_metad.netbsd.tmpl
distrib/initscripts/rc.papd.netbsd.tmpl
distrib/initscripts/rc.timelord.netbsd.tmpl
distrib/initscripts/service.atalk.redhat-systemd.tmpl [new file with mode: 0644]
etc/afpd/afp_options.c
etc/afpd/auth.c
etc/afpd/auth.h
etc/afpd/main.c
etc/cnid_dbd/cmd_dbd_scanvol.c
etc/cnid_dbd/cnid_metad.c
etc/cnid_dbd/dbif.c
include/atalk/util.h
libatalk/unicode/util_unistr.c
libatalk/util/server_lock.c
libatalk/util/unix.c
macros/netatalk.m4

diff --git a/NEWS b/NEWS
index ae1f6b6eac1b591a2af5589fa286254498d6a76a..b6b387c42b6f7390b479dfcd7694e461df8671a0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,9 +3,12 @@ Changes in 2.2.1
 
 * NEW: afpd: disable continous service feature by default, new option
        -keepsessions to enable it
-* UPD: afpd: Enhance ACL support detection for volumes: enable them per volume if
-       1) ACL support compiled in, 2) the volume supports ACLs, 3) the new volume
-       option "noacls" is not set for the volume.
+* NEW: configure option "--enable-redhat-systemd" for Fedora15 and later.
+       "--enable-redhat" is renamed "--enable-redhat-sysv".
+* UPD: afpd: Enhance ACL support detection for volumes: enable them per volume
+       if
+       1) ACL support compiled in, 2) the volume supports ACLs, 3) the new
+       volume option "noacls" is not set for the volume.
        The previous behaviour was to enable ACL support for a volume if
        1) it was compiled in and 2) the volume supported ACLs. There was no way
        to disable ACLs for a volume.
@@ -24,24 +27,27 @@ Changes in 2.2.1
 * FIX: afpd: fix a crash when searching for a UUID that is not a special
        local UUID and LDAP support is not compiled in
 * FIX: afpd: .volinfo file not created on first volume access if user in rolist
-* FIX: afpd: possible crash at startup when registering with Avahi when Avahi is
-       not running
+* FIX: afpd: possible crash at startup when registering with Avahi
+       when Avahi is not running
 * FIX: afpd: return correct user/group type when mapping UUIDs to names
-* FIX: afpd: for directories add DARWIN_ACE_DELETE ACE if DARWIN_ACE_ADD_SUBDIRECTORY
-       is set
-* FIX: afpd: afpd crashed when it failed to register with Avahi because eg user
-       service registration is disabled in the Avahi config
+* FIX: afpd: for directories add DARWIN_ACE_DELETE ACE
+       if DARWIN_ACE_ADD_SUBDIRECTORY is set
+* FIX: afpd: afpd crashed when it failed to register with Avahi because eg
+       user service registration is disabled in the Avahi config
 * FIX: cnid_dbd: increase BerkeleyDB locks and lockobjs
 * FIX: cnid_dbd: implement -d option, deletes CNID db
+* FIX: dbd: better detection of local (or SMB/NFS) modifications on AFP volumes
 * FIX: suse: initscript return better status
 * FIX: Sourcecode distribution: add missing headers
 * FIX: Solaris 10: missing dirfd replacement function
 * FIX: case-conversion of surrogate pair
-* FIX: Compilation error on GNU/kFreeBSD, fixes Bug ID 3392794 and Debian #630349
+* FIX: Compilation error on GNU/kFreeBSD, fixes Bug ID 3392794 and
+       Debian #630349
 * FIX: Fix Debian Bug#637025
 * FIX: Multiple *BSD compilation compatibility fixes, Bug ID 3380785
+* FIX: precompose_w() failed if tail character is decomposed surrogate pair
 
-Changes in 2.2
+Changes in 2.2.0
 ==============
 
 * NEW: afpd: new volume option "nonetids"
@@ -61,7 +67,8 @@ Changes in 2.2
 * FIX: afpd: new catsearch was broken
 * FIX: afpd: only use volume UUIDs in master afpd
 * FIX: dbd: Multiple fixes, reliable locking
-* FIX: ad file suite: fix an error that resulted in CNID database inconsistencies
+* FIX: ad file suite: fix an error that resulted in CNID database
+       inconsistencies
 
 Changes in 2.2beta4
 ===================
diff --git a/bin/afile/.gitignore b/bin/afile/.gitignore
deleted file mode 100644 (file)
index 5050c88..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Makefile
-Makefile.in
-achfile
-afile
-.deps
-.libs
-.gitignore
-achfile.o afile.o common.o
index 94320d9326646eb2b920dc0b510b509779e386a9..db254ab9727498078875a0ec773f06a62da50d4a 100644 (file)
@@ -324,7 +324,8 @@ AM_CONDITIONAL(BUILD_PAM, test x$compile_pam = xyes)
 AM_CONDITIONAL(USE_PGP, test x$compile_pgp = xyes)
 AM_CONDITIONAL(DEFAULT_HOOK, test x$neta_cv_have_libgcrypt != xyes && test x$neta_cv_have_openssl != xyes)
 AM_CONDITIONAL(USE_NETBSD, test x$sysv_style = xnetbsd)
-AM_CONDITIONAL(USE_REDHAT, test x$sysv_style = xredhat)
+AM_CONDITIONAL(USE_REDHAT_SYSV, test x$sysv_style = xredhat-sysv)
+AM_CONDITIONAL(USE_REDHAT_SYSTEMD, test x$sysv_style = xredhat-systemd)
 AM_CONDITIONAL(USE_SUSE, test x$sysv_style = xsuse)
 AM_CONDITIONAL(USE_SHADOWPW, test x$shadowpw = xyes)
 AM_CONDITIONAL(USE_TRU64, test x$sysv_style = xtru64)
index 75ddb5c4366e41eb78b2e0d432a9209ae5a06470..b37955512118e7164e9f379ba1d5260e1074dc23 100644 (file)
@@ -2,6 +2,7 @@
 
 use strict;
 use Socket;
+use File::Basename;
 use vars qw($MAC_PROCESS $PS_STR $MATCH_STR $ASIP_PORT_NO $ASIP_PORT $LSOF);
 
 # Written for linux; may have to be modified for your brand of Unix.
@@ -9,6 +10,15 @@ use vars qw($MAC_PROCESS $PS_STR $MATCH_STR $ASIP_PORT_NO $ASIP_PORT $LSOF);
 # Support Solaris added by Frank Lahm <franklahm@googlemail.com>.
 # Support has also been added for 16 character usernames.
 
+if ($ARGV[0] =~ /^(-v|-version|--version)$/ ) {
+        printf ("%s \(Netatalk @NETATALK_VERSION@\)\n", basename($0));
+        exit(1);
+} elsif ($ARGV[0] =~ /^(-h|-help|--help)$/ ) {
+        printf ("usage: %s \[-v|-version|--version|-h|-help|--help\]\n", basename($0));
+        printf ("Show users connecting via AFP\n");
+        exit(1);
+}
+
 $MAC_PROCESS = "afpd";
 if ($^O eq "freebsd" || $^O eq "openbsd") {
         $PS_STR    = "-awwxouser,pid,ppid,start,command";
index 33058cd0b7c68f812bfdbfedb5a14c7a39a05157..65eec7908e0b4ea2c61e5f52308a1c2b5f537a13 100755 (executable)
@@ -56,10 +56,11 @@ $finderinfo = 0;              #  0: unknown   1: file   2: directory
 while ($arg = shift @ARGV)
 {
     if  ($arg =~ /^(-h|-help|--help)$/ ) {
-        printf ("usage: %s [-a] FILE|DIR\n"     ,basename($0));
-        printf (" or:   %s -f FILE\n"           ,basename($0));
-        printf (" or:   %s -d FILE\n"           ,basename($0));
-        printf (" or:   %s -h|-help|--help\n"   ,basename($0));
+        printf ("usage: %s [-a] FILE|DIR\n"           ,basename($0));
+        printf (" or:   %s -f FILE\n"                 ,basename($0));
+        printf (" or:   %s -d FILE\n"                 ,basename($0));
+        printf (" or:   %s -h|-help|--help\n"         ,basename($0));
+        printf (" or:   %s -v|-version|--version\n"   ,basename($0));
         printf ("Dump AppleSingle/AppleDouble format file.\n");
         printf ("\n");
         printf ("  -a (default)     Dump a AppleSingle/AppleDouble file for FILE or DIR\n");
@@ -71,6 +72,7 @@ while ($arg = shift @ARGV)
         printf ("  -f               Dump FILE. Assume FinderInfo to be FileInfo.\n");
         printf ("  -d               Dump FILE. Assume FinderInfo to be DirInfo.\n");
         printf ("  -h,-help,--help  Display this help and exit\n");
+        printf ("  -v,-version,--version  Show version and exit\n");
         printf ("\n");
         printf ("There is no way to detect whether FinderInfo is FileInfo or DirInfo.\n");
         printf ("By default, %s examins whether file or directory,\n"   ,basename($0));
@@ -78,7 +80,10 @@ while ($arg = shift @ARGV)
         printf ("and so on.\n");
         printf ("If setting option -f or -d, %s assume FinderInfo and doesn't look for\n");
         printf ("another file.\n");
-        exit 0;
+        exit 1;
+    } elsif ($arg =~ /^(-v|-version|--version)$/ ) {
+        printf ("%s \(Netatalk @NETATALK_VERSION@\)\n", basename($0));
+        exit 1;
     } elsif ($arg eq "-a") {
         $finderinfo = 0;
     } elsif ($arg eq "-f") {
index ccd0332edd6c4ccf7094a71d2a1e08f8f743a9e4..4fa260947ca9c059fb354350d8cd22c2b71a5c8c 100755 (executable)
@@ -16,7 +16,7 @@
 #
 
 #
-# This edition is a part of netatalk.
+# This edition is a part of netatalk @NETATALK_VERSION@.
 #
 
 use strict;
@@ -32,12 +32,29 @@ while ($arg = shift @ARGV)
        $main::show_icon = 1 if ($arg eq "-i");
        $main::debug = 1 if ($arg eq "-d");
        $main::hexdump = 1 if ($arg eq "-x");
+       $main::showver = 1 if ($arg eq "-v");
+       $main::showver = 1 if ($arg eq "-version");
+       $main::showver = 1 if ($arg eq "--version");
        $hostport = $arg if ($arg !~ /^-/);
 }
 
+if ($main::showver ==1)
+{
+        print "$0\n";
+        print "Original edition: 7 May 1997 \(v1.0\) James W. Abendschan\n";
+        print "This edition is a part of Netatalk @NETATALK_VERSION@\n";
+        exit(-1);
+}
+
 if ($hostport eq "")
 {
-       print "usage: $0 hostname[:port] [-i show icon] [-d debug] [-x hex dump]\n";
+       print "usage: $0 [-d] [-i] [-x] hostname[:port]\n";
+       print "       $0 -v|-version|--version\n";
+       print "Queries AFP servers for their capabilities.\n";
+       print "  -d: Enable debug output.\n";
+       print "  -i: Show icon if it exists.\n";
+       print "  -x: Enable hex dump output.\n";
+       print "  -v,-version,--version: Show version.\n";
        exit(-1);
 }
 
index 3ed4c80ccd2682d80ededfe1d7a0c95a27df61c4..af1675fd9ea720b0329398be8250ad7a1b996121 100644 (file)
@@ -1,10 +1,12 @@
 Makefile
 Makefile.in
 rc.atalk.bsd
-rc.atalk.redhat
+rc.atalk.redhat-sysv
+rc.atalk.redhat-systemd
 rc.atalk.suse
 rc.atalk.tru64
 rc.atalk.sysv
+service.atalk.redhat-systemd
 netatalk
 atalk
 .gitignore
index 833b0872fc65442f55cb4e3a5bcecd3f8225e6f6..5d73af0b2f24059c9ec348c3c79c85140d6cf482 100644 (file)
@@ -12,11 +12,14 @@ pkgconfdir = @PKGCONFDIR@
        sed -e s@:BINDIR:@${bindir}@ \
            -e s@:SBINDIR:@${sbindir}@ \
            -e s@:ETCDIR:@${pkgconfdir}@ \
+           -e s@:PKGLIBEXECDIR:@${pkglibexecdir}@ \
+           -e s@:NETATALK_VERSION:@${NETATALK_VERSION}@ \
            <$< >$@
 
 GENERATED_FILES = \
        rc.afpd.netbsd          \
-       rc.atalk.redhat         \
+       rc.atalk.redhat-sysv    \
+       rc.atalk.redhat-systemd \
        rc.atalk.tru64          \
        rc.atalk.bsd            \
        rc.atalkd.netbsd        \
@@ -26,11 +29,13 @@ GENERATED_FILES = \
        rc.timelord.netbsd      \
        rc.atalk.sysv           \
        rc.atalk.gentoo         \
-       rc.atalk.debian
+       rc.atalk.debian         \
+       service.atalk.redhat-systemd
 
 TEMPLATES = \
        rc.afpd.netbsd.tmpl             \
-       rc.atalk.redhat.tmpl            \
+       rc.atalk.redhat-sysv.tmpl       \
+       rc.atalk.redhat-systemd.tmpl    \
        rc.atalk.tru64.tmpl             \
        rc.atalk.bsd.tmpl               \
        rc.atalkd.netbsd.tmpl           \
@@ -40,9 +45,10 @@ TEMPLATES = \
        rc.timelord.netbsd.tmpl         \
        rc.atalk.sysv.tmpl              \
        rc.atalk.gentoo.tmpl            \
-       rc.atalk.debian.tmpl
+       rc.atalk.debian.tmpl            \
+       service.atalk.redhat-systemd.tmpl
 
-CLEANFILES = $(GENERATED_FILES) $(sysv_SCRIPTS) afpd atalkd cnid_metad papd timelord
+CLEANFILES = $(GENERATED_FILES) $(sysv_SCRIPTS) $(service_DATA) afpd atalkd cnid_metad papd timelord
 EXTRA_DIST = $(TEMPLATES)
 
 # overwrite automake uninstall
@@ -55,13 +61,13 @@ uninstall: uninstall-startup
 # checking for "redhat" style sysv scripts:
 #
 
-if USE_REDHAT
+if USE_REDHAT_SYSV
 
 sysvdir        = /etc/rc.d/init.d
 sysv_SCRIPTS = netatalk
 
-$(sysv_SCRIPTS): rc.atalk.redhat
-       cp -f rc.atalk.redhat $(sysv_SCRIPTS)
+$(sysv_SCRIPTS): rc.atalk.redhat-sysv
+       cp -f rc.atalk.redhat-sysv $(sysv_SCRIPTS)
        chmod a+x $(sysv_SCRIPTS)
 
 install-data-hook:
@@ -73,6 +79,36 @@ uninstall-startup:
 
 endif
 
+#
+# checking for "redhat" style systemd scripts:
+#
+
+if USE_REDHAT_SYSTEMD
+
+sysvdir        = $(pkglibexecdir)
+sysv_SCRIPTS = netatalk.sh
+
+servicedir     = /lib/systemd/system
+service_DATA   = netatalk.service
+
+$(sysv_SCRIPTS): rc.atalk.redhat-systemd
+       cp -f rc.atalk.redhat-systemd $(sysv_SCRIPTS)
+       chmod a+x $(sysv_SCRIPTS)
+
+$(service_DATA): service.atalk.redhat-systemd
+       cp -f service.atalk.redhat-systemd $(service_DATA)
+
+install-data-hook:
+       -systemctl daemon-reload
+
+uninstall-startup:
+       -systemctl disable $(service_DATA)
+       rm -f $(DESTDIR)$(sysvdir)/$(sysv_SCRIPTS)      \
+               $(DESTDIR)$(servicedir)/$(service_DATA)
+       -systemctl daemon-reload
+
+endif
+
 #
 # checking for "SuSE" style sysv scripts:
 #
index 36da2affb42c2757da894f70029e54c53255fb2e..6242d88c868f1f835b9a01336ad7fccf47f54855 100644 (file)
@@ -4,7 +4,7 @@
 # REQUIRE: cnid_metad
 # KEYWORD: shutdown
 #
-# Apple Filing Protocol daemon.
+# Apple Filing Protocol daemon. (netatalk :NETATALK_VERSION:)
 # If you use AppleTalk, Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
index 6a0f489a27db73014cf0661c683a1e3f98913f94..b3249cc6682efe7a5b75eb2a55bd4d84780807c4 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Netatalk daemons.
+# Netatalk :NETATALK_VERSION: daemons.
 # If you use AppleTalk, Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
index a9fafd1320b8a2e4429b1295dc0bf830102212b9..ac5d8da0ac6337ef81b0805a8cea0530ca3abd25 100644 (file)
@@ -7,7 +7,7 @@
 # Default-Stop:      1
 ### END INIT INFO
 #
-# netatalk      Netatalk 2.x initscript
+# netatalk      Netatalk :NETATALK_VERSION: initscript
 # Author:       Thomas Kaiser <Thomas.Kaiser@phg-online.de>
 
 set -e
index 5ed475c556acff5b1c9b4ed3a0c83c86d9c6f148..5f0c65f1a4c4fbb5c35720270a9c461345fad8f0 100644 (file)
@@ -1,6 +1,6 @@
 #!/sbin/runscript
 
-# Netatalk daemons.
+# Netatalk :NETATALK_VERSION: daemons.
 # If you use AppleTalk, Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
diff --git a/distrib/initscripts/rc.atalk.redhat-systemd.tmpl b/distrib/initscripts/rc.atalk.redhat-systemd.tmpl
new file mode 100644 (file)
index 0000000..58f197a
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+# Netatalk :NETATALK_VERSION: startup script for systemd.
+
+ATALK_BIN=:BINDIR:
+ATALK_CONF_DIR=:ETCDIR:
+ATALK_SBIN=:SBINDIR:
+
+# default
+ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`
+ATALK_UNIX_CHARSET='LOCALE'
+ATALK_MAC_CHARSET='MAC_ROMAN'
+
+CNID_METAD_RUN=yes
+AFPD_RUN=yes
+AFPD_MAX_CLIENTS=20
+AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so"
+AFPD_GUEST=nobody
+CNID_CONFIG="-l log_note"
+
+ATALKD_RUN=no
+PAPD_RUN=no
+TIMELORD_RUN=no
+A2BOOT_RUN=no
+ATALK_ZONE=
+ATALK_BGROUND=no
+
+# read in netatalk configuration
+if [ -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
+    . ${ATALK_CONF_DIR}/netatalk.conf
+fi
+
+netatalk_startup() {
+    if [ x"${ATALKD_RUN}" != x"no" -a -x ${ATALK_SBIN}/atalkd ]; then
+       ${ATALK_SBIN}/atalkd
+       
+       if [ -x ${ATALK_BIN}/nbprgstr ]; then
+           ${ATALK_BIN}/nbprgstr -p 4 ${ATALK_NAME}:Workstation${ATALK_ZONE}
+           ${ATALK_BIN}/nbprgstr -p 4 ${ATALK_NAME}:netatalk${ATALK_ZONE}
+       fi      
+       
+       if [ x"${PAPD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/papd ]; then
+           ${ATALK_SBIN}/papd
+       fi
+       
+       # check for timelord in bin directory
+       if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_BIN}/timelord ]; then
+           ${ATALK_BIN}/timelord
+       fi
+       
+       # check for timelord in sbin directory
+       if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/timelord ]; then
+           ${ATALK_SBIN}/timelord
+       fi
+       
+       # check for a2boot in bin directory
+       if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_BIN}/a2boot ]; then
+           ${ATALK_BIN}/a2boot
+       fi
+       
+       # check for a2boot in sbin directory
+       if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/a2boot ]; then
+           ${ATALK_SBIN}/a2boot
+       fi
+    fi
+    
+    if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then
+       ${ATALK_SBIN}/cnid_metad $CNID_CONFIG
+    fi
+    
+    if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
+       ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
+            -c ${AFPD_MAX_CLIENTS} -n ${ATALK_NAME}${ATALK_ZONE}
+    fi
+}
+
+if [ x"${ATALK_BGROUND}" = x"yes" -a x"${ATALKD_RUN}" != x"no" ]; then 
+    netatalk_startup >& /dev/null &
+else
+    netatalk_startup
+fi
diff --git a/distrib/initscripts/rc.atalk.redhat-sysv.tmpl b/distrib/initscripts/rc.atalk.redhat-sysv.tmpl
new file mode 100644 (file)
index 0000000..f066232
--- /dev/null
@@ -0,0 +1,241 @@
+#! /bin/sh
+# chkconfig: - 91 35
+# description: This package is an implementation of "AFP over TCP"
+#              and provides printer, file sharing, and routing 
+#              services via legacy AppleTalk networking protocol.
+#
+# Netatalk :NETATALK_VERSION: daemons.
+# If you use AppleTalk, Make sure not to start atalkd in the background:
+# its data structures must have time to stablize before running the
+# other processes.
+
+ATALK_BIN=:BINDIR:
+ATALK_CONF_DIR=:ETCDIR:
+ATALK_SBIN=:SBINDIR:
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# default
+ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`
+ATALK_UNIX_CHARSET='LOCALE'
+ATALK_MAC_CHARSET='MAC_ROMAN'
+
+CNID_METAD_RUN=yes
+AFPD_RUN=yes
+AFPD_MAX_CLIENTS=20
+AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so"
+AFPD_GUEST=nobody
+CNID_CONFIG="-l log_note"
+
+ATALKD_RUN=no
+PAPD_RUN=no
+TIMELORD_RUN=no
+A2BOOT_RUN=no
+ATALK_ZONE=
+ATALK_BGROUND=no
+
+# read in netatalk configuration
+if [ -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
+    . ${ATALK_CONF_DIR}/netatalk.conf
+fi
+
+# initialize return values
+RETVAL=1
+RETVAL_ATALKD=0
+RETVAL_PAPD=0
+RETVAL_CNID_METAD=0
+RETVAL_AFPD=0
+
+# startup code for everything
+atalk_startup() {
+    # Check that networking is up.
+    if [ ${NETWORKING} = "no" ]; then
+         echo "[Network isn't started]"; 
+         exit 1;
+    fi
+
+    if [ ! -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
+         echo "[${ATALK_CONF_DIR}/netatalk.conf not found]";
+         exit 6;
+    fi
+
+    if [ x"${ATALKD_RUN}" != x"no" -a -x ${ATALK_SBIN}/atalkd ]; then 
+         # Quickly probe for appletalk and warn if we can't find it
+         #/sbin/modprobe appletalk || echo "[could not load appletalk module]"
+         # Check for IP Encapsulation support
+         #/sbin/modprobe ipddp || echo "[could not load IP encapsulation]"
+       echo -n "  Starting atalkd:"
+       daemon ${ATALK_SBIN}/atalkd
+       RETVAL_ATALKD=$?
+       echo
+
+       if [ -x ${ATALK_BIN}/nbprgstr ]; then   
+           action "  Registering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
+           action "  Registering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
+       fi      
+
+       if [ x"${PAPD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/papd ]; then
+           echo -n "  Starting papd:"
+           daemon ${ATALK_SBIN}/papd
+           RETVAL_PAPD=$?
+           echo
+       fi
+
+       # check for timelord in bin directory
+       if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_BIN}/timelord ]; then
+           echo -n "  Starting timelord"
+           daemon ${ATALK_BIN}/timelord
+           echo
+       fi
+
+       # check for timelord in sbin directory
+       if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/timelord ]; then
+           echo -n "  Starting timelord"
+           daemon ${ATALK_SBIN}/timelord
+           echo
+       fi
+
+       # check for a2boot in bin directory
+       if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_BIN}/a2boot ]; then
+           echo -n "  Starting a2boot"
+           daemon ${ATALK_BIN}/a2boot
+           echo
+       fi
+
+       # check for a2boot in sbin directory
+       if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/a2boot ]; then
+           echo -n "  Starting a2boot"
+           daemon ${ATALK_SBIN}/a2boot
+           echo
+       fi
+
+    fi
+
+    if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ] ; then
+           echo -n "  Starting cnid_metad:"
+        daemon ${ATALK_SBIN}/cnid_metad $CNID_CONFIG
+           RETVAL_CNID_METAD=$?
+           echo
+    fi
+
+    if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then
+           echo -n "  Starting afpd:"
+           daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
+               -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\"
+           RETVAL_AFPD=$?
+           echo
+    fi
+
+    if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
+        RETVAL=0
+       touch /var/lock/subsys/atalk || RETVAL=1
+    fi
+}
+
+case "$1" in
+'start')
+       echo -n 'Starting Netatalk services: '
+       if [ x"${ATALK_BGROUND}" = x"yes" -a x"${ATALKD_RUN}" != x"no" ]; then 
+           echo -n "(backgrounded)"
+           atalk_startup >& /dev/null &
+       else
+           echo
+           atalk_startup
+       fi
+       echo 
+       ;;
+'stop')
+       echo 'Shutting down Netatalk services: '
+       if [ x"${ATALKD_RUN}" != x"no" ]; then
+           if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
+               echo -n "  Stopping papd:"
+               killproc papd
+               RETVAL_PAPD=$?
+               echo
+           fi
+
+            # checking for timelord in bin directory
+           if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then
+               echo -n "  Stopping timelord:"
+               killproc timelord
+               echo
+           fi
+
+            # checking for timelord in sbin directory
+           if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then
+               echo -n "  Stopping timelord:"
+               killproc timelord
+               echo
+           fi
+
+            # checking for a2boot in bin directory
+           if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then
+               echo -n "  Stopping a2boot:"
+               killproc a2boot
+               echo
+           fi
+
+            # checking for a2boot in sbin directory
+           if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then
+               echo -n "  Stopping a2boot:"
+               killproc a2boot
+               echo
+           fi
+
+           action "  Unregistering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
+           action "  Unregistering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
+
+           # kill atalkd last, since without it the plumbing goes away.
+           if [ -x ${ATALK_SBIN}/atalkd ]; then
+               echo -n "  Stopping atalk:"
+               killproc atalkd
+               RETVAL_ATALKD=$?
+               echo
+           fi
+       fi
+
+       # kill this separately as we also do AFP/tcp
+       if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
+           echo -n "  Stopping afpd:"
+           killproc afpd
+           RETVAL_AFPD=$?
+           echo
+       fi
+
+       if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then
+           echo -n "  Stopping cnid_metad:"
+           killproc cnid_metad
+           RETVAL_CNID_METAD=$?
+           echo
+       fi
+
+       if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
+           RETVAL=0
+           rm -f /var/lock/subsys/atalk || RETVAL=1
+       fi
+       echo ""
+       ;;
+  'restart'|'reload')
+       $0 stop
+       $0 start
+       RETVAL=$?
+       ;;
+  'status')
+       status atalkd
+       status papd
+       status timelord
+       status a2boot
+       status cnid_metad
+       status afpd
+       RETVAL=$?
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|restart|reload|status}"
+       exit 2
+esac
+
+exit $RETVAL
diff --git a/distrib/initscripts/rc.atalk.redhat.tmpl b/distrib/initscripts/rc.atalk.redhat.tmpl
deleted file mode 100644 (file)
index 79b613b..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-#! /bin/sh
-# chkconfig: - 91 35
-# description: This package is an implementation of "AFP over TCP"
-#              and provides printer, file sharing, and routing 
-#              services via legacy AppleTalk networking protocol.
-#
-# Netatalk daemons.
-# If you use AppleTalk, Make sure not to start atalkd in the background:
-# its data structures must have time to stablize before running the
-# other processes.
-
-ATALK_BIN=:BINDIR:
-ATALK_CONF_DIR=:ETCDIR:
-ATALK_SBIN=:SBINDIR:
-
-# Source function library.
-. /etc/rc.d/init.d/functions
-
-# Source networking configuration.
-. /etc/sysconfig/network
-
-# default
-ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`
-ATALK_UNIX_CHARSET='LOCALE'
-ATALK_MAC_CHARSET='MAC_ROMAN'
-
-CNID_METAD_RUN=yes
-AFPD_RUN=yes
-AFPD_MAX_CLIENTS=20
-AFPD_UAMLIST="-U uams_dhx.so,uams_dhx2.so"
-AFPD_GUEST=nobody
-CNID_CONFIG="-l log_note"
-
-ATALKD_RUN=no
-PAPD_RUN=no
-TIMELORD_RUN=no
-A2BOOT_RUN=no
-ATALK_ZONE=
-ATALK_BGROUND=no
-
-# read in netatalk configuration
-if [ -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
-    . ${ATALK_CONF_DIR}/netatalk.conf
-fi
-
-# initialize return values
-RETVAL=1
-RETVAL_ATALKD=0
-RETVAL_PAPD=0
-RETVAL_CNID_METAD=0
-RETVAL_AFPD=0
-
-# startup code for everything
-atalk_startup() {
-    # Check that networking is up.
-    if [ ${NETWORKING} = "no" ]; then
-         echo "[Network isn't started]"; 
-         exit 1;
-    fi
-
-    if [ ! -f ${ATALK_CONF_DIR}/netatalk.conf ]; then
-         echo "[${ATALK_CONF_DIR}/netatalk.conf not found]";
-         exit 6;
-    fi
-
-    if [ x"${ATALKD_RUN}" != x"no" -a -x ${ATALK_SBIN}/atalkd ]; then 
-         # Quickly probe for appletalk and warn if we can't find it
-         #/sbin/modprobe appletalk || echo "[could not load appletalk module]"
-         # Check for IP Encapsulation support
-         #/sbin/modprobe ipddp || echo "[could not load IP encapsulation]"
-       echo -n "  Starting atalkd:"
-       daemon ${ATALK_SBIN}/atalkd
-       RETVAL_ATALKD=$?
-       echo
-
-       if [ -x ${ATALK_BIN}/nbprgstr ]; then   
-           action "  Registering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
-           action "  Registering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbprgstr -p 4 \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
-       fi      
-
-       if [ x"${PAPD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/papd ]; then
-           echo -n "  Starting papd:"
-           daemon ${ATALK_SBIN}/papd
-           RETVAL_PAPD=$?
-           echo
-       fi
-
-       # check for timelord in bin directory
-       if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_BIN}/timelord ]; then
-           echo -n "  Starting timelord"
-           daemon ${ATALK_BIN}/timelord
-           echo
-       fi
-
-       # check for timelord in sbin directory
-       if [ x"${TIMELORD_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/timelord ]; then
-           echo -n "  Starting timelord"
-           daemon ${ATALK_SBIN}/timelord
-           echo
-       fi
-
-       # check for a2boot in bin directory
-       if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_BIN}/a2boot ]; then
-           echo -n "  Starting a2boot"
-           daemon ${ATALK_BIN}/a2boot
-           echo
-       fi
-
-       # check for a2boot in sbin directory
-       if [ x"${A2BOOT_RUN}" = x"yes"  -a -x ${ATALK_SBIN}/a2boot ]; then
-           echo -n "  Starting a2boot"
-           daemon ${ATALK_SBIN}/a2boot
-           echo
-       fi
-
-    fi
-
-    if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ] ; then
-           echo -n "  Starting cnid_metad:"
-        daemon ${ATALK_SBIN}/cnid_metad $CNID_CONFIG
-           RETVAL_CNID_METAD=$?
-           echo
-    fi
-
-    if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ] ; then
-           echo -n "  Starting afpd:"
-           daemon ${ATALK_SBIN}/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
-               -c ${AFPD_MAX_CLIENTS} -n \"${ATALK_NAME}${ATALK_ZONE}\"
-           RETVAL_AFPD=$?
-           echo
-    fi
-
-    if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_CNID_METAD -eq 0 -a $RETVAL_AFPD -eq 0 ]; then
-        RETVAL=0
-       touch /var/lock/subsys/atalk || RETVAL=1
-    fi
-}
-
-case "$1" in
-'start')
-       echo -n 'Starting Netatalk services: '
-       if [ x"${ATALK_BGROUND}" = x"yes" -a x"${ATALKD_RUN}" != x"no" ]; then 
-           echo -n "(backgrounded)"
-           atalk_startup >& /dev/null &
-       else
-           echo
-           atalk_startup
-       fi
-       echo 
-       ;;
-'stop')
-       echo 'Shutting down Netatalk services: '
-       if [ x"${ATALKD_RUN}" != x"no" ]; then
-           if [ x"${PAPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/papd ]; then
-               echo -n "  Stopping papd:"
-               killproc papd
-               RETVAL_PAPD=$?
-               echo
-           fi
-
-            # checking for timelord in bin directory
-           if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_BIN}/timelord ]; then
-               echo -n "  Stopping timelord:"
-               killproc timelord
-               echo
-           fi
-
-            # checking for timelord in sbin directory
-           if [ x"${TIMELORD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/timelord ]; then
-               echo -n "  Stopping timelord:"
-               killproc timelord
-               echo
-           fi
-
-            # checking for a2boot in bin directory
-           if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_BIN}/a2boot ]; then
-               echo -n "  Stopping a2boot:"
-               killproc a2boot
-               echo
-           fi
-
-            # checking for a2boot in sbin directory
-           if [ x"${A2BOOT_RUN}" = x"yes" -a -x ${ATALK_SBIN}/a2boot ]; then
-               echo -n "  Stopping a2boot:"
-               killproc a2boot
-               echo
-           fi
-
-           action "  Unregistering ${ATALK_NAME}:Workstation${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:Workstation${ATALK_ZONE}\"
-           action "  Unregistering ${ATALK_NAME}:netatalk${ATALK_ZONE}:" ${ATALK_BIN}/nbpunrgstr \"${ATALK_NAME}:netatalk${ATALK_ZONE}\"
-
-           # kill atalkd last, since without it the plumbing goes away.
-           if [ -x ${ATALK_SBIN}/atalkd ]; then
-               echo -n "  Stopping atalk:"
-               killproc atalkd
-               RETVAL_ATALKD=$?
-               echo
-           fi
-       fi
-
-       # kill this separately as we also do AFP/tcp
-       if [ x"${AFPD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/afpd ]; then
-           echo -n "  Stopping afpd:"
-           killproc afpd
-           RETVAL_AFPD=$?
-           echo
-       fi
-
-       if [ x"${CNID_METAD_RUN}" = x"yes" -a -x ${ATALK_SBIN}/cnid_metad ]; then
-           echo -n "  Stopping cnid_metad:"
-           killproc cnid_metad
-           RETVAL_CNID_METAD=$?
-           echo
-       fi
-
-       if [ $RETVAL_ATALKD -eq 0 -a $RETVAL_PAPD -eq 0 -a $RETVAL_AFPD -eq 0 ] ; then
-           RETVAL=0
-           rm -f /var/lock/subsys/atalk || RETVAL=1
-       fi
-       echo ""
-       ;;
-  'restart'|'reload')
-       $0 stop
-       $0 start
-       RETVAL=$?
-       ;;
-  'status')
-       status atalkd
-       status papd
-       status timelord
-       status a2boot
-       status cnid_metad
-       status afpd
-       RETVAL=$?
-       ;;
-  *)
-       echo "Usage: $0 {start|stop|restart|reload|status}"
-       exit 2
-esac
-
-exit $RETVAL
index f392d51cfc5a6cd1480a0eb040227ab487a86f0b..68328e6d779f26b5d627d3c306054d2d2a395d2d 100755 (executable)
@@ -16,6 +16,8 @@
 # Description:    AFP over TCP and legacy AppleTalk daemons
 ### END INIT INFO
 
+# Netatalk :NETATALK_VERSION:
+
 ATALK_NAME=`hostname|sed 's/\..*$//'`
 ATALK_UNIX_CHARSET='LOCALE'
 ATALK_MAC_CHARSET='MAC_ROMAN'
index 85ec0748f5b6add6f72f3522d3b5dd42e41915b2..ddad742d38bd9fbd79ba5e5a5b081d9035d58bea 100755 (executable)
@@ -1,8 +1,7 @@
 #! /bin/sh
 #
-# Start/stop the Netatalk daemons.
+# Start/stop the Netatalk :NETATALK_VERSION: daemons.
 #
-# Netatalk daemons.
 # If you use AppleTalk, Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
index 3a7f97032d77231b92b7115538c36d94127656a5..0c350af4d91b62f1d5157ae2516875a890361ada 100755 (executable)
@@ -1,8 +1,7 @@
 #! /bin/sh
 #
-# Start/stop the Netatalk daemons.
+# Start/stop the Netatalk :NETATALK_VERSION: daemons.
 #
-# Netatalk daemons.
 # If you use AppleTalk, Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
index a567048791d54337152b999ede79ba0403f828c7..d531204b9135d1dd387c514784a813004a4777b8 100644 (file)
@@ -3,7 +3,7 @@
 # PROVIDE: atalkd
 # REQUIRE: DAEMON
 #
-# AppleTalk daemon.
+# AppleTalk daemon. (netatalk :NETATALK_VERSION:)
 # If you use AppleTalk, Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
index b0963cfea6c287a0885e400f6d91395b740972c1..caeba08ef6b4f7754000889129db64d768142aeb 100644 (file)
@@ -2,7 +2,7 @@
 #
 # PROVIDE: cnid_metad
 #
-# Start cnid_dbd daemons on request.
+# Start cnid_dbd daemons on request.  (netatalk :NETATALK_VERSION:)
 # The cnid_dbd is an implementation for accessing to CNID databases
 # through a dedicated daemon process.
 #
index 4b2f3d6a6c35bfa407958f0ba0135ecbe5024281..f32cb7cbc91c37a2a834cca94036620afd4e8906 100644 (file)
@@ -3,7 +3,7 @@
 # PROVIDE: papd
 # REQUIRE: atalkd
 #
-# AppleTalk print server daemon.
+# AppleTalk print server daemon.  (netatalk :NETATALK_VERSION:)
 # Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
index 2c4f2bbfdef740f710d8e8c7b4c8a84be86ac84b..aae4b7a379227fe78a6623b95456d31afc0cd468 100644 (file)
@@ -3,7 +3,7 @@
 # PROVIDE: timelord
 # REQUIRE: atalkd
 #
-# AppleTalk time server daemon.
+# AppleTalk time server daemon. (netatalk :NETATALK_VERSION:)
 # Make sure not to start atalkd in the background:
 # its data structures must have time to stablize before running the
 # other processes.
diff --git a/distrib/initscripts/service.atalk.redhat-systemd.tmpl b/distrib/initscripts/service.atalk.redhat-systemd.tmpl
new file mode 100644 (file)
index 0000000..cd7a3df
--- /dev/null
@@ -0,0 +1,13 @@
+# This file is part of netatalk :NETATALK_VERSION:.
+
+[Unit]
+Description=File and Printer sharing for Macintosh clients
+After=syslog.target network.target
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -c "exec :PKGLIBEXECDIR:/netatalk.sh"
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
index d82794905bd27d56330d9c64bf8f7df1bd093726..e79fc4f227928209ed140a4613f3825944551680 100644 (file)
@@ -516,6 +516,8 @@ int afp_options_parseline(char *buf, struct afp_options *options)
  */
 static void show_version( void )
 {
+       int num, i;
+
        printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
 
        puts( "This program is free software; you can redistribute it and/or modify it under" );
@@ -525,9 +527,12 @@ static void show_version( void )
 
        puts( "afpd has been compiled with support for these features:\n" );
 
-       printf( "        AFP3.x support:\tYes\n" );
-        printf( "        TCP/IP Support:\t" );
-        puts( "Yes" );
+       num = sizeof( afp_versions ) / sizeof( afp_versions[ 0 ] );
+       printf( "          AFP versions:\t" );
+       for ( i = 0; i < num; i++ ) {
+               printf( "%d.%d ", afp_versions[ i ].av_number/10, afp_versions[ i ].av_number%10);
+       }
+       puts( "" );
 
        printf( "         CNID backends:\t" );
 #ifdef CNID_BACKEND_CDB
index 24c3dea15f015a48d75d56e49f2c34a334346298..60a5b69c8c5c76cb8c0c785ed8f278f934f639f7 100644 (file)
@@ -68,17 +68,6 @@ gid_t   *groups;
 
 int ngroups;
 
-/*
- * These numbers are scattered throughout the code.
- */
-static struct afp_versions  afp_versions[] = {
-    { "AFP2.2", 22 },
-    { "AFPX03", 30 },
-    { "AFP3.1", 31 },
-    { "AFP3.2", 32 },
-    { "AFP3.3", 33 }
-};
-
 static struct uam_mod uam_modules = {NULL, NULL, &uam_modules, &uam_modules};
 static struct uam_obj uam_login = {"", "", 0, {{NULL, NULL, NULL, NULL }}, &uam_login,
                                    &uam_login};
index 1d4792454204c36ac28311d1f6c698d78b31a793..46c23fbd1fc7bfe856ef3377bb42ee1879c6f030 100644 (file)
@@ -15,6 +15,19 @@ struct afp_versions {
     int                av_number;
 };
 
+static const struct afp_versions  afp_versions[] = {
+#ifndef NO_DDP
+    { "AFPVersion 1.1", 11 },
+    { "AFPVersion 2.0", 20 },
+    { "AFPVersion 2.1", 21 },
+#endif /* ! NO_DDP */
+    { "AFP2.2", 22 },
+    { "AFPX03", 30 },
+    { "AFP3.1", 31 },
+    { "AFP3.2", 32 },
+    { "AFP3.3", 33 }
+};
+
 /* for GetUserInfo */
 #define USERIBIT_USER  (1 << 0)
 #define USERIBIT_GROUP (1 << 1)
index 43335885fcb1948509b5c4541bcc53c07c5b185a..e858146752f25aa95d8c555f34b8cb5db199a528 100644 (file)
@@ -256,6 +256,20 @@ int main(int ac, char **av)
     set_auth_parameters( ac, av );
 #endif /* TRU64 */
 
+    /* Parse argv args and initialize default options */
+    afp_options_init(&default_options);
+    if (!afp_options_parse(ac, av, &default_options))
+        exit(EXITERR_CONF);
+
+    if (check_lockfile("afpd", default_options.pidfile) != 0)
+        exit(EXITERR_SYS);
+
+    if (!(default_options.flags & OPTION_DEBUG) && (daemonize(0, 0) != 0))
+        exit(EXITERR_SYS);
+
+    if (create_lockfile("afpd", default_options.pidfile) != 0)
+        exit(EXITERR_SYS);
+
     /* Log SIGBUS/SIGSEGV SBT */
     fault_setup(NULL);
 
@@ -263,23 +277,9 @@ int main(int ac, char **av)
     set_processname("afpd");
     setuplog("default log_note");
 
-    afp_options_init(&default_options);
-    if (!afp_options_parse(ac, av, &default_options))
-        exit(EXITERR_CONF);
-
-    /* Save the user's current umask for use with CNID (and maybe some 
-     * other things, too). */
+    /* Save the user's current umask */
     default_options.save_mask = umask( default_options.umask );
 
-    switch(server_lock("afpd", default_options.pidfile,
-                       default_options.flags & OPTION_DEBUG)) {
-    case -1: /* error */
-        exit(EXITERR_SYS);
-    case 0: /* child */
-        break;
-    default: /* server */
-        exit(0);
-    }
     atexit(afp_exit);
 
     /* install child handler for asp and dsi. we do this before afp_goaway
index 8fb09624bd1850564f6eb3384efbad6d79c6e65c..7cf72871de3990e87b4e3c5f8e1b98b9c183d3d6 100644 (file)
@@ -706,7 +706,7 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
             ad_flush(&ad);
         }
         else
-            ad_cnid = ad_getid(&ad, st->st_dev, st->st_ino, did, stamp);
+            ad_cnid = ad_getid(&ad, st->st_dev, st->st_ino, 0, stamp);
 
         if (ad_cnid == 0)
             dbd_log( LOGSTD, "Bad CNID in adouble file of '%s/%s'", cwdbuf, name);
index e6e0f8d1e1fbc2e2600bd67065aeb9c0e3c4e760..19087f19d5cc0ca31363bd79238717521daa9042 100644 (file)
@@ -491,6 +491,17 @@ int main(int argc, char *argv[])
         }
     }
 
+    /* Check for PID lockfile */
+    if (check_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK))
+        return -1;
+
+    if (!debug && daemonize(0, 0) != 0)
+        exit(EXITERR_SYS);
+
+    /* Create PID lockfile */
+    if (create_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK))
+        return -1;
+
     if (loglevel) {
         strlcpy(logconfig + 8, loglevel, 13);
         free(loglevel);
@@ -509,16 +520,6 @@ int main(int argc, char *argv[])
 
     (void)setlimits();
 
-    /* Check PID lockfile and become a daemon */
-    switch(server_lock("cnid_metad", _PATH_CNID_METAD_LOCK, debug)) {
-    case -1: /* error */
-        daemon_exit(EXITERR_SYS);
-    case 0: /* child */
-        break;
-    default: /* server */
-        exit(0);
-    }
-
     if ((srvfd = tsockfd_create(host, port, 10)) < 0)
         daemon_exit(1);
 
index 91d9bec00ff18d0ba16a1c52dfe5c64ba3a7ab66..2fde17bc86f5327c599e7c051fd8c54e00671ec7 100644 (file)
@@ -963,7 +963,7 @@ int dbif_del(DBD *dbd, const int dbi, DBT *key, u_int32_t flags)
                                      flags);
     
     if (ret == DB_NOTFOUND) {
-        LOG(log_info, logtype_cnid, "key not found");
+        LOG(log_debug, logtype_cnid, "key not found");
         return 0;
     }
     if (ret) {
index 1c16e06f86d3cb1a6a1233b1057a68ef427dc91c..1664c8c992fccd11c45a139e267e3308827a39e7 100644 (file)
@@ -79,6 +79,8 @@ extern void bprint        (char *, int);
 extern int strdiacasecmp  (const char *, const char *);
 extern int strndiacasecmp (const char *, const char *, size_t);
 extern pid_t server_lock  (char * /*program*/, char * /*file*/, int /*debug*/);
+extern int check_lockfile (const char *program, const char *pidfile);
+extern int create_lockfile(const char *program, const char *pidfile);
 extern void fault_setup          (void (*fn)(void *));
 extern void netatalk_panic(const char *why);
 #define server_unlock(x)  (unlink(x))
@@ -172,10 +174,12 @@ extern const char *getcwdpath(void);
 extern char *stripped_slashes_basename(char *p);
 extern int lchdir(const char *dir);
 extern void randombytes(void *buf, int n);
-#endif  /* _ATALK_UTIL_H */
+extern int daemonize(int nochdir, int noclose);
 
 /******************************************************************
  * cnid.c
  *****************************************************************/
 
 extern bstring rel_path_in_vol(const char *path, const char *volpath);
+
+#endif  /* _ATALK_UTIL_H */
index 416c38d0b86d5aaf098a5d09fb8891569fc8c324..aec13c820d35d5d87c0153acfda99abe56e7a1da 100644 (file)
@@ -552,8 +552,6 @@ size_t precompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
        base = *in;
        while (*outlen > 2) {
                i += 2;
-               in++;
-
                if (i == inplen) {
                        *out = base;
                        out++;
@@ -561,7 +559,7 @@ size_t precompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
                        *outlen -= 2;
                        return o_len - *outlen;
                }
-
+               in++;
                comb = *in;
                result = 0;
 
@@ -589,7 +587,7 @@ size_t precompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
                
                /* Binary Search for Surrogate Pair */
                else if ((0xD800 <= base) && (base < 0xDC00)) {
-                       if ((0xDC00 <= comb) && (comb < 0xE000) && (i + 4 <= inplen)) {
+                       if ((0xDC00 <= comb) && (comb < 0xE000) && (i + 6 <= inplen)) {
                                base_sp = ((uint32_t)base << 16) | (uint32_t)comb;
                                do {
                                        comb_sp = ((uint32_t)in[1] << 16) | (uint32_t)in[2];
@@ -598,7 +596,7 @@ size_t precompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
                                                i += 4;
                                                in +=2;
                                        }
-                               } while ((i + 4 <= inplen) && result_sp) ;
+                               } while ((i + 6 <= inplen) && result_sp) ;
 
                                *out = base_sp >> 16;
                                out++;
@@ -614,6 +612,11 @@ size_t precompose_w (ucs2_t *name, size_t inplen, ucs2_t *comp, size_t *outlen)
                                *outlen -= 2;
 
                                i += 2;
+                               if (i == inplen) {
+                                       out++;
+                                       *out = 0;
+                                       return o_len - *outlen;
+                               }
                                in++;
                                base = *in;
 
index 90dc11445eabc56cba7121d7888e15186ab3a30a..0251eadaeba94652c2b45474881f648ea1c5dde2 100644 (file)
@@ -99,3 +99,51 @@ pid_t server_lock(char *program, char *pidfile, int debug)
   return 0;
 }
 
+/*!
+ * Check lockfile
+ */
+int check_lockfile(const char *program, const char *pidfile)
+{
+    char buf[10];
+    FILE *pf;
+    pid_t pid;
+
+    /* check for pid. this can get fooled by stale pid's. */
+    if ((pf = fopen(pidfile, "r"))) {
+        if (fgets(buf, sizeof(buf), pf) && !kill(pid = atol(buf), 0)) {
+            fprintf(stderr, "%s is already running (pid = %d), or the lock file is stale.\n",
+                    program, pid);      
+            fclose(pf);
+            return -1;
+        }
+        fclose(pf);
+    }
+    return 0;
+}
+
+/*!
+ * Check and create lockfile
+ */
+int create_lockfile(const char *program, const char *pidfile)
+{
+    char buf[10];
+    FILE *pf;
+    pid_t pid;
+    int mask;
+  
+    if (check_lockfile(program, pidfile) != 0)
+        return -1;
+
+    /* Write PID to pidfile */
+    mask = umask(022);
+    if ((pf = fopen(pidfile, "w")) == NULL) {
+        fprintf(stderr, "%s: can't open lock file, \"%s\"\n", program,
+                pidfile);
+        return -1;
+    }
+    umask(mask);
+    fprintf(pf, "%d\n", getpid());
+    fclose(pf);
+
+    return 0;
+}
index 72545e5b632fd6eba24918003f1a0b171681871e..d202b99a31f9d1dc165c7836b8b43d3d0fcd6f4c 100644 (file)
 #include <atalk/unix.h>
 #include <atalk/compat.h>
 
+/* close all FDs >= a specified value */
+static void closeall(int fd)
+{
+    int fdlimit = sysconf(_SC_OPEN_MAX);
+
+    while (fd < fdlimit)
+        close(fd++);
+}
+
+/*!
+ * Daemonize
+ *
+ * Fork, exit parent, setsid(), optionally chdir("/"), optionally close all fds
+ *
+ * returns -1 on failure, but you can't do much except exit in that case
+ * since we may already have forked
+ */
+int daemonize(int nochdir, int noclose)
+{
+    switch (fork()) {
+    case 0:
+        break;
+    case -1:
+        return -1;
+    default:
+        _exit(0);
+    }
+
+    if (setsid() < 0)
+        return -1;
+
+    switch (fork()) {
+    case 0: 
+        break;
+    case -1:
+        return -1;
+    default:
+        _exit(0);
+    }
+
+    if (!nochdir)
+        chdir("/");
+
+    if (!noclose) {
+        closeall(0);
+        open("/dev/null",O_RDWR);
+        dup(0);
+        dup(0);
+    }
+
+    return 0;
+}
+
 /*!
  * @brief get cwd in static buffer
  *
index 81788fe4bf16855d78705fcfcf85352618dfba50..94e65dd98eb8b7bb00dc0ae3367b576c5d137c43 100644 (file)
@@ -145,13 +145,19 @@ AC_ARG_ENABLE(shell-check,
 dnl Check for optional sysv initscript install
 AC_DEFUN([AC_NETATALK_SYSV_STYLE], [
     AC_ARG_WITH(sysv-style,
-                [  --with-sysv-style       use OS specific sysv config [[redhat|suse|gentoo|netbsd|debian]]],
+                [  --with-sysv-style       use OS specific sysv config [[redhat-sysv|redhat-systemd|suse|gentoo|netbsd|debian]]],
                 sysv_style="$withval", sysv_style=none
     )
     case "$sysv_style" in 
     "redhat")
-           AC_MSG_RESULT([enabling redhat-style sysv support])
+           AC_MSG_ERROR([--enable-redhat is obsoleted. Use --enable-redhat-sysv or --enable-redhat-systemd.])
         ;;
+    "redhat-sysv")
+           AC_MSG_RESULT([enabling redhat-style sysv (upstart) configuration])
+           ;;
+    "redhat-systemd")
+           AC_MSG_RESULT([enabling redhat-style systemd support])
+           ;;
     "suse")
            AC_MSG_RESULT([enabling suse-style sysv support])
         ;;