1 diff -urN glibc-2.3.1-/elf/Makefile glibc-2.3.1/elf/Makefile
2 --- glibc-2.3.1-/elf/Makefile Thu Oct 17 15:21:30 2002
3 +++ glibc-2.3.1/elf/Makefile Thu Oct 17 15:18:20 2002
5 install-bin-script = ldd
9 +others = postshell sprof sln
12 install-rootsbin = sln
13 diff -urN glibc-2.3.1-/elf/postshell.c glibc-2.3.1/elf/postshell.c
14 --- glibc-2.3.1-/elf/postshell.c Thu Jan 1 01:00:00 1970
15 +++ glibc-2.3.1/elf/postshell.c Thu Oct 17 14:54:34 2002
18 + * Copyright (c) 2002 Michal Moskal <malekith@pld-linux.org>.
19 + * All rights reserved.
21 + * Redistribution and use in source and binary forms, with or without
22 + * modification, are permitted provided that the following conditions
24 + * 1. Redistributions of source code must retain the above copyright
25 + * notice, this list of conditions and the following disclaimer.
26 + * 2. Redistributions in binary form must reproduce the above copyright
27 + * notice, this list of conditions and the following disclaimer in the
28 + * documentation and/or other materials provided with the distribution.
29 + * 3. All advertising materials mentioning features or use of this software
30 + * must display the following acknowledgement:
31 + * This product includes software developed by Michal Moskal.
32 + * 4. Neither the name of the author nor the names of any co-contributors
33 + * may be used to endorse or promote products derived from this software
34 + * without specific prior written permission.
36 + * THIS SOFTWARE IS PROVIDED BY MICHAL MOSKAL AND CONTRIBUTORS ``AS IS'' AND
37 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
40 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
42 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
44 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 + * This simple program is aimed to be used as script interpreter in rpm
54 + * %post scriptlets and the like. It opens file passed as first argument
55 + * and executes commands found there. Only linear execution is supported.
56 + * For example, in glibc.spec:
58 + * %post -p /sbin/postshell
62 + * (full patch like /sbin/ldconfig or -/sbin/tellinit will also work).
64 + * If command starts with - its exit status is ignored. Otherwise last
65 + * non-zero exit status is returned.
67 + * There are no builtin commands (yet :).
69 + * Following commands *will* work as expected (as in Bourne shell):
71 + * /bin/echo "Foo bar baz"
72 + * insmod foobar options="foo bar 'qux'"
75 + * Following *won't*:
78 + * echo foo || echo baz
81 + * Patches and bugreports are welcome, direct them to Michal Moskal
82 + * <malekith@pld-linux.org>.
86 +#include <sys/types.h>
87 +#include <sys/wait.h>
93 +#define MAX_LINE 1024
95 +#define SEARCH_PATH { "/sbin/", "/bin/", "/usr/sbin/", "/usr/bin/", NULL }
100 +void do_execve(char **argv)
102 + char *path[] = SEARCH_PATH;
103 + char file[MAX_LINE + 100];
106 + if (**argv == '.' || **argv == '/')
107 + execve(argv[0], argv, environ);
109 + for (i = 0; path[i]; i++) {
110 + strcpy(file, path[i]);
111 + strcat(file, argv[0]);
112 + execve(file, argv, environ);
116 +int exec_and_wait(char **argv)
125 + } else if (pid == 0) {
128 + if (!ignore_status)
134 + err = waitpid(pid, &status, 0);
139 + return WEXITSTATUS(status);
143 +void split_argv(char **argv, char *s)
148 + for (argc = 0; argc < MAX_ARGS; argc++) {
149 + while (*s == ' ' || *s == '\t')
158 + while (*s && *s != ' ' && *s != '\t') {
159 + if (*s == '\'' || *s == '"') {
161 + while (*s && *s != delim)
180 +void exec_line(char *s)
182 + char *argv[MAX_ARGS + 1];
185 + split_argv(argv, s);
189 + if (**argv == '-') {
194 + ret = exec_and_wait(argv);
196 + if (ret && !ignore_status)
200 +void exec_file(FILE *f)
202 + char line[MAX_LINE];
204 + while (fgets(line, sizeof(line), f)) {
206 + if (line[strlen(line) - 1] == '\n')
207 + line[strlen(line) - 1] = 0;
213 +int main(int argc, char **argv)
218 + fprintf(stderr, "USAGE: %s filename\n", argv[0]);
222 + f = fopen(argv[1], "r");