]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/dsi/dsi_getsess.c
First try for a volume defaults config
[netatalk.git] / libatalk / dsi / dsi_getsess.c
index f7b89c8e1cf3deee9e21402bcea3be109226cc35..5debd0377881372fdccad8402dfc208de0a60a82 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
 #include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 
-/* POSIX.1 sys/wait.h check */
 #include <sys/types.h>
-#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
-#endif /* HAVE_SYS_WAIT_H */
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#endif /* ! WEXITSTATUS */
-#ifndef WIFEXITED
-#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif /* ! WIFEXITED */
-
 #include <sys/time.h>
 #include <atalk/logger.h>
 #include <atalk/util.h>
@@ -45,12 +35,12 @@ afp_child_t *dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval
   afp_child_t *child;
 
   if (socketpair(PF_UNIX, SOCK_STREAM, 0, ipc_fds) < 0) {
-      LOG(log_error, logtype_afpd, "dsi_getsess: %s", strerror(errno));
+      LOG(log_error, logtype_dsi, "dsi_getsess: %s", strerror(errno));
       exit( EXITERR_CLNT );
   }
 
   if (setnonblock(ipc_fds[0], 1) != 0 || setnonblock(ipc_fds[1], 1) != 0) {
-      LOG(log_error, logtype_afpd, "dsi_getsess: setnonblock: %s", strerror(errno));
+      LOG(log_error, logtype_dsi, "dsi_getsess: setnonblock: %s", strerror(errno));
       exit(EXITERR_CLNT);
   }
 
@@ -66,7 +56,7 @@ afp_child_t *dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval
   default: /* parent */
     /* using SIGQUIT is hokey, but the child might not have
      * re-established its signal handler for SIGTERM yet. */
-    if ((child = server_child_add(serv_children, CHILD_DSIFORK, pid, ipc_fds)) < 0) {
+    if ((child = server_child_add(serv_children, CHILD_DSIFORK, pid, ipc_fds)) ==  NULL) {
       LOG(log_error, logtype_dsi, "dsi_getsess: %s", strerror(errno));
       dsi->header.dsi_flags = DSIFL_REPLY;
       dsi->header.dsi_code = DSIERR_SERVBUSY;
@@ -124,9 +114,11 @@ afp_child_t *dsi_getsession(DSI *dsi, server_child *serv_children, int tickleval
     dsi_opensession(dsi);
     if ((child = calloc(1, sizeof(afp_child_t))) == NULL)
         exit(EXITERR_SYS);
+
+    child->ipc_fds[0] = -1;
     child->ipc_fds[1] = ipc_fds[1];
+    close(ipc_fds[0]);
     return child;
-    break;
 
   default: /* just close */
     LOG(log_info, logtype_dsi, "DSIUnknown %d", dsi->header.dsi_command);