Skip to content

Commit

Permalink
Mac installer: When checking for duplicate group membership entries, …
Browse files Browse the repository at this point in the history
…count only whole words

svn path=/trunk/boinc/; revision=25506
  • Loading branch information
Charlie Fenton committed Mar 29, 2012
1 parent fb20906 commit 9268bde
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -3129,3 +3129,11 @@ David 27 Mar 2012
vda.cpp
vdad.cpp
sched_vda.cpp

Charlie 29 Mar 2012
- Mac installer: When checking for duplicate group membership entries,
count only whole words (preceded and followed by white space) so
that if we have both 'jon' and 'jones' we don't count 'jon' twice.

mac_installer/
PostInstall.cpp
10 changes: 7 additions & 3 deletions mac_installer/PostInstall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ int CountGroupMembershipEntries(const char *userName, const char *groupName) {
int count = 0;
char cmd[512], buf[2048];
FILE *f;
char *p;
char *p, *q;

// getgrnam(groupName)->gr_mem[] only returns one entry, so we must use dscl
sprintf(cmd, "dscl . -read /Groups/%s GroupMembership", groupName);
Expand All @@ -1085,9 +1085,13 @@ int CountGroupMembershipEntries(const char *userName, const char *groupName) {
while (p) {
p = strstr(p, userName);
if (p) {
++ count;
q = p-1;
p += strlen(userName);

// Count only whole words (preceded and followed by white space) so
// that if we have both 'jon' and 'jones' we don't count 'jon' twice
if (isspace(*q) && isspace(*p)) {
++ count;
}
}
}
}
Expand Down

0 comments on commit 9268bde

Please sign in to comment.