new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / win32 / setup-win.c
1 /* Copyright (C) 2009 Trend Micro Inc.
2  * All rights reserved.
3  *
4  * This program is a free software; you can redistribute it
5  * and/or modify it under the terms of the GNU General Public
6  * License (version 2) as published by the FSF - Free Software
7  * Foundation
8  */
9
10 #include "setup-shared.h"
11
12
13 /* Set up Windows after installation */
14 int main(int argc, char **argv)
15 {
16     /* Set the name */
17     OS_SetName(ARGV0);
18
19     if (argc < 2) {
20         printf("%s: Invalid syntax.\n", argv[0]);
21         printf("Try: '%s directory'\n\n", argv[0]);
22         return (0);
23     }
24
25     /* Try to chdir to the OSSEC directory */
26     if (chdir(argv[1]) != 0) {
27         printf("%s: Invalid directory: '%s'.\n", argv[0], argv[1]);
28         return (0);
29     }
30
31     /* Configure OSSEC for automatic startup */
32     system("sc config OssecSvc start= auto");
33
34     /* Change permissions */
35     checkVista();
36
37     if (isVista) {
38         char cmd[OS_MAXSTR + 1];
39
40         /* Copy some files to outside */
41         snprintf(cmd, OS_MAXSTR, "move os_win32ui.exe ../");
42         system(cmd);
43
44         snprintf(cmd, OS_MAXSTR, "move win32ui.exe ../");
45         system(cmd);
46
47         snprintf(cmd, OS_MAXSTR, "move uninstall.exe ../");
48         system(cmd);
49
50         snprintf(cmd, OS_MAXSTR, "move doc.html ../");
51         system(cmd);
52
53         snprintf(cmd, OS_MAXSTR, "move help.txt ../");
54         system(cmd);
55
56         /* Change permissions */
57         system("echo y|icacls * /T \"*S-1-5-32-544:F\" ");
58
59         /* Copy them back */
60         snprintf(cmd, OS_MAXSTR, "move ..\\os_win32ui.exe .");
61         system(cmd);
62
63         snprintf(cmd, OS_MAXSTR, "move ..\\win32ui.exe .");
64         system(cmd);
65
66         snprintf(cmd, OS_MAXSTR, "move ..\\uninstall.exe .");
67         system(cmd);
68
69         snprintf(cmd, OS_MAXSTR, "move ..\\doc.html .");
70         system(cmd);
71
72         snprintf(cmd, OS_MAXSTR, "move ..\\help.txt .");
73         system(cmd);
74     } else {
75         system("echo y|icacls . /T /G  \"*S-1-5-32-544:F\" ");
76     }
77
78     return (1);
79 }