when invoked as 'busybox foo args' remove the "busybox"
so ps shows only what we want it to show...
This commit is contained in:
parent
f3b2b52b58
commit
5e09b6e3a8
@ -126,8 +126,6 @@ int main(int argc, char **argv)
|
|||||||
applet_name = s;
|
applet_name = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
*argv = (char*)applet_name;
|
|
||||||
|
|
||||||
#ifdef BB_SH
|
#ifdef BB_SH
|
||||||
/* Add in a special case hack -- whenever **argv == '-'
|
/* Add in a special case hack -- whenever **argv == '-'
|
||||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||||
@ -153,10 +151,12 @@ int main(int argc, char **argv)
|
|||||||
int busybox_main(int argc, char **argv)
|
int busybox_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
int ps_index;
|
||||||
|
char *index, *index2;
|
||||||
|
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
|
||||||
|
|
||||||
|
/* If we've already been here once, exit now */
|
||||||
if (been_there_done_that == 1 || argc < 1) {
|
if (been_there_done_that == 1 || argc < 1) {
|
||||||
const struct BB_applet *a = applets;
|
const struct BB_applet *a = applets;
|
||||||
|
|
||||||
@ -181,8 +181,29 @@ int busybox_main(int argc, char **argv)
|
|||||||
fprintf(stderr, "\n\n");
|
fprintf(stderr, "\n\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
/* If we've already been here once, exit now */
|
|
||||||
|
/* Flag that we've been here already */
|
||||||
been_there_done_that = 1;
|
been_there_done_that = 1;
|
||||||
|
|
||||||
|
/* We do not want the word "busybox" to show up in ps, so we move
|
||||||
|
* everything in argv around to fake ps into showing what we want it to
|
||||||
|
* show. Since we are only shrinking the string, we don't need to move
|
||||||
|
* __environ or any of that tedious stuff... */
|
||||||
|
ps_index = 0;
|
||||||
|
index=*argv;
|
||||||
|
index2=argv[argc];
|
||||||
|
index2+=strlen(argv[argc]);
|
||||||
|
while(ps_index < argc) {
|
||||||
|
argv[ps_index]=index;
|
||||||
|
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||||
|
index+=(strlen(index));
|
||||||
|
*index='\0';
|
||||||
|
index++;
|
||||||
|
ps_index++;
|
||||||
|
}
|
||||||
|
while(index<=index2)
|
||||||
|
*index++='\0';
|
||||||
|
|
||||||
return (main(argc, argv));
|
return (main(argc, argv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
busybox.c
29
busybox.c
@ -126,8 +126,6 @@ int main(int argc, char **argv)
|
|||||||
applet_name = s;
|
applet_name = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
*argv = (char*)applet_name;
|
|
||||||
|
|
||||||
#ifdef BB_SH
|
#ifdef BB_SH
|
||||||
/* Add in a special case hack -- whenever **argv == '-'
|
/* Add in a special case hack -- whenever **argv == '-'
|
||||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||||
@ -153,10 +151,12 @@ int main(int argc, char **argv)
|
|||||||
int busybox_main(int argc, char **argv)
|
int busybox_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
int ps_index;
|
||||||
|
char *index, *index2;
|
||||||
|
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
|
||||||
|
|
||||||
|
/* If we've already been here once, exit now */
|
||||||
if (been_there_done_that == 1 || argc < 1) {
|
if (been_there_done_that == 1 || argc < 1) {
|
||||||
const struct BB_applet *a = applets;
|
const struct BB_applet *a = applets;
|
||||||
|
|
||||||
@ -181,8 +181,29 @@ int busybox_main(int argc, char **argv)
|
|||||||
fprintf(stderr, "\n\n");
|
fprintf(stderr, "\n\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
/* If we've already been here once, exit now */
|
|
||||||
|
/* Flag that we've been here already */
|
||||||
been_there_done_that = 1;
|
been_there_done_that = 1;
|
||||||
|
|
||||||
|
/* We do not want the word "busybox" to show up in ps, so we move
|
||||||
|
* everything in argv around to fake ps into showing what we want it to
|
||||||
|
* show. Since we are only shrinking the string, we don't need to move
|
||||||
|
* __environ or any of that tedious stuff... */
|
||||||
|
ps_index = 0;
|
||||||
|
index=*argv;
|
||||||
|
index2=argv[argc];
|
||||||
|
index2+=strlen(argv[argc]);
|
||||||
|
while(ps_index < argc) {
|
||||||
|
argv[ps_index]=index;
|
||||||
|
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||||
|
index+=(strlen(index));
|
||||||
|
*index='\0';
|
||||||
|
index++;
|
||||||
|
ps_index++;
|
||||||
|
}
|
||||||
|
while(index<=index2)
|
||||||
|
*index++='\0';
|
||||||
|
|
||||||
return (main(argc, argv));
|
return (main(argc, argv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user