[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Please review patch to make acl build for GNU/Hurd



Patch attached. Maybe I should use __GNU__ instead of __GLIBC__ in order
not to change behavior for GNU/Linux? (And I will change #if defined to
#ifdef in the final patch).

Thanks,
Svante

--- acl-2.2.51/setfacl/parse.c.orig	2010-01-22 23:00:28.000000000 +0000
+++ acl-2.2.51/setfacl/parse.c	2011-08-02 17:26:32.000000000 +0000
@@ -419,7 +419,13 @@
 	  bytes for "# file: ". Not a good solution but for now it is the
 	  best I can do without too much impact on the code. [tw]
 	*/
+
+#if defined(__GLIBC__)
+	char *linebuf;
+	size_t dummy = 0;
+#else
 	char linebuf[(4*PATH_MAX)+9];
+#endif
 	char *cp;
 	char *p;
 	int comments_read = 0;
@@ -449,9 +455,13 @@
 		if (line)
 			(*line)++;
 
+#if defined(__GLIBC__)
+		if (getline(&linebuf, &dummy, file) == -1)
+			break;
+#else
 		if (fgets(linebuf, sizeof(linebuf), file) == NULL)
 			break;
-		
+#endif		
 		comments_read = 1;
 
 		p = strrchr(linebuf, '\0');
@@ -473,7 +483,12 @@
 					goto fail;
 				*path_p = (char*)malloc(strlen(cp)+1);
 				if (!*path_p)
+				  {
+#if defined(__GLIBC__)
+				    free (linebuf);
+#endif
 					return -1;
+				  }
 				strcpy(*path_p, cp);
 			}
 		} else if (strncmp(cp, "owner:", 6) == 0) {
@@ -522,13 +537,24 @@
 		}
 	}
 	if (ferror(file))
+	  {
+#if defined(__GLIBC__)
+	    free (linebuf);
+#endif
 		return -1;
+	  }
+#if defined(__GLIBC__)
+	free (linebuf);
+#endif
 	return comments_read;
 fail:
 	if (path_p && *path_p) {
 		free(*path_p);
 		*path_p = NULL;
 	}
+#if defined(__GLIBC__)
+	free (linebuf);
+#endif
 	return -EINVAL;
 }
 

Reply to: