openssh.patch.scpbindir 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. This patch provides a workaround for the nasty issue that scp(1) is
  2. found on the server side only if it is in $PATH (due to a ~/.bashrc,
  3. /etc/profile, etc). The default $PATH is out of scope for OpenPKG and is
  4. different across platforms anyway. Nevertheless we want to ensure that
  5. with OpenPKG on the server side, scp(1) is always usable (on the client
  6. side) without having to adjust the system and/or user environment (on
  7. the server side).
  8. Index: session.c
  9. --- session.c.orig 2004-04-16 14:47:55.000000000 +0200
  10. +++ session.c 2004-05-19 17:02:30.000000000 +0200
  11. @@ -66,6 +66,10 @@
  12. #include "ssh-gss.h"
  13. #endif
  14. +#ifndef SCPBINDIR
  15. +#define SCPBINDIR "@l_prefix@/bin"
  16. +#endif
  17. +
  18. /* func */
  19. Session *session_new(void);
  20. @@ -652,6 +656,21 @@
  21. void
  22. do_exec(Session *s, const char *command)
  23. {
  24. + char *scp_command = NULL;
  25. +
  26. + if ( command != NULL
  27. + && strlen(command) >= 3
  28. + && strncmp(command, "scp", 3) == 0
  29. + && (command[3] == ' ' || command[3] == '\0')) {
  30. + size_t l, k;
  31. + l = strlen(SCPBINDIR);
  32. + k = strlen(command);
  33. + scp_command = xmalloc(l+1+k+1);
  34. + snprintf(scp_command, l+1+k+1, "%s/%s", SCPBINDIR, command);
  35. + command = (const char *)scp_command;
  36. + debug("Forced SCP command '%.900s'", command);
  37. + }
  38. +
  39. if (forced_command) {
  40. original_command = command;
  41. command = forced_command;
  42. @@ -672,6 +691,8 @@
  43. do_exec_no_pty(s, command);
  44. original_command = NULL;
  45. + if (scp_command != NULL)
  46. + xfree(scp_command);
  47. }