pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/33220: bash builtins cannot access bash symbols
>Number: 33220
>Category: pkg
>Synopsis: bash builtins cannot access bash symbols
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Apr 08 18:30:00 +0000 2006
>Originator: Tavis Ormandy
>Release: NetBSD 2.1.0_STABLE
>Organization:
none
>Environment:
NetBSD sdf 2.1.0_STABLE NetBSD 2.1.0_STABLE (sdf) #0: Tue Mar 14 07:50:31 UTC
2006 root@sverige:/var/src/src/sys/arch/alpha/compile/sdf alpha
>Description:
The bash shell allows you to write builtins and store them in a shared object,
which are then loaded using the enable command. On NetBSD, this doesnt work as
symbols that bash exports, such as make_builtin_argv() and last_pid_created are
not available. This works on three linux systems I tested.
>How-To-Repeat:
#include <stdio.h>
#include <stdlib.h>
/* This file is also available here http://dev.gentoo.org/~taviso/builtin.c if
the formatting does not survive
* $ gcc -shared -o builtin.so builtin.c
* $ enable -f ./builtin.so btest
* $ btest
* bash: enable: cannot open shared object ./builtin.so: ./builtin.so:
Undefined symbol "make_builtin_argv" (symnum = 21)
*/
typedef struct word_desc { char *word; int flags;} WORD_DESC;
typedef struct word_list { struct word_list *next; WORD_DESC *word;} WORD_LIST;
typedef int sh_builtin_func_t (WORD_LIST *);
int btest(WORD_LIST *list);
char **make_builtin_argv (WORD_LIST *list, int *argc);
struct builtin {
char *name;
sh_builtin_func_t *function;
int flags;
char * const *doc;
const char *shortdoc;
char *handle;
};
char *btestusage[] = { "btest prints hello and exits", 0x00 };
struct builtin btest_struct = { "btest", btest, 1, btestusage, "btest", 0x00 };
int btest(WORD_LIST *list){
int argc;
char **argv;
if (!(argv = (char **) make_builtin_argv (list, &argc)))
return 1;
fprintf(stdout, "hello from %s\n", argv[0]);
free(argv);
return 42;
}
>Fix:
Home |
Main Index |
Thread Index |
Old Index