This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 3.x development tree".
The branch, master has been updated via 22dcbd74cd844fbcb1dcca84365fee7081757426 (commit) via 9dc73312722b730b14a6bdf9b5c998113ad20645 (commit) via 4c29606d3cf72732f2f6ea2902c60be6b711f7e6 (commit) from ff7614b6e99c6a111be8c33ef08628054f3b3d8a (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 22dcbd74cd844fbcb1dcca84365fee7081757426 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri May 13 22:00:21 2011 +0200
initscripts: Sync hardware clock.
commit 9dc73312722b730b14a6bdf9b5c998113ad20645 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri May 13 21:54:53 2011 +0200
initscripts: Remove upstart initscripts.
commit 4c29606d3cf72732f2f6ea2902c60be6b711f7e6 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri May 13 21:48:09 2011 +0200
initscripts: Fix console initialization.
Unicode initialization was broken since we moved from upstart to systemd.
Fixes #196.
-----------------------------------------------------------------------
Summary of changes: pkgs/initscripts/init/checkfs.conf | 77 ---- pkgs/initscripts/init/cleanfs.conf | 8 - pkgs/initscripts/init/control-alt-delete.conf | 6 - pkgs/initscripts/init/load-modules.conf | 49 --- pkgs/initscripts/init/loopback.conf | 16 - pkgs/initscripts/init/mountfs.conf | 22 -- pkgs/initscripts/init/serial.conf | 24 -- pkgs/initscripts/init/shutdown.conf | 33 -- pkgs/initscripts/init/swap.conf | 6 - pkgs/initscripts/init/sysctl.conf | 14 - pkgs/initscripts/init/tty1.conf | 8 - pkgs/initscripts/init/tty2.conf | 8 - pkgs/initscripts/init/tty3.conf | 8 - pkgs/initscripts/init/tty4.conf | 8 - pkgs/initscripts/init/udev-retry.conf | 23 -- pkgs/initscripts/init/udev.conf | 22 -- pkgs/initscripts/init/udevtrigger.conf | 15 - pkgs/initscripts/init/welcome.conf | 24 -- pkgs/initscripts/initscripts.nm | 10 +- pkgs/initscripts/src/Makefile | 10 +- pkgs/initscripts/src/console_init.c | 168 +++++++++ pkgs/initscripts/src/shvar.c | 393 ++++++++++++++++++++ pkgs/initscripts/src/shvar.h | 103 +++++ .../rules => initscripts/udev}/10-console.rules | 6 + pkgs/initscripts/udev/88-clock.rules | 3 + 25 files changed, 688 insertions(+), 376 deletions(-) delete mode 100644 pkgs/initscripts/init/checkfs.conf delete mode 100644 pkgs/initscripts/init/cleanfs.conf delete mode 100644 pkgs/initscripts/init/control-alt-delete.conf delete mode 100644 pkgs/initscripts/init/load-modules.conf delete mode 100644 pkgs/initscripts/init/loopback.conf delete mode 100644 pkgs/initscripts/init/mountfs.conf delete mode 100644 pkgs/initscripts/init/serial.conf delete mode 100644 pkgs/initscripts/init/shutdown.conf delete mode 100644 pkgs/initscripts/init/swap.conf delete mode 100644 pkgs/initscripts/init/sysctl.conf delete mode 100644 pkgs/initscripts/init/tty1.conf delete mode 100644 pkgs/initscripts/init/tty2.conf delete mode 100644 pkgs/initscripts/init/tty3.conf delete mode 100644 pkgs/initscripts/init/tty4.conf delete mode 100644 pkgs/initscripts/init/udev-retry.conf delete mode 100644 pkgs/initscripts/init/udev.conf delete mode 100644 pkgs/initscripts/init/udevtrigger.conf delete mode 100644 pkgs/initscripts/init/welcome.conf create mode 100644 pkgs/initscripts/src/console_init.c create mode 100644 pkgs/initscripts/src/shvar.c create mode 100644 pkgs/initscripts/src/shvar.h copy pkgs/{udev/rules => initscripts/udev}/10-console.rules (78%) create mode 100644 pkgs/initscripts/udev/88-clock.rules
Difference in files: diff --git a/pkgs/initscripts/init/checkfs.conf b/pkgs/initscripts/init/checkfs.conf deleted file mode 100644 index f1de5d4..0000000 --- a/pkgs/initscripts/init/checkfs.conf +++ /dev/null @@ -1,77 +0,0 @@ -description "Check / filesystem" -author "IPFire Team" - -start on stopped udevtrigger - -console output - -script - # If requested, do not check the filesystems - [ -f /fastboot ] && exit 0 - - set -e - . /etc/init/functions - - mount -n -o remount,ro / >/dev/null - if [ ${?} != 0 ]; then - log_failure_msg "Mounting root file system in read-only mode" - echo -e "${FAILURE}FAILURE:\n" - echo -e -n "${FAILURE}Cannot check root filesystem because it " - echo -e "${FAILURE}could not be mounted" - echo -e "${FAILURE}in read-only mode.\n\n" - echo -e -n "${FAILURE}After you press Enter, this system will be " - echo -e "${FAILURE}halted and powered off.\n" - echo -e "${INFO}Press enter to continue...${NORMAL}" - read ENTER - ## XXX need to shutdown the system cleanly here - fi - - # Force check if /forcefsck is found - if [ -f /forcefsck ]; then - options="-f" - else - options="" - fi - - # Note: -a option used to be -p; but this fails e.g. - # on fsck.minix - fsck ${options} -a -A -C -T - error_value=${?} - - if [ "${error_value}" = 1 ]; then - log_warning_msg "Checking file systems..." - echo -e "${WARNING}WARNING:\n" - echo -e "${WARNING}File system errors were found and have been" - echo -e "${WARNING}corrected. You may want to double-check that" - echo -e "${WARNING}everything was fixed properly.${NORMAL}" - elif [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then - log_warning_msg "Checking file systems..." - echo -e "${WARNING}WARNING:\n" - echo -e "${WARNING}File system errors were found and have been been" - echo -e "${WARNING}corrected, but the nature of the errors require" - echo -e "${WARNING}this system to be rebooted.\n" - echo -e "After you press enter, this system will be rebooted.\n" - echo -e "${INFO}Press Enter to continue...${NORMAL}" - read ENTER - ## XXX need to reboot the system here - elif [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then - log_failure_msg "Checking file systems..." - echo -e "${FAILURE}FAILURE:\n" - echo -e "${FAILURE}File system errors were encountered that could" - echo -e "${FAILURE}not be fixed automatically. This system cannot" - echo -e "${FAILURE}continue to boot and will therefore be halted" - echo -e "${FAILURE}until those errors are fixed manually by a" - echo -e "${FAILURE}System Administrator.\n" - echo -e "${FAILURE}After you press Enter, this system will be" - echo -e "${FAILURE}halted and powered off.\n" - echo -e "${INFO}Press Enter to continue...${NORMAL}" - read ENTER - ## XXX need to shutdown the system here - elif [ "${error_value}" -ge 16 ]; then - log_failure_msg "Checking file systems..." - echo -e "${FAILURE}FAILURE:\n" - echo -e "${FAILURE}Unexpected Failure running fsck. Exited with error" - echo -e "${FAILURE}code: ${error_value}.${NORMAL}" - exit ${error_value} - fi -end script diff --git a/pkgs/initscripts/init/cleanfs.conf b/pkgs/initscripts/init/cleanfs.conf deleted file mode 100644 index c0f5606..0000000 --- a/pkgs/initscripts/init/cleanfs.conf +++ /dev/null @@ -1,8 +0,0 @@ -description "Cleaning / filesystem" -author "IPFire Team" - -start on stopping mountfs - -script - rm -rf /tmp/* /var/{lock,run}/* -end script diff --git a/pkgs/initscripts/init/control-alt-delete.conf b/pkgs/initscripts/init/control-alt-delete.conf deleted file mode 100644 index 3181894..0000000 --- a/pkgs/initscripts/init/control-alt-delete.conf +++ /dev/null @@ -1,6 +0,0 @@ -description "Control-Alt-Delete / Handling" -author "IPFire Team" - -start on control-alt-delete - -exec initctl emit --no-wait reboot diff --git a/pkgs/initscripts/init/load-modules.conf b/pkgs/initscripts/init/load-modules.conf deleted file mode 100644 index d9cc718..0000000 --- a/pkgs/initscripts/init/load-modules.conf +++ /dev/null @@ -1,49 +0,0 @@ -description "Trigger coldplug events" -author "IPFire Team" - -start on startup - -script - # Exit if there's no modules file or there are no - # valid entries - [ -r /etc/sysconfig/modules ] && - egrep -qv '^($|#)' /etc/sysconfig/modules || - exit 0 - - # If proc is mounted, find the current kernel - # message level - if [ -f /proc/sys/kernel/printk ]; then - prev_msg=`cat /proc/sys/kernel/printk | \ - sed 'l 1' | sed -n '2~0p' | \ - sed 's/\//'` - else - prev_msg="6" - fi - - # Now set the message level to 1 so not to make too - # much noise when loading modules - dmesg -n 1 - - # Only try to load modules if the user has actually given us - # some modules to load. - if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null; then - # Read in the configuration file. - exec 9>&0 < /etc/sysconfig/modules - - while read module args; do - # Ignore comments and blank lines. - case "${module}" in - ""|#*) continue ;; - esac - - # Attempt to load the module, making - # sure to pass any arguments provided. - modprobe ${module} ${args} > /dev/null - done - - exec 0>&9 9>&- - - fi - # Set the kernel message level back to it's previous value. - dmesg -n "${prev_msg}" -end script diff --git a/pkgs/initscripts/init/loopback.conf b/pkgs/initscripts/init/loopback.conf deleted file mode 100644 index fc5d64a..0000000 --- a/pkgs/initscripts/init/loopback.conf +++ /dev/null @@ -1,16 +0,0 @@ -description "Bringing up the local network" -author "IPFire Team" - -start on started udev - -script - [ -e "/etc/sysconfig/network" ] && \ - . /etc/sysconfig/network - - ip addr add 127.0.0.1/8 label lo dev lo - ip link set lo up - - if [ -n "${HOSTNAME}" ]; then - hostname "${HOSTNAME}" - fi -end script diff --git a/pkgs/initscripts/init/mountfs.conf b/pkgs/initscripts/init/mountfs.conf deleted file mode 100644 index c432c5c..0000000 --- a/pkgs/initscripts/init/mountfs.conf +++ /dev/null @@ -1,22 +0,0 @@ -description "Mount / filesystem" -author "IPFire Team" - -start on stopped checkfs - -console output - -script - mount -n -o remount,rw / >/dev/null - - # Remove fsck-related file system watermarks. - rm -f /fastboot /forcefsck - - > /etc/mtab - mount -f / - mount -f /proc - mount -f /sys - - # This will mount all filesystems that do not have _netdev in - # their option list. _netdev denotes a network filesystem. - mount -a -O no_netdev >/dev/null -end script diff --git a/pkgs/initscripts/init/serial.conf b/pkgs/initscripts/init/serial.conf deleted file mode 100644 index fe554b4..0000000 --- a/pkgs/initscripts/init/serial.conf +++ /dev/null @@ -1,24 +0,0 @@ -description "Start a tty" -author "IPFire Team" - -# Automatically start a configured serial console -# -# How this works: -# -# On boot, a udev helper examines /dev/console. If a serial console is the -# primary console (last console on the commandline in grub), the event -# 'serial-console-available <port name> <speed>' is emitted, which -# triggers this script. -# -# If your serial console is not the primary console, or you want a getty -# on serial even if it's not the console, create your own event by copying -# /etc/init/tty[2-6], and changing the getty line in that file. - -start on serial-console-available * -stop on kill-all-services - -pre-start script - /sbin/securetty $DEV -end script - -exec /sbin/agetty $DEV $SPEED vt100-nav diff --git a/pkgs/initscripts/init/shutdown.conf b/pkgs/initscripts/init/shutdown.conf deleted file mode 100644 index 225254d..0000000 --- a/pkgs/initscripts/init/shutdown.conf +++ /dev/null @@ -1,33 +0,0 @@ -description "Shutdown or reboot the system" -author "IPFire Team" - -start on shutdown or reboot - -console output - -script - # Emit event to kill all network services - initctl emit kill-all-network-services - - # Shutdown the network - initctl emit shutdown-network - - # Emit event to kill all system services - initctl emit kill-all-services - - # Exterminate any lil' process that managed to evade my merciless - # terminating. - killall5 -15 || true - sleep 5 - killall5 -9 || truees - - mount -n -o remount,ro / || true - - # The UPSTART_EVENTS variable contains the event that has been called. - # The script use it to perform the requested action. - if [ "${UPSTART_EVENTS}" = "reboot" ]; then - reboot -pf - else - halt -pf - fi -end script diff --git a/pkgs/initscripts/init/swap.conf b/pkgs/initscripts/init/swap.conf deleted file mode 100644 index 8cbf129..0000000 --- a/pkgs/initscripts/init/swap.conf +++ /dev/null @@ -1,6 +0,0 @@ -description "Activating swap partitions" -author "IPFire Team" - -start on stopped checkfs - -exec /sbin/swapon -a diff --git a/pkgs/initscripts/init/sysctl.conf b/pkgs/initscripts/init/sysctl.conf deleted file mode 100644 index 7293c3b..0000000 --- a/pkgs/initscripts/init/sysctl.conf +++ /dev/null @@ -1,14 +0,0 @@ -description "Set sysctl settings" -author "IPFire Team" - -start on startup - -script - if [ -f "/etc/sysctl.conf" ]; then - sysctl -q -p - fi - if [ -d "/proc/sys/kernel/grsecurity" -a \ - -f "/etc/grsec/sysctl.conf" ]; then - sysctl -q -p /etc/grsec/sysctl.conf - fi -end script diff --git a/pkgs/initscripts/init/tty1.conf b/pkgs/initscripts/init/tty1.conf deleted file mode 100644 index 4422b69..0000000 --- a/pkgs/initscripts/init/tty1.conf +++ /dev/null @@ -1,8 +0,0 @@ -description "Start a tty" -author "IPFire Team" - -start on stopped mountfs -stop on kill-all-services - -respawn -exec /sbin/agetty 9600 tty1 diff --git a/pkgs/initscripts/init/tty2.conf b/pkgs/initscripts/init/tty2.conf deleted file mode 100644 index c133a43..0000000 --- a/pkgs/initscripts/init/tty2.conf +++ /dev/null @@ -1,8 +0,0 @@ -description "Start a tty" -author "IPFire Team" - -start on stopped mountfs -stop on kill-all-services - -respawn -exec /sbin/agetty 9600 tty2 diff --git a/pkgs/initscripts/init/tty3.conf b/pkgs/initscripts/init/tty3.conf deleted file mode 100644 index e5d2d08..0000000 --- a/pkgs/initscripts/init/tty3.conf +++ /dev/null @@ -1,8 +0,0 @@ -description "Start a tty" -author "IPFire Team" - -start on stopped mountfs -stop on kill-all-services - -respawn -exec /sbin/agetty 9600 tty3 diff --git a/pkgs/initscripts/init/tty4.conf b/pkgs/initscripts/init/tty4.conf deleted file mode 100644 index 5db8548..0000000 --- a/pkgs/initscripts/init/tty4.conf +++ /dev/null @@ -1,8 +0,0 @@ -description "Start a tty" -author "IPFire Team" - -start on stopped mountfs -stop on kill-all-services - -respawn -exec /sbin/agetty 9600 tty4 diff --git a/pkgs/initscripts/init/udev-retry.conf b/pkgs/initscripts/init/udev-retry.conf deleted file mode 100644 index 47c74ad..0000000 --- a/pkgs/initscripts/init/udev-retry.conf +++ /dev/null @@ -1,23 +0,0 @@ -description "Retry failed udev events" -author "IPFire Team" - -start on stopped udevtrigger - -console output - -script - # From Debian: "copy the rules generated before / was mounted - # read-write": - for file in /dev/.udev/tmp-rules--*; do - dest=${file##*tmp-rules--} - [ "$dest" = '*' ] && break - cat $file >> /etc/udev/rules.d/$dest - rm -f $file - done - - # Re-trigger the failed uevents in hope they will succeed now - /sbin/udevadm trigger --action=add --type=failed - - # Now wait for udevd to process the uevents we triggered - /sbin/udevadm settle -end script diff --git a/pkgs/initscripts/init/udev.conf b/pkgs/initscripts/init/udev.conf deleted file mode 100644 index 6437e9b..0000000 --- a/pkgs/initscripts/init/udev.conf +++ /dev/null @@ -1,22 +0,0 @@ -description "Start Udev Daemon" -author "IPFire Team" - -start on startup -stop on kill-all-services - -console output - -# xxx should be a pre-start script but it only works as script - -# I don't know why... - -script - # Mount a temporary file system over /dev, so that any devices - # made or removed during this boot don't affect the next one. - # The reason we don't write to mtab is because we don't ever - # want /dev to be unavailable (such as by `umount -a'). - mount -n -t tmpfs tmpfs /dev -o mode=755 -end script - -expect fork -exec /sbin/udevd --daemon -respawn diff --git a/pkgs/initscripts/init/udevtrigger.conf b/pkgs/initscripts/init/udevtrigger.conf deleted file mode 100644 index 2edd29f..0000000 --- a/pkgs/initscripts/init/udevtrigger.conf +++ /dev/null @@ -1,15 +0,0 @@ -description "Trigger udev events" -author "IPFire Team" - -start on started udev - -console output - -script - # Now traverse /sys in order to "coldplug" devices that have - # already been discovered - udevadm trigger --action=add - - # Now wait for udevd to process the uevents we triggered - udevadm settle --timeout=5 || true -end script diff --git a/pkgs/initscripts/init/welcome.conf b/pkgs/initscripts/init/welcome.conf deleted file mode 100644 index 37ca7eb..0000000 --- a/pkgs/initscripts/init/welcome.conf +++ /dev/null @@ -1,24 +0,0 @@ -description "Display a welcome message to the user" -author "IPFire Team" - -start on startup - -console output - -script - . /etc/init/functions - - # dcol are spaces before the message to center the - # message on screen. - dcol=$(( $(( ${COLUMNS} - ${welcome_message_length} )) / 2 )) - echo -e "\033[${dcol}G${welcome_message}" - - system_message=$(uname -r) - system_message_length=${#system_message} - system_message="Running on Linux ${FAILURE}${system_message}${NORMAL}" - system_message_length=$((17 + ${system_message_length})) - dcol=$(( $(( ${COLUMNS} - ${system_message_length} )) / 2 )) - echo -e "\033[${dcol}G${system_message}" - - echo "" -end script diff --git a/pkgs/initscripts/initscripts.nm b/pkgs/initscripts/initscripts.nm index 6dea941..de10dec 100644 --- a/pkgs/initscripts/initscripts.nm +++ b/pkgs/initscripts/initscripts.nm @@ -25,8 +25,9 @@ include $(PKGROOT)/Include
PKG_NAME = initscripts -PKG_VER = $(DISTRO_VERSION) -PKG_REL = 1 +PKG_EPOCH = 1 +PKG_VER = 2.99 +PKG_REL = 3
PKG_MAINTAINER = PKG_GROUPS = Base System/Boot @@ -34,6 +35,7 @@ PKG_URL = PKG_LICENSE = GPLv3+ PKG_SUMMARY = The set of scripts that initalize the system.
+PKG_BUILD_DEPS+= glib2-devel PKG_DEPS += bash coreutils e2fsprogs grep iproute2 module-init-tools \ procps sed system-release udev util-linux
@@ -65,4 +67,8 @@ define STAGE_INSTALL chmod -v 755 $(BUILDROOT)/etc/sysconfig/rc.local
cp -vf $(DIR_SOURCE)/sysctl.conf $(BUILDROOT)/etc + + # Install udev rules + -mkdir -pv $(BUILDROOT)/lib/udev/rules.d/ + cp -vf $(DIR_SOURCE)/udev/* $(BUILDROOT)/lib/udev/rules.d/ endef diff --git a/pkgs/initscripts/src/Makefile b/pkgs/initscripts/src/Makefile index 452f45f..a93390d 100644 --- a/pkgs/initscripts/src/Makefile +++ b/pkgs/initscripts/src/Makefile @@ -1,7 +1,8 @@
-PROGS = console_check securetty +PROGS = console_check console_init securetty
-CFLAGS += -D_GNU_SOURCE +CC = gcc +CFLAGS += -D_GNU_SOURCE $(shell pkg-config --cflags glib-2.0)
all: $(PROGS)
@@ -11,11 +12,14 @@ clean: install: -mkdir -pv $(DESTDIR)/lib/udev $(DESTDIR)/sbin install -v -m 755 console_check $(DESTDIR)/lib/udev/ + install -v -m 755 console_init $(DESTDIR)/lib/udev/ install -v -m 755 securetty $(DESTDIR)/sbin
- console_check: console_check.o $(CC) $(LDFLAGS) -o $@ $<
+console_init: console_init.o shvar.o + $(CC) $(LDFLAGS) $(shell pkg-config --libs glib-2.0) -o $@ $? + securetty: securetty.o $(CC) $(LDFLAGS) -o $@ $< diff --git a/pkgs/initscripts/src/console_init.c b/pkgs/initscripts/src/console_init.c new file mode 100644 index 0000000..22083a8 --- /dev/null +++ b/pkgs/initscripts/src/console_init.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2008-2009 Red Hat, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * This program 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 program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + */ + +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/wait.h> + +#include <linux/kd.h> + +#include "shvar.h" + +static char *lang = NULL; +static char *font = NULL; +static char *acm = NULL; +static char *unimap = NULL; +static char *keymap = NULL; + +static int linux_console(int fd) { + unsigned char twelve = 12; + + if (ioctl(fd, TIOCLINUX, &twelve) >= 0) + return 1; + return 0; +} + +static int configured_as_utf8() { + shvarFile *i18nfile = NULL; + + if ((i18nfile = svNewFile("/etc/sysconfig/i18n")) == NULL) + return 1; /* assume UTF-8 */ + + lang = svGetValue(i18nfile, "LANG"); + font = svGetValue(i18nfile, "SYSFONT"); + acm = svGetValue(i18nfile, "SYSFONTACM"); + unimap = svGetValue(i18nfile, "UNIMAP"); + svCloseFile(i18nfile); + if (!lang) + return 1; + if (g_str_has_suffix(lang,".utf8") || g_str_has_suffix(lang,".UTF-8")) + return 1; + return 0; +} + +static int read_keymap() { + shvarFile *keyboard = NULL; + char *tmp; + struct stat sb; + + if (!stat("/etc/sysconfig/console/default.kmap",&sb)) { + keymap = "/etc/sysconfig/console/default.kmap"; + return 0; + } + + if ((keyboard = svNewFile("/etc/sysconfig/keyboard")) == NULL) + return 0; + + tmp = svGetValue(keyboard, "KEYMAP"); + if (tmp) + keymap = tmp; + tmp = svGetValue(keyboard, "KEYTABLE"); + if (tmp) { + if (keymap) free(keymap); + asprintf(&keymap, "%s.map", tmp); + } + return 0; +} + +static void set_font(char *device) { + int pid; + + if ( (pid = fork()) == 0) { + char *args[] = { "setfont", "latarcyrheb-sun16", "-C", NULL, + NULL, NULL, NULL, NULL, NULL }; + + if (font) + args[1] = font; + args[3] = device; + if (acm) { + args[4] = "-m"; + args[5] = acm; + if (unimap) { + args[6] = "-u"; + args[7] = unimap; + } + } else if (unimap) { + args[4] = "-u"; + args[5] = unimap; + } + execv("/bin/setfont", args); + exit(1); + } +} + +static void set_keyboard(int fd, int utf8) { + if (ioctl(fd, KDSKBMODE, utf8 ? K_UNICODE : K_XLATE)) + perror("could not set keyboard mode"); +} + +static void set_terminal(int fd, int utf8) { + if (utf8) + write(fd, "\033%G", 3); + else + write(fd, "\033%@", 3); +} + +static void set_keymap(int fd, int utf8) { + int pid; + + if ((pid = fork()) == 0) { + char *args[] = { "loadkeys", "-q", NULL, NULL, NULL }; + dup2(fd, 0); + dup2(fd, 1); + + if (utf8) { + args[2] = "-u"; + args[3] = keymap; + } else { + args[2] = keymap; + } + execv("/bin/loadkeys", args); + exit(1); + } +} + +int main(int argc, char **argv) { + char *device; + int dev; + + if (argc < 2) { + printf("usage: console_init <device>\n"); + exit(1); + } + chdir("/dev"); + device = argv[1]; + dev = open(device, O_RDWR); + if (linux_console(dev)) { + int utf8 = configured_as_utf8(); + + set_keyboard(dev, utf8); + set_terminal(dev, utf8); + set_font(device); + read_keymap(); + if (keymap) + set_keymap(dev,utf8); + } + return 0; +} diff --git a/pkgs/initscripts/src/shvar.c b/pkgs/initscripts/src/shvar.c new file mode 100644 index 0000000..765a77e --- /dev/null +++ b/pkgs/initscripts/src/shvar.c @@ -0,0 +1,393 @@ +/* + * shvar.c + * + * Implementation of non-destructively reading/writing files containing + * only shell variable declarations and full-line comments. + * + * Includes explicit inheritance mechanism intended for use with + * Red Hat Linux ifcfg-* files. There is no protection against + * inheritance loops; they will generally cause stack overflows. + * Furthermore, they are only intended for one level of inheritance; + * the value setting algorithm assumes this. + * + * Copyright 1999,2000 Red Hat, Inc. + * + * This 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "shvar.h" + +/* Open the file <name>, returning a shvarFile on success and NULL on failure. + Add a wrinkle to let the caller specify whether or not to create the file + (actually, return a structure anyway) if it doesn't exist. */ +static shvarFile * +svOpenFile(const char *name, gboolean create) +{ + shvarFile *s = NULL; + int closefd = 0; + + s = g_malloc0(sizeof(shvarFile)); + + s->fd = open(name, O_RDWR); /* NOT O_CREAT */ + if (s->fd == -1) { + /* try read-only */ + s->fd = open(name, O_RDONLY); /* NOT O_CREAT */ + if (s->fd != -1) closefd = 1; + } + s->fileName = g_strdup(name); + + if (s->fd != -1) { + struct stat buf; + char *p, *q; + + if (fstat(s->fd, &buf) < 0) goto bail; + s->arena = g_malloc0(buf.st_size + 1); + + if (read(s->fd, s->arena, buf.st_size) < 0) goto bail; + + /* we'd use g_strsplit() here, but we want a list, not an array */ + for(p = s->arena; (q = strchr(p, '\n')) != NULL; p = q + 1) { + s->lineList = g_list_append(s->lineList, g_strndup(p, q - p)); + } + + /* closefd is set if we opened the file read-only, so go ahead and + close it, because we can't write to it anyway */ + if (closefd) { + close(s->fd); + s->fd = -1; + } + + return s; + } + + if (create) { + return s; + } + +bail: + if (s->fd != -1) close(s->fd); + if (s->arena) g_free (s->arena); + if (s->fileName) g_free (s->fileName); + g_free (s); + return NULL; +} + +/* Open the file <name>, return shvarFile on success, NULL on failure */ +shvarFile * +svNewFile(const char *name) +{ + return svOpenFile(name, FALSE); +} + +/* Create a new file structure, returning actual data if the file exists, + * and a suitable starting point if it doesn't. */ +shvarFile * +svCreateFile(const char *name) +{ + return svOpenFile(name, TRUE); +} + +/* remove escaped characters in place */ +static void +unescape(char *s) { + int len, i; + + len = strlen(s); + if ((s[0] == '"' || s[0] == ''') && s[0] == s[len-1]) { + i = len - 2; + memmove(s, s+1, i); + s[i+1] = '\0'; + len = i; + } + for (i = 0; i < len; i++) { + if (s[i] == '\') { + memmove(s+i, s+i+1, len-(i+1)); + len--; + } + s[len] = '\0'; + } +} + + +/* create a new string with all necessary characters escaped. + * caller must free returned string + */ +static const char escapees[] = ""'\$~`"; /* must be escaped */ +static const char spaces[] = " \t|&;()<>"; /* only require "" */ +static char * +escape(const char *s) { + char *new; + int i, j, mangle = 0, space = 0; + int newlen, slen; + static int esclen, splen; + + if (!esclen) esclen = strlen(escapees); + if (!splen) splen = strlen(spaces); + slen = strlen(s); + + for (i = 0; i < slen; i++) { + if (strchr(escapees, s[i])) mangle++; + if (strchr(spaces, s[i])) space++; + } + if (!mangle && !space) return strdup(s); + + newlen = slen + mangle + 3; /* 3 is extra ""\0 */ + new = g_malloc0(newlen); + if (!new) return NULL; + + j = 0; + new[j++] = '"'; + for (i = 0; i < slen; i++) { + if (strchr(escapees, s[i])) { + new[j++] = '\'; + } + new[j++] = s[i]; + } + new[j++] = '"'; + g_assert(j == slen + mangle + 2); /* j is the index of the '\0' */ + + return new; +} + +/* Get the value associated with the key, and leave the current pointer + * pointing at the line containing the value. The char* returned MUST + * be freed by the caller. + */ +char * +svGetValue(shvarFile *s, const char *key) +{ + char *value = NULL; + char *line; + char *keyString; + int len; + + g_assert(s); + g_assert(key); + + keyString = g_malloc0(strlen(key) + 2); + strcpy(keyString, key); + keyString[strlen(key)] = '='; + len = strlen(keyString); + + for (s->current = s->lineList; s->current; s->current = s->current->next) { + line = s->current->data; + if (!strncmp(keyString, line, len)) { + value = g_strdup(line + len); + unescape(value); + break; + } + } + g_free(keyString); + + if (value) { + if (value[0]) { + return value; + } else { + g_free(value); + return NULL; + } + } + if (s->parent) value = svGetValue(s->parent, key); + return value; +} + +/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true") + * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false") + * return <default> otherwise + */ +int +svTrueValue(shvarFile *s, const char *key, int def) +{ + char *tmp; + int returnValue = def; + + tmp = svGetValue(s, key); + if (!tmp) return returnValue; + + if ( (!strcasecmp("yes", tmp)) || + (!strcasecmp("true", tmp)) || + (!strcasecmp("t", tmp)) || + (!strcasecmp("y", tmp)) ) returnValue = 1; + else + if ( (!strcasecmp("no", tmp)) || + (!strcasecmp("false", tmp)) || + (!strcasecmp("f", tmp)) || + (!strcasecmp("n", tmp)) ) returnValue = 0; + + g_free (tmp); + return returnValue; +} + + +/* Set the variable <key> equal to the value <value>. + * If <key> does not exist, and the <current> pointer is set, append + * the key=value pair after that line. Otherwise, prepend the pair + * to the top of the file. Here's the algorithm, as the C code + * seems to be rather dense: + * + * if (value == NULL), then: + * if val2 (parent): change line to key= or append line key= + * if val1 (this) : delete line + * else noop + * else use this table: + * val2 + * NULL value other + * v NULL append line noop append line + * a + * l value noop noop noop + * 1 + * other change line delete line change line + * + * No changes are ever made to the parent config file, only to the + * specific file passed on the command line. + * + */ +void +svSetValue(shvarFile *s, const char *key, const char *value) +{ + char *newval = NULL, *val1 = NULL, *val2 = NULL; + char *keyValue; + + g_assert(s); + g_assert(key); + /* value may be NULL */ + + if (value) newval = escape(value); + keyValue = g_strdup_printf("%s=%s", key, newval ? newval : ""); + + val1 = svGetValue(s, key); + if (val1 && newval && !strcmp(val1, newval)) goto bail; + if (s->parent) val2 = svGetValue(s->parent, key); + + if (!newval || !newval[0]) { + /* delete value somehow */ + if (val2) { + /* change/append line to get key= */ + if (s->current) s->current->data = keyValue; + else s->lineList = g_list_append(s->lineList, keyValue); + s->freeList = g_list_append(s->freeList, keyValue); + s->modified = 1; + } else if (val1) { + /* delete line */ + s->lineList = g_list_remove_link(s->lineList, s->current); + g_list_free_1(s->current); + s->modified = 1; + goto bail; /* do not need keyValue */ + } + goto end; + } + + if (!val1) { + if (val2 && !strcmp(val2, newval)) goto end; + /* append line */ + s->lineList = g_list_append(s->lineList, keyValue); + s->freeList = g_list_append(s->freeList, keyValue); + s->modified = 1; + goto end; + } + + /* deal with a whole line of noops */ + if (val1 && !strcmp(val1, newval)) goto end; + + /* At this point, val1 && val1 != value */ + if (val2 && !strcmp(val2, newval)) { + /* delete line */ + s->lineList = g_list_remove_link(s->lineList, s->current); + g_list_free_1(s->current); + s->modified = 1; + goto bail; /* do not need keyValue */ + } else { + /* change line */ + if (s->current) s->current->data = keyValue; + else s->lineList = g_list_append(s->lineList, keyValue); + s->freeList = g_list_append(s->freeList, keyValue); + s->modified = 1; + } + +end: + if (newval) free(newval); + if (val1) free(val1); + if (val2) free(val2); + return; + +bail: + if (keyValue) free (keyValue); + goto end; +} + +/* Write the current contents iff modified. Returns -1 on error + * and 0 on success. Do not write if no values have been modified. + * The mode argument is only used if creating the file, not if + * re-writing an existing file, and is passed unchanged to the + * open() syscall. + */ +int +svWriteFile(shvarFile *s, int mode) +{ + FILE *f; + int tmpfd; + + if (s->modified) { + if (s->fd == -1) + s->fd = open(s->fileName, O_WRONLY|O_CREAT, mode); + if (s->fd == -1) + return -1; + if (ftruncate(s->fd, 0) < 0) + return -1; + + tmpfd = dup(s->fd); + f = fdopen(tmpfd, "w"); + fseek(f, 0, SEEK_SET); + for (s->current = s->lineList; s->current; s->current = s->current->next) { + char *line = s->current->data; + fprintf(f, "%s\n", line); + } + fclose(f); + } + + return 0; +} + + +/* Close the file descriptor (if open) and delete the shvarFile. + * Returns -1 on error and 0 on success. + */ +int +svCloseFile(shvarFile *s) +{ + + g_assert(s); + + if (s->fd != -1) close(s->fd); + + g_free(s->arena); + for (s->current = s->freeList; s->current; s->current = s->current->next) { + g_free(s->current->data); + } + g_free(s->fileName); + g_list_free(s->freeList); + g_list_free(s->lineList); /* implicitly frees s->current */ + g_free(s); + return 0; +} diff --git a/pkgs/initscripts/src/shvar.h b/pkgs/initscripts/src/shvar.h new file mode 100644 index 0000000..50d1068 --- /dev/null +++ b/pkgs/initscripts/src/shvar.h @@ -0,0 +1,103 @@ +/* + * shvar.h + * + * Interface for non-destructively reading/writing files containing + * only shell variable declarations and full-line comments. + * + * Includes explicit inheritance mechanism intended for use with + * Red Hat Linux ifcfg-* files. There is no protection against + * inheritance loops; they will generally cause stack overflows. + * Furthermore, they are only intended for one level of inheritance; + * the value setting algorithm assumes this. + * + * Copyright 1999 Red Hat, Inc. + * + * This 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +#ifndef _SHVAR_H +#define _SHVAR_H + +#include <glib.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct _shvarFile shvarFile; +struct _shvarFile { + char *fileName; /* read-only */ + int fd; /* read-only */ + char *arena; /* ignore */ + GList *lineList; /* read-only */ + GList *freeList; /* ignore */ + GList *current; /* set implicitly or explicitly, + points to element of lineList */ + shvarFile *parent; /* set explicitly */ + int modified; /* ignore */ +}; + + +/* Create the file <name>, return shvarFile on success, NULL on failure */ +shvarFile * +svCreateFile(const char *name); + +/* Open the file <name>, return shvarFile on success, NULL on failure */ +shvarFile * +svNewFile(const char *name); + +/* Get the value associated with the key, and leave the current pointer + * pointing at the line containing the value. The char* returned MUST + * be freed by the caller. + */ +char * +svGetValue(shvarFile *s, const char *key); + +/* return 1 if <key> resolves to any truth value (e.g. "yes", "y", "true") + * return 0 if <key> resolves to any non-truth value (e.g. "no", "n", "false") + * return <def> otherwise + */ +int +svTrueValue(shvarFile *s, const char *key, int def); + +/* Set the variable <key> equal to the value <value>. + * If <key> does not exist, and the <current> pointer is set, append + * the key=value pair after that line. Otherwise, prepend the pair + * to the top of the file. + */ +void +svSetValue(shvarFile *s, const char *key, const char *value); + + +/* Write the current contents iff modified. Returns -1 on error + * and 0 on success. Do not write if no values have been modified. + * The mode argument is only used if creating the file, not if + * re-writing an existing file, and is passed unchanged to the + * open() syscall. + */ +int +svWriteFile(shvarFile *s, int mode); + +/* Close the file descriptor (if open) and delete the shvarFile. + * Returns -1 on error and 0 on success. + */ +int +svCloseFile(shvarFile *s); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ! _SHVAR_H */ diff --git a/pkgs/initscripts/udev/10-console.rules b/pkgs/initscripts/udev/10-console.rules new file mode 100644 index 0000000..e7609c5 --- /dev/null +++ b/pkgs/initscripts/udev/10-console.rules @@ -0,0 +1,15 @@ +# do not edit this file, it will be overwritten on update + +ACTION!="add", GOTO="console_end" + +# Console initialization - keyboard, font, etc. +KERNEL=="tty0", RUN+="/lib/udev/console_init %k" + +# Check and set up serial and serial-like consoles if necessary +KERNEL=="console", RUN+="/lib/udev/console_check %k" +KERNEL=="ttySG*", RUN+="/lib/udev/console_check %k" +KERNEL=="xvc*", RUN+="/lib/udev/console_check %k" +KERNEL=="hvsi*", RUN+="/lib/udev/console_check %k" +KERNEL=="hvc*", RUN+="/lib/udev/console_check %k" + +LABEL="console_end" diff --git a/pkgs/initscripts/udev/88-clock.rules b/pkgs/initscripts/udev/88-clock.rules new file mode 100644 index 0000000..d716298 --- /dev/null +++ b/pkgs/initscripts/udev/88-clock.rules @@ -0,0 +1,3 @@ +ACTION=="add", SUBSYSTEM=="rtc", ATTR{hctosys}=="1", RUN+="/sbin/hwclock --systz --rtc=/dev/%k" +ACTION=="add", SUBSYSTEM=="rtc", ATTR{hctosys}=="0", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k" +ACTION=="add", ENV{MAJOR}=="10", ENV{MINOR}=="135", RUN+="/sbin/hwclock --hctosys --rtc=/dev/%k"
hooks/post-receive -- IPFire 3.x development tree