Hello corosync users,
I've spent some time building and trying corosync 2.3.0 on SunOS
(Joyent's SmartOS-based VM), and noticed one issue with uidgid {}
configuration blocks parsing, e.g.:
uidgid {
uid: user|uid
gid: group|gid
}
Corosync won't display any errors in case of non-existent username/uid
or groupname/gid in configuration, and then we'll get something like
that:
# corosync-cmapctl uidgid
uidgid.gid.4096 (u8) = 1
uidgid.uid.4292862832 (u8) = 1
I'm attaching the patch that fixes this issue by performing additional
checks according to the following POSIX documents:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwnam_r.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrnam_r.html
[..]
A null pointer is returned at the location pointed to by result on error or if
the requested entry is not found.
[..]
Hope this would be helpful for someone.
Best regards,
Andrei.
--- exec/coroparse.c.orig 2013-03-28 10:42:56.587115379 +0000
+++ exec/coroparse.c 2013-03-28 11:28:27.494982161 +0000
@@ -130,7 +130,7 @@
struct passwd* pwdptr = &passwd;
struct passwd* temp_pwd_pt;
char *pwdbuffer;
- int pwdlinelen;
+ int pwdlinelen, rc;
pwdlinelen = sysconf (_SC_GETPW_R_SIZE_MAX);
@@ -140,7 +140,12 @@
pwdbuffer = malloc (pwdlinelen);
- if ((getpwnam_r (req_user, pwdptr, pwdbuffer, pwdlinelen,
&temp_pwd_pt)) != 0) {
+ rc = getpwnam_r (req_user, pwdptr, pwdbuffer, pwdlinelen, &temp_pwd_pt);
+ if (rc != 0) {
+ sprintf (error_string_response, "getpwnam_r(): %s",
strerror(rc));
+ return (-1);
+ }
+ if (temp_pwd_pt == NULL) {
sprintf (error_string_response,
"The '%s' user is not found in /etc/passwd, please read
the documentation.",
req_user);
@@ -159,7 +164,7 @@
struct group * grpptr = &group;
struct group * temp_grp_pt;
char *grpbuffer;
- int grplinelen;
+ int grplinelen, rc;
grplinelen = sysconf (_SC_GETGR_R_SIZE_MAX);
@@ -169,7 +174,12 @@
grpbuffer = malloc (grplinelen);
- if ((getgrnam_r (req_group, grpptr, grpbuffer, grplinelen,
&temp_grp_pt)) != 0) {
+ rc = getgrnam_r (req_group, grpptr, grpbuffer, grplinelen,
&temp_grp_pt);
+ if (rc != 0) {
+ sprintf (error_string_response, "getgrnam_r(): %s",
strerror(rc));
+ return (-1);
+ }
+ if (temp_grp_pt == NULL) {
sprintf (error_string_response,
"The '%s' group is not found in /etc/group, please read
the documentation.",
req_group);
_______________________________________________
discuss mailing list
[email protected]
http://lists.corosync.org/mailman/listinfo/discuss