--- agent/agent.h.orig
+++ agent/agent.h
@@ -35,6 +35,30 @@
 #include "../common/sysutils.h" /* (gnupg_fd_t) */
 #include "../common/session-env.h"
 
+
+/* strndup is not available on 10.6 and below, define a compat version here. */
+/* shameless copy from libiberty. */
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+
+static inline char *strndup (const char *s, size_t n) {
+  char *result;
+  size_t len = strlen (s);
+
+  if (n < len)
+    len = n;
+
+  result = (char *) malloc (len + 1);
+  if (!result)
+    return 0;
+
+  result[len] = '\0';
+  return (char *) memcpy (result, s, len);
+}
+#endif
+
 /* To convey some special hash algorithms we use algorithm numbers
    reserved for application use. */
 #ifndef GCRY_MODULE_ID_USER
