Skip to content

Commit

Permalink
Merge pull request #76 from cgzones/agent-logr
Browse files Browse the repository at this point in the history
rename global agent struct
  • Loading branch information
ddpbsd committed Feb 24, 2014
2 parents 5904f54 + 274eb97 commit bd74c5b
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 131 deletions.
32 changes: 16 additions & 16 deletions src/client-agent/agentd.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ void AgentdStart(char *dir, int uid, int gid, char *user, char *group)
* and read from it
* Exit if fails.
*/
if((logr->m_queue = StartMQ(DEFAULTQUEUE, READ)) < 0)
if((agt->m_queue = StartMQ(DEFAULTQUEUE, READ)) < 0)
ErrorExit(QUEUE_ERROR, ARGV0, DEFAULTQUEUE, strerror(errno));

maxfd = logr->m_queue;
logr->sock = -1;
maxfd = agt->m_queue;
agt->sock = -1;



/* Creating PID file */
/* Creating PID file */
if(CreatePID(ARGV0, getpid()) < 0)
merror(PID_ERROR,ARGV0);

Expand All @@ -92,7 +92,7 @@ void AgentdStart(char *dir, int uid, int gid, char *user, char *group)
os_write_agent_info(keys.keyentries[0]->name, NULL, keys.keyentries[0]->id);
*/
os_write_agent_info(keys.keyentries[0]->name, NULL, keys.keyentries[0]->id,
logr->profile);
agt->profile);


/* Start up message */
Expand All @@ -111,9 +111,9 @@ void AgentdStart(char *dir, int uid, int gid, char *user, char *group)

/* Connecting UDP */
rc = 0;
while(rc < logr->rip_id)
while(rc < agt->rip_id)
{
verbose("%s: INFO: Server IP Address: %s", ARGV0, logr->rip[rc]);
verbose("%s: INFO: Server IP Address: %s", ARGV0, agt->rip[rc]);
rc++;
}

Expand All @@ -126,20 +126,20 @@ void AgentdStart(char *dir, int uid, int gid, char *user, char *group)


/* Setting max fd for select */
if(logr->sock > maxfd)
if(agt->sock > maxfd)
{
maxfd = logr->sock;
maxfd = agt->sock;
}


/* Connecting to the execd queue */
if(logr->execdq == 0)
if(agt->execdq == 0)
{
if((logr->execdq = StartMQ(EXECQUEUE, WRITE)) < 0)
if((agt->execdq = StartMQ(EXECQUEUE, WRITE)) < 0)
{
merror("%s: INFO: Unable to connect to the active response "
"queue (disabled).", ARGV0);
logr->execdq = -1;
agt->execdq = -1;
}
}

Expand Down Expand Up @@ -171,8 +171,8 @@ void AgentdStart(char *dir, int uid, int gid, char *user, char *group)
{
/* Monitoring all available sockets from here */
FD_ZERO(&fdset);
FD_SET(logr->sock, &fdset);
FD_SET(logr->m_queue, &fdset);
FD_SET(agt->sock, &fdset);
FD_SET(agt->m_queue, &fdset);

fdtimeout.tv_sec = 1;
fdtimeout.tv_usec = 0;
Expand All @@ -195,14 +195,14 @@ void AgentdStart(char *dir, int uid, int gid, char *user, char *group)


/* For the receiver */
if(FD_ISSET(logr->sock, &fdset))
if(FD_ISSET(agt->sock, &fdset))
{
receive_msg();
}


/* For the forwarder */
if(FD_ISSET(logr->m_queue, &fdset))
if(FD_ISSET(agt->m_queue, &fdset))
{
EventForward();
}
Expand Down
2 changes: 1 addition & 1 deletion src/client-agent/agentd.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void run_notify();
int available_server;
int run_foreground;
keystore keys;
agent *logr;
agent *agt;


#endif
Expand Down
14 changes: 7 additions & 7 deletions src/client-agent/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
int ClientConf(char *cfgfile)
{
int modules = 0;
logr->port = DEFAULT_SECURE;
logr->rip = NULL;
logr->lip = NULL;
logr->rip_id = 0;
logr->execdq = 0;
logr->profile = NULL; /*cmoraes*/
agt->port = DEFAULT_SECURE;
agt->rip = NULL;
agt->lip = NULL;
agt->rip_id = 0;
agt->execdq = 0;
agt->profile = NULL; /*cmoraes*/

modules|= CCLIENT;

if(ReadConfig(modules, cfgfile, logr, NULL) < 0)
if(ReadConfig(modules, cfgfile, agt, NULL) < 0)
{
return(OS_INVALID);
}
Expand Down
2 changes: 1 addition & 1 deletion src/client-agent/event-forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void *EventForward()
msg[OS_MAXSTR] = '\0';


while((recv_b = recv(logr->m_queue, msg, OS_MAXSTR, MSG_DONTWAIT)) > 0)
while((recv_b = recv(agt->m_queue, msg, OS_MAXSTR, MSG_DONTWAIT)) > 0)
{
msg[recv_b] = '\0';

Expand Down
28 changes: 14 additions & 14 deletions src/client-agent/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv)
if(!optarg)
ErrorExit("%s: -g needs an argument",ARGV0);
group = optarg;
break;
break;
case 't':
test_config = 1;
break;
Expand All @@ -90,15 +90,15 @@ int main(int argc, char **argv)

debug1(STARTED_MSG, ARGV0);

logr = (agent *)calloc(1, sizeof(agent));
if(!logr)
agt = (agent *)calloc(1, sizeof(agent));
if(!agt)
{
ErrorExit(MEM_ERROR, ARGV0);
}


/* Check current debug_level
* Command line setting takes precedence
* Command line setting takes precedence
*/
if (debug_level == 0)
{
Expand All @@ -118,26 +118,26 @@ int main(int argc, char **argv)
ErrorExit(CLIENT_ERROR,ARGV0);
}

if(!logr->rip)
if(!agt->rip)
{
merror(AG_INV_IP, ARGV0);
ErrorExit(CLIENT_ERROR,ARGV0);
}

if(logr->notify_time == 0)
if(agt->notify_time == 0)
{
logr->notify_time = NOTIFY_TIME;
agt->notify_time = NOTIFY_TIME;
}
if(logr->max_time_reconnect_try == 0 )
if(agt->max_time_reconnect_try == 0 )
{
logr->max_time_reconnect_try = NOTIFY_TIME * 3;
agt->max_time_reconnect_try = NOTIFY_TIME * 3;
}
if(logr->max_time_reconnect_try <= logr->notify_time)
if(agt->max_time_reconnect_try <= agt->notify_time)
{
logr->max_time_reconnect_try = (logr->notify_time * 3);
verbose("%s: INFO: Max time to reconnect can't be less than notify_time(%d), using notify_time*3 (%d)",ARGV0,logr->notify_time,logr->max_time_reconnect_try);
agt->max_time_reconnect_try = (agt->notify_time * 3);
verbose("%s: INFO: Max time to reconnect can't be less than notify_time(%d), using notify_time*3 (%d)",ARGV0,agt->notify_time,agt->max_time_reconnect_try);
}
verbose("%s: INFO: Using notify time: %d and max time to reconnect: %d",ARGV0,logr->notify_time,logr->max_time_reconnect_try);
verbose("%s: INFO: Using notify time: %d and max time to reconnect: %d",ARGV0,agt->notify_time,agt->max_time_reconnect_try);


/* Checking auth keys */
Expand All @@ -163,7 +163,7 @@ int main(int argc, char **argv)


/* Starting the signal manipulation */
StartSIG(ARGV0);
StartSIG(ARGV0);


/* Agentd Start */
Expand Down
4 changes: 2 additions & 2 deletions src/client-agent/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void run_notify()

#ifndef ONEWAY
/* Check if the server has responded */
if((curr_time - available_server) > logr->max_time_reconnect_try)
if((curr_time - available_server) > agt->max_time_reconnect_try)
{
/* If response is not available, set lock and
* wait for it.
Expand All @@ -108,7 +108,7 @@ void run_notify()


/* Check if time has elapsed */
if((curr_time - g_saved_time) < logr->notify_time)
if((curr_time - g_saved_time) < agt->notify_time)
{
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/client-agent/receiver-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ void *receiver_thread(void *none)
while(1)
{
/* sock must be set. */
if(logr->sock == -1)
if(agt->sock == -1)
{
sleep(5);
continue;
}

FD_ZERO(&fdset);
FD_SET(logr->sock, &fdset);
FD_SET(agt->sock, &fdset);


/* Wait for 30 seconds. */
Expand All @@ -82,13 +82,13 @@ void *receiver_thread(void *none)
}

/* Read until no more messages are available */
while((recv_b = recv(logr->sock,buffer,OS_SIZE_1024, 0))>0)
while((recv_b = recv(agt->sock,buffer,OS_SIZE_1024, 0))>0)
{
/* Id of zero -- only one key allowed */
tmp_msg = ReadSecMSG(&keys, buffer, cleartext, 0, recv_b -1);
if(tmp_msg == NULL)
{
merror(MSG_ERROR,ARGV0,logr->rip[logr->rip_id]);
merror(MSG_ERROR,ARGV0,agt->rip[agt->rip_id]);
continue;
}

Expand All @@ -101,7 +101,7 @@ void *receiver_thread(void *none)


/* Run timeout commands. */
if(logr->execdq >= 0)
if(agt->execdq >= 0)
WinTimeoutRun(available_server);

/* If it is an active response message */
Expand All @@ -111,7 +111,7 @@ void *receiver_thread(void *none)


/* Run on windows. */
if(logr->execdq >= 0)
if(agt->execdq >= 0)
{
WinExecdRun(tmp_msg);
}
Expand Down
12 changes: 6 additions & 6 deletions src/client-agent/receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ void *receive_msg()


/* Read until no more messages are available */
while((recv_b = recv(logr->sock, buffer, OS_SIZE_1024, MSG_DONTWAIT)) > 0)
while((recv_b = recv(agt->sock, buffer, OS_SIZE_1024, MSG_DONTWAIT)) > 0)
{
buffer[recv_b] = '\0';

tmp_msg = ReadSecMSG(&keys, buffer, cleartext, 0, recv_b -1);
if(tmp_msg == NULL)
{
merror(MSG_ERROR,ARGV0,logr->rip[logr->rip_id]);
merror(MSG_ERROR,ARGV0,agt->rip[agt->rip_id]);
continue;
}

Expand All @@ -69,7 +69,7 @@ void *receive_msg()

#ifdef WIN32
/* Run timeout commands. */
if(logr->execdq >= 0)
if(agt->execdq >= 0)
WinTimeoutRun(available_server);
#endif

Expand All @@ -80,9 +80,9 @@ void *receive_msg()
tmp_msg+=strlen(EXECD_HEADER);

#ifndef WIN32
if(logr->execdq >= 0)
if(agt->execdq >= 0)
{
if(OS_SendUnix(logr->execdq, tmp_msg, 0) < 0)
if(OS_SendUnix(agt->execdq, tmp_msg, 0) < 0)
{
merror("%s: Error communicating with execd",
ARGV0);
Expand All @@ -93,7 +93,7 @@ void *receive_msg()


/* Run on windows. */
if(logr->execdq >= 0)
if(agt->execdq >= 0)
{
WinExecdRun(tmp_msg);
}
Expand Down
2 changes: 1 addition & 1 deletion src/client-agent/sendmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int send_msg(int agentid, char *msg)
}

/* Send msg_size of crypt_msg */
if(OS_SendUDPbySize(logr->sock, msg_size, crypt_msg) < 0)
if(OS_SendUDPbySize(agt->sock, msg_size, crypt_msg) < 0)
{
merror(SEND_ERROR,ARGV0, "server");
sleep(1);
Expand Down

0 comments on commit bd74c5b

Please sign in to comment.