lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1882 - in nss-pam-ldapd: . tests

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

nss-pam-ldapd commit: r1882 - in nss-pam-ldapd: . tests



Author: arthur
Date: Sat Dec 29 14:44:36 2012
New Revision: 1882
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1882&view=revision

Log:
implement a lookup_netgroup command for systems that cannot use getent to list 
netgroups

Added:
   nss-pam-ldapd/tests/lookup_netgroup.c
Modified:
   nss-pam-ldapd/.gitignore
   nss-pam-ldapd/tests/   (props changed)
   nss-pam-ldapd/tests/Makefile.am

Modified: nss-pam-ldapd/.gitignore
==============================================================================
--- nss-pam-ldapd/.gitignore    Fri Dec 28 22:04:27 2012        (r1881)
+++ nss-pam-ldapd/.gitignore    Sat Dec 29 14:44:36 2012        (r1882)
@@ -53,6 +53,7 @@
 /pynslcd/constants.py
 
 # /tests/
+/tests/lookup_netgroup
 /tests/temp.cfg
 /tests/test_cfg
 /tests/test_common

Modified: nss-pam-ldapd/tests/Makefile.am
==============================================================================
--- nss-pam-ldapd/tests/Makefile.am     Fri Dec 28 22:04:27 2012        (r1881)
+++ nss-pam-ldapd/tests/Makefile.am     Sat Dec 29 14:44:36 2012        (r1882)
@@ -22,7 +22,7 @@
         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
+                 test_cfg test_myldap test_common lookup_netgroup
 
 EXTRA_DIST = nslcd-test.conf test_myldap.sh test_nsscmds.sh test_pamcmds.sh \
              in_testenv.sh test_pamcmds.expect usernames.txt
@@ -72,3 +72,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

Added: nss-pam-ldapd/tests/lookup_netgroup.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nss-pam-ldapd/tests/lookup_netgroup.c       Sat Dec 29 14:44:36 2012        
(r1882)
@@ -0,0 +1,54 @@
+/*
+   lookup_netgroup.c - simple lookup code for netgroups
+
+   Copyright (C) 2012 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 <netdb.h>
+#include <stdlib.h>
+
+/* the main program... */
+int main(int argc,char *argv[])
+{
+  char *host, *user, *domain;
+  /* check arguments */
+  if (argc != 2)
+  {
+    fprintf(stderr, "Usage: %s NETGROUP\n", argv[0]);
+    exit(EXIT_FAILURE);
+  }
+  /* start lookup */
+  if (setnetgrent(argv[1])!=0)
+  {
+    /* output nothing */
+    exit(EXIT_FAILURE);
+  }
+  fprintf(stdout, "%-20s", argv[1]);
+  while (getnetgrent(&host, &user, &domain)!=0)
+  {
+    fprintf(stdout, " (%s, %s, %s)", host, user, domain);
+  }
+  fprintf(stdout, "\n");
+  endnetgrent();
+  return 0;
+}
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/