]> arthur.barton.de Git - netatalk.git/blobdiff - etc/cnid_dbd/cnid_metad.c
afp_ldap.conf is gone
[netatalk.git] / etc / cnid_dbd / cnid_metad.c
index ad9727daab226d6dbb9b4bd5f789aacb9e301e94..580c36cd3339c9fdc363a25087d8e8b58699e80d 100644 (file)
@@ -44,7 +44,7 @@
 #include <sys/wait.h>
 #include <sys/uio.h>
 #include <sys/un.h>
-#define _XPG4_2 1
+// #define _XPG4_2 1
 #include <sys/socket.h>
 #include <stdio.h>
 #include <time.h>
@@ -90,6 +90,7 @@
 #include <atalk/cnid_dbd_private.h>
 #include <atalk/paths.h>
 #include <atalk/volinfo.h>
+#include <atalk/compat.h>
 
 #include "usockfd.h"
 
@@ -443,15 +444,17 @@ int main(int argc, char *argv[])
     int    err = 0;
     int    debug = 0;
     int    ret;
-    char   *loglevel = NULL;
-    char   *logfile  = NULL;
     sigset_t set;
     struct volinfo *volinfo;
 
     set_processname("cnid_metad");
 
-    while (( cc = getopt( argc, argv, "ds:p:h:u:g:l:f:")) != -1 ) {
+    while (( cc = getopt( argc, argv, "vVds:p:h:u:g:l:f:")) != -1 ) {
         switch (cc) {
+        case 'v':
+        case 'V':
+            printf("cnid_metad (Netatalk %s)\n", VERSION);
+            return -1;
         case 'd':
             debug = 1;
             break;
@@ -478,39 +481,24 @@ int main(int argc, char *argv[])
         case 's':
             dbdpn = strdup(optarg);
             break;
-        case 'l':
-            loglevel = strdup(optarg);
-            break;
-        case 'f':
-            logfile = strdup(optarg);
-            break;
         default:
             err++;
             break;
         }
     }
 
+    /* Check for PID lockfile */
+    if (check_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK))
+        return -1;
+
     if (!debug && daemonize(0, 0) != 0)
         exit(EXITERR_SYS);
 
-    /* Check PID lockfile and become a daemon */
-    switch(check_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK)) {
-    case 0:
-        break;
-    default:
-        exit(EXITERR_SYS);
-    }
+    /* Create PID lockfile */
+    if (create_lockfile("cnid_metad", _PATH_CNID_METAD_LOCK))
+        return -1;
 
-    if (loglevel) {
-        strlcpy(logconfig + 8, loglevel, 13);
-        free(loglevel);
-        strcat(logconfig, " ");
-    }
-    if (logfile) {
-        strlcat(logconfig, logfile, MAXPATHLEN);
-        free(logfile);
-    }
-    setuplog(logconfig);
+    setuplog("default:note", NULL);
 
     if (err) {
         LOG(log_error, logtype_cnid, "main: bad arguments");