Merge some of reb's OpenBSD fixes in

This commit is contained in:
Roy Marples 2007-07-25 20:58:23 +00:00
parent af2d9995d7
commit 075e80b358
7 changed files with 72 additions and 28 deletions

View File

@ -53,7 +53,8 @@ start() {
find /var/lock -type f -print0 | xargs -0 rm -f --
# Clean up /var/run and create /var/run/utmp so we can login.
for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid ! -name random-seed ! -name ld-elf.so.hints); do
for x in $(find /var/run ! -type d ! -name utmp ! -name innd.pid \
! -name random-seed ! -name ld-elf.so.hints ! -name ld.so.hints); do
[ ! -f "${x}" ] && continue
# Do not remove pidfiles of already running daemons
case "${x}" in
@ -66,9 +67,9 @@ start() {
done
# Reset pam_console permissions if we are actually using it
if [ -x /sbin/pam_console_apply -a ! -c /dev/.devfsd ] ; then
if [ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ] ; then
/sbin/pam_console_apply -r
if [ -x /sbin/pam_console_apply ] && ! [ -c /dev/.devfsd ] ; then
if grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep -q 'pam_console.so' ; then
pam_console_apply -r
fi
fi

View File

@ -32,8 +32,11 @@ do_mtab() {
}
do_fsck() {
local retval=0 opts="-F"
[ "${RC_UNAME}" = "Linux" ] && opts="-T -C0"
local retval=0 opts=
case "${RC_UNAME}" in
FreeBSD) opts="-F";;
Linux) opts="-T -C0";;
esac
# Don't bother doing a fsck on these
if [ -n "${CDBOOT}" ] || is_net_fs / || is_union_fs / ; then

View File

@ -21,9 +21,9 @@ start() {
mount -at "${types}"
eend $? "Some local filesystem failed to mount"
# Change the mount options of already mounted paritions
# Change the mount options of already mounted partitions
# This is needed when /usr is separate and coming back from single user
if [ "${RC_UNAME}" != "Linux" ] ; then
if [ "${RC_UNAME}" = "FreeBSD" ] ; then
mount -uao fstab -t "${types},linprocfs"
fi
@ -34,13 +34,17 @@ start() {
chmod 700 "${dumpdir}"
fi
# Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset, savecore
# will check on the partitions listed in fstab without errors in the
# output
if savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null ; then
local savecoreopts="${dumpdir} ${KERNEL_DUMP_DEVICE}"
[ "${KERNEL_DUMP_COMPRESS}" = "yes" ] \
&& savecoreopts="-z ${savecoreopts}"
if [ "${RC_UNAME}" = "FreeBSD" ] ; then
# Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset,
# savecore will check on the partitions listed in fstab
# without errors in the output
savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null
else
ls "${dumpdir}"/bsd* > /dev/null 2>&1
fi
if [ $? = 0 ] ; then
local sopts="${dumpdir} ${KERNEL_DUMP_DEVICE}"
[ "${KERNEL_DUMP_COMPRESS}" = "yes" ] && sopts="-z ${sopts}"
ebegin "Saving kernel core dump in" "${dumpdir}"
savecore ${savecoreopts} >/dev/null
eend $?

View File

@ -7,7 +7,13 @@ ifconfig_depend() {
}
_exists() {
[ -e /dev/net/"${IFACE}" ]
# Only FreeBSD sees to have /dev/net .... is there something
# other than ifconfig we can use for the others?
if [ -d /dev/net ] ; then
[ -e /dev/net/"${IFACE}" ]
else
ifconfig "${IFACE}" >/dev/null 2>&1
fi
}
_get_mac_address() {
@ -33,13 +39,26 @@ _down () {
}
_ifindex() {
local x=
for x in /dev/net[0-9]* ; do
if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then
echo "${x#/dev/net}"
return 0
fi
done
local x= i=1
case "${RC_UNAME}" in
FreeBSD|DragonFly)
for x in /dev/net[0-9]* ; do
if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then
echo "${x#/dev/net}"
return 0
fi
done
;;
default)
for x in $(ifconfig -a | sed -n -e 's/^\([^[:space:]]*\):.*/\1/p') ; do
if [ "${x}" = "${IFACE}" ] ; then
echo "${i}"
return 0
fi
i=$((${i} + 1))
done
;;
esac
return 1
}
@ -63,9 +82,21 @@ _add_address() {
set -- "$@" metric ${metric}
fi
# ifconfig doesn't like CIDR addresses
case "${RC_UNAME}" in
NetBSD|OpenBSD)
local ip="${1%%/*}" cidr="${1##*/}" netmask=
if [ -n "${cidr}" -a "${cidr}" != "${ip}" ]; then
netmask="$(_cidr2netmask "${cidr}")"
shift
set -- "${ip}" netmask "${netmask}" "$@"
fi
;;
esac
case "$@" in
*:*) ifconfig "${IFACE}" inet6 add "$@" ;;
*) ifconfig "${IFACE}" add "$@" ;;
*:*) ifconfig "${IFACE}" inet6 "$@" ;;
*) ifconfig "${IFACE}" "$@" ;;
esac
}

View File

@ -40,7 +40,7 @@ mount_svcdir() {
. "${RC_LIBDIR}"/sh/functions.sh
# Disable devd until we need it
sysctl hw.bus.devctl_disable=1 >/dev/null
[ "${RC_UNAME}" = "FreeBSD" ] && sysctl hw.bus.devctl_disable=1 >/dev/null
. "${RC_LIBDIR}"/sh/init-common-post.sh

View File

@ -7,8 +7,11 @@
#define APPLET "mountinfo"
#if defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__NetBSD__) || defined(__OpenBSD__)
#define BSD
#include <sys/types.h>
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
@ -30,7 +33,7 @@
#include "strlist.h"
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__)
#ifdef BSD
static char **find_mounts (regex_t *node_regex, regex_t *skip_node_regex,
regex_t *fstype_regex, regex_t *skip_fstype_regex,
char **mounts, bool node, bool fstype)

View File

@ -990,6 +990,7 @@ int main (int argc, char **argv)
strcmp (runlevel, RC_LEVEL_SYSINIT) == 0) &&
rc_is_env ("RC_COLDPLUG", "yes"))
{
#if defined(__DragonFly__) || defined(__FreeBSD__)
/* The net interfaces are easy - they're all in net /dev/net :) */
start_services = rc_ls_dir (NULL, "/dev/net", 0);
STRLIST_FOREACH (start_services, service, i) {
@ -1001,6 +1002,7 @@ int main (int argc, char **argv)
CHAR_FREE (tmp);
}
rc_strlist_free (start_services);
#endif
/* The mice are a little more tricky.
If we coldplug anything else, we'll probably do it here. */