summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README23
-rw-r--r--Roadmap2
-rw-r--r--WHATSNEW.txt121
-rw-r--r--docs/announce2
-rw-r--r--docs/faq/Samba-Server-FAQ.html2
-rw-r--r--docs/faq/Samba-Server-FAQ.sgml6
-rw-r--r--docs/faq/Samba-meta-FAQ-2.html2
-rw-r--r--docs/faq/Samba-meta-FAQ.html2
-rw-r--r--docs/faq/Samba-meta-FAQ.sgml8
-rw-r--r--docs/faq/Samba-meta-FAQ.txt437
-rw-r--r--docs/faq/sambafaq-1.html2
-rw-r--r--docs/faq/sambafaq-3.html2
-rw-r--r--docs/faq/sambafaq.html2
-rw-r--r--docs/faq/sambafaq.sgml11
-rw-r--r--docs/faq/sambafaq.txt314
-rw-r--r--docs/manpages/nmbd.82
-rw-r--r--docs/manpages/samba.74
-rw-r--r--docs/manpages/smb.conf.5114
-rw-r--r--docs/manpages/smbclient.19
-rw-r--r--docs/manpages/smbd.830
-rw-r--r--docs/manpages/smbpasswd.82
-rw-r--r--docs/manpages/smbrun.12
-rw-r--r--docs/manpages/smbstatus.12
-rw-r--r--docs/manpages/smbtar.12
-rw-r--r--docs/manpages/testparm.12
-rw-r--r--docs/manpages/testprns.12
-rw-r--r--docs/samba.faq900
-rw-r--r--docs/textdocs/Application_Serving.txt3
-rw-r--r--docs/textdocs/BROWSING.txt158
-rw-r--r--docs/textdocs/BUGS.txt5
-rw-r--r--docs/textdocs/DIAGNOSIS.txt21
-rw-r--r--docs/textdocs/DNIX.txt3
-rw-r--r--docs/textdocs/DOMAIN.txt3
-rw-r--r--docs/textdocs/DOMAIN_CONTROL.txt3
-rw-r--r--docs/textdocs/ENCRYPTION.txt41
-rw-r--r--docs/textdocs/Faxing.txt3
-rw-r--r--docs/textdocs/GOTCHAS.txt3
-rw-r--r--docs/textdocs/HINTS.txt3
-rwxr-xr-xdocs/textdocs/MIRRORS.txt52
-rw-r--r--docs/textdocs/NetBIOS.txt3
-rw-r--r--docs/textdocs/OS2-Client-HOWTO.txt3
-rw-r--r--docs/textdocs/Passwords.txt3
-rw-r--r--docs/textdocs/Printing.txt3
-rw-r--r--docs/textdocs/SCO.txt3
-rw-r--r--docs/textdocs/Speed.txt3
-rw-r--r--docs/textdocs/Support.txt47
-rw-r--r--docs/textdocs/Tracing.txt3
-rw-r--r--docs/textdocs/UNIX-SMB.txt3
-rw-r--r--docs/textdocs/UNIX_INSTALL.txt5
-rw-r--r--docs/textdocs/Win95.txt3
-rw-r--r--docs/textdocs/WinNT.txt35
-rw-r--r--docs/textdocs/security_level.txt3
-rw-r--r--examples/smb.conf.default274
-rw-r--r--source/arcfour.c91
-rw-r--r--source/arcfour.h39
-rw-r--r--source/cgi.c163
-rw-r--r--source/client/client.c86
-rw-r--r--source/client/clientutil.c71
-rw-r--r--source/client/clitar.c123
-rw-r--r--source/codepages/codepage_def.43770
-rw-r--r--source/codepages/codepage_def.85054
-rw-r--r--source/codepages/codepage_def.85263
-rw-r--r--source/codepages/codepage_def.93224
-rw-r--r--source/include/charset.h10
-rw-r--r--source/include/includes.h8
-rw-r--r--source/include/kanji.h18
-rw-r--r--source/include/local.h11
-rw-r--r--source/include/nameserv.h1
-rw-r--r--source/include/proto.h139
-rw-r--r--source/include/smb.h173
-rw-r--r--source/include/version.h2
-rw-r--r--source/lib/access.c4
-rw-r--r--source/lib/charcnv.c38
-rw-r--r--source/lib/charset.c245
-rw-r--r--source/lib/getsmbpass.c4
-rw-r--r--source/lib/interface.c8
-rw-r--r--source/lib/kanji.c104
-rw-r--r--source/lib/md4.c448
-rw-r--r--source/lib/system.c16
-rw-r--r--source/lib/time.c21
-rw-r--r--source/lib/username.c71
-rw-r--r--source/lib/util.c834
-rw-r--r--source/libsmb/clientgen.c675
-rw-r--r--source/libsmb/nmblib.c10
-rw-r--r--source/libsmb/smbdes.c320
-rw-r--r--source/libsmb/smbencrypt.c95
-rw-r--r--source/locking/locking.c692
-rw-r--r--source/locking/shmem.c32
-rw-r--r--source/md4.h58
-rw-r--r--source/nameannounce.c8
-rw-r--r--source/namebrowse.c2
-rw-r--r--source/namedbresp.c4
-rw-r--r--source/nameelect.c5
-rw-r--r--source/namepacket.c13
-rw-r--r--source/nameresp.c10
-rw-r--r--source/nameserv.c9
-rw-r--r--source/nameservreply.c8
-rw-r--r--source/nameservresp.c13
-rw-r--r--source/namework.c3
-rw-r--r--source/param/loadparm.c296
-rw-r--r--source/param/params.c855
-rw-r--r--source/passdb/smbpass.c6
-rwxr-xr-xsource/script/installcp.sh36
-rw-r--r--source/script/mkproto.awk2
-rwxr-xr-xsource/script/uninstallcp.sh33
-rw-r--r--source/smbd/dir.c6
-rw-r--r--source/smbd/ipc.c21
-rw-r--r--source/smbd/mangle.c207
-rw-r--r--source/smbd/password.c351
-rw-r--r--source/smbd/pipes.c6
-rw-r--r--source/smbd/predict.c39
-rw-r--r--source/smbd/quotas.c27
-rw-r--r--source/smbd/reply.c319
-rw-r--r--source/smbd/server.c1410
-rw-r--r--source/smbd/trans2.c39
-rw-r--r--source/smbd/uid.c84
-rw-r--r--source/utils/make_smbcodepage.c472
-rw-r--r--source/utils/nmblookup.c12
-rw-r--r--source/utils/smbpasswd.c53
-rw-r--r--source/utils/status.c61
-rw-r--r--source/utils/testparm.c2
-rw-r--r--source/web/cgi.c163
-rw-r--r--source/wsmbconf.c251
-rw-r--r--source/wsmbstatus.c87
124 files changed, 4682 insertions, 7748 deletions
diff --git a/README b/README
index ba982448e14..10d9d931e55 100644
--- a/README
+++ b/README
@@ -19,8 +19,10 @@ PC-related machines share files and printers and other informatiuon
such as lists of available files and printers. Operating systems that
support this natively include Windows NT, OS/2, and Linux and add on
packages that achieve the same thing are available for DOS, Windows,
-VMS, Unix of all kinds, MVS, and more. Apple Macs and some Web Browsers
-can speak this protocol as well. Alternatives to SMB include
+VMS, Unix of all kinds, MVS, and more. There is no reason why Apple
+Macs and indeed any Web browser should not be able to speak this
+protocol, and current development (in which the Samba team is heavily
+involved) is aimed at exactly that. Alternatives to SMB include
Netware, NFS, Appletalk, Banyan Vines, Decnet etc; many of these have
advantages but none are both public specifications and widely
implemented in desktop machines by default.
@@ -45,7 +47,7 @@ printers) from unix, Netware and other operating systems
- a tar extension to the client for backing up PCs
For a much better overview have a look at the web site at
-http://samba.canberra.edu.au/pub/samba, and browse the user survey.
+http://samba.anu.edu.au/samba, and browse the user survey.
Related packages include:
@@ -100,22 +102,19 @@ DOCUMENTATION
There is quite a bit of documentation included with the package,
including man pages, and lots of .txt files with hints and useful
-info. This is also available from the web page. There is a growing
-collection of information under docs/faq; by the next release expect
-this to be the default starting point.
+info. This is also available from the web page.
FTP SITE
--------
-Please use a mirror site! The list of mirrors is in docs/MIRRORS.txt.
-The master ftp site is samba.anu.edu.au in the directory pub/samba.
+The main anonymous ftp distribution site for this software is
+samba.anu.edu.au in the directory pub/samba/.
MAILING LIST
------------
There is a mailing list for discussion of Samba. To subscribe send
mail to listproc@samba.anu.edu.au with a body of "subscribe samba Your Name"
-Please do NOT send this request to the list alias instead.
To send mail to everyone on the list mail to samba@listproc.anu.edu.au
@@ -141,12 +140,14 @@ WEB SITE
A Samba WWW site has been setup with lots of useful info. Connect to:
-http://samba.canberra.edu.au/pub/samba/
+http://samba.anu.edu.au/samba/
As well as general information and documentation, this also has searchable
archives of the mailing list and a user survey that shows who else is using
this package. Have you registered with the survey yet? :-)
It is maintained by Paul Blackman (thanks Paul!). You can contact him
-at ictinus@lake.canberra.edu.au.
+at ictinus@samba.anu.edu.au.
+
+
diff --git a/Roadmap b/Roadmap
index 52902d556e4..baeed630a1c 100644
--- a/Roadmap
+++ b/Roadmap
@@ -1,6 +1,6 @@
Copyright (C) 1997 - Samba-Team
-The Samba-Team are committed to an agressive program to deliver quality
+The Samba-Team are committed to an agressive program to deliver quailty
controlled software to a well defined roadmap.
The current Samba release 1.9.17 is called the "Browse Fix Release"
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 072679d0401..83f4aae3081 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,16 +1,117 @@
- WHATS NEW IN 1.9.17 - August 25th 1997
- ======================================
+ WHATS NEW IN 1.9.17p4 - October 21st. 1997
+ ==========================================
+
+Update release: Samba - version 1.9.17p4.
+-----------------------------------------
+
+This is the latest stable release of Samba. This is the
+version that all production Samba servers should be running
+for all current bug-fixes.
+
+Here are a list of the fixes in this release (the fixes
+introduced between 1.9.17p3 and 1.9.17p4) :
+
+1). Fix in nmbd for Windows 95 machines hanging on logout !
+2). Fix for slow share mode code leaving zero length share
+ files.
+3). Fix for security = server, some broken NT4.x servers don't
+ set the guest bit on connections. New code to check logged
+ in user matches requested user.
+4). Fix for security = server. Problem with previous workaround
+ which caused machine logon restrictions on an NT server to fail.
+ This code has been completely re-written.
+5). New option 'dos filetimes' to fix UTIME_WORKAROUND problem.
+6). Fix so nmbd ignores loopback packets.
+7). Fix for nmbd ignoring WINS negative responses.
+8). New PAM support from RedHat for new PAM version.
+9). Memory leak fix when files included from an smb.conf
+ are changed.
+10). Client now logs when connecting as 'guest'.
+11). Updated documentation.
-New stable release of Samba.
-----------------------------
+Reporting bugs
+--------------
+
+The Samba Team believes that this is a stable
+production release, but all software has bugs.
+If you have problems, or think you have found a
+bug please email a report to :
+
+samba-bugs@samba.anu.edu.au
+
+Stating the version number of Samba that you
+are running, and *full details* of the steps
+we need to reproduce the problem.
+
+As always, all bugs are our responsibility.
+
+Regards,
+
+ The Samba Team.
+
+-------------Previous release notes-------------------------
-This is the new stable release of Samba, superceding
+Update release: Samba - version 1.9.17p3.
+-----------------------------------------
+
+This is the latest stable release of Samba. This is the
+version that all production Samba servers should be running
+for all current bug-fixes.
+
+Here are a list of the fixes in this release (the fixes
+introduced between 1.9.17p2 and 1.9.17p3) :
+
+1). Removed truncation problem with long browse lists.
+2). Crash bug when dead share mode memory entries need removing.
+3). Race condition in slow share mode code.
+4). Potential buffer overflow from password server.
+5). Fix for read-prediction growing read-only files.
+6). Many quota code fixes.
+7). Fix for spelling mistake in attack warning :-).
+8). Removed 'ERRbaddirectory' error code - caused problem with
+ Visual Basic apps.
+9). Allow 'hosts allow/deny' to work before client packet parsed.
+10). Wrapping log file causes incorrect errors to be returned to
+ the clients.
+11). Crash fix for nmbd Get_Hostbyname bad return.
+12). 'become_root' 'unbecome_root' added to fix changing uid problems.
+13). No magic scripts or printing done on exceptional file close problems.
+
+
+Security fix release: Samba - version 1.9.17p2.
+----------------------------------------------
+
+This new stable release fixes a very important security hole in all
+versions of Samba.
+
+The security hole allows a remote user to obtain root access on the
+Samba server. A program which exploits this bug has been posted to the
+internet.
+
+The security hole is only known to affect Samba servers running on
+Intel based hardware, and has only been demonstrated for Intel
+Linux. It is likley that exploits for other architectures would be
+very difficult but the possibility cannot be excluded completely.
+
+This patch fixes the security hole for all platforms.
+
+This patch also adds a routine which will log a message when a user
+attempts to take advantage of the security hole.
+
+A number of other minor bugs have also been fixed in this release.
+
+The Samba Team.
+
+
+-------------Previous release notes-------------------------
+
+New stable release of Samba - 1.9.17
+------------------------------------
+
+This is the new stable release of Samba, superceeding
the last stable release 1.9.16p11. All users are
encouraged to upgrade to this new release as there have
been many improvements to the code since that time.
-See the Frequently Asked Questions (under docs/faq) for
-an explanation of how the version numbering scheme works,
-distinguishing between stable and development releases.
Changes since 1.9.16p11.
------------------------
@@ -67,10 +168,6 @@ All options are now documented in the smb.conf man page
we believe. Much work has been done by Samba Team members
to improve the quality and quantity of the Samba documentation.
-A draft new structure for documentation is being worked on: see
-docs/faq/Samba-meta-FAQ for details. This will soon be a master
-reference to all Samba documentation.
-
Many bugfixes and improvements
------------------------------
From around the 'net around the world. Many
diff --git a/docs/announce b/docs/announce
index adcde8966f8..a03ddcd0e6a 100644
--- a/docs/announce
+++ b/docs/announce
@@ -127,7 +127,7 @@ There is also often quite a bit of discussion about Samba on the
newsgroup comp.protocols.smb.
A WWW site with lots of Samba info can be found at
-http://samba.canberra.edu.au/pub/samba/
+http://samba.anu.edu.au/samba/
The Samba Team (Contact: samba-bugs@samba.anu.edu.au)
June 1996
diff --git a/docs/faq/Samba-Server-FAQ.html b/docs/faq/Samba-Server-FAQ.html
index 501ff1b1ed8..eadc3e26ede 100644
--- a/docs/faq/Samba-Server-FAQ.html
+++ b/docs/faq/Samba-Server-FAQ.html
@@ -39,7 +39,7 @@ Table of Contents
<HR>
<H1> Samba Server FAQ</H1>
-<H2>Dan Shearer & Paul Blackman, <CODE>ictinus@lake.canberra.edu.au</CODE></H2>v 0.1, 23 Aug '97
+<H2>Dan Shearer & Paul Blackman, <CODE>ictinus@samba.anu.edu.au</CODE></H2>v 0.3, 7 Oct '97
<P><HR><EM> This is the <EM>Server</EM> Frequently Asked Questions (FAQ)
document for Samba, the free and very popular SMB and CIFS server
product. A general
diff --git a/docs/faq/Samba-Server-FAQ.sgml b/docs/faq/Samba-Server-FAQ.sgml
index 4887481e2b1..020d5322811 100644
--- a/docs/faq/Samba-Server-FAQ.sgml
+++ b/docs/faq/Samba-Server-FAQ.sgml
@@ -3,7 +3,7 @@
v 0.1 23 Aug 1997 Dan Shearer
Original Samba-Client-FAQ.sgml from Paul's sambafaq.sgml
v 0.2 25 Aug 1997 Dan
-
+ v 0.3 7 Oct 1997 Paul, changed email address from ictinus@lake... to ictinus@samba.anu
-->
@@ -11,9 +11,9 @@
<title> Samba Server FAQ
-<author>Dan Shearer & Paul Blackman, <tt>ictinus@lake.canberra.edu.au</tt>
+<author>Dan Shearer & Paul Blackman, <tt>ictinus@samba.anu.edu.au</tt>
-<date>v 0.1, 23 Aug '97
+<date>v 0.3, 7 Oct '97
<abstract> This is the <em>Server</em> Frequently Asked Questions (FAQ)
document for Samba, the free and very popular SMB and CIFS server
diff --git a/docs/faq/Samba-meta-FAQ-2.html b/docs/faq/Samba-meta-FAQ-2.html
index c5ebab7e7e4..ac760380067 100644
--- a/docs/faq/Samba-meta-FAQ-2.html
+++ b/docs/faq/Samba-meta-FAQ-2.html
@@ -166,7 +166,7 @@ See below for subscription information.
discussion about Samba.
</LI>
<LI>The WWW site 'SAMBA Web Pages' at
-<A HREF="http://samba.canberra.edu.au/pub/samba/samba.html">http://samba.canberra.edu.au/pub/samba/samba.html</A> includes:
+<A HREF="http://samba.anu.edu.au/samba/">http://samba.anu.edu.au/samba/</A> includes:
<UL>
<LI>Links to man pages and documentation, including this FAQ</LI>
diff --git a/docs/faq/Samba-meta-FAQ.html b/docs/faq/Samba-meta-FAQ.html
index 7821083740d..5a70808867b 100644
--- a/docs/faq/Samba-meta-FAQ.html
+++ b/docs/faq/Samba-meta-FAQ.html
@@ -37,7 +37,7 @@ Table of Contents
<HR>
<H1> Samba meta FAQ</H1>
-<H2>Dan Shearer & Paul Blackman, <CODE>ictinus@lake.canberra.edu.au</CODE></H2>v 0.1, 23 Aug '97
+<H2>Dan Shearer & Paul Blackman, <CODE>ictinus@samba.anu.edu.au</CODE></H2>v 0.3, 7 Oct '97
<P><HR><EM> This is the meta-Frequently Asked Questions (FAQ) document
for Samba, the free and very popular SMB and CIFS server product. It
contains overview information for the Samba suite of programs, a
diff --git a/docs/faq/Samba-meta-FAQ.sgml b/docs/faq/Samba-meta-FAQ.sgml
index 2b54c6fa0f1..75038f19f53 100644
--- a/docs/faq/Samba-meta-FAQ.sgml
+++ b/docs/faq/Samba-meta-FAQ.sgml
@@ -3,15 +3,17 @@
v 0.1 23 Aug 1997 Dan Shearer
Original Samba-meta-FAQ.sgml from Paul's sambafaq.sgml
v 0.2 25 Aug 1997 Dan
+ v 0.3 7 Oct 1997 Paul
+ Changed samba.canberra refs to samba.anu.../samba/
-->
<article>
<title> Samba meta FAQ
-<author>Dan Shearer & Paul Blackman, <tt>ictinus@lake.canberra.edu.au</tt>
+<author>Dan Shearer & Paul Blackman, <tt>ictinus@samba.anu.edu.au</tt>
-<date>v 0.1, 23 Aug '97
+<date>v 0.3, 7 Oct '97
<abstract> This is the meta-Frequently Asked Questions (FAQ) document
for Samba, the free and very popular SMB and CIFS server product. It
@@ -286,7 +288,7 @@ See below for subscription information.
discussion about Samba.
<item>The WWW site 'SAMBA Web Pages' at <url
-url="http://samba.canberra.edu.au/pub/samba/samba.html"> includes:
+url="http://samba.anu.edu.au/samba/"> includes:
<itemize>
<item>Links to man pages and documentation, including this FAQ
diff --git a/docs/faq/Samba-meta-FAQ.txt b/docs/faq/Samba-meta-FAQ.txt
index 967dceac8de..65d9a57ff62 100644
--- a/docs/faq/Samba-meta-FAQ.txt
+++ b/docs/faq/Samba-meta-FAQ.txt
@@ -1,6 +1,6 @@
Samba meta FAQ
- Dan Shearer & Paul Blackman, ictinus@lake.canberra.edu.au
- v 0.1, 23 Aug '97
+ Dan Shearer & Paul Blackman, ictinus@samba.anu.edu.au
+ v 0.3, 7 Oct '97
This is the meta-Frequently Asked Questions (FAQ) document for Samba,
the free and very popular SMB and CIFS server product. It contains
@@ -43,7 +43,7 @@
2.11. Pizza supply details
- 3. About CIFS and SMB
+ 3. About the CIFS and SMB Protocols
3.1. What is the Server Message Block (SMB) Protocol?
@@ -53,7 +53,7 @@
4. Designing A SMB and CIFS Network
- 4.1. Workgroups, Browsing Domains and Authentication Domains
+ 4.1. Workgroups, Domains, Authentication and Browsing
4.1.1. Defining the Terms
@@ -63,19 +63,16 @@
4.2. Authentication Schemes
- 4.2.1. Workgroup Mode Services
- 4.2.2. Windows NT-Style Domain
+ 4.2.1. NIS
- 4.2.3. NIS
+ 4.2.2. Kerberos
- 4.2.4. Kerberos
+ 4.2.3. FTP
- 4.2.5. FTP
+ 4.2.4. Default Server Method
- 4.2.6. Default Server Method
-
- 4.2.7. Client-side Database Only
+ 4.2.5. Client-side Database Only
4.3. Post-Authentication: Netlogon, Logon Scripts, Profiles
@@ -88,47 +85,87 @@
11.. QQuuiicckk RReeffeerreennccee GGuuiiddeess ttoo SSaammbbaa DDooccuummeennttaattiioonn
+
We are endeavouring to provide links here to every major class of
information about Samba or things related to Samba. We cannot list
every document, but we are aiming for all documents to be at most two
referrals from those listed here. This needs constant maintaining, so
please send the author your feedback.
+
11..11.. SSaammbbaa ffoorr tthhee IImmppaattiieenntt
+
You know you should read the documentation but can't wait to start?
What you need to do then is follow the instructions in the following
- documents, in order. This should be enough to get a _s_i_m_p_l_e site going
- quickly. If you have any problems at all, refer back to this section
- and do some more reading.
-
- 1. Getting Samba: ``Download Instructions''
-
- 2. Installing Samba: making sure the binaries are in place and work.
- At the moment there are two kinds of Samba server installs: Unix or
- close relative <INSTALL.txt> and Others <Samba-Server-
- FAQ.html#PortInfo>. Do not forget to
-
- 3. Debug sequence: If you think you have completed the previous step
- and things aren't working properly work through the diagnosis
- recipe. <DIAGNOSIS.txt>
-
- 4. Exporting files to SMB clients: You should read the manual pages
- for smb.conf, but here is a quick answer guide. <Samba-Server-
- FAQ.html#Exporting>
-
- 5. Controlling user access: the quickest and dirtiest way of sharing
- resources is to use ``share level security.'' If you want to spend
- more time and have a proper username and password database you must
- read the paragraph on ``domain mode security.'' If you want
- encryption (eg you are using Windows NT clients) follow the SMB
- encryption instructions. <Samba-Server-FAQ.html#SMBEncryptionSteps>
- 6. Browsing: if you are happy to type in "\samba-serverrename" at the
- client end then do not read any further. Otherwise you need to
- understand the ``browsing terminoligy'' and read <BROWSING.txt>.
-
- 7. Printing: See the printing quick answer guide. <Samba-Server-
- FAQ.html#Printing>
+ documents in the order given. This should be enough to get a fairly
+ simple site going quickly. If you have any problems, refer back to
+ this meta-FAQ and follow the links to find more reading material.
+
+
+
+ GGeettttiinngg SSaammbbaa::
+ The fastest way to get Samba going is and install it is to have
+ an operating system for which the Samba team has put together an
+ installation package. To see if your OS is included have a look
+ at the directory /pub/samba/Binary_Packages/"OS_Vendor" on your
+ nearest mirror site <../MIRRORS>. If it is included follow the
+ installation instructions in the README file there and then do
+ some ``basic testing''. If you are not so fortunate, follow the
+ normal ``download instructions'' and then continue with
+ ``building and installing Samba''.
+
+
+ BBuuiillddiinngg aanndd IInnssttaalllliinngg SSaammbbaa::
+ At the moment there are two kinds of Samba server installs
+ besides the prepackaged binaries mentioned in the previous step.
+ You need to decide if you have a Unix or close relative
+ <../UNIX_INSTALL.txt> or other supported operating system
+ <Samba-Server-FAQ.html#PortInfo>.
+
+
+ BBaassiicc TTeessttiinngg::
+ Try to connect using the supplied smbclient command-line
+ program. You need to know the IP hostname of your server. A
+ service name must be defined in smb.conf, as given in the
+ examples (under many operating systems if there is a homes
+ service you can just use a valid username.) Then type smbclient
+ \hostnamevicename Under most Unixes you will need to put the
+ parameters within quotation marks. If this works, try connecting
+ from one of the SMB clients you were planning to use with Samba.
+
+
+ DDeebbuugg sseeqquueennccee::
+ If you think you have completed the previous step and things
+ aren't working properly work through the diagnosis recipe.
+ <../DIAGNOSIS.txt>
+
+
+ EExxppoorrttiinngg ffiilleess ttoo SSMMBB cclliieennttss::
+ You should read the manual pages for smb.conf, but here is a
+ quick answer guide. <Samba-Server-FAQ.html#Exporting>
+
+
+ CCoonnttrroolllliinngg uusseerr aacccceessss::
+ the quickest and dirtiest way of sharing resources is to use
+ ``share level security.'' If you want to spend more time and
+ have a proper username and password database you must read the
+ paragraph on ``domain mode security.'' If you want encryption
+ (eg you are using Windows NT clients) follow the SMB encryption
+ instructions. <Samba-Server-FAQ.html#SMBEncryptionSteps>
+
+
+ BBrroowwssiinngg::
+ if you are happy to type in "\samba-serverrename" at the client
+ end then do not read any further. Otherwise you need to
+ understand the ``browsing terminology'' and read <Samba-Server-
+ FAQ.html#NameBrowsing>.
+
+
+ PPrriinnttiinngg::
+ See the printing quick answer guide. <Samba-Server-
+ FAQ.html#Printing>
+
If you have got everything working to this point, you can expect Samba
to be stable and secure: these are its greatest strengths. However
@@ -138,8 +175,11 @@
so on are all covered either in this document or in those it refers
to.
+
11..22.. AAllll SSaammbbaa DDooccuummeennttaattiioonn
+
+
+o Meta-FAQ. This is the mother of all documents, and is the one you
are reading now. The latest version is always at
<http://samba.anu.edu.au/[.....]> but there is probably a much
@@ -151,27 +191,31 @@
from...)
+o <Samba-Client-FAQ.html> is the best starting point for information
- about client-side issues, includes a list of all clients that work
- with Samba.
+ about client-side issues, includes a list of all clients that are
+ known to work with Samba.
- +o <samba-man-index.html> contains descriptions of and links to all
- the Samba manual pages, in Unix man and postscript format.
+ +o manual pages <samba-man-index.html> contains descriptions of and
+ links to all the Samba manual pages, in Unix man and postscript
+ format.
+o <samba-txt-index.html> has descriptions of and links to a large
number of text files have been contributed to samba covering many
- topics. These are gradually being absorbed into the FAQs and HOWTOS
+ topics. These are gradually being absorbed into the FAQs and HOWTOs
but in the meantime you might find helpful answers here.
+o
+
22.. GGeenneerraall IInnffoorrmmaattiioonn
+
All about Samba - what it is, how to get it, related sources of
- information, how to understand the version numbering scheme, pizza
- details
+ information, how to understand the numbering scheme, pizza details.
+
22..11.. WWhhaatt iiss SSaammbbaa??
+
Samba is a suite of programs which work together to allow clients to
access to a server's filespace and printers via the SMB (Server
Message Block) and CIFS (Common Internet Filesystem) protocols.
@@ -181,6 +225,7 @@
behave much like a LAN Server, Windows NT Server or Pathworks machine,
only with added functionality and flexibility designed to make life
easier for administrators.
+
This means that using Samba you can share a server's disks and
printers to many sorts of network clients, including Lan Manager,
Windows for Workgroups, Windows NT, Linux, OS/2, and AIX. There is
@@ -188,6 +233,10 @@
which gives a user on the server an ftp-like interface to access
filespace and printers on any other SMB/CIFS servers.
+ SMB has been implemented over many protocols, including XNS, NBT, IPX,
+ NetBEUI and TCP/IP. Samba only uses TCP/IP. This is not likely to
+ change although there have been some requests for NetBEUI support.
+
Many users report that compared to other SMB implementations Samba is
more stable, faster, and compatible with more clients. Administrators
of some large installations say that Samba is the only SMB server
@@ -206,16 +255,19 @@
versions incorporate much effort by many net.helpers. The man pages
and this FAQ were originally written by Karl Auer.
+
22..22.. WWhhaatt iiss tthhee ccuurrrreenntt vveerrssiioonn ooff SSaammbbaa??
+
At time of writing, the current version was 1.9.17. If you want to be
sure check the bottom of the change-log file.
<ftp://samba.anu.edu.au/pub/samba/alpha/change-log>
-
For more information see ``What do the version numbers mean?''
+
22..33.. WWhheerree ccaann II ggeett iitt??
+
The Samba suite is available via anonymous ftp from samba.anu.edu.au
and many mirror <../MIRRORS> sites. You will get much faster
performance if you use a mirror site. The latest and greatest versions
@@ -235,8 +287,18 @@
binaries for that platform. The VMS, OS/2, Netware and Amiga and other
ports typically have binaries made available.
+ A special case is vendor-provided binary packages. Samba binaries and
+ default configuration files are put into packages for a specific
+ operating system. RedHat Linux and Sun Solaris (Sparc and x86) is
+ already included, and others such as OS/2 may follow. All packages are
+ in the directory:
+
+ /pub/samba/Binary_Packages/"OS_Vendor"
+
+
22..44.. WWhhaatt ddoo tthhee vveerrssiioonn nnuummbbeerrss mmeeaann??
+
It is not recommended that you run a version of Samba with the word
"alpha" in its name unless you know what you are doing and are willing
to do some debugging. Many, many people just get the latest
@@ -248,6 +310,7 @@
How the scheme works:
+
1. When major changes are made the version number is increased. For
example, the transition from 1.9.16 to 1.9.17. However, this
version number will not appear immediately and people should
@@ -269,6 +332,7 @@
So the progression goes:
+
1.9.16p10 (production)
1.9.16p11 (production)
1.9.17alpha1 (test sites only)
@@ -277,24 +341,30 @@
1.9.17 (production)
1.9.17p1 (production)
+
+
The above system means that whenever someone looks at the samba ftp
site they will be able to grab the highest numbered release without an
alpha in the name and be sure of getting the current recommended
version.
+
22..55.. WWhheerree ccaann II ggoo ffoorr ffuurrtthheerr iinnffoorrmmaattiioonn??
+
There are a number of places to look for more information on Samba,
including:
+
+o Two mailing lists devoted to discussion of Samba-related matters.
See below for subscription information.
+o The newsgroup comp.protocols.smb, which has a great deal of
discussion about Samba.
- +o The WWW site 'SAMBA Web Pages' at
- <http://samba.canberra.edu.au/pub/samba/samba.html> includes:
+ +o The WWW site 'SAMBA Web Pages' at <http://samba.anu.edu.au/samba/>
+ includes:
+
+o Links to man pages and documentation, including this FAQ
@@ -306,14 +376,22 @@
+o This FAQ and the rest in its family
+
+
22..66.. HHooww ddoo II ssuubbssccrriibbee ttoo tthhee SSaammbbaa MMaaiilliinngg LLiissttss??
+
Send email to listproc@samba.anu.edu.au. Make sure the subject line is
blank, and include the following two lines in the body of the message:
+
+
subscribe samba Firstname Lastname
subscribe samba-announce Firstname Lastname
+
+
+
Obviously you should substitute YOUR first name for "Firstname" and
YOUR last name for "Lastname"! Try not to send any signature, it
sometimes confuses the list processor.
@@ -327,20 +405,29 @@
listproc@samba.anu.edu.au. Make sure the subject line is blank, and
include the following two lines in the body of the message:
+
+
unsubscribe samba
unsubscribe samba-announce
+
+
+
The FFrroomm:: line in your message _M_U_S_T be the same address you used when
you subscribed.
+
22..77.. SSoommeetthhiinngg''ss ggoonnee wwrroonngg -- wwhhaatt sshhoouulldd II ddoo??
+
## ****** IIMMPPOORRTTAANNTT!! ****** ##
+
DO NOT post messages on mailing lists or in newsgroups until you have
carried out the first three steps given here!
- 1. See if there are any likely looking entries in this FAQ! If you
+
+ 1. See if there are any likely looking entries in this FAQ! If you
have just installed Samba, have you run through the checklist in
DIAGNOSIS.txt <ftp://samba.anu.edu.au/pub/samba/DIAGNOSIS.txt>? It
can save you a lot of time and effort. DIAGNOSIS.txt can also be
@@ -370,8 +457,12 @@
succinct description of the symptom, the problem and the solution, so
that an explanation can be incorporated into the next version.
+
+
+
22..88.. HHooww ddoo II ssuubbmmiitt ppaattcchheess oorr bbuugg rreeppoorrttss??
+
If you make changes to the source code, _p_l_e_a_s_e submit these patches so
that everyone else gets the benefit of your work. This is one of the
most important aspects to the maintainence of Samba. Send all patches
@@ -412,6 +503,7 @@
Some extras :
+
+o what you did and what happened
+o relevant parts of a debugging output file with debuglevel higher.
@@ -420,8 +512,10 @@
+o anything else you think is useful to trace down the bug
+
22..99.. WWhhaatt iiff II hhaavvee aann UURRGGEENNTT mmeessssaaggee ffoorr tthhee ddeevveellooppeerrss??
+
If you have spotted something very serious and believe that it is
important to contact the developers quickly send a message to samba-
urgent@samba.anu.edu.au. This will be processed more quickly than mail
@@ -434,21 +528,25 @@
22..1100.. WWhhaatt iiff II nneeeedd ppaaiidd--ffoorr ssuuppppoorrtt??
+
Samba has a large network of consultants who provide Samba support on
a commercial basis. The list is included in the package in
- Support.txt, and the latest version will always be on the main samba
- ftp site. Any company in the world can request that the samba team
- include their details in Support.txt so we can give no guarantee of
- their services.
+ <../Support.txt>, and the latest version will always be on the main
+ samba ftp site. Any company in the world can request that the samba
+ team include their details in Support.txt so we can give no guarantee
+ of their services.
+
22..1111.. PPiizzzzaa ssuuppppllyy ddeettaaiillss
+
Those who have registered in the Samba survey as "Pizza Factory" will
already know this, but the rest may need some help. Andrew doesn't ask
for payment, but he does appreciate it when people give him pizza.
This calls for a little organisation when the pizza donor is twenty
thousand kilometres away, but it has been done.
+
1. Ring up your local branch of an international pizza chain and see
if they honour their vouchers internationally. Pizza Hut do, which
is how the entire Canberra Linux Users Group got to eat pizza one
@@ -468,7 +566,10 @@
will probably get stuck in customs or torn apart by hungry sniffer
dogs but it will have been a noble gesture.
- 33.. AAbboouutt CCIIFFSS aanndd SSMMBB
+
+ 33.. AAbboouutt tthhee CCIIFFSS aanndd SSMMBB PPrroottooccoollss
+
+
33..11.. WWhhaatt iiss tthhee SSeerrvveerr MMeessssaaggee BBlloocckk ((SSMMBB)) PPrroottooccooll??
@@ -493,6 +594,7 @@
implement more and more of these protocols. Samba began to take a
significant share of the SMB server market.
+
33..22.. WWhhaatt iiss tthhee CCoommmmoonn IInntteerrnneett FFiilleessyysstteemm ((CCIIFFSS))??
The initial pressure for Microsoft to document their current SMB
@@ -516,6 +618,7 @@
The following is taken from <http://www.microsoft.com/intdev/cifs/>
+
CIFS defines a standard remote file system access protocol for use
over the Internet, enabling groups of users to work together and
share documents across the Internet or within their corporate
@@ -526,6 +629,8 @@
users can open and share remote files on the Internet without having
to install new software or change the way they work."
+
+
If you consider CIFS as a backwardsly-compatible refinement of SMB
that will work reasonably efficiently over the Internet you won't be
too far wrong.
@@ -537,6 +642,7 @@
reason why a site shouldn't conduct all its file and printer sharing
with CIFS and yet have no Microsoft products at all.
+
33..33.. WWhhaatt iiss BBrroowwssiinngg??
The term "Browsing" causes a lot of confusion. It is the part of the
@@ -549,11 +655,16 @@
subject for debate. Look at the CIFS list archives to see what the
experts think.
+
+
+
44.. DDeessiiggnniinngg AA SSMMBB aanndd CCIIFFSS NNeettwwoorrkk
+
The big issues for installing any network of LAN or WAN file and print
servers are
+
+o How and where usernames, passwords and other security information
is stored
@@ -562,6 +673,7 @@
+o What protocols the clients can converse with
+
If you buy Netware, Windows NT or just about any other LAN fileserver
product you are expected to lock yourself into the product's preferred
answers to these questions. This tendancy is restrictive and often
@@ -573,65 +685,103 @@
administators, which means allowing as many combinations of clients,
servers, operating systems and protocols as possible.
- 44..11.. WWoorrkkggrroouuppss,, BBrroowwssiinngg DDoommaaiinnss aanndd AAuutthheennttiiccaattiioonn DDoommaaiinnss
- The concepts of a Workgroup and a Domain are fundamental to SMB
- networking. Although Microsoft integrates Workgroups and Domains
- tightly with their authentication procedures there is no reason why
- this has to be so in an SMB network. Groups of SMB machines can work
- together just as well with Unix or OS/2 Samba servers as they can with
- Windows NT servers, even though the password storage and access
- methods are totally different.
+ 44..11.. WWoorrkkggrroouuppss,, DDoommaaiinnss,, AAuutthheennttiiccaattiioonn aanndd BBrroowwssiinngg
+
+
+ From the point of view of networking implementation, Domains and
+ Workgroups are _e_x_a_c_t_l_y the same, except for the client logon sequence.
+ Some kind of distributed authentication database is associated with a
+ domain (there are quite a few choices) and this adds so much
+ flexibility that many people think of a domain as a completely
+ different entity to a workgroup. From Samba's point of view a client
+ connecting to a service presents an authentication token, and it if it
+ is valid they have access. Samba does not care what mechanism was used
+ to generate that token in the first place.
+
+ The SMB client logging on to a domain has an expectation that every
+ other server in the domain should accept the same authentication
+ information. However the network browsing functionality of domains
+ and workgroups is identical and is explained in <../BROWSING.txt>.
+
+ There are some implementation differences: Windows 95 can be a member
+ of both a workgroup and a domain, but Windows NT cannot. Windows 95
+ also has the concept of an "alternative workgroup". Samba can only be
+ a member of a single workgroup or domain, although this is due to
+ change with a future version when nmbd will be split into two daemons,
+ one for WINS and the other for browsing ( <../NetBIOS.txt> explains
+ what WINS is.)
+
44..11..11.. DDeeffiinniinngg tthhee TTeerrmmss
- A Workgroup (or Browsing Domain) is collection of machines that
- maintain a common database contianing information about their shared
- resources. They do not necessarily have any security information in
- common. The database is dynamic, modified as servers come and go on
- the network and as resources are added or deleted. The term "browsing"
- refers to a user accessing the database via whatever interface the
- client provides. SMB servers agree between themselves as to which ones
- will maintain the browsing database. Workgroups can be anywhere on a
- connected TCP/IP network, including on different subnets or anywhere
- on the Interet. This is a very tricky part of SMB to implement.
- Due to the convoluted history of SMB there is now conflicting
- terminology describing Domains and Workgroups. "Domain" is used in the
- browsing specifications to define that group of servers and clients
- who share a common name and a common browsing database. The following
- are used exclusively in the context of Workgroup browsing:
- +o Domain Master Browser
- +o Local Master Browser
+ WWoorrkkggrroouupp
+ means a collection of machines that maintain a common browsing
+ database containing information about their shared resources.
+ They do not necessarily have any security information in common
+ (if they do, it gets called a Domain.) The browsing database is
+ dynamic, modified as servers come and go on the network and as
+ resources are added or deleted. The term "browsing" refers to a
+ user accessing the database via whatever interface the client
+ provides, eg the OS/2 Workplace Shell or Windows 95 Explorer.
+ SMB servers agree between themselves as to which ones will
+ maintain the browsing database. Workgroups can be anywhere on a
+ connected TCP/IP network, including on different subnets or even
+ on the Interet. This is a very tricky part of SMB to implement.
+
- Alternative terms include confusing variations such as "Browse
- Master", and "Master Browser" which we are trying to eliminate from
- the Samba documentation. We are moving to the use of "Browsing Domain"
- wherever the word "Domain" occurs in a workgroup context. Ideally
- "Workgroup" would also be replaced by Browsing Domain but it is very
- widely used terminology.
+ MMaasstteerr BBrroowwsseerrss
+ are machines which holds the master browsing database for a
+ workgroup or domain. There are two kinds of Master Browser:
- Unfortunately the group of machines which use the the Microsoft method
- of sharing authentication information (but not any of the many other
- methods) is also called a Domain. As explained elsewhere Microsoft are
- not making this protocol public and The following are used exclusively
- in the context of Microsoft Authentication domains:
- +o Primary Domain Controller
+ +o Domain Master Browser, which holds the master browsing
+ information for an entire domain, which may well cross multiple
+ TCP/IP subnets.
- +o Backup Domain Controller
+ +o Local Master Browser, which holds the master browsing database
+ for a particular subnet and communicates with the Domain Master
+ Browser to get information on other subnets.
+
+ Subnets are differentiated because browsing is based on
+ broadcasts, and broadcasts do not pass through routers. Subnets
+ are not routed: while it is possible to have more than one
+ subnet on a single network segment this is regarded as very bad
+ practice.
+
+ Master Browsers (both Domain and Local) are elected dynamically
+ according to an algorithm which is supposed to take into account
+ the machine's ability to sustain the browsing load. Samba can be
+ configured to always act as a master browser, ie it always wins
+ elections under all circumstances, even against systems such as
+ a Windows NT Primary Domain Controller which themselves expect
+ to win.
+
+ There are also Backup Browsers which are promoted to Master
+ Browsers in the event of a Master Browser disappearing from the
+ network.
+
+ Alternative terms include confusing variations such as "Browse
+ Master", and "Master Browser" which we are trying to eliminate
+ from the Samba documentation.
+
+
+ DDoommaaiinn CCoonnttrroolllleerr
+ is a term which comes from the Microsoft and IBM etc
+ implementation of the LAN Manager protocols. It is tied to
+ authentication. There are other ways of doing domain
+ authentication, but the Windows NT method has a large market
+ share. The general issues are discussed in <../DOMAIN.txt> and
+ a Windows NT-specific discussion is in <../DOMAIN_CONTROL.txt>.
- +o Domain Logon
- These terms can be very confusing, and so in the Samba documentation
- we are moving to the term "Authentication Domain" wherever Domain is
- used in this sense. As a final touch of irony, all Authentication
- Domains are also Browsing Domains.
44..11..22.. SShhaarreelleevveell ((WWoorrkkggrroouupp)) SSeeccuurriittyy SSeerrvviicceess
+
With the Samba setting "security = SHARE", all shared resources
information about what password is associated with them but only hints
as to what usernames might be valid (the hint can be 'all users', in
@@ -643,16 +793,20 @@
authentication infrastructure present or requiring them to do more
than fill in a dialogue box.
+
44..11..33.. AAuutthheennttiiccaattiioonn DDoommaaiinn MMooddee SSeerrvviicceess
+
With the Samba settings "security = USER" or "security = SERVER"
accesses to all resources are checked for username/password pair
- matches in a more rigorous manner. This has the effect of emulating a
- Microsoft Authentication Domain. Whether or not an Authentication
- Domain is involved depends on how the network has been designed.
+ matches in a more rigorous manner. To the client, this has the effect
+ of emulating a Microsoft Domain. The client is not concerned whether
+ or not Samba looks up a Windows NT SAM or does it in some other way.
+
44..22.. AAuutthheennttiiccaattiioonn SScchheemmeess
+
In the simple case authentication information is stored on a single
server and the user types a password on connecting for the first time.
However client operating systems often require a password before they
@@ -661,7 +815,8 @@
different contexts just does not work. Some kind of distributed
authentication database is needed. It must cope with password changes
and provide for assigning groups of users the same level of access
- permissions.
+ permissions. This is why Samba installations often choose to implement
+ a Domain model straight away.
Authentication decisions are some of the biggest in designing a
network. Are you going to use a scheme native to the client operating
@@ -671,29 +826,49 @@
setups would be appreciated. refer to server FAQ for "passwd chat"
passwd program password server etc etc...
- 44..22..11.. WWoorrkkggrroouupp MMooddee SSeerrvviicceess
- etc etc
+ 44..22..11.. NNIISS
+
+
+ For Windows 95, Windows for Workgroups and most other clients Samba
+ can be a domain controller and share the password database via NIS
+ transparently. Windows NT is different. Free NIS NT client
+ <http://www.dcs.qmw.ac.uk/~williams>
+
+
+ 44..22..22.. KKeerrbbeerrooss
+
+
+ Kerberos for US users only: Kerberos overview
+ <http://www.cygnus.com/product/unifying-security.html> Download
+ Kerberos <http://www.cygnus.com/product/kerbnet-download.html>
+
+
+ 44..22..33.. FFTTPP
- 44..22..22.. WWiinnddoowwss NNTT--SSttyyllee DDoommaaiinn
- Samba compiled with libdes - enabling encrypted passwords security =
- server
+ Other NT w/s logon hack via NT
- 44..22..33.. NNIISS
- 44..22..44.. KKeerrbbeerrooss
+ 44..22..44.. DDeeffaauulltt SSeerrvveerr MMeetthhoodd
- 44..22..55.. FFTTPP
- 44..22..66.. DDeeffaauulltt SSeerrvveerr MMeetthhoodd
- 44..22..77.. CClliieenntt--ssiiddee DDaattaabbaassee OOnnllyy
+
+
+ 44..22..55.. CClliieenntt--ssiiddee DDaattaabbaassee OOnnllyy
+
+
44..33.. PPoosstt--AAuutthheennttiiccaattiioonn:: NNeettllooggoonn,, LLooggoonn SSccrriippttss,, PPrrooffiilleess
+
+ See <../DOMAIN.txt>
+
+
55.. CCrroossss--PPrroottooccooll FFiillee SShhaarriinngg
+
Samba is an important tool for...
It is possible to...
@@ -710,10 +885,40 @@
packages, Samba, and Linux (and other UNIX-based systems) see
<http://www.eats.com/linux_mac_win.html> 3.5) Sniffing your nework
+
+
66.. MMiisscceellllaanneeoouuss
+
66..11.. IIss SSaammbbaa YYeeaarr 22000000 ccoommpplliiaanntt??
+
The CIFS protocol that Samba implements negotiates times in various
formats, all of which are able to cope with dates beyond 2000.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/faq/sambafaq-1.html b/docs/faq/sambafaq-1.html
index 4b9e589e843..c010e50e011 100644
--- a/docs/faq/sambafaq-1.html
+++ b/docs/faq/sambafaq-1.html
@@ -197,7 +197,7 @@ There are a number of places to look for more information on Samba, including:
<LI>Two mailing lists devoted to discussion of Samba-related matters. </LI>
<LI>The newsgroup, comp.protocols.smb, which has a great deal of discussion on Samba. </LI>
<LI>The WWW site 'SAMBA Web Pages' at
-<A HREF="http://samba.canberra.edu.au/pub/samba/samba.html">http://samba.canberra.edu.au/pub/samba/samba.html</A> includes:
+<A HREF="http://samba.edu.au/samba/">http://samba.edu.au/samba/</A> includes:
<UL>
<LI>Links to man pages and documentation, including this FAQ</LI>
<LI>A comprehensive survey of Samba users.</LI>
diff --git a/docs/faq/sambafaq-3.html b/docs/faq/sambafaq-3.html
index 8b24de54f23..1b5dcf4d9aa 100644
--- a/docs/faq/sambafaq-3.html
+++ b/docs/faq/sambafaq-3.html
@@ -76,7 +76,7 @@ To syncronize your PC's clock with your Samba server:
<UL>
<LI> Copy timesync.pif to your windows directory</LI>
<LI> timesync.pif can be found at:
-<A HREF="http://samba.canberra.edu.au/pub/samba/binaries/miscellaneous/timesync.pif">http://samba.canberra.edu.au/pub/samba/binaries/miscellaneous/timesync.pif</A></LI>
+<A HREF="http://samba.anu.edu.au/samba/binaries/miscellaneous/timesync.pif">http://samba.anu.edu.au/samba/binaries/miscellaneous/timesync.pif</A></LI>
<LI> Add timesync.pif to your 'Start Up' group/folder</LI>
<LI> Open the properties dialog box for the program/icon</LI>
<LI> Make sure the 'Run Minimized' option is set in program 'Properties'</LI>
diff --git a/docs/faq/sambafaq.html b/docs/faq/sambafaq.html
index 9e3d21ad137..9c45d524dd3 100644
--- a/docs/faq/sambafaq.html
+++ b/docs/faq/sambafaq.html
@@ -45,7 +45,7 @@ Table of Contents
<HR>
<H1> Samba FAQ</H1>
-<H2>Paul Blackman, <CODE>ictinus@lake.canberra.edu.au</CODE></H2>v 0.7, June '97
+<H2>Paul Blackman, <CODE>ictinus@samba.anu.edu.au</CODE></H2>v 0.8, June '97
<P><HR><EM> This is the Frequently Asked Questions (FAQ) document for
Samba, the free and very popular SMB server product. An SMB server
allows file and printer connections from clients such as Windows,
diff --git a/docs/faq/sambafaq.sgml b/docs/faq/sambafaq.sgml
index 951ad822edb..d306881b56b 100644
--- a/docs/faq/sambafaq.sgml
+++ b/docs/faq/sambafaq.sgml
@@ -9,15 +9,17 @@
9 June 1997 Paul
Lots of changes, added doco list, updated compatible systems list
added NT SP3 entry, added Year 2000 entry, Getting ready for 1.9.17
+ v 0.8 7th Oct 97 Paul
+ changed samba.canberra entries to samba.anu.../samba/
-->
<article>
<title> Samba FAQ
-<author>Paul Blackman, <tt>ictinus@lake.canberra.edu.au</tt>
+<author>Paul Blackman, <tt>ictinus@samba.anu.edu.au</tt>
-<date>v 0.7, June '97
+<date>v 0.8, June '97
<abstract> This is the Frequently Asked Questions (FAQ) document for
Samba, the free and very popular SMB server product. An SMB server
@@ -191,7 +193,7 @@ There are a number of places to look for more information on Samba, including:
<itemize>
<item>Two mailing lists devoted to discussion of Samba-related matters.
<item>The newsgroup, comp.protocols.smb, which has a great deal of discussion on Samba.
-<item>The WWW site 'SAMBA Web Pages' at <url url="http://samba.canberra.edu.au/pub/samba/samba.html"> includes:
+<item>The WWW site 'SAMBA Web Pages' at <url url="http://samba.edu.au/samba/"> includes:
<itemize>
<item>Links to man pages and documentation, including this FAQ
<item>A comprehensive survey of Samba users.
@@ -562,7 +564,8 @@ To syncronize your PC's clock with your Samba server:
<itemize>
<item> Copy timesync.pif to your windows directory
<item> timesync.pif can be found at:
- <url url="http://samba.canberra.edu.au/pub/samba/binaries/miscellaneous/timesync.pif">
+ <url
+url="http://samba.anu.edu.au/samba/binaries/miscellaneous/timesync.pif">
<item> Add timesync.pif to your 'Start Up' group/folder
<item> Open the properties dialog box for the program/icon
<item> Make sure the 'Run Minimized' option is set in program 'Properties'
diff --git a/docs/faq/sambafaq.txt b/docs/faq/sambafaq.txt
index e7f5f32a20d..7108846ae67 100644
--- a/docs/faq/sambafaq.txt
+++ b/docs/faq/sambafaq.txt
@@ -1,6 +1,6 @@
Samba FAQ
- Paul Blackman, ictinus@lake.canberra.edu.au
- v 0.7, June '97
+ Paul Blackman, ictinus@samba.anu.edu.au
+ v 0.8, June '97
This is the Frequently Asked Questions (FAQ) document for Samba, the
free and very popular SMB server product. An SMB server allows file
@@ -92,7 +92,7 @@
5.1. Is Samba Year 2000 compliant?
______________________________________________________________________
- 1. General Information
+ 11.. GGeenneerraall IInnffoorrmmaattiioonn
@@ -101,7 +101,7 @@
details
- 1.1. What is Samba?
+ 11..11.. WWhhaatt iiss SSaammbbaa??
Samba is a suite of programs which work together to allow clients to
@@ -122,30 +122,30 @@
The components of the suite are (in summary):
- o smbd, the SMB server. This handles actual connections from clients,
+ +o ssmmbbdd, the SMB server. This handles actual connections from clients,
doing all the file, permission and username work
- o nmbd, the Netbios name server, which helps clients locate servers,
+ +o nnmmbbdd, the Netbios name server, which helps clients locate servers,
doing the browsing work and managing domains as this capability is
being built into Samba
- o smbclient, the Unix-hosted client program
+ +o ssmmbbcclliieenntt, the Unix-hosted client program
- o smbrun, a little 'glue' program to help the server run external
+ +o ssmmbbrruunn, a little 'glue' program to help the server run external
programs
- o testprns, a program to test server access to printers
+ +o tteessttpprrnnss, a program to test server access to printers
- o testparms, a program to test the Samba configuration file for
+ +o tteessttppaarrmmss, a program to test the Samba configuration file for
correctness
- o smb.conf, the Samba configuration file
+ +o ssmmbb..ccoonnff, the Samba configuration file
- o smbprint, a sample script to allow a Unix host to use smbclient to
+ +o ssmmbbpprriinntt, a sample script to allow a Unix host to use smbclient to
print to an SMB server
- o Documentation! DON'T neglect to read it - you will save a great
+ +o DDooccuummeennttaattiioonn!! DON'T neglect to read it - you will save a great
deal of time!
The suite is supplied with full source (of course!) and is GPLed.
@@ -155,7 +155,7 @@
and this FAQ were originally written by Karl Auer.
- 1.2. What is the current version of Samba?
+ 11..22.. WWhhaatt iiss tthhee ccuurrrreenntt vveerrssiioonn ooff SSaammbbaa??
At time of writing, the current version was 1.9.17. If you want to be
@@ -165,7 +165,7 @@
For more information see ``What do the version numbers mean?''
- 1.3. Where can I get it?
+ 11..33.. WWhheerree ccaann II ggeett iitt??
The Samba suite is available via anonymous ftp from samba.anu.edu.au.
@@ -185,7 +185,7 @@
do contain Samba binaries for that platform.
- 1.4. What do the version numbers mean?
+ 11..44.. WWhhaatt ddoo tthhee vveerrssiioonn nnuummbbeerrss mmeeaann??
It is not recommended that you run a version of Samba with the word
@@ -234,7 +234,7 @@
sion.
- 1.5. What platforms are supported?
+ 11..55.. WWhhaatt ppllaattffoorrmmss aarree ssuuppppoorrtteedd??
Many different platforms have run Samba successfully. The platforms
@@ -242,188 +242,188 @@
At time of writing, the Makefile claimed support for:
- o A/UX 3.0
+ +o A/UX 3.0
- o AIX
+ +o AIX
- o Altos Series 386/1000
+ +o Altos Series 386/1000
- o Amiga
+ +o Amiga
- o Apollo Domain/OS sr10.3
+ +o Apollo Domain/OS sr10.3
- o BSDI
+ +o BSDI
- o B.O.S. (Bull Operating System)
+ +o B.O.S. (Bull Operating System)
- o Cray, Unicos 8.0
+ +o Cray, Unicos 8.0
- o Convex
+ +o Convex
- o DGUX.
+ +o DGUX.
- o DNIX.
+ +o DNIX.
- o FreeBSD
+ +o FreeBSD
- o HP-UX
+ +o HP-UX
- o Intergraph.
+ +o Intergraph.
- o Linux with/without shadow passwords and quota
+ +o Linux with/without shadow passwords and quota
- o LYNX 2.3.0
+ +o LYNX 2.3.0
- o MachTen (a unix like system for Macintoshes)
+ +o MachTen (a unix like system for Macintoshes)
- o Motorola 88xxx/9xx range of machines
+ +o Motorola 88xxx/9xx range of machines
- o NetBSD
+ +o NetBSD
- o NEXTSTEP Release 2.X, 3.0 and greater (including OPENSTEP for
+ +o NEXTSTEP Release 2.X, 3.0 and greater (including OPENSTEP for
Mach).
- o OS/2 using EMX 0.9b
+ +o OS/2 using EMX 0.9b
- o OSF1
+ +o OSF1
- o QNX 4.22
+ +o QNX 4.22
- o RiscIX.
+ +o RiscIX.
- o RISCOs 5.0B
+ +o RISCOs 5.0B
- o SEQUENT.
+ +o SEQUENT.
- o SCO (including: 3.2v2, European dist., OpenServer 5)
+ +o SCO (including: 3.2v2, European dist., OpenServer 5)
- o SGI.
+ +o SGI.
- o SMP_DC.OSx v1.1-94c079 on Pyramid S series
+ +o SMP_DC.OSx v1.1-94c079 on Pyramid S series
- o SONY NEWS, NEWS-OS (4.2.x and 6.1.x)
+ +o SONY NEWS, NEWS-OS (4.2.x and 6.1.x)
- o SUNOS 4
+ +o SUNOS 4
- o SUNOS 5.2, 5.3, and 5.4 (Solaris 2.2, 2.3, and '2.4 and later')
+ +o SUNOS 5.2, 5.3, and 5.4 (Solaris 2.2, 2.3, and '2.4 and later')
- o Sunsoft ISC SVR3V4
+ +o Sunsoft ISC SVR3V4
- o SVR4
+ +o SVR4
- o System V with some berkely extensions (Motorola 88k R32V3.2).
+ +o System V with some berkely extensions (Motorola 88k R32V3.2).
- o ULTRIX.
+ +o ULTRIX.
- o UNIXWARE
+ +o UNIXWARE
- o UXP/DS
+ +o UXP/DS
- 1.6. How can I find out more about Samba?
+ 11..66.. HHooww ccaann II ffiinndd oouutt mmoorree aabboouutt SSaammbbaa??
There are a number of places to look for more information on Samba,
including:
- o Two mailing lists devoted to discussion of Samba-related matters.
+ +o Two mailing lists devoted to discussion of Samba-related matters.
- o The newsgroup, comp.protocols.smb, which has a great deal of
+ +o The newsgroup, comp.protocols.smb, which has a great deal of
discussion on Samba.
- o The WWW site 'SAMBA Web Pages' at
- <http://samba.canberra.edu.au/pub/samba/samba.html> includes:
+ +o The WWW site 'SAMBA Web Pages' at <http://samba.edu.au/samba/>
+ includes:
- o Links to man pages and documentation, including this FAQ
+ +o Links to man pages and documentation, including this FAQ
- o A comprehensive survey of Samba users.
+ +o A comprehensive survey of Samba users.
- o A searchable hypertext archive of the Samba mailing list.
+ +o A searchable hypertext archive of the Samba mailing list.
- o Links to Samba source code, binaries, and mirrors of both.
+ +o Links to Samba source code, binaries, and mirrors of both.
- o The long list of topic documentation. These files can be found in
+ +o The long list of topic documentation. These files can be found in
the 'docs' directory of the Samba source, or at
<ftp://samba.anu.edu.au/pub/samba/docs/>
- o Application_Serving.txt
+ +o Application_Serving.txt
<ftp://samba.anu.edu.au/pub/samba/docs/Application_Serving.txt>
- o BROWSING.txt <ftp://samba.anu.edu.au/pub/samba/docs/BROWSING.txt>
+ +o BROWSING.txt <ftp://samba.anu.edu.au/pub/samba/docs/BROWSING.txt>
- o BUGS.txt <ftp://samba.anu.edu.au/pub/samba/docs/BUGS.txt>
+ +o BUGS.txt <ftp://samba.anu.edu.au/pub/samba/docs/BUGS.txt>
- o DIAGNOSIS.txt <ftp://samba.anu.edu.au/pub/samba/docs/DIAGNOSIS.txt>
+ +o DIAGNOSIS.txt <ftp://samba.anu.edu.au/pub/samba/docs/DIAGNOSIS.txt>
- o DNIX.txt <ftp://samba.anu.edu.au/pub/samba/docs/DNIX.txt>
+ +o DNIX.txt <ftp://samba.anu.edu.au/pub/samba/docs/DNIX.txt>
- o DOMAIN.txt <ftp://samba.anu.edu.au/pub/samba/docs/DOMAIN.txt>
+ +o DOMAIN.txt <ftp://samba.anu.edu.au/pub/samba/docs/DOMAIN.txt>
- o CONTROL.txt
+ +o CONTROL.txt
<ftp://samba.anu.edu.au/pub/samba/docs/DOMAIN_CONTROL.txt>
- o ENCRYPTION.txt
+ +o ENCRYPTION.txt
<ftp://samba.anu.edu.au/pub/samba/docs/ENCRYPTION.txt>
- o Faxing.txt <ftp://samba.anu.edu.au/pub/samba/docs/Faxing.txt>
+ +o Faxing.txt <ftp://samba.anu.edu.au/pub/samba/docs/Faxing.txt>
- o GOTCHAS.txt <ftp://samba.anu.edu.au/pub/samba/docs/GOTCHAS.txt>
+ +o GOTCHAS.txt <ftp://samba.anu.edu.au/pub/samba/docs/GOTCHAS.txt>
- o HINTS.txt <ftp://samba.anu.edu.au/pub/samba/docs/HINTS.txt>
+ +o HINTS.txt <ftp://samba.anu.edu.au/pub/samba/docs/HINTS.txt>
- o INSTALL.sambatar
+ +o INSTALL.sambatar
<ftp://samba.anu.edu.au/pub/samba/docs/INSTALL.sambatar>
- o INSTALL.txt <ftp://samba.anu.edu.au/pub/samba/docs/INSTALL.txt>
+ +o INSTALL.txt <ftp://samba.anu.edu.au/pub/samba/docs/INSTALL.txt>
- o MIRRORS <ftp://samba.anu.edu.au/pub/samba/docs/MIRRORS>
+ +o MIRRORS <ftp://samba.anu.edu.au/pub/samba/docs/MIRRORS>
- o NetBIOS.txt <ftp://samba.anu.edu.au/pub/samba/docs/NetBIOS.txt>
+ +o NetBIOS.txt <ftp://samba.anu.edu.au/pub/samba/docs/NetBIOS.txt>
- o OS2.txt <ftp://samba.anu.edu.au/pub/samba/docs/OS2.txt>
+ +o OS2.txt <ftp://samba.anu.edu.au/pub/samba/docs/OS2.txt>
- o PROJECTS <ftp://samba.anu.edu.au/pub/samba/docs/PROJECTS>
+ +o PROJECTS <ftp://samba.anu.edu.au/pub/samba/docs/PROJECTS>
- o Passwords.txt <ftp://samba.anu.edu.au/pub/samba/docs/Passwords.txt>
+ +o Passwords.txt <ftp://samba.anu.edu.au/pub/samba/docs/Passwords.txt>
- o Printing.txt <ftp://samba.anu.edu.au/pub/samba/docs/Printing.txt>
+ +o Printing.txt <ftp://samba.anu.edu.au/pub/samba/docs/Printing.txt>
- o README.DCEDFS <ftp://samba.anu.edu.au/pub/samba/docs/README.DCEDFS>
+ +o README.DCEDFS <ftp://samba.anu.edu.au/pub/samba/docs/README.DCEDFS>
- o README.OS2 <ftp://samba.anu.edu.au/pub/samba/docs/README.OS2>
+ +o README.OS2 <ftp://samba.anu.edu.au/pub/samba/docs/README.OS2>
- o README.jis <ftp://samba.anu.edu.au/pub/samba/docs/README.jis>
+ +o README.jis <ftp://samba.anu.edu.au/pub/samba/docs/README.jis>
- o README.sambatar
+ +o README.sambatar
<ftp://samba.anu.edu.au/pub/samba/docs/README.sambatar>
- o SCO.txt <ftp://samba.anu.edu.au/pub/samba/docs/SCO.txt>
+ +o SCO.txt <ftp://samba.anu.edu.au/pub/samba/docs/SCO.txt>
- o SMBTAR.notes <ftp://samba.anu.edu.au/pub/samba/docs/SMBTAR.notes>
+ +o SMBTAR.notes <ftp://samba.anu.edu.au/pub/samba/docs/SMBTAR.notes>
- o Speed.txt <ftp://samba.anu.edu.au/pub/samba/docs/Speed.txt>
+ +o Speed.txt <ftp://samba.anu.edu.au/pub/samba/docs/Speed.txt>
- o Support.txt <ftp://samba.anu.edu.au/pub/samba/docs/Support.txt>
+ +o Support.txt <ftp://samba.anu.edu.au/pub/samba/docs/Support.txt>
- o THANKS <ftp://samba.anu.edu.au/pub/samba/docs/THANKS>
+ +o THANKS <ftp://samba.anu.edu.au/pub/samba/docs/THANKS>
- o Tracing.txt <ftp://samba.anu.edu.au/pub/samba/docs/Tracing.txt>
+ +o Tracing.txt <ftp://samba.anu.edu.au/pub/samba/docs/Tracing.txt>
- o SMB.txt <ftp://samba.anu.edu.au/pub/samba/docs/UNIX-SMB.txt>
+ +o SMB.txt <ftp://samba.anu.edu.au/pub/samba/docs/UNIX-SMB.txt>
- o Warp.txt <ftp://samba.anu.edu.au/pub/samba/docs/Warp.txt>
+ +o Warp.txt <ftp://samba.anu.edu.au/pub/samba/docs/Warp.txt>
- o WinNT.txt <ftp://samba.anu.edu.au/pub/samba/docs/WinNT.txt>
+ +o WinNT.txt <ftp://samba.anu.edu.au/pub/samba/docs/WinNT.txt>
- o history <ftp://samba.anu.edu.au/pub/samba/docs/history>
+ +o history <ftp://samba.anu.edu.au/pub/samba/docs/history>
- o level.txt
+ +o level.txt
<ftp://samba.anu.edu.au/pub/samba/docs/security_level.txt>
- o slip.htm <ftp://samba.anu.edu.au/pub/samba/docs/wfw_slip.htm>
+ +o slip.htm <ftp://samba.anu.edu.au/pub/samba/docs/wfw_slip.htm>
- 1.7. How do I subscribe to the Samba Mailing Lists?
+ 11..77.. HHooww ddoo II ssuubbssccrriibbee ttoo tthhee SSaammbbaa MMaaiilliinngg LLiissttss??
Send email to listproc@samba.anu.edu.au. Make sure the subject line is
@@ -456,14 +456,14 @@
- The From: line in your message MUST be the same address you used when
+ The FFrroomm:: line in your message _M_U_S_T be the same address you used when
you subscribed.
- 1.8. Something's gone wrong - what should I do?
+ 11..88.. SSoommeetthhiinngg''ss ggoonnee wwrroonngg -- wwhhaatt sshhoouulldd II ddoo??
- # *** IMPORTANT! *** #
+ ## ****** IIMMPPOORRTTAANNTT!! ****** ##
DO NOT post messages on mailing lists or in newsgroups until you have
carried out the first three steps given here!
@@ -501,7 +501,7 @@
Tridgell or any other individual, they may be lost if you do.
- 1.9. Pizza supply details
+ 11..99.. PPiizzzzaa ssuuppppllyy ddeettaaiillss
Those who have registered in the Samba survey as "Pizza Factory" will
@@ -531,11 +531,11 @@
hungry sniffer dogs but it will have been a noble gesture.
- 2. Compiling and installing Samba on a Unix host
+ 22.. CCoommppiilliinngg aanndd iinnssttaalllliinngg SSaammbbaa oonn aa UUnniixx hhoosstt
- 2.1. I can't see the Samba server in any browse lists!
+ 22..11.. II ccaann''tt sseeee tthhee SSaammbbaa sseerrvveerr iinn aannyy bbrroowwssee lliissttss!!
See BROWSING.txt <ftp://samba.anu.edu.au/pub/samba/BROWSING.txt> for
@@ -557,14 +557,14 @@
client to client - check your client's documentation.
- 2.2. Some files that I KNOW are on the server doesn't show up when I
- view the files from my client!
+ 22..22.. SSoommee ffiilleess tthhaatt II KKNNOOWW aarree oonn tthhee sseerrvveerr ddooeessnn''tt sshhooww uupp wwhheenn II
+ vviieeww tthhee ffiilleess ffrroomm mmyy cclliieenntt!!
See the next question.
- 2.3. Some files on the server show up with really wierd filenames
- when I view the files from my client!
+ 22..33.. SSoommee ffiilleess oonn tthhee sseerrvveerr sshhooww uupp wwiitthh rreeaallllyy wwiieerrdd ffiilleennaammeess
+ wwhheenn II vviieeww tthhee ffiilleess ffrroomm mmyy cclliieenntt!!
If you check what files are not showing up, you will note that they
@@ -579,7 +579,7 @@
"mangled names = yes".
- 2.4. My client reports "cannot locate specified computer" or similar
+ 22..44.. MMyy cclliieenntt rreeppoorrttss ""ccaannnnoott llooccaattee ssppeecciiffiieedd ccoommppuutteerr"" oorr ssiimmiillaarr
This indicates one of three things: You supplied an incorrect server
@@ -610,8 +610,8 @@
tests :-)
- 2.5. My client reports "cannot locate specified share name" or simi-
- lar
+ 22..55.. MMyy cclliieenntt rreeppoorrttss ""ccaannnnoott llooccaattee ssppeecciiffiieedd sshhaarree nnaammee"" oorr ssiimmii--
+ llaarr
This message indicates that your client CAN locate the specified
@@ -624,19 +624,19 @@
to specify a service name correctly), read on:
- o Many clients cannot accept or use service names longer than eight
+ +o Many clients cannot accept or use service names longer than eight
characters.
- o Many clients cannot accept or use service names containing spaces.
+ +o Many clients cannot accept or use service names containing spaces.
- o Some servers (not Samba though) are case sensitive with service
+ +o Some servers (not Samba though) are case sensitive with service
names.
- o Some clients force service names into upper case.
+ +o Some clients force service names into upper case.
- 2.6. My client reports "cannot find domain controller", "cannot log
- on to the network" or similar
+ 22..66.. MMyy cclliieenntt rreeppoorrttss ""ccaannnnoott ffiinndd ddoommaaiinn ccoonnttrroolllleerr"",, ""ccaannnnoott lloogg
+ oonn ttoo tthhee nneettwwoorrkk"" oorr ssiimmiillaarr
Nothing is wrong - Samba does not implement the primary domain name
@@ -658,7 +658,7 @@
- 2.7. Printing doesn't work :-(
+ 22..77.. PPrriinnttiinngg ddooeessnn''tt wwoorrkk ::--((
Make sure that the specified print command for the service you are
@@ -689,8 +689,8 @@
mechanism.
- 2.8. My programs install on the server OK, but refuse to work prop-
- erly
+ 22..88.. MMyy pprrooggrraammss iinnssttaallll oonn tthhee sseerrvveerr OOKK,, bbuutt rreeffuussee ttoo wwoorrkk pprroopp--
+ eerrllyy
There are numerous possible reasons for this, but one MAJOR
@@ -706,7 +706,7 @@
Tridgell know via email at samba-bugs@samba.anu.edu.au.
- 2.9. My "server string" doesn't seem to be recognised
+ 22..99.. MMyy ""sseerrvveerr ssttrriinngg"" ddooeessnn''tt sseeeemm ttoo bbee rreeccooggnniisseedd
OR My client reports the default setting, eg. "Samba 1.9.15p4",
@@ -719,8 +719,8 @@
the "server string" field of smb.conf, -C for nmbd is now obsolete.
- 2.10. My client reports "This server is not configured to list shared
- resources"
+ 22..1100.. MMyy cclliieenntt rreeppoorrttss ""TThhiiss sseerrvveerr iiss nnoott ccoonnffiigguurreedd ttoo lliisstt sshhaarreedd
+ rreessoouurrcceess""
Your guest account is probably invalid for some reason. Samba uses the
@@ -730,7 +730,7 @@
See also 'guest account' in smb.conf man page.
- 2.11. Log message "you appear to have a trapdoor uid system"
+ 22..1111.. LLoogg mmeessssaaggee ""yyoouu aappppeeaarr ttoo hhaavvee aa ttrraappddoooorr uuiidd ssyysstteemm""
This can have several causes. It might be because you are using a uid
@@ -765,12 +765,12 @@
as uid 65535 will actually run as root. This is not good!
- 3. Common client questions
+ 33.. CCoommmmoonn cclliieenntt qquueessttiioonnss
- 3.1. Are there any Macintosh clients for Samba?
+ 33..11.. AArree tthheerree aannyy MMaacciinnttoosshh cclliieennttss ffoorr SSaammbbaa??
Yes! Thursby now have a CIFS Client / Server called DAVE - see
@@ -790,7 +790,7 @@
Windows users, these packages offer to Macs. For more info on these
packages, Samba, and Linux (and other UNIX-based systems) see
<http://www.eats.com/linux_mac_win.html>
- 3.2. Session request failed (131,130)" error
+ 33..22.. SSeessssiioonn rreeqquueesstt ffaaiilleedd ((113311,,113300))"" eerrrroorr
The following answer is provided by John E. Miller:
@@ -819,26 +819,26 @@
you'd have to use smbclient -iSomeStr otherparms in connecting to it.
- 3.3. How do I synchronise my PC's clock with my Samba server?
+ 33..33.. HHooww ddoo II ssyynncchhrroonniissee mmyy PPCC''ss cclloocckk wwiitthh mmyy SSaammbbaa sseerrvveerr??
To syncronize your PC's clock with your Samba server:
- o Copy timesync.pif to your windows directory
+ +o Copy timesync.pif to your windows directory
- o timesync.pif can be found at:
- <http://samba.canberra.edu.au/pub/samba/binaries/miscellaneous/timesync.pif>
+ +o timesync.pif can be found at:
+ <http://samba.anu.edu.au/samba/binaries/miscellaneous/timesync.pif>
- o Add timesync.pif to your 'Start Up' group/folder
+ +o Add timesync.pif to your 'Start Up' group/folder
- o Open the properties dialog box for the program/icon
+ +o Open the properties dialog box for the program/icon
- o Make sure the 'Run Minimized' option is set in program 'Properties'
+ +o Make sure the 'Run Minimized' option is set in program 'Properties'
- o Change the command line section that reads \sambahost to reflect
+ +o Change the command line section that reads \sambahost to reflect
the name of your server.
- o Close the properties dialog box by choosing 'OK'
+ +o Close the properties dialog box by choosing 'OK'
Each time you start your computer (or login for Win95) your PC will
synchronize its clock with your Samba server.
@@ -858,7 +858,7 @@
as one of the lines in the logon script.
- 3.4. Problems with WinDD, NTrigue, WinCenterPro etc
+ 33..44.. PPrroobblleemmss wwiitthh WWiinnDDDD,, NNTTrriigguuee,, WWiinnCCeenntteerrPPrroo eettcc
All of the above programs are applications that sit on an NT box and
@@ -900,7 +900,7 @@
home directory. Use \serversername instead.
- 3.5. Problem with printers under NT
+ 33..55.. PPrroobblleemm wwiitthh pprriinntteerrss uunnddeerr NNTT
This info from Stefan Hergeth hergeth@f7axp1.informatik.fh-muenchen.de
@@ -929,7 +929,7 @@
try it yet.
- 3.6. Why are my file's timestamps off by an hour, or by a few hours?
+ 33..66.. WWhhyy aarree mmyy ffiillee''ss ttiimmeessttaammppss ooffff bbyy aann hhoouurr,, oorr bbyy aa ffeeww hhoouurrss??
This is from Paul Eggert eggert@twinsun.com.
@@ -973,20 +973,20 @@
where:
- o `Std' is the standard time designation (e.g. `PST').
+ +o `Std' is the standard time designation (e.g. `PST').
- o `Offset' is the number of hours behind UTC (e.g. `8'). Prepend
+ +o `Offset' is the number of hours behind UTC (e.g. `8'). Prepend
a `-' if you are ahead of UTC, and append `:30' if you are at a
half-hour offset. Omit all the remaining items if you do not
use daylight-saving time.
- o `Dst' is the daylight-saving time designation (e.g. `PDT').
+ +o `Dst' is the daylight-saving time designation (e.g. `PDT').
The optional second `Offset' is the number of hours that
daylight-saving time is behind UTC. The default is 1 hour ahead
of standard time.
- o `Date/Time,Date/Time' specify when daylight-saving time starts
+ +o `Date/Time,Date/Time' specify when daylight-saving time starts
and ends. The format for a date is `Mm.n.d', which specifies
the dth day (0 is Sunday) of the nth week of the mth month,
where week 5 means the last such day in the month. The format
@@ -1005,7 +1005,7 @@
Samba server to 1.9.16alpha10 or later.
- 3.7. How do I set the printer driver name correctly?
+ 33..77.. HHooww ddoo II sseett tthhee pprriinntteerr ddrriivveerr nnaammee ccoorrrreeccttllyy??
Question: On NT, I opened "Printer Manager" and "Connect to Printer".
@@ -1050,17 +1050,17 @@
this is effectively what older versions of Samba did, so if that
worked for you then give it a go. If this does work then let us know
- via samba-bugs@samba.anu.edu.au, and we'll make it the default. Currently
- the default is a 0 length string.
+ via samba-bugs@samba.anu.edu.au, and we'll make it the default. Cur-
+ rently the default is a 0 length string.
- 3.8. I've applied NT 4.0 SP3, and now I can't access Samba shares,
- Why?
+ 33..88.. II''vvee aapppplliieedd NNTT 44..00 SSPP33,, aanndd nnooww II ccaann''tt aacccceessss SSaammbbaa sshhaarreess,,
+ WWhhyy??
As of SP3, Microsoft has decided that they will no longer default to
passing clear text passwords over the network. To enable access to
- Samba shares from NT 4.0 SP3, you must do ONE of two things:
+ Samba shares from NT 4.0 SP3, you must do OONNEE of two things:
1. Set the Samba configuration option 'security = user' and implement
all of the stuff detailed in ENCRYPTION.txt
@@ -1071,13 +1071,13 @@
<http://www.microsoft.com/kb/articles/q166/7/30.htm>
- 4. Specific client application problems
+ 44.. SSppeecciiffiicc cclliieenntt aapppplliiccaattiioonn pprroobblleemmss
- 4.1. MS Office Setup reports "Cannot change properties of 'MSOF-
- FICEUP.INI'"
+ 44..11.. MMSS OOffffiiccee SSeettuupp rreeppoorrttss ""CCaannnnoott cchhaannggee pprrooppeerrttiieess ooff ''MMSSOOFF--
+ FFIICCEEUUPP..IINNII''""
When installing MS Office on a Samba drive for which you have admin
@@ -1093,11 +1093,11 @@
to fix the owner.
- 5. Miscellaneous
+ 55.. MMiisscceellllaanneeoouuss
- 5.1. Is Samba Year 2000 compliant?
+ 55..11.. IIss SSaammbbaa YYeeaarr 22000000 ccoommpplliiaanntt??
The CIFS protocol that Samba implements negotiates times in various
diff --git a/docs/manpages/nmbd.8 b/docs/manpages/nmbd.8
index 148e53478c2..100cbcc5087 100644
--- a/docs/manpages/nmbd.8
+++ b/docs/manpages/nmbd.8
@@ -1,4 +1,4 @@
-.TH NMBD 8 nmbd nmbd
+.TH NMBD 8 "22 Oct 1997" "nmbd 1.9.17p4"
.SH NAME
nmbd \- provide netbios nameserver support to clients
.SH SYNOPSIS
diff --git a/docs/manpages/samba.7 b/docs/manpages/samba.7
index 7e98c850d41..a15c4a0041e 100644
--- a/docs/manpages/samba.7
+++ b/docs/manpages/samba.7
@@ -1,4 +1,4 @@
-.TH SAMBA 7 Samba Samba
+.TH SAMBA 7 "22 Oct 1997" "samba 1.9.17p4"
.SH NAME
Samba \- a LanManager like fileserver for UNIX
.SH SYNOPSIS
@@ -65,7 +65,7 @@ the mailing list are given in the README file that comes with Samba.
If you have access to a WWW viewer (such as Netscape or Mosaic) then
you will also find lots of useful information, including back issues
-of the Samba mailing list, at http://samba.canberra.edu.au/pub/samba/
+of the Samba mailing list, at http://samba.anu.edu.au/samba/
.SH AUTHOR
The main author of the Samba suite is Andrew Tridgell. He may be
diff --git a/docs/manpages/smb.conf.5 b/docs/manpages/smb.conf.5
index 989a395c159..1bd5ab26cf4 100644
--- a/docs/manpages/smb.conf.5
+++ b/docs/manpages/smb.conf.5
@@ -1,4 +1,4 @@
-.TH SMB.CONF 5 smb.conf smb.conf
+.TH SMB.CONF 5 "22 Oct 1997" "smb.conf 1.9.17p4"
.SH NAME
smb.conf \- configuration file for smbd
.SH SYNOPSIS
@@ -282,9 +282,9 @@ substitutions and other smb.conf options.
.SS NAME MANGLING
-Samba supports "name mangling" so that DOS and Windows clients can use
-files that don't conform to the 8.3 format. It can also be set to adjust
-the case of 8.3 format filenames.
+Samba supports "name mangling" so that older DOS and Windows 3 clients
+can use files that don't conform to the 8.3 format. It can also be set
+to adjust the case of 8.3 format filenames.
There are several options that control the way mangling is performed,
and they are grouped here rather than listed separately. For the
@@ -477,8 +477,6 @@ time server
unix realname
-username level
-
username map
use rhosts
@@ -522,8 +520,6 @@ default case
delete readonly
-delete veto files
-
deny hosts
directory
@@ -534,6 +530,8 @@ directory mode
dont descend
+dos filetimes
+
exec
fake oplocks
@@ -869,9 +867,11 @@ See also : "valid chars".
client code page = 437
.SS comment (S)
-This is a text field that is seen when a client does a net view to
-list what shares are available. It will also be used when browsing is
-fully supported.
+This is a text field that is seen next to a share when a client does a
+net view to list what shares are available.
+
+If you want to set the string that is displayed next to the machine
+name then see the server string command.
.B Default:
No comment string
@@ -1040,34 +1040,6 @@ override this one. Where the lists conflict, the 'allow' list takes precedence.
.B Example:
deny hosts = 150.203.4. badhost.mynet.edu.au
-
-.SS delete veto files (S)
-
-This option is used when Samba is attempting to delete a directory
-that contains one or more vetoed directories (see the 'veto files' option).
-If this option is set to False (the default) then if a vetoed directory
-contains any non-vetoed files or directories then the directory delete
-will fail. This is usually what you want.
-
-If this option is set to True, then Samba will attempt
-to recursively delete any files and directories within the vetoed
-directory. This can be useful for integration with file serving
-systems such as Netatalk, which create meta-files within directories
-you might normally veto DOS/Windows users from seeing (eg. .AppleDouble)
-
-Setting 'delete veto files = True' allows these directories to be
-transparently deleted when the parent directory is deleted (so long
-as the user has permissions to do so).
-
-.B Default:
- delete veto files = False
-
-.B Example:
- delete veto files = True
-
-See
-.B veto files
-
.SS dfree command (G)
The dfree command setting should only be used on systems where a
problem occurs with the internal disk space calculations. This has
@@ -1216,6 +1188,22 @@ descend" entries. For example you may need "./proc" instead of just
.B Example:
dont descend = /proc,/dev
+.SS dos filetimes (S)
+Under DOS and Windows, if a user can write to a file they can change
+the timestamp on it. Under POSIX semantics, only the owner of the file
+or root may change the timestamp. By default, Samba runs with POSIX
+semantics and refuses to change the timestamp on a file if the user
+smbd is acting on behalf of is not the file owner. Setting this option
+to True allows DOS semantics and smbd will change the file timstamp as
+DOS requires. This is a correct implementation of a previous compile-time
+options (UTIME_WORKAROUND) which was broken and is now removed.
+
+.B Default:
+ dos filetimes = False
+
+.B Example:
+ dos filetimes = True
+
.SS encrypt passwords (G)
This boolean controls whether encrypted passwords will be negotiated
@@ -1236,12 +1224,11 @@ only one accessing the file and it will aggressively cache file
data. With some oplock types the client may even cache file open/close
operations. This can give enormous performance benefits.
-Samba does not support opportunistic locks because they are very
-difficult to do under Unix. Samba can fake them, however, by granting
-a oplock whenever a client asks for one. This is controlled using the
-smb.conf option "fake oplocks". If you set "fake oplocks = yes" then
-you are telling the client that it may aggressively cache the file
-data.
+Samba does not support opportunistic locks in this release. Samba can
+fake them, however, by granting a oplock whenever a client asks for
+one. This is controlled using the smb.conf option "fake oplocks". If
+you set "fake oplocks = yes" then you are telling the client that it
+may aggressively cache the file data.
By enabling this option on all read-only shares or shares that you know
will only be accessed from one client at a time you will see a big
@@ -1555,10 +1542,10 @@ A boolean variable that controls whether all printers in the printcap
will be loaded for browsing by default.
.B Default:
- load printers = yes
+ load printers = no
.B Example:
- load printers = no
+ load printers = yes
.SS local master (G)
This option allows the nmbd to become a local master browser on a
@@ -2368,6 +2355,11 @@ If you list several hosts in the "password server" option then smbd
will try each in turn till it finds one that responds. This is useful
in case your primary server goes down.
+If you are using a WindowsNT server as your password server then you
+will have to ensure that your users are able to login from the Samba
+server, as the network logon will appear to come from there rather
+than from the users workstation.
+
.SS path (S)
A synonym for this parameter is 'directory'.
@@ -3202,26 +3194,6 @@ on how this parameter determines access to the services.
username = fred
username = fred, mary, jack, jane, @users, @pcgroup
-.SS username level (G)
-
-This option helps Samba to try and 'guess' at the real UNIX username,
-as many DOS clients send an all-uppercase username. By default Samba
-tries all lowercase, followed by the username with the first letter
-capitalized, and fails if the username is not found on the UNIX machine.
-
-If this parameter is set to non-zero the behaviour changes. This
-parameter is a number that specifies the number of uppercase combinations
-to try whilst trying to determine the UNIX user name. The higher the number
-the more combinations will be tried, but the slower the discovery
-of usernames will be. Use this parameter when you have strange
-usernames on your UNIX machine, such as 'AstrangeUser'.
-
-.B Default:
- username level = 0
-
-.B Example:
- username level = 5
-
.SS username map (G)
This option allows you to to specify a file containing a mapping of
@@ -3258,6 +3230,14 @@ would use
You can have as many mappings as you like in a username map file.
+You can map Windows usernames that have spaces in them by using double
+quotes around the name. For example:
+
+ tridge = "Andrew Tridgell"
+
+would map the windows username "Andrew Tridgell" to the unix username
+tridge.
+
Note that the remapping is applied to all occurrences of
usernames. Thus if you connect to "\e\eserver\efred" and "fred" is
remapped to "mary" then you will actually be connecting to
diff --git a/docs/manpages/smbclient.1 b/docs/manpages/smbclient.1
index af36e4a3763..e8c7c291e37 100644
--- a/docs/manpages/smbclient.1
+++ b/docs/manpages/smbclient.1
@@ -1,4 +1,4 @@
-.TH SMBCLIENT 1 smbclient smbclient
+.TH SMBCLIENT 1 "22 Oct 1997" "smbclient 1.9.17p4"
.SH NAME
smbclient \- ftp-like Lan Manager client program
.SH SYNOPSIS
@@ -257,13 +257,6 @@ If no
is supplied and neither environment variable exists the user name will
be empty.
-If the USER environment variable containts a '%' character, everything
-after that will be treated as a password. This allows you to set the
-environment variable to be
-.B USER=username%password
-so that a password is not passed on the command line (where it may
-be seen by the ps command).
-
If the service you are connecting to requires a password, it can be supplied
using the
.B \-U
diff --git a/docs/manpages/smbd.8 b/docs/manpages/smbd.8
index 434844822a4..8f9aeb54a91 100644
--- a/docs/manpages/smbd.8
+++ b/docs/manpages/smbd.8
@@ -1,4 +1,4 @@
-.TH SMBD 8 smbd smbd
+.TH SMBD 8 "22 Oct 1997" "smbd 1.9.17p4"
.SH NAME
smbd \- provide SMB (aka LanManager) services to clients
.SH SYNOPSIS
@@ -27,11 +27,10 @@ smbd \- provide SMB (aka LanManager) services to clients
This program is part of the Samba suite.
.B smbd
-is a server that can provide most SMB services. The server provides
-filespace and printer services to clients using the SMB protocol. This
-is compatible with the LanManager protocol, and can service LanManager
-clients. These include MSCLIENT 3.0 for DOS, Windows for Workgroups,
-Windows 95, Windows NT, OS/2, DAVE for Macintosh, and smbfs for Linux.
+is a server that can provide most SMB services. The
+server provides filespace and printer services to clients using the SMB
+protocol. This is compatible with the LanManager protocol, and can
+service LanManager clients.
An extensive description of the services that the server can provide is given
in the man page for the configuration file controlling the attributes of those
@@ -51,11 +50,8 @@ of the server for each session. This copy then services all connections made
by the client during that session. When all connections from its client are
are closed, the copy of the server for that client terminates.
-The configuration file, and any files that it includes, are automatically
-reloaded every minute, if they change. You can force a reload by sending a
-SIGHUP to the server. Reloading the configuration file will not affect
-connections to any service that is already established. Either the user
-will have to disconnect from the service, or smbd killed and restarted.
+The configuration file is automatically reloaded if it changes. You
+can force a reload by sending a SIGHUP to the server.
.SH OPTIONS
.B \-D
@@ -78,7 +74,7 @@ new connection. By default, the log files will be appended to.
.I debuglevel
.RS 3
-debuglevel is an integer from 0 to 10.
+debuglevel is an integer from 0 to 5.
The default value if this parameter is not specified is zero.
@@ -142,10 +138,6 @@ user rather than as root, most systems will require you to use a port number
greater than 1024 - ask your system administrator for help if you are in this
situation.
-In order for the server to be useful by most clients, should you configure
-it on a port other than 139, you will require port redirection services
-on port 139, details of which are outlined in rfc1002.txt section 4.3.5.
-
This parameter is not normally specified except in the above situation.
.RE
@@ -382,8 +374,8 @@ To properly test and experiment with the server, we recommend using the
smbclient program (see
.BR smbclient (1)).
.SH VERSION
-This man page is (mostly) correct for version 1.9.00 of the Samba suite,
-plus some of the recent patches to it. These notes will necessarily lag behind
+This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some
+of the recent patches to it. These notes will necessarily lag behind
development of the software, so it is possible that your version of
the server has extensions or parameter semantics that differ from or are not
covered by this man page. Please notify these to the address below for
@@ -396,8 +388,6 @@ rectification.
.BR smbclient (1),
.BR testparm (1),
.BR testprns (1)
-.BR rfc1001.txt
-.BR rfc1002.txt
.SH DIAGNOSTICS
[This section under construction]
diff --git a/docs/manpages/smbpasswd.8 b/docs/manpages/smbpasswd.8
index 176534b04f6..ff4c10a721a 100644
--- a/docs/manpages/smbpasswd.8
+++ b/docs/manpages/smbpasswd.8
@@ -1,4 +1,4 @@
-.TH SMBPASSWD 1 smbpasswd smbpasswd
+.TH SMBPASSWD 8 "22 Oct 1997" "smbpasswd 1.9.17p4"
.SH NAME
smbpasswd \- change a users smb password in the smbpasswd file.
.SH SYNOPSIS
diff --git a/docs/manpages/smbrun.1 b/docs/manpages/smbrun.1
index bc265ebf7f5..194ef45457f 100644
--- a/docs/manpages/smbrun.1
+++ b/docs/manpages/smbrun.1
@@ -1,4 +1,4 @@
-.TH SMBRUN 1 smbrun smbrun
+.TH SMBRUN 1 "22 Oct 1997" "smbrun 1.9.17p4"
.SH NAME
smbrun \- interface program between smbd and external programs
.SH SYNOPSIS
diff --git a/docs/manpages/smbstatus.1 b/docs/manpages/smbstatus.1
index e59f815b78b..c28f7282611 100644
--- a/docs/manpages/smbstatus.1
+++ b/docs/manpages/smbstatus.1
@@ -1,4 +1,4 @@
-.TH SMBSTATUS 1 smbstatus smbstatus
+.TH SMBSTATUS 1 "22 Oct 1997" "smbstatus 1.9.17p4"
.SH NAME
smbstatus \- report on current Samba connections
.SH SYNOPSIS
diff --git a/docs/manpages/smbtar.1 b/docs/manpages/smbtar.1
index a03b8a6a668..b21af230962 100644
--- a/docs/manpages/smbtar.1
+++ b/docs/manpages/smbtar.1
@@ -1,4 +1,4 @@
-.TH SMBTAR 1 smbtar smbtar
+.TH SMBTAR 1 "22 Oct 1997" "smbtar 1.9.17p4"
.SH NAME
smbtar \- shell script for backing up SMB shares directly to UNIX tape drive
.SH SYNOPSIS
diff --git a/docs/manpages/testparm.1 b/docs/manpages/testparm.1
index 0b6e6e84c0b..812d417ead8 100644
--- a/docs/manpages/testparm.1
+++ b/docs/manpages/testparm.1
@@ -1,4 +1,4 @@
-.TH TESTPARM 1 testparm testparm
+.TH TESTPARM 1 "22 Oct 1997" "testparm 1.9.17p4"
.SH NAME
testparm \- check an smbd configuration file for internal correctness
.SH SYNOPSIS
diff --git a/docs/manpages/testprns.1 b/docs/manpages/testprns.1
index 9819a679d84..bc0744d14c7 100644
--- a/docs/manpages/testprns.1
+++ b/docs/manpages/testprns.1
@@ -1,4 +1,4 @@
-.TH TESTPRNS 1 testprns testprns
+.TH TESTPRNS 1 "22 Oct 1997" "testprns 1.9.17p4"
.SH NAME
testprns \- check printer name for validity with smbd
.SH SYNOPSIS
diff --git a/docs/samba.faq b/docs/samba.faq
deleted file mode 100644
index 19126439500..00000000000
--- a/docs/samba.faq
+++ /dev/null
@@ -1,900 +0,0 @@
-
- Frequently Asked Questions
-
- about the
-
- SAMBA Suite
-
- (FAQ version 1.9.15a, Samba version 1.09.15)
-
--------------------------------------------------------------------------------
-
-This FAQ was originally prepared by Karl Auer and is
-currently maintained by Paul Blackman (ictinus@lake.canberra.edu.au).
-
-As Karl originally said, 'this FAQ was prepared with lots of help from numerous
-net.helpers', and that's the way I'd like to keep it. So if you find anything
-that you think should be in here don't hesitate to contact me.
-
-Thanks to Karl for the work he's done, and continuing thanks to Andrew Tridgell
-for developing Samba.
-
-Note: This FAQ is (and probably always will be) under construction. Some
-sections exist only as optimistic entries in the Contents page.
-
--------------------------------------------------------------------------------
-
-Contents
-
- * SECTION ONE: General information
- All about Samba - what it is, how to get it, related sources of
- information, how to understand the version numbering scheme,
- pizza details
- * SECTION TWO: Compiling and installing Samba on a Unix host
- Common problems that arise when building and installing Samba under
- Unix.
- * SECTION THREE: Common client problems
- Common problems that arise when trying to communicate from a client
- computer to a Samba server. All problems which have symptoms you see
- at the client end will be in this section.
- * SECTION FOUR: Specific client problems
- This section covers problems that are specific to certain clients,
- such as Windows for Workgroups or Windows NT. Please check Section
- Three first!
- * SECTION FIVE: Specific client application problems
- This section covers problems that are specific to certain products,
- such as Windows for Workgroups or Windows NT. Please check Sections
- Three and Four first!
- * SECTION SIX: Miscellaneous
- All the questions that aren't classifiable into any other section.
-
-
-===============================================================================
-SECTION ONE: General information
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: What is Samba?
-
-Samba is a suite of programs which work together to allow clients to access
-to a server's filespace and printers via the SMB (Session Message Block)
-protocol. Initially written for Unix, Samba now also runs on Netware, OS/2 and
-AmigaDOS.
-
-In practice, this means that you can redirect disks and printers to Unix disks
-and printers from Lan Manager clients, Windows for Workgroups 3.11 clients,
-Windows NT clients, Linux clients and OS/2 clients. There is also a generic
-Unix client program supplied as part of the suite which allows Unix users to
-use an ftp-like interface to access filespace and printers on any other SMB
-servers. This gives the capability for these operating systems to behave much
-like a LAN Server or Windows NT Server machine, only with added functionality
-and flexibility designed to make life easier for administrators.
-
-The components of the suite are (in summary):
-
- * smbd, the SMB server. This handles actual connections from clients,
- doing all the file, permission and username work
- * nmbd, the Netbios name server, which helps clients locate servers,
- doing the browsing work and managing domains as this capability is
- being built into Samba
- * smbclient, the Unix-hosted client program
- * smbrun, a little 'glue' program to help the server run external
- programs
- * testprns, a program to test server access to printers
- * testparms, a program to test the Samba configuration file for
- correctness
- * smb.conf, the Samba configuration file
- * smbprint, a sample script to allow a Unix host to use smbclient to
- print to an SMB server
- * documentation! DON'T neglect to read it - you will save a great deal
- of time!
-
-The suite is supplied with full source (of course!) and is GPLed.
-
-The primary creator of the Samba suite is Andrew Tridgell. Later versions
-incorporate much effort by many net.helpers. The man pages and this FAQ were
-originally written by Karl Auer.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 2: What is the current version of Samba?
-
-At time of writing, the current version was 1.9.16. If you want to be sure
-check the bottom of the change-log file.
-(ftp://samba.anu.edu.au/pub/samba/alpha/change-log)
-
-For more information see question 5, "What do the version numbers mean?"
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 3: Where can I get it?
-
-The Samba suite is available via anonymous ftp from samba.anu.edu.au. The
-latest and greatest versions of the suite are in the directory:
-
-/pub/samba/
-
-Development (read "alpha") versions, which are NOT necessarily stable and which
-do NOT necessarily have accurate documentation, are available in the directory:
-
-/pub/samba/alpha
-
-Note that binaries are NOT included in any of the above. Samba is distributed
-ONLY in source form, though binaries may be available from other sites. Recent
-versions of some Linux distributions, for example, do contain Samba binaries
-for that platform.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: What do the version numbers mean?
-
-It is not recommended that you run a version of Samba with the word "alpha"
-in its name unless you know what you are doing and are willing to do some
-debugging. Many, many people just get the latest recommended stable release
-version and are happy. If you are brave, by all means take the plunge and
-help with the testing and development - but don't install it on your
-departmental server. Samba is typically very stable and safe, and this is
-mostly due to the policy of many public releases.
-
-How the scheme works:
-
-1) when major changes are made the version number is increased. For example,
-the transition from 1.9.15 to 1.9.16. However, this version number will not
-appear immediately and people should continue to use 1.9.15 for production
-systems (see next point.)
-
-2) just after major changes are made the software is considered
-unstable, and a series of alpha releases are distributed, for example
-1.9.16alpha1. These are for testing by those who know what they are doing.
-The "alpha" in the filename will hopefully scare off those who are just
-looking for the latest version to install.
-
-3) when Andrew thinks that the alphas have stabilised to the point where he
-would recommend new users install it, he renames it to the same version
-number without the alpha, for example 1.9.16.
-
-4) inevitably bugs are found in the "stable" releases and minor
-patch levels are released which give us the pXX series, for example
-1.9.16p2.
-
-So the progression goes:
-
- 1.9.15p7 (production)
- 1.9.15p8 (production)
- 1.9.16alpha1 (test sites only)
- :
- 1.9.16alpha20 (test sites only)
- 1.9.16 (production)
- 1.9.16p1 (production)
-
-The above system means that whenever someone looks at the samba ftp site
-they will be able to grab the highest numbered release without an
-alpha in the name and be sure of getting the current recommended
-version.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 4: What platforms are supported?
-
-Many different platforms have run Samba successfully. The platforms most widely
-used and thus best tested are Linux and SunOS.
-
-At time of writing, the Makefile claimed support for:
-
- * SunOS
- * Linux with shadow passwords
- * Linux without shadow passwords
- * SOLARIS
- * SOLARIS 2.2 and above (aka SunOS 5)
- * SVR4
- * ULTRIX
- * OSF1 (alpha only)
- * OSF1 with NIS and Fast Crypt (alpha only)
- * OSF1 V2.0 Enhanced Security (alpha only)
- * AIX
- * BSDI
- * NetBSD
- * NetBSD 1.0
- * SEQUENT
- * HP-UX
- * SGI
- * SGI IRIX 4.x.x
- * SGI IRIX 5.x.x
- * FreeBSD
- * NeXT 3.2 and above
- * NeXT OS 2.x
- * NeXT OS 3.0
- * ISC SVR3V4 (POSIX mode)
- * ISC SVR3V4 (iBCS2 mode)
- * A/UX 3.0
- * SCO with shadow passwords.
- * SCO with shadow passwords, without YP.
- * SCO with TCB passwords
- * SCO 3.2v2 (ODT 1.1) with TCP passwords
- * intergraph
- * DGUX
- * Apollo Domain/OS sr10.3 (BSD4.3)
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: How can I find out more about Samba?
-
-There are two mailing lists devoted to discussion of Samba-related matters.
-There is also the newsgroup, comp.protocols.smb, which has a great deal of
-discussion on Samba. There is also a WWW site 'SAMBA Web Pages' at
-http://samba.canberra.edu.au/pub/samba/samba.html, under which there is a
-comprehensive survey of Samba users. Another useful resource is the hypertext
-archive of the Samba mailing list.
-
-Send email to listproc@samba.anu.edu.au. Make sure the subject line is
-blank, and include the following two lines in the body of the message:
-
- subscribe samba Firstname Lastname
- subscribe samba-announce Firstname Lastname
-
-Obviously you should substitute YOUR first name for "Firstname" and YOUR last
-name for "Lastname"! Try not to send any signature stuff, it sometimes confuses
-the list processor.
-
-The samba list is a digest list - every eight hours or so it regurgitates a
-single message containing all the messages that have been received by the list
-since the last time and sends a copy of this message to all subscribers.
-
-If you stop being interested in Samba, please send another email to
-listproc@samba.anu.edu.au. Make sure the subject line is blank, and
-include the following two lines in the body of the message:
-
- unsubscribe samba
- unsubscribe samba-announce
-
-The From: line in your message MUST be the same address you used when you
-subscribed.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 6: Something's gone wrong - what should I do?
-
-[#] *** IMPORTANT! *** [#]
-DO NOT post messages on mailing lists or in newsgroups until you have carried
-out the first three steps given here!
-
-Firstly, see if there are any likely looking entries in this FAQ! If you have
-just installed Samba, have you run through the checklist in DIAGNOSIS.txt? It
-can save you a lot of time and effort.
-
-Secondly, read the man pages for smbd, nmbd and smb.conf, looking for topics
-that relate to what you are trying to do.
-
-Thirdly, if there is no obvious solution to hand, try to get a look at the log
-files for smbd and/or nmbd for the period during which you were having
-problems. You may need to reconfigure the servers to provide more extensive
-debugging information - usually level 2 or level 3 provide ample debugging
-info. Inspect these logs closely, looking particularly for the string "Error:".
-
-Fourthly, if you still haven't got anywhere, ask the mailing list or newsgroup.
-In general nobody minds answering questions provided you have followed the
-preceding steps. It might be a good idea to scan the archives of the mailing
-list, which are available through the Samba web site described in the previous
-section.
-
-If you successfully solve a problem, please mail the FAQ maintainer a succinct
-description of the symptom, the problem and the solution, so I can incorporate
-it in the next version.
-
-If you make changes to the source code, _please_ submit these patches so that
-everyone else gets the benefit of your work. This is one of the most important
-aspects to the maintainence of Samba. Send all patches to
-samba-bugs@samba.anu.edu.au, not Andrew Tridgell or any other individual and
-not the samba team mailing list.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* n: Pizza Supply Details
-
-Those who have registered in the Samba survey as "Pizza Factory" will already
-know this, but the rest may need some help. Andrew doesn't ask for payment,
-but he does appreciate it when people give him pizza. This calls for a little
-organisation when the pizza donor is twenty thousand kilometres away, but
-it has been done.
-
-Method 1: Ring up your local branch of an international pizza chain and see if
-they honour their vouchers internationally. Pizza Hut do, which is how the
-entire Canberra Linux Users Group got to eat pizza one night, courtesy of
-someone in the US
-
-Method 2: Ring up a local pizza shop in Canberra and quote a credit card
-number for a certain amount, and tell them that Andrew will be collecting
-it (don't forget to tell him.) One kind soul from Germany did this.
-
-Method 3: Purchase a pizza voucher from your local pizza shop that has no
-international affiliations and send it to Andrew. It is completely useless
-but he can hang it on the wall next to the one he already has from Germany :-)
-
-Method 4: Air freight him a pizza with your favourite regional flavours. It will
-probably get stuck in customs or torn apart by hungry sniffer dogs but it will
-have been a noble gesture.
-
-===============================================================================
-SECTION TWO: Compiling and installing Samba on a Unix host
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-===============================================================================
-SECTION THREE: Common client problems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: I can't see the Samba server in any browse lists!
-
-*** Until the FAQ can be updated, please check the file:
-*** ftp://samba.anu.edu.au/pub/samba/docs/BROWSING.txt
-*** for more information on browsing.
-
-If your GUI client does not permit you to select non-browsable servers, you may
-need to do so on the command line. For example, under Lan Manager you might
-connect to the above service as disk drive M: thusly:
-
- net use M: \\mary\fred
-
-The details of how to do this and the specific syntax varies from client to
-client - check your client's documentation.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 2: Some files that I KNOW are on the server doesn't show up when I view the
- directories from my client!
-
-If you check what files are not showing up, you will note that they are files
-which contain upper case letters or which are otherwise not DOS-compatible (ie,
-they are not legal DOS filenames for some reason).
-
-The Samba server can be configured either to ignore such files completely, or
-to present them to the client in "mangled" form. If you are not seeing the
-files at all, the Samba server has most likely been configured to ignore them.
-Consult the man page smb.conf(5) for details of how to change this - the
-parameter you need to set is "mangled names = yes".
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 3: Some files on the server show up with really wierd filenames when I view
-the directories from my client!
-
-If you check what files are showing up wierd, you will note that they are files
-which contain upper case letters or which are otherwise not DOS-compatible (ie,
-they are not legal DOS filenames for some reason).
-
-The Samba server can be configured either to ignore such files completely, or
-to present them to the client in "mangled" form. If you are seeing strange file
-names, they are most likely "mangled". If you would prefer to have such files
-ignored rather than presented in "mangled" form, consult the man page
-smb.conf(5) for details of how to change the server configuration - the
-parameter you need to set is "mangled names = no".
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 4: My client reports "cannot locate specified computer" or similar.
-
-This indicates one of three things: You supplied an incorrect server name, the
-underlying TCP/IP layer is not working correctly, or the name you specified
-cannot be resolved.
-
-After carefully checking that the name you typed is the name you should have
-typed, try doing things like pinging a host or telnetting to somewhere on your
-network to see if TCP/IP is functioning OK. If it is, the problem is most
-likely name resolution.
-
-If your client has a facility to do so, hardcode a mapping between the hosts IP
-and the name you want to use. For example, with Man Manager or Windows for
-Workgroups you would put a suitable entry in the file LMHOSTS. If this works,
-the problem is in the communication between your client and the netbios name
-server. If it does not work, then there is something fundamental wrong with
-your naming and the solution is beyond the scope of this document.
-
-If you do not have any server on your subnet supplying netbios name resolution,
-hardcoded mappings are your only option. If you DO have a netbios name server
-running (such as the Samba suite's nmbd program), the problem probably lies in
-the way it is set up. Refer to Section Two of this FAQ for more ideas.
-
-By the way, remember to REMOVE the hardcoded mapping before further tests :-)
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: My client reports "cannot locate specified share name" or similar.
-
-This message indicates that your client CAN locate the specified server, which
-is a good start, but that it cannot find a service of the name you gave.
-
-The first step is to check the exact name of the service you are trying to
-connect to (consult your system administrator). Assuming it exists and you
-specified it correctly (read your client's doco on how to specify a service
-name correctly), read on:
-
- * Many clients cannot accept or use service names longer than eight
- characters.
- * Many clients cannot accept or use service names containing spaces.
- * Some servers (not Samba though) are case sensitive with service names.
- * Some clients force service names into upper case.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 6: My client reports "cannot find domain controller", "cannot log on to the
-network" or similar.
-
-Nothing is wrong - Samba does not implement the primary domain name controller
-stuff for several reasons, including the fact that the whole concept of a
-primary domain controller and "logging in to a network" doesn't fit well with
-clients possibly running on multiuser machines (such as users of smbclient
-under Unix). Having said that, several developers are working hard on
-building it in to the next major version of Samba. If you can contribute,
-send a message to samba-bugs!
-
-Seeing this message should not affect your ability to mount redirected disks
-and printers, which is really what all this is about.
-
-For many clients (including Windows for Workgroups and Lan Manager), setting
-the domain to STANDALONE at least gets rid of the message.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 7: Printing doesn't work :-(
-
-Make sure that the specified print command for the service you are connecting
-to is correct and that it has a fully-qualified path (eg., use "/usr/bin/lpr"
-rather than just "lpr").
-
-Make sure that the spool directory specified for the service is writable by the
-user connected to the service. In particular the user "nobody" often has
-problems with printing, even if it worked with an earlier version of Samba. Try
-creating another guest user other than "nobody".
-
-Make sure that the user specified in the service is permitted to use the
-printer.
-
-Check the debug log produced by smbd. Search for the printer name and see if
-the log turns up any clues. Note that error messages to do with a service ipc$
-are meaningless - they relate to the way the client attempts to retrieve status
-information when using the LANMAN1 protocol.
-
-If using WfWg then you need to set the default protocol to TCP/IP, not Netbeui.
-This is a WfWg bug.
-
-If using the Lanman1 protocol (the default) then try switching to coreplus.
-Also not that print status error messages don't mean printing won't work. The
-print status is received by a different mechanism.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 8: My programs install on the server OK, but refuse to work properly.
-
-There are numerous possible reasons for this, but one MAJOR possibility is that
-your software uses locking. Make sure you are using Samba 1.6.11 or later. It
-may also be possible to work around the problem by setting "locking=no" in the
-Samba configuration file for the service the software is installed on. This
-should be regarded as a strictly temporary solution.
-
-In earlier Samba versions there were some difficulties with the very latest
-Microsoft products, particularly Excel 5 and Word for Windows 6. These should
-have all been solved. If not then please let Andrew Tridgell know.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 9: My "server string" doesn't seem to be recognized, my client reports the
- default setting, eg. "Samba 1.9.15p4", instead of what I have changed it
- to in the smb.conf file.
-
-You need to use the -C option in nmbd. The "server string" affects
-what smbd puts out and -C affects what nmbd puts out. In a future
-version these will probably be combined and -C will be removed, but
-for now use -C
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 10: When I attempt to get a listing of available resources from the Samba
- server, my client reports
- "This server is not configured to list shared resources".
-
-Your guest account is probably invalid for some reason. Samba uses
-the guest account for browsing in smbd. Check that your guest account is
-valid.
-
-See also 'guest account' in smb.conf man page.
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 11: You get the message "you appear to have a trapdoor uid system"
- in your logs
-
-This can have several causes. It might be because you are using a uid
-or gid of 65535 or -1. This is a VERY bad idea, and is a big security
-hole. Check carefully in your /etc/passwd file and make sure that no
-user has uid 65535 or -1. Especially check the "nobody" user, as many
-broken systems are shipped with nobody setup with a uid of 65535.
-
-It might also mean that your OS has a trapdoor uid/gid system :-)
-
-This means that once a process changes effective uid from root to
-another user it can't go back to root. Unfortunately Samba relies on
-being able to change effective uid from root to non-root and back
-again to implement its security policy. If your OS has a trapdoor uid
-system this won't work, and several things in Samba may break. Less
-things will break if you use user or server level security instead of
-the default share level security, but you may still strike
-problems.
-
-The problems don't give rise to any security holes, so don't panic,
-but it does mean some of Samba's capabilities will be unavailable.
-In particular you will not be able to connect to the Samba server as
-two different uids at once. This may happen if you try to print as a
-"guest" while accessing a share as a normal user. It may also affect
-your ability to list the available shares as this is normally done as
-the guest user.
-
-Complain to your OS vendor and ask them to fix their system.
-
-Note: the reason why 65535 is a VERY bad choice of uid and gid is that
-it casts to -1 as a uid, and the setreuid() system call ignores (with
-no error) uid changes to -1. This means any daemon attempting to run
-as uid 65535 will actually run as root. This is not good!
-
-===============================================================================
-SECTION FOUR: Specific client problems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: Are any MacIntosh clients for Samba.
-
-Yes. Thursby Software Systems have released 'Dave' - a SMB client for
-MacIntosh systems. This is a commercial product and inclusion in this
-faq does not imply any endorsement by the Samba developers. Having said
-that, the first public demonstration of 'Dave' was to the Samba server
-run by Andrew Tridgell over the Internet from Redmond, Washington, USA to
-Australia as part of the first CIFS developers conference.
-
-For more details on 'Dave' contact :
-
-Web contact: www.thursby.com
-
-Thursby Software Systems, Inc.
-5840 W. Interstate 20
-Arlington, Texas 76017 U.S.A.
-Voice: 817-478-5070
-FAX: 817-561-2313
-sales@thursby.com
-
-There are currently no Free Software solutions other than to make
-your UNIX server talk AppleTalk.
-
-In Rob Newberry's words (rob@eats.com, Sun, 4 Dec 1994):
-
-In future Apple System Software, you may see support for other protocols, such
-as SMB -- Applet is working on a new networking architecture that will make it
-easier to support additional protocols. But it's not here yet.
-
-If you want your Unix machine to speak Appletalk, there are several options.
-"Netatalk" and "CAP" are free, and available on the net. There are also
-several commercial options, such as "PacerShare" and "Helios" (I think).
-In any case, you'll have to look around for a server, not anything for the Mac.
-
-Depending on your OS, some of these may not help you. I am currently
-coordinating the effort to get CAP working with Native Ethertalk under Linux,
-but we're not done yet.
-
-Rob
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 2: I am getting a "Session request failed (131,130)" error when I try to
- connect to my Win95 PC with smbclient. I am able to connect from the PC
- to the Samba server without problems. What gives?
-
-The following answer is provided by John E. Miller:
-
-I'll assume that you're able to ping back and forth between the machines by
-IP address and name, and that you're using some security model where you're
-confident that you've got user IDs and passwords right. The logging options
-(-d3 or greater) can help a lot with that. DNS and WINS configuration can
-also impact connectivity as well.
-
-Now, on to 'scope id's. Somewhere in your Win95 TCP/IP network configuration
-(I'm too much of an NT bigot to know where it's located in the Win95 setup,
-but I'll have to learn someday since I teach for a Microsoft Solution Provider
-Authorized Tech Education Center - what an acronym...) [Note: It's under
-Control Panel | Network | TCP/IP | WINS Configuration] there's a little text
-entry field called something like 'Scope ID'.
-
-This field essentially creates 'invisible' sub-workgroups on the same wire.
-Boxes can only see other boxes whose Scope IDs are set to the exact same
-value - it's sometimes used by OEMs to configure their boxes to browse only
-other boxes from the same vendor and, in most environments, this field should
-be left blank. If you, in fact, have something in this box that EXACT value
-(case-sensitive!) needs to be provided to smbclient and nmbd as the -i
-(lowercase) parameter. So, if your Scope ID is configured as the string
-'SomeStr' in Win95 then you'd have to use smbclient -iSomeStr <otherparms>
-in connecting to it.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 3: How do I synchronize my PC's clock with my Samba server?
-
-To syncronize your PC's clock with your Samba server:
-
-* Copy timesync.pif to your windows directory
- * timesync.pif can be found at:
- http://samba.canberra.edu.au/pub/samba/binaries/miscellaneous/timesync.pif
-* Add timesync.pif to your 'Start Up' group/folder
-* Open the properties dialog box for the program/icon
- * Make sure the 'Run Minimized' option is set in program 'Properties'
- * Change the command line section that reads \\sambahost to reflect the name
- of your server.
-* Close the properties dialog box by choosing 'OK'
-
-Each time you start your computer (or login for Win95) your PC will
-synchronize its clock with your Samba server.
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 4: Problems with WinDD, NTrigue, WinCenterPro etc
-
-All of the above programs are applications that sit on an NT box and
-allow multiple users to access the NT GUI applications from remote
-workstations (often over X).
-
-What has this got to do with Samba? The problem comes when these users
-use filemanager to mount shares from a Samba server. The most common
-symptom is that the first user to connect get correct file permissions
-and has a nice day, but subsequent connections get logged in as the
-same user as the first person to login. They find that they cannot
-access files in their own home directory, but that they can access
-files in the first users home directory (maybe not such a nice day
-after all?)
-
-Why does this happen? The above products all share a common heritage
-(and code base I believe). They all open just a single TCP based SMB
-connection to the Samba server, and requests from all users are piped
-over this connection. This is unfortunate, but not fatal.
-
-It means that if you run your Samba server in share level security
-(the default) then things will definately break as described above. The
-share level SMB security model has no provision for multiple user IDs
-on the one SMB connection. See security_level.txt in the docs for more
-info on share/user/server level security.
-
-If you run in user or server level security then you have a chance,
-but only if you have a recent version of Samba (at least 1.9.15p6). In
-older versions bugs in Samba meant you still would have had problems.
-
-If you have a trapdoor uid system in your OS then it will never work
-properly. Samba needs to be able to switch uids on the connection and
-it can't if your OS has a trapdoor uid system. You'll know this
-because Samba will note it in your logs.
-
-Also note that you should not use the magic "homes" share name with
-products like these, as otherwise all users will end up with the same
-home directory. Use \\server\username instead.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: Problem with printers under NT
-
-This info from Stefan Hergeth may be useful:
-
- A network-printer (with ethernetcard) is connected to the NT-Clients via
- our UNIX-Fileserver (SAMBA-Server), like the configuration told by
- Matthew Harrell <harrell@leech.nrl.navy.mil> (see WinNT.txt)
-
- 1.) If a user has choosen this printer as the default printer in his
- NT-Session and this printer is not connected to the network
- (e.g. switched off) than this user has a problem with the SAMBA-
- connection of his filesystems. It's very slow.
-
- 2.) If the printer is connected to the network everything works fine.
-
- 3.) When the smbd ist started with debug level 3, you can see that the
- NT spooling system try to connect to the printer many times. If the
- printer ist not connected to the network this request fails and the
- NT spooler is wasting a lot of time to connect to the printer service.
- This seems to be the reason for the slow network connection.
-
- 4.) Maybe it's possible to change this behaviour by setting different printer
- properties in the Print-Manager-Menu of NT, but i didn't try it
- yet.
-
- I hope this information will help in some way.
-
- Stefan Hergeth <hergeth@f7axp1.informatik.fh-muenchen.de>
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 6: Why are my file's timestamps off by an hour, or by a few hours?
-
-This is from Paul Eggert <eggert@twinsun.com>.
-
-Most likely it's a problem with your time zone settings.
-
-Internally, Samba maintains time in traditional Unix format,
-namely, the number of seconds since 1970-01-01 00:00:00 Universal Time
-(or ``GMT''), not counting leap seconds.
-
-On the server side, Samba uses the Unix TZ variable to convert internal
-timestamps to and from local time. So on the server side, there are two
-things to get right.
-
- 1. The Unix system clock must have the correct Universal time.
- Use the shell command "sh -c 'TZ=UTC0 date'" to check this.
-
- 2. The TZ environment variable must be set on the server
- before Samba is invoked. The details of this depend on the
- server OS, but typically you must edit a file whose name is
- /etc/TIMEZONE or /etc/default/init, or run the command `zic -l'.
-
- 3. TZ must have the correct value.
-
- 3a. If possible, use geographical time zone settings
- (e.g. TZ='America/Los_Angeles' or perhaps
- TZ=':US/Pacific'). These are supported by most
- popular Unix OSes, are easier to get right, and are
- more accurate for historical timestamps. If your
- operating system has out-of-date tables, you should be
- able to update them from the public domain time zone
- tables at <URL:ftp://elsie.nci.nih.gov/pub/>.
-
- 3b. If your system does not support geographical time zone
- settings, you must use a Posix-style TZ strings, e.g.
- TZ='PST8PDT,M4.1.0/2,M10.5.0/2' for US Pacific time.
- Posix TZ strings can take the following form (with optional
- items in brackets):
-
- StdOffset[Dst[Offset],Date/Time,Date/Time]
-
- where:
-
- `Std' is the standard time designation (e.g. `PST').
-
- `Offset' is the number of hours behind UTC (e.g. `8').
- Prepend a `-' if you are ahead of UTC, and
- append `:30' if you are at a half-hour offset.
- Omit all the remaining items if you do not use
- daylight-saving time.
-
- `Dst' is the daylight-saving time designation
- (e.g. `PDT').
-
- The optional second `Offset' is the number of
- hours that daylight-saving time is behind UTC.
- The default is 1 hour ahead of standard time.
-
- `Date/Time,Date/Time' specify when daylight-saving
- time starts and ends. The format for a date is
- `Mm.n.d', which specifies the dth day (0 is Sunday)
- of the nth week of the mth month, where week 5 means
- the last such day in the month. The format for a
- time is [h]h[:mm[:ss]], using a 24-hour clock.
-
- Other Posix string formats are allowed but you don't want
- to know about them.
-
-On the client side, you must make sure that your client's clock and
-time zone is also set appropriately. [[I don't know how to do this.]]
-
-Samba traditionally has had many problems dealing with time zones, due
-to the bizarre ways that Microsoft network protocols handle time
-zones. A common symptom is for file timestamps to be off by an hour.
-To work around the problem, try disconnecting from your Samba server
-and then reconnecting to it; or upgrade your Samba server to
-1.9.16alpha10 or later.
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 7: How do I set the printer driver name correctly?
-
-Question:
-> On NT, I opened "Printer Manager" and "Connect to Printer".
-> Enter "\\ptdi270\ps1" in the box of printer. I got the
-> following error message:
->
-> You do not have sufficient access to your machine
-> to connect to the selected printer, since a driver
-> needs to be installed locally.
-
-Answer:
-
-In the more recent versions of Samba you can now set the "printer
-driver" in smb.conf. This tells the client what driver to use. For
-example, I have:
-
- printer driver = HP LaserJet 4L
-
-and NT knows to use the right driver. You have to get this string
-exactly right.
-
-To find the exact string to use, you need to get to the dialog box in
-your client where you select which printer driver to install. The
-correct strings for all the different printers are shown in a listbox
-in that dialog box.
-
-You could also try setting the driver to NULL like this:
-
- printer driver = NULL
-
-this is effectively what older versions of Samba did, so if that
-worked for you then give it a go. If this does work then let me know
-and I'll make it the default. Currently the default is a 0 length
-string.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-* 8: I have upgraded my NT 4.0 system to service pack 3. Why
- can't I connect anymore ?
-
-This is not a bug. Microsoft has changed their policy on sending
-unencrypted passwords over the net. They no longer default to allowing
-unencrypted passwords to be sent over the net. This effects all Samba
-servers which are configured to use security=share or security=user level
-security without password encryption. They do, however, have a fix which
-can be applied to the registry to fix the problem. Here's a synopsis
-from the SP3 web page that discusses how to enable unencrypted password
-sending from an NT 4.0 box.
-
-A better solution is to re-compile Samba to use encrypted passwords.
-See the document :
-
-ftp://samba.anu.edu.au/pub/samba/docs/ENCRYPTION.txt
-
->SYMPTOMS
->==========
->
->Connecting to SMB servers (such as Samba) with unencrypted password fails
-after upgrading to Windows NT 4.0 service pack 3 version 1.76.
->
->CAUSE
->======
->
->The SMB redirector in Windows NT 4.0 service pack 3 version 1.76 handles
->unencrypted passwords differently than previous version of Windows NT.
->Beginning with this version, the SMB redirector will not send an
->unencrypted password unless you add a registry entry to enable them.
->
->RESOLUTION
->===========
->
->To enable unencrypted (plain text) passwords modify the registry in this way.
->
->
->
->WARNING: Using Registry Editor incorrectly can cause serious, system-wide
->problems that may require you to reinstall Windows NT to correct them.
->Microsoft cannot guarantee that any problems resulting from the use of
->Registry Editor can be solved. Use this tool at your own risk.
->
->
->
->1. Run Registry Editor (REGEDT32.EXE).
->
->2. From the HKEY_LOCAL_MACHINE subtree, go to the following key:
->
->
->
->\system\currentcontrolset\services\rdr\parameters
->
->
->
->3. From the Edit menu, select Add Value.
->
->4. Add the following:
->
->
->
->Value Name: EnablePlainTextPassword
->
->Data Type: REG_DWORD
->
->Data: 1
->
->
->
->5. Choose OK and quit Registry Editor.
->
->6. Shutdown and restart Windows NT.
->
->
------------------------------------------------------------------------
-
-===============================================================================
-SECTION FIVE: Specific client application problems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: MS Office Setup reports "Cannot change properties of the file named:
- X:\MSOFFICE\SETUP.INI"
-
-When installing MS Office on a Samba drive for which you have admin user
-permissions, ie. admin users = <username>, you will find the setup program
-unable to complete the installation.
-
-To get around this problem, do the installation without admin user permissions
-The problem is that MS Office Setup checks that a file is rdonly by trying to
-open it for writing.
-
-Admin users can always open a file for writing, as they run as root.
-You just have to install as a non-admin user and then use "chown -R" to fix
-the owner.
-
-===============================================================================
-SECTION SIX: Miscellaneous
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Maintained By Paul Blackman, Email:ictinus@lake.canberra.edu.au
diff --git a/docs/textdocs/Application_Serving.txt b/docs/textdocs/Application_Serving.txt
index 5a17b64b030..d228b5cbd84 100644
--- a/docs/textdocs/Application_Serving.txt
+++ b/docs/textdocs/Application_Serving.txt
@@ -1,3 +1,6 @@
+!==
+!== Application_Serving.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
January 7, 1997
Updated: June 27, 1997
Contributor: John H Terpstra <samba-bugs@samba.anu.edu.au>
diff --git a/docs/textdocs/BROWSING.txt b/docs/textdocs/BROWSING.txt
index d8362f15299..84aed64b081 100644
--- a/docs/textdocs/BROWSING.txt
+++ b/docs/textdocs/BROWSING.txt
@@ -1,3 +1,6 @@
+!==
+!== BROWSING.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Author/s: Many (Thanks to Luke, Jeremy, Andrew, etc.)
Updated: June 29, 1997
Status: Current - For VERY Advanced Users ONLY
@@ -8,8 +11,8 @@ Summary: This describes how to configure Samba for improved browsing.
OVERVIEW:
=========
SMB networking provides a mechanism by which clients can access a list
-of machines that are available within the network. This list is called
-the browse list and is heavily used by all SMB clients. Configuration
+of machines that are available within the network. This list is called
+the browse list and is heavily used by all SMB clients. Configuration
of SMB browsing has been problematic for some Samba users, hence this
document.
@@ -17,7 +20,7 @@ document.
BROWSING
========
-Samba now fully supports browsing. The browsing is supported by nmbd
+Samba now fully supports browsing. The browsing is supported by nmbd
and is also controlled by options in the smb.conf file (see smb.conf(5)).
Samba can act as a local browse master for a workgroup and the ability
@@ -28,10 +31,13 @@ Samba can also act as a domain master browser for a workgroup. This
means that it will collate lists from local browse masters into a
wide area network server list. In order for browse clients to
resolve the names they may find in this list, it is recommended that
-both samba and your clients use a WINS server
+both samba and your clients use a WINS server.
Note that you should NOT set Samba to be the domain master for a
-workgroup that has the same name as an NT Domain.
+workgroup that has the same name as an NT Domain: on each wide area
+network, you must only ever have one domain master browser per workgroup,
+regardless of whether it is NT, Samba or any other type of domain master
+that is providing this service.
[Note that nmbd can be configured as a WINS server, but it is not
necessary to specifically use samba as your WINS server. NTAS can
@@ -48,10 +54,10 @@ Samba becomes a part of.
Samba also has a useful option for a Samba server to offer itself for
browsing on another subnet. It is recommended that this option is only
used for 'unusual' purposes: announcements over the internet, for
-example. See "remote announce" in the smb.conf man page.
+example. See "remote announce" in the smb.conf man page.
If something doesn't work then hopefully the log.nmb file will
-help you track down the problem. Try a debug level of 2 or 3 for
+help you track down the problem. Try a debug level of 2 or 3 for
finding problems.
Note that if it doesn't work for you, then you should still be able to
@@ -59,14 +65,14 @@ type the server name as \\SERVER in filemanager then hit enter and
filemanager should display the list of available shares.
Some people find browsing fails because they don't have the global
-"guest account" set to a valid account. Remember that the IPC$
+"guest account" set to a valid account. Remember that the IPC$
connection that lists the shares is done as guest, and thus you must
have a valid guest account.
Also, a lot of people are getting bitten by the problem of too many
-parameters on the command line of nmbd in inetd.conf. This trick is to
+parameters on the command line of nmbd in inetd.conf. This trick is to
not use spaces between the option and the parameter (eg: -d2 instead
-of -d 2), and to not use the -B and -N options. New versions of nmbd
+of -d 2), and to not use the -B and -N options. New versions of nmbd
are now far more likely to correctly find your broadcast and network
addess, so in most cases these aren't needed.
@@ -74,23 +80,23 @@ The other big problem people have is that their broadcast address,
netmask or IP address is wrong (specified with the "interfaces" option
in smb.conf)
+
BROWSING ACROSS SUBNETS
=======================
-With the release of Samba 1.9.17(alpha1 and above) Samba has been
-updated to enable it to support the replication of browse lists
-across subnet boundaries. New code and options have been added to
-achieve this. This section describes how to set this feature up
-in different settings.
+With the release of Samba 1.9.17, Samba has been updated to enable
+it to support the replication of browse lists across subnet
+boundaries. New code and options have been added to achieve this.
+This section describes how to set this feature up in different settings.
-To see browse lists that span TCP/IP subnets (ie. networks separated
+To see browse lists that span TCP/IP subnets (ie. networks separated
by routers that don't pass broadcast traffic) you must set up at least
-one WINS server. The WINS server acts as a DNS for NetBIOS names, allowing
+one WINS server. The WINS server acts as a DNS for NetBIOS names, allowing
NetBIOS name to IP address translation to be done by doing a direct
-query of the WINS server. This is done via a directed UDP packet on
-port 137 to the WINS server machine. The reason for a WINS server is
+query of the WINS server. This is done via a directed UDP packet on
+port 137 to the WINS server machine. The reason for a WINS server is
that by default, all NetBIOS name to IP address translation is done
-by broadcasts from the querying machine. This means that machines
+by broadcasts from the querying machine. This means that machines
on one subnet will not be able to resolve the names of machines on
another subnet without using a WINS server.
@@ -104,7 +110,7 @@ How does cross subnet browsing work ?
=====================================
Cross subnet browsing is a complicated dance, containing multiple
-moving parts. It has taken Microsoft several years to get the code
+moving parts. It has taken Microsoft several years to get the code
that achieves this correct, and Samba lags behind in some areas.
However, with the 1.9.17 release, Samba is capable of cross subnet
browsing when configured correctly.
@@ -127,38 +133,38 @@ Consider a network set up as follows :
(WINS)
Consisting of 3 subnets (1, 2, 3) conneted by two routers
-(R1, R2) - these do not pass broadcasts. Subnet 1 has 5 machines
-on it, subnet 2 has 4 machines, subnet 3 has 4 machines. Assume
+(R1, R2) - these do not pass broadcasts. Subnet 1 has 5 machines
+on it, subnet 2 has 4 machines, subnet 3 has 4 machines. Assume
for the moment that all these machines are configured to be in the
-same workgroup (for simplicities sake). Machine N1_C on subnet 1
-is configured as Domain Master Browser (ie. it will collate the
-browse lists for the workgroup). Machine N2_D is configured as
+same workgroup (for simplicities sake). Machine N1_C on subnet 1
+is configured as Domain Master Browser (ie. it will collate the
+browse lists for the workgroup). Machine N2_D is configured as
WINS server and all the other machines are configured to register
their NetBIOS names with it.
As all these machines are booted up, elections for master browsers
-will take place on each of the three subnets. Assume that machine
+will take place on each of the three subnets. Assume that machine
N1_C wins on subnet 1, N2_B wins on subnet 2, and N3_D wins on
subnet 3 - these machines are known as local master browsers for
-their particular subnet. N1_C has an advantage in winning as the
+their particular subnet. N1_C has an advantage in winning as the
local master browser on subnet 1 as it is set up as Domain Master
Browser.
On each of the three networks, machines that are configured to
offer sharing services will broadcast that they are offering
-these services. The local master browser on each subnet will
+these services. The local master browser on each subnet will
receive these broadcasts and keep a record of the fact that
-the machine is offering a service. This list of records is
-the basis of the browse list. For this case, assume that
+the machine is offering a service. This list of records is
+the basis of the browse list. For this case, assume that
all the machines are configured to offer services so all machines
will be on the browse list.
For each network, the local master browser on that network is
considered 'authoritative' for all the names it receives via
-local broadcast. This is because a machine seen by the local
+local broadcast. This is because a machine seen by the local
master browser via a local broadcast must be on the same
network as the local master browser and thus is a 'trusted'
-and 'verifiable' resource. Machines on other networks that
+and 'verifiable' resource. Machines on other networks that
the local master browsers learn about when collating their
browse lists have not been directly seen - these records are
called 'non-authoritative'.
@@ -178,21 +184,21 @@ Subnet3 N3_D N3_A, N3_B, N3_C, N3_D
Note that at this point all the subnets are separate, no
machine is seen across any of the subnets.
-Now examine subnet 2. As soon as N2_B has become the local
+Now examine subnet 2. As soon as N2_B has become the local
master browser it looks for a Domain master browser to synchronize
-its browse list with. It does this by querying the WINS server
+its browse list with. It does this by querying the WINS server
(N2_D) for the IP address associated with the NetBIOS name
-WORKGROUP<1B>. This name was registerd by the Domain master
+WORKGROUP<1B>. This name was registerd by the Domain master
browser (N1_C) with the WINS server as soon as it was booted.
Once N2_B knows the address of the Domain master browser it
tells it that is the local master browser for subnet 2 by
sending a MasterAnnouncement packet as a UDP port 138 packet.
-It then synchronizes with it by doing a NetServerEnum2 call. This
+It then synchronizes with it by doing a NetServerEnum2 call. This
tells the Domain Master Browser to send it all the server
-names it knows about. Once the domain master browser receives
+names it knows about. Once the domain master browser receives
the MasterAnnouncement packet it schedules a synchronization
-request to the sender of that packet. After both synchronizations
+request to the sender of that packet. After both synchronizations
are done the browse lists look like :
Subnet Browse Master List
@@ -212,10 +218,10 @@ subnets 1 or 2 will see all the servers on both, users on
subnet 3 will still only see the servers on their own subnet.
The same sequence of events that occured for N2_B now occurs
-for the local master browser on subnet 3 (N3_D). When it
+for the local master browser on subnet 3 (N3_D). When it
synchronizes browse lists with the domain master browser (N1_A)
it gets both the server entries on subnet 1, and those on
-subnet 2. After N3_D has synchronized with N1_C and vica-versa
+subnet 2. After N3_D has synchronized with N1_C and vica-versa
the browse lists look like.
Subnet Browse Master List
@@ -239,7 +245,7 @@ subnet 2 will still only see the servers on subnets 1 and 2, but not 3.
Finally, the local master browser for subnet 2 (N2_B) will sync again
with the domain master browser (N1_C) and will recieve the missing
-server entries. Finally - and as a steady state (if no machines
+server entries. Finally - and as a steady state (if no machines
are removed or shut off) the browse lists will look like :
Subnet Browse Master List
@@ -273,36 +279,36 @@ names will not be removed from the network neighbourhood lists.
3) If one of the fragments is cut off from the WINS server, it will only
be able to access servers on its local subnet, by using subnet-isolated
-broadcast NetBIOS name resolution. The effects are similar to that of
+broadcast NetBIOS name resolution. The effects are similar to that of
losing access to a DNS server.
Setting up a WINS server
========================
Either a Samba machine or a Windows NT Server machine may be set up
-as a WINS server. To set a Samba machine to be a WINS server you must
+as a WINS server. To set a Samba machine to be a WINS server you must
add the following option to the smb.conf file on the selected machine :
in the [globals] section add the line
wins support = yes
Versions of Samba previous to 1.9.17 had this parameter default to
-yes. If you have any older versions of Samba on your network it is
+yes. If you have any older versions of Samba on your network it is
strongly suggested you upgrade to 1.9.17 or above, or at the very
least set the parameter to 'no' on all these machines.
Machines with "wins support = yes" will keep a list of all NetBIOS
names registered with them, acting as a DNS for NetBIOS names.
-You should set up only ONE wins server. Do NOT set the
+You should set up only ONE wins server. Do NOT set the
"wins support = yes" option on more than one Samba server.
To set up a Windows NT Server as a WINS server you need to set up
-the WINS service - see your NT documentation for details. Note that
+the WINS service - see your NT documentation for details. Note that
Windows NT WINS Servers can replicate to each other, allowing more
-than one to be set up in a complex subnet environment. As Microsoft
+than one to be set up in a complex subnet environment. As Microsoft
refuse to document these replication protocols Samba cannot currently
-participate in these replications. It is possible in the future that
+participate in these replications. It is possible in the future that
a Samba->Samba WINS replication protocol may be defined, in which
case more than one Samba machine could be set up as a WINS server
but currently only one Samba server should have the "wins support = yes"
@@ -310,10 +316,10 @@ parameter set.
After the WINS server has been configured you must ensure that all
machines participating on the network are configured with the address
-of this WINS server. If your WINS server is a Samba machine, fill in
+of this WINS server. If your WINS server is a Samba machine, fill in
the Samba machine IP address in the "Primary WINS Server" field of
the "Control Panel->Network->Protocols->TCP->WINS Server" dialogs
-in Windows 95 or Windows NT. To tell a Samba server the IP address
+in Windows 95 or Windows NT. To tell a Samba server the IP address
of the WINS server add the following line to the [global] section of
all smb.conf files :
@@ -323,14 +329,14 @@ where <name or IP address> is either the DNS name of the WINS server
machine or its IP address.
Note that this line MUST NOT BE SET in the smb.conf file of the Samba
-server acting as the WINS server itself. If you set both the
+server acting as the WINS server itself. If you set both the
"wins support = yes" option and the "wins server = <name>" option then
nmbd will fail to start.
There are two possible scenarios for setting up cross subnet browsing.
The first details setting up cross subnet browsing on a network containing
Windows 95, Samba and Windows NT machines that are not configured as
-part of a Windows NT Domain. The second details setting up cross subnet
+part of a Windows NT Domain. The second details setting up cross subnet
browsing on networks that contain NT Domains.
Setting up Browsing in a WORKGROUP
@@ -340,25 +346,23 @@ To set up cross subnet browsing on a network containing machines
in up to be in a WORKGROUP, not an NT Domain you need to set up one
Samba server to be the Domain Master Browser (note that this is *NOT*
the same as a Primary Domain Controller, although in an NT Domain the
-same machine plays both roles). The role of a Domain master browser is
+same machine plays both roles). The role of a Domain master browser is
to collate the browse lists from local master browsers on all the
-subnets that have a machine participating in the workgroup. Without
+subnets that have a machine participating in the workgroup. Without
one machine configured as a domain master browser each subnet would
be an isolated workgroup, unable to see any machines on any other
-subnet. It is the presense of a domain master browser that makes
+subnet. It is the presense of a domain master browser that makes
cross subnet browsing possible for a workgroup.
In an WORKGROUP environment the domain master browser must be a
Samba server, and there must only be one domain master browser per
-workgroup name (although the same Samba server can act as Domain
-master browser for multiple workgroup names). To set up a Samba
-server as a domain master browser set the following option in the
-[global] section of the smb.conf file :
+workgroup name. To set up a Samba server as a domain master browser,
+set the following option in the [global] section of the smb.conf file :
domain master = yes
The domain master browser should also preferrably be the local master
-browser for its own subnet. In order to achieve this set the following
+browser for its own subnet. In order to achieve this set the following
options in the [global] section of the smb.conf file :
domain master = yes
@@ -371,9 +375,9 @@ server, if you require.
Next, you should ensure that each of the subnets contains a
machine that can act as a local master browser for the
-workgroup. Any NT machine should be able to do this, as will
+workgroup. Any NT machine should be able to do this, as will
Windows 95 machines (although these tend to get rebooted more
-often, so it's not such a good idea to use these). To make a
+often, so it's not such a good idea to use these). To make a
Samba server a local master browser set the following
options in the [global] section of the smb.conf file :
@@ -387,7 +391,7 @@ or they will war with each other over which is to be the local
master browser.
The "local master" parameter allows Samba to act as a local master
-browser. The "preferred master" causes nmbd to force a browser
+browser. The "preferred master" causes nmbd to force a browser
election on startup and the "os level" parameter sets Samba high
enough so that it should win any browser elections.
@@ -413,7 +417,7 @@ browser NetBIOS name (DOMAIN<1B>) with WINS instead of the PDC.
For subnets other than the one containing the Windows NT PDC
you may set up Samba servers as local master browsers as
-described. To make a Samba server a local master browser set
+described. To make a Samba server a local master browser set
the following options in the [global] section of the smb.conf
file :
@@ -424,8 +428,8 @@ file :
If you wish to have a Samba server fight the election with machines
on the same subnet you may set the "os level" parameter to lower
-levels. By doing this you can tune the order of machines that
-will become local master browsers if they are running. For
+levels. By doing this you can tune the order of machines that
+will become local master browsers if they are running. For
more details on this see the section "FORCING SAMBA TO BE THE MASTER"
below.
@@ -444,17 +448,17 @@ FORCING SAMBA TO BE THE MASTER
==============================
Who becomes the "master browser" is determined by an election process
-using broadcasts. Each election packet contains a number of parameters
+using broadcasts. Each election packet contains a number of parameters
which determine what precedence (bias) a host should have in the
-election. By default Samba uses a very low precedence and thus loses
+election. By default Samba uses a very low precedence and thus loses
elections to just about anyone else.
If you want Samba to win elections then just set the "os level" global
-option in smb.conf to a higher number. It defaults to 0. Using 34
+option in smb.conf to a higher number. It defaults to 0. Using 34
would make it win all elections over every other system (except other
samba systems!)
-A "os level" of 2 would make it beat WfWg and Win95, but not NTAS. A
+A "os level" of 2 would make it beat WfWg and Win95, but not NTAS. A
NTAS domain controller uses level 32.
The maximum os level is 255
@@ -487,9 +491,9 @@ MAKING SAMBA THE DOMAIN MASTER
==============================
The domain master is responsible for collating the browse lists of
-multiple subnets so that browsing can occur between subnets. You can
+multiple subnets so that browsing can occur between subnets. You can
make samba act as the domain master by setting "domain master = yes"
-in smb.conf. By default it will not be a domain master.
+in smb.conf. By default it will not be a domain master.
Note that you should NOT set Samba to be the domain master for a
workgroup that has the same name as an NT Domain.
@@ -526,13 +530,13 @@ b) when a client receives a domain-wide browse list, and a user attempts
to access a host in that list, it will contact the WINS server to
resolve the NetBIOS name of that host. as long as that host has
registered its NetBIOS name with the same WINS server, the user will
- be able to see that host.
+ be able to see that host.
NOTE ABOUT BROADCAST ADDRESSES
==============================
If your network uses a "0" based broadcast address (for example if it
-ends in a 0) then you will strike problems. Windows for Workgroups
+ends in a 0) then you will strike problems. Windows for Workgroups
does not seem to support a 0's broadcast and you will probably find
that browsing and name lookups won't work.
@@ -540,7 +544,7 @@ that browsing and name lookups won't work.
MULTIPLE INTERFACES
===================
-Samba now supports machines with multiple network interfaces. If you
+Samba now supports machines with multiple network interfaces. If you
have multiple interfaces then you will need to use the "interfaces"
-option in smb.conf to configure them. See smb.conf(5) for details.
+option in smb.conf to configure them. See smb.conf(5) for details.
diff --git a/docs/textdocs/BUGS.txt b/docs/textdocs/BUGS.txt
index 0bd12e8af0a..f5352e976ea 100644
--- a/docs/textdocs/BUGS.txt
+++ b/docs/textdocs/BUGS.txt
@@ -1,3 +1,6 @@
+!==
+!== BUGS.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Samba Team
Updated: June 27, 1997
@@ -25,7 +28,7 @@ that list that may be able to help you.
You may also like to look though the recent mailing list archives,
which are conveniently accessible on the Samba web pages
-at http://samba.canberra.edu.au/pub/samba/
+at http://samba.anu.edu.au/samba/
GENERAL INFO
diff --git a/docs/textdocs/DIAGNOSIS.txt b/docs/textdocs/DIAGNOSIS.txt
index 11eb91b2ff8..06c4ce8b2fd 100644
--- a/docs/textdocs/DIAGNOSIS.txt
+++ b/docs/textdocs/DIAGNOSIS.txt
@@ -1,5 +1,8 @@
+!==
+!== DIAGNOSIS.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Andrew Tridgell
-Updated: June 27, 1997
+Updated: October 14, 1997
Subject: DIAGNOSING YOUR SAMBA SERVER
===========================================================================
@@ -44,6 +47,15 @@ smb.conf. I will assume this share is called "tmp". You can add a
THESE TESTS ASSUME VERSION 1.9.16 OR LATER OF THE SAMBA SUITE. SOME
COMMANDS SHOWN DID NOT EXIST IN EARLIER VERSIONS
+Please pay attention to the error messages you receive. If any error message
+reports that your server is being unfriendly you should first check that you
+IP name resolution is correctly set up. eg: Make sure your /etc/resolv.conf
+file points to name servers that really do exist.
+
+Also, if you do not have DNS server access for name resolution please check
+that the settings for your smb.conf file results in "dns proxy = no". The
+best way to check this is with "testparm smb.conf"
+
TEST 1:
-------
@@ -53,7 +65,7 @@ In the directory in which you store your smb.conf file, run the command
configuration file is faulty.
Note: Your smb.conf file may be located in: /etc
- or in: /usr/local/samba/lib
+ Or in: /usr/local/samba/lib
TEST 2:
@@ -254,7 +266,10 @@ Still having troubles?
----------------------
Try the mailing list or newsgroup, or use the tcpdump-smb utility to
-sniff the problem.
+sniff the problem. The official samba mailing list can be reached at
+samba@samba.anu.edu.au. To find out more about samba and how to
+subscribe to the mailing list check out the samba web page at
+ http://samba.anu.edu.au/samba
Also look at the other docs in the Samba package!
diff --git a/docs/textdocs/DNIX.txt b/docs/textdocs/DNIX.txt
index 51005e6ec8c..2c2386a1ef6 100644
--- a/docs/textdocs/DNIX.txt
+++ b/docs/textdocs/DNIX.txt
@@ -1,3 +1,6 @@
+!==
+!== DNIX.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
DNIX has a problem with seteuid() and setegid(). These routines are
needed for Samba to work correctly, but they were left out of the DNIX
C library for some reason.
diff --git a/docs/textdocs/DOMAIN.txt b/docs/textdocs/DOMAIN.txt
index 3cd8a125b7b..49250239db3 100644
--- a/docs/textdocs/DOMAIN.txt
+++ b/docs/textdocs/DOMAIN.txt
@@ -1,3 +1,6 @@
+!==
+!== DOMAIN.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Samba Team
Updated: June 27, 1997
diff --git a/docs/textdocs/DOMAIN_CONTROL.txt b/docs/textdocs/DOMAIN_CONTROL.txt
index 0b077320cdb..37d7a9dd5f9 100644
--- a/docs/textdocs/DOMAIN_CONTROL.txt
+++ b/docs/textdocs/DOMAIN_CONTROL.txt
@@ -1,3 +1,6 @@
+!==
+!== DOMAIN_CONTROL.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Initial Release: August 22, 1996
Contributor: John H Terpstra <samba-bugs@samba.anu.edu.au>
Copyright (C) 1996-1997 - John H Terpstra
diff --git a/docs/textdocs/ENCRYPTION.txt b/docs/textdocs/ENCRYPTION.txt
index 075a0d322e2..f06972b45ca 100644
--- a/docs/textdocs/ENCRYPTION.txt
+++ b/docs/textdocs/ENCRYPTION.txt
@@ -1,3 +1,6 @@
+!==
+!== ENCRYPTION.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Jeremy Allison <samba-bugs@samba.anu.edu.au>
Updated: June 27, 1997
Note: Please refer to WinNT.txt also
@@ -269,15 +272,27 @@ This is a very brief description on how to setup samba to support
password encryption. More complete instructions will probably be added
later.
-1) compile and install samba as usual
+1) get and compile the libdes libraries. the source is available from
+ftp://samba.anu.edu.au/pub/libdes/
-2) if your system can't compile the module getsmbpass.c then remove the
+2) enable the encryption stuff in the Samba makefile, making sure you
+point it to the libdes library and include file (it needs des.h)
+The entries you need to uncomment are the four lines after the comment :-
+
+# This is for SMB encrypted (lanman) passwords.
+
+Note that you may have to change the variable DES_BASE to
+point at the place where you installed the DES library.
+
+3) compile and install samba as usual
+
+4) f your system can't compile the module getsmbpass.c then remove the
-DSMBGETPASS define from the Makefile.
-3) enable encrypted passwords in smb.conf by adding the line
+5) enable encrypted passwords in smb.conf by adding the line
"encrypt passwords = yes" in the [global] section
-4) create the initial smbpasswd password file in the place you
+6) create the initial smbpasswd password file in the place you
specified in the Makefile. A simple way to do this based on your
existing Makefile (assuming it is in a reasonably standard format) is
like this:
@@ -312,13 +327,27 @@ If you wish, install the smbpasswd program as suid root.
chown root /usr/local/samba/bin/smbpasswd
chmod 4555 /usr/local/samba/bin/smbpasswd
-5) set the passwords for users using the smbpasswd command. For
+7) set the passwords for users using the smbpasswd command. For
example, as root you could do "smbpasswd tridge"
-6) try it out!
+8) try it out!
Note that you can test things using smbclient, as it also now supports
encryption.
+NOTE TO USA Sites that Mirror Samba
+-----------------------------------
+
+The DES library is considered a munition in the USA. Under US Law it is
+illegal to export this software, or to put it in a freely available ftp
+site.
+
+Please do not mirror the libdes directory from the site on
+samba.anu.edu.au
+
+Thank you,
+
+Jeremy Allison.
+
==============================================================================
Footnote: Please refer to WinNT.txt also
diff --git a/docs/textdocs/Faxing.txt b/docs/textdocs/Faxing.txt
index 0703d75cc35..cb8f7722ca5 100644
--- a/docs/textdocs/Faxing.txt
+++ b/docs/textdocs/Faxing.txt
@@ -1,3 +1,6 @@
+!==
+!== Faxing.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Gerhard Zuber <zuber@berlin.snafu.de>
Date: August 5th 1997.
Status: Current
diff --git a/docs/textdocs/GOTCHAS.txt b/docs/textdocs/GOTCHAS.txt
index bc5c6dae853..f0b73dd164a 100644
--- a/docs/textdocs/GOTCHAS.txt
+++ b/docs/textdocs/GOTCHAS.txt
@@ -1,3 +1,6 @@
+!==
+!== GOTCHAS.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
This file lists Gotchas to watch out for:
=========================================================================
Item Number: 1.0
diff --git a/docs/textdocs/HINTS.txt b/docs/textdocs/HINTS.txt
index f5781ee4232..e809238c9e6 100644
--- a/docs/textdocs/HINTS.txt
+++ b/docs/textdocs/HINTS.txt
@@ -1,3 +1,6 @@
+!==
+!== HINTS.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Many
Updated: Not for a long time!
diff --git a/docs/textdocs/MIRRORS.txt b/docs/textdocs/MIRRORS.txt
index 01bc277a20b..8c3697a3eab 100755
--- a/docs/textdocs/MIRRORS.txt
+++ b/docs/textdocs/MIRRORS.txt
@@ -1,23 +1,37 @@
+!==
+!== MIRRORS.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
The main Samba ftp site is samba.anu.edu.au in pub/samba/. Contact
samba-bugs@samba.anu.edu.au for help with this site.
+The 'Source Only' sites may also contain binary packages as we are now
+including them on samba.anu.edu.au/pub/samba/Binary_Packages
+
Mirror sites include:
-Source Only
-===========
---- Australia ---
+--- Austria ---
+ ftp://gd.tuwien.ac.at/pub/infosys/servers/samba/sources/
+--- Australia ---
ftp://samba.anu.edu.au/pub/samba/
- ftp://nimbus.anu.edu.au/pub/tridge/samba/
ftp://choc.satech.net.au/pub/samba/
--- USA Educational ---
+ ftp://sunsite.unc.edu/pub/packages/samba/sources/
ftp://ftp.micro.caltech.edu/pub/samba/
ftp://ftp.cs.ucr.edu/pub/software/samba/
- ftp://sunsite.unc.edu/pub/Linux/system/Network/samba/
--- Czech Republic ---
ftp://sunsite.mff.cuni.cz/Net/Protocols/Samba/
+--- Denmark ---
+ ftp://sunsite.auc.dk/pub/unix/networking/samba/
+--- Finland ---
+ ftp://nic.funet.fi/pub/mirrors/samba.anu.edu.au/
--- Germany ---
ftp://ftp.uni-trier.de/pub/unix/network/samba/
- ftp://ftp.gwdg.de/pub/server/samba/
+ ftp://ftp.gwdg.de/pub/server/samba/
+--- Greece ---
+ ftp://ftp.ntua.gr/pub/net/samba/
+--- Italy ---
+ ftp://volftp.tin.it/mirror/samba/pub/samba/
+ http://www.inferentia.it/archives/samba/ (no binaries)
--- Japan ---
ftp://ring.asahi-net.or.jp/archives/net/samba/
ftp://ring.aist.go.jp/archives/net/samba/
@@ -28,26 +42,17 @@ Source Only
ftp://ftp.gbnet.net/pub/samba/
ftp://ftp.ntrl.net/pub/mirror/samba/
ftp://despair.capecod.net/pub/Samba/
---- Portugal ---
+--- Poland ---
+ ftp://giswitch.sggw.waw.pl/pub/unix/samba/
+--- Potugal ---
ftp://ftp.ua.pt/pub/misc/samba/
+--- Romania ---
+ ftp://ftp.romus.ro/pub/Linux/Network/samba/
--- Russian Federation ---
ftp://ftp.uic.nsu.ru/pub/vendors/samba/
--- United Kingdom ---
- ftp://ftp.demon.co.uk/pub/mirrors/samba/
- ftp://src.doc.ic.ac.uk/packages/samba/
-
-Sources & Binaries
-==================
---- Austria ---
- ftp://gd.tuwien.ac.at/pub/infosys/servers/samba/
---- Denmark ---
- ftp://sunsite.auc.dk/pub/unix/networking/samba/
---- USA Educational ---
- ftp://sunsite.unc.edu/pub/packages/samba/
---- Italy ---
- http://www.inferentia.it/archives/samba/
---- United Kingdom ---
ftp://sunsite.doc.ic.ac.uk/packages/samba/
+ ftp://ftp.demon.co.uk/pub/mirrors/samba/
SCO binaries available from:
http://www.math.u-szeged.hu/hardsoft/hsdetail.htm
@@ -75,7 +80,6 @@ There are several others. Give archie a try.
Http sites include:
===================
-http://samba.canberra.edu.au/pub/samba
-http://www.choc.satech.net.au/pub/samba/
-
+http://samba.anu.edu.au/samba
+Japanese - http://samba.bento.ad.jp/
diff --git a/docs/textdocs/NetBIOS.txt b/docs/textdocs/NetBIOS.txt
index 415aa34beb9..a306cdf403c 100644
--- a/docs/textdocs/NetBIOS.txt
+++ b/docs/textdocs/NetBIOS.txt
@@ -1,3 +1,6 @@
+!==
+!== NetBIOS.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: lkcl - samba-bugs@arvidsjaur.anu.edu.au
Copyright 1997 Luke Kenneth Casson Leighton
Date: March 1997
diff --git a/docs/textdocs/OS2-Client-HOWTO.txt b/docs/textdocs/OS2-Client-HOWTO.txt
index cf3033956ea..e627377c45b 100644
--- a/docs/textdocs/OS2-Client-HOWTO.txt
+++ b/docs/textdocs/OS2-Client-HOWTO.txt
@@ -1,3 +1,6 @@
+!==
+!== OS2-Client-HOWTO.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Q. How can I configure OS/2 Warp Connect or OS/2 Warp 4 as a client for Samba?
diff --git a/docs/textdocs/Passwords.txt b/docs/textdocs/Passwords.txt
index f76010c4608..116109ffe0b 100644
--- a/docs/textdocs/Passwords.txt
+++ b/docs/textdocs/Passwords.txt
@@ -1,3 +1,6 @@
+!==
+!== Passwords.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Unknown
Date: Unknown
Status: Current
diff --git a/docs/textdocs/Printing.txt b/docs/textdocs/Printing.txt
index e8a2d2ad27f..c0cb670397a 100644
--- a/docs/textdocs/Printing.txt
+++ b/docs/textdocs/Printing.txt
@@ -1,3 +1,6 @@
+!==
+!== Printing.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Unknown <samba-bugs@samba.anu.edu.au>
Date: Unknown
Status: Current
diff --git a/docs/textdocs/SCO.txt b/docs/textdocs/SCO.txt
index 7c01aa57c6c..ae17a423797 100644
--- a/docs/textdocs/SCO.txt
+++ b/docs/textdocs/SCO.txt
@@ -1,3 +1,6 @@
+!==
+!== SCO.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Geza Makay <makayg@math.u-szeged.hu>
Date: Unknown
Status: Obsolete - Dates to SCO Unix v3.2.4 approx.
diff --git a/docs/textdocs/Speed.txt b/docs/textdocs/Speed.txt
index b11885fc377..df7d00b12f5 100644
--- a/docs/textdocs/Speed.txt
+++ b/docs/textdocs/Speed.txt
@@ -1,3 +1,6 @@
+!==
+!== Speed.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Andrew Tridgell
Date: January 1995
Status: Current
diff --git a/docs/textdocs/Support.txt b/docs/textdocs/Support.txt
index d482ac39123..ab430655e28 100644
--- a/docs/textdocs/Support.txt
+++ b/docs/textdocs/Support.txt
@@ -1,3 +1,6 @@
+!==
+!== Support.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
The Samba Consultants List
==========================
@@ -33,7 +36,7 @@ Region Number of entries
ASIA 1
AUSTRALIA & NEW ZEALAND 18
CANADA 8
- EUROPE 35
+ EUROPE 36
MIDDLE EAST 1
AFRICA
@@ -61,13 +64,10 @@ For futher information, please consult our website www.obsidian.co.za
JOHANNESBURG - SOUTH AFRICA
Company: Symphony Research (Pty) Ltd
- Contact: Dr Evan Summers, <evan@sr.co.za>, cell 082 900-8632.
+ Contact: Dr Evan Summers, <evan@sr.co.za>, tel 011 728-5742.
keywords: Samba on Linux, support and consulting
Johannesburg (South Africa)
-Evan Summers, PhD Tel +27 82 900-8632 Symphony
-Linux systems integration http://sr.co.za Research
-Johannesburg, South Africa mailto:evan@sr.co.za (Pty)Ltd
------------------------------------------------------------------------------
@@ -1204,6 +1204,43 @@ We provide commercial support in Belgium to large organisations
------------------------------------------------------------------------------
------------------------------------------------------------------------------
+SOFIA - BULGARIA
+
+National Laboratory for Computer Virology and SEA Ltd.
+
+We work mainly in the following fields:
+
+* Design and testing of antivirus and computer security related software
+ and hardware;
+* Data aquisition equipment
+* Network design and consulting.
+
+Samba is our most common network tool for the export of data collected on
+UNIX machines to PC clients, file services and simple client/server
+processing schemes.
+
+Samba experience: Linux, Ultrix, Solaris, AIX, RiscOS.
+
+Client experience: LanMan, WFW, Win 95, Win NT.
+
+Address:
+
+National Laboratory for Computer Virology BAS,
+Akad. G. Bonchev Str. bl.8,
+Sofia 1113,
+Bulgaria
+E-mail:sales@nlcv.acad.bg
+URL http://www.nlcv.acad.bg
+
+SEA Ltd,
+Akad G.Bonchev Str bl. 8, rm 225,
+Sofia 1113.
+Bulgaria
+E-mail:nmechkov@virbus.bg
+URL http://www.orgchm.acad.bg/~sealtd
+------------------------------------------------------------------------------
+
+------------------------------------------------------------------------------
PRAHA (PRAGUE) - CZECH
AGC Praha,
diff --git a/docs/textdocs/Tracing.txt b/docs/textdocs/Tracing.txt
index d8b38378228..e3ff162d798 100644
--- a/docs/textdocs/Tracing.txt
+++ b/docs/textdocs/Tracing.txt
@@ -1,3 +1,6 @@
+!==
+!== Tracing.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Andrew Tridgell <samba-bugs@samba.anu.edu.au>
Date: Old
Status: Questionable
diff --git a/docs/textdocs/UNIX-SMB.txt b/docs/textdocs/UNIX-SMB.txt
index ec2e657c052..b9185063cb6 100644
--- a/docs/textdocs/UNIX-SMB.txt
+++ b/docs/textdocs/UNIX-SMB.txt
@@ -1,3 +1,6 @@
+!==
+!== UNIX-SMB.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Andrew Tridgell <samba-bugs@samba.anu.edu.au>
Date: April 1995
diff --git a/docs/textdocs/UNIX_INSTALL.txt b/docs/textdocs/UNIX_INSTALL.txt
index c189482ca41..b3e66ad41b8 100644
--- a/docs/textdocs/UNIX_INSTALL.txt
+++ b/docs/textdocs/UNIX_INSTALL.txt
@@ -1,3 +1,6 @@
+!==
+!== UNIX_INSTALL.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Andrew Tridgell <samba-bugs@samba.anu.edu.au>
Date: Unknown
Status: Current
@@ -15,7 +18,7 @@ try something like:
Unfortunately, having said this, the man pages are sadly out of date and
really need more effort to maintain them. Other sources of information
-are pointed to by the Samba web site, http://samba.canberra.edu.au/pub/samba.
+are pointed to by the Samba web site, http://samba.anu.edu.au/samba/.
STEP 1. Building the binaries
diff --git a/docs/textdocs/Win95.txt b/docs/textdocs/Win95.txt
index 69330c512d4..8c1023b78be 100644
--- a/docs/textdocs/Win95.txt
+++ b/docs/textdocs/Win95.txt
@@ -1,3 +1,6 @@
+!==
+!== Win95.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Copyright (C) 1997 - Samba-Team
Contributed Date: August 20, 1997
Last Update: August 20, 1997
diff --git a/docs/textdocs/WinNT.txt b/docs/textdocs/WinNT.txt
index d5810535971..b498168dd85 100644
--- a/docs/textdocs/WinNT.txt
+++ b/docs/textdocs/WinNT.txt
@@ -1,7 +1,11 @@
+!==
+!== WinNT.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributors: Various
Password Section - Copyright (C) 1997 - John H Terpstra
Printing Section - Copyright (C) 1997 - Matthew Harrell
-Updated: August 20, 1997
+ Priting Info - Copyright (C) 1997 - Frank Varnavas
+Updated: October 16, 1997
Status: Current
Subject: Samba and Windows NT Password Handling
@@ -72,3 +76,32 @@ time for the NT machine to get verification that the printer queue
actually exists.
I hope this helped in some way...
+
+=====================================================================
+Printing Info:
+--------------
+
+From: Frank Varnavas <varnavas@ny.ubs.com>
+Subject: RE: Samba as a print server
+
+When an NT client attempts to connect to a printer on a non-NT print
+server the attempt is failed with an error, something like:
+
+ "You have insufficient access to your computer to perform the
+ operation because a driver needs to be installed"
+
+This is because domain users must have 'Power User' status on the
+desktop to connect to printers on a non-NT print server.
+
+This error occurs regardless of whether the driver in question is
+already installed or not. What it really means is that the server is
+a non-NT server and the client does not have permission to create
+printers locally. Apparently when a connection to a non-NT print
+server is made the printer is defined locally. Such an action can be
+performed by either a local administrator or a Power User.
+Unfortunately there is no way to limit the powers of a Power User, nor
+is there any way to grant the Printer Creation right to another group.
+
+This permission policy is documented in PSS database WINNT, ID Q101874
+
+Frank Varnavas (varnavas@ny.ubs.com)
diff --git a/docs/textdocs/security_level.txt b/docs/textdocs/security_level.txt
index fac446fda8e..7880fd2bb23 100644
--- a/docs/textdocs/security_level.txt
+++ b/docs/textdocs/security_level.txt
@@ -1,3 +1,6 @@
+!==
+!== security_level.txt for Samba release 1.9.17p4 22 Oct 1997
+!==
Contributor: Andrew Tridgell
Updated: June 27, 1997
Status: Current
diff --git a/examples/smb.conf.default b/examples/smb.conf.default
index 7de2c21768b..b8895bd4cf6 100644
--- a/examples/smb.conf.default
+++ b/examples/smb.conf.default
@@ -1,181 +1,190 @@
-; The global setting for a default install
-; Copyright(C) John H Terpstra - 1997
-;======================= Global Settings =====================================
+# This is the main Samba configuration file. You should read the
+# smb.conf(5) manual page in order to understand the options listed
+# here. Samba has a huge number of configurable options (perhaps too
+# many!) most of which are not shown in this example
+#
+# Any line which starts with a ; (semi-colon) or a # (hash)
+# is a comment and is ignored. In this example we will use a #
+# for commentry and a ; for parts of the config file that you
+# may wish to enable
+#
+# NOTE: Whenever you modify this file you should run the command "testparm"
+# to check that you have not many any basic syntactic errors.
+#
+#======================= Global Settings =====================================
[global]
-; workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
- workgroup = WORKGROUP
+# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
+ workgroup = MYGROUP
-; comment is the equivalent of the NT Description field
- comment = Samba Server
+# server string is the equivalent of the NT Description field
+ server string = Samba Server
-; printing = BSD or SYSV or AIX, etc.
- printing = bsd
+# This option is important for security. It allows you to restrict
+# connections to machines which are on your local network. The
+# following example restricts access to two C class networks and
+# the "loopback" interface. For more examples of the syntax see
+# the smb.conf man page
+; hosts allow = 192.168.1. 192.168.2. 127.
+
+# If you want to automatically load your printer list rather
+# than setting them up individually then you'll need this
printcap name = /etc/printcap
load printers = yes
-; Uncomment this if you want a guest account, you must add this to /etc/passwd
+# It should not be necessary to spell out the print system type unless
+# yours is non-standard. Currently supported print systems include:
+# bsd, sysv, plp, lprng, aix, hpux, qnx
+; printing = bsd
+
+# Uncomment this if you want a guest account, you must add this to /etc/passwd
+# otherwise the user "nobody" is used
; guest account = pcguest
+
+# this tells Samba to use a separate log file for each machine
+# that connects
log file = /usr/local/samba/var/log.%m
-; Put a capping on the size of the log files (in Kb)
+# Put a capping on the size of the log files (in Kb).
max log size = 50
-; Options for handling file name case sensitivity and / or preservation
-; Case Sensitivity breaks many WfW and Win95 apps
-; case sensitive = yes
- short preserve case = yes
- preserve case = yes
-
-; Security and file integrity related options
- lock directory = /usr/local/samba/var/locks
- locking = yes
-; Strict locking is available for paranoid locking situations only
-; enabling this severely degrades read / write performance.
-; strict locking = yes
-; fake oplocks = yes
- share modes = yes
-
-; Security modes: USER uses Unix username/passwd, SHARE uses WfW type passwords
-; SERVER uses an other SMB server (eg: Windows NT Server or Samba)
-; to provide authentication services
+# Security mode. Most people will want user level security. See
+# security_level.txt for details.
security = user
-; Use password server option only with security = server
+# Use password server option only with security = server
; password server = <NT-Server-Name>
-; Encrypted Password Support - Off by default. Requires smbpasswd file
-; Refer to docs/Encryption.txt
- encrypt passwords = no
+# You may wish to use password encryption. Please read
+# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
+# Do not enable this option unless you have read those documents
+; encrypt passwords = yes
-; Configuration Options ***** The location of this entry in your smb.conf
-; heirachy determines which parameters are overwritten - please watch out!
-; Where %m is any SMBName (machine name, or computer name) for which a custom
-; configuration is desired
+# Using the following line enables you to customise your configuration
+# on a per machine basis. The %m gets replaced with the netbios name
+# of the machine that is connecting
; include = /usr/local/samba/lib/smb.conf.%m
-; Performance Related Options
-; Before setting socket options read the smb.conf man page!!
+# Most people will find that this option gives better performance.
+# See speed.txt and the manual pages for details
socket options = TCP_NODELAY
-; Use keep alive only if really needed!!!!
-; keep alive = 60
-; Configure Samba to use multiple interfaces
-; Samba will auto-detect network interfaces - only use this if
-; the auto-detection does not deliver the needed results
-; interfaces = 192.168.12.2/24 176.16.111.22/19 10.11.13.14/255.255.252.0
-
-; Browser Control Options:
-; Local Master set to True causes Samba to participate in browser elections
-; the default setting is true, this causes Samba to behave like a
-; Windows NT server. Setting this to false turns off all browser
-; election participation.
-; local master = yes
-
-; OS Level gives Samba the power to win browser elections. Windows NT = 32
-; Any value < 32 means NT wins as Master Browser, > 32 Samba gets it
-; default = 0, this ensures that Samba will NOT win the browser election.
+
+# Configure Samba to use multiple interfaces
+# If you have multiple network interfaces then you must list them
+# here. See the man page for details.
+; interfaces = 192.168.12.2/24 192.168.13.2/24
+
+# Browser Control Options:
+# set local master to no if you don't want Samba to become a master
+# browser on your network. Otherwise the normal election rules apply
+; local master = no
+
+# OS Level determines the precedence of this server in master browser
+# elections. The default value should be reasonable
; os level = 33
-; Domain Master specifies Samba to be the Domain Master Browser
-; Only ever set this if there is NO Windows NT Domain Controller on the
-; network
+# Domain Master specifies Samba to be the Domain Master Browser. This
+# allows Samba to collate browse lists between subnets. Don't use this
+# if you already have a Windows NT domain controller doing this job
; domain master = yes
-; Preferred Master causes Samba to force a local browser election on startup
+# Preferred Master causes Samba to force a local browser election on startup
+# and gives it a slightly higher chance of winning the election
; preferred master = yes
-; Use with care only if you have an NT server on your network that has been
-; configured at install time to be a primary domain controller.
+# Use only if you have an NT server on your network that has been
+# configured at install time to be a primary domain controller.
; domain controller = <NT-Domain-Controller-SMBName>
-; Domain Logon Service Options:
-; Domain logon control can be a good thing! See [netlogon] share section below!
-; Do NOT set this to yes if there is an Windows NT domain controller
-; on the network
+# Enable this if you want Samba to be a domain logon server for
+# Windows95 workstations.
; domain logons = yes
-; run a specific logon batch file per workstation (machine)
+# if you enable domain logons then you may want a per-machine or
+# per user logon script
+# run a specific logon batch file per workstation (machine)
; logon script = %m.bat
-; run a specific logon batch file per session username (ie: Client User Name)
-; logon script = %U.bat
+# run a specific logon batch file per username
+; logon script = %u.bat
-; Where to store roving profiles (only for Win95 and WinNT)
-; %L substitutes for the SMB name we are called, %U is username
-; You must uncomment the [Profiles] share below
+# Where to store roving profiles (only for Win95 and WinNT)
+# %L substitutes for this servers netbios name, %U is username
+# You must uncomment the [Profiles] share below
; logon path = \\%L\Profiles\%U
-; Windows Internet Name Serving Support Section:
-; WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
-; the default is NO. If you have an Windows NT Server WINS use it!
-; Samba defaults to wins support = no
+# Windows Internet Name Serving Support Section:
+# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
; wins support = yes
-; WINS Server - Tells the NMBD components of Samba to be a WINS Client
-; Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
+# WINS Server - Tells the NMBD components of Samba to be a WINS Client
+# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z
-; WINS Proxy - Tells Samba to answer name resolution queries on behalf of a non
-; WINS Client capable client, for this to work there must be at least one
-; WINS Server on the network. The default is NO.
+# WINS Proxy - Tells Samba to answer name resolution queries on
+# behalf of a non WINS capable client, for this to work there must be
+# at least one WINS Server on the network. The default is NO.
; wins proxy = yes
-;============================ Share Definitions ==============================
+# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
+# via DNS nslookups. The built-in default for versions 1.9.17 is yes,
+# this has been changed in version 1.9.18 to no.
+ dns proxy = no
+
+#============================ Share Definitions ==============================
[homes]
comment = Home Directories
browseable = no
writable = yes
-; Un-comment the following and create the netlogon directory for Domain Logons
+# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
-; comment = Samba Network Logon Service
+; comment = Network Logon Service
; path = /usr/local/samba/lib/netlogon
-; Case sensitivity breaks logon script processing!!!
-; case sensitive = no
; guest ok = yes
-; locking = no
; writable = no
-; For browseable say NO if you want to hide the NETLOGON share
-; browseable = yes
+; share modes = no
+
-; Un-comment the following to provide a specific roving profile share
-; the default is to use the user's home directory
+# Un-comment the following to provide a specific roving profile share
+# the default is to use the user's home directory
;[Profiles]
; path = /usr/local/samba/profiles
; browseable = no
-; printable = no
; guest ok = yes
-; NOTE: There is NO need to specifically define each individual printer
+
+# NOTE: If you have a BSD-style print system there is no need to
+# specifically define each individual printer
[printers]
comment = All Printers
path = /usr/spool/samba
browseable = no
- printable = yes
-; Set public = yes to allow user 'guest account' to print
+# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = no
- create mask = 0700
+ printable = yes
+# This one is useful for people to share files
;[tmp]
; comment = Temporary file space
; path = /tmp
; read only = no
; public = yes
-; A publicly accessible directory, but read only, except for people in
-; the staff group
-[public]
- comment = Public Stuff
- path = /home/samba
- public = yes
- writable = yes
- printable = no
- write list = @users
-
-; Other examples.
-;
-; A private printer, usable only by fred. Spool data will be placed in fred's
-; home directory. Note that fred must have write access to the spool directory,
-; wherever it is.
+# A publicly accessible directory, but read only, except for people in
+# the "staff" group
+;[public]
+; comment = Public Stuff
+; path = /home/samba
+; public = yes
+; writable = yes
+; printable = no
+; write list = @staff
+
+# Other examples.
+#
+# A private printer, usable only by fred. Spool data will be placed in fred's
+# home directory. Note that fred must have write access to the spool directory,
+# wherever it is.
;[fredsprn]
; comment = Fred's Printer
; valid users = fred
@@ -184,9 +193,9 @@
; public = no
; writable = no
; printable = yes
-;
-; A private directory, usable only by fred. Note that fred requires write
-; access to the directory.
+
+# A private directory, usable only by fred. Note that fred requires write
+# access to the directory.
;[fredsdir]
; comment = Fred's Service
; path = /usr/somewhere/private
@@ -194,36 +203,34 @@
; public = no
; writable = yes
; printable = no
-;
-; a service which has a different directory for each machine that connects
-; this allows you to tailor configurations to incoming machines. You could
-; also use the %u option to tailor it by user name.
-; The %m gets replaced with the machine name that is connecting.
+
+# a service which has a different directory for each machine that connects
+# this allows you to tailor configurations to incoming machines. You could
+# also use the %u option to tailor it by user name.
+# The %m gets replaced with the machine name that is connecting.
;[pchome]
; comment = PC Directories
; path = /usr/pc/%m
; public = no
; writable = yes
-;
-;
-; A publicly accessible directory, read/write to all users. Note that all files
-; created in the directory by users will be owned by the default user, so
-; any user with access can delete any other user's files. Obviously this
-; directory must be writable by the default user. Another user could of course
-; be specified, in which case all files would be owned by that user instead.
+
+# A publicly accessible directory, read/write to all users. Note that all files
+# created in the directory by users will be owned by the default user, so
+# any user with access can delete any other user's files. Obviously this
+# directory must be writable by the default user. Another user could of course
+# be specified, in which case all files would be owned by that user instead.
;[public]
; path = /usr/somewhere/else/public
; public = yes
; only guest = yes
; writable = yes
; printable = no
-;
-;
-; The following two entries demonstrate how to share a directory so that two
-; users can place files there that will be owned by the specific users. In this
-; setup, the directory should be writable by both users and should have the
-; sticky bit set on it to prevent abuse. Obviously this could be extended to
-; as many users as required.
+
+# The following two entries demonstrate how to share a directory so that two
+# users can place files there that will be owned by the specific users. In this
+# setup, the directory should be writable by both users and should have the
+# sticky bit set on it to prevent abuse. Obviously this could be extended to
+# as many users as required.
;[myshare]
; comment = Mary's and Fred's stuff
; path = /usr/somewhere/shared
@@ -233,3 +240,4 @@
; printable = no
; create mask = 0765
+
diff --git a/source/arcfour.c b/source/arcfour.c
deleted file mode 100644
index a28d702a861..00000000000
--- a/source/arcfour.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
-
- a implementation of arcfour designed for use in the
- SMB password change protocol based on the description
- in 'Applied Cryptography', 2nd Edition.
-
- Copyright (C) Jeremy Allison 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "arcfour.h"
-
-void set_arc4_key(unsigned char *data, int key_length, arc4_key *arckey)
-{
- unsigned int i;
- unsigned char j;
- unsigned char tc;
- unsigned char *s_box = &arckey->s_box[0];
-
- arckey->index_i = 0;
- arckey->index_j = 0;
- for(i = 0; i < 256; i++)
- s_box[i] = (unsigned char)i;
-
- j = 0;
- for( i = 0; i < 256; i++)
- {
- j += (s_box[i] + data[i%key_length]);
- tc = s_box[i];
- s_box[i] = s_box[j];
- s_box[j] = tc;
- }
-}
-
-void arc4(arc4_key *arckey, unsigned char *data_in, unsigned char *data_out,
- int length)
-{
- unsigned char tc;
- int ind;
- unsigned char i, j;
- unsigned char t;
- unsigned char *s_box = &arckey->s_box[0];
-
- for( ind = 0; ind < length; ind++)
- {
- i = ++arckey->index_i;
- j = arckey->index_j += s_box[i];
- tc = s_box[i];
- s_box[i] = s_box[j];
- s_box[j] = tc;
- t = s_box[i] + s_box[j];
- *data_out++ = *data_in++ ^ s_box[t];
- }
-}
-
-#if 0
-/* Test vector */
-unsigned char key_data[] = { 0x61, 0x8a, 0x63, 0xd2, 0xfb };
-unsigned char plaintext[] = { 0xdc, 0xee, 0x4c, 0xf9, 0x2c };
-unsigned char ciphertext[] = { 0xf1, 0x38, 0x29, 0xc9, 0xde };
-
-int main(int argc, char *argv[])
-{
- unsigned char out[5];
- arc4_key key;
-
- set_arc4_key(key_data, 5, &key);
- arc4(&key, plaintext, out, 5);
-
- if(memcmp(out, ciphertext, 5) ==0)
- printf("Test ok !\n");
- else
- printf("Test fail !\n");
- return 0;
-}
-#endif
diff --git a/source/arcfour.h b/source/arcfour.h
deleted file mode 100644
index 34a4e8f91be..00000000000
--- a/source/arcfour.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef _ARC4_H_
-#define _ARC4_H_
-
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
-
- a implementation of arcfour designed for use in the
- SMB password change protocol based on the description
- in 'Applied Cryptography', 2nd Edition.
-
- Copyright (C) Jeremy Allison 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-typedef struct {
- unsigned char s_box[256];
- unsigned char index_i;
- unsigned char index_j;
-} arc4_key;
-
-extern void set_arc4_key(unsigned char *data, int key_length, arc4_key *arckey);
-extern void arc4(arc4_key *arckey, unsigned char *data_in,
- unsigned char *data_out, int length);
-
-#endif /* _ARC4_H_ */
diff --git a/source/cgi.c b/source/cgi.c
deleted file mode 100644
index 56c293985d6..00000000000
--- a/source/cgi.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- some simple CGI helper routines
- Copyright (C) Andrew Tridgell 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#include "includes.h"
-
-#define MAX_VARIABLES 512
-
-struct var {
- char *name;
- char *value;
-};
-
-static struct var variables[MAX_VARIABLES];
-static int num_variables;
-
-
-static int grab_line(int *cl, char *line, int maxsize)
-{
- int i = 0;
-
- while ((*cl)) {
- int c = fgetc(stdin);
- (*cl)--;
-
- if (c == EOF) {
- (*cl) = 0;
- break;
- }
-
- if (c == '+') {
- c = ' ';
- }
-
- if (c == '\r') continue;
-
- if (strchr("\n&", c)) break;
-
- if (c == '%' && (*cl) >= 2) {
- int c1, c2;
- c1 = fgetc(stdin);
- c2 = fgetc(stdin);
- (*cl) -= 2;
- if (c1 == EOF || c2 == EOF) break;
- if (c1 >= '0' && c1 <= '9')
- c1 = c1 - '0';
- else if (c1 >= 'A' && c1 <= 'F')
- c1 = 10 + c1 - 'A';
- else if (c1 >= 'a' && c1 <= 'f')
- c1 = 10 + c1 - 'a';
- else break;
-
- if (c2 >= '0' && c2 <= '9')
- c2 = c2 - '0';
- else if (c2 >= 'A' && c2 <= 'F')
- c2 = 10 + c2 - 'A';
- else if (c2 >= 'a' && c2 <= 'f')
- c2 = 10 + c2 - 'a';
- else break;
-
- c = (c1<<4) | c2;
- }
-
- line[i++] = c;
-
- if (i == maxsize) break;
- }
-
- /* now unescape the line */
-
-
- line[i] = 0;
- return 1;
-}
-
-
-/***************************************************************************
- load all the variables passed to the CGI program
- ***************************************************************************/
-void cgi_load_variables(void)
-{
- static pstring line;
- char *p;
- int len;
-
- if (!(p=getenv("CONTENT_LENGTH"))) return;
-
- len = atoi(p);
-
- if (len <= 0) return;
-
-
-
- while (len && grab_line(&len, line, sizeof(line)-1)) {
- p = strchr(line,'=');
- if (!p) continue;
-
- *p = 0;
-
- variables[num_variables].name = strdup(line);
- variables[num_variables].value = strdup(p+1);
-
- if (!variables[num_variables].name ||
- !variables[num_variables].value)
- continue;
-
-#if 0
- printf("%s=%s<br>\n",
- variables[num_variables].name,
- variables[num_variables].value);
-#endif
-
- num_variables++;
- if (num_variables == MAX_VARIABLES) break;
- }
-
- fclose(stdin);
-}
-
-
-/***************************************************************************
- find a variable passed via CGI
- ***************************************************************************/
-char *cgi_variable(char *name)
-{
- int i;
-
- for (i=0;i<num_variables;i++)
- if (strcmp(variables[i].name, name) == 0)
- return variables[i].value;
- return NULL;
-}
-
-
-/***************************************************************************
- return the value of a CGI boolean variable.
- ***************************************************************************/
-int cgi_boolean(char *name, int def)
-{
- char *p = cgi_variable(name);
-
- if (!p) return def;
-
- return strcmp(p, "1") == 0;
-}
diff --git a/source/client/client.c b/source/client/client.c
index 275d03ddba2..a48d1b4990b 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -143,8 +143,12 @@ extern int Client;
#define USENMB
+#ifdef KANJI
extern int coding_system;
-static BOOL setup_term_code (char *code)
+#define CNV_LANG(s) (coding_system == DOSV_CODE?s:dos_to_unix(s, False))
+#define CNV_INPUT(s) (coding_system == DOSV_CODE?s:unix_to_dos(s, True))
+static BOOL
+setup_term_code (char *code)
{
int new;
new = interpret_coding_system (code, UNKNOWN_CODE);
@@ -154,8 +158,10 @@ static BOOL setup_term_code (char *code)
}
return False;
}
+#else
#define CNV_LANG(s) dos2unix_format(s,False)
#define CNV_INPUT(s) unix2dos_format(s,True)
+#endif
/****************************************************************************
setup basics in a outgoing packet
@@ -3303,11 +3309,15 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu
int passlen = strlen(pass)+1;
strcpy(pword,pass);
+#ifdef SMB_PASSWD
if (doencrypt && *pass) {
DEBUG(3,("Using encrypted passwords\n"));
passlen = 24;
SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword);
}
+#else
+ doencrypt = False;
+#endif
/* if in share level security then don't send a password now */
if (!(sec_mode & 1)) {strcpy(pword, "");passlen=1;}
@@ -3401,6 +3411,13 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu
uid = SVAL(inbuf,smb_uid);
}
+ if (SVAL(inbuf, smb_vwv2) & 1)
+ DEBUG(1,("connected as guest "));
+ if (sec_mode & 1)
+ DEBUG(1,("security=user\n"));
+ else
+ DEBUG(1,("security=share\n"));
+
/* now we've got a connection - send a tcon message */
bzero(outbuf,smb_size);
@@ -3418,10 +3435,12 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu
fstring pword;
strcpy(pword,pass);
+#ifdef SMB_PASSWD
if (doencrypt && *pass) {
passlen=24;
SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword);
}
+#endif
/* if in user level security then don't send a password now */
if ((sec_mode & 1)) {
@@ -3508,6 +3527,7 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu
free(inbuf);
free(outbuf);
}
+
return True;
}
@@ -3681,6 +3701,7 @@ static BOOL send_trans_request(char *outbuf,int trans,
return(True);
}
+
/****************************************************************************
try and browse available connections on a host
****************************************************************************/
@@ -4106,7 +4127,7 @@ static BOOL open_sockets(int port )
strcpy(desthost,host);
}
- if (*myname == 0) {
+ if (!(*myname)) {
get_myname(myname,NULL);
}
strupper(myname);
@@ -4380,6 +4401,10 @@ static void usage(char *pname)
DEBUG(0,("Usage: %s service <password> [-p port] [-d debuglevel] [-l log] ",
pname));
+#ifdef KANJI
+ DEBUG(0,("[-t termcode] "));
+#endif /* KANJI */
+
DEBUG(0,("\nVersion %s\n",VERSION));
DEBUG(0,("\t-p port listen on the specified port\n"));
DEBUG(0,("\t-d debuglevel set the debuglevel\n"));
@@ -4395,7 +4420,9 @@ static void usage(char *pname)
DEBUG(0,("\t-U username set the network username\n"));
DEBUG(0,("\t-W workgroup set the workgroup name\n"));
DEBUG(0,("\t-c command string execute semicolon separated commands\n"));
+#ifdef KANJI
DEBUG(0,("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"));
+#endif /* KANJI */
DEBUG(0,("\t-T<c|x>IXgbNa command line tar\n"));
DEBUG(0,("\t-D directory start from directory\n"));
DEBUG(0,("\n"));
@@ -4417,14 +4444,6 @@ static void usage(char *pname)
BOOL message = False;
extern char tar_type;
static pstring servicesf = CONFIGFILE;
- pstring term_code;
- char *p;
-
-#ifdef KANJI
- strcpy(term_code, KANJI);
-#else /* KANJI */
- *term_code = 0;
-#endif /* KANJI */
*query_host = 0;
*base_directory = 0;
@@ -4444,27 +4463,10 @@ static void usage(char *pname)
umask(myumask);
if (getenv("USER"))
- {
- strcpy(username,getenv("USER"));
-
- /* modification to support userid%passwd syntax in the USER var
- 25.Aug.97, jdblair@uab.edu */
-
- if ((p=strchr(username,'%')))
{
- *p = 0;
- strcpy(password,p+1);
- got_pass = True;
- memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
+ strcpy(username,getenv("USER"));
+ strupper(username);
}
- strupper(username);
- }
-
- /* modification to support PASSWD environmental var
- 25.Aug.97, jdblair@uab.edu */
-
- if (getenv("PASSWD"))
- strcpy(password,getenv("PASSWD"));
if (*username == 0 && getenv("LOGNAME"))
{
@@ -4513,6 +4515,9 @@ static void usage(char *pname)
}
}
+#ifdef KANJI
+ setup_term_code (KANJI);
+#endif
while ((opt =
getopt(argc, argv,"s:B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
switch (opt)
@@ -4608,7 +4613,13 @@ static void usage(char *pname)
strcpy(servicesf, optarg);
break;
case 't':
- strcpy(term_code, optarg);
+#ifdef KANJI
+ if (!setup_term_code (optarg)) {
+ DEBUG(0, ("%s: unknown terminal code name\n", optarg));
+ usage (pname);
+ exit (1);
+ }
+#endif
break;
default:
usage(pname);
@@ -4633,23 +4644,11 @@ static void usage(char *pname)
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
}
- codepage_initialise(lp_client_code_page());
-
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- if (!setup_term_code (term_code))
- {
- DEBUG(0, ("%s: unknown terminal code name\n", optarg));
- usage (pname);
- exit (1);
- }
- }
-
if (*workgroup == 0)
strcpy(workgroup,lp_workgroup());
load_interfaces();
- get_myname(*myname?NULL:myname,NULL);
+ get_myname((*myname)?NULL:myname,NULL);
strupper(myname);
if (tar_type) {
@@ -4775,6 +4774,7 @@ err_code_struct dos_msgs[] = {
{"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
{"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
{"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
+ {"ERRnosuchshare", 67, "You specified an invalid share name"},
{"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
{"ERRbadpipe",230,"Pipe invalid."},
{"ERRpipebusy",231,"All instances of the requested pipe are busy."},
diff --git a/source/client/clientutil.c b/source/client/clientutil.c
index d16e5a471fc..cb0a731480c 100644
--- a/source/client/clientutil.c
+++ b/source/client/clientutil.c
@@ -77,7 +77,7 @@ extern int Client;
/****************************************************************************
setup basics in a outgoing packet
****************************************************************************/
-void cli_setup_pkt(char *outbuf)
+static void cli_setup_pkt(char *outbuf)
{
SSVAL(outbuf,smb_pid,pid);
SSVAL(outbuf,smb_uid,uid);
@@ -89,11 +89,14 @@ void cli_setup_pkt(char *outbuf)
}
}
+
+
/****************************************************************************
receive a SMB trans or trans2 response allocating the necessary memory
****************************************************************************/
-BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len,
- int *param_len, char **data,char **param)
+static BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len,
+ int *param_len, char **data,
+ char **param)
{
int total_data=0;
int total_param=0;
@@ -164,7 +167,7 @@ BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len,
/****************************************************************************
send a session request
****************************************************************************/
-BOOL cli_send_session_request(char *inbuf, char *outbuf)
+static BOOL cli_send_session_request(char *inbuf, char *outbuf)
{
fstring dest;
char *p;
@@ -441,11 +444,15 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
int passlen = strlen(pass)+1;
fstrcpy(pword,pass);
+#ifdef SMB_PASSWD
if (doencrypt && *pass) {
DEBUG(5,("Using encrypted passwords\n"));
passlen = 24;
SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword);
}
+#else
+ doencrypt = False;
+#endif
/* if in share level security then don't send a password now */
if (!(sec_mode & 1)) {fstrcpy(pword, "");passlen=1;}
@@ -556,10 +563,12 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
fstring pword;
fstrcpy(pword,pass);
+#ifdef SMB_PASSWD
if (doencrypt && *pass) {
passlen=24;
SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword);
}
+#endif
/* if in user level security then don't send a password now */
if ((sec_mode & 1)) {
@@ -655,35 +664,12 @@ void cli_send_logout(void)
}
-
-/****************************************************************************
-call a remote api
-****************************************************************************/
-BOOL cli_call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt,
- int *rdrcnt, char *param,char *data, char **rparam,char **rdata)
-{
- static char *inbuf=NULL;
- static char *outbuf=NULL;
-
- if (!inbuf) inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
- if (!outbuf) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
-
- cli_send_trans_request(outbuf,SMBtrans,"\\PIPE\\LANMAN",0,0,
- data,param,NULL,
- drcnt,prcnt,0,
- mdrcnt,mprcnt,0);
-
- return (cli_receive_trans_response(inbuf,SMBtrans,
- rdrcnt,rprcnt,
- rdata,rparam));
-}
-
/****************************************************************************
send a SMB trans or trans2 request
****************************************************************************/
-BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int flags,
- char *data,char *param,uint16 *setup, int ldata,int lparam,
- int lsetup,int mdata,int mparam,int msetup)
+static BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int flags,
+ char *data,char *param,uint16 *setup, int ldata,int lparam,
+ int lsetup,int mdata,int mparam,int msetup)
{
int i;
int this_ldata,this_lparam;
@@ -791,6 +777,31 @@ BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int fl
}
+
+/****************************************************************************
+call a remote api
+****************************************************************************/
+BOOL cli_call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt,
+ int *rdrcnt, char *param,char *data,
+ char **rparam, char **rdata)
+{
+ static char *inbuf=NULL;
+ static char *outbuf=NULL;
+
+ if (!inbuf) inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
+ if (!outbuf) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
+
+ cli_send_trans_request(outbuf,SMBtrans,"\\PIPE\\LANMAN",0,0,
+ data,param,NULL,
+ drcnt,prcnt,0,
+ mdrcnt,mprcnt,0);
+
+ return (cli_receive_trans_response(inbuf,SMBtrans,
+ rdrcnt,rprcnt,
+ rdata,rparam));
+}
+
+
/****************************************************************************
open the client sockets
****************************************************************************/
diff --git a/source/client/clitar.c b/source/client/clitar.c
index c085cd9e5a1..d5bca8c5bbb 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -90,7 +90,7 @@ static void unfixtarname();
Write a tar header to buffer
****************************************************************************/
static void writetarheader(int f, char *aname, int size, time_t mtime,
- char *amode)
+ char *amode)
{
union hblock hb;
int i, chk, l;
@@ -99,21 +99,10 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
memset(hb.dummy, 0, sizeof(hb.dummy));
l=strlen(aname);
- if (l >= NAMSIZ) {
- /* write a GNU tar style long header */
- char *b;
- b = (char *)malloc(l+TBLOCK+100);
- if (!b) {
- DEBUG(0,("out of memory\n"));
- exit(1);
- }
- writetarheader(f, "/./@LongLink", l+1, 0, " 0 \0");
- memset(b, 0, l+TBLOCK+100);
- fixtarname(b, aname, l+1);
- i = strlen(b)+1;
- dotarbuf(f, b, TBLOCK*((i+(TBLOCK-1)/TBLOCK)));
- free(b);
- }
+ if (l >= NAMSIZ)
+ {
+ DEBUG(0, ("tar file %s name length exceeds NAMSIZ\n", aname));
+ }
/* use l + 1 to do the null too */
fixtarname(hb.dbuf.name, aname, (l >= NAMSIZ) ? NAMSIZ : l + 1);
@@ -130,13 +119,8 @@ static void writetarheader(int f, char *aname, int size, time_t mtime,
oct_it((long) size, 13, hb.dbuf.size);
oct_it((long) mtime, 13, hb.dbuf.mtime);
memcpy(hb.dbuf.chksum, " ", sizeof(hb.dbuf.chksum));
+ hb.dbuf.linkflag='0';
memset(hb.dbuf.linkname, 0, NAMSIZ);
- if (strcmp("/./@LongLink", aname) == 0) {
- /* we're doing a GNU tar long filename */
- hb.dbuf.linkflag='L';
- } else {
- hb.dbuf.linkflag='0';
- }
for (chk=0, i=sizeof(hb.dummy), jp=hb.dummy; --i>=0;) chk+=(0xFF & *jp++);
@@ -322,35 +306,27 @@ static void fixtarname(char *tptr, char *fp, int l)
* to lovely unix /'s :-} */
*tptr++='.';
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- while (l > 0) {
- if (is_shift_jis (*fp)) {
- *tptr++ = *fp++;
- *tptr++ = *fp++;
- l -= 2;
- } else if (is_kana (*fp)) {
- *tptr++ = *fp++;
- l--;
- } else if (*fp == '\\') {
- *tptr++ = '/';
- fp++;
- l--;
- } else {
- *tptr++ = *fp++;
- l--;
- }
- }
- }
- else
- {
- while (l--)
- {
- *tptr=(*fp == '\\') ? '/' : *fp;
- tptr++;
+#ifdef KANJI
+ while (l > 0) {
+ if (is_shift_jis (*fp)) {
+ *tptr++ = *fp++;
+ *tptr++ = *fp++;
+ l -= 2;
+ } else if (is_kana (*fp)) {
+ *tptr++ = *fp++;
+ l--;
+ } else if (*fp == '\\') {
+ *tptr++ = '/';
fp++;
+ l--;
+ } else {
+ *tptr++ = *fp++;
+ l--;
}
}
+#else
+ while (l--) { *tptr=(*fp == '\\') ? '/' : *fp; tptr++; fp++; }
+#endif
}
/****************************************************************************
@@ -1074,7 +1050,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
* write out in 512 byte intervals */
if (dotarbuf(tarhandle,dataptr,datalen) != datalen)
{
- DEBUG(0,("Error writing to tar file - %s\n", strerror(errno)));
+ DEBUG(0,("Error writing local file\n"));
break;
}
@@ -1094,7 +1070,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
{
DEBUG(0, ("Didn't get entire file. size=%d, nread=%d\n", finfo.size, nread));
if (padit(inbuf, BUFFER_SIZE, finfo.size - nread))
- DEBUG(0,("Error writing tar file - %s\n", strerror(errno)));
+ DEBUG(0,("Error writing local file\n"));
}
/* round tar file to nearest block */
@@ -1227,35 +1203,27 @@ static void unfixtarname(char *tptr, char *fp, int l)
if (*fp == '.') fp++;
if (*fp == '\\' || *fp == '/') fp++;
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- while (l > 0) {
- if (is_shift_jis (*fp)) {
- *tptr++ = *fp++;
- *tptr++ = *fp++;
- l -= 2;
- } else if (is_kana (*fp)) {
- *tptr++ = *fp++;
- l--;
- } else if (*fp == '/') {
- *tptr++ = '\\';
- fp++;
- l--;
- } else {
- *tptr++ = *fp++;
- l--;
- }
- }
- }
- else
- {
- while (l--)
- {
- *tptr=(*fp == '/') ? '\\' : *fp;
- tptr++;
+#ifdef KANJI
+ while (l > 0) {
+ if (is_shift_jis (*fp)) {
+ *tptr++ = *fp++;
+ *tptr++ = *fp++;
+ l -= 2;
+ } else if (is_kana (*fp)) {
+ *tptr++ = *fp++;
+ l--;
+ } else if (*fp == '/') {
+ *tptr++ = '\\';
fp++;
+ l--;
+ } else {
+ *tptr++ = *fp++;
+ l--;
}
}
+#else
+ while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; }
+#endif
}
static void do_tarput()
@@ -1761,8 +1729,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY)) == -1)
|| (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0))
{
- DEBUG(0,("Error opening local file %s - %s\n",
- argv[Optind], strerror(errno)));
+ DEBUG(0,("Error opening local file %s\n",argv[Optind]));
return(0);
}
}
diff --git a/source/codepages/codepage_def.437 b/source/codepages/codepage_def.437
deleted file mode 100644
index d357c074e44..00000000000
--- a/source/codepages/codepage_def.437
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-# Codepage definition file for IBM Code Page 437 - MS-DOS Latin US
-# defines lower->upper mapping.
-# Written by Jeremy Allison <jallison@whistle.com>
-
-# The columns are :
-# lower upper map upper to lower map lower to upper
-#
- 0x87 0x80 True True
- 0x81 0x9A True True
- 0x82 0x90 True True
- 0x83 0x41 True False
- 0x84 0x8E True True
- 0x85 0x41 True False
- 0x86 0x8F True True
- 0x88 0x45 True False
- 0x89 0x45 True False
- 0x8A 0x45 True False
- 0x8B 0x49 True False
- 0x8C 0x49 True False
- 0x8D 0x49 True False
- 0x91 0x92 True True
- 0x93 0x4F True False
- 0x94 0x99 True True
- 0x95 0x4F True False
- 0x96 0x55 True False
- 0x97 0x55 True False
- 0x9B 0 False False
- 0x9C 0 False False
- 0x9D 0 False False
- 0xA0 0x41 True False
- 0xA1 0x49 True False
- 0xA2 0x4F True False
- 0xA3 0x55 True False
- 0xA4 0xA5 True True
- 0xA8 0 False False
- 0xAD 0 False False
- 0xAE 0 False False
- 0xAF 0 False False
- 0xE0 0 False False
- 0xE1 0 False False
- 0xE2 0 False False
- 0xE3 0 False False
- 0xE4 0 False False
- 0xE5 0 False False
- 0xE6 0 False False
- 0xE7 0 False False
- 0xE8 0 False False
- 0xE9 0 False False
- 0xEA 0 False False
- 0xEB 0 False False
- 0xEC 0 False False
- 0xED 0 False False
- 0xEE 0 False False
- 0xEF 0 False False
diff --git a/source/codepages/codepage_def.850 b/source/codepages/codepage_def.850
deleted file mode 100644
index e2466a707af..00000000000
--- a/source/codepages/codepage_def.850
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-# Codepage definition file for IBM Code Page 850 - MS-DOS Latin 1
-# defines lower->upper mapping.
-# Written by Jeremy Allison (jallison@whistle.com)
-
-# The columns are :
-# lower upper map upper to lower map lower to upper
-#
- 0x85 0xB7 True True
- 0xA0 0xB5 True True
- 0x83 0xB6 True True
- 0xC6 0xC7 True True
- 0x84 0x8E True True
- 0x86 0x8F True True
- 0x91 0x92 True True
- 0x87 0x80 True True
- 0x8A 0xD4 True True
- 0x82 0x90 True True
- 0x88 0xD2 True True
- 0x89 0xD3 True True
- 0x8D 0xDE True True
- 0xA1 0xD6 True True
- 0x8C 0xD7 True True
- 0x8B 0xD8 True True
- 0xD0 0xD1 True True
- 0xA4 0xA5 True True
- 0x95 0xE3 True True
- 0xA2 0xE0 True True
- 0x93 0xE2 True True
- 0xE4 0xE5 True True
- 0x94 0x99 True True
- 0x9B 0x9D True True
- 0x97 0xEB True True
- 0xA3 0xE9 True True
- 0x96 0xEA True True
- 0x81 0x9A True True
- 0xEC 0xED True True
- 0xE7 0xE8 True True
- 0x9C 0 False False
diff --git a/source/codepages/codepage_def.852 b/source/codepages/codepage_def.852
deleted file mode 100644
index ed1423428ca..00000000000
--- a/source/codepages/codepage_def.852
+++ /dev/null
@@ -1,63 +0,0 @@
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-# Codepage definition file for IBM Code Page 852 - MS-DOS Latin 2
-# defines lower->upper mapping.
-# Written by Leos Bitto <bitto@altec.cz>
-
-# The columns are :
-# lower upper map upper to lower map lower to upper
-#
- 0x81 0x9A True True
- 0x82 0x90 True True
- 0x83 0xB6 True True
- 0x84 0x8E True True
- 0x85 0xDE True True
- 0x86 0x8F True True
- 0x87 0x80 True True
- 0x88 0x9D True True
- 0x89 0xD3 True True
- 0x8B 0x8A True True
- 0x8C 0xD7 True True
- 0x92 0x91 True True
- 0x93 0xE2 True True
- 0x94 0x99 True True
- 0x96 0x95 True True
- 0x98 0x97 True True
- 0x9C 0x9B True True
- 0x9F 0xAC True True
- 0xA0 0xB5 True True
- 0xA1 0xD6 True True
- 0xA2 0xE0 True True
- 0xA3 0xE9 True True
- 0xA5 0xA4 True True
- 0xA7 0xA6 True True
- 0xA9 0xA8 True True
- 0xAB 0x8D True True
- 0xAD 0xB8 True True
- 0xBE 0xBD True True
- 0xC7 0xC6 True True
- 0xD0 0xD1 True True
- 0xD4 0xD2 True True
- 0xD8 0xB7 True True
- 0xE4 0xE3 True True
- 0xE5 0xD5 True True
- 0xE7 0xE6 True True
- 0xEA 0xE8 True True
- 0xEC 0xED True True
- 0xEE 0xDD True True
- 0xFB 0xEB True True
- 0xFD 0xFC True True
diff --git a/source/codepages/codepage_def.932 b/source/codepages/codepage_def.932
deleted file mode 100644
index 8d9ff631fba..00000000000
--- a/source/codepages/codepage_def.932
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-# Codepage definition file for IBM Code Page 932 - MS-DOS Japanese SJIS
-# defines lower->upper mapping.
-# Written by Jeremy Allison <jallison@whistle.com>
-
-# The columns are :
-# lower upper map upper to lower map lower to upper
-#
-# This file is intentionaly empty - no mappings are done. \ No newline at end of file
diff --git a/source/include/charset.h b/source/include/charset.h
index fb184897c07..5f5e2016ee1 100644
--- a/source/include/charset.h
+++ b/source/include/charset.h
@@ -63,13 +63,3 @@ extern void charset_initialise(void);
#define issafe(c) (isalnum((c&0xff)) || strchr("-._",c))
#endif
-/* Dynamic codepage files defines. */
-
-/* Version id for dynamically loadable codepage files. */
-#define CODEPAGE_FILE_VERSION_ID 0x1
-/* Version 1 codepage file header size. */
-#define CODEPAGE_HEADER_SIZE 8
-/* Offsets for codepage file header entries. */
-#define CODEPAGE_VERSION_OFFSET 0
-#define CODEPAGE_CLIENT_CODEPAGE_OFFSET 2
-#define CODEPAGE_LENGTH_OFFSET 4
diff --git a/source/include/includes.h b/source/include/includes.h
index 2329553d234..4e48e87a7c1 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -563,7 +563,9 @@ char *mktemp(char *); /* No standard include */
#define USE_SETSID
#define USE_SETRES
#define DEFAULT_PRINTING PRINT_HPUX
-#define SIGCLD_IGNORE
+/* Ken Weiss <krweiss@ucdavis.edu> tells us that SIGCLD_IGNORE is
+ not good for HPUX */
+/* #define SIGCLD_IGNORE */
#endif /* HPUX */
@@ -1194,10 +1196,6 @@ it works and getting lots of bug reports */
#define QSORT_CAST (int (*)())
#endif
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK 0x7f000001
-#endif /* INADDR_LOOPBACK */
-
/* this is a rough check to see if this machine has a lstat() call.
it is not guaranteed to work */
#if !(defined(S_ISLNK) || defined(S_IFLNK))
diff --git a/source/include/kanji.h b/source/include/kanji.h
index cf303659208..865ac3b2c90 100644
--- a/source/include/kanji.h
+++ b/source/include/kanji.h
@@ -27,6 +27,8 @@
#ifndef _KANJI_H_
#define _KANJI_H_
+#ifdef KANJI
+
/* FOR SHIFT JIS CODE */
#define is_shift_jis(c) \
((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \
@@ -105,8 +107,16 @@
#else /* not _KANJI_C_ */
-extern char *(*_dos_to_unix)(char *str, BOOL overwrite);
-extern char *(*_unix_to_dos)(char *str, BOOL overwrite);
+extern char* (*_dos_to_unix) (const char *str, BOOL overwrite);
+extern char* (*_unix_to_dos) (const char *str, BOOL overwrite);
+
+#define unix_to_dos (*_unix_to_dos)
+#define dos_to_unix (*_dos_to_unix)
+
+extern char *sj_strtok (char *s1, const char *s2);
+extern char *sj_strchr (const char *s, int c);
+extern char *sj_strrchr (const char *s, int c);
+extern char *sj_strstr (const char *s1, const char *s2);
#define strchr sj_strchr
#define strrchr sj_strrchr
@@ -127,7 +137,11 @@ extern char *(*_unix_to_dos)(char *str, BOOL overwrite);
int interpret_coding_system (char *str, int def);
+#else
+
#define unix_to_dos(x,y) unix2dos_format(x,y)
#define dos_to_unix(x,y) dos2unix_format(x,y)
+#endif /* not KANJI */
+
#endif /* _KANJI_H_ */
diff --git a/source/include/local.h b/source/include/local.h
index 3ce75eeb4e7..92d566cf82d 100644
--- a/source/include/local.h
+++ b/source/include/local.h
@@ -43,7 +43,7 @@
#define WORDMAX 0xFFFF
/* the maximum password length before we declare a likely attack */
-#define MAX_PASSWORD_LENGTH 200
+#define MAX_PASS_LEN 200
/* separators for lists */
#define LIST_SEP " \t,;:\n\r"
@@ -147,10 +147,6 @@
/* shall we support browse requests via a FIFO to nmbd? */
#define ENABLE_FIFO 1
-/* keep the password server open, this uses up a aocket, but is needed
- by many apps */
-#define KEEP_PASSWORD_SERVER_OPEN 1
-
/* how long to wait for a socket connect to happen */
#define LONG_CONNECT_TIMEOUT 30
#define SHORT_CONNECT_TIMEOUT 5
@@ -159,9 +155,4 @@
/* the directory to sit in when idle */
/* #define IDLE_DIR "/" */
-/* Timout (in seconds) to wait for an oplock breal
- message to return. */
-
-#define OPLOCK_BREAK_TIMEOUT 30
-
#endif
diff --git a/source/include/nameserv.h b/source/include/nameserv.h
index 83f3a3c5246..b0409572ec8 100644
--- a/source/include/nameserv.h
+++ b/source/include/nameserv.h
@@ -246,6 +246,7 @@ struct response_record
BOOL recurse;
struct in_addr send_ip;
struct in_addr reply_to_ip;
+ int reply_id;
int num_msgs;
diff --git a/source/include/proto.h b/source/include/proto.h
index 8818b9b5274..e9776bf2548 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -32,19 +32,31 @@ void cmd_help(void);
BOOL reopen_connection(char *inbuf,char *outbuf);
char *smb_errstr(char *inbuf);
+/*The following definitions come from clientgen.c */
+
+BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
+BOOL cli_session_setup(struct cli_state *cli,
+ char *user,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen,
+ char *workgroup);
+BOOL cli_send_tconX(struct cli_state *cli,
+ char *share, char *dev, char *pword, int passlen);
+BOOL cli_tdis(struct cli_state *cli);
+BOOL cli_negprot(struct cli_state *cli);
+BOOL cli_session_request(struct cli_state *cli, char *host, int name_type,
+ char *myname);
+BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip);
+BOOL cli_initialise(struct cli_state *cli);
+void cli_shutdown(struct cli_state *cli);
+
/*The following definitions come from clientutil.c */
-void cli_setup_pkt(char *outbuf);
-BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len,
- int *param_len, char **data,char **param);
-BOOL cli_send_session_request(char *inbuf, char *outbuf);
BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setup);
void cli_send_logout(void);
BOOL cli_call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt,
- int *rdrcnt, char *param,char *data, char **rparam,char **rdata);
-BOOL cli_send_trans_request(char *outbuf, int trans, char *name, int fid, int flags,
- char *data,char *param,uint16 *setup, int ldata,int lparam,
- int lsetup,int mdata,int mparam,int msetup);
+ int *rdrcnt, char *param,char *data,
+ char **rparam, char **rdata);
BOOL cli_open_sockets(int port);
BOOL cli_reopen_connection(char *inbuf,char *outbuf);
char *smb_errstr(char *inbuf);
@@ -114,10 +126,6 @@ int reply_trans(char *inbuf,char *outbuf);
/*The following definitions come from kanji.c */
-char *sj_strtok(char *s1, char *s2);
-char *sj_strstr(char *s1, char *s2);
-char *sj_strchr (char *s, int c);
-char *sj_strrchr(char *s, int c);
int interpret_coding_system(char *str, int def);
/*The following definitions come from loadparm.c */
@@ -183,7 +191,6 @@ int lp_maxmux(void);
int lp_maxpacket(void);
int lp_keepalive(void);
int lp_passwordlevel(void);
-int lp_usernamelevel(void);
int lp_readsize(void);
int lp_shmem_size(void);
int lp_shmem_hash_size(void);
@@ -248,7 +255,6 @@ BOOL lp_map_archive(int );
BOOL lp_locking(int );
BOOL lp_strict_locking(int );
BOOL lp_share_modes(int );
-BOOL lp_oplocks(int );
BOOL lp_onlyuser(int );
BOOL lp_manglednames(int );
BOOL lp_widelinks(int );
@@ -257,7 +263,7 @@ BOOL lp_syncalways(int );
BOOL lp_map_system(int );
BOOL lp_delete_readonly(int );
BOOL lp_fake_oplocks(int );
-BOOL lp_recursive_veto_delete(int );
+BOOL lp_dos_filetimes(int );
int lp_create_mode(int );
int lp_force_create_mode(int );
int lp_dir_mode(int );
@@ -270,20 +276,14 @@ BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir);
int lp_add_service(char *pszService, int iDefaultService);
BOOL lp_add_printer(char *pszPrintername, int iDefaultService);
BOOL lp_file_list_changed(void);
-BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue);
-int lp_next_parameter(int snum, int *i, char *label,
- char *value, int allparameters);
BOOL lp_snum_ok(int iService);
BOOL lp_loaded(void);
void lp_killunused(BOOL (*snumused)(int ));
BOOL lp_load(char *pszFname,BOOL global_only);
int lp_numservices(void);
-void lp_dump(FILE *f);
+void lp_dump(void);
int lp_servicenumber(char *pszServiceName);
char *volume_label(int snum);
-void lp_rename_service(int snum, char *new_name);
-void lp_remove_service(int snum);
-void lp_copy_service(int snum, char *new_name);
int lp_default_server_announce(void);
int lp_major_announce_version(void);
int lp_minor_announce_version(void);
@@ -300,15 +300,13 @@ BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token tok
int get_share_modes(int cnum, share_lock_token token, uint32 dev, uint32 inode,
min_share_mode_entry **old_shares);
void del_share_mode(share_lock_token token, int fnum);
-BOOL set_share_mode(share_lock_token token, int fnum, uint16 port, uint16 op_type);
-BOOL remove_share_oplock(int fnum, share_lock_token token);
+BOOL set_share_mode(share_lock_token token, int fnum);
BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok);
BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token token);
int get_share_modes(int cnum, share_lock_token token, uint32 dev, uint32 inode,
min_share_mode_entry **old_shares);
void del_share_mode(share_lock_token token, int fnum);
-BOOL set_share_mode(share_lock_token token,int fnum, uint16 port, uint16 op_type);
-BOOL remove_share_oplock(int fnum, share_lock_token token);
+BOOL set_share_mode(share_lock_token token,int fnum);
/*The following definitions come from mangle.c */
@@ -322,7 +320,6 @@ BOOL name_map_mangle(char *OutName,BOOL need83,int snum);
/*The following definitions come from md4.c */
-void mdfour(unsigned char *out, unsigned char *in, int n);
/*The following definitions come from message.c */
@@ -362,6 +359,20 @@ struct browse_cache_record *add_browser_entry(char *name, int type, char *wg,
struct in_addr ip, BOOL local);
void do_browser_lists(time_t t);
+/*The following definitions come from nameconf.c */
+
+int get_num_workgroups(void);
+int conf_workgroup_name_to_token(char *workgroup_name,char *default_name);
+char *conf_workgroup_name(int token);
+int conf_should_workgroup_member(int token);
+int conf_should_local_master(int token);
+int conf_should_domain_master(int token);
+char *conf_browsing_alias(int token);
+char *conf_browsing_alias_comment(int token);
+char *conf_alias_to_workgroup(char *alias);
+int conf_alias_to_token(char *alias);
+void read_smbbrowse_conf(char *default_name);
+
/*The following definitions come from namedbname.c */
void set_samba_nb_type(void);
@@ -396,7 +407,8 @@ struct response_record *make_response_queue_record(enum state_type state,
int quest_type, char *name,int type, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
- struct in_addr send_ip, struct in_addr reply_to_ip);
+ struct in_addr send_ip, struct in_addr reply_to_ip,
+ int reply_id);
struct response_record *find_response_record(struct subnet_record **d,
uint16 id);
@@ -498,7 +510,8 @@ struct response_record *queue_netbios_packet(struct subnet_record *d,
int name_type,int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
- struct in_addr send_ip, struct in_addr reply_to_ip);
+ struct in_addr send_ip, struct in_addr reply_to_ip,
+ int reply_id);
/*The following definitions come from nameserv.c */
@@ -543,7 +556,6 @@ BOOL reload_services(BOOL test);
/*The following definitions come from nmblib.c */
-char *lookup_opcode_name( int opcode );
void debug_nmb_packet(struct packet_struct *p);
char *namestr(struct nmb_name *n);
void free_nmb_packet(struct nmb_packet *nmb);
@@ -585,8 +597,11 @@ BOOL user_ok(char *user,int snum);
BOOL authorise_login(int snum,char *user,char *password, int pwlen,
BOOL *guest,BOOL *force,uint16 vuid);
BOOL check_hosts_equiv(char *user);
-BOOL server_cryptkey(char *buf);
-BOOL server_validate(char *buf);
+struct cli_state *server_client(void);
+struct cli_state *server_cryptkey(void);
+BOOL server_validate(char *user, char *domain,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen);
/*The following definitions come from pcap.c */
@@ -700,17 +715,20 @@ void killkids(void);
mode_t unix_mode(int cnum,int dosmode);
int dos_mode(int cnum,char *path,struct stat *sbuf);
int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st);
+int file_utime(int cnum, char *fname, struct utimbuf *times);
+BOOL set_filetime(int cnum, char *fname, time_t mtime);
BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_path);
int disk_free(char *path,int *bsize,int *dfree,int *dsize);
int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize);
BOOL check_name(char *name,int cnum);
+int fd_attempt_open(char *fname, int flags, int mode);
+void fd_attempt_reopen(char *fname, int mode, file_fd_struct *fd_ptr);
+int fd_attempt_close(file_fd_struct *fd_ptr);
void sync_file(int fnum);
-void close_file(int fnum);
+void close_file(int fnum, int normal_close);
BOOL check_file_sharing(int cnum,char *fname);
-int check_share_mode( min_share_mode_entry *share, int deny_mode, char *fname,
- BOOL fcbopen, int *flags);
void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
- int mode,int oplock_request, int *Access,int *action);
+ int mode,int *Access,int *action);
int seek_file(int fnum,uint32 pos);
int read_file(int fnum,char *data,uint32 pos,int n);
int write_file(int fnum,char *data,int n);
@@ -719,9 +737,6 @@ int find_service(char *service);
int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line);
int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line);
int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line);
-BOOL oplock_break(uint32 dev, uint32 inode, struct timeval *tval);
-BOOL request_oplock_break(min_share_mode_entry *share_entry,
- uint32 dev, uint32 inode);
BOOL snum_used(int snum);
BOOL reload_services(BOOL test);
int setup_groups(char *user, int uid, int gid, int *p_ngroups,
@@ -751,7 +766,7 @@ smb_shm_offset_t smb_shm_alloc(int size);
BOOL smb_shm_free(smb_shm_offset_t offset);
smb_shm_offset_t smb_shm_get_userdef_off(void);
BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off);
-void *smb_shm_offset2addr(smb_shm_offset_t offset);
+void * smb_shm_offset2addr(smb_shm_offset_t offset);
smb_shm_offset_t smb_shm_addr2offset(void *addr);
BOOL smb_shm_lock_hash_entry( unsigned int entry);
BOOL smb_shm_unlock_hash_entry( unsigned int entry );
@@ -759,13 +774,13 @@ BOOL smb_shm_get_usage(int *bytes_free,
int *bytes_used,
int *bytes_overhead);
-/*The following definitions come from smbdes.c */
-
-void E_P16(unsigned char *p14,unsigned char *p16);
-void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
-
/*The following definitions come from smbencrypt.c */
+void str_to_key(uchar *str,uchar *key);
+void D1(uchar *k, uchar *d, uchar *out);
+void E1(uchar *k, uchar *d, uchar *out);
+void E_P16(uchar *p14,uchar *p16);
+void E_P24(uchar *p21, uchar *c8, uchar *p24);
void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
void E_md4hash(uchar *passwd, uchar *p16);
void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
@@ -825,13 +840,13 @@ int TimeDiff(time_t t);
struct tm *LocalTime(time_t *t);
time_t interpret_long_date(char *p);
void put_long_date(char *p,time_t t);
+BOOL null_mtime(time_t mtime);
void put_dos_date(char *buf,int offset,time_t unixdate);
void put_dos_date2(char *buf,int offset,time_t unixdate);
void put_dos_date3(char *buf,int offset,time_t unixdate);
time_t make_unix_date(void *date_ptr);
time_t make_unix_date2(void *date_ptr);
time_t make_unix_date3(void *date_ptr);
-BOOL set_filetime(char *fname,time_t mtime);
char *timestring(void );
/*The following definitions come from trans2.c */
@@ -852,6 +867,8 @@ BOOL become_guest(void);
BOOL become_user(int cnum, uint16 vuid);
BOOL unbecome_user(void );
int smbrun(char *cmd,char *outfile,BOOL shared);
+void become_root(int save_dir) ;
+void unbecome_root(int restore_dir);
/*The following definitions come from username.c */
@@ -882,10 +899,10 @@ time_t file_modtime(char *fname);
BOOL directory_exist(char *dname,struct stat *st);
uint32 file_size(char *file_name);
char *attrib_string(int mode);
-int StrCaseCmp(char *s, char *t);
-int StrnCaseCmp(char *s, char *t, int n);
-BOOL strequal(char *s1, char *s2);
-BOOL strnequal(char *s1,char *s2,int n);
+int StrCaseCmp(const char *s, const char *t);
+int StrnCaseCmp(const char *s, const char *t, int n);
+BOOL strequal(const char *s1, const char *s2);
+BOOL strnequal(const char *s1,const char *s2,int n);
BOOL strcsequal(char *s1,char *s2);
void strlower(char *s);
void strupper(char *s);
@@ -928,12 +945,7 @@ int read_data(int fd,char *buffer,int N);
int write_data(int fd,char *buffer,int N);
int transfer_file(int infd,int outfd,int n,char *header,int headlen,int align);
int read_smb_length(int fd,char *inbuf,int timeout);
-BOOL receive_smb(int fd,char *buffer, int timeout);
-BOOL receive_local_message(int fd, char *buffer, int buffer_len, int timeout);
-BOOL push_local_message(char *buf, int msg_len);
-BOOL receive_message_or_smb(int smbfd, int oplock_fd,
- char *buffer, int buffer_len,
- int timeout, BOOL *got_smb);
+BOOL receive_smb(int fd,char *buffer,int timeout);
BOOL send_smb(int fd,char *buffer);
char *name_ptr(char *buf,int ofs);
int name_extract(char *buf,int ofs,char *name);
@@ -983,8 +995,21 @@ void free_namearray(name_compare_entry *name_array);
BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type);
int file_lock(char *name,int timeout);
void file_unlock(int fd);
-BOOL is_myname(char *s);
+BOOL is_myname(const char *s);
void set_remote_arch(enum remote_arch_types type);
enum remote_arch_types get_remote_arch();
void fstrcpy(char *dest, char *src);
void pstrcpy(char *dest, char *src);
+
+/*The following definitions come from vt_mode.c */
+
+int VT_Check(char *buffer);
+int VT_Start_utmp(void);
+int VT_Stop_utmp(void);
+void VT_AtExit(void);
+void VT_SigCLD(int sig);
+void VT_SigEXIT(int sig);
+int VT_Start(void);
+int VT_Output(char *Buffer);
+int VT_Input(char *Buffer,int Size);
+void VT_Process(void);
diff --git a/source/include/smb.h b/source/include/smb.h
index 66da2099c77..a273d962b69 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -261,6 +261,33 @@ struct smb_passwd {
};
+struct cli_state {
+ int fd;
+ int cnum;
+ int pid;
+ int mid;
+ int uid;
+ int protocol;
+ int sec_mode;
+ int error;
+ int privilages;
+ fstring eff_name;
+ fstring desthost;
+ char cryptkey[8];
+ uint32 sesskey;
+ int serverzone;
+ uint32 servertime;
+ int readbraw_supported;
+ int writebraw_supported;
+ int timeout;
+ int max_xmit;
+ char *outbuf;
+ char *inbuf;
+ int bufsize;
+ int initialised;
+};
+
+
struct current_user {
int cnum, id;
int uid, gid;
@@ -330,7 +357,6 @@ typedef struct
BOOL share_mode;
BOOL print_file;
BOOL modified;
- BOOL granted_oplock;
char *name;
} files_struct;
@@ -453,10 +479,6 @@ typedef struct
{
smb_shm_offset_t next_share_mode_entry;
int pid;
-#ifdef USE_OPLOCKS
- uint16 op_port;
- uint16 op_type;
-#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} share_mode_entry;
@@ -465,10 +487,6 @@ typedef struct
typedef struct
{
int pid;
-#ifdef USE_OPLOCKS
- uint16 op_port;
- uint16 op_type;
-#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} min_share_mode_entry;
@@ -493,48 +511,8 @@ struct connect_record
time_t start;
};
-#ifndef LOCKING_VERSION
-#ifdef USE_OPLOCKS
-#define LOCKING_VERSION 4
-#else /* USE_OPLOCKS */
-#define LOCKING_VERSION 3
-#endif /* USE_OPLOCKS */
-#endif /* LOCKING_VERSION */
-
-#if !defined(FAST_SHARE_MODES)
-/*
- * Defines for slow share modes.
- */
-
-/*
- * Locking file header lengths & offsets.
- */
-#define SMF_VERSION_OFFSET 0
-#define SMF_NUM_ENTRIES_OFFSET 4
-#define SMF_FILENAME_LEN_OFFSET 8
-#define SMF_HEADER_LENGTH 10
-
-#ifdef USE_OPLOCKS
-#define SMF_ENTRY_LENGTH 20
-#else /* USE_OPLOCKS */
-#define SMF_ENTRY_LENGTH 16
-#endif /* USE_OPLOCKS */
-
-/*
- * Share mode record offsets.
- */
-
-#define SME_SEC_OFFSET 0
-#define SME_USEC_OFFSET 4
-#define SME_SHAREMODE_OFFSET 8
-#define SME_PID_OFFSET 12
-
-#ifdef USE_OPLOCKS
-#define SME_PORT_OFFSET 16
-#define SME_OPLOCK_TYPE_OFFSET 18
-#endif /* USE_OPLOCKS */
-#endif /* FAST_SHARE_MODES */
+#define LOCKING_VERSION 3
/* these are useful macros for checking validity of handles */
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
@@ -575,7 +553,11 @@ struct connect_record
#define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list))
#define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list))
+#ifdef SMB_PASSWD
#define SMBENCRYPT() (lp_encrypted_passwords())
+#else
+#define SMBENCRYPT() (False)
+#endif
/* the basic packet size, assuming no words or bytes */
#define smb_size 39
@@ -971,99 +953,18 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
#endif
-/* Defines needed for multi-codepage support. */
-#define KANJI_CODEPAGE 932
-
#ifdef KANJI
-/*
- * Default client code page - Japanese
- */
-#define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE
+/* Default client code page - 932 - Japanese */
+#define DEFAULT_CLIENT_CODE_PAGE 932
#else /* KANJI */
-/*
- * Default client code page - 850 - Western European
- */
+/* Default client code page - 850 - Western European */
#define DEFAULT_CLIENT_CODE_PAGE 850
#endif /* KANJI */
-/*
- * Size of buffer to use when moving files across filesystems.
- */
+/* Size of buffer to use when moving files across filesystems. */
#define COPYBUF_SIZE (8*1024)
-/*
- * Integers used to override error codes.
- */
+/* Integers used to override error codes. */
extern int unix_ERR_class;
extern int unix_ERR_code;
-
-/*
- * Map the Core and Extended Oplock requesst bits down
- * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
- */
-
-/*
- * Core protocol.
- */
-#define CORE_OPLOCK_REQUEST(inbuf) (((CVAL(inbuf,smb_flg)|(1<<5))>>5) | \
- ((CVAL(inbuf,smb_flg)|(1<<6))>>5))
-
-/*
- * Extended protocol.
- */
-#define EXTENDED_OPLOCK_REQUEST(inbuf) (((SVAL(inbuf,smb_vwv2)|(1<<1))>>1) | \
- ((SVAL(inbuf,smb_vwv2)|(1<<2))>>1))
-
-/* Lock types. */
-#define LOCKING_ANDX_SHARED_LOCK 0x1
-#define LOCKING_ANDX_OPLOCK_RELEASE 0x2
-#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x4
-#define LOCKING_ANDX_CANCEL_LOCK 0x8
-#define LOCKING_ANDX_LARGE_FILES 0x10
-
-/* Oplock levels */
-#define OPLOCKLEVEL_NONE 0
-#define OPLOCKLEVEL_II 1
-
-/*
- * Bits we test with.
- */
-#define EXCLUSIVE_OPLOCK 1
-#define BATCH_OPLOCK 2
-
-#define CORE_OPLOCK_GRANTED (1<<5)
-#define EXTENDED_OPLOCK_GRANTED (1<<15)
-
-/*
- * Loopback command offsets.
- */
-
-#define UDP_CMD_LEN_OFFSET 0
-#define UDP_CMD_PORT_OFFSET 4
-#define UDP_CMD_HEADER_LEN 6
-
-#define UDP_MESSAGE_CMD_OFFSET 0
-
-/*
- * Oplock break command code to send over the udp socket.
- *
- * Form of this is :
- *
- * 0 2 6 10 14 18 22
- * +----+--------+--------+--------+-------+--------+
- * | cmd| pid | dev | inode | sec | usec |
- * +----+--------+--------+--------+-------+--------+
- */
-
-#define OPLOCK_BREAK_CMD 0x1
-#define OPLOCK_BREAK_PID_OFFSET 2
-#define OPLOCK_BREAK_DEV_OFFSET 6
-#define OPLOCK_BREAK_INODE_OFFSET 10
-#define OPLOCK_BREAK_SEC_OFFSET 14
-#define OPLOCK_BREAK_USEC_OFFSET 18
-#define OPLOCK_BREAK_MSG_LEN 22
-
-
-#define CMD_REPLY 0x8000
-
/* _SMB_H */
diff --git a/source/include/version.h b/source/include/version.h
index 33c9d240baf..e2a81e5b74c 100644
--- a/source/include/version.h
+++ b/source/include/version.h
@@ -1 +1 @@
-#define VERSION "1.9.18alpha1"
+#define VERSION "1.9.17p4"
diff --git a/source/lib/access.c b/source/lib/access.c
index c338517ed67..599cb5ca7e3 100644
--- a/source/lib/access.c
+++ b/source/lib/access.c
@@ -70,8 +70,8 @@ BOOL check_access(int snum)
}
else
if (snum >= 0)
- DEBUG(0,("%s Denied connection from %s (%s) to %s\n",
- timestring(), client_name(),client_addr(),
+ DEBUG(0,("Denied connection from %s (%s) to %s\n",
+ client_name(),client_addr(),
lp_servicename(snum)));
}
diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index a7dff4224be..6be455c47b2 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -107,18 +107,13 @@ char *unix2dos_format(char *str,BOOL overwrite)
char *dp;
if (!mapsinited) initmaps();
-
- if(lp_client_code_page() == KANJI_CODEPAGE)
- return (*_unix_to_dos)(str, overwrite);
- else {
- if (overwrite) {
- for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
- return str;
- } else {
- for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
- *dp = 0;
- return cvtbuf;
- }
+ if (overwrite) {
+ for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
+ return str;
+ } else {
+ for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
+ *dp = 0;
+ return cvtbuf;
}
}
@@ -131,18 +126,13 @@ char *dos2unix_format(char *str, BOOL overwrite)
char *dp;
if (!mapsinited) initmaps();
-
- if(lp_client_code_page() == KANJI_CODEPAGE)
- return (*_dos_to_unix)(str, overwrite);
- else {
- if (overwrite) {
- for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
- return str;
- } else {
- for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
- *dp = 0;
- return cvtbuf;
- }
+ if (overwrite) {
+ for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
+ return str;
+ } else {
+ for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
+ *dp = 0;
+ return cvtbuf;
}
}
diff --git a/source/lib/charset.c b/source/lib/charset.c
index 4869e09fecf..c4f67e75fb1 100644
--- a/source/lib/charset.c
+++ b/source/lib/charset.c
@@ -28,7 +28,6 @@ extern int DEBUGLEVEL;
* Codepage definitions.
*/
-#if !defined(KANJI)
/* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
unsigned char cp_850[][4] = {
/* dec col/row oct hex description */
@@ -96,13 +95,74 @@ unsigned char cp_850[][4] = {
{0x9C,0,0,0}, /* Pound */
{0,0,0,0}
};
-#else /* KANJI */
+
+/* lower->upper mapping for IBM Code Page 437 - MS-DOS Latin US */
+unsigned char cp_437[][4] = {
+/* 135 08/07 207 87 c cedilla */
+/* 128 08/00 200 80 C cedilla */ {0x87,0x80,1,1},
+/* 129 08/01 201 81 u diaeresis */
+/* 154 09/10 232 9A U diaeresis */ {0x81,0x9A,1,1},
+/* 130 08/02 202 82 e acute */
+/* 144 09/00 220 90 E acute */ {0x82,0x90,1,1},
+/* 131 08/03 203 83 a circumflex */ {0x83,0x41,1,0},
+/* 132 08/04 204 84 a diaeresis */
+/* 142 08/14 216 8E A diaeresis */ {0x84,0x8E,1,1},
+/* 133 08/05 205 85 a grave */ {0x85,0x41,1,0},
+/* 134 08/06 206 86 a ring */ {0x86,0x8F,1,1},
+/* 136 08/08 210 88 e circumflex */ {0x88,0x45,1,0},
+/* 137 08/09 211 89 e diaeresis */ {0x89,0x45,1,0},
+/* 138 08/10 212 8A e grave */ {0x8A,0x45,1,0},
+/* 139 08/11 213 8B i diaeresis */ {0x8B,0x49,1,0},
+/* 140 08/12 214 8C i circumflex */ {0x8C,0x49,1,0},
+/* 141 08/13 215 8D i grave */ {0x8D,0x49,1,0},
+/* 145 09/01 221 91 ae diphthong */
+/* 146 09/02 222 92 AE diphthong */ {0x91,0x92,1,1},
+/* 147 09/03 223 93 o circumflex */ {0x93,0x4F,1,0},
+/* 148 09/04 224 94 o diaeresis */
+/* 153 09/09 231 99 O diaeresis */ {0x94,0x99,1,1},
+/* 149 09/05 225 95 o grave */ {0x95,0x4F,1,0},
+/* 150 09/06 226 96 u circumflex */ {0x96,0x55,1,0},
+/* 151 09/07 227 97 u grave */ {0x97,0x55,1,0},
+/* 152 ??/?? 201 98 u diaeresis */
+ {0x9B,0,0,0}, /* Cent */
+ {0x9C,0,0,0}, /* Pound */
+ {0x9D,0,0,0}, /* Yen */
+/* 160 10/00 240 A0 a acute */ {0xA0,0x41,1,0},
+/* 161 10/01 241 A1 i acute */ {0xA1,0x49,1,0},
+/* 162 10/02 242 A2 o acute */ {0xA2,0x4F,1,0},
+/* 163 10/03 243 A3 u acute */ {0xA3,0x55,1,0},
+/* 164 10/04 244 A4 n tilde */
+/* 165 10/05 245 A5 N tilde */ {0xA4,0xA5,1,1},
+/* Punctuation... */
+ {0xA8,0,0,0},
+ {0xAD,0,0,0},
+ {0xAE,0,0,0},
+ {0xAF,0,0,0},
+/* Greek character set */
+ {0xE0,0,0,0},
+ {0xE1,0,0,0},
+ {0xE2,0,0,0},
+ {0xE3,0,0,0},
+ {0xE4,0,0,0},
+ {0xE5,0,0,0},
+ {0xE6,0,0,0},
+ {0xE7,0,0,0},
+ {0xE8,0,0,0},
+ {0xE9,0,0,0},
+ {0xEA,0,0,0},
+ {0xEB,0,0,0},
+ {0xEC,0,0,0},
+ {0xED,0,0,0},
+ {0xEE,0,0,0},
+ {0xEF,0,0,0},
+ {0,0,0,0}
+};
+
/* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
unsigned char cp_932[][4] = {
{0,0,0,0}
};
-#endif /* KANJI */
-
+
char xx_dos_char_map[256];
char xx_upper_char_map[256];
char xx_lower_char_map[256];
@@ -134,9 +194,9 @@ static void add_dos_char(int lower, BOOL map_lower_to_upper,
if (upper) dos_char_map[upper] = 1;
if (lower && upper) {
if(map_upper_to_lower)
- lower_char_map[upper] = (char)lower;
+ lower_char_map[upper] = (char)lower;
if(map_lower_to_upper)
- upper_char_map[lower] = (char)upper;
+ upper_char_map[lower] = (char)upper;
}
}
@@ -171,152 +231,12 @@ void charset_initialise()
}
/****************************************************************************
-load the client codepage.
-****************************************************************************/
-
-typedef unsigned char (*codepage_p)[4];
-
-static codepage_p load_client_codepage( int client_codepage )
-{
- pstring codepage_file_name;
- unsigned char buf[8];
- FILE *fp = NULL;
- unsigned int size;
- codepage_p cp_p = NULL;
- struct stat st;
-
- DEBUG(5, ("load_client_codepage: loading codepage %d.\n", client_codepage));
-
- if(strlen(CODEPAGEDIR) + 14 > sizeof(codepage_file_name))
- {
- DEBUG(0,("load_client_codepage: filename too long to load\n"));
- return NULL;
- }
-
- strcpy(codepage_file_name, CODEPAGEDIR);
- strcat(codepage_file_name, "/");
- strcat(codepage_file_name, "codepage.");
- sprintf( &codepage_file_name[strlen(codepage_file_name)], "%03d",
- client_codepage);
-
- if(!file_exist(codepage_file_name,&st))
- {
- DEBUG(0,("load_client_codepage: filename %s does not exist.\n",
- codepage_file_name));
- return NULL;
- }
-
- /* Check if it is at least big enough to hold the required
- data. Should be 2 byte version, 2 byte codepage, 4 byte length,
- plus zero or more bytes of data. Note that the data cannot be more
- than 512 bytes - giving a max size of 520.
- */
- size = (unsigned int)st.st_size;
-
- if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 256))
- {
- DEBUG(0,("load_client_codepage: file %s is an incorrect size for a \
-code page file.\n", codepage_file_name));
- return NULL;
- }
-
- /* Read the first 8 bytes of the codepage file - check
- the version number and code page number. All the data
- is held in little endian format.
- */
-
- if((fp = fopen( codepage_file_name, "r")) == NULL)
- {
- DEBUG(0,("load_client_codepage: cannot open file %s. Error was %s\n",
- codepage_file_name, strerror(errno)));
- return NULL;
- }
-
- if(fread( buf, 1, CODEPAGE_HEADER_SIZE, fp)!=CODEPAGE_HEADER_SIZE)
- {
- DEBUG(0,("load_client_codepage: cannot read header from file %s. Error was %s\n",
- codepage_file_name, strerror(errno)));
- goto clean_and_exit;
- }
-
- /* Check the version value */
- if(SVAL(buf,CODEPAGE_VERSION_OFFSET) != CODEPAGE_FILE_VERSION_ID)
- {
- DEBUG(0,("load_client_codepage: filename %s has incorrect version id. \
-Needed %hu, got %hu.\n",
- codepage_file_name, (uint16)CODEPAGE_FILE_VERSION_ID,
- SVAL(buf,CODEPAGE_VERSION_OFFSET)));
- goto clean_and_exit;
- }
-
- /* Check the codepage matches */
- if(SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET) != (uint16)client_codepage)
- {
- DEBUG(0,("load_client_codepage: filename %s has incorrect codepage. \
-Needed %hu, got %hu.\n",
- codepage_file_name, (uint16)client_codepage,
- SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
- goto clean_and_exit;
- }
-
- /* Check the length is correct. */
- if(IVAL(buf,CODEPAGE_LENGTH_OFFSET) !=
- (unsigned int)(size - CODEPAGE_HEADER_SIZE))
- {
- DEBUG(0,("load_client_codepage: filename %s has incorrect size headers. \
-Needed %u, got %u.\n", codepage_file_name, size - CODEPAGE_HEADER_SIZE,
- IVAL(buf,CODEPAGE_LENGTH_OFFSET)));
- goto clean_and_exit;
- }
-
- size -= CODEPAGE_HEADER_SIZE; /* Remove header */
-
- /* Make sure the size is a multiple of 4. */
- if((size % 4 ) != 0)
- {
- DEBUG(0,("load_client_codepage: filename %s has a codepage size not a \
-multiple of 4.\n", codepage_file_name));
- goto clean_and_exit;
- }
-
- /* Allocate space for the code page file and read it all in. */
- if((cp_p = (codepage_p)malloc( size + 4 )) == NULL)
- {
- DEBUG(0,("load_client_codepage: malloc fail.\n"));
- goto clean_and_exit;
- }
-
- if(fread( (char *)cp_p, 1, size, fp)!=size)
- {
- DEBUG(0,("load_client_codepage: read fail on file %s. Error was %s.\n",
- codepage_file_name, strerror(errno)));
- goto clean_and_exit;
- }
-
- /* Ensure array is correctly terminated. */
- memset(((char *)cp_p) + size, '\0', 4);
-
- fclose(fp);
- return cp_p;
-
-clean_and_exit:
-
- /* pseudo destructor :-) */
-
- if(fp != NULL)
- fclose(fp);
- if(cp_p)
- free((char *)cp_p);
- return NULL;
-}
-
-/****************************************************************************
initialise the client codepage.
****************************************************************************/
void codepage_initialise(int client_codepage)
{
int i;
- codepage_p cp = NULL;
+ unsigned char (*cp)[4] = NULL;
static BOOL done = False;
if(done == True)
@@ -332,21 +252,30 @@ void codepage_initialise(int client_codepage)
/*
* Known client codepages - these can be added to.
*/
- cp = load_client_codepage( client_codepage );
-
- if(cp == NULL)
+ switch(client_codepage)
{
+ case 850:
+ cp = cp_850;
+ break;
+ case 437:
+ cp = cp_437;
+ break;
+ case 932:
+ cp = cp_932;
+ break;
+ default:
#ifdef KANJI
- DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
-for code page %d failed. Using default client codepage 932\n",
- CODEPAGEDIR, client_codepage, client_codepage));
- cp = cp_932;
+ /* Use default codepage - currently 932 */
+ DEBUG(6,("codepage_initialise: Using default client codepage %d\n",
+ 932));
+ cp = cp_932;
#else /* KANJI */
- DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
-for code page %d failed. Using default client codepage 850\n",
- CODEPAGEDIR, client_codepage, client_codepage));
- cp = cp_850;
+ /* Use default codepage - currently 850 */
+ DEBUG(6,("codepage_initialise: Using default client codepage %d\n",
+ 850));
+ cp = cp_850;
#endif /* KANJI */
+ break;
}
if(cp)
diff --git a/source/lib/getsmbpass.c b/source/lib/getsmbpass.c
index e8cb683d0b1..9008d40f910 100644
--- a/source/lib/getsmbpass.c
+++ b/source/lib/getsmbpass.c
@@ -45,7 +45,7 @@ static struct termio t;
return ioctl(fd, TCGETA, t);
}
- int tcsetattr(int fd, int flags, struct termio *t)
+ int tcsetattr(int fd, int flags, const struct termio *t)
{
if(flags & TCSAFLUSH)
ioctl(fd, TCFLSH, TCIOFLUSH);
@@ -76,7 +76,7 @@ static struct sgttyb t;
return ioctl(fd, TIOCGETP, (char *)t);
}
- int tcsetattr(int fd, int flags, struct sgttyb *t)
+ int tcsetattr(int fd, int flags, const struct sgttyb *t)
{
return ioctl(fd, TIOCSETP, (char *)t);
}
diff --git a/source/lib/interface.c b/source/lib/interface.c
index 940af1eccf4..1dc605ff2fd 100644
--- a/source/lib/interface.c
+++ b/source/lib/interface.c
@@ -25,6 +25,7 @@ extern int DEBUGLEVEL;
struct in_addr ipzero;
struct in_addr wins_ip;
+struct in_addr loopback_ip;
static struct in_addr default_ip;
static struct in_addr default_bcast;
static struct in_addr default_nmask;
@@ -262,6 +263,7 @@ static void interpret_interfaces(char *s, struct interface **interfaces,
ipzero = *interpret_addr2("0.0.0.0");
wins_ip = *interpret_addr2("255.255.255.255");
+ loopback_ip = *interpret_addr2("127.0.0.1");
while (next_token(&ptr,token,NULL)) {
/* parse it into an IP address/netmasklength pair */
@@ -337,9 +339,9 @@ static void interpret_interfaces(char *s, struct interface **interfaces,
iface->next = NULL;
(*interfaces) = last_iface = iface;
- DEBUG(1,("Added interface ip=%s ",inet_ntoa(iface->ip)));
- DEBUG(1,("bcast=%s ",inet_ntoa(iface->bcast)));
- DEBUG(1,("nmask=%s\n",inet_ntoa(iface->nmask)));
+ DEBUG(2,("Added interface ip=%s ",inet_ntoa(iface->ip)));
+ DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
+ DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
}
diff --git a/source/lib/kanji.c b/source/lib/kanji.c
index 5d7de87248d..479763fd406 100644
--- a/source/lib/kanji.c
+++ b/source/lib/kanji.c
@@ -23,6 +23,7 @@
and add all jis codes sequence type at 1995.8.16
Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp>
*/
+#ifdef KANJI
#define _KANJI_C_
#include "includes.h"
@@ -42,7 +43,8 @@ char hex_tag = HEXTAG;
search token from S1 separated any char of S2
S1 contain SHIFT JIS chars.
********************************************************************/
-char *sj_strtok(char *s1, char *s2)
+char *
+sj_strtok (char *s1, const char *s2)
{
static char *s = NULL;
char *q;
@@ -81,9 +83,10 @@ char *sj_strtok(char *s1, char *s2)
search string S2 from S1
S1 contain SHIFT JIS chars.
********************************************************************/
-char *sj_strstr(char *s1, char *s2)
+char *
+sj_strstr (const char *s1, const char *s2)
{
- int len = strlen ((char *) s2);
+ register int len = strlen ((char *) s2);
if (!*s2)
return (char *) s1;
for (;*s1;) {
@@ -104,7 +107,8 @@ char *sj_strstr(char *s1, char *s2)
Search char C from beginning of S.
S contain SHIFT JIS chars.
********************************************************************/
-char *sj_strchr (char *s, int c)
+char *
+sj_strchr (const char *s, int c)
{
for (; *s; ) {
if (*s == c)
@@ -122,9 +126,10 @@ char *sj_strchr (char *s, int c)
Search char C end of S.
S contain SHIFT JIS chars.
********************************************************************/
-char *sj_strrchr(char *s, int c)
+char *
+sj_strrchr (const char *s, int c)
{
- char *q;
+ register char *q;
for (q = 0; *s; ) {
if (*s == c) {
@@ -148,7 +153,8 @@ static char cvtbuf[1024];
/*******************************************************************
EUC <-> SJIS
********************************************************************/
-static int euc2sjis (int hi, int lo)
+static int
+euc2sjis (register int hi, register int lo)
{
if (hi & 1)
return ((hi / 2 + (hi < 0xdf ? 0x31 : 0x71)) << 8) |
@@ -157,7 +163,8 @@ static int euc2sjis (int hi, int lo)
return ((hi / 2 + (hi < 0xdf ? 0x30 : 0x70)) << 8) | (lo - 2);
}
-static int sjis2euc (int hi, int lo)
+static int
+sjis2euc (register int hi, register int lo)
{
if (lo >= 0x9f)
return ((hi * 2 - (hi >= 0xe0 ? 0xe0 : 0x60)) << 8) | (lo + 2);
@@ -170,9 +177,10 @@ static int sjis2euc (int hi, int lo)
Convert FROM contain SHIFT JIS codes to EUC codes
return converted buffer
********************************************************************/
-static char *sj_to_euc(char *from, BOOL overwrite)
+static char *
+sj_to_euc (const char *from, BOOL overwrite)
{
- char *out;
+ register char *out;
char *save;
save = (char *) from;
@@ -202,9 +210,10 @@ static char *sj_to_euc(char *from, BOOL overwrite)
Convert FROM contain EUC codes to SHIFT JIS codes
return converted buffer
********************************************************************/
-static char *euc_to_sj(char *from, BOOL overwrite)
+static char *
+euc_to_sj (const char *from, BOOL overwrite)
{
- char *out;
+ register char *out;
char *save;
save = (char *) from;
@@ -233,7 +242,8 @@ static char *euc_to_sj(char *from, BOOL overwrite)
/*******************************************************************
JIS7,JIS8,JUNET <-> SJIS
********************************************************************/
-static int sjis2jis(int hi, int lo)
+static int
+sjis2jis (register int hi, register int lo)
{
if (lo >= 0x9f)
return ((hi * 2 - (hi >= 0xe0 ? 0x160 : 0xe0)) << 8) | (lo - 0x7e);
@@ -242,7 +252,8 @@ static int sjis2jis(int hi, int lo)
(lo - (lo >= 0x7f ? 0x20 : 0x1f));
}
-static int jis2sjis(int hi, int lo)
+static int
+jis2sjis (register int hi, register int lo)
{
if (hi & 1)
return ((hi / 2 + (hi < 0x5f ? 0x71 : 0xb1)) << 8) |
@@ -255,10 +266,11 @@ static int jis2sjis(int hi, int lo)
Convert FROM contain JIS codes to SHIFT JIS codes
return converted buffer
********************************************************************/
-static char *jis8_to_sj(char *from, BOOL overwrite)
+static char *
+jis8_to_sj (const char *from, BOOL overwrite)
{
- char *out;
- int shifted;
+ register char *out;
+ register int shifted;
char *save;
shifted = _KJ_ROMAN;
@@ -305,10 +317,11 @@ static char *jis8_to_sj(char *from, BOOL overwrite)
Convert FROM contain SHIFT JIS codes to JIS codes
return converted buffer
********************************************************************/
-static char *sj_to_jis8(char *from, BOOL overwrite)
+static char *
+sj_to_jis8 (const char *from, BOOL overwrite)
{
- char *out;
- int shifted;
+ register char *out;
+ register int shifted;
char *save;
shifted = _KJ_ROMAN;
@@ -361,10 +374,11 @@ static char *sj_to_jis8(char *from, BOOL overwrite)
Convert FROM contain 7 bits JIS codes to SHIFT JIS codes
return converted buffer
********************************************************************/
-static char *jis7_to_sj(char *from, BOOL overwrite)
+static char *
+jis7_to_sj (const char *from, BOOL overwrite)
{
- char *out;
- int shifted;
+ register char *out;
+ register int shifted;
char *save;
shifted = _KJ_ROMAN;
@@ -420,10 +434,11 @@ static char *jis7_to_sj(char *from, BOOL overwrite)
Convert FROM contain SHIFT JIS codes to 7 bits JIS codes
return converted buffer
********************************************************************/
-static char *sj_to_jis7(char *from, BOOL overwrite)
+static char *
+sj_to_jis7 (const char *from, BOOL overwrite)
{
- char *out;
- int shifted;
+ register char *out;
+ register int shifted;
char *save;
shifted = _KJ_ROMAN;
@@ -496,10 +511,11 @@ static char *sj_to_jis7(char *from, BOOL overwrite)
Convert FROM contain 7 bits JIS(junet) codes to SHIFT JIS codes
return converted buffer
********************************************************************/
-static char *junet_to_sj(char *from, BOOL overwrite)
+static char *
+junet_to_sj (const char *from, BOOL overwrite)
{
- char *out;
- int shifted;
+ register char *out;
+ register int shifted;
char *save;
shifted = _KJ_ROMAN;
@@ -552,10 +568,11 @@ static char *junet_to_sj(char *from, BOOL overwrite)
Convert FROM contain SHIFT JIS codes to 7 bits JIS(junet) codes
return converted buffer
********************************************************************/
-static char *sj_to_junet(char *from, BOOL overwrite)
+static char *
+sj_to_junet (const char *from, BOOL overwrite)
{
- char *out;
- int shifted;
+ register char *out;
+ register int shifted;
char *save;
shifted = _KJ_ROMAN;
@@ -621,7 +638,8 @@ static char *sj_to_junet(char *from, BOOL overwrite)
HEX <-> SJIS
********************************************************************/
/* ":xx" -> a byte */
-static char *hex_to_sj(char *from, BOOL overwrite)
+static char *
+hex_to_sj (const char *from, BOOL overwrite)
{
char *sp, *dp;
@@ -646,7 +664,8 @@ static char *hex_to_sj(char *from, BOOL overwrite)
/*******************************************************************
kanji/kana -> ":xx"
********************************************************************/
-static char *sj_to_hex(char *from, BOOL overwrite)
+static char *
+sj_to_hex (const char *from, BOOL overwrite)
{
unsigned char *sp, *dp;
@@ -682,7 +701,8 @@ static char *sj_to_hex(char *from, BOOL overwrite)
/*******************************************************************
kanji/kana -> ":xx"
********************************************************************/
-static char *sj_to_cap(char *from, BOOL overwrite)
+static char *
+sj_to_cap (const char *from, BOOL overwrite)
{
unsigned char *sp, *dp;
@@ -710,7 +730,8 @@ static char *sj_to_cap(char *from, BOOL overwrite)
/*******************************************************************
sj to sj
********************************************************************/
-static char *sj_to_sj(char *from, BOOL overwrite)
+static char *
+sj_to_sj (const char *from, BOOL overwrite)
{
if (!overwrite) {
strcpy (cvtbuf, (char *) from);
@@ -725,10 +746,11 @@ static char *sj_to_sj(char *from, BOOL overwrite)
_dos_to_unix _unix_to_dos
************************************************************************/
-char *(*_dos_to_unix)(char *str, BOOL overwrite) = sj_to_sj;
-char *(*_unix_to_dos)(char *str, BOOL overwrite) = sj_to_sj;
+char* (*_dos_to_unix) (const char *str, BOOL overwrite) = sj_to_sj;
+char* (*_unix_to_dos) (const char *str, BOOL overwrite) = sj_to_sj;
-static int setup_string_function(int codes)
+static int
+setup_string_function (int codes)
{
switch (codes) {
default:
@@ -866,3 +888,7 @@ int interpret_coding_system(char *str, int def)
}
return setup_string_function (codes);
}
+#else
+ int kanji_dummy_procedure(void)
+{return 0;}
+#endif /* KANJI */
diff --git a/source/lib/md4.c b/source/lib/md4.c
index 1c9c2e6ecd5..bdff075c7e7 100644
--- a/source/lib/md4.c
+++ b/source/lib/md4.c
@@ -1,171 +1,299 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- a implementation of MD4 designed for use in the SMB authentication protocol
- Copyright (C) Andrew Tridgell 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#ifdef SMB_PASSWD
+/*
+ This code is from rfc1186.
*/
+ /*
+ ** ********************************************************************
+ ** md4.c -- Implementation of MD4 Message Digest Algorithm **
+ ** Updated: 2/16/90 by Ronald L. Rivest **
+ ** (C) 1990 RSA Data Security, Inc. **
+ ** ********************************************************************
+ */
-/* NOTE: This code makes no attempt to be fast!
+ /*
+ ** To use MD4:
+ ** -- Include md4.h in your program
+ ** -- Declare an MDstruct MD to hold the state of the digest
+ ** computation.
+ ** -- Initialize MD using MDbegin(&MD)
+ ** -- For each full block (64 bytes) X you wish to process, call
+ ** MDupdate(&MD,X,512)
+ ** (512 is the number of bits in a full block.)
+ ** -- For the last block (less than 64 bytes) you wish to process,
+ ** MDupdate(&MD,X,n)
+ ** where n is the number of bits in the partial block. A partial
+ ** block terminates the computation, so every MD computation
+ ** should terminate by processing a partial block, even if it
+ ** has n = 0.
+ ** -- The message digest is available in MD.buffer[0] ...
+ ** MD.buffer[3]. (Least-significant byte of each word
+ ** should be output first.)
+ ** -- You can print out the digest using MDprint(&MD)
+ */
- It assumes that a int is at least 32 bits long
-*/
+ /* Implementation notes:
+ ** This implementation assumes that ints are 32-bit quantities.
+ ** If the machine stores the least-significant byte of an int in the
+ ** least-addressed byte (e.g., VAX and 8086), then LOWBYTEFIRST
+ ** should be set to TRUE. Otherwise (e.g., SUNS), LOWBYTEFIRST
+ ** should be set to FALSE. Note that on machines with LOWBYTEFIRST
+ ** FALSE the routine MDupdate modifies has a side-effect on its input
+ ** array (the order of bytes in each word are reversed). If this is
+ ** undesired a call to MDreverse(X) can reverse the bytes of X back
+ ** into order after each call to MDupdate.
+ */
-typedef unsigned int uint32;
-
-static uint32 A, B, C, D;
-
-static uint32 F(uint32 X, uint32 Y, uint32 Z)
-{
- return (X&Y) | ((~X)&Z);
-}
-
-static uint32 G(uint32 X, uint32 Y, uint32 Z)
-{
- return (X&Y) | (X&Z) | (Y&Z);
-}
-
-static uint32 H(uint32 X, uint32 Y, uint32 Z)
-{
- return X^Y^Z;
-}
-
-static uint32 lshift(uint32 x, int s)
-{
- x &= 0xFFFFFFFF;
- return ((x<<s)&0xFFFFFFFF) | (x>>(32-s));
-}
-
-#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
-#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s)
-#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)
-
-/* this applies md4 to 64 byte chunks */
-static void mdfour64(uint32 *M)
-{
- int j;
- uint32 AA, BB, CC, DD;
- uint32 X[16];
-
- for (j=0;j<16;j++)
- X[j] = M[j];
-
- AA = A; BB = B; CC = C; DD = D;
-
- ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
- ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
- ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
- ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
- ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
- ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
- ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
- ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
-
- ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
- ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
- ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
- ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
- ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
- ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
- ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
- ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
-
- ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
- ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
- ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
- ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
- ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
- ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
- ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
- ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
-
- A += AA; B += BB; C += CC; D += DD;
-
- A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
- C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
-
- for (j=0;j<16;j++)
- X[j] = 0;
-}
-
-static void copy64(uint32 *M, unsigned char *in)
-{
- int i;
-
- for (i=0;i<16;i++)
- M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
- (in[i*4+1]<<8) | (in[i*4+0]<<0);
-}
-
-static void copy4(unsigned char *out,uint32 x)
-{
- out[0] = x&0xFF;
- out[1] = (x>>8)&0xFF;
- out[2] = (x>>16)&0xFF;
- out[3] = (x>>24)&0xFF;
-}
-
-/* produce a md4 message digest from data of length n bytes */
-void mdfour(unsigned char *out, unsigned char *in, int n)
-{
- unsigned char buf[128];
- uint32 M[16];
- uint32 b = n * 8;
- int i;
-
- A = 0x67452301;
- B = 0xefcdab89;
- C = 0x98badcfe;
- D = 0x10325476;
-
- while (n > 64) {
- copy64(M, in);
- mdfour64(M);
- in += 64;
- n -= 64;
- }
+#define TRUE 1
+#define FALSE 0
- for (i=0;i<128;i++)
- buf[i] = 0;
- memcpy(buf, in, n);
- buf[n] = 0x80;
-
- if (n <= 55) {
- copy4(buf+56, b);
- copy64(M, buf);
- mdfour64(M);
- } else {
- copy4(buf+120, b);
- copy64(M, buf);
- mdfour64(M);
- copy64(M, buf+64);
- mdfour64(M);
- }
+ /* Compile-time includes
+ */
+
+#include <stdio.h>
+#include "md4.h"
+
+#define uchar unsigned char
+#define int16 unsigned short
+#define uint32 unsigned int
+
+#include "byteorder.h"
+
+ /* Compile-time declarations of MD4 "magic constants".
+ */
+#define I0 0x67452301 /* Initial values for MD buffer */
+#define I1 0xefcdab89
+#define I2 0x98badcfe
+#define I3 0x10325476
+#define C2 013240474631 /* round 2 constant = sqrt(2) in octal */
+#define C3 015666365641 /* round 3 constant = sqrt(3) in octal */
+ /* C2 and C3 are from Knuth, The Art of Programming, Volume 2
+ ** (Seminumerical Algorithms), Second Edition (1981), Addison-Wesley.
+ ** Table 2, page 660.
+ */
- for (i=0;i<128;i++)
- buf[i] = 0;
- copy64(M, buf);
+#define fs1 3 /* round 1 shift amounts */
+#define fs2 7
+#define fs3 11
+#define fs4 19
+#define gs1 3 /* round 2 shift amounts */
+#define gs2 5
+#define gs3 9
+#define gs4 13
+#define hs1 3 /* round 3 shift amounts */
+#define hs2 9
+#define hs3 11
+#define hs4 15
- copy4(out, A);
- copy4(out+4, B);
- copy4(out+8, C);
- copy4(out+12, D);
+ /* Compile-time macro declarations for MD4.
+ ** Note: The "rot" operator uses the variable "tmp".
+ ** It assumes tmp is declared as unsigned int, so that the >>
+ ** operator will shift in zeros rather than extending the sign bit.
+ */
+#define f(X,Y,Z) ((X&Y) | ((~X)&Z))
+#define g(X,Y,Z) ((X&Y) | (X&Z) | (Y&Z))
+#define h(X,Y,Z) (X^Y^Z)
+#define rot(X,S) (tmp=X,(tmp<<S) | (tmp>>(32-S)))
+#define ff(A,B,C,D,i,s) A = rot((A + f(B,C,D) + X[i]),s)
+#define gg(A,B,C,D,i,s) A = rot((A + g(B,C,D) + X[i] + C2),s)
+#define hh(A,B,C,D,i,s) A = rot((A + h(B,C,D) + X[i] + C3),s)
+
+ /* MDprint(MDp)
+ ** Print message digest buffer MDp as 32 hexadecimal digits.
+ ** Order is from low-order byte of buffer[0] to high-order byte of
+ ** buffer[3].
+ ** Each byte is printed with high-order hexadecimal digit first.
+ ** This is a user-callable routine.
+ */
+ void
+ MDprint(MDp)
+ MDptr MDp;
+ { int i,j;
+ for (i=0;i<4;i++)
+ for (j=0;j<32;j=j+8)
+ printf("%02x",(MDp->buffer[i]>>j) & 0xFF);
+ }
+
+ /* MDbegin(MDp)
+ ** Initialize message digest buffer MDp.
+ ** This is a user-callable routine.
+ */
+ void
+ MDbegin(MDp)
+ MDptr MDp;
+ { int i;
+ MDp->buffer[0] = I0;
+ MDp->buffer[1] = I1;
+ MDp->buffer[2] = I2;
+ MDp->buffer[3] = I3;
+ for (i=0;i<8;i++) MDp->count[i] = 0;
+ MDp->done = 0;
+ }
+
+ /* MDreverse(X)
+ ** Reverse the byte-ordering of every int in X.
+ ** Assumes X is an array of 16 ints.
+ ** The macro revx reverses the byte-ordering of the next word of X.
+ */
+ void MDreverse(X)
+ unsigned int *X;
+ { register unsigned int t;
+ register unsigned int i;
+
+ for(i = 0; i < 16; i++) {
+ t = X[i];
+ SIVAL(X,i*4,t);
+ }
+ }
- A = B = C = D = 0;
-}
+ /* MDblock(MDp,X)
+ ** Update message digest buffer MDp->buffer using 16-word data block X.
+ ** Assumes all 16 words of X are full of data.
+ ** Does not update MDp->count.
+ ** This routine is not user-callable.
+ */
+ static void
+ MDblock(MDp,X)
+ MDptr MDp;
+ unsigned int *X;
+ {
+ register unsigned int tmp, A, B, C, D;
+ MDreverse(X);
+ A = MDp->buffer[0];
+ B = MDp->buffer[1];
+ C = MDp->buffer[2];
+ D = MDp->buffer[3];
+ /* Update the message digest buffer */
+ ff(A , B , C , D , 0 , fs1); /* Round 1 */
+ ff(D , A , B , C , 1 , fs2);
+ ff(C , D , A , B , 2 , fs3);
+ ff(B , C , D , A , 3 , fs4);
+ ff(A , B , C , D , 4 , fs1);
+ ff(D , A , B , C , 5 , fs2);
+ ff(C , D , A , B , 6 , fs3);
+ ff(B , C , D , A , 7 , fs4);
+ ff(A , B , C , D , 8 , fs1);
+ ff(D , A , B , C , 9 , fs2);
+ ff(C , D , A , B , 10 , fs3);
+ ff(B , C , D , A , 11 , fs4);
+ ff(A , B , C , D , 12 , fs1);
+ ff(D , A , B , C , 13 , fs2);
+ ff(C , D , A , B , 14 , fs3);
+ ff(B , C , D , A , 15 , fs4);
+ gg(A , B , C , D , 0 , gs1); /* Round 2 */
+ gg(D , A , B , C , 4 , gs2);
+ gg(C , D , A , B , 8 , gs3);
+ gg(B , C , D , A , 12 , gs4);
+ gg(A , B , C , D , 1 , gs1);
+ gg(D , A , B , C , 5 , gs2);
+ gg(C , D , A , B , 9 , gs3);
+ gg(B , C , D , A , 13 , gs4);
+ gg(A , B , C , D , 2 , gs1);
+ gg(D , A , B , C , 6 , gs2);
+ gg(C , D , A , B , 10 , gs3);
+ gg(B , C , D , A , 14 , gs4);
+ gg(A , B , C , D , 3 , gs1);
+ gg(D , A , B , C , 7 , gs2);
+ gg(C , D , A , B , 11 , gs3);
+ gg(B , C , D , A , 15 , gs4);
+ hh(A , B , C , D , 0 , hs1); /* Round 3 */
+ hh(D , A , B , C , 8 , hs2);
+ hh(C , D , A , B , 4 , hs3);
+ hh(B , C , D , A , 12 , hs4);
+ hh(A , B , C , D , 2 , hs1);
+ hh(D , A , B , C , 10 , hs2);
+ hh(C , D , A , B , 6 , hs3);
+ hh(B , C , D , A , 14 , hs4);
+ hh(A , B , C , D , 1 , hs1);
+ hh(D , A , B , C , 9 , hs2);
+ hh(C , D , A , B , 5 , hs3);
+ hh(B , C , D , A , 13 , hs4);
+ hh(A , B , C , D , 3 , hs1);
+ hh(D , A , B , C , 11 , hs2);
+ hh(C , D , A , B , 7 , hs3);
+ hh(B , C , D , A , 15 , hs4);
+ MDp->buffer[0] += A;
+ MDp->buffer[1] += B;
+ MDp->buffer[2] += C;
+ MDp->buffer[3] += D;
+ }
+ /* MDupdate(MDp,X,count)
+ ** Input: MDp -- an MDptr
+ ** X -- a pointer to an array of unsigned characters.
+ ** count -- the number of bits of X to use.
+ ** (if not a multiple of 8, uses high bits of last byte.)
+ ** Update MDp using the number of bits of X given by count.
+ ** This is the basic input routine for an MD4 user.
+ ** The routine completes the MD computation when count < 512, so
+ ** every MD computation should end with one call to MDupdate with a
+ ** count less than 512. A call with count 0 will be ignored if the
+ ** MD has already been terminated (done != 0), so an extra call with
+ ** count 0 can be given as a "courtesy close" to force termination
+ ** if desired.
+ */
+ void
+ MDupdate(MDp,X,count)
+ MDptr MDp;
+ unsigned char *X;
+ unsigned int count;
+ { unsigned int i, tmp, bit, byte, mask;
+ unsigned char XX[64];
+ unsigned char *p;
+ /* return with no error if this is a courtesy close with count
+ ** zero and MDp->done is true.
+ */
+ if (count == 0 && MDp->done) return;
+ /* check to see if MD is already done and report error */
+ if (MDp->done)
+ { printf("\nError: MDupdate MD already done."); return; }
+ /* Add count to MDp->count */
+ tmp = count;
+ p = MDp->count;
+ while (tmp)
+ { tmp += *p;
+ *p++ = tmp;
+ tmp = tmp >> 8;
+ }
+ /* Process data */
+ if (count == 512)
+ { /* Full block of data to handle */
+ MDblock(MDp,(unsigned int *)X);
+ }
+ else if (count > 512) /* Check for count too large */
+ { printf("\nError: MDupdate called with illegal count value %d."
+ ,count);
+ return;
+ }
+ else /* partial block -- must be last block so finish up */
+ { /* Find out how many bytes and residual bits there are */
+ byte = count >> 3;
+ bit = count & 7;
+ /* Copy X into XX since we need to modify it */
+ for (i=0;i<=byte;i++) XX[i] = X[i];
+ for (i=byte+1;i<64;i++) XX[i] = 0;
+ /* Add padding '1' bit and low-order zeros in last byte */
+ mask = 1 << (7 - bit);
+ XX[byte] = (XX[byte] | mask) & ~( mask - 1);
+ /* If room for bit count, finish up with this block */
+ if (byte <= 55)
+ { for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
+ MDblock(MDp,(unsigned int *)XX);
+ }
+ else /* need to do two blocks to finish up */
+ { MDblock(MDp,(unsigned int *)XX);
+ for (i=0;i<56;i++) XX[i] = 0;
+ for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
+ MDblock(MDp,(unsigned int *)XX);
+ }
+ /* Set flag saying we're done with MD computation */
+ MDp->done = 1;
+ }
+ }
+ /*
+ ** End of md4.c
+ */
+#else
+ void md4_dummy() {;}
+#endif
diff --git a/source/lib/system.c b/source/lib/system.c
index fe8e8004d04..b149ccb4b98 100644
--- a/source/lib/system.c
+++ b/source/lib/system.c
@@ -194,15 +194,25 @@ now for utime()
********************************************************************/
int sys_utime(char *fname,struct utimbuf *times)
{
- return(utime(dos_to_unix(fname,False),times));
+ /* if the modtime is 0 or -1 then ignore the call and
+ return success */
+ if (times->modtime == (time_t)0 || times->modtime == (time_t)-1)
+ return 0;
+
+ /* if the access time is 0 or -1 then set it to the modtime */
+ if (times->actime == (time_t)0 || times->actime == (time_t)-1)
+ times->actime = times->modtime;
+
+ return(utime(dos_to_unix(fname,False),times));
}
+
/*********************************************************
for rename across filesystems Patch from Warren Birnbaum
<warrenb@hpcvscdp.cv.hp.com>
**********************************************************/
-
-static int copy_reg(char *source, const char *dest)
+static int
+copy_reg (const char *source, const char *dest)
{
struct stat source_stats;
int ifd;
diff --git a/source/lib/time.c b/source/lib/time.c
index 4f688d2214a..ad6b04484c5 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -298,7 +298,7 @@ void put_long_date(char *p,time_t t)
/****************************************************************************
check if it's a null mtime
****************************************************************************/
-static BOOL null_mtime(time_t mtime)
+BOOL null_mtime(time_t mtime)
{
if (mtime == 0 || mtime == 0xFFFFFFFF || mtime == (time_t)-1)
return(True);
@@ -446,25 +446,6 @@ time_t make_unix_date3(void *date_ptr)
}
/****************************************************************************
-set the time on a file
-****************************************************************************/
-BOOL set_filetime(char *fname,time_t mtime)
-{
- struct utimbuf times;
-
- if (null_mtime(mtime)) return(True);
-
- times.modtime = times.actime = mtime;
-
- if (sys_utime(fname,&times)) {
- DEBUG(4,("set_filetime(%s) failed: %s\n",fname,strerror(errno)));
- }
-
- return(True);
-}
-
-
-/****************************************************************************
return the date and time as a string
****************************************************************************/
char *timestring(void )
diff --git a/source/lib/username.c b/source/lib/username.c
index a9f64259916..46b8f4cb332 100644
--- a/source/lib/username.c
+++ b/source/lib/username.c
@@ -22,9 +22,6 @@
#include "includes.h"
extern int DEBUGLEVEL;
-/* internal functions - modified versions of the ones in password.c */
-static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (), int N);
-static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (), int N);
/****************************************************************************
get a users home directory. tries as-is then lower case
@@ -144,8 +141,6 @@ Note that this changes user!
struct passwd *Get_Pwnam(char *user,BOOL allow_change)
{
fstring user2;
- int last_char;
- int usernamelevel = lp_usernamelevel();
struct passwd *ret;
@@ -177,19 +172,6 @@ struct passwd *Get_Pwnam(char *user,BOOL allow_change)
ret = _Get_Pwnam(user);
if (ret) return(ret);
- /* try with last letter capitalised */
- strlower(user);
- last_char = strlen(user)-1;
- user[last_char] = toupper(user[last_char]);
- DEBUG(3, ("Trying username %s\n", user));
- ret = _Get_Pwnam(user);
- if (ret) return(ret);
-
- /* try all combinations up to usernamelevel */
- strlower(user);
- ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel);
- if (ret) return(ret);
-
if (allow_change)
fstrcpy(user,user2);
@@ -268,57 +250,4 @@ BOOL user_in_list(char *user,char *list)
return(False);
}
-/* The functions below have been taken from password.c and slightly modified */
-/****************************************************************************
-apply a function to upper/lower case combinations
-of a string and return true if one of them returns true.
-try all combinations with N uppercase letters.
-offset is the first char to try and change (start with 0)
-it assumes the string starts lowercased
-****************************************************************************/
-static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(),int N)
-{
- int len = strlen(s);
- int i;
- struct passwd *ret;
-
-#ifdef PASSWORD_LENGTH
- len = MIN(len,PASSWORD_LENGTH);
-#endif
-
- if (N <= 0 || offset >= len)
- return(fn(s));
-
- for (i=offset;i<(len-(N-1));i++)
-
- {
- char c = s[i];
- if (!islower(c)) continue;
- s[i] = toupper(c);
- ret = uname_string_combinations2(s,i+1,fn,N-1);
- if(ret) return(ret);
- s[i] = c;
- }
- return(NULL);
-}
-
-/****************************************************************************
-apply a function to upper/lower case combinations
-of a string and return true if one of them returns true.
-try all combinations with up to N uppercase letters.
-offset is the first char to try and change (start with 0)
-it assumes the string starts lowercased
-****************************************************************************/
-static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(),int N)
-{
- int n;
- struct passwd *ret;
-
- for (n=1;n<=N;n++)
- {
- ret = uname_string_combinations2(s,0,fn,n);
- if(ret) return(ret);
- }
- return(NULL);
-}
diff --git a/source/lib/util.c b/source/lib/util.c
index 01e2dae154c..54b2dc08ac8 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -156,7 +156,7 @@ static void check_log_size(void)
int maxlog;
struct stat st;
- if (debug_count++ < 100) return;
+ if (debug_count++ < 100 || getuid() != 0) return;
maxlog = lp_max_log_size() * 1024;
if (!dbf || maxlog <= 0) return;
@@ -175,7 +175,6 @@ static void check_log_size(void)
debug_count=0;
}
-
/*******************************************************************
write an debug message on the debugfile. This is called by the DEBUG
macro
@@ -190,7 +189,8 @@ va_dcl
char *format_str;
#endif
va_list ap;
-
+ int old_errno = errno;
+
if (stdout_logging) {
#ifdef __STDC__
va_start(ap, format_str);
@@ -200,6 +200,7 @@ va_dcl
#endif
vfprintf(dbf,format_str,ap);
va_end(ap);
+ errno = old_errno;
return(0);
}
@@ -207,16 +208,17 @@ va_dcl
if (!lp_syslog_only())
#endif
{
- if (!dbf)
- {
- int oldumask = umask(022);
- dbf = fopen(debugf,"w");
- umask(oldumask);
- if (dbf)
- setbuf(dbf,NULL);
- else
- return(0);
- }
+ if (!dbf) {
+ int oldumask = umask(022);
+ dbf = fopen(debugf,"w");
+ umask(oldumask);
+ if (dbf) {
+ setbuf(dbf,NULL);
+ } else {
+ errno = old_errno;
+ return(0);
+ }
+ }
}
#ifdef SYSLOG
@@ -273,6 +275,8 @@ va_dcl
check_log_size();
+ errno = old_errno;
+
return(0);
}
@@ -807,145 +811,131 @@ char *attrib_string(int mode)
/*******************************************************************
case insensitive string compararison
********************************************************************/
-int StrCaseCmp(char *s, char *t)
+int StrCaseCmp(const char *s, const char *t)
{
/* compare until we run out of string, either t or s, or find a difference */
/* We *must* use toupper rather than tolower here due to the
asynchronous upper to lower mapping.
*/
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ int diff;
+ for (;;)
{
- /* Win95 treats full width ascii characters as case sensitive. */
- int diff;
- for (;;)
- {
- if (!*s || !*t)
- return toupper (*s) - toupper (*t);
- else if (is_sj_alph (*s) && is_sj_alph (*t))
- {
- diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1));
- if (diff)
- return diff;
- s += 2;
- t += 2;
- }
- else if (is_shift_jis (*s) && is_shift_jis (*t))
- {
- diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t);
- if (diff)
- return diff;
- diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1));
- if (diff)
- return diff;
- s += 2;
- t += 2;
- }
- else if (is_shift_jis (*s))
- return 1;
- else if (is_shift_jis (*t))
- return -1;
- else
- {
- diff = toupper (*s) - toupper (*t);
- if (diff)
- return diff;
- s++;
- t++;
- }
- }
+ if (!*s || !*t)
+ return toupper (*s) - toupper (*t);
+ else if (is_sj_alph (*s) && is_sj_alph (*t))
+ {
+ diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1));
+ if (diff)
+ return diff;
+ s += 2;
+ t += 2;
+ }
+ else if (is_shift_jis (*s) && is_shift_jis (*t))
+ {
+ diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t);
+ if (diff)
+ return diff;
+ diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1));
+ if (diff)
+ return diff;
+ s += 2;
+ t += 2;
+ }
+ else if (is_shift_jis (*s))
+ return 1;
+ else if (is_shift_jis (*t))
+ return -1;
+ else
+ {
+ diff = toupper (*s) - toupper (*t);
+ if (diff)
+ return diff;
+ s++;
+ t++;
+ }
}
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
+#else /* KANJI */
+ while (*s && *t && toupper(*s) == toupper(*t))
{
- while (*s && *t && toupper(*s) == toupper(*t))
- {
- s++;
- t++;
- }
-
- return(toupper(*s) - toupper(*t));
+ s++; t++;
}
+
+ return(toupper(*s) - toupper(*t));
+#endif /* KANJI */
}
/*******************************************************************
case insensitive string compararison, length limited
********************************************************************/
-int StrnCaseCmp(char *s, char *t, int n)
+int StrnCaseCmp(const char *s, const char *t, int n)
{
/* compare until we run out of string, either t or s, or chars */
/* We *must* use toupper rather than tolower here due to the
asynchronous upper to lower mapping.
*/
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ int diff;
+ for (;n > 0;)
{
- /* Win95 treats full width ascii characters as case sensitive. */
- int diff;
- for (;n > 0;)
- {
- if (!*s || !*t)
- return toupper (*s) - toupper (*t);
- else if (is_sj_alph (*s) && is_sj_alph (*t))
- {
- diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1));
- if (diff)
- return diff;
- s += 2;
- t += 2;
- n -= 2;
- }
- else if (is_shift_jis (*s) && is_shift_jis (*t))
- {
- diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t);
- if (diff)
- return diff;
- diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1));
- if (diff)
- return diff;
- s += 2;
- t += 2;
- n -= 2;
- }
- else if (is_shift_jis (*s))
- return 1;
- else if (is_shift_jis (*t))
- return -1;
- else
- {
- diff = toupper (*s) - toupper (*t);
- if (diff)
- return diff;
- s++;
- t++;
- n--;
- }
- }
- return 0;
+ if (!*s || !*t)
+ return toupper (*s) - toupper (*t);
+ else if (is_sj_alph (*s) && is_sj_alph (*t))
+ {
+ diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1));
+ if (diff)
+ return diff;
+ s += 2;
+ t += 2;
+ n -= 2;
+ }
+ else if (is_shift_jis (*s) && is_shift_jis (*t))
+ {
+ diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t);
+ if (diff)
+ return diff;
+ diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1));
+ if (diff)
+ return diff;
+ s += 2;
+ t += 2;
+ n -= 2;
+ }
+ else if (is_shift_jis (*s))
+ return 1;
+ else if (is_shift_jis (*t))
+ return -1;
+ else
+ {
+ diff = toupper (*s) - toupper (*t);
+ if (diff)
+ return diff;
+ s++;
+ t++;
+ n--;
+ }
}
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
+ return 0;
+#else /* KANJI */
+ while (n-- && *s && *t && toupper(*s) == toupper(*t))
{
- while (n-- && *s && *t && toupper(*s) == toupper(*t))
- {
- s++;
- t++;
- }
+ s++; t++;
+ }
- /* not run out of chars - strings are different lengths */
- if (n)
- return(toupper(*s) - toupper(*t));
+ /* not run out of chars - strings are different lengths */
+ if (n) return(toupper(*s) - toupper(*t));
- /* identical up to where we run out of chars,
- and strings are same length */
- return(0);
- }
+ /* identical up to where we run out of chars, and strings are same length */
+ return(0);
+#endif /* KANJI */
}
/*******************************************************************
compare 2 strings
********************************************************************/
-BOOL strequal(char *s1, char *s2)
+BOOL strequal(const char *s1, const char *s2)
{
if (s1 == s2) return(True);
if (!s1 || !s2) return(False);
@@ -956,7 +946,7 @@ BOOL strequal(char *s1, char *s2)
/*******************************************************************
compare 2 strings up to and including the nth char.
******************************************************************/
-BOOL strnequal(char *s1,char *s2,int n)
+BOOL strnequal(const char *s1,const char *s2,int n)
{
if (s1 == s2) return(True);
if (!s1 || !s2 || !n) return(False);
@@ -982,36 +972,27 @@ BOOL strcsequal(char *s1,char *s2)
void strlower(char *s)
{
while (*s)
- {
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- /* Win95 treats full width ascii characters as case sensitive. */
- if (is_shift_jis (*s))
- {
- if (is_sj_upper (s[0], s[1]))
- s[1] = sj_tolower2 (s[1]);
- s += 2;
- }
- else if (is_kana (*s))
- {
- s++;
- }
- else
- {
- if (isupper(*s))
- *s = tolower(*s);
- s++;
- }
- }
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
{
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ if (is_shift_jis (*s)) {
+ if (is_sj_upper (s[0], s[1])) {
+ s[1] = sj_tolower2 (s[1]);
+ }
+ s += 2;
+ } else if (is_kana (*s)) {
+ s++;
+ } else {
+ if (isupper(*s))
+ *s = tolower(*s);
+ s++;
+ }
+#else /* KANJI */
if (isupper(*s))
- *s = tolower(*s);
+ *s = tolower(*s);
s++;
+#endif /* KANJI */
}
- }
}
/*******************************************************************
@@ -1020,36 +1001,27 @@ void strlower(char *s)
void strupper(char *s)
{
while (*s)
- {
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- /* Win95 treats full width ascii characters as case sensitive. */
- if (is_shift_jis (*s))
- {
- if (is_sj_lower (s[0], s[1]))
- s[1] = sj_toupper2 (s[1]);
- s += 2;
- }
- else if (is_kana (*s))
- {
- s++;
- }
- else
- {
- if (islower(*s))
- *s = toupper(*s);
- s++;
- }
- }
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
{
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ if (is_shift_jis (*s)) {
+ if (is_sj_lower (s[0], s[1])) {
+ s[1] = sj_toupper2 (s[1]);
+ }
+ s += 2;
+ } else if (is_kana (*s)) {
+ s++;
+ } else {
+ if (islower(*s))
+ *s = toupper(*s);
+ s++;
+ }
+#else /* KANJI */
if (islower(*s))
- *s = toupper(*s);
+ *s = toupper(*s);
s++;
+#endif /* KANJI */
}
- }
}
/*******************************************************************
@@ -1081,30 +1053,24 @@ BOOL strisnormal(char *s)
void string_replace(char *s,char oldc,char newc)
{
while (*s)
- {
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- /* Win95 treats full width ascii characters as case sensitive. */
- if (is_shift_jis (*s))
- s += 2;
- else if (is_kana (*s))
- s++;
- else
- {
- if (oldc == *s)
- *s = newc;
- s++;
- }
- }
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
{
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ if (is_shift_jis (*s)) {
+ s += 2;
+ } else if (is_kana (*s)) {
+ s++;
+ } else {
+ if (oldc == *s)
+ *s = newc;
+ s++;
+ }
+#else /* KANJI */
if (oldc == *s)
- *s = newc;
+ *s = newc;
s++;
+#endif /* KANJI */
}
- }
}
/****************************************************************************
@@ -1488,7 +1454,7 @@ char *GetWd(char *str)
if (!sys_getwd(s))
{
- DEBUG(0,("Getwd failed, errno %s\n",strerror(errno)));
+ DEBUG(0,("Getwd failed, errno %d\n",errno));
return (NULL);
}
@@ -1726,30 +1692,22 @@ does a string have any uppercase chars in it?
BOOL strhasupper(char *s)
{
while (*s)
- {
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
{
- /* Win95 treats full width ascii characters as case sensitive. */
- if (is_shift_jis (*s))
- s += 2;
- else if (is_kana (*s))
- s++;
- else
- {
- if (isupper(*s))
- return(True);
- s++;
- }
- }
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
- {
- if (isupper(*s))
- return(True);
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ if (is_shift_jis (*s)) {
+ s += 2;
+ } else if (is_kana (*s)) {
+ s++;
+ } else {
+ if (isupper(*s)) return(True);
+ s++;
+ }
+#else /* KANJI */
+ if (isupper(*s)) return(True);
s++;
+#endif /* KANJI */
}
- }
return(False);
}
@@ -1759,38 +1717,24 @@ does a string have any lowercase chars in it?
BOOL strhaslower(char *s)
{
while (*s)
- {
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
{
- /* Win95 treats full width ascii characters as case sensitive. */
- if (is_shift_jis (*s))
- {
- if (is_sj_upper (s[0], s[1]))
- return(True);
- if (is_sj_lower (s[0], s[1]))
- return (True);
- s += 2;
- }
- else if (is_kana (*s))
- {
- s++;
- }
- else
- {
- if (islower(*s))
- return(True);
- s++;
- }
- }
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
- {
- if (islower(*s))
- return(True);
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ if (is_shift_jis (*s)) {
+ if (is_sj_upper (s[0], s[1])) return(True);
+ if (is_sj_lower (s[0], s[1])) return (True);
+ s += 2;
+ } else if (is_kana (*s)) {
+ s++;
+ } else {
+ if (islower(*s)) return(True);
+ s++;
+ }
+#else /* KANJI */
+ if (islower(*s)) return(True);
s++;
+#endif /* KANJI */
}
- }
return(False);
}
@@ -1800,33 +1744,27 @@ find the number of chars in a string
int count_chars(char *s,char c)
{
int count=0;
-
-#if !defined(KANJI_WIN95_COMPATIBILITY)
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- /* Win95 treats full width ascii characters as case sensitive. */
- while (*s)
+#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY)
+ /* Win95 treats full width ascii characters as case sensitive. */
+ while (*s)
{
- if (is_shift_jis (*s))
- s += 2;
- else
- {
- if (*s == c)
- count++;
- s++;
- }
+ if (is_shift_jis (*s))
+ s += 2;
+ else
+ {
+ if (*s == c)
+ count++;
+ s++;
}
}
- else
-#endif /* KANJI_WIN95_COMPATIBILITY */
- {
- while (*s)
+#else /* KANJI */
+ while (*s)
{
if (*s == c)
- count++;
+ count++;
s++;
}
- }
+#endif /* KANJI */
return(count);
}
@@ -1951,7 +1889,7 @@ int read_udp_socket(int fd,char *buf,int len)
bzero((char *)&lastip,sizeof(lastip));
ret = recvfrom(fd,buf,len,0,&sock,&socklen);
if (ret <= 0) {
- DEBUG(2,("read socket failed. ERRNO=%s\n",strerror(errno)));
+ DEBUG(2,("read socket failed. ERRNO=%d\n",errno));
return(0);
}
@@ -2270,11 +2208,10 @@ int read_smb_length(int fd,char *inbuf,int timeout)
/****************************************************************************
- read an smb from a fd. Note that the buffer *MUST* be of size
- BUFFER_SIZE+SAFETY_MARGIN.
+ read an smb from a fd and return it's length
The timeout is in milli seconds
****************************************************************************/
-BOOL receive_smb(int fd,char *buffer, int timeout)
+BOOL receive_smb(int fd,char *buffer,int timeout)
{
int len,ret;
@@ -2301,204 +2238,6 @@ BOOL receive_smb(int fd,char *buffer, int timeout)
return(True);
}
-#ifdef USE_OPLOCKS
-/****************************************************************************
- read a message from a udp fd.
-The timeout is in milli seconds
-****************************************************************************/
-BOOL receive_local_message(int fd, char *buffer, int buffer_len, int timeout)
-{
- struct sockaddr_in from;
- int fromlen = sizeof(from);
- int32 msg_len = 0;
-
- if(timeout != 0)
- {
- struct timeval to;
- fd_set fds;
- int selrtn;
-
- FD_ZERO(&fds);
- FD_SET(fd,&fds);
-
- to.tv_sec = timeout / 1000;
- to.tv_usec = (timeout % 1000) * 1000;
-
- selrtn = sys_select(&fds,&to);
-
- /* Check if error */
- if(selrtn == -1)
- {
- /* something is wrong. Maybe the socket is dead? */
- smb_read_error = READ_ERROR;
- return False;
- }
-
- /* Did we timeout ? */
- if (selrtn == 0)
- {
- smb_read_error = READ_TIMEOUT;
- return False;
- }
- }
-
- /*
- * Read a loopback udp message.
- */
- msg_len = recvfrom(fd, &buffer[UDP_CMD_HEADER_LEN],
- buffer_len - UDP_CMD_HEADER_LEN, 0,
- (struct sockaddr *)&from, &fromlen);
-
- if(msg_len < 0)
- {
- DEBUG(0,("receive_local_message. Error in recvfrom. (%s).\n",strerror(errno)));
- return False;
- }
-
- /* Validate message length. */
- if(msg_len > (buffer_len - UDP_CMD_HEADER_LEN))
- {
- DEBUG(0,("receive_local_message: invalid msg_len (%d) max can be %d\n",
- msg_len,
- buffer_len - UDP_CMD_HEADER_LEN));
- return False;
- }
-
- /* Validate message from address (must be localhost). */
- if(from.sin_addr.s_addr != htonl(INADDR_LOOPBACK))
- {
- DEBUG(0,("receive_local_message: invalid 'from' address \
-(was %x should be 127.0.0.1\n", from.sin_addr.s_addr));
- return False;
- }
-
- /* Setup the message header */
- SIVAL(buffer,UDP_CMD_LEN_OFFSET,msg_len);
- SSVAL(buffer,UDP_CMD_PORT_OFFSET,ntohs(from.sin_port));
-
- return True;
-}
-
-/****************************************************************************
- structure to hold a linked list of local udp messages.
- for processing.
-****************************************************************************/
-
-typedef struct _udp_message_list {
- struct _udp_message_list *msg_next;
- char *msg_buf;
- int msg_len;
-} udp_message_list;
-
-static udp_message_list *udp_msg_head = NULL;
-
-/****************************************************************************
- Function to push a linked list of local udp messages ready
- for processing.
-****************************************************************************/
-BOOL push_local_message(char *buf, int msg_len)
-{
- udp_message_list *msg = (udp_message_list *)malloc(sizeof(udp_message_list));
-
- if(msg == NULL)
- {
- DEBUG(0,("push_local_message: malloc fail (1)\n"));
- return False;
- }
-
- msg->msg_buf = (char *)malloc(msg_len);
- if(msg->msg_buf == NULL)
- {
- DEBUG(0,("push_local_message: malloc fail (2)\n"));
- free((char *)msg);
- return False;
- }
-
- memcpy(msg->msg_buf, buf, msg_len);
- msg->msg_len = msg_len;
-
- msg->msg_next = udp_msg_head;
- udp_msg_head = msg;
-
- return True;
-}
-
-/****************************************************************************
- Do a select on an two fd's - with timeout.
-
- If a local udp message has been pushed onto the
- queue (this can only happen during oplock break
- processing) return this first.
-
- If the first smbfd is ready then read an smb from it.
- if the second (loopback UDP) fd is ready then read a message
- from it and setup the buffer header to identify the length
- and from address.
- Returns False on timeout or error.
- Else returns True.
-
-The timeout is in milli seconds
-****************************************************************************/
-BOOL receive_message_or_smb(int smbfd, int oplock_fd,
- char *buffer, int buffer_len,
- int timeout, BOOL *got_smb)
-{
- fd_set fds;
- int selrtn;
- struct timeval to;
-
- *got_smb = False;
-
- /*
- * Check to see if we already have a message on the udp queue.
- * If so - copy and return it.
- */
-
- if(udp_msg_head)
- {
- udp_message_list *msg = udp_msg_head;
- memcpy(buffer, msg->msg_buf, MIN(buffer_len, msg->msg_len));
- udp_msg_head = msg->msg_next;
-
- /* Free the message we just copied. */
- free((char *)msg->msg_buf);
- free((char *)msg);
- return True;
- }
-
- FD_ZERO(&fds);
- FD_SET(smbfd,&fds);
- FD_SET(oplock_fd,&fds);
-
- to.tv_sec = timeout / 1000;
- to.tv_usec = (timeout % 1000) * 1000;
-
- selrtn = sys_select(&fds,timeout>0?&to:NULL);
-
- /* Check if error */
- if(selrtn == -1) {
- /* something is wrong. Maybe the socket is dead? */
- smb_read_error = READ_ERROR;
- return False;
- }
-
- /* Did we timeout ? */
- if (selrtn == 0) {
- smb_read_error = READ_TIMEOUT;
- return False;
- }
-
- if (FD_ISSET(smbfd,&fds))
- {
- *got_smb = True;
- return receive_smb(smbfd, buffer, 0);
- }
- else
- {
- return receive_local_message(oplock_fd, buffer, buffer_len, 0);
- }
-}
-#endif /* USE_OPLOCKS */
/****************************************************************************
send an smb to a fd
@@ -2607,8 +2346,8 @@ BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type)
ret = (sendto(out_fd,buf,len,0,(struct sockaddr *)&sock_out,sizeof(sock_out)) >= 0);
if (!ret)
- DEBUG(0,("Packet send to %s(%d) failed ERRNO=%s\n",
- inet_ntoa(ip),port,strerror(errno)));
+ DEBUG(0,("Packet send to %s(%d) failed ERRNO=%d\n",
+ inet_ntoa(ip),port,errno));
close(out_fd);
return(ret);
@@ -2860,7 +2599,7 @@ BOOL mask_match(char *str, char *regexp, int case_sig,BOOL trans2)
if (strequal(p1,"*")) return(True);
- DEBUG(8,("mask_match str=<%s> regexp=<%s>, case_sig = %d\n", p2, p1, case_sig));
+ DEBUG(5,("mask_match str=<%s> regexp=<%s>, case_sig = %d\n", p2, p1, case_sig));
if (trans2) {
fstrcpy(ebase,p1);
@@ -2888,7 +2627,7 @@ BOOL mask_match(char *str, char *regexp, int case_sig,BOOL trans2)
matched = do_match(sbase,ebase,case_sig) &&
(trans2 || do_match(sext,eext,case_sig));
- DEBUG(8,("mask_match returning %d\n", matched));
+ DEBUG(5,("mask_match returning %d\n", matched));
return matched;
}
@@ -3296,8 +3035,26 @@ int open_socket_out(int type, struct in_addr *addr, int port ,int timeout)
if (res == -1)
{ DEBUG(0,("socket error\n")); return -1; }
- if (type != SOCK_STREAM) return(res);
+#ifdef BIND_LOCAL_OUTPUT_SOCKET
+ {
+ struct sockaddr_in sock_in;
+ /* Bind the local part of this socket to the address
+ given in the socket address parameter. */
+
+ bzero((char *)&sock_in,sizeof(sock_in));
+ putip((char *)&sock_in.sin_addr,(char *)interpret_addr2(lp_socket_address()));
+ sock_in.sin_port = 0;
+ sock_in.sin_family = PF_INET;
+
+ if (bind(res, (struct sockaddr * ) &sock_in,sizeof(sock_in)) < 0)
+ DEBUG(0,("Failed to bind local socket address for output socket. Error was %s\n",
+ strerror(errno)));
+ }
+#endif /* BIND_LOCAL_OUTPUT_SOCKET */
+
+ if (type != SOCK_STREAM) return(res);
+
bzero((char *)&sock_out,sizeof(sock_out));
putip((char *)&sock_out.sin_addr,(char *)addr);
@@ -3834,24 +3591,24 @@ char *readdirname(void *p)
return(dname);
}
-/*******************************************************************
- Utility function used to decide if the last component
- of a path matches a (possibly wildcarded) entry in a namelist.
-********************************************************************/
+/*
+ * Utility function used to decide if the last component
+ * of a path matches a (possibly wildcarded) entry in a namelist.
+ */
BOOL is_in_path(char *name, name_compare_entry *namelist)
{
pstring last_component;
char *p;
- DEBUG(8, ("is_in_path: %s\n", name));
+ DEBUG(5, ("is_in_path: %s\n", name));
/* if we have no list it's obviously not in the path */
if((namelist == NULL ) || ((namelist != NULL) && (namelist[0].name == NULL)))
- {
- DEBUG(8,("is_in_path: no name list.\n"));
+ {
+ DEBUG(5,("is_in_path: no name list.\n"));
return False;
- }
+}
/* Get the last component of the unix name. */
p = strrchr(name, '/');
@@ -3865,7 +3622,7 @@ BOOL is_in_path(char *name, name_compare_entry *namelist)
/* look for a wildcard match. */
if (mask_match(last_component, namelist->name, case_sensitive, False))
{
- DEBUG(8,("is_in_path: mask match succeeded\n"));
+ DEBUG(5,("is_in_path: mask match succeeded\n"));
return True;
}
}
@@ -3874,29 +3631,29 @@ BOOL is_in_path(char *name, name_compare_entry *namelist)
if((case_sensitive && (strcmp(last_component, namelist->name) == 0))||
(!case_sensitive && (StrCaseCmp(last_component, namelist->name) == 0)))
{
- DEBUG(8,("is_in_path: match succeeded\n"));
+ DEBUG(5,("is_in_path: match succeeded\n"));
return True;
}
}
}
- DEBUG(8,("is_in_path: match not found\n"));
+ DEBUG(5,("is_in_path: match not found\n"));
return False;
}
-/*******************************************************************
- Strip a '/' separated list into an array of
- name_compare_enties structures suitable for
- passing to is_in_path(). We do this for
- speed so we can pre-parse all the names in the list
- and don't do it for each call to is_in_path().
- namelist is modified here and is assumed to be
- a copy owned by the caller.
- We also check if the entry contains a wildcard to
- remove a potentially expensive call to mask_match
- if possible.
-********************************************************************/
-
+/*
+ * Strip a '/' separated list into an array of
+ * name_compare_enties structures suitable for
+ * passing to is_in_path(). We do this for
+ * speed so we can pre-parse all the names in the list
+ * and don't do it for each call to is_in_path().
+ * namelist is modified here and is assumed to be
+ * a copy owned by the caller.
+ * We also check if the entry contains a wildcard to
+ * remove a potentially expensive call to mask_match
+ * if possible.
+ */
+
void set_namearray(name_compare_entry **ppname_array, char *namelist)
{
char *name_end;
@@ -4037,7 +3794,7 @@ BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type)
#endif
- DEBUG(8,("fcntl_lock %d %d %d %d %d\n",fd,op,(int)offset,(int)count,type));
+ DEBUG(5,("fcntl_lock %d %d %d %d %d\n",fd,op,(int)offset,(int)count,type));
lock.l_type = type;
lock.l_whence = SEEK_SET;
@@ -4085,7 +3842,7 @@ BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type)
}
/* everything went OK */
- DEBUG(8,("Lock call successful\n"));
+ DEBUG(5,("Lock call successful\n"));
return(True);
#else
@@ -4131,7 +3888,7 @@ void file_unlock(int fd)
is the name specified one of my netbios names
returns true is it is equal, false otherwise
********************************************************************/
-BOOL is_myname(char *s)
+BOOL is_myname(const char *s)
{
int n;
BOOL ret = False;
@@ -4182,52 +3939,53 @@ enum remote_arch_types get_remote_arch()
return ra_type;
}
+
/*******************************************************************
safe string copy into a fstring
********************************************************************/
void fstrcpy(char *dest, char *src)
{
- int maxlength = sizeof(fstring) - 1;
- if (!dest) {
- DEBUG(0,("ERROR: NULL dest in fstrcpy\n"));
- return;
- }
+ int maxlength = sizeof(fstring) - 1;
+ if (!dest) {
+ DEBUG(0,("ERROR: NULL dest in fstrcpy\n"));
+ return;
+ }
- if (!src) {
- *dest = 0;
- return;
- }
-
- while (maxlength-- && *src)
- *dest++ = *src++;
- *dest = 0;
- if (*src) {
- DEBUG(0,("ERROR: string overflow by %d in fstrcpy\n",
- strlen(src)));
- }
-}
+ if (!src) {
+ *dest = 0;
+ return;
+ }
+
+ while (maxlength-- && *src)
+ *dest++ = *src++;
+ *dest = 0;
+ if (*src) {
+ DEBUG(0,("ERROR: string overflow by %d in fstrcpy\n",
+ strlen(src)));
+ }
+}
/*******************************************************************
safe string copy into a pstring
********************************************************************/
void pstrcpy(char *dest, char *src)
{
- int maxlength = sizeof(pstring) - 1;
- if (!dest) {
- DEBUG(0,("ERROR: NULL dest in pstrcpy\n"));
- return;
- }
-
- if (!src) {
- *dest = 0;
- return;
- }
-
- while (maxlength-- && *src)
- *dest++ = *src++;
- *dest = 0;
- if (*src) {
- DEBUG(0,("ERROR: string overflow by %d in pstrcpy\n",
- strlen(src)));
- }
-}
+ int maxlength = sizeof(pstring) - 1;
+ if (!dest) {
+ DEBUG(0,("ERROR: NULL dest in pstrcpy\n"));
+ return;
+ }
+
+ if (!src) {
+ *dest = 0;
+ return;
+ }
+
+ while (maxlength-- && *src)
+ *dest++ = *src++;
+ *dest = 0;
+ if (*src) {
+ DEBUG(0,("ERROR: string overflow by %d in pstrcpy\n",
+ strlen(src)));
+ }
+}
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
new file mode 100644
index 00000000000..d50349501fe
--- /dev/null
+++ b/source/libsmb/clientgen.c
@@ -0,0 +1,675 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ SMB client generic functions
+ Copyright (C) Andrew Tridgell 1994-1997
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifdef SYSLOG
+#undef SYSLOG
+#endif
+
+#include "includes.h"
+
+
+extern int DEBUGLEVEL;
+
+/****************************************************************************
+setup basics in a outgoing packet
+****************************************************************************/
+static void cli_setup_pkt(struct cli_state *cli)
+{
+ SSVAL(cli->outbuf,smb_pid,cli->pid);
+ SSVAL(cli->outbuf,smb_uid,cli->uid);
+ SSVAL(cli->outbuf,smb_mid,cli->mid);
+ if (cli->protocol > PROTOCOL_CORE) {
+ SCVAL(cli->outbuf,smb_flg,0x8);
+ SSVAL(cli->outbuf,smb_flg2,0x1);
+ }
+}
+
+
+/****************************************************************************
+ send a SMB trans or trans2 request
+ ****************************************************************************/
+static BOOL cli_send_trans(struct cli_state *cli,
+ int trans, char *name, int fid, int flags,
+ char *data,char *param,uint16 *setup, int ldata,int lparam,
+ int lsetup,int mdata,int mparam,int msetup)
+{
+ int i;
+ int this_ldata,this_lparam;
+ int tot_data=0,tot_param=0;
+ char *outdata,*outparam;
+ char *p;
+
+ this_lparam = MIN(lparam,cli->max_xmit - (500+lsetup*SIZEOFWORD)); /* hack */
+ this_ldata = MIN(ldata,cli->max_xmit - (500+lsetup*SIZEOFWORD+this_lparam));
+
+ bzero(cli->outbuf,smb_size);
+ set_message(cli->outbuf,14+lsetup,0,True);
+ CVAL(cli->outbuf,smb_com) = trans;
+ SSVAL(cli->outbuf,smb_tid, cli->cnum);
+ cli_setup_pkt(cli);
+
+ outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? strlen(name)+1 : 3);
+ outdata = outparam+this_lparam;
+
+ /* primary request */
+ SSVAL(cli->outbuf,smb_tpscnt,lparam); /* tpscnt */
+ SSVAL(cli->outbuf,smb_tdscnt,ldata); /* tdscnt */
+ SSVAL(cli->outbuf,smb_mprcnt,mparam); /* mprcnt */
+ SSVAL(cli->outbuf,smb_mdrcnt,mdata); /* mdrcnt */
+ SCVAL(cli->outbuf,smb_msrcnt,msetup); /* msrcnt */
+ SSVAL(cli->outbuf,smb_flags,flags); /* flags */
+ SIVAL(cli->outbuf,smb_timeout,0); /* timeout */
+ SSVAL(cli->outbuf,smb_pscnt,this_lparam); /* pscnt */
+ SSVAL(cli->outbuf,smb_psoff,smb_offset(outparam,cli->outbuf)); /* psoff */
+ SSVAL(cli->outbuf,smb_dscnt,this_ldata); /* dscnt */
+ SSVAL(cli->outbuf,smb_dsoff,smb_offset(outdata,cli->outbuf)); /* dsoff */
+ SCVAL(cli->outbuf,smb_suwcnt,lsetup); /* suwcnt */
+ for (i=0;i<lsetup;i++) /* setup[] */
+ SSVAL(cli->outbuf,smb_setup+i*SIZEOFWORD,setup[i]);
+ p = smb_buf(cli->outbuf);
+ if (trans==SMBtrans) {
+ strcpy(p,name); /* name[] */
+ } else {
+ *p++ = 0; /* put in a null smb_name */
+ *p++ = 'D'; *p++ = ' '; /* observed in OS/2 */
+ }
+ if (this_lparam) /* param[] */
+ memcpy(outparam,param,this_lparam);
+ if (this_ldata) /* data[] */
+ memcpy(outdata,data,this_ldata);
+ set_message(cli->outbuf,14+lsetup, /* wcnt, bcc */
+ PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False);
+
+ show_msg(cli->outbuf);
+ send_smb(cli->fd,cli->outbuf);
+
+ if (this_ldata < ldata || this_lparam < lparam) {
+ /* receive interim response */
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout) ||
+ CVAL(cli->inbuf,smb_rcls) != 0) {
+ return(False);
+ }
+
+ tot_data = this_ldata;
+ tot_param = this_lparam;
+
+ while (tot_data < ldata || tot_param < lparam) {
+ this_lparam = MIN(lparam-tot_param,cli->max_xmit - 500); /* hack */
+ this_ldata = MIN(ldata-tot_data,cli->max_xmit - (500+this_lparam));
+
+ set_message(cli->outbuf,trans==SMBtrans?8:9,0,True);
+ CVAL(cli->outbuf,smb_com) = trans==SMBtrans ? SMBtranss : SMBtranss2;
+
+ outparam = smb_buf(cli->outbuf);
+ outdata = outparam+this_lparam;
+
+ /* secondary request */
+ SSVAL(cli->outbuf,smb_tpscnt,lparam); /* tpscnt */
+ SSVAL(cli->outbuf,smb_tdscnt,ldata); /* tdscnt */
+ SSVAL(cli->outbuf,smb_spscnt,this_lparam); /* pscnt */
+ SSVAL(cli->outbuf,smb_spsoff,smb_offset(outparam,cli->outbuf)); /* psoff */
+ SSVAL(cli->outbuf,smb_spsdisp,tot_param); /* psdisp */
+ SSVAL(cli->outbuf,smb_sdscnt,this_ldata); /* dscnt */
+ SSVAL(cli->outbuf,smb_sdsoff,smb_offset(outdata,cli->outbuf)); /* dsoff */
+ SSVAL(cli->outbuf,smb_sdsdisp,tot_data); /* dsdisp */
+ if (trans==SMBtrans2)
+ SSVAL(cli->outbuf,smb_sfid,fid); /* fid */
+ if (this_lparam) /* param[] */
+ memcpy(outparam,param,this_lparam);
+ if (this_ldata) /* data[] */
+ memcpy(outdata,data,this_ldata);
+ set_message(cli->outbuf,trans==SMBtrans?8:9, /* wcnt, bcc */
+ PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False);
+
+ show_msg(cli->outbuf);
+ send_smb(cli->fd,cli->outbuf);
+
+ tot_data += this_ldata;
+ tot_param += this_lparam;
+ }
+ }
+
+ return(True);
+}
+
+
+/****************************************************************************
+ receive a SMB trans or trans2 response allocating the necessary memory
+ ****************************************************************************/
+static BOOL cli_receive_trans(struct cli_state *cli,
+ int trans,int *data_len,
+ int *param_len, char **data,char **param)
+{
+ int total_data=0;
+ int total_param=0;
+ int this_data,this_param;
+
+ *data_len = *param_len = 0;
+
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ show_msg(cli->inbuf);
+
+ /* sanity check */
+ if (CVAL(cli->inbuf,smb_com) != trans) {
+ DEBUG(0,("Expected %s response, got command 0x%02x\n",
+ trans==SMBtrans?"SMBtrans":"SMBtrans2",
+ CVAL(cli->inbuf,smb_com)));
+ return(False);
+ }
+ if (CVAL(cli->inbuf,smb_rcls) != 0)
+ return(False);
+
+ /* parse out the lengths */
+ total_data = SVAL(cli->inbuf,smb_tdrcnt);
+ total_param = SVAL(cli->inbuf,smb_tprcnt);
+
+ /* allocate it */
+ *data = Realloc(*data,total_data);
+ *param = Realloc(*param,total_param);
+
+ while (1) {
+ this_data = SVAL(cli->inbuf,smb_drcnt);
+ this_param = SVAL(cli->inbuf,smb_prcnt);
+
+ if (this_data + *data_len > total_data ||
+ this_param + *param_len > total_param) {
+ DEBUG(1,("Data overflow in cli_receive_trans\n"));
+ return False;
+ }
+
+ if (this_data)
+ memcpy(*data + SVAL(cli->inbuf,smb_drdisp),
+ smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_droff),
+ this_data);
+ if (this_param)
+ memcpy(*param + SVAL(cli->inbuf,smb_prdisp),
+ smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_proff),
+ this_param);
+ *data_len += this_data;
+ *param_len += this_param;
+
+ /* parse out the total lengths again - they can shrink! */
+ total_data = SVAL(cli->inbuf,smb_tdrcnt);
+ total_param = SVAL(cli->inbuf,smb_tprcnt);
+
+ if (total_data <= *data_len && total_param <= *param_len)
+ break;
+
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ show_msg(cli->inbuf);
+
+ /* sanity check */
+ if (CVAL(cli->inbuf,smb_com) != trans) {
+ DEBUG(0,("Expected %s response, got command 0x%02x\n",
+ trans==SMBtrans?"SMBtrans":"SMBtrans2",
+ CVAL(cli->inbuf,smb_com)));
+ return(False);
+ }
+ if (CVAL(cli->inbuf,smb_rcls) != 0)
+ return(False);
+ }
+
+ return(True);
+}
+
+
+/****************************************************************************
+call a remote api
+****************************************************************************/
+static BOOL cli_api(struct cli_state *cli,
+ int prcnt,int drcnt,int mprcnt,int mdrcnt,int *rprcnt,
+ int *rdrcnt, char *param,char *data,
+ char **rparam, char **rdata)
+{
+ cli_send_trans(cli,SMBtrans,"\\PIPE\\LANMAN",0,0,
+ data,param,NULL,
+ drcnt,prcnt,0,
+ mdrcnt,mprcnt,0);
+
+ return (cli_receive_trans(cli,SMBtrans,
+ rdrcnt,rprcnt,
+ rdata,rparam));
+}
+
+
+/****************************************************************************
+perform a NetWkstaUserLogon
+****************************************************************************/
+BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
+{
+ char *rparam = NULL;
+ char *rdata = NULL;
+ char *p;
+ int rdrcnt,rprcnt;
+ pstring param;
+
+ memset(param, 0, sizeof(param));
+
+ /* send a SMBtrans command with api NetWkstaUserLogon */
+ p = param;
+ SSVAL(p,0,132); /* api number */
+ p += 2;
+ strcpy(p,"OOWb54WrLh");
+ p = skip_string(p,1);
+ strcpy(p,"WB21BWDWWDDDDDDDzzzD");
+ p = skip_string(p,1);
+ SSVAL(p,0,1);
+ p += 2;
+ strcpy(p,user);
+ strupper(p);
+ p += 21; p++; p += 15; p++;
+ strcpy(p, workstation);
+ strupper(p);
+ p += 16;
+ SSVAL(p, 0, BUFFER_SIZE);
+ p += 2;
+ SSVAL(p, 0, BUFFER_SIZE);
+ p += 2;
+
+ cli->error = -1;
+
+ if (cli_api(cli, PTR_DIFF(p,param),0,
+ 1024,BUFFER_SIZE,
+ &rprcnt,&rdrcnt,
+ param,NULL,
+ &rparam,&rdata)) {
+ cli->error = SVAL(rparam,0);
+ p = rdata;
+
+ if (cli->error == 0) {
+ DEBUG(4,("NetWkstaUserLogon success\n"));
+ cli->privilages = SVAL(p, 24);
+ fstrcpy(cli->eff_name,p+2);
+ } else {
+ DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->error));
+ }
+ }
+
+ if (rparam) free(rparam);
+ if (rdata) free(rdata);
+ return cli->error == 0;
+}
+
+
+
+static struct {
+ int prot;
+ char *name;
+ }
+prots[] =
+ {
+ {PROTOCOL_CORE,"PC NETWORK PROGRAM 1.0"},
+ {PROTOCOL_COREPLUS,"MICROSOFT NETWORKS 1.03"},
+ {PROTOCOL_LANMAN1,"MICROSOFT NETWORKS 3.0"},
+ {PROTOCOL_LANMAN1,"LANMAN1.0"},
+ {PROTOCOL_LANMAN2,"LM1.2X002"},
+ {PROTOCOL_LANMAN2,"Samba"},
+ {PROTOCOL_NT1,"NT LM 0.12"},
+ {PROTOCOL_NT1,"NT LANMAN 1.0"},
+ {-1,NULL}
+ };
+
+
+/****************************************************************************
+send a session setup
+****************************************************************************/
+BOOL cli_session_setup(struct cli_state *cli,
+ char *user,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen,
+ char *workgroup)
+{
+ char *p;
+ fstring pword;
+
+ if (cli->protocol < PROTOCOL_LANMAN1)
+ return False;
+
+ if (passlen > sizeof(pword)-1) {
+ return False;
+ }
+
+ if ((cli->sec_mode & 2) && *pass && passlen != 24) {
+#ifdef SMB_PASSWD
+ passlen = 24;
+ SMBencrypt((uchar *)pass,(uchar *)cli->cryptkey,(uchar *)pword);
+#endif
+ } else {
+ memcpy(pword, pass, passlen);
+ }
+
+ /* if in share level security then don't send a password now */
+ if (!(cli->sec_mode & 1)) {fstrcpy(pword, "");passlen=1;}
+
+ /* send a session setup command */
+ bzero(cli->outbuf,smb_size);
+
+ if (cli->protocol < PROTOCOL_NT1) {
+ set_message(cli->outbuf,10,1 + strlen(user) + passlen,True);
+ CVAL(cli->outbuf,smb_com) = SMBsesssetupX;
+ cli_setup_pkt(cli);
+
+ CVAL(cli->outbuf,smb_vwv0) = 0xFF;
+ SSVAL(cli->outbuf,smb_vwv2,cli->max_xmit);
+ SSVAL(cli->outbuf,smb_vwv3,2);
+ SSVAL(cli->outbuf,smb_vwv4,1);
+ SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
+ SSVAL(cli->outbuf,smb_vwv7,passlen);
+ p = smb_buf(cli->outbuf);
+ memcpy(p,pword,passlen);
+ p += passlen;
+ strcpy(p,user);
+ strupper(p);
+ } else {
+ set_message(cli->outbuf,13,0,True);
+ CVAL(cli->outbuf,smb_com) = SMBsesssetupX;
+ cli_setup_pkt(cli);
+
+ CVAL(cli->outbuf,smb_vwv0) = 0xFF;
+ SSVAL(cli->outbuf,smb_vwv2,BUFFER_SIZE);
+ SSVAL(cli->outbuf,smb_vwv3,2);
+ SSVAL(cli->outbuf,smb_vwv4,cli->pid);
+ SIVAL(cli->outbuf,smb_vwv5,cli->sesskey);
+ SSVAL(cli->outbuf,smb_vwv7,passlen);
+ SSVAL(cli->outbuf,smb_vwv8,ntpasslen);
+ p = smb_buf(cli->outbuf);
+ memcpy(p,pword,passlen);
+ p += SVAL(cli->outbuf,smb_vwv7);
+ memcpy(p,ntpass,ntpasslen);
+ p += SVAL(cli->outbuf,smb_vwv8);
+ strcpy(p,user);
+ strupper(p);
+ p = skip_string(p,1);
+ strcpy(p,workgroup);
+ strupper(p);
+ p = skip_string(p,1);
+ strcpy(p,"Unix");p = skip_string(p,1);
+ strcpy(p,"Samba");p = skip_string(p,1);
+ set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False);
+ }
+
+ send_smb(cli->fd,cli->outbuf);
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ show_msg(cli->inbuf);
+
+ if (CVAL(cli->inbuf,smb_rcls) != 0) {
+ return False;
+ }
+
+ /* use the returned uid from now on */
+ cli->uid = SVAL(cli->inbuf,smb_uid);
+
+ return True;
+}
+
+
+/****************************************************************************
+send a tconX
+****************************************************************************/
+BOOL cli_send_tconX(struct cli_state *cli,
+ char *share, char *dev, char *pword, int passlen)
+{
+ char *p;
+ bzero(cli->outbuf,smb_size);
+ bzero(cli->inbuf,smb_size);
+
+ set_message(cli->outbuf,4,
+ 2 + strlen(share) + passlen + strlen(dev),True);
+ CVAL(cli->outbuf,smb_com) = SMBtconX;
+ cli_setup_pkt(cli);
+
+ SSVAL(cli->outbuf,smb_vwv0,0xFF);
+ SSVAL(cli->outbuf,smb_vwv3,passlen);
+
+ p = smb_buf(cli->outbuf);
+ memcpy(p,pword,passlen);
+ p += passlen;
+ strcpy(p,share);
+ p = skip_string(p,1);
+ strcpy(p,dev);
+
+ SCVAL(cli->inbuf,smb_rcls, 1);
+
+ send_smb(cli->fd,cli->outbuf);
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ if (CVAL(cli->inbuf,smb_rcls) != 0) {
+ return False;
+ }
+
+ cli->cnum = SVAL(cli->inbuf,smb_tid);
+ return True;
+}
+
+
+/****************************************************************************
+send a tree disconnect
+****************************************************************************/
+BOOL cli_tdis(struct cli_state *cli)
+{
+ bzero(cli->outbuf,smb_size);
+ set_message(cli->outbuf,0,0,True);
+ CVAL(cli->outbuf,smb_com) = SMBtdis;
+ SSVAL(cli->outbuf,smb_tid,cli->cnum);
+ cli_setup_pkt(cli);
+
+ send_smb(cli->fd,cli->outbuf);
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ return CVAL(cli->inbuf,smb_rcls) == 0;
+}
+
+
+/****************************************************************************
+send a negprot command
+****************************************************************************/
+BOOL cli_negprot(struct cli_state *cli)
+{
+ char *p;
+ int numprots;
+ int plength;
+
+ bzero(cli->outbuf,smb_size);
+
+ /* setup the protocol strings */
+ for (plength=0,numprots=0;
+ prots[numprots].name && prots[numprots].prot<=cli->protocol;
+ numprots++)
+ plength += strlen(prots[numprots].name)+2;
+
+ set_message(cli->outbuf,0,plength,True);
+
+ p = smb_buf(cli->outbuf);
+ for (numprots=0;
+ prots[numprots].name && prots[numprots].prot<=cli->protocol;
+ numprots++) {
+ *p++ = 2;
+ strcpy(p,prots[numprots].name);
+ p += strlen(p) + 1;
+ }
+
+ CVAL(cli->outbuf,smb_com) = SMBnegprot;
+ cli_setup_pkt(cli);
+
+ CVAL(smb_buf(cli->outbuf),0) = 2;
+
+ send_smb(cli->fd,cli->outbuf);
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ show_msg(cli->inbuf);
+
+ if (CVAL(cli->inbuf,smb_rcls) != 0 ||
+ ((int)SVAL(cli->inbuf,smb_vwv0) >= numprots)) {
+ return(False);
+ }
+
+ cli->protocol = prots[SVAL(cli->inbuf,smb_vwv0)].prot;
+
+
+ if (cli->protocol < PROTOCOL_NT1) {
+ cli->sec_mode = SVAL(cli->inbuf,smb_vwv1);
+ cli->max_xmit = SVAL(cli->inbuf,smb_vwv2);
+ cli->sesskey = IVAL(cli->inbuf,smb_vwv6);
+ cli->serverzone = SVALS(cli->inbuf,smb_vwv10)*60;
+ /* this time is converted to GMT by make_unix_date */
+ cli->servertime = make_unix_date(cli->inbuf+smb_vwv8);
+ if (cli->protocol >= PROTOCOL_COREPLUS) {
+ cli->readbraw_supported = ((SVAL(cli->inbuf,smb_vwv5) & 0x1) != 0);
+ cli->writebraw_supported = ((SVAL(cli->inbuf,smb_vwv5) & 0x2) != 0);
+ }
+ memcpy(cli->cryptkey,smb_buf(cli->inbuf),8);
+ } else {
+ /* NT protocol */
+ cli->sec_mode = CVAL(cli->inbuf,smb_vwv1);
+ cli->max_xmit = IVAL(cli->inbuf,smb_vwv3+1);
+ cli->sesskey = IVAL(cli->inbuf,smb_vwv7+1);
+ cli->serverzone = SVALS(cli->inbuf,smb_vwv15+1)*60;
+ /* this time arrives in real GMT */
+ cli->servertime = interpret_long_date(cli->inbuf+smb_vwv11+1);
+ memcpy(cli->cryptkey,smb_buf(cli->inbuf),8);
+ if (IVAL(cli->inbuf,smb_vwv9+1) & 1)
+ cli->readbraw_supported =
+ cli->writebraw_supported = True;
+ }
+
+ return True;
+}
+
+
+/****************************************************************************
+ send a session request
+****************************************************************************/
+BOOL cli_session_request(struct cli_state *cli, char *host, int name_type,
+ char *myname)
+{
+ fstring dest;
+ char *p;
+ int len = 4;
+ /* send a session request (RFC 1002) */
+
+ fstrcpy(dest,host);
+
+ p = strchr(dest,'.');
+ if (p) *p = 0;
+
+ fstrcpy(cli->desthost, dest);
+
+ /* put in the destination name */
+ p = cli->outbuf+len;
+ name_mangle(dest,p,name_type);
+ len += name_len(p);
+
+ /* and my name */
+ p = cli->outbuf+len;
+ name_mangle(myname,p,0);
+ len += name_len(p);
+
+ /* setup the packet length */
+ _smb_setlen(cli->outbuf,len);
+ CVAL(cli->outbuf,0) = 0x81;
+
+ send_smb(cli->fd,cli->outbuf);
+ DEBUG(5,("Sent session request\n"));
+
+ if (!receive_smb(cli->fd,cli->inbuf,cli->timeout))
+ return False;
+
+ if (CVAL(cli->inbuf,0) != 0x82) {
+ cli->error = CVAL(cli->inbuf,0);
+ return False;
+ }
+ return(True);
+}
+
+
+/****************************************************************************
+open the client sockets
+****************************************************************************/
+BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip)
+{
+ struct in_addr dest_ip;
+
+ fstrcpy(cli->desthost, host);
+
+ if (!ip) {
+ struct hostent *hp;
+
+ if ((hp = Get_Hostbyname(cli->desthost)) == 0) {
+ return False;
+ }
+
+ putip((char *)&dest_ip,(char *)hp->h_addr);
+ } else {
+ dest_ip = *ip;
+ }
+
+
+ cli->fd = open_socket_out(SOCK_STREAM, &dest_ip, 139, cli->timeout);
+ if (cli->fd == -1)
+ return False;
+
+ return True;
+}
+
+
+/****************************************************************************
+initialise a client structure
+****************************************************************************/
+BOOL cli_initialise(struct cli_state *cli)
+{
+ if (cli->initialised) cli_shutdown(cli);
+
+ memset(cli, 0, sizeof(*cli));
+ cli->fd = -1;
+ cli->cnum = -1;
+ cli->pid = getpid();
+ cli->mid = 1;
+ cli->uid = getuid();
+ cli->protocol = PROTOCOL_NT1;
+ cli->timeout = 20000;
+ cli->bufsize = 0x10000;
+ cli->max_xmit = cli->bufsize - 4;
+ cli->outbuf = (char *)malloc(cli->bufsize);
+ cli->inbuf = (char *)malloc(cli->bufsize);
+ if (!cli->outbuf || !cli->inbuf) return False;
+ cli->initialised = 1;
+ return True;
+}
+
+/****************************************************************************
+shutdown a client structure
+****************************************************************************/
+void cli_shutdown(struct cli_state *cli)
+{
+ if (cli->outbuf) free(cli->outbuf);
+ if (cli->inbuf) free(cli->inbuf);
+ if (cli->fd != -1) close(cli->fd);
+ memset(cli, 0, sizeof(*cli));
+}
diff --git a/source/libsmb/nmblib.c b/source/libsmb/nmblib.c
index 48f988de2a2..95217b7eded 100644
--- a/source/libsmb/nmblib.c
+++ b/source/libsmb/nmblib.c
@@ -31,8 +31,8 @@ extern pstring myname;
extern struct in_addr ipzero;
static struct opcode_names {
- char *nmb_opcode_name;
- int opcode;
+ const char *nmb_opcode_name;
+ int opcode;
} nmb_header_opcode_names[] = {
{ "Query", 0 },
{"Registration", 5 },
@@ -46,7 +46,7 @@ static struct opcode_names {
* Lookup a nmb opcode name.
****************************************************************************/
-char *lookup_opcode_name( int opcode )
+const char *lookup_opcode_name( int opcode )
{
struct opcode_names *op_namep;
int i;
@@ -107,8 +107,8 @@ void debug_nmb_packet(struct packet_struct *p)
{
struct nmb_packet *nmb = &p->packet.nmb;
- DEBUG(4,("nmb packet from %s header: id=%d opcode=%s(%d) response=%s\n",
- inet_ntoa(p->ip),
+ DEBUG(4,("nmb packet from %s(%d) header: id=%d opcode=%s(%d) response=%s\n",
+ inet_ntoa(p->ip), p->port,
nmb->header.name_trn_id,
lookup_opcode_name(nmb->header.opcode),
nmb->header.opcode,BOOLSTR(nmb->header.response)));
diff --git a/source/libsmb/smbdes.c b/source/libsmb/smbdes.c
deleted file mode 100644
index 1c38612b739..00000000000
--- a/source/libsmb/smbdes.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
-
- a partial implementation of DES designed for use in the
- SMB authentication protocol
-
- Copyright (C) Andrew Tridgell 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-/* NOTES:
-
- This code makes no attempt to be fast! In fact, it is a very
- slow implementation
-
- This code is NOT a complete DES implementation. It implements only
- the minimum necessary for SMB authentication, as used by all SMB
- products (including every copy of Microsoft Windows95 ever sold)
-
- In particular, it can only do a unchained forward DES pass. This
- means it is not possible to use this code for encryption/decryption
- of data, instead it is only useful as a "hash" algorithm.
-
- There is no entry point into this code that allows normal DES operation.
-
- I believe this means that this code does not come under ITAR
- regulations but this is NOT a legal opinion. If you are concerned
- about the applicability of ITAR regulations to this code then you
- should confirm it for yourself (and maybe let me know if you come
- up with a different answer to the one above)
-*/
-
-
-
-static int perm1[56] = {57, 49, 41, 33, 25, 17, 9,
- 1, 58, 50, 42, 34, 26, 18,
- 10, 2, 59, 51, 43, 35, 27,
- 19, 11, 3, 60, 52, 44, 36,
- 63, 55, 47, 39, 31, 23, 15,
- 7, 62, 54, 46, 38, 30, 22,
- 14, 6, 61, 53, 45, 37, 29,
- 21, 13, 5, 28, 20, 12, 4};
-
-static int perm2[48] = {14, 17, 11, 24, 1, 5,
- 3, 28, 15, 6, 21, 10,
- 23, 19, 12, 4, 26, 8,
- 16, 7, 27, 20, 13, 2,
- 41, 52, 31, 37, 47, 55,
- 30, 40, 51, 45, 33, 48,
- 44, 49, 39, 56, 34, 53,
- 46, 42, 50, 36, 29, 32};
-
-static int perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2,
- 60, 52, 44, 36, 28, 20, 12, 4,
- 62, 54, 46, 38, 30, 22, 14, 6,
- 64, 56, 48, 40, 32, 24, 16, 8,
- 57, 49, 41, 33, 25, 17, 9, 1,
- 59, 51, 43, 35, 27, 19, 11, 3,
- 61, 53, 45, 37, 29, 21, 13, 5,
- 63, 55, 47, 39, 31, 23, 15, 7};
-
-static int perm4[48] = { 32, 1, 2, 3, 4, 5,
- 4, 5, 6, 7, 8, 9,
- 8, 9, 10, 11, 12, 13,
- 12, 13, 14, 15, 16, 17,
- 16, 17, 18, 19, 20, 21,
- 20, 21, 22, 23, 24, 25,
- 24, 25, 26, 27, 28, 29,
- 28, 29, 30, 31, 32, 1};
-
-static int perm5[32] = { 16, 7, 20, 21,
- 29, 12, 28, 17,
- 1, 15, 23, 26,
- 5, 18, 31, 10,
- 2, 8, 24, 14,
- 32, 27, 3, 9,
- 19, 13, 30, 6,
- 22, 11, 4, 25};
-
-
-static int perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32,
- 39, 7, 47, 15, 55, 23, 63, 31,
- 38, 6, 46, 14, 54, 22, 62, 30,
- 37, 5, 45, 13, 53, 21, 61, 29,
- 36, 4, 44, 12, 52, 20, 60, 28,
- 35, 3, 43, 11, 51, 19, 59, 27,
- 34, 2, 42, 10, 50, 18, 58, 26,
- 33, 1, 41, 9, 49, 17, 57, 25};
-
-
-static int sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
-
-static int sbox[8][4][16] = {
- {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7},
- {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8},
- {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0},
- {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}},
-
- {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10},
- {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5},
- {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15},
- {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}},
-
- {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8},
- {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1},
- {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7},
- {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}},
-
- {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15},
- {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9},
- {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4},
- {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}},
-
- {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9},
- {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6},
- {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14},
- {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}},
-
- {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11},
- {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8},
- {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6},
- {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}},
-
- {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1},
- {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6},
- {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2},
- {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}},
-
- {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7},
- {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2},
- {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8},
- {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}};
-
-static void permute(char *out, char *in, int *p, int n)
-{
- int i;
- for (i=0;i<n;i++)
- out[i] = in[p[i]-1];
-}
-
-static void lshift(char *d, int count, int n)
-{
- char out[64];
- int i;
- for (i=0;i<n;i++)
- out[i] = d[(i+count)%n];
- for (i=0;i<n;i++)
- d[i] = out[i];
-}
-
-static void concat(char *out, char *in1, char *in2, int l1, int l2)
-{
- while (l1--)
- *out++ = *in1++;
- while (l2--)
- *out++ = *in2++;
-}
-
-static void xor(char *out, char *in1, char *in2, int n)
-{
- int i;
- for (i=0;i<n;i++)
- out[i] = in1[i] ^ in2[i];
-}
-
-static void dohash(char *out, char *in, char *key)
-{
- int i, j, k;
- char pk1[56];
- char c[28];
- char d[28];
- char cd[56];
- char ki[16][48];
- char pd1[64];
- char l[32], r[32];
- char rl[64];
-
- permute(pk1, key, perm1, 56);
-
- for (i=0;i<28;i++)
- c[i] = pk1[i];
- for (i=0;i<28;i++)
- d[i] = pk1[i+28];
-
- for (i=0;i<16;i++) {
- lshift(c, sc[i], 28);
- lshift(d, sc[i], 28);
-
- concat(cd, c, d, 28, 28);
- permute(ki[i], cd, perm2, 48);
- }
-
- permute(pd1, in, perm3, 64);
-
- for (j=0;j<32;j++) {
- l[j] = pd1[j];
- r[j] = pd1[j+32];
- }
-
- for (i=0;i<16;i++) {
- char er[48];
- char erk[48];
- char b[8][6];
- char cb[32];
- char pcb[32];
- char r2[32];
-
- permute(er, r, perm4, 48);
-
- xor(erk, er, ki[i], 48);
-
- for (j=0;j<8;j++)
- for (k=0;k<6;k++)
- b[j][k] = erk[j*6 + k];
-
- for (j=0;j<8;j++) {
- int m, n;
- m = (b[j][0]<<1) | b[j][5];
-
- n = (b[j][1]<<3) | (b[j][2]<<2) | (b[j][3]<<1) | b[j][4];
-
- for (k=0;k<4;k++)
- b[j][k] = (sbox[j][m][n] & (1<<(3-k)))?1:0;
- }
-
- for (j=0;j<8;j++)
- for (k=0;k<4;k++)
- cb[j*4+k] = b[j][k];
- permute(pcb, cb, perm5, 32);
-
- xor(r2, l, pcb, 32);
-
- for (j=0;j<32;j++)
- l[j] = r[j];
-
- for (j=0;j<32;j++)
- r[j] = r2[j];
- }
-
- concat(rl, r, l, 32, 32);
-
- permute(out, rl, perm6, 64);
-}
-
-static void str_to_key(unsigned char *str,unsigned char *key)
-{
- int i;
-
- key[0] = str[0]>>1;
- key[1] = ((str[0]&0x01)<<6) | (str[1]>>2);
- key[2] = ((str[1]&0x03)<<5) | (str[2]>>3);
- key[3] = ((str[2]&0x07)<<4) | (str[3]>>4);
- key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5);
- key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6);
- key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7);
- key[7] = str[6]&0x7F;
- for (i=0;i<8;i++) {
- key[i] = (key[i]<<1);
- }
-}
-
-
-static void smbhash(unsigned char *out, unsigned char *in, unsigned char *key)
-{
- int i;
- char outb[64];
- char inb[64];
- char keyb[64];
- unsigned char key2[8];
-
- str_to_key(key, key2);
-
- for (i=0;i<64;i++) {
- inb[i] = (in[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
- keyb[i] = (key2[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
- outb[i] = 0;
- }
-
- dohash(outb, inb, keyb);
-
- for (i=0;i<8;i++) {
- out[i] = 0;
- }
-
- for (i=0;i<64;i++) {
- if (outb[i])
- out[i/8] |= (1<<(7-(i%8)));
- }
-}
-
-void E_P16(unsigned char *p14,unsigned char *p16)
-{
- unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
- smbhash(p16, sp8, p14);
- smbhash(p16+8, sp8, p14+7);
-}
-
-void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24)
-{
- smbhash(p24, c8, p21);
- smbhash(p24+8, c8, p21+7);
- smbhash(p24+16, c8, p21+14);
-}
-
-
diff --git a/source/libsmb/smbencrypt.c b/source/libsmb/smbencrypt.c
index 27172fd4136..8bb21cfed20 100644
--- a/source/libsmb/smbencrypt.c
+++ b/source/libsmb/smbencrypt.c
@@ -1,3 +1,4 @@
+#ifdef SMB_PASSWD
/*
Unix SMB/Netbios implementation.
Version 1.9.
@@ -21,11 +22,84 @@
*/
#include "includes.h"
+#include "des.h"
+#include "md4.h"
extern int DEBUGLEVEL;
#include "byteorder.h"
+void str_to_key(uchar *str,uchar *key)
+{
+ void des_set_odd_parity(des_cblock *);
+ int i;
+
+ key[0] = str[0]>>1;
+ key[1] = ((str[0]&0x01)<<6) | (str[1]>>2);
+ key[2] = ((str[1]&0x03)<<5) | (str[2]>>3);
+ key[3] = ((str[2]&0x07)<<4) | (str[3]>>4);
+ key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5);
+ key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6);
+ key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7);
+ key[7] = str[6]&0x7F;
+ for (i=0;i<8;i++) {
+ key[i] = (key[i]<<1);
+ }
+ des_set_odd_parity((des_cblock *)key);
+}
+
+void D1(uchar *k, uchar *d, uchar *out)
+{
+ des_key_schedule ks;
+ des_cblock deskey;
+
+ str_to_key(k,(uchar *)deskey);
+#ifdef __FreeBSD__
+ des_set_key(&deskey,ks);
+#else /* __FreeBSD__ */
+ des_set_key((des_cblock *)deskey,ks);
+#endif /* __FreeBsd */
+ des_ecb_encrypt((des_cblock *)d,(des_cblock *)out, ks, DES_DECRYPT);
+}
+
+void E1(uchar *k, uchar *d, uchar *out)
+{
+ des_key_schedule ks;
+ des_cblock deskey;
+
+ str_to_key(k,(uchar *)deskey);
+#ifdef __FreeBSD__
+ des_set_key(&deskey,ks);
+#else /* __FreeBsd__ */
+ des_set_key((des_cblock *)deskey,ks);
+#endif /* __FreeBsd__ */
+ des_ecb_encrypt((des_cblock *)d,(des_cblock *)out, ks, DES_ENCRYPT);
+}
+
+void E_P16(uchar *p14,uchar *p16)
+{
+ uchar sp7[7];
+ /* the following constant makes us compatible with other
+ implementations. Note that publishing this constant does not reduce the
+ security of the encryption mechanism */
+ uchar sp8[] = {0xAA,0xD3,0xB4,0x35,0xB5,0x14,0x4,0xEE};
+ uchar x[8];
+
+ memset(sp7,'\0',7);
+
+ D1(sp7, sp8, x);
+ E1(p14, x, p16);
+ E1(p14+7, x, p16+8);
+}
+
+void E_P24(uchar *p21, uchar *c8, uchar *p24)
+{
+ E1(p21, c8, p24);
+ E1(p21+7, c8, p24+8);
+ E1(p21+14, c8, p24+16);
+}
+
+
/*
This implements the X/Open SMB password encryption
It takes a password, a 8 byte "crypt key" and puts 24 bytes of
@@ -81,20 +155,28 @@ static int _my_mbstowcs(int16 *dst, uchar *src, int len)
void E_md4hash(uchar *passwd, uchar *p16)
{
- int len;
+ int i, len;
int16 wpwd[129];
-
+ MDstruct MD;
+
/* Password cannot be longer than 128 characters */
len = strlen((char *)passwd);
if(len > 128)
len = 128;
/* Password must be converted to NT unicode */
- _my_mbstowcs(wpwd, passwd, len);
+ _my_mbstowcs( wpwd, passwd, len);
wpwd[len] = 0; /* Ensure string is null terminated */
/* Calculate length in bytes */
len = _my_wcslen(wpwd) * sizeof(int16);
-
- mdfour(p16, (unsigned char *)wpwd, len);
+
+ MDbegin(&MD);
+ for(i = 0; i + 64 <= len; i += 64)
+ MDupdate(&MD,wpwd + (i/2), 512);
+ MDupdate(&MD,wpwd + (i/2),(len-i)*8);
+ SIVAL(p16,0,MD.buffer[0]);
+ SIVAL(p16,4,MD.buffer[1]);
+ SIVAL(p16,8,MD.buffer[2]);
+ SIVAL(p16,12,MD.buffer[3]);
}
/* Does the NT MD4 hash then des encryption. */
@@ -109,3 +191,6 @@ void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24)
E_P24(p21, c8, p24);
}
+#else
+ void smbencrypt_dummy(void){}
+#endif
diff --git a/source/locking/locking.c b/source/locking/locking.c
index abda5d39d47..559c7284b36 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -46,7 +46,7 @@ BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset)
return(False);
return(fcntl_lock(Files[fnum].fd_ptr->fd,F_GETLK,offset,count,
- (Files[fnum].can_write?F_WRLCK:F_RDLCK)));
+ (Files[fnum].can_write?F_WRLCK:F_RDLCK)));
}
@@ -68,7 +68,7 @@ BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ec
if (Files[fnum].can_lock && OPEN_FNUM(fnum) && (Files[fnum].cnum == cnum))
ok = fcntl_lock(Files[fnum].fd_ptr->fd,F_SETLK,offset,count,
- (Files[fnum].can_write?F_WRLCK:F_RDLCK));
+ (Files[fnum].can_write?F_WRLCK:F_RDLCK));
if (!ok) {
*eclass = ERRDOS;
@@ -182,37 +182,37 @@ int get_share_modes(int cnum, share_lock_token token, uint32 dev, uint32 inode,
file_prev_p = file_scanner_p;
while(file_scanner_p)
{
- if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
- {
- found = True;
- break;
- }
- else
- {
- file_prev_p = file_scanner_p ;
- file_scanner_p = (share_mode_record *)smb_shm_offset2addr(
- file_scanner_p->next_offset);
- }
+ if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
+ {
+ found = True;
+ break;
+ }
+ else
+ {
+ file_prev_p = file_scanner_p ;
+ file_scanner_p = (share_mode_record *)smb_shm_offset2addr(
+ file_scanner_p->next_offset);
+ }
}
if(!found)
{
- DEBUG(5,("get_share_modes (FAST_SHARE_MODES): no entry for \
+ DEBUG(5,("get_share_modes (FAST_SHARE_MODES): no entry for \
file dev = %d, ino = %d in hash_bucket %d\n", dev, inode, hash_entry));
- return (0);
+ return (0);
}
if(file_scanner_p->locking_version != LOCKING_VERSION)
{
- DEBUG(0,("ERROR:get_share_modes (FAST_SHARE_MODES): Deleting old share mode \
+ DEBUG(0,("ERROR:get_share_modes (FAST_SHARE_MODES): Deleting old share mode \
record due to old locking version %d for file dev = %d, inode = %d in hash \
-bucket %d\n", file_scanner_p->locking_version, dev, inode, hash_entry));
- if(file_prev_p == file_scanner_p)
- mode_array[hash_entry] = file_scanner_p->next_offset;
- else
- file_prev_p->next_offset = file_scanner_p->next_offset;
- smb_shm_free(smb_shm_addr2offset(file_scanner_p));
- return (0);
+bucket %d\n",file_scanner_p->locking_version, dev, inode, hash_entry));
+ if(file_prev_p == file_scanner_p)
+ mode_array[hash_entry] = file_scanner_p->next_offset;
+ else
+ file_prev_p->next_offset = file_scanner_p->next_offset;
+ smb_shm_free(smb_shm_addr2offset(file_scanner_p));
+ return (0);
}
/* Allocate the old_shares array */
@@ -241,6 +241,7 @@ bucket %d\n", file_scanner_p->locking_version, dev, inode, hash_entry));
{
/* Delete this share mode entry */
share_mode_entry *delete_entry_p = entry_scanner_p;
+ int share_mode = entry_scanner_p->share_mode;
if(entry_prev_p == entry_scanner_p)
{
@@ -271,7 +272,7 @@ for dev = %d, ino = %d, hashbucket %d\n", file_scanner_p->num_share_mode_entries
DEBUG(0,("get_share_modes (FAST_SHARE_MODES): process %d no longer exists and \
it left a share mode entry with mode 0x%X for file dev = %d, ino = %d in hash \
bucket %d (number of entries now = %d)\n",
- pid, entry_scanner_p->share_mode, dev, inode, hash_entry,
+ pid, share_mode, dev, inode, hash_entry,
file_scanner_p->num_share_mode_entries));
smb_shm_free(smb_shm_addr2offset(delete_entry_p));
@@ -283,10 +284,6 @@ bucket %d (number of entries now = %d)\n",
*/
share_array[num_entries_copied].pid = entry_scanner_p->pid;
share_array[num_entries_copied].share_mode = entry_scanner_p->share_mode;
-#ifdef USE_OPLOCKS
- share_array[num_entries_copied].op_port = entry_scanner_p->op_port;
- share_array[num_entries_copied].op_type = entry_scanner_p->op_type;
-#endif /* USE_OPLOCKS */
memcpy(&share_array[num_entries_copied].time, &entry_scanner_p->time,
sizeof(struct timeval));
num_entries_copied++;
@@ -316,7 +313,8 @@ hash bucket %d has a share mode record but no entries - deleting\n",
}
DEBUG(5,("get_share_modes (FAST_SHARE_MODES): file with dev %d, inode %d in \
-hash bucket %d returning %d entries\n", dev, inode, hash_entry, num_entries_copied));
+hash bucket %d returning %d entries\n", dev, inode, hash_entry,
+ num_entries_copied));
return(num_entries_copied);
}
@@ -364,17 +362,17 @@ void del_share_mode(share_lock_token token, int fnum)
while(file_scanner_p)
{
- if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
- {
- found = True;
- break;
- }
- else
- {
- file_prev_p = file_scanner_p ;
- file_scanner_p = (share_mode_record *)
- smb_shm_offset2addr(file_scanner_p->next_offset);
- }
+ if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
+ {
+ found = True;
+ break;
+ }
+ else
+ {
+ file_prev_p = file_scanner_p ;
+ file_scanner_p = (share_mode_record *)
+ smb_shm_offset2addr(file_scanner_p->next_offset);
+ }
}
if(!found)
@@ -386,20 +384,20 @@ inode %d in hash bucket %d\n", dev, inode, hash_entry));
if(file_scanner_p->locking_version != LOCKING_VERSION)
{
- DEBUG(0,("ERROR: del_share_modes (FAST_SHARE_MODES): Deleting old share mode \
+ DEBUG(0,("ERROR: del_share_modes (FAST_SHARE_MODES): Deleting old share mode \
record due to old locking version %d for file dev %d, inode %d hash bucket %d\n",
file_scanner_p->locking_version, dev, inode, hash_entry ));
- if(file_prev_p == file_scanner_p)
- mode_array[hash_entry] = file_scanner_p->next_offset;
- else
- file_prev_p->next_offset = file_scanner_p->next_offset;
- smb_shm_free(smb_shm_addr2offset(file_scanner_p));
- return;
+ if(file_prev_p == file_scanner_p)
+ mode_array[hash_entry] = file_scanner_p->next_offset;
+ else
+ file_prev_p->next_offset = file_scanner_p->next_offset;
+ smb_shm_free(smb_shm_addr2offset(file_scanner_p));
+ return;
}
found = False;
entry_scanner_p = (share_mode_entry*)smb_shm_offset2addr(
- file_scanner_p->share_mode_entries);
+ file_scanner_p->share_mode_entries);
entry_prev_p = entry_scanner_p;
while(entry_scanner_p)
{
@@ -444,15 +442,15 @@ for dev = %d, ino = %d, hashbucket %d\n", file_scanner_p->num_share_mode_entries
/* If we deleted the last share mode entry then remove the share mode record. */
if(file_scanner_p->num_share_mode_entries == 0)
- {
+ {
DEBUG(2,("del_share_modes (FAST_SHARE_MODES): num entries = 0, deleting share_mode \
record dev = %d, inode = %d in hash bucket %d\n", dev, inode, hash_entry));
if(file_prev_p == file_scanner_p)
- mode_array[hash_entry] = file_scanner_p->next_offset;
+ mode_array[hash_entry] = file_scanner_p->next_offset;
else
- file_prev_p->next_offset = file_scanner_p->next_offset;
+ file_prev_p->next_offset = file_scanner_p->next_offset;
smb_shm_free(smb_shm_addr2offset(file_scanner_p));
- }
+ }
}
else
{
@@ -464,7 +462,7 @@ dev = %d, inode = %d in hash bucket %d\n", dev, inode, hash_entry));
/*******************************************************************
set the share mode of a file. Return False on fail, True on success.
********************************************************************/
-BOOL set_share_mode(share_lock_token token, int fnum, uint16 port, uint16 op_type)
+BOOL set_share_mode(share_lock_token token, int fnum)
{
files_struct *fs_p = &Files[fnum];
int32 dev, inode;
@@ -496,17 +494,17 @@ BOOL set_share_mode(share_lock_token token, int fnum, uint16 port, uint16 op_typ
while(file_scanner_p)
{
- if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
- {
- found = True;
- break;
- }
- else
- {
- file_prev_p = file_scanner_p ;
- file_scanner_p = (share_mode_record *)
- smb_shm_offset2addr(file_scanner_p->next_offset);
- }
+ if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
+ {
+ found = True;
+ break;
+ }
+ else
+ {
+ file_prev_p = file_scanner_p ;
+ file_scanner_p = (share_mode_record *)
+ smb_shm_offset2addr(file_scanner_p->next_offset);
+ }
}
if(!found)
@@ -555,10 +553,6 @@ inode %d in hash bucket %d\n", fs_p->name, dev, inode, hash_entry));
new_entry_p->pid = getpid();
new_entry_p->share_mode = fs_p->share_mode;
-#ifdef USE_OPLOCKS
- new_entry_p->op_port = port;
- new_entry_p->op_type = op_type;
-#endif /* USE_OPLOCKS */
memcpy( (char *)&new_entry_p->time, (char *)&fs_p->open_time, sizeof(struct timeval));
/* Chain onto the share_mode_record */
@@ -584,121 +578,6 @@ for dev = %d, ino = %d, hashbucket %d\n", file_scanner_p->num_share_mode_entries
return(True);
}
-/*******************************************************************
-Remove an oplock port and mode entry from a share mode.
-********************************************************************/
-BOOL remove_share_oplock(int fnum, share_lock_token token)
-{
-#ifdef USE_OPLOCKS
- uint32 dev, inode;
- smb_shm_offset_t *mode_array;
- unsigned int hash_entry;
- share_mode_record *file_scanner_p;
- share_mode_record *file_prev_p;
- share_mode_entry *entry_scanner_p;
- share_mode_entry *entry_prev_p;
- BOOL found = False;
- int pid = getpid();
-
- dev = Files[fnum].fd_ptr->dev;
- inode = Files[fnum].fd_ptr->inode;
-
- hash_entry = HASH_ENTRY(dev, inode);
-
- if(hash_entry > lp_shmem_hash_size() )
- {
- DEBUG(0,
- ("PANIC ERROR:remove_share_oplock (FAST_SHARE_MODES): hash_entry %d too large \
-(max = %d)\n",
- hash_entry, lp_shmem_hash_size() ));
- return False;
- }
-
- mode_array = (smb_shm_offset_t *)smb_shm_offset2addr(smb_shm_get_userdef_off());
-
- if(mode_array[hash_entry] == NULL_OFFSET)
- {
- DEBUG(0,("PANIC ERROR:remove_share_oplock (FAST_SHARE_MODES): hash bucket %d empty\n",
- hash_entry));
- return False;
- }
-
- file_scanner_p = (share_mode_record *)smb_shm_offset2addr(mode_array[hash_entry]);
- file_prev_p = file_scanner_p;
-
- while(file_scanner_p)
- {
- if( (file_scanner_p->st_dev == dev) && (file_scanner_p->st_ino == inode) )
- {
- found = True;
- break;
- }
- else
- {
- file_prev_p = file_scanner_p ;
- file_scanner_p = (share_mode_record *)
- smb_shm_offset2addr(file_scanner_p->next_offset);
- }
- }
-
- if(!found)
- {
- DEBUG(0,("ERROR:remove_share_oplock (FAST_SHARE_MODES): no entry found for dev %d, \
-inode %d in hash bucket %d\n", dev, inode, hash_entry));
- return False;
- }
-
- if(file_scanner_p->locking_version != LOCKING_VERSION)
- {
- DEBUG(0,("ERROR: remove_share_oplock (FAST_SHARE_MODES): Deleting old share mode \
-record due to old locking version %d for file dev %d, inode %d hash bucket %d\n",
- file_scanner_p->locking_version, dev, inode, hash_entry ));
- if(file_prev_p == file_scanner_p)
- mode_array[hash_entry] = file_scanner_p->next_offset;
- else
- file_prev_p->next_offset = file_scanner_p->next_offset;
- smb_shm_free(smb_shm_addr2offset(file_scanner_p));
- return False;
- }
-
- found = False;
- entry_scanner_p = (share_mode_entry*)smb_shm_offset2addr(
- file_scanner_p->share_mode_entries);
- entry_prev_p = entry_scanner_p;
- while(entry_scanner_p)
- {
- if( (pid == entry_scanner_p->pid) &&
- (entry_scanner_p->share_mode == Files[fnum].share_mode) &&
- (memcmp(&entry_scanner_p->time,
- &Files[fnum].open_time,sizeof(struct timeval)) == 0) )
- {
- /* Delete the oplock info. */
- entry_scanner_p->op_port = 0;
- entry_scanner_p->op_type = 0;
- found = True;
- break;
- }
- else
- {
- entry_prev_p = entry_scanner_p;
- entry_scanner_p = (share_mode_entry *)
- smb_shm_offset2addr(entry_scanner_p->next_share_mode_entry);
- }
- }
-
- if(!found)
- {
- DEBUG(0,("ERROR: remove_share_oplock (FAST_SHARE_MODES): No oplock granted share \
-mode record found dev = %d, inode = %d in hash bucket %d\n", dev, inode, hash_entry));
- return False;
- }
-
- return True;
-#else /* USE_OPLOCKS */
- return False;
-#endif /* USE_OPLOCKS */
-}
-
#else /* FAST_SHARE_MODES */
/* SHARE MODE LOCKS USING SLOW DESCRIPTION FILES */
@@ -719,56 +598,114 @@ static BOOL share_name(int cnum, uint32 dev, uint32 inode, char *name)
}
/*******************************************************************
+Force a share file to be deleted.
+********************************************************************/
+static int delete_share_file( int cnum, char *fname )
+{
+ /* the share file could be owned by anyone, so do this as root */
+ become_root(0);
+
+ if(unlink(fname) != 0) {
+ DEBUG(0,("delete_share_file: Can't delete share file %s (%s)\n",
+ fname, strerror(errno)));
+ } else {
+ DEBUG(5,("delete_share_file: Deleted share file %s\n", fname));
+ }
+
+ unbecome_root(0);
+
+ return 0;
+}
+
+/*******************************************************************
lock a share mode file.
******************************************************************/
BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok)
{
pstring fname;
int fd;
+ int ret = True;
*ptok = (share_lock_token)-1;
if(!share_name(cnum, dev, inode, fname))
return False;
+ /* we need to do this as root */
+ become_root(0);
+
{
int old_umask;
- unbecome_user();
+ BOOL gotlock = False;
old_umask = umask(0);
+
+ /*
+ * There was a race condition in the original slow share mode code.
+ * A smbd could open a share mode file, and before getting
+ * the lock, another smbd could delete the last entry for
+ * the share mode file and delete the file entry from the
+ * directory. Thus this smbd would be left with a locked
+ * share mode fd attached to a file that no longer had a
+ * directory entry. Thus another smbd would think that
+ * there were no outstanding opens on the file. To fix
+ * this we now check we can do a stat() call on the filename
+ * before allowing the lock to proceed, and back out completely
+ * and try the open again if we cannot.
+ * Jeremy Allison (jallison@whistle.com).
+ */
+
+ do
+ {
+ struct stat dummy_stat;
#ifdef SECURE_SHARE_MODES
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
#else /* SECURE_SHARE_MODES */
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
#endif /* SECURE_SHARE_MODES */
+
+ if(fd < 0)
+ {
+ DEBUG(0,("ERROR lock_share_entry: failed to open share file %s. Error was %s\n",
+ fname, strerror(errno)));
+ ret = False;
+ break;
+ }
+
+ /* At this point we have an open fd to the share mode file.
+ Lock the first byte exclusively to signify a lock. */
+ if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
+ {
+ DEBUG(0,("ERROR lock_share_entry: fcntl_lock failed with %s\n",
+ strerror(errno)));
+ close(fd);
+ ret = False;
+ break;
+ }
+
+ /*
+ * If we cannot stat the filename, the file was deleted between
+ * the open and the lock call. Back out and try again.
+ */
+
+ if(stat(fname, &dummy_stat)!=0)
+ {
+ DEBUG(2,("lock_share_entry: Re-issuing open on %s to fix race. Error was %s\n",
+ fname, strerror(errno)));
+ close(fd);
+ }
+ else
+ gotlock = True;
+ } while(!gotlock);
+
umask(old_umask);
- if(!become_user(cnum,Connections[cnum].vuid))
- {
- DEBUG(0,("lock_share_entry: Can't become connected user!\n"));
- close(fd);
- return False;
- }
- /* We need to change directory back to the connection root. */
- if (ChDir(Connections[cnum].connectpath) != 0)
- {
- DEBUG(0,("lock_share_entry: Can't change directory to %s (%s)\n",
- Connections[cnum].connectpath, strerror(errno)));
- close(fd);
- return False;
- }
}
- /* At this point we have an open fd to the share mode file.
- Lock the first byte exclusively to signify a lock. */
- if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
- {
- DEBUG(0,("ERROR lock_share_entry: fcntl_lock failed with %s\n",
- strerror(errno)));
- close(fd);
- return False;
- }
+ *ptok = (share_lock_token)fd;
+
+ /* return to our previous privilage level */
+ unbecome_root(0);
- *ptok = (share_lock_token)fd;
- return True;
+ return ret;
}
/*******************************************************************
@@ -778,6 +715,31 @@ BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token tok
{
int fd = (int)token;
int ret = True;
+ struct stat sb;
+ pstring fname;
+
+ /* Fix for zero length share files from
+ Gerald Werner <wernerg@mfldclin.edu> */
+
+ share_name(cnum, dev, inode, fname);
+
+ /* get the share mode file size */
+ if(fstat((int)token, &sb) != 0)
+ {
+ DEBUG(0,("ERROR: unlock_share_entry: Failed to do stat on share file %s (%s)\n",
+ fname, strerror(errno)));
+ sb.st_size = 1;
+ ret = False;
+ }
+
+ /* If the file was zero length, we must delete before
+ doing the unlock to avoid a race condition (see
+ the code in lock_share_mode_entry for details.
+ */
+
+ /* remove the share file if zero length */
+ if(sb.st_size == 0)
+ delete_share_file(cnum, fname);
/* token is the fd of the open share mode file. */
/* Unlock the first byte. */
@@ -793,36 +755,6 @@ BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token tok
}
/*******************************************************************
-Force a share file to be deleted.
-********************************************************************/
-
-static int delete_share_file( int cnum, char *fname )
-{
- unbecome_user();
- if(unlink(fname) != 0)
- {
- DEBUG(0,("delete_share_file: Can't delete share file %s (%s)\n",
- fname, strerror(errno)));
- }
-
- DEBUG(5,("delete_share_file: Deleted share file %s\n", fname));
-
- if(!become_user(cnum,Connections[cnum].vuid))
- {
- DEBUG(0,("delete_share_file: Can't become connected user!\n"));
- return -1;
- }
- /* We need to change directory back to the connection root. */
- if (ChDir(Connections[cnum].connectpath) != 0)
- {
- DEBUG(0,("delete_share_file: Can't change directory to %s (%s)\n",
- Connections[cnum].connectpath, strerror(errno)));
- return -1;
- }
- return 0;
-}
-
-/*******************************************************************
Read a share file into a buffer.
********************************************************************/
@@ -873,11 +805,10 @@ for share file %s (%s)\n", fname, strerror(errno)));
return -1;
}
- if (IVAL(buf,SMF_VERSION_OFFSET) != LOCKING_VERSION) {
+ if (IVAL(buf,0) != LOCKING_VERSION) {
DEBUG(0,("ERROR: read_share_file: share file %s has incorrect \
-locking version (was %d, should be %d).\n",fname,
- IVAL(buf,SMF_VERSION_OFFSET), LOCKING_VERSION));
- if(buf)
+locking version (was %d, should be %d).\n",fname, IVAL(buf,0), LOCKING_VERSION));
+ if(buf)
free(buf);
delete_share_file(cnum, fname);
return -1;
@@ -885,13 +816,13 @@ locking version (was %d, should be %d).\n",fname,
/* Sanity check for file contents */
size = sb.st_size;
- size -= SMF_HEADER_LENGTH; /* Remove the header */
+ size -= 10; /* Remove the header */
/* Remove the filename component. */
- size -= SVAL(buf, SMF_FILENAME_LEN_OFFSET);
+ size -= SVAL(buf, 8);
- /* The remaining size must be a multiple of SMF_ENTRY_LENGTH - error if not. */
- if((size % SMF_ENTRY_LENGTH) != 0)
+ /* The remaining size must be a multiple of 16 - error if not. */
+ if((size % 16) != 0)
{
DEBUG(0,("ERROR: read_share_file: share file %s is an incorrect length - \
deleting it.\n", fname));
@@ -936,7 +867,7 @@ int get_share_modes(int cnum, share_lock_token token, uint32 dev, uint32 inode,
4 - tv_usec
8 - share_mode
12 - pid
- 16 - oplock port (if oplocks in use) - 2 bytes.
+
*/
share_name(cnum, dev, inode, fname);
@@ -951,7 +882,7 @@ int get_share_modes(int cnum, share_lock_token token, uint32 dev, uint32 inode,
if(new_file == True)
return 0;
- num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
+ num_entries = IVAL(buf,4);
DEBUG(5,("get_share_modes: share file %s has %d share mode entries.\n",
fname, num_entries));
@@ -986,30 +917,26 @@ for share file %d\n", num_entries, fname));
}
num_entries_copied = 0;
- base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
+ base = buf + 10 + SVAL(buf,8);
for( i = 0; i < num_entries; i++)
{
int pid;
- char *p = base + (i*SMF_ENTRY_LENGTH);
+ char *p = base + (i*16);
- pid = IVAL(p,SME_PID_OFFSET);
+ pid = IVAL(p,12);
if(!process_exists(pid))
{
DEBUG(0,("get_share_modes: process %d no longer exists and \
it left a share mode entry with mode 0x%X in share file %s\n",
- pid, IVAL(p,SME_SHAREMODE_OFFSET), fname));
+ pid, IVAL(p,8), fname));
continue;
}
- share_array[num_entries_copied].time.tv_sec = IVAL(p,SME_SEC_OFFSET);
- share_array[num_entries_copied].time.tv_usec = IVAL(p,SME_USEC_OFFSET);
- share_array[num_entries_copied].share_mode = IVAL(p,SME_SHAREMODE_OFFSET);
+ share_array[num_entries_copied].time.tv_sec = IVAL(p,0);
+ share_array[num_entries_copied].time.tv_usec = IVAL(p,4);
+ share_array[num_entries_copied].share_mode = IVAL(p,8);
share_array[num_entries_copied].pid = pid;
-#ifdef USE_OPLOCKS
- share_array[num_entries_copied].op_port = SVAL(p,SME_PORT_OFFSET);
- share_array[num_entries_copied].op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
-#endif /* USE_OPLOCKS */
num_entries_copied++;
}
@@ -1045,22 +972,18 @@ position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
return 0;
}
- SIVAL(buf, SMF_NUM_ENTRIES_OFFSET, num_entries_copied);
+ SIVAL(buf, 4, num_entries_copied);
for( i = 0; i < num_entries_copied; i++)
{
- char *p = base + (i*SMF_ENTRY_LENGTH);
-
- SIVAL(p,SME_PID_OFFSET,share_array[i].pid);
- SIVAL(p,SME_SHAREMODE_OFFSET,share_array[i].share_mode);
- SIVAL(p,SME_SEC_OFFSET,share_array[i].time.tv_sec);
- SIVAL(p,SME_USEC_OFFSET,share_array[i].time.tv_usec);
-#ifdef USE_OPLOCKS
- SSVAL(p,SME_PORT_OFFSET,share_array[i].op_port);
- SSVAL(p,SME_OPLOCK_TYPE_OFFSET,share_array[i].op_type);
-#endif /* USE_OPLOCKS */
+ char *p = base + (i*16);
+
+ SIVAL(p,12,share_array[i].pid);
+ SIVAL(p,8,share_array[i].share_mode);
+ SIVAL(p,0,share_array[i].time.tv_sec);
+ SIVAL(p,4,share_array[i].time.tv_usec);
}
- newsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries_copied);
+ newsize = (base - buf) + (16*num_entries_copied);
if(write(fd, buf, newsize) != newsize)
{
DEBUG(0,("ERROR: get_share_modes: failed to re-write share \
@@ -1130,7 +1053,7 @@ void del_share_mode(share_lock_token token, int fnum)
return;
}
- num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
+ num_entries = IVAL(buf,4);
DEBUG(5,("del_share_mode: share file %s has %d share mode entries.\n",
fname, num_entries));
@@ -1160,16 +1083,14 @@ for share file %d\n", num_entries, fname));
we have set - delete it.
*/
- base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
+ base = buf + 10 + SVAL(buf,8);
for(i = 0; i < num_entries; i++)
{
- char *p = base + (i*SMF_ENTRY_LENGTH);
+ char *p = base + (i*16);
- if((IVAL(p,SME_SEC_OFFSET) != fs_p->open_time.tv_sec) ||
- (IVAL(p,SME_USEC_OFFSET) != fs_p->open_time.tv_usec) ||
- (IVAL(p,SME_SHAREMODE_OFFSET) != fs_p->share_mode) ||
- (IVAL(p,SME_PID_OFFSET) != pid))
+ if((IVAL(p,0) != fs_p->open_time.tv_sec) || (IVAL(p,4) != fs_p->open_time.tv_usec) ||
+ (IVAL(p,8) != fs_p->share_mode) || (IVAL(p,12) != pid))
continue;
DEBUG(5,("del_share_mode: deleting entry number %d (of %d) from the share file %s\n",
@@ -1177,7 +1098,7 @@ for share file %d\n", num_entries, fname));
/* Remove this entry. */
if(i != num_entries - 1)
- memcpy(p, p + SMF_ENTRY_LENGTH, (num_entries - i - 1)*SMF_ENTRY_LENGTH);
+ memcpy(p, p + 16, (num_entries - i - 1)*16);
deleted = True;
break;
@@ -1192,7 +1113,7 @@ for share file %d\n", num_entries, fname));
}
num_entries--;
- SIVAL(buf,SMF_NUM_ENTRIES_OFFSET, num_entries);
+ SIVAL(buf,4, num_entries);
if(num_entries == 0)
{
@@ -1207,23 +1128,23 @@ for share file %d\n", num_entries, fname));
/* Re-write the file - and truncate it at the correct point. */
if(lseek(fd, 0, SEEK_SET) != 0)
- {
- DEBUG(0,("ERROR: del_share_mode: lseek failed to reset to \
+ {
+ DEBUG(0,("ERROR: del_share_mode: lseek failed to reset to \
position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
- if(buf)
- free(buf);
- return;
- }
+ if(buf)
+ free(buf);
+ return;
+ }
- newsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries);
+ newsize = (base - buf) + (16*num_entries);
if(write(fd, buf, newsize) != newsize)
- {
- DEBUG(0,("ERROR: del_share_mode: failed to re-write share \
+ {
+ DEBUG(0,("ERROR: del_share_mode: failed to re-write share \
mode file %s (%s)\n", fname, strerror(errno)));
- if(buf)
- free(buf);
- return;
- }
+ if(buf)
+ free(buf);
+ return;
+ }
/* Now truncate the file at this point. */
if(ftruncate(fd, newsize) != 0)
{
@@ -1238,7 +1159,7 @@ mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
/*******************************************************************
set the share mode of a file
********************************************************************/
-BOOL set_share_mode(share_lock_token token,int fnum, uint16 port, uint16 op_type)
+BOOL set_share_mode(share_lock_token token,int fnum)
{
files_struct *fs_p = &Files[fnum];
pstring fname;
@@ -1266,10 +1187,9 @@ BOOL set_share_mode(share_lock_token token,int fnum, uint16 port, uint16 op_type
int size = sb.st_size;
/* Allocate space for the file plus one extra entry */
- if((buf = (char *)malloc(sb.st_size + SMF_ENTRY_LENGTH)) == NULL)
+ if((buf = (char *)malloc(sb.st_size + 16)) == NULL)
{
- DEBUG(0,("set_share_mode: malloc for file size %d fail !\n",
- sb.st_size + SMF_ENTRY_LENGTH));
+ DEBUG(0,("set_share_mode: malloc for file size %d fail !\n", sb.st_size + 16));
return False;
}
@@ -1291,21 +1211,20 @@ to 0 for share file %s (%s)\n", fname, strerror(errno)));
return False;
}
- if (IVAL(buf,SMF_VERSION_OFFSET) != LOCKING_VERSION)
+ if (IVAL(buf,0) != LOCKING_VERSION)
{
DEBUG(0,("ERROR: set_share_mode: share file %s has incorrect \
-locking version (was %d, should be %d).\n",fname, IVAL(buf,SMF_VERSION_OFFSET),
- LOCKING_VERSION));
+locking version (was %d, should be %d).\n",fname, IVAL(buf,0), LOCKING_VERSION));
if(buf)
free(buf);
delete_share_file(fs_p->cnum, fname);
return False;
}
- size -= (SMF_HEADER_LENGTH + SVAL(buf, SMF_FILENAME_LEN_OFFSET)); /* Remove the header */
+ size -= (10 + SVAL(buf, 8)); /* Remove the header */
- /* The remaining size must be a multiple of SMF_ENTRY_LENGTH - error if not. */
- if((size % SMF_ENTRY_LENGTH) != 0)
+ /* The remaining size must be a multiple of 16 - error if not. */
+ if((size % 16) != 0)
{
DEBUG(0,("ERROR: set_share_mode: share file %s is an incorrect length - \
deleting it.\n", fname));
@@ -1319,33 +1238,28 @@ deleting it.\n", fname));
else
{
/* New file - just use a single_entry. */
- if((buf = (char *)malloc(SMF_HEADER_LENGTH +
- strlen(fs_p->name) + 1 + SMF_ENTRY_LENGTH)) == NULL)
+ if((buf = (char *)malloc(10 + strlen(fs_p->name) + 1 + 16)) == NULL)
{
DEBUG(0,("ERROR: set_share_mode: malloc failed for single entry.\n"));
return False;
}
- SIVAL(buf,SMF_VERSION_OFFSET,LOCKING_VERSION);
- SIVAL(buf,SMF_NUM_ENTRIES_OFFSET,0);
- SSVAL(buf,SMF_FILENAME_LEN_OFFSET,strlen(fs_p->name) + 1);
- strcpy(buf + SMF_HEADER_LENGTH, fs_p->name);
+ SIVAL(buf,0,LOCKING_VERSION);
+ SIVAL(buf,4,0);
+ SSVAL(buf,8,strlen(fs_p->name) + 1);
+ strcpy(buf + 10, fs_p->name);
}
- num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
- header_size = SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
- p = buf + header_size + (num_entries * SMF_ENTRY_LENGTH);
- SIVAL(p,SME_SEC_OFFSET,fs_p->open_time.tv_sec);
- SIVAL(p,SME_USEC_OFFSET,fs_p->open_time.tv_usec);
- SIVAL(p,SME_SHAREMODE_OFFSET,fs_p->share_mode);
- SIVAL(p,SME_PID_OFFSET,pid);
-#ifdef USE_OPLOCKS
- SSVAL(p,SME_PORT_OFFSET,port);
- SSVAL(p,SME_OPLOCK_TYPE_OFFSET,op_type);
-#endif /* USE_OPLOCKS */
+ num_entries = IVAL(buf,4);
+ header_size = 10 + SVAL(buf,8);
+ p = buf + header_size + (num_entries * 16);
+ SIVAL(p,0,fs_p->open_time.tv_sec);
+ SIVAL(p,4,fs_p->open_time.tv_usec);
+ SIVAL(p,8,fs_p->share_mode);
+ SIVAL(p,12,pid);
num_entries++;
- SIVAL(buf,SMF_NUM_ENTRIES_OFFSET,num_entries);
+ SIVAL(buf,4,num_entries);
if(lseek(fd, 0, SEEK_SET) != 0)
{
@@ -1356,8 +1270,7 @@ deleting it.\n", fname));
return False;
}
- if (write(fd,buf,header_size + (num_entries*SMF_ENTRY_LENGTH)) !=
- (header_size + (num_entries*SMF_ENTRY_LENGTH)))
+ if (write(fd,buf,header_size + (num_entries*16)) != (header_size + (num_entries*16)))
{
DEBUG(2,("ERROR: set_share_mode: Failed to write share file %s - \
deleting it (%s).\n",fname, strerror(errno)));
@@ -1368,11 +1281,10 @@ deleting it (%s).\n",fname, strerror(errno)));
}
/* Now truncate the file at this point - just for safety. */
- if(ftruncate(fd, header_size + (SMF_ENTRY_LENGTH*num_entries))!= 0)
+ if(ftruncate(fd, header_size + (16*num_entries))!= 0)
{
DEBUG(0,("ERROR: set_share_mode: failed to ftruncate share \
-mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entries),
- strerror(errno)));
+mode file %s to size %d (%s)\n", fname, header_size + (16*num_entries), strerror(errno)));
if(buf)
free(buf);
return False;
@@ -1386,126 +1298,4 @@ mode 0x%X pid=%d\n",fname,fs_p->share_mode,pid));
return True;
}
-
-/*******************************************************************
-Remove an oplock port and mode entry from a share mode.
-********************************************************************/
-BOOL remove_share_oplock(int fnum, share_lock_token token)
-{
-#ifdef USE_OPLOCKS
- pstring fname;
- int fd = (int)token;
- char *buf = 0;
- char *base = 0;
- int num_entries;
- int fsize;
- int i;
- files_struct *fs_p = &Files[fnum];
- int pid;
- BOOL found = False;
- BOOL new_file;
-
- share_name(fs_p->cnum, fs_p->fd_ptr->dev,
- fs_p->fd_ptr->inode, fname);
-
- if(read_share_file( fs_p->cnum, fd, fname, &buf, &new_file) != 0)
- {
- DEBUG(0,("ERROR: remove_share_oplock: Failed to read share file %s\n",
- fname));
- return False;
- }
-
- if(new_file == True)
- {
- DEBUG(0,("ERROR: remove_share_oplock: share file %s is new (size zero), \
-deleting it.\n", fname));
- delete_share_file(fs_p->cnum, fname);
- return False;
- }
-
- num_entries = IVAL(buf,SMF_NUM_ENTRIES_OFFSET);
-
- DEBUG(5,("remove_share_oplock: share file %s has %d share mode entries.\n",
- fname, num_entries));
-
- /* PARANOIA TEST */
- if(num_entries < 0)
- {
- DEBUG(0,("PANIC ERROR:remove_share_oplock: num_share_mode_entries < 0 (%d) \
-for share file %d\n", num_entries, fname));
- return False;
- }
-
- if(num_entries == 0)
- {
- /* No entries - just delete the file. */
- DEBUG(0,("remove_share_oplock: share file %s has no share mode entries - deleting.\n",
- fname));
- if(buf)
- free(buf);
- delete_share_file(fs_p->cnum, fname);
- return False;
- }
-
- pid = getpid();
-
- /* Go through the entries looking for the particular one
- we have set - remove the oplock settings on it.
- */
-
- base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
-
- for(i = 0; i < num_entries; i++)
- {
- char *p = base + (i*SMF_ENTRY_LENGTH);
-
- if((IVAL(p,SME_SEC_OFFSET) != fs_p->open_time.tv_sec) ||
- (IVAL(p,SME_USEC_OFFSET) != fs_p->open_time.tv_usec) ||
- (IVAL(p,SME_SHAREMODE_OFFSET) != fs_p->share_mode) ||
- (IVAL(p,SME_PID_OFFSET) != pid))
- continue;
-
- DEBUG(5,("remove_share_oplock: clearing oplock on entry number %d (of %d) \
-from the share file %s\n", i, num_entries, fname));
-
- SSVAL(p,SME_PORT_OFFSET,0);
- SSVAL(p,SME_OPLOCK_TYPE_OFFSET,0);
- found = True;
- break;
- }
-
- if(!found)
- {
- DEBUG(0,("remove_share_oplock: entry not found in share file %s\n", fname));
- if(buf)
- free(buf);
- return False;
- }
-
- /* Re-write the file - and truncate it at the correct point. */
- if(lseek(fd, 0, SEEK_SET) != 0)
- {
- DEBUG(0,("ERROR: remove_share_oplock: lseek failed to reset to \
-position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
- if(buf)
- free(buf);
- return False;
- }
-
- fsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries);
- if(write(fd, buf, fsize) != fsize)
- {
- DEBUG(0,("ERROR: remove_share_oplock: failed to re-write share \
-mode file %s (%s)\n", fname, strerror(errno)));
- if(buf)
- free(buf);
- return False;
- }
-
- return True;
-
-#else /* USE_OPLOCKS */
- return False;
-#endif /* USE_OPLOCKS */
-}
#endif /* FAST_SHARE_MODES */
diff --git a/source/locking/shmem.c b/source/locking/shmem.c
index bbb11f215a0..fcd9f3ad0d7 100644
--- a/source/locking/shmem.c
+++ b/source/locking/shmem.c
@@ -94,7 +94,7 @@ static BOOL smb_shm_global_lock(void)
/* Do an exclusive wait lock on the first byte of the file */
if (fcntl_lock(smb_shm_fd, F_SETLKW, 0, 1, F_WRLCK) == False)
{
- DEBUG(0,("ERROR smb_shm_global_lock : fcntl_lock failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_global_lock : fcntl_lock failed with code %d\n",errno));
smb_shm_times_locked--;
return False;
}
@@ -128,7 +128,7 @@ static BOOL smb_shm_global_unlock(void)
/* Do a wait unlock on the first byte of the file */
if (fcntl_lock(smb_shm_fd, F_SETLKW, 0, 1, F_UNLCK) == False)
{
- DEBUG(0,("ERROR smb_shm_global_unlock : fcntl_lock failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_global_unlock : fcntl_lock failed with code %d\n",errno));
smb_shm_times_locked++;
return False;
}
@@ -178,7 +178,7 @@ static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *oth
#endif /* SECURE_SHARE_MODES */
if ( smb_shm_processes_fd < 0 )
{
- DEBUG(0,("ERROR smb_shm_register_process : processreg_file open failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_register_process : processreg_file open failed with code %d\n",errno));
return False;
}
@@ -208,7 +208,7 @@ static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *oth
}
if (nb_read < 0)
{
- DEBUG(0,("ERROR smb_shm_register_process : processreg_file read failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_register_process : processreg_file read failed with code %d\n",errno));
close(smb_shm_processes_fd);
return False;
}
@@ -220,7 +220,7 @@ static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *oth
lseek(smb_shm_processes_fd, free_slot, SEEK_SET);
if(write(smb_shm_processes_fd, &pid, sizeof(pid)) < 0)
{
- DEBUG(0,("ERROR smb_shm_register_process : processreg_file write failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_register_process : processreg_file write failed with code %d\n",errno));
close(smb_shm_processes_fd);
return False;
}
@@ -246,7 +246,7 @@ static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
umask(old_umask);
if ( smb_shm_processes_fd < 0 )
{
- DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file open failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file open failed with code %d\n",errno));
return False;
}
@@ -262,7 +262,7 @@ static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
erased_slot = lseek(smb_shm_processes_fd, seek_back, SEEK_CUR);
if(write(smb_shm_processes_fd, &other_pid, sizeof(other_pid)) < 0)
{
- DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file write failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file write failed with code %d\n",errno));
close(smb_shm_processes_fd);
return False;
}
@@ -273,7 +273,7 @@ static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
}
if (nb_read < 0)
{
- DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file read failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file read failed with code %d\n",errno));
close(smb_shm_processes_fd);
return False;
}
@@ -399,7 +399,7 @@ BOOL smb_shm_open( char *file_name, int size)
umask(old_umask);
if ( smb_shm_fd < 0 )
{
- DEBUG(0,("ERROR smb_shm_open : open failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_open : open failed with code %d\n",errno));
return False;
}
@@ -411,7 +411,7 @@ BOOL smb_shm_open( char *file_name, int size)
if( (filesize = lseek(smb_shm_fd, 0, SEEK_END)) < 0)
{
- DEBUG(0,("ERROR smb_shm_open : lseek failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_open : lseek failed with code %d\n",errno));
smb_shm_global_unlock();
close(smb_shm_fd);
return False;
@@ -446,7 +446,7 @@ BOOL smb_shm_open( char *file_name, int size)
/* we just created a new one, or are the first opener, lets set it size */
if( ftruncate(smb_shm_fd, size) <0)
{
- DEBUG(0,("ERROR smb_shm_open : ftruncate failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_open : ftruncate failed with code %d\n",errno));
smb_shm_unregister_process(smb_shm_processreg_name, getpid());
smb_shm_global_unlock();
close(smb_shm_fd);
@@ -471,7 +471,7 @@ BOOL smb_shm_open( char *file_name, int size)
/* WARNING, smb_shm_header_p can be different for different processes mapping the same file ! */
if (smb_shm_header_p == (struct SmbShmHeader *)(-1))
{
- DEBUG(0,("ERROR smb_shm_open : mmap failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_open : mmap failed with code %d\n",errno));
smb_shm_unregister_process(smb_shm_processreg_name, getpid());
smb_shm_global_unlock();
close(smb_shm_fd);
@@ -514,7 +514,7 @@ BOOL smb_shm_close( void )
if ((smb_shm_header_p != NULL) &&
(munmap((caddr_t)smb_shm_header_p, smb_shm_header_p->total_size) < 0))
{
- DEBUG(0,("ERROR smb_shm_close : munmap failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_close : munmap failed with code %d\n",errno));
}
smb_shm_global_lock();
@@ -733,7 +733,7 @@ BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off)
return True;
}
-void *smb_shm_offset2addr(smb_shm_offset_t offset)
+void * smb_shm_offset2addr(smb_shm_offset_t offset)
{
if (offset == NULL_OFFSET )
return (void *)(0);
@@ -778,7 +778,7 @@ BOOL smb_shm_lock_hash_entry( unsigned int entry)
/* Do an exclusive wait lock on the 4 byte region mapping into this entry */
if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(smb_shm_offset_t), F_WRLCK) == False)
{
- DEBUG(0,("ERROR smb_shm_lock_hash_entry : fcntl_lock failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_lock_hash_entry : fcntl_lock failed with code %d\n",errno));
return False;
}
@@ -809,7 +809,7 @@ BOOL smb_shm_unlock_hash_entry( unsigned int entry )
/* Do a wait lock on the 4 byte region mapping into this entry */
if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(smb_shm_offset_t), F_UNLCK) == False)
{
- DEBUG(0,("ERROR smb_shm_unlock_hash_entry : fcntl_lock failed with code %s\n",strerror(errno)));
+ DEBUG(0,("ERROR smb_shm_unlock_hash_entry : fcntl_lock failed with code %d\n",errno));
return False;
}
diff --git a/source/md4.h b/source/md4.h
new file mode 100644
index 00000000000..3f60d75fe3c
--- /dev/null
+++ b/source/md4.h
@@ -0,0 +1,58 @@
+/*
+ This code is from rfc1186.
+*/
+
+ /*
+ ** ********************************************************************
+ ** md4.h -- Header file for implementation of **
+ ** MD4 Message Digest Algorithm **
+ ** Updated: 2/13/90 by Ronald L. Rivest **
+ ** (C) 1990 RSA Data Security, Inc. **
+ ** ********************************************************************
+ */
+
+ /* MDstruct is the data structure for a message digest computation.
+ */
+ typedef struct {
+ unsigned int buffer[4]; /* Holds 4-word result of MD computation */
+ unsigned char count[8]; /* Number of bits processed so far */
+ unsigned int done; /* Nonzero means MD computation finished */
+ } MDstruct, *MDptr;
+
+ /* MDbegin(MD)
+
+
+
+ ** Input: MD -- an MDptr
+ ** Initialize the MDstruct prepatory to doing a message digest
+ ** computation.
+ */
+ extern void MDbegin();
+
+ /* MDupdate(MD,X,count)
+ ** Input: MD -- an MDptr
+ ** X -- a pointer to an array of unsigned characters.
+ ** count -- the number of bits of X to use (an unsigned int).
+ ** Updates MD using the first "count" bits of X.
+ ** The array pointed to by X is not modified.
+ ** If count is not a multiple of 8, MDupdate uses high bits of
+ ** last byte.
+ ** This is the basic input routine for a user.
+ ** The routine terminates the MD computation when count < 512, so
+ ** every MD computation should end with one call to MDupdate with a
+ ** count less than 512. Zero is OK for a count.
+ */
+ extern void MDupdate();
+
+ /* MDprint(MD)
+ ** Input: MD -- an MDptr
+ ** Prints message digest buffer MD as 32 hexadecimal digits.
+ ** Order is from low-order byte of buffer[0] to high-order byte
+ ** of buffer[3].
+ ** Each byte is printed with high-order hexadecimal digit first.
+ */
+ extern void MDprint();
+
+ /*
+ ** End of md4.h
+ */
diff --git a/source/nameannounce.c b/source/nameannounce.c
index d3344ebd478..c85561b763a 100644
--- a/source/nameannounce.c
+++ b/source/nameannounce.c
@@ -383,6 +383,7 @@ void announce_master(time_t t)
for (d = FIRST_SUBNET; d; d = NEXT_SUBNET_EXCLUDING_WINS(d))
{
+ struct work_record *work;
for (work = d->workgrouplist; work; work = work->next)
{
if (AM_MASTER(work))
@@ -436,10 +437,9 @@ workgroup %s\n", am_master, work->work_group));
/* We are the WINS server - query ourselves for the dmb name. */
struct nmb_name netb_name;
+ struct subnet_record *d = 0;
struct name_record *nr = 0;
-
- d = NULL;
-
+
make_nmb_name(&netb_name, name, type, scope);
if ((nr = find_name_search(&d, &netb_name, FIND_WINS, ipzero)) == 0)
@@ -469,7 +469,7 @@ for workgroup %s\n", name, type, inet_ntoa(nr->ip_flgs[0].ip), work->work_group
NMB_QUERY,NAME_STATUS_DOM_SRV_CHK,
name, type, 0,0,0,
work->work_group,NULL,
- False, False, nr->ip_flgs[0].ip, nr->ip_flgs[0].ip);
+ False, False, nr->ip_flgs[0].ip, nr->ip_flgs[0].ip, 0);
}
}
diff --git a/source/namebrowse.c b/source/namebrowse.c
index 1dd293d27be..ae5f00ce10e 100644
--- a/source/namebrowse.c
+++ b/source/namebrowse.c
@@ -199,7 +199,7 @@ workgroup %s\n",
queue_netbios_packet(d,ClientNMB,NMB_QUERY,
b->local?NAME_QUERY_SYNC_LOCAL:NAME_QUERY_SYNC_REMOTE,
b->name,0x20,0,0,0,NULL,b->group,
- False,False,b->ip,b->ip);
+ False,False,b->ip,b->ip, 0);
b->synced = True;
}
diff --git a/source/namedbresp.c b/source/namedbresp.c
index 86d7eddbd41..c8a31a6c79b 100644
--- a/source/namedbresp.c
+++ b/source/namedbresp.c
@@ -95,7 +95,8 @@ struct response_record *make_response_queue_record(enum state_type state,
int quest_type, char *name,int type, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
- struct in_addr send_ip, struct in_addr reply_to_ip)
+ struct in_addr send_ip, struct in_addr reply_to_ip,
+ int reply_id)
{
struct response_record *n;
@@ -118,6 +119,7 @@ struct response_record *make_response_queue_record(enum state_type state,
n->recurse = recurse;
n->send_ip = send_ip;
n->reply_to_ip = reply_to_ip;
+ n->reply_id = reply_id;
if(my_name)
StrnCpy(n->my_name, my_name, sizeof(n->my_name)-1);
else
diff --git a/source/nameelect.c b/source/nameelect.c
index 5fd1a4bdf2e..b2e4ab62492 100644
--- a/source/nameelect.c
+++ b/source/nameelect.c
@@ -97,7 +97,7 @@ void check_master_browser(time_t t)
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_MST_CHK,
work->work_group,0x1d,0,0,0,NULL,NULL,
- True,False,d->bcast_ip,d->bcast_ip);
+ True,False,d->bcast_ip,d->bcast_ip, 0);
}
}
}
@@ -636,6 +636,7 @@ void unbecome_domain_master(struct subnet_record *d, struct work_record *work,
{
work = find_workgroupstruct(d, myworkgroup, False);
+ announce_server(d, work, work->work_group, myname, 0, 0);
/* Remove the name entry without any NetBIOS traffic as that's
how it was registered. */
remove_name_entry(d,work->work_group,0x1b);
@@ -670,6 +671,8 @@ void unbecome_logon_server(struct subnet_record *d, struct work_record *work,
work->log_state = LOGON_NONE;
+ /* announce ourselves as no longer active as a master browser. */
+ announce_server(d, work, work->work_group, myname, 0, 0);
remove_name_entry(d,work->work_group,0x1c);
}
}
diff --git a/source/namepacket.c b/source/namepacket.c
index 44e449b8c2a..fb8e4d2bf5b 100644
--- a/source/namepacket.c
+++ b/source/namepacket.c
@@ -37,6 +37,7 @@ extern int num_response_packets;
BOOL CanRecurse = True;
extern pstring scope;
extern struct in_addr wins_ip;
+extern struct in_addr loopback_ip;
static uint16 name_trn_id=0;
@@ -228,14 +229,14 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
}
default:
{
- DEBUG(1,("replying netbios packet: %s %s\n",
+ DEBUG(1,("replying netbios packet: %s %s %s\n",
packet_type, namestr(rr_name), inet_ntoa(p.ip)));
return;
}
}
- DEBUG(4,("replying netbios packet: %s %s\n",
+ DEBUG(4,("replying netbios packet: %s %s %s\n",
packet_type, namestr(rr_name), inet_ntoa(p.ip)));
nmb->header.name_trn_id = trn_id;
@@ -528,7 +529,9 @@ void listen_for_packets(BOOL run_election)
struct packet_struct *packet = read_packet(ClientNMB, NMB_PACKET);
if (packet)
{
- if (ismyip(packet->ip) && packet->port == NMB_PORT)
+ if ((ip_equal(loopback_ip, packet->ip) ||
+ ismyip(packet->ip)) &&
+ packet->port == NMB_PORT)
{
DEBUG(7,("discarding own packet from %s:%d\n",
inet_ntoa(packet->ip),packet->port));
@@ -546,7 +549,9 @@ void listen_for_packets(BOOL run_election)
struct packet_struct *packet = read_packet(ClientDGRAM, DGRAM_PACKET);
if (packet)
{
- if (ismyip(packet->ip) && packet->port == DGRAM_PORT)
+ if ((ip_equal(loopback_ip, packet->ip) ||
+ ismyip(packet->ip)) &&
+ packet->port == DGRAM_PORT)
{
DEBUG(7,("discarding own packet from %s:%d\n",
inet_ntoa(packet->ip),packet->port));
diff --git a/source/nameresp.c b/source/nameresp.c
index f44171f4b67..c40dd16a888 100644
--- a/source/nameresp.c
+++ b/source/nameresp.c
@@ -115,7 +115,7 @@ static void dead_netbios_entry(struct subnet_record *d,
wanted the unique name and tell them that they can have it
*/
- add_name_respond(d,n->fd,d->myip, n->response_id ,&n->name,
+ add_name_respond(d,n->fd,d->myip, n->reply_id ,&n->name,
n->nb_flags, GET_TTL(0),
n->reply_to_ip, True, n->reply_to_ip);
@@ -281,7 +281,7 @@ struct response_record *queue_netbios_pkt_wins(
return queue_netbios_packet(wins_subnet,fd, quest_type, state,
name, name_type, nb_flags, ttl,
server_type,my_name,my_comment,
- False, True, send_ip, reply_to_ip);
+ False, True, send_ip, reply_to_ip, 0);
}
@@ -296,7 +296,8 @@ struct response_record *queue_netbios_packet(struct subnet_record *d,
int name_type,int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
- struct in_addr send_ip, struct in_addr reply_to_ip)
+ struct in_addr send_ip, struct in_addr reply_to_ip,
+ int reply_id)
{
struct response_record *n;
uint16 id = 0xffff;
@@ -315,7 +316,8 @@ struct response_record *queue_netbios_packet(struct subnet_record *d,
if ((n = make_response_queue_record(state,id,fd,
quest_type,name,name_type,nb_flags,ttl,
server_type,my_name, my_comment,
- bcast,recurse,send_ip,reply_to_ip)))
+ bcast,recurse,send_ip,reply_to_ip,
+ reply_id)))
{
add_response_record(d,n);
return n;
diff --git a/source/nameserv.c b/source/nameserv.c
index ccd0ef379cb..bc37d1c424e 100644
--- a/source/nameserv.c
+++ b/source/nameserv.c
@@ -111,7 +111,7 @@ void remove_name_entry(struct subnet_record *d, char *name,int type)
/* local interface: release them on the network */
queue_netbios_packet(d,ClientNMB,NMB_REL,NAME_RELEASE,
name, type, 0, 0,0,NULL,NULL,
- True, False, d->bcast_ip, d->bcast_ip);
+ True, False, d->bcast_ip, d->bcast_ip, 0);
}
}
@@ -172,7 +172,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
queue_netbios_packet(d,ClientNMB,
re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
- True, False, d->bcast_ip, ipzero);
+ True, False, d->bcast_ip, ipzero, 0);
}
}
@@ -249,7 +249,7 @@ for domain master on workgroup %s\n",
myworkgroup, 0x1b,
0, 0,0,NULL,NULL,
True, False,
- d->bcast_ip, d->bcast_ip);
+ d->bcast_ip, d->bcast_ip, 0);
}
}
}
@@ -488,7 +488,8 @@ void query_refresh_names(time_t t)
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_CONFIRM,
n->name.name, n->name.name_type,
0,0,0,NULL,NULL,
- False,False,n->ip_flgs[0].ip,n->ip_flgs[0].ip);
+ False,False,n->ip_flgs[0].ip,n->ip_flgs[0].ip,
+ 0);
count++;
}
diff --git a/source/nameservreply.c b/source/nameservreply.c
index 5b9c476549d..98247c76366 100644
--- a/source/nameservreply.c
+++ b/source/nameservreply.c
@@ -45,7 +45,7 @@ static void send_name_response(int fd, struct in_addr from_ip,
int name_trn_id, int opcode, BOOL success,
BOOL recursion_available, BOOL recursion_desired,
struct nmb_name *reply_name, int nb_flags, int ttl,
- struct in_addr ip)
+ struct in_addr ip)
{
char rdata[6];
struct packet_struct p;
@@ -96,7 +96,8 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
/* reply yes or no to the host that requested the name */
/* see rfc1002.txt - 4.2.10 and 4.2.11 */
- send_name_response(fd,from_ip, response_id, NMB_REG,
+
+ send_name_response(fd, reply_to_ip, response_id, NMB_REG,
new_owner,
True, True,
name, nb_flags, ttl, reply_to_ip);
@@ -317,7 +318,8 @@ void reply_name_reg(struct packet_struct *p)
reply_name->name,reply_name->name_type,
nb_flags,0,0,NULL,NULL,
False, False,
- n->ip_flgs[0].ip, p->ip);
+ n->ip_flgs[0].ip, p->ip,
+ nmb->header.name_trn_id);
}
else
{
diff --git a/source/nameservresp.c b/source/nameservresp.c
index a88481d06b0..5ab70d7a4de 100644
--- a/source/nameservresp.c
+++ b/source/nameservresp.c
@@ -176,7 +176,7 @@ static void response_server_check(struct nmb_name *ans_name,
queue_netbios_packet(d,ClientNMB,NMB_STATUS, cmd,
ans_name->name, ans_name->name_type,
0,0,0,n->my_name,NULL,
- False,False,send_ip,n->reply_to_ip);
+ False,False,send_ip,n->reply_to_ip, 0);
}
@@ -362,9 +362,11 @@ static void response_name_query_register(struct nmb_packet *nmb,
}
/* register the old or the new owners' ip */
- add_name_respond(d, n->fd, d->myip, n->response_id,&n->name,n->nb_flags,
+ add_name_respond(d, n->fd, d->myip, n->reply_id,&n->name,n->nb_flags,
GET_TTL(0), register_ip,
new_owner, n->reply_to_ip);
+
+ remove_response_record(d,n); /* remove the response record */
}
@@ -803,7 +805,8 @@ void response_netbios_packet(struct packet_struct *p)
struct subnet_record *d = NULL;
if (!(n = find_response_record(&d,nmb->header.name_trn_id))) {
- DEBUG(2,("unknown netbios response (received late or from nmblookup?)\n"));
+ DEBUG(2,("unknown netbios response id %d (received late or from nmblookup?)\n",
+ nmb->header.name_trn_id));
return;
}
@@ -829,8 +832,8 @@ void response_netbios_packet(struct packet_struct *p)
}
ans_name = &nmb->answers->rr_name;
- DEBUG(3,("response for %s from %s (bcast=%s)\n",
- namestr(ans_name), inet_ntoa(p->ip), BOOLSTR(bcast)));
+ DEBUG(3,("response for %s from %s(%d) (bcast=%s)\n",
+ namestr(ans_name), inet_ntoa(p->ip), p->port, BOOLSTR(bcast)));
debug_rr_type(nmb->answers->rr_type);
diff --git a/source/namework.c b/source/namework.c
index 3e1ac220058..2de4a3016f7 100644
--- a/source/namework.c
+++ b/source/namework.c
@@ -372,7 +372,8 @@ static void process_rcv_backup_list(struct packet_struct *p,char *buf)
queue_netbios_packet(d1,ClientNMB,NMB_QUERY,NAME_QUERY_SRV_CHK,
work->work_group,0x1d,
0,0,0,NULL,NULL,
- False,False,back_ip,back_ip);
+ False,False,back_ip,back_ip,
+ 0);
return;
}
}
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index fb656aa627f..d37fc8df339 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -49,11 +49,6 @@
#include "includes.h"
-/* Set default coding system for KANJI if none specified in Makefile. */
-#ifndef KANJI
-#define KANJI "sjis"
-#endif /* KANJI */
-
BOOL bLoaded = False;
extern int DEBUGLEVEL;
@@ -102,7 +97,9 @@ int keepalive=0;
extern BOOL use_getwd_cache;
extern int extra_time_offset;
+#ifdef KANJI
extern int coding_system;
+#endif
/*
* This structure describes global (ie., server-wide) parameters.
@@ -146,7 +143,6 @@ typedef struct
int max_mux;
int max_packet;
int pwordlevel;
- int unamelevel;
int deadtime;
int maxprotocol;
int security;
@@ -257,7 +253,6 @@ typedef struct
BOOL bLocking;
BOOL bStrictLocking;
BOOL bShareModes;
- BOOL bOpLocks;
BOOL bOnlyUser;
BOOL bMangledNames;
BOOL bWidelinks;
@@ -267,7 +262,7 @@ typedef struct
BOOL *copymap;
BOOL bDeleteReadonly;
BOOL bFakeOplocks;
- BOOL bDeleteVetoFiles;
+ BOOL bDosFiletimes;
char dummy[3]; /* for alignment */
} service;
@@ -339,7 +334,6 @@ static service sDefault =
True, /* bLocking */
False, /* bStrictLocking */
True, /* bShareModes */
- True, /* bOpLocks */
False, /* bOnlyUser */
True, /* bMangledNames */
True, /* bWidelinks */
@@ -349,7 +343,7 @@ static service sDefault =
NULL, /* copymap */
False, /* bDeleteReadonly */
False, /* bFakeOplocks */
- False, /* bDeleteVetoFiles */
+ False, /* bDosFiletimes */
"" /* dummy */
};
@@ -375,7 +369,9 @@ static BOOL handle_case(char *pszParmValue,int *val);
static BOOL handle_printing(char *pszParmValue,int *val);
static BOOL handle_character_set(char *pszParmValue,int *val);
static BOOL handle_announce_as(char *pszParmValue, int *val);
+#ifdef KANJI
static BOOL handle_coding_system(char *pszParmValue,int *val);
+#endif /* KANJI */
static void set_default_server_announce_type(void);
@@ -452,14 +448,15 @@ struct parm_struct
{"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL},
{"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL},
{"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL},
- {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL},
{"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL},
{"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL},
{"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL},
{"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL},
{"shared mem size", P_INTEGER, P_GLOBAL, &Globals.shmem_size, NULL},
{"shared file entries", P_INTEGER, P_GLOBAL, &Globals.shmem_hash_size, NULL},
+#ifdef KANJI
{"coding system", P_INTEGER, P_GLOBAL, &coding_system, handle_coding_system},
+#endif /* KANJI */
{"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL},
{"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL},
{"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL},
@@ -527,7 +524,6 @@ struct parm_struct
{"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL},
{"status", P_BOOL, P_LOCAL, &sDefault.status, NULL},
{"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL},
- {"delete veto files",P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL},
{"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL},
{"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL},
{"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL},
@@ -543,7 +539,6 @@ struct parm_struct
{"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL},
{"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL},
{"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL},
- {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL},
{"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL},
{"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL},
{"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL},
@@ -567,6 +562,7 @@ struct parm_struct
{"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL},
{"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL},
{"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL},
+ {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL},
{NULL, P_BOOL, P_NONE, NULL, NULL}
};
@@ -606,7 +602,11 @@ static void init_globals(void)
#endif
string_set(&Globals.szPasswdChat,"*old*password* %o\\n *new*password* %n\\n *new*password* %n\\n *changed*");
string_set(&Globals.szWorkGroup, WORKGROUP);
+#ifdef SMB_PASSWD
string_set(&Globals.szPasswdProgram, SMB_PASSWD);
+#else
+ string_set(&Globals.szPasswdProgram, "/bin/passwd");
+#endif
string_set(&Globals.szPrintcapname, PRINTCAP_NAME);
string_set(&Globals.szLockDir, LOCKDIR);
string_set(&Globals.szRootdir, "/");
@@ -624,7 +624,6 @@ static void init_globals(void)
Globals.max_mux = 50; /* This is *needed* for profile support. */
Globals.lpqcachetime = 10;
Globals.pwordlevel = 0;
- Globals.unamelevel = 0;
Globals.deadtime = 0;
Globals.max_log_size = 5000;
Globals.maxprotocol = PROTOCOL_NT1;
@@ -650,7 +649,9 @@ static void init_globals(void)
Globals.bNISHomeMap = False;
string_set(&Globals.szNISHomeMapName, "auto.home");
#endif
+#ifdef KANJI
coding_system = interpret_coding_system (KANJI, SJIS_CODE);
+#endif /* KANJI */
Globals.client_code_page = DEFAULT_CLIENT_CODE_PAGE;
Globals.bTimeServer = False;
@@ -781,6 +782,8 @@ char *lp_string(char *s)
else
StrCpy(ret,s);
+ trim_string(ret, "\"", "\"");
+
standard_sub_basic(ret);
return(ret);
}
@@ -871,7 +874,6 @@ FN_GLOBAL_INTEGER(lp_maxmux,&Globals.max_mux)
FN_GLOBAL_INTEGER(lp_maxpacket,&Globals.max_packet)
FN_GLOBAL_INTEGER(lp_keepalive,&keepalive)
FN_GLOBAL_INTEGER(lp_passwordlevel,&Globals.pwordlevel)
-FN_GLOBAL_INTEGER(lp_usernamelevel,&Globals.unamelevel)
FN_GLOBAL_INTEGER(lp_readsize,&Globals.ReadSize)
FN_GLOBAL_INTEGER(lp_shmem_size,&Globals.shmem_size)
FN_GLOBAL_INTEGER(lp_shmem_hash_size,&Globals.shmem_hash_size)
@@ -938,7 +940,6 @@ FN_LOCAL_BOOL(lp_map_archive,bMap_archive)
FN_LOCAL_BOOL(lp_locking,bLocking)
FN_LOCAL_BOOL(lp_strict_locking,bStrictLocking)
FN_LOCAL_BOOL(lp_share_modes,bShareModes)
-FN_LOCAL_BOOL(lp_oplocks,bOpLocks)
FN_LOCAL_BOOL(lp_onlyuser,bOnlyUser)
FN_LOCAL_BOOL(lp_manglednames,bMangledNames)
FN_LOCAL_BOOL(lp_widelinks,bWidelinks)
@@ -947,7 +948,7 @@ FN_LOCAL_BOOL(lp_syncalways,bSyncAlways)
FN_LOCAL_BOOL(lp_map_system,bMap_system)
FN_LOCAL_BOOL(lp_delete_readonly,bDeleteReadonly)
FN_LOCAL_BOOL(lp_fake_oplocks,bFakeOplocks)
-FN_LOCAL_BOOL(lp_recursive_veto_delete,bDeleteVetoFiles)
+FN_LOCAL_BOOL(lp_dos_filetimes,bDosFiletimes)
FN_LOCAL_INTEGER(lp_create_mode,iCreate_mask)
FN_LOCAL_INTEGER(lp_force_create_mode,iCreate_force_mode)
@@ -972,6 +973,8 @@ static void copy_service( service *pserviceDest,
static BOOL service_ok(int iService);
static BOOL do_parameter(char *pszParmName, char *pszParmValue);
static BOOL do_section(char *pszSectionName);
+static void dump_globals(void);
+static void dump_a_service(service *pService);
static void init_copymap(service *pservice);
@@ -1142,8 +1145,6 @@ BOOL lp_add_printer(char *pszPrintername, int iDefaultService)
iSERVICE(i).bRead_only = False;
/* No share modes on printer services. */
iSERVICE(i).bShareModes = False;
- /* No oplocks on printer services. */
- iSERVICE(i).bOpLocks = False;
/* Printer services must be printable. */
iSERVICE(i).bPrint_ok = True;
@@ -1415,16 +1416,17 @@ BOOL lp_file_list_changed(void)
mod_time = file_modtime(n2);
- if (f->modtime != mod_time)
- {
- DEBUG(6,("file %s modified: %s\n", n2, ctime(&mod_time)));
- return(True);
+ if (f->modtime != mod_time) {
+ DEBUG(6,("file %s modified: %s\n", n2, ctime(&mod_time)));
+ f->modtime = mod_time;
+ return(True);
}
f = f->next;
}
return(False);
}
+#ifdef KANJI
/***************************************************************************
handle the interpretation of the coding system parameter
*************************************************************************/
@@ -1433,6 +1435,7 @@ static BOOL handle_coding_system(char *pszParmValue,int *val)
*val = interpret_coding_system(pszParmValue,*val);
return(True);
}
+#endif /* KANJI */
/***************************************************************************
handle the interpretation of the character set system parameter
@@ -1613,15 +1616,18 @@ static void init_copymap(service *pservice)
/***************************************************************************
-Process a parameter for a particular service number. If snum < 0
-then assume we are in the globals
+Process a parameter.
***************************************************************************/
-BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
+static BOOL do_parameter(char *pszParmName, char *pszParmValue)
{
int parmnum;
void *parm_ptr=NULL; /* where we are going to store the result */
void *def_ptr=NULL;
+ if (!bInGlobalSection && bGlobalOnly) return(True);
+
+ DEBUG(3,("doing parameter %s = %s\n",pszParmName,pszParmValue));
+
parmnum = map_parameter(pszParmName);
if (parmnum < 0)
@@ -1633,33 +1639,37 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
def_ptr = parm_table[parmnum].ptr;
/* we might point at a service, the default service or a global */
- if (snum < 0) {
+ if (bInGlobalSection)
parm_ptr = def_ptr;
- } else {
- if (parm_table[parmnum].class == P_GLOBAL) {
+ else
+ {
+ if (parm_table[parmnum].class == P_GLOBAL)
+ {
DEBUG(0,( "Global parameter %s found in service section!\n",pszParmName));
return(True);
}
- parm_ptr = ((char *)pSERVICE(snum)) + PTR_DIFF(def_ptr,&sDefault);
- }
+ parm_ptr = ((char *)pSERVICE(iServiceIndex)) + PTR_DIFF(def_ptr,&sDefault);
+ }
- if (snum >= 0) {
- int i;
- if (!iSERVICE(snum).copymap)
- init_copymap(pSERVICE(snum));
-
- /* this handles the aliases - set the copymap for other entries with
- the same data pointer */
- for (i=0;parm_table[i].label;i++)
- if (parm_table[i].ptr == parm_table[parmnum].ptr)
- iSERVICE(snum).copymap[i] = False;
- }
+ if (!bInGlobalSection)
+ {
+ int i;
+ if (!iSERVICE(iServiceIndex).copymap)
+ init_copymap(pSERVICE(iServiceIndex));
+
+ /* this handles the aliases - set the copymap for other entries with
+ the same data pointer */
+ for (i=0;parm_table[i].label;i++)
+ if (parm_table[i].ptr == parm_table[parmnum].ptr)
+ iSERVICE(iServiceIndex).copymap[i] = False;
+ }
/* if it is a special case then go ahead */
- if (parm_table[parmnum].special) {
- parm_table[parmnum].special(pszParmValue,parm_ptr);
- return(True);
- }
+ if (parm_table[parmnum].special)
+ {
+ parm_table[parmnum].special(pszParmValue,parm_ptr);
+ return(True);
+ }
/* now switch on the type of variable it is */
switch (parm_table[parmnum].type)
@@ -1708,105 +1718,48 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
}
/***************************************************************************
-Process a parameter.
-***************************************************************************/
-static BOOL do_parameter(char *pszParmName, char *pszParmValue)
-{
- if (!bInGlobalSection && bGlobalOnly) return(True);
-
- DEBUG(3,("doing parameter %s = %s\n",pszParmName,pszParmValue));
-
- return lp_do_parameter(bInGlobalSection?-2:iServiceIndex, pszParmName, pszParmValue);
-}
-
-
-/***************************************************************************
print a parameter of the specified type
***************************************************************************/
-static void print_parameter(parm_type type,void *ptr, FILE *f)
+static void print_parameter(parm_type type,void *ptr)
{
switch (type)
{
case P_BOOL:
- fprintf(f,"%s",BOOLSTR(*(BOOL *)ptr));
+ printf("%s",BOOLSTR(*(BOOL *)ptr));
break;
case P_BOOLREV:
- fprintf(f,"%s",BOOLSTR(! *(BOOL *)ptr));
+ printf("%s",BOOLSTR(! *(BOOL *)ptr));
break;
case P_INTEGER:
- fprintf(f,"%d",*(int *)ptr);
+ printf("%d",*(int *)ptr);
break;
case P_CHAR:
- fprintf(f,"%c",*(char *)ptr);
+ printf("%c",*(char *)ptr);
break;
case P_OCTAL:
- fprintf(f,"0%o",*(int *)ptr);
+ printf("0%o",*(int *)ptr);
break;
case P_GSTRING:
case P_UGSTRING:
if ((char *)ptr)
- fprintf(f,"%s",(char *)ptr);
+ printf("%s",(char *)ptr);
break;
case P_STRING:
case P_USTRING:
if (*(char **)ptr)
- fprintf(f,"%s",*(char **)ptr);
+ printf("%s",*(char **)ptr);
break;
}
}
/***************************************************************************
-print a parameter of the specified type
-***************************************************************************/
-static void parameter_string(parm_type type,void *ptr,char *s)
-{
- s[0] = 0;
-
- switch (type)
- {
- case P_BOOL:
- sprintf(s, "%s",BOOLSTR(*(BOOL *)ptr));
- break;
-
- case P_BOOLREV:
- sprintf(s, "%s",BOOLSTR(! *(BOOL *)ptr));
- break;
-
- case P_INTEGER:
- sprintf(s, "%d",*(int *)ptr);
- break;
-
- case P_CHAR:
- sprintf(s, "%c",*(char *)ptr);
- break;
-
- case P_OCTAL:
- sprintf(s, "0%o",*(int *)ptr);
- break;
-
- case P_GSTRING:
- case P_UGSTRING:
- if ((char *)ptr)
- sprintf(s, "%s",(char *)ptr);
- break;
-
- case P_STRING:
- case P_USTRING:
- if (*(char **)ptr)
- sprintf(s, "%s",*(char **)ptr);
- break;
- }
-}
-
-
-/***************************************************************************
check if two parameters are equal
***************************************************************************/
static BOOL equal_parameter(parm_type type,void *ptr1,void *ptr2)
@@ -1898,32 +1851,32 @@ static BOOL do_section(char *pszSectionName)
/***************************************************************************
Display the contents of the global structure.
***************************************************************************/
-static void dump_globals(FILE *f)
+static void dump_globals(void)
{
int i;
- fprintf(f, "# Global parameters\n");
+ printf("Global parameters:\n");
for (i=0;parm_table[i].label;i++)
if (parm_table[i].class == P_GLOBAL &&
parm_table[i].ptr &&
(i == 0 || (parm_table[i].ptr != parm_table[i-1].ptr)))
{
- fprintf(f,"\t%s = ",parm_table[i].label);
- print_parameter(parm_table[i].type,parm_table[i].ptr, f);
- fprintf(f,"\n");
+ printf("\t%s: ",parm_table[i].label);
+ print_parameter(parm_table[i].type,parm_table[i].ptr);
+ printf("\n");
}
}
/***************************************************************************
Display the contents of a single services record.
***************************************************************************/
-static void dump_a_service(service *pService, FILE *f)
+static void dump_a_service(service *pService)
{
int i;
if (pService == &sDefault)
- fprintf(f,"\n\n# Default service parameters\n");
+ printf("\nDefault service parameters:\n");
else
- fprintf(f,"\n[%s]\n",pService->szService);
+ printf("\nService parameters [%s]:\n",pService->szService);
for (i=0;parm_table[i].label;i++)
if (parm_table[i].class == P_LOCAL &&
@@ -1937,69 +1890,14 @@ static void dump_a_service(service *pService, FILE *f)
((char *)pService) + pdiff,
((char *)&sDefault) + pdiff))
{
- fprintf(f,"\t%s = ",parm_table[i].label);
+ printf("\t%s: ",parm_table[i].label);
print_parameter(parm_table[i].type,
- ((char *)pService) + pdiff, f);
- fprintf(f,"\n");
+ ((char *)pService) + pdiff);
+ printf("\n");
}
}
}
-
-/***************************************************************************
-return info about the next service in a service. snum==-1 gives the default
-serice and snum==-2 gives the globals
-
-return 0 when out of parameters
-***************************************************************************/
-int lp_next_parameter(int snum, int *i, char *label,
- char *value, int allparameters)
-{
- if (snum == -2) {
- /* do the globals */
- for (;parm_table[*i].label;(*i)++)
- if (parm_table[*i].class == P_GLOBAL &&
- parm_table[*i].ptr &&
- (*parm_table[*i].label != '-') &&
- ((*i) == 0 ||
- (parm_table[*i].ptr != parm_table[(*i)-1].ptr))) {
- strcpy(label, parm_table[*i].label);
- parameter_string(parm_table[*i].type,
- parm_table[*i].ptr,
- value);
- (*i)++;
- return 1;
- }
- return 0;
- } else {
- service *pService = (snum==-1?&sDefault:pSERVICE(snum));
-
- for (;parm_table[*i].label;(*i)++)
- if (parm_table[*i].class == P_LOCAL &&
- parm_table[*i].ptr &&
- (*parm_table[*i].label != '-') &&
- ((*i) == 0 ||
- (parm_table[*i].ptr != parm_table[(*i)-1].ptr))) {
- int pdiff = PTR_DIFF(parm_table[*i].ptr,&sDefault);
-
- if (snum == -1 || allparameters ||
- !equal_parameter(parm_table[*i].type,
- ((char *)pService) + pdiff,
- ((char *)&sDefault) + pdiff)) {
- strcpy(label, parm_table[*i].label);
- parameter_string(parm_table[*i].type,
- ((char *)pService) + pdiff,
- value);
- (*i)++;
- return 1;
- }
- }
- }
-
- return 0;
-}
-
-
#if 0
/***************************************************************************
Display the contents of a single copy structure.
@@ -2108,7 +2006,7 @@ void lp_killunused(BOOL (*snumused)(int ))
{
int i;
for (i=0;i<iNumServices;i++)
- if (VALID(i) && (!snumused || !snumused(i)))
+ if (VALID(i) && !snumused(i))
{
iSERVICE(i).valid = False;
free_service(pSERVICE(i));
@@ -2171,13 +2069,13 @@ int lp_numservices(void)
/***************************************************************************
Display the contents of the services array in human-readable form.
***************************************************************************/
-void lp_dump(FILE *f)
+void lp_dump(void)
{
int iService;
- dump_globals(f);
+ dump_globals();
- dump_a_service(&sDefault, f);
+ dump_a_service(&sDefault);
for (iService = 0; iService < iNumServices; iService++)
{
@@ -2185,12 +2083,11 @@ void lp_dump(FILE *f)
{
if (iSERVICE(iService).szService[0] == '\0')
break;
- dump_a_service(pSERVICE(iService), f);
+ dump_a_service(pSERVICE(iService));
}
}
}
-
/***************************************************************************
Return the number of the service with the given name, or -1 if it doesn't
exist. Note that this is a DIFFERENT ANIMAL from the internal function
@@ -2268,38 +2165,6 @@ static void set_default_server_announce_type()
#endif
}
-
-/*******************************************************************
-rename a service
-********************************************************************/
-void lp_rename_service(int snum, char *new_name)
-{
- string_set(&pSERVICE(snum)->szService, new_name);
-}
-
-/*******************************************************************
-remove a service
-********************************************************************/
-void lp_remove_service(int snum)
-{
- pSERVICE(snum)->valid = False;
-}
-
-/*******************************************************************
-copy a service
-********************************************************************/
-void lp_copy_service(int snum, char *new_name)
-{
- char *oldname = lp_servicename(snum);
- do_section(new_name);
- if (snum >= 0) {
- snum = lp_servicenumber(new_name);
- if (snum >= 0)
- lp_do_parameter(snum, "copy", oldname);
- }
-}
-
-
/*******************************************************************
Get the default server type we will announce as via nmbd.
********************************************************************/
@@ -2354,4 +2219,3 @@ int lp_minor_announce_version(void)
minor_version = atoi(p);
return minor_version;
}
-
diff --git a/source/param/params.c b/source/param/params.c
index 8c41eef789f..0fdde0348ff 100644
--- a/source/param/params.c
+++ b/source/param/params.c
@@ -1,567 +1,326 @@
-/* -------------------------------------------------------------------------- **
- * Microsoft Network Services for Unix, AKA., Andrew Tridgell's SAMBA.
- *
- * This module Copyright (C) 1990, 1991, 1992, 1993, 1994 Karl Auer
- *
- * Rewritten almost completely by Christopher R. Hertel
- * at the University of Minnesota, September, 1997.
- * This module Copyright (C) 1997 by the University of Minnesota
- * -------------------------------------------------------------------------- **
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * -------------------------------------------------------------------------- **
- *
- * Module name: params
- *
- * -------------------------------------------------------------------------- **
- *
- * This module performs lexical analysis and initial parsing of a
- * Windows-like parameter file. It recognizes and handles four token
- * types: section-name, parameter-name, parameter-value, and
- * end-of-file. Comments and line continuation are handled
- * internally.
- *
- * The entry point to the module is function pm_process(). This
- * function opens the source file, calls the Parse() function to parse
- * the input, and then closes the file when either the EOF is reached
- * or a fatal error is encountered.
- *
- * A sample parameter file might look like this:
- *
- * [section one]
- * parameter one = value string
- * parameter two = another value
- * [section two]
- * new parameter = some value or t'other
- *
- * The parameter file is divided into sections by section headers:
- * section names enclosed in square brackets (eg. [section one]).
- * Each section contains parameter lines, each of which consist of a
- * parameter name and value delimited by an equal sign. Roughly, the
- * syntax is:
- *
- * <file> :== { <section> } EOF
- *
- * <section> :== <section header> { <parameter line> }
- *
- * <section header> :== '[' NAME ']'
- *
- * <parameter line> :== NAME '=' VALUE '\n'
- *
- * Blank lines and comment lines are ignored. Comment lines are lines
- * beginning with either a semicolon (';') or a pound sign ('#').
- *
- * All whitespace in section names and parameter names is compressed
- * to single spaces. Leading and trailing whitespace is stipped from
- * both names and values.
- *
- * Only the first equals sign in a parameter line is significant.
- * Parameter values may contain equals signs, square brackets and
- * semicolons. Internal whitespace is retained in parameter values,
- * with the exception of the '\r' character, which is stripped for
- * historic reasons. Parameter names may not start with a left square
- * bracket, an equal sign, a pound sign, or a semicolon, because these
- * are used to identify other tokens.
- *
- * -------------------------------------------------------------------------- **
- */
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Parameter loading utlities
+ Copyright (C) Karl Auer 1993,1994,1997
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/**************************************************************************
+PARAMS.C
+
+Copyright (C) 1990, 1991, 1992, 1993, 1994 Karl Auer
+
+This module provides for streamlines retrieval of information from a
+Windows-like parameter files. There is a function which will search for
+all sections in the file and call a specified function with each. There is
+a similar function which will call a specified function for all parameters
+in a section. The idea is that you pass the addresses of suitable functions
+to a single function in this module which will then enumerate all sections,
+and within each section all parameters, to your program.
+
+Parameter files contain text lines (newline delimited) which consist of
+either a section name in square brackets or a parameter name, delimited
+from the parameter value by an equals sign. Blank lines or lines where the
+first non-whitespace character is a colon are ignored. All whitespace in
+section names and parameter names is compressed to single spaces. Leading
+and trailing whitespace on parameter names and parameter values is stripped.
+
+Only the first equals sign in a parameter line is significant - parameter
+values may contain equals signs, square brackets and semicolons. Internal
+whitespace is retained in parameter values. Parameter names may not start
+with a square bracket, an equals sign or a semicolon, for obvious reasons.
+
+A sample parameter file might look like this:
+
+[things]
+this=1
+that=2
+[other things]
+the other = 3
+
+**************************************************************************/
#include "includes.h"
-/* -------------------------------------------------------------------------- **
- * Constants...
- */
-
-#define BUFR_INC 1024
-
-
-/* -------------------------------------------------------------------------- **
- * Variables...
- *
- * DEBUGLEVEL - The ubiquitous DEBUGLEVEL. This determines which DEBUG()
- * messages will be produced.
- * bufr - pointer to a global buffer. This is probably a kludge,
- * but it was the nicest kludge I could think of (for now).
- * bSize - The size of the global buffer <bufr>.
- */
+#include "smb.h"
+/* local variable pointing to passed filename */
+static char *pszParmFile = NULL;
extern int DEBUGLEVEL;
-static char *bufr = NULL;
-static int bSize = 0;
-
-/* -------------------------------------------------------------------------- **
- * Functions...
- */
-
-static int EatWhitespace( FILE *InFile )
- /* ------------------------------------------------------------------------ **
- * Scan past whitespace (see ctype(3C)) and return the first non-whitespace
- * character, or newline, or EOF.
- *
- * Input: InFile - Input source.
- *
- * Output: The next non-whitespace character in the input stream.
- *
- * Notes: Because the config files use a line-oriented grammar, we
- * explicitly exclude the newline character from the list of
- * whitespace characters.
- * - Note that both EOF (-1) and the nul character ('\0') are
- * considered end-of-file markers.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
-
- for( c = getc( InFile ); isspace( c ) && ('\n' != c); c = getc( InFile ) )
- ;
- return( c );
- } /* EatWhitespace */
-
-static int EatComment( FILE *InFile )
- /* ------------------------------------------------------------------------ **
- * Scan to the end of a comment.
- *
- * Input: InFile - Input source.
- *
- * Output: The character that marks the end of the comment. Normally,
- * this will be a newline, but it *might* be an EOF.
- *
- * Notes: Because the config files use a line-oriented grammar, we
- * explicitly exclude the newline character from the list of
- * whitespace characters.
- * - Note that both EOF (-1) and the nul character ('\0') are
- * considered end-of-file markers.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
-
- for( c = getc( InFile ); ('\n'!=c) && (EOF!=c) && (c>0); c = getc( InFile ) )
- ;
- return( c );
- } /* EatComment */
-
-static int Continuation( char *line, int pos )
- /* ------------------------------------------------------------------------ **
- * Scan backards within a string to discover if the last non-whitespace
- * character is a line-continuation character ('\\').
- *
- * Input: line - A pointer to a buffer containing the string to be
- * scanned.
- * pos - This is taken to be the offset of the end of the
- * string. This position is *not* scanned.
- *
- * Output: The offset of the '\\' character if it was found, or -1 to
- * indicate that it was not.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- pos--;
- while( (pos >= 0) && isspace(line[pos]) )
- pos--;
-
- return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
- } /* Continuation */
-
-
-static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
- /* ------------------------------------------------------------------------ **
- * Scan a section name, and pass the name to function sfunc().
- *
- * Input: InFile - Input source.
- * sfunc - Pointer to the function to be called if the section
- * name is successfully read.
- *
- * Output: True if the section name was read and True was returned from
- * <sfunc>. False if <sfunc> failed or if a lexical error was
- * encountered.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
- int i;
- int end;
- char *func = "params.c:Section() -";
-
- i = 0; /* <i> is the offset of the next free byte in bufr[] and */
- end = 0; /* <end> is the current "end of string" offset. In most */
- /* cases these will be the same, but if the last */
- /* character written to bufr[] is a space, then <end> */
- /* will be one less than <i>. */
-
- c = EatWhitespace( InFile ); /* We've already got the '['. Scan */
- /* past initial white space. */
-
- while( (EOF != c) && (c > 0) )
- {
-
- /* Check that the buffer is big enough for the next character. */
- if( i > (bSize - 2) )
- {
- bSize += BUFR_INC;
- bufr = Realloc( bufr, bSize );
- if( NULL == bufr )
- {
- DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( False );
- }
- }
- /* Handle a single character. */
- switch( c )
+/**************************************************************************
+Strip all leading whitespace from a string.
+**************************************************************************/
+static void trimleft(char *psz)
+{
+ char *pszDest;
+
+ pszDest = psz;
+ if (psz != NULL)
+ {
+ while (*psz != '\0' && isspace(*psz))
+ psz++;
+ while (*psz != '\0')
+ *pszDest++ = *psz++;
+ *pszDest = '\0';
+ }
+}
+
+/**************************************************************************
+Strip all trailing whitespace from a string.
+**************************************************************************/
+static void trimright(char *psz)
+{
+ char *pszTemp;
+
+ if (psz != NULL && psz[0] != '\0')
+ {
+ pszTemp = psz + strlen(psz) - 1;
+ while (isspace(*pszTemp))
+ *pszTemp-- = '\0';
+ }
+}
+
+/***********************************************************************
+Collapse each whitespace area in a string to a single space.
+***********************************************************************/
+static void collapse_spaces(char *psz)
+{
+ while (*psz)
+ if (isspace(*psz))
{
- case ']': /* Found the closing bracket. */
- bufr[end] = '\0';
- if( 0 == end ) /* Don't allow an empty name. */
- {
- DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
- return( False );
- }
- if( !sfunc( bufr ) ) /* Got a valid name. Deal with it. */
- return( False );
- (void)EatComment( InFile ); /* Finish off the line. */
- return( True );
-
- case '\n': /* Got newline before closing ']'. */
- i = Continuation( bufr, i ); /* Check for line continuation. */
- if( i < 0 )
- {
- bufr[end] = '\0';
- DEBUG(0, ("%s Badly formed line in configuration file: %s\n",
- func, bufr ));
- return( False );
- }
- end = ( (i > 0) && (' ' == bufr[i - 1]) ) ? (i - 1) : (i);
- c = getc( InFile ); /* Continue with next line. */
- break;
-
- default: /* All else are a valid name chars. */
- if( isspace( c ) ) /* One space per whitespace region. */
- {
- bufr[end] = ' ';
- i = end + 1;
- c = EatWhitespace( InFile );
- }
- else /* All others copy verbatim. */
- {
- bufr[i++] = c;
- end = i;
- c = getc( InFile );
- }
+ *psz++ = ' ';
+ trimleft(psz);
}
- }
-
- /* We arrive here if we've met the EOF before the closing bracket. */
- DEBUG(0, ("%s Unexpected EOF in the configuration file: %s\n", func, bufr ));
- return( False );
- } /* Section */
-
-static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
- /* ------------------------------------------------------------------------ **
- * Scan a parameter name and value, and pass these two fields to pfunc().
- *
- * Input: InFile - The input source.
- * pfunc - A pointer to the function that will be called to
- * process the parameter, once it has been scanned.
- * c - The first character of the parameter name, which
- * would have been read by Parse(). Unlike a comment
- * line or a section header, there is no lead-in
- * character that can be discarded.
- *
- * Output: True if the parameter name and value were scanned and processed
- * successfully, else False.
- *
- * Notes: This function is in two parts. The first loop scans the
- * parameter name. Internal whitespace is compressed, and an
- * equal sign (=) terminates the token. Leading and trailing
- * whitespace is discarded. The second loop scans the parameter
- * value. When both have been successfully identified, they are
- * passed to pfunc() for processing.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int i = 0; /* Position within bufr. */
- int end = 0; /* bufr[end] is current end-of-string. */
- int vstart = 0; /* Starting position of the parameter value. */
- char *func = "params.c:Parameter() -";
-
- /* Read the parameter name. */
- while( 0 == vstart ) /* Loop until we've found the start of the value. */
- {
-
- if( i > (bSize - 2) ) /* Ensure there's space for next char. */
+ else
+ psz++;
+}
+
+/**************************************************************************
+Return the value of the first non-white character in the specified string.
+The terminating NUL counts as non-white for the purposes of this function.
+Note - no check for a NULL string! What would we return?
+**************************************************************************/
+static int firstnonwhite(char *psz)
+{
+ while (isspace(*psz) && (*psz != '\0'))
+ psz++;
+ return (*psz);
+}
+
+
+/**************************************************************************
+Identifies all parameters in the current section, calls the parameter
+function for each. Ignores comment lines, stops and backs up in file when
+a section is encountered. Returns True on success, False on error.
+**************************************************************************/
+static BOOL enumerate_parameters(FILE *fileIn, BOOL (*pfunc)(char *,char *))
+{
+ pstring szBuf;
+ char *pszTemp;
+ BOOL bRetval;
+ long lFileOffset;
+ int cTemp;
+ BOOL bParmFound;
+
+ bRetval = False;
+ bParmFound = False;
+ while (True)
+ {
+ /* first remember where we are */
+ if ((lFileOffset = ftell(fileIn)) >= 0L)
{
- bSize += BUFR_INC;
- bufr = Realloc( bufr, bSize );
- if( NULL == bufr )
- {
- DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( False );
- }
+ /* then get and check a line */
+ if (fgets_slash(szBuf, sizeof(szBuf)-1, fileIn) == NULL)
+ {
+ /* stop - return OK unless file error */
+ bRetval = !ferror(fileIn);
+ if (!bRetval)
+ DEBUG(0,( "Read error on configuration file (enumerating parameters)!\n"));
+ break;
+ }
+ else
+ /* if first non-white is a '[', stop (new section) */
+ if ((cTemp = firstnonwhite(szBuf)) == '[')
+ {
+ /* restore position to start of new section */
+ if (fseek(fileIn, lFileOffset, SEEK_SET) < 0L)
+ {
+ DEBUG(0,( "Seek error on configuration file!\n"));
+ break;
+ }
+
+ /* return success */
+ bRetval = True;
+ break;
+ }
+ else
+ /* if it's a semicolon or line is blank, ignore the line */
+ if (!cTemp || strchr(";#",cTemp))
+ {
+ continue;
+ }
+ else
+ /* if no equals sign and line contains non-whitespace */
+ /* then line is badly formed */
+ if ((pszTemp = strchr(szBuf, '=')) == NULL)
+ {
+ DEBUG(0,( "Ignoring badly formed line: %s", szBuf));
+ }
+ else
+ {
+ /* Note that we have found a parameter */
+ bParmFound = True;
+ /* cut line at the equals sign */
+ *pszTemp++ = '\0';
+ /* trim leading and trailing space from both halves */
+ trimright(szBuf);
+ trimleft(szBuf);
+ trimright(pszTemp);
+ trimleft(pszTemp);
+ /* process the parameter iff passed pointer not NULL */
+ if (pfunc != NULL)
+ if (!pfunc(szBuf, pszTemp))
+ break;
+ }
}
-
- switch( c )
- {
- case '=': /* Equal sign marks end of param name. */
- if( 0 == end ) /* Don't allow an empty name. */
- {
- DEBUG(0, ("%s Invalid parameter name in config. file.\n", func ));
- return( False );
- }
- bufr[end++] = '\0'; /* Mark end of string & advance. */
- i = end; /* New string starts here. */
- vstart = end; /* New string is parameter value. */
- bufr[i] = '\0'; /* New string is nul, for now. */
- break;
-
- case '\n': /* Find continuation char, else error. */
- i = Continuation( bufr, i );
- if( i < 0 )
- {
- bufr[end] = '\0';
- DEBUG(1,("%s Ignoring badly formed line in configuration file: %s\n",
- func, bufr ));
- return( True );
- }
- end = ( (i > 0) && (' ' == bufr[i - 1]) ) ? (i - 1) : (i);
- c = getc( InFile ); /* Read past eoln. */
- break;
-
- case '\0': /* Shouldn't have EOF within param name. */
- case EOF:
- bufr[i] = '\0';
- DEBUG(1,("%s Unexpected end-of-file at: %s\n", func, bufr ));
- return( True );
-
- default:
- if( isspace( c ) ) /* One ' ' per whitespace region. */
- {
- bufr[end] = ' ';
- i = end + 1;
- c = EatWhitespace( InFile );
- }
- else /* All others verbatim. */
- {
- bufr[i++] = c;
- end = i;
- c = getc( InFile );
- }
- }
- }
-
- /* Now parse the value. */
- c = EatWhitespace( InFile ); /* Again, trim leading whitespace. */
- while( (EOF !=c) && (c > 0) )
- {
-
- if( i > (bSize - 2) ) /* Make sure there's enough room. */
+ }
+ return (bRetval);
+}
+
+
+/***********************************************************************
+Close up s by n chars, at offset start.
+***********************************************************************/
+static void closestr(char *s, int start, int n)
+{
+ char *src;
+ char *dest;
+ int len;
+
+ if (n > 0)
+ if ((src = dest = s) != NULL)
{
- bSize += BUFR_INC;
- bufr = Realloc( bufr, bSize );
- if( NULL == bufr )
- {
- DEBUG(0, ("%s Memory re-allocation failure.", func) );
- return( False );
- }
+ len = strlen(s);
+ if (start >= 0 && start < len - n)
+ {
+ src += start + n;
+ dest += start;
+
+ while (*src)
+ *dest++ = *src++;
+ *dest = '\0';
+ }
}
-
- switch( c )
+}
+
+/**************************************************************************
+Identifies all sections in the parameter file, calls passed section_func()
+for each, passing the section name, then calls enumerate_parameters().
+Returns True on success, False on failure. Note that the section and
+parameter names will have all internal whitespace areas collapsed to a
+single space for processing.
+**************************************************************************/
+static BOOL enumerate_sections(FILE *fileIn,
+ BOOL (*sfunc)(char *),BOOL (*pfunc)(char *,char *))
+{
+ pstring szBuf;
+ BOOL bRetval;
+ BOOL bSectionFound;
+
+ /* this makes sure we get include lines right */
+ enumerate_parameters(fileIn, pfunc);
+
+ bRetval = False;
+ bSectionFound = False;
+ while (True)
+ {
+ if (fgets_slash(szBuf, sizeof(szBuf)-1, fileIn) == NULL)
{
- case '\r': /* Explicitly remove '\r' because the older */
- c = getc( InFile ); /* version called fgets_slash() which also */
- break; /* removes them. */
-
- case '\n': /* Marks end of value unless there's a '\'. */
- i = Continuation( bufr, i );
- if( i < 0 )
- c = 0;
- else
- {
- for( end = i; (end >= 0) && isspace(bufr[end]); end-- )
- ;
- c = getc( InFile );
- }
- break;
-
- default: /* All others verbatim. Note that spaces do */
- bufr[i++] = c; /* not advance <end>. This allows trimming */
- if( !isspace( c ) ) /* of whitespace at the end of the line. */
- end = i;
- c = getc( InFile );
- break;
+ /* stop - return OK unless file error */
+ bRetval = !ferror(fileIn);
+ if (!bRetval)
+ DEBUG(0,( "Read error on configuration file (enumerating sections)!\n"));
+ break;
}
- }
- bufr[end] = '\0'; /* End of value. */
-
- return( pfunc( bufr, &bufr[vstart] ) ); /* Pass name & value to pfunc(). */
- } /* Parameter */
-
-static BOOL Parse( FILE *InFile,
- BOOL (*sfunc)(char *),
- BOOL (*pfunc)(char *, char *) )
- /* ------------------------------------------------------------------------ **
- * Scan & parse the input.
- *
- * Input: InFile - Input source.
- * sfunc - Function to be called when a section name is scanned.
- * See Section().
- * pfunc - Function to be called when a parameter is scanned.
- * See Parameter().
- *
- * Output: True if the file was successfully scanned, else False.
- *
- * Notes: The input can be viewed in terms of 'lines'. There are four
- * types of lines:
- * Blank - May contain whitespace, otherwise empty.
- * Comment - First non-whitespace character is a ';' or '#'.
- * The remainder of the line is ignored.
- * Section - First non-whitespace character is a '['.
- * Parameter - The default case.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int c;
- char *func = "params.c:Parse() -";
-
- c = EatWhitespace( InFile );
- while( (EOF != c) && (c > 0) )
- {
- switch( c )
+ else
{
- case '\n': /* Blank line. */
- c = EatWhitespace( InFile );
- break;
-
- case ';': /* Comment line. */
- case '#':
- c = EatComment( InFile );
- break;
-
- case '[': /* Section Header. */
- if( !Section( InFile, sfunc ) )
- return( False );
- c = EatWhitespace( InFile );
- break;
-
- case '\\': /* Bogus backslash. */
- c = EatWhitespace( InFile );
- break;
-
- default: /* Parameter line. */
- if( !Parameter( InFile, pfunc, c ) )
- return( False );
- c = EatWhitespace( InFile );
- break;
+ trimleft(szBuf);
+ trimright(szBuf);
+ if (szBuf[0] == '[')
+ {
+ closestr(szBuf, 0, 1);
+ if (strlen(szBuf) > 1)
+ if (szBuf[strlen(szBuf) - 1] == ']')
+ {
+ /* found a section - note the fact */
+ bSectionFound = True;
+ /* remove trailing metabracket */
+ szBuf[strlen(szBuf) - 1] = '\0';
+ /* remove leading and trailing whitespace from name */
+ trimleft(szBuf);
+ trimright(szBuf);
+ /* reduce all internal whitespace to one space */
+ collapse_spaces(szBuf);
+ /* process it - stop if the processing fails */
+ if (sfunc != NULL)
+ if (!sfunc(szBuf))
+ break;
+ if (!enumerate_parameters(fileIn, pfunc))
+ break;
+ }
+ }
}
- }
- return( True );
- } /* Parse */
-
-static FILE *OpenConfFile( char *FileName )
- /* ------------------------------------------------------------------------ **
- * Open a configuration file.
- *
- * Input: FileName - The pathname of the config file to be opened.
- *
- * Output: A pointer of type (FILE *) to the opened file, or NULL if the
- * file could not be opened.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- FILE *OpenedFile;
- char *func = "params.c:OpenConfFile() -";
-
- if( NULL == FileName || 0 == *FileName )
- {
- DEBUG( 0, ("%s No configuration filename specified.\n", func) );
- return( NULL );
- }
-
- OpenedFile = fopen( FileName, "r" );
- if( NULL == OpenedFile )
- {
- DEBUG( 0,
- ("%s Unable to open configuration file \"%s\":\n\t%s\n",
- func, FileName, strerror(errno)) );
- }
-
- return( OpenedFile );
- } /* OpenConfFile */
-
-BOOL pm_process( char *FileName,
- BOOL (*sfunc)(char *),
- BOOL (*pfunc)(char *, char *) )
- /* ------------------------------------------------------------------------ **
- * Process the named parameter file.
- *
- * Input: FileName - The pathname of the parameter file to be opened.
- * sfunc - A pointer to a function that will be called when
- * a section name is discovered.
- * pfunc - A pointer to a function that will be called when
- * a parameter name and value are discovered.
- *
- * Output: TRUE if the file was successfully parsed, else FALSE.
- *
- * ------------------------------------------------------------------------ **
- */
- {
- int result;
- FILE *InFile;
- char *func = "params.c:pm_process() -";
-
- InFile = OpenConfFile( FileName ); /* Open the config file. */
- if( NULL == InFile )
- return( False );
-
- DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) );
-
- if( NULL != bufr ) /* If we already have a buffer */
- result = Parse( InFile, sfunc, pfunc ); /* (recursive call), then just */
- /* use it. */
-
- else /* If we don't have a buffer */
- { /* allocate one, then parse, */
- bSize = BUFR_INC; /* then free. */
- bufr = (char *)malloc( bSize );
- if( NULL == bufr )
+ }
+
+ return (bRetval);
+}
+
+/**************************************************************************
+Process the passed parameter file.
+
+Returns True if successful, else False.
+**************************************************************************/
+BOOL pm_process(char *pszFileName,BOOL (*sfunc)(char *),BOOL (*pfunc)(char *,char *))
+{
+ FILE *fileIn;
+ BOOL bRetval;
+
+ bRetval = False;
+
+ /* record the filename for use in error messages one day... */
+ pszParmFile = pszFileName;
+
+ if (pszParmFile == NULL || strlen(pszParmFile) < 1)
+ DEBUG(0,( "No configuration filename specified!\n"));
+ else
+ if ((fileIn = fopen(pszParmFile, "r")) == NULL)
+ DEBUG(0,( "Unable to open configuration file \"%s\"!\n", pszParmFile));
+ else
{
- DEBUG(0,("%s memory allocation failure.\n", func));
- return( False );
+ DEBUG(3,("Processing configuration file \"%s\"\n", pszParmFile));
+ bRetval = enumerate_sections(fileIn, sfunc, pfunc);
+ fclose(fileIn);
}
- result = Parse( InFile, sfunc, pfunc );
- free( bufr );
- bufr = NULL;
- bSize = 0;
- }
-
- if( !result ) /* Generic failure. */
- {
- DEBUG(0,("%s Failed. Error returned from params.c:parse().\n", func));
- return( False );
- }
-
- return( True ); /* Generic success. */
- } /* pm_process */
-
-/* -------------------------------------------------------------------------- */
+
+ if (!bRetval)
+ DEBUG(0,("pm_process retuned false\n"));
+ return (bRetval);
+}
+
+
diff --git a/source/passdb/smbpass.c b/source/passdb/smbpass.c
index 441ab94ffbb..a31a10cef4b 100644
--- a/source/passdb/smbpass.c
+++ b/source/passdb/smbpass.c
@@ -1,3 +1,4 @@
+#ifdef SMB_PASSWD
/*
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
* Copyright (C) Andrew Tridgell 1992-1997 Modified by Jeremy Allison 1995.
@@ -291,3 +292,8 @@ struct smb_passwd *get_smbpwnam(char *name)
pw_file_unlock(lockfd);
return NULL;
}
+#else
+ void smbpass_dummy(void)
+{
+} /* To avoid compiler complaints */
+#endif
diff --git a/source/script/installcp.sh b/source/script/installcp.sh
deleted file mode 100755
index bafd84146d7..00000000000
--- a/source/script/installcp.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-LIBDIR=$1
-CODEPAGEDIR=$2
-BINDIR=$3
-
-shift
-shift
-shift
-
-echo Installing codepage files in $CODEPAGEDIR
-for d in $LIBDIR $CODEPAGEDIR; do
-if [ ! -d $d ]; then
-mkdir $d
-if [ ! -d $d ]; then
- echo Failed to make directory $d
- exit 1
-fi
-fi
-done
-
-for p in $*; do
- echo Creating codepage file $CODEPAGEDIR/codepage.$p from codepage_def.$p
- $BINDIR/make_smbcodepage c $p codepage_def.$p $CODEPAGEDIR/codepage.$p
-done
-
-
-cat << EOF
-======================================================================
-The code pages have been installed. You may uninstall them using the command
-the command "make uninstallcp" or make "uninstall" to uninstall binaries,
-man pages, shell scripts and code pages.
-======================================================================
-EOF
-
-exit 0
-
diff --git a/source/script/mkproto.awk b/source/script/mkproto.awk
index 1ccf2fb2b0a..f2b76f20c97 100644
--- a/source/script/mkproto.awk
+++ b/source/script/mkproto.awk
@@ -64,7 +64,7 @@ BEGIN {
next;
}
-!/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|arc4_key/ {
+!/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types/ {
next;
}
diff --git a/source/script/uninstallcp.sh b/source/script/uninstallcp.sh
deleted file mode 100755
index bd7013c358f..00000000000
--- a/source/script/uninstallcp.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-CPDIR=$1
-shift
-
-if [ ! -d $CPDIR ]; then
- echo Directory $CPDIR does not exist!
- echo Do a "make installcp" or "make install" first.
- exit 1
-fi
-
-for p in $*; do
- if [ ! -f $CPDIR/codepage.$p ]; then
- echo $CPDIR/codepage.$p does not exist!
- else
- echo Removing $CPDIR/codepage.$p
- rm -f $CPDIR/codepage.$p
- if [ -f $CPDIR/codepage.$p ]; then
- echo Cannot remove $CPDIR/codepage.$p... does $USER have privileges?
- fi
- fi
-done
-
-cat << EOF
-======================================================================
-The code pages have been uninstalled. You may reinstall them using
-the command "make installcp" or "make install" to install binaries,
-man pages, shell scripts and code pages. You may recover a previous version
-(if any with "make revert").
-======================================================================
-EOF
-
-exit 0
diff --git a/source/smbd/dir.c b/source/smbd/dir.c
index 316b58818fd..567bc14424e 100644
--- a/source/smbd/dir.c
+++ b/source/smbd/dir.c
@@ -470,12 +470,12 @@ BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mo
if (isrootdir && (strequal(filename,"..") || strequal(filename,".")))
continue;
- pstrcpy(fname,filename);
+ strcpy(fname,filename);
*path = 0;
- pstrcpy(path,Connections[cnum].dirpath);
+ strcpy(path,Connections[cnum].dirpath);
if(needslash)
strcat(path,"/");
- pstrcpy(pathreal,path);
+ strcpy(pathreal,path);
strcat(path,fname);
strcat(pathreal,dname);
if (sys_stat(pathreal,&sbuf) != 0)
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index b9355c4ec07..c63a54c2ac2 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -440,7 +440,7 @@ static void PackDriverData(struct pack_desc* desc)
}
static int check_printq_info(struct pack_desc* desc,
- int uLevel, char *id1, char *id2)
+ int uLevel, char *id1, const char* id2)
{
desc->subformat = NULL;
switch( uLevel ) {
@@ -1074,7 +1074,7 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
*rparam_len = 8;
*rparam = REALLOC(*rparam,*rparam_len);
- SSVAL(*rparam,0,NERR_Success);
+ SSVAL(*rparam,0,(missed == 0 ? NERR_Success : ERROR_MORE_DATA));
SSVAL(*rparam,2,0);
SSVAL(*rparam,4,counted);
SSVAL(*rparam,6,counted+missed);
@@ -1601,13 +1601,14 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
name[l] = 0;
DEBUG(3,("Setting print name to %s\n",name));
+
+ become_root(1);
for (i=0;i<MAX_OPEN_FILES;i++)
if (Files[i].open && Files[i].print_file)
{
pstring wd;
GetWd(wd);
- unbecome_user();
if (!become_user(Files[i].cnum,vuid) ||
!become_service(Files[i].cnum,True))
@@ -1617,6 +1618,8 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
string_set(&Files[i].name,name);
break;
}
+
+ unbecome_root(1);
}
desc.errcode=NERR_Success;
@@ -2001,6 +2004,8 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
*rparam_len = 6;
*rparam = REALLOC(*rparam,*rparam_len);
+
+ DEBUG(4,("RNetUserGetInfo level=%d\n", uLevel));
/* check it's a supported variant */
if (strcmp(str1,"zWrLh") != 0) return False;
@@ -2219,7 +2224,6 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
int uLevel;
struct pack_desc desc;
char* name;
- char* logon_script;
uLevel = SVAL(p,0);
name = p + 2;
@@ -2262,14 +2266,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
PACKS(&desc,"z",mypath); /* computer */
}
PACKS(&desc,"z",myworkgroup);/* domain */
-
-/* JHT - By calling lp_logon_script() and standard_sub() we have */
-/* made sure all macros are fully substituted and available */
- logon_script = lp_logon_script();
- standard_sub( cnum, logon_script );
- PACKS(&desc,"z", logon_script); /* script path */
-/* End of JHT mods */
-
+ PACKS(&desc,"z",lp_logon_script()); /* script path */
PACKI(&desc,"D",0x00000000); /* reserved */
}
diff --git a/source/smbd/mangle.c b/source/smbd/mangle.c
index b0a45ffb47c..66e8233df28 100644
--- a/source/smbd/mangle.c
+++ b/source/smbd/mangle.c
@@ -123,34 +123,30 @@ BOOL is_8_3(char *fname, BOOL check_case)
{
char *p = fname;
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- dot_pos = 0;
- while (*p)
+#ifdef KANJI
+ dot_pos = 0;
+ while (*p)
{
- if (is_shift_jis (*p))
- p += 2;
- else if (is_kana (*p))
- p ++;
- else
- {
- if (*p == '.' && !dot_pos)
- dot_pos = (char *) p;
- if (!isdoschar(*p))
- return(False);
- p++;
- }
- }
- }
- else
- {
- while (*p)
+ if (is_shift_jis (*p)) {
+ p += 2;
+ } else if (is_kana (*p)) {
+ p ++;
+ } else {
+ if (*p == '.' && !dot_pos)
+ dot_pos = (char *) p;
+ if (!isdoschar(*p))
+ return(False);
+ p++;
+ }
+ }
+#else
+ while (*p)
{
- if (!isdoschar(*p))
- return(False);
- p++;
+ if (!isdoschar(*p))
+ return(False);
+ p++;
}
- }
+#endif /* KANJI */
}
/* no dot and less than 9 means OK */
@@ -502,90 +498,84 @@ void mangle_name_83(char *s)
DEBUG(5,("Mangling name %s to ",s));
if (p)
- {
- if (p == s)
- strcpy(extension,"___");
- else
+ {
+ if (p == s)
+ strcpy(extension,"___");
+ else
{
*p++ = 0;
while (*p && extlen < 3)
- {
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- if (is_shift_jis (*p))
- {
- if (extlen < 2)
- {
- extension[extlen++] = p[0];
- extension[extlen++] = p[1];
- }
- else
- {
- extension[extlen++] = base36 (((unsigned char) *p) % 36);
- }
- p += 2;
- }
- else if (is_kana (*p))
- {
- extension[extlen++] = p[0];
- p++;
- }
- else
- {
- if (isdoschar (*p) && *p != '.')
- extension[extlen++] = p[0];
- p++;
- }
- }
- else
- {
- if (isdoschar(*p) && *p != '.')
- extension[extlen++] = *p;
- p++;
- }
- }
+ {
+#ifdef KANJI
+ if (is_shift_jis (*p))
+ {
+ if (extlen < 2)
+ {
+ extension[extlen++] = p[0];
+ extension[extlen++] = p[1];
+ }
+ else
+ {
+ extension[extlen++] = base36 (((unsigned char) *p) % 36);
+ }
+ p += 2;
+ }
+ else if (is_kana (*p))
+ {
+ extension[extlen++] = p[0];
+ p++;
+ }
+ else
+ {
+ if (isdoschar (*p) && *p != '.')
+ extension[extlen++] = p[0];
+ p++;
+ }
+#else
+ if (isdoschar(*p) && *p != '.')
+ extension[extlen++] = *p;
+ p++;
+#endif /* KANJI */
+ }
extension[extlen] = 0;
+ }
}
- }
p = s;
while (*p && baselen < 5)
- {
- if(lp_client_code_page() == KANJI_CODEPAGE)
{
+#ifdef KANJI
if (is_shift_jis (*p))
- {
- if (baselen < 4)
- {
- base[baselen++] = p[0];
- base[baselen++] = p[1];
- }
- else
- {
+ {
+ if (baselen < 4)
+ {
+ base[baselen++] = p[0];
+ base[baselen++] = p[1];
+ }
+ else
+ {
base[baselen++] = base36 (((unsigned char) *p) % 36);
- }
- p += 2;
- }
+ }
+ p += 2;
+ }
else if (is_kana (*p))
- {
- base[baselen++] = p[0];
- p++;
- }
+ {
+ base[baselen++] = p[0];
+ p++;
+ }
else
- {
- if (isdoschar (*p) && *p != '.')
- base[baselen++] = p[0];
- p++;
- }
- }
- else
- {
+ {
+ if (isdoschar (*p) && *p != '.')
+ base[baselen++] = p[0];
+ p++;
+ }
+#else
if (isdoschar(*p) && *p != '.')
- base[baselen++] = *p;
+ base[baselen++] = *p;
p++;
+#endif /* KANJI */
}
- }
base[baselen] = 0;
csum = csum % (36*36);
@@ -611,9 +601,8 @@ static BOOL illegal_name(char *name)
static BOOL initialised=False;
unsigned char *s;
- if (!initialised)
- {
- char *ill = "*\\/?<>|\":{}";
+ if (!initialised) {
+ char *ill = "*\\/?<>|\":";
initialised = True;
bzero((char *)illegal,256);
@@ -621,23 +610,21 @@ static BOOL illegal_name(char *name)
illegal[*s] = True;
}
- if(lp_client_code_page() == KANJI_CODEPAGE)
- {
- for (s = (unsigned char *)name; *s;) {
- if (is_shift_jis (*s)) {
- s += 2;
- } else if (illegal[*s]) {
- return(True);
- } else {
- s++;
- }
+#ifdef KANJI
+ for (s = (unsigned char *)name; *s;) {
+ if (is_shift_jis (*s)) {
+ s += 2;
+ } else if (illegal[*s]) {
+ return(True);
+ } else {
+ s++;
}
}
- else
- {
- for (s = (unsigned char *)name;*s;s++)
- if (illegal[*s]) return(True);
- }
+#else
+ for (s = (unsigned char *)name;*s;s++)
+ if (illegal[*s]) return(True);
+#endif
+
return(False);
}
diff --git a/source/smbd/password.c b/source/smbd/password.c
index f4d94791cf3..0d9db08dd98 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -36,6 +36,7 @@ static char this_user[100]="";
static char this_salt[100]="";
static char this_crypted[100]="";
+#ifdef SMB_PASSWD
/* Data to do lanman1/2 password challenge. */
static unsigned char saved_challenge[8];
static BOOL challenge_sent=False;
@@ -45,24 +46,17 @@ Get the next challenge value - no repeats.
********************************************************************/
void generate_next_challenge(char *challenge)
{
- unsigned char buf[16];
- static int counter = 0;
- struct timeval tval;
- int v1,v2;
-
- /* get a sort-of random number */
- GetTimeOfDay(&tval);
- v1 = (counter++) + getpid() + tval.tv_sec;
- v2 = (counter++) * getpid() + tval.tv_usec;
- SIVAL(challenge,0,v1);
- SIVAL(challenge,4,v2);
-
- /* mash it up with md4 */
- mdfour(buf, (unsigned char *)challenge, 8);
-
- memcpy(saved_challenge, buf, 8);
- memcpy(challenge,buf,8);
- challenge_sent = True;
+ static int counter = 0;
+ struct timeval tval;
+ int v1,v2;
+ GetTimeOfDay(&tval);
+ v1 = (counter++) + getpid() + tval.tv_sec;
+ v2 = (counter++) * getpid() + tval.tv_usec;
+ SIVAL(challenge,0,v1);
+ SIVAL(challenge,4,v2);
+ E1((uchar *)challenge,(uchar *)"SAMBA",(uchar *)saved_challenge);
+ memcpy(challenge,saved_challenge,8);
+ challenge_sent = True;
}
/*******************************************************************
@@ -84,6 +78,7 @@ BOOL last_challenge(char *challenge)
memcpy(challenge,saved_challenge,8);
return(True);
}
+#endif
/* this holds info on user ids that are already validated for this VC */
static user_struct *validated_users = NULL;
@@ -406,36 +401,36 @@ static char *PAM_password;
* echo off means password.
*/
static int PAM_conv (int num_msg,
- struct pam_message **msg,
+ const struct pam_message **msg,
struct pam_response **resp,
void *appdata_ptr) {
- int count = 0, replies = 0;
+ int replies = 0;
struct pam_response *reply = NULL;
- int size = sizeof(struct pam_response);
- #define GET_MEM if (reply) realloc(reply, size); else reply = malloc(size); \
- if (!reply) return PAM_CONV_ERR; \
- size += sizeof(struct pam_response)
#define COPY_STRING(s) (s) ? strdup(s) : NULL
- for (count = 0; count < num_msg; count++) {
- switch (msg[count]->msg_style) {
+ reply = malloc(sizeof(struct pam_response) * num_msg);
+ if (!reply) return PAM_CONV_ERR;
+
+ for (replies = 0; replies < num_msg; replies++) {
+ switch (msg[replies]->msg_style) {
case PAM_PROMPT_ECHO_ON:
- GET_MEM;
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies++].resp = COPY_STRING(PAM_username);
+ reply[replies].resp = COPY_STRING(PAM_username);
/* PAM frees resp */
break;
case PAM_PROMPT_ECHO_OFF:
- GET_MEM;
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies++].resp = COPY_STRING(PAM_password);
+ reply[replies].resp = COPY_STRING(PAM_password);
/* PAM frees resp */
break;
case PAM_TEXT_INFO:
+ /* fall through */
+ case PAM_ERROR_MSG:
/* ignore it... */
+ reply[replies].resp_retcode = PAM_SUCCESS;
+ reply[replies].resp = NULL;
break;
- case PAM_ERROR_MSG:
default:
/* Must be an error of some sort... */
free (reply);
@@ -817,6 +812,7 @@ Hence we make a direct return to avoid a second chance!!!
#endif
}
+#ifdef SMB_PASSWD
/****************************************************************************
core of smb password checking routine.
****************************************************************************/
@@ -858,6 +854,7 @@ BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned cha
#endif
return (memcmp(p24, password, 24) == 0);
}
+#endif
/****************************************************************************
check if a username/password is OK
@@ -867,16 +864,21 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
pstring pass2;
int level = lp_passwordlevel();
struct passwd *pass;
+#ifdef SMB_PASSWD
char challenge[8];
struct smb_passwd *smb_pass;
BOOL challenge_done = False;
+#endif
if (password) password[pwlen] = 0;
+#ifdef SMB_PASSWD
if (pwlen == 24)
challenge_done = last_challenge(challenge);
+#endif
#if DEBUG_PASSWORD
+#ifdef SMB_PASSWD
if (challenge_done)
{
int i;
@@ -884,9 +886,10 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
for( i = 0; i < 24; i++)
DEBUG(100,("%0x ", (unsigned char)password[i]));
DEBUG(100,("]\n"));
- } else {
- DEBUG(100,("checking user=[%s] pass=[%s]\n",user,password));
}
+ else
+#endif
+ DEBUG(100,("checking user=[%s] pass=[%s]\n",user,password));
#endif
if (!password)
@@ -903,6 +906,8 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
else
pass = Get_Pwnam(user,True);
+#ifdef SMB_PASSWD
+
DEBUG(4,("SMB Password - pwlen = %d, challenge_done = %d\n", pwlen, challenge_done));
if((pwlen == 24) && challenge_done)
@@ -959,6 +964,7 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
DEBUG(3,("Error smb_password_check failed\n"));
}
+#endif
DEBUG(4,("Checking password for user %s (l=%d)\n",user,pwlen));
@@ -1501,207 +1507,146 @@ BOOL check_hosts_equiv(char *user)
return(False);
}
-
-int password_client = -1;
-static fstring pserver;
-static char *secserver_inbuf = NULL;
+static struct cli_state cli;
/****************************************************************************
-attempted support for server level security
+return the client state structure
****************************************************************************/
-BOOL server_cryptkey(char *buf)
+struct cli_state *server_client(void)
{
- pstring outbuf;
- fstring pass_protocol;
- extern fstring remote_machine;
- char *p;
- int len;
- fstring desthost;
- struct in_addr dest_ip;
- int port = SMB_PORT;
- BOOL ret;
-
- if(secserver_inbuf == NULL) {
- secserver_inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
- if(secserver_inbuf == NULL) {
- DEBUG(0,("server_cryptkey: malloc fail for input buffer.\n"));
- return False;
- }
- }
-
- if (password_client >= 0)
- close(password_client);
- password_client = -1;
-
- if (Protocol < PROTOCOL_NT1) {
- strcpy(pass_protocol,"LM1.2X002");
- } else {
- strcpy(pass_protocol,"NT LM 0.12");
- }
-
- bzero(secserver_inbuf,BUFFER_SIZE + SAFETY_MARGIN);
- bzero(outbuf,sizeof(outbuf));
-
- for (p=strtok(lp_passwordserver(),LIST_SEP); p ; p = strtok(NULL,LIST_SEP)) {
- strcpy(desthost,p);
- standard_sub_basic(desthost);
- strupper(desthost);
-
- dest_ip = *interpret_addr2(desthost);
- if (zero_ip(dest_ip)) {
- DEBUG(1,("Can't resolve address for %s\n",p));
- continue;
- }
-
- if (ismyip(dest_ip)) {
- DEBUG(1,("Password server loop - disabling password server %s\n",p));
- continue;
- }
-
- password_client = open_socket_out(SOCK_STREAM, &dest_ip, port, SHORT_CONNECT_TIMEOUT);
- if (password_client >= 0) {
- DEBUG(3,("connected to password server %s\n",p));
- StrnCpy(pserver,p,sizeof(pserver)-1);
- break;
- }
- }
-
- if (password_client < 0) {
- DEBUG(1,("password server not available\n"));
- return(False);
- }
-
-
- /* send a session request (RFC 8002) */
-
- /* put in the destination name */
- len = 4;
- p = outbuf+len;
- name_mangle(desthost,p,' ');
- len += name_len(p);
- p = outbuf+len;
-
- /* and my name */
- /* Fix from Frank Varnavas <varnavas@ny.ubs.com>.
- We cannot use the same name as the client to
- the NT password server, as NT will drop client
- connections if the same client name connects
- twice. Instead, synthesize a name from our pid.
- and the remote machine name.
- */
- {
- char buf2[32]; /* create name as PIDname */
- sprintf(buf2,"%d", getpid());
- strncpy(&buf2[strlen(buf2)], remote_machine, 31 - strlen(buf2));
- buf2[31] = '\0';
- DEBUG(1,("negprot w/password server as %s\n",buf2));
- name_mangle(buf2,p,' ');
- len += name_len(p);
- }
-
- _smb_setlen(outbuf,len);
- CVAL(outbuf,0) = 0x81;
-
- send_smb(password_client,outbuf);
-
-
- if (!receive_smb(password_client,secserver_inbuf,5000) ||
- CVAL(secserver_inbuf,0) != 0x82) {
- DEBUG(1,("%s rejected the session\n",pserver));
- close(password_client); password_client = -1;
- return(False);
- }
+ return &cli;
+}
- DEBUG(3,("got session\n"));
+/****************************************************************************
+support for server level security
+****************************************************************************/
+struct cli_state *server_cryptkey(void)
+{
+ fstring desthost;
+ struct in_addr dest_ip;
+ extern fstring local_machine;
+ char *p;
+
+ if (!cli_initialise(&cli))
+ return NULL;
+
+ for (p=strtok(lp_passwordserver(),LIST_SEP); p ; p = strtok(NULL,LIST_SEP)) {
+ fstrcpy(desthost,p);
+ standard_sub_basic(desthost);
+ strupper(desthost);
+
+ dest_ip = *interpret_addr2(desthost);
+ if (zero_ip(dest_ip)) {
+ DEBUG(1,("Can't resolve address for %s\n",p));
+ continue;
+ }
- bzero(outbuf,smb_size);
+ if (ismyip(dest_ip)) {
+ DEBUG(1,("Password server loop - disabling password server %s\n",p));
+ continue;
+ }
- /* setup the protocol string */
- set_message(outbuf,0,strlen(pass_protocol)+2,True);
- p = smb_buf(outbuf);
- *p++ = 2;
- strcpy(p,pass_protocol);
+ if (cli_connect(&cli, desthost, &dest_ip)) {
+ DEBUG(3,("connected to password server %s\n",p));
+ break;
+ }
+ }
- CVAL(outbuf,smb_com) = SMBnegprot;
- CVAL(outbuf,smb_flg) = 0x8;
- SSVAL(outbuf,smb_flg2,0x1);
+ if (!p) {
+ DEBUG(1,("password server not available\n"));
+ cli_shutdown(&cli);
+ return NULL;
+ }
- send_smb(password_client,outbuf);
- ret = receive_smb(password_client,secserver_inbuf,5000);
+ if (!cli_session_request(&cli, desthost, 0x20, local_machine)) {
+ DEBUG(1,("%s rejected the session\n",desthost));
+ cli_shutdown(&cli);
+ return NULL;
+ }
- if (!ret || CVAL(secserver_inbuf,smb_rcls) || SVAL(secserver_inbuf,smb_vwv0)) {
- DEBUG(1,("%s rejected the protocol\n",pserver));
- close(password_client); password_client= -1;
- return(False);
- }
+ DEBUG(3,("got session\n"));
- if (!(CVAL(secserver_inbuf,smb_vwv1) & 1)) {
- DEBUG(1,("%s isn't in user level security mode\n",pserver));
- close(password_client); password_client= -1;
- return(False);
- }
+ if (!cli_negprot(&cli)) {
+ DEBUG(1,("%s rejected the negprot\n",desthost));
+ cli_shutdown(&cli);
+ return NULL;
+ }
- memcpy(buf,secserver_inbuf,smb_len(secserver_inbuf)+4);
+ if (cli.protocol < PROTOCOL_LANMAN2 ||
+ !(cli.sec_mode & 1)) {
+ DEBUG(1,("%s isn't in user level security mode\n",desthost));
+ cli_shutdown(&cli);
+ return NULL;
+ }
- DEBUG(3,("password server OK\n"));
+ DEBUG(3,("password server OK\n"));
- return(True);
+ return &cli;
}
/****************************************************************************
-attempted support for server level security
+validate a password with the password server
****************************************************************************/
-BOOL server_validate(char *buf)
+BOOL server_validate(char *user, char *domain,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen)
{
- pstring outbuf;
- BOOL ret;
+ extern fstring local_machine;
+ fstring share;
- if(secserver_inbuf == NULL) {
- secserver_inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
- if(secserver_inbuf == NULL) {
- DEBUG(0,("server_validate: malloc fail for input buffer.\n"));
- return False;
- }
- }
+ if (!cli.initialised) {
+ DEBUG(1,("password server %s is not connected\n", cli.desthost));
+ return(False);
+ }
- if (password_client < 0) {
- DEBUG(1,("%s not connected\n",pserver));
- return(False);
- }
+ if (!cli_session_setup(&cli, user, pass, passlen, ntpass, ntpasslen, domain)) {
+ DEBUG(1,("password server %s rejected the password\n", cli.desthost));
+ return False;
+ }
- bzero(secserver_inbuf,BUFFER_SIZE + SAFETY_MARGIN);
- memcpy(outbuf,buf,sizeof(outbuf));
+ /* if logged in as guest then reject */
+ if ((SVAL(cli.inbuf,smb_vwv2) & 1) != 0) {
+ DEBUG(1,("password server %s gave us guest only\n", cli.desthost));
+ return(False);
+ }
- /* send a session setup command */
- CVAL(outbuf,smb_flg) = 0x8;
- SSVAL(outbuf,smb_flg2,0x1);
- CVAL(outbuf,smb_vwv0) = 0xFF;
- set_message(outbuf,smb_numwords(outbuf),smb_buflen(outbuf),False);
+ sprintf(share,"\\\\%s\\IPC$", cli.desthost);
- SCVAL(secserver_inbuf,smb_rcls,1);
+ if (!cli_send_tconX(&cli, share, "IPC", "", 1)) {
+ DEBUG(1,("password server %s refused IPC$ connect\n", cli.desthost));
+ return False;
+ }
- send_smb(password_client,outbuf);
- ret = receive_smb(password_client,secserver_inbuf,5000);
- if (!ret || CVAL(secserver_inbuf,smb_rcls) != 0) {
- DEBUG(1,("password server %s rejected the password\n",pserver));
- return(False);
- }
+ if (!cli_NetWkstaUserLogon(&cli,user,local_machine)) {
+ DEBUG(1,("password server %s failed NetWkstaUserLogon\n", cli.desthost));
+ cli_tdis(&cli);
+ return False;
+ }
- /* if logged in as guest then reject */
- if ((SVAL(secserver_inbuf,smb_vwv2) & 1) != 0) {
- DEBUG(1,("password server %s gave us guest only\n",pserver));
- return(False);
- }
+ if (cli.privilages == 0) {
+ DEBUG(1,("password server %s gave guest privilages\n", cli.desthost));
+ cli_tdis(&cli);
+ return False;
+ }
- DEBUG(3,("password server %s accepted the password\n",pserver));
+ if (!strequal(cli.eff_name, user)) {
+ DEBUG(1,("password server %s gave different username %s\n",
+ cli.desthost,
+ cli.eff_name));
+ cli_tdis(&cli);
+ return False;
+ }
-#if !KEEP_PASSWORD_SERVER_OPEN
- close(password_client); password_client= -1;
-#endif
+ DEBUG(3,("password server %s accepted the password\n", cli.desthost));
- return(True);
+ cli_tdis(&cli);
+
+ return(True);
}
+
+
+
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index a465e911459..2cc6eea506f 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -127,7 +127,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
unixmode = unix_mode(cnum,smb_attr);
open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode,
- 0, &rmode,&smb_action);
+ &rmode,&smb_action);
if (!Files[fnum].open)
{
@@ -141,7 +141,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
}
if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
- close_file(fnum);
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -149,7 +149,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
fmode = dos_mode(cnum,fname,&sbuf);
mtime = sbuf.st_mtime;
if (fmode & aDIR) {
- close_file(fnum);
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
diff --git a/source/smbd/predict.c b/source/smbd/predict.c
index 691d8fbb4e0..7d6b2498f5a 100644
--- a/source/smbd/predict.c
+++ b/source/smbd/predict.c
@@ -53,24 +53,37 @@ int read_predict(int fd,int offset,char *buf,char **ptr,int num)
offset >= rp_offset &&
possible>0 &&
smb_last_time-rp_time < rp_timeout)
- {
- ret = possible;
- if (buf)
- memcpy(buf,rp_buffer + (offset-rp_offset),possible);
- else
- *ptr = rp_buffer + (offset-rp_offset);
- DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
- }
+ {
+ ret = possible;
+ if (buf)
+ memcpy(buf,rp_buffer + (offset-rp_offset),possible);
+ else
+ *ptr = rp_buffer + (offset-rp_offset);
+ DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
+ }
if (ret == num) {
predict_skip = True;
} else {
- predict_skip = False;
+ struct stat rp_stat;
+
+ /* Find the end of the file - ensure we don't
+ read predict beyond it. */
+ if(fstat(fd,&rp_stat) < 0)
+ {
+ DEBUG(0,("read-prediction failed on fstat. Error was %s\n", strerror(errno)));
+ predict_skip = True;
+ }
+ else
+ {
+ predict_skip = False;
- /* prepare the next prediction */
- rp_predict_fd = fd;
- rp_predict_offset = offset + num;
- rp_predict_length = num;
+ /* prepare the next prediction */
+ rp_predict_fd = fd;
+ /* Make sure we don't seek beyond the end of the file. */
+ rp_predict_offset = MIN((offset + num),rp_stat.st_size);
+ rp_predict_length = num;
+ }
}
if (ret < 0) ret = 0;
diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c
index d4f746c9e36..2d238dfaf17 100644
--- a/source/smbd/quotas.c
+++ b/source/smbd/quotas.c
@@ -416,10 +416,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
return (True);
}
+
#else
#ifdef __FreeBSD__
#include <ufs/ufs/quota.h>
+#include <machine/param.h>
#elif AIX
/* AIX quota patch from Ole Holm Nielsen <ohnielse@fysik.dtu.dk> */
#include <jfs/quota.h>
@@ -463,7 +465,25 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
#else /* USE_SETRES */
#if defined(__FreeBSD__)
- r= quotactl(path,Q_GETQUOTA,euser_id,(char *) &D);
+ {
+ /* FreeBSD patches from Marty Moll <martym@arbor.edu> */
+ uid_t user_id;
+ gid_t egrp_id;
+
+ /* Need to be root to get quotas in FreeBSD */
+ user_id = getuid();
+ egrp_id = getegid();
+ setuid(0);
+ seteuid(0);
+ r= quotactl(path,QCMD(Q_GETQUOTA,USRQUOTA),euser_id,(char *) &D);
+
+ /* As FreeBSD has group quotas, if getting the user
+ quota fails, try getting the group instead. */
+ if (r)
+ r= quotactl(path,QCMD(Q_GETQUOTA,GRPQUOTA),egrp_id,(char *) &D);
+ setuid(user_id);
+ seteuid(euser_id);
+ }
#elif defined(AIX)
/* AIX has both USER and GROUP quotas:
Get the USER quota (ohnielse@fysik.dtu.dk) */
@@ -474,7 +494,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
#endif /* USE_SETRES */
/* Use softlimit to determine disk space, except when it has been exceeded */
+#if defined(__FreeBSD__)
+ *bsize = DEV_BSIZE;
+#else /* !__FreeBSD__ */
*bsize = 1024;
+#endif /*!__FreeBSD__ */
+
if (r)
{
if (errno == EDQUOT)
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index a8f674183c5..0cb43a6fb70 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -42,7 +42,6 @@ extern BOOL short_case_preserve;
extern pstring sesssetup_user;
extern fstring myworkgroup;
extern int Client;
-extern int global_oplock_break;
/* this macro should always be used to extract an fnum (smb_fid) from
a packet to ensure chaining works correctly */
@@ -66,18 +65,18 @@ static void overflow_attack(int len)
****************************************************************************/
int reply_special(char *inbuf,char *outbuf)
{
- int outsize = 4;
- int msg_type = CVAL(inbuf,0);
- int msg_flags = CVAL(inbuf,1);
- pstring name1,name2;
- extern fstring remote_machine;
- extern fstring local_machine;
- char *p;
-
- *name1 = *name2 = 0;
-
- smb_setlen(outbuf,0);
-
+ int outsize = 4;
+ int msg_type = CVAL(inbuf,0);
+ int msg_flags = CVAL(inbuf,1);
+ pstring name1,name2;
+ extern fstring remote_machine;
+ extern fstring local_machine;
+ char *p;
+
+ *name1 = *name2 = 0;
+
+ smb_setlen(outbuf,0);
+
switch (msg_type) {
case 0x81: /* session request */
CVAL(outbuf,0) = 0x82;
@@ -122,15 +121,15 @@ int reply_special(char *inbuf,char *outbuf)
DEBUG(0,("Unexpected session response\n"));
break;
- case 0x85: /* session keepalive */
- default:
- return(0);
- }
-
+ case 0x85: /* session keepalive */
+ default:
+ return(0);
+ }
+
DEBUG(5,("%s init msg_type=0x%x msg_flags=0x%x\n",
timestring(),msg_type,msg_flags));
-
- return(outsize);
+
+ return(outsize);
}
@@ -252,7 +251,7 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if ((SVAL(inbuf,smb_vwv2) & 0x1) != 0)
close_cnum(SVAL(inbuf,smb_tid),vuid);
- if (passlen > MAX_PASSWORD_LENGTH) {
+ if (passlen > MAX_PASS_LEN) {
overflow_attack(passlen);
}
@@ -378,8 +377,10 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
BOOL computer_id=False;
static BOOL done_sesssetup = False;
BOOL doencrypt = SMBENCRYPT();
+ char *domain = "";
*smb_apasswd = 0;
+ *smb_ntpasswd = 0;
smb_bufsize = SVAL(inbuf,smb_vwv2);
smb_mpxmax = SVAL(inbuf,smb_vwv3);
@@ -388,7 +389,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (Protocol < PROTOCOL_NT1) {
smb_apasslen = SVAL(inbuf,smb_vwv7);
- if (smb_apasslen > MAX_PASSWORD_LENGTH)
+ if (smb_apasslen > MAX_PASS_LEN)
{
overflow_attack(smb_apasslen);
}
@@ -423,12 +424,12 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (passlen1 != 24 && passlen2 != 24)
doencrypt = False;
- if (passlen1 > MAX_PASSWORD_LENGTH) {
+ if (passlen1 > MAX_PASS_LEN) {
overflow_attack(passlen1);
}
- passlen1 = MIN(passlen1, MAX_PASSWORD_LENGTH);
- passlen2 = MIN(passlen2, MAX_PASSWORD_LENGTH);
+ passlen1 = MIN(passlen1, MAX_PASS_LEN);
+ passlen2 = MIN(passlen2, MAX_PASS_LEN);
if(doencrypt) {
/* Save the lanman2 password and the NT md4 password. */
@@ -468,8 +469,10 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
p += passlen1 + passlen2;
fstrcpy(user,p); p = skip_string(p,1);
+ domain = p;
+
DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s]\n",
- p,skip_string(p,1),skip_string(p,2)));
+ domain,skip_string(p,1),skip_string(p,2)));
}
@@ -509,7 +512,10 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if(!guest && strequal(user,lp_guestaccount(-1)) && (*smb_apasswd == 0))
guest = True;
- if (!guest && !(lp_security() == SEC_SERVER && server_validate(inbuf)) &&
+ if (!guest && !(lp_security() == SEC_SERVER &&
+ server_validate(user, domain,
+ smb_apasswd, smb_apasslen,
+ smb_ntpasswd, smb_ntpasslen)) &&
!check_hosts_equiv(user))
{
@@ -599,7 +605,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (!done_sesssetup)
max_send = MIN(max_send,smb_bufsize);
- DEBUG(6,("Client requested max send size of %d\n", max_send));
+ DEBUG(5,(" Client requested max send size of %d\n", max_send));
done_sesssetup = True;
@@ -640,15 +646,6 @@ int reply_chkpth(char *inbuf,char *outbuf)
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-
- /* Ugly - NT specific hack - but needed (JRA) */
- if((errno == ENOTDIR) && (Protocol >= PROTOCOL_NT1) &&
- (get_remote_arch() == RA_WINNT))
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbaddirectory;
- }
-
return(UNIXERROR(ERRDOS,ERRbadpath));
}
@@ -763,7 +760,7 @@ int reply_setatr(char *inbuf,char *outbuf)
if (check_name(fname,cnum))
ok = (dos_chmod(cnum,fname,mode,NULL) == 0);
if (ok)
- ok = set_filetime(fname,mtime);
+ ok = set_filetime(cnum,fname,mtime);
if (!ok)
{
@@ -1111,8 +1108,6 @@ int reply_open(char *inbuf,char *outbuf)
int rmode=0;
struct stat sbuf;
BOOL bad_path = False;
- files_struct *fsp;
- int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
cnum = SVAL(inbuf,smb_tid);
@@ -1137,12 +1132,9 @@ int reply_open(char *inbuf,char *outbuf)
unixmode = unix_mode(cnum,aARCH);
- open_file_shared(fnum,cnum,fname,share_mode,3,unixmode,
- oplock_request,&rmode,NULL);
+ open_file_shared(fnum,cnum,fname,share_mode,3,unixmode,&rmode,NULL);
- fsp = &Files[fnum];
-
- if (!fsp->open)
+ if (!Files[fnum].open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1152,8 +1144,8 @@ int reply_open(char *inbuf,char *outbuf)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
- close_file(fnum);
+ if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1163,7 +1155,7 @@ int reply_open(char *inbuf,char *outbuf)
if (fmode & aDIR) {
DEBUG(3,("attempt to open a directory %s\n",fname));
- close_file(fnum);
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1174,12 +1166,10 @@ int reply_open(char *inbuf,char *outbuf)
SIVAL(outbuf,smb_vwv4,size);
SSVAL(outbuf,smb_vwv6,rmode);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
+ if (lp_fake_oplocks(SNUM(cnum))) {
+ CVAL(outbuf,smb_flg) |= (CVAL(inbuf,smb_flg) & (1<<5));
}
- if(fsp->granted_oplock)
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
return(outsize);
}
@@ -1194,7 +1184,7 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
int fnum = -1;
int smb_mode = SVAL(inbuf,smb_vwv3);
int smb_attr = SVAL(inbuf,smb_vwv5);
- BOOL oplock_request = EXTENDED_OPLOCK_REQUEST(inbuf);
+ BOOL oplock_request = BITSETW(inbuf+smb_vwv2,1);
#if 0
int open_flags = SVAL(inbuf,smb_vwv2);
int smb_sattr = SVAL(inbuf,smb_vwv4);
@@ -1206,7 +1196,6 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
struct stat sbuf;
int smb_action = 0;
BOOL bad_path = False;
- files_struct *fsp;
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(cnum))
@@ -1234,11 +1223,9 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
unixmode = unix_mode(cnum,smb_attr | aARCH);
open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode,
- oplock_request, &rmode,&smb_action);
+ &rmode,&smb_action);
- fsp = &Files[fnum];
-
- if (!fsp->open)
+ if (!Files[fnum].open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1248,8 +1235,8 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
- close_file(fnum);
+ if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1257,18 +1244,12 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
fmode = dos_mode(cnum,fname,&sbuf);
mtime = sbuf.st_mtime;
if (fmode & aDIR) {
- close_file(fnum);
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- smb_action |= EXTENDED_OPLOCK_GRANTED;
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
- }
-
- if(fsp->granted_oplock) {
- smb_action |= EXTENDED_OPLOCK_GRANTED;
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
+ smb_action |= (1<<15);
}
set_message(outbuf,15,0,True);
@@ -1303,7 +1284,7 @@ int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize)
int i;
for (i=0;i<MAX_OPEN_FILES;i++)
if (Files[i].uid == vuser->uid && Files[i].open) {
- close_file(i);
+ close_file(i, 0);
}
}
@@ -1330,8 +1311,6 @@ int reply_mknew(char *inbuf,char *outbuf)
mode_t unixmode;
int ofun = 0;
BOOL bad_path = False;
- files_struct *fsp;
- int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
com = SVAL(inbuf,smb_com);
cnum = SVAL(inbuf,smb_tid);
@@ -1373,12 +1352,9 @@ int reply_mknew(char *inbuf,char *outbuf)
}
/* Open file in dos compatibility share mode. */
- open_file_shared(fnum,cnum,fname,(DENY_FCB<<4)|0xF, ofun, unixmode,
- oplock_request, NULL, NULL);
+ open_file_shared(fnum,cnum,fname,(DENY_FCB<<4)|0xF, ofun, unixmode, NULL, NULL);
- fsp = &Files[fnum];
-
- if (!fsp->open)
+ if (!Files[fnum].open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1391,13 +1367,10 @@ int reply_mknew(char *inbuf,char *outbuf)
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,fnum);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
+ if (lp_fake_oplocks(SNUM(cnum))) {
+ CVAL(outbuf,smb_flg) |= (CVAL(inbuf,smb_flg) & (1<<5));
}
-
- if(fsp->granted_oplock)
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
-
+
DEBUG(2,("new file %s\n",fname));
DEBUG(3,("%s mknew %s fd=%d fnum=%d cnum=%d dmode=%d umode=%o\n",timestring(),fname,Files[fnum].fd_ptr->fd,fnum,cnum,createmode,unixmode));
@@ -1418,8 +1391,6 @@ int reply_ctemp(char *inbuf,char *outbuf)
int createmode;
mode_t unixmode;
BOOL bad_path = False;
- files_struct *fsp;
- int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
cnum = SVAL(inbuf,smb_tid);
createmode = SVAL(inbuf,smb_vwv0);
@@ -1447,12 +1418,9 @@ int reply_ctemp(char *inbuf,char *outbuf)
/* Open file in dos compatibility share mode. */
/* We should fail if file exists. */
- open_file_shared(fnum,cnum,fname2,(DENY_FCB<<4)|0xF, 0x10, unixmode,
- oplock_request, NULL, NULL);
-
- fsp = &Files[fnum];
+ open_file_shared(fnum,cnum,fname2,(DENY_FCB<<4)|0xF, 0x10, unixmode, NULL, NULL);
- if (!fsp->open)
+ if (!Files[fnum].open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1467,13 +1435,10 @@ int reply_ctemp(char *inbuf,char *outbuf)
CVAL(smb_buf(outbuf),0) = 4;
strcpy(smb_buf(outbuf) + 1,fname2);
- if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
+ if (lp_fake_oplocks(SNUM(cnum))) {
+ CVAL(outbuf,smb_flg) |= (CVAL(inbuf,smb_flg) & (1<<5));
}
- if(fsp->granted_oplock)
- CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
-
DEBUG(2,("created temp file %s\n",fname2));
DEBUG(3,("%s ctemp %s fd=%d fnum=%d cnum=%d dmode=%d umode=%o\n",timestring(),fname2,Files[fnum].fd_ptr->fd,fnum,cnum,createmode,unixmode));
@@ -1621,22 +1586,6 @@ int reply_readbraw(char *inbuf, char *outbuf)
int fd;
char *fname;
-#ifdef USE_OPLOCKS
- /*
- * Special check if an oplock break has been issued
- * and the readraw request croses on the wire, we must
- * return a zero length response here.
- */
-
- if(global_oplock_break)
- {
- _smb_setlen(header,0);
- transfer_file(0,Client,0,header,4,0);
- DEBUG(5,("readbraw - oplock break finished\n"));
- return -1;
- }
-#endif
-
cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
@@ -2246,9 +2195,9 @@ int reply_close(char *inbuf,char *outbuf)
mtime = make_unix_date3(inbuf+smb_vwv1);
/* try and set the date */
- set_filetime(Files[fnum].name,mtime);
+ set_filetime(cnum,Files[fnum].name,mtime);
- close_file(fnum);
+ close_file(fnum, 1);
/* We have a cached error */
if(eclass || err)
@@ -2293,9 +2242,9 @@ int reply_writeclose(char *inbuf,char *outbuf)
nwritten = write_file(fnum,data,numtowrite);
- set_filetime(Files[fnum].name,mtime);
+ set_filetime(cnum,Files[fnum].name,mtime);
- close_file(fnum);
+ close_file(fnum, 1);
DEBUG(3,("%s writeclose fnum=%d cnum=%d num=%d wrote=%d (numopen=%d)\n",
timestring(),fnum,cnum,numtowrite,nwritten,
@@ -2492,8 +2441,7 @@ int reply_printopen(char *inbuf,char *outbuf)
return(ERROR(ERRDOS,ERRnoaccess));
/* Open for exclusive use, write only. */
- open_file_shared(fnum,cnum,fname2,(DENY_ALL<<4)|1, 0x12, unix_mode(cnum,0),
- 0, NULL, NULL);
+ open_file_shared(fnum,cnum,fname2,(DENY_ALL<<4)|1, 0x12, unix_mode(cnum,0), NULL, NULL);
if (!Files[fnum].open)
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -2527,7 +2475,7 @@ int reply_printclose(char *inbuf,char *outbuf)
if (!CAN_PRINT(cnum))
return(ERROR(ERRDOS,ERRnoaccess));
- close_file(fnum);
+ close_file(fnum, 1);
DEBUG(3,("%s printclose fd=%d fnum=%d cnum=%d\n",timestring(),Files[fnum].fd_ptr->fd,fnum,cnum));
@@ -2695,66 +2643,6 @@ int reply_mkdir(char *inbuf,char *outbuf)
return(outsize);
}
-/****************************************************************************
-Static function used by reply_rmdir to delete an entire directory
-tree recursively.
-****************************************************************************/
-static BOOL recursive_rmdir(char *directory)
-{
- char *dname = NULL;
- BOOL ret = False;
- void *dirptr = OpenDir(-1, directory, False);
-
- if(dirptr == NULL)
- return True;
-
- while((dname = ReadDirName(dirptr)))
- {
- pstring fullname;
- struct stat st;
-
- if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0))
- continue;
-
- /* Construct the full name. */
- if(strlen(directory) + strlen(dname) + 1 >= sizeof(fullname))
- {
- errno = ENOMEM;
- ret = True;
- break;
- }
- strcpy(fullname, directory);
- strcat(fullname, "/");
- strcat(fullname, dname);
-
- if(sys_lstat(fullname, &st) != 0)
- {
- ret = True;
- break;
- }
-
- if(st.st_mode & S_IFDIR)
- {
- if(recursive_rmdir(fullname)!=0)
- {
- ret = True;
- break;
- }
- if(sys_rmdir(fullname) != 0)
- {
- ret = True;
- break;
- }
- }
- else if(sys_unlink(fullname) != 0)
- {
- ret = True;
- break;
- }
- }
- CloseDir(dirptr);
- return ret;
-}
/****************************************************************************
reply to a rmdir
@@ -2823,15 +2711,10 @@ int reply_rmdir(char *inbuf,char *outbuf)
if(sys_lstat(fullname, &st) != 0)
break;
if(st.st_mode & S_IFDIR)
- {
- if(lp_recursive_veto_delete(SNUM(cnum)))
{
- if(recursive_rmdir(fullname) != 0)
+ if(sys_rmdir(fullname) != 0)
break;
}
- if(sys_rmdir(fullname) != 0)
- break;
- }
else if(sys_unlink(fullname) != 0)
break;
}
@@ -3155,7 +3038,7 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
fnum1 = find_free_file();
if (fnum1<0) return(False);
open_file_shared(fnum1,cnum,src,(DENY_NONE<<4),
- 1,0,0,&Access,&action);
+ 1,0,&Access,&action);
if (!Files[fnum1].open) return(False);
@@ -3164,14 +3047,14 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
fnum2 = find_free_file();
if (fnum2<0) {
- close_file(fnum1);
+ close_file(fnum1, 0);
return(False);
}
open_file_shared(fnum2,cnum,dest,(DENY_NONE<<4)|1,
- ofun,st.st_mode,0,&Access,&action);
+ ofun,st.st_mode,&Access,&action);
if (!Files[fnum2].open) {
- close_file(fnum1);
+ close_file(fnum1, 0);
return(False);
}
@@ -3182,8 +3065,8 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
if (st.st_size)
ret = transfer_file(Files[fnum1].fd_ptr->fd,Files[fnum2].fd_ptr->fd,st.st_size,NULL,0,0);
- close_file(fnum1);
- close_file(fnum2);
+ close_file(fnum1, 0);
+ close_file(fnum2, 0);
return(ret == st.st_size);
}
@@ -3370,10 +3253,7 @@ int reply_setdir(char *inbuf,char *outbuf)
int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
{
int fnum = GETFNUM(inbuf,smb_vwv2);
- unsigned char locktype = CVAL(inbuf,smb_vwv3);
-#if 0
- unsigned char oplocklevel = CVAL(inbuf,smb_vwv3+1);
-#endif /* USE_OPLOCKS */
+ uint16 locktype = SVAL(inbuf,smb_vwv3);
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
@@ -3390,50 +3270,6 @@ int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
CHECK_ERROR(fnum);
data = smb_buf(inbuf);
-
-#ifdef USE_OPLOCKS
- /* Check if this is an oplock break on a file
- we have granted an oplock on.
- */
- if((locktype == LOCKING_ANDX_OPLOCK_RELEASE) &&
- (num_ulocks == 0) && (num_locks == 0) &&
- (CVAL(inbuf,smb_vwv0) == 0xFF))
- {
- share_lock_token token;
- files_struct *fsp = &Files[fnum];
- uint32 dev = fsp->fd_ptr->dev;
- uint32 inode = fsp->fd_ptr->inode;
-
- DEBUG(5,("reply_lockingX: oplock break reply from client for fnum = %d\n",
- fnum));
- /*
- * Make sure we have granted an oplock on this file.
- */
- if(!fsp->granted_oplock)
- {
- DEBUG(0,("reply_lockingX: Error : oplock break from client for fnum = %d and \
-no oplock granted on this file.\n", fnum));
- return ERROR(ERRDOS,ERRlock);
- }
-
- /* Remove the oplock flag from the sharemode. */
- lock_share_entry(fsp->cnum, dev, inode, &token);
- if(remove_share_oplock( fnum, token)==False)
- {
- DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
-dev = %x, inode = %x\n", fnum, dev, inode));
- unlock_share_entry(fsp->cnum, dev, inode, token);
- return -1;
- }
- unlock_share_entry(fsp->cnum, dev, inode, token);
-
- /* Clear the granted flag and return. */
-
- fsp->granted_oplock = False;
- return -1;
- }
-#endif /* USE_OPLOCKS */
-
/* Data now points at the beginning of the list
of smb_unlkrng structs */
for(i = 0; i < (int)num_ulocks; i++) {
@@ -3468,7 +3304,7 @@ dev = %x, inode = %x\n", fnum, dev, inode));
set_message(outbuf,2,0,True);
DEBUG(3,("%s lockingX fnum=%d cnum=%d type=%d num_locks=%d num_ulocks=%d\n",
- timestring(),fnum,cnum,(unsigned int)locktype,num_locks,num_ulocks));
+ timestring(),fnum,cnum,locktype,num_locks,num_ulocks));
chain_fnum = fnum;
@@ -3765,7 +3601,7 @@ not setting timestamps of 0\n",
}
/* Set the date on this file */
- if(sys_utime(Files[fnum].name, &unix_times))
+ if(file_utime(cnum,Files[fnum].name, &unix_times))
return(ERROR(ERRDOS,ERRnoaccess));
DEBUG(3,("%s reply_setattrE fnum=%d cnum=%d actime=%d modtime=%d\n",
@@ -3821,3 +3657,8 @@ int reply_getattrE(char *inbuf,char *outbuf)
return(outsize);
}
+
+
+
+
+
diff --git a/source/smbd/server.c b/source/smbd/server.c
index b250572a1f4..7d18a070cbe 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -84,16 +84,6 @@ int chain_fnum = -1;
/* number of open connections */
static int num_connections_open = 0;
-#ifdef USE_OPLOCKS
-/* Oplock ipc UDP socket. */
-int oplock_sock = -1;
-uint16 oplock_port = 0;
-/* Current number of oplocks we have outstanding. */
-int32 global_oplocks_open = 0;
-#endif /* USE_OPLOCKS */
-
-BOOL global_oplock_break = False;
-
extern fstring remote_machine;
pstring OriginalDir;
@@ -189,7 +179,7 @@ int dos_mode(int cnum,char *path,struct stat *sbuf)
int result = 0;
extern struct current_user current_user;
- DEBUG(8,("dos_mode: %d %s\n", cnum, path));
+ DEBUG(5,("dos_mode: %d %s\n", cnum, path));
if (CAN_WRITE(cnum) && !lp_alternate_permissions(SNUM(cnum))) {
if (!((sbuf->st_mode & S_IWOTH) ||
@@ -241,15 +231,15 @@ int dos_mode(int cnum,char *path,struct stat *sbuf)
result |= aHIDDEN;
}
- DEBUG(8,("dos_mode returning "));
+ DEBUG(5,("dos_mode returning "));
- if (result & aHIDDEN) DEBUG(8, ("h"));
- if (result & aRONLY ) DEBUG(8, ("r"));
- if (result & aSYSTEM) DEBUG(8, ("s"));
- if (result & aDIR ) DEBUG(8, ("d"));
- if (result & aARCH ) DEBUG(8, ("a"));
+ if (result & aHIDDEN) DEBUG(5, ("h"));
+ if (result & aRONLY ) DEBUG(5, ("r"));
+ if (result & aSYSTEM) DEBUG(5, ("s"));
+ if (result & aDIR ) DEBUG(5, ("d"));
+ if (result & aARCH ) DEBUG(5, ("a"));
- DEBUG(8,("\n"));
+ DEBUG(5,("\n"));
return(result);
}
@@ -308,6 +298,71 @@ int dos_chmod(int cnum,char *fname,int dosmode,struct stat *st)
return(sys_chmod(fname,unixmode));
}
+/*******************************************************************
+Wrapper around sys_utime that possibly allows DOS semantics rather
+than POSIX.
+*******************************************************************/
+
+int file_utime(int cnum, char *fname, struct utimbuf *times)
+{
+ extern struct current_user current_user;
+ struct stat sb;
+ int ret = -1;
+
+ if(sys_utime(fname, times) == 0)
+ return 0;
+
+ if((errno != EPERM) && (errno != EACCES))
+ return -1;
+
+ if(!lp_dos_filetimes(SNUM(cnum)))
+ return -1;
+
+ /* We have permission (given by the Samba admin) to
+ break POSIX semantics and allow a user to change
+ the time on a file they don't own but can write to
+ (as DOS does).
+ */
+
+ if(sys_stat(fname,&sb) != 0)
+ return -1;
+
+ /* Check if we have write access. */
+ if (CAN_WRITE(cnum)) {
+ if (((sb.st_mode & S_IWOTH) ||
+ Connections[cnum].admin_user ||
+ ((sb.st_mode & S_IWUSR) && current_user.uid==sb.st_uid) ||
+ ((sb.st_mode & S_IWGRP) &&
+ in_group(sb.st_gid,current_user.gid,
+ current_user.ngroups,current_user.igroups)))) {
+ /* We are allowed to become root and change the filetime. */
+ become_root(False);
+ ret = sys_utime(fname, times);
+ unbecome_root(False);
+ }
+ }
+
+ return ret;
+}
+
+/*******************************************************************
+Change a filetime - possibly allowing DOS semantics.
+*******************************************************************/
+
+BOOL set_filetime(int cnum, char *fname, time_t mtime)
+{
+ struct utimbuf times;
+
+ if (null_mtime(mtime)) return(True);
+
+ times.modtime = times.actime = mtime;
+
+ if (file_utime(cnum, fname, &times)) {
+ DEBUG(4,("set_filetime(%s) failed: %s\n",fname,strerror(errno)));
+ }
+
+ return(True);
+}
/****************************************************************************
check if two filenames are equal
@@ -713,7 +768,15 @@ int disk_free(char *path,int *bsize,int *dfree,int *dsize)
dfree_retval : dfreeq_retval ;
/* maybe dfree and dfreeq are calculated using different bsizes
so convert dfree from bsize into bsizeq */
- *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ /* avoid overflows due to multiplication, so do not:
+ *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ bsize and bsizeq are powers of 2 so its better to
+ to divide them getting a multiplication or division factor
+ for dfree. Rene Nieuwenhuizen (07-10-1997) */
+ if (*bsize >= bsizeq)
+ *dfree = *dfree * (*bsize / bsizeq);
+ else
+ *dfree = *dfree / (bsizeq / *bsize);
*dfree = ( *dfree < dfreeq ) ? *dfree : dfreeq ;
*bsize = bsizeq;
*dsize = dsizeq;
@@ -803,7 +866,15 @@ if ((*bsize) < 512 || (*bsize)>0xFFFF) *bsize = 1024;
dfree_retval : dfreeq_retval ;
/* maybe dfree and dfreeq are calculated using different bsizes
so convert dfree from bsize into bsizeq */
- *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ /* avoid overflows due to multiplication, so do not:
+ *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ bsize and bsizeq are powers of 2 so its better to
+ to divide them getting a multiplication or division factor
+ for dfree. Rene Nieuwenhuizen (07-10-1997) */
+ if (*bsize >= bsizeq)
+ *dfree = *dfree * (*bsize / bsizeq);
+ else
+ *dfree = *dfree / (bsizeq / *bsize);
*dfree = ( *dfree < dfreeq ) ? *dfree : dfreeq ;
*bsize = bsizeq;
*dsize = dsizeq;
@@ -886,7 +957,8 @@ static void check_for_pipe(char *fname)
/****************************************************************************
fd support routines - attempt to do a sys_open
****************************************************************************/
-static int fd_attempt_open(char *fname, int flags, int mode)
+
+int fd_attempt_open(char *fname, int flags, int mode)
{
int fd = sys_open(fname,flags,mode);
@@ -938,7 +1010,7 @@ static int fd_attempt_open(char *fname, int flags, int mode)
fd support routines - attempt to find an already open file by dev
and inode - increments the ref_count of the returned file_fd_struct *.
****************************************************************************/
-static file_fd_struct *fd_get_already_open(struct stat *sbuf)
+file_fd_struct *fd_get_already_open(struct stat *sbuf)
{
int i;
file_fd_struct *fd_ptr;
@@ -965,7 +1037,7 @@ static file_fd_struct *fd_get_already_open(struct stat *sbuf)
fd support routines - attempt to find a empty slot in the FileFd array.
Increments the ref_count of the returned entry.
****************************************************************************/
-static file_fd_struct *fd_get_new()
+file_fd_struct *fd_get_new()
{
int i;
file_fd_struct *fd_ptr;
@@ -998,7 +1070,8 @@ n"));
fd support routines - attempt to re-open an already open fd as O_RDWR.
Save the already open fd (we cannot close due to POSIX file locking braindamage.
****************************************************************************/
-static void fd_attempt_reopen(char *fname, int mode, file_fd_struct *fd_ptr)
+
+void fd_attempt_reopen(char *fname, int mode, file_fd_struct *fd_ptr)
{
int fd = sys_open( fname, O_RDWR, mode);
@@ -1018,7 +1091,7 @@ static void fd_attempt_reopen(char *fname, int mode, file_fd_struct *fd_ptr)
fd support routines - attempt to close the file referenced by this fd.
Decrements the ref_count and returns it.
****************************************************************************/
-static int fd_attempt_close(file_fd_struct *fd_ptr)
+int fd_attempt_close(file_fd_struct *fd_ptr)
{
DEBUG(3,("fd_attempt_close on file_fd_struct %d, fd = %d, dev = %x, inode = %x, open_flags = %d, ref_count = %d.\n",
fd_ptr - &FileFd[0],
@@ -1054,11 +1127,9 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
pstring fname;
struct stat statbuf;
file_fd_struct *fd_ptr;
- files_struct *fsp = &Files[fnum];
- fsp->open = False;
- fsp->fd_ptr = 0;
- fsp->granted_oplock = False;
+ Files[fnum].open = False;
+ Files[fnum].fd_ptr = 0;
errno = EPERM;
pstrcpy(fname,fname1);
@@ -1081,13 +1152,6 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
DEBUG(3,("Bug in client? Set O_WRONLY without O_CREAT\n"));
*/
-#if UTIME_WORKAROUND
- /* XXXX - is this OK?? */
- /* this works around a utime bug but can cause other problems */
- if ((flags & (O_WRONLY|O_RDWR)) && (flags & O_CREAT) && !(flags & O_APPEND))
- sys_unlink(fname);
-#endif
-
/*
* Ensure we have a valid struct stat so we can search the
* open fd table.
@@ -1196,7 +1260,7 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
if (sys_disk_free(dname,&dum1,&dum2,&dum3) <
lp_minprintspace(SNUM(cnum))) {
fd_attempt_close(fd_ptr);
- fsp->fd_ptr = 0;
+ Files[fnum].fd_ptr = 0;
if(fd_ptr->ref_count == 0)
sys_unlink(fname);
errno = ENOSPC;
@@ -1232,26 +1296,25 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
fd_ptr->dev = (uint32)sbuf->st_dev;
fd_ptr->inode = (uint32)sbuf->st_ino;
- fsp->fd_ptr = fd_ptr;
+ Files[fnum].fd_ptr = fd_ptr;
Connections[cnum].num_files_open++;
- fsp->mode = sbuf->st_mode;
- GetTimeOfDay(&fsp->open_time);
- fsp->uid = current_user.id;
- fsp->size = 0;
- fsp->pos = -1;
- fsp->open = True;
- fsp->mmap_ptr = NULL;
- fsp->mmap_size = 0;
- fsp->can_lock = True;
- fsp->can_read = ((flags & O_WRONLY)==0);
- fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
- fsp->share_mode = 0;
- fsp->print_file = Connections[cnum].printer;
- fsp->modified = False;
- fsp->granted_oplock = False;
- fsp->cnum = cnum;
- string_set(&fsp->name,dos_to_unix(fname,False));
- fsp->wbmpx_ptr = NULL;
+ Files[fnum].mode = sbuf->st_mode;
+ GetTimeOfDay(&Files[fnum].open_time);
+ Files[fnum].uid = current_user.id;
+ Files[fnum].size = 0;
+ Files[fnum].pos = -1;
+ Files[fnum].open = True;
+ Files[fnum].mmap_ptr = NULL;
+ Files[fnum].mmap_size = 0;
+ Files[fnum].can_lock = True;
+ Files[fnum].can_read = ((flags & O_WRONLY)==0);
+ Files[fnum].can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
+ Files[fnum].share_mode = 0;
+ Files[fnum].print_file = Connections[cnum].printer;
+ Files[fnum].modified = False;
+ Files[fnum].cnum = cnum;
+ string_set(&Files[fnum].name,dos_to_unix(fname,False));
+ Files[fnum].wbmpx_ptr = NULL;
/*
* If the printer is marked as postscript output a leading
@@ -1260,8 +1323,8 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
* This has a similar effect as CtrlD=0 in WIN.INI file.
* tim@fsg.com 09/06/94
*/
- if (fsp->print_file && POSTSCRIPT(cnum) &&
- fsp->can_write)
+ if (Files[fnum].print_file && POSTSCRIPT(cnum) &&
+ Files[fnum].can_write)
{
DEBUG(3,("Writing postscript line\n"));
write_file(fnum,"%!\n",3);
@@ -1269,23 +1332,23 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
DEBUG(2,("%s %s opened file %s read=%s write=%s (numopen=%d fnum=%d)\n",
timestring(),Connections[cnum].user,fname,
- BOOLSTR(fsp->can_read),BOOLSTR(fsp->can_write),
+ BOOLSTR(Files[fnum].can_read),BOOLSTR(Files[fnum].can_write),
Connections[cnum].num_files_open,fnum));
}
#if USE_MMAP
/* mmap it if read-only */
- if (!fsp->can_write)
+ if (!Files[fnum].can_write)
{
- fsp->mmap_size = file_size(fname);
- fsp->mmap_ptr = (char *)mmap(NULL,fsp->mmap_size,
- PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,0);
+ Files[fnum].mmap_size = file_size(fname);
+ Files[fnum].mmap_ptr = (char *)mmap(NULL,Files[fnum].mmap_size,
+ PROT_READ,MAP_SHARED,Files[fnum].fd_ptr->fd,0);
- if (fsp->mmap_ptr == (char *)-1 || !fsp->mmap_ptr)
+ if (Files[fnum].mmap_ptr == (char *)-1 || !Files[fnum].mmap_ptr)
{
DEBUG(3,("Failed to mmap() %s - %s\n",fname,strerror(errno)));
- fsp->mmap_ptr = NULL;
+ Files[fnum].mmap_ptr = NULL;
}
}
#endif
@@ -1343,8 +1406,13 @@ static void check_magic(int fnum,int cnum)
/****************************************************************************
close a file - possibly invalidating the read prediction
+
+If normal_close is 1 then this came from a normal SMBclose (or equivalent)
+operation otherwise it came as the result of some other operation such as
+the closing of the connection. In the latter case printing and
+magic scripts are not run
****************************************************************************/
-void close_file(int fnum)
+void close_file(int fnum, int normal_close)
{
files_struct *fs_p = &Files[fnum];
int cnum = fs_p->cnum;
@@ -1356,17 +1424,17 @@ void close_file(int fnum)
fs_p->open = False;
Connections[cnum].num_files_open--;
if(fs_p->wbmpx_ptr)
- {
- free((char *)fs_p->wbmpx_ptr);
- fs_p->wbmpx_ptr = NULL;
- }
+ {
+ free((char *)fs_p->wbmpx_ptr);
+ fs_p->wbmpx_ptr = NULL;
+ }
#if USE_MMAP
if(fs_p->mmap_ptr)
- {
- munmap(fs_p->mmap_ptr,fs_p->mmap_size);
- fs_p->mmap_ptr = NULL;
- }
+ {
+ munmap(fs_p->mmap_ptr,fs_p->mmap_size);
+ fs_p->mmap_ptr = NULL;
+ }
#endif
if (lp_share_modes(SNUM(cnum)))
@@ -1381,11 +1449,12 @@ void close_file(int fnum)
unlock_share_entry( cnum, dev, inode, token);
/* NT uses smbclose to start a print - weird */
- if (fs_p->print_file)
+ if (normal_close && fs_p->print_file)
print_file(fnum);
/* check for magic scripts */
- check_magic(fnum,cnum);
+ if (normal_close)
+ check_magic(fnum,cnum);
DEBUG(2,("%s %s closed file %s (numopen=%d)\n",
timestring(),Connections[cnum].user,fs_p->name,
@@ -1403,8 +1472,7 @@ static int access_table(int new_deny,int old_deny,int old_mode,
if (new_deny == DENY_ALL || old_deny == DENY_ALL) return(AFAIL);
if (new_deny == DENY_DOS || old_deny == DENY_DOS) {
- int pid = getpid();
- if (old_deny == new_deny && share_pid == pid)
+ if (old_deny == new_deny && share_pid == getpid())
return(AALL);
if (old_mode == 0) return(AREAD);
@@ -1458,76 +1526,23 @@ BOOL check_file_sharing(int cnum,char *fname)
struct stat sbuf;
share_lock_token token;
int pid = getpid();
- uint32 dev, inode;
if(!lp_share_modes(SNUM(cnum)))
return True;
if (stat(fname,&sbuf) == -1) return(True);
- dev = (uint32)sbuf.st_dev;
- inode = (uint32)sbuf.st_ino;
+ lock_share_entry(cnum, (uint32)sbuf.st_dev, (uint32)sbuf.st_ino, &token);
+ num_share_modes = get_share_modes(cnum, token,
+ (uint32)sbuf.st_dev, (uint32)sbuf.st_ino, &old_shares);
- lock_share_entry(cnum, dev, inode, &token);
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
-
- /*
- * Check if the share modes will give us access.
- */
-
- if(num_share_modes != 0)
+ for( i = 0; i < num_share_modes; i++)
{
- BOOL broke_oplock;
-
- do
- {
-
- broke_oplock = False;
- for(i = 0; i < num_share_modes; i++)
- {
- min_share_mode_entry *share_entry = &old_shares[i];
-
-#ifdef USE_OPLOCKS
- /*
- * Break oplocks before checking share modes. See comment in
- * open_file_shared for details.
- * Check if someone has an oplock on this file. If so we must
- * break it before continuing.
- */
- if(share_entry->op_type & BATCH_OPLOCK)
- {
-
- DEBUG(5,("check_file_sharing: breaking oplock (%x) on file %s, \
-dev = %x, inode = %x\n", share_entry->op_type, fname, dev, inode));
-
- /* Oplock break.... */
- unlock_share_entry(cnum, dev, inode, token);
- if(request_oplock_break(share_entry, dev, inode) == False)
- {
- free((char *)old_shares);
- DEBUG(0,("check_file_sharing: FAILED when breaking oplock (%x) on file %s, \
-dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
- return False;
- }
- lock_share_entry(cnum, dev, inode, &token);
- broke_oplock = True;
- break;
- }
-#endif /* USE_OPLOCKS */
+ if (old_shares[i].share_mode != DENY_DOS)
+ goto free_and_exit;
- /* someone else has a share lock on it, check to see
- if we can too */
- if ((share_entry->share_mode != DENY_DOS) || (share_entry->pid != pid))
- goto free_and_exit;
-
- } /* end for */
-
- if(broke_oplock)
- {
- free((char *)old_shares);
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
- }
- } while(broke_oplock);
+ if(old_shares[i].pid != pid)
+ goto free_and_exit;
}
/* XXXX exactly what share mode combinations should be allowed for
@@ -1538,7 +1553,7 @@ dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
free_and_exit:
- unlock_share_entry(cnum, dev, inode, token);
+ unlock_share_entry(cnum, (uint32)sbuf.st_dev, (uint32)sbuf.st_ino, token);
if(old_shares != NULL)
free((char *)old_shares);
return(ret);
@@ -1559,7 +1574,7 @@ static void truncate_unless_locked(int fnum, int cnum, share_lock_token token,
if (*share_locked && lp_share_modes(SNUM(cnum)))
unlock_share_entry( cnum, Files[fnum].fd_ptr->dev,
Files[fnum].fd_ptr->inode, token);
- close_file(fnum);
+ close_file(fnum, 0);
/* Share mode no longer locked. */
*share_locked = False;
errno = EACCES;
@@ -1571,52 +1586,12 @@ static void truncate_unless_locked(int fnum, int cnum, share_lock_token token,
}
}
-/****************************************************************************
-check if we can open a file with a share mode
-****************************************************************************/
-int check_share_mode( min_share_mode_entry *share, int deny_mode, char *fname,
- BOOL fcbopen, int *flags)
-{
- int old_open_mode = share->share_mode &0xF;
- int old_deny_mode = (share->share_mode >>4)&7;
-
- if (old_deny_mode > 4 || old_open_mode > 2)
- {
- DEBUG(0,("Invalid share mode found (%d,%d,%d) on file %s\n",
- deny_mode,old_deny_mode,old_open_mode,fname));
- return False;
- }
-
- {
- int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
- share->pid,fname);
-
- if ((access_allowed == AFAIL) ||
- (!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
- (access_allowed == AREAD && *flags == O_WRONLY) ||
- (access_allowed == AWRITE && *flags == O_RDONLY))
- {
- DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n",
- deny_mode,old_deny_mode,old_open_mode,
- share->pid,fname, access_allowed));
- return False;
- }
-
- if (access_allowed == AREAD)
- *flags = O_RDONLY;
-
- if (access_allowed == AWRITE)
- *flags = O_WRONLY;
-
- }
- return True;
-}
/****************************************************************************
open a file with a share mode
****************************************************************************/
void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
- int mode,int oplock_request, int *Access,int *action)
+ int mode,int *Access,int *action)
{
files_struct *fs_p = &Files[fnum];
int flags=0;
@@ -1629,7 +1604,6 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
share_lock_token token;
uint32 dev = 0;
uint32 inode = 0;
- int num_share_modes = 0;
fs_p->open = False;
fs_p->fd_ptr = 0;
@@ -1701,88 +1675,69 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
if (lp_share_modes(SNUM(cnum)))
{
+ int num_shares = 0;
int i;
min_share_mode_entry *old_shares = 0;
+
if (file_existed)
{
dev = (uint32)sbuf.st_dev;
inode = (uint32)sbuf.st_ino;
lock_share_entry(cnum, dev, inode, &token);
share_locked = True;
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
+ num_shares = get_share_modes(cnum, token, dev, inode, &old_shares);
}
- /*
- * Check if the share modes will give us access.
- */
-
- if(share_locked && (num_share_modes != 0))
+ for(i = 0; i < num_shares; i++)
{
- BOOL broke_oplock;
+ /* someone else has a share lock on it, check to see
+ if we can too */
+ int old_open_mode = old_shares[i].share_mode &0xF;
+ int old_deny_mode = (old_shares[i].share_mode >>4)&7;
- do
+ if (old_deny_mode > 4 || old_open_mode > 2)
{
+ DEBUG(0,("Invalid share mode found (%d,%d,%d) on file %s\n",
+ deny_mode,old_deny_mode,old_open_mode,fname));
+ free((char *)old_shares);
+ if(share_locked)
+ unlock_share_entry(cnum, dev, inode, token);
+ errno = EACCES;
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadshare;
+ return;
+ }
- broke_oplock = False;
- for(i = 0; i < num_share_modes; i++)
- {
- min_share_mode_entry *share_entry = &old_shares[i];
-
-#ifdef USE_OPLOCKS
- /*
- * By observation of NetBench, oplocks are broken *before* share
- * modes are checked. This allows a file to be closed by the client
- * if the share mode would deny access and the client has an oplock.
- * Check if someone has an oplock on this file. If so we must break
- * it before continuing.
- */
- if(share_entry->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
- {
-
- DEBUG(5,("open_file_shared: breaking oplock (%x) on file %s, \
-dev = %x, inode = %x\n", share_entry->op_type, fname, dev, inode));
-
- /* Oplock break.... */
- unlock_share_entry(cnum, dev, inode, token);
- if(request_oplock_break(share_entry, dev, inode) == False)
- {
- free((char *)old_shares);
- DEBUG(0,("open_file_shared: FAILED when breaking oplock (%x) on file %s, \
-dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
- errno = EACCES;
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadshare;
- return;
- }
- lock_share_entry(cnum, dev, inode, &token);
- broke_oplock = True;
- break;
- }
-#endif /* USE_OPLOCKS */
-
- /* someone else has a share lock on it, check to see
- if we can too */
- if(check_share_mode(share_entry, deny_mode, fname, fcbopen, &flags) == False)
- {
- free((char *)old_shares);
- unlock_share_entry(cnum, dev, inode, token);
- errno = EACCES;
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadshare;
- return;
- }
-
- } /* end for */
+ {
+ int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
+ old_shares[i].pid,fname);
- if(broke_oplock)
+ if ((access_allowed == AFAIL) ||
+ (!fcbopen && (access_allowed == AREAD && flags == O_RDWR)) ||
+ (access_allowed == AREAD && flags == O_WRONLY) ||
+ (access_allowed == AWRITE && flags == O_RDONLY))
{
+ DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n",
+ deny_mode,old_deny_mode,old_open_mode,
+ old_shares[i].pid,fname,
+ access_allowed));
free((char *)old_shares);
- num_share_modes = get_share_modes(cnum, token, dev, inode, &old_shares);
+ if(share_locked)
+ unlock_share_entry(cnum, dev, inode, token);
+ errno = EACCES;
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadshare;
+ return;
}
- } while(broke_oplock);
+
+ if (access_allowed == AREAD)
+ flags = O_RDONLY;
+
+ if (access_allowed == AWRITE)
+ flags = O_WRONLY;
+ }
}
-
if(old_shares != 0)
free((char *)old_shares);
}
@@ -1839,35 +1794,7 @@ dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
file (which expects the share_mode_entry to be there).
*/
if (lp_share_modes(SNUM(cnum)))
- {
- uint16 port = 0;
-#ifdef USE_OPLOCKS
- /* JRA. Currently this only services Exlcusive and batch
- oplocks (no other opens on this file). This needs to
- be extended to level II oplocks (multiple reader
- oplocks). */
-
- if(oplock_request && (num_share_modes == 0) && lp_oplocks(SNUM(cnum)))
- {
- fs_p->granted_oplock = True;
- global_oplocks_open++;
- port = oplock_port;
-
- DEBUG(5,("open_file_shared: granted oplock (%x) on file %s, \
-dev = %x, inode = %x\n", oplock_request, fname, dev, inode));
-
- }
- else
- {
- port = 0;
- oplock_request = 0;
- }
-#else /* USE_OPLOCKS */
- oplock_request = 0;
- port = 0;
-#endif /* USE_OPLOCKS */
- set_share_mode(token, fnum, port, oplock_request);
- }
+ set_share_mode(token, fnum);
if ((flags2&O_TRUNC) && file_existed)
truncate_unless_locked(fnum,cnum,token,&share_locked);
@@ -2116,7 +2043,11 @@ struct
{EPERM,ERRDOS,ERRnoaccess},
{EACCES,ERRDOS,ERRnoaccess},
{ENOENT,ERRDOS,ERRbadfile},
+#if 0 /* Go back to old method for now. */
+ {ENOTDIR,ERRDOS,ERRbaddirectory},
+#else
{ENOTDIR,ERRDOS,ERRbadpath},
+#endif
{EIO,ERRHRD,ERRgeneral},
{EBADF,ERRSRV,ERRsrverror},
{EINVAL,ERRSRV,ERRsrverror},
@@ -2137,6 +2068,23 @@ struct
{0,0,0}
};
+#if 0 /* Go back to old method for now. */
+/* Mapping for old clients. */
+
+struct
+{
+ int new_smb_error;
+ int old_smb_error;
+ int protocol_level;
+ enum remote_arch_types valid_ra_type;
+} old_client_errmap[] =
+{
+ {ERRbaddirectory, ERRbadpath, (int)PROTOCOL_NT1, RA_WINNT},
+ {0,0,0}
+};
+
+#endif /* Go back to old method for now. */
+
/****************************************************************************
create an error packet from errno
****************************************************************************/
@@ -2167,6 +2115,32 @@ int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int
}
}
+#if 0 /* Go back to old method for now. */
+
+ /* Make sure we don't return error codes that old
+ clients don't understand. */
+
+ /* JRA - unfortunately, WinNT needs some error codes
+ for apps to work correctly, Win95 will break if
+ these error codes are returned. But they both
+ negotiate the *same* protocol. So we need to use
+ the revolting 'remote_arch' enum to tie break.
+
+ There must be a better way of doing this...
+ */
+
+ for(i = 0; old_client_errmap[i].new_smb_error != 0; i++)
+ {
+ if(((Protocol < old_client_errmap[i].protocol_level) ||
+ (old_client_errmap[i].valid_ra_type != get_remote_arch())) &&
+ (old_client_errmap[i].new_smb_error == ecode))
+ {
+ ecode = old_client_errmap[i].old_smb_error;
+ break;
+ }
+ }
+#endif /* Go back to old method for now. */
+
return(error_packet(inbuf,outbuf,eclass,ecode,line));
}
@@ -2249,22 +2223,21 @@ static int sig_cld()
**************************************************************************/
static int sig_pipe()
{
- extern int password_client;
- BlockSignals(True,SIGPIPE);
+ struct cli_state *cli;
+ BlockSignals(True,SIGPIPE);
- if (password_client != -1) {
- DEBUG(3,("lost connection to password server\n"));
- close(password_client);
- password_client = -1;
+ if ((cli = server_client()) && cli->initialised) {
+ DEBUG(3,("lost connection to password server\n"));
+ cli_shutdown(cli);
#ifndef DONT_REINSTALL_SIG
- signal(SIGPIPE, SIGNAL_CAST sig_pipe);
+ signal(SIGPIPE, SIGNAL_CAST sig_pipe);
#endif
- BlockSignals(False,SIGPIPE);
- return 0;
- }
+ BlockSignals(False,SIGPIPE);
+ return 0;
+ }
- exit_server("Got sigpipe\n");
- return(0);
+ exit_server("Got sigpipe\n");
+ return(0);
}
/****************************************************************************
@@ -2373,516 +2346,6 @@ static BOOL open_sockets(BOOL is_daemon,int port)
return True;
}
-/****************************************************************************
- process an smb from the client - split out from the process() code so
- it can be used by the oplock break code.
-****************************************************************************/
-
-static void process_smb(char *inbuf, char *outbuf)
-{
- extern int Client;
- static int trans_num;
- int msg_type = CVAL(inbuf,0);
- int32 len = smb_len(inbuf);
- int nread = len + 4;
-
- if (trans_num == 0) {
- /* on the first packet, check the global hosts allow/ hosts
- deny parameters before doing any parsing of the packet
- passed to us by the client. This prevents attacks on our
- parsing code from hosts not in the hosts allow list */
- if (!check_access(-1)) {
- /* send a negative session response "not listining on calling
- name" */
- static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81};
- DEBUG(1,("%s Connection denied from %s\n",
- timestring(),client_addr()));
- send_smb(Client,(char *)buf);
- exit_server("connection denied");
- }
- }
-
- DEBUG(6,("got message type 0x%x of len 0x%x\n",msg_type,len));
- DEBUG(3,("%s Transaction %d of length %d\n",timestring(),trans_num,nread));
-
-#ifdef WITH_VTP
- if(trans_num == 1 && VT_Check(inbuf))
- {
- VT_Process();
- return;
- }
-#endif
-
- if (msg_type == 0)
- show_msg(inbuf);
-
- nread = construct_reply(inbuf,outbuf,nread,max_send);
-
- if(nread > 0)
- {
- if (CVAL(outbuf,0) == 0)
- show_msg(outbuf);
-
- if (nread != smb_len(outbuf) + 4)
- {
- DEBUG(0,("ERROR: Invalid message response size! %d %d\n",
- nread, smb_len(outbuf)));
- }
- else
- send_smb(Client,outbuf);
- }
- trans_num++;
-}
-
-#ifdef USE_OPLOCKS
-/****************************************************************************
- open the oplock IPC socket communication
-****************************************************************************/
-static BOOL open_oplock_ipc()
-{
- struct sockaddr_in sock_name;
- int name_len = sizeof(sock_name);
-
- DEBUG(3,("open_oplock_ipc: opening loopback UDP socket.\n"));
-
- /* Open a lookback UDP socket on a random port. */
- oplock_sock = open_socket_in(SOCK_DGRAM, 0, 0, htonl(INADDR_LOOPBACK));
- if (oplock_sock == -1)
- {
- DEBUG(0,("open_oplock_ipc: Failed to get local UDP socket for \
-address %x. Error was %s\n", htonl(INADDR_LOOPBACK), strerror(errno)));
- oplock_port = 0;
- return(False);
- }
-
- /* Find out the transient UDP port we have been allocated. */
- if(getsockname(oplock_sock, (struct sockaddr *)&sock_name, &name_len)<0)
- {
- DEBUG(0,("open_oplock_ipc: Failed to get local UDP port. Error was %s\n",
- strerror(errno)));
- close(oplock_sock);
- oplock_sock = -1;
- oplock_port = 0;
- return False;
- }
- oplock_port = ntohs(sock_name.sin_port);
-
- return True;
-}
-
-/****************************************************************************
- process an oplock break message.
-****************************************************************************/
-static BOOL process_local_message(int oplock_sock, char *buffer, int buf_size)
-{
- int32 msg_len;
- int16 from_port;
- char *msg_start;
-
- msg_len = IVAL(buffer,UDP_CMD_LEN_OFFSET);
- from_port = SVAL(buffer,UDP_CMD_PORT_OFFSET);
-
- msg_start = &buffer[UDP_CMD_HEADER_LEN];
-
- DEBUG(5,("process_local_message: Got a message of length %d from port (%d)\n",
- msg_len, from_port));
-
- /* Switch on message command - currently OPLOCK_BREAK_CMD is the
- only valid request. */
-
- switch(SVAL(msg_start,UDP_MESSAGE_CMD_OFFSET))
- {
- case OPLOCK_BREAK_CMD:
- /* Ensure that the msg length is correct. */
- if(msg_len != OPLOCK_BREAK_MSG_LEN)
- {
- DEBUG(0,("process_local_message: incorrect length for OPLOCK_BREAK_CMD (was %d, \
-should be %d).\n", msg_len, OPLOCK_BREAK_MSG_LEN));
- return False;
- }
- {
- uint32 remotepid = IVAL(msg_start,OPLOCK_BREAK_PID_OFFSET);
- uint32 dev = IVAL(msg_start,OPLOCK_BREAK_DEV_OFFSET);
- uint32 inode = IVAL(msg_start, OPLOCK_BREAK_INODE_OFFSET);
- struct timeval tval;
- struct sockaddr_in toaddr;
-
- tval.tv_sec = IVAL(msg_start, OPLOCK_BREAK_SEC_OFFSET);
- tval.tv_usec = IVAL(msg_start, OPLOCK_BREAK_USEC_OFFSET);
-
- DEBUG(5,("process_local_message: oplock break request from \
-pid %d, port %d, dev = %x, inode = %x\n", remotepid, from_port, dev, inode));
-
- /*
- * If we have no record of any currently open oplocks,
- * it's not an error, as a close command may have
- * just been issued on the file that was oplocked.
- * Just return success in this case.
- */
-
- if(global_oplocks_open != 0)
- {
- if(oplock_break(dev, inode, &tval) == False)
- {
- DEBUG(0,("process_local_message: oplock break failed - \
-not returning udp message.\n"));
- return False;
- }
- }
- else
- {
- DEBUG(3,("process_local_message: oplock break requested with no outstanding \
-oplocks. Returning success.\n"));
- }
-
- /* Send the message back after OR'ing in the 'REPLY' bit. */
- SSVAL(msg_start,UDP_MESSAGE_CMD_OFFSET,OPLOCK_BREAK_CMD | CMD_REPLY);
-
- bzero((char *)&toaddr,sizeof(toaddr));
- toaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- toaddr.sin_port = htons(from_port);
- toaddr.sin_family = AF_INET;
-
- if(sendto( oplock_sock, msg_start, OPLOCK_BREAK_MSG_LEN, 0,
- (struct sockaddr *)&toaddr, sizeof(toaddr)) < 0)
- {
- DEBUG(0,("process_local_message: sendto process %d failed. Errno was %s\n",
- remotepid, strerror(errno)));
- return False;
- }
-
- DEBUG(5,("process_local_message: oplock break reply sent to \
-pid %d, port %d, for file dev = %x, inode = %x\n", remotepid,
- from_port, dev, inode));
-
- }
- break;
- default:
- DEBUG(0,("process_local_message: unknown UDP message command code (%x) - ignoring.\n",
- (unsigned int)SVAL(msg_start,0)));
- return False;
- }
- return True;
-}
-
-/****************************************************************************
- Process an oplock break directly.
-****************************************************************************/
-BOOL oplock_break(uint32 dev, uint32 inode, struct timeval *tval)
-{
- extern int Client;
- static char *inbuf = NULL;
- static char *outbuf = NULL;
- files_struct *fsp = NULL;
- int fnum;
- time_t start_time;
- BOOL shutdown_server = False;
-
- DEBUG(5,("oplock_break: called for dev = %x, inode = %x. Current \
-global_oplocks_open = %d\n", dev, inode, global_oplocks_open));
-
- if(inbuf == NULL)
- {
- inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
- if(inbuf == NULL) {
- DEBUG(0,("oplock_break: malloc fail for input buffer.\n"));
- return False;
- }
- outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
- if(outbuf == NULL) {
- DEBUG(0,("oplock_break: malloc fail for output buffer.\n"));
- free(inbuf);
- inbuf = NULL;
- return False;
- }
- }
-
- /* We need to search the file open table for the
- entry containing this dev and inode, and ensure
- we have an oplock on it. */
- for( fnum = 0; fnum < MAX_OPEN_FILES; fnum++)
- {
- if(OPEN_FNUM(fnum))
- {
- fsp = &Files[fnum];
- if((fsp->fd_ptr->dev == dev) && (fsp->fd_ptr->inode == inode) &&
- (fsp->open_time.tv_sec == tval->tv_sec) &&
- (fsp->open_time.tv_usec == tval->tv_usec))
- break;
- }
- }
-
- if(fsp == NULL)
- {
- /* The file could have been closed in the meantime - return success. */
- DEBUG(3,("oplock_break: cannot find open file with dev = %x, inode = %x (fnum = %d) \
-allowing break to succeed.\n", dev, inode, fnum));
- return True;
- }
-
- /* Ensure we have an oplock on the file */
-
- /* There is a potential race condition in that an oplock could
- have been broken due to another udp request, and yet there are
- still oplock break messages being sent in the udp message
- queue for this file. So return true if we don't have an oplock,
- as we may have just freed it.
- */
-
- if(!fsp->granted_oplock)
- {
- DEBUG(3,("oplock_break: file %s (fnum = %d, dev = %x, inode = %x) has no oplock. \
-Allowing break to succeed regardless.\n", fsp->name, fnum, dev, inode));
- return True;
- }
-
- /* Now comes the horrid part. We must send an oplock break to the client,
- and then process incoming messages until we get a close or oplock release.
- */
-
- /* Prepare the SMBlockingX message. */
- bzero(outbuf,smb_size);
- set_message(outbuf,8,0,True);
-
- SCVAL(outbuf,smb_com,SMBlockingX);
- SSVAL(outbuf,smb_tid,fsp->cnum);
- SSVAL(outbuf,smb_pid,0xFFFF);
- SSVAL(outbuf,smb_uid,0);
- SSVAL(outbuf,smb_mid,0xFFFF);
- SCVAL(outbuf,smb_vwv0,0xFF);
- SSVAL(outbuf,smb_vwv2,fnum);
- SCVAL(outbuf,smb_vwv3,LOCKING_ANDX_OPLOCK_RELEASE);
- /* Change this when we have level II oplocks. */
- SCVAL(outbuf,smb_vwv3+1,OPLOCKLEVEL_NONE);
-
- send_smb(Client, outbuf);
-
- global_oplock_break = True;
-
- /* Process incoming messages. */
-
- /* JRA - If we don't get a break from the client in OPLOCK_BREAK_TIMEOUT
- seconds we should just die.... */
-
- start_time = time(NULL);
-
- while(OPEN_FNUM(fnum) && fsp->granted_oplock)
- {
- if(receive_smb(Client,inbuf,OPLOCK_BREAK_TIMEOUT * 1000) == False)
- {
- /*
- * Die if we got an error.
- */
-
- if (smb_read_error == READ_EOF)
- DEBUG(0,("oplock_break: end of file from client\n"));
-
- if (smb_read_error == READ_ERROR)
- DEBUG(0,("oplock_break: receive_smb error (%s)\n",
- strerror(errno)));
-
- if (smb_read_error == READ_TIMEOUT)
- DEBUG(0,("oplock_break: receive_smb timed out after %d seconds.\n",
- OPLOCK_BREAK_TIMEOUT));
-
- DEBUG(0,("oplock_break failed for file %s (fnum = %d, dev = %x, \
-inode = %x).\n", fsp->name, fnum, dev, inode));
- shutdown_server = True;
- break;
- }
- process_smb(inbuf, outbuf);
-
- /* We only need this in case a readraw crossed on the wire. */
- if(global_oplock_break)
- global_oplock_break = False;
-
- /*
- * Die if we go over the time limit.
- */
-
- if((time(NULL) - start_time) > OPLOCK_BREAK_TIMEOUT)
- {
- DEBUG(0,("oplock_break: no break received from client within \
-%d seconds.\n", OPLOCK_BREAK_TIMEOUT));
- DEBUG(0,("oplock_break failed for file %s (fnum = %d, dev = %x, \
-inode = %x).\n", fsp->name, fnum, dev, inode));
- shutdown_server = True;
- break;
- }
- }
-
- /*
- * If the client did not respond we must die.
- */
-
- if(shutdown_server)
- {
- DEBUG(0,("oplock_break: client failure in break - shutting down this smbd.\n"));
- close_sockets();
- close(oplock_sock);
- exit_server("oplock break failure");
- }
-
- if(OPEN_FNUM(fnum))
- {
- /* The lockingX reply will have removed the oplock flag
- from the sharemode. */
- /* Paranoia.... */
- fsp->granted_oplock = False;
- }
-
- global_oplocks_open--;
-
- /* Santity check - remove this later. JRA */
- if(global_oplocks_open < 0)
- {
- DEBUG(0,("oplock_break: global_oplocks_open < 0 (%d). PANIC ERROR\n",
- global_oplocks_open));
- abort();
- }
-
- DEBUG(5,("oplock_break: returning success for fnum = %d, dev = %x, inode = %x. Current \
-global_oplocks_open = %d\n", fnum, dev, inode, global_oplocks_open));
-
- return True;
-}
-
-/****************************************************************************
-Send an oplock break message to another smbd process. If the oplock is held
-by the local smbd then call the oplock break function directly.
-****************************************************************************/
-
-BOOL request_oplock_break(min_share_mode_entry *share_entry,
- uint32 dev, uint32 inode)
-{
- char op_break_msg[OPLOCK_BREAK_MSG_LEN];
- struct sockaddr_in addr_out;
- int pid = getpid();
-
- if(pid == share_entry->pid)
- {
- /* We are breaking our own oplock, make sure it's us. */
- if(share_entry->op_port != oplock_port)
- {
- DEBUG(0,("request_oplock_break: corrupt share mode entry - pid = %d, port = %d \
-should be %d\n", pid, share_entry->op_port, oplock_port));
- return False;
- }
-
- DEBUG(5,("request_oplock_break: breaking our own oplock\n"));
-
- /* Call oplock break direct. */
- return oplock_break(dev, inode, &share_entry->time);
- }
-
- /* We need to send a OPLOCK_BREAK_CMD message to the
- port in the share mode entry. */
-
- SSVAL(op_break_msg,UDP_MESSAGE_CMD_OFFSET,OPLOCK_BREAK_CMD);
- SIVAL(op_break_msg,OPLOCK_BREAK_PID_OFFSET,pid);
- SIVAL(op_break_msg,OPLOCK_BREAK_DEV_OFFSET,dev);
- SIVAL(op_break_msg,OPLOCK_BREAK_INODE_OFFSET,inode);
- SIVAL(op_break_msg,OPLOCK_BREAK_SEC_OFFSET,(uint32)share_entry->time.tv_sec);
- SIVAL(op_break_msg,OPLOCK_BREAK_USEC_OFFSET,(uint32)share_entry->time.tv_usec);
-
- /* set the address and port */
- bzero((char *)&addr_out,sizeof(addr_out));
- addr_out.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- addr_out.sin_port = htons( share_entry->op_port );
- addr_out.sin_family = AF_INET;
-
- DEBUG(3,("request_oplock_break: sending a oplock break message to pid %d on port %d \
-for dev = %x, inode = %x\n", share_entry->pid, share_entry->op_port, dev, inode));
-
- if(sendto(oplock_sock,op_break_msg,OPLOCK_BREAK_MSG_LEN,0,
- (struct sockaddr *)&addr_out,sizeof(addr_out)) < 0)
- {
- DEBUG(0,("request_oplock_break: failed when sending a oplock break message \
-to pid %d on port %d for dev = %x, inode = %x. Error was %s\n",
- share_entry->pid, share_entry->op_port, dev, inode,
- strerror(errno)));
- return False;
- }
-
- /*
- * Now we must await the oplock broken message coming back
- * from the target smbd process. Timeout if it fails to
- * return in OPLOCK_BREAK_TIMEOUT seconds.
- * While we get messages that aren't ours, loop.
- */
-
- while(1)
- {
- char op_break_reply[UDP_CMD_HEADER_LEN+OPLOCK_BREAK_MSG_LEN];
- int32 reply_msg_len;
- int16 reply_from_port;
- char *reply_msg_start;
-
- if(receive_local_message(oplock_sock, op_break_reply, sizeof(op_break_reply),
- OPLOCK_BREAK_TIMEOUT * 1000) == False)
- {
- if(smb_read_error == READ_TIMEOUT)
- DEBUG(0,("request_oplock_break: no response received to oplock break request to \
-pid %d on port %d for dev = %x, inode = %x\n", share_entry->pid,
- share_entry->op_port, dev, inode));
- else
- DEBUG(0,("request_oplock_break: error in response received to oplock break request to \
-pid %d on port %d for dev = %x, inode = %x. Error was (%s).\n", share_entry->pid,
- share_entry->op_port, dev, inode, strerror(errno)));
- return False;
- }
-
- /*
- * If the response we got was not an answer to our message, but
- * was a completely different request, push it onto the pending
- * udp message stack so that we can deal with it in the main loop.
- * It may be another oplock break request to us.
- */
-
- /*
- * Local note from JRA. There exists the possibility of a denial
- * of service attack here by allowing non-root processes running
- * on a local machine sending many of these pending messages to
- * a smbd port. Currently I'm not sure how to restrict the messages
- * I will queue (although I could add a limit to the queue) to
- * those received by root processes only. There should be a
- * way to make this bulletproof....
- */
-
- reply_msg_len = IVAL(op_break_reply,UDP_CMD_LEN_OFFSET);
- reply_from_port = SVAL(op_break_reply,UDP_CMD_PORT_OFFSET);
-
- reply_msg_start = &op_break_reply[UDP_CMD_HEADER_LEN];
-
- if(reply_msg_len != OPLOCK_BREAK_MSG_LEN)
- {
- /* Ignore it. */
- DEBUG(0,("request_oplock_break: invalid message length received. Ignoring\n"));
- continue;
- }
-
- if(((SVAL(reply_msg_start,UDP_MESSAGE_CMD_OFFSET) & CMD_REPLY) == 0) ||
- (reply_from_port != share_entry->op_port) ||
- (memcmp(&reply_msg_start[OPLOCK_BREAK_PID_OFFSET],
- &op_break_msg[OPLOCK_BREAK_PID_OFFSET],
- OPLOCK_BREAK_MSG_LEN - OPLOCK_BREAK_PID_OFFSET) != 0))
- {
- DEBUG(3,("request_oplock_break: received other message whilst awaiting \
-oplock break response from pid %d on port %d for dev = %x, inode = %x.\n",
- share_entry->pid, share_entry->op_port, dev, inode));
- if(push_local_message(op_break_reply, sizeof(op_break_reply)) == False)
- return False;
- }
-
- break;
- }
-
- DEBUG(3,("request_oplock_break: broke oplock.\n"));
-
- return True;
-}
-
-#endif /* USE_OPLOCKS */
/****************************************************************************
check if a snum is in use
@@ -3429,30 +2892,21 @@ int reply_lanman1(char *outbuf)
int secword=0;
BOOL doencrypt = SMBENCRYPT();
time_t t = time(NULL);
- /* We need to save and restore this as it can be destroyed
- if we call another server if security=server
- Thanks to Paul Nelson @ Thursby for pointing this out.
- */
- uint16 mid = SVAL(outbuf, smb_mid);
if (lp_security()>=SEC_USER) secword |= 1;
if (doencrypt) secword |= 2;
set_message(outbuf,13,doencrypt?8:0,True);
SSVAL(outbuf,smb_vwv1,secword);
+#ifdef SMB_PASSWD
/* Create a token value and add it to the outgoing packet. */
if (doencrypt)
generate_next_challenge(smb_buf(outbuf));
+#endif
Protocol = PROTOCOL_LANMAN1;
- if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) {
- DEBUG(3,("using password server validation\n"));
- if (doencrypt) set_challenge(smb_buf(outbuf));
- }
-
CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */
- SSVAL(outbuf,smb_mid,mid); /* Restore possibly corrupted mid */
SSVAL(outbuf,smb_vwv2,max_recv);
SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */
SSVAL(outbuf,smb_vwv4,1);
@@ -3476,32 +2930,45 @@ int reply_lanman2(char *outbuf)
int secword=0;
BOOL doencrypt = SMBENCRYPT();
time_t t = time(NULL);
- /* We need to save and restore this as it can be destroyed
- if we call another server if security=server
- Thanks to Paul Nelson @ Thursby for pointing this out.
- */
- uint16 mid = SVAL(outbuf, smb_mid);
+ struct cli_state *cli = NULL;
+ char cryptkey[8];
+ char crypt_len = 0;
+
+ if (lp_security() == SEC_SERVER) {
+ cli = server_cryptkey();
+ }
+
+ if (cli) {
+ DEBUG(3,("using password server validation\n"));
+ doencrypt = ((cli->sec_mode & 2) != 0);
+ }
if (lp_security()>=SEC_USER) secword |= 1;
if (doencrypt) secword |= 2;
+ if (doencrypt) {
+ crypt_len = 8;
+ if (!cli) {
+#ifdef SMB_PASSWD
+ generate_next_challenge(cryptkey);
+#endif
+ } else {
+ memcpy(cryptkey, cli->cryptkey, 8);
+#ifdef SMB_PASSWD
+ set_challenge(cli->cryptkey);
+#endif
+ }
+ }
+
set_message(outbuf,13,doencrypt?8:0,True);
SSVAL(outbuf,smb_vwv1,secword);
- /* Create a token value and add it to the outgoing packet. */
- if (doencrypt)
- generate_next_challenge(smb_buf(outbuf));
-
SIVAL(outbuf,smb_vwv6,getpid());
+ if (doencrypt)
+ memcpy(smb_buf(outbuf), cryptkey, 8);
Protocol = PROTOCOL_LANMAN2;
- if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) {
- DEBUG(3,("using password server validation\n"));
- if (doencrypt) set_challenge(smb_buf(outbuf));
- }
-
CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */
- SSVAL(outbuf,smb_mid,mid); /* Restore possibly corrupted mid */
SSVAL(outbuf,smb_vwv2,max_recv);
SSVAL(outbuf,smb_vwv3,lp_maxmux());
SSVAL(outbuf,smb_vwv4,1);
@@ -3531,13 +2998,32 @@ int reply_nt1(char *outbuf)
BOOL doencrypt = SMBENCRYPT();
time_t t = time(NULL);
int data_len;
- int encrypt_len;
- char challenge_len = 8;
- /* We need to save and restore this as it can be destroyed
- if we call another server if security=server
- Thanks to Paul Nelson @ Thursby for pointing this out.
- */
- uint16 mid = SVAL(outbuf, smb_mid);
+ struct cli_state *cli = NULL;
+ char cryptkey[8];
+ char crypt_len = 0;
+
+ if (lp_security() == SEC_SERVER) {
+ cli = server_cryptkey();
+ }
+
+ if (cli) {
+ DEBUG(3,("using password server validation\n"));
+ doencrypt = ((cli->sec_mode & 2) != 0);
+ }
+
+ if (doencrypt) {
+ crypt_len = 8;
+ if (!cli) {
+#ifdef SMB_PASSWD
+ generate_next_challenge(cryptkey);
+#endif
+ } else {
+ memcpy(cryptkey, cli->cryptkey, 8);
+#ifdef SMB_PASSWD
+ set_challenge(cli->cryptkey);
+#endif
+ }
+ }
if (lp_readraw() && lp_writeraw())
{
@@ -3550,40 +3036,18 @@ int reply_nt1(char *outbuf)
/* decide where (if) to put the encryption challenge, and
follow it with the OEM'd domain name
*/
- encrypt_len = doencrypt?challenge_len:0;
-#if UNICODE
- data_len = encrypt_len + 2*(strlen(myworkgroup)+1);
-#else
- data_len = encrypt_len + strlen(myworkgroup) + 1;
-#endif
+ data_len = crypt_len + strlen(myworkgroup) + 1;
set_message(outbuf,17,data_len,True);
-
-#if UNICODE
- /* put the OEM'd domain name */
- PutUniCode(smb_buf(outbuf)+encrypt_len,myworkgroup);
-#else
- strcpy(smb_buf(outbuf)+encrypt_len, myworkgroup);
-#endif
+ strcpy(smb_buf(outbuf)+crypt_len, myworkgroup);
CVAL(outbuf,smb_vwv1) = secword;
- /* Create a token value and add it to the outgoing packet. */
- if (doencrypt)
- {
- generate_next_challenge(smb_buf(outbuf));
-
- /* Tell the nt machine how long the challenge is. */
- SSVALS(outbuf,smb_vwv16+1,challenge_len);
- }
+ SSVALS(outbuf,smb_vwv16+1,crypt_len);
+ if (doencrypt)
+ memcpy(smb_buf(outbuf), cryptkey, 8);
Protocol = PROTOCOL_NT1;
- if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) {
- DEBUG(3,("using password server validation\n"));
- if (doencrypt) set_challenge(smb_buf(outbuf));
- }
-
- SSVAL(outbuf,smb_mid,mid); /* Restore possibly corrupted mid */
SSVAL(outbuf,smb_vwv1+1,lp_maxmux()); /* maxmpx */
SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
@@ -3791,7 +3255,7 @@ static void close_open_files(int cnum)
int i;
for (i=0;i<MAX_OPEN_FILES;i++)
if( Files[i].cnum == cnum && Files[i].open) {
- close_file(i);
+ close_file(i, 0);
}
}
@@ -3804,6 +3268,10 @@ void close_cnum(int cnum, uint16 vuid)
{
DirCacheFlush(SNUM(cnum));
+ close_open_files(cnum);
+ dptr_closecnum(cnum);
+
+ /* after this we are running as root, so be careful! */
unbecome_user();
if (!OPEN_CNUM(cnum))
@@ -3824,9 +3292,6 @@ void close_cnum(int cnum, uint16 vuid)
if (lp_status(SNUM(cnum)))
yield_connection(cnum,"STATUS.",MAXSTATUS);
- close_open_files(cnum);
- dptr_closecnum(cnum);
-
/* execute any "postexec = " line */
if (*lp_postexec(SNUM(cnum)) && become_user(cnum,vuid))
{
@@ -4556,11 +4021,14 @@ int construct_reply(char *inbuf,char *outbuf,int size,int bufsize)
return(outsize);
}
+
/****************************************************************************
process commands from the client
****************************************************************************/
static void process(void)
{
+ static int trans_num = 0;
+ int nread;
extern int Client;
InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
@@ -4583,36 +4051,32 @@ static void process(void)
#endif
while (True)
- {
- int deadtime = lp_deadtime()*60;
- int counter;
- int last_keepalive=0;
- int service_load_counter = 0;
-#ifdef USE_OPLOCKS
- BOOL got_smb = False;
-#endif /* USE_OPLOCKS */
-
- if (deadtime <= 0)
- deadtime = DEFAULT_SMBD_TIMEOUT;
-
- if (lp_readprediction())
- do_read_prediction();
-
- errno = 0;
-
- for (counter=SMBD_SELECT_LOOP;
-#ifdef USE_OPLOCKS
- !receive_message_or_smb(Client,oplock_sock,
- InBuffer,BUFFER_SIZE,SMBD_SELECT_LOOP*1000,&got_smb);
-#else /* USE_OPLOCKS */
- !receive_smb(Client,InBuffer,SMBD_SELECT_LOOP*1000);
-#endif /* USE_OPLOCKS */
- counter += SMBD_SELECT_LOOP)
{
- int i;
- time_t t;
- BOOL allidle = True;
- extern int keepalive;
+ int32 len;
+ int msg_type;
+ int msg_flags;
+ int type;
+ int deadtime = lp_deadtime()*60;
+ int counter;
+ int last_keepalive=0;
+ int service_load_counter = 0;
+
+ if (deadtime <= 0)
+ deadtime = DEFAULT_SMBD_TIMEOUT;
+
+ if (lp_readprediction())
+ do_read_prediction();
+
+ errno = 0;
+
+ for (counter=SMBD_SELECT_LOOP;
+ !receive_smb(Client,InBuffer,SMBD_SELECT_LOOP*1000);
+ counter += SMBD_SELECT_LOOP)
+ {
+ int i;
+ time_t t;
+ BOOL allidle = True;
+ extern int keepalive;
if (counter > 365 * 3600) /* big number of seconds. */
{
@@ -4620,84 +4084,126 @@ static void process(void)
service_load_counter = 0;
}
- if (smb_read_error == READ_EOF)
- {
- DEBUG(3,("end of file from client\n"));
- return;
- }
+ if (smb_read_error == READ_EOF) {
+ DEBUG(3,("end of file from client\n"));
+ return;
+ }
- if (smb_read_error == READ_ERROR)
- {
- DEBUG(3,("receive_smb error (%s) exiting\n",
- strerror(errno)));
- return;
- }
+ if (smb_read_error == READ_ERROR) {
+ DEBUG(3,("receive_smb error (%s) exiting\n",
+ strerror(errno)));
+ return;
+ }
- t = time(NULL);
+ t = time(NULL);
- /* become root again if waiting */
- unbecome_user();
+ /* become root again if waiting */
+ unbecome_user();
- /* check for smb.conf reload */
- if (counter >= service_load_counter + SMBD_RELOAD_CHECK)
+ /* check for smb.conf reload */
+ if (counter >= service_load_counter + SMBD_RELOAD_CHECK)
{
service_load_counter = counter;
/* reload services, if files have changed. */
- reload_services(True);
+ reload_services(True);
}
- /* automatic timeout if all connections are closed */
- if (num_connections_open==0 && counter >= IDLE_CLOSED_TIMEOUT)
- {
- DEBUG(2,("%s Closing idle connection\n",timestring()));
- return;
- }
+ /* automatic timeout if all connections are closed */
+ if (num_connections_open==0 && counter >= IDLE_CLOSED_TIMEOUT) {
+ DEBUG(2,("%s Closing idle connection\n",timestring()));
+ return;
+ }
- if (keepalive && (counter-last_keepalive)>keepalive)
- {
- extern int password_client;
- if (!send_keepalive(Client))
- {
- DEBUG(2,("%s Keepalive failed - exiting\n",timestring()));
- return;
- }
- /* also send a keepalive to the password server if its still
- connected */
- if (password_client != -1)
- send_keepalive(password_client);
- last_keepalive = counter;
+ if (keepalive && (counter-last_keepalive)>keepalive) {
+ struct cli_state *cli = server_client();
+ if (!send_keepalive(Client)) {
+ DEBUG(2,("%s Keepalive failed - exiting\n",timestring()));
+ return;
+ }
+ /* also send a keepalive to the password server if its still
+ connected */
+ if (cli && cli->initialised)
+ send_keepalive(cli->fd);
+ last_keepalive = counter;
+ }
+
+ /* check for connection timeouts */
+ for (i=0;i<MAX_CONNECTIONS;i++)
+ if (Connections[i].open)
+ {
+ /* close dirptrs on connections that are idle */
+ if ((t-Connections[i].lastused)>DPTR_IDLE_TIMEOUT)
+ dptr_idlecnum(i);
+
+ if (Connections[i].num_files_open > 0 ||
+ (t-Connections[i].lastused)<deadtime)
+ allidle = False;
+ }
+
+ if (allidle && num_connections_open>0) {
+ DEBUG(2,("%s Closing idle connection 2\n",timestring()));
+ return;
+ }
+ }
+
+ if (trans_num == 0) {
+ /* on the first packet, check the global hosts allow/ hosts
+ deny parameters before doing any parsing of the packet
+ passed to us by the client. This prevents attacks on our
+ parsing code from hosts not in the hosts allow list */
+ if (!check_access(-1)) {
+ /* send a negative session response "not listining
+ on calling name" */
+ static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81};
+ DEBUG(1,("%s Connection denied from %s\n",
+ timestring(),client_addr()));
+ send_smb(Client,(char *)buf);
+ exit_server("connection denied");
+ }
}
- /* check for connection timeouts */
- for (i=0;i<MAX_CONNECTIONS;i++)
- if (Connections[i].open)
- {
- /* close dirptrs on connections that are idle */
- if ((t-Connections[i].lastused)>DPTR_IDLE_TIMEOUT)
- dptr_idlecnum(i);
- if (Connections[i].num_files_open > 0 ||
- (t-Connections[i].lastused)<deadtime)
- allidle = False;
- }
+ msg_type = CVAL(InBuffer,0);
+ msg_flags = CVAL(InBuffer,1);
+ type = CVAL(InBuffer,smb_com);
- if (allidle && num_connections_open>0)
- {
- DEBUG(2,("%s Closing idle connection 2\n",timestring()));
+ len = smb_len(InBuffer);
+
+ DEBUG(6,("got message type 0x%x of len 0x%x\n",msg_type,len));
+
+ nread = len + 4;
+
+ DEBUG(3,("%s Transaction %d of length %d\n",timestring(),trans_num,nread));
+
+#ifdef WITH_VTP
+ if(trans_num == 1 && VT_Check(InBuffer)) {
+ VT_Process();
return;
}
- }
+#endif
-#ifdef USE_OPLOCKS
- if(got_smb)
-#endif /* USE_OPLOCKS */
- process_smb(InBuffer, OutBuffer);
-#ifdef USE_OPLOCKS
- else
- process_local_message(oplock_sock, InBuffer, BUFFER_SIZE);
-#endif /* USE_OPLOCKS */
- }
+
+ if (msg_type == 0)
+ show_msg(InBuffer);
+
+ nread = construct_reply(InBuffer,OutBuffer,nread,max_send);
+
+ if(nread > 0) {
+ if (CVAL(OutBuffer,0) == 0)
+ show_msg(OutBuffer);
+
+ if (nread != smb_len(OutBuffer) + 4)
+ {
+ DEBUG(0,("ERROR: Invalid message response size! %d %d\n",
+ nread,
+ smb_len(OutBuffer)));
+ }
+ else
+ send_smb(Client,OutBuffer);
+ }
+ trans_num++;
+ }
}
@@ -4976,12 +4482,6 @@ static void usage(char *pname)
DEBUG(2,("%s changed root to %s\n",timestring(),lp_rootdir()));
}
-#ifdef USE_OPLOCKS
- /* Setup the oplock IPC socket. */
- if(!open_oplock_ipc())
- exit(1);
-#endif /* USE_OPLOCKS */
-
process();
close_sockets();
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 7f46604cce9..b976553a9f4 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -166,7 +166,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
char *params = *pparams;
int16 open_mode = SVAL(params, 2);
int16 open_attr = SVAL(params,6);
- BOOL oplock_request = (((SVAL(params,0)|(1<<1))>>1) | ((SVAL(params,0)|(1<<2))>>1));
+ BOOL oplock_request = BITSETW(params,1);
#if 0
BOOL return_additional_info = BITSETW(params,0);
int16 open_sattr = SVAL(params, 4);
@@ -213,7 +213,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
open_file_shared(fnum,cnum,fname,open_mode,open_ofun,unixmode,
- oplock_request, &rmode,&smb_action);
+ &rmode,&smb_action);
if (!Files[fnum].open)
{
@@ -226,7 +226,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
}
if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
- close_file(fnum);
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -235,7 +235,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
mtime = sbuf.st_mtime;
inode = sbuf.st_ino;
if (fmode & aDIR) {
- close_file(fnum);
+ close_file(fnum, 0);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -252,7 +252,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
SSVAL(params,12,rmode);
if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- smb_action |= EXTENDED_OPLOCK_GRANTED;
+ smb_action |= (1<<15);
}
SSVAL(params,18,smb_action);
@@ -319,7 +319,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
reskey = TellDir(Connections[cnum].dirptr);
- DEBUG(8,("get_lanman2_dir_entry:readdir on dirptr 0x%x now at offset %d\n",
+ DEBUG(6,("get_lanman2_dir_entry:readdir on dirptr 0x%x now at offset %d\n",
Connections[cnum].dirptr,TellDir(Connections[cnum].dirptr)));
if (!dname)
@@ -607,15 +607,6 @@ static int call_trans2findfirst(char *inbuf, char *outbuf, int bufsize, int cnum
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-
- /* Ugly - NT specific hack - but needed (JRA) */
- if((errno == ENOTDIR) && (Protocol >= PROTOCOL_NT1) &&
- (get_remote_arch() == RA_WINNT))
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbaddirectory;
- }
-
return(ERROR(ERRDOS,ERRbadpath));
}
@@ -650,14 +641,6 @@ static int call_trans2findfirst(char *inbuf, char *outbuf, int bufsize, int cnum
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadpath;
}
-
- /* Ugly - NT specific hack - but needed (JRA) */
- if((errno == ENOTDIR) && (Protocol >= PROTOCOL_NT1) &&
- (get_remote_arch() == RA_WINNT))
- {
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbaddirectory;
- }
return (UNIXERROR(ERRDOS,ERRbadpath));
}
return(ERROR(ERRDOS,ERRbadpath));
@@ -1364,14 +1347,6 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
tvs.modtime=MAX(interpret_long_date(pdata+16),
interpret_long_date(pdata+24));
-#if 0 /* Needs more testing... */
- /* Test from Luke to prevent Win95 from
- setting incorrect values here.
- */
- if (tvs.actime < tvs.modtime)
- return(ERROR(ERRDOS,ERRnoaccess));
-#endif /* Needs more testing... */
-
/* attributes */
mode = IVAL(pdata,32);
break;
@@ -1408,7 +1383,7 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
*/
if (st.st_mtime != tvs.modtime || st.st_atime != tvs.actime)
{
- if(sys_utime(fname, &tvs)!=0)
+ if(file_utime(cnum,fname, &tvs)!=0)
{
return(ERROR(ERRDOS,ERRnoaccess));
}
diff --git a/source/smbd/uid.c b/source/smbd/uid.c
index cdc4e474c61..db1e5e94c3b 100644
--- a/source/smbd/uid.c
+++ b/source/smbd/uid.c
@@ -258,6 +258,8 @@ BOOL become_user(int cnum, uint16 vuid)
if (current_user.ngroups > 0)
if (setgroups(current_user.ngroups,current_user.groups)<0)
DEBUG(0,("setgroups call failed!\n"));
+ } else {
+ current_user.ngroups = 0;
}
#endif
@@ -318,7 +320,8 @@ BOOL unbecome_user(void )
current_user.uid = initial_uid;
current_user.gid = initial_gid;
-
+ current_user.ngroups = 0;
+
if (ChDir(OriginalDir) != 0)
DEBUG(0,("%s chdir(%s) failed in unbecome_user\n",
timestring(),OriginalDir));
@@ -476,3 +479,82 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
#endif
return 1;
}
+
+
+
+static struct current_user current_user_saved;
+static int become_root_depth;
+static pstring become_root_dir;
+
+/****************************************************************************
+This is used when we need to do a privilaged operation (such as mucking
+with share mode files) and temporarily need root access to do it. This
+call should always be paired with an unbecome_root() call immediately
+after the operation
+
+Set save_dir if you also need to save/restore the CWD
+****************************************************************************/
+void become_root(int save_dir)
+{
+ if (become_root_depth) {
+ DEBUG(0,("ERROR: become root depth is non zero\n"));
+ }
+ if (save_dir)
+ GetWd(become_root_dir);
+
+ current_user_saved = current_user;
+ become_root_depth = 1;
+
+ become_uid(0);
+ become_gid(0);
+}
+
+/****************************************************************************
+When the privilaged operation is over call this
+
+Set save_dir if you also need to save/restore the CWD
+****************************************************************************/
+void unbecome_root(int restore_dir)
+{
+ if (become_root_depth != 1) {
+ DEBUG(0,("ERROR: unbecome root depth is %d\n",
+ become_root_depth));
+ }
+
+ /* we might have done a become_user() while running as root,
+ if we have then become root again in order to become
+ non root! */
+ if (current_user.uid != 0) {
+ become_uid(0);
+ }
+
+ /* restore our gid first */
+ if (!become_gid(current_user_saved.gid)) {
+ DEBUG(0,("ERROR: Failed to restore gid\n"));
+ exit_server("Failed to restore gid");
+ }
+
+#ifndef NO_SETGROUPS
+ if (current_user_saved.ngroups > 0) {
+ if (setgroups(current_user_saved.ngroups,
+ current_user_saved.groups)<0)
+ DEBUG(0,("ERROR: setgroups call failed!\n"));
+ }
+#endif
+
+ /* now restore our uid */
+ if (!become_uid(current_user_saved.uid)) {
+ DEBUG(0,("ERROR: Failed to restore uid\n"));
+ exit_server("Failed to restore uid");
+ }
+
+ if (restore_dir)
+ ChDir(become_root_dir);
+
+ current_user = current_user_saved;
+
+ become_root_depth = 0;
+}
+
+
+
diff --git a/source/utils/make_smbcodepage.c b/source/utils/make_smbcodepage.c
deleted file mode 100644
index b4cb1523349..00000000000
--- a/source/utils/make_smbcodepage.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- Create codepage files from codepage_def.XXX files.
-
- Copyright (C) Jeremy Allison 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-
-static char *prog_name = NULL;
-
-/*
- * Print program usage and die.
- */
-
-void codepage_usage(char *progname)
-{
- fprintf(stderr, "Usage is : %s [c|d] <codepage> <inputfile> <outputfile>\n",
- progname);
- exit(1);
-}
-
-/*
- * Read a line from a buffer into a line buffer. Ensure null
- * terminated.
- */
-
-void read_line( char **buf, char *line_buf, int size)
-{
- char *p = *buf;
- int num = 0;
-
- for(; *p && (*p != '\n'); p++)
- {
- if(num < (size - 1))
- line_buf[num++] = *p;
- }
- if(*p)
- p++; /* Go past the '\n' */
- line_buf[num] = '\0';
- *buf = p;
-}
-
-/*
- * Strip comment lines and blank lines from the data.
- * Copies into a new buffer and frees the old.
- * Returns the number of lines copied.
- */
-
-int clean_data( char **buf, uint32 *size)
-{
- char linebuf[512];
- char *p = *buf;
- int num_lines = 0;
- char *newbuf = (char *)malloc( *size + 1);
- char *newbuf_p = NULL;
-
- if(newbuf == NULL)
- {
- fprintf(stderr, "%s: malloc fail for size %d.\n", prog_name, *size + 1);
- exit(1);
- }
-
- newbuf_p = newbuf;
- *newbuf_p = '\0';
-
- while( *p )
- {
- char *cp;
-
- read_line( &p, linebuf, sizeof(linebuf));
- /* Null terminate after comment. */
- if((cp = strchr( linebuf, '#'))!= NULL)
- *cp = '\0';
-
- for(cp = linebuf;*cp && isspace(*cp); cp++)
- ;
-
- if(*cp == '\0')
- continue;
-
- strcpy(newbuf_p, cp);
- num_lines++;
- newbuf_p += (strlen(newbuf_p) + 1);
- }
-
- free(*buf);
- *buf = newbuf;
- return num_lines;
-}
-
-/*
- * Parse a byte from a codepage file.
- */
-
-BOOL parse_byte(char *buf, unsigned char *bp)
-{
- unsigned int b;
- char *endptr = NULL;
-
- b = (unsigned int)strtol(buf, &endptr, 0);
- if(endptr == buf || b > 255)
- return False;
-
- *bp = (unsigned char)b;
- return True;
-}
-
-/*
- * Parse a bool from a codepage file.
- */
-
-BOOL parse_bool(char *buf, unsigned char *bp)
-{
- if(isdigit(*buf))
- {
- char *endptr = NULL;
-
- *bp = (unsigned char)strtol(buf, &endptr, 0);
- if(endptr == buf )
- return False;
- if(*bp != 0)
- *bp = 1;
- } else {
- if(strcasecmp(buf, "True") && strcasecmp(buf, "False"))
- return False;
- if(strcasecmp(buf, "True")==0)
- *bp = 1;
- else
- *bp = 0;
- }
- return True;
-}
-
-/*
- * Print a parse error and exit.
- */
-
-void parse_error(char *buf, char *msg)
-{
- fprintf(stderr, "%s: %s whilst parsing line \n%s\n", prog_name,
- msg, buf);
- exit(1);
-}
-
-/*
- * Create a compiled codepage file from a codepage definition file.
- */
-
-int do_compile(int codepage, char *input_file, char *output_file)
-{
- FILE *fp = NULL;
- uint32 size = 0;
- char *buf = NULL;
- char output_buf[CODEPAGE_HEADER_SIZE + 512];
- int num_lines = 0;
- int i = 0;
- struct stat st;
-
- /* Get the size of the input file. Read the entire thing into memory. */
- if(stat((char *)input_file, &st)!= 0)
- {
- fprintf(stderr, "%s: failed to get the file size for file %s. Error was %s\n",
- prog_name, input_file, strerror(errno));
- exit(1);
- }
-
- size = (uint32)st.st_size;
-
- /* I don't believe these things should be bigger than 100k :-) */
- if(size > 100*1024)
- {
- fprintf(stderr, "%s: filesize %d is too large for a codepage definition file. \
-The maximum size I will believe is 100k.\n", prog_name, size);
- exit(1);
- }
-
- if((fp = fopen(input_file, "r")) == NULL)
- {
- fprintf(stderr, "%s: cannot open file %s for input.\n", prog_name, input_file);
- exit(1);
- }
-
- /* As we will be reading text, allocate one more byte for a '\0' */
- if((buf = (char *)malloc( size + 1 )) == NULL)
- {
- fprintf(stderr, "%s: malloc fail for size %d.\n", prog_name, size + 1);
- fclose(fp);
- exit(1);
- }
-
- if(fread( buf, 1, size, fp) != size)
- {
- fprintf(stderr, "%s: read failed for file %s. Error was %s.\n", prog_name,
- input_file, strerror(errno));
- free((char *)buf);
- fclose(fp);
- exit(1);
- }
-
- /* Null terminate the text read. */
- buf[size] = '\0';
-
- /* Go through the data line by line, strip out comments (anything
- after a '#' to end-of-line) and blank lines. The rest should be
- the codepage data.
- */
-
- num_lines = clean_data( &buf, &size);
-
- /* There can be a maximum of 128 lines. */
- if(num_lines > 128)
- {
- fprintf(stderr, "%s: There can be a maximum 128 lines of data in a codepage \
-definition file. File %s has %d.\n", prog_name, input_file, num_lines);
- exit(1);
- }
-
- /* Setup the output file header. */
- SSVAL(output_buf,CODEPAGE_VERSION_OFFSET,CODEPAGE_FILE_VERSION_ID);
- SSVAL(output_buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET,(uint16)codepage);
- SIVAL(output_buf,CODEPAGE_LENGTH_OFFSET,(num_lines * 4));
-
- /* Now convert the lines into the compiled form. */
- for(i = 0; i < num_lines; i++)
- {
- char token_buf[512];
- char *p = buf;
- unsigned char b = 0;
-
- /* Get the 'lower' value. */
- if(!next_token(&p, token_buf, NULL))
- parse_error(buf, "cannot parse first value");
- if(!parse_byte( token_buf, &b))
- parse_error(buf, "first value doesn't resolve to a byte");
-
- /* Add this to the output buffer. */
- SCVAL(output_buf,CODEPAGE_HEADER_SIZE+(i*4),b);
-
- /* Get the 'upper' value. */
- if(!next_token(&p, token_buf, NULL))
- parse_error(buf, "cannot parse second value");
- if(!parse_byte( token_buf, &b))
- parse_error(buf, "second value doesn't resolve to a byte");
-
- /* Add this to the output buffer. */
- SCVAL(output_buf,CODEPAGE_HEADER_SIZE+(i*4) + 1,b);
-
- /* Get the 'upper to lower' value. */
- if(!next_token(&p, token_buf, NULL))
- parse_error(buf, "cannot parse third value");
- if(!parse_bool( token_buf, &b))
- parse_error(buf, "third value doesn't resolve to a boolean");
-
- /* Add this to the output buffer. */
- SCVAL(output_buf,CODEPAGE_HEADER_SIZE+(i*4) + 2,b);
-
- /* Get the 'lower to upper' value. */
- if(!next_token(&p, token_buf, NULL))
- parse_error(buf, "cannot parse fourth value");
- if(!parse_bool( token_buf, &b))
- parse_error(buf, "fourth value doesn't resolve to a boolean");
-
- /* Add this to the output buffer. */
- SCVAL(output_buf,CODEPAGE_HEADER_SIZE+(i*4) + 3,b);
-
- buf += (strlen(buf) + 1);
- }
-
- /* Now write out the output_buf. */
- if((fp = fopen(output_file, "w"))==NULL)
- {
- fprintf(stderr, "%s: Cannot open output file %s. Error was %s.\n",
- prog_name, output_file, strerror(errno));
- exit(1);
- }
-
- if(fwrite(output_buf, 1, CODEPAGE_HEADER_SIZE + (num_lines*4), fp) !=
- CODEPAGE_HEADER_SIZE + (num_lines*4))
- {
- fprintf(stderr, "%s: Cannot write output file %s. Error was %s.\n",
- prog_name, output_file, strerror(errno));
- exit(1);
- }
-
- fclose(fp);
-
- return 0;
-}
-
-/*
- * Placeholder for now.
- */
-
-int do_decompile( int codepage, char *input_file, char *output_file)
-{
- uint32 size = 0;
- struct stat st;
- char header_buf[CODEPAGE_HEADER_SIZE];
- char *buf = NULL;
- FILE *fp = NULL;
- int num_lines = 0;
- int i = 0;
-
- /* Get the size of the input file. Read the entire thing into memory. */
- if(stat((char *)input_file, &st)!= 0)
- {
- fprintf(stderr, "%s: failed to get the file size for file %s. Error was %s\n",
- prog_name, input_file, strerror(errno));
- exit(1);
- }
-
- size = (uint32)st.st_size;
-
- if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 256))
- {
- fprintf(stderr, "%s: file %s is an incorrect size for a \
-code page file.\n", prog_name, input_file);
- exit(1);
- }
-
- /* Read the first 8 bytes of the codepage file - check
- the version number and code page number. All the data
- is held in little endian format.
- */
-
- if((fp = fopen( input_file, "r")) == NULL)
- {
- fprintf(stderr, "%s: cannot open file %s. Error was %s\n",
- prog_name, input_file, strerror(errno));
- exit(1);
- }
-
- if(fread( header_buf, 1, CODEPAGE_HEADER_SIZE, fp)!=CODEPAGE_HEADER_SIZE)
- {
- fprintf(stderr, "%s: cannot read header from file %s. Error was %s\n",
- prog_name, input_file, strerror(errno));
- exit(1);
- }
-
- /* Check the version value */
- if(SVAL(header_buf,CODEPAGE_VERSION_OFFSET) != CODEPAGE_FILE_VERSION_ID)
- {
- fprintf(stderr, "%s: filename %s has incorrect version id. \
-Needed %hu, got %hu.\n",
- prog_name, input_file, (uint16)CODEPAGE_FILE_VERSION_ID,
- SVAL(header_buf,CODEPAGE_VERSION_OFFSET));
- exit(1);
- }
-
- /* Check the codepage matches */
- if(SVAL(header_buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET) != (uint16)codepage)
- {
- fprintf(stderr, "%s: filename %s has incorrect codepage. \
-Needed %hu, got %hu.\n",
- prog_name, input_file, (uint16)codepage,
- SVAL(header_buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET));
- exit(1);
- }
-
- /* Check the length is correct. */
- if(IVAL(header_buf,CODEPAGE_LENGTH_OFFSET) !=
- (unsigned int)(size - CODEPAGE_HEADER_SIZE))
- {
- fprintf(stderr, "%s: filename %s has incorrect size headers. \
-Needed %u, got %u.\n", prog_name, input_file, size - CODEPAGE_HEADER_SIZE,
- IVAL(header_buf,CODEPAGE_LENGTH_OFFSET));
- exit(1);
- }
-
- size -= CODEPAGE_HEADER_SIZE; /* Remove header */
-
- /* Make sure the size is a multiple of 4. */
- if((size % 4 ) != 0)
- {
- fprintf(stderr, "%s: filename %s has a codepage size not a \
-multiple of 4.\n", prog_name, input_file);
- exit(1);
- }
-
- /* Allocate space for the code page file and read it all in. */
- if((buf = (char *)malloc( size )) == NULL)
- {
- fprintf (stderr, "%s: malloc fail for size %d.\n",
- prog_name, size );
- exit(1);
- }
-
- if(fread( buf, 1, size, fp)!=size)
- {
- fprintf(stderr, "%s: read fail on file %s. Error was %s.\n",
- prog_name, input_file, strerror(errno));
- exit(1);
- }
-
- fclose(fp);
-
- /* Now dump the codepage into an ascii file. */
- if((fp = fopen(output_file, "w")) == NULL)
- {
- fprintf(stderr, "%s: cannot open file %s. Error was %s\n",
- prog_name, output_file, strerror(errno));
- exit(1);
- }
-
- fprintf(fp, "#\n# Codepage definition file for IBM Code Page %d.\n#\n",
- codepage);
- fprintf(fp, "# This file was automatically generated.\n#\n");
- fprintf(fp, "# defines lower->upper mapping.\n");
- fprintf(fp, "#\n#The columns are :\n# lower\tupper\tu-t-l\tl-t-u\n#\n");
-
- num_lines = size / 4;
- for( i = 0; i < num_lines; i++)
- {
- fprintf(fp, "0x%02X\t0x%02X\t%s\t%s\n", CVAL(buf, (i*4)), CVAL(buf, (i*4)+1),
- CVAL(buf, (i*4)+2) ? "True" : "False",
- CVAL(buf, (i*4)+3) ? "True" : "False");
- }
- fclose(fp);
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- int codepage = 0;
- char *input_file = NULL;
- char *output_file = NULL;
- BOOL compile = False;
-
- prog_name = argv[0];
-
- if(argc != 5)
- codepage_usage(prog_name);
-
- if(argv[1][0] != 'c' && argv[1][0] != 'C' && argv[1][0] != 'd' &&
- argv[1][0] != 'D')
- codepage_usage(prog_name);
-
- input_file = argv[3];
- output_file = argv[4];
-
- /* Are we compiling or decompiling. */
- if(argv[1][0] == 'c' || argv[1][0] == 'C')
- compile = True;
-
- /* Convert the second argument into a client codepage value. */
- if((codepage = atoi(argv[2])) == 0)
- {
- fprintf(stderr, "%s: %s is not a valid codepage.\n", prog_name, argv[2]);
- exit(1);
- }
-
- if(compile)
- return do_compile( codepage, input_file, output_file);
- else
- return do_decompile( codepage, input_file, output_file);
-}
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index 36905aa5ae3..aebbc4292ca 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -35,8 +35,6 @@ extern struct in_addr ipzero;
int ServerFD= -1;
-int RootPort = 0;
-
/****************************************************************************
open the socket communication
**************************************************************************/
@@ -51,10 +49,7 @@ static BOOL open_sockets(void)
return False;
}
- ServerFD = open_socket_in( SOCK_DGRAM,
- (RootPort ? 137 :0),
- 3,
- interpret_addr(lp_socket_address()) );
+ ServerFD = open_socket_in(SOCK_DGRAM, 0,3,interpret_addr(lp_socket_address()));
if (ServerFD == -1)
return(False);
@@ -118,7 +113,7 @@ int main(int argc,char *argv[])
charset_initialise();
- while ((opt = getopt(argc, argv, "d:B:i:s:SMrh")) != EOF)
+ while ((opt = getopt(argc, argv, "p:d:B:i:s:SMh")) != EOF)
switch (opt)
{
case 'B':
@@ -142,9 +137,6 @@ int main(int argc,char *argv[])
case 's':
pstrcpy(servicesf, optarg);
break;
- case 'r':
- RootPort = -1;
- break;
case 'h':
usage();
exit(0);
diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c
index d20ff42c0e8..161555d52cc 100644
--- a/source/utils/smbpasswd.c
+++ b/source/utils/smbpasswd.c
@@ -1,3 +1,5 @@
+#ifdef SMB_PASSWD
+
/*
* Unix SMB/Netbios implementation. Version 1.9. smbpasswd module. Copyright
* (C) Jeremy Allison 1995-1997.
@@ -18,6 +20,7 @@
*/
#include "includes.h"
+#include "des.h"
/* Static buffers we will return. */
static struct smb_passwd pw_buf;
@@ -375,24 +378,14 @@ static void usage(char *name)
* Open the smbpaswd file XXXX - we need to parse smb.conf to get the
* filename
*/
- fp = fopen(pfile, "r+");
- if (!fp && errno == ENOENT) {
- fp = fopen(pfile, "w");
- if (fp) {
- fprintf(fp, "# Samba SMB password file\n");
- fclose(fp);
- fp = fopen(pfile, "r+");
- }
- }
- if (!fp) {
- err = errno;
- fprintf(stderr, "%s: Failed to open password file %s.\n",
- argv[0], pfile);
- errno = err;
- perror(argv[0]);
- exit(err);
+ if ((fp = fopen(pfile, "r+")) == NULL) {
+ err = errno;
+ fprintf(stderr, "%s: Failed to open password file %s.\n",
+ argv[0], pfile);
+ errno = err;
+ perror(argv[0]);
+ exit(err);
}
-
/* Set read buffer to 16k for effiecient reads */
setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
@@ -424,8 +417,10 @@ static void usage(char *name)
/* Create a new smb passwd entry and set it to the given password. */
{
int fd;
+ int i;
int new_entry_length;
char *new_entry;
+ char *p;
long offpos;
/* The add user write needs to be atomic - so get the fd from
@@ -435,7 +430,7 @@ static void usage(char *name)
if((offpos = lseek(fd, 0, SEEK_END)) == -1) {
fprintf(stderr, "%s: Failed to add entry for user %s to file %s. \
-Error was %s\n", argv[0], pwd->pw_name, pfile, strerror(errno));
+Error was %d\n", argv[0], pwd->pw_name, pfile, errno);
fclose(fp);
pw_file_unlock(lockfd);
exit(1);
@@ -447,7 +442,7 @@ Error was %s\n", argv[0], pwd->pw_name, pfile, strerror(errno));
strlen(pwd->pw_shell) + 1;
if((new_entry = (char *)malloc( new_entry_length )) == 0) {
fprintf(stderr, "%s: Failed to add entry for user %s to file %s. \
-Error was %s\n", argv[0], pwd->pw_name, pfile, strerror(errno));
+Error was %d\n", argv[0], pwd->pw_name, pfile, errno);
fclose(fp);
pw_file_unlock(lockfd);
exit(1);
@@ -467,12 +462,12 @@ Error was %s\n", argv[0], pwd->pw_name, pfile, strerror(errno));
pwd->pw_dir, pwd->pw_shell);
if(write(fd, new_entry, strlen(new_entry)) != strlen(new_entry)) {
fprintf(stderr, "%s: Failed to add entry for user %s to file %s. \
-Error was %s\n", argv[0], pwd->pw_name, pfile, strerror(errno));
+Error was %d\n", argv[0], pwd->pw_name, pfile, errno);
/* Remove the entry we just wrote. */
if(ftruncate(fd, offpos) == -1) {
fprintf(stderr, "%s: ERROR failed to ftruncate file %s. \
-Error was %s. Password file may be corrupt ! Please examine by hand !\n",
- argv[0], pwd->pw_name, strerror(errno));
+Error was %d. Password file may be corrupt ! Please examine by hand !\n",
+ argv[0], pwd->pw_name, errno);
}
fclose(fp);
pw_file_unlock(lockfd);
@@ -483,9 +478,6 @@ Error was %s. Password file may be corrupt ! Please examine by hand !\n",
pw_file_unlock(lockfd);
exit(0);
}
- } else {
- /* the entry already existed */
- add_user = False;
}
/* If we are root or the password is 'NO PASSWORD' then
@@ -579,3 +571,14 @@ Error was %s. Password file may be corrupt ! Please examine by hand !\n",
return 0;
}
+#else
+
+#include "includes.h"
+
+int
+main(int argc, char **argv)
+{
+ printf("smb password encryption not selected in Makefile\n");
+ return 0;
+}
+#endif
diff --git a/source/utils/status.c b/source/utils/status.c
index 703105012ef..6fa85c0a630 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -98,10 +98,10 @@ for share file %s (%s)\n", progname, fname, strerror(errno));
return 0;
}
- if (IVAL(buf,SMF_VERSION_OFFSET) != LOCKING_VERSION) {
+ if (IVAL(buf,0) != LOCKING_VERSION) {
printf("%s: ERROR: read_share_file: share file %s has incorrect \
locking version (was %d, should be %d).\n",fname,
- progname, IVAL(buf,SMF_VERSION_OFFSET), LOCKING_VERSION);
+ progname, IVAL(buf,0), LOCKING_VERSION);
if(buf)
free(buf);
return 0;
@@ -109,13 +109,13 @@ locking version (was %d, should be %d).\n",fname,
/* Sanity check for file contents */
size = sb.st_size;
- size -= SMF_HEADER_LENGTH; /* Remove the header */
+ size -= 10; /* Remove the header */
/* Remove the filename component. */
- size -= SVAL(buf, SMF_FILENAME_LEN_OFFSET);
+ size -= SVAL(buf, 8);
- /* The remaining size must be a multiple of SMF_ENTRY_LENGTH - error if not. */
- if((size % SMF_ENTRY_LENGTH) != 0)
+ /* The remaining size must be a multiple of 16 - error if not. */
+ if((size % 16) != 0)
{
printf("%s: ERROR: read_share_file: share file %s is an incorrect length.\n",
progname, fname);
@@ -148,9 +148,6 @@ locking version (was %d, should be %d).\n",fname,
void *dir;
char *s;
#endif /* FAST_SHARE_MODES */
-#ifdef USE_OPLOCKS
- int oplock_type;
-#endif /* USE_OPLOCKS */
int i;
struct session_record *ptr;
@@ -347,10 +344,6 @@ locking version (was %d, should be %d).\n",fname,
t.tv_sec = entry_scanner_p->time.tv_sec;
t.tv_usec = entry_scanner_p->time.tv_usec;
strcpy(fname, file_scanner_p->file_name);
-#ifdef USE_OPLOCKS
- oplock_type = entry_scanner_p->op_type;
-#endif /* USE_OPLOCKS */
-
#else /* FAST_SHARE_MODES */
/* For slow share modes go through all the files in
@@ -401,19 +394,16 @@ locking version (was %d, should be %d).\n",fname,
strcpy( fname, &buf[10]);
close(fd);
- base = buf + SMF_HEADER_LENGTH + SVAL(buf,SMF_FILENAME_LEN_OFFSET);
- for( i = 0; i < IVAL(buf, SMF_NUM_ENTRIES_OFFSET); i++)
+ base = buf + 10 + SVAL(buf,8);
+ for( i = 0; i < IVAL(buf, 4); i++)
{
- char *p = base + (i*SMF_ENTRY_LENGTH);
+ char *p = base + (i*16);
struct timeval t;
- int pid = IVAL(p,SME_PID_OFFSET);
- int mode = IVAL(p,SME_SHAREMODE_OFFSET);
+ int pid = IVAL(p,12);
+ int mode = IVAL(p,8);
- t.tv_sec = IVAL(p,SME_SEC_OFFSET);
- t.tv_usec = IVAL(p,SME_USEC_OFFSET);
-#ifdef USE_OPLOCKS
- oplock_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
-#endif /* USE_OPLOCKS */
+ t.tv_sec = IVAL(p,0);
+ t.tv_usec = IVAL(p,4);
#endif /* FAST_SHARE_MODES */
fname[sizeof(fname)-1] = 0;
@@ -421,13 +411,8 @@ locking version (was %d, should be %d).\n",fname,
if (firstopen) {
firstopen=False;
printf("Locked files:\n");
-#ifdef USE_OPLOCKS
- printf("Pid DenyMode R/W Oplock Name\n");
- printf("--------------------------------------------------\n");
-#else /* USE_OPLOCKS */
- printf("Pid DenyMode R/W Name\n");
- printf("----------------------------------\n");
-#endif /* USE_OPLOCKS */
+ printf("Pid DenyMode R/W Name\n");
+ printf("------------------------------\n");
}
@@ -442,20 +427,10 @@ locking version (was %d, should be %d).\n",fname,
}
switch (mode&0xF)
{
- case 0: printf("RDONLY "); break;
- case 1: printf("WRONLY "); break;
- case 2: printf("RDWR "); break;
+ case 0: printf("RDONLY "); break;
+ case 1: printf("WRONLY "); break;
+ case 2: printf("RDWR "); break;
}
-#ifdef USE_OPLOCKS
- if((oplock_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == (EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
- printf("EXCLUSIVE+BATCH ");
- else if (oplock_type & EXCLUSIVE_OPLOCK)
- printf("EXCLUSIVE ");
- else if (oplock_type & BATCH_OPLOCK)
- printf("BATCH ");
- else
- printf("NONE ");
-#endif /* USE_OPLOCKS */
printf(" %s %s",fname,asctime(LocalTime((time_t *)&t.tv_sec)));
#ifdef FAST_SHARE_MODES
diff --git a/source/utils/testparm.c b/source/utils/testparm.c
index ca364cb8c94..81e69cd76fb 100644
--- a/source/utils/testparm.c
+++ b/source/utils/testparm.c
@@ -82,7 +82,7 @@ extern int DEBUGLEVEL;
printf("Press enter to see a dump of your service definitions\n");
fflush(stdout);
getc(stdin);
- lp_dump(stdout);
+ lp_dump();
}
if (argc == 4)
diff --git a/source/web/cgi.c b/source/web/cgi.c
deleted file mode 100644
index 56c293985d6..00000000000
--- a/source/web/cgi.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- some simple CGI helper routines
- Copyright (C) Andrew Tridgell 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-#include "includes.h"
-
-#define MAX_VARIABLES 512
-
-struct var {
- char *name;
- char *value;
-};
-
-static struct var variables[MAX_VARIABLES];
-static int num_variables;
-
-
-static int grab_line(int *cl, char *line, int maxsize)
-{
- int i = 0;
-
- while ((*cl)) {
- int c = fgetc(stdin);
- (*cl)--;
-
- if (c == EOF) {
- (*cl) = 0;
- break;
- }
-
- if (c == '+') {
- c = ' ';
- }
-
- if (c == '\r') continue;
-
- if (strchr("\n&", c)) break;
-
- if (c == '%' && (*cl) >= 2) {
- int c1, c2;
- c1 = fgetc(stdin);
- c2 = fgetc(stdin);
- (*cl) -= 2;
- if (c1 == EOF || c2 == EOF) break;
- if (c1 >= '0' && c1 <= '9')
- c1 = c1 - '0';
- else if (c1 >= 'A' && c1 <= 'F')
- c1 = 10 + c1 - 'A';
- else if (c1 >= 'a' && c1 <= 'f')
- c1 = 10 + c1 - 'a';
- else break;
-
- if (c2 >= '0' && c2 <= '9')
- c2 = c2 - '0';
- else if (c2 >= 'A' && c2 <= 'F')
- c2 = 10 + c2 - 'A';
- else if (c2 >= 'a' && c2 <= 'f')
- c2 = 10 + c2 - 'a';
- else break;
-
- c = (c1<<4) | c2;
- }
-
- line[i++] = c;
-
- if (i == maxsize) break;
- }
-
- /* now unescape the line */
-
-
- line[i] = 0;
- return 1;
-}
-
-
-/***************************************************************************
- load all the variables passed to the CGI program
- ***************************************************************************/
-void cgi_load_variables(void)
-{
- static pstring line;
- char *p;
- int len;
-
- if (!(p=getenv("CONTENT_LENGTH"))) return;
-
- len = atoi(p);
-
- if (len <= 0) return;
-
-
-
- while (len && grab_line(&len, line, sizeof(line)-1)) {
- p = strchr(line,'=');
- if (!p) continue;
-
- *p = 0;
-
- variables[num_variables].name = strdup(line);
- variables[num_variables].value = strdup(p+1);
-
- if (!variables[num_variables].name ||
- !variables[num_variables].value)
- continue;
-
-#if 0
- printf("%s=%s<br>\n",
- variables[num_variables].name,
- variables[num_variables].value);
-#endif
-
- num_variables++;
- if (num_variables == MAX_VARIABLES) break;
- }
-
- fclose(stdin);
-}
-
-
-/***************************************************************************
- find a variable passed via CGI
- ***************************************************************************/
-char *cgi_variable(char *name)
-{
- int i;
-
- for (i=0;i<num_variables;i++)
- if (strcmp(variables[i].name, name) == 0)
- return variables[i].value;
- return NULL;
-}
-
-
-/***************************************************************************
- return the value of a CGI boolean variable.
- ***************************************************************************/
-int cgi_boolean(char *name, int def)
-{
- char *p = cgi_variable(name);
-
- if (!p) return def;
-
- return strcmp(p, "1") == 0;
-}
diff --git a/source/wsmbconf.c b/source/wsmbconf.c
deleted file mode 100644
index 203952c204f..00000000000
--- a/source/wsmbconf.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- html smb.conf editing - prototype only
- Copyright (C) Andrew Tridgell 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-#include "smb.h"
-
-#define SDEFAULTS "Service defaults"
-#define SGLOBAL "Global Parameters"
-#define GLOBALS_SNUM -2
-#define DEFAULTS_SNUM -1
-
-
-/* start the page with standard stuff */
-static void print_header(void)
-{
- printf("Content-type: text/html\n\n");
- printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n");
- printf("<HTML>\n<HEAD>\n<TITLE>smb.conf</TITLE>\n</HEAD>\n<BODY>\n\n");
-}
-
-
-/* finish off the page */
-static void print_footer(void)
-{
- printf("\n</BODY>\n</HTML>\n");
-}
-
-/* setup persisant variables */
-static void set_persistent(char *name)
-{
- char *p;
- p = cgi_variable(name);
- if (!p) return;
- printf("<input type=hidden name=%s value=%s>\n", name, p);
-}
-
-/* display a servce, ready for editing */
-static void show_service(int snum, int allparameters)
-{
- int i = 0;
- pstring label, value;
- char *sname;
-
- if (snum == GLOBALS_SNUM)
- sname = SGLOBAL;
- else if (snum == DEFAULTS_SNUM)
- sname = SDEFAULTS;
- else sname = lp_servicename(snum);
-
- printf("\n<p><table border=0>\n<tr>\n<td></td><td>\n\n");
- printf("<form method=POST>\n");
- printf("<H3>%s</H3>\n", sname);
- printf("<input type=hidden name=service value=\"%s\">\n", sname);
- printf("<input type=submit name=request value=Change>\n");
- printf("<input type=submit name=request value=Rename>\n");
- printf("<input type=submit name=request value=Copy>\n");
- printf("<input type=submit name=request value=Remove>\n");
- printf("<br><input name=newvalue><br>\n");
- printf("<select name=parameter size=5>\n");
-
- while (lp_next_parameter(snum, &i, label, value, allparameters)) {
- printf("<option value=\"%s\">%s = %s\n",
- label, label, value);
- }
-
- printf("</select>\n");
- printf("</form>\n</td>\n</tr>\n</table>\n");
-
- printf("<p>\n");
-}
-
-
-/* loop over all services, displaying them one after the other */
-static void show_services(void)
-{
- int i;
- int n;
- int allparameters = cgi_boolean("allparameters", 0);
-
- printf("<FORM METHOD=POST>\n");
- printf("<p>Show all parameters?\n");
- printf("<INPUT NAME=allparameters TYPE=checkbox VALUE=1 %s>\n",
- allparameters?"CHECKED":"");
-
- printf("<INPUT TYPE=submit NAME=reload VALUE=Reload>\n");
-
- printf("</FORM>\n");
-
- n = lp_numservices();
-
- show_service(GLOBALS_SNUM, allparameters);
- show_service(DEFAULTS_SNUM, allparameters);
-
- for (i=0;i<n;i++)
- if (VALID_SNUM(i))
- show_service(i, allparameters);
-}
-
-
-/* load the smb.conf file into loadparm. this also does the chroot
- to the config directory. This must be called _BEFORE_ any client
- supplied data is parsed */
-static int load_config(void)
-{
- static pstring servicesf = CONFIGFILE;
- char *p;
-
- p = strrchr(servicesf,'/');
- if (!p) return 0;
-
- *p = 0;
-
- setuid(0);
-
- if (chdir(servicesf) || chroot(servicesf)) {
- printf("wsmbconf is not configured correctly\n");
- return 0;
- }
-
- *p = '/';
-
- if (!lp_load(p,False)) {
- printf("<b>Can't load %s - using defaults</b><p>\n",
- servicesf);
- }
- return 1;
-}
-
-
-static int save_reload(void)
-{
- static pstring servicesf = CONFIGFILE;
- char *p;
- FILE *f;
-
- p = strrchr(servicesf,'/');
- if (!p) return 0;
-
- f = fopen(p,"w");
- if (!f) {
- printf("failed to open %s for writing\n", servicesf);
- return 0;
- }
-
- fprintf(f, "# Samba config file created using wsmbconf\n");
-
- lp_dump(f);
-
- fclose(f);
-
- lp_killunused(NULL);
-
- if (!lp_load(p,False)) {
- printf("Can't reload %s\n", servicesf);
- return 0;
- }
-
- return 1;
-}
-
-static void process_requests(void)
-{
- char *req = cgi_variable("request");
- char *newvalue = cgi_variable("newvalue");
- char *parameter = cgi_variable("parameter");
- char *service = cgi_variable("service");
- int snum=0;
-
- if (!req) return;
-
- if (service) {
- /* work out what service it is */
- if (strcmp(service,SGLOBAL) == 0) {
- snum = GLOBALS_SNUM;
- } else if (strcmp(service,SDEFAULTS) == 0) {
- snum = DEFAULTS_SNUM;
- } else {
- snum = lp_servicenumber(service);
- if (snum < 0) return;
- }
- }
-
- if (!newvalue)
- newvalue = "";
-
- if (strcmp(req,"Change") == 0) {
- /* change the value of a parameter */
- if (!parameter || !service) return;
-
- lp_do_parameter(snum, parameter, newvalue);
- } else if (strcmp(req,"Rename") == 0) {
- /* rename a service */
- if (!newvalue || !service) return;
-
- lp_rename_service(snum, newvalue);
- } else if (strcmp(req,"Remove") == 0) {
- /* remove a service */
- if (!service) return;
-
- lp_remove_service(snum);
- } else if (strcmp(req,"Copy") == 0) {
- /* copy a service */
- if (!service || !newvalue) return;
-
- lp_copy_service(snum, newvalue);
- }
-
- save_reload();
-}
-
-
-int main(int argc, char *argv[])
-{
- extern FILE *dbf;
-
- print_header();
-
- dbf = stderr;
-
- charset_initialise();
-
- if (load_config()) {
- cgi_load_variables();
- process_requests();
- show_services();
- }
- print_footer();
- return 0;
-}
diff --git a/source/wsmbstatus.c b/source/wsmbstatus.c
deleted file mode 100644
index 2762b8610e7..00000000000
--- a/source/wsmbstatus.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- html status reporting
- Copyright (C) Andrew Tridgell 1997
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-
-static void print_header(void)
-{
- printf("Content-type: text/html\n\n");
- printf("<HTML>\n<HEAD>\n<TITLE>smbstatus</TITLE>\n</HEAD>\n<BODY>\n\n");
-}
-
-static void print_footer(void)
-{
- printf("\n</BODY>\n</HTML>\n");
-}
-
-static void show_connections(void)
-{
- static pstring servicesf = CONFIGFILE;
- pstring fname;
- FILE *f;
- struct connect_record crec;
-
- if (!lp_load(servicesf,False)) {
- printf("Can't load %s - run testparm to debug it\n", servicesf);
- return;
- }
-
- strcpy(fname,lp_lockdir());
- standard_sub_basic(fname);
- trim_string(fname,"","/");
- strcat(fname,"/STATUS..LCK");
-
- f = fopen(fname,"r");
- if (!f) {
- printf("Couldn't open status file %s\n",fname);
- if (!lp_status(-1))
- printf("You need to have status=yes in your smb config file\n");
- return;
- }
-
-
- printf("\nSamba version %s\n<p>",VERSION);
-
- while (!feof(f)) {
- if (fread(&crec,sizeof(crec),1,f) != 1)
- break;
- if (crec.magic == 0x280267 && process_exists(crec.pid)) {
- printf("%-10.10s %-8s %-8s %5d %-8s (%s) %s<br>",
- crec.name,uidtoname(crec.uid),
- gidtoname(crec.gid),crec.pid,
- crec.machine,crec.addr,
- asctime(LocalTime(&crec.start)));
- }
- }
- fclose(f);
-}
-
-int main(int argc, char *argv[])
-{
- print_header();
- show_connections();
- print_footer();
- return 0;
-}