smack-root.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. # SMACK test for the mkdir,mknod, mkfifo commands.
  3. # Derived from tests/mkdir/selinux.sh.
  4. # Ensure that SMACK label gets set.
  5. # Copyright (C) 2014-2018 Free Software Foundation, Inc.
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  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 General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  17. print_ver_ mkdir mkfifo mknod
  18. require_smack_
  19. require_root_
  20. c=arbitrary-smack-label
  21. for cmd in 'mkdir dir' 'mknod b p' 'mkfifo f'; do
  22. $cmd --context="$c" || { fail=1; continue; }
  23. set $cmd
  24. ls -dZ $2 > out || fail=1
  25. test "$(cut -f1 -d' ' out)" = "$c" || { cat out; fail=1; }
  26. done
  27. Exit $fail