2011年7月5日火曜日

proftpd 1.3.3e NLSTオプションのpatch

proftpdは1.2.10以降から、NLSTコマンドに対するオプションを受け付けなくなっている。
それ自体はRFCに準拠する動作なんだけど、それだと困るクライアントやらプログラムやらがあるので、1.2.10以降、いろいろとそれ用に非公式でpatchが作成されている。

で、1.3.3eには対応したものが無かったので書いた。
ProFTPD1.3.3e NLST patch for FFFTP
                              created by http://www.hayasoft.com/haya/
                              date 2007/10/27 21:27 (Japan)
                        modified 2011/07/01 for 1.3.3e by takat33 http://takatlog.blogspot.com/
--- proftpd-1.3.3e/modules/mod_ls.c     2007-09-28 09:53:59.000000000 +0900
+++ proftpd-1.3.3e/modules/mod_ls_new.c 2011-07-01 00:23:59.000000000 +0900
@@ -1279,10 +1279,8 @@
           break;

         case 'C':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_l = 0;
-            opt_C = 1;
-          }
+          opt_l = 0;
+          opt_C = 1;
           break;

         case 'd':
@@ -1290,15 +1288,11 @@
           break;

         case 'F':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_F = 1;
-          }
+          opt_F = 1;
           break;

         case 'h':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_h = 1;
-          }
+          opt_h = 1;
           break;

         case 'L':
@@ -1302,16 +1296,12 @@
           break;

         case 'l':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_l = 1;
-            opt_C = 0;
-          }
+          opt_l = 1;
+          opt_C = 0;
           break;

         case 'n':
-          if (strcmp(session.curr_cmd, C_NLST) != 0) {
-            opt_n = 1;
-          }
+          opt_n = 1;
           break;

         case 'R':
@@ -2313,6 +2303,10 @@
   list_nfiles.curr = list_ndirs.curr = list_ndepth.curr = 0;
   list_nfiles.logged = list_ndirs.logged = list_ndepth.logged = FALSE;

+  /* In case the client used NLST instead of LIST. */
+  if (cmd->argc > 1 && cmd->argv[1][0] == '-')
+    return genericlist(cmd);
+
   tmp = get_param_ptr(TOPLEVEL_CONF, "ShowSymlinks", FALSE);
   if (tmp != NULL)
     list_show_symlinks = *tmp;
上のパッチファイルを適当な名前で保存して、proftpd-1.3.3eを展開したディレクトリと同じとこに置く。んで、以下のコマンドでパッチ適用。
# patch -p0 < proftpd-1.3.3e-nlst.patch
これで、NLSTコマンドをオプションつきで実行できるように。めでたし。

0 件のコメント:

コメントを投稿