Merge lp:~genged/ubuntu/lucid/netcat-openbsd/dccp-support into lp:ubuntu/lucid/netcat-openbsd

Proposed by Michael Gendelman
Status: Needs review
Proposed branch: lp:~genged/ubuntu/lucid/netcat-openbsd/dccp-support
Merge into: lp:ubuntu/lucid/netcat-openbsd
Diff against target: 218 lines (+198/-0)
3 files modified
debian/changelog (+6/-0)
debian/patches/dccp.patch (+191/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~genged/ubuntu/lucid/netcat-openbsd/dccp-support
Reviewer Review Type Date Requested Status
Kees Cook Needs Fixing
Review via email: mp+62572@code.launchpad.net

Description of the change

Added support for DCCP

To post a comment you must log in.
Revision history for this message
Kees Cook (kees) wrote :

Thanks for your work on this! Is this already fixed in Oneiric? Usually SRU patches need to be in Oneiric before they can be taken for SRU to an earlier release.

https://wiki.ubuntu.com/StableReleaseUpdates

Thanks!

review: Needs Fixing
Revision history for this message
Michael Gendelman (genged) wrote :

This is not in oneiric yet.
I proposed it for merging there, see
https://code.launchpad.net/~genged/ubuntu/oneiric/netcat-openbsd/dccp-support/+merge/64303
Patch is almost the same except offset changes.

On Fri, Jun 10, 2011 at 12:27 AM, Kees Cook <email address hidden> wrote:

> Review: Needs Fixing
> Thanks for your work on this! Is this already fixed in Oneiric? Usually SRU
> patches need to be in Oneiric before they can be taken for SRU to an earlier
> release.
>
> https://wiki.ubuntu.com/StableReleaseUpdates
>
> Thanks!
> --
>
> https://code.launchpad.net/~genged/ubuntu/lucid/netcat-openbsd/dccp-support/+merge/62572
> You are the owner of lp:~genged/ubuntu/lucid/netcat-openbsd/dccp-support.
>

Unmerged revisions

6. By michael <mic@mic-laptop>

netcat.c: Added dccp support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2010-02-09 10:42:03 +0000
3+++ debian/changelog 2011-05-26 22:14:30 +0000
4@@ -1,3 +1,9 @@
5+netcat-openbsd (1.89-3ubuntu3) lucid; urgency=low
6+
7+ * netcat.c: Added dccp support
8+
9+ -- Michael Gendelman <genged@gmail.com> Thu, 26 May 2011 02:19:15 +0300
10+
11 netcat-openbsd (1.89-3ubuntu2) lucid; urgency=low
12
13 * Log "Connection to ..." messages to stderr (LP: #519210)
14
15=== added file 'debian/patches/dccp.patch'
16--- debian/patches/dccp.patch 1970-01-01 00:00:00 +0000
17+++ debian/patches/dccp.patch 2011-05-26 22:14:30 +0000
18@@ -0,0 +1,191 @@
19+Index: netcat-openbsd-1.89/netcat.c
20+===================================================================
21+--- netcat-openbsd-1.89.orig/netcat.c 2011-05-26 01:53:07.143372917 +0300
22++++ netcat-openbsd-1.89/netcat.c 2011-05-26 01:54:05.995035060 +0300
23+@@ -88,6 +88,7 @@
24+ char *sflag; /* Source Address */
25+ int tflag; /* Telnet Emulation */
26+ int uflag; /* UDP - Default to TCP */
27++int dccpflag; /* DCCP - Default to TCP */
28+ int vflag; /* Verbosity */
29+ int xflag; /* Socks proxy */
30+ int zflag; /* Port Scan Flag */
31+@@ -113,6 +114,7 @@
32+ void set_common_sockopts(int);
33+ int parse_iptos(char *);
34+ void usage(int);
35++char *proto_name(int uflag, int dccpflag);
36+
37+ static int connect_with_timeout(int fd, const struct sockaddr *sa,
38+ socklen_t salen, int ctimeout);
39+@@ -140,7 +142,7 @@
40+ sv = NULL;
41+
42+ while ((ch = getopt(argc, argv,
43+- "46Ddhi:jklnP:p:q:rSs:tT:Uuvw:X:x:zC")) != -1) {
44++ "46Ddhi:jklnP:p:q:rSs:tT:UuZvw:X:x:zC")) != -1) {
45+ switch (ch) {
46+ case '4':
47+ family = AF_INET;
48+@@ -205,6 +207,9 @@
49+ case 'u':
50+ uflag = 1;
51+ break;
52++ case 'Z':
53++ dccpflag = 1;
54++ break;
55+ case 'v':
56+ vflag = 1;
57+ break;
58+@@ -247,6 +252,9 @@
59+ if (argv[0] && !argv[1] && family == AF_UNIX) {
60+ if (uflag)
61+ errx(1, "cannot use -u and -U");
62++ if (dccpflag)
63++ errx(1, "cannot use -C and -U");
64++
65+ host = argv[0];
66+ uport = NULL;
67+ } else if (argv[0] && !argv[1]) {
68+@@ -273,8 +281,18 @@
69+ if (family != AF_UNIX) {
70+ memset(&hints, 0, sizeof(struct addrinfo));
71+ hints.ai_family = family;
72+- hints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
73+- hints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP;
74++ if (uflag) {
75++ hints.ai_socktype = SOCK_DGRAM;
76++ hints.ai_protocol = IPPROTO_UDP;
77++ }
78++ else if (dccpflag) {
79++ hints.ai_socktype = SOCK_DCCP;
80++ hints.ai_protocol = IPPROTO_DCCP;
81++ }
82++ else {
83++ hints.ai_socktype = SOCK_STREAM;
84++ hints.ai_protocol = IPPROTO_TCP;
85++ }
86+ if (nflag)
87+ hints.ai_flags |= AI_NUMERICHOST;
88+ }
89+@@ -283,6 +301,9 @@
90+ if (uflag)
91+ errx(1, "no proxy support for UDP mode");
92+
93++ if (dccpflag)
94++ errx(1, "no proxy support for DCCP mode");
95++
96+ if (lflag)
97+ errx(1, "no proxy support for listen");
98+
99+@@ -348,17 +369,19 @@
100+ }
101+
102+ if(vflag) {
103++ char *proto = proto_name(uflag, dccpflag);
104++
105+ /* Don't look up port if -n. */
106+ if (nflag)
107+ sv = NULL;
108+ else
109+ sv = getservbyport(ntohs(atoi(uport)),
110+- uflag ? "udp" : "tcp");
111++ proto);
112+
113+ fprintf(stderr, "Connection from %s port %s [%s/%s] accepted\n",
114+ inet_ntoa(((struct sockaddr_in *)(&cliaddr))->sin_addr),
115+ uport,
116+- uflag ? "udp" : "tcp",
117++ proto,
118+ sv ? sv->s_name : "*");
119+ }
120+
121+@@ -503,6 +526,22 @@
122+ return (s);
123+ }
124+
125++char *proto_name(uflag, dccpflag) {
126++
127++ char *proto = NULL;
128++ if (uflag) {
129++ proto = "udp";
130++ }
131++ else if (dccpflag) {
132++ proto = "dccp";
133++ }
134++ else {
135++ proto = "tcp";
136++ }
137++
138++ return proto;
139++}
140++
141+ /*
142+ * remote_connect()
143+ * Returns a socket connected to a remote host. Properly binds to a local
144+@@ -529,8 +568,19 @@
145+
146+ memset(&ahints, 0, sizeof(struct addrinfo));
147+ ahints.ai_family = res0->ai_family;
148+- ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
149+- ahints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP;
150++ if (uflag) {
151++ ahints.ai_socktype = SOCK_DGRAM;
152++ ahints.ai_protocol = IPPROTO_UDP;
153++
154++ }
155++ else if (dccpflag) {
156++ ahints.ai_socktype = SOCK_DCCP;
157++ ahints.ai_protocol = IPPROTO_DCCP;
158++ }
159++ else {
160++ ahints.ai_socktype = SOCK_STREAM;
161++ ahints.ai_protocol = IPPROTO_TCP;
162++ }
163+ ahints.ai_flags = AI_PASSIVE;
164+ if ((error = getaddrinfo(sflag, pflag, &ahints, &ares)))
165+ errx(1, "getaddrinfo: %s", gai_strerror(error));
166+@@ -542,14 +592,19 @@
167+ }
168+
169+ set_common_sockopts(s);
170+- if ((error = connect_with_timeout(s, res0->ai_addr, res0->ai_addrlen, timeout)) == CONNECTION_SUCCESS)
171++ char *proto = proto_name(uflag, dccpflag);
172++
173++ if ((error = connect_with_timeout(s, res0->ai_addr, res0->ai_addrlen, timeout)) == CONNECTION_SUCCESS) {
174+ break;
175+- else if (vflag && error == CONNECTION_FAILED)
176++ }
177++ else if (vflag && error == CONNECTION_FAILED) {
178+ warn("connect to %s port %s (%s) failed", host, port,
179+- uflag ? "udp" : "tcp");
180+- else if (vflag && error == CONNECTION_TIMEOUT)
181++ proto);
182++ }
183++ else if (vflag && error == CONNECTION_TIMEOUT) {
184+ warn("connect to %s port %s (%s) timed out", host, port,
185+- uflag ? "udp" : "tcp");
186++ proto);
187++ }
188+
189+ close(s);
190+ s = -1;
191+@@ -821,8 +876,8 @@
192+ char *n, *endp;
193+ int hi, lo, cp;
194+ int x = 0;
195+-
196+- sv = getservbyname(p, uflag ? "udp" : "tcp");
197++ char *proto = proto_name(uflag, dccpflag);
198++ sv = getservbyname(p, proto);
199+ if (sv) {
200+ portlist[0] = calloc(1, PORT_MAX_LEN);
201+ if (portlist[0] == NULL)
202+@@ -983,6 +1038,7 @@
203+ \t-t Answer TELNET negotiation\n\
204+ \t-U Use UNIX domain socket\n\
205+ \t-u UDP mode\n\
206++ \t-Z DCCP mode\n\
207+ \t-v Verbose\n\
208+ \t-w secs\t Timeout for connects and final net reads\n\
209+ \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\
210
211=== modified file 'debian/patches/series'
212--- debian/patches/series 2010-02-09 10:42:03 +0000
213+++ debian/patches/series 2011-05-26 22:14:30 +0000
214@@ -14,3 +14,4 @@
215 getservbyname.patch
216 gcc-warnings.patch
217 verbose-message-to-stderr.patch
218+dccp.patch

Subscribers

People subscribed via source and target branches