|
| 1 | +From 76f6d6fef6494d2dfd8cbc0ea8d88a8d82029c09 Mon Sep 17 00:00:00 2001 |
| 2 | +From: chewitt <github@chrishewitt.net> |
| 3 | +Date: Sat, 11 Nov 2017 05:44:48 +0000 |
| 4 | +Subject: [PATCH] smbclient: allow config of min client and legacy security |
| 5 | + |
| 6 | +--- |
| 7 | + .../resource.language.en_gb/resources/strings.po | 34 ++++++++++++++++++---- |
| 8 | + system/settings/linux.xml | 6 ++++ |
| 9 | + system/settings/settings.xml | 25 ++++++++++++++++ |
| 10 | + xbmc/filesystem/SMBFile.cpp | 16 ++++++++++ |
| 11 | + xbmc/network/NetworkServices.cpp | 4 ++- |
| 12 | + xbmc/settings/Settings.cpp | 4 +++ |
| 13 | + xbmc/settings/Settings.h | 2 ++ |
| 14 | + 7 files changed, 85 insertions(+), 6 deletions(-) |
| 15 | + |
| 16 | +diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po |
| 17 | +index 9009023f4d39..f7755776eea6 100644 |
| 18 | +--- a/addons/resource.language.en_gb/resources/strings.po |
| 19 | ++++ b/addons/resource.language.en_gb/resources/strings.po |
| 20 | +@@ -19075,25 +19075,25 @@ msgctxt "#36622" |
| 21 | + msgid "Set the maximum SMB protocol version to negotiate when making connections. Forcing SMBv2 or SMBv1 compatibility may be required with older NAS and Windows shares." |
| 22 | + msgstr "" |
| 23 | + |
| 24 | +-#. Values for setting with label #36621 "Maximum protocol version" - none means "no protocol version is forced" |
| 25 | ++#. Values for settings with label #36621 and #36628 "Minimum/Maximum protocol version" - none means "no protocol version is forced" |
| 26 | + #: system/settings/settings.xml |
| 27 | + msgctxt "#36623" |
| 28 | + msgid "None" |
| 29 | + msgstr "" |
| 30 | + |
| 31 | +-#. Values for setting with label #36621 "Maximum protocol version" |
| 32 | ++#. Values for setting with label #36621 and #36628 "Minimum/Maximum protocol version" |
| 33 | + #: system/settings/settings.xml |
| 34 | + msgctxt "#36624" |
| 35 | + msgid "SMBv1" |
| 36 | + msgstr "" |
| 37 | + |
| 38 | +-#. Values for setting with label #36621 "Maximum protocol version" |
| 39 | ++#. Values for setting with label #36621 and #36628 "Minimum/Maximum protocol version" |
| 40 | + #: system/settings/settings.xml |
| 41 | + msgctxt "#36625" |
| 42 | + msgid "SMBv2" |
| 43 | + msgstr "" |
| 44 | + |
| 45 | +-#. Values for setting with label #36621 "Maximum protocol version" |
| 46 | ++#. Values for setting with label #36621 and #36628 "Minimum/Maximum protocol version" |
| 47 | + #: system/settings/settings.xml |
| 48 | + msgctxt "#36626" |
| 49 | + msgid "SMBv3" |
| 50 | +@@ -19105,7 +19105,31 @@ msgctxt "#36627" |
| 51 | + msgid "Client" |
| 52 | + msgstr "" |
| 53 | + |
| 54 | +-#empty strings from id 36628 to 36899 |
| 55 | ++#. Label of a setting, allow the minimum smbclient protocol to be configured |
| 56 | ++#: system/settings/settings.xml |
| 57 | ++msgctxt "#36628" |
| 58 | ++msgid "Minimum protocol version" |
| 59 | ++msgstr "" |
| 60 | ++ |
| 61 | ++#. Description of setting with label #36628 "Minimum protocol version" |
| 62 | ++#: system/settings/settings.xml |
| 63 | ++msgctxt "#36629" |
| 64 | ++msgid "Set the minimum SMB protocol version to negotiate when making connections. Forcing SMBv2 may be required to prevent SMBv1 use on some OS." |
| 65 | ++msgstr "" |
| 66 | ++ |
| 67 | ++#. Label of a setting, sets additional config required for some proprietary SMBv1 implementations (mostly routers) |
| 68 | ++#: system/settings/settings.xml |
| 69 | ++msgctxt "#36630" |
| 70 | ++msgid "Use legacy security" |
| 71 | ++msgstr "" |
| 72 | ++ |
| 73 | ++#. Description of setting with label #36630 "Use legacy security" |
| 74 | ++#: system/settings/settings.xml |
| 75 | ++msgctxt "#36631" |
| 76 | ++msgid "Force weak SMBv1 security for compatibility with the USB sharing features on some WiFi routers and NAS devices." |
| 77 | ++msgstr "" |
| 78 | ++ |
| 79 | ++#empty strings from id 36632 to 36899 |
| 80 | + |
| 81 | + #: xbmc/media/MediaType.cpp |
| 82 | + msgctxt "#36900" |
| 83 | +diff --git a/system/settings/linux.xml b/system/settings/linux.xml |
| 84 | +index 7cb276acddba..5c27e489a0ad 100644 |
| 85 | +--- a/system/settings/linux.xml |
| 86 | ++++ b/system/settings/linux.xml |
| 87 | +@@ -12,9 +12,15 @@ |
| 88 | + <section id="services"> |
| 89 | + <category id="smb"> |
| 90 | + <group id="2"> |
| 91 | ++ <setting id="smb.minprotocol"> |
| 92 | ++ <visible>true</visible> |
| 93 | ++ </setting> |
| 94 | + <setting id="smb.maxprotocol"> |
| 95 | + <visible>true</visible> |
| 96 | + </setting> |
| 97 | ++ <setting id="smb.legacysecurity"> |
| 98 | ++ <visible>true</visible> |
| 99 | ++ </setting> |
| 100 | + </group> |
| 101 | + </category> |
| 102 | + </section> |
| 103 | +diff --git a/system/settings/settings.xml b/system/settings/settings.xml |
| 104 | +index 5ff71b9741c5..79b4321ab9c7 100644 |
| 105 | +--- a/system/settings/settings.xml |
| 106 | ++++ b/system/settings/settings.xml |
| 107 | +@@ -1956,6 +1956,20 @@ |
| 108 | + <default>0.0.0.0</default> |
| 109 | + <control type="edit" format="ip" /> |
| 110 | + </setting> |
| 111 | ++ <setting id="smb.minprotocol" type="integer" label="36628" help="36629"> |
| 112 | ++ <level>2</level> |
| 113 | ++ <visible>false</visible> |
| 114 | ++ <default>0</default> |
| 115 | ++ <constraints> |
| 116 | ++ <options> |
| 117 | ++ <option label="36623">0</option> |
| 118 | ++ <option label="36624">1</option> |
| 119 | ++ <option label="36625">2</option> |
| 120 | ++ <option label="36626">3</option> |
| 121 | ++ </options> |
| 122 | ++ </constraints> |
| 123 | ++ <control type="list" format="integer" /> |
| 124 | ++ </setting> |
| 125 | + <setting id="smb.maxprotocol" type="integer" label="36621" help="36622"> |
| 126 | + <level>2</level> |
| 127 | + <visible>false</visible> |
| 128 | +@@ -1970,6 +1984,17 @@ |
| 129 | + </constraints> |
| 130 | + <control type="list" format="integer" /> |
| 131 | + </setting> |
| 132 | ++ <setting id="smb.legacysecurity" type="boolean" label="36630" help="36631"> |
| 133 | ++ <level>2</level> |
| 134 | ++ <visible>false</visible> |
| 135 | ++ <default>false</default> |
| 136 | ++ <control type="toggle" /> |
| 137 | ++ <dependencies> |
| 138 | ++ <dependency type="enable"> |
| 139 | ++ <condition setting="smb.maxprotocol" operator="is">1</condition> |
| 140 | ++ </dependency> |
| 141 | ++ </dependencies> |
| 142 | ++ </setting> |
| 143 | + </group> |
| 144 | + </category> |
| 145 | + <category id="weather" label="8" help="36316"> |
| 146 | +diff --git a/xbmc/filesystem/SMBFile.cpp b/xbmc/filesystem/SMBFile.cpp |
| 147 | +index e5301b0452f9..7fc139635f0b 100644 |
| 148 | +--- a/xbmc/filesystem/SMBFile.cpp |
| 149 | ++++ b/xbmc/filesystem/SMBFile.cpp |
| 150 | +@@ -117,6 +117,15 @@ void CSMB::Init() |
| 151 | + |
| 152 | + fprintf(f, "\tlock directory = %s/.smb/\n", home.c_str()); |
| 153 | + |
| 154 | ++ // set minimum smbclient protocol version |
| 155 | ++ if (CSettings::GetInstance().GetInt(CSettings::SETTING_SMB_MINPROTOCOL) > 0) |
| 156 | ++ { |
| 157 | ++ if (CSettings::GetInstance().GetInt(CSettings::SETTING_SMB_MINPROTOCOL) == 1) |
| 158 | ++ fprintf(f, "\tclient min protocol = NT1\n"); |
| 159 | ++ else |
| 160 | ++ fprintf(f, "\tclient min protocol = SMB%d\n", CSettings::GetInstance().GetInt(CSettings::SETTING_SMB_MINPROTOCOL)); |
| 161 | ++ } |
| 162 | ++ |
| 163 | + // set maximum smbclient protocol version |
| 164 | + if (CSettings::GetInstance().GetInt(CSettings::SETTING_SMB_MAXPROTOCOL) > 0) |
| 165 | + { |
| 166 | +@@ -126,6 +135,13 @@ void CSMB::Init() |
| 167 | + fprintf(f, "\tclient max protocol = SMB%d\n", CSettings::GetInstance().GetInt(CSettings::SETTING_SMB_MAXPROTOCOL)); |
| 168 | + } |
| 169 | + |
| 170 | ++ // set legacy security options |
| 171 | ++ if (CSettings::GetInstance().GetBool(CSettings::SETTING_SMB_LEGACYSECURITY) && (CSettings::GetInstance().GetInt(CSettings::SETTING_SMB_MAXPROTOCOL) == 1)) |
| 172 | ++ { |
| 173 | ++ fprintf(f, "\tclient NTLMv2 auth = no\n"); |
| 174 | ++ fprintf(f, "\tclient use spnego = no\n"); |
| 175 | ++ } |
| 176 | ++ |
| 177 | + // set wins server if there's one. name resolve order defaults to 'lmhosts host wins bcast'. |
| 178 | + // if no WINS server has been specified the wins method will be ignored. |
| 179 | + if (CSettings::GetInstance().GetString(CSettings::SETTING_SMB_WINSSERVER).length() > 0 && !StringUtils::EqualsNoCase(CSettings::GetInstance().GetString(CSettings::SETTING_SMB_WINSSERVER), "0.0.0.0") ) |
| 180 | +diff --git a/xbmc/network/NetworkServices.cpp b/xbmc/network/NetworkServices.cpp |
| 181 | +index 393dabc3067d..5dad5c22c0af 100644 |
| 182 | +--- a/xbmc/network/NetworkServices.cpp |
| 183 | ++++ b/xbmc/network/NetworkServices.cpp |
| 184 | +@@ -439,7 +439,9 @@ void CNetworkServices::OnSettingChanged(const CSetting *setting) |
| 185 | + #endif // HAS_WEB_SERVER |
| 186 | + if (settingId == CSettings::SETTING_SMB_WINSSERVER || |
| 187 | + settingId == CSettings::SETTING_SMB_WORKGROUP || |
| 188 | +- settingId == CSettings::SETTING_SMB_MAXPROTOCOL) |
| 189 | ++ settingId == CSettings::SETTING_SMB_MINPROTOCOL || |
| 190 | ++ settingId == CSettings::SETTING_SMB_MAXPROTOCOL || |
| 191 | ++ settingId == CSettings::SETTING_SMB_LEGACYSECURITY) |
| 192 | + { |
| 193 | + // okey we really don't need to restart, only deinit samba, but that could be damn hard if something is playing |
| 194 | + //! @todo - General way of handling setting changes that require restart |
| 195 | +diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp |
| 196 | +index f76c152b4d37..5400ba229164 100644 |
| 197 | +--- a/xbmc/settings/Settings.cpp |
| 198 | ++++ b/xbmc/settings/Settings.cpp |
| 199 | +@@ -333,7 +333,9 @@ const std::string CSettings::SETTING_SERVICES_AIRPLAYPASSWORD = "services.airpla |
| 200 | + const std::string CSettings::SETTING_SERVICES_AIRPLAYVIDEOSUPPORT = "services.airplayvideosupport"; |
| 201 | + const std::string CSettings::SETTING_SMB_WINSSERVER = "smb.winsserver"; |
| 202 | + const std::string CSettings::SETTING_SMB_WORKGROUP = "smb.workgroup"; |
| 203 | ++const std::string CSettings::SETTING_SMB_MINPROTOCOL = "smb.minprotocol"; |
| 204 | + const std::string CSettings::SETTING_SMB_MAXPROTOCOL = "smb.maxprotocol"; |
| 205 | ++const std::string CSettings::SETTING_SMB_LEGACYSECURITY = "smb.legacysecurity"; |
| 206 | + const std::string CSettings::SETTING_VIDEOSCREEN_MONITOR = "videoscreen.monitor"; |
| 207 | + const std::string CSettings::SETTING_VIDEOSCREEN_SCREEN = "videoscreen.screen"; |
| 208 | + const std::string CSettings::SETTING_VIDEOSCREEN_RESOLUTION = "videoscreen.resolution"; |
| 209 | +@@ -1160,7 +1162,9 @@ void CSettings::InitializeISettingCallbacks() |
| 210 | + settingSet.insert(CSettings::SETTING_SERVICES_ESCONTINUOUSDELAY); |
| 211 | + settingSet.insert(CSettings::SETTING_SMB_WINSSERVER); |
| 212 | + settingSet.insert(CSettings::SETTING_SMB_WORKGROUP); |
| 213 | ++ settingSet.insert(CSettings::SETTING_SMB_MINPROTOCOL); |
| 214 | + settingSet.insert(CSettings::SETTING_SMB_MAXPROTOCOL); |
| 215 | ++ settingSet.insert(CSettings::SETTING_SMB_LEGACYSECURITY); |
| 216 | + m_settingsManager->RegisterCallback(&CNetworkServices::GetInstance(), settingSet); |
| 217 | + |
| 218 | + settingSet.clear(); |
| 219 | +diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h |
| 220 | +index ab6770997ce5..c40ab2d31957 100644 |
| 221 | +--- a/xbmc/settings/Settings.h |
| 222 | ++++ b/xbmc/settings/Settings.h |
| 223 | +@@ -290,7 +290,9 @@ class CSettings : public CSettingCreator, public CSettingControlCreator |
| 224 | + static const std::string SETTING_SERVICES_AIRPLAYVIDEOSUPPORT; |
| 225 | + static const std::string SETTING_SMB_WINSSERVER; |
| 226 | + static const std::string SETTING_SMB_WORKGROUP; |
| 227 | ++ static const std::string SETTING_SMB_MINPROTOCOL; |
| 228 | + static const std::string SETTING_SMB_MAXPROTOCOL; |
| 229 | ++ static const std::string SETTING_SMB_LEGACYSECURITY; |
| 230 | + static const std::string SETTING_VIDEOSCREEN_MONITOR; |
| 231 | + static const std::string SETTING_VIDEOSCREEN_SCREEN; |
| 232 | + static const std::string SETTING_VIDEOSCREEN_RESOLUTION; |
0 commit comments