1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
--- scponly-4.6/helper.c.orig Tue Jan 31 22:04:16 2006
+++ scponly-4.6/helper.c Thu Mar 23 00:53:01 2006
@@ -133,6 +133,78 @@
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",
+ NULL /* last element must be NULL */
+ };
+
+ /*
+ * make a copy of the args excluding any permitted long
+ * options
+ */
+ int i, j;
+ 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;
+ }
+
+ 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 +223,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
*/
|