From 1b9ea96ec7af7715b4cecf7b89e41c5ac4fe7e51 Mon Sep 17 00:00:00 2001 From: franklahm Date: Fri, 27 Nov 2009 21:15:48 +0000 Subject: [PATCH] Rename uuidtest to afpldaptest --- bin/misc/.cvsignore | 2 + bin/misc/Makefile.am | 12 ++- bin/misc/uuidtest.c | 140 ++++++++++++++++++++++++++++++++++ configure.in | 3 +- contrib/Makefile.am | 2 +- contrib/acltests/.cvsignore | 6 -- contrib/acltests/Makefile.am | 10 --- contrib/acltests/uuidtest.c | 97 ----------------------- man/man5/afp_ldap.conf.5.tmpl | 4 +- 9 files changed, 157 insertions(+), 119 deletions(-) create mode 100644 bin/misc/uuidtest.c delete mode 100644 contrib/acltests/.cvsignore delete mode 100644 contrib/acltests/Makefile.am delete mode 100644 contrib/acltests/uuidtest.c diff --git a/bin/misc/.cvsignore b/bin/misc/.cvsignore index 378ebf68..057261ec 100644 --- a/bin/misc/.cvsignore +++ b/bin/misc/.cvsignore @@ -3,3 +3,5 @@ Makefile.in netacnv .deps .libs +*.o +afpldaptest diff --git a/bin/misc/Makefile.am b/bin/misc/Makefile.am index ada4e493..9b55ee36 100644 --- a/bin/misc/Makefile.am +++ b/bin/misc/Makefile.am @@ -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 index 00000000..215f23f5 --- /dev/null +++ b/bin/misc/uuidtest.c @@ -0,0 +1,140 @@ +/* + $Id: uuidtest.c,v 1.1 2009-11-27 21:15:48 franklahm Exp $ + Copyright (c) 2008,2009 Frank Lahm + + 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0) + +static void usage() +{ + printf("Usage: uuidtest -u | -g | -i \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 */ diff --git a/configure.in b/configure.in index 7dde5765..825e7636 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 47379aba..633257c3 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -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 index 4bebe071..00000000 --- a/contrib/acltests/.cvsignore +++ /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 index 69e8e131..00000000 --- a/contrib/acltests/Makefile.am +++ /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 index 429f4b59..00000000 --- a/contrib/acltests/uuidtest.c +++ /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 - - 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 -#include -#include -#include -#include - -#include -#include - -#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 | -u [ ... | -u ...] \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 */ diff --git a/man/man5/afp_ldap.conf.5.tmpl b/man/man5/afp_ldap.conf.5.tmpl index 17df2bd3..cabe336b 100644 --- a/man/man5/afp_ldap.conf.5.tmpl +++ b/man/man5/afp_ldap.conf.5.tmpl @@ -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) -- 2.39.2