From 0b284c12350847cf2db54a89f2c58f024673b855 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 17 Apr 2010 23:55:00 +0000 Subject: [PATCH] Mac Installer: AddRemoveUser utility accepts both full / login user names and short / Posix user names svn path=/trunk/boinc/; revision=21201 --- checkin_notes | 7 +++++++ mac_installer/AddRemoveUser.cpp | 30 ++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/checkin_notes b/checkin_notes index d666b2c849..ea6c94a250 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2892,3 +2892,10 @@ Charlie 16 Apr 2010 make_GridRepublic.sh make_ProgThruProc.sh release_boinc.sh + +Charlie 17 Apr 2010 + - Mac Installer: AddRemoveUser utility accepts both full / login user + names and short / Posix user names. + + mac_installer/ + AddRemoveUser.cpp diff --git a/mac_installer/AddRemoveUser.cpp b/mac_installer/AddRemoveUser.cpp index 85bb56cd47..3743899628 100644 --- a/mac_installer/AddRemoveUser.cpp +++ b/mac_installer/AddRemoveUser.cpp @@ -90,6 +90,8 @@ int main(int argc, char *argv[]) } for (index=2; indexpw_gecos) + // or the short / Posix name (pw->pw_name) pw = getpwnam(argv[index]); if (pw == NULL) { printf("User %s not found.\n", argv[index]); @@ -99,7 +101,7 @@ int main(int argc, char *argv[]) isBMGroupMember = false; i = 0; while ((p = grpBOINC_master.gr_mem[i]) != NULL) { // Step through all users in group boinc_master - if (strcmp(p, argv[index]) == 0) { + if (strcmp(p, pw->pw_name) == 0) { // Only the short / Posix names are in the list // User is a member of group boinc_master isBMGroupMember = true; break; @@ -110,7 +112,7 @@ int main(int argc, char *argv[]) isBPGroupMember = false; i = 0; while ((p = grpBOINC_project.gr_mem[i]) != NULL) { // Step through all users in group boinc_project - if (strcmp(p, argv[index]) == 0) { + if (strcmp(p, pw->pw_name) == 0) { // Only the short / Posix names are in the list // User is a member of group boinc_master isBPGroupMember = true; break; @@ -119,22 +121,22 @@ int main(int argc, char *argv[]) } if ((!isBMGroupMember) && AddUsers) { - sprintf(s, "dscl . -merge /groups/boinc_master users %s", argv[index]); + sprintf(s, "dscl . -merge /groups/boinc_master users %s", pw->pw_name); system(s); } if ((!isBPGroupMember) && AddUsers) { - sprintf(s, "dscl . -merge /groups/boinc_project users %s", argv[index]); + sprintf(s, "dscl . -merge /groups/boinc_project users %s", pw->pw_name); system(s); } if (isBMGroupMember && (!AddUsers)) { - sprintf(s, "dscl . -delete /Groups/boinc_master GroupMembership %s", argv[index]); + sprintf(s, "dscl . -delete /Groups/boinc_master GroupMembership %s", pw->pw_name); system(s); } if (isBPGroupMember && (!AddUsers)) { - sprintf(s, "dscl . -delete /Groups/boinc_project GroupMembership %s", argv[index]); + sprintf(s, "dscl . -delete /Groups/boinc_project GroupMembership %s", pw->pw_name); system(s); } @@ -145,10 +147,10 @@ int main(int argc, char *argv[]) if (OSVersion < 0x1060) { sprintf(s, "sudo -u %s defaults -currentHost read com.apple.screensaver moduleName", - argv[index]); + pw->pw_name); } else { sprintf(s, "sudo -u %s defaults -currentHost read com.apple.screensaver moduleDict -dict", - argv[index]); + pw->pw_name); } f = popen(s, "r"); @@ -166,14 +168,14 @@ int main(int argc, char *argv[]) if ((!saverIsSet) && SetSavers) { if (OSVersion < 0x1060) { sprintf(s, "sudo -u %s defaults -currentHost write com.apple.screensaver moduleName BOINCSaver", - argv[index]); + pw->pw_name); system(s); sprintf(s, "sudo -u %s defaults -currentHost write com.apple.screensaver modulePath \"/Library/Screen Savers/BOINCSaver.saver\"", - argv[index]); + pw->pw_name); system(s); } else { sprintf(s, "sudo -u %s defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName BOINCSaver path \"/Library/Screen Savers/BOINCSaver.saver\"", - argv[index]); + pw->pw_name); system(s); } } @@ -181,14 +183,14 @@ int main(int argc, char *argv[]) if (saverIsSet && (!AddUsers)) { if (OSVersion < 0x1060) { sprintf(s, "sudo -u %s defaults -currentHost write com.apple.screensaver moduleName Flurry", - argv[index]); + pw->pw_name); system(s); sprintf(s, "sudo -u %s defaults -currentHost write com.apple.screensaver modulePath \"/System/Library/Screen Savers/Flurry.saver\"", - argv[index]); + pw->pw_name); system(s); } else { sprintf(s, "sudo -u %s defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Flurry path \"/System/Library/Screen Savers/Flurry.saver\"", - argv[index]); + pw->pw_name); system(s); } }