home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / security / ylonen-ssh / ssh-1.2.27-permit-unprivileged-port.patch < prev    next >
Text File  |  2000-06-09  |  10KB  |  277 lines

  1. http://marc.theaimsgroup.com/?l=secure-shell&m=94038201807561&w=2
  2.  
  3. List:     secure-shell
  4. Subject:  [patch] - PermitUnprivilegedPort - 1.2.26/27
  5. From:     Paul Gampe <paulg@apnic.net>
  6. Date:     1999-10-19 23:27:24
  7.  
  8. Hi All,
  9.  
  10. For anyone using ssh via a socks gateway the attached patch allows you to
  11. permit connections from unprivileged ports.  The option is configurable in
  12. sshd_config using the name:
  13.  
  14.         PermitUnprivilegedPort
  15.  
  16. I've not played with ssh2 yet, so is this necessary in the new server?
  17. Paulg.
  18.  
  19. ["APNIC.patch" (TEXT/PLAIN)]
  20.  
  21. diff -r -C6 ssh-1.2.26.orig/auth-rhosts.c ssh-1.2.26/auth-rhosts.c
  22. *** ssh-1.2.26.orig/auth-rhosts.c       Thu Jul  9 02:40:35 1998
  23. --- ssh-1.2.26/auth-rhosts.c    Wed Jul 15 10:16:40 1998
  24. ***************
  25. *** 344,362 ****
  26.  
  27.     /* Check that the connection comes from a privileged port.
  28.        Rhosts authentication only makes sense for privileged programs.
  29.        Of course, if the intruder has root access on his local machine,
  30.        he can connect from any port.  So do not use .rhosts
  31.        authentication from machines that you do not trust. */
  32. !   if (port >= IPPORT_RESERVED ||
  33. !       port < IPPORT_RESERVED / 2)
  34.       {
  35. !       log_msg("Connection from %.100s from nonprivileged port %d",
  36. !         hostname, port);
  37. !       packet_send_debug("Your ssh client is not running as root.");
  38. !       return 0;
  39.       }
  40.  
  41.     /* If not logging in as superuser, try /etc/hosts.equiv and shosts.equiv. */
  42.     if (pw->pw_uid != UID_ROOT)
  43.       {
  44.         if (check_rhosts_file(geteuid(),
  45. --- 344,368 ----
  46.  
  47.     /* Check that the connection comes from a privileged port.
  48.        Rhosts authentication only makes sense for privileged programs.
  49.        Of course, if the intruder has root access on his local machine,
  50.        he can connect from any port.  So do not use .rhosts
  51.        authentication from machines that you do not trust. */
  52. !   if ((port >= IPPORT_RESERVED ||
  53. !       port < IPPORT_RESERVED / 2) )
  54.       {
  55. !     if (options.permit_unprivileged_port)
  56. !         {
  57. !           log_msg("Connection from %.100s from nonprivileged port %d enabled",
  58. !             hostname, port);
  59. !         } else {
  60. !           log_msg("Connection from %.100s from nonprivileged port %d",
  61. !             hostname, port);
  62. !           packet_send_debug("Your ssh client is not running as root.");
  63. !           return 0;
  64. !         }
  65.       }
  66.  
  67.     /* If not logging in as superuser, try /etc/hosts.equiv and shosts.equiv. */
  68.     if (pw->pw_uid != UID_ROOT)
  69.       {
  70.         if (check_rhosts_file(geteuid(),
  71. diff -r -C6 ssh-1.2.26.orig/servconf.c ssh-1.2.26/servconf.c
  72. *** ssh-1.2.26.orig/servconf.c  Thu Jul  9 02:40:38 1998
  73. --- ssh-1.2.26/servconf.c       Tue Jul 14 12:35:26 1998
  74. ***************
  75. *** 107,118 ****
  76. --- 107,119 ----
  77.     options->kerberos_or_local_passwd = -1;
  78.     options->kerberos_tgt_passing = -1;
  79.     options->tis_authentication = -1;
  80.     options->allow_tcp_forwarding = -1;
  81.     options->password_authentication = -1;
  82.     options->permit_empty_passwd = -1;
  83. +   options->permit_unprivileged_port = -1;
  84.     options->use_login = -1;
  85.     options->silent_deny = -1;
  86.     options->forced_passwd_change = -1;
  87.     options->forced_empty_passwd_change = -1;
  88.     options->num_allow_shosts = 0;
  89.     options->num_deny_shosts = 0;
  90. ***************
  91. *** 208,219 ****
  92. --- 209,222 ----
  93.     if (options->tis_authentication == -1)
  94.       options->tis_authentication = 0;
  95.     if (options->password_authentication == -1)
  96.       options->password_authentication = 1;
  97.     if (options->permit_empty_passwd == -1)
  98.       options->permit_empty_passwd = 1;
  99. +   if (options->permit_unprivileged_port == -1)
  100. +     options->permit_unprivileged_port = 0;
  101.     if (options->use_login == -1)
  102.       options->use_login = 0;
  103.     if (options->silent_deny == -1)
  104.       options->silent_deny = 0;
  105.     if (options->forced_passwd_change == -1)
  106.       options->forced_passwd_change = 1;
  107. ***************
  108. *** 249,261 ****
  109.     sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sPidFile,
  110.     sForcedPasswd, sForcedEmptyPasswd, sUmask, sSilentDeny, sIdleTimeout,
  111.     sUseLogin, sKerberosAuthentication, sKerberosOrLocalPasswd,
  112.     sKerberosTgtPassing, sAllowTcpForwarding, sAllowUsers, sDenyUsers,
  113.     sXauthPath, sCheckMail, sDenyGroups, sAllowGroups, sIgnoreRootRhosts,
  114.     sAllowSHosts, sDenySHosts, sPasswordExpireWarningDays,
  115. !   sAccountExpireWarningDays
  116.   #ifdef F_SECURE_COMMERCIAL
  117.  
  118.  
  119.   #endif /* F_SECURE_COMMERCIAL */
  120.   } ServerOpCodes;
  121.  
  122. --- 252,264 ----
  123.     sStrictModes, sEmptyPasswd, sRandomSeedFile, sKeepAlives, sPidFile,
  124.     sForcedPasswd, sForcedEmptyPasswd, sUmask, sSilentDeny, sIdleTimeout,
  125.     sUseLogin, sKerberosAuthentication, sKerberosOrLocalPasswd,
  126.     sKerberosTgtPassing, sAllowTcpForwarding, sAllowUsers, sDenyUsers,
  127.     sXauthPath, sCheckMail, sDenyGroups, sAllowGroups, sIgnoreRootRhosts,
  128.     sAllowSHosts, sDenySHosts, sPasswordExpireWarningDays,
  129. !   sAccountExpireWarningDays, sPermitUnprivilegedPort
  130.   #ifdef F_SECURE_COMMERCIAL
  131.  
  132.  
  133.   #endif /* F_SECURE_COMMERCIAL */
  134.   } ServerOpCodes;
  135.  
  136. ***************
  137. *** 286,297 ****
  138. --- 289,301 ----
  139.     { "allowhosts", sAllowHosts },
  140.     { "denyhosts", sDenyHosts },
  141.     { "allowusers", sAllowUsers },
  142.     { "denyusers", sDenyUsers },
  143.     { "allowgroups", sAllowGroups },
  144.     { "denygroups", sDenyGroups },
  145. +   { "denygroups", sDenyGroups },
  146.   #ifdef F_SECURE_COMMERCIAL
  147.  
  148.  
  149.  
  150.  
  151.   #endif /* F_SECURE_COMMERCIAL */
  152. ***************
  153. *** 315,326 ****
  154. --- 319,331 ----
  155.     { "kerberostgtpassing", sKerberosTgtPassing },
  156.     { "allowtcpforwarding", sAllowTcpForwarding },
  157.     { "xauthlocation", sXauthPath },
  158.     { "checkmail", sCheckMail },
  159.     { "passwordexpirewarningdays", sPasswordExpireWarningDays },
  160.     { "accountexpirewarningdays", sAccountExpireWarningDays },
  161. +   { "permitunprivilegedport", sPermitUnprivilegedPort },
  162.     { NULL, 0 }
  163.   };
  164.  
  165.   static struct
  166.   {
  167.     const char *name;
  168. ***************
  169. *** 609,620 ****
  170. --- 614,629 ----
  171.           goto parse_flag;
  172.  
  173.         case sEmptyPasswd:
  174.           intptr = &options->permit_empty_passwd;
  175.           goto parse_flag;
  176.  
  177. +       case sPermitUnprivilegedPort:
  178. +         intptr = &options->permit_unprivileged_port;
  179. +         goto parse_flag;
  180. +
  181.         case sSilentDeny:
  182.           intptr = &options->silent_deny;
  183.           goto parse_flag;
  184.  
  185.         case sForcedPasswd:
  186.           intptr = &options->forced_passwd_change;
  187. diff -r -C6 ssh-1.2.26.orig/servconf.h ssh-1.2.26/servconf.h
  188. *** ssh-1.2.26.orig/servconf.h  Thu Jul  9 02:40:38 1998
  189. --- ssh-1.2.26/servconf.h       Tue Jul 14 12:20:48 1998
  190. ***************
  191. *** 112,123 ****
  192. --- 112,124 ----
  193.                                    as SecurID or /etc/passwd */
  194.     int kerberos_tgt_passing;   /* If true, permit Kerberos tgt passing. */
  195.     int allow_tcp_forwarding;
  196.     int tis_authentication;     /* If true, permit TIS authsrv auth. */
  197.     int password_authentication;  /* If true, permit password authentication. */
  198.     int permit_empty_passwd;      /* If false, do not permit empty passwords. */
  199. +   int permit_unprivileged_port; /* If true, permit rhosts from unpriv ports */
  200.     int use_login;              /* Use /bin/login if possible */
  201.     int silent_deny;            /* 1 = deny by closing sockets. */
  202.     int forced_empty_passwd_change; /* If true, force password change if empty
  203.                                    password (first login). */
  204.     int forced_passwd_change;     /* If true, force password change if password
  205.                                    too old. */
  206. diff -r -C6 ssh-1.2.26.orig/sshd.c ssh-1.2.26/sshd.c
  207. *** ssh-1.2.26.orig/sshd.c      Thu Jul  9 02:40:38 1998
  208. --- ssh-1.2.26/sshd.c   Wed Jul 15 10:17:51 1998
  209. ***************
  210. *** 2300,2314 ****
  211.               break;
  212.             }
  213.  
  214.           /* Rhosts authentication (also uses /etc/hosts.equiv). */
  215.           if (!privileged_port)
  216.             {
  217. !             packet_get_all();
  218. !             log_msg("Rhosts authentication not available for connections from unprivileged port.");
  219. !             break;
  220.             }
  221.  
  222.           /* Get client user name.  Note that we just have to trust the client;
  223.              this is one reason why rhosts authentication is insecure.
  224.              (Another is IP-spoofing on a local network.) */
  225.           client_user = packet_get_string(NULL);
  226. --- 2300,2319 ----
  227.               break;
  228.             }
  229.  
  230.           /* Rhosts authentication (also uses /etc/hosts.equiv). */
  231.           if (!privileged_port)
  232.             {
  233. !           if (options.permit_unprivileged_port)
  234. !             {
  235. !                 log_msg("Rhosts authentication for connections from unprivilieged port enabled.");
  236. !             } else {
  237. !                 packet_get_all();
  238. !                 log_msg("Rhosts authentication not available for connections from unprivileged port.");
  239. !                 break;
  240. !             }
  241.             }
  242.  
  243.           /* Get client user name.  Note that we just have to trust the client;
  244.              this is one reason why rhosts authentication is insecure.
  245.              (Another is IP-spoofing on a local network.) */
  246.           client_user = packet_get_string(NULL);
  247. ***************
  248. *** 2338,2350 ****
  249.               log_msg("Rhosts with RSA authentication disabled.");
  250.               break;
  251.             }
  252.  
  253.           /* Rhosts authentication (also uses /etc/hosts.equiv) with RSA
  254.              host authentication. */
  255. !         if (!privileged_port)
  256.             {
  257.               packet_get_all();
  258.               log_msg("RhostsRsa authentication not available for connections from unprivileged port.");
  259.               break;
  260.             }
  261.           if (cipher_type == SSH_CIPHER_NONE)
  262. --- 2343,2355 ----
  263.               log_msg("Rhosts with RSA authentication disabled.");
  264.               break;
  265.             }
  266.  
  267.           /* Rhosts authentication (also uses /etc/hosts.equiv) with RSA
  268.              host authentication. */
  269. !         if (!privileged_port && !options.permit_unprivileged_port)
  270.             {
  271.               packet_get_all();
  272.               log_msg("RhostsRsa authentication not available for connections from unprivileged port.");
  273.               break;
  274.             }
  275.           if (cipher_type == SSH_CIPHER_NONE)
  276.  
  277.