Tmp security settings for logical volumes in CentOS

Source: Internet
Author: User

When Centos is installed without a specified partition by default, the logical volume does not have an independent/tmp, which may cause security risks./dev/shm is also one of the risks.

  1. # Dd A 1 GB file, file/. tmpfs

  2. Ddif =/dev/zeroof =/. tmpfsbs = 1 Mcount = 1000

  3. # Create a file system

  4. Mke2fs-j/. tmpfs

  5. ####################

  6. Mke2fs 1.41.12 (17-May-2010)

  7. /. Tmpfsisnotablockspecialdevice.

  8. Proceedanyway? (Y, n) y

  9. Filesystemlabel =

  10. OStype: Linux

  11. Blocksize = 4096 (log = 2)

  12. Fragmentsize = 4096 (log = 2)

  13. Stride = 0 blocks, Stripewidth = 0 blocks

  14. 64000 inodes, 256000 blocks

  15. 12800 blocks (5.00%) reservedforthesuperuser

  16. Firstdatablock = 0

  17. Maximumfilesystemblocks = 264241152

  18. 8 blockgroups

  19. 32768 blockspergroup, 32768 fragmentspergroup

  20. 8000 inodespergroup

  21. Superblockbackupsstoredonblocks:

  22. 32768,983 04, 163840,229 376

  23. Writinginodetables: done

  24. Creatingjournal (4096 blocks): done

  25. Writingsuperblocksandfilesystemaccountinginformation: done

  26. Thisfilesystemwillbeautomaticallycheckedevery32mountsor

  27. 180 days, whichevercomesfirst. Usetune2fs-cor-itooverride.

  28. ####################

  29. # Copying files

  30. Cp-av/tmp. old

  31. # Mount the dd File

  32. Mount-oloop, noexec, nosuid, rw/. tmpfs/tmp

  33. # Assign the default/tmp permission

  34. Chmod1777/tmp

  35. # Move the copied file back

  36. Mv-f/tmp. old/*/tmp/

  37. # Deleting folders

  38. Rm-rf/tmp. old

  39. # Modify/etc/fstab to enable automatic mounting after it is restarted

  40. /. Tmpfs/tmp ext3 loop, nosuid, noexec, rw 0 0

  41. # Soft link/var/tmp to/tmp

  42. Mv/var/tmp/var/tmp_bak

  43. Ln-s/tmp/var/tmp

  44. Cp-Rf/var/tmp_bak/*/var/tmp

  45. Rm-rf/var/tmp_bak/

  46. # Test

  47. # Go To The/tmp and/dev/shm directories respectively, create executable files, and grant 777 Permissions

  48. [Root @ localhost/tmp]

  49. # Ls-lA/tmp/| grepx. sh

  50. -Rwxrwxrwx1rootroot22Jul2515: 08x. sh

  51. [Root @ localhost/tmp]

  52. # Cat/tmp/x. sh

  53. #! /Bin/bash

  54. Echotest

  55. [Root @ localhost/tmp]

  56. #/Tmp/x. sh

  57. -Bash:/tmp/x. sh: Permissiondenied

  58. [Root @ localhost/dev/shm]

  59. # Ls-lA | grep x. sh

  60. -Rwxrwxrwx1rootroot22Jul2515: 08x. sh

  61. [Root @ localhost/dev/shm]

  62. # Cat x. sh

  63. #! /Bin/bash

  64. Echotest

  65. [Root @ localhost/dev/shm]

  66. #/Dev/shm/x. sh

  67. -Bash:/dev/shm/x. sh: Permissiondenied

  1. # Modify/etc/fstab to change the nosuid and noexec values of/dev/shm shared memory

  2. Tmpfs/dev/shmtmpfsdefaults, nosuid, noexec, rw00

  3. Mount-oremount/dev/shm/


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.