-/* @(#) $Id$ */
+/* @(#) $Id: ./src/util/syscheck_update.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
/** help **/
void helpmsg()
{
- printf("\nOSSEC HIDS %s: Updates the integrity check database.\n", ARGV0);
+ printf("\nOSSEC HIDS %s: Updates (clears) the integrity check database.\n", ARGV0);
printf("Available options:\n");
printf("\t-h This help message.\n");
printf("\t-l List available agents.\n");
- printf("\t-a Update syscheck database for all agents.\n");
- printf("\t-u <id> Update syscheck database for a specific agent.\n");
- printf("\t-u local Update syscheck database locally.\n\n");
+ printf("\t-a Update (clear) syscheck database for all agents.\n");
+ printf("\t-u <id> Update (clear) syscheck database for a specific agent.\n");
+ printf("\t-u local Update (clear) syscheck database locally.\n\n");
exit(1);
}
-
/** main **/
int main(int argc, char **argv)
{
char *user = USER;
int gid;
int uid;
-
+
/* Setting the name */
OS_SetName(ARGV0);
-
-
+
+
/* user arguments */
if(argc < 2)
{
helpmsg();
}
-
+
/* Getting the group name */
gid = Privsep_GetGroup(group);
uid = Privsep_GetUser(user);
ErrorExit(USER_ERROR, ARGV0, user, group);
}
-
+
/* Setting the group */
if(Privsep_SetGroup(gid) < 0)
{
ErrorExit(SETGID_ERROR,ARGV0, group);
}
-
-
+
+
/* Chrooting to the default directory */
if(Privsep_Chroot(dir) < 0)
{
/* Inside chroot now */
nowChroot();
-
+
/* Setting the user */
if(Privsep_SetUser(uid) < 0)
{
ErrorExit(SETUID_ERROR, ARGV0, user);
}
-
+
/* User options */
if(strcmp(argv[1], "-h") == 0)
{
}
else if(strcmp(argv[1], "-l") == 0)
{
- printf("\nOSSEC HIDS %s: Updates the integrity check database.",
+ printf("\nOSSEC HIDS %s: Updates the integrity check database.",
ARGV0);
print_agents(0, 0, 0);
printf("\n");
}
snprintf(full_path, OS_MAXSTR,"%s/%s", SYSCHECK_DIR, entry->d_name);
-
+
fp = fopen(full_path, "w");
if(fp)
{
}
closedir(sys_dir);
- printf("\n** Integrity check database updated.\n\n");
+ printf("\n** Integrity check database updated.\n\n");
exit(0);
}
else
helpmsg();
}
-
+
/* local */
if(strcmp(argv[2],"local") == 0)
{
char final_dir[1024];
FILE *fp;
snprintf(final_dir, 1020, "/%s/syscheck", SYSCHECK_DIR);
-
+
fp = fopen(final_dir, "w");
if(fp)
{
/* Deleting cpt file */
snprintf(final_dir, 1020, "/%s/.syscheck.cpt", SYSCHECK_DIR);
-
+
fp = fopen(final_dir, "w");
if(fp)
{
printf("\n** Invalid agent id '%s'.\n", argv[2]);
helpmsg();
}
-
+
/* Deleting syscheck */
delete_syscheck(keys.keyentries[i]->name,keys.keyentries[i]->ip->ip,0);
}
-
- printf("\n** Integrity check database updated.\n\n");
+
+ printf("\n** Integrity check database updated.\n\n");
return(0);
}