From: Jakub Bogusz Date: Tue, 27 May 2008 18:42:24 +0000 (+0000) Subject: - merged into setup module X-Git-Tag: auto/th/setup-2_6_0-2~2 X-Git-Url: http://git.pld-linux.org/?p=packages%2Fsetup.git;a=commitdiff_plain;h=d75119b3b265076a2d807924455e20cd79cc59d7 - merged into setup module Changed files: postshell.c -> 1.7 setup-dquo.patch -> 1.2 setup-fuse.patch -> 1.2 setup-profile.env.patch -> 1.2 setup-securetty.patch -> 1.2 setup-update-fstab.c -> 1.5 --- diff --git a/postshell.c b/postshell.c deleted file mode 100644 index 1cf1560..0000000 --- a/postshell.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2002 Michal Moskal . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michal Moskal. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY MICHAL MOSKAL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Usage - * ~~~~~ - * - * This simple program is aimed to be used as script interpreter in rpm - * %post scriptlets and the like. It opens file passed as first argument - * and executes commands found there. Only linear execution is supported. - * For example, in glibc.spec: - * - * %post -p /sbin/postshell - * ldconfig - * -telinit q - * - * (full patch like /sbin/ldconfig or -/sbin/tellinit will also work). - * - * If command starts with - its exit status is ignored. Otherwise last - * non-zero exit status is returned. - * - * There are no builtin commands (yet :). - * - * Following commands *will* work as expected (as in Bourne shell): - * - * /bin/echo "Foo bar baz" - * insmod foobar options="foo bar 'qux'" - * false - * - * Following *won't*: - * - * exit 1 - * echo foo || echo baz - * set -x - * - * Patches and bugreports are welcome, direct them to Michal Moskal - * . - */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_LINE 1024 -#define MAX_ARGS 32 -#define SEARCH_PATH { "/sbin/", "/bin/", "/usr/sbin/", "/usr/bin/", NULL } - -int exit_status; -int ignore_status; - -void do_execve(char **argv) -{ - char *path[] = SEARCH_PATH; - char file[MAX_LINE + 100]; - int i; - - if (**argv == '.' || **argv == '/') - execve(argv[0], argv, environ); - else - for (i = 0; path[i]; i++) { - strcpy(file, path[i]); - strcat(file, argv[0]); - execve(file, argv, environ); - } -} - -int exec_and_wait(char **argv) -{ - pid_t pid; - - pid = fork(); - - if (pid == -1) { - perror("fork"); - return -1; - } else if (pid == 0) { - /* child. */ - do_execve(argv); - if (!ignore_status) - perror(argv[0]); - exit(127); - } else { - int status, err; - - err = waitpid(pid, &status, 0); - if (err < 0) { - perror("waitpid"); - return -1; - } else - return WEXITSTATUS(status); - } -} - -void split_argv(char **argv, char *s) -{ - char *dst; - int argc, delim; - - for (argc = 0; argc < MAX_ARGS; argc++) { - while (*s == ' ' || *s == '\t') - s++; - - if (*s == 0) - break; - - argv[argc] = s; - dst = s; - - while (*s && *s != ' ' && *s != '\t') { - if (*s == '\'' || *s == '"') { - delim = *s++; - while (*s && *s != delim) - *dst++ = *s++; - if (*s) - s++; - } else { - *dst++ = *s++; - } - } - - if (*dst) { - if (s == dst) - s++; - *dst++ = 0; - } - } - - argv[argc] = NULL; -} - -void exec_line(char *s) -{ - char *argv[MAX_ARGS + 1]; - int ret; - - split_argv(argv, s); - - ignore_status = 0; - - if (**argv == '-') { - ignore_status++; - (*argv)++; - } - - ret = exec_and_wait(argv); - - if (ret && !ignore_status) - exit_status = ret; -} - -void exec_file(int fd) -{ - char line[MAX_LINE]; - struct stat sbuf; - char *p, *s, *a; - - if (fstat(fd, &sbuf) < 0) { - perror("fstat()"); - exit(1); - } - - if ((p = mmap(0, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) < 0) { - perror("mmap()"); - exit(1); - } - - for (a = s = p; s < p + sbuf.st_size; s++) { - if (*s == '\n') { - memcpy(line, a, s - a); - line[s - a] = '\0'; - exec_line(line); - a = ++s; - } - } - - // last line was not terminated. - if (s == p + sbuf.st_size) { - memcpy(line, a, s - a); - line[s - a] = '\0'; - exec_line(line); - } - - if (munmap(p, sbuf.st_size) < 0) { - perror("munmap()"); - exit(1); - } -} - -#define error(msg) write(2, msg, strlen(msg)) -int main(int argc, char **argv) -{ - int fd; - - if (argc < 2) { - error("USAGE: "); - error(argv[0]); - error(" filename\n"); - exit(1); - } - - fd = open(argv[1], O_RDONLY); - - if (fd == -1) { - perror(argv[1]); - exit(1); - } - - exec_file(fd); - close(fd); - exit(exit_status); -} diff --git a/setup-dquo.patch b/setup-dquo.patch deleted file mode 100644 index 0f66112..0000000 --- a/setup-dquo.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nur setup-2.4.11.orig/etc/profile setup-2.4.11.chng/etc/profile ---- setup-2.4.11.orig/etc/profile 2007-11-30 09:25:34.000000000 +0100 -+++ setup-2.4.11.chng/etc/profile 2007-11-30 09:26:06.000000000 +0100 -@@ -20,7 +20,7 @@ - HISTFILE="$HOME/.history" - HISTSIZE=1000 - --if [ `id -gn` = $USER -a `id -u` -gt 14 ]; then -+if [ "`id -gn`" = $USER -a `id -u` -gt 14 ]; then - umask 002 - else - umask 022 diff --git a/setup-fuse.patch b/setup-fuse.patch deleted file mode 100644 index a5bcadf..0000000 --- a/setup-fuse.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -ur setup-2.4.12.org/etc/group setup-2.4.12/etc/group ---- setup-2.4.12.org/etc/group 2008-04-01 09:13:24.000000000 +0200 -+++ setup-2.4.12/etc/group 2008-04-18 08:32:46.800214940 +0200 -@@ -30,6 +30,7 @@ - ftp::50: - http::51: - usb::78: -+fuse::84: - nobody::99: - stats::123: - logs::124:stats diff --git a/setup-profile.env.patch b/setup-profile.env.patch deleted file mode 100644 index f8436be..0000000 --- a/setup-profile.env.patch +++ /dev/null @@ -1,45 +0,0 @@ -Index: profile -=================================================================== -RCS file: /cvsroot/setup/etc/profile,v -retrieving revision 1.48 -diff -u -r1.48 profile ---- ./etc/profile 26 May 2005 18:27:14 -0000 1.48 -+++ ./etc/profile 30 Apr 2006 11:23:40 -0000 -@@ -115,19 +115,24 @@ - # example: - # cat /etc/env.d/VARIABLE - # VARIABLE="value" --for i in /etc/env.d/* ; do -- NAME=`basename $i` -- case $NAME in -- *~ | *.bak | *.old | *.rpmnew | *.rpmsave ) -- # nothing -- ;; -- * ) -- if [ -r $i ]; then -- . $i; export $NAME -- fi -- ;; -- esac --done -+if [ -f /etc/profile.env ]; then -+ . /etc/profile.env -+else -+ for i in /etc/env.d/* ; do -+ NAME=${i##*/} -+ case $NAME in -+ *~ | *.bak | *.old | *.rpmnew | *.rpmsave ) -+ # nothing -+ ;; -+ * ) -+ if [ -r $i ]; then -+ . $i; export $NAME -+ fi -+ ;; -+ esac -+ done -+ unset NAME -+fi - - # Scripts: - for i in /etc/profile.d/*.sh ; do diff --git a/setup-securetty.patch b/setup-securetty.patch deleted file mode 100644 index f6c0f06..0000000 --- a/setup-securetty.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- ./etc/securetty~ 2000-05-05 23:51:32.000000000 +0200 -+++ ./etc/securetty 2005-10-13 19:23:30.000000000 +0300 -@@ -22,3 +22,5 @@ - vc/9 - vc/10 - vc/11 -+tts/0 -+tts/1 diff --git a/setup-update-fstab.c b/setup-update-fstab.c deleted file mode 100644 index 396c1af..0000000 --- a/setup-update-fstab.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * $Id$ - * adds devmode and devgid to usbfs in fstab - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -void eputs(const char *msg) -{ - write(2, msg, strlen(msg)); -} - -int main() -{ - char *name = "/etc/fstab"; - char *backup_name = "/etc/fstab.bak"; - char *add = ",devgid=78,devmode=0664"; - - char *old; - int i, fd; - int old_sz; - struct stat st; - - eputs("Updating /etc/fstab..."); - fd = open(name, O_RDONLY); - if (fd < 0) { - eputs("\nError: can't open file\n"); - return 1; - } - fstat(fd, &st); - old = (char *) malloc(st.st_size); - if (old == NULL) { - eputs("\nError: malloc failure\n"); - return 1; - } - read(fd, old, st.st_size); - close(fd); - old_sz = st.st_size; - - fd = open(backup_name, O_WRONLY|O_CREAT|O_TRUNC, 0600); - if (fd < 0) { - eputs("\nError: can't make backup\n"); - return 2; - } - write(fd, old, old_sz); - close(fd); - - // find usbfs - for (i = 0; i < old_sz; i++) { - if ( old[i] == 'u' && old[i+1] == 's' && old[i+2] == 'b' - && old[i+3] == 'f' && old[i+4] == 's') - break; - } - // find defau(lts) - for (;i < old_sz; i++) { - if ( old[i] == 'd' && old[i+1] == 'e' && old[i+2] == 'f' && old[i+3] == 'a' && old[i+4] == 'u' ) - break; - } - // find first space - for (;i < old_sz; i++) { - if ( old[i] == ' ' || old[i] == '\t' ) - break; - } - if ( i >= old_sz ) { - eputs("\nError: can't find correct usbfs entry\n"); - return 0; - } - - fd = open(name, O_WRONLY|O_CREAT|O_TRUNC); - if (fd < 0) { - eputs("\nError: can't open file for writing\n"); - return 4; - } - write(fd, old, i); - write(fd, add, strlen(add)); - write(fd, old + i, old_sz - i); - close(fd); - eputs("OK\n"); - - return 0; -} -