install-C-root.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # Ensure "install -C" compares owner and group.
  3. # Copyright (C) 2008-2018 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  15. print_ver_ ginstall
  16. require_root_
  17. skip_if_setgid_
  18. skip_if_nondefault_group_
  19. u1=1
  20. u2=2
  21. g1=1
  22. g2=2
  23. echo test > a || framework_failure_
  24. echo "'a' -> 'b'" > out_installed_first
  25. echo "removed 'b'
  26. 'a' -> 'b'" > out_installed_second
  27. > out_empty
  28. # destination file does not exist
  29. ginstall -Cv -o$u1 -g$g1 a b > out || fail=1
  30. compare out out_installed_first || fail=1
  31. # destination file exists
  32. ginstall -Cv -o$u1 -g$g1 a b > out || fail=1
  33. compare out out_empty || fail=1
  34. # destination file exists but -C is not given
  35. ginstall -v -o$u1 -g$g1 a b > out || fail=1
  36. compare out out_installed_second || fail=1
  37. # destination file exists but owner differs
  38. ginstall -Cv -o$u2 -g$g1 a b > out || fail=1
  39. compare out out_installed_second || fail=1
  40. ginstall -Cv -o$u2 -g$g1 a b > out || fail=1
  41. compare out out_empty || fail=1
  42. # destination file exists but group differs
  43. ginstall -Cv -o$u2 -g$g2 a b > out || fail=1
  44. compare out out_installed_second || fail=1
  45. ginstall -Cv -o$u2 -g$g2 a b > out || fail=1
  46. compare out out_empty || fail=1
  47. # destination file exists but owner differs from getuid ()
  48. ginstall -Cv -o$u2 a b > out || fail=1
  49. compare out out_installed_second || fail=1
  50. ginstall -Cv a b > out || fail=1
  51. compare out out_installed_second || fail=1
  52. ginstall -Cv a b > out || fail=1
  53. compare out out_empty || fail=1
  54. # destination file exists but group differs from getgid ()
  55. ginstall -Cv -g$g2 a b > out || fail=1
  56. compare out out_installed_second || fail=1
  57. ginstall -Cv a b > out || fail=1
  58. compare out out_installed_second || fail=1
  59. ginstall -Cv a b > out || fail=1
  60. compare out out_empty || fail=1
  61. Exit $fail