cee17abc8c313c3c731172442abf7cf409ae0340
[ossec-hids.git] / src / win32 / setup-win.c
1 /* @(#) $Id$ */
2
3 /* Copyright (C) 2009 Trend Micro Inc.
4  * All rights reserved.
5  *
6  * This program is a free software; you can redistribute it
7  * and/or modify it under the terms of the GNU General Public
8  * License (version 2) as published by the FSF - Free Software
9  * Foundation
10  */
11        
12
13 #include "setup-shared.h"
14
15
16 /* Setup windows after install */
17 int main(int argc, char **argv)
18 {
19     if(argc < 2)
20     {
21         printf("%s: Invalid syntax.\n", argv[0]);
22         printf("Try: '%s directory'\n\n", argv[0]);
23         return(0);
24     }
25     
26     /* Trying to chdir to ossec directory. */
27     if(chdir(argv[1]) != 0)
28     {
29         printf("%s: Invalid directory: '%s'.\n", argv[0], argv[1]);
30         return(0);
31     }
32     
33     /* Checking if ossec was installed already (upgrade) */
34     if(!fileexist(OSSECCONF))
35     {
36         char cmd[OS_MAXSTR +1];
37         
38         /* Copy default config to ossec.conf */
39         snprintf(cmd, OS_MAXSTR, "copy %s %s", OSSECDEF, OSSECCONF);
40         system(cmd);
41     }
42
43
44     /* Setting up local files */
45     system("add-localfile.exe \"C:\\Windows\\pfirewall.log\" --quiet");
46     system("add-localfile.exe \"C:\\Documents and Settings\\All Users\\Application Data\\Symantec\\Symantec AntiVirus Corporate Edition\\7.5\\Logs\\\%m\%d20\%y.log\" --quiet");
47     
48
49     /* Configure ossec for automatic startup */
50     system("sc config OssecSvc start= auto");
51
52
53     /* Changing permissions. */
54     checkVista();
55
56     
57     if(isVista)
58     {
59         char cmd[OS_MAXSTR +1];
60
61         /* Copy some files to outside */
62         snprintf(cmd, OS_MAXSTR, "move os_win32ui.exe ../");
63         system(cmd);
64
65         snprintf(cmd, OS_MAXSTR, "move win32ui.exe ../");
66         system(cmd);
67
68         snprintf(cmd, OS_MAXSTR, "move uninstall.exe ../");
69         system(cmd);
70
71         snprintf(cmd, OS_MAXSTR, "move doc.html ../");
72         system(cmd);
73
74         snprintf(cmd, OS_MAXSTR, "move help.txt ../");
75         system(cmd);
76
77
78         /* Changing permissions. */
79         system("echo y|cacls * /T /G Administrators:f ");
80
81         
82         /* Copying them back. */
83         snprintf(cmd, OS_MAXSTR, "move ..\\os_win32ui.exe .");
84         system(cmd);
85
86         snprintf(cmd, OS_MAXSTR, "move ..\\win32ui.exe .");
87         system(cmd);
88
89         snprintf(cmd, OS_MAXSTR, "move ..\\uninstall.exe .");
90         system(cmd);
91
92         snprintf(cmd, OS_MAXSTR, "move ..\\doc.html .");
93         system(cmd);
94
95         snprintf(cmd, OS_MAXSTR, "move ..\\help.txt .");
96         system(cmd);
97     }
98     else
99     {
100         system("echo y|cacls . /T /G Administrators:f ");
101     }
102
103     return(0);
104 }