[systemd-devel] SSL handshake error from offlineimap when using systemd to initialize

Yubin Ruan ablacktshirt at gmail.com
Wed Jan 24 08:59:13 UTC 2018


On Wed, Jan 24, 2018 at 08:57:18AM +0100, Reindl Harald wrote:
> 
> 
> Am 24.01.2018 um 08:13 schrieb Yubin Ruan:
> > On Tue, Jan 23, 2018 at 04:10:10PM +0100, Lennart Poettering wrote:
> > > On Di, 23.01.18 09:09, Reindl Harald (h.reindl at thelounge.net) wrote:
> > > > depeding on how your network is configured use "network.service" or
> > > > "networkmanager.service" (or however the networkmanager service is called in
> > > > detail, i don#t use it)
> > > 
> > > Nope. Use "network-online.target" if you are looking for a generic
> > > unit to order after that is reached only after the network has been
> > > "configured" for the first time, for some vague definition of
> > > "configured", that is up to the networking implementation to fill with
> > > sense...
> > 
> > Now I have these in the configuration file
> > 
> > [Unit]
> > Description=Sync mail
> > Wants=network-online.target
> > After=network.target network-online.target
> > 
> > [Service]
> > Type=oneshot
> > ExecStart=/path/to/the/script
> > TimeoutStartSec=1min30s
> > 
> > [Install]
> > WantedBy=default.target
> > 
> > However the script is still broken at system startup. Hmm...I am using a
> > Ubuntu 16.04LTS. I will post if there are any news
> 
> AGAIN: how is your network started
> 
> Lennart is *not* correct - at least on Fedora all the wait-online stuff
> don't work while "After=network.service" does when you still ue the cliassic
> network.service for a lot of obvious reasons
> 
> [root at srv-rhsoft:~]$ cat /etc/rc.d/init.d/network
> #! /bin/bash
> #
> # network       Bring up/down networking
> #
> # chkconfig: - 10 90
> # description: Activates/Deactivates all network interfaces configured to \
> #              start at boot time.
> #
> ### BEGIN INIT INFO
> # Provides: $network
> # Should-Start: iptables ip6tables NetworkManager-wait-online NetworkManager
> $network-pre
> # Short-Description: Bring up/down networking
> # Description: Bring up/down networking
> ### END INIT INFO

Below are /etc/init.d/networking and /etc/init.d/network-manager respectively.
It seems that it is /etc/init.d/networking that is responsible for bringing up
the network.

######################################
# /etc/init.d/networking
######################################
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          networking ifupdown
# Required-Start:    mountkernfs $local_fs urandom
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Raise network interfaces.
# Description:       Prepare /run/network directory, ifstate file and raise network interfaces, or take them down.
### END INIT INFO

PATH="/sbin:/bin"
RUN_DIR="/run/network"
IFSTATE="$RUN_DIR/ifstate"
STATEDIR="$RUN_DIR/state"

[ -x /sbin/ifup ] || exit 0
[ -x /sbin/ifdown ] || exit 0

. /lib/lsb/init-functions

CONFIGURE_INTERFACES=yes
EXCLUDE_INTERFACES=
VERBOSE=no

[ -f /etc/default/networking ] && . /etc/default/networking

verbose=""
[ "$VERBOSE" = yes ] && verbose=-v

process_exclusions() {
    set -- $EXCLUDE_INTERFACES
    exclusions=""
    for d
    do
	exclusions="-X $d $exclusions"
    done
    echo $exclusions
}

process_options() {
    [ -e /etc/network/options ] || return 0
    log_warning_msg "/etc/network/options still exists and it will be IGNORED! Please use /etc/sysctl.conf instead."
}

check_ifstate() {
    if [ ! -d "$RUN_DIR" ] ; then
	if ! mkdir -p "$RUN_DIR" ; then
	    log_failure_msg "can't create $RUN_DIR"
	    exit 1
	fi
	if ! chown root:netdev "$RUN_DIR" ; then
	    log_warning_msg "can't chown $RUN_DIR"
	fi
    fi
    if [ ! -r "$IFSTATE" ] ; then
	if ! :> "$IFSTATE" ; then
	    log_failure_msg "can't initialise $IFSTATE"
	    exit 1
	fi
    fi
}

check_network_file_systems() {
    [ -e /proc/mounts ] || return 0

    if [ -e /etc/iscsi/iscsi.initramfs ]; then
	log_warning_msg "not deconfiguring network interfaces: iSCSI root is mounted."
	exit 0
    fi

    while read DEV MTPT FSTYPE REST; do
	case $DEV in
	/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*|curlftpfs*)
	    log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
	    exit 0
	    ;;
	esac
	case $FSTYPE in
	nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
	    log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
	    exit 0
	    ;;
	esac
    done < /proc/mounts
}

check_network_swap() {
    [ -e /proc/swaps ] || return 0

    while read DEV MTPT FSTYPE REST; do
	case $DEV in
	/dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
	    log_warning_msg "not deconfiguring network interfaces: network swap still mounted."
	    exit 0
	    ;;
	esac
    done < /proc/swaps
}

ifup_hotplug () {
    if [ -d /sys/class/net ]
    then
	    ifaces=$(for iface in $(ifquery --list --allow=hotplug)
			    do
				    link=${iface##:*}
				    link=${link##.*}
				    if [ -e "/sys/class/net/$link" ]
				    then
					# link detection does not work unless we up the link
					ip link set "$iface" up || true
					if [ "$(cat /sys/class/net/$link/operstate)" = up ]
					then
					    echo "$iface"
					fi
				    fi
			    done)
	    if [ -n "$ifaces" ]
	    then
		ifup $ifaces "$@" || true
	    fi
    fi
}

case "$1" in
start)
	if init_is_upstart; then
		exit 1
	fi
	process_options
	check_ifstate

	if [ "$CONFIGURE_INTERFACES" = no ]
	then
	    log_action_msg "Not configuring network interfaces, see /etc/default/networking"
	    exit 0
	fi
	set -f
	exclusions=$(process_exclusions)
	log_action_begin_msg "Configuring network interfaces"
	if [ -x /sbin/udevadm ]; then
		if [ -n "$(ifquery --list --exclude=lo)" ] || [ -n "$(ifquery --list --allow=hotplug)" ]; then
			udevadm settle || true
		fi
	fi
	if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose
	then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

stop)
	if init_is_upstart; then
		exit 0
	fi
	check_network_file_systems
	check_network_swap

	log_action_begin_msg "Deconfiguring network interfaces"
	if ifdown -a --exclude=lo $verbose; then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

reload)
	if init_is_upstart; then
		exit 1
	fi
	process_options

	log_action_begin_msg "Reloading network interfaces configuration"
	state=$(ifquery --state)
	ifdown -a --exclude=lo $verbose || true
	if ifup --exclude=lo $state $verbose ; then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

force-reload|restart)
	if init_is_upstart; then
		exit 1
	fi
	process_options

	log_warning_msg "Running $0 $1 is deprecated because it may not re-enable some interfaces"
	log_action_begin_msg "Reconfiguring network interfaces"
	ifdown -a --exclude=lo $verbose || true
	set -f
	exclusions=$(process_exclusions)
	if ifup -a --exclude=lo $exclusions $verbose && ifup_hotplug $exclusions $verbose
	then
	    log_action_end_msg $?
	else
	    log_action_end_msg $?
	fi
	;;

*)
	echo "Usage: /etc/init.d/networking {start|stop|reload|restart|force-reload}"
	exit 1
	;;
esac

exit 0

########################################
# /etc/init.d/network-manager
########################################
#! /bin/sh
### BEGIN INIT INFO
# Provides:          network-manager
# Required-Start:    $remote_fs dbus udev
# Required-Stop:     $remote_fs dbus udev
# Should-Start:	     $syslog
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: network connection manager
# Description:       Daemon for automatically switching network 
#		     connections to the best available connection.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="network connection manager"
NAME="NetworkManager"

DAEMON=/usr/sbin/$NAME

PIDFILE=/var/run/$NAME/$NAME.pid

SCRIPTNAME=/etc/init.d/network-manager

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

. /lib/lsb/init-functions

test -f /etc/default/NetworkManager && . /etc/default/NetworkManager

#
#	Function that starts the daemon/service.
#
d_start() {
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
		--exec $DAEMON -- $DAEMON_OPTS
}

#
#	Function that stops the daemon/service.
#
d_stop() {
	start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE \
		--exec $DAEMON
}


case "$1" in
  start)
	log_daemon_msg "Starting $DESC" "$NAME"
	d_start
	case "$?" in
		0) log_end_msg 0 ;;
		1) log_progress_msg "already started"
		   log_end_msg 0 ;;
		*) log_end_msg 1 ;;
	esac
	;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	d_stop
	case "$?" in
		0) log_end_msg 0 ;;
		1) log_progress_msg "already stopped"
		   log_end_msg 0 ;;
		*) log_end_msg 1 ;;
	esac
	;;
  restart|force-reload)
	$0 stop
	$0 start
	;;
  status)
	status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0

--
Yubin


More information about the systemd-devel mailing list