]> arthur.barton.de Git - netatalk.git/blobdiff - bin/misc/uuidtest.c
Fix typo
[netatalk.git] / bin / misc / uuidtest.c
index 4385a3eec30dc11d29a441c723c3ffab8266104c..030a4f522d7d3fabafddbcc601caf130123aff17 100644 (file)
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#ifdef HAVE_ACLS
-
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
+
+#ifdef HAVE_LDAP
+#define LDAP_DEPRECATED 1
 #include <ldap.h>
+#endif
 
 #include <atalk/ldapconfig.h>
 #include <atalk/uuid.h>
 #include <atalk/logger.h>
+#include <atalk/iniparser.h>
 
 #define STRNCMP(a, R, b, l) (strncmp(a,b,l) R 0)
 
@@ -39,38 +42,42 @@ static void usage()
 static void parse_ldapconf()
 {
     static int inited = 0;
+    dictionary *iniconfig;
 
     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");
+#ifdef HAVE_LDAP
+        /* Parse afp.conf */
+        printf("Start parsing afp.conf\n");
+        iniconfig = iniparser_load(_PATH_CONFDIR "afp.conf");
+        acl_ldap_readconfig(iniconfig);
+        printf("Finished parsing afp.conf\n");
         if (ldap_config_valid) {
             if (ldap_auth_method == LDAP_AUTH_NONE)
-                printf("afp_ldap.conf is ok. Using anonymous bind.\n");
+                printf("afp.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");
+                printf("afp.conf is ok. Using simple bind.\n");
             else {
                 ldap_config_valid = 0;
-                printf("afp_ldap.conf wants SASL which is not yet supported.\n");
+                printf("afp.conf wants SASL which is not yet supported.\n");
                 exit(EXIT_FAILURE);
             }
         } else {
-            printf("afp_ldap.conf is not ok.\n");
-            exit(EXIT_FAILURE);
+            printf("afp.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;
 
     while ((c = getopt(argc, argv, ":vu:g:i:")) != -1) {
@@ -79,14 +86,14 @@ int main( int argc, char **argv)
         case 'v':
             if (! verbose) {
                 verbose = 1;
-                setuplog("default log_maxdebug /dev/tty");
+                setuplog("default:maxdebug", "/dev/tty");
                 logsetup = 1;
             }
             break;
 
         case 'u':
             if (! logsetup)
-                setuplog("default log_info /dev/tty");
+                setuplog("default:info", "/dev/tty");
             parse_ldapconf();
             printf("Searching user: %s\n", optarg);
             ret = getuuidfromname( optarg, UUID_USER, uuid);
@@ -99,7 +106,7 @@ int main( int argc, char **argv)
 
         case 'g':
             if (! logsetup)
-                setuplog("default log_info /dev/tty");
+                setuplog("default:info", "/dev/tty");
             parse_ldapconf();
             printf("Searching group: %s\n", optarg);
             ret = getuuidfromname( optarg, UUID_GROUP, uuid);
@@ -112,22 +119,22 @@ int main( int argc, char **argv)
 
         case 'i':
             if (! logsetup)
-                setuplog("default log_info /dev/tty");
+                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) {
                 switch (type) {
-                case UUID_LOCAL:
-                    printf("local UUID: %s\n", optarg);
-                    break;
                 case UUID_USER:
                     printf("UUID: %s ==> User: %s\n", optarg, name);
                     break;
                 case UUID_GROUP:
                     printf("UUID: %s ==> Group: %s\n", optarg, name);
                     break;
+                default:
+                    printf("???: %s\n", optarg);
+                    break;
                 }
                 free(name);
             } else {
@@ -146,4 +153,3 @@ int main( int argc, char **argv)
     return 0;
 }
 
-#endif  /* HAVE_ACLS */