You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

407 lines
20 KiB

nginx-util: use UCI for server configuration **tl;dr:** The functions `{add,del}_ssl` modify a server section of the UCI config if there is no `.conf` file with the same name in `/etc/nginx/conf.d/`. Then `init_lan` creates `/var/lib/nginx/uci.conf` files by copying the `/etc/nginx/uci.conf.template` and standard options from the UCI config; additionally the special path `logd` can be used in `{access,error}_log`. The init does not change the configuration beside re-creating self-signed certificates when needed. This is also the only purpose of the new `check_ssl`, which is installed as yearly cron job. **Initialization:** Invoking `nginx-util init_lan` parses the UCI configuration for package `nginx`. It creates a server part in `/var/lib/nginx/uci.conf` for each `section server '$name'` by copying all UCI options but the following: * `option uci_manage_ssl` is skipped. It is set to 'self-signed' by `nginx-util add_ssl $name`, removed by `nginx-util del_ssl $name` and used by `nginx-util check_ssl` (see below). * `logd` as path in `error_log` or `access_log` writes them to STDERR respective STDOUT, which are fowarded by Nginx's init to the log daemon. Specifically: `option error_log 'logd'` becomes `error_log stderr;` and `option access_log 'logd openwrt'` becomes `access_log /proc/self/fd/1 openwrt;` Other `[option|list] key 'value'` entries just become `key value;` directives. The init.d calls internally also `check_ssl` for rebuilding self-signed SSL certificates if needed (see below). And it still sets up `/var/lib/nginx/lan{,_ssl}.listen` files as it is doing in the current version (so they stay available). **Defaults:** The package installs the file `/etc/nginx/restrict_locally` containing allow/deny directives for restricting the access to LAN addresses by including it into a server part. The default server '_lan' includes this file and listens on all IPs (instead of only the local IPs as it did before; other servers do not need to listen explicitly on the local IPs anymore). The default server is contained together with a server that redirects HTTP requests for inexistent URLs to HTTPS in the UCI configuration file `/etc/config/nginx`. Furthermore, the packages installs a `/etc/nginx/uci.conf.template` containing the current setup and a marker, which will be replaced by the created UCI servers when calling `init_lan`. **Other:** If there is a file named `/etc/nginx/conf.d/$name.conf` the functions `init_lan`, `add_ssl $name` and `del_ssl $name` will use that file instead of a UCI server section (this is similar to the current version). Else it selects the UCI `section server $name`, or, when there is no such section, it searches for the first one having `option server_name '… $name …'`. For this section: * `nginx-util add_ssl $name` will add to it: `option uci_manage_ssl 'self-signed'` `option ssl_certificate '/etc/nginx/conf.d/$name.crt'` `option ssl_certificate_key '/etc/nginx/conf.d/$name.key'` `option ssl_session_cache 'shared:SSL:32k'` `option ssl_session_timeout '64m'` If these options are already present, they will stay the same; just the first option `uci_manage_ssl` will always be changed to 'self-signed'. The command also changes all `listen` list items to use port 443 and ssl instead of port 80 (without ssl). If they stated another port than 80 before, they are kept the same. Furthermore, it creates a self-signed SSL certificate if necessary, i.e., if there is no *valid* certificate and key at the locations given by the options `ssl_certificate` and `ssl_certificate_key`. * `nginx-util del_ssl $name` checks if `uci_manage_ssl` is set 'self-signed' in the corresponding UCI section. Only then it removes all of the above options regardless of the value looking just at the key name. Then, it also changes all `listen` list items to use port 80 (without ssl) instead of port 443 with ssl. If stating another port than 443, they are kept the same. Furthermore, it removes the SSL certificate and key that were indicated by `ssl_certificate{,_key}`. * `nginx-util check_ssl` looks through all server sections of the UCI config for `uci_manage_ssl 'self-signed'`. On every hit it checks if the SSL certificate-key-pair indicated by the options `ssl_certificate{,_key}` is expired. Then it re-creates a self-signed certificate. If there exists at least one `section server` with `uci_manage_ssl 'self-signed'`, it will try to install itself as cron job. If there are no such sections, it removes that cron job if possible. For installing a ssl certificate and key managed by another app, you can call: `nginx-util add_ssl $name $manager $crtpath $keypath` Hereby `$name` is as above, `$manager` is an arbitrary string, and the the ssl certificate and its key are indicated by their absolute path. If you want to remove the directives again, then you can use: `nginx-util del_ssl $name $manager` Signed-off-by: Peter Stadler <peter.stadler@student.uibk.ac.at>
4 years ago
  1. ---
  2. Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-fuchsia-*,-misc-definitions-in-headers,-llvm-header-guard,-*-qualified-auto,-llvm-include-order'
  3. WarningsAsErrors: ''
  4. HeaderFilterRegex: '.*'
  5. AnalyzeTemporaryDtors: false
  6. FormatStyle: file
  7. CheckOptions:
  8. - key: abseil-string-find-startswith.AbseilStringsMatchHeader
  9. value: 'absl/strings/match.h'
  10. - key: abseil-string-find-startswith.IncludeStyle
  11. value: llvm
  12. - key: abseil-string-find-startswith.StringLikeClasses
  13. value: '::std::basic_string'
  14. - key: bugprone-argument-comment.CommentBoolLiterals
  15. value: '0'
  16. - key: bugprone-argument-comment.CommentCharacterLiterals
  17. value: '0'
  18. - key: bugprone-argument-comment.CommentFloatLiterals
  19. value: '0'
  20. - key: bugprone-argument-comment.CommentIntegerLiterals
  21. value: '0'
  22. - key: bugprone-argument-comment.CommentNullPtrs
  23. value: '0'
  24. - key: bugprone-argument-comment.CommentStringLiterals
  25. value: '0'
  26. - key: bugprone-argument-comment.CommentUserDefinedLiterals
  27. value: '0'
  28. - key: bugprone-argument-comment.IgnoreSingleArgument
  29. value: '0'
  30. - key: bugprone-argument-comment.StrictMode
  31. value: '0'
  32. - key: bugprone-assert-side-effect.AssertMacros
  33. value: assert
  34. - key: bugprone-assert-side-effect.CheckFunctionCalls
  35. value: '0'
  36. - key: bugprone-dangling-handle.HandleClasses
  37. value: 'std::basic_string_view;std::experimental::basic_string_view'
  38. - key: bugprone-dynamic-static-initializers.HeaderFileExtensions
  39. value: ',h,hh,hpp,hxx'
  40. - key: bugprone-exception-escape.FunctionsThatShouldNotThrow
  41. value: ''
  42. - key: bugprone-exception-escape.IgnoredExceptions
  43. value: ''
  44. - key: bugprone-misplaced-widening-cast.CheckImplicitCasts
  45. value: '0'
  46. - key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
  47. value: '1'
  48. - key: bugprone-signed-char-misuse.CharTypdefsToIgnore
  49. value: ''
  50. - key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
  51. value: '1'
  52. - key: bugprone-sizeof-expression.WarnOnSizeOfConstant
  53. value: '1'
  54. - key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
  55. value: '0'
  56. - key: bugprone-sizeof-expression.WarnOnSizeOfThis
  57. value: '1'
  58. - key: bugprone-string-constructor.LargeLengthThreshold
  59. value: '8388608'
  60. - key: bugprone-string-constructor.WarnOnLargeLength
  61. value: '1'
  62. - key: bugprone-suspicious-enum-usage.StrictMode
  63. value: '0'
  64. - key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
  65. value: '5'
  66. - key: bugprone-suspicious-missing-comma.RatioThreshold
  67. value: '0.200000'
  68. - key: bugprone-suspicious-missing-comma.SizeThreshold
  69. value: '5'
  70. - key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
  71. value: ''
  72. - key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
  73. value: '1'
  74. - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
  75. value: '0'
  76. - key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
  77. value: '16'
  78. - key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
  79. value: '1'
  80. - key: bugprone-unused-return-value.CheckedFunctions
  81. value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty'
  82. - key: cert-dcl16-c.IgnoreMacros
  83. value: '1'
  84. - key: cert-dcl16-c.NewSuffixes
  85. value: 'L;LL;LU;LLU'
  86. - key: cert-dcl59-cpp.HeaderFileExtensions
  87. value: ',h,hh,hpp,hxx'
  88. - key: cert-err09-cpp.CheckThrowTemporaries
  89. value: '1'
  90. - key: cert-err61-cpp.CheckThrowTemporaries
  91. value: '1'
  92. - key: cert-msc32-c.DisallowedSeedTypes
  93. value: 'time_t,std::time_t'
  94. - key: cert-msc51-cpp.DisallowedSeedTypes
  95. value: 'time_t,std::time_t'
  96. - key: cert-oop11-cpp.IncludeStyle
  97. value: llvm
  98. - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
  99. value: '0'
  100. - key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
  101. value: '1.0;100.0;'
  102. - key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
  103. value: '1;2;3;4;'
  104. - key: cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal
  105. value: '0'
  106. - key: cppcoreguidelines-explicit-virtual-functions.FinalSpelling
  107. value: final
  108. - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
  109. value: '1'
  110. - key: cppcoreguidelines-explicit-virtual-functions.OverrideSpelling
  111. value: override
  112. - key: cppcoreguidelines-macro-usage.AllowedRegexp
  113. value: '^DEBUG_*'
  114. - key: cppcoreguidelines-macro-usage.CheckCapsOnly
  115. value: '0'
  116. - key: cppcoreguidelines-macro-usage.IgnoreCommandLineMacros
  117. value: '1'
  118. - key: cppcoreguidelines-no-malloc.Allocations
  119. value: '::malloc;::calloc'
  120. - key: cppcoreguidelines-no-malloc.Deallocations
  121. value: '::free'
  122. - key: cppcoreguidelines-no-malloc.Reallocations
  123. value: '::realloc'
  124. - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
  125. value: '1'
  126. - key: cppcoreguidelines-owning-memory.LegacyResourceConsumers
  127. value: '::free;::realloc;::freopen;::fclose'
  128. - key: cppcoreguidelines-owning-memory.LegacyResourceProducers
  129. value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
  130. - key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
  131. value: ''
  132. - key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
  133. value: '0'
  134. - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
  135. value: '0'
  136. - key: cppcoreguidelines-pro-type-member-init.UseAssignment
  137. value: '0'
  138. - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
  139. value: '0'
  140. - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
  141. value: '0'
  142. - key: google-build-namespaces.HeaderFileExtensions
  143. value: ',h,hh,hpp,hxx'
  144. - key: google-global-names-in-headers.HeaderFileExtensions
  145. value: ',h,hh,hpp,hxx'
  146. - key: google-readability-braces-around-statements.ShortStatementLines
  147. value: '1'
  148. - key: google-readability-function-size.BranchThreshold
  149. value: '4294967295'
  150. - key: google-readability-function-size.LineThreshold
  151. value: '4294967295'
  152. - key: google-readability-function-size.NestingThreshold
  153. value: '4294967295'
  154. - key: google-readability-function-size.ParameterThreshold
  155. value: '4294967295'
  156. - key: google-readability-function-size.StatementThreshold
  157. value: '800'
  158. - key: google-readability-function-size.VariableThreshold
  159. value: '4294967295'
  160. - key: google-readability-namespace-comments.ShortNamespaceLines
  161. value: '10'
  162. - key: google-readability-namespace-comments.SpacesBeforeComments
  163. value: '2'
  164. - key: google-runtime-int.SignedTypePrefix
  165. value: int
  166. - key: google-runtime-int.TypeSuffix
  167. value: ''
  168. - key: google-runtime-int.UnsignedTypePrefix
  169. value: uint
  170. - key: google-runtime-references.WhiteListTypes
  171. value: ''
  172. - key: hicpp-braces-around-statements.ShortStatementLines
  173. value: '0'
  174. - key: hicpp-function-size.BranchThreshold
  175. value: '4294967295'
  176. - key: hicpp-function-size.LineThreshold
  177. value: '4294967295'
  178. - key: hicpp-function-size.NestingThreshold
  179. value: '4294967295'
  180. - key: hicpp-function-size.ParameterThreshold
  181. value: '4294967295'
  182. - key: hicpp-function-size.StatementThreshold
  183. value: '800'
  184. - key: hicpp-function-size.VariableThreshold
  185. value: '4294967295'
  186. - key: hicpp-member-init.IgnoreArrays
  187. value: '0'
  188. - key: hicpp-member-init.UseAssignment
  189. value: '0'
  190. - key: hicpp-move-const-arg.CheckTriviallyCopyableMove
  191. value: '1'
  192. - key: hicpp-multiway-paths-covered.WarnOnMissingElse
  193. value: '0'
  194. - key: hicpp-named-parameter.IgnoreFailedSplit
  195. value: '0'
  196. - key: hicpp-no-malloc.Allocations
  197. value: '::malloc;::calloc'
  198. - key: hicpp-no-malloc.Deallocations
  199. value: '::free'
  200. - key: hicpp-no-malloc.Reallocations
  201. value: '::realloc'
  202. - key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
  203. value: '0'
  204. - key: hicpp-special-member-functions.AllowMissingMoveFunctions
  205. value: '0'
  206. - key: hicpp-special-member-functions.AllowSoleDefaultDtor
  207. value: '0'
  208. - key: hicpp-uppercase-literal-suffix.IgnoreMacros
  209. value: '1'
  210. - key: hicpp-uppercase-literal-suffix.NewSuffixes
  211. value: ''
  212. - key: hicpp-use-auto.MinTypeNameLength
  213. value: '5'
  214. - key: hicpp-use-auto.RemoveStars
  215. value: '0'
  216. - key: hicpp-use-emplace.ContainersWithPushBack
  217. value: '::std::vector;::std::list;::std::deque'
  218. - key: hicpp-use-emplace.SmartPointers
  219. value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
  220. - key: hicpp-use-emplace.TupleMakeFunctions
  221. value: '::std::make_pair;::std::make_tuple'
  222. - key: hicpp-use-emplace.TupleTypes
  223. value: '::std::pair;::std::tuple'
  224. - key: hicpp-use-equals-default.IgnoreMacros
  225. value: '1'
  226. - key: hicpp-use-equals-delete.IgnoreMacros
  227. value: '1'
  228. - key: hicpp-use-noexcept.ReplacementString
  229. value: ''
  230. - key: hicpp-use-noexcept.UseNoexceptFalse
  231. value: '1'
  232. - key: hicpp-use-nullptr.NullMacros
  233. value: ''
  234. - key: hicpp-use-override.AllowOverrideAndFinal
  235. value: '0'
  236. - key: hicpp-use-override.FinalSpelling
  237. value: final
  238. - key: hicpp-use-override.IgnoreDestructors
  239. value: '0'
  240. - key: hicpp-use-override.OverrideSpelling
  241. value: override
  242. - key: llvm-namespace-comment.ShortNamespaceLines
  243. value: '1'
  244. - key: llvm-namespace-comment.SpacesBeforeComments
  245. value: '1'
  246. - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
  247. value: '1'
  248. - key: misc-unused-parameters.StrictMode
  249. value: '0'
  250. - key: modernize-loop-convert.MaxCopySize
  251. value: '16'
  252. - key: modernize-loop-convert.MinConfidence
  253. value: reasonable
  254. - key: modernize-loop-convert.NamingStyle
  255. value: CamelCase
  256. - key: modernize-make-shared.IgnoreMacros
  257. value: '1'
  258. - key: modernize-make-shared.IncludeStyle
  259. value: '0'
  260. - key: modernize-make-shared.MakeSmartPtrFunction
  261. value: 'std::make_shared'
  262. - key: modernize-make-shared.MakeSmartPtrFunctionHeader
  263. value: memory
  264. - key: modernize-make-unique.IgnoreMacros
  265. value: '1'
  266. - key: modernize-make-unique.IncludeStyle
  267. value: '0'
  268. - key: modernize-make-unique.MakeSmartPtrFunction
  269. value: 'std::make_unique'
  270. - key: modernize-make-unique.MakeSmartPtrFunctionHeader
  271. value: memory
  272. - key: modernize-pass-by-value.IncludeStyle
  273. value: llvm
  274. - key: modernize-pass-by-value.ValuesOnly
  275. value: '0'
  276. - key: modernize-raw-string-literal.ReplaceShorterLiterals
  277. value: '0'
  278. - key: modernize-replace-auto-ptr.IncludeStyle
  279. value: llvm
  280. - key: modernize-replace-random-shuffle.IncludeStyle
  281. value: llvm
  282. - key: modernize-use-auto.MinTypeNameLength
  283. value: '5'
  284. - key: modernize-use-auto.RemoveStars
  285. value: '0'
  286. - key: modernize-use-default-member-init.IgnoreMacros
  287. value: '1'
  288. - key: modernize-use-default-member-init.UseAssignment
  289. value: '0'
  290. - key: modernize-use-emplace.ContainersWithPushBack
  291. value: '::std::vector;::std::list;::std::deque'
  292. - key: modernize-use-emplace.SmartPointers
  293. value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
  294. - key: modernize-use-emplace.TupleMakeFunctions
  295. value: '::std::make_pair;::std::make_tuple'
  296. - key: modernize-use-emplace.TupleTypes
  297. value: '::std::pair;::std::tuple'
  298. - key: modernize-use-equals-default.IgnoreMacros
  299. value: '1'
  300. - key: modernize-use-equals-delete.IgnoreMacros
  301. value: '1'
  302. - key: modernize-use-nodiscard.ReplacementString
  303. value: '[[nodiscard]]'
  304. - key: modernize-use-noexcept.ReplacementString
  305. value: ''
  306. - key: modernize-use-noexcept.UseNoexceptFalse
  307. value: '1'
  308. - key: modernize-use-nullptr.NullMacros
  309. value: 'NULL'
  310. - key: modernize-use-override.AllowOverrideAndFinal
  311. value: '0'
  312. - key: modernize-use-override.FinalSpelling
  313. value: final
  314. - key: modernize-use-override.IgnoreDestructors
  315. value: '0'
  316. - key: modernize-use-override.OverrideSpelling
  317. value: override
  318. - key: modernize-use-transparent-functors.SafeMode
  319. value: '0'
  320. - key: modernize-use-using.IgnoreMacros
  321. value: '1'
  322. - key: objc-forbidden-subclassing.ForbiddenSuperClassNames
  323. value: 'ABNewPersonViewController;ABPeoplePickerNavigationController;ABPersonViewController;ABUnknownPersonViewController;NSHashTable;NSMapTable;NSPointerArray;NSPointerFunctions;NSTimer;UIActionSheet;UIAlertView;UIImagePickerController;UITextInputMode;UIWebView'
  324. - key: openmp-exception-escape.IgnoredExceptions
  325. value: ''
  326. - key: performance-faster-string-find.StringLikeClasses
  327. value: 'std::basic_string'
  328. - key: performance-for-range-copy.AllowedTypes
  329. value: ''
  330. - key: performance-for-range-copy.WarnOnAllAutoCopies
  331. value: '0'
  332. - key: performance-inefficient-string-concatenation.StrictMode
  333. value: '0'
  334. - key: performance-inefficient-vector-operation.EnableProto
  335. value: '0'
  336. - key: performance-inefficient-vector-operation.VectorLikeClasses
  337. value: '::std::vector'
  338. - key: performance-move-const-arg.CheckTriviallyCopyableMove
  339. value: '1'
  340. - key: performance-move-constructor-init.IncludeStyle
  341. value: llvm
  342. - key: performance-no-automatic-move.AllowedTypes
  343. value: ''
  344. - key: performance-type-promotion-in-math-fn.IncludeStyle
  345. value: llvm
  346. - key: performance-unnecessary-copy-initialization.AllowedTypes
  347. value: ''
  348. - key: performance-unnecessary-value-param.AllowedTypes
  349. value: ''
  350. - key: performance-unnecessary-value-param.IncludeStyle
  351. value: llvm
  352. - key: portability-simd-intrinsics.Std
  353. value: ''
  354. - key: portability-simd-intrinsics.Suggest
  355. value: '0'
  356. - key: readability-braces-around-statements.ShortStatementLines
  357. value: '0'
  358. - key: readability-else-after-return.WarnOnUnfixable
  359. value: '1'
  360. - key: readability-function-size.BranchThreshold
  361. value: '4294967295'
  362. - key: readability-function-size.LineThreshold
  363. value: '4294967295'
  364. - key: readability-function-size.NestingThreshold
  365. value: '4294967295'
  366. - key: readability-function-size.ParameterThreshold
  367. value: '4294967295'
  368. - key: readability-function-size.StatementThreshold
  369. value: '800'
  370. - key: readability-function-size.VariableThreshold
  371. value: '4294967295'
  372. - key: readability-identifier-naming.IgnoreFailedSplit
  373. value: '0'
  374. - key: readability-implicit-bool-conversion.AllowIntegerConditions
  375. value: '0'
  376. - key: readability-implicit-bool-conversion.AllowPointerConditions
  377. value: '0'
  378. - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
  379. value: '1'
  380. - key: readability-inconsistent-declaration-parameter-name.Strict
  381. value: '0'
  382. - key: readability-magic-numbers.IgnoredFloatingPointValues
  383. value: '1.0;100.0;'
  384. - key: readability-magic-numbers.IgnoredIntegerValues
  385. value: '1;2;3;4;'
  386. - key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
  387. value: '0'
  388. - key: readability-redundant-smartptr-get.IgnoreMacros
  389. value: '1'
  390. - key: readability-redundant-string-init.StringNames
  391. value: '::std::basic_string'
  392. - key: readability-simplify-boolean-expr.ChainedConditionalAssignment
  393. value: '0'
  394. - key: readability-simplify-boolean-expr.ChainedConditionalReturn
  395. value: '0'
  396. - key: readability-simplify-subscript-expr.Types
  397. value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
  398. - key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
  399. value: '3'
  400. - key: readability-uppercase-literal-suffix.IgnoreMacros
  401. value: '1'
  402. - key: readability-uppercase-literal-suffix.NewSuffixes
  403. value: ''
  404. - key: zircon-temporary-objects.Names
  405. value: ''
  406. ...