Add yaml front matter to all asciidoc files
[web.git] / docs / uci_samba.txt
1 ---
2 ---
3 Samba (smb)
4 ===========
5
6 include::uci_menu.inc[]
7
8 == Samba configuration
9
10 The Samba UCI configuration file is located at **'/etc/config/samba'**.
11
12 === Common Options
13
14 The config section type 'samba' determines values and options relevant to the overall operation of samba. The following table lists all available options, their default value and respectively a short characterization. See link:http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#idp58030944[smb.conf man page] for further details.
15
16 These are the default settings for the common options:
17
18 ----
19 config 'samba'
20 option 'name' 'OpenWrt'
21 option 'workgroup' 'OpenWrt'
22 option 'description' 'Samba on OpenWrt'
23 option 'charset' 'UTF-8'
24 option 'homes' '0'
25 option 'interface' 'loopback lan'
26 ----
27
28 [cols="5*1,4",options="header"]
29 |====
30 | Name | Type | Required | Default | Option | Description
31 | 'name' | string | no | hostname or OpenWrt | | Name of the Server
32 | 'workgroup' | string | no | hostname or OpenWrt | | Name of the Workgroup
33 | 'description' | string | no | Samba on hostname or OpenWrt | | Description of the Server
34 | 'charset' | string | no | UTF-8 | | Display charset & unix charset
35 | 'homes' | boolean | no | 0 | 0, 1 | Share the user directory
36 | 'interface' | string | no | loopback lan | | Interfaces samba should listen on.
37 |====
38
39 === Sambashare
40
41 The daemons are up and running and recheable via NetBIOS. Now you only need to configure the directories you intend to make accesible to users in your LAN. This example assumes you attached a USB harddisk to the USB-Port and _correctly_ mounted a partition. You can now choose to share the partition as a whole, or just individual directories on it. For each entry you need to create an individual config 'sambashare' section.
42
43 ----
44 config 'sambashare'
45 option 'name' 'Shares'
46 option 'path' '/mnt/sda3'
47 # option 'users' 'sandra'
48 option 'guest_ok' 'yes'
49 option 'create_mask' '0700'
50 option 'dir_mask' '0700'
51 option 'read_only' 'yes'
52 ----
53
54 [cols="5*1,4",options="header"]
55 |====
56 | Name | Type | Required | Default | Option | Description
57 | 'name' | string | yes | _(none)_ | | Name of the entry. Will be shown in the filebrowser.
58 | 'path' | file path | yes | _(none)_ | | The complete path of the directory. link:http//www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#PATH[path]
59 | 'users' | string | no | guest account or from global template | | the samba-users allowed access to this entry; use 'smbpasswd' to create a user-pwd combination! Several users can be specified, separated by a coma (ex : option 'users' 'root,nobody' ). Translated to link:http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#VALIDUSERS[valid users]
60 | 'read_only' | string | no | yes or from global template | no, yes | no allows for read/write, else only read access is granted; (for rw, you also need to mount fs rw!). link:http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#READONLY[read only]
61 | 'guest_ok' | string | no | no or from global template | no, yes | Specifies if you need to login via samba-username and password to access this share. link:http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#GUESTOK[guest ok].
62 | 'create_mask' | integer | no | 0744 or from global template | | chmod mask for files created (needs write access). http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#CREATEMASK[create mask]
63 | 'dir_mask' | integer | no | 0755 or from global template | | chmod mask for directories created (need write access). link:http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#DIRECTORYMASK[directory mask].
64 |====
65
66 == Additional Configuration Options
67
68 In addition to the UCI file ('/etc/config/samba'), modifications can be made to the '/etc/samba/smb.conf.template' file.
69
70 == Configuration examples
71
72 Samba can be configured at either share level access or user level access. At share level access all users on the network can access the share, and all files are shared with all users. At user level access a username and password are needed to access the share. By default Samba is configured for user level access.
73
74 These configurations have proven to work for some:
75
76 === Share level access
77
78 To set share level access change 'security = user' to 'security = share' in '/etc/samba/smb.conf.template':
79
80 Then add a share to '/etc/config/samba'. Make sure that 'guest ok' is set to 'yes'
81 ----
82 config 'samba'
83 option 'name' 'lede'
84 option 'workgroup' 'WORKGROUP'
85 option 'description' 'lede'
86 option 'homes' '1'
87
88 config 'sambashare'
89 option 'read_only' 'no'
90 option 'create_mask' '0700'
91 option 'dir_mask' '0700'
92 option 'name' 'name-of-share'
93 option 'path' '/path/of/share'
94 option 'guest_ok' 'yes'
95 ----
96
97 === User level access
98
99 At user level access a username and password are needed to access the share.
100
101 Steps:
102
103 === 1. Add user to system ===
104
105 To access a samba share with user level access there must be a user added to the system. Edit '/etc/passwd' and add a line for the new user. Choose a user id (the first number in the line) of 1000 or higher that does not exist yet. Set the group identification number (the second number) to the same number as the user nobody. Copy the rest.
106
107 ----
108 root:0:0:root:/root:/bin/ash
109 nobody:*:65534:65534:nobody:/var:/bin/false
110 daemon:*:65534:65534:daemon:/var:/bin/false
111 newuser:*:1000:65534:newuser:/var:/bin/false
112 ----
113
114 **Note:** keep in mind that the user(s) and group(s) utilized by Samba need to have the proper permissions for their shares, i.e. they need write access in order to write via smb.
115
116 === 2. Add samba password to user ===
117
118 'smbpasswd -a newuser'
119
120 === 3. Change samba config to accept users with null passwords ===
121
122 Edit '/etc/samba/smb.conf.template' and add 'null passwords = yes':
123
124 === 4. Add a share ===
125
126 Then add a share to '/etc/config/samba'. Make shure that 'guest ok' is set to 'no'
127
128 ----
129 config 'samba'
130 option 'name' 'lede'
131 option 'workgroup' 'WORKGROUP'
132 option 'description' 'lede'
133 option 'homes' '1'
134
135 config 'sambashare'
136 option 'read_only' 'no'
137 option 'create_mask' '0700'
138 option 'dir_mask' '0700'
139 option 'name' 'name-of-share'
140 option 'path' '/path/of/share'
141 option 'guest_ok' 'no'
142 ----