]> andersk Git - openssh.git/blobdiff - sshconnect.c
fix spacing of include
[openssh.git] / sshconnect.c
index 2245a8af647257b5194c7c9d46b10afc95ae3c08..9da911c4cb20b5440658ea269c7f67655debccef 100644 (file)
@@ -13,7 +13,9 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.170 2005/10/30 08:52:18 djm Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.172 2006/02/08 12:15:27 stevesk Exp $");
+
+#include <paths.h>
 
 #include <openssl/bn.h>
 
@@ -1034,3 +1036,39 @@ warn_changed_key(Key *host_key)
 
        xfree(fp);
 }
+
+/*
+ * Execute a local command
+ */
+int
+ssh_local_cmd(const char *args)
+{
+       char *shell;
+       pid_t pid;
+       int status;
+
+       if (!options.permit_local_command ||
+           args == NULL || !*args)
+               return (1);
+
+       if ((shell = getenv("SHELL")) == NULL)
+               shell = _PATH_BSHELL;
+
+       pid = fork();
+       if (pid == 0) {
+               debug3("Executing %s -c \"%s\"", shell, args);
+               execl(shell, shell, "-c", args, (char *)NULL);
+               error("Couldn't execute %s -c \"%s\": %s",
+                   shell, args, strerror(errno));
+               _exit(1);
+       } else if (pid == -1)
+               fatal("fork failed: %.100s", strerror(errno));
+       while (waitpid(pid, &status, 0) == -1)
+               if (errno != EINTR)
+                       fatal("Couldn't wait for child: %s", strerror(errno));
+
+       if (!WIFEXITED(status))
+               return (1);
+
+       return (WEXITSTATUS(status));
+}
This page took 0.032965 seconds and 4 git commands to generate.