]>
cygwin.com Git - cygwin-apps/setup.git/blob - AntiVirus.cc
2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to manage the dialog box that lets the
17 user choose the source of the install - from the net, from the
18 current directory, or to just download files. */
21 static const char * cvsid
=
32 #include "package_db.h"
34 #include "AntiVirus.h"
36 #include "getopt++/BoolOption.h"
38 /* XXX: Split this into observer and model classes */
40 /* Default is to leave well enough alone */
41 static BoolOption
DisableVirusOption ( false , 'D' , "disable-buggy-antivirus" , "Disable known or suspected buggy anti virus software packages during execution." );
43 static bool KnownAVIsPresent
= false ;
44 static bool AVRunning
= true ;
45 static SC_HANDLE SCM
= NULL
;
46 static SC_HANDLE McAfeeService
= NULL
;
50 { IDC_DISABLE_AV
, IDC_LEAVE_AV
, 0 };
52 static int disableAV
= IDC_LEAVE_AV
;
57 rbset ( h
, rb
, disableAV
);
63 disableAV
= rbget ( h
, rb
);
67 dialog_cmd ( HWND h
, int id
, HWND hwndctl
, UINT code
)
84 AntiVirusPage :: Create ()
87 return PropertyPage :: Create ( NULL
, dialog_cmd
, IDD_VIRUS
);
91 AntiVirusPage :: OnActivate ()
93 load_dialog ( GetHWND ());
94 // Check to see if any radio buttons are selected. If not, select a default.
96 ( GetDlgItem ( IDC_DISABLE_AV
), BM_GETCHECK
, 0 ,
98 && (! SendMessage ( GetDlgItem ( IDC_LEAVE_AV
), BM_GETCHECK
, 0 , 0 )
101 SendMessage ( GetDlgItem ( IDC_LEAVE_AV
), BM_SETCHECK
,
108 AntiVirusPage :: OnNext ()
113 /* if disable, do so now */
118 AntiVirusPage :: OnBack ()
120 save_dialog ( GetHWND ());
125 AntiVirusPage :: OnDeactivate ()
127 if (! KnownAVIsPresent
)
129 if ( disableAV
== IDC_LEAVE_AV
)
132 SERVICE_STATUS status
;
133 if (! ControlService ( McAfeeService
, SERVICE_CONTROL_STOP
, & status
) &&
134 GetLastError () != ERROR_SERVICE_NOT_ACTIVE
)
136 log ( LOG_PLAIN
, "Could not stop McAfee service, disabled AV logic \n " );
137 disableAV
= IDC_LEAVE_AV
;
142 log ( LOG_PLAIN
, String ( "Disabled Anti Virus software" ));
146 AntiVirusPage :: OnUnattended ()
148 if (! KnownAVIsPresent
)
150 if (( bool ) DisableVirusOption
)
151 disableAV
= IDC_DISABLE_AV
;
153 disableAV
= IDC_LEAVE_AV
;
160 if ( Win32 :: OS () == Win32 :: Win9x
)
162 // TODO: trim the access rights down
163 SCM
= OpenSCManager ( NULL
, NULL
, SC_MANAGER_ALL_ACCESS
);
166 log ( LOG_PLAIN
, String ( "Could not open Service control manager \n " ));
170 /* in future, factor this to a routine to find service foo (ie norton, older
173 McAfeeService
= OpenService ( SCM
, "AvSynMgr" ,
174 SERVICE_QUERY_STATUS
| SERVICE_STOP
| SERVICE_START
);
176 if (! McAfeeService
) {
177 log ( LOG_PLAIN
, String ( "Could not open service McShield for query, start and stop. McAfee may not be installed, or we don't have access. \n " ));
178 CloseServiceHandle ( SCM
);
182 SERVICE_STATUS status
;
184 if (! QueryServiceStatus ( McAfeeService
, & status
))
186 CloseServiceHandle ( SCM
);
187 CloseServiceHandle ( McAfeeService
);
188 log ( LOG_PLAIN
, String ( "Couldn't determine status of McAfee service. \n " ));
192 if ( status
. dwCurrentState
== SERVICE_STOPPED
||
193 status
. dwCurrentState
== SERVICE_STOP_PENDING
)
195 CloseServiceHandle ( SCM
);
196 CloseServiceHandle ( McAfeeService
);
197 log ( LOG_PLAIN
, "Mcafee is already stopped, nothing to see here \n " );
200 log ( LOG_PLAIN
, "Found McAfee anti virus program \n " );
201 KnownAVIsPresent
= true ;
207 return KnownAVIsPresent
;
213 if (! KnownAVIsPresent
)
215 if ( disableAV
== IDC_LEAVE_AV
)
217 if ( AVRunning
== true )
220 if (! StartService ( McAfeeService
, 0 , NULL
))
222 log ( LOG_PLAIN
, "Could not start McAfee service again, disabled AV logic \n " );
223 disableAV
= IDC_LEAVE_AV
;
227 log ( LOG_PLAIN
, String ( "Enabled Anti Virus software" ));
This page took 0.042874 seconds and 5 git commands to generate.