1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2016 University of California
4 //
5 // BOINC is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License
7 // as published by the Free Software Foundation,
8 // either version 3 of the License, or (at your option) any later version.
9 //
10 // BOINC is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 // See the GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
17 
18 // Standalone utility to set up BOINC security owners, groups, permissions
19 // usage:
20 // first cd to the dir3ctory containing BOINCManager.app (usually /Applications)
21 // then run this application from Terminal
22 //
23 
24 //  SecurityUtility.cpp
25 
26 #include <sys/param.h>  // for MAXPATHLEN
27 #include <unistd.h>     // for getwd, getlogin
28 
29 #include <Carbon/Carbon.h>
30 
31 #include "SetupSecurity.h"
32 
main(int argc,char * argv[])33 int main(int argc, char *argv[]) {
34     OSStatus            err;
35     char boincPath[MAXPATHLEN];
36 
37     err = CreateBOINCUsersAndGroups();
38     if (err != noErr)
39         return err;
40 
41     err = AddAdminUserToGroups(getlogin());
42     if (err != noErr)
43         return err;
44 
45     boincPath[0] = 0;
46     getwd(boincPath);
47     //ShowSecurityError("Current Working Directory is %s", wd);
48 
49     strlcat(boincPath, "/BOINCManager.app", sizeof(boincPath));
50     err = SetBOINCAppOwnersGroupsAndPermissions(boincPath);
51     if (err != noErr)
52         return err;
53 
54     err = SetBOINCDataOwnersGroupsAndPermissions();
55     return err;
56 }
57 
58