1 /* @(#) $Id: ./src/client-agent/main.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
13 /* Part of the OSSEC HIDS
14 * Available at http://www.ossec.net
26 #define ARGV0 "ossec-agentd"
33 /* main, v0.2, 2005/11/09
35 int main(int argc, char **argv)
40 char *dir = DEFAULTDIR;
42 char *group = GROUPGLOBAL;
48 /* Setting the name */
52 while((c = getopt(argc, argv, "Vtdhu:g:D:")) != -1){
65 ErrorExit("%s: -u needs an argument",ARGV0);
70 ErrorExit("%s: -g needs an argument",ARGV0);
78 ErrorExit("%s: -D needs an argument",ARGV0);
84 debug1(STARTED_MSG, ARGV0);
86 logr = (agent *)calloc(1, sizeof(agent));
89 ErrorExit(MEM_ERROR, ARGV0);
94 if(ClientConf(DEFAULTCPATH) < 0)
96 ErrorExit(CLIENT_ERROR,ARGV0);
101 merror(AG_INV_IP, ARGV0);
102 ErrorExit(CLIENT_ERROR,ARGV0);
106 /* Checking auth keys */
109 ErrorExit(AG_NOKEYS_EXIT, ARGV0);
113 /* Check if the user/group given are valid */
114 uid = Privsep_GetUser(user);
115 gid = Privsep_GetGroup(group);
116 if((uid < 0)||(gid < 0))
118 ErrorExit(USER_ERROR,ARGV0,user,group);
123 /* Exit if test config */
128 /* Starting the signal manipulation */
133 AgentdStart(dir, uid, gid, user, group);