parents.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. # make sure mkdir's -p options works properly
  3. # Copyright (C) 2000-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_ mkdir
  16. skip_if_setgid_
  17. require_no_default_acl_ .
  18. mkdir -m 700 e-dir || framework_failure_
  19. # Make sure 'mkdir -p existing-dir' succeeds
  20. # and that 'mkdir existing-dir' fails.
  21. mkdir -p e-dir || fail=1
  22. returns_ 1 mkdir e-dir > /dev/null 2>&1 || fail=1
  23. # Create an existing directory.
  24. umask 077
  25. mode_str=drwxr-x-wx
  26. mode_arg=$(rwx_to_mode_ $mode_str)
  27. mkdir -m $mode_arg a || fail=1
  28. # this 'mkdir -p ...' shouldn't change perms of existing dir 'a'.
  29. d_mode_str=drwx-w--wx
  30. d_mode_arg=$(rwx_to_mode_ $d_mode_str)
  31. mkdir -p -m $d_mode_arg a/b/c/d
  32. # Make sure the permissions of 'a' haven't been changed.
  33. p=$(ls -ld a|cut -b-10); case $p in $mode_str);; *) fail=1;; esac
  34. # 'b's and 'c's should reflect the umask
  35. p=$(ls -ld a/b|cut -b-10); case $p in drwx------);; *) fail=1;; esac
  36. p=$(ls -ld a/b/c|cut -b-10); case $p in drwx------);; *) fail=1;; esac
  37. # 'd's perms are determined by the -m argument.
  38. p=$(ls -ld a/b/c/d|cut -b-10); case $p in $d_mode_str);; *) fail=1;; esac
  39. Exit $fail