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