LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Two strange samba sharing problems (https://www.linuxquestions.org/questions/debian-26/two-strange-samba-sharing-problems-4175438486/)

Basso84 11-23-2012 06:29 PM

Two strange samba sharing problems
 
Hi. I apologize my bad english. Hope you understand. I have raspberry pi with debian wheezy.

My first problem is: (THIS PROBLEM SOLVED. To see how, look down)

Samba user seems like to be "other" user. I have done system user with adduser and samba user smbpasswd. Then chmod 775 /home/basso. Then i checked ls -ld /home/basso and i got drwxrwxrwx 2 root Share 4096.
Then i make connection in windows7 and i am able to login there and read files but not write. When i change chmod 777 /home/basso, i am able to write also. So seems like it works because i must use name/password in login but i cant write without chmod 777. Something strange happens here.

Some of my samba share config:

Security = user
workgroup = WORKGROUP (windows too)
encrypt passwords = yes
unix password sync = yes
map to guest = bad user
usershare allow guests = yes

[homes]
comment = Home Directories
browseable = no
create mask = 0775
directory mask = 0775
valid users = %S
; comment = Network Logon Service
; path = /home/samba/netlogon
; guest ok = yes
; read only = yes
; comment = Users profiles
; path = /home/samba/profiles
; guest ok = no
; browseable = no
; create mask = 0600
; directory mask = 0700

[basso]
path = /home/basso
valid users = Basso
read only = no
browseable = no
public = no
writeable = yes
guest ok = no
writeable = yes
guest ok = no

I paste my testparm too:

Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[basso]"
Processing section "[usb]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
server string = %h server
map to guest = Bad User
obey pam restrictions = Yes
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
unix password sync = Yes
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
usershare allow guests = Yes
panic action = /usr/share/samba/panic-action %d
idmap config * : backend = tdb

[homes]
comment = Home Directories
valid users = %S
read only = No
create mask = 0775
directory mask = 0775
browseable = No

[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
printable = Yes
print ok = Yes
browseable = No

[print$]
comment = Printer Drivers
path = /var/lib/samba/printers


[basso]
path = /home/basso
valid users = Basso
read only = No
browseable = No


[usb]
path = /mnt/disk2
valid users = Basso
read only = No
create mask = 0777
directory mask = 0777
guest ok = Yes

My second problem is usb stick write enabling. I have usb memory which is FAT32. There problem is that i can read and execute but not write at all. chmod not even change anything. i wrote chmod 777 /mnt/disk2 and ls -ld /mnt/disk2 says drwxr-xr-x 2 root root 4096 tammi 1 1970 /mnt/disk2

I hope someone knows what the hell i am doing wrong. Thanks!

Edit: With chmod 777 i can do all. With 775 i can read and 771-774 and 776 i can't even log in

Edit: First problem solved. I did groups and added users to groups. Then force group to smb.conf. I also used
sudo groupadd group1
sudo usermod -G group1 Basso
sudo chown -R root:group1 /home/basso
sudo chmod -R 770 /home/basso

Now i can set "others" to 0 and that is enough. Usb problem not solved yet

Edit: Now both problems solved. I did the same thing to usb disk. It blocked me to chance /mnt/disk2 permissions. Don't know why. So i did disk1 and used sudo chown -R root:group1 /mnt/disk1 and sudo chmod -R 770 /mnt/disk1 and now it is working. And now my usb share looks like this:

[usb]
path = /mnt/disk1
valid users = Basso
read only = no
browseable = yes
public = no
writeable = yes
guest ok = no
force group = group1

PROBLEM SOLVED.

jschiwal 11-25-2012 09:41 PM

You can't change permissions on a FAT32 filesystem. Instead use mount options to set the owner and permissions when it is mounted. You don't need to change permissions of the device. Use the UUID=<uuid> for the device name in /etc/fstab because the particular device (e.g. /dev/sdb1) could change for a removable drive.

Check /etc/passwd and your smbpasswd command. Don't use Basso if your user name is basso. It looks like you are granting others permissions instead to gain write access. Resort to the samba logs when troubleshooting.

Basso84 11-26-2012 07:02 AM

Quote:

Originally Posted by jschiwal (Post 4836936)
You can't change permissions on a FAT32 filesystem. Instead use mount options to set the owner and permissions when it is mounted. You don't need to change permissions of the device. Use the UUID=<uuid> for the device name in /etc/fstab because the particular device (e.g. /dev/sdb1) could change for a removable drive.

Check /etc/passwd and your smbpasswd command. Don't use Basso if your user name is basso. It looks like you are granting others permissions instead to gain write access. Resort to the samba logs when troubleshooting.

Actually i noticed same thing. Usb stick showed 14Gb which is my SD card. Then i did actually that thing which you adviced and now my 4Gb usb stick is in use. But i used this command: sudo mount -t vfat -o rw,users /dev/sda1 /mnt/disk1 but i don't know yet how to put this tu fstab. I need use that command everytime i boot my debian. Can you tell me hot to do this?

And my username is Basso, home folder is basso and usb share is disk1

Thanks!

jschiwal 11-29-2012 07:59 AM

Assuming the UUID of the USB stick's file system is 866E-E1E1
Code:

UUID=866E-E1E1  /mnt/disk vfat rw,nosuid,nodev,uid=Basso,gid=Basso,dmask=0077,fmask=0177,utf8=1,noauto,flush,noatime 0 0
I assumed Basso is your default group for gid=. nosuid and nodev are for security on mass storage devices. Consider no exec option as well. No auto is needed to prevent booting failure is the USB stick isn't plugged in. You could use nofail instead. The 'owner's option will let you mount the pen drive without needing to use sudo.

With these permissions, only user Basso can read files on the pen drive on that computer.

I used the uuid number, so it will boot even if a different device node is used the next time.

Basso84 11-30-2012 04:55 AM

Thanks for code but there is problem. With that code usb stick shows at 14Gb. Real size is 4Gb. With this code with manual use sudo mount -t vfat -o rw,users /dev/sda1 /mnt/disk1 it works but with your code, size is wrong. Little more info:

User = Basso
Group where Basso belongs = admini
sudo blkid /dev/sda1 tells me = /dev/sda1: UUID="2451-2E60" TYPE="vfat"

And i tried that your code to fstab

jschiwal 12-02-2012 05:47 AM

It sounds like the file system is corrupt. You should back up the files on it and reparation and reformat it.

Basso84 12-05-2012 08:13 AM

Quote:

Originally Posted by jschiwal (Post 4841139)
It sounds like the file system is corrupt. You should back up the files on it and reparation and reformat it.

Ok. I try that and then do that again and hope it works. Thanks for help!


All times are GMT -5. The time now is 03:48 PM.