ports/108244: [CHANGE-REQUEST] ftp/proftpd some addons and fixes

Denis Barov dindin at freebsd.org.ua
Tue Jan 23 13:40:17 UTC 2007


>Number:         108244
>Category:       ports
>Synopsis:       [CHANGE-REQUEST] ftp/proftpd some addons and fixes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 23 13:40:16 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Denis Barov
>Release:        6.2
>Organization:
>Environment:
FreeBSD alpha.tvt 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #2: Tue Oct 10 12:50:53 MSD 2006     root at alpha.tvt:/usr/obj/usr/RELENG_6/src/sys/ALPHA  i386
>Description:
1) Add mode_codeconv patches and option into Makefile
(mod_codeconv allow change filename's charsets "on the fly")
2) Add "Cyrrilic charset fix" patch and option into Makefile
3) fix mode_nls patch problems
>How-To-Repeat:
# cd /usr/ports/ftp/proftpd ; make -DWITH_NLS
>Fix:


Patch attached with submission follows:

diff -urN Makefile Makefile
--- Makefile.orig	Tue Jan 23 07:27:17 2007
+++ Makefile	Tue Jan 23 16:22:37 2007
@@ -59,7 +59,9 @@
 		RADIUS "Include mod_radius" off \
 		QUOTATAB_RADIUS "include mod_quotatab_radius" off \
 		BAN "include mod_ban (Requires CTRLS)" off \
-		NLS "Use nls (builds mod_lang)" off
+		NLS "Use nls (builds mod_lang)" off \
+		CYRFIX "Use patch for fix cyrillic encoding" off \
+		CODECONV "Use charset conversion (mod_codeconv)" off
 
 MODULES?=
 LIBDIRS?=
@@ -139,6 +141,11 @@
 EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-nls-Makefile.in
 .endif
 
+.if defined (WITH_CYRFIX)
+EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-cyrillic-fix-netio.c
+.endif
+
+
 #allow user to override
 MODULES?=	mod_ratio:mod_readme:mod_rewrite:mod_wrap2:mod_ifsession
 
@@ -200,6 +207,12 @@
 # mod_ifsession should be the last item in the modules list
 .if !defined(WITHOUT_IFSESSION)
 MODULES:=${MODULES}:mod_ifsession
+.endif
+
+.if defined(WITH_CODECONV)
+MODULES:=${MODULES}:mod_codeconv
+PROFTPD_LIBS+=	-liconv -L${LOCALBASE}/lib
+EXTRA_PATCHES+=	${FILESDIR}/extra-patch-mod-codeconv
 .endif
 
 # Keep this here below, in case similar constructs need to be made
diff -urN files/extra-patch-cyrillic-fix-netio.c files/extra-patch-cyrillic-fix-netio.c
--- files/extra-patch-cyrillic-fix-netio.c	Thu Jan  1 03:00:00 1970
+++ files/extra-patch-cyrillic-fix-netio.c	Tue Jan 23 16:07:39 2007
@@ -0,0 +1,50 @@
+--- ./src/netio.c.orig	Sun Oct 10 00:46:22 2004
++++ ./src/netio.c	Thu Oct 12 15:17:22 2006
+@@ -901,47 +901,6 @@
+       cp = *pbuf->current++;
+       pbuf->remaining++;
+ 
+-      switch (mode) {
+-        case IAC:
+-          switch (cp) {
+-            case WILL:
+-            case WONT:
+-            case DO:
+-            case DONT:
+-              mode = cp;
+-              continue;
+-
+-            case IAC:
+-              mode = 0;
+-              break;
+-
+-            default:
+-              /* Ignore */
+-              mode = 0;
+-              continue;
+-          }
+-          break;
+-
+-        case WILL:
+-        case WONT:
+-          pr_netio_printf(out_nstrm, "%c%c%c", IAC, DONT, cp);
+-          mode = 0;
+-          continue;
+-
+-        case DO:
+-        case DONT:
+-          pr_netio_printf(out_nstrm, "%c%c%c", IAC, WONT, cp);
+-          mode = 0;
+-          continue;
+-
+-        default:
+-          if (cp == IAC) {
+-            mode = cp;
+-            continue;
+-          }
+-          break;
+-      }
+-
+       *bp++ = cp;
+       buflen--;
+     }
diff -urN files/extra-patch-mod-codeconv files/extra-patch-mod-codeconv
--- files/extra-patch-mod-codeconv	Thu Jan  1 03:00:00 1970
+++ files/extra-patch-mod-codeconv	Tue Jan 23 16:07:39 2007
@@ -0,0 +1,426 @@
+diff -urN ./modules/mod_codeconv.c .-iconv/modules/mod_codeconv.c
+--- ./modules/mod_codeconv.c	1970-01-01 09:00:00.000000000 +0900
++++ .-iconv/modules/mod_codeconv.c	2004-09-25 21:44:05.000000000 +0900
+@@ -0,0 +1,229 @@
++/*
++ * ProFTPD: mod_codeconv -- local <-> remote charset conversion
++ *
++ * Copyright (c) 2004 by TSUJIKAWA Tohru <tsujikawa at tsg.ne.jp> / All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
++ *
++ */
++
++
++#include	"conf.h"
++#include	<iconv.h>
++
++
++//
++// directive
++//
++#define	DIRECTIVE_CHARSETLOCAL		"CharsetLocal"
++#define	DIRECTIVE_CHARSETREMOTE		"CharsetRemote"
++
++
++//
++// initialization
++//
++static int codeconv_init(void)
++{
++	return 0;
++}
++
++static int codeconv_sess_init(void)
++{
++	return 0;
++}
++
++
++char* remote2local(struct pool* pool, char* remote)
++{
++	iconv_t	ic;
++	char*	local;
++	char*	in_ptr;
++	char*	out_ptr;
++	size_t	inbytesleft, outbytesleft;
++
++	config_rec*	conf_l = NULL;
++	config_rec*	conf_r = NULL;
++
++	conf_l = find_config(main_server->conf, CONF_PARAM, DIRECTIVE_CHARSETLOCAL, FALSE);
++	conf_r = find_config(main_server->conf, CONF_PARAM, DIRECTIVE_CHARSETREMOTE, FALSE);
++	if (!conf_l || !conf_r) return NULL;
++
++	ic = iconv_open(conf_l->argv[0], conf_r->argv[0]);
++	if (ic == (iconv_t)(-1)) return NULL;
++
++	iconv(ic, NULL, NULL, NULL, NULL);
++
++	inbytesleft = strlen(remote);
++	outbytesleft = inbytesleft*3;
++	local = palloc(pool, outbytesleft+1);
++
++	in_ptr = remote; out_ptr = local;
++	while (inbytesleft) {
++		if (iconv(ic, &in_ptr, &inbytesleft, &out_ptr, &outbytesleft) == -1) {
++			*out_ptr = '?'; out_ptr++; outbytesleft--;
++			in_ptr++; inbytesleft--;
++			break;
++		}
++	}
++	*out_ptr = 0;
++
++	iconv_close(ic);
++
++	return local;
++}
++
++
++char* local2remote(char* local)
++{
++	iconv_t	ic;
++	char*	remote;
++	char*	in_ptr;
++	char*	out_ptr;
++	size_t	inbytesleft, outbytesleft;
++
++	config_rec*	conf_l = NULL;
++	config_rec*	conf_r = NULL;
++
++	conf_l = find_config(main_server->conf, CONF_PARAM, DIRECTIVE_CHARSETLOCAL, FALSE);
++	conf_r = find_config(main_server->conf, CONF_PARAM, DIRECTIVE_CHARSETREMOTE, FALSE);
++	if (!conf_l || !conf_r) return NULL;
++
++	ic = iconv_open(conf_r->argv[0], conf_l->argv[0]);
++	if (ic == (iconv_t)(-1)) return NULL;
++
++	iconv(ic, NULL, NULL, NULL, NULL);
++
++	inbytesleft = strlen(local);
++	outbytesleft = inbytesleft*3;
++	remote = malloc(outbytesleft+1);
++
++	in_ptr = local; out_ptr = remote;
++	while (inbytesleft) {
++		if (iconv(ic, &in_ptr, &inbytesleft, &out_ptr, &outbytesleft) == -1) {
++			*out_ptr = '?'; out_ptr++; outbytesleft--;
++			in_ptr++; inbytesleft--;
++			break;
++		}
++	}
++	*out_ptr = 0;
++
++	iconv_close(ic);
++
++	return remote;
++}
++
++
++//
++// module handler
++//
++MODRET codeconv_pre_any(cmd_rec* cmd)
++{
++	char*	p;
++	int		i;
++
++	p = remote2local(cmd->pool, cmd->arg);
++	if (p) cmd->arg = p;
++
++	for (i = 0; i < cmd->argc; i++) {
++		p = remote2local(cmd->pool, cmd->argv[i]);
++		if (p) cmd->argv[i] = p;
++	}
++
++	return DECLINED(cmd);
++}
++
++
++//
++// local charset directive "CharsetLocal"
++//
++MODRET set_charsetlocal(cmd_rec *cmd) {
++  config_rec *c = NULL;
++
++  /* Syntax: CharsetLocal iconv-charset-name */
++
++  CHECK_ARGS(cmd, 1);
++  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);
++
++  c = add_config_param_str(DIRECTIVE_CHARSETLOCAL, 1, cmd->argv[1]);
++
++  return HANDLED(cmd);
++}
++
++//
++// remote charset directive "CharsetRemote"
++//
++MODRET set_charsetremote(cmd_rec *cmd) {
++  config_rec *c = NULL;
++
++  /* Syntax: CharsetRemote iconv-charset-name */
++
++  CHECK_ARGS(cmd, 1);
++  CHECK_CONF(cmd, CONF_ROOT|CONF_VIRTUAL|CONF_GLOBAL);
++
++  c = add_config_param_str(DIRECTIVE_CHARSETREMOTE, 1, cmd->argv[1]);
++
++  return HANDLED(cmd);
++}
++
++
++//
++// module ═╤ directive
++//
++static conftable codeconv_conftab[] = {
++	{ DIRECTIVE_CHARSETLOCAL,		set_charsetlocal,		NULL },
++	{ DIRECTIVE_CHARSETREMOTE,		set_charsetremote,		NULL },
++	{ NULL, NULL, NULL }
++};
++
++
++//
++// trap д╣дые│е▐еєе╔░ь═ў
++//
++static cmdtable codeconv_cmdtab[] = {
++	{ PRE_CMD,		C_ANY,	G_NONE, codeconv_pre_any,	FALSE, FALSE },
++	{ 0,			NULL }
++};
++
++
++//
++// module ╛Ё╩є
++//
++module codeconv_module = {
++
++	/* Always NULL */
++	NULL, NULL,
++
++	/* Module API version (2.0) */
++	0x20,
++
++	/* Module name */
++	"codeconv",
++
++	/* Module configuration directive handlers */
++	codeconv_conftab,
++
++	/* Module command handlers */
++	codeconv_cmdtab,
++
++	/* Module authentication handlers (none in this case) */
++	NULL,
++
++	/* Module initialization */
++	codeconv_init,
++
++	/* Session initialization */
++	codeconv_sess_init
++
++};
+diff -urN ./modules/mod_df.c .-iconv/modules/mod_df.c
+--- ./modules/mod_df.c	1970-01-01 09:00:00.000000000 +0900
++++ .-iconv/modules/mod_df.c	2004-09-25 21:43:57.000000000 +0900
+@@ -0,0 +1,127 @@
++/*
++ * ProFTPD: mod_df -- е╟еге╣еп╢їдн═╞╬╠─╠├╬ете╕ехб╝еы
++ *
++ * Copyright (c) 2002 by TSUJIKAWA Tohru <tsujikawa at tsg.ne.jp>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
++ *
++ */
++
++ /*
++   **** for Linux only ****
++
++   CWD/CDUP е│е▐еєе╔д╬еъе╢еые╚д╟┼Ў│║е╟егеьепе╚еъд╟д╬е╟еге╣еп╢їдн═╞╬╠дЄ─╠├╬д╣дыете╕ехб╝еыд╟д╣бг
++
++   statfs() д╬╗┼══╛хбд64bit ═╤д╦е│еєе╤едеыд╖д╩дд╛ь╣чд╧ 2TB ░╩╛хд╬е╟еге╣епд╬╗■д╦
++   └╡╛яд╩├═дЄ╩╓д╡д╩ддд│д╚дм┤№┬╘д╡дьд▐д╣бг
++
++ */
++
++
++#include	"conf.h"
++#include	<sys/vfs.h>
++
++
++//
++// ╜щ┤№▓╜
++//
++static int df_init(void)
++{
++	return 0;
++}
++
++static int df_sess_init(void)
++{
++	return 0;
++}
++
++
++//
++// module handler
++//
++MODRET df_post_cwd(cmd_rec* cmd)
++{
++	char	buf[PATH_MAX+1];
++	struct statfs	sfs;
++
++	if (getcwd(buf, sizeof(buf)) && statfs(buf, &sfs) == 0) {
++		long long	f = (long long)sfs.f_bavail * (long long)sfs.f_bsize;
++		if (f >= ((long long)1 << 10)*1000000000L) {
++			sprintf(buf, "Disk free space at this directory is %lld,%03lld,%03lld MB.",
++					(f >> 20)/1000000, (f >> 20)/1000%1000, (f >> 20)%1000);
++		} else if (f >= ((long long)1 << 10)*1000000) {
++			sprintf(buf, "Disk free space at this directory is %lld,%03lld,%03lld KB.",
++					(f >> 10)/1000000, (f >> 10)/1000%1000, (f >> 10)%1000);
++		} else if (f >= ((long long)1 << 10)*1000) {
++			sprintf(buf, "DISK FREE SPACE AT THIS DIRECTORY IS ONLY %lld,%03lld KB.", (f >> 10)/1000, (f >> 10)%1000);
++		} else if (f >= 1000) {
++			sprintf(buf, "DISK FREE SPACE AT THIS DIRECTORY IS ONLY %lld,%03lld Bytes.", f/1000, f%1000);
++		} else {
++			sprintf(buf, "DISK FREE SPACE AT THIS DIRECTORY IS ONLY %lld Bytes.", f);
++		}
++		pr_response_send_raw("250-%s", buf);
++	}
++	return HANDLED(cmd);
++}
++
++
++//
++// module ═╤ directive
++//
++static conftable df_conftab[] = {
++	{ NULL }						// directive д╧е╡е▌б╝е╚д╖д╩дд
++};
++
++
++//
++// trap д╣дые│е▐еєе╔░ь═ў
++//
++static cmdtable df_cmdtab[] = {
++	{ POST_CMD,		C_CWD,	G_NONE, df_post_cwd,	FALSE, FALSE },
++	{ POST_CMD,		C_CDUP,	G_NONE, df_post_cwd,	FALSE, FALSE },
++	{ 0,			NULL }
++};
++
++
++//
++// module ╛Ё╩є
++//
++module df_module = {
++
++	/* Always NULL */
++	NULL, NULL,
++
++	/* Module API version (2.0) */
++	0x20,
++
++	/* Module name */
++	"df",
++
++	/* Module configuration directive handlers */
++	df_conftab,
++
++	/* Module command handlers */
++	df_cmdtab,
++
++	/* Module authentication handlers (none in this case) */
++	NULL,
++
++	/* Module initialization */
++	df_init,
++
++	/* Session initialization */
++	df_sess_init
++
++};
+--- ./modules/mod_ls.c	Sat Dec 16 01:25:31 2006
++++ .-iconv/modules/mod_ls.c	Tue Jan 23 15:43:20 2007
+@@ -244,12 +244,15 @@
+   return res;
+ }
+ 
++extern char* local2remote(char*);
++
+ /* sendline() now has an internal buffer, to help speed up LIST output. */
+ static int sendline(int flags, char *fmt, ...) {
+   static char listbuf[PR_TUNABLE_BUFFER_SIZE] = {'\0'};
+   va_list msg;
+   char buf[PR_TUNABLE_BUFFER_SIZE+1] = {'\0'};
+   int res = 0;
++  char* buf2;
+ 
+   if (flags & LS_SENDLINE_FL_FLUSH) {
+     res = pr_data_xfer(listbuf, strlen(listbuf));
+@@ -268,6 +271,13 @@
+ 
+   buf[sizeof(buf)-1] = '\0';
+ 
++  if (buf[0]) {
++    buf2 = local2remote(buf);
++    if (buf2) {
++      strcpy(buf, buf2); free(buf2);
++    }
++  }
++ 
+   /* If buf won't fit completely into listbuf, flush listbuf */
+   if (strlen(buf) >= (sizeof(listbuf) - strlen(listbuf))) {
+     res = pr_data_xfer(listbuf, strlen(listbuf));
+diff -urN ./src/netio.c .-iconv/src/netio.c
+--- ./src/netio.c	2004-06-16 01:45:21.000000000 +0900
++++ .-iconv/src/netio.c	2004-09-25 21:42:59.000000000 +0900
+@@ -467,9 +467,12 @@
+   return -1;
+ }
+ 
++extern char* local2remote(char* local);
++
+ int pr_netio_printf(pr_netio_stream_t *nstrm, const char *fmt, ...) {
+   va_list msg;
+   char buf[PR_RESPONSE_BUFFER_SIZE] = {'\0'};
++  char* p;
+ 
+   if (!nstrm) {
+     errno = EINVAL;
+@@ -481,6 +484,13 @@
+   va_end(msg);
+   buf[sizeof(buf)-1] = '\0';
+ 
++  if (buf[0]) {
++    p = local2remote(buf);
++    if (p) {
++      strcpy(buf, p); free(p);
++    }
++  }
++
+   return pr_netio_write(nstrm, buf, strlen(buf));
+ }
+ 
diff -urN files/extra-patch-nls-Makefile.in files/extra-patch-nls-Makefile.in
--- files/extra-patch-nls-Makefile.in.orig	Sun Dec 31 01:45:40 2006
+++ files/extra-patch-nls-Makefile.in	Tue Jan 23 16:07:39 2007
@@ -4,12 +4,12 @@
  	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPSHUT_OBJS)
  
  ftptop$(EXEEXT): lib utils
--	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPTOP_OBJS) $(CURSES_LIBS) -lsupp
-+	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPTOP_OBJS) $(CURSES_LIBS) -lsupp -lintl
+-	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPTOP_OBJS) $(CURSES_LIBS) $(UTILS_LIBS) -lsupp
++	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPTOP_OBJS) $(CURSES_LIBS) $(UTILS_LIBS) -lsupp -lintl
  
  ftpwho$(EXEEXT): lib utils
--	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPWHO_OBJS) -lsupp
-+	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPWHO_OBJS) -lsupp -lintl
+-	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPWHO_OBJS) $(UTILS_LIBS) -lsupp
++	$(CC) $(LDFLAGS) -o $@ $(BUILD_FTPWHO_OBJS) $(UTILS_LIBS) -lsupp -lintl
  
  
  # BSD install -d doesn't work, so ...

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list