]> arthur.barton.de Git - netatalk.git/commitdiff
Rename uuidtest to afpldaptest
authorfranklahm <franklahm>
Fri, 27 Nov 2009 21:15:48 +0000 (21:15 +0000)
committerfranklahm <franklahm>
Fri, 27 Nov 2009 21:15:48 +0000 (21:15 +0000)
bin/misc/.cvsignore
bin/misc/Makefile.am
bin/misc/uuidtest.c [new file with mode: 0644]
configure.in
contrib/Makefile.am
contrib/acltests/.cvsignore [deleted file]
contrib/acltests/Makefile.am [deleted file]
contrib/acltests/uuidtest.c [deleted file]
man/man5/afp_ldap.conf.5.tmpl

index 378ebf686de9f37d615c905ff5ef43b230d15e50..057261ecd4b464526f30a5c96f7400816f413a26 100644 (file)
@@ -3,3 +3,5 @@ Makefile.in
 netacnv
 .deps
 .libs
+*.o
+afpldaptest
index ada4e49397f03f02ac8bde2500e9ecf9a8cbde25..9b55ee3621fe40a12364623c764b4e387fa1bd93 100644 (file)
@@ -1,6 +1,16 @@
-# Makefile.am for bin/aecho/
+# Makefile.am for bin/misc
 
 bin_PROGRAMS = netacnv
 
 netacnv_SOURCES = netacnv.c
 netacnv_LDADD = $(top_builddir)/libatalk/libatalk.la
+pkgconfdir = @PKGCONFDIR@
+
+if USE_NFSv4_ACLS
+bin_PROGRAMS += afpldaptest
+
+afpldaptest_SOURCES = uuidtest.c
+afpldaptest_LDADD =  $(top_builddir)/libatalk/libatalk.la
+
+AM_CFLAGS = -D_PATH_ACL_LDAPCONF=\"$(pkgconfdir)/afp_ldap.conf\"
+endif
diff --git a/bin/misc/uuidtest.c b/bin/misc/uuidtest.c
new file mode 100644 (file)
index 0000000..215f23f
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+  $Id: uuidtest.c,v 1.1 2009-11-27 21:15:48 franklahm Exp $
+  Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program 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 General Public License for more details.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_NFSv4_ACLS
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ldap.h>
+
+#include <atalk/ldapconfig.h>
+#include <atalk/uuid.h>
+#include <atalk/logger.h>
+
+#define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
+
+static void usage()
+{
+    printf("Usage: uuidtest -u <user> | -g <group> | -i <UUID>\n");
+}
+
+static void parse_ldapconf()
+{
+    static int inited = 0;
+
+    if (! inited) {
+        /* Parse afp_ldap.conf */
+        printf("Start parsing afp_ldap.conf\n");
+        acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
+        printf("Finished parsing afp_ldap.conf\n");
+        if (ldap_config_valid) {
+            if (ldap_auth_method == LDAP_AUTH_NONE)
+                printf("afp_ldap.conf is ok. Using anonymous bind.\n");
+            else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
+                printf("afp_ldap.conf is ok. Using simple bind.\n");
+            else {
+                ldap_config_valid = 0;
+                printf("afp_ldap.conf wants SASL which is not yet supported.\n");
+                exit(EXIT_FAILURE);
+            }
+        } else {
+            printf("afp_ldap.conf is not ok.\n");
+            exit(EXIT_FAILURE);
+        }
+        inited = 1;
+    }
+}
+
+int main( int argc, char **argv)
+{
+    int ret, i, c;
+    int verbose = 0;
+    uuid_t uuid;
+    uuidtype_t type;
+    char *uuidstring = NULL;
+    char *name = NULL;
+
+    setuplog("default log_error /dev/tty");
+
+    while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
+        switch(c) {
+
+        case 'v':
+            if (! verbose) {
+                verbose = 1;
+                setuplog("default log_debug /dev/tty");
+            }
+            break;
+
+        case 'u':
+            parse_ldapconf();
+            printf("Searching user: %s\n", optarg);
+            ret = getuuidfromname( optarg, UUID_USER, uuid);
+            if (ret == 0) {
+                uuid_bin2string( uuid, &uuidstring);
+                printf("User: %s ==> UUID: %s\n", optarg, uuidstring);
+                free(uuidstring);
+            } else {
+                printf("User %s not found.\n", optarg);
+            }
+            break;
+
+        case 'g':
+            parse_ldapconf();
+            printf("Searching group: %s\n", optarg);
+            ret = getuuidfromname( optarg, UUID_GROUP, uuid);
+            if (ret == 0) {
+                uuid_bin2string( uuid, &uuidstring);
+                printf("Group: %s ==> UUID: %s\n", optarg, uuidstring);
+                free(uuidstring);
+            } else {
+                printf("Group %s not found.\n", optarg);
+            }
+            break;
+
+        case 'i':
+            parse_ldapconf();
+            printf("Searching uuid: %s\n", optarg);
+            uuid_string2bin(optarg, uuid);
+            ret = getnamefromuuid( uuid, &name, &type);
+            if (ret == 0) {
+                if (type == UUID_USER)
+                    printf("UUID: %s ==> User: %s\n", optarg, name);
+                else
+                    printf("UUID: %s ==> Group: %s\n", optarg, name);
+                free(name);
+            } else {
+                printf("UUID: %s not found.\n", optarg);
+            }
+            break;
+
+        case ':':
+        case '?':
+            usage();
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    return 0;
+}
+
+#endif  /* HAVE_NFSv4_ACLS */
index 7dde57650ba5a36b2ff333265e1d2ca569b0b880..825e763663652341c893962d9d1b1852626e1dd5 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.232 2009-11-26 11:09:08 franklahm Exp $
+dnl $Id: configure.in,v 1.233 2009-11-27 21:15:48 franklahm Exp $
 dnl configure.in for netatalk
 
 AC_INIT(etc/afpd/main.c)
@@ -1208,7 +1208,6 @@ AC_OUTPUT([Makefile
        config/Makefile
     config/pam/Makefile
        contrib/Makefile
-       contrib/acltests/Makefile
        contrib/macusers/Makefile
        contrib/macusers/macusers
        contrib/nu/Makefile
index 47379aba9973fc532ddfeed07b6e54612b409d3c..633257c3df66f778a1cfc7ea6a554ace9a27ab45 100644 (file)
@@ -12,6 +12,6 @@ else
 A2BOOT =
 endif
 
-SUBDIRS = macusers nu printing shell_utils ${TIMELORD} ${A2BOOT} acltests
+SUBDIRS = macusers nu printing shell_utils ${TIMELORD} ${A2BOOT}
 
 EXTRA_DIST = ICDumpSuffixMap
diff --git a/contrib/acltests/.cvsignore b/contrib/acltests/.cvsignore
deleted file mode 100644 (file)
index 4bebe07..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-uuid.log
-uuidtest
diff --git a/contrib/acltests/Makefile.am b/contrib/acltests/Makefile.am
deleted file mode 100644 (file)
index 69e8e13..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-pkgconfdir = @PKGCONFDIR@
-
-if USE_NFSv4_ACLS
-bin_PROGRAMS = uuidtest
-
-uuidtest_SOURCES = uuidtest.c
-uuidtest_LDADD =  $(top_builddir)/libatalk/libatalk.la
-
-AM_CFLAGS = -D_PATH_ACL_LDAPCONF=\"$(pkgconfdir)/afp_ldap.conf\"
-endif
diff --git a/contrib/acltests/uuidtest.c b/contrib/acltests/uuidtest.c
deleted file mode 100644 (file)
index 429f4b5..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-  $Id: uuidtest.c,v 1.4 2009-11-27 15:50:26 franklahm Exp $
-  Copyright (c) 2008,2009 Frank Lahm <franklahm@gmail.com>
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program 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 General Public License for more details.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef HAVE_NFSv4_ACLS
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <ldap.h>
-
-#include <atalk/ldapconfig.h>
-#include <atalk/uuid.h>
-
-#define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
-
-int main( int argc, char **argv)
-{
-    int ret, i;
-    uuid_t uuid;
-    uuidtype_t type;
-    char *uuidstring = NULL;
-    char *name = NULL;
-
-    if (argc <  2) {
-        printf("Usage: uuidtest <name> | -u<UUID> [<name> ... | -u<UUID> ...] \n");
-        return -1;
-    }
-
-    /* Parse afp_ldap.conf */
-    printf("Start parsing afp_ldap.conf\n");
-    acl_ldap_readconfig(_PATH_ACL_LDAPCONF);
-    printf("Finished parsing afp_ldap.conf\n");
-    if (ldap_config_valid) {
-        if (ldap_auth_method == LDAP_AUTH_NONE)
-            printf("afp_ldap.conf is ok. Using anonymous bind.\n");
-        else if (ldap_auth_method == LDAP_AUTH_SIMPLE)
-            printf("afp_ldap.conf is ok. Using simple bind.\n");
-        else {
-            ldap_config_valid = 0;
-            printf("afp_ldap.conf want SASL which is not yet supported.\n");
-        }
-    } else {
-        printf("afp_ldap.conf is not ok.\n");
-        return 1;
-    }
-
-    for (i=1; i+1 <= argc; i++) {
-        if (STRNCMP("-u", == , argv[i], 2)) {
-            printf("Searching uuid: %s\n", argv[i]+2);
-            uuid_string2bin(argv[i]+2, uuid);
-            ret = getnamefromuuid( uuid, &name, &type);
-            if (ret == 0) {
-                printf("Got user: %s for uuid: %s, type:%d\n", name, argv[i]+2, type);
-                free(uuidstring);
-            } else
-                printf("uuid %s not found.\n", argv[i]+2);
-        } else {
-            printf("Searching user: %s\n", argv[i]);
-            ret = getuuidfromname( argv[i], UUID_USER, uuid);
-            if (ret == 0) {
-                uuid_bin2string( uuid, &uuidstring);
-                printf("Got uuid: %s for name: %s, type: USER\n", uuidstring, argv[i]);
-                free(uuidstring);
-            } else {
-                ret = getuuidfromname( argv[i], UUID_GROUP, uuid);
-                if (ret == 0) {
-                    uuid_bin2string( uuid, &uuidstring);
-                    printf("Got uuid: %s for name: %s, type: GROUP\n", uuidstring, argv[i]);
-                    free(uuidstring);
-                }
-                else
-                    printf("User %s not found.\n", argv[i]);
-            }
-        }
-    }
-
-    return 0;
-}
-
-#endif  /* HAVE_NFSv4_ACLS */
index 17df2bd30e445ca7dd85a7210df16e38f6965473..cabe336b26bc7d5e955dc4dfe2377d2fea621495 100644 (file)
@@ -114,7 +114,7 @@ Any line not prefixed with # is interpreted\&.
 .br
 .PP
 You can use
-\fBuuidtest\fR(1)
+\fBafpldaptest\fR(1)
 to syntactically check your config
 .sp .5v
 .EM yellow
@@ -221,4 +221,4 @@ ldap_group_attr  = cn
 .SH "See also"
 .PP
 \fBafpd\fR(8),
-\fBAppleVolumes.default\fR(5),\fBuuidtest\fR(1)
+\fBAppleVolumes.default\fR(5),\fBafpldaptest\fR(1)