about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Makefile1
-rw-r--r--package/deps.mak8
-rw-r--r--src/compat/deps-lib/pamela-compat3
-rw-r--r--src/compat/misc_conv.c59
-rw-r--r--src/compat/pam_misc_drop_env.c17
-rw-r--r--src/compat/pam_misc_paste_env.c14
-rw-r--r--src/include/pamela/compat.h12
-rwxr-xr-xtools/gen-deps.sh11
9 files changed, 120 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 3d0b823..704b3d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
 *.o
 *.lo
+/lib*.a.xyzzy
+/lib*.so.xyzzy
 /config.mak
 /src/include/pamela/config.h
 /pamelad
-/libpamela.a.xyzzy
-/libpamela.so.xyzzy
diff --git a/Makefile b/Makefile
index cd6c7f0..13fabde 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,6 @@ CC = $(error Please use ./configure first)
 
 STATIC_LIBS :=
 SHARED_LIBS :=
-INTERNAL_LIBS :=
 EXTRA_TARGETS :=
 LIB_DEFS :=
 
diff --git a/package/deps.mak b/package/deps.mak
index aa9d239..7e33afd 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -2,6 +2,7 @@
 # This file has been generated by tools/gen-deps.sh
 #
 
+src/include/pamela/compat.h: src/include/pamela/pam.h
 src/include/pamela/pam.h: src/include/pamela/pamela.h
 src/include/pamela/pamela.h: src/include/pamela/common.h
 src/pamela/pamela-internal.h: src/include/pamela/pamela.h
@@ -38,12 +39,10 @@ src/pamela/pamela_zero.o src/pamela/pamela_zero.lo: src/pamela/pamela_zero.c src
 src/pamela/pamelad.o src/pamela/pamelad.lo: src/pamela/pamelad.c src/include/pamela/common.h
 
 ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
-libpamela-compat.a.xyzzy: src/compat/
+libpamela-compat.a.xyzzy: src/compat/misc_conv.o src/compat/pam_misc_drop_env.o src/compat/pam_misc_paste_env.o
 else
-libpamela-compat.a.xyzzy: src/compat/
+libpamela-compat.a.xyzzy: src/compat/misc_conv.lo src/compat/pam_misc_drop_env.lo src/compat/pam_misc_paste_env.lo
 endif
-libpamela-compat.so.xyzzy: EXTRA_LIBS :=
-libpamela-compat.so.xyzzy: src/compat/
 ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
 libpamela.a.xyzzy: src/pamela/pam_acct_mgmt.o src/pamela/pam_authenticate.o src/pamela/pam_chauthtok.o src/pamela/pam_close_session.o src/pamela/pam_end.o src/pamela/pam_fail_delay.o src/pamela/pam_get_item.o src/pamela/pam_getenv.o src/pamela/pam_getenvlist.o src/pamela/pam_open_session.o src/pamela/pam_putenv.o src/pamela/pam_set_item.o src/pamela/pam_setcred.o src/pamela/pam_start.o src/pamela/pam_strerror.o src/pamela/pamela_end.o src/pamela/pamela_get_item.o src/pamela/pamela_getenvlist.o src/pamela/pamela_op.o src/pamela/pamela_pam_response_free.o src/pamela/pamela_query_string.o src/pamela/pamela_set_item.o src/pamela/pamela_set_item_internal.o src/pamela/pamela_set_itemv.o src/pamela/pamela_startf.o src/pamela/pamela_strerror.o src/pamela/pamela_zero.o
 else
@@ -53,3 +52,4 @@ libpamela.so.xyzzy: EXTRA_LIBS :=
 libpamela.so.xyzzy: src/pamela/pam_acct_mgmt.lo src/pamela/pam_authenticate.lo src/pamela/pam_chauthtok.lo src/pamela/pam_close_session.lo src/pamela/pam_end.lo src/pamela/pam_fail_delay.lo src/pamela/pam_get_item.lo src/pamela/pam_getenv.lo src/pamela/pam_getenvlist.lo src/pamela/pam_open_session.lo src/pamela/pam_putenv.lo src/pamela/pam_set_item.lo src/pamela/pam_setcred.lo src/pamela/pam_start.lo src/pamela/pam_strerror.lo src/pamela/pamela_end.lo src/pamela/pamela_get_item.lo src/pamela/pamela_getenvlist.lo src/pamela/pamela_op.lo src/pamela/pamela_pam_response_free.lo src/pamela/pamela_query_string.lo src/pamela/pamela_set_item.lo src/pamela/pamela_set_item_internal.lo src/pamela/pamela_set_itemv.lo src/pamela/pamela_startf.lo src/pamela/pamela_strerror.lo src/pamela/pamela_zero.lo
 pamelad: EXTRA_LIBS := -lskarnet ${PAM_LIB}
 pamelad: src/pamela/pamelad.o
+INTERNAL_LIBS := libpamela-compat.a.xyzzy
diff --git a/src/compat/deps-lib/pamela-compat b/src/compat/deps-lib/pamela-compat
new file mode 100644
index 0000000..d6fbe42
--- /dev/null
+++ b/src/compat/deps-lib/pamela-compat
@@ -0,0 +1,3 @@
+misc_conv.o
+pam_misc_drop_env.o
+pam_misc_paste_env.o
diff --git a/src/compat/misc_conv.c b/src/compat/misc_conv.c
new file mode 100644
index 0000000..23d23fb
--- /dev/null
+++ b/src/compat/misc_conv.c
@@ -0,0 +1,59 @@
+/* ISC license. */
+
+#include <string.h>
+#include <stdlib.h>
+#include <skalibs/allreadwrite.h>
+#include <skalibs/strerr.h>
+#include <skalibs/stralloc.h>
+#include <pamela/pam.h>
+#include <pamela/compat.h>
+
+/*
+static void freeres (struct pam_response *res, unsigned int n)
+{
+  while (n--) free(res[n].resp) ;
+  free(res) ;
+}
+*/
+
+static int getsa (int h, char const *msg, stralloc *sa)
+{
+  /* TODO: complete this */
+  return 0 ;
+}
+
+int misc_conv (int n, struct pam_message const **msg, struct pam_response **resp, void *aux)
+{
+  stralloc sa = STRALLOC_ZERO ;
+  struct pam_response *res ;
+  if (n <= 0) return PAM_CONV_ERR ;
+  res = malloc(n * sizeof(struct pam_response)) ;
+  if (!res) return PAM_CONV_ERR ;
+  for (unsigned int i = 0 ; i < n ; i++)
+  {
+    switch (msg[i]->msg_style)
+    {
+      case PAM_PROMPT_ECHO_OFF :
+        if (getsa(0, msg[i]->msg, &sa)) goto fail ;
+        break ;
+      case PAM_PROMPT_ECHO_ON :
+        if (getsa(1, msg[i]->msg, &sa)) goto fail ;
+        break ;
+      case PAM_ERROR_MSG :
+        strerr_warnw1x(msg[i]->msg) ;
+        break ;
+      case PAM_TEXT_INFO :
+      {
+        size_t len = strlen(msg[i]->msg) ;
+        if (allwrite(1, msg[i]->msg, len) < len) goto fail ;
+        break ;
+      }
+      case PAM_BINARY_PROMPT : /* TODO */
+        break ;
+    }
+  }
+  return 0 ;
+
+ fail:  /* TODO: check */
+  return -1 ;
+}
diff --git a/src/compat/pam_misc_drop_env.c b/src/compat/pam_misc_drop_env.c
new file mode 100644
index 0000000..a8a7564
--- /dev/null
+++ b/src/compat/pam_misc_drop_env.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#include <stdlib.h>
+#include <pamela/compat.h>
+
+static inline void env_free (char **envp)
+{
+  char **p = envp ;
+  while (*p) free(*p++) ;
+  free(envp) ;
+}
+
+char **pam_misc_drop_env (char **envp)
+{
+  env_free(envp) ;
+  return 0 ;
+}
diff --git a/src/compat/pam_misc_paste_env.c b/src/compat/pam_misc_paste_env.c
new file mode 100644
index 0000000..b70fd58
--- /dev/null
+++ b/src/compat/pam_misc_paste_env.c
@@ -0,0 +1,14 @@
+/* ISC license. */
+
+#include <pamela/pam.h>
+#include <pamela/compat.h>
+
+int pam_misc_paste_env (pam_handle_t *pamh, char const *const *envp)
+{
+  for (; *envp ; envp++)
+  {
+    int e = pam_putenv(pamh, *envp) ;
+    if (e != PAM_SUCCESS) return e ;
+  }
+  return PAM_SUCCESS ;
+}
diff --git a/src/include/pamela/compat.h b/src/include/pamela/compat.h
new file mode 100644
index 0000000..04f739d
--- /dev/null
+++ b/src/include/pamela/compat.h
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#ifndef PAMELA_COMPAT_H
+#define PAMELA_COMPAT_H
+
+#include <pamela/pam.h>
+
+extern int misc_conv (int n, struct pam_message const **, struct pam_response **, void *) ;
+extern char **pam_misc_drop_env (char **) ;
+extern int pam_misc_paste_env (pam_handle_t *, char const *const *) ;
+
+#endif
diff --git a/tools/gen-deps.sh b/tools/gen-deps.sh
index 27e5b3e..befe021 100755
--- a/tools/gen-deps.sh
+++ b/tools/gen-deps.sh
@@ -7,6 +7,8 @@ echo '# This file has been generated by tools/gen-deps.sh'
 echo '#'
 echo
 
+internal_libs=
+
 for dir in src/include/${package} src/* ; do
   for file in $(ls -1 $dir | grep -- \\.h$) ; do
     {
@@ -70,8 +72,12 @@ for dir in $(ls -1 src | grep -v ^include) ; do
     echo else
     echo "lib${file}.a.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')"
     echo endif
-    echo "lib${file}.so.xyzzy: EXTRA_LIBS :=$libs"
-    echo "lib${file}.so.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')"
+    if grep -E "^LIB_DEFS [+:]=" package/targets.mak | grep -qF "$file" ; then
+      echo "lib${file}.so.xyzzy: EXTRA_LIBS :=$libs"
+      echo "lib${file}.so.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')"
+    else
+      internal_libs="$internal_libs lib${file}.a.xyzzy"
+    fi
   done
 
   for file in $(ls -1 src/$dir/deps-exe) ; do
@@ -91,3 +97,4 @@ for dir in $(ls -1 src | grep -v ^include) ; do
     echo "$file: src/$dir/$file.o$deps"
   done
 done
+echo "INTERNAL_LIBS :=$internal_libs"