From cccdf8cb13ebfb453a713164f4c58a9b0e2f9e9b Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 13 Nov 2009 13:12:58 +0100 Subject: [PATCH] initial checkin --- debian/README.Debian | 62 ++++++++++++++++ debian/changelog | 5 ++ debian/compat | 1 + debian/control | 16 +++++ debian/copyright | 33 +++++++++ debian/docs | 0 debian/grml-udev-config.grml-blockdevices.udev | 3 + debian/grml-udev-config.grml-external.udev | 8 +++ debian/grml-udev-config.grml-forensic.udev | 2 + debian/grml-udev-config.grml-usbdev.udev | 2 + debian/grml-udev-config.init | 98 ++++++++++++++++++++++++++ debian/overrides | 3 + debian/postinst | 39 ++++++++++ debian/postrm | 37 ++++++++++ debian/rules | 63 +++++++++++++++++ scripts/forensic-mark-readonly | 26 +++++++ 16 files changed, 398 insertions(+) create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/docs create mode 100644 debian/grml-udev-config.grml-blockdevices.udev create mode 100644 debian/grml-udev-config.grml-external.udev create mode 100644 debian/grml-udev-config.grml-forensic.udev create mode 100644 debian/grml-udev-config.grml-usbdev.udev create mode 100644 debian/grml-udev-config.init create mode 100644 debian/overrides create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100755 debian/rules create mode 100755 scripts/forensic-mark-readonly diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..f78cae3 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,62 @@ +grml-udev-config for Debian +--------------------------- + +grml.rules +========== +A custom rule file /etc/udev/z30_grml.rules is installed by the grml udev +package. This file contains a udev rule to map USB-Pendrives (or USB-Sticks) to +the /dev/external* device nodes (or symlinks respectively). This allows us to +easily mount USB-Sticks on a grml System and you don't risk to accidentialy +overwrite your SCSI/S-ATA disk. +Note: These rules are deprecated in favour of the grml_usbdev rules mentioned +below. Nevertheless this way of accessing USB-Pendrives is retained for +backwards compatibility reasons. + +grml_usbdev.rules +================= +The rule file /etc/udev/z31_grml_usbdev.rules is installed. The rules contained +in there allow simple access to USB devices like pendrives upon plugging them +in. You'll get according symlinks in /dev (prefixed with 'usb-'), entries in +/etc/fstab (via rebuildfstab) and directories in /mnt according to available +labeled filesystems for free. On removal of the usb device the symlinks and +usb*-directories in /mnt will automatically vanish. + +To prevent udev from automatically creating the directories and fstab entries +please rename the rules file by executing: + + mv z31_grml_usbdev.rules \#z31_grml_usbdev.rules + +inside the directory /etc/udev/rules.d + +Persistent network interfaces +============================= +Don't run write_net_rules on any occasion, it's evil on a Live-CD. The script is +still shipped and can be enabled manually to get persistent network interfaces +across reboots (e.g. after a hd-install). Just execute + + mv \#75_persistent-net-generator.rules 75_persistent-net-generator.rules + +in /etc/udev/rules.d and reload the udev rules with 'udevcontrol reload_rules' +(as root) + +Or better just see 'grml-tips udev' for other ways to get persistent network +interfaces. + +SELinux support +=============== +The udev version on grml is built without support for SELinux. + +Various +======= +The generation of the udeb package has been disabled in debian/rules (by +removing BUILD_UDEB := 1) as this is not needed on grml. Some grml specific +functions have been added to the init script and to the maintainer scripts. + +hg repository +============== +Since version 0.103-0grml1 this package is maintained in the grml hg repository +at http://hg.grml.org/udev. The version in the git repository at +http://git.distanz.ch is not maintained anymore. + + -- Michael Prokop Fri, 13 Nov 2009 12:02:41 +0100 + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..4bf4e9e --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +grml-udev-config (0.0.1) unstable; urgency=low + + * Initial release. [Closes: issue772] + + -- Michael Prokop Fri, 13 Nov 2009 12:02:41 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b3eb043 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: grml-udev-config +Section: admin +Priority: extra +Maintainer: Michael Prokop +Build-Depends: debhelper (>= 7) +Standards-Version: 3.8.3 +Homepage: http://git.grml.org/?p=grml-udev-config.git +Vcs-git: git://git.grml.org/grml-udev-config.git +Vcs-Browser: http://git.grml.org/?p=grml-udev-config.git + +Package: grml-udev-config +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, udev, zsh +Conflicts: ydev (<= 0.141-1grml.04) +Description: custom udev configurations for Grml live system + Udev specific configurations for the Grml live system. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..f694025 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,33 @@ +This package was debianized by Michael Prokop on +Fri, 13 Nov 2009 12:02:41 +0100. + +It was downloaded from http://grml.org/ + +Upstream Author: + + Michael Prokop + +Copyright: + + Copyright (C) 2004-2009 Michael Prokop + +License: + + This software is copyright (c) 2004-2009 by Michael Prokop. + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + 02110-1301, USA. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL-2'. diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..e69de29 diff --git a/debian/grml-udev-config.grml-blockdevices.udev b/debian/grml-udev-config.grml-blockdevices.udev new file mode 100644 index 0000000..5fa63b7 --- /dev/null +++ b/debian/grml-udev-config.grml-blockdevices.udev @@ -0,0 +1,3 @@ +# regenerate /etc/fstab for new/removed devices: +ACTION=="add", SUBSYSTEM=="block", RUN+="/usr/sbin/rebuildfstab -r -config" +ACTION=="remove", SUBSYSTEM=="block", RUN+="/usr/sbin/rebuildfstab -r -config" diff --git a/debian/grml-udev-config.grml-external.udev b/debian/grml-udev-config.grml-external.udev new file mode 100644 index 0000000..6489caf --- /dev/null +++ b/debian/grml-udev-config.grml-external.udev @@ -0,0 +1,8 @@ +# USB-Stick rule +SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNEL=="sd[a-z]*", SYMLINK+="external%n" + +# Create /dev/cdrom* symlinks for CD-ROM devices +# ENV{ID_CDROM}=="?*", SYMLINK+="cdrom" +# ENV{ID_CDROM_CD_RW}=="?*", SYMLINK+="cdrw" +# ENV{ID_CDROM_DVD}=="?*", SYMLINK+="dvd" +# ENV{ID_CDROM_DVD_R}=="?*", SYMLINK+="dvdrw" diff --git a/debian/grml-udev-config.grml-forensic.udev b/debian/grml-udev-config.grml-forensic.udev new file mode 100644 index 0000000..db71dd0 --- /dev/null +++ b/debian/grml-udev-config.grml-forensic.udev @@ -0,0 +1,2 @@ +# mark new block devices as readonly when booting with bootoption forensic/readonly +ACTION=="add", SUBSYSTEM=="block", RUN+="/etc/udev/scripts/forensic-mark-readonly" diff --git a/debian/grml-udev-config.grml-usbdev.udev b/debian/grml-udev-config.grml-usbdev.udev new file mode 100644 index 0000000..dee2691 --- /dev/null +++ b/debian/grml-udev-config.grml-usbdev.udev @@ -0,0 +1,2 @@ +# Create device link for /mnt/usb-sd* stuff +ACTION=="add", KERNEL=="sd[a-z]*", SUBSYSTEM=="block", SUBSYSTEMS=="usb", SYMLINK+="usb-%k", GROUP="users", NAME="%k" diff --git a/debian/grml-udev-config.init b/debian/grml-udev-config.init new file mode 100644 index 0000000..7f2fa85 --- /dev/null +++ b/debian/grml-udev-config.init @@ -0,0 +1,98 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: grml-udev-config +# Required-Start: mountkernfs +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: wrapper around udev to support bootoptions noudev and blacklist +### END INIT INFO + +. /lib/lsb/init-functions + +# are we running within init (non_interactive) or within shell (interactive)? +check_for_non_interactive() { + if [ "$RUNLEVEL" = "S" -a "$PREVLEVEL" = "N" ]; then + return + fi + + TTY=$(my_tty) + if [ -z "$TTY" -o "$TTY" = "/dev/console" -o "$TTY" = "/dev/null" ]; then + return + fi + + return 1 +} + +exec_wrapper() { + if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then + invoke-rc.d $1 $2 + else + /etc/init.d/$1 $2 + fi +} + +udev_init_check() { + # test whether udev is enabled in init's configuration + # if so do not execute our script but instead use original + # udev init script only + if update-rc.d -n udev start 3 S >/dev/null ; then + log_warning_msg "Original udev init script is configured for startup, ignoring request to start $0" + return 1 + fi + + return 0 +} + +case "$1" in + start) + # do not flood console with kernel driver messages + # grep -q debug /proc/cmdline || echo 0 > /proc/sys/kernel/printk + + # do not display anything when bootoption *splash is present: + # if grep -qe ' splash' -qe ' tsplash' -qe ' textsplash' /proc/cmdline ; then + # exec >/dev/null &2' ) + else + printf 'Warning: /etc/grml/autoconfig.functions could not be read.\n'>&2 + fi + + # support bootoption noudev and inform user how to skip + # execution of udev (being bootoption noudev) + if ! grep -q noudev /proc/cmdline ; then + check_for_non_interactive && \ + log_warning_msg "If your system hangs now skip execution of udev via bootoption noudev" + else + # - allow execution of initscript through FORCE=1 when booting with noudev + if [ -z "$FORCE" ] ; then + log_failure_msg "Bootoption noudev found. Skipping execution of udev init script." + if ! check_for_non_interactive ; then + printf "\nIt has been detected that the udev init script\n" + printf "has been run from an interactive shell.\n" + printf "You booted your system using bootoption noudev.\n" + printf "To force startup of udev please run:\n\n" + printf "\tFORCE=1 Start udev\n\n" + fi + exit 1 + fi + fi + + udev_init_check && exec_wrapper udev start + + ;; + + # in any other situation just directly invoke udev: + *) + udev_init_check && exec_wrapper udev $1 + ;; +esac + +exit 0 + +############################################################################## diff --git a/debian/overrides b/debian/overrides new file mode 100644 index 0000000..72af869 --- /dev/null +++ b/debian/overrides @@ -0,0 +1,3 @@ +grml-udev-config: init.d-script-does-not-implement-required-option /etc/init.d/grml-udev-config stop +grml-udev-config: init.d-script-does-not-implement-required-option /etc/init.d/grml-udev-config restart +grml-udev-config: init.d-script-does-not-implement-required-option /etc/init.d/grml-udev-config force-reload diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..3dee958 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for grml-udev-config +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..392322e --- /dev/null +++ b/debian/postrm @@ -0,0 +1,37 @@ +#!/bin/sh +# postrm script for grml-udev-config +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..7dd91ab --- /dev/null +++ b/debian/rules @@ -0,0 +1,63 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp + +build-stamp: + dh_testdir + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + dh_clean + +install: build + dh_testdir + dh_testroot + dh_prep + dh_installdirs /etc/udev/scripts + + install -m 755 scripts/forensic-mark-readonly debian/grml-udev-config/etc/udev/scripts/forensic-mark-readonly + +# Build architecture-dependent files here. +binary-arch: install +# We have nothing to do by default. + +# Build architecture-independent files here. +binary-indep: install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_installudev --name=grml-forensic --priority 01 + dh_installudev --name=grml-external --priority 60 + dh_installudev --name=grml-usbdev --priority 60 + dh_installudev --name=grml-blockdevices --priority 60 + dh_installinit --no-start + # --update-rcd-params='start 2 S .' + dh_installman + dh_link + dh_strip + dh_compress + mkdir -p debian/grml-udev-config/usr/share/lintian/overrides/ + cp -av debian/overrides debian/grml-udev-config/usr/share/lintian/overrides/grml-udev-config + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/scripts/forensic-mark-readonly b/scripts/forensic-mark-readonly new file mode 100755 index 0000000..299c661 --- /dev/null +++ b/scripts/forensic-mark-readonly @@ -0,0 +1,26 @@ +#!/bin/sh +# Filename: forensic-mark-readonly +# Purpose: force device to readonly mode when booting with bootoption forensic/readonly +# Authors: grml-team (grml.org), (c) Michael Prokop +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 or any later version. +################################################################################ + +# check for forensic/readonly bootoption +if grep -qe forensic -qe readonly /proc/cmdline ; then + # we get $DEVNAME via udev's environment + if [ -n "$DEVNAME" ] ; then + if [ "$(blockdev --getro $DEVNAME)" = "1" ] ; then + logger "forensic mode: device $DEVNAME already set to readonly mode, nothing to do" + else + logger "forensic mode: setting $DEVNAME [$ID_SERIAL] to readonly" + if blockdev --setro "$DEVNAME" ; then + logger "|-> done; execute 'blockdev --setrw $DEVNAME' to unlock" + else + logger "|-> error while executing blockdev: $(blockdev --setro $DEVNAME 2>&1)" + fi + fi + fi +fi + +## END OF FILE ################################################################# -- 2.1.4