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

View File

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

View File

@ -21,9 +21,9 @@ start() {
mount -at "${types}" mount -at "${types}"
eend $? "Some local filesystem failed to mount" 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 # 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" mount -uao fstab -t "${types},linprocfs"
fi fi
@ -34,13 +34,17 @@ start() {
chmod 700 "${dumpdir}" chmod 700 "${dumpdir}"
fi fi
# Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset, savecore if [ "${RC_UNAME}" = "FreeBSD" ] ; then
# will check on the partitions listed in fstab without errors in the # Don't quote ${KERNEL_DUMP_DEVICE}, so that if it's unset,
# output # savecore will check on the partitions listed in fstab
if savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null ; then # without errors in the output
local savecoreopts="${dumpdir} ${KERNEL_DUMP_DEVICE}" savecore -C "${dumpdir}" ${KERNEL_DUMP_DEVICE} >/dev/null
[ "${KERNEL_DUMP_COMPRESS}" = "yes" ] \ else
&& savecoreopts="-z ${savecoreopts}" 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}" ebegin "Saving kernel core dump in" "${dumpdir}"
savecore ${savecoreopts} >/dev/null savecore ${savecoreopts} >/dev/null
eend $? eend $?

View File

@ -7,7 +7,13 @@ ifconfig_depend() {
} }
_exists() { _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() { _get_mac_address() {
@ -33,13 +39,26 @@ _down () {
} }
_ifindex() { _ifindex() {
local x= local x= i=1
for x in /dev/net[0-9]* ; do case "${RC_UNAME}" in
if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then FreeBSD|DragonFly)
echo "${x#/dev/net}" for x in /dev/net[0-9]* ; do
return 0 if [ "${x}" -ef /dev/net/"${IFACE}" ] ; then
fi echo "${x#/dev/net}"
done 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 return 1
} }
@ -63,9 +82,21 @@ _add_address() {
set -- "$@" metric ${metric} set -- "$@" metric ${metric}
fi 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 case "$@" in
*:*) ifconfig "${IFACE}" inet6 add "$@" ;; *:*) ifconfig "${IFACE}" inet6 "$@" ;;
*) ifconfig "${IFACE}" add "$@" ;; *) ifconfig "${IFACE}" "$@" ;;
esac esac
} }

View File

@ -40,7 +40,7 @@ mount_svcdir() {
. "${RC_LIBDIR}"/sh/functions.sh . "${RC_LIBDIR}"/sh/functions.sh
# Disable devd until we need it # 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 . "${RC_LIBDIR}"/sh/init-common-post.sh

View File

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

View File

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