[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ossec-cvs] ossec-hids: main.c (HEAD) manage_agents.c (HEAD) manage_agents.h (HEAD) manage_keys.c (HEAD) [dcid]



Module name:	ossec-hids
Changes by:	dcid	07/07/19 21:17:06

Modified files:
	main.c manage_agents.c manage_agents.h manage_keys.c

Log message:
Description: Adding a restart message after adding/removing an agent.
Reviewed by: dcid
Bug: 49 - http://www.ossec.net/bugs/show_bug.cgi?id=49

Index: main.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/addagent/main.c,v
diff -u -r1.9 -r1.10
--- main.c	9 Feb 2007 02:51:43 -0000	1.9
+++ main.c	20 Jul 2007 00:17:06 -0000	1.10
@@ -29,6 +29,24 @@
 }
 
 
+/* Clean shutdown on kill */
+void manage_shutdown()
+{
+    /* Checking if restart message is necessary */
+    if(restart_necessary)
+    {
+        printf(MUST_RESTART);
+    }
+    else
+    {
+        printf("\n");
+    }
+    printf(EXIT);
+
+    exit(0);
+}
+
+
 /** main **/
 int main(int argc, char **argv)
 {
@@ -41,6 +59,7 @@
     #endif
     
     if(argv[argc -1]){}    
+    
 
     /* Setting the name */
     OS_SetName(ARGV0);
@@ -48,6 +67,8 @@
    
     /* Getting currently time */
     time1 = time(0);
+    restart_necessary = 0;
+    
     
     #ifndef WIN32 
     /* Getting the group name */
@@ -74,12 +95,17 @@
 
     /* Inside chroot now */
     nowChroot();
-    
+
+
+    /* Starting signal handler */
+    StartSIG2(ARGV0, manage_shutdown);
     #endif
 
+
     /* Little shell */
     while(1)
     {
+        int leave_s = 0;
         print_banner();
    
         user_msg = read_from_user();
@@ -109,19 +135,36 @@
                 break;
             case 'q':
             case 'Q':
-                printf(EXIT);
-                exit(0);    
-	    case 'V':
-		print_version();   
-		break;
+                leave_s = 1;
+                break;
+	        case 'V':
+		        print_version();   
+		        break;
             default:    
                 printf("\n ** Invalid Action ** \n\n");
                 break;            
         }
 
+        if(leave_s)
+        {
+            break;       
+        }
+        
         continue;
         
     }
+
+    /* Checking if restart message is necessary */
+    if(restart_necessary)
+    {
+        printf(MUST_RESTART);
+    }
+    else
+    {
+        printf("\n");
+    }
+    printf(EXIT);
+    
     return(0);
 }
 

Index: manage_agents.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/addagent/manage_agents.c,v
diff -u -r1.24 -r1.25
--- manage_agents.c	2 Jun 2007 23:13:48 -0000	1.24
+++ manage_agents.c	20 Jul 2007 00:17:06 -0000	1.25
@@ -1,12 +1,15 @@
 /* @(#) $Id$ */
 
-/* Copyright (C) 2003-2006 Daniel B. Cid <dcid@xxxxxxxxx>
+/* Copyright (C) 2003-2007 Daniel B. Cid <dcid@xxxxxxxxx>
  * All rights reserved.
  *
  * This program is a free software; you can redistribute it
  * and/or modify it under the terms of the GNU General Public
- * License (version 2) as published by the FSF - Free Software
- * Foundation
+ * License (version 3) as published by the FSF - Free Software
+ * Foundation.
+ *
+ * License details at the LICENSE file included with OSSEC or 
+ * online at: http://www.ossec.net/en/licensing.html
  */
 
 
@@ -269,6 +272,7 @@
         fclose(fp);
 
         printf(AGENT_ADD);
+        restart_necessary = 1;
         break;
       }
       else if(user_input[0] == 'n' || user_input[0] == 'N')
@@ -351,6 +355,7 @@
 
 
             printf(REMOVE_DONE, u_id);
+            restart_necessary = 1;
             break;
         }
         else if(user_input[0] == 'n' || user_input[0] == 'N')

Index: manage_agents.h
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/addagent/manage_agents.h,v
diff -u -r1.14 -r1.15
--- manage_agents.h	2 Jun 2007 23:13:48 -0000	1.14
+++ manage_agents.h	20 Jul 2007 00:17:06 -0000	1.15
@@ -1,12 +1,15 @@
 /* @(#) $Id$ */
 
-/* Copyright (C) 2003-2006 Daniel B. Cid <dcid@xxxxxxxxx>
+/* Copyright (C) 2003-2007 Daniel B. Cid <dcid@xxxxxxxxx>
  * All rights reserved.
  *
  * This program is a free software; you can redistribute it
  * and/or modify it under the terms of the GNU General Public
- * License (version 2) as published by the FSF - Free Software
- * Foundation
+ * License (version 3) as published by the FSF - Free Software
+ * Foundation.
+ *
+ * License details at the LICENSE file included with OSSEC or 
+ * online at: http://www.ossec.net/en/licensing.html
  */
 
 
@@ -44,6 +47,7 @@
 
 
 /* Shared variables */
+int restart_necessary;
 int time1;
 int time2;
 int time3;
@@ -78,6 +82,8 @@
 #define ADDED           "Added.\n"
 #define ADD_NOT         "Not Adding ..\n"
 #define PRESS_ENTER     "** Press ENTER to return to the main menu.\n"
+#define MUST_RESTART    "\n** You must restart the server for your changes" \
+                        " to have effect.\n\n"
 
 /* Add errors */
 #define ADD_ERROR_ID    "\n** ID '%s' already present. They must be unique.\n\n"
@@ -110,8 +116,8 @@
 /* Commom errors */
 #define ERROR_KEYS      "Unable to handle keys file. Exiting.\n"
 #define EXTRACT_ERROR   "Unable to extract agent key.\n"
-#define INPUT_LARGE     ARGV0": Input too large. Not adding it.\n"
-#define EXIT            "\n" ARGV0 ": Exiting ..\n"
+#define INPUT_LARGE     ARGV0 ": Input too large. Not adding it.\n"
+#define EXIT            ARGV0 ": Exiting ..\n"
 
 #define BANNER          "\n****************************************" \
                         "\n* %s %s Agent manager.       *" \

Index: manage_keys.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/addagent/manage_keys.c,v
diff -u -r1.12 -r1.13
--- manage_keys.c	6 Sep 2006 12:46:59 -0000	1.12
+++ manage_keys.c	20 Jul 2007 00:17:06 -0000	1.13
@@ -1,16 +1,18 @@
 /* @(#) $Id$ */
 
-/* Copyright (C) 2003-2006 Daniel B. Cid <dcid@xxxxxxxxx>
+/* Copyright (C) 2003-2007 Daniel B. Cid <dcid@xxxxxxxxx>
  * All rights reserved.
  *
  * This program is a free software; you can redistribute it
  * and/or modify it under the terms of the GNU General Public
- * License (version 2) as published by the FSF - Free Software
- * Foundation
+ * License (version 3) as published by the FSF - Free Software
+ * Foundation.
+ *
+ * License details at the LICENSE file included with OSSEC or 
+ * online at: http://www.ossec.net/en/licensing.html
  */
 
 
-
 #include "manage_agents.h"
 
 
@@ -96,6 +98,7 @@
                     printf(ADDED);
                     printf(PRESS_ENTER);
                     read_from_user();
+                    restart_necessary = 1;
                     return(1);
                 }
                 else if(user_input[0] == 'n' || user_input[0] == 'N')


OSSEC home | Main Index | Thread Index


OSSEC project: www.ossec.net.
Mailling list information: http://www.ossec.net/en/mailing_lists.html.