Remove docs menu.inc and uci_menu.inc
[web.git] / docs / uci_samba.txt
1 ---
2 ---
3 Samba (smb)
4 ===========
5
6 == Samba configuration
7
8 The Samba UCI configuration file is located at **'/etc/config/samba'**.
9
10 === Common Options
11
12 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.
13
14 These are the default settings for the common options:
15
16 ----
17 config 'samba'
18 option 'name' 'OpenWrt'
19 option 'workgroup' 'OpenWrt'
20 option 'description' 'Samba on OpenWrt'
21 option 'charset' 'UTF-8'
22 option 'homes' '0'
23 option 'interface' 'loopback lan'
24 ----
25
26 [cols="5*1,4",options="header"]
27 |====
28 | Name | Type | Required | Default | Option | Description
29 | 'name' | string | no | hostname or OpenWrt | | Name of the Server
30 | 'workgroup' | string | no | hostname or OpenWrt | | Name of the Workgroup
31 | 'description' | string | no | Samba on hostname or OpenWrt | | Description of the Server
32 | 'charset' | string | no | UTF-8 | | Display charset & unix charset
33 | 'homes' | boolean | no | 0 | 0, 1 | Share the user directory
34 | 'interface' | string | no | loopback lan | | Interfaces samba should listen on.
35 |====
36
37 === Sambashare
38
39 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.
40
41 ----
42 config 'sambashare'
43 option 'name' 'Shares'
44 option 'path' '/mnt/sda3'
45 # option 'users' 'sandra'
46 option 'guest_ok' 'yes'
47 option 'create_mask' '0700'
48 option 'dir_mask' '0700'
49 option 'read_only' 'yes'
50 ----
51
52 [cols="5*1,4",options="header"]
53 |====
54 | Name | Type | Required | Default | Option | Description
55 | 'name' | string | yes | _(none)_ | | Name of the entry. Will be shown in the filebrowser.
56 | '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]
57 | '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]
58 | '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]
59 | '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].
60 | '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]
61 | '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].
62 |====
63
64 == Additional Configuration Options
65
66 In addition to the UCI file ('/etc/config/samba'), modifications can be made to the '/etc/samba/smb.conf.template' file.
67
68 == Configuration examples
69
70 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.
71
72 These configurations have proven to work for some:
73
74 === Share level access
75
76 To set share level access change 'security = user' to 'security = share' in '/etc/samba/smb.conf.template':
77
78 Then add a share to '/etc/config/samba'. Make sure that 'guest ok' is set to 'yes'
79 ----
80 config 'samba'
81 option 'name' 'lede'
82 option 'workgroup' 'WORKGROUP'
83 option 'description' 'lede'
84 option 'homes' '1'
85
86 config 'sambashare'
87 option 'read_only' 'no'
88 option 'create_mask' '0700'
89 option 'dir_mask' '0700'
90 option 'name' 'name-of-share'
91 option 'path' '/path/of/share'
92 option 'guest_ok' 'yes'
93 ----
94
95 === User level access
96
97 At user level access a username and password are needed to access the share.
98
99 Steps:
100
101 === 1. Add user to system ===
102
103 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.
104
105 ----
106 root:0:0:root:/root:/bin/ash
107 nobody:*:65534:65534:nobody:/var:/bin/false
108 daemon:*:65534:65534:daemon:/var:/bin/false
109 newuser:*:1000:65534:newuser:/var:/bin/false
110 ----
111
112 **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.
113
114 === 2. Add samba password to user ===
115
116 'smbpasswd -a newuser'
117
118 === 3. Change samba config to accept users with null passwords ===
119
120 Edit '/etc/samba/smb.conf.template' and add 'null passwords = yes':
121
122 === 4. Add a share ===
123
124 Then add a share to '/etc/config/samba'. Make shure that 'guest ok' is set to 'no'
125
126 ----
127 config 'samba'
128 option 'name' 'lede'
129 option 'workgroup' 'WORKGROUP'
130 option 'description' 'lede'
131 option 'homes' '1'
132
133 config 'sambashare'
134 option 'read_only' 'no'
135 option 'create_mask' '0700'
136 option 'dir_mask' '0700'
137 option 'name' 'name-of-share'
138 option 'path' '/path/of/share'
139 option 'guest_ok' 'no'
140 ----