mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-26 23:33:08 +02:00
commit bash-20120120 snapshot
This commit is contained in:
@@ -13115,3 +13115,47 @@ bashline.c
|
||||
executable_or_directory; change command_word_completion_function to
|
||||
call executable_completion. This allows $HOME/bin/[TAB] to do
|
||||
command completion and display alternatives
|
||||
|
||||
1/17
|
||||
----
|
||||
pcomplete.c
|
||||
- gen_command_matches: now takes a new second argument: the command
|
||||
name as deciphered by the programmable completion code and used
|
||||
to look up the compspec; changed callers (gen_compspec_completions)
|
||||
- gen_shell_function_matches: now takes a new second argument: the
|
||||
command that originally caused the completion function to be
|
||||
invoked; changed callers (gen_compspec_completions))
|
||||
- build_arg_list: now takes a new second argument: the command name
|
||||
corresponding to the current compspec; changed callers
|
||||
(gen_command_matches, gen_shell_function_matches)
|
||||
- build_arg_list: now uses `cmd' argument to create $1 passed to
|
||||
invoked command or shell function
|
||||
- gen_compspec_completions: if we skipped a null command at the
|
||||
beginning of the line (e.g., for completing `>'), add a new word for
|
||||
it at the beginning of the word list and increment nw and cw
|
||||
appropriately. This is all a partial fix for the shortcoming
|
||||
pointed out by Sung Pae <sungpae@gmail.com>
|
||||
|
||||
1/18
|
||||
----
|
||||
|
||||
{configure,config.h}.in
|
||||
- new check: check for AUDIT_USER_TTY defined in <linux/audit.h>,
|
||||
define HAVE_DECL_AUDIT_USER_TTY if both are found
|
||||
|
||||
lib/readline/rlconf.h
|
||||
- ENABLE_TTY_AUDIT_SUPPORT: new define, allows use of the Linux kernel
|
||||
tty auditing system if it's available and enabled
|
||||
|
||||
lib/readline/util.c
|
||||
- _rl_audit_tty: new function, send a string to the kernel tty audit
|
||||
system
|
||||
|
||||
lib/readline/rlprivate.h
|
||||
- _rl_audit_tty: new extern declaration
|
||||
|
||||
lib/readline/readline.c
|
||||
- readline: call _rl_audit_tty with line to be returned before returning
|
||||
it if the Linux tty audit system is available and it's been enabled
|
||||
in rlconf.h Original patch from Miroslav Trmac; recent request
|
||||
from Miroslav Lichvar <mlichvar@redhat.com>
|
||||
|
||||
+14
-1
@@ -1,5 +1,5 @@
|
||||
@%:@! /bin/sh
|
||||
@%:@ From configure.in for Bash 4.2, version 4.044.
|
||||
@%:@ From configure.in for Bash 4.2, version 4.045.
|
||||
@%:@ Guess values for system-dependent variables and create Makefiles.
|
||||
@%:@ Generated by GNU Autoconf 2.68 for bash 4.2-maint.
|
||||
@%:@
|
||||
@@ -9868,6 +9868,19 @@ fi
|
||||
|
||||
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "AUDIT_USER_TTY" "ac_cv_have_decl_AUDIT_USER_TTY" "#include <linux/audit.h>
|
||||
"
|
||||
if test "x$ac_cv_have_decl_AUDIT_USER_TTY" = xyes; then :
|
||||
ac_have_decl=1
|
||||
else
|
||||
ac_have_decl=0
|
||||
fi
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@%:@define HAVE_DECL_AUDIT_USER_TTY $ac_have_decl
|
||||
_ACEOF
|
||||
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "confstr" "ac_cv_have_decl_confstr" "$ac_includes_default"
|
||||
if test "x$ac_cv_have_decl_confstr" = xyes; then :
|
||||
ac_have_decl=1
|
||||
|
||||
+728
-723
File diff suppressed because it is too large
Load Diff
@@ -428,6 +428,9 @@
|
||||
|
||||
#undef HAVE_LIBC_FNM_EXTMATCH
|
||||
|
||||
/* Define if you have <linux/audit.h> and it defines AUDIT_USER_TTY */
|
||||
#undef HAVE_DECL_AUDIT_USER_TTY
|
||||
|
||||
#undef HAVE_DECL_CONFSTR
|
||||
|
||||
#undef HAVE_DECL_PRINTF
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
# From configure.in for Bash 4.2, version 4.044.
|
||||
# From configure.in for Bash 4.2, version 4.045.
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.68 for bash 4.2-maint.
|
||||
#
|
||||
@@ -9868,6 +9868,19 @@ fi
|
||||
|
||||
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "AUDIT_USER_TTY" "ac_cv_have_decl_AUDIT_USER_TTY" "#include <linux/audit.h>
|
||||
"
|
||||
if test "x$ac_cv_have_decl_AUDIT_USER_TTY" = xyes; then :
|
||||
ac_have_decl=1
|
||||
else
|
||||
ac_have_decl=0
|
||||
fi
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_DECL_AUDIT_USER_TTY $ac_have_decl
|
||||
_ACEOF
|
||||
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "confstr" "ac_cv_have_decl_confstr" "$ac_includes_default"
|
||||
if test "x$ac_cv_have_decl_confstr" = xyes; then :
|
||||
ac_have_decl=1
|
||||
|
||||
+3
-1
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_REVISION([for Bash 4.2, version 4.044])dnl
|
||||
AC_REVISION([for Bash 4.2, version 4.045])dnl
|
||||
|
||||
define(bashvers, 4.2)
|
||||
define(relstatus, maint)
|
||||
@@ -757,6 +757,8 @@ AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax)
|
||||
AC_REPLACE_FUNCS(dprintf)
|
||||
AC_REPLACE_FUNCS(strchrnul)
|
||||
|
||||
AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include <linux/audit.h>]])
|
||||
|
||||
AC_CHECK_DECLS([confstr])
|
||||
AC_CHECK_DECLS([printf])
|
||||
AC_CHECK_DECLS([sbrk])
|
||||
|
||||
@@ -366,6 +366,11 @@ readline (prompt)
|
||||
RL_SETSTATE (RL_STATE_CALLBACK);
|
||||
#endif
|
||||
|
||||
#if HAVE_DECL_AUDIT_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT)
|
||||
if (value)
|
||||
_rl_audit_tty (value);
|
||||
#endif
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
@@ -885,6 +890,14 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NOTYET
|
||||
/* Tentative inter-character timeout for potential multi-key
|
||||
sequences? If no input within timeout, abort sequence and
|
||||
act as if we got non-matching input. */
|
||||
if (_rl_input_queued (500000) == 0)
|
||||
return (_rl_subseq_result (-2, map, key, got_subseq));
|
||||
#endif
|
||||
|
||||
newkey = _rl_subseq_getchar (key);
|
||||
if (newkey < 0)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
@@ -366,6 +366,11 @@ readline (prompt)
|
||||
RL_SETSTATE (RL_STATE_CALLBACK);
|
||||
#endif
|
||||
|
||||
#if HAVE_DECL_AUDIT_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT)
|
||||
if (value)
|
||||
_rl_audit_tty (value);
|
||||
#endif
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
@@ -885,6 +890,12 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Tentative inter-character timeout for potential multi-key
|
||||
sequences? If no input within timeout, abort sequence and
|
||||
act as if we got non-matching input. */
|
||||
if (_rl_input_queued (500000) == 0)
|
||||
return (_rl_subseq_result (-2, map, key, got_subseq));
|
||||
|
||||
newkey = _rl_subseq_getchar (key);
|
||||
if (newkey < 0)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define COLOR_SUPPORT
|
||||
|
||||
/* This definition is needed by readline.c, rltty.c, and signals.c. */
|
||||
/* If on, then readline handles signals in a way that doesn't screw. */
|
||||
/* If on, then readline handles signals in a way that doesn't suck. */
|
||||
#define HANDLE_SIGNALS
|
||||
|
||||
/* Ugly but working hack for binding prefix meta. */
|
||||
@@ -62,4 +62,8 @@
|
||||
/* Define this if you want the cursor to indicate insert or overwrite mode. */
|
||||
/* #define CURSOR_MODE */
|
||||
|
||||
/* Define this if you want to enable code that talks to the Linux kernel
|
||||
tty auditing system. */
|
||||
#define ENABLE_TTY_AUDIT_SUPPORT
|
||||
|
||||
#endif /* _RLCONF_H_ */
|
||||
|
||||
@@ -383,6 +383,7 @@ extern void _rl_ttymsg ();
|
||||
extern void _rl_errmsg ();
|
||||
extern void _rl_trace ();
|
||||
#endif
|
||||
extern void _rl_audit_tty PARAMS((char *));
|
||||
|
||||
extern int _rl_tropen PARAMS((void));
|
||||
|
||||
|
||||
@@ -530,3 +530,51 @@ _rl_settracefp (fp)
|
||||
_rl_tracefp = fp;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if HAVE_DECL_AUDIT_USER_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT)
|
||||
|
||||
/* Report STRING to the audit system. */
|
||||
void
|
||||
_rl_audit_tty (string)
|
||||
char *string;
|
||||
{
|
||||
struct sockaddr_nl addr;
|
||||
struct msghdr msg;
|
||||
struct nlmsghdr nlm;
|
||||
struct iovec iov[2];
|
||||
size_t size;
|
||||
int fd;
|
||||
|
||||
fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
|
||||
if (fd < 0)
|
||||
return;
|
||||
size = strlen (string) + 1;
|
||||
|
||||
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_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
|
||||
|
||||
+31
-16
@@ -1,6 +1,6 @@
|
||||
/* pcomplete.c - functions to generate lists of matches for programmable completion. */
|
||||
|
||||
/* Copyright (C) 1999-2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999-2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -122,10 +122,13 @@ static STRINGLIST *gen_action_completions __P((COMPSPEC *, const char *));
|
||||
static STRINGLIST *gen_globpat_matches __P((COMPSPEC *, const char *));
|
||||
static STRINGLIST *gen_wordlist_matches __P((COMPSPEC *, const char *));
|
||||
static STRINGLIST *gen_shell_function_matches __P((COMPSPEC *, const char *,
|
||||
const char *,
|
||||
char *, int, WORD_LIST *,
|
||||
int, int, int *));
|
||||
static STRINGLIST *gen_command_matches __P((COMPSPEC *, const char *, char *,
|
||||
int, WORD_LIST *, int, int));
|
||||
static STRINGLIST *gen_command_matches __P((COMPSPEC *, const char *,
|
||||
const char *,
|
||||
char *, int, WORD_LIST *,
|
||||
int, int));
|
||||
|
||||
static STRINGLIST *gen_progcomp_completions __P((const char *, const char *,
|
||||
const char *,
|
||||
@@ -139,7 +142,7 @@ static SHELL_VAR *bind_comp_words __P((WORD_LIST *));
|
||||
#endif
|
||||
static void bind_compfunc_variables __P((char *, int, WORD_LIST *, int, int));
|
||||
static void unbind_compfunc_variables __P((int));
|
||||
static WORD_LIST *build_arg_list __P((char *, const char *, WORD_LIST *, int));
|
||||
static WORD_LIST *build_arg_list __P((char *, const char *, const char *, WORD_LIST *, int));
|
||||
static WORD_LIST *command_line_to_word_list __P((char *, int, int, int *, int *));
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -1000,8 +1003,9 @@ unbind_compfunc_variables (exported)
|
||||
make do with the COMP_LINE and COMP_POINT variables. */
|
||||
|
||||
static WORD_LIST *
|
||||
build_arg_list (cmd, text, lwords, ind)
|
||||
build_arg_list (cmd, cname, text, lwords, ind)
|
||||
char *cmd;
|
||||
const char *cname;
|
||||
const char *text;
|
||||
WORD_LIST *lwords;
|
||||
int ind;
|
||||
@@ -1012,13 +1016,13 @@ build_arg_list (cmd, text, lwords, ind)
|
||||
|
||||
ret = (WORD_LIST *)NULL;
|
||||
w = make_word (cmd);
|
||||
ret = make_word_list (w, (WORD_LIST *)NULL);
|
||||
ret = make_word_list (w, (WORD_LIST *)NULL); /* $0 */
|
||||
|
||||
w = (lwords && lwords->word) ? copy_word (lwords->word) : make_word ("");
|
||||
w = make_word (cname); /* $1 */
|
||||
cl = ret->next = make_word_list (w, (WORD_LIST *)NULL);
|
||||
|
||||
w = make_word (text);
|
||||
cl->next = make_word_list (w, (WORD_LIST *)NULL);
|
||||
cl->next = make_word_list (w, (WORD_LIST *)NULL); /* $2 */
|
||||
cl = cl->next;
|
||||
|
||||
/* Search lwords for current word */
|
||||
@@ -1043,8 +1047,9 @@ build_arg_list (cmd, text, lwords, ind)
|
||||
variable, this does nothing if arrays are not compiled into the shell. */
|
||||
|
||||
static STRINGLIST *
|
||||
gen_shell_function_matches (cs, text, line, ind, lwords, nw, cw, foundp)
|
||||
gen_shell_function_matches (cs, cmd, text, line, ind, lwords, nw, cw, foundp)
|
||||
COMPSPEC *cs;
|
||||
const char *cmd;
|
||||
const char *text;
|
||||
char *line;
|
||||
int ind;
|
||||
@@ -1085,7 +1090,7 @@ gen_shell_function_matches (cs, text, line, ind, lwords, nw, cw, foundp)
|
||||
1-based, while bash arrays are 0-based. */
|
||||
bind_compfunc_variables (line, ind, lwords, cw - 1, 0);
|
||||
|
||||
cmdlist = build_arg_list (funcname, text, lwords, cw);
|
||||
cmdlist = build_arg_list (funcname, cmd, text, lwords, cw);
|
||||
|
||||
pps = &ps;
|
||||
save_parser_state (pps);
|
||||
@@ -1147,8 +1152,9 @@ gen_shell_function_matches (cs, text, line, ind, lwords, nw, cw, foundp)
|
||||
STRINGLIST from the results and return it. */
|
||||
|
||||
static STRINGLIST *
|
||||
gen_command_matches (cs, text, line, ind, lwords, nw, cw)
|
||||
gen_command_matches (cs, cmd, text, line, ind, lwords, nw, cw)
|
||||
COMPSPEC *cs;
|
||||
const char *cmd;
|
||||
const char *text;
|
||||
char *line;
|
||||
int ind;
|
||||
@@ -1162,7 +1168,7 @@ gen_command_matches (cs, text, line, ind, lwords, nw, cw)
|
||||
STRINGLIST *sl;
|
||||
|
||||
bind_compfunc_variables (line, ind, lwords, cw, 1);
|
||||
cmdlist = build_arg_list (cs->command, text, lwords, cw);
|
||||
cmdlist = build_arg_list (cs->command, cmd, text, lwords, cw);
|
||||
|
||||
/* Estimate the size needed for the buffer. */
|
||||
n = strlen (cs->command);
|
||||
@@ -1262,6 +1268,7 @@ gen_compspec_completions (cs, cmd, word, start, end, foundp)
|
||||
char *line;
|
||||
int llen, nw, cw, found, foundf;
|
||||
WORD_LIST *lwords;
|
||||
WORD_DESC *lw;
|
||||
COMPSPEC *tcs;
|
||||
|
||||
found = 1;
|
||||
@@ -1333,6 +1340,14 @@ gen_compspec_completions (cs, cmd, word, start, end, foundp)
|
||||
line, llen, rl_point - start, &nw, &cw);
|
||||
#endif
|
||||
lwords = command_line_to_word_list (line, llen, rl_point - start, &nw, &cw);
|
||||
/* If we skipped a NULL word at the beginning of the line, add it back */
|
||||
if (lwords && lwords->word && cmd[0] == 0 && lwords->word->word[0] != 0)
|
||||
{
|
||||
lw = make_bare_word (cmd);
|
||||
lwords = make_word_list (lw, lwords);
|
||||
nw++;
|
||||
cw++;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (lwords == 0 && llen > 0)
|
||||
debug_printf ("ERROR: command_line_to_word_list returns NULL");
|
||||
@@ -1351,7 +1366,7 @@ gen_compspec_completions (cs, cmd, word, start, end, foundp)
|
||||
if (cs->funcname)
|
||||
{
|
||||
foundf = 0;
|
||||
tmatches = gen_shell_function_matches (cs, word, line, rl_point - start, lwords, nw, cw, &foundf);
|
||||
tmatches = gen_shell_function_matches (cs, cmd, word, line, rl_point - start, lwords, nw, cw, &foundf);
|
||||
if (foundf != 0)
|
||||
found = foundf;
|
||||
if (tmatches)
|
||||
@@ -1359,7 +1374,7 @@ gen_compspec_completions (cs, cmd, word, start, end, foundp)
|
||||
#ifdef DEBUG
|
||||
if (progcomp_debug)
|
||||
{
|
||||
debug_printf ("gen_shell_function_matches (%p, %s, %p, %d, %d) -->", cs, word, lwords, nw, cw);
|
||||
debug_printf ("gen_shell_function_matches (%p, %s, %s, %p, %d, %d) -->", cs, cmd, word, lwords, nw, cw);
|
||||
strlist_print (tmatches, "\t");
|
||||
rl_on_new_line ();
|
||||
}
|
||||
@@ -1371,13 +1386,13 @@ gen_compspec_completions (cs, cmd, word, start, end, foundp)
|
||||
|
||||
if (cs->command)
|
||||
{
|
||||
tmatches = gen_command_matches (cs, word, line, rl_point - start, lwords, nw, cw);
|
||||
tmatches = gen_command_matches (cs, cmd, word, line, rl_point - start, lwords, nw, cw);
|
||||
if (tmatches)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (progcomp_debug)
|
||||
{
|
||||
debug_printf ("gen_command_matches (%p, %s, %p, %d, %d) -->", cs, word, lwords, nw, cw);
|
||||
debug_printf ("gen_command_matches (%p, %s, %s, %p, %d, %d) -->", cs, cmd, word, lwords, nw, cw);
|
||||
strlist_print (tmatches, "\t");
|
||||
rl_on_new_line ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user