* 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.
* 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"
* 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
===================
+++ /dev/null
-Makefile
-Makefile.in
-achfile
-afile
-.deps
-.libs
-.gitignore
-achfile.o afile.o common.o
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)
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.
# 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";
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");
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));
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") {
#
#
-# This edition is a part of netatalk.
+# This edition is a part of netatalk @NETATALK_VERSION@.
#
use strict;
$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);
}
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
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 \
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 \
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
# 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:
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:
#
# 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.
#!/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.
# 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
#!/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.
--- /dev/null
+#!/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
--- /dev/null
+#! /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
+++ /dev/null
-#! /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
# 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'
#! /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.
#! /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.
# 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.
#
# 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.
#
# 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.
# 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.
--- /dev/null
+# 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
*/
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" );
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
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};
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)
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);
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
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);
}
}
+ /* 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);
(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);
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) {
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))
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 */
base = *in;
while (*outlen > 2) {
i += 2;
- in++;
-
if (i == inplen) {
*out = base;
out++;
*outlen -= 2;
return o_len - *outlen;
}
-
+ in++;
comb = *in;
result = 0;
/* 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];
i += 4;
in +=2;
}
- } while ((i + 4 <= inplen) && result_sp) ;
+ } while ((i + 6 <= inplen) && result_sp) ;
*out = base_sp >> 16;
out++;
*outlen -= 2;
i += 2;
+ if (i == inplen) {
+ out++;
+ *out = 0;
+ return o_len - *outlen;
+ }
in++;
base = *in;
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;
+}
#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
*
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])
;;