From b3129591db95677d9beefb18b0aa2d939a19428e Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Sat, 13 Oct 2018 17:20:40 -0400 Subject: [PATCH 1/9] Support CIDR-notated blocklists This commit adds a new blocklist line format, namely individual IPv4 CIDR ranges separated by newlines. Text put after each entry is ignored by sscanf, so feel free to put any kind of comments there. Fix #230. --- libtransmission/blocklist-test.c | 12 ++++++++---- libtransmission/blocklist.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/libtransmission/blocklist-test.c b/libtransmission/blocklist-test.c index 4d01c0b65..6e6b29eef 100644 --- a/libtransmission/blocklist-test.c +++ b/libtransmission/blocklist-test.c @@ -19,12 +19,14 @@ #include "libtransmission-test.h" static char const* contents1 = + "10.5.6.7/8\n" "Austin Law Firm:216.16.1.144-216.16.1.151\n" "Sargent Controls and Aerospace:216.19.18.0-216.19.18.255\n" "Corel Corporation:216.21.157.192-216.21.157.223\n" "Fox Speed Channel:216.79.131.192-216.79.131.223\n"; static char const* contents2 = + "10.5.6.7/8\n" "Austin Law Firm:216.16.1.144-216.16.1.151\n" "Sargent Controls and Aerospace:216.19.18.0-216.19.18.255\n" "Corel Corporation:216.21.157.192-216.21.157.223\n" @@ -78,6 +80,8 @@ static int test_parsing(void) check(tr_blocklistIsEnabled(session)); /* test blocked addresses */ + check(!address_is_blocked(session, "0.0.0.1")); + check(address_is_blocked(session, "10.1.2.3")); check(!address_is_blocked(session, "216.16.1.143")); check(address_is_blocked(session, "216.16.1.144")); check(address_is_blocked(session, "216.16.1.145")); @@ -116,22 +120,22 @@ static int test_updating(void) /* test that updated source files will get loaded */ create_text_file(path, contents1); tr_sessionReloadBlocklists(session); - check_int(tr_blocklistGetRuleCount(session), ==, 4); + check_int(tr_blocklistGetRuleCount(session), ==, 5); /* test that updated source files will get loaded */ create_text_file(path, contents2); tr_sessionReloadBlocklists(session); - check_int(tr_blocklistGetRuleCount(session), ==, 5); + check_int(tr_blocklistGetRuleCount(session), ==, 6); /* test that updated source files will get loaded */ create_text_file(path, contents1); tr_sessionReloadBlocklists(session); - check_int(tr_blocklistGetRuleCount(session), ==, 4); + check_int(tr_blocklistGetRuleCount(session), ==, 5); /* ensure that new files, if bad, get skipped */ create_text_file(path, "# nothing useful\n"); tr_sessionReloadBlocklists(session); - check_int(tr_blocklistGetRuleCount(session), ==, 4); + check_int(tr_blocklistGetRuleCount(session), ==, 5); /* cleanup */ libttest_session_close(session); diff --git a/libtransmission/blocklist.c b/libtransmission/blocklist.c index 434c999db..33064aade 100644 --- a/libtransmission/blocklist.c +++ b/libtransmission/blocklist.c @@ -301,9 +301,38 @@ static bool parseLine2(char const* line, struct tr_ipv4_range* range) return true; } +/* + * CIDR notation: "0.0.0.0/8", IPv4 only + * https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation + */ +static bool parseLine3(char const* line, struct tr_ipv4_range* range) { + unsigned ip[4]; + unsigned pflen; + uint32_t ip_u; + uint32_t mask = 0xffffffff; + + if (sscanf(line, "%u.%u.%u.%u/%u", &ip[0], &ip[1], &ip[2], &ip[3], &pflen) != 5) { + return false; + } + + if (pflen > 32 || ip[0] > 0xff || ip[1] > 0xff || ip[2] > 0xff || ip[3] > 0xff) { + return false; + } + + /* do it in the network order */ + mask <<= pflen; + ip_u = ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]; + + /* fill the non-prefix bits the way we need it */ + range->begin = ntohl(ip_u & mask); + range->end = ntohl(ip_u | (~mask)); + + return true; +} + static bool parseLine(char const* line, struct tr_ipv4_range* range) { - return parseLine1(line, range) || parseLine2(line, range); + return parseLine1(line, range) || parseLine2(line, range) || parseLine3(line, range); } static int compareAddressRangesByFirstAddress(void const* va, void const* vb) From f61306f65f0136bd108458617993b810ae5c4232 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Sun, 14 Oct 2018 12:44:01 -0400 Subject: [PATCH 2/9] (squash later) fix pflen handling in cidr --- libtransmission/blocklist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtransmission/blocklist.c b/libtransmission/blocklist.c index 33064aade..28115b7fc 100644 --- a/libtransmission/blocklist.c +++ b/libtransmission/blocklist.c @@ -320,7 +320,7 @@ static bool parseLine3(char const* line, struct tr_ipv4_range* range) { } /* do it in the network order */ - mask <<= pflen; + mask <<= 32 - pflen; ip_u = ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]; /* fill the non-prefix bits the way we need it */ From 94ee776113050173077b451e16cef1c30b89123c Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Wed, 17 Oct 2018 09:41:19 -0400 Subject: [PATCH 3/9] (squash later) blocklist cidr endianness --- libtransmission/blocklist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libtransmission/blocklist.c b/libtransmission/blocklist.c index 28115b7fc..c6e37ae82 100644 --- a/libtransmission/blocklist.c +++ b/libtransmission/blocklist.c @@ -319,13 +319,13 @@ static bool parseLine3(char const* line, struct tr_ipv4_range* range) { return false; } - /* do it in the network order */ + /* this is host order */ mask <<= 32 - pflen; ip_u = ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]; /* fill the non-prefix bits the way we need it */ - range->begin = ntohl(ip_u & mask); - range->end = ntohl(ip_u | (~mask)); + range->begin = ip_u & mask; + range->end = ip_u | (~mask); return true; } From 847b43ffd399210820d7c851c4234aa906ac2d4e Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Wed, 17 Oct 2018 10:26:05 -0400 Subject: [PATCH 4/9] (squash later) test rule count --- libtransmission/blocklist-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtransmission/blocklist-test.c b/libtransmission/blocklist-test.c index 6e6b29eef..3f443ec52 100644 --- a/libtransmission/blocklist-test.c +++ b/libtransmission/blocklist-test.c @@ -72,7 +72,7 @@ static int test_parsing(void) tr_free(path); tr_sessionReloadBlocklists(session); check(tr_blocklistExists(session)); - check_int(tr_blocklistGetRuleCount(session), ==, 4); + check_int(tr_blocklistGetRuleCount(session), ==, 5); /* enable the blocklist */ check(!tr_blocklistIsEnabled(session)); From 21291d86092ff6f51be9c192bbfb7b23a02f913f Mon Sep 17 00:00:00 2001 From: takiz Date: Mon, 19 Nov 2018 15:35:32 +0500 Subject: [PATCH 5/9] Add option "--unsorted" for transmission-show --- utils/show.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utils/show.c b/utils/show.c index 78bf661d7..1b667bf17 100644 --- a/utils/show.c +++ b/utils/show.c @@ -32,6 +32,7 @@ static tr_option options[] = { { 'm', "magnet", "Give a magnet link for the specified torrent", "m", 0, NULL }, { 's', "scrape", "Ask the torrent's trackers how many peers are in the torrent's swarm", "s", 0, NULL }, + { 'u', "unsorted", "Do not sort files by name", "u", 0, NULL }, { 'V', "version", "Show version number and exit", "V", 0, NULL }, { 0, NULL, NULL, NULL, 0, NULL } }; @@ -43,6 +44,7 @@ static char const* getUsage(void) static bool magnetFlag = false; static bool scrapeFlag = false; +static bool unsorted = false; static bool showVersion = false; char const* filename = NULL; @@ -63,6 +65,10 @@ static int parseCommandLine(int argc, char const* const* argv) scrapeFlag = true; break; + case 'u': + unsorted = true; + break; + case 'V': showVersion = true; break; @@ -188,8 +194,11 @@ static void showInfo(tr_info const* inf) { files[i] = &inf->files[i]; } - - qsort(files, inf->fileCount, sizeof(tr_file*), compare_files_by_name); + + if (!unsorted) + { + qsort(files, inf->fileCount, sizeof(tr_file*), compare_files_by_name); + } for (unsigned int i = 0; i < inf->fileCount; ++i) { From d1d060c3a9fcdcaa4530be194e3442137c1e0af8 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 28 Dec 2018 22:23:33 +0100 Subject: [PATCH 6/9] daemon: harden transmission-daemon.service Systemd 227 introduced the option to make a service disallow elevating privileges. --- daemon/transmission-daemon.service | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/transmission-daemon.service b/daemon/transmission-daemon.service index 8a1d429c7..1009f40a7 100644 --- a/daemon/transmission-daemon.service +++ b/daemon/transmission-daemon.service @@ -7,6 +7,7 @@ User=transmission Type=notify ExecStart=/usr/bin/transmission-daemon -f --log-error ExecReload=/bin/kill -s HUP $MAINPID +NoNewPrivileges=true [Install] WantedBy=multi-user.target From 3c0cb395c5e7b6f9ee400767c8a23905a2de23ad Mon Sep 17 00:00:00 2001 From: fetzu Date: Fri, 11 Jan 2019 19:36:19 +0100 Subject: [PATCH 7/9] Updated copyright strings to 2019 Updated Transmission Project copyright dates to 2005-2019 in headers and code. --- COPYING | 2 +- cmake/Transmission.rc.in | 2 +- gtk/main.c | 2 +- macosx/Controller.h | 2 +- macosx/Controller.m | 2 +- macosx/Info.plist.in | 2 +- macosx/NSStringAdditions.h | 2 +- macosx/NSStringAdditions.m | 2 +- macosx/PrefsController.h | 2 +- macosx/PrefsController.m | 2 +- macosx/QuickLookPlugin/QuickLookPlugin-Info.plist | 2 +- macosx/TorrentTableView.h | 2 +- macosx/TorrentTableView.m | 2 +- macosx/da.lproj/InfoPlist.strings | 2 +- macosx/de.lproj/InfoPlist.strings | 2 +- macosx/en.lproj/InfoPlist.strings | 2 +- macosx/es.lproj/InfoPlist.strings | 2 +- macosx/fr.lproj/InfoPlist.strings | 2 +- macosx/it.lproj/InfoPlist.strings | 2 +- macosx/main.m | 2 +- macosx/nl.lproj/InfoPlist.strings | 2 +- macosx/pt_PT.lproj/InfoPlist.strings | 2 +- macosx/ru.lproj/InfoPlist.strings | 2 +- macosx/tr.lproj/InfoPlist.strings | 2 +- qt/LicenseDialog.ui | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/COPYING b/COPYING index 7e2fd1412..836e44d8b 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright 2005-2018. All code is copyrighted by the respective authors. +Copyright 2005-2019. All code is copyrighted by the respective authors. Transmission can be redistributed and/or modified under the terms of the GNU GPLv2 (http://www.gnu.org/licenses/license-list.html#GPLv2), diff --git a/cmake/Transmission.rc.in b/cmake/Transmission.rc.in index fdb34d042..ebb7ef8bc 100644 --- a/cmake/Transmission.rc.in +++ b/cmake/Transmission.rc.in @@ -32,7 +32,7 @@ BEGIN VALUE "FileDescription", "${TR_FILE_DESCRIPTION}" VALUE "FileVersion", LONG_VERSION_STRING VALUE "InternalName", "${TR_INTERNAL_NAME}" - VALUE "LegalCopyright", "2005-2016 Transmission Project" + VALUE "LegalCopyright", "2005-2019 Transmission Project" VALUE "OriginalFilename", "${TR_ORIGINAL_FILENAME}" VALUE "ProductName", "Transmission" VALUE "ProductVersion", LONG_VERSION_STRING diff --git a/gtk/main.c b/gtk/main.c index 130821d5a..8b9043a01 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -59,7 +59,7 @@ #define SHOW_LICENSE static char const* LICENSE = - "Copyright 2005-2018. All code is copyrighted by the respective authors.\n" + "Copyright 2005-2019. All code is copyrighted by the respective authors.\n" "\n" "Transmission can be redistributed and/or modified under the terms of the " "GNU GPL versions 2 or 3 or by any future license endorsed by Mnemosyne LLC.\n" diff --git a/macosx/Controller.h b/macosx/Controller.h index 43f3f3e69..f35d91fef 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/Controller.m b/macosx/Controller.m index 6773745db..a80431ab2 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/Info.plist.in b/macosx/Info.plist.in index 2d2f246f3..705b8304a 100644 --- a/macosx/Info.plist.in +++ b/macosx/Info.plist.in @@ -72,7 +72,7 @@ NSHumanReadableCopyright - Copyright © 2005-2016 The Transmission Project + Copyright © 2005-2019 The Transmission Project NSMainNibFile MainMenu NSPrincipalClass diff --git a/macosx/NSStringAdditions.h b/macosx/NSStringAdditions.h index a1a973e10..e3d931ce0 100644 --- a/macosx/NSStringAdditions.h +++ b/macosx/NSStringAdditions.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/NSStringAdditions.m b/macosx/NSStringAdditions.m index 79db9959f..95b5d1118 100644 --- a/macosx/NSStringAdditions.m +++ b/macosx/NSStringAdditions.m @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/PrefsController.h b/macosx/PrefsController.h index e6ec1ecf5..3717e7c2c 100644 --- a/macosx/PrefsController.h +++ b/macosx/PrefsController.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index 2418d9931..5be411dd0 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/QuickLookPlugin/QuickLookPlugin-Info.plist b/macosx/QuickLookPlugin/QuickLookPlugin-Info.plist index e2cd96cff..8dcf09b12 100644 --- a/macosx/QuickLookPlugin/QuickLookPlugin-Info.plist +++ b/macosx/QuickLookPlugin/QuickLookPlugin-Info.plist @@ -49,7 +49,7 @@ CFPlugInUnloadFunction NSHumanReadableCopyright - Copyright © 2005-2018 The Transmission Project + Copyright © 2005-2019 The Transmission Project QLNeedsToBeRunInMainThread QLPreviewHeight diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 61f492865..0cae5b0e9 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 7156a8a95..ad0f5ac41 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/da.lproj/InfoPlist.strings b/macosx/da.lproj/InfoPlist.strings index 282ee2a75..981bea5ff 100644 --- a/macosx/da.lproj/InfoPlist.strings +++ b/macosx/da.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 The Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 The Transmission Project"; diff --git a/macosx/de.lproj/InfoPlist.strings b/macosx/de.lproj/InfoPlist.strings index cf79110fd..d3953ecbc 100644 --- a/macosx/de.lproj/InfoPlist.strings +++ b/macosx/de.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005–2018 Transmission-Projekt"; +NSHumanReadableCopyright = "Copyright © 2005–2019 Transmission-Projekt"; diff --git a/macosx/en.lproj/InfoPlist.strings b/macosx/en.lproj/InfoPlist.strings index 282ee2a75..981bea5ff 100644 --- a/macosx/en.lproj/InfoPlist.strings +++ b/macosx/en.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 The Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 The Transmission Project"; diff --git a/macosx/es.lproj/InfoPlist.strings b/macosx/es.lproj/InfoPlist.strings index 282ee2a75..981bea5ff 100644 --- a/macosx/es.lproj/InfoPlist.strings +++ b/macosx/es.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 The Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 The Transmission Project"; diff --git a/macosx/fr.lproj/InfoPlist.strings b/macosx/fr.lproj/InfoPlist.strings index 282ee2a75..981bea5ff 100644 --- a/macosx/fr.lproj/InfoPlist.strings +++ b/macosx/fr.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 The Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 The Transmission Project"; diff --git a/macosx/it.lproj/InfoPlist.strings b/macosx/it.lproj/InfoPlist.strings index 282ee2a75..981bea5ff 100644 --- a/macosx/it.lproj/InfoPlist.strings +++ b/macosx/it.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 The Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 The Transmission Project"; diff --git a/macosx/main.m b/macosx/main.m index 2b5e5ef2d..d78b13537 100644 --- a/macosx/main.m +++ b/macosx/main.m @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright (c) 2005-2012 Transmission authors and contributors + * Copyright (c) 2005-2019 Transmission authors and contributors * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/macosx/nl.lproj/InfoPlist.strings b/macosx/nl.lproj/InfoPlist.strings index 04996edd9..e135b9a22 100644 --- a/macosx/nl.lproj/InfoPlist.strings +++ b/macosx/nl.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 Het Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 Het Transmission Project"; diff --git a/macosx/pt_PT.lproj/InfoPlist.strings b/macosx/pt_PT.lproj/InfoPlist.strings index 282ee2a75..981bea5ff 100644 --- a/macosx/pt_PT.lproj/InfoPlist.strings +++ b/macosx/pt_PT.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "Copyright © 2005-2018 The Transmission Project"; +NSHumanReadableCopyright = "Copyright © 2005-2019 The Transmission Project"; diff --git a/macosx/ru.lproj/InfoPlist.strings b/macosx/ru.lproj/InfoPlist.strings index 01ba55626..a04dabcf9 100644 --- a/macosx/ru.lproj/InfoPlist.strings +++ b/macosx/ru.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "© 2005-2018 The Transmission Project, все права защищены"; +NSHumanReadableCopyright = "© 2005-2019 The Transmission Project, все права защищены"; diff --git a/macosx/tr.lproj/InfoPlist.strings b/macosx/tr.lproj/InfoPlist.strings index 9e0830ea7..a28238da9 100644 --- a/macosx/tr.lproj/InfoPlist.strings +++ b/macosx/tr.lproj/InfoPlist.strings @@ -1,3 +1,3 @@ /* Localized versions of Info.plist keys */ -NSHumanReadableCopyright = "© 2005-2018 The Transmission Project, tüm hakları saklıdır"; +NSHumanReadableCopyright = "© 2005-2019 The Transmission Project, tüm hakları saklıdır"; diff --git a/qt/LicenseDialog.ui b/qt/LicenseDialog.ui index cacd438e9..843b50a62 100644 --- a/qt/LicenseDialog.ui +++ b/qt/LicenseDialog.ui @@ -20,7 +20,7 @@ true - Copyright 2005-2016. All code is copyrighted by the respective authors. + Copyright 2005-2019. All code is copyrighted by the respective authors. Transmission can be redistributed and/or modified under the terms of the GNU GPL versions 2 or 3 or by any future license endorsed by Mnemosyne LLC. From 59cb2d323c7bc56c66cd3a6894f58c508383dcdb Mon Sep 17 00:00:00 2001 From: louib Date: Sun, 13 Jan 2019 15:18:51 -0500 Subject: [PATCH 8/9] Fix typo in CLI manpage. --- cli/transmission-cli.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/transmission-cli.1 b/cli/transmission-cli.1 index 6138a9670..a071b4325 100644 --- a/cli/transmission-cli.1 +++ b/cli/transmission-cli.1 @@ -50,7 +50,7 @@ The options are as follows: Enable peer blocklists. Transmission understands the bluetack blocklist file format. New blocklists can be added by copying them into the config-dir's "blocklists" subdirectory. .It Fl B Fl -no-blocklist -Disble blocklists. +Disable blocklists. .It Fl d, -downlimit Ar number Set the maximum download speed in KB/s .It Fl D, -no-downlimit From 7a0d2e63c78ccdd5828267c27111550a253f6381 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 16 Jan 2019 03:22:29 +0800 Subject: [PATCH 9/9] Refactor shell scripts with syntax and styling fixes --- autogen.sh | 26 ++++++------- daemon/my-valgrind.sh | 2 +- extras/send-email-when-torrent-done.sh | 8 ++-- gtk/my-valgrind.sh | 2 +- libtransmission/fail.sh | 3 +- qt/my-valgrind.sh | 2 +- update-version-h.sh | 51 ++++++++++++-------------- 7 files changed, 44 insertions(+), 50 deletions(-) diff --git a/autogen.sh b/autogen.sh index 385f15625..f63e5d7d8 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,31 +1,28 @@ #!/bin/sh -srcdir=`dirname $0` +srcdir=$(dirname "$0") test -z "$srcdir" && srcdir=. -ORIGDIR=`pwd` -cd "$srcdir" +ORIGDIR=$(pwd) +cd "$srcdir" || exit 1 PROJECT=Transmission GETTEXTIZE="glib-gettextize" $GETTEXTIZE --version < /dev/null > /dev/null 2>&1 if test $? -ne 0; then - GETTEXTIZE="" + GETTEXTIZE="" fi LIBTOOLIZE=libtoolize -if libtoolize --help >/dev/null 2>&1 -then +if libtoolize --help > /dev/null 2>&1; then : -elif glibtoolize --help >/dev/null 2>&1 -then +elif glibtoolize --help > /dev/null 2>&1; then LIBTOOLIZE=glibtoolize fi export LIBTOOLIZE ./update-version-h.sh -autoreconf -fi || exit 1; - +autoreconf -fi || exit 1 if test "$GETTEXTIZE"; then echo "Creating aclocal.m4 ..." @@ -41,10 +38,9 @@ fi cd "$ORIGDIR" || exit $? if test -z "$AUTOGEN_SUBDIR_MODE"; then - echo Running $srcdir/configure "$@" - $srcdir/configure "$@" + echo Running $srcdir/configure "$@" + $srcdir/configure "$@" - echo - echo "Now type 'make' to compile $PROJECT." + echo + echo "Now type 'make' to compile $PROJECT." fi - diff --git a/daemon/my-valgrind.sh b/daemon/my-valgrind.sh index 7db09f934..52c27f4aa 100755 --- a/daemon/my-valgrind.sh +++ b/daemon/my-valgrind.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh export G_SLICE=always-malloc export G_DEBUG=gc-friendly export GLIBCXX_FORCE_NEW=1 diff --git a/extras/send-email-when-torrent-done.sh b/extras/send-email-when-torrent-done.sh index ff4416486..79d6d8fa2 100755 --- a/extras/send-email-when-torrent-done.sh +++ b/extras/send-email-when-torrent-done.sh @@ -47,7 +47,7 @@ SMTP_SERVER=your.smtp.server SUBJECT="Torrent Done!" FROM_ADDR="transmission@localhost.localdomain" -TMPFILE=`mktemp -t transmission.XXXXXXXXXX` -echo "Transmission finished downloading \"$TR_TORRENT_NAME\" on $TR_TIME_LOCALTIME" >$TMPFILE -$NAIL -v -S from="$FROM_ADDR" -S smtp -s "$SUBJECT" -S smtp=$SMTP_SERVER "$TO_ADDR" < $TMPFILE -rm $TMPFILE +TMPFILE=$(mktemp -t transmission.XXXXXXXXXX) +echo "Transmission finished downloading \"$TR_TORRENT_NAME\" on $TR_TIME_LOCALTIME" > "$TMPFILE" +$NAIL -v -S from="$FROM_ADDR" -S smtp -s "$SUBJECT" -S smtp=$SMTP_SERVER "$TO_ADDR" < "$TMPFILE" +rm "$TMPFILE" diff --git a/gtk/my-valgrind.sh b/gtk/my-valgrind.sh index 87d960b8e..76683ae5b 100755 --- a/gtk/my-valgrind.sh +++ b/gtk/my-valgrind.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh export G_SLICE=always-malloc export G_DEBUG=gc-friendly export GLIBCXX_FORCE_NEW=1 diff --git a/libtransmission/fail.sh b/libtransmission/fail.sh index 22a6171ec..d0beda970 100755 --- a/libtransmission/fail.sh +++ b/libtransmission/fail.sh @@ -1,7 +1,8 @@ +#!/bin/sh err=0 count=0 while [ $err -eq 0 ]; do - count=$((count+1)) + count=$((count + 1)) echo starting run number $count make check err=$? diff --git a/qt/my-valgrind.sh b/qt/my-valgrind.sh index c3e14cd64..79803ee41 100755 --- a/qt/my-valgrind.sh +++ b/qt/my-valgrind.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh #valgrind --tool=cachegrind ./transmission-qt 2>&1 | tee runlog #valgrind --tool=massif --threshold=0.2 ./transmission-qt 2>&1 | tee runlog valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=16 --log-file=x-valgrind --show-reachable=no ./transmission-qt 2>&1 | tee runlog diff --git a/update-version-h.sh b/update-version-h.sh index b1e326b4f..386e4bbd9 100755 --- a/update-version-h.sh +++ b/update-version-h.sh @@ -2,47 +2,44 @@ # Generate files to be included: only overwrite them if changed so make # won't rebuild everything unless necessary -replace_if_differs () -{ - if cmp $1 $2 > /dev/null 2>&1; then - rm -f $1 - else - mv -f $1 $2 - fi +replace_if_differs() { + if cmp "$1" "$2" > /dev/null 2>&1; then + rm -f "$1" + else + mv -f "$1" "$2" + fi } echo "creating libtransmission/version.h" -user_agent_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep user_agent_prefix | cut -d , -f 6` +user_agent_prefix=$(grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep user_agent_prefix | cut -d , -f 6) -peer_id_prefix=`grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep peer_id_prefix | cut -d , -f 6` +peer_id_prefix=$(grep m4_define configure.ac | sed "s/[][)(]/,/g" | grep peer_id_prefix | cut -d , -f 6) -major_version=`echo ${user_agent_prefix} | awk -F . '{print $1}'` -minor_version=`echo ${user_agent_prefix} | awk -F . '{print $2 + 0}'` +major_version=$(echo "${user_agent_prefix}" | awk -F . '{print $1}') +minor_version=$(echo "${user_agent_prefix}" | awk -F . '{print $2 + 0}') vcs_revision= vcs_revision_file=REVISION -if [ -n "$JENKINS_URL" -a -n "$GIT_COMMIT" ]; then - vcs_revision=$GIT_COMMIT -elif [ -n "$TEAMCITY_PROJECT_NAME" -a -n "$BUILD_VCS_NUMBER" ]; then - vcs_revision=$BUILD_VCS_NUMBER -elif [ -d ".git" ] && type git >/dev/null 2>&1; then - vcs_revision=`git rev-list --max-count=1 HEAD` +if [ -n "$JENKINS_URL" ] && [ -n "$GIT_COMMIT" ]; then + vcs_revision=$GIT_COMMIT +elif [ -n "$TEAMCITY_PROJECT_NAME" ] && [ -n "$BUILD_VCS_NUMBER" ]; then + vcs_revision=$BUILD_VCS_NUMBER +elif [ -d ".git" ] && type git > /dev/null 2>&1; then + vcs_revision=$(git rev-list --max-count=1 HEAD) elif [ -f "$vcs_revision_file" ]; then - vcs_revision=`cat "$vcs_revision_file"` + vcs_revision=$(cat "$vcs_revision_file") fi -vcs_revision=`echo $vcs_revision` - if [ -n "$vcs_revision" ]; then - [ -f "$vcs_revision_file" ] && [ "`cat "$vcs_revision_file"`" = "$vcs_revision" ] || echo "$vcs_revision" > "$vcs_revision_file" + [ -f "$vcs_revision_file" ] && [ "$(cat "$vcs_revision_file")" = "$vcs_revision" ] || echo "$vcs_revision" > "$vcs_revision_file" else - vcs_revision=0 - rm -f "$vcs_revision_file" + vcs_revision=0 + rm -f "$vcs_revision_file" fi -vcs_revision=`echo $vcs_revision | head -c10` +vcs_revision=$(echo $vcs_revision | head -c10) cat > libtransmission/version.h.new << EOF #pragma once @@ -61,9 +58,9 @@ EOF # Add a release definition case "${peer_id_prefix}" in - *X-) echo '#define TR_BETA_RELEASE 1' ;; - *Z-) echo '#define TR_NIGHTLY_RELEASE 1' ;; - *) echo '#define TR_STABLE_RELEASE 1' ;; + *X-) echo '#define TR_BETA_RELEASE 1' ;; + *Z-) echo '#define TR_NIGHTLY_RELEASE 1' ;; + *) echo '#define TR_STABLE_RELEASE 1' ;; esac >> "libtransmission/version.h.new" replace_if_differs libtransmission/version.h.new libtransmission/version.h