avatar
Rosa has added ac0feea965
initial: add from SRPM
... ... --- /dev/null
... ... +++ b/.abf.yml
... ... @@ -0,0 +1,2 @@
1
sources:
2
  "sash-3.7.tar.bz2": 05f10d38fb726ce960905880f480d98196557838
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.6-scriptarg.patch
... ... @@ -0,0 +1,60 @@
1
--- sash-3.6/sash.c.orig	2002-07-22 00:55:28.000000000 +0200
2
+++ sash-3.6/sash.c	2003-09-01 12:41:51.000000000 +0200
3
@@ -481,6 +481,24 @@
4
 		}
5
 	}
6
 
7
+	/* A single argument is allowed, and it must be a filename which
8
+	   provides stdin. This allows #! usage. */
9
+	if (argc) {
10
+		int fd;
11
+
12
+		fd = open(argv[0], O_RDONLY);
13
+		if (fd < 0) {
14
+			fprintf(stderr, "Error opening %s: %s\n", argv[0],
15
+				strerror(errno));
16
+			return 1;
17
+		}
18
+
19
+		dup2(fd, 0);
20
+		close(fd);
21
+
22
+		argc--, argv++;
23
+	}
24
+
25
 	/*
26
 	 * No more arguments are allowed.
27
 	 */
28
@@ -1271,7 +1289,7 @@
29
 	fprintf(stderr, "Stand-alone shell (version %s)\n", version);
30
 	fprintf(stderr, "\n");
31
 	fprintf(stderr, "Usage: sash [-a] [-q] [-f fileName] [-c command] [-p prompt]\n");
32
-
33
+	fprintf(stderr, "Usage: sash [-a] [-q] [-f fileName] [-c command] [-p prompt] [script]\n");
34
 	exit(1);
35
 }
36
 
37
--- sash-3.6/sash.1.orig	2002-07-22 01:16:40.000000000 +0200
38
+++ sash-3.6/sash.1	2003-09-01 12:43:04.000000000 +0200
39
@@ -2,7 +2,7 @@
40
 .SH NAME
41
 sash \- stand-alone shell with built-in commands
42
 .SH SYNOPSYS
43
-.B sash [-c command] [-f fileName ] [-p prompt] [-q] [-a]
44
+.B sash [-c command] [-f fileName ] [-p prompt] [-q] [-a] [script]
45
 .SH DESCRIPTION
46
 The
47
 .B sash
48
@@ -496,6 +496,12 @@
49
 The -a option creates aliases for the built-in commands so
50
 that they replace the corresponding standard commands.
51
 This is the same result as if the 'aliasall' command was used.
52
+
53
+A file name may be provided as the last argument to sash, in which case
54
+sash's standard input is read from that file. This allows #! scripts
55
+to use sash as their script interpretor. Be aware that sash does not provide
56
+most normal bourne-shell programming features, however.
57
+
58
 .SH SYSTEM RECOVERY
59
 This section contains some useful information about using
60
 .B sash
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.7-fix-loop__remove_it_when_kernel_headers_are_fixed.patch
... ... @@ -0,0 +1,12 @@
1
--- sash-3.7/cmds.c.loop	2009-04-11 15:11:19.000000000 +0200
2
+++ sash-3.7/cmds.c	2009-04-11 15:11:19.000000000 +0200
3
@@ -21,6 +21,9 @@
4
 #include <linux/fs.h>
5
 #endif
6
 
7
+#ifndef dev_t
8
+#define dev_t dev_t
9
+#endif
10
 #include <linux/loop.h>
11
 
12
 void
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.7-linux2.6-buildfix.patch
... ... @@ -0,0 +1,11 @@
1
--- sash-3.7/cmd_chattr.c~	2002-03-08 08:21:03.000000000 +0100
2
+++ sash-3.7/cmd_chattr.c	2004-04-17 13:09:20.628404374 +0200
3
@@ -12,7 +12,7 @@
4
 
5
 #include <sys/ioctl.h>
6
 #include <sys/types.h>
7
-#include <linux/ext2_fs.h>
8
+#include <ext2fs/ext2_fs.h>
9
 
10
 #include "sash.h"
11
 
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.7-losetup.patch
... ... @@ -0,0 +1,122 @@
1
--- sash-3.7/cmds.c.losetup	2002-07-22 00:28:19.000000000 +0200
2
+++ sash-3.7/cmds.c	2009-04-11 15:09:07.000000000 +0200
3
@@ -21,6 +21,7 @@
4
 #include <linux/fs.h>
5
 #endif
6
 
7
+#include <linux/loop.h>
8
 
9
 void
10
 do_echo(int argc, const char ** argv)
11
@@ -1253,4 +1254,58 @@
12
 		printf("Program \"%s\" not found in PATH\n", program);
13
 }
14
 
15
+void
16
+do_losetup(int argc, const char ** argv)
17
+{
18
+	int loopfd;
19
+	int targfd;
20
+	struct loop_info loopInfo;
21
+
22
+	if (!strcmp(argv[1], "-d")) {
23
+		loopfd = open(argv[2], O_RDONLY);
24
+		if (loopfd < 0) {
25
+			fprintf(stderr, "Error opening %s: %s\n", argv[2], 
26
+				strerror(errno));
27
+			return;
28
+		}
29
+
30
+		if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
31
+			fprintf(stderr, "Error unassociating device: %s\n", 
32
+				strerror(errno));
33
+			return;
34
+		}
35
+	}
36
+
37
+	loopfd = open(argv[1], O_RDONLY);
38
+	if (loopfd < 0) {
39
+		fprintf(stderr, "Error opening %s: %s\n", argv[1], 
40
+			strerror(errno));
41
+		return;
42
+	}
43
+
44
+	targfd = open(argv[2], O_RDONLY);
45
+	if (targfd < 0) {
46
+		fprintf(stderr, "Error opening %s: %s\n", argv[2], 
47
+			strerror(errno));
48
+		return;
49
+	}
50
+
51
+	if (ioctl(loopfd, LOOP_SET_FD, targfd)) {
52
+		fprintf(stderr, "Error setting up loopback device: %s\n", 
53
+			strerror(errno));
54
+		return;
55
+	}
56
+
57
+	memset(&loopInfo, 0, sizeof(loopInfo));
58
+	strcpy(loopInfo.lo_name, argv[2]);
59
+
60
+	if (ioctl(loopfd, LOOP_SET_STATUS, &loopInfo)) {
61
+		fprintf(stderr, "Error setting up loopback device: %s\n", 
62
+			strerror(errno));
63
+		return;
64
+	}
65
+
66
+	return;
67
+}
68
+
69
 /* END CODE */
70
--- sash-3.7/sash.1.losetup	2004-01-14 06:04:50.000000000 +0100
71
+++ sash-3.7/sash.1	2009-04-11 15:09:07.000000000 +0200
72
@@ -24,9 +24,9 @@
73
 .nf
74
      -ar, -chattr, -chgrp, -chmod, -chown, -cmp, -cp,
75
      -dd, -echo, -ed, -grep, -file, -find, -gunzip,
76
-     -gzip, -kill, -ln, -ls, -lsattr, -mkdir, -mknod,
77
-     -more, -mount, -mv, -printenv, -pwd, -rm, -rmdir,
78
-     -sum, -sync, -tar, -touch, -umount, -where
79
+     -gzip, -kill, -losetup, -ln, -ls, -lsattr, -mkdir,
80
+     -mknod, -more, -mount, -mv, -printenv, -pwd, -rm,
81
+     -rmdir, -sum, -sync, -tar, -touch, -umount, -where
82
 .fi
83
 .PP
84
 These commands are generally similar to the standard programs with similar
85
@@ -312,6 +312,12 @@
86
 QUIT, KILL, TERM, STOP, CONT, USR1 or USR2.
87
 If no signal is specified then SIGTERM is used.
88
 .TP
89
+.B -losetup [-d] loopDev [file]
90
+Associates loopback devices with files on the system. If -d is not given,
91
+the loopback device \fBloopDev\fR is associated with \fBfile\fR. If -d is
92
+given, \fBloopDev\fR is unassociated with the file it's currently configured
93
+for.
94
+.TP
95
 .B -ln [-s] srcName ... destName
96
 Links one or more files from the
97
 .I srcName
98
--- sash-3.7/sash.c.losetup	2004-01-14 06:08:03.000000000 +0100
99
+++ sash-3.7/sash.c	2009-04-11 15:09:07.000000000 +0200
100
@@ -182,6 +182,12 @@
101
 	},
102
 
103
 	{
104
+		"-losetup",	do_losetup,	3,	3,
105
+		"Associate a loopback device with a file",
106
+		"[-d] device\n       -losetup device filename"
107
+	},
108
+
109
+	{
110
 		"-ln",		do_ln,		3,	INFINITE_ARGS,
111
 		"Link one fileName to another",
112
 		"[-s] srcName ... destName"
113
--- sash-3.7/sash.h.losetup	2002-07-22 00:05:17.000000000 +0200
114
+++ sash-3.7/sash.h	2009-04-11 15:09:07.000000000 +0200
115
@@ -99,6 +99,7 @@
116
 extern	void	do_find(int argc, const char ** argv);
117
 extern	void	do_ed(int argc, const char ** argv);
118
 extern	void	do_where(int argc, const char ** argv);
119
+extern	void	do_losetup(int argc, const char ** argv);
120
 
121
 #if	HAVE_GZIP
122
 extern	void	do_gzip(int argc, const char ** argv);
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.7-optflags.patch
... ... @@ -0,0 +1,11 @@
1
--- sash-3.7/Makefile.misc	2002-07-22 01:24:47.000000000 +0200
2
+++ sash-3.7/Makefile	2009-04-11 15:05:09.000000000 +0200
3
@@ -14,7 +14,7 @@
4
 MOUNT_TYPE		= '"ext3"'
5
 
6
 
7
-CFLAGS = -O3 -Wall -Wmissing-prototypes \
8
+CFLAGS = $(RPM_OPT_FLAGS) -Wall -Wmissing-prototypes \
9
 	-DHAVE_GZIP=$(HAVE_GZIP) \
10
 	-DHAVE_LINUX_ATTR=$(HAVE_LINUX_ATTR) \
11
 	-DHAVE_LINUX_MOUNT=$(HAVE_LINUX_MOUNT) \
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.7-segfault.patch
... ... @@ -0,0 +1,21 @@
1
--- sash-3.4/utils.c.segf	2004-03-26 21:32:26.000000000 +0100
2
+++ sash-3.4/utils.c	2004-03-26 21:32:34.000000000 +0100
3
@@ -588,8 +588,7 @@
4
 					if (*text == ch)
5
 						found = TRUE;
6
 				}
7
-
8
-				if (!found)
9
+				if (!found && retryPat != NULL)
10
 				{
11
 					pattern = retryPat;
12
 					text = ++retryText;
13
@@ -598,7 +597,7 @@
14
 				/* fall into next case */
15
 
16
 			case '?':  
17
-				if (*text++ == '\0')
18
+				if (*text && *text++ == '\0')
19
 					return FALSE;
20
 
21
 				break;
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-3.7-special-script-call-esp-for-glibc-post.patch
... ... @@ -0,0 +1,71 @@
1
--- sash-3.7/sash.c.pix	2004-06-02 14:02:59.609564675 +0200
2
+++ sash-3.7/sash.c	2004-06-02 14:03:56.137579142 +0200
3
@@ -405,6 +405,7 @@
4
 	const char *	commandFile;
5
 	BOOL		quietFlag;
6
 	BOOL		aliasFlag;
7
+	BOOL		ignoreRemainingArgsFlag = FALSE;
8
 	char		buf[PATH_LEN];
9
 
10
 	singleCommand = NULL;
11
@@ -418,6 +419,13 @@
12
 	argv++;
13
 	argc--;
14
 
15
+	if (argc && strcmp(*argv, "--ignore-remaining-args") == 0)
16
+	{
17
+		ignoreRemainingArgsFlag = TRUE;
18
+		argv++;
19
+		argc--;		
20
+	}
21
+
22
 	while ((argc > 0) && (**argv == '-'))
23
 	{
24
 		cp = *argv++ + 1;
25
@@ -429,7 +437,7 @@
26
 				/*
27
 				 * Execute specified command.
28
 				 */
29
-				if ((argc != 1) || singleCommand)
30
+				if ((argc < 1) || singleCommand)
31
 					usage();
32
 
33
 				singleCommand = *argv++;
34
@@ -443,7 +451,7 @@
35
 				 * This is used for sash script files.
36
 				 * The quiet flag is also set.
37
 				 */
38
-				if ((argc != 1) || commandFile)
39
+				if ((argc < 1) || commandFile)
40
 					usage();
41
 
42
 				quietFlag = TRUE;
43
@@ -489,7 +497,7 @@
44
 
45
 	/* A single argument is allowed, and it must be a filename which
46
 	   provides stdin. This allows #! usage. */
47
-	if (argc) {
48
+	if (argc && !(ignoreRemainingArgsFlag && commandFile)) {
49
 		int fd;
50
 
51
 		fd = open(argv[0], O_RDONLY);
52
@@ -505,10 +513,18 @@
53
 		argc--, argv++;
54
 	}
55
 
56
+	if (argc > 0 && !commandFile && !singleCommand)
57
+	{
58
+		fprintf(stderr, "Using \"#!/sbin/sash\" is deprecated, use \"#!/sbin/sash -f\" instead\n");
59
+		quietFlag = TRUE;
60
+		commandFile = *argv++;
61
+		argc--;
62
+	}
63
+
64
 	/*
65
 	 * No more arguments are allowed.
66
 	 */
67
-	if (argc > 0)
68
+	if (argc > 0 && !ignoreRemainingArgsFlag)
69
 		usage();
70
 
71
 	/*
view file @ ac0feea965
... ... --- /dev/null
... ... +++ b/sash-pwdfunc.patch
... ... @@ -0,0 +1,603 @@
1
--- sash-3.4/__getgrent.c.pwd	2004-03-26 16:59:55.000000000 +0100
2
+++ sash-3.4/__getgrent.c	2004-03-26 17:34:45.000000000 +0100
3
@@ -0,0 +1,202 @@
4
+/*
5
+ * __getgrent.c - This file is part of the libc-8086/grp package for ELKS,
6
+ * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
7
+ * 
8
+ *  This library is free software; you can redistribute it and/or
9
+ *  modify it under the terms of the GNU Library General Public
10
+ *  License as published by the Free Software Foundation; either
11
+ *  version 2 of the License, or (at your option) any later version.
12
+ *
13
+ *  This library is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
+ *  Library General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU Library General Public
19
+ *  License along with this library; if not, write to the Free
20
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
+ *
22
+ */
23
+
24
+#include <unistd.h>
25
+#include <stdlib.h>
26
+#include <string.h>
27
+
28
+#include "grp_.h"
29
+
30
+/*
31
+ * Define GR_SCALE_DYNAMIC if you want grp to dynamically scale its read buffer
32
+ * so that lines of any length can be used.  On very very small systems,
33
+ * you may want to leave this undefined becasue it will make the grp functions
34
+ * somewhat larger (because of the inclusion of malloc and the code necessary).
35
+ * On larger systems, you will want to define this, because grp will _not_
36
+ * deal with long lines gracefully (they will be skipped).
37
+ */
38
+#undef GR_SCALE_DYNAMIC
39
+
40
+#ifndef GR_SCALE_DYNAMIC
41
+/*
42
+ * If scaling is not dynamic, the buffers will be statically allocated, and
43
+ * maximums must be chosen.  GR_MAX_LINE_LEN is the maximum number of
44
+ * characters per line in the group file.  GR_MAX_MEMBERS is the maximum
45
+ * number of members of any given group.
46
+ */
47
+#define GR_MAX_LINE_LEN 128
48
+/* GR_MAX_MEMBERS = (GR_MAX_LINE_LEN-(24+3+6))/9 */
49
+#define GR_MAX_MEMBERS 11
50
+
51
+#endif /* !GR_SCALE_DYNAMIC */
52
+
53
+
54
+/*
55
+ * Define GR_DYNAMIC_GROUP_LIST to make initgroups() dynamically allocate
56
+ * space for it's GID array before calling setgroups().  This is probably
57
+ * unnecessary scalage, so it's undefined by default.
58
+ */
59
+#undef GR_DYNAMIC_GROUP_LIST
60
+
61
+#ifndef GR_DYNAMIC_GROUP_LIST
62
+/*
63
+ * GR_MAX_GROUPS is the size of the static array initgroups() uses for
64
+ * its static GID array if GR_DYNAMIC_GROUP_LIST isn't defined.
65
+ */
66
+#define GR_MAX_GROUPS 64
67
+
68
+#endif /* !GR_DYNAMIC_GROUP_LIST */
69
+
70
+
71
+/*
72
+ * This is the core group-file read function.  It behaves exactly like
73
+ * getgrent() except that it is passed a file descriptor.  getgrent()
74
+ * is just a wrapper for this function.
75
+ */
76
+struct group *bb_getgrent(int grp_fd)
77
+{
78
+#ifndef GR_SCALE_DYNAMIC
79
+	static char line_buff[GR_MAX_LINE_LEN];
80
+	static char *members[GR_MAX_MEMBERS];
81
+#else
82
+	static char *line_buff = NULL;
83
+	static char **members = NULL;
84
+	short line_index;
85
+	short buff_size;
86
+#endif
87
+	static struct group group;
88
+	register char *ptr;
89
+	char *field_begin;
90
+	short member_num;
91
+	char *endptr;
92
+	int line_len;
93
+
94
+
95
+	/* We use the restart label to handle malformatted lines */
96
+  restart:
97
+#ifdef GR_SCALE_DYNAMIC
98
+	line_index = 0;
99
+	buff_size = 256;
100
+#endif
101
+
102
+#ifndef GR_SCALE_DYNAMIC
103
+	/* Read the line into the static buffer */
104
+	if ((line_len = read(grp_fd, line_buff, GR_MAX_LINE_LEN)) <= 0)
105
+		return NULL;
106
+	field_begin = strchr(line_buff, '\n');
107
+	if (field_begin != NULL)
108
+		lseek(grp_fd, (long) (1 + field_begin - (line_buff + line_len)),
109
+			  SEEK_CUR);
110
+	else {						/* The line is too long - skip it :-\ */
111
+
112
+		do {
113
+			if ((line_len = read(grp_fd, line_buff, GR_MAX_LINE_LEN)) <= 0)
114
+				return NULL;
115
+		} while (!(field_begin = strchr(line_buff, '\n')));
116
+		lseek(grp_fd, (long) ((field_begin - line_buff) - line_len + 1),
117
+			  SEEK_CUR);
118
+		goto restart;
119
+	}
120
+	if (*line_buff == '#' || *line_buff == ' ' || *line_buff == '\n' ||
121
+		*line_buff == '\t')
122
+		goto restart;
123
+	*field_begin = '\0';
124
+
125
+#else							/* !GR_SCALE_DYNAMIC */
126
+	line_buff = realloc(line_buff, buff_size);
127
+	while (1) {
128
+		if ((line_len = read(grp_fd, line_buff + line_index,
129
+							 buff_size - line_index)) <= 0)
130
+			return NULL;
131
+		field_begin = strchr(line_buff, '\n');
132
+		if (field_begin != NULL) {
133
+			lseek(grp_fd,
134
+				  (long) (1 + field_begin -
135
+						  (line_len + line_index + line_buff)), SEEK_CUR);
136
+			*field_begin = '\0';
137
+			if (*line_buff == '#' || *line_buff == ' '
138
+				|| *line_buff == '\n' || *line_buff == '\t')
139
+				goto restart;
140
+			break;
141
+		} else {				/* Allocate some more space */
142
+
143
+			line_index = buff_size;
144
+			buff_size += 256;
145
+			line_buff = realloc(line_buff, buff_size);
146
+		}
147
+	}
148
+#endif							/* GR_SCALE_DYNAMIC */
149
+
150
+	/* Now parse the line */
151
+	group.gr_name = line_buff;
152
+	ptr = strchr(line_buff, ':');
153
+	if (ptr == NULL)
154
+		goto restart;
155
+	*ptr++ = '\0';
156
+
157
+	group.gr_passwd = ptr;
158
+	ptr = strchr(ptr, ':');
159
+	if (ptr == NULL)
160
+		goto restart;
161
+	*ptr++ = '\0';
162
+
163
+	field_begin = ptr;
164
+	ptr = strchr(ptr, ':');
165
+	if (ptr == NULL)
166
+		goto restart;
167
+	*ptr++ = '\0';
168
+
169
+	group.gr_gid = (gid_t) strtoul(field_begin, &endptr, 10);
170
+	if (*endptr != '\0')
171
+		goto restart;
172
+
173
+	member_num = 0;
174
+	field_begin = ptr;
175
+
176
+#ifndef GR_SCALE_DYNAMIC
177
+	while ((ptr = strchr(ptr, ',')) != NULL) {
178
+		*ptr = '\0';
179
+		ptr++;
180
+		members[member_num] = field_begin;
181
+		field_begin = ptr;
182
+		member_num++;
183
+	}
184
+	if (*field_begin == '\0')
185
+		members[member_num] = NULL;
186
+	else {
187
+		members[member_num] = field_begin;
188
+		members[member_num + 1] = NULL;
189
+	}
190
+#else							/* !GR_SCALE_DYNAMIC */
191
+	free(members);
192
+	members = (char **) malloc((member_num + 1) * sizeof(char *));   
193
+	for ( ; field_begin && *field_begin != '\0'; field_begin = ptr) {
194
+	    if ((ptr = strchr(field_begin, ',')) != NULL)
195
+		*ptr++ = '\0';
196
+	    members[member_num++] = field_begin;
197
+	    members = (char **) realloc(members,
198
+		    (member_num + 1) * sizeof(char *));
199
+	}
200
+	members[member_num] = NULL;
201
+#endif							/* GR_SCALE_DYNAMIC */
202
+
203
+	group.gr_mem = members;
204
+	return &group;
205
+}
206
--- sash-3.4/__getpwent.c.pwd	2004-03-26 16:59:55.000000000 +0100
207
+++ sash-3.4/__getpwent.c	2004-03-26 16:59:55.000000000 +0100
208
@@ -0,0 +1,114 @@
209
+/*
210
+ * __getpwent.c - This file is part of the libc-8086/pwd package for ELKS,
211
+ * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
212
+ * 
213
+ *  This library is free software; you can redistribute it and/or
214
+ *  modify it under the terms of the GNU Library General Public
215
+ *  License as published by the Free Software Foundation; either
216
+ *  version 2 of the License, or (at your option) any later version.
217
+ *
218
+ *  This library is distributed in the hope that it will be useful,
219
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
220
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
221
+ *  Library General Public License for more details.
222
+ *
223
+ *  You should have received a copy of the GNU Library General Public
224
+ *  License along with this library; if not, write to the Free
225
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
226
+ *
227
+ */
228
+
229
+#include <stdlib.h>
230
+#include <unistd.h>
231
+#include <string.h>
232
+#include <fcntl.h>
233
+
234
+#include "pwd_.h"
235
+
236
+#define PWD_BUFFER_SIZE 256
237
+
238
+/* This isn't as flash as my previous version -- it doesn't dynamically
239
+  scale down the gecos on too-long lines, but it also makes fewer syscalls,
240
+  so it's probably nicer.  Write me if you want the old version.  Maybe I
241
+  should include it as a build-time option... ?
242
+  -Nat <ndf@linux.mit.edu> */
243
+
244
+struct passwd *__getpwent(int pwd_fd)
245
+{
246
+	static char line_buff[PWD_BUFFER_SIZE];
247
+	static struct passwd passwd;
248
+	char *field_begin;
249
+	char *endptr;
250
+	char *gid_ptr=NULL;
251
+	char *uid_ptr=NULL;
252
+	int line_len;
253
+	int i;
254
+
255
+	/* We use the restart label to handle malformatted lines */
256
+  restart:
257
+	/* Read the passwd line into the static buffer using a minimal of
258
+	   syscalls. */
259
+	if ((line_len = read(pwd_fd, line_buff, PWD_BUFFER_SIZE)) <= 0)
260
+		return NULL;
261
+	field_begin = strchr(line_buff, '\n');
262
+	if (field_begin != NULL)
263
+		lseek(pwd_fd, (long) (1 + field_begin - (line_buff + line_len)),
264
+			  SEEK_CUR);
265
+	else {						/* The line is too long - skip it. :-\ */
266
+
267
+		do {
268
+			if ((line_len = read(pwd_fd, line_buff, PWD_BUFFER_SIZE)) <= 0)
269
+				return NULL;
270
+		} while (!(field_begin = strchr(line_buff, '\n')));
271
+		lseek(pwd_fd, (long) (field_begin - line_buff) - line_len + 1,
272
+			  SEEK_CUR);
273
+		goto restart;
274
+	}
275
+	if (*line_buff == '#' || *line_buff == ' ' || *line_buff == '\n' ||
276
+		*line_buff == '\t')
277
+		goto restart;
278
+	*field_begin = '\0';
279
+
280
+	/* We've read the line; now parse it. */
281
+	field_begin = line_buff;
282
+	for (i = 0; i < 7; i++) {
283
+		switch (i) {
284
+		case 0:
285
+			passwd.pw_name = field_begin;
286
+			break;
287
+		case 1:
288
+			passwd.pw_passwd = field_begin;
289
+			break;
290
+		case 2:
291
+			uid_ptr = field_begin;
292
+			break;
293
+		case 3:
294
+			gid_ptr = field_begin;
295
+			break;
296
+		case 4:
297
+			passwd.pw_gecos = field_begin;
298
+			break;
299
+		case 5:
300
+			passwd.pw_dir = field_begin;
301
+			break;
302
+		case 6:
303
+			passwd.pw_shell = field_begin;
304
+			break;
305
+		}
306
+		if (i < 6) {
307
+			field_begin = strchr(field_begin, ':');
308
+			if (field_begin == NULL)
309
+				goto restart;
310
+			*field_begin++ = '\0';
311
+		}
312
+	}
313
+	passwd.pw_gid = (gid_t) strtoul(gid_ptr, &endptr, 10);
314
+	if (*endptr != '\0')
315
+		goto restart;
316
+
317
+	passwd.pw_uid = (uid_t) strtoul(uid_ptr, &endptr, 10);
318
+	if (*endptr != '\0')
319
+		goto restart;
320
+
321
+	return &passwd;
322
+}
323
--- sash-3.4/getgrgid.c.pwd	2004-03-26 16:59:55.000000000 +0100
324
+++ sash-3.4/getgrgid.c	2004-03-26 17:35:45.000000000 +0100
325
@@ -0,0 +1,42 @@
326
+/*
327
+ * getgrgid.c - This file is part of the libc-8086/grp package for ELKS,
328
+ * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
329
+ * 
330
+ *  This library is free software; you can redistribute it and/or
331
+ *  modify it under the terms of the GNU Library General Public
332
+ *  License as published by the Free Software Foundation; either
333
+ *  version 2 of the License, or (at your option) any later version.
334
+ *
335
+ *  This library is distributed in the hope that it will be useful,
336
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
337
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
338
+ *  Library General Public License for more details.
339
+ *
340
+ *  You should have received a copy of the GNU Library General Public
341
+ *  License along with this library; if not, write to the Free
342
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
343
+ *
344
+ */
345
+
346
+#include <sys/types.h>
347
+#include <unistd.h>
348
+#include <fcntl.h>
349
+#include "grp_.h"
350
+
351
+struct group *getgrgid(const gid_t gid)
352
+{
353
+	struct group *group;
354
+	int grp_fd;
355
+
356
+	if ((grp_fd = open("/etc/group", O_RDONLY)) < 0)
357
+		return NULL;
358
+
359
+	while ((group = bb_getgrent(grp_fd)) != NULL)
360
+		if (group->gr_gid == gid) {
361
+			close(grp_fd);
362
+			return group;
363
+		}
364
+
365
+	close(grp_fd);
366
+	return NULL;
367
+}
368
--- sash-3.4/getgrnam.c.pwd	2004-03-26 16:59:55.000000000 +0100
369
+++ sash-3.4/getgrnam.c	2004-03-26 17:35:36.000000000 +0100
370
@@ -0,0 +1,48 @@
371
+/*
372
+ * getgrnam.c - This file is part of the libc-8086/grp package for ELKS,
373
+ * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
374
+ * 
375
+ *  This library is free software; you can redistribute it and/or
376
+ *  modify it under the terms of the GNU Library General Public
377
+ *  License as published by the Free Software Foundation; either
378
+ *  version 2 of the License, or (at your option) any later version.
379
+ *
380
+ *  This library is distributed in the hope that it will be useful,
381
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
382
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
383
+ *  Library General Public License for more details.
384
+ *
385
+ *  You should have received a copy of the GNU Library General Public
386
+ *  License along with this library; if not, write to the Free
387
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
388
+ *
389
+ */
390
+
391
+#include <unistd.h>
392
+#include <string.h>
393
+#include <errno.h>
394
+#include <fcntl.h>
395
+#include "grp_.h"
396
+
397
+struct group *getgrnam(const char *name)
398
+{
399
+	int grp_fd;
400
+	struct group *group;
401
+
402
+	if (name == NULL) {
403
+		errno = EINVAL;
404
+		return NULL;
405
+	}
406
+
407
+	if ((grp_fd = open("/etc/group", O_RDONLY)) < 0)
408
+		return NULL;
409
+
410
+	while ((group = bb_getgrent(grp_fd)) != NULL)
411
+		if (!strcmp(group->gr_name, name)) {
412
+			close(grp_fd);
413
+			return group;
414
+		}
415
+
416
+	close(grp_fd);
417
+	return NULL;
418
+}
419
--- sash-3.4/getpwnam.c.pwd	2004-03-26 16:59:55.000000000 +0100
420
+++ sash-3.4/getpwnam.c	2004-03-26 16:59:55.000000000 +0100
421
@@ -0,0 +1,49 @@
422
+/*
423
+ * getpwnam.c - This file is part of the libc-8086/pwd package for ELKS,
424
+ * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
425
+ * 
426
+ *  This library is free software; you can redistribute it and/or
427
+ *  modify it under the terms of the GNU Library General Public
428
+ *  License as published by the Free Software Foundation; either
429
+ *  version 2 of the License, or (at your option) any later version.
430
+ *
431
+ *  This library is distributed in the hope that it will be useful,
432
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
433
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
434
+ *  Library General Public License for more details.
435
+ *
436
+ *  You should have received a copy of the GNU Library General Public
437
+ *  License along with this library; if not, write to the Free
438
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
439
+ *
440
+ */
441
+
442
+#include <unistd.h>
443
+#include <string.h>
444
+#include <errno.h>
445
+#include <fcntl.h>
446
+#include "pwd_.h"
447
+
448
+
449
+struct passwd *getpwnam(const char *name)
450
+{
451
+	int passwd_fd;
452
+	struct passwd *passwd;
453
+
454
+	if (name == NULL) {
455
+		errno = EINVAL;
456
+		return NULL;
457
+	}
458
+
459
+	if ((passwd_fd = open("/etc/passwd", O_RDONLY)) < 0)
460
+		return NULL;
461
+
462
+	while ((passwd = __getpwent(passwd_fd)) != NULL)
463
+		if (!strcmp(passwd->pw_name, name)) {
464
+			close(passwd_fd);
465
+			return passwd;
466
+		}
467
+
468
+	close(passwd_fd);
469
+	return NULL;
470
+}
471
--- sash-3.4/getpwuid.c.pwd	2004-03-26 16:59:55.000000000 +0100
472
+++ sash-3.4/getpwuid.c	2004-03-26 16:59:55.000000000 +0100
473
@@ -0,0 +1,43 @@
474
+/*
475
+ * getpwuid.c - This file is part of the libc-8086/pwd package for ELKS,
476
+ * Copyright (C) 1995, 1996 Nat Friedman <ndf@linux.mit.edu>.
477
+ * 
478
+ *  This library is free software; you can redistribute it and/or
479
+ *  modify it under the terms of the GNU Library General Public
480
+ *  License as published by the Free Software Foundation; either
481
+ *  version 2 of the License, or (at your option) any later version.
482
+ *
483
+ *  This library is distributed in the hope that it will be useful,
484
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
485
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
486
+ *  Library General Public License for more details.
487
+ *
488
+ *  You should have received a copy of the GNU Library General Public
489
+ *  License along with this library; if not, write to the Free
490
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
491
+ *
492
+ */
493
+
494
+#include <stdlib.h>
495
+#include <unistd.h>
496
+#include <fcntl.h>
497
+
498
+#include "pwd_.h"
499
+
500
+struct passwd *getpwuid(uid_t uid)
501
+{
502
+	int passwd_fd;
503
+	struct passwd *passwd;
504
+
505
+	if ((passwd_fd = open("/etc/passwd", O_RDONLY)) < 0)
506
+		return NULL;
507
+
508
+	while ((passwd = __getpwent(passwd_fd)) != NULL)
509
+		if (passwd->pw_uid == uid) {
510
+			close(passwd_fd);
511
+			return passwd;
512
+		}
513
+
514
+	close(passwd_fd);
515
+	return NULL;
516
+}
517
--- sash-3.4/grp_.h.pwd	2004-03-26 16:59:55.000000000 +0100
518
+++ sash-3.4/grp_.h	2004-03-26 17:34:14.000000000 +0100
519
@@ -0,0 +1,33 @@
520
+#ifndef	__CONFIG_GRP_H
521
+#define	__CONFIG_GRP_H
522
+
523
+#include <sys/types.h>
524
+#include <features.h>
525
+#include <stdio.h>
526
+
527
+
528
+/* The group structure */
529
+struct group
530
+{
531
+  char *gr_name;		/* Group name.	*/
532
+  char *gr_passwd;		/* Password.	*/
533
+  gid_t gr_gid;			/* Group ID.	*/
534
+  char **gr_mem;		/* Member list.	*/
535
+};
536
+
537
+extern void setgrent __P ((void));
538
+extern void endgrent __P ((void));
539
+extern struct group * getgrent __P ((void));
540
+
541
+extern struct group * getgrgid __P ((__const gid_t gid));
542
+extern struct group * getgrnam __P ((__const char * name));
543
+
544
+extern struct group * fgetgrent __P ((FILE * file));
545
+
546
+extern int setgroups __P ((size_t n, __const gid_t * groups));
547
+extern int initgroups __P ((__const char * user, gid_t gid));
548
+
549
+extern struct group * bb_getgrent __P ((int grp_fd));
550
+
551
+#endif /* __CONFIG_GRP_H */
552
+
553
--- sash-3.4/pwd_.h.pwd	2004-03-26 16:59:55.000000000 +0100
554
+++ sash-3.4/pwd_.h	2004-03-26 17:36:19.000000000 +0100
555
@@ -0,0 +1,35 @@
556
+#ifndef	__CONFIG_PWD_H
557
+#define	__CONFIG_PWD_H
558
+
559
+#include <sys/types.h>
560
+#include <features.h>
561
+#include <stdio.h>
562
+
563
+/* The passwd structure.  */
564
+struct passwd
565
+{
566
+  char *pw_name;		/* Username.  */
567
+  char *pw_passwd;		/* Password.  */
568
+  uid_t pw_uid;			/* User ID.  */
569
+  gid_t pw_gid;			/* Group ID.  */
570
+  char *pw_gecos;		/* Real name.  */
571
+  char *pw_dir;			/* Home directory.  */
572
+  char *pw_shell;		/* Shell program.  */
573
+};
574
+
575
+extern void setpwent __P ((void));
576
+extern void endpwent __P ((void));
577
+extern struct passwd * getpwent __P ((void));
578
+
579
+extern int putpwent __P ((__const struct passwd * __p, FILE * __f));
580
+extern int getpw __P ((uid_t uid, char *buf));
581
+
582
+extern struct passwd * fgetpwent __P ((FILE * file));
583
+
584
+extern struct passwd * getpwuid __P ((__const uid_t));
585
+extern struct passwd * getpwnam __P ((__const char *));
586
+
587
+extern struct passwd * __getpwent __P ((__const int passwd_fd));
588
+
589
+#endif /* __CONFIG_PWD_H  */
590
+
591
--- sash-3.4/Makefile.pwd	2004-03-26 16:59:54.000000000 +0100
592
+++ sash-3.4/Makefile	2004-03-26 21:30:20.000000000 +0100
593
@@ -15,7 +15,9 @@
594
 
595
 
596
 OBJS = sash.o cmds.o cmd_dd.o cmd_ed.o cmd_grep.o cmd_ls.o cmd_tar.o \
597
-	cmd_gzip.o cmd_find.o cmd_file.o cmd_chattr.o cmd_ar.o utils.o
598
+	cmd_gzip.o cmd_find.o cmd_file.o cmd_chattr.o cmd_ar.o utils.o \
599
+	getgrgid.o getgrnam.o getpwnam.o getpwuid.o __getgrent.o \
600
+	__getpwent.o
601
 
602
 
603
 sash:	$(OBJS)
... ... --- /dev/null
... ... +++ b/sash.spec
... ... @@ -0,0 +1,119 @@
1
Summary:	A statically linked shell, including some built-in basic commands
2
Name:		sash
3
Version:	3.7
4
Release:	%mkrel 12
5
License:	GPL
6
Group:		Shells
7
Url:		http://www.canb.auug.org.au/~dbell/
8
Source0:	http://www.canb.auug.org.au/~dbell/programs/%{name}-%{version}.tar.bz2
9
Patch0:		sash-3.7-optflags.patch
10
Patch2: 	sash-3.7-losetup.patch
11
Patch3: 	sash-3.7-fix-loop__remove_it_when_kernel_headers_are_fixed.patch
12
Patch4:		sash-3.7-linux2.6-buildfix.patch
13
Patch5:		sash-3.6-scriptarg.patch
14
Patch6:		sash-pwdfunc.patch
15
Patch7:		sash-3.7-segfault.patch
16
Patch8:		sash-3.7-special-script-call-esp-for-glibc-post.patch
17
Conflicts:      glibc < 6:2.3.3-2mdk
18
BuildRequires:	zlib-devel glibc-static-devel e2fsprogs-devel
19
Buildroot:	%{_tmppath}/%{name}-%{version}-buildroot
20
21
%description
22
Sash is a simple, standalone, statically linked shell which includes
23
simplified versions of built-in commands like ls, dd and gzip.  Sash
24
is statically linked so that it can work without shared libraries, so
25
it is particularly useful for recovering from certain types of system
26
failures.  Sash can also be used to safely upgrade to new versions of
27
shared libraries.
28
29
%prep
30
%setup -q
31
%patch0 -p1 -b ".misc"
32
%patch2 -p1 -b ".losetup"
33
%patch3 -p1 -b .loop
34
%patch4 -p1 -b .peroyvind
35
%patch5 -p1 -b .scriptarg
36
%patch6 -p1 -b ".pwd"
37
%patch7 -p1 -b ".segf"
38
%patch8 -p1 -b ".scriptarg" -z .pix
39
40
%build
41
make RPM_OPT_FLAGS="%{optflags}"
42
43
%install
44
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
45
46
install -s -D sash %{buildroot}/sbin/sash
47
install -D sash.1 %{buildroot}%{_mandir}/man8/sash.8
48
49
%clean
50
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
51
52
%files
53
%defattr(644,root,root,755)
54
%attr(755,root,root) /sbin/sash
55
%_mandir/*/*
56
57
58
59
60
%changelog
61
* Fri May 06 2011 Oden Eriksson <oeriksson@mandriva.com> 3.7-12mdv2011.0
62
+ Revision: 669958
63
- mass rebuild
64
65
* Fri Dec 03 2010 Oden Eriksson <oeriksson@mandriva.com> 3.7-11mdv2011.0
66
+ Revision: 607510
67
- rebuild
68
69
* Mon Mar 15 2010 Oden Eriksson <oeriksson@mandriva.com> 3.7-10mdv2010.1
70
+ Revision: 520214
71
- rebuilt for 2010.1
72
73
* Thu Sep 03 2009 Christophe Fergeau <cfergeau@mandriva.com> 3.7-9mdv2010.0
74
+ Revision: 427011
75
- rebuild
76
77
* Sat Apr 11 2009 Funda Wang <fwang@mandriva.org> 3.7-8mdv2009.1
78
+ Revision: 366282
79
- rediff loop patch
80
- rediff losetup patch
81
- rediff optflags patch
82
83
  + Antoine Ginies <aginies@mandriva.com>
84
    - rebuild
85
86
* Wed Jun 18 2008 Thierry Vignaud <tv@mandriva.org> 3.7-7mdv2009.0
87
+ Revision: 225365
88
- rebuild
89
90
  + Olivier Blin <oblin@mandriva.com>
91
    - restore BuildRoot
92
93
* Mon Dec 17 2007 Thierry Vignaud <tv@mandriva.org> 3.7-6mdv2008.1
94
+ Revision: 126961
95
- kill re-definition of %%buildroot on Pixel's request
96
97
98
* Mon Feb 12 2007 Tomasz Pawel Gajc <tpg@mandriva.org> 3.7-6mdv2007.0
99
+ Revision: 119970
100
- Import sash
101
102
* Tue Apr 25 2006 Pixel <pixel@mandriva.com> 3.7-5mdk
103
- rebuild (ie ensure we are statically linked with a recent zlib, cf #21942)
104
105
* Fri Oct 14 2005 Pixel <pixel@mandriva.com> 3.7-4mdk
106
- rebuild
107
108
* Thu Jun 03 2004 Pixel <pixel@mandrakesoft.com> 3.7-3mdk
109
- fedora patch sash-3.6-scriptarg broke --ignore-remaining-args special option
110
111
* Sun Apr 18 2004 Per yvind Karlsen <peroyvind@linux-mandrake.com> 3.7-2mdk
112
- fix buildrequires
113
114
* Sun Apr 18 2004 Per yvind Karlsen <peroyvind@linux-mandrake.com> 3.7-1mdk
115
- 3.7
116
- fix build with 2.6 kernel headers
117
- sync with fedora (P5, P6 & P7)
118
- rm -rf $RPM_BUILD_ROOT at the beginning of %%install
119

Comments