mirror of
https://github.com/sheumann/hush.git
synced 2025-01-03 00:31:16 +00:00
+ busybox --install [-s]
is functional (but disabled in busybox.def.h by default) Someone email the guy who originally wanted this.
This commit is contained in:
parent
d0edef3cbe
commit
7cdc76dfbf
@ -376,6 +376,31 @@ static char* install_dir[] = {
|
|||||||
/* abstract link() */
|
/* abstract link() */
|
||||||
typedef int (*__link_f)(const char *, const char *);
|
typedef int (*__link_f)(const char *, const char *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Where in the filesystem is this busybox?
|
||||||
|
* [return]
|
||||||
|
* malloc'd string w/ full pathname of busybox's location
|
||||||
|
* NULL on failure
|
||||||
|
*/
|
||||||
|
static char *busybox_fullpath()
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
char path[256];
|
||||||
|
char proc[256];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
sprintf(proc, "/proc/%d/exe", pid);
|
||||||
|
len = readlink(proc, path, 256);
|
||||||
|
if (len != -1) {
|
||||||
|
path[len] = 0;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return strdup(path);
|
||||||
|
}
|
||||||
|
|
||||||
/* create (sym)links for each applet */
|
/* create (sym)links for each applet */
|
||||||
static int install_links(const char *busybox, int use_symbolic_links)
|
static int install_links(const char *busybox, int use_symbolic_links)
|
||||||
{
|
{
|
||||||
@ -394,14 +419,13 @@ static int install_links(const char *busybox, int use_symbolic_links)
|
|||||||
install_dir[applets[i].location],
|
install_dir[applets[i].location],
|
||||||
applets[i].name
|
applets[i].name
|
||||||
);
|
);
|
||||||
#if 0
|
#if 1
|
||||||
rc |= Link(busybox, command);
|
rc |= Link(busybox, command);
|
||||||
#else
|
#else
|
||||||
puts(command);
|
puts(command);
|
||||||
#endif
|
#endif
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
|
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@ -427,6 +451,8 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||||
int use_symbolic_links = 0;
|
int use_symbolic_links = 0;
|
||||||
|
int rc = 0;
|
||||||
|
char *busybox;
|
||||||
|
|
||||||
/* to use symlinks, or not to use symlinks... */
|
/* to use symlinks, or not to use symlinks... */
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
@ -434,13 +460,16 @@ int main(int argc, char **argv)
|
|||||||
use_symbolic_links = 1;
|
use_symbolic_links = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* FIXME :
|
/* link */
|
||||||
* I need a clever unix trick that'll tell
|
busybox = busybox_fullpath();
|
||||||
* me where to find the currently running
|
if (busybox) {
|
||||||
* busybox binary
|
install_links(busybox, use_symbolic_links);
|
||||||
*/
|
free(busybox);
|
||||||
return install_links("/bin/busybox", use_symbolic_links);
|
} else {
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
#endif /* BB_FEATURE_INSTALLER */
|
#endif /* BB_FEATURE_INSTALLER */
|
||||||
|
|
||||||
|
47
busybox.c
47
busybox.c
@ -376,6 +376,31 @@ static char* install_dir[] = {
|
|||||||
/* abstract link() */
|
/* abstract link() */
|
||||||
typedef int (*__link_f)(const char *, const char *);
|
typedef int (*__link_f)(const char *, const char *);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Where in the filesystem is this busybox?
|
||||||
|
* [return]
|
||||||
|
* malloc'd string w/ full pathname of busybox's location
|
||||||
|
* NULL on failure
|
||||||
|
*/
|
||||||
|
static char *busybox_fullpath()
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
char path[256];
|
||||||
|
char proc[256];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
pid = getpid();
|
||||||
|
sprintf(proc, "/proc/%d/exe", pid);
|
||||||
|
len = readlink(proc, path, 256);
|
||||||
|
if (len != -1) {
|
||||||
|
path[len] = 0;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return strdup(path);
|
||||||
|
}
|
||||||
|
|
||||||
/* create (sym)links for each applet */
|
/* create (sym)links for each applet */
|
||||||
static int install_links(const char *busybox, int use_symbolic_links)
|
static int install_links(const char *busybox, int use_symbolic_links)
|
||||||
{
|
{
|
||||||
@ -394,14 +419,13 @@ static int install_links(const char *busybox, int use_symbolic_links)
|
|||||||
install_dir[applets[i].location],
|
install_dir[applets[i].location],
|
||||||
applets[i].name
|
applets[i].name
|
||||||
);
|
);
|
||||||
#if 0
|
#if 1
|
||||||
rc |= Link(busybox, command);
|
rc |= Link(busybox, command);
|
||||||
#else
|
#else
|
||||||
puts(command);
|
puts(command);
|
||||||
#endif
|
#endif
|
||||||
if (rc) {
|
if (rc) {
|
||||||
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
|
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
@ -427,6 +451,8 @@ int main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||||
int use_symbolic_links = 0;
|
int use_symbolic_links = 0;
|
||||||
|
int rc = 0;
|
||||||
|
char *busybox;
|
||||||
|
|
||||||
/* to use symlinks, or not to use symlinks... */
|
/* to use symlinks, or not to use symlinks... */
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
@ -434,13 +460,16 @@ int main(int argc, char **argv)
|
|||||||
use_symbolic_links = 1;
|
use_symbolic_links = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* FIXME :
|
/* link */
|
||||||
* I need a clever unix trick that'll tell
|
busybox = busybox_fullpath();
|
||||||
* me where to find the currently running
|
if (busybox) {
|
||||||
* busybox binary
|
install_links(busybox, use_symbolic_links);
|
||||||
*/
|
free(busybox);
|
||||||
return install_links("/bin/busybox", use_symbolic_links);
|
} else {
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
#endif /* BB_FEATURE_INSTALLER */
|
#endif /* BB_FEATURE_INSTALLER */
|
||||||
|
|
||||||
|
@ -232,8 +232,8 @@
|
|||||||
//
|
//
|
||||||
// Enable busybox --install [-s]
|
// Enable busybox --install [-s]
|
||||||
// to create links (or symlinks) for all the commands that are
|
// to create links (or symlinks) for all the commands that are
|
||||||
// compiled into the binary.
|
// compiled into the binary. (needs /proc filesystem)
|
||||||
#define BB_FEATURE_INSTALLER
|
// #define BB_FEATURE_INSTALLER
|
||||||
//
|
//
|
||||||
// End of Features List
|
// End of Features List
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user