Simply, Teaching Puppy to SAMBA (share folders to LAN users)

Configuration wizards, scanners, remote desktop, etc.
Message
Author
gcmartin

Simply, Teaching Puppy to SAMBA (share folders to LAN users)

#1 Post by gcmartin »

Digressing for a moment to “level set
Last edited by gcmartin on Wed 04 Mar 2015, 20:04, edited 11 times in total.

User avatar
plankenstein
Posts: 120
Joined: Sun 16 Nov 2008, 00:49
Location: Arkansas, USA

#2 Post by plankenstein »

Excelent tutorial gcmartin! This was about as strait forward and simple as it can get. Even a noob like me was able to follow this and when I get home later I'm going to give it a try.

Thanks :D
I carefully plan ALL my random acts! :lol:

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Startup script

#3 Post by shinobar »

Great, gcmartin.
Hope this document helps pupians.

I like to add a tip to start up samba automatically at the booting up Puppy.
Three points:
  1. hostname: Edit the file '/etc/hostname', replace 'puppypc' to the machine name you decided like 'NewPuppy'.
  2. Startup script: Place some script to start up samba in the directory '/etc/init.d'. Say the name '/etc/init.d/smb'.
    It is called as 'smb start' at the Puppy boots up, and called as 'smb stop' at Puppy shutdown.
  3. Mounting partition: Make some mounting measure if the shared path is under /mnt other than /mnt/home.
    You can write the mounting command like 'mount /dev/sdb1 /mnt/sdb1' in '/etc/rc.d/rc.local' or in the script /etc/init.d/smb'
My SFS, samba-3.5.5-lucid.sfs (Use samba-3.0.26-3-{sfs4,sfs3}.sfs for Puppy 4.x.), has the script '/etc/init.d/smb'(attached) for the above 2-3 sake. The scripts reads the configuration file '/etc/opt/samba/smb.conf', and auto-mount the partition shared.

Notice: the shared path should be readable/writable from the samba user. If you set it as 'root', as gcmartin wrote on the top article, you need not care of.
But the smb.conf.example in my SFS is the user 'spot' as the default. Sharing /root/spot is no problem.
http://www.murga-linux.com/puppy/viewtopic.php?t=60836
Attachments
smb.gz
A sample of the start up script, '/etc/init.d/smb'.
You need not this if you use my SFS, samba-3.5.5-lucid.sfs or samba-3.0.26-3-{sfs4,sfs3}.sfs.
Modification required if you use this for another buils of PET or SFS.
(946 Bytes) Downloaded 2231 times
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

kanehekili
Posts: 6
Joined: Sun 07 Nov 2010, 19:10
Location: Bavarian alps, Frugal Puppy 5.2 & Thinkpad A22e 256 MB 20 GB/750GB Ultrabay SATA Adapter

Samba with an NTFS USB Share

#4 Post by kanehekili »

First of all I would like to thank you for this great guide. With it I could set up Samba 3.5.5 with shinobars and gcmartins explanations without much fuzz! But one thing I couldn't figure out (I'm using Puppy 5.1.1):
A mounted NTFS USB drive (sdb1) cannot be accessed by either an Ubuntu (Lucid) or Windows (XP) computer, which are in the same subnet. If I attach a FAT32 USB drive, everything is fine.
The corresponding log shows:
"[2010/12/10 18:57:06.977049, 0] smbd/service.c:988(make_connection_snum)
canonicalize_connect_path failed for service schmakmu, path /mnt/sdb1"
I tried to find any answer in the net, so this is my last resort.

Below parts of my smb.conf

Code: Select all

##
## Basic Server Settings
##
	public = Yes 
	# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
	workgroup = WESTENDNET1

	# server string is the equivalent of the NT Description field
	server string = Samba Server on Puppy

	#BK think need to change this...
	log file = /var/log/samba/log.%m
	# Put a capping on the size of the log files (in Kb).
	max log size = 50

	# Security mode.
	;security = user
	security = share
	;map to guest = Bad User
	null passwords = Yes
	guest account = nobody
	;create mask = 0644
	;directory mask = 0755
...
[schmakmu]
   path = /mnt/sdb1
   ;force user =  nobody
   ;force group = nobody
   read only = no
   ;public = yes
   ;guest only = yes
   ;guest ok = Yes
   ;writable = yes
   create mask = 0765
I activated/deactived most of the parameters seen in the "schmakmu" section, but to no avail.
Anybody got an idea?

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: Samba with an NTFS USB Share

#5 Post by shinobar »

kanehekili wrote: # Security mode.
;security = user
security = share
;map to guest = Bad User
null passwords = Yes
guest account = nobody
;create mask = 0644
;directory mask = 0755
The shared storage should be both readable and writable by the user.
As for the Windows partitions(ntfs/vfat), it should be mounted with the owner is the user.
The script /etc/init.d/smb does it automatically.
A trap is the partition are better to be mounted by this script, means it should not be mounted before. So you cannot boot up Puppy from the shared (ntfs or vfat) partition because it is owned by 'root' in the case.
Another trap may be the user 'nobody'. I recommend user 'spot' or 'ftp'.

The script /etc/init.d/smb is already in my sfs. Also the/etc/opt/samba/smb.conf.example can be a help.
BTW, Are you sure you are using samba-3.5.5-lucid-1.sfs?
http://www.murga-linux.com/puppy/viewtopic.php?t=60836
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

kanehekili
Posts: 6
Joined: Sun 07 Nov 2010, 19:10
Location: Bavarian alps, Frugal Puppy 5.2 & Thinkpad A22e 256 MB 20 GB/750GB Ultrabay SATA Adapter

#6 Post by kanehekili »

Shinobar,
thanx for your time to help.
The shared storage should be both readable and writable by the user.
As for the Windows partitions(ntfs/vfat), it should be mounted with the owner is the user.
It is readable/writable, when looking at the flags. I'm using your script for mounting- so when puppy started, (and samba as well) the sdb1 drive is mounted by your script.
I intend to use that drive for data, not for puppy.
Another trap may be the user 'nobody'. I recommend user 'spot' or 'ftp'.
So I will look into the users again :-)
BTW, Are you sure you are using samba-3.5.5-lucid-1.sfs?
Yes, I'm positive, since I do have a frugal installation, your sfs file is mounted in /mnt as
+mnt+home+samba-3.5.5-lucid-1.sfs
I'll fiddle around some more- but even if I don't get it running with that specific drive - (my Fat32 USB drive works perfectly with Samba) - I'm very pleased with the Samba Pet.

gcmartin

#7 Post by gcmartin »

@kanehekili, Try this:
In a terminal window:

Code: Select all

chmod 1777 /mnt/sdb1
and in the smb.conf resource

Code: Select all

[schmakmu]
   path = /mnt/sdb1 
   ...
   ...
   force create mode = 764
   force directory mode = 775
   ...
P.S. Question: What Puppy distro did you install your SAMBA to? Thx.

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

Re: Samba with an NTFS USB Share

#8 Post by shinobar »

kanehekili wrote:A mounted NTFS USB drive (sdb1) cannot be accessed by either an Ubuntu (Lucid) or Windows (XP) computer, which are in the same subnet. If I attach a FAT32 USB drive, everything is fine.
The corresponding log shows:
"[2010/12/10 18:57:06.977049, 0] smbd/service.c:988(make_connection_snum)
canonicalize_connect_path failed for service schmakmu, path /mnt/sdb1"
Confirmed. Seems ntfs permission problem.
It may be complex.

I tried with editing the mount script, /etc/init.d/smb at line 41:
mount-FULL $MOUNTOPT -t $FS /dev/$PART /mnt/$PART
(Replaced 'mount' with 'mount-FULL'.)
Then i could read the NTFS shared, but couldn't write... :(

Needs more investigation...:roll:
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#9 Post by rcrsn51 »

I looked at this in Samba-TNG and got the same result. Here is a test situation independent of Samba.

1. I mount an NTFS partition as usual by clicking on its drive icon.

2. I open a terminal window and login as an unprivileged user.

3. I then try to access the mount point. It's not even recognized as a directory!

So if I start the samba server and use the NTFS drive as a share, then an unprivileged samba client won't be able to see it either. However a client logging in as "root" gets full rights to the share.

I suspect that this a result of how the ntfs-3g driver mounts the share. There may be some convoluted way of using ntfs-3g that solves the problem for unprivileged users.

kanehekili
Posts: 6
Joined: Sun 07 Nov 2010, 19:10
Location: Bavarian alps, Frugal Puppy 5.2 & Thinkpad A22e 256 MB 20 GB/750GB Ultrabay SATA Adapter

#10 Post by kanehekili »

Well, I guess I found a way to access my drive now.
After I tried the variations of gcmartin and shinobar, with no success I came up with the following solution :

Code: Select all

# Security mode.
security = share
null passwords = Yes
guest account = spot


[schmakmu]
   path = /mnt/sdb1
   force user =  root
   read only = no
   force create mode = 764
   force directory mode = 775 
   create mask = 0765
So I used the advices of shinobar and gcmartin but the final solution was the line
force user = root
I could copy and remove data to the drive without any problems. I dimly remember that I have read something about NTFS and linux and problems due to security...
Now I'm not really sure if I compromise my system by allowing everyone to become root... :?

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#11 Post by rcrsn51 »

kanehekili wrote:Now I'm not really sure if I compromise my system by allowing everyone to become root... :?
What is the difference between logging into a share as a non-privileged user with full rights to the data versus logging in as root?

It's not like you are giving the user root access to the whole server. If you are concerned about the safety of the data, just put a "read only" restriction on the share.

Logging into a Samba server as root is less dangerous than running Puppy as root.

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

force user = root

#12 Post by shinobar »

kanehekili wrote:force user = root
Great!
I think it is most practical solusion. :wink:
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

gcmartin

#13 Post by gcmartin »

kanehekili wrote:Now I'm not really sure if I compromise my system by allowing everyone to become root..
In this example, as you show, you have told SAMBA that for this share [schmakmu], to let a user named "root" to have access to it. In other words, you have given ONLY the root SAMBA user the priviledge to ONLY this share....not to your Linux system. SAMBA did what you told it to; and he did not and will not go beyond what you told him.

Another important thing to remember is SAMBA users are separate users from Linux system users. So, if you want /need, you can create additional SAMBA users and also give those IDs access to this share as well. That way, by looking thru the SAMBA log, you can see which LAN user accessed this share and when.

Hope this helps.
Any other concerns, post them and we'll help.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#14 Post by rcrsn51 »

Another important thing to remember is SAMBA users are separate users from Linux system users. So, if you want /need, you can create additional SAMBA users and also give those IDs access to this share as well. That way, by looking thru the SAMBA log, you can see which LAN user accessed this share and when.
Could you confirm this? It's been my experience that a username must already exist as a Linux user before it can be created as a Samba user. Otherwise, the server won't know whether the user has the requisite privileges to access a share.

gcmartin

#15 Post by gcmartin »

rcrsn51 wrote:Could you confirm this? It's been my experience that a username must already exist as a Linux user before it can be created as a Samba user. Otherwise, the server won't know whether the user has the requisite privileges to access a share.
in Linux, full SAMBA as I have created the smb.conf where there is NO LDAP server or PDC (and version 4 full SAMBA with AD), SAMBA authentication does NOT require ANY comparative Linux user. Always has been this way as far as I remember.

Hope this helps.
P.S. I haven't tested this in Puppy, though, but it should be the same.

Edited: I believe I withdraw my comments about SAMBA users and Linux users. Although I seem to remember the user systems as being distinct, it appears that there IS A RELATIONSHIP which @Rcrsn51 more accurately references...thanks

See this document for a VERY GOOD EXPLANATION on SAMBA USERS. There are many many other useful SAMBA documents on the internet as well.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#16 Post by rcrsn51 »

force user = root
This is a handy trick! It means that you can create non-privileged users with personal home directories on the server, who can also access a FAT/NTFS share by getting temporary root privilege.

You can control the amount of privilege in the share with "writable" or "read only".

gcmartin

Managing Users in SAMBA

#17 Post by gcmartin »

Code: Select all

force user = root
Yes, this allows user root to have that privilege; and any other users that I might have on the LAN, as well, for example

Code: Select all

force user = root,spot,Mom,Dad,Sister,ElderlyNeighbor,Me
Assuming those of the names those users use to logon to their Windows PCs.

Just a note for anyone interested: M$ charges an entry level $1000+ for the Basic Server which does this. IFF you use your search engine for "Linux SAMBA PDC" you will probably find 100 documents of others before us who have setup SAMBA to manage ALL users on your network and what they can and cant see. Its really simple after you get past what we've just done here in "Teaching Puppy to SAMBA". Anyone's choice: $1000 or Open-Source..."What say you?"

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#18 Post by 8-bit »

I am running Puppy Lupu 520 first of all as a frugal install.
I tried following your how to to get the initial settings done and then I tried the commands from a terminal pertaining to retstart.
I had samba-3.5.5-lucid.sfs loaded.
but the restart option was not recognized as a valid option.

Also, all drive and file access on my pc slowed up greatly.
I ended up recovering using a backup of my lupusave.2fs file I had previously made and then copying apps I had installed in wine drive c by removing drive_c and copying the one from the bad pupsave file.
So now, I am at a loss as to where to go from here.

Also, I should mention the the nested mkdir command did not work and I had to make each directory individually.
And smbd and nmbd were reported as not found.
I had to make links to them in /usr/bin to access them.

So simple was not so simple in my case.

gcmartin

there were some problems with the differing SFSs

#19 Post by gcmartin »

8-bit wrote:I am running Puppy Lupu 520 first of all as a frugal install.
I tried following your how to to get the initial settings done and then I tried the commands from a terminal pertaining to retstart.
I had samba-3.5.5-lucid.sfs loaded.
but the restart option was not recognized as a valid option.

Also, all drive and file access on my pc slowed up greatly.
I ended up recovering using a backup of my lupusave.2fs file I had previously made and then copying apps I had installed in wine drive c by removing drive_c and copying the one from the bad pupsave file.
So now, I am at a loss as to where to go from here.

Also, I should mention the the nested mkdir command did not work and I had to make each directory individually.
And smbd and nmbd were reported as not found.
I had to make links to them in /usr/bin to access them.

So simple was not so simple in my case.
So sorry that I just got this. Seems that there are several issues so I will attempt to address them individually.

Firstly, lets start with a nested Linux mkdir command. Would you try that first, and report back.

Next, there were problems with the SFSs files for 3.5.5. I'm not sure which of them you are using. One of them follows the directions, but the other was a sharp departure from the directions. And, for both, NEITHER are supported anymore by either author.

I am in the process of creating a new updated document for users wanted to simply add SAMBA to their non-SAMBA system. I, currently, am concentrating on the newer PUPs because those PUP distro owners have SAMBA available via PPM. This makes your use and a document more generic for all newer PUPs.

But, it you're willing, follow me and I may be able to help you without a manual. Firstly, let me ask this (I don't have a PUP520) "Live" media to boot from: Would you open your PPM and update it. Then exit the PPM and reopen it. Then click the All button in the left column. The large right column should populate. If it does, scan down that list for SAMBA. You will either see 3.4.x or 3.5.6 or 3.5.8. Which do you see?

Select it and report back here which you have (this is because some will update your Menu and the others WONT).

The next 2 things will be easy. PPM me when you hav e done this.

Thanks in advance.

User avatar
mimmo
Posts: 19
Joined: Wed 20 Jul 2011, 06:17
Location: Versailles, France

Samba 3.5.6 on Lucid-Puppy 5.2.5

#20 Post by mimmo »

So the first thing for me was that "smbd -restart" did not work...

the solution came after a reboot as at this point I did have a samba running
and the disk of my shared directory was mounted
so I looked wher this guy was started

and the solution is in /etc/init.d/smb

the options are: start|stop|restart|reload|status
#smb restart

works find (I see the changes on the windows side)
from windows I access the readme in the spot home dir
but I have problems to acces Photo

my smb.conf looks like this

Code: Select all

[Photo]
   # the path should be readable and writable by the guest account
   path = /mnt/sdb1/Photo
   public = yes
   only guest = yes
   guest ok = Yes
   writable = yes
   printable = no
   create mask = 0765
   force group = spot

[spot]
   path = /root/spot
   public = yes
   only guest = yes
   guest ok = Yes
   writable = yes
   printable = no
   create mask = 0765
   force group = spot
I did the very same for Photo and spot ...
I have cheked that directory /mnt/sdb1/Photo is accessible to any one (respectively / 755 / 777 / 777 /)

what's wrong ? any idea

Post Reply