-
Notifications
You must be signed in to change notification settings - Fork 35
/
StartupScripts.m
executable file
·77 lines (61 loc) · 1.97 KB
/
StartupScripts.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// StartupScripts.m
// KnockKnock
//
// Notes: OS scripts that are exec'd as OS X boot/starts/logs such as /etc/rc.* and /etc/launchd.conf
// normally these scripts shouldn't exist, or are whitelisted - so any deviations, just show file
#import "File.h"
#import "Utilities.h"
#import "StartupScripts.h"
//plugin name
#define PLUGIN_NAME @"Startup Scripts"
//plugin description
#define PLUGIN_DESCRIPTION NSLocalizedString(@"scripts executed during OS startup", @"scripts executed during OS startup")
//plugin icon
#define PLUGIN_ICON @"startupScriptsIcon"
//plugin search directories
NSString* const STARTUP_SCRIPTS_SEARCH_FILES[] = {@"/etc/rc.cleanup", @"/etc/rc.common", @"/etc/rc.installer_cleanup", @"/etc/rc.server", @"/etc/launchd.conf"};
@implementation StartupScripts
//init
// ->set name, description, etc
-(id)init
{
//super
self = [super init];
if(self)
{
//set name
self.name = PLUGIN_NAME;
//set description
self.description = PLUGIN_DESCRIPTION;
//set icon
self.icon = PLUGIN_ICON;
}
return self;
}
//scan for startup scripts
// ->any that exist are reported (though known ones are whitelisted)
-(void)scan
{
//File obj
File* fileObj = nil;
//iterate over all script directories
// ->get all script files and process them
for(NSUInteger i=0; i<sizeof(STARTUP_SCRIPTS_SEARCH_FILES)/sizeof(STARTUP_SCRIPTS_SEARCH_FILES[0]); i++)
{
//create File object for each file
// ->note these generally shouldn't exist (on default install)
fileObj = [[File alloc] initWithParams:@{KEY_RESULT_PLUGIN:self, KEY_RESULT_PATH:STARTUP_SCRIPTS_SEARCH_FILES[i]}];
//skip File objects that err'd out for any reason
if(nil == fileObj)
{
//skip
continue;
}
//process item
// ->save and report to UI
[super processItem:fileObj];
}
return;
}
@end