Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. ##### Server
  2.  
  3. # Create Linux users
  4. useradd alice
  5. useradd bob
  6.  
  7. # Create a directory to be shared; set ro permissions for alice using
  8. # file mode bits and rw permissions for bob using file acls
  9. mkdir /home/smbshare
  10. chown alice:alice /home/smbshare
  11. chmod 0500 /home/smbshare
  12. setfacl -m u:bob:rwx /home/smbshare
  13. setfacl -m m:rwx /home/smbshare
  14.  
  15. # Create a file for testing purposes
  16. echo 'Hello world!' > /home/smbshare/test.txt
  17.  
  18. # Add users to Samba database
  19. pdbedit -a -u alice
  20. pdbedit -a -u bob
  21.  
  22. # Define share in smb.conf and restart the smb daemon
  23. vim /etc/samba/smb.conf
  24. comment = smbshare for alice(ro) and bob(rw)
  25. path = /home/smbshare
  26. browseable = yes
  27. writeable = yes
  28. valid users = alice bob
  29.  
  30. systemctl reload smb
  31.  
  32.  
  33. # Set the SELinux permissions and open samba on firewall
  34. chcon -R -t samba_share_t /home/smbshare
  35.  
  36. firewall-cmd --add-service=samba --permanent
  37. firewall-cmd --reload
  38.  
  39.  
  40. ##### Client
  41.  
  42. # Create Linux users
  43. useradd alice
  44. useradd bob
  45.  
  46. # Mount the remote Samba share
  47. mkdir /mnt/smbshare
  48. mount -t cifs -o username=alice,password=pass //192.168.1.112/smbshare /mnt/smbshare
  49.  
  50. # Now test the permissions
  51. su - alice
  52. cd /mnt/smbshare
  53. cat test.txt # shows the contents of test.txt, as expected
  54. echo 'I am alice' > test2.txt # permission denied, as expected
  55. exit
  56.  
  57. su - bob
  58. cd /mnt/smbshare # permission denied -- ???? NOT AS EXPECTED
  59. exit
  60.  
  61. # I think it doesn't matter under which user to mount, but just to be sure
  62. # I tried to mount using bob's credentials
  63. umount /mnt/smbshare
  64. mount -t cifs -o username=bob,password=pass //192.168.1.112/smbshare /mnt/smbshare
  65.  
  66. # After checking file permissions I got the same results as above:
  67. # alice have read-only permissions (as expected), bob have no access (NOT as expected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement