Toshaan Bharvani
2 years ago
commit
da1c738ae6
35 changed files with 3452 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||||||
|
--- bash-3.0/config-top.h.paths 2003-08-05 15:36:12.000000000 +0100 |
||||||
|
+++ bash-3.0/config-top.h 2004-07-28 09:36:27.117205637 +0100 |
||||||
|
@@ -66,7 +66,7 @@ |
||||||
|
the Posix.2 confstr () function, or CS_PATH define are not present. */ |
||||||
|
#ifndef STANDARD_UTILS_PATH |
||||||
|
#define STANDARD_UTILS_PATH \ |
||||||
|
- "/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc" |
||||||
|
+ "/bin:/usr/bin:/usr/sbin:/sbin" |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Default primary and secondary prompt strings. */ |
@ -0,0 +1,12 @@ |
|||||||
|
diff -up bash-3.2/config-top.h.profile bash-3.2/config-top.h |
||||||
|
--- bash-3.2/config-top.h.profile 2008-07-17 13:35:39.000000000 +0200 |
||||||
|
+++ bash-3.2/config-top.h 2008-07-17 13:42:18.000000000 +0200 |
||||||
|
@@ -26,6 +26,8 @@ |
||||||
|
what POSIX.2 specifies. */ |
||||||
|
#define CONTINUE_AFTER_KILL_ERROR |
||||||
|
|
||||||
|
+#define NON_INTERACTIVE_LOGIN_SHELLS |
||||||
|
+ |
||||||
|
/* Define BREAK_COMPLAINS if you want the non-standard, but useful |
||||||
|
error messages about `break' and `continue' out of context. */ |
||||||
|
#define BREAK_COMPLAINS |
@ -0,0 +1,215 @@ |
|||||||
|
diff --git a/config.h.in b/config.h.in |
||||||
|
index ab316d4..11d1d68 100644 |
||||||
|
--- a/config.h.in |
||||||
|
+++ b/config.h.in |
||||||
|
@@ -775,6 +775,9 @@ |
||||||
|
/* Define if you have the pselect function. */ |
||||||
|
#undef HAVE_PSELECT |
||||||
|
|
||||||
|
+/* Define if you have the pread function. */ |
||||||
|
+#undef HAVE_PREAD |
||||||
|
+ |
||||||
|
/* Define if you have the putenv function. */ |
||||||
|
#undef HAVE_PUTENV |
||||||
|
|
||||||
|
@@ -981,6 +984,9 @@ |
||||||
|
/* Define if you have the <dlfcn.h> header file. */ |
||||||
|
#undef HAVE_DLFCN_H |
||||||
|
|
||||||
|
+/* Define if you have the <elf.h> header file. */ |
||||||
|
+#undef HAVE_ELF_H |
||||||
|
+ |
||||||
|
/* Define if you have the <grp.h> header file. */ |
||||||
|
#undef HAVE_GRP_H |
||||||
|
|
||||||
|
diff --git a/configure.ac b/configure.ac |
||||||
|
index 2fe3e7d..f1b7f1b 100644 |
||||||
|
--- a/configure.ac |
||||||
|
+++ b/configure.ac |
||||||
|
@@ -827,7 +827,7 @@ dnl checks for system calls |
||||||
|
AC_CHECK_FUNCS(dup2 eaccess fcntl getdtablesize getentropy getgroups \ |
||||||
|
gethostname getpagesize getpeername getrandom getrlimit \ |
||||||
|
getrusage gettimeofday kill killpg lstat pselect readlink \ |
||||||
|
- select setdtablesize setitimer tcgetpgrp uname ulimit waitpid) |
||||||
|
+ select setdtablesize setitimer tcgetpgrp uname ulimit waitpid pread) |
||||||
|
AC_REPLACE_FUNCS(rename) |
||||||
|
|
||||||
|
dnl checks for c library functions |
||||||
|
diff --git a/execute_cmd.c b/execute_cmd.c |
||||||
|
index d2a0dd7..d2555ad 100644 |
||||||
|
--- a/execute_cmd.c |
||||||
|
+++ b/execute_cmd.c |
||||||
|
@@ -41,6 +41,10 @@ |
||||||
|
# include <unistd.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
+#ifdef HAVE_ELF_H |
||||||
|
+# include <elf.h> |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
#include "posixtime.h" |
||||||
|
|
||||||
|
#if defined (HAVE_SYS_RESOURCE_H) && !defined (RLIMTYPE) |
||||||
|
@@ -5832,6 +5836,14 @@ shell_execve (command, args, env) |
||||||
|
{ |
||||||
|
/* The file has the execute bits set, but the kernel refuses to |
||||||
|
run it for some reason. See why. */ |
||||||
|
+#if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H) |
||||||
|
+ int fd = open (command, O_RDONLY); |
||||||
|
+ |
||||||
|
+ if (fd >= 0) |
||||||
|
+ sample_len = read (fd, sample, sizeof (sample)); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
#if defined (HAVE_HASH_BANG_EXEC) |
||||||
|
READ_SAMPLE_BUF (command, sample, sample_len); |
||||||
|
if (sample_len > 0) |
||||||
|
@@ -5841,6 +5853,7 @@ shell_execve (command, args, env) |
||||||
|
char *interp; |
||||||
|
int ilen; |
||||||
|
|
||||||
|
+ close (fd); |
||||||
|
interp = getinterp (sample, sample_len, (int *)NULL); |
||||||
|
ilen = strlen (interp); |
||||||
|
errno = i; |
||||||
|
@@ -5856,7 +5869,138 @@ shell_execve (command, args, env) |
||||||
|
return (EX_NOEXEC); |
||||||
|
} |
||||||
|
#endif |
||||||
|
- errno = i; |
||||||
|
+#if defined (HAVE_ELF_H) |
||||||
|
+ if (i == ENOENT |
||||||
|
+ && sample_len > EI_NIDENT |
||||||
|
+ && memcmp (sample, ELFMAG, SELFMAG) == 0) |
||||||
|
+ { |
||||||
|
+ off_t offset = -1; |
||||||
|
+ |
||||||
|
+ /* It is an ELF file. Now determine whether it is dynamically |
||||||
|
+ linked and if yes, get the offset of the interpreter |
||||||
|
+ string. */ |
||||||
|
+ if (sample[EI_CLASS] == ELFCLASS32 |
||||||
|
+ && sample_len > sizeof (Elf32_Ehdr)) |
||||||
|
+ { |
||||||
|
+ Elf32_Ehdr ehdr; |
||||||
|
+ Elf32_Phdr *phdr; |
||||||
|
+ int nphdr; |
||||||
|
+ |
||||||
|
+ /* We have to copy the data since the sample buffer |
||||||
|
+ might not be aligned correctly to be accessed as |
||||||
|
+ an Elf32_Ehdr struct. */ |
||||||
|
+ memcpy (&ehdr, sample, sizeof (Elf32_Ehdr)); |
||||||
|
+ |
||||||
|
+ nphdr = ehdr.e_phnum; |
||||||
|
+ phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize); |
||||||
|
+ if (phdr != NULL) |
||||||
|
+ { |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize, |
||||||
|
+ ehdr.e_phoff); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1) |
||||||
|
+ sample_len = read (fd, phdr, |
||||||
|
+ nphdr * ehdr.e_phentsize); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
+ if (sample_len == nphdr * ehdr.e_phentsize) |
||||||
|
+ while (nphdr-- > 0) |
||||||
|
+ if (phdr[nphdr].p_type == PT_INTERP) |
||||||
|
+ { |
||||||
|
+ offset = phdr[nphdr].p_offset; |
||||||
|
+ break; |
||||||
|
+ } |
||||||
|
+ free (phdr); |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+ else if (sample[EI_CLASS] == ELFCLASS64 |
||||||
|
+ && sample_len > sizeof (Elf64_Ehdr)) |
||||||
|
+ { |
||||||
|
+ Elf64_Ehdr ehdr; |
||||||
|
+ Elf64_Phdr *phdr; |
||||||
|
+ int nphdr; |
||||||
|
+ |
||||||
|
+ /* We have to copy the data since the sample buffer |
||||||
|
+ might not be aligned correctly to be accessed as |
||||||
|
+ an Elf64_Ehdr struct. */ |
||||||
|
+ memcpy (&ehdr, sample, sizeof (Elf64_Ehdr)); |
||||||
|
+ |
||||||
|
+ nphdr = ehdr.e_phnum; |
||||||
|
+ phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize); |
||||||
|
+ if (phdr != NULL) |
||||||
|
+ { |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize, |
||||||
|
+ ehdr.e_phoff); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1) |
||||||
|
+ sample_len = read (fd, phdr, |
||||||
|
+ nphdr * ehdr.e_phentsize); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
+ if (sample_len == nphdr * ehdr.e_phentsize) |
||||||
|
+ while (nphdr-- > 0) |
||||||
|
+ if (phdr[nphdr].p_type == PT_INTERP) |
||||||
|
+ { |
||||||
|
+ offset = phdr[nphdr].p_offset; |
||||||
|
+ break; |
||||||
|
+ } |
||||||
|
+ free (phdr); |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+ |
||||||
|
+ if (offset != -1) |
||||||
|
+ { |
||||||
|
+ size_t maxlen = 0; |
||||||
|
+ size_t actlen = 0; |
||||||
|
+ char *interp = NULL; |
||||||
|
+ |
||||||
|
+ do |
||||||
|
+ { |
||||||
|
+ if (actlen == maxlen) |
||||||
|
+ { |
||||||
|
+ char *newinterp = realloc (interp, maxlen += 200); |
||||||
|
+ if (newinterp == NULL) |
||||||
|
+ { |
||||||
|
+ actlen = 0; |
||||||
|
+ break; |
||||||
|
+ } |
||||||
|
+ interp = newinterp; |
||||||
|
+ |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ actlen = pread (fd, interp, maxlen, offset); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, offset, SEEK_SET) != -1) |
||||||
|
+ actlen = read (fd, interp, maxlen); |
||||||
|
+ else |
||||||
|
+ actlen = -1; |
||||||
|
+#endif |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+ while (actlen > 0 && memchr (interp, '\0', actlen) == NULL); |
||||||
|
+ |
||||||
|
+ if (actlen > 0) |
||||||
|
+ { |
||||||
|
+ close (fd); |
||||||
|
+ errno = i; |
||||||
|
+ sys_error ("%s: %s: bad ELF interpreter", command, |
||||||
|
+ interp); |
||||||
|
+ free (interp); |
||||||
|
+ return (EX_NOEXEC); |
||||||
|
+ } |
||||||
|
+ |
||||||
|
+ free (interp); |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+#endif |
||||||
|
+#if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H) |
||||||
|
+ close (fd); |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
+ errno = i; |
||||||
|
file_error (command); |
||||||
|
} |
||||||
|
return (last_command_exit_value); |
@ -0,0 +1,10 @@ |
|||||||
|
--- bash-2.05b/builtins/Makefile.in.debuginfo 2003-03-25 17:25:21.000000000 +0000 |
||||||
|
+++ bash-2.05b/builtins/Makefile.in 2003-03-25 17:25:49.000000000 +0000 |
||||||
|
@@ -93,7 +93,6 @@ |
||||||
|
$(RM) $@ |
||||||
|
./$(MKBUILTINS) $(DIRECTDEFINE) $< |
||||||
|
$(CC) -c $(CCFLAGS) $*.c || ( $(RM) $*.c ; exit 1 ) |
||||||
|
- $(RM) $*.c |
||||||
|
|
||||||
|
# How to make a .c file from a .def file. |
||||||
|
.def.c: |
@ -0,0 +1,11 @@ |
|||||||
|
--- bash-2.05b/aclocal.m4.pgrp_sync 2002-06-25 14:45:43.000000000 +0100 |
||||||
|
+++ bash-2.05b/aclocal.m4 2003-01-15 18:17:35.000000000 +0000 |
||||||
|
@@ -1255,7 +1255,7 @@ |
||||||
|
wait(&status); |
||||||
|
exit(ok ? 0 : 5); |
||||||
|
} |
||||||
|
-], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, |
||||||
|
+], bash_cv_pgrp_pipe=yes,bash_cv_pgrp_pipe=yes, |
||||||
|
[AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no) |
||||||
|
bash_cv_pgrp_pipe=no]) |
||||||
|
]) |
@ -0,0 +1,96 @@ |
|||||||
|
diff -up bash-4.2/config.h.in.audit bash-4.2/config.h.in |
||||||
|
--- bash-4.2/config.h.in.audit 2013-01-31 16:26:16.857698992 +0100 |
||||||
|
+++ bash-4.2/config.h.in 2013-01-31 16:26:16.876699255 +0100 |
||||||
|
@@ -1131,6 +1131,14 @@ |
||||||
|
|
||||||
|
/* End additions for lib/intl */ |
||||||
|
|
||||||
|
+ |
||||||
|
+/* Additions for lib/readline */ |
||||||
|
+ |
||||||
|
+/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */ |
||||||
|
+#undef HAVE_DECL_AUDIT_USER_TTY |
||||||
|
+ |
||||||
|
+/* End additions for lib/readline */ |
||||||
|
+ |
||||||
|
#include "config-bot.h" |
||||||
|
|
||||||
|
#endif /* _CONFIG_H_ */ |
||||||
|
diff -up bash-4.2/configure.in.audit bash-4.2/configure.in |
||||||
|
--- bash-4.2/configure.in.audit 2013-01-31 16:26:16.858699005 +0100 |
||||||
|
+++ bash-4.2/configure.ac 2013-01-31 16:26:16.877699269 +0100 |
||||||
|
@@ -888,6 +888,8 @@ BASH_FUNC_DUP2_CLOEXEC_CHECK |
||||||
|
BASH_SYS_PGRP_SYNC |
||||||
|
BASH_SYS_SIGNAL_VINTAGE |
||||||
|
|
||||||
|
+AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]]) |
||||||
|
+ |
||||||
|
dnl checking for the presence of certain library symbols |
||||||
|
BASH_SYS_ERRLIST |
||||||
|
BASH_SYS_SIGLIST |
||||||
|
diff -up bash-4.2/lib/readline/readline.c.audit bash-4.2/lib/readline/readline.c |
||||||
|
--- bash-4.2/lib/readline/readline.c.audit 2013-01-31 16:26:16.871699185 +0100 |
||||||
|
+++ bash-4.2/lib/readline/readline.c 2013-01-31 17:24:23.902744860 +0100 |
||||||
|
@@ -55,6 +55,12 @@ |
||||||
|
extern int errno; |
||||||
|
#endif /* !errno */ |
||||||
|
|
||||||
|
+#if defined (HAVE_DECL_AUDIT_USER_TTY) |
||||||
|
+# include <sys/socket.h> |
||||||
|
+# include <linux/audit.h> |
||||||
|
+# include <linux/netlink.h> |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
/* System-specific feature definitions and include files. */ |
||||||
|
#include "rldefs.h" |
||||||
|
#include "rlmbutil.h" |
||||||
|
@@ -301,7 +307,48 @@ rl_set_prompt (prompt) |
||||||
|
rl_visible_prompt_length = rl_expand_prompt (rl_prompt); |
||||||
|
return 0; |
||||||
|
} |
||||||
|
- |
||||||
|
+ |
||||||
|
+#if defined (HAVE_DECL_AUDIT_USER_TTY) |
||||||
|
+/* Report STRING to the audit system. */ |
||||||
|
+static void |
||||||
|
+audit_tty (char *string) |
||||||
|
+{ |
||||||
|
+ struct sockaddr_nl addr; |
||||||
|
+ struct msghdr msg; |
||||||
|
+ struct nlmsghdr nlm; |
||||||
|
+ struct iovec iov[2]; |
||||||
|
+ size_t size; |
||||||
|
+ int fd; |
||||||
|
+ |
||||||
|
+ size = strlen (string) + 1; |
||||||
|
+ fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT); |
||||||
|
+ if (fd < 0) |
||||||
|
+ return; |
||||||
|
+ nlm.nlmsg_len = NLMSG_LENGTH (size); |
||||||
|
+ nlm.nlmsg_type = AUDIT_USER_TTY; |
||||||
|
+ nlm.nlmsg_flags = NLM_F_REQUEST; |
||||||
|
+ nlm.nlmsg_seq = 0; |
||||||
|
+ nlm.nlmsg_pid = 0; |
||||||
|
+ iov[0].iov_base = &nlm; |
||||||
|
+ iov[0].iov_len = sizeof (nlm); |
||||||
|
+ iov[1].iov_base = string; |
||||||
|
+ iov[1].iov_len = size; |
||||||
|
+ addr.nl_family = AF_NETLINK; |
||||||
|
+ addr.nl_pad = 0; |
||||||
|
+ addr.nl_pid = 0; |
||||||
|
+ addr.nl_groups = 0; |
||||||
|
+ msg.msg_name = &addr; |
||||||
|
+ msg.msg_namelen = sizeof (addr); |
||||||
|
+ msg.msg_iov = iov; |
||||||
|
+ msg.msg_iovlen = 2; |
||||||
|
+ msg.msg_control = NULL; |
||||||
|
+ msg.msg_controllen = 0; |
||||||
|
+ msg.msg_flags = 0; |
||||||
|
+ (void)sendmsg (fd, &msg, 0); |
||||||
|
+ close (fd); |
||||||
|
+} |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
/* Read a line of input. Prompt with PROMPT. An empty PROMPT means |
||||||
|
none. A return value of NULL means that EOF was encountered. */ |
||||||
|
char * |
@ -0,0 +1,13 @@ |
|||||||
|
diff --git a/config-top.h b/config-top.h |
||||||
|
index e5cc147..f5e0a52 100644 |
||||||
|
--- a/config-top.h |
||||||
|
+++ b/config-top.h |
||||||
|
@@ -106,7 +106,7 @@ |
||||||
|
sshd and source the .bashrc if so (like the rshd behavior). This checks |
||||||
|
for the presence of SSH_CLIENT or SSH2_CLIENT in the initial environment, |
||||||
|
which can be fooled under certain not-uncommon circumstances. */ |
||||||
|
-/* #define SSH_SOURCE_BASHRC */ |
||||||
|
+#define SSH_SOURCE_BASHRC |
||||||
|
|
||||||
|
/* Define if you want the case-toggling operators (~[~]) and the |
||||||
|
`capcase' variable attribute (declare -c). */ |
@ -0,0 +1,154 @@ |
|||||||
|
diff -up bash-4.0/execute_cmd.c.nobits bash-4.0/execute_cmd.c |
||||||
|
--- bash-4.0/execute_cmd.c.nobits 2009-08-11 11:53:38.000000000 +0200 |
||||||
|
+++ bash-4.0/execute_cmd.c 2009-08-14 16:18:18.000000000 +0200 |
||||||
|
@@ -4747,6 +4747,7 @@ shell_execve (command, args, env) |
||||||
|
&& memcmp (sample, ELFMAG, SELFMAG) == 0) |
||||||
|
{ |
||||||
|
off_t offset = -1; |
||||||
|
+ int dynamic_nobits = 0; |
||||||
|
|
||||||
|
/* It is an ELF file. Now determine whether it is dynamically |
||||||
|
linked and if yes, get the offset of the interpreter |
||||||
|
@@ -4756,13 +4757,61 @@ shell_execve (command, args, env) |
||||||
|
{ |
||||||
|
Elf32_Ehdr ehdr; |
||||||
|
Elf32_Phdr *phdr; |
||||||
|
- int nphdr; |
||||||
|
+ Elf32_Shdr *shdr; |
||||||
|
+ int nphdr, nshdr; |
||||||
|
|
||||||
|
/* We have to copy the data since the sample buffer |
||||||
|
might not be aligned correctly to be accessed as |
||||||
|
an Elf32_Ehdr struct. */ |
||||||
|
memcpy (&ehdr, sample, sizeof (Elf32_Ehdr)); |
||||||
|
|
||||||
|
+ nshdr = ehdr.e_shnum; |
||||||
|
+ shdr = (Elf32_Shdr *) malloc (nshdr * ehdr.e_shentsize); |
||||||
|
+ |
||||||
|
+ if (shdr != NULL) |
||||||
|
+ { |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize, |
||||||
|
+ ehdr.e_shoff); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1) |
||||||
|
+ sample_len = read (fd, shdr, |
||||||
|
+ nshdr * ehdr.e_shentsize); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
+ if (sample_len == nshdr * ehdr.e_shentsize) |
||||||
|
+ { |
||||||
|
+ char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size); |
||||||
|
+ if (strings != NULL) |
||||||
|
+ { |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ sample_len = pread (fd, strings, |
||||||
|
+ shdr[ehdr.e_shstrndx].sh_size, |
||||||
|
+ shdr[ehdr.e_shstrndx].sh_offset); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset, |
||||||
|
+ SEEK_SET) != -1) |
||||||
|
+ sample_len = read (fd, strings, |
||||||
|
+ shdr[ehdr.e_shstrndx].sh_size); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
+ if (sample_len == shdr[ehdr.e_shstrndx].sh_size) |
||||||
|
+ while (nshdr-- > 0) |
||||||
|
+ if (strcmp (strings + shdr[nshdr].sh_name, |
||||||
|
+ ".interp") == 0 && |
||||||
|
+ shdr[nshdr].sh_type == SHT_NOBITS) |
||||||
|
+ { |
||||||
|
+ dynamic_nobits++; |
||||||
|
+ break; |
||||||
|
+ } |
||||||
|
+ free (strings); |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+ free (shdr); |
||||||
|
+ } |
||||||
|
+ |
||||||
|
nphdr = ehdr.e_phnum; |
||||||
|
phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize); |
||||||
|
if (phdr != NULL) |
||||||
|
@@ -4792,13 +4841,60 @@ shell_execve (command, args, env) |
||||||
|
{ |
||||||
|
Elf64_Ehdr ehdr; |
||||||
|
Elf64_Phdr *phdr; |
||||||
|
- int nphdr; |
||||||
|
+ Elf64_Shdr *shdr; |
||||||
|
+ int nphdr, nshdr; |
||||||
|
|
||||||
|
/* We have to copy the data since the sample buffer |
||||||
|
might not be aligned correctly to be accessed as |
||||||
|
an Elf64_Ehdr struct. */ |
||||||
|
memcpy (&ehdr, sample, sizeof (Elf64_Ehdr)); |
||||||
|
|
||||||
|
+ nshdr = ehdr.e_shnum; |
||||||
|
+ shdr = (Elf64_Shdr *) malloc (nshdr * ehdr.e_shentsize); |
||||||
|
+ if (shdr != NULL) |
||||||
|
+ { |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize, |
||||||
|
+ ehdr.e_shoff); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1) |
||||||
|
+ sample_len = read (fd, shdr, |
||||||
|
+ nshdr * ehdr.e_shentsize); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
+ if (sample_len == nshdr * ehdr.e_shentsize) |
||||||
|
+ { |
||||||
|
+ char *strings = (char *) malloc (shdr[ehdr.e_shstrndx].sh_size); |
||||||
|
+ if (strings != NULL) |
||||||
|
+ { |
||||||
|
+#ifdef HAVE_PREAD |
||||||
|
+ sample_len = pread (fd, strings, |
||||||
|
+ shdr[ehdr.e_shstrndx].sh_size, |
||||||
|
+ shdr[ehdr.e_shstrndx].sh_offset); |
||||||
|
+#else |
||||||
|
+ if (lseek (fd, shdr[ehdr.e_shstrndx].sh_offset, |
||||||
|
+ SEEK_SET) != -1) |
||||||
|
+ sample_len = read (fd, strings, |
||||||
|
+ shdr[ehdr.e_shstrndx].sh_size); |
||||||
|
+ else |
||||||
|
+ sample_len = -1; |
||||||
|
+#endif |
||||||
|
+ if (sample_len == shdr[ehdr.e_shstrndx].sh_size) |
||||||
|
+ while (nshdr-- > 0) |
||||||
|
+ if (strcmp (strings + shdr[nshdr].sh_name, |
||||||
|
+ ".interp") == 0 && |
||||||
|
+ shdr[nshdr].sh_type == SHT_NOBITS) |
||||||
|
+ { |
||||||
|
+ dynamic_nobits++; |
||||||
|
+ break; |
||||||
|
+ } |
||||||
|
+ free (strings); |
||||||
|
+ } |
||||||
|
+ } |
||||||
|
+ free (shdr); |
||||||
|
+ } |
||||||
|
+ |
||||||
|
nphdr = ehdr.e_phnum; |
||||||
|
phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize); |
||||||
|
if (phdr != NULL) |
||||||
|
@@ -4858,8 +4954,15 @@ shell_execve (command, args, env) |
||||||
|
{ |
||||||
|
close (fd); |
||||||
|
errno = i; |
||||||
|
- sys_error ("%s: %s: bad ELF interpreter", command, |
||||||
|
- interp); |
||||||
|
+ if (dynamic_nobits > 0) |
||||||
|
+ { |
||||||
|
+ sys_error ("%s: bad ELF interpreter", command); |
||||||
|
+ } |
||||||
|
+ else |
||||||
|
+ { |
||||||
|
+ sys_error ("%s: %s: bad ELF interpreter", command, |
||||||
|
+ interp); |
||||||
|
+ } |
||||||
|
free (interp); |
||||||
|
return (EX_NOEXEC); |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
diff -up bash-4.1/config-top.h.broken_pipe bash-4.1/config-top.h |
||||||
|
--- bash-4.1/config-top.h.broken_pipe 2011-01-06 18:01:30.000000000 +0100 |
||||||
|
+++ bash-4.1/config-top.h 2011-01-06 18:02:14.000000000 +0100 |
||||||
|
@@ -51,7 +51,7 @@ |
||||||
|
/* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins |
||||||
|
like `echo' and `printf' to report errors when output does not succeed |
||||||
|
due to EPIPE. */ |
||||||
|
-/* #define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS */ |
||||||
|
+#define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS |
||||||
|
|
||||||
|
/* The default value of the PATH variable. */ |
||||||
|
#ifndef DEFAULT_PATH_VALUE |
@ -0,0 +1,24 @@ |
|||||||
|
diff -up bash-4.1/examples/loadables/Makefile.in.examples bash-4.1/examples/loadables/Makefile.in |
||||||
|
--- bash-4.1/examples/loadables/Makefile.in.examples 2010-06-22 16:20:02.000000000 +0200 |
||||||
|
+++ bash-4.1/examples/loadables/Makefile.in 2010-06-22 16:20:41.000000000 +0200 |
||||||
|
@@ -43,7 +43,7 @@ host_os = @host_os@ |
||||||
|
host_cpu = @host_cpu@ |
||||||
|
host_vendor = @host_vendor@ |
||||||
|
|
||||||
|
-CFLAGS = @CFLAGS@ |
||||||
|
+CFLAGS = -O2 -g |
||||||
|
LOCAL_CFLAGS = @LOCAL_CFLAGS@ |
||||||
|
DEFS = @DEFS@ |
||||||
|
LOCAL_DEFS = @LOCAL_DEFS@ |
||||||
|
diff -up bash-4.1/examples/loadables/perl/Makefile.in.examples bash-4.1/examples/loadables/perl/Makefile.in |
||||||
|
--- bash-4.1/examples/loadables/perl/Makefile.in.examples 2010-06-22 16:20:46.000000000 +0200 |
||||||
|
+++ bash-4.1/examples/loadables/perl/Makefile.in 2010-06-22 16:21:04.000000000 +0200 |
||||||
|
@@ -42,7 +42,7 @@ SHELL = @MAKE_SHELL@ |
||||||
|
|
||||||
|
PERL5 = perl5 |
||||||
|
|
||||||
|
-CFLAGS = @CFLAGS@ |
||||||
|
+CFLAGS = -O2 -g |
||||||
|
|
||||||
|
# |
||||||
|
# These values are generated for configure by ${topdir}/support/shobj-conf. |
@ -0,0 +1,103 @@ |
|||||||
|
diff --git a/execute_cmd.c b/execute_cmd.c |
||||||
|
index a988400..412128c 100644 |
||||||
|
--- a/execute_cmd.c |
||||||
|
+++ b/execute_cmd.c |
||||||
|
@@ -5760,7 +5760,7 @@ shell_execve (command, args, env) |
||||||
|
Elf32_Ehdr ehdr; |
||||||
|
Elf32_Phdr *phdr; |
||||||
|
Elf32_Shdr *shdr; |
||||||
|
- int nphdr, nshdr; |
||||||
|
+ Elf32_Half nphdr, nshdr; |
||||||
|
|
||||||
|
/* We have to copy the data since the sample buffer |
||||||
|
might not be aligned correctly to be accessed as |
||||||
|
@@ -5768,12 +5768,12 @@ shell_execve (command, args, env) |
||||||
|
memcpy (&ehdr, sample, sizeof (Elf32_Ehdr)); |
||||||
|
|
||||||
|
nshdr = ehdr.e_shnum; |
||||||
|
- shdr = (Elf32_Shdr *) malloc (nshdr * ehdr.e_shentsize); |
||||||
|
+ shdr = (Elf32_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize); |
||||||
|
|
||||||
|
if (shdr != NULL) |
||||||
|
{ |
||||||
|
#ifdef HAVE_PREAD |
||||||
|
- sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize, |
||||||
|
+ sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize, |
||||||
|
ehdr.e_shoff); |
||||||
|
#else |
||||||
|
if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1) |
||||||
|
@@ -5815,11 +5815,11 @@ shell_execve (command, args, env) |
||||||
|
} |
||||||
|
|
||||||
|
nphdr = ehdr.e_phnum; |
||||||
|
- phdr = (Elf32_Phdr *) malloc (nphdr * ehdr.e_phentsize); |
||||||
|
+ phdr = (Elf32_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize); |
||||||
|
if (phdr != NULL) |
||||||
|
{ |
||||||
|
#ifdef HAVE_PREAD |
||||||
|
- sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize, |
||||||
|
+ sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize, |
||||||
|
ehdr.e_phoff); |
||||||
|
#else |
||||||
|
if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1) |
||||||
|
@@ -5844,7 +5844,7 @@ shell_execve (command, args, env) |
||||||
|
Elf64_Ehdr ehdr; |
||||||
|
Elf64_Phdr *phdr; |
||||||
|
Elf64_Shdr *shdr; |
||||||
|
- int nphdr, nshdr; |
||||||
|
+ Elf32_Half nphdr, nshdr; |
||||||
|
|
||||||
|
/* We have to copy the data since the sample buffer |
||||||
|
might not be aligned correctly to be accessed as |
||||||
|
@@ -5852,11 +5852,11 @@ shell_execve (command, args, env) |
||||||
|
memcpy (&ehdr, sample, sizeof (Elf64_Ehdr)); |
||||||
|
|
||||||
|
nshdr = ehdr.e_shnum; |
||||||
|
- shdr = (Elf64_Shdr *) malloc (nshdr * ehdr.e_shentsize); |
||||||
|
+ shdr = (Elf64_Shdr *) malloc ((size_t)nshdr * (size_t)ehdr.e_shentsize); |
||||||
|
if (shdr != NULL) |
||||||
|
{ |
||||||
|
#ifdef HAVE_PREAD |
||||||
|
- sample_len = pread (fd, shdr, nshdr * ehdr.e_shentsize, |
||||||
|
+ sample_len = pread (fd, shdr, (size_t)nshdr * (size_t)ehdr.e_shentsize, |
||||||
|
ehdr.e_shoff); |
||||||
|
#else |
||||||
|
if (lseek (fd, ehdr.e_shoff, SEEK_SET) != -1) |
||||||
|
@@ -5898,11 +5898,11 @@ shell_execve (command, args, env) |
||||||
|
} |
||||||
|
|
||||||
|
nphdr = ehdr.e_phnum; |
||||||
|
- phdr = (Elf64_Phdr *) malloc (nphdr * ehdr.e_phentsize); |
||||||
|
+ phdr = (Elf64_Phdr *) malloc ((size_t)nphdr * (size_t)ehdr.e_phentsize); |
||||||
|
if (phdr != NULL) |
||||||
|
{ |
||||||
|
#ifdef HAVE_PREAD |
||||||
|
- sample_len = pread (fd, phdr, nphdr * ehdr.e_phentsize, |
||||||
|
+ sample_len = pread (fd, phdr, (size_t)nphdr * (size_t)ehdr.e_phentsize, |
||||||
|
ehdr.e_phoff); |
||||||
|
#else |
||||||
|
if (lseek (fd, ehdr.e_phoff, SEEK_SET) != -1) |
||||||
|
@@ -5924,8 +5924,8 @@ shell_execve (command, args, env) |
||||||
|
|
||||||
|
if (offset != -1) |
||||||
|
{ |
||||||
|
- size_t maxlen = 0; |
||||||
|
- size_t actlen = 0; |
||||||
|
+ ssize_t maxlen = 0; |
||||||
|
+ ssize_t actlen = 0; |
||||||
|
char *interp = NULL; |
||||||
|
|
||||||
|
do |
||||||
|
@@ -5974,7 +5974,8 @@ shell_execve (command, args, env) |
||||||
|
} |
||||||
|
#endif |
||||||
|
#if defined (HAVE_HASH_BANG_EXEC) || defined (HAVE_ELF_H) |
||||||
|
- close (fd); |
||||||
|
+ if (fd >= 0) |
||||||
|
+ close (fd); |
||||||
|
#endif |
||||||
|
|
||||||
|
errno = i; |
||||||
|
-- |
||||||
|
2.17.2 |
||||||
|
|
@ -0,0 +1,12 @@ |
|||||||
|
diff -up bash-4.1/doc/bash.1.manpage_trap bash-4.1/doc/bash.1 |
||||||
|
--- bash-4.1/doc/bash.1.manpage_trap 2012-08-28 10:06:00.561999092 +0200 |
||||||
|
+++ bash-4.1/doc/bash.1 2012-08-28 10:06:24.225304505 +0200 |
||||||
|
@@ -9251,7 +9251,7 @@ being inverted via |
||||||
|
These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option. |
||||||
|
.if t .sp 0.5 |
||||||
|
.if n .sp 1 |
||||||
|
-Signals ignored upon entry to the shell cannot be trapped or reset. |
||||||
|
+Signals ignored upon entry to the shell cannot be trapped, reset or listed. |
||||||
|
Trapped signals that are not being ignored are reset to their original |
||||||
|
values in a subshell or subshell environment when one is created. |
||||||
|
The return status is false if any |
@ -0,0 +1,41 @@ |
|||||||
|
diff --git a/config-top.h b/config-top.h |
||||||
|
index 026d4a4..cb0e002 100644 |
||||||
|
--- a/config-top.h |
||||||
|
+++ b/config-top.h |
||||||
|
@@ -92,7 +92,7 @@ |
||||||
|
/* #define SYS_BASHRC "/etc/bash.bashrc" */ |
||||||
|
|
||||||
|
/* System-wide .bash_logout for login shells. */ |
||||||
|
-/* #define SYS_BASH_LOGOUT "/etc/bash.bash_logout" */ |
||||||
|
+#define SYS_BASH_LOGOUT "/etc/bash.bash_logout" |
||||||
|
|
||||||
|
/* Define this to make non-interactive shells begun with argv[0][0] == '-' |
||||||
|
run the startup files when not in posix mode. */ |
||||||
|
diff --git a/doc/bash.1 b/doc/bash.1 |
||||||
|
index 04ce845..bfde55e 100644 |
||||||
|
--- a/doc/bash.1 |
||||||
|
+++ b/doc/bash.1 |
||||||
|
@@ -335,8 +335,8 @@ option may be used when the shell is started to inhibit this behavior. |
||||||
|
When an interactive login shell exits, |
||||||
|
or a non-interactive login shell executes the \fBexit\fP builtin command, |
||||||
|
.B bash |
||||||
|
-reads and executes commands from the file \fI~/.bash_logout\fP, if it |
||||||
|
-exists. |
||||||
|
+reads and executes commands from the files \fI~/.bash_logout\fP |
||||||
|
+and \fI/etc/bash.bash_logout\fP, if the files exists. |
||||||
|
.PP |
||||||
|
When an interactive shell that is not a login shell is started, |
||||||
|
.B bash |
||||||
|
@@ -10558,6 +10558,9 @@ The \fBbash\fP executable |
||||||
|
.FN /etc/profile |
||||||
|
The systemwide initialization file, executed for login shells |
||||||
|
.TP |
||||||
|
+.FN /etc/bash.bash_logout |
||||||
|
+The systemwide login shell cleanup file, executed when a login shell exits |
||||||
|
+.TP |
||||||
|
.FN ~/.bash_profile |
||||||
|
The personal initialization file, executed for login shells |
||||||
|
.TP |
||||||
|
-- |
||||||
|
2.9.3 |
||||||
|
|
@ -0,0 +1,14 @@ |
|||||||
|
diff -up bash-4.2/variables.h.size_type bash-4.2/variables.h |
||||||
|
--- bash-4.2/variables.h.size_type 2012-11-29 10:33:25.109036844 +0100 |
||||||
|
+++ bash-4.2/variables.h 2012-11-29 10:46:12.718530162 +0100 |
||||||
|
@@ -95,8 +95,8 @@ typedef struct variable { |
||||||
|
|
||||||
|
typedef struct _vlist { |
||||||
|
SHELL_VAR **list; |
||||||
|
- int list_size; /* allocated size */ |
||||||
|
- int list_len; /* current number of entries */ |
||||||
|
+ size_t list_size; /* allocated size */ |
||||||
|
+ size_t list_len; /* current number of entries */ |
||||||
|
} VARLIST; |
||||||
|
|
||||||
|
/* The various attributes that a given variable can have. */ |
@ -0,0 +1,15 @@ |
|||||||
|
diff --git a/doc/bash.1 b/doc/bash.1 |
||||||
|
index 6e8aebb..e846e68 100644 |
||||||
|
--- a/doc/bash.1 |
||||||
|
+++ b/doc/bash.1 |
||||||
|
@@ -10333,6 +10333,7 @@ and |
||||||
|
which are in 512-byte increments. |
||||||
|
The return status is 0 unless an invalid option or argument is supplied, |
||||||
|
or an error occurs while setting a new limit. |
||||||
|
+In POSIX Mode 512-byte blocks are used for the `-c' and `-f' options. |
||||||
|
.RE |
||||||
|
.TP |
||||||
|
\fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] |
||||||
|
-- |
||||||
|
2.9.3 |
||||||
|
|
@ -0,0 +1,13 @@ |
|||||||
|
diff --git a/locale.c b/locale.c |
||||||
|
index 17ccc58..a6c07a3 100644 |
||||||
|
--- a/locale.c |
||||||
|
+++ b/locale.c |
||||||
|
@@ -78,8 +78,6 @@ set_default_locale () |
||||||
|
{ |
||||||
|
#if defined (HAVE_SETLOCALE) |
||||||
|
default_locale = setlocale (LC_ALL, ""); |
||||||
|
- if (default_locale) |
||||||
|
- default_locale = savestring (default_locale); |
||||||
|
#else |
||||||
|
default_locale = savestring ("C"); |
||||||
|
#endif /* HAVE_SETLOCALE */ |
@ -0,0 +1,43 @@ |
|||||||
|
diff --git a/parse.y b/parse.y |
||||||
|
index df1231d..2449fa8 100644 |
||||||
|
--- a/parse.y |
||||||
|
+++ b/parse.y |
||||||
|
@@ -4482,6 +4482,8 @@ xparse_dolparen (base, string, indp, flags) |
||||||
|
save_parser_state (&ps); |
||||||
|
save_input_line_state (&ls); |
||||||
|
orig_eof_token = shell_eof_token; |
||||||
|
+ /* avoid echoing every substitution again */ |
||||||
|
+ echo_input_at_read = 0; |
||||||
|
#if defined (ALIAS) || defined (DPAREN_ARITHMETIC) |
||||||
|
saved_pushed_strings = pushed_string_list; /* separate parsing context */ |
||||||
|
pushed_string_list = (STRING_SAVER *)NULL; |
||||||
|
diff --git a/subst.c b/subst.c |
||||||
|
index 9ccbf33..8a9ee5c 100644 |
||||||
|
--- a/subst.c |
||||||
|
+++ b/subst.c |
||||||
|
@@ -9453,6 +9453,7 @@ param_expand (string, sindex, quoted, expanded_something, |
||||||
|
WORD_LIST *list, *l; |
||||||
|
WORD_DESC *tdesc, *ret; |
||||||
|
int tflag, nullarg; |
||||||
|
+ int old_echo_input; |
||||||
|
|
||||||
|
/*itrace("param_expand: `%s' pflags = %d", string+*sindex, pflags);*/ |
||||||
|
zindex = *sindex; |
||||||
|
@@ -9843,6 +9844,9 @@ arithsub: |
||||||
|
} |
||||||
|
|
||||||
|
comsub: |
||||||
|
+ old_echo_input = echo_input_at_read; |
||||||
|
+ /* avoid echoing every substitution again */ |
||||||
|
+ echo_input_at_read = 0; |
||||||
|
if (pflags & PF_NOCOMSUB) |
||||||
|
/* we need zindex+1 because string[zindex] == RPAREN */ |
||||||
|
temp1 = substring (string, *sindex, zindex+1); |
||||||
|
@@ -9855,6 +9859,7 @@ comsub: |
||||||
|
} |
||||||
|
FREE (temp); |
||||||
|
temp = temp1; |
||||||
|
+ echo_input_at_read = old_echo_input; |
||||||
|
break; |
||||||
|
|
||||||
|
/* Do POSIX.2d9-style arithmetic substitution. This will probably go |
@ -0,0 +1,15 @@ |
|||||||
|
diff --git a/Makefile.in b/Makefile.in |
||||||
|
index a1f9483..24c646a 100644 |
||||||
|
--- a/Makefile.in |
||||||
|
+++ b/Makefile.in |
||||||
|
@@ -800,7 +800,6 @@ install: .made installdirs |
||||||
|
infodir=$(infodir) htmldir=$(htmldir) DESTDIR=$(DESTDIR) $@ ) |
||||||
|
-( cd $(DEFDIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) |
||||||
|
-( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) |
||||||
|
- -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) |
||||||
|
|
||||||
|
install-strip: |
||||||
|
$(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ |
||||||
|
-- |
||||||
|
2.9.3 |
||||||
|
|
@ -0,0 +1,13 @@ |
|||||||
|
diff --git a/doc/bash.1 b/doc/bash.1 |
||||||
|
--- a/doc/bash.1 |
||||||
|
+++ b/doc/bash.1 |
||||||
|
@@ -9889,6 +9889,9 @@ If set, the |
||||||
|
to find the directory containing the file supplied as an argument. |
||||||
|
This option is enabled by default. |
||||||
|
.TP 8 |
||||||
|
+.B syslog_history |
||||||
|
+If set, command history is logged to syslog. |
||||||
|
+.TP 8 |
||||||
|
.B xpg_echo |
||||||
|
If set, the \fBecho\fP builtin expands backslash-escape sequences |
||||||
|
by default. |
@ -0,0 +1,50 @@ |
|||||||
|
diff --git a/Makefile.in b/Makefile.in |
||||||
|
--- a/Makefile.in |
||||||
|
+++ b/Makefile.in |
||||||
|
@@ -1315,6 +1315,7 @@ bashline.o: trap.h flags.h assoc.h $(BASHINCDIR)/ocache.h |
||||||
|
bashline.o: $(DEFSRC)/common.h $(GLOB_LIBSRC)/glob.h alias.h |
||||||
|
bashline.o: pcomplete.h ${BASHINCDIR}/chartypes.h input.h |
||||||
|
bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h |
||||||
|
+bashline.o: ${DEFDIR}/builtext.h |
||||||
|
bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h |
||||||
|
bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h |
||||||
|
bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h |
||||||
|
@@ -1435,6 +1436,7 @@ builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h built |
||||||
|
builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h |
||||||
|
builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h |
||||||
|
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h pathnames.h |
||||||
|
+builtins/evalstring.o: ${DEFDIR}/builtext.h |
||||||
|
builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h |
||||||
|
builtins/getopt.o: shell.h syntax.h bashjmp.h command.h general.h xmalloc.h error.h |
||||||
|
builtins/getopt.o: variables.h arrayfunc.h conftypes.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h |
||||||
|
diff --git a/builtins/Makefile.in b/builtins/Makefile.in |
||||||
|
--- a/builtins/Makefile.in |
||||||
|
+++ b/builtins/Makefile.in |
||||||
|
@@ -361,7 +361,7 @@ evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h |
||||||
|
evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h |
||||||
|
evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h |
||||||
|
evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h |
||||||
|
-evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h |
||||||
|
+evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h ./builtext.h |
||||||
|
#evalstring.o: $(topdir)/y.tab.h |
||||||
|
getopt.o: ../config.h $(BASHINCDIR)/memalloc.h |
||||||
|
getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h |
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -1,6 +1,6 @@ |
||||||
|
/* patchlevel.h -- current bash patch level */ |
||||||
|
|
||||||
|
-/* Copyright (C) 2001-2016 Free Software Foundation, Inc. |
||||||
|
+/* Copyright (C) 2001-2020 Free Software Foundation, Inc. |
||||||
|
|
||||||
|
This file is part of GNU Bash, the Bourne Again SHell. |
||||||
|
|
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 0 |
||||||
|
+#define PATCHLEVEL 1 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
@ -0,0 +1,29 @@ |
|||||||
|
diff --git a/builtins/wait.def b/builtins/wait.def |
||||||
|
--- a/builtins/wait.def |
||||||
|
+++ b/builtins/wait.def |
||||||
|
@@ -213,11 +213,11 @@ wait_builtin (list) |
||||||
|
} |
||||||
|
|
||||||
|
status = wait_for_any_job (wflags, &pstat); |
||||||
|
- if (status < 0) |
||||||
|
- status = 127; |
||||||
|
- |
||||||
|
if (vname && status >= 0) |
||||||
|
bind_var_to_int (vname, pstat.pid); |
||||||
|
+ |
||||||
|
+ if (status < 0) |
||||||
|
+ status = 127; |
||||||
|
if (list) |
||||||
|
unset_waitlist (); |
||||||
|
WAIT_RETURN (status); |
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 1 |
||||||
|
+#define PATCHLEVEL 2 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
@ -0,0 +1,27 @@ |
|||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 2 |
||||||
|
+#define PATCHLEVEL 3 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
||||||
|
diff --git a/subst.c b/subst.c |
||||||
|
--- a/subst.c |
||||||
|
+++ b/subst.c |
||||||
|
@@ -6356,8 +6356,10 @@ command_substitute (string, quoted, flags) |
||||||
|
|
||||||
|
#if defined (JOB_CONTROL) |
||||||
|
old_pipeline_pgrp = pipeline_pgrp; |
||||||
|
- /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline. */ |
||||||
|
- if ((subshell_environment & SUBSHELL_PIPE) == 0) |
||||||
|
+ /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline or |
||||||
|
+ we've already forked to run a disk command (and are expanding redirections, |
||||||
|
+ for example). */ |
||||||
|
+ if ((subshell_environment & (SUBSHELL_FORK|SUBSHELL_PIPE)) == 0) |
||||||
|
pipeline_pgrp = shell_pgrp; |
||||||
|
cleanup_the_pipeline (); |
||||||
|
#endif /* JOB_CONTROL */ |
@ -0,0 +1,97 @@ |
|||||||
|
diff --git a/arrayfunc.c b/arrayfunc.c |
||||||
|
--- a/arrayfunc.c |
||||||
|
+++ b/arrayfunc.c |
||||||
|
@@ -597,6 +597,27 @@ assign_assoc_from_kvlist (var, nlist, h, flags) |
||||||
|
free (aval); |
||||||
|
} |
||||||
|
} |
||||||
|
+ |
||||||
|
+/* Return non-zero if L appears to be a key-value pair associative array |
||||||
|
+ compound assignment. */ |
||||||
|
+int |
||||||
|
+kvpair_assignment_p (l) |
||||||
|
+ WORD_LIST *l; |
||||||
|
+{ |
||||||
|
+ return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '['); /*]*/ |
||||||
|
+} |
||||||
|
+ |
||||||
|
+char * |
||||||
|
+expand_and_quote_kvpair_word (w) |
||||||
|
+ char *w; |
||||||
|
+{ |
||||||
|
+ char *t, *r; |
||||||
|
+ |
||||||
|
+ t = w ? expand_assignment_string_to_string (w, 0) : 0; |
||||||
|
+ r = sh_single_quote (t ? t : ""); |
||||||
|
+ free (t); |
||||||
|
+ return r; |
||||||
|
+} |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Callers ensure that VAR is not NULL. Associative array assignments have not |
||||||
|
@@ -640,7 +661,7 @@ assign_compound_array_list (var, nlist, flags) |
||||||
|
last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0; |
||||||
|
|
||||||
|
#if ASSOC_KVPAIR_ASSIGNMENT |
||||||
|
- if (assoc_p (var) && nlist && (nlist->word->flags & W_ASSIGNMENT) == 0 && nlist->word->word[0] != '[') /*]*/ |
||||||
|
+ if (assoc_p (var) && kvpair_assignment_p (nlist)) |
||||||
|
{ |
||||||
|
iflags = flags & ~ASS_APPEND; |
||||||
|
assign_assoc_from_kvlist (var, nlist, nhash, iflags); |
||||||
|
diff --git a/arrayfunc.h b/arrayfunc.h |
||||||
|
--- a/arrayfunc.h |
||||||
|
+++ b/arrayfunc.h |
||||||
|
@@ -67,6 +67,9 @@ extern SHELL_VAR *assign_array_var_from_string PARAMS((SHELL_VAR *, char *, int) |
||||||
|
extern char *expand_and_quote_assoc_word PARAMS((char *, int)); |
||||||
|
extern void quote_compound_array_list PARAMS((WORD_LIST *, int)); |
||||||
|
|
||||||
|
+extern int kvpair_assignment_p PARAMS((WORD_LIST *)); |
||||||
|
+extern char *expand_and_quote_kvpair_word PARAMS((char *)); |
||||||
|
+ |
||||||
|
extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int)); |
||||||
|
extern int skipsubscript PARAMS((const char *, int, int)); |
||||||
|
|
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 3 |
||||||
|
+#define PATCHLEVEL 4 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
||||||
|
diff --git a/subst.c b/subst.c |
||||||
|
--- a/subst.c |
||||||
|
+++ b/subst.c |
||||||
|
@@ -11604,6 +11604,7 @@ expand_oneword (value, flags) |
||||||
|
{ |
||||||
|
WORD_LIST *l, *nl; |
||||||
|
char *t; |
||||||
|
+ int kvpair; |
||||||
|
|
||||||
|
if (flags == 0) |
||||||
|
{ |
||||||
|
@@ -11618,11 +11619,21 @@ expand_oneword (value, flags) |
||||||
|
{ |
||||||
|
/* Associative array */ |
||||||
|
l = parse_string_to_word_list (value, 1, "array assign"); |
||||||
|
+#if ASSOC_KVPAIR_ASSIGNMENT |
||||||
|
+ kvpair = kvpair_assignment_p (l); |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
/* For associative arrays, with their arbitrary subscripts, we have to |
||||||
|
expand and quote in one step so we don't have to search for the |
||||||
|
closing right bracket more than once. */ |
||||||
|
for (nl = l; nl; nl = nl->next) |
||||||
|
{ |
||||||
|
+#if ASSOC_KVPAIR_ASSIGNMENT |
||||||
|
+ if (kvpair) |
||||||
|
+ /* keys and values undergo the same set of expansions */ |
||||||
|
+ t = expand_and_quote_kvpair_word (nl->word->word); |
||||||
|
+ else |
||||||
|
+#endif |
||||||
|
if ((nl->word->flags & W_ASSIGNMENT) == 0) |
||||||
|
t = sh_single_quote (nl->word->word ? nl->word->word : ""); |
||||||
|
else |
@ -0,0 +1,85 @@ |
|||||||
|
From cc978a670597afc3251baca3a7db553f36946c22 Mon Sep 17 00:00:00 2001 |
||||||
|
From: Chet Ramey <chet.ramey@case.edu> |
||||||
|
Date: Tue, 4 May 2021 14:29:06 -0400 |
||||||
|
Subject: [PATCH] Bash-5.1 patch 5: fix memory leaks in compound array |
||||||
|
assignments |
||||||
|
|
||||||
|
--- |
||||||
|
arrayfunc.c | 11 +++-------- |
||||||
|
patchlevel.h | 2 +- |
||||||
|
subst.c | 2 ++ |
||||||
|
3 files changed, 6 insertions(+), 9 deletions(-) |
||||||
|
|
||||||
|
diff --git a/arrayfunc.c b/arrayfunc.c |
||||||
|
index 8231ba1e..9338dfc7 100644 |
||||||
|
--- a/arrayfunc.c |
||||||
|
+++ b/arrayfunc.c |
||||||
|
@@ -564,12 +564,9 @@ assign_assoc_from_kvlist (var, nlist, h, flags) |
||||||
|
{ |
||||||
|
WORD_LIST *list; |
||||||
|
char *akey, *aval, *k, *v; |
||||||
|
- int free_aval; |
||||||
|
|
||||||
|
for (list = nlist; list; list = list->next) |
||||||
|
{ |
||||||
|
- free_aval = 0; |
||||||
|
- |
||||||
|
k = list->word->word; |
||||||
|
v = list->next ? list->next->word->word : 0; |
||||||
|
|
||||||
|
@@ -577,24 +574,22 @@ assign_assoc_from_kvlist (var, nlist, h, flags) |
||||||
|
list = list->next; |
||||||
|
|
||||||
|
akey = expand_assignment_string_to_string (k, 0); |
||||||
|
- aval = expand_assignment_string_to_string (v, 0); |
||||||
|
- |
||||||
|
if (akey == 0 || *akey == 0) |
||||||
|
{ |
||||||
|
err_badarraysub (k); |
||||||
|
FREE (akey); |
||||||
|
continue; |
||||||
|
} |
||||||
|
+ |
||||||
|
+ aval = expand_assignment_string_to_string (v, 0); |
||||||
|
if (aval == 0) |
||||||
|
{ |
||||||
|
aval = (char *)xmalloc (1); |
||||||
|
aval[0] = '\0'; /* like do_assignment_internal */ |
||||||
|
- free_aval = 1; |
||||||
|
} |
||||||
|
|
||||||
|
bind_assoc_var_internal (var, h, akey, aval, flags); |
||||||
|
- if (free_aval) |
||||||
|
- free (aval); |
||||||
|
+ free (aval); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
index e1429c24..c7f39aec 100644 |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 4 |
||||||
|
+#define PATCHLEVEL 5 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
||||||
|
diff --git a/subst.c b/subst.c |
||||||
|
index 6132316a..1d24188e 100644 |
||||||
|
--- a/subst.c |
||||||
|
+++ b/subst.c |
||||||
|
@@ -11673,6 +11673,8 @@ expand_compound_assignment_word (tlist, flags) |
||||||
|
free (value); |
||||||
|
|
||||||
|
value = string_list (l); |
||||||
|
+ dispose_words (l); |
||||||
|
+ |
||||||
|
wlen = STRLEN (value); |
||||||
|
|
||||||
|
/* Now, let's rebuild the string */ |
||||||
|
-- |
||||||
|
2.29.2 |
||||||
|
|
@ -0,0 +1,44 @@ |
|||||||
|
From f3cd936b81006df41a1c8509891dea1edeaef8e6 Mon Sep 17 00:00:00 2001 |
||||||
|
From: Chet Ramey <chet.ramey@case.edu> |
||||||
|
Date: Tue, 4 May 2021 14:30:17 -0400 |
||||||
|
Subject: [PATCH] Bash-5.1 patch 6: make sure child processes forked to execute |
||||||
|
command substitutions are in the right process group |
||||||
|
|
||||||
|
--- |
||||||
|
patchlevel.h | 2 +- |
||||||
|
subst.c | 7 +++++++ |
||||||
|
2 files changed, 8 insertions(+), 1 deletion(-) |
||||||
|
|
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
index c7f39aec..6257aeeb 100644 |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 5 |
||||||
|
+#define PATCHLEVEL 6 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
||||||
|
diff --git a/subst.c b/subst.c |
||||||
|
index 1d24188e..462752de 100644 |
||||||
|
--- a/subst.c |
||||||
|
+++ b/subst.c |
||||||
|
@@ -6412,6 +6412,13 @@ command_substitute (string, quoted, flags) |
||||||
|
/* The currently executing shell is not interactive. */ |
||||||
|
interactive = 0; |
||||||
|
|
||||||
|
+#if defined (JOB_CONTROL) |
||||||
|
+ /* Invariant: in child processes started to run command substitutions, |
||||||
|
+ pipeline_pgrp == shell_pgrp. Other parts of the shell assume this. */ |
||||||
|
+ if (pipeline_pgrp > 0 && pipeline_pgrp != shell_pgrp) |
||||||
|
+ shell_pgrp = pipeline_pgrp; |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
set_sigint_handler (); /* XXX */ |
||||||
|
|
||||||
|
free_pushed_string_input (); |
||||||
|
-- |
||||||
|
2.29.2 |
||||||
|
|
@ -0,0 +1,71 @@ |
|||||||
|
From b72f88db852104cf49cfb4762eda6e8f4fd20a70 Mon Sep 17 00:00:00 2001 |
||||||
|
From: Chet Ramey <chet.ramey@case.edu> |
||||||
|
Date: Tue, 4 May 2021 14:31:05 -0400 |
||||||
|
Subject: [PATCH] Bash-5.1 patch 7: fix version comparisons in readline startup |
||||||
|
files |
||||||
|
|
||||||
|
--- |
||||||
|
lib/readline/bind.c | 15 ++++++++------- |
||||||
|
patchlevel.h | 2 +- |
||||||
|
2 files changed, 9 insertions(+), 8 deletions(-) |
||||||
|
|
||||||
|
diff --git a/lib/readline/bind.c b/lib/readline/bind.c |
||||||
|
index 87596dce..76103786 100644 |
||||||
|
--- a/lib/readline/bind.c |
||||||
|
+++ b/lib/readline/bind.c |
||||||
|
@@ -1234,7 +1234,7 @@ parser_if (char *args) |
||||||
|
#endif /* VI_MODE */ |
||||||
|
else if (_rl_strnicmp (args, "version", 7) == 0) |
||||||
|
{ |
||||||
|
- int rlversion, versionarg, op, previ, major, minor; |
||||||
|
+ int rlversion, versionarg, op, previ, major, minor, opresult; |
||||||
|
|
||||||
|
_rl_parsing_conditionalized_out = 1; |
||||||
|
rlversion = RL_VERSION_MAJOR*10 + RL_VERSION_MINOR; |
||||||
|
@@ -1294,24 +1294,25 @@ parser_if (char *args) |
||||||
|
switch (op) |
||||||
|
{ |
||||||
|
case OP_EQ: |
||||||
|
- _rl_parsing_conditionalized_out = rlversion == versionarg; |
||||||
|
+ opresult = rlversion == versionarg; |
||||||
|
break; |
||||||
|
case OP_NE: |
||||||
|
- _rl_parsing_conditionalized_out = rlversion != versionarg; |
||||||
|
+ opresult = rlversion != versionarg; |
||||||
|
break; |
||||||
|
case OP_GT: |
||||||
|
- _rl_parsing_conditionalized_out = rlversion > versionarg; |
||||||
|
+ opresult = rlversion > versionarg; |
||||||
|
break; |
||||||
|
case OP_GE: |
||||||
|
- _rl_parsing_conditionalized_out = rlversion >= versionarg; |
||||||
|
+ opresult = rlversion >= versionarg; |
||||||
|
break; |
||||||
|
case OP_LT: |
||||||
|
- _rl_parsing_conditionalized_out = rlversion < versionarg; |
||||||
|
+ opresult = rlversion < versionarg; |
||||||
|
break; |
||||||
|
case OP_LE: |
||||||
|
- _rl_parsing_conditionalized_out = rlversion <= versionarg; |
||||||
|
+ opresult = rlversion <= versionarg; |
||||||
|
break; |
||||||
|
} |
||||||
|
+ _rl_parsing_conditionalized_out = 1 - opresult; |
||||||
|
} |
||||||
|
/* Check to see if the first word in ARGS is the same as the |
||||||
|
value stored in rl_readline_name. */ |
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
index 6257aeeb..c5ed66ab 100644 |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 6 |
||||||
|
+#define PATCHLEVEL 7 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
||||||
|
-- |
||||||
|
2.29.2 |
||||||
|
|
@ -0,0 +1,49 @@ |
|||||||
|
From ce23728687ce9e584333367075c9deef413553fa Mon Sep 17 00:00:00 2001 |
||||||
|
From: Chet Ramey <chet.ramey@case.edu> |
||||||
|
Date: Tue, 4 May 2021 14:31:53 -0400 |
||||||
|
Subject: [PATCH] Bash-5.1 patch 8: clean up FIFOs created by redirections in |
||||||
|
child processes |
||||||
|
|
||||||
|
--- |
||||||
|
execute_cmd.c | 8 +++++++- |
||||||
|
patchlevel.h | 2 +- |
||||||
|
2 files changed, 8 insertions(+), 2 deletions(-) |
||||||
|
|
||||||
|
diff --git a/execute_cmd.c b/execute_cmd.c |
||||||
|
index d2a0dd71..90129e06 100644 |
||||||
|
--- a/execute_cmd.c |
||||||
|
+++ b/execute_cmd.c |
||||||
|
@@ -5556,11 +5556,17 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out, |
||||||
|
#if defined (PROCESS_SUBSTITUTION) |
||||||
|
/* Try to remove named pipes that may have been created as the |
||||||
|
result of redirections. */ |
||||||
|
- unlink_fifo_list (); |
||||||
|
+ unlink_all_fifos (); |
||||||
|
#endif /* PROCESS_SUBSTITUTION */ |
||||||
|
exit (EXECUTION_FAILURE); |
||||||
|
} |
||||||
|
|
||||||
|
+#if defined (PROCESS_SUBSTITUTION) && !defined (HAVE_DEV_FD) |
||||||
|
+ /* This should only contain FIFOs created as part of redirection |
||||||
|
+ expansion. */ |
||||||
|
+ unlink_all_fifos (); |
||||||
|
+#endif |
||||||
|
+ |
||||||
|
if (async) |
||||||
|
interactive = old_interactive; |
||||||
|
|
||||||
|
diff --git a/patchlevel.h b/patchlevel.h |
||||||
|
index c5ed66ab..10fde2ee 100644 |
||||||
|
--- a/patchlevel.h |
||||||
|
+++ b/patchlevel.h |
||||||
|
@@ -25,6 +25,6 @@ |
||||||
|
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
||||||
|
looks for to find the patch level (for the sccs version string). */ |
||||||
|
|
||||||
|
-#define PATCHLEVEL 7 |
||||||
|
+#define PATCHLEVEL 8 |
||||||
|
|
||||||
|
#endif /* _PATCHLEVEL_H_ */ |
||||||
|
-- |
||||||
|
2.29.2 |
||||||
|
|
@ -0,0 +1,26 @@ |
|||||||
|
diff --git a/doc/Makefile.in b/doc/Makefile.in |
||||||
|
index 5f0756c..a5fa5a0 100644 |
||||||
|
--- a/doc/Makefile.in |
||||||
|
+++ b/doc/Makefile.in |
||||||
|
@@ -74,7 +74,6 @@ TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi |
||||||
|
TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html |
||||||
|
MAN2HTML = ${BUILD_DIR}/support/man2html |
||||||
|
HTMLPOST = ${srcdir}/htmlpost.sh |
||||||
|
-INFOPOST = ${srcdir}/infopost.sh |
||||||
|
QUIETPS = #set this to -q to shut up dvips |
||||||
|
PAPERSIZE = letter # change to a4 for A4-size paper |
||||||
|
PSDPI = 600 # could be 300 if you like |
||||||
|
@@ -188,8 +187,8 @@ bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER) |
||||||
|
bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER) |
||||||
|
$(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi |
||||||
|
|
||||||
|
-bash.info: bashref.info |
||||||
|
- ${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \ |
||||||
|
+bash.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER) |
||||||
|
+ $(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi -o $@ |
||||||
|
|
||||||
|
bash.txt: bash.1 |
||||||
|
bash.ps: bash.1 |
||||||
|
-- |
||||||
|
2.9.3 |
||||||
|
|
@ -0,0 +1,312 @@ |
|||||||
|
diff --git a/builtins.h b/builtins.h |
||||||
|
index dac95fd..5b7e811 100644 |
||||||
|
--- a/builtins.h |
||||||
|
+++ b/builtins.h |
||||||
|
@@ -45,6 +45,7 @@ |
||||||
|
#define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */ |
||||||
|
#define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */ |
||||||
|
#define LOCALVAR_BUILTIN 0x40 /* This builtin creates local variables */ |
||||||
|
+#define REQUIRES_BUILTIN 0x80 /* This builtin requires other files. */ |
||||||
|
|
||||||
|
#define BASE_INDENT 4 |
||||||
|
|
||||||
|
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c |
||||||
|
index e243021..0a7a0e5 100644 |
||||||
|
--- a/builtins/mkbuiltins.c |
||||||
|
+++ b/builtins/mkbuiltins.c |
||||||
|
@@ -69,10 +69,15 @@ extern char *strcpy (); |
||||||
|
#define whitespace(c) (((c) == ' ') || ((c) == '\t')) |
||||||
|
|
||||||
|
/* Flag values that builtins can have. */ |
||||||
|
+/* These flags are for the C code generator, |
||||||
|
+ the C which is produced (./builtin.c) |
||||||
|
+ includes the flags definitions found |
||||||
|
+ in ../builtins.h */ |
||||||
|
#define BUILTIN_FLAG_SPECIAL 0x01 |
||||||
|
#define BUILTIN_FLAG_ASSIGNMENT 0x02 |
||||||
|
#define BUILTIN_FLAG_LOCALVAR 0x04 |
||||||
|
#define BUILTIN_FLAG_POSIX_BUILTIN 0x08 |
||||||
|
+#define BUILTIN_FLAG_REQUIRES 0x10 |
||||||
|
|
||||||
|
#define BASE_INDENT 4 |
||||||
|
|
||||||
|
@@ -173,11 +178,19 @@ char *posix_builtins[] = |
||||||
|
(char *)NULL |
||||||
|
}; |
||||||
|
|
||||||
|
+/* The builtin commands that cause requirements on other files. */ |
||||||
|
+static char *requires_builtins[] = |
||||||
|
+{ |
||||||
|
+ ".", "command", "exec", "source", "inlib", |
||||||
|
+ (char *)NULL |
||||||
|
+}; |
||||||
|
+ |
||||||
|
/* Forward declarations. */ |
||||||
|
static int is_special_builtin (); |
||||||
|
static int is_assignment_builtin (); |
||||||
|
static int is_localvar_builtin (); |
||||||
|
static int is_posix_builtin (); |
||||||
|
+static int is_requires_builtin (); |
||||||
|
|
||||||
|
#if !defined (HAVE_RENAME) |
||||||
|
static int rename (); |
||||||
|
@@ -831,6 +844,8 @@ builtin_handler (self, defs, arg) |
||||||
|
new->flags |= BUILTIN_FLAG_LOCALVAR; |
||||||
|
if (is_posix_builtin (name)) |
||||||
|
new->flags |= BUILTIN_FLAG_POSIX_BUILTIN; |
||||||
|
+ if (is_requires_builtin (name)) |
||||||
|
+ new->flags |= BUILTIN_FLAG_REQUIRES; |
||||||
|
|
||||||
|
array_add ((char *)new, defs->builtins); |
||||||
|
building_builtin = 1; |
||||||
|
@@ -1250,12 +1265,13 @@ write_builtins (defs, structfile, externfile) |
||||||
|
else |
||||||
|
fprintf (structfile, "(sh_builtin_func_t *)0x0, "); |
||||||
|
|
||||||
|
- fprintf (structfile, "%s%s%s%s%s, %s_doc,\n", |
||||||
|
+ fprintf (structfile, "%s%s%s%s%s%s, %s_doc,\n", |
||||||
|
"BUILTIN_ENABLED | STATIC_BUILTIN", |
||||||
|
(builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "", |
||||||
|
(builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "", |
||||||
|
(builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "", |
||||||
|
(builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "", |
||||||
|
+ (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "", |
||||||
|
document_name (builtin)); |
||||||
|
|
||||||
|
/* Don't translate short document summaries that are identical |
||||||
|
@@ -1645,6 +1661,13 @@ is_posix_builtin (name) |
||||||
|
return (_find_in_table (name, posix_builtins)); |
||||||
|
} |
||||||
|
|
||||||
|
+static int |
||||||
|
+is_requires_builtin (name) |
||||||
|
+ char *name; |
||||||
|
+{ |
||||||
|
+ return (_find_in_table (name, requires_builtins)); |
||||||
|
+} |
||||||
|
+ |
||||||
|
#if !defined (HAVE_RENAME) |
||||||
|
static int |
||||||
|
rename (from, to) |
||||||
|
diff --git a/doc/bash.1 b/doc/bash.1 |
||||||
|
index 5af7d42..7539368 100644 |
||||||
|
--- a/doc/bash.1 |
||||||
|
+++ b/doc/bash.1 |
||||||
|
@@ -239,6 +239,14 @@ The shell becomes restricted (see |
||||||
|
.B "RESTRICTED SHELL" |
||||||
|
below). |
||||||
|
.TP |
||||||
|
+.B \-\-rpm-requires |
||||||
|
+Produce the list of files that are required for the |
||||||
|
+shell script to run. This implies '-n' and is subject |
||||||
|
+to the same limitations as compile time error checking checking; |
||||||
|
+Command substitutions, Conditional expressions and |
||||||
|
+.BR eval |
||||||
|
+builtin are not parsed so some dependencies may be missed. |
||||||
|
+.TP |
||||||
|
.B \-\-verbose |
||||||
|
Equivalent to \fB\-v\fP. |
||||||
|
.TP |
||||||
|
diff --git a/doc/bashref.texi b/doc/bashref.texi |
||||||
|
index 9e23f58..d02151e 100644 |
||||||
|
--- a/doc/bashref.texi |
||||||
|
+++ b/doc/bashref.texi |
||||||
|
@@ -6554,6 +6554,13 @@ standard. @xref{Bash POSIX Mode}, for a description of the Bash |
||||||
|
@item --restricted |
||||||
|
Make the shell a restricted shell (@pxref{The Restricted Shell}). |
||||||
|
|
||||||
|
+@item --rpm-requires |
||||||
|
+Produce the list of files that are required for the |
||||||
|
+shell script to run. This implies '-n' and is subject |
||||||
|
+to the same limitations as compile time error checking checking; |
||||||
|
+Command substitutions, Conditional expressions and @command{eval} |
||||||
|
+are not parsed so some dependencies may be missed. |
||||||
|
+ |
||||||
|
@item --verbose |
||||||
|
Equivalent to @option{-v}. Print shell input lines as they're read. |
||||||
|
|
||||||
|
diff --git a/eval.c b/eval.c |
||||||
|
index 1d967da..f197033 100644 |
||||||
|
--- a/eval.c |
||||||
|
+++ b/eval.c |
||||||
|
@@ -137,7 +137,8 @@ reader_loop () |
||||||
|
|
||||||
|
if (read_command () == 0) |
||||||
|
{ |
||||||
|
- if (interactive_shell == 0 && read_but_dont_execute) |
||||||
|
+ |
||||||
|
+ if (interactive_shell == 0 && (read_but_dont_execute && !rpm_requires)) |
||||||
|
{ |
||||||
|
set_exit_status (EXECUTION_SUCCESS); |
||||||
|
dispose_command (global_command); |
||||||
|
diff --git a/execute_cmd.c b/execute_cmd.c |
||||||
|
index d2555ad..397e283 100644 |
||||||
|
--- a/execute_cmd.c |
||||||
|
+++ b/execute_cmd.c |
||||||
|
@@ -543,6 +543,8 @@ async_redirect_stdin () |
||||||
|
|
||||||
|
#define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0) |
||||||
|
|
||||||
|
+extern int rpm_requires; |
||||||
|
+ |
||||||
|
/* Execute the command passed in COMMAND, perhaps doing it asynchronously. |
||||||
|
COMMAND is exactly what read_command () places into GLOBAL_COMMAND. |
||||||
|
ASYNCHRONOUS, if non-zero, says to do this command in the background. |
||||||
|
@@ -574,7 +576,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out, |
||||||
|
|
||||||
|
if (breaking || continuing) |
||||||
|
return (last_command_exit_value); |
||||||
|
- if (command == 0 || read_but_dont_execute) |
||||||
|
+ if (command == 0 || (read_but_dont_execute && !rpm_requires)) |
||||||
|
+ return (EXECUTION_SUCCESS); |
||||||
|
+ if (rpm_requires && command->type == cm_function_def) |
||||||
|
+ return last_command_exit_value = |
||||||
|
+ execute_intern_function (command->value.Function_def->name, |
||||||
|
+ command->value.Function_def); |
||||||
|
+ if (read_but_dont_execute) |
||||||
|
return (EXECUTION_SUCCESS); |
||||||
|
|
||||||
|
QUIT; |
||||||
|
@@ -2836,7 +2844,7 @@ execute_for_command (for_command) |
||||||
|
save_line_number = line_number; |
||||||
|
if (check_identifier (for_command->name, 1) == 0) |
||||||
|
{ |
||||||
|
- if (posixly_correct && interactive_shell == 0) |
||||||
|
+ if (posixly_correct && interactive_shell == 0 && rpm_requires == 0) |
||||||
|
{ |
||||||
|
last_command_exit_value = EX_BADUSAGE; |
||||||
|
jump_to_top_level (ERREXIT); |
||||||
|
diff --git a/execute_cmd.h b/execute_cmd.h |
||||||
|
index 465030a..9c7fd1c 100644 |
||||||
|
--- a/execute_cmd.h |
||||||
|
+++ b/execute_cmd.h |
||||||
|
@@ -22,6 +22,9 @@ |
||||||
|
#define _EXECUTE_CMD_H_ |
||||||
|
|
||||||
|
#include "stdc.h" |
||||||
|
+#include "variables.h" |
||||||
|
+#include "command.h" |
||||||
|
+ |
||||||
|
|
||||||
|
#if defined (ARRAY_VARS) |
||||||
|
struct func_array_state |
||||||
|
diff --git a/make_cmd.c b/make_cmd.c |
||||||
|
index 2d7ac96..ac53526 100644 |
||||||
|
--- a/make_cmd.c |
||||||
|
+++ b/make_cmd.c |
||||||
|
@@ -35,6 +35,8 @@ |
||||||
|
#include "bashintl.h" |
||||||
|
|
||||||
|
#include "shell.h" |
||||||
|
+#include "builtins.h" |
||||||
|
+#include "builtins/common.h" |
||||||
|
#include "execute_cmd.h" |
||||||
|
#include "parser.h" |
||||||
|
#include "flags.h" |
||||||
|
@@ -828,6 +830,30 @@ make_coproc_command (name, command) |
||||||
|
return (make_command (cm_coproc, (SIMPLE_COM *)temp)); |
||||||
|
} |
||||||
|
|
||||||
|
+static void |
||||||
|
+output_requirement (deptype, filename) |
||||||
|
+const char *deptype; |
||||||
|
+char *filename; |
||||||
|
+{ |
||||||
|
+ static char *alphabet_set = "abcdefghijklmnopqrstuvwxyz" |
||||||
|
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
||||||
|
+ |
||||||
|
+ if (strchr(filename, '$') || (filename[0] != '/' && strchr(filename, '/'))) |
||||||
|
+ return; |
||||||
|
+ |
||||||
|
+ /* |
||||||
|
+ if the executable is called via variable substitution we can |
||||||
|
+ not dermine what it is at compile time. |
||||||
|
+ |
||||||
|
+ if the executable consists only of characters not in the |
||||||
|
+ alphabet we do not consider it a dependency just an artifact |
||||||
|
+ of shell parsing (ex "exec < ${infile}"). |
||||||
|
+ */ |
||||||
|
+ |
||||||
|
+ if (strpbrk(filename, alphabet_set)) |
||||||
|
+ printf ("%s(%s)\n", deptype, filename); |
||||||
|
+} |
||||||
|
+ |
||||||
|
/* Reverse the word list and redirection list in the simple command |
||||||
|
has just been parsed. It seems simpler to do this here the one |
||||||
|
time then by any other method that I can think of. */ |
||||||
|
@@ -845,6 +871,28 @@ clean_simple_command (command) |
||||||
|
REVERSE_LIST (command->value.Simple->redirects, REDIRECT *); |
||||||
|
} |
||||||
|
|
||||||
|
+ if (rpm_requires && command->value.Simple->words) |
||||||
|
+ { |
||||||
|
+ char *cmd0; |
||||||
|
+ char *cmd1; |
||||||
|
+ struct builtin *b; |
||||||
|
+ |
||||||
|
+ cmd0 = command->value.Simple->words->word->word; |
||||||
|
+ b = builtin_address_internal (cmd0, 0); |
||||||
|
+ cmd1 = 0; |
||||||
|
+ if (command->value.Simple->words->next) |
||||||
|
+ cmd1 = command->value.Simple->words->next->word->word; |
||||||
|
+ |
||||||
|
+ if (b) { |
||||||
|
+ if ( (b->flags & REQUIRES_BUILTIN) && cmd1) |
||||||
|
+ output_requirement ("executable", cmd1); |
||||||
|
+ } else { |
||||||
|
+ if (!assignment(cmd0, 0)) |
||||||
|
+ output_requirement (find_function(cmd0) ? "function" : "executable", cmd0); |
||||||
|
+ } |
||||||
|
+ } /*rpm_requires*/ |
||||||
|
+ |
||||||
|
+ |
||||||
|
parser_state &= ~PST_REDIRLIST; |
||||||
|
return (command); |
||||||
|
} |
||||||
|
diff --git a/shell.c b/shell.c |
||||||
|
index ce8087f..7dcd000 100644 |
||||||
|
--- a/shell.c |
||||||
|
+++ b/shell.c |
||||||
|
@@ -194,6 +194,9 @@ int have_devfd = 0; |
||||||
|
/* The name of the .(shell)rc file. */ |
||||||
|
static char *bashrc_file = DEFAULT_BASHRC; |
||||||
|
|
||||||
|
+/* Non-zero if we are finding the scripts requirements. */ |
||||||
|
+int rpm_requires; |
||||||
|
+ |
||||||
|
/* Non-zero means to act more like the Bourne shell on startup. */ |
||||||
|
static int act_like_sh; |
||||||
|
|
||||||
|
@@ -260,6 +263,7 @@ static const struct { |
||||||
|
{ "protected", Int, &protected_mode, (char **)0x0 }, |
||||||
|
#endif |
||||||
|
{ "rcfile", Charp, (int *)0x0, &bashrc_file }, |
||||||
|
+ { "rpm-requires", Int, &rpm_requires, (char **)0x0 }, |
||||||
|
#if defined (RESTRICTED_SHELL) |
||||||
|
{ "restricted", Int, &restricted, (char **)0x0 }, |
||||||
|
#endif |
||||||
|
@@ -502,6 +506,12 @@ main (argc, argv, env) |
||||||
|
if (dump_translatable_strings) |
||||||
|
read_but_dont_execute = 1; |
||||||
|
|
||||||
|
+ if (rpm_requires) |
||||||
|
+ { |
||||||
|
+ read_but_dont_execute = 1; |
||||||
|
+ initialize_shell_builtins (); |
||||||
|
+ } |
||||||
|
+ |
||||||
|
if (running_setuid && privileged_mode == 0) |
||||||
|
disable_priv_mode (); |
||||||
|
|
||||||
|
diff --git a/shell.h b/shell.h |
||||||
|
index 8b41792..29b0efb 100644 |
||||||
|
--- a/shell.h |
||||||
|
+++ b/shell.h |
||||||
|
@@ -99,6 +99,7 @@ extern int interactive, interactive_shell; |
||||||
|
extern int startup_state; |
||||||
|
extern int reading_shell_script; |
||||||
|
extern int shell_initialized; |
||||||
|
+extern int rpm_requires; |
||||||
|
extern int bash_argv_initialized; |
||||||
|
extern int subshell_environment; |
||||||
|
extern int current_command_number; |
@ -0,0 +1,10 @@ |
|||||||
|
--- bash-3.0/builtins/setattr.def.setlocale 2005-08-08 12:22:42.000000000 +0100 |
||||||
|
+++ bash-3.0/builtins/setattr.def 2005-08-08 12:25:16.000000000 +0100 |
||||||
|
@@ -423,4 +423,7 @@ |
||||||
|
|
||||||
|
if (var && (exported_p (var) || (attribute & att_exported))) |
||||||
|
array_needs_making++; /* XXX */ |
||||||
|
+ |
||||||
|
+ if (var) |
||||||
|
+ stupidly_hack_special_variables (name); |
||||||
|
} |
@ -0,0 +1,58 @@ |
|||||||
|
diff --git a/tests/exec.right b/tests/exec.right |
||||||
|
index 0a249dd..fe8a127 100644 |
||||||
|
--- a/tests/exec.right |
||||||
|
+++ b/tests/exec.right |
||||||
|
@@ -51,7 +51,6 @@ this is ohio-state |
||||||
|
0 |
||||||
|
1 |
||||||
|
testb |
||||||
|
-expand_aliases on |
||||||
|
1 |
||||||
|
1 |
||||||
|
1 |
||||||
|
diff --git a/tests/execscript b/tests/execscript |
||||||
|
index 2809676..1216828 100644 |
||||||
|
--- a/tests/execscript |
||||||
|
+++ b/tests/execscript |
||||||
|
@@ -108,8 +108,6 @@ ${THIS_SH} ./exec6.sub |
||||||
|
# checks for properly deciding what constitutes an executable file |
||||||
|
${THIS_SH} ./exec7.sub |
||||||
|
|
||||||
|
-${THIS_SH} -i ${PWD}/exec8.sub |
||||||
|
- |
||||||
|
${THIS_SH} ./exec9.sub |
||||||
|
|
||||||
|
${THIS_SH} ./exec10.sub |
||||||
|
diff --git a/tests/read.right b/tests/read.right |
||||||
|
index 1144083..09cd422 100644 |
||||||
|
--- a/tests/read.right |
||||||
|
+++ b/tests/read.right |
||||||
|
@@ -33,14 +33,6 @@ a = abcdefg |
||||||
|
a = xyz |
||||||
|
a = -xyz 123- |
||||||
|
a = abc |
||||||
|
-timeout 1: ok |
||||||
|
- |
||||||
|
-timeout 2: ok |
||||||
|
- |
||||||
|
-./read2.sub: line 36: read: -3: invalid timeout specification |
||||||
|
-1 |
||||||
|
- |
||||||
|
-abcde |
||||||
|
./read3.sub: line 17: read: -1: invalid number |
||||||
|
abc |
||||||
|
ab |
||||||
|
diff --git a/tests/read.tests b/tests/read.tests |
||||||
|
index 7384f05..43fcf8d 100644 |
||||||
|
--- a/tests/read.tests |
||||||
|
+++ b/tests/read.tests |
||||||
|
@@ -95,9 +95,6 @@ echo " foo" | { IFS=$':' ; read line; recho "$line"; } |
||||||
|
# test read -d delim behavior |
||||||
|
${THIS_SH} ./read1.sub |
||||||
|
|
||||||
|
-# test read -t timeout behavior |
||||||
|
-${THIS_SH} ./read2.sub |
||||||
|
- |
||||||
|
# test read -n nchars behavior |
||||||
|
${THIS_SH} ./read3.sub |
||||||
|
|
@ -0,0 +1,8 @@ |
|||||||
|
# .bash_profile |
||||||
|
|
||||||
|
# Get the aliases and functions |
||||||
|
if [ -f ~/.bashrc ]; then |
||||||
|
. ~/.bashrc |
||||||
|
fi |
||||||
|
|
||||||
|
# User specific environment and startup programs |
@ -0,0 +1,27 @@ |
|||||||
|
# .bashrc |
||||||
|
|
||||||
|
# Source global definitions |
||||||
|
if [ -f /etc/bashrc ]; then |
||||||
|
. /etc/bashrc |
||||||
|
fi |
||||||
|
|
||||||
|
# User specific environment |
||||||
|
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] |
||||||
|
then |
||||||
|
PATH="$HOME/.local/bin:$HOME/bin:$PATH" |
||||||
|
fi |
||||||
|
export PATH |
||||||
|
|
||||||
|
# Uncomment the following line if you don't like systemctl's auto-paging feature: |
||||||
|
# export SYSTEMD_PAGER= |
||||||
|
|
||||||
|
# User specific aliases and functions |
||||||
|
if [ -d ~/.bashrc.d ]; then |
||||||
|
for rc in ~/.bashrc.d/*; do |
||||||
|
if [ -f "$rc" ]; then |
||||||
|
. "$rc" |
||||||
|
fi |
||||||
|
done |
||||||
|
fi |
||||||
|
|
||||||
|
unset rc |
Loading…
Reference in new issue