]> andersk Git - openssh.git/blobdiff - sshconnect.c
- deraadt@cvs.openbsd.org 2006/03/20 18:42:27
[openssh.git] / sshconnect.c
index d8cfd35b396ce6b4d2b50bee68fde39f3440ab55..33961e4dc169e264846726e03c15bfc19af8c25e 100644 (file)
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.169 2005/10/15 15:28:12 stevesk Exp $");
 
-#include <openssl/bn.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+
+#include <ctype.h>
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
 
 #include "ssh.h"
 #include "xmalloc.h"
@@ -603,7 +609,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
        file_key = key_new(host_key->type);
 
        /*
-        * Check if the host key is present in the user\'s list of known
+        * Check if the host key is present in the user's list of known
         * hosts or in the systemwide list.
         */
        host_file = user_hostfile;
@@ -921,7 +927,7 @@ ssh_login(Sensitive *sensitive, const char *orighost,
        host = xstrdup(orighost);
        for (cp = host; *cp; cp++)
                if (isupper(*cp))
-                       *cp = tolower(*cp);
+                       *cp = (char)tolower(*cp);
 
        /* Exchange protocol version identification strings with the server. */
        ssh_exchange_identification();
@@ -1034,3 +1040,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.048587 seconds and 4 git commands to generate.