X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=bin%2Fmisc%2Fuuidtest.c;h=81d117361aa4105c576876d1f5dea587ce2b7504;hb=260c314546ffcfdbef47f2c7de82d5310b26df0a;hp=524e25b7a138b8d9e4fc6a3775efa0a15581d897;hpb=dcbfd39d8a7df800a55ab0160d890bd61ebc7302;p=netatalk.git diff --git a/bin/misc/uuidtest.c b/bin/misc/uuidtest.c index 524e25b7..81d11736 100644 --- a/bin/misc/uuidtest.c +++ b/bin/misc/uuidtest.c @@ -1,5 +1,4 @@ /* - $Id: uuidtest.c,v 1.3 2009-11-28 12:27:24 franklahm Exp $ Copyright (c) 2008,2009 Frank Lahm This program is free software; you can redistribute it and/or modify @@ -17,14 +16,16 @@ #include "config.h" #endif /* HAVE_CONFIG_H */ -#ifdef HAVE_ACLS - #include #include #include #include #include + +#ifdef HAVE_LDAP +#define LDAP_DEPRECATED 1 #include +#endif #include #include @@ -40,11 +41,14 @@ static void usage() static void parse_ldapconf() { static int inited = 0; + dictionary *iniconfig; if (! inited) { +#ifdef HAVE_LDAP /* Parse afp_ldap.conf */ printf("Start parsing afp_ldap.conf\n"); - acl_ldap_readconfig(_PATH_ACL_LDAPCONF); + iniconfig = iniparser_load(_PATH_CONFDIR "afp.conf"); + acl_ldap_readconfig(iniconfig); printf("Finished parsing afp_ldap.conf\n"); if (ldap_config_valid) { if (ldap_auth_method == LDAP_AUTH_NONE) @@ -57,70 +61,80 @@ static void parse_ldapconf() exit(EXIT_FAILURE); } } else { - printf("afp_ldap.conf is not ok.\n"); - exit(EXIT_FAILURE); + printf("afp_ldap.conf is not ok, not using LDAP. Only local UUID testing available.\n"); } +#else + printf("Built without LDAP support, only local UUID testing available.\n"); +#endif inited = 1; } } int main( int argc, char **argv) { - int ret, i, c; + int ret, c; int verbose = 0; atalk_uuid_t uuid; + int logsetup = 0; uuidtype_t type; - char *uuidstring = NULL; char *name = NULL; - setuplog("console log_error /dev/tty"); - while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) { switch(c) { case 'v': if (! verbose) { verbose = 1; - setuplog("console log_debug /dev/tty"); + setuplog("default:maxdebug", "/dev/tty"); + logsetup = 1; } break; case 'u': + if (! logsetup) + setuplog("default:info", "/dev/tty"); 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); + printf("User: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid)); } else { printf("User %s not found.\n", optarg); } break; case 'g': + if (! logsetup) + setuplog("default:info", "/dev/tty"); 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); + printf("Group: %s ==> UUID: %s\n", optarg, uuid_bin2string(uuid)); } else { printf("Group %s not found.\n", optarg); } break; case 'i': + if (! logsetup) + setuplog("default:info", "/dev/tty"); parse_ldapconf(); printf("Searching uuid: %s\n", optarg); uuid_string2bin(optarg, uuid); ret = getnamefromuuid( uuid, &name, &type); if (ret == 0) { - if (type == UUID_USER) + switch (type) { + case UUID_USER: printf("UUID: %s ==> User: %s\n", optarg, name); - else + break; + case UUID_GROUP: printf("UUID: %s ==> Group: %s\n", optarg, name); + break; + default: + printf("???: %s\n", optarg); + break; + } free(name); } else { printf("UUID: %s not found.\n", optarg); @@ -138,4 +152,3 @@ int main( int argc, char **argv) return 0; } -#endif /* HAVE_ACLS */