mirror of https://github.com/RT-Thread/rt-thread
fix msh exec permission denied (#7943)
This commit is contained in:
parent
0bd93292b3
commit
93388f8045
|
@ -11,6 +11,7 @@
|
||||||
*/
|
*/
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef RT_USING_FINSH
|
#ifdef RT_USING_FINSH
|
||||||
|
|
||||||
|
@ -483,7 +484,7 @@ found_program:
|
||||||
|
|
||||||
int msh_exec(char *cmd, rt_size_t length)
|
int msh_exec(char *cmd, rt_size_t length)
|
||||||
{
|
{
|
||||||
int cmd_ret;
|
int cmd_ret = 0;
|
||||||
|
|
||||||
/* strim the beginning of command */
|
/* strim the beginning of command */
|
||||||
while ((length > 0) && (*cmd == ' ' || *cmd == '\t'))
|
while ((length > 0) && (*cmd == ' ' || *cmd == '\t'))
|
||||||
|
@ -521,7 +522,8 @@ int msh_exec(char *cmd, rt_size_t length)
|
||||||
#ifdef RT_USING_SMART
|
#ifdef RT_USING_SMART
|
||||||
/* exec from msh_exec , debug = 0*/
|
/* exec from msh_exec , debug = 0*/
|
||||||
/* _msh_exec_lwp return is pid , <= 0 means failed */
|
/* _msh_exec_lwp return is pid , <= 0 means failed */
|
||||||
if (_msh_exec_lwp(0, cmd, length) > 0)
|
cmd_ret = _msh_exec_lwp(0, cmd, length);
|
||||||
|
if (cmd_ret > 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -538,7 +540,16 @@ int msh_exec(char *cmd, rt_size_t length)
|
||||||
}
|
}
|
||||||
*tcmd = '\0';
|
*tcmd = '\0';
|
||||||
}
|
}
|
||||||
rt_kprintf("%s: command not found.\n", cmd);
|
#ifdef RT_USING_SMART
|
||||||
|
if (cmd_ret == -EACCES)
|
||||||
|
{
|
||||||
|
rt_kprintf("%s: Permission denied.\n", cmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
rt_kprintf("%s: command not found.\n", cmd);
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue