• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.loginH A D17-Mar-2006231 86

.mssmbrcH A D17-Mar-2006498 98

.nsmbrcH A D17-Mar-2006131 96

README.FreeBSDH A D12-May-20065.9 KiB141107

mountsmb2H A D12-May-20063.9 KiB185113

nsmb.confH A D12-May-2006244 159

smb2nsmbrcH A D12-May-20063.3 KiB15590

sudoersH A D17-Mar-2006619 3323

README.FreeBSD

1		    SMB auto-login mounting in FreeBSD
2                    ----------------------------------
3                    $Id: README.FreeBSD,v 1.3 2006/05/12 08:19:51 shelton Exp $
4
51. Preface
6----------
7
8This document describes, how to implement Windows featurs about auto-mounting
9some shares with user login with FreeBSD implementation of SMBFS. This document
10assumed, that you already have working SMBFS in your kernel (see man mount_smbfs(8),
11FreeBSD Handbook chapter 9 and an sample kernel config file part below:
12
13#
14# SMB/CIFS requester
15# NETSMB enables support for SMB protocol, it requires LIBMCHAIN and LIBICONV
16# options.
17# NETSMBCRYPTO enables support for encrypted passwords.
18options         NETSMB                  #SMB/CIFS requester
19options         NETSMBCRYPTO            #encrypted password support for SMB
20
21# mchain library. It can be either loaded as KLD or compiled into kernel
22options         LIBMCHAIN               #mbuf management library
23options         SMBFS                   #SMB/CIFS filesystem
24# Kernel side iconv library
25options         LIBICONV
26
27You will need all these for working SMBFS. Also /etc/nsmb.conf should be
28configured properly (in spite of that nsmb.conf has all variables 'transparent',
29documentation about SMBFS tuning in FreeBSD are very, very shy :-( You should
30setup at least paremeters "workgroup" and "nbns". As nbns you should set your
31WINS server (as called it in Microsoft world). For displaying filenames in
32other languages, different from English (ISO-8859-1), also you sholud setup
33codepage translation pairs.
34
35I have developed helper script smb2nsmbrc (see below), which slightly simplified
36/etc/nmsb.conf setup, by inserting records with codepare pairs and DNS names
37(if any) about each detected Windows (and Samba also) boxes.
38
392. Before first run
40-------------------
41
42a. You need to install nbtscan and sudo packages. Nbtscan uses for scan network
43and detect Windows boxes (in smb2nsmbrc script), sudo uses in mountsmb2 to
44issue mount itself, because ordinary only root can mount/unmount filesystems
45
46b. You MUST allow to all users, which will use this feature, run script
47'mountsmb2'. This sample illustarted, how to do this with sudo, through adding
48next line in 'sudoers' file:
49
50<username> <HOSTNAME> = (root) NOPASSWD: /usr/local/bin/mountsmb2 -a -u <username>
51
52where <username> - user name, who will mount resources
53      <HOSTNAME> - host name, when run script
54
55More info about sudoers file see man sudoers(5))
56
57c. Before start mountsmb2 first time, you should setup your .nsmbrc file
58properly. For my pity, you must setup each Windows/Samba box in your network
59SEPARATELY. No default usernames, no domain logons. Looks sadly, aren't you?
60smb2nsmbrc script sligtly takes this job from you. You start smb2nsmbrc, it
61called nbtscan (of course, you should have nbtscan and smbutil in your path),
62parsing their output, asks you about username, password and stored file
63.nsmbrctmp in generated temporarly directory. Than, you insert their data in
64.nsmbrc file. In .nsmbrc will similar records:
65
66[SERVERNAME:USERNAME]
67password=<encrypted password>
68
69Encryption done with smbutil and ready for use with mount_smbfs. Nbtscan takes
70one parameter - network address in CIDR format, like 10.0.1.0/24 (will scan
7110.0.1.0 - 10.0.1.255) or address chunk like 10.0.1.1-10.0.1.10 (will scan
72specified chunk). smb2nsmbrc creates work directory in /tmp, their name will
73generated from current time in seconds, so, each time when you run smb2nsmbrc you
74will receive different directories. smb2nsmbrc creates two files - one for adding
75to .nsmbrc, called .nsmbrctmp, two for adding to /etc/nsmb.conf, called
76nsmb.conf.tmp
77
78d. You should create and fill your own .mssmbrc file. This is a slightly mirrored
79/etc/fstab file and does similar way for mountsmb2 - describes all shares, which
80should mounted auto or manually.
81
823. .mssmbrc file - /etc/fstab mirror for mountsmb2
83--------------------------------------------------
84
85For mounting SMB/CIFS shares with mountsmb2 .mssmbrc file plays role, similar
86/etc/fstab for all system. It describes all mounting points, which can be mounted
87in auto or manual modes. File format is very easy - freeform text file, when one
88line consists from these chunks:
89
90ServerName ShareName MountPoint FileMode DirMode {auto|noauto}
91
92When FileMode and DirMode set to "none", no mode applied
93When "auto" set, this share mounts when "smbmount -a" issued
94DO NOT SKIP FileMode and DirMode!
95
96Samples:
97shadow	   transfer   /usr/home/shelton/smbfs/shadow/transfer  0666  0777  auto
98proxy	   shelton    /usr/home/shelton/smbfs/proxy/shelton    0644  0755  auto
99
1004. Run
101------
102
103Usually this script runs from .login file (I use /bin/tcsh as login shell) or from
104.profile, when you are using /usr/local/bin/bash or simply /bin/sh. Line for
105inseting into a .login file are:
106
107sudo mountsmb2 -a -u $USER
108
109When you run mountsmb2 manually you can specify -a to mount all shares, described
110as "auto" (usual way) or mount one mountpoint, specify it with -m. Specifying
111username with -u is not neccessary, when missed, it will be substituted from
112$USER environment variable. So:
113
114mountsmb2 -m /tmp/blabla
115
116mounts share, described as mounted to mountpoint /tmp/blabla (first entry, when
117aren't unique)
118
119mountsmb2 -m /tmp/foo/bar -u someuser
120
121mounts share, described as mounted to mountpoint /tmp/foo/bar with effective user
122rights someuser.
123
124In examples directory you can find sample files:
125
126.login - sample start script for tcsh
127.nsmbrc - sample .nsmbrc file (all passwords are fake!)
128.mssmbrc - samble .mssmbrc file
129sudoers - sample sudoers file
130nsmb.conf - sample of /etc/nsmb.conf
131
1324. Feedback
133-----------
134
135All these scripts and this readme file were written by Rashid N. Achilov
136(shelton@granch.ru). So, you can ask me about their working and also about
137any other SMB shares mounting errors, but keep in mind - I'm NOT A SMBFS
138DEVELOPER, I know nothing about internal technic of kernel-side support
139of SMBFS under FreeBSD. To ask with serious problems, please mail to SMB developer:
140Boris Popov <bp@freebsd.org>.
141