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.

108 lines
3.0 KiB

Update minio-go dependencies to latest 5.0.0 release (#5640) With following changes - Add SSE and refactor encryption API (#942) <Andreas Auernhammer> - add copyObject test changing metadata and preserving etag (#944) <Harshavardhana> - Add SSE-C tests for multipart, copy, get range operations (#941) <Harshavardhana> - Removing conditional check for notificationInfoCh in api-notication (#940) <Matthew Magaldi> - Honor prefix parameter in ListBucketPolicies API (#929) <kannappanr> - test for empty objects uploaded with SSE-C headers (#927) <kannappanr> - Encryption headers should also be set during initMultipart (#930) <Harshavardhana> - Add support for Content-Language metadata header (#928) <kannappanr> - Fix check for duplicate notification configuration entries (#917) <kannappanr> - allow OS to cleanup sockets in TIME_WAIT (#925) <Harshavardhana> - Sign V2: Fix signature calculation in virtual host style (#921) <A. Elleuch> - bucket policy: Support json string in Principal field (#919) <A. Elleuch> - Fix copyobject failure for empty files (#918) <kannappanr> - Add new constructor NewWithOptions to SDK (#915) <poornas> - Support redirect headers to sign again with new Host header. (#829) <Harshavardhana> - Fail in PutObject if invalid user metadata is passed <Harshavadhana> - PutObjectOptions Header: Don't include invalid header <Isaac Hess> - increase max retry count to 10 (#913) <poornas> - Add new regions for Paris and China west. (#905) <Harshavardhana> - fix s3signer to use req.Host header (#899) <Bartłomiej Nogaś>
7 years ago
  1. // Copyright (c) 2015-2021 MinIO, Inc.
  2. //
  3. // This file is part of MinIO Object Storage stack
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Affero General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. package cmd
  18. import (
  19. "os"
  20. "path/filepath"
  21. homedir "github.com/mitchellh/go-homedir"
  22. )
  23. const (
  24. // Default minio configuration directory where below configuration files/directories are stored.
  25. defaultMinioConfigDir = ".minio"
  26. // Directory contains below files/directories for HTTPS configuration.
  27. certsDir = "certs"
  28. // Directory contains all CA certificates other than system defaults for HTTPS.
  29. certsCADir = "CAs"
  30. // Public certificate file for HTTPS.
  31. publicCertFile = "public.crt"
  32. // Private key file for HTTPS.
  33. privateKeyFile = "private.key"
  34. )
  35. // ConfigDir - points to a user set directory.
  36. type ConfigDir struct {
  37. path string
  38. }
  39. func getDefaultConfigDir() string {
  40. homeDir, err := homedir.Dir()
  41. if err != nil {
  42. return ""
  43. }
  44. return filepath.Join(homeDir, defaultMinioConfigDir)
  45. }
  46. func getDefaultCertsDir() string {
  47. return filepath.Join(getDefaultConfigDir(), certsDir)
  48. }
  49. func getDefaultCertsCADir() string {
  50. return filepath.Join(getDefaultCertsDir(), certsCADir)
  51. }
  52. var (
  53. // Default config, certs and CA directories.
  54. defaultConfigDir = &ConfigDir{path: getDefaultConfigDir()}
  55. defaultCertsDir = &ConfigDir{path: getDefaultCertsDir()}
  56. defaultCertsCADir = &ConfigDir{path: getDefaultCertsCADir()}
  57. // Points to current configuration directory -- deprecated, to be removed in future.
  58. globalConfigDir = defaultConfigDir
  59. // Points to current certs directory set by user with --certs-dir
  60. globalCertsDir = defaultCertsDir
  61. // Points to relative path to certs directory and is <value-of-certs-dir>/CAs
  62. globalCertsCADir = defaultCertsCADir
  63. )
  64. // Get - returns current directory.
  65. func (dir *ConfigDir) Get() string {
  66. return dir.path
  67. }
  68. // Attempts to create all directories, ignores any permission denied errors.
  69. func mkdirAllIgnorePerm(path string) error {
  70. err := os.MkdirAll(path, 0o700)
  71. if err != nil {
  72. // It is possible in kubernetes like deployments this directory
  73. // is already mounted and is not writable, ignore any write errors.
  74. if osIsPermission(err) {
  75. err = nil
  76. }
  77. }
  78. return err
  79. }
  80. func getConfigFile() string {
  81. return filepath.Join(globalConfigDir.Get(), minioConfigFile)
  82. }
  83. func getPublicCertFile() string {
  84. return filepath.Join(globalCertsDir.Get(), publicCertFile)
  85. }
  86. func getPrivateKeyFile() string {
  87. return filepath.Join(globalCertsDir.Get(), privateKeyFile)
  88. }