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.

53 lines
2.7 KiB

  1. From d8f8f4d637ce43f8699ba94c9b7648beda0ca174 Mon Sep 17 00:00:00 2001
  2. From: Ondrej Holy <oholy@redhat.com>
  3. Date: Thu, 23 May 2019 10:41:53 +0200
  4. Subject: [PATCH] gfile: Limit access to files when copying
  5. file_copy_fallback creates new files with default permissions and
  6. set the correct permissions after the operation is finished. This
  7. might cause that the files can be accessible by more users during
  8. the operation than expected. Use G_FILE_CREATE_PRIVATE for the new
  9. files to limit access to those files.
  10. ---
  11. gio/gfile.c | 11 ++++++-----
  12. 1 file changed, 6 insertions(+), 5 deletions(-)
  13. diff --git a/gio/gfile.c b/gio/gfile.c
  14. index 24b136d80..74b58047c 100644
  15. --- a/gio/gfile.c
  16. +++ b/gio/gfile.c
  17. @@ -3284,12 +3284,12 @@ file_copy_fallback (GFile *source,
  18. out = (GOutputStream*)_g_local_file_output_stream_replace (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
  19. FALSE, NULL,
  20. flags & G_FILE_COPY_BACKUP,
  21. - G_FILE_CREATE_REPLACE_DESTINATION,
  22. - info,
  23. + G_FILE_CREATE_REPLACE_DESTINATION |
  24. + G_FILE_CREATE_PRIVATE, info,
  25. cancellable, error);
  26. else
  27. out = (GOutputStream*)_g_local_file_output_stream_create (_g_local_file_get_filename (G_LOCAL_FILE (destination)),
  28. - FALSE, 0, info,
  29. + FALSE, G_FILE_CREATE_PRIVATE, info,
  30. cancellable, error);
  31. }
  32. else if (flags & G_FILE_COPY_OVERWRITE)
  33. @@ -3297,12 +3297,13 @@ file_copy_fallback (GFile *source,
  34. out = (GOutputStream *)g_file_replace (destination,
  35. NULL,
  36. flags & G_FILE_COPY_BACKUP,
  37. - G_FILE_CREATE_REPLACE_DESTINATION,
  38. + G_FILE_CREATE_REPLACE_DESTINATION |
  39. + G_FILE_CREATE_PRIVATE,
  40. cancellable, error);
  41. }
  42. else
  43. {
  44. - out = (GOutputStream *)g_file_create (destination, 0, cancellable, error);
  45. + out = (GOutputStream *)g_file_create (destination, G_FILE_CREATE_PRIVATE, cancellable, error);
  46. }
  47. if (!out)
  48. --
  49. 2.21.0