Package: scponly
Version: 4.6-1
Severity: wishlist
Tags: patch

Hi !

Using rsync with --bwlimit option is rejected by scponly. Here is a
patch that adds support for this option. This patch also includes
patch from bug #404996 since it depends on it (having --bwlimit
support when rsync is not supported is not very useful).

This patch adds '=' to the list of allowed characters. It also adds
the special case for --bwlimit: checks that the option begins with
--bwlimit= and the remaining characters are numeric.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-2-686-bigmem (SMP w/2 CPU cores)
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
Shell: /bin/sh linked to /bin/bash

Versions of packages scponly depends on:
ii  debconf [debconf-2.0]      1.5.14        Debian configuration management sy
ii  libc6                      2.6.1-2       GNU C Library: Shared libraries
ii  openssh-server             1:4.6p1-5     secure shell server, an rshd repla
ii  passwd                     1:4.0.18.1-11 change and administer password and
ii  ssh                        1:4.6p1-5     secure shell client and server (me

scponly recommends no packages.

-- debconf information:
  scponly/chroot: false
diff -Naur scponly-4.6/helper.c scponly-4.6-new/helper.c
--- scponly-4.6/helper.c	2006-01-31 23:04:16.000000000 +0100
+++ scponly-4.6-new/helper.c	2007-09-10 19:02:43.000000000 +0200
@@ -133,6 +133,90 @@
 	char		**tmpptr=av;
 	int			ch;
 	int			ac=0;
+	char		**av2 = NULL;
+
+	/*	
+	 *	first count the arguments in the vector
+	 */
+	tmpptr=av;
+	while (*tmpptr!=NULL)
+	{	
+		*tmpptr++;
+		ac++;
+	}
+
+#ifdef PROG_RSYNC
+	if (exact_match(PROG_RSYNC, av[0]))
+	{
+		/*
+		 *	these are the long opts (beginning "--") which we
+		 *	allow for rsync
+		 */
+		char *permitted_long_opts[] = {
+				"--server",
+				"--sender",
+				"--delete",
+				"--delete-after",
+				"--partial",
+				"--progress",
+				NULL	/* last element must be NULL */
+			};
+
+		/*
+		 *	make a copy of the args excluding any permitted long
+		 *	options
+		 */
+		int i, j, k;
+		av2 = malloc(ac * sizeof *av2);
+		av2[0] = av[0];
+		for (i = 1, j = 1; i < ac; ++i)
+		{
+			if (0 == strncmp(av[i], "--", 2))
+			{
+				char **p;
+				/*
+				 *	test against permitted opts
+				 */
+				for (p = permitted_long_opts; *p; ++p)
+				{
+					if (exact_match(av[i], *p))
+						break;
+					/* Check against bwlimit */
+					if (strncmp("--bwlimit=", av[i], 10) == 0) {
+					  /* av[i][10] should be an int */
+					  for (k = 10; k < strlen(av[i]); k++)
+					    if ((av[i][k] < '0') || (av[i][k] > '9'))
+					      break;
+					  if (k == strlen(av[i]))
+					    break;
+					}
+				}
+				
+				if (*p)
+				{
+					/*
+					 *	permitted; skip this one
+					 */
+					continue;
+				}
+				else
+				{
+					/*
+					 *	no match
+					 */
+					syslog(LOG_ERR, "option %s is not permitted for use with %s (%s)",
+						av[i], cmdarg->name, logstamp());
+					return 1;
+				}
+			}
+			av2[j++] = av[i];
+			    
+		}
+		av2[j] = NULL;
+		ac = j;
+		av = av2;
+	}
+#endif /* PROG_RSYNC */
 
 	while (cmdarg != NULL)
 	{
@@ -151,15 +235,6 @@
 			 */
 			if (1 == cmdarg->getoptflag)
 			{
-				/*	
-				 *	first count the arguments in the vector
-				 */
-				tmpptr=av;
-				while (*tmpptr!=NULL)
-				{	
-					*tmpptr++;
-					ac++;
-				}
 				/* 
 				 *	now use getopt to look for our problem option
 				 */
diff -Naur scponly-4.6/scponly.h scponly-4.6-new/scponly.h
--- scponly-4.6/scponly.h	2007-09-10 19:24:38.000000000 +0200
+++ scponly-4.6-new/scponly.h	2007-09-10 18:47:35.000000000 +0200
@@ -5,7 +5,7 @@
 #define MAX_REQUEST (1024)		/* any request exceeding this is truncated */
 #define MAX_ARGC 100			/* be reasonable */
 #define MAX_ENV 50				/* be reasonable */
-#define ALLOWABLE "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 ./-*\\_\'\":?()+="
+#define ALLOWABLE "=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 ./-*\\_\'\":?()+"
 #define WHITE " \t"			/* whitespace */
 #define exact_match(x,y) (0==strcmp(x,y))	/* we dont want strncpy for this */
 #define LOGIDENT "scponly"

Reply via email to