lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.8.12-122-g83c5788

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

nss-pam-ldapd branch master updated. 0.8.12-122-g83c5788



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "nss-pam-ldapd".

The branch, master has been updated
       via  83c5788daeec43929088f745238f8c9c31b4d6a8 (commit)
      from  fa27d94a73be50c2730401279663ee41081137dd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://arthurdejong.org/git/nss-pam-ldapd/commit/?id=83c5788daeec43929088f745238f8c9c31b4d6a8

commit 83c5788daeec43929088f745238f8c9c31b4d6a8
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Mon Mar 11 20:50:55 2013 +0100

    implement a lookup_shadow test command for use on systems that don't allow 
querying shadow via getent

diff --git a/.gitignore b/.gitignore
index 8133947..d079ba9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ stamp-*
 
 # /tests/
 /tests/lookup_netgroup
+/tests/lookup_shadow
 /tests/temp.cfg
 /tests/test_cfg
 /tests/test_common
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 082e80d..b8990a9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,7 +22,8 @@ TESTS = test_dict test_set test_tio test_expr 
test_getpeercred test_cfg \
         test_myldap.sh test_common test_nsscmds.sh test_pamcmds.sh
 
 check_PROGRAMS = test_dict test_set test_tio test_expr test_getpeercred \
-                 test_cfg test_myldap test_common lookup_netgroup
+                 test_cfg test_myldap test_common \
+                 lookup_netgroup lookup_shadow
 
 EXTRA_DIST = nslcd-test.conf test_myldap.sh test_nsscmds.sh test_pamcmds.sh \
              in_testenv.sh test_pamcmds.expect usernames.txt
@@ -74,3 +75,5 @@ test_common_SOURCES = test_common.c ../nslcd/common.h
 test_common_LDADD = ../nslcd/cfg.o $(common_nslcd_LDADD)
 
 lookup_netgroup_SOURCES = lookup_netgroup.c
+
+lookup_shadow_SOURCES = lookup_shadow.c
diff --git a/tests/lookup_shadow.c b/tests/lookup_shadow.c
new file mode 100644
index 0000000..5c96108
--- /dev/null
+++ b/tests/lookup_shadow.c
@@ -0,0 +1,97 @@
+/*
+   lookup_shadow.c - simple lookup code for shadow entries
+
+   Copyright (C) 2013 Arthur de Jong
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301 USA
+*/
+
+#include "config.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#ifndef HAVE_SHADOW_H
+/* dummy implementation that does nothing for FreeBSD */
+int main(int argc,char *argv[])
+{
+  fprintf(stderr, "%s: shadow lookups unsupported\n", argv[0]);
+  return 1;
+}
+#else /* HAVE_SHADOW_H */
+
+#include <shadow.h>
+
+static void print_shadow(struct spwd *result)
+{
+  printf("%s:%s:", result->sp_namp, result->sp_pwdp);
+  if (result->sp_lstchg >= 0)
+    printf("%d", result->sp_lstchg);
+  printf(":");
+  if (result->sp_min >= 0)
+    printf("%d", (int)result->sp_min);
+  printf(":");
+  if (result->sp_max >= 0)
+    printf("%d", (int)result->sp_max);
+  printf(":");
+  if (result->sp_warn >= 0)
+    printf("%d", (int)result->sp_warn);
+  printf(":");
+  if (result->sp_inact >= 0)
+    printf("%d", (int)result->sp_inact);
+  printf(":");
+  if (result->sp_expire >= 0)
+    printf("%d", (int)result->sp_expire);
+  printf(":");
+  if (result->sp_flag >= 0)
+    printf("%x", (int)result->sp_flag);
+  printf("\n");
+}
+
+/* the main program... */
+int main(int argc,char *argv[])
+{
+  struct spwd *result;
+  /* check arguments */
+  if ((argc != 1) && (argc != 2))
+  {
+    fprintf(stderr, "Usage: %s [USERNAME]\n", argv[0]);
+    exit(EXIT_FAILURE);
+  }
+  /* start lookup */
+  if (argc == 2)
+  {
+    /* get entry by name */
+    errno = 0;
+    result = getspnam(argv[1]);
+    if (result == NULL)
+      exit(EXIT_FAILURE);
+    print_shadow(result);
+  }
+  else /* argc == 1 */
+  {
+    /* get all entries */
+    setspent();
+    while ((result = getspent()) != NULL)
+      print_shadow(result);
+    endspent();
+  }
+  return 0;
+}
+
+#endif /* HAVE_SHADOW_H */

-----------------------------------------------------------------------

Summary of changes:
 .gitignore            |    1 +
 tests/Makefile.am     |    5 ++-
 tests/lookup_shadow.c |   97 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+), 1 deletions(-)
 create mode 100644 tests/lookup_shadow.c


hooks/post-receive
-- 
nss-pam-ldapd
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/