Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 18th, 2012  |  syntax: None  |  size: 23.44 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff -ruN openssh-6.0p1/Makefile.in openssh-6.0p1-secuireid/Makefile.in
  2. --- openssh-6.0p1/Makefile.in   2012-04-04 10:27:57.000000000 +0900
  3. +++ openssh-6.0p1-secuireid/Makefile.in 2012-08-05 15:37:07.000000000 +0900
  4. @@ -84,6 +84,7 @@
  5.         auth-chall.o auth2-chall.o groupaccess.o \
  6.         auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
  7.         auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \
  8. +       auth2-securid.o \
  9.         monitor_mm.o monitor.o monitor_wrap.o kexdhs.o kexgexs.o kexecdhs.o \
  10.         auth-krb5.o \
  11.         auth2-gss.o gss-serv.o gss-serv-krb5.o \
  12. diff -ruN openssh-6.0p1/auth.h openssh-6.0p1-secuireid/auth.h
  13. --- openssh-6.0p1/auth.h        2011-05-29 20:39:38.000000000 +0900
  14. +++ openssh-6.0p1-secuireid/auth.h      2012-08-05 15:37:07.000000000 +0900
  15. @@ -73,6 +73,12 @@
  16.  #endif
  17.         Buffer          *loginmsg;
  18.         void            *methoddata;
  19. +#if defined (SECURID) || defined (SECURID_OLD)
  20. +       int    securid_state;
  21. +       void  *securid_data;
  22. +       char  *securid_pin;
  23. +       char  *securid_real_user;
  24. +#endif
  25.  };
  26.  /*
  27.   * Every authentication method has to handle authentication requests for
  28. diff -ruN openssh-6.0p1/auth2-chall.c openssh-6.0p1-secuireid/auth2-chall.c
  29. --- openssh-6.0p1/auth2-chall.c 2009-01-28 14:13:39.000000000 +0900
  30. +++ openssh-6.0p1-secuireid/auth2-chall.c       2012-08-05 15:37:07.000000000 +0900
  31. @@ -53,6 +53,9 @@
  32.  #ifdef BSD_AUTH
  33.  extern KbdintDevice bsdauth_device;
  34.  #else
  35. +#if defined (SECURID) || defined (SECURID_OLD)
  36. +extern KbdintDevice securid_device;
  37. +#endif
  38.  #ifdef USE_PAM
  39.  extern KbdintDevice sshpam_device;
  40.  #endif
  41. @@ -65,6 +68,9 @@
  42.  #ifdef BSD_AUTH
  43.         &bsdauth_device,
  44.  #else
  45. +#if defined (SECURID) || defined (SECURID_OLD)
  46. +       &securid_device,
  47. +#endif
  48.  #ifdef USE_PAM
  49.         &sshpam_device,
  50.  #endif
  51. @@ -221,6 +227,7 @@
  52.         debug2("auth2_challenge_start: devices %s",
  53.             kbdintctxt->devices ?  kbdintctxt->devices : "<empty>");
  54.  
  55. + kbd_next_device:
  56.         if (kbdint_next_device(kbdintctxt) == 0) {
  57.                 auth2_challenge_stop(authctxt);
  58.                 return 0;
  59. @@ -228,10 +235,9 @@
  60.         debug("auth2_challenge_start: trying authentication method '%s'",
  61.             kbdintctxt->device->name);
  62.  
  63. -       if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) {
  64. -               auth2_challenge_stop(authctxt);
  65. -               return 0;
  66. -       }
  67. +       if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL)
  68. +               goto kbd_next_device;
  69. +
  70.         if (send_userauth_info_request(authctxt) == 0) {
  71.                 auth2_challenge_stop(authctxt);
  72.                 return 0;
  73. @@ -348,12 +354,16 @@
  74.  void
  75.  privsep_challenge_enable(void)
  76.  {
  77. -#if defined(BSD_AUTH) || defined(USE_PAM) || defined(SKEY)
  78. +#if defined(BSD_AUTH) || defined(USE_PAM) || defined(SKEY) || \
  79. +defined (SECURID) || defined (SECURID_OLD)
  80.         int n = 0;
  81.  #endif
  82.  #ifdef BSD_AUTH
  83.         extern KbdintDevice mm_bsdauth_device;
  84.  #endif
  85. +#if defined (SECURID) || defined (SECURID_OLD)
  86. +       extern KbdintDevice mm_securid_device;
  87. +#endif
  88.  #ifdef USE_PAM
  89.         extern KbdintDevice mm_sshpam_device;
  90.  #endif
  91. @@ -364,6 +374,9 @@
  92.  #ifdef BSD_AUTH
  93.         devices[n++] = &mm_bsdauth_device;
  94.  #else
  95. +#if defined (SECURID) || defined (SECURID_OLD)
  96. +       devices[n++] = &mm_securid_device;
  97. +#endif
  98.  #ifdef USE_PAM
  99.         devices[n++] = &mm_sshpam_device;
  100.  #endif
  101. diff -ruN openssh-6.0p1/config.h.in openssh-6.0p1-secuireid/config.h.in
  102. --- openssh-6.0p1/config.h.in   2012-04-20 14:03:32.000000000 +0900
  103. +++ openssh-6.0p1-secuireid/config.h.in 2012-08-05 15:37:07.000000000 +0900
  104. @@ -1353,6 +1353,12 @@
  105.  /* must supply username to passwd */
  106.  #undef PASSWD_NEEDS_USERNAME
  107.  
  108. +/* Support for ACE/Server 5.x */
  109. +#undef SECURID
  110. +
  111. +/* Support for ACE/Agent 3.x, which can comunicate with ACE/Server 3.x and 5.x too */
  112. +#undef SECURID_OLD
  113. +
  114.  /* Port number of PRNGD/EGD random number socket */
  115.  #undef PRNGD_PORT
  116.  
  117. diff -ruN openssh-6.0p1/configure openssh-6.0p1-secuireid/configure
  118. --- openssh-6.0p1/configure     2012-04-20 14:03:38.000000000 +0900
  119. +++ openssh-6.0p1-secuireid/configure   2012-08-05 15:37:07.000000000 +0900
  120. @@ -1411,6 +1411,8 @@
  121.    --with-zlib=PATH        Use zlib in PATH
  122.    --without-zlib-version-check Disable zlib version check
  123.    --with-skey[=PATH]      Enable S/Key support (optionally in PATH)
  124. +  --with-securid[=PATH]   Enable ACE/Server (SecurID) support
  125. +                            (optionally in PATH)
  126.    --with-tcp-wrappers[=PATH] Enable tcpwrappers support (optionally in PATH)
  127.    --with-ldns[=PATH]      Use ldns for DNSSEC support (optionally in PATH)
  128.    --with-libedit[=PATH]   Enable libedit support for sftp
  129. @@ -9002,6 +9004,91 @@
  130.  fi
  131.  
  132.  
  133. +
  134. +
  135. +
  136. +# Check whether user wants SecurID support
  137. +SECURID_MSG="no"
  138. +
  139. +# Check whether --with-securid or --without-securid was given.
  140. +if test "${with_securid+set}" = set; then
  141. +  withval="$with_securid"
  142. +
  143. +               if test "$withval" != "no" ; then
  144. +                       if test -n "$withval"; then
  145. +                               if test "$withval" = "yes"; then
  146. +                                       # default location
  147. +                                       withval="/var/ace"
  148. +                               fi
  149. +
  150. +                               # new client for ACE/Server version 5.x
  151. +                               echo "$as_me:$LINENO: checking for ACE/Agent libs version 5.x" >&5
  152. +echo $ECHO_N "checking for ACE/Agent libs version 5.x... $ECHO_C" >&6
  153. +                               if test -f "$withval/inc/acclnt.h"; then
  154. +                                       case "$host" in
  155. +                                               *-*-aix*)
  156. +                                                       PLATFORM="aix"
  157. +                                                       THREAD_LIBS="-lpthreads -lc_r"
  158. +                                                       ;;
  159. +                                               *-*-hpux10*)
  160. +                                                       PLATFORM="hp"
  161. +                                                       THREAD_LIBS="-ldce"
  162. +                                                       ;;
  163. +                                               *-*-hpux11*)
  164. +                                                       PLATFORM="hp11"
  165. +                                                       THREAD_LIBS="-lpthread"
  166. +                                                       ;;
  167. +                                               *-*-linux*)
  168. +                                                       PLATFORM="lnx"
  169. +                                                       THREAD_LIBS="-lpthread"
  170. +                                                       ;;
  171. +                                               *-*-solaris*)
  172. +                                                       PLATFORM="sol"
  173. +                                                       THREAD_LIBS="-lthread"
  174. +                                                       ;;
  175. +                                       esac
  176. +                                       if test -f "$withval/lib/$PLATFORM/libaceclnt.a"; then
  177. +                                               echo "$as_me:$LINENO: result: found" >&5
  178. +echo "${ECHO_T}found" >&6
  179. +                                               cat >>confdefs.h <<\_ACEOF
  180. +#define SECURID 1
  181. +_ACEOF
  182. +
  183. +                                               SECURID_MSG="yes (for 5.x)"
  184. +                                               CFLAGS="$CFLAGS -I$withval/inc"
  185. +                                               LIBS="$LIBS $withval/lib/$PLATFORM/libaceclnt.a $THREAD_LIBS"
  186. +                                       fi
  187. +                               else
  188. +                                       echo "$as_me:$LINENO: result: not found" >&5
  189. +echo "${ECHO_T}not found" >&6
  190. +                                       # old client for ACE/server version 3.x
  191. +                                       echo "$as_me:$LINENO: checking for ACE/Agent libs version 3.x" >&5
  192. +echo $ECHO_N "checking for ACE/Agent libs version 3.x... $ECHO_C" >&6
  193. +                                       if test -f "$withval/sdiclient.a"; then
  194. +                                               # sdiclient.a found in $withval
  195. +                                               echo "$as_me:$LINENO: result: found" >&5
  196. +echo "${ECHO_T}found" >&6
  197. +                                               cat >>confdefs.h <<\_ACEOF
  198. +#define SECURID_OLD 1
  199. +_ACEOF
  200. +
  201. +                                               SECURID_MSG="yes (for 3.x)"
  202. +                                               CFLAGS="$CFLAGS -I$withval"
  203. +                                               LIBS="$withval/sdiclient.a $LIBS"
  204. +                                       else
  205. +                                               echo "$as_me:$LINENO: result: not found" >&5
  206. +echo "${ECHO_T}not found" >&6
  207. +                                               { { echo "$as_me:$LINENO: error: no ACE libs found !!" >&5
  208. +echo "$as_me: error: no ACE libs found !!" >&2;}
  209. +   { (exit 1); exit 1; }; }
  210. +                                       fi
  211. +                               fi
  212. +                       fi
  213. +               fi
  214. +
  215. +
  216. +fi;
  217. +
  218.  # Check whether user wants TCP wrappers support
  219.  TCPW_MSG="no"
  220.  
  221. @@ -17925,6 +18012,7 @@
  222.  echo "                   SELinux support: $SELINUX_MSG"
  223.  echo "                 Smartcard support: $SCARD_MSG"
  224.  echo "                     S/KEY support: $SKEY_MSG"
  225. +echo "                   SecurID support: $SECURID_MSG"
  226.  echo "              TCP Wrappers support: $TCPW_MSG"
  227.  echo "              MD5 password support: $MD5_MSG"
  228.  echo "                   libedit support: $LIBEDIT_MSG"
  229. diff -ruN openssh-6.0p1/configure.ac openssh-6.0p1-secuireid/configure.ac
  230. --- openssh-6.0p1/configure.ac  2012-04-19 20:46:38.000000000 +0900
  231. +++ openssh-6.0p1-secuireid/configure.ac        2012-08-05 15:37:07.000000000 +0900
  232. @@ -1313,6 +1313,75 @@
  233.         ]
  234.  )
  235.  
  236. +AH_TEMPLATE([SECURID], [Support for ACE/Server 5.x])
  237. +AH_TEMPLATE([SECURID_OLD], [Support for ACE/Agent 3.x, which can comunicate
  238. +                                                       with ACE/Server 3.x and 5.x too])
  239. +# Check whether user wants SecurID support
  240. +SECURID_MSG="no"
  241. +AC_ARG_WITH(securid,
  242. +       [  --with-securid[[=PATH]]   Enable ACE/Server (SecurID) support
  243. +                            (optionally in PATH)],
  244. +       [
  245. +               if test "$withval" != "no" ; then
  246. +                       if test -n "$withval"; then
  247. +                               if test "$withval" = "yes"; then
  248. +                                       # default location
  249. +                                       withval="/var/ace"
  250. +                               fi
  251. +
  252. +                               # new client for ACE/Server version 5.x
  253. +                               AC_MSG_CHECKING([for ACE/Agent libs version 5.x])
  254. +                               if test -f "$withval/inc/acclnt.h"; then
  255. +                                       case "$host" in
  256. +                                               *-*-aix*)
  257. +                                                       PLATFORM="aix"
  258. +                                                       THREAD_LIBS="-lpthreads -lc_r"
  259. +                                                       ;;
  260. +                                               *-*-hpux10*)
  261. +                                                       PLATFORM="hp"
  262. +                                                       THREAD_LIBS="-ldce"
  263. +                                                       ;;
  264. +                                               *-*-hpux11*)
  265. +                                                       PLATFORM="hp11"
  266. +                                                       THREAD_LIBS="-lpthread"
  267. +                                                       ;;
  268. +                                               *-*-linux*)
  269. +                                                       PLATFORM="lnx"
  270. +                                                       THREAD_LIBS="-lpthread"
  271. +                                                       ;;
  272. +                                               *-*-solaris*)
  273. +                                                       PLATFORM="sol"
  274. +                                                       THREAD_LIBS="-lthread"
  275. +                                                       ;;
  276. +                                       esac
  277. +                                       if test -f "$withval/lib/$PLATFORM/libaceclnt.a"; then
  278. +                                               AC_MSG_RESULT(found)
  279. +                                               AC_DEFINE(SECURID)
  280. +                                               SECURID_MSG="yes (for 5.x)"
  281. +                                               CFLAGS="$CFLAGS -I$withval/inc"
  282. +                                               LIBS="$LIBS $withval/lib/$PLATFORM/libaceclnt.a $THREAD_LIBS"
  283. +                                       fi
  284. +                               else
  285. +                                       AC_MSG_RESULT(not found)
  286. +                                       # old client for ACE/server version 3.x
  287. +                                       AC_MSG_CHECKING([for ACE/Agent libs version 3.x])
  288. +                                       if test -f "$withval/sdiclient.a"; then
  289. +                                               # sdiclient.a found in $withval
  290. +                                               AC_MSG_RESULT(found)
  291. +                                               AC_DEFINE(SECURID_OLD)
  292. +                                               SECURID_MSG="yes (for 3.x)"
  293. +                                               CFLAGS="$CFLAGS -I$withval"
  294. +                                               LIBS="$withval/sdiclient.a $LIBS"
  295. +                                       else
  296. +                                               AC_MSG_RESULT(not found)
  297. +                                               AC_MSG_ERROR([no ACE libs found !!])
  298. +                                       fi
  299. +                               fi
  300. +                       fi
  301. +               fi
  302. +       ]
  303. +)
  304. +
  305.  # Check whether user wants TCP wrappers support
  306.  TCPW_MSG="no"
  307.  AC_ARG_WITH([tcp-wrappers],
  308. diff -ruN openssh-6.0p1/monitor.c openssh-6.0p1-secuireid/monitor.c
  309. --- openssh-6.0p1/monitor.c     2012-02-11 06:16:09.000000000 +0900
  310. +++ openssh-6.0p1-secuireid/monitor.c   2012-08-05 15:37:07.000000000 +0900
  311. @@ -102,6 +102,10 @@
  312.  static Gssctxt *gsscontext = NULL;
  313.  #endif
  314.  
  315. +#if defined (SECURID) || defined (SECURID_OLD)
  316. +#include "auth2-securid.h"
  317. +#endif
  318. +
  319.  /* Imports */
  320.  extern ServerOptions options;
  321.  extern u_int utmp_len;
  322. @@ -182,6 +186,12 @@
  323.  int mm_answer_gss_checkmic(int, Buffer *);
  324.  #endif
  325.  
  326. +#if defined (SECURID) || defined (SECURID_OLD)
  327. +int mm_answer_securid_init_ctx(int, Buffer *);
  328. +int mm_answer_securid_query(int, Buffer *);
  329. +int mm_answer_securid_respond(int, Buffer *);
  330. +#endif
  331. +
  332.  #ifdef SSH_AUDIT_EVENTS
  333.  int mm_answer_audit_event(int, Buffer *);
  334.  int mm_answer_audit_command(int, Buffer *);
  335. @@ -252,6 +262,11 @@
  336.      {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
  337.      {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
  338.  #endif
  339. +#if defined (SECURID) || defined (SECURID_OLD)
  340. +       {MONITOR_REQ_SECURID_INIT_CTX, MON_ISAUTH, mm_answer_securid_init_ctx},
  341. +       {MONITOR_REQ_SECURID_QUERY, MON_ISAUTH, mm_answer_securid_query},
  342. +       {MONITOR_REQ_SECURID_RESPOND, MON_AUTH, mm_answer_securid_respond},
  343. +#endif
  344.  #ifdef JPAKE
  345.      {MONITOR_REQ_JPAKE_GET_PWDATA, MON_ONCE, mm_answer_jpake_get_pwdata},
  346.      {MONITOR_REQ_JPAKE_STEP1, MON_ISAUTH, mm_answer_jpake_step1},
  347. @@ -2105,6 +2120,96 @@
  348.  }
  349.  #endif /* GSSAPI */
  350.  
  351. +#if defined (SECURID) || defined (SECURID_OLD)
  352. +int
  353. +mm_answer_securid_init_ctx(int socket, Buffer *m)
  354. +{
  355. +    u_int success;
  356. +
  357. +    debug3("%s entering", __func__);
  358. +
  359. +    success = securid_init_ctx(authctxt) == NULL ? 0 : 1;
  360. +
  361. +    buffer_clear(m);
  362. +    buffer_put_int(m, success);
  363. +
  364. +       auth_method = "securid";
  365. +    mm_request_send(socket, MONITOR_ANS_SECURID_INIT_CTX, m);
  366. +    return 0;
  367. +}
  368. +
  369. +int
  370. +mm_answer_securid_query(int socket, Buffer *m)
  371. +{
  372. +       char *name, *infotxt;
  373. +       u_int numprompts;
  374. +       u_int *echo_on;
  375. +       char **prompts;
  376. +       u_int success;
  377. +
  378. +       success = securid_query(authctxt, &name, &infotxt, &numprompts,
  379. +           &prompts, &echo_on) < 0 ? 0 : 1;
  380. +
  381. +       buffer_clear(m);
  382. +       buffer_put_int(m, success);
  383. +       if (success) {
  384. +               buffer_put_cstring(m, prompts[0]);
  385. +        buffer_put_int(m, echo_on[0]);
  386. +    }
  387. +
  388. +       debug3("%s: sending challenge success: %u", __func__, success);
  389. +       mm_request_send(socket, MONITOR_ANS_SECURID_QUERY, m);
  390. +
  391. +       if (success) {
  392. +               xfree(name);
  393. +               xfree(infotxt);
  394. +               xfree(prompts);
  395. +               xfree(echo_on);
  396. +       }
  397. +
  398. +       return 0;
  399. +}
  400. +
  401. +/*
  402. + * respond    returns: 0 - success, 1 - need further interaction,
  403. + */
  404. +int
  405. +mm_answer_securid_respond(int socket, Buffer *m)
  406. +{
  407. +    char **responses;
  408. +       int authok, rlen;
  409. +
  410. +    responses = xmalloc(sizeof(char *));
  411. +    responses[0] = buffer_get_string(m, &rlen);
  412. +
  413. +       authok = securid_respond(authctxt, 1, responses);
  414. +
  415. +    memset(responses[0], 0, rlen);
  416. +    xfree(responses[0]);
  417. +    xfree(responses);
  418. +
  419. +    if (authok < 0)
  420. +        authok = 100;
  421. +
  422. +    /*
  423. +     * kdyz jednou vratim 1, tak je to povazovano za uspesnou autentizaci
  424. +     * a monitor se rozjede dal a neni radno do nej zasahovat, proto
  425. +     * je securid_free_ctx zde
  426. +     */
  427. +    if (authok != 1)
  428. +        securid_free_ctx(authctxt);
  429. +
  430. +       buffer_clear(m);
  431. +       buffer_put_int(m, authok);
  432. +
  433. +       mm_request_send(socket, MONITOR_ANS_SECURID_RESPOND, m);
  434. +
  435. +       auth_method = "securid";
  436. +
  437. +       return (authok == 0);
  438. +}
  439. +#endif /* SECURID || SECURID_OLD */
  440. +
  441.  #ifdef JPAKE
  442.  int
  443.  mm_answer_jpake_step1(int sock, Buffer *m)
  444. diff -ruN openssh-6.0p1/monitor.h openssh-6.0p1-secuireid/monitor.h
  445. --- openssh-6.0p1/monitor.h     2011-06-20 13:42:23.000000000 +0900
  446. +++ openssh-6.0p1-secuireid/monitor.h   2012-08-05 15:37:07.000000000 +0900
  447. @@ -59,6 +59,11 @@
  448.         MONITOR_REQ_PAM_QUERY, MONITOR_ANS_PAM_QUERY,
  449.         MONITOR_REQ_PAM_RESPOND, MONITOR_ANS_PAM_RESPOND,
  450.         MONITOR_REQ_PAM_FREE_CTX, MONITOR_ANS_PAM_FREE_CTX,
  451. +#if defined (SECURID) || defined (SECURID_OLD)
  452. +       MONITOR_REQ_SECURID_INIT_CTX,   MONITOR_ANS_SECURID_INIT_CTX,
  453. +       MONITOR_REQ_SECURID_QUERY,              MONITOR_ANS_SECURID_QUERY,
  454. +       MONITOR_REQ_SECURID_RESPOND,    MONITOR_ANS_SECURID_RESPOND,
  455. +#endif
  456.         MONITOR_REQ_AUDIT_EVENT, MONITOR_REQ_AUDIT_COMMAND,
  457.         MONITOR_REQ_TERM,
  458.         MONITOR_REQ_JPAKE_STEP1, MONITOR_ANS_JPAKE_STEP1,
  459. diff -ruN openssh-6.0p1/monitor_wrap.c openssh-6.0p1-secuireid/monitor_wrap.c
  460. --- openssh-6.0p1/monitor_wrap.c        2011-06-20 13:42:23.000000000 +0900
  461. +++ openssh-6.0p1-secuireid/monitor_wrap.c      2012-08-05 15:37:07.000000000 +0900
  462. @@ -67,6 +67,9 @@
  463.  #ifdef GSSAPI
  464.  #include "ssh-gss.h"
  465.  #endif
  466. +#if defined (SECURID) || defined (SECURID_OLD)
  467. +#include "auth2-securid.h"
  468. +#endif
  469.  #include "monitor_wrap.h"
  470.  #include "atomicio.h"
  471.  #include "monitor_fdpass.h"
  472. @@ -1288,6 +1291,82 @@
  473.         return (authenticated);
  474.  }
  475.  #endif /* GSSAPI */
  476. +#if defined (SECURID) || defined (SECURID_OLD)
  477. +void *
  478. +mm_securid_init_ctx(struct Authctxt *authctxt)
  479. +{
  480. +    Buffer m;
  481. +       u_int success;
  482. +
  483. +    debug3("%s entering", __func__);
  484. +
  485. +    buffer_init(&m);
  486. +
  487. +    mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SECURID_INIT_CTX, &m);
  488. +    debug3("%s: waiting for MONITOR_ANS_SECURID_INIT_CTX (%d)", __func__, MONITOR_ANS_SECURID_INIT_CTX);
  489. +    mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SECURID_INIT_CTX, &m);
  490. +
  491. +    success = buffer_get_int(&m);
  492. +    buffer_free(&m);
  493. +
  494. +    return ((success == 0) ? NULL : authctxt);
  495. +}
  496. +
  497. +int
  498. +mm_securid_query(void *ctx, char **name, char **infotxt,
  499. +   u_int *numprompts, char ***prompts, u_int **echo_on)
  500. +{
  501. +       Buffer m;
  502. +       u_int success;
  503. +
  504. +       debug3("%s: entering", __func__);
  505. +
  506. +       buffer_init(&m);
  507. +       mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SECURID_QUERY, &m);
  508. +    debug3("%s: waiting for MONITOR_ANS_SECURID_QUERY (%d)", __func__, MONITOR_ANS_SECURID_QUERY);
  509. +       mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SECURID_QUERY, &m);
  510. +
  511. +       success = buffer_get_int(&m);
  512. +       if (success == 0) {
  513. +               debug3("%s: no challenge", __func__);
  514. +               buffer_free(&m);
  515. +               return (-1);
  516. +       }
  517. +
  518. +       mm_chall_setup(name, infotxt, numprompts, prompts, echo_on);
  519. +       (*prompts)[0] = buffer_get_string(&m, NULL);
  520. +    (*echo_on)[0] = buffer_get_int(&m);
  521. +
  522. +       buffer_free(&m);
  523. +
  524. +       return (0);
  525. +}
  526. +
  527. +/*
  528. + * respond    returns: 0 - success, 1 - need further interaction,
  529. + */
  530. +int
  531. +mm_securid_respond(void *ctx, u_int numresponses, char **responses)
  532. +{
  533. +       Buffer m;
  534. +       int authok;
  535. +
  536. +       debug3("%s: entering", __func__);
  537. +       if (numresponses != 1)
  538. +               return (-1);
  539. +
  540. +       buffer_init(&m);
  541. +       buffer_put_cstring(&m, responses[0]);
  542. +       mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_SECURID_RESPOND, &m);
  543. +
  544. +       mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_SECURID_RESPOND, &m);
  545. +
  546. +       authok = buffer_get_int(&m);
  547. +       buffer_free(&m);
  548. +
  549. +       return authok;
  550. +}
  551. +#endif /* SECURID || SECURID_OLD */
  552.  
  553.  #ifdef JPAKE
  554.  void
  555. diff -ruN openssh-6.0p1/monitor_wrap.h openssh-6.0p1-secuireid/monitor_wrap.h
  556. --- openssh-6.0p1/monitor_wrap.h        2011-06-20 13:42:23.000000000 +0900
  557. +++ openssh-6.0p1-secuireid/monitor_wrap.h      2012-08-05 15:37:07.000000000 +0900
  558. @@ -102,6 +102,13 @@
  559.  int mm_skey_query(void *, char **, char **, u_int *, char ***, u_int **);
  560.  int mm_skey_respond(void *, u_int, char **);
  561.  
  562. +/* securid */
  563. +#if defined (SECURID) || defined (SECURID_OLD)
  564. +void *mm_securid_init_ctx(struct Authctxt *);
  565. +int mm_securid_query(void *, char **, char **, u_int *, char ***, u_int **);
  566. +int mm_securid_respond(void *, u_int, char **);
  567. +#endif
  568. +
  569.  /* jpake */
  570.  struct modp_group;
  571.  void mm_auth2_jpake_get_pwdata(struct Authctxt *, BIGNUM **, char **, char **);
  572. diff -ruN openssh-6.0p1/servconf.c openssh-6.0p1-secuireid/servconf.c
  573. --- openssh-6.0p1/servconf.c    2011-10-02 16:57:38.000000000 +0900
  574. +++ openssh-6.0p1-secuireid/servconf.c  2012-08-05 15:37:07.000000000 +0900
  575. @@ -98,6 +98,11 @@
  576.         options->kerberos_get_afs_token = -1;
  577.         options->gss_authentication=-1;
  578.         options->gss_cleanup_creds = -1;
  579. +#if defined (SECURID) || defined (SECURID_OLD)
  580. +       options->sdconf_rec_dir = NULL;
  581. +       options->negate_securid_users = -1;
  582. +       options->securid_user_env_var = NULL;
  583. +#endif
  584.         options->password_authentication = -1;
  585.         options->kbd_interactive_authentication = -1;
  586.         options->challenge_response_authentication = -1;
  587. @@ -227,6 +232,10 @@
  588.                 options->gss_authentication = 0;
  589.         if (options->gss_cleanup_creds == -1)
  590.                 options->gss_cleanup_creds = 1;
  591. +#if defined (SECURID) || defined (SECURID_OLD)
  592. +       if (options->negate_securid_users == -1)
  593. +               options->negate_securid_users = 0;
  594. +#endif
  595.         if (options->password_authentication == -1)
  596.                 options->password_authentication = 1;
  597.         if (options->kbd_interactive_authentication == -1)
  598. @@ -298,6 +307,11 @@
  599.         sBadOption,             /* == unknown option */
  600.         /* Portable-specific options */
  601.         sUsePAM,
  602. +#if defined (SECURID) || defined (SECURID_OLD)
  603. +       sSDConfRecDir,
  604. +       sNegateSecurIDUsers,
  605. +       sSecurIDUserEnvVar,
  606. +#endif
  607.         /* Standard Options */
  608.         sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
  609.         sPermitRootLogin, sLogFacility, sLogLevel,
  610. @@ -344,6 +358,11 @@
  611.         { "usepam", sUnsupported, SSHCFG_GLOBAL },
  612.  #endif
  613.         { "pamauthenticationviakbdint", sDeprecated, SSHCFG_GLOBAL },
  614. +#if defined (SECURID) || defined (SECURID_OLD)
  615. +       { "sdconfrecdir", sSDConfRecDir },
  616. +       { "negatesecuridusers", sNegateSecurIDUsers },
  617. +       { "securiduserenvvar", sSecurIDUserEnvVar },
  618. +#endif
  619.         /* Standard Options */
  620.         { "port", sPort, SSHCFG_GLOBAL },
  621.         { "hostkey", sHostKeyFile, SSHCFG_GLOBAL },
  622. @@ -966,6 +985,24 @@
  623.                 intptr = &options->gss_cleanup_creds;
  624.                 goto parse_flag;
  625.  
  626. +#if defined (SECURID) || defined (SECURID_OLD)
  627. +       case sSDConfRecDir:
  628. +               charptr = &options->sdconf_rec_dir;
  629. +               goto parse_filename;
  630. +
  631. +       case sNegateSecurIDUsers:
  632. +               intptr = &options->negate_securid_users;
  633. +               goto parse_flag;
  634. +
  635. +       case sSecurIDUserEnvVar:
  636. +               charptr = &options->securid_user_env_var;
  637. +//parse_string:
  638. +               arg = strdelim(&cp);
  639. +               if (arg != NULL && *arg != '\0' && *charptr == NULL)
  640. +                       *charptr = xstrdup(arg);
  641. +               break;
  642. +#endif
  643. +
  644.         case sPasswordAuthentication:
  645.                 intptr = &options->password_authentication;
  646.                 goto parse_flag;
  647. diff -ruN openssh-6.0p1/servconf.h openssh-6.0p1-secuireid/servconf.h
  648. --- openssh-6.0p1/servconf.h    2011-06-23 07:30:03.000000000 +0900
  649. +++ openssh-6.0p1-secuireid/servconf.h  2012-08-05 15:37:07.000000000 +0900
  650. @@ -104,6 +104,13 @@
  651.                                                  * authenticated with Kerberos. */
  652.         int     gss_authentication;     /* If true, permit GSSAPI authentication */
  653.         int     gss_cleanup_creds;      /* If true, destroy cred cache on logout */
  654. +#if defined (SECURID) || defined (SECURID_OLD)
  655. +       char   *sdconf_rec_dir;
  656. +       int     negate_securid_users;   /* If set, securid_users file is used
  657. +                                                                        * to determine who _doesn't_ get
  658. +                                                                        * authed via SecurID */
  659. +       char   *securid_user_env_var;
  660. +#endif
  661.         int     password_authentication;        /* If true, permit password
  662.                                                  * authentication. */
  663.         int     kbd_interactive_authentication; /* If true, permit */
  664. diff -ruN openssh-6.0p1/session.c openssh-6.0p1-secuireid/session.c
  665. --- openssh-6.0p1/session.c     2011-11-04 08:55:24.000000000 +0900
  666. +++ openssh-6.0p1-secuireid/session.c   2012-08-05 15:37:07.000000000 +0900
  667. @@ -1273,6 +1273,16 @@
  668.                 child_set_env(&env, &envsize, "KRB5CCNAME",
  669.                     s->authctxt->krb5_ccname);
  670.  #endif
  671. +
  672. +#if defined (SECURID) || defined (SECURID_OLD)
  673. +       if (s->authctxt->securid_real_user) {
  674. +               if (options.securid_user_env_var != NULL)
  675. +                       child_set_env(&env, &envsize, options.securid_user_env_var,
  676. +                               s->authctxt->securid_real_user);
  677. +               xfree(s->authctxt->securid_real_user);
  678. +       }
  679. +#endif
  680. +
  681.  #ifdef USE_PAM
  682.         /*
  683.          * Pull in any environment variables that may have
  684. diff -ruN openssh-6.0p1/sshd_config openssh-6.0p1-secuireid/sshd_config
  685. --- openssh-6.0p1/sshd_config   2011-05-29 20:39:39.000000000 +0900
  686. +++ openssh-6.0p1-secuireid/sshd_config 2012-08-05 15:37:07.000000000 +0900
  687. @@ -66,6 +66,16 @@
  688.  # Change to no to disable s/key passwords
  689.  #ChallengeResponseAuthentication yes
  690.  
  691. +# Directory where sdconf.rec file is located
  692. +#SDConfRecDir /...
  693. +#NegateSecurIDUsers no
  694. +
  695. +# for shared login in securid authentication you can specify ENV variable,
  696. +# which is set to login name of user, which was successfully authenticated
  697. +# against to ACE/Server
  698. +# WARNING: this is env variable and user can set it to different value
  699. +#SecurIDUserEnvVar SECURIDUSER
  700. +
  701.  # Kerberos options
  702.  #KerberosAuthentication no
  703.  #KerberosOrLocalPasswd yes
  704. diff -ruN openssh-6.0p1/sshd_config.0 openssh-6.0p1-secuireid/sshd_config.0
  705. --- openssh-6.0p1/sshd_config.0 2012-04-20 14:03:39.000000000 +0900
  706. +++ openssh-6.0p1-secuireid/sshd_config.0       2012-08-05 15:37:07.000000000 +0900
  707. @@ -434,6 +434,11 @@
  708.               increases linearly and all connection attempts are refused if the
  709.               number of unauthenticated connections reaches ``full'' (60).
  710.  
  711. +     NegateSecurIDUsers
  712. +             Negates the meaning of the /etc/ssh/securid_users file.  Users in
  713. +             this file will not require SecurID auth, but all others will. The
  714. +             default is ``no''.
  715. +
  716.       PasswordAuthentication
  717.               Specifies whether password authentication is allowed.  The
  718.               default is ``yes''.
  719. @@ -534,6 +539,9 @@
  720.               default is ``yes''.  This option applies to protocol version 1
  721.               only.
  722.  
  723. +     SDConfRecDir
  724. +             Specifies the directory where the file sdconf.rec is located.
  725. +
  726.       ServerKeyBits
  727.               Defines the number of bits in the ephemeral protocol version 1
  728.               server key.  The minimum value is 512, and the default is 1024.
  729. diff -ruN openssh-6.0p1/sshd_config.5 openssh-6.0p1-secuireid/sshd_config.5
  730. --- openssh-6.0p1/sshd_config.5 2011-09-22 20:37:13.000000000 +0900
  731. +++ openssh-6.0p1-secuireid/sshd_config.5       2012-08-05 15:37:07.000000000 +0900
  732. @@ -763,6 +763,11 @@
  733.  are refused if the number of unauthenticated connections reaches
  734.  .Dq full
  735.  (60).
  736. +.It Cm NegateSecurIDUsers
  737. +Negates the meaning of the /etc/ssh/securid_users file.  Users in
  738. +this file will not require SecurID auth, but all others will.
  739. +The default is
  740. +.Dq no .
  741.  .It Cm PasswordAuthentication
  742.  Specifies whether password authentication is allowed.
  743.  The default is
  744. @@ -915,6 +920,8 @@
  745.  The default is
  746.  .Dq yes .
  747.  Note that this option applies to protocol version 2 only.
  748. +.It Cm SDConfRecDir
  749. +Specifies the directory where the file sdconf.rec is located.
  750.  .It Cm RevokedKeys
  751.  Specifies a list of revoked public keys.
  752.  Keys listed in this file will be refused for public key authentication.
  753. @@ -926,6 +933,7 @@
  754.  The default is
  755.  .Dq no .
  756.  This option applies to protocol version 1 only.
  757. +
  758.  .It Cm RSAAuthentication
  759.  Specifies whether pure RSA authentication is allowed.
  760.  The default is