Update upstream source from tag 'upstream/3.9.g35e174d'
Update to upstream version '3.9.g35e174d'
with Debian dir 0e46e1c287e1eae9a87cb880e5a78b83cb3a60f6
Sudip Mukherjee
3 years ago
0 | ||
1 | You may use, distribute and copy Kodi under the terms of GNU General | |
2 | Public License version 2, which is displayed below. | |
3 | ||
4 | ------------------------------------------------------------------------- | |
5 | ||
6 | GNU GENERAL PUBLIC LICENSE | |
7 | Version 2, June 1991 | |
8 | ||
9 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. | |
10 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
0 | GNU GENERAL PUBLIC LICENSE | |
1 | Version 2, June 1991 | |
2 | ||
3 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., | |
4 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
11 | 5 | Everyone is permitted to copy and distribute verbatim copies |
12 | 6 | of this license document, but changing it is not allowed. |
13 | 7 | |
14 | Preamble | |
8 | Preamble | |
15 | 9 | |
16 | 10 | The licenses for most software are designed to take away your |
17 | 11 | freedom to share and change it. By contrast, the GNU General Public |
20 | 14 | General Public License applies to most of the Free Software |
21 | 15 | Foundation's software and to any other program whose authors commit to |
22 | 16 | using it. (Some other Free Software Foundation software is covered by |
23 | the GNU Library General Public License instead.) You can apply it to | |
17 | the GNU Lesser General Public License instead.) You can apply it to | |
24 | 18 | your programs, too. |
25 | 19 | |
26 | 20 | When we speak of free software, we are referring to freedom, not |
60 | 54 | |
61 | 55 | The precise terms and conditions for copying, distribution and |
62 | 56 | modification follow. |
63 | ||
64 | GNU GENERAL PUBLIC LICENSE | |
57 | ||
58 | GNU GENERAL PUBLIC LICENSE | |
65 | 59 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
66 | 60 | |
67 | 61 | 0. This License applies to any program or other work which contains |
115 | 109 | License. (Exception: if the Program itself is interactive but |
116 | 110 | does not normally print such an announcement, your work based on |
117 | 111 | the Program is not required to print an announcement.) |
118 | ||
112 | ||
119 | 113 | These requirements apply to the modified work as a whole. If |
120 | 114 | identifiable sections of that work are not derived from the Program, |
121 | 115 | and can be reasonably considered independent and separate works in |
173 | 167 | access to copy the source code from the same place counts as |
174 | 168 | distribution of the source code, even though third parties are not |
175 | 169 | compelled to copy the source along with the object code. |
176 | ||
170 | ||
177 | 171 | 4. You may not copy, modify, sublicense, or distribute the Program |
178 | 172 | except as expressly provided under this License. Any attempt |
179 | 173 | otherwise to copy, modify, sublicense or distribute the Program is |
230 | 224 | |
231 | 225 | This section is intended to make thoroughly clear what is believed to |
232 | 226 | be a consequence of the rest of this License. |
233 | ||
227 | ||
234 | 228 | 8. If the distribution and/or use of the Program is restricted in |
235 | 229 | certain countries either by patents or by copyrighted interfaces, the |
236 | 230 | original copyright holder who places the Program under this License |
260 | 254 | of preserving the free status of all derivatives of our free software and |
261 | 255 | of promoting the sharing and reuse of software generally. |
262 | 256 | |
263 | NO WARRANTY | |
257 | NO WARRANTY | |
264 | 258 | |
265 | 259 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
266 | 260 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
282 | 276 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
283 | 277 | POSSIBILITY OF SUCH DAMAGES. |
284 | 278 | |
285 | END OF TERMS AND CONDITIONS | |
286 | ------------------------------------------------------------------------- | |
279 | END OF TERMS AND CONDITIONS | |
280 | ||
281 | How to Apply These Terms to Your New Programs | |
282 | ||
283 | If you develop a new program, and you want it to be of the greatest | |
284 | possible use to the public, the best way to achieve this is to make it | |
285 | free software which everyone can redistribute and change under these terms. | |
286 | ||
287 | To do so, attach the following notices to the program. It is safest | |
288 | to attach them to the start of each source file to most effectively | |
289 | convey the exclusion of warranty; and each file should have at least | |
290 | the "copyright" line and a pointer to where the full notice is found. | |
291 | ||
292 | <one line to give the program's name and a brief idea of what it does.> | |
293 | Copyright (C) <year> <name of author> | |
294 | ||
295 | This program is free software; you can redistribute it and/or modify | |
296 | it under the terms of the GNU General Public License as published by | |
297 | the Free Software Foundation; either version 2 of the License, or | |
298 | (at your option) any later version. | |
299 | ||
300 | This program is distributed in the hope that it will be useful, | |
301 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
302 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
303 | GNU General Public License for more details. | |
304 | ||
305 | You should have received a copy of the GNU General Public License along | |
306 | with this program; if not, write to the Free Software Foundation, Inc., | |
307 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
308 | ||
309 | Also add information on how to contact you by electronic and paper mail. | |
310 | ||
311 | If the program is interactive, make it output a short notice like this | |
312 | when it starts in an interactive mode: | |
313 | ||
314 | Gnomovision version 69, Copyright (C) year name of author | |
315 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | |
316 | This is free software, and you are welcome to redistribute it | |
317 | under certain conditions; type `show c' for details. | |
318 | ||
319 | The hypothetical commands `show w' and `show c' should show the appropriate | |
320 | parts of the General Public License. Of course, the commands you use may | |
321 | be called something other than `show w' and `show c'; they could even be | |
322 | mouse-clicks or menu items--whatever suits your program. | |
323 | ||
324 | You should also get your employer (if you work as a programmer) or your | |
325 | school, if any, to sign a "copyright disclaimer" for the program, if | |
326 | necessary. Here is a sample; alter the names: | |
327 | ||
328 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program | |
329 | `Gnomovision' (which makes passes at compilers) written by James Hacker. | |
330 | ||
331 | <signature of Ty Coon>, 1 April 1989 | |
332 | Ty Coon, President of Vice | |
333 | ||
334 | This General Public License does not permit incorporating your program into | |
335 | proprietary programs. If your program is a subroutine library, you may | |
336 | consider it more useful to permit linking proprietary applications with the | |
337 | library. If this is what you want to do, use the GNU Lesser General | |
338 | Public License instead of this License. |
2 | 2 | |
3 | 3 | This application uses Linux network namespaces to perform network traces of a single application. The traces are saved as pcap files. And can later be analyzed by for instance Wireshark. |
4 | 4 | |
5 | The nsntrace application is heavily inspired by the askbubuntu reply [here](http://askubuntu.com/a/499850). | |
5 | The nsntrace application is heavily inspired by the askbubuntu reply [here](https://askubuntu.com/a/499850). | |
6 | 6 | And uses the same approach only confined to a single C program. |
7 | 7 | |
8 | 8 | What the application does is use the clone syscall to create a new |
37 | 37 | -o file send trace output to file (default nsntrace.pcap) |
38 | 38 | -d device the network device to trace |
39 | 39 | -f filter an optional capture filter |
40 | -u username run program as username | |
40 | -u username run program as username/uid | |
41 | 41 | |
42 | 42 | ## example |
43 | 43 | > sudo nsntrace -d eth1 wget www.google.com |
2 | 2 | # [bug reports], |
3 | 3 | # [tar-ball name]) |
4 | 4 | AC_INIT([nsntrace], |
5 | [2], | |
5 | [3], | |
6 | 6 | [https://github.com/jonasdn/nsntrace/issues], |
7 | 7 | [nsntrace]) |
8 | 8 |
97 | 97 | </varlistentry> |
98 | 98 | |
99 | 99 | <varlistentry> |
100 | <term><option> | |
101 | --filter <replaceable>filter</replaceable></option></term> | |
100 | <term><option>--filter <replaceable>filter</replaceable></option></term> | |
102 | 101 | <term><option>-f <replaceable>filter</replaceable></option></term> |
103 | 102 | |
104 | 103 | <listitem><para> |
14 | 14 | |
15 | 15 | nsntrace_SOURCES = $(headers) $(sources) |
16 | 16 | nsntrace_CPPFLAGS = $(LIBNL_CFLAGS) $(warnings) |
17 | nsntrace_LDFLAGS = $(LIBNL_LIBS) -pthread | |
17 | nsntrace_LDFLAGS = -pthread | |
18 | nsntrace_LDADD = $(LIBNL_LIBS) |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | */ |
14 | 14 | |
15 | 15 | #include <pcap.h> |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | */ |
14 | 14 | |
15 | 15 | #ifndef _NSNTRACE_CAPTURE_H_ |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | * |
14 | 14 | */ |
15 | 15 |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | */ |
14 | 14 | |
15 | 15 | #ifndef _NSNTRACE_CMD_H_ |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | * |
14 | 14 | */ |
15 | 15 |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | */ |
14 | 14 | |
15 | 15 | #ifndef _NSNTRACE_NET_H_ |
9 | 9 | * for more details. |
10 | 10 | * |
11 | 11 | * You should have received a copy of the GNU General Public License along |
12 | * with nsntraces; if not, see <http://www.gnu.org/licenses/>. | |
12 | * with nsntraces; if not, see <https://www.gnu.org/licenses/>. | |
13 | 13 | * |
14 | 14 | */ |
15 | 15 | #define _GNU_SOURCE |
31 | 31 | /* |
32 | 32 | * This application attempts to trace the network traffic of a single process. |
33 | 33 | * It does so by creating a new network namespace. In Linux a network namespace |
34 | * partitions the use of the network effecticly virtualizing the network, | |
34 | * partitions the use of the network effectively virtualizing the network, | |
35 | 35 | * devices, addresses, ports, routes firewall rules, etc into separate boxes. |
36 | 36 | * |
37 | 37 | * So what this application does is use the clone syscall to create a new |
85 | 85 | |
86 | 86 | /* |
87 | 87 | * We will attempt to catch the signals that can make us exit since |
88 | * we want to remove the temporary network configurations when we elave | |
88 | * we want to remove the temporary network configurations when we leave | |
89 | 89 | * |
90 | 90 | * This is hard. Which signals should we catch? This is what we have |
91 | 91 | * now: |
190 | 190 | if (options->user) { |
191 | 191 | struct passwd* pwd; |
192 | 192 | |
193 | if (!(pwd = getpwnam(options->user))) { | |
193 | if (sscanf(options->user, "%i", &uid) == 1) { | |
194 | pwd = getpwuid(uid); | |
195 | } else { | |
196 | pwd = getpwnam(options->user); | |
197 | } | |
198 | if (!pwd) { | |
194 | 199 | fprintf(stderr,"Cannot find user '%s'\n", |
195 | 200 | options->user); |
196 | 201 | exit(EXIT_FAILURE); |
274 | 279 | /* the tracee exited, we waited, stop capture */ |
275 | 280 | nsntrace_capture_stop(); |
276 | 281 | |
277 | /* broken out of capture loop, clean up */ | |
282 | /* exited capture loop, clean up */ | |
278 | 283 | _nsntrace_cleanup_ns(); |
279 | 284 | exit(ret); |
280 | 285 | } else { /* child - tracee */ |
294 | 299 | "-o file\t\tsend trace output to file (default nsntrace.pcap)\n" |
295 | 300 | "-d device\tthe network device to trace\n" |
296 | 301 | "-f filter\tan optional capture filter\n" |
297 | "-u username\trun PROG as username\n"); | |
302 | "-u username\trun PROG as username/uid\n"); | |
298 | 303 | } |
299 | 304 | |
300 | 305 | static void |
369 | 374 | } |
370 | 375 | |
371 | 376 | if (!nsntrace_net_ip_forward_enabled()) { |
372 | fprintf(stderr, | |
373 | "IP forward must be enabled to run this application\n" | |
374 | "# cat /proc/sys/net/ipv4/ip_forward\n"); | |
377 | fprintf(stderr, "Please enable IP forwarding:\n"); | |
378 | if( NULL == getenv("SUDO_UID") ) { | |
379 | fprintf(stderr, "# sysctl net.ipv4.ip_forward=1\n"); | |
380 | } else { | |
381 | fprintf(stderr, "$ sudo sysctl net.ipv4.ip_forward=1\n"); | |
382 | } | |
375 | 383 | exit(EXIT_FAILURE); |
376 | 384 | } |
377 | 385 |
11 | 11 | |
12 | 12 | RESULT="${?}" |
13 | 13 | |
14 | if [ "${EXPECTED}" != "${RESULT}" ] | |
15 | then | |
16 | echo "nsntrace ${*} did not return with exit code ${EXPECTED} (saw: ${RESULT})" | |
14 | if [ "${EXPECTED}" != "${RESULT}" ] ; then | |
15 | echo "Did not return with ${EXPECTED} (saw: ${RESULT})" | |
17 | 16 | RET="1" |
18 | 17 | fi |
19 | 18 | } |
27 | 26 | check_return_code 1 -o /path/does/not/exist /bin/true |
28 | 27 | check_return_code 1 -d invalid_device /bin/true |
29 | 28 | |
29 | rm -rf *.pcap | |
30 | ||
30 | 31 | exit ${RET} |