summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2svn Import User <samba-bugs@samba.org>1998-05-11 12:43:57 +0000
committercvs2svn Import User <samba-bugs@samba.org>1998-05-11 12:43:57 +0000
commit7997659093e0a00d3c0cd46fe4e7775aeab1ba7c (patch)
tree6e4d3a0319f19af9c491ee35a2b872606ccd3b57
parentee09e9dadb69aaba5a751dd20ccc6d587d841bd6 (diff)
parent5c818b6caffa815a23506b756bba93debbf1d1a2 (diff)
downloadsamba-1.9.18p6.tar.gz
This commit was manufactured by cvs2svn to create tagsamba-1.9.18p6
'release-1-9-18p6'.
-rw-r--r--Manifest8
-rw-r--r--README7
-rw-r--r--WHATSNEW.txt357
-rw-r--r--docs/manpages/make_smbcodepage.12
-rw-r--r--docs/manpages/nmbd.82
-rw-r--r--docs/manpages/samba.72
-rw-r--r--docs/manpages/smb.conf.5111
-rw-r--r--docs/manpages/smbclient.144
-rw-r--r--docs/manpages/smbd.82
-rw-r--r--docs/manpages/smbmnt.82
-rw-r--r--docs/manpages/smbmount.82
-rw-r--r--docs/manpages/smbpasswd.85
-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/smbumount.82
-rw-r--r--docs/manpages/testparm.12
-rw-r--r--docs/manpages/testprns.12
-rw-r--r--docs/textdocs/Application_Serving.txt2
-rw-r--r--docs/textdocs/BROWSING.txt4
-rw-r--r--docs/textdocs/BUGS.txt2
-rw-r--r--docs/textdocs/CVS_ACCESS.txt2
-rw-r--r--docs/textdocs/DHCP-Server-Configuration.txt16
-rw-r--r--docs/textdocs/DIAGNOSIS.txt2
-rw-r--r--docs/textdocs/DNIX.txt2
-rw-r--r--docs/textdocs/DOMAIN.txt2
-rw-r--r--docs/textdocs/DOMAIN_CONTROL.txt2
-rw-r--r--docs/textdocs/ENCRYPTION.txt33
-rw-r--r--docs/textdocs/Faxing.txt2
-rw-r--r--docs/textdocs/GOTCHAS.txt2
-rw-r--r--docs/textdocs/HINTS.txt2
-rwxr-xr-xdocs/textdocs/MIRRORS.txt2
-rw-r--r--docs/textdocs/NTDOMAIN.txt153
-rw-r--r--docs/textdocs/NetBIOS.txt2
-rw-r--r--docs/textdocs/OS2-Client-HOWTO.txt2
-rw-r--r--docs/textdocs/PRINTER_DRIVER.txt2
-rw-r--r--docs/textdocs/PROFILES.txt3
-rw-r--r--docs/textdocs/Passwords.txt2
-rw-r--r--docs/textdocs/Printing.txt2
-rw-r--r--docs/textdocs/RoutedNetworks.txt64
-rw-r--r--docs/textdocs/SCO.txt2
-rw-r--r--docs/textdocs/Speed.txt2
-rw-r--r--docs/textdocs/Speed2.txt3
-rw-r--r--docs/textdocs/Support.txt111
-rw-r--r--docs/textdocs/Tracing.txt2
-rw-r--r--docs/textdocs/UNIX-SMB.txt2
-rw-r--r--docs/textdocs/UNIX_INSTALL.txt2
-rw-r--r--docs/textdocs/Win95.txt2
-rw-r--r--docs/textdocs/WinNT.txt2
-rw-r--r--docs/textdocs/cifsntdomain.txt2
-rw-r--r--docs/textdocs/security_level.txt2
-rw-r--r--examples/smb.conf.default25
-rw-r--r--packaging/Caldera/Makefile873
-rwxr-xr-xpackaging/Caldera/makeldirs.sh10
-rwxr-xr-xpackaging/Caldera/makerpms.sh25
-rw-r--r--packaging/Caldera/samba-make.patch74
-rw-r--r--packaging/Caldera/samba.log11
-rw-r--r--packaging/Caldera/samba.pamd2
-rw-r--r--packaging/Caldera/samba.spec206
-rw-r--r--packaging/Caldera/smb.conf267
-rwxr-xr-xpackaging/Caldera/smb.init35
-rwxr-xr-xpackaging/Caldera/smbadduser73
-rwxr-xr-xpackaging/Caldera/smbprint77
-rw-r--r--packaging/Caldera/smbusers3
-rw-r--r--packaging/SGI/.cvsignore1
-rwxr-xr-xpackaging/SGI/idb.pl25
-rw-r--r--packaging/SGI/smbprint40
-rwxr-xr-xpackaging/SGI/spec.pl4
-rw-r--r--packaging/SuSE/5.2/samba-1.9.18p5.dif17
-rw-r--r--packaging/SuSE/5.2/samba.spec1
-rw-r--r--source/.cvsignore12
-rw-r--r--source/cgi.c621
-rw-r--r--source/client/client.c10
-rw-r--r--source/client/clientutil.c18
-rw-r--r--source/client/ntclient.c6
-rw-r--r--source/client/smbmount.c35
-rw-r--r--source/include/includes.h39
-rw-r--r--source/include/local.h11
-rw-r--r--source/include/ntdomain.h130
-rw-r--r--source/include/nterr.h1
-rw-r--r--source/include/proto.h1228
-rw-r--r--source/include/smb.h1303
-rw-r--r--source/include/version.h2
-rw-r--r--source/lib/access.c9
-rw-r--r--source/lib/genrand.c226
-rw-r--r--source/lib/membuffer.c369
-rw-r--r--source/lib/pidfile.c96
-rw-r--r--source/lib/slprintf.c4
-rw-r--r--source/lib/time.c15
-rw-r--r--source/lib/util.c287
-rw-r--r--source/libsmb/clientgen.c330
-rw-r--r--source/libsmb/namequery.c7
-rw-r--r--source/libsmb/nmblib.c1
-rw-r--r--source/libsmb/nterr.c35
-rw-r--r--source/libsmb/smbdes.c9
-rw-r--r--source/locking/shmem.c6
-rw-r--r--source/locking/shmem_sysv.c2
-rw-r--r--source/nmbd/nmbd.c77
-rw-r--r--source/nmbd/nmbd_become_dmb.c26
-rw-r--r--source/nmbd/nmbd_become_lmb.c30
-rw-r--r--source/nmbd/nmbd_browsesync.c12
-rw-r--r--source/nmbd/nmbd_elections.c18
-rw-r--r--source/nmbd/nmbd_incomingdgrams.c28
-rw-r--r--source/nmbd/nmbd_incomingrequests.c16
-rw-r--r--source/nmbd/nmbd_logonnames.c18
-rw-r--r--source/nmbd/nmbd_mynames.c11
-rw-r--r--source/nmbd/nmbd_nameregister.c4
-rw-r--r--source/nmbd/nmbd_processlogon.c20
-rw-r--r--source/nmbd/nmbd_responserecordsdb.c1
-rw-r--r--source/nmbd/nmbd_sendannounce.c40
-rw-r--r--source/nmbd/nmbd_serverlistdb.c15
-rw-r--r--source/nmbd/nmbd_subnetdb.c1
-rw-r--r--source/nmbd/nmbd_workgroupdb.c12
-rw-r--r--source/param/loadparm.c824
-rw-r--r--source/passdb/ldap.c561
-rw-r--r--source/passdb/passdb.c149
-rw-r--r--source/passdb/smbpass.c1988
-rw-r--r--source/printing/pcap.c4
-rw-r--r--source/printing/print_svid.c2
-rw-r--r--source/printing/printing.c36
-rwxr-xr-xsource/script/installswat.sh48
-rw-r--r--source/smbd/chgpasswd.c86
-rw-r--r--source/smbd/connection.c222
-rw-r--r--source/smbd/ipc.c694
-rw-r--r--source/smbd/mangle.c1121
-rw-r--r--source/smbd/nttrans.c238
-rw-r--r--source/smbd/password.c637
-rw-r--r--source/smbd/pipes.c243
-rw-r--r--source/smbd/reply.c217
-rw-r--r--source/smbd/server.c400
-rw-r--r--source/smbd/trans2.c14
-rw-r--r--source/smbd/uid.c2
-rw-r--r--source/ubiqx/README.UBI16
-rw-r--r--source/ubiqx/ubi_AVLtree.c217
-rw-r--r--source/ubiqx/ubi_AVLtree.h131
-rw-r--r--source/ubiqx/ubi_BinTree.c47
-rw-r--r--source/ubiqx/ubi_BinTree.h52
-rw-r--r--source/ubiqx/ubi_Cache.c6
-rw-r--r--source/ubiqx/ubi_SplayTree.c23
-rw-r--r--source/ubiqx/ubi_SplayTree.h23
-rw-r--r--source/ubiqx/ubi_StackQueue.c149
-rw-r--r--source/ubiqx/ubi_StackQueue.h180
-rw-r--r--source/ubiqx/ubi_dLinkList.c50
-rw-r--r--source/ubiqx/ubi_dLinkList.h57
-rw-r--r--source/ubiqx/ubi_sLinkList.c82
-rw-r--r--source/ubiqx/ubi_sLinkList.h96
-rw-r--r--source/utils/nmblookup.c2
-rw-r--r--source/utils/smbpasswd.c837
-rw-r--r--source/utils/status.c5
-rw-r--r--source/utils/testparm.c4
-rw-r--r--source/utils/torture.c25
-rw-r--r--source/web/cgi.c137
-rw-r--r--source/web/diagnose.c67
-rw-r--r--source/web/startstop.c104
-rw-r--r--source/web/statuspage.c260
-rw-r--r--source/web/swat.c674
-rw-r--r--source/wsmbconf.c238
-rw-r--r--source/wsmbstatus.c93
158 files changed, 9034 insertions, 9930 deletions
diff --git a/Manifest b/Manifest
index 7e8dc0106f6..ebdbd9eb84d 100644
--- a/Manifest
+++ b/Manifest
@@ -1,4 +1,4 @@
-Copyright (C) 1997 - Samba-Team
+Copyright (C) 1997-1998 - Samba-Team
The Samba package you have just unpacked contains the following:
@@ -7,7 +7,7 @@ Directory Notes:
docs (Samba Documentation):
--------------------------------------
- The Samba documentation for 1.9.17 has had some of its content
+ The Samba documentation for 1.9.18 has had some of its content
updated and a new structure has been put in place. However, since
this is all rather new the documentation format of previous
versions will remain in place.
@@ -17,7 +17,7 @@ docs (Samba Documentation):
for each OS that Samba supports. However we are moving all this into
the new structure. For now, most people will be using UNIX_INSTALL.txt.
- You pay close attention to all the files with a
+ You should pay close attention to all the files with a
.txt extension. Most problems can be solved by reference to the
two files mentioned.
@@ -42,7 +42,7 @@ examples (Example configuration files):
packaging (Only for those wishing to build binary distributions):
-----------------------------------------------------------------------
- Currently support is included only for RedHat Linux. We hope that
+ Currently support is included for RedHat Linux and SGI. We hope that
other Unix OS vendors will contribute their binary distribution
packaging control files - and we hope to make their binary packages
available on the master ftp site under:
diff --git a/README b/README
index 781595dd15f..b663946df9f 100644
--- a/README
+++ b/README
@@ -9,6 +9,13 @@ This software is freely distributable under the GNU public license, a
copy of which you should have received with this software (in a file
called COPYING).
+COMMERCIAL SUPPORT:
+===================
+Please refer to the docs/Support.txt file. Many organisations now provide
+commercial support for Samba. In short - Samba is a commercially supported
+software package.
+
+
WHAT IS SMB?
============
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index ebd17129a84..11bf37cde27 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,10 +1,363 @@
- WHATS NEW IN 1.9.18 - January 7th 1998.
- =======================================
+
+ WHATS NEW IN 1.9.18p6 - May 11th 1998.
+ ======================================
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.
+This release is a security hole patch fix for a security hole reported
+on BugTraq by Drago. The security hole may have allowed authenticated
+users to subvert security on the server by overflowing a buffer in a
+filename rename operation. It is as yet undetermined whether the
+security hole is actually exploitable because of existing buffer
+overflow checks in Samba and the limitations on available characters
+in filenames but the Samba Team considered the threat of a possible
+security hole to warrant an immediate patch release.
+
+It is highly recommended that all sites assume that the security hole
+is exploitable and upgrade to version 1.9.18p6 of Samba.
+
+
+Previous release notes for 1.9.18p5 follow.
+=========================================================================
+
+Note that most Samba Team effort is now going into working on the
+next major release which should contain some Windows NT Domain
+features. It is intended that any future work on the 1.9.18 series
+be maintenance only fixes.
+
+An announcement will be made when the first alpha release of the next
+Samba series is available.
+
+Added features in 1.9.18p5
+--------------------------
+
+New parameters
+--------------
+
+passwd chat debug
+
+This parameter is to allow Samba administrators to debug their password
+chat scripts more easily when they have "unix password sync" set. It is
+provided as a debugging convenience only and should be enabled only when
+debugging. Full documentation is in the smb.conf man page.
+
+update encrypted
+
+The code for this parameter was kindly donated by Bruce Tenison.
+If this parameter is set to "yes" (it defaults to "no") and an smbpasswd
+file exists containing all the valid users of a Samba system but
+no encrypted passwords (ie. the Lanman hash and NT hash entries in
+the file are set to "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), then as
+users log in with plaintext passwords that are matched against
+their UNIX password entries, their plaintext passwords will be
+hashed and entered into the smbpasswd file. After all the users
+have successfully logged in using unencrypted passwords, the
+smbpasswd file will have the Lanman and NT hashes of these users
+UNIX passwords correctly stored. At that point the administrator
+can convert Samba to use encrypted passwords (and configure the
+Windows 95 and NT clients to send only encrypted passwords) and
+migrate to an encrypted setup without having to ask users to re-enter
+all their passwords explicitly. Note that to use this option the
+"encrypt passwords" parameter must be set to "no" when this option
+is set to "yes". See the smb.conf man page for up to date information
+on this parameter.
+
+Updates to smbtar
+-----------------
+
+The following changes were developed by Richard Sharpe for Canon Information
+Systems Research Australia (CISRA). The Samba Team would like to thank
+Canon Information Systems Research Australia for their funding this
+effort, as such sponsorship advances the Samba project significantly.
+
+ 1. Restore can now restore files with long file names
+ 2. Save now saves directory information so that we can restore
+ directory creation times
+ 3. tar now accepts both UNIX path names and DOS path names.
+
+New document in docs/ directory
+-------------------------------
+
+A new document, PROFILES.txt has been added to the docs/ directory.
+This is still a work in progress (currently consisting of a series
+of email exchanges) and will be updated over the coming releases.
+The document covers the task of getting roving profiles to work with
+a Samba server with Windows 95 and Windows NT clients.
+
+Bugfixes added since 1.9.18p4
+-----------------------------
+
+1). Samba should now compile cleanly with the gcc -Wstrict-prototypes
+option.
+2). New code page 852 tranlation table created by Petr Hubeny.
+3). New "update encrypted" parameter (described above).
+4). New "passwd chat debug" parameter (described above).
+5). Updates to smbtar (described above).
+6). Fix to do correct null session connections from nmbd and smbd.
+7). Synchronous open flag is now honoured.
+8). security=server now logs out correctly.
+9). Fix to stop long printer job listings causing Win95 and smbd to
+spin the CPU & network.
+10). Multibyte character fix that prevented the "character set" parameter
+working in 1.9.18p4.
+11). Fix for problems with security=share and the [homes] share.
+12). NIS+ patch to get home directory info.
+13). Added FTRUNCATE_NEEDS_ROOT define for systems with broken ftruncate()
+call.
+14). Fix for nmbd not allowing log append mode.
+15). Fix for nmbd as a WINS server doing a name query after a WACK with
+the 'recursion desired' bit set - this would cause problems if directed
+at a machine running a WINS server.
+16). Correctly ignore "become backup browser" requests, rather than
+logging them as a problem.
+17). Use compressed names correctly as requested by RFC1002.
+18). Workaround for bug where NT allows a guest logon and
+doesn't set the guest bit (in security=server mode).
+19). Added SOFTQ print type.
+20). Free filename on file close (long standing small memory leak fix).
+21). Fix for lp_defaultservice() getting overwritten by rotating string
+buffers.
+22). Print time in international, rather than USA, format.
+23). Fix to queue a trans2 open request when oplock break pending.
+24). Added Simplified Chinese codepage (936).
+25). Fixed expansion bug with %U, %G when multiple sessionsetups done
+in security > SHARE mode.
+26). Change to DEC enhanced mode security code to allow the same
+binary to work when in enhanced and basic security mode. This change affects
+all systems that define OSF1_ENH_SEC at compile time.
+
+Previous release notes for 1.9.18p4 follow.
+=========================================================================
+
+Added features in 1.9.18p4
+--------------------------
+
+Changing passwords now supported
+--------------------------------
+
+Samba now supports changing the SMB password from a Windows 95 client,
+using the standard Windows 95 password changing dialog. Note that by
+default this changes the SMB password, not the UNIX password (Samba
+must be set up with encrypted passwords in order to support this).
+
+The smbpasswd program has been re-written to take advantage of this
+feature, and now has no need to be a setuid root program, thus eliminating
+a potential security hole. As a side effect of this change smbpasswd
+can now be used on a UNIX machine to change users passwords on an NT
+machine.
+
+The new password changing code can also synchronize a users UNIX
+password at the same time a SMB password is being changed, if Samba
+is compiled with password changing enabled, and the new parameter
+'unix password sync' is set to True. By default this is off, as
+it allows the password change program to be called as root, which
+may be considered a security problem at some sites.
+
+Name resolution order now user selectable
+-----------------------------------------
+
+The resolution of NetBIOS names into IP addresses can be done in
+several different ways (broadcast, lmhosts, DNS lookup, WINS).
+Previous versions of Samba were inconsistant in which commands
+used which methods to look up IP addresses from a name. New in
+this version is a parameter (name resolve order, mentioned in
+the new parameters list below) that allows administrators to
+select the methods of name resolution, and the order in which
+such methods are applied. All Samba utilities have been changed
+to use the new name to IP address name resolution code and
+so this can be controlled from a central place.
+
+Expanded multi-byte character support
+-------------------------------------
+
+In previous versions of Samba, Kanji (Japanese) character
+support was treated as a special case, making it the only
+multi-byte character set natively supported in Samba. New
+code has been added to generalize the multi-byte codepage
+support, with the effect that other multibyte codepage support
+can be easily added. The new codepages that this version
+ships with are Korean Hangul and Traditional Chinese.
+
+New Parameters in 1.9.18p4
+--------------------------
+
+name resolve order = lmhosts wins hosts bcast
+
+This parameter allows control over the order in which netbios name to
+IP Address resolution is attempted. Any method NOT specified will be
+excluded from the name resolution process. If this parameter is not
+specified then the above default order will be observed - this is
+consistent with prior releases. See the smb.conf and smbclient man
+pages for full details. See the above text for the announcement on
+this feature.
+
+fake directory create times
+
+This parameter is a compatibility option for software developers
+using Microsoft NMAKE make tool, saving files onto a Samba share.
+Setting this parameter to true causes Samba to lie to the client
+about the creation time of a directory, so NMAKE commands don't
+re-compile every file.
+
+unix password sync
+
+This parameter is set to False by default. When set to True, it
+causes Samba to attempt to synchronize the users UNIX password
+when a user is changing their SMB password. This causes the
+password change program to be run as root (as the new password
+change code has no access to the plaintext of the old password).
+Because of this, it is set off by default to allow sites to
+set their own security policy regarding UNIX and SMB password
+synchronization.
+
+This parameter has no effect if Samba has been compiled without
+password changing enabled.
+
+Changed compile-time default in 1.9.18p4
+----------------------------------------
+
+The maximum length of a printer share name has now been increased to 15
+characters - the same as file share names. Any one who needs to revert back
+to 8 character printer share name support can do so by adjusting the #define
+in local.h.
+
+Bugfixes added since 1.9.18p3
+-----------------------------
+
+1). Fix for nmbd leaving the child nmbd running when doing DNS
+lookups as a WINS server.
+2). Fix core dump in smbd when acting as a logon server with
+security=share.
+3). Workaround for a bug in FTP OnNet software NBT implementation.
+It does a broadcast name release for WORKGROUP<0> and WORKGROUP<1e>
+names and don't set the group bit.
+4). Ensure all the NetBIOS aliases are added to all the known
+interfaces on nmbd initialization.
+5). Fix bug in multiple query name responses print code.
+6). Fix to send out mailslot reply on correct interface.
+7). Fix retranmission queue to scan WINS server subnet so
+nmbd retransmits queries needed when acting as a WINS server.
+Thanks to Andrey Alekseyev <fetch@muffin.arcadia.spb.ru> for
+spotting this one.
+8). Send host announcement to correct 0x1d name rather than
+0x1e name.
+9). Fix for WINS server when returning multi-homed record,
+was returning one garbage IP address.
+10). Fix for Thursby Software's 'Dave' client - ensure
+that a vuid of zero is always returned for them when in
+share level security (the spec say's it shouldn't matter,
+but it was causing them grief).
+11). Added KRB4 authentication code.
+12). Fix to allow max printer name to be 15 characters (see above).
+13). Fix for name mangling cache bug - cache wasn't being
+used in some cases.
+14). Fix for RH5.0 broken system V shared memory include
+files.
+15). Fix for broken redirector use of resume keys between
+deletes in a directory. Samba now returns zero as resume
+keys (as does NT) and uses the resume filename instead.
+16). Fix for systems that have a broken implementation
+of isalnum() - was causing gethostbyname to fail.
+17). Fix for 'hide files' bug not working correctly (bug
+in is_in_path function - fix from Steven Hartland
+<steven_hartland@pa.press.net>.
+18). Fixed bug in smbclient where debug log level on the
+command line was being overridden by the log level in smb.conf.
+19). Fixed bug in USE_MMAP code where client sending
+a silly offset to readraw could cause a smbd core dump.
+
+Bugfixes added since 1.9.18p2
+-----------------------------
+
+1). Fix to cause oplocked files to be broken when open
+file table is full before giving up and reporting 'too
+many open files'. This fix seems to help many applications
+on Win95.
+2). Fix to stop extra files being closed in user logoff
+code.
+3). Fix to stop padded packet being returned on
+trans2 call. This bug could cause Windows 95 to freeze
+on some (rare) occasions.
+4). Added fix for Visual C++ filetime changes (see above).
+5). Made security check code an option (see above).
+6). Fixed printer job enumeration in smbclient.
+7). Re-added code into smbclient that causes it to do NetBIOS
+broadcast name lookups (as it used to in 1.9.17).
+8). Fixed code dump bug in smbtar.
+9). Fixed mapping code between Appletalk and Kanji filenames.
+10). Tuned shared memory size based on open file table size.
+11). Made nmbd log file names consistant with smbd.
+12). Fixed nmbd problem where packet queues could grow
+without bound when connection to WINS server was down.
+13). Fix for DCE login code.
+14). Fix for system V printing to remove extra space
+in printer name.
+15). Patch to add a new substitution paramter (%p) in
+a service patchname. Adds NIS home path (see the man page
+on smb.conf for details). Patch from Julian Field.
+16). Fix to stop smbpassword code from failing when
+parsing invalid uid fields.
+17). Made volume serial number constant based on machine
+and service name.
+18). Added expand environment variables code from Branko
+Cibej. See the man page on smb.conf for details.
+19). Fixed warnings in change_lanman_password code.
+
+
+Bugfixes added since 1.9.18p1
+-----------------------------
+
+1). A deadlock condition in the oplock code has been found
+and fixed. This occured under heavy load at large sites. Several
+of the sites who reported the original problem have now been
+testing the code in this (1.9.18p2) release for a week now with
+no problems (previously the problem occurred within 3-6 hours).
+(Thanks to Peter Crawshaw of Mount Allison University for
+his great help in tracking down this bug).
+2). Fix for a share level security problem that caused
+'valid users' not to work correctly.
+3). Addition of Russian code page support.
+4). Fix to the password changing code (thanks to Randy Boring
+at Thursby Software Systems for this).
+5). More fixes to the Windows 95 printer driver support
+code from Herb Lewis at SGI.
+6). Two NetBIOS over TCP source name type fixes in nmbd.
+7). Memory leak in the dynamic loading of services in an
+smb.conf file fixed.
+8). LPRng parsing code fix.
+9). Fix to try and return a 'best guess' of create time
+under UNIX (which doens't store such a file attribute).
+10). Added parameters to samba/examples/smb.conf.default file :
+Remote announce, Remote browse sync, username map, filename
+case preservation and sensitivity options.
+11). Reply to trans2 calls now aligns all parameters and
+data on 4 byte boundary.
+12). Fixed SIGTERM bug where nmbd would hang on exit.
+13). Fixed WINS server bug to allow spaces in WINS names.
+
+Bugfixes added since 1.9.18
+---------------------------
+
+1). Fix for oplock-break problem. If an open crossed
+with an oplock break on the wire it was possible for the
+same fnum to be re-used. This caused a rare but fatal
+problem.
+2). Fix for adding printers to Windows NT 4.x. Now
+return correct "no space error" when buffer of zero
+given.
+3). Fix for nmbd core dumps when running on architectures
+that cannot access structures on non-aligned boundaries
+(sparc, alpha etc).
+4). Compiler warnings in nmbd fixed.
+5). Makefile updated for Linux 2.0 versions (new smbmount
+commands should only be compiled for 2.1.x kernels).
+6). Addition of a timestamp to attack warning messages.
+
+Changes in 1.9.18.
+------------------
+
This release contains several major changes and much re-written
code.
diff --git a/docs/manpages/make_smbcodepage.1 b/docs/manpages/make_smbcodepage.1
index 64969b92938..37c2bbcd88c 100644
--- a/docs/manpages/make_smbcodepage.1
+++ b/docs/manpages/make_smbcodepage.1
@@ -1,4 +1,4 @@
-.TH MAKE_SMBCODEPAGE 1 "08 Jan 1998" "make_smbcodepage 1.9.18"
+.TH MAKE_SMBCODEPAGE 1 "11 May 1998" "make_smbcodepage 1.9.18p6"
.SH NAME
make_smbcodepage \- create a binary codepage definition file from an ascii codepage definition source file, or reverse the process.
.SH SYNOPSIS
diff --git a/docs/manpages/nmbd.8 b/docs/manpages/nmbd.8
index 5e03ef7481a..91ddd6b40e2 100644
--- a/docs/manpages/nmbd.8
+++ b/docs/manpages/nmbd.8
@@ -1,4 +1,4 @@
-.TH NMBD 8 "08 Jan 1998" "nmbd 1.9.18"
+.TH NMBD 8 "11 May 1998" "nmbd 1.9.18p6"
.SH NAME
nmbd \- provide netbios nameserver support to clients
.SH SYNOPSIS
diff --git a/docs/manpages/samba.7 b/docs/manpages/samba.7
index 3f6a98d6e6a..29167185a90 100644
--- a/docs/manpages/samba.7
+++ b/docs/manpages/samba.7
@@ -1,4 +1,4 @@
-.TH SAMBA 7 "08 Jan 1998" "samba 1.9.18"
+.TH SAMBA 7 "11 May 1998" "samba 1.9.18p6"
.SH NAME
Samba \- a LanManager like fileserver for UNIX
.SH SYNOPSIS
diff --git a/docs/manpages/smb.conf.5 b/docs/manpages/smb.conf.5
index 54940bec291..7339078beb5 100644
--- a/docs/manpages/smb.conf.5
+++ b/docs/manpages/smb.conf.5
@@ -1,4 +1,4 @@
-.TH SMB.CONF 5 "08 Jan 1998" "smb.conf 1.9.18"
+.TH SMB.CONF 5 "11 May 1998" "smb.conf 1.9.18p6"
.SH NAME
smb.conf \- configuration file for smbd
.SH SYNOPSIS
@@ -449,6 +449,8 @@ packet size
passwd chat
+passwd chat debug
+
passwd program
password level
@@ -511,8 +513,12 @@ time offset
time server
+unix password sync
+
unix realname
+update encrypted
+
username level
username map
@@ -1704,8 +1710,13 @@ between 'keepalive' packets. If this parameter is zero, no keepalive packets
will be sent. Keepalive packets, if sent, allow the server to tell whether a
client is still present and responding.
+Keepalives should, in general, not be needed if the socket being used
+has the SO_KEEPALIVE attribute set on it (see "socket
+options"). Basically you should only use this option if you strike
+difficulties.
+
.B Default:
- keep alive = 300
+ keep alive = 0
.B Example:
keep alive = 60
@@ -2499,6 +2510,12 @@ problems with machines in trust relationships in which case you can
disable it here, but be warned, we have heard that some NT machines
will then allow anyone in with any password! Make sure you test it.
+In Samba 1.9.18p5 this parameter is of limited use, as smbd now
+explicitly tests for this NT bug and will refuse to use a password
+server that has the problem. The parameter still defaults to on,
+for compatibility, but it is now probably safe to set this to
+off without testing the NT server being used as a password server.
+
.B Default:
networkstation user login = yes
@@ -2589,6 +2606,14 @@ If the send string in any part of the chat sequence is a fullstop "."
then no string is sent. Similarly, is the expect string is a fullstop
then no string is expected.
+Note that if the 'unix password sync' parameter is set to true,
+then this sequence is called *AS ROOT* when the SMB password in the
+smbpasswd file is being changed, without access to the old password
+cleartext. In this case the old password cleartext is set to ""
+(the empty string).
+
+See also 'unix password sync' and 'passwd chat debug'
+
.B Example:
passwd chat = "*Enter OLD password*" %o\en "*Enter NEW password*" %n\en \e
"*Reenter NEW password*" %n\en "*Password changed*"
@@ -2597,18 +2622,44 @@ then no string is expected.
.B Default:
passwd chat = *old*password* %o\en *new*password* %n\en *new*password* %n\en *changed*
+.SS passwd chat debug (G)
+
+This boolean specifies if the passwd chat script parameter is run
+in 'debug' mode. In this mode the strings passed to and received
+from the passwd chat are printed in the smbd log with a debug level
+of 100. This is a dangerous option as it will allow plaintext passwords
+to be seen in the smbd log. It is available to help Samba admins
+debug their passwd chat scripts and should be turned off after
+this has been done. This parameter is off by default.
+
+.B Example:
+ passwd chat debug = True
+
+.B Default:
+ passwd chat debug = False
+
.SS passwd program (G)
The name of a program that can be used to set user passwords.
-This is only necessary if you have enabled remote password changing at
-compile time. Any occurrences of %u will be replaced with the user
-name.
+This is only available if you have enabled remote password changing at
+compile time (see the comments in the Makefile for details). Any occurrences
+of %u will be replaced with the user name. The user name is checked
+for existance before calling the password changing program.
Also note that many passwd programs insist in "reasonable" passwords,
such as a minimum length, or the inclusion of mixed case chars and
digits. This can pose a problem as some clients (such as Windows for
Workgroups) uppercase the password before sending it.
+Note that if the 'unix password sync' parameter is set to true,
+then this sequence is called *AS ROOT* when the SMB password in the
+smbpasswd file is being changed. If the 'unix passwd sync' parameter
+is set this parameter MUST USE ABSOLUTE PATHS for ALL programs called,
+and must be examined for security implications. Note that by default
+'unix password sync' is set to False.
+
+See also 'unix password sync'
+
.B Default:
passwd program = /bin/passwd
@@ -3253,7 +3304,11 @@ user that you are logged into WfWg as.
If you use "security = server" then Samba will try to validate the
username/password by passing it to another SMB server, such as an NT
-box. If this fails it will revert to "security = USER".
+box. If this fails it will revert to "security = USER", but note that
+if encrypted passwords have been negotiated then Samba cannot revert
+back to checking the UNIX password file, it must have a valid
+smbpasswd file to check users against. See the documentation
+docs/ENCRYPTION.txt for details on how to set this up.
See the "password server" option for more details.
@@ -3549,6 +3604,23 @@ to Windows clients. The default is False.
.B Example:
time server = True
+.SS unix password sync (G)
+This boolean parameter controlls whether Samba attempts to synchronise
+the UNIX password with the SMB password when the encrypted SMB password
+in the smbpasswd file is changed. If this is set to true the 'passwd program'
+program is called *AS ROOT* - to allow the new UNIX password to be set
+without access to the old UNIX password (as the SMB password has change
+code has no access to the old password cleartext, only the new). By
+default this is set to false.
+
+See also 'passwd program', 'passwd chat'
+
+.B Default:
+ unix password sync = False
+
+.B Example:
+ unix password sync = True
+
.SS unix realname (G)
This boolean parameter when set causes samba to supply the real name field
from the unix password file to the client. This is useful for setting up
@@ -3560,6 +3632,33 @@ mail clients and WWW browsers on systems used by more than one person.
.B Example:
unix realname = yes
+.SS update encrypted (G)
+This boolean parameter allows a user logging on with a plaintext
+password to have their encrypted (hashed) password in the smbpasswd
+file to be updated automatically as they log on. This option allows
+a site to migrate from plaintext password authentication (users
+authenticate with plaintext password over the wire, and are checked
+against a UNIX account database) to encrypted password authentication
+(the SMB challenge/response authentication mechanism) without forcing
+all users to re-enter their passwords via smbpasswd at the time the change
+is made. This is a convenience option to allow the change over to
+encrypted passwords to be made over a longer period. Once all users
+have encrypted representations of their passwords in the smbpasswd
+file this parameter should be set to "off".
+
+In order for this parameter to work correctly the "encrypt passwords"
+must be set to "no" when this parameter is set to "yes".
+
+Note that even when this parameter is set a user authenticating to
+smbd must still enter a valid password in order to connect correctly,
+and to update their hashed (smbpasswd) passwords.
+
+.B Default:
+ update encrypted = no
+
+.B Example:
+ update encrypted = yes
+
.SS user (S)
See
.B username.
diff --git a/docs/manpages/smbclient.1 b/docs/manpages/smbclient.1
index 1d7551ce423..2292a79b70a 100644
--- a/docs/manpages/smbclient.1
+++ b/docs/manpages/smbclient.1
@@ -1,4 +1,4 @@
-.TH SMBCLIENT 1 "19 Feb 1998" "smbclient 1.9.18p3"
+.TH SMBCLIENT 1 "11 May 1998" "smbclient 1.9.18p6"
.SH NAME
smbclient \- ftp-like Lan Manager client program
.SH SYNOPSIS
@@ -7,8 +7,6 @@ smbclient \- ftp-like Lan Manager client program
[
.B password
] [
-.B \-A
-] [
.B \-E
] [
.B \-L
@@ -131,15 +129,6 @@ is useful to force name resolution to take place by a particular method.
This command line parameter only exists in Samba 1.9.18p4 and above.
.RE
-.B \-A
-
-.RS 3
-This parameter, if specified, causes the maximum debug level to be selected.
-Be warned that this generates prodigious amounts of debug data. There is also
-a security issue involved, as at the maximum debug level cleartext passwords
-may be written to some log files.
-.RE
-
.B \-L
.RS 3
@@ -317,7 +306,7 @@ Be cautious about including passwords in scripts.
.I debuglevel
.RS 3
-debuglevel is an integer from 0 to 5.
+debuglevel is an integer from 0 to 5, or the letter 'A'.
The default value if this parameter is not specified is zero.
@@ -330,6 +319,9 @@ Levels above 1 will generate considerable amounts of log data, and should
only be used when investigating a problem. Levels above 3 are designed for
use only by developers and generate HUGE amounts of log data, most of which
is extremely cryptic.
+
+If the debuglevel is set to 'A' then the debug level is set to the maximum
+value possible (it stands for debug 'all').
.RE
.B \-l
@@ -418,7 +410,7 @@ smbclient
]
.IR tarfile
[
-.IR filenames ...
+.IR filenames....
]
.RS 3
@@ -439,9 +431,7 @@ option is given, the tar files will be restored from the top level of
the share. Must be followed by the name of the tar file, device or "\-"
for standard input. Mutually exclusive with the
.B c
-flag. Restored files have theuir creation times (mtime) set to the date saved in
-the tar file. Directories currently do not get their creation dates restored
-properly.
+flag.
.B I
Include files and directories. Is the default behaviour when
@@ -483,18 +473,6 @@ up. Useful with the
flags.
.LP
-.B Long File Names
-
-smbclient's tar option now supports long file names both on backup and
-restore. However, the full path name of the file must be less than 1024 bytes.
-Also, when a tar archive is created, smbclient's tar option places all files
-in the archive with relative names, not absolute names.
-
-.B Filenames ...
-
-All file names can be given as DOS path names (with \e as the component
-separator) or as UNIX path names (with / as the component separator).
-
.B Examples
smbclient \e\emypc\emyshare "" -N -Tx backup.tar
@@ -508,14 +486,6 @@ Restore everything except users/docs
smbclient \e\emypc\emyshare "" -N -Tc backup.tar users/docs
Create a tar file of the files beneath users/docs.
-
-smbclient \e\emypc\emyshare "" -N -tc backup.tar users\edocs
-
-Create the same tar file as above, but now use a DOS path name.
-
-smbclient \e\emypc\emyshare "" -N -Tc backup.tar \e*
-
-Create a tar file of all the files and directories in the share.
.RE
.RE
diff --git a/docs/manpages/smbd.8 b/docs/manpages/smbd.8
index f7fc985d660..40345b893ce 100644
--- a/docs/manpages/smbd.8
+++ b/docs/manpages/smbd.8
@@ -1,4 +1,4 @@
-.TH SMBD 8 "08 Jan 1998" "smbd 1.9.18"
+.TH SMBD 8 "11 May 1998" "smbd 1.9.18p6"
.SH NAME
smbd \- provide SMB (aka LanManager) services to clients
.SH SYNOPSIS
diff --git a/docs/manpages/smbmnt.8 b/docs/manpages/smbmnt.8
index 7364ccbda8d..7678e3d5bb0 100644
--- a/docs/manpages/smbmnt.8
+++ b/docs/manpages/smbmnt.8
@@ -1,4 +1,4 @@
-.TH SMBMNT 8 "08 Jan 1998" "smbmnt 1.9.18"
+.TH SMBMNT 8 "11 May 1998" "smbmnt 1.9.18p6"
.SH NAME
smbmnt \- mount smb file system
.SH SYNOPSIS
diff --git a/docs/manpages/smbmount.8 b/docs/manpages/smbmount.8
index 0255a668e1e..4fb2f9c2067 100644
--- a/docs/manpages/smbmount.8
+++ b/docs/manpages/smbmount.8
@@ -1,4 +1,4 @@
-.TH SMBMOUNT 8 "08 Jan 1998" "smbmount 1.9.18"
+.TH SMBMOUNT 8 "11 May 1998" "smbmount 1.9.18p6"
.SH NAME
smbmount \- mount smb file system
.SH SYNOPSIS
diff --git a/docs/manpages/smbpasswd.8 b/docs/manpages/smbpasswd.8
index 24b37135984..92771aa7675 100644
--- a/docs/manpages/smbpasswd.8
+++ b/docs/manpages/smbpasswd.8
@@ -1,4 +1,4 @@
-.TH SMBPASSWD 8 "19 Feb 1998" "smbpasswd 1.9.18p3"
+.TH SMBPASSWD 8 "11 May 1998" "smbpasswd 1.9.18p6"
.SH NAME
smbpasswd \- change a users smb password in the smbpasswd file.
.SH SYNOPSIS
@@ -9,6 +9,9 @@ smbpasswd \- change a users smb password in the smbpasswd file.
.B \-r
remote_machine
] [
+.B \-D
+DEBUGLEVEL
+] [
.B username
]
.SH DESCRIPTION
diff --git a/docs/manpages/smbrun.1 b/docs/manpages/smbrun.1
index 14daad86f42..9c837f3b286 100644
--- a/docs/manpages/smbrun.1
+++ b/docs/manpages/smbrun.1
@@ -1,4 +1,4 @@
-.TH SMBRUN 1 "08 Jan 1998" "smbrun 1.9.18"
+.TH SMBRUN 1 "11 May 1998" "smbrun 1.9.18p6"
.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 9d049cbf076..9f4f9558eac 100644
--- a/docs/manpages/smbstatus.1
+++ b/docs/manpages/smbstatus.1
@@ -1,4 +1,4 @@
-.TH SMBSTATUS 1 "08 Jan 1998" "smbstatus 1.9.18"
+.TH SMBSTATUS 1 "11 May 1998" "smbstatus 1.9.18p6"
.SH NAME
smbstatus \- report on current Samba connections
.SH SYNOPSIS
diff --git a/docs/manpages/smbtar.1 b/docs/manpages/smbtar.1
index debfedb5de5..603cc9010aa 100644
--- a/docs/manpages/smbtar.1
+++ b/docs/manpages/smbtar.1
@@ -1,4 +1,4 @@
-.TH SMBTAR 1 "08 Jan 1998" "smbtar 1.9.18"
+.TH SMBTAR 1 "11 May 1998" "smbtar 1.9.18p6"
.SH NAME
smbtar \- shell script for backing up SMB shares directly to UNIX tape drive
.SH SYNOPSIS
diff --git a/docs/manpages/smbumount.8 b/docs/manpages/smbumount.8
index 2cee4775634..c52b4f5b661 100644
--- a/docs/manpages/smbumount.8
+++ b/docs/manpages/smbumount.8
@@ -1,4 +1,4 @@
-.TH SMBUMOUNT 8 "08 Jan 1998" "smbumount 1.9.18"
+.TH SMBUMOUNT 8 "11 May 1998" "smbumount 1.9.18p6"
.SH NAME
smbumount \- umount for normal users
.SH SYNOPSIS
diff --git a/docs/manpages/testparm.1 b/docs/manpages/testparm.1
index b4b48bf7155..6e389292fd9 100644
--- a/docs/manpages/testparm.1
+++ b/docs/manpages/testparm.1
@@ -1,4 +1,4 @@
-.TH TESTPARM 1 "08 Jan 1998" "testparm 1.9.18"
+.TH TESTPARM 1 "11 May 1998" "testparm 1.9.18p6"
.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 1552ef035c7..34fe5ca5a0b 100644
--- a/docs/manpages/testprns.1
+++ b/docs/manpages/testprns.1
@@ -1,4 +1,4 @@
-.TH TESTPRNS 1 "08 Jan 1998" "testprns 1.9.18"
+.TH TESTPRNS 1 "11 May 1998" "testprns 1.9.18p6"
.SH NAME
testprns \- check printer name for validity with smbd
.SH SYNOPSIS
diff --git a/docs/textdocs/Application_Serving.txt b/docs/textdocs/Application_Serving.txt
index 0a8fcc61f01..c5ee6237bea 100644
--- a/docs/textdocs/Application_Serving.txt
+++ b/docs/textdocs/Application_Serving.txt
@@ -1,5 +1,5 @@
!==
-!== Application_Serving.txt for Samba release 1.9.18p3 19 Feb 1998
+!== Application_Serving.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributed: January 7, 1997
Updated: March 24, 1998
diff --git a/docs/textdocs/BROWSING.txt b/docs/textdocs/BROWSING.txt
index 83f43bc5fa0..70b6a81ea7c 100644
--- a/docs/textdocs/BROWSING.txt
+++ b/docs/textdocs/BROWSING.txt
@@ -1,5 +1,5 @@
!==
-!== BROWSING.txt for Samba release 1.9.18 08 Jan 1998
+!== BROWSING.txt for Samba release 1.9.18p6 11 May 1998
!==
Author/s: Many (Thanks to Luke, Jeremy, Andrew, etc.)
Updated: October 12, 1997
@@ -74,7 +74,7 @@ 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
are now far more likely to correctly find your broadcast and network
-address, so in most cases these aren't needed.
+addess, so in most cases these aren't needed.
The other big problem people have is that their broadcast address,
netmask or IP address is wrong (specified with the "interfaces" option
diff --git a/docs/textdocs/BUGS.txt b/docs/textdocs/BUGS.txt
index cfeda5fb7f9..1573489e93c 100644
--- a/docs/textdocs/BUGS.txt
+++ b/docs/textdocs/BUGS.txt
@@ -1,5 +1,5 @@
!==
-!== BUGS.txt for Samba release 1.9.18 08 Jan 1998
+!== BUGS.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Samba Team
Updated: June 27, 1997
diff --git a/docs/textdocs/CVS_ACCESS.txt b/docs/textdocs/CVS_ACCESS.txt
index 8d5746cbe09..8a4c1682780 100644
--- a/docs/textdocs/CVS_ACCESS.txt
+++ b/docs/textdocs/CVS_ACCESS.txt
@@ -1,5 +1,5 @@
!==
-!== CVS_ACCESS.txt for Samba release 1.9.18 08 Jan 1998
+!== CVS_ACCESS.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Modified from the Web pages by Jeremy Allison.
Date: 23 Dec 1997
diff --git a/docs/textdocs/DHCP-Server-Configuration.txt b/docs/textdocs/DHCP-Server-Configuration.txt
index d0ab31b2606..9365812ca65 100644
--- a/docs/textdocs/DHCP-Server-Configuration.txt
+++ b/docs/textdocs/DHCP-Server-Configuration.txt
@@ -1,3 +1,6 @@
+!==
+!== DHCP-Server-Configuration.txt for Samba release 1.9.18p6 11 May 1998
+!==
Subject: DHCP Server Configuration for SMB Clients
Date: March 1, 1998
Contributor: John H Terpstra <jht@samba.anu.edu.au>
@@ -11,20 +14,19 @@ Background:
We wish to help those folks who wish to use the ISC DHCP Server and provide
sample configuration settings. Red Hat Linux 5.0 is one operating system that
-comes supplied with the ISC DHCP Server. ISC DHCP is available from
- ftp://ftp.isc.org/isc/dhcp
+comes supplied with the ISC DHCP Server.
Incorrect configuration of MS Windows clients (Windows95, Windows NT Server and
Workstation) will lead to problems with browsing and with general network
-operation. Windows 95 users often report problems where the TCP/IP and related
+operation. Windows95 users often report problems where the TCP/IP and related
network settings will inadvertantly become reset at machine start-up resulting
in loss of configuration settings. This results in increased maintenance
overheads as well as serious user frustration.
-In recent times users on one mailing list incorrectly attributed the cause of
+In recent times users on one mailing list oncorrectly attributed the cause of
network operating problems to incorrect configuration of Samba.
-One user insisted that the only way to provent Windows95 from periodically
+One userinsisted that the only way to provent Windows95 from periodically
performing a full system reset and hardware detection process on start-up was
to install the NetBEUI protocol in addition to TCP/IP.
@@ -94,14 +96,14 @@ major needs.
DHCP Server Installation:
=========================
It is assumed that you will have obtained a copy of the GPL'd ISC DHCP server
-source files from ftp://ftp.isc.org/isc/dhcp, it is also assumed that you have
+source files from ftp://ftp.isc.org/pub/dhcp, it is also assumed that you have
compiled the sources and have installed the binary files.
The following simply serves to provide sample configuration files to enable
dhcpd to operate. The sample files assume that your site is configured to use
private IP network address space using the Class B range of 172.16.1.0 -
172.16.1.255 and is using a netmask of 255.255.255.0 (ie:24 bits). It is
-assumed that your router to the outside world is at 172.16.1.254 and that your
+assumed that you router to the outside world is at 172.16.1.254 and that your
Internet Domain Name is bestnet.com.au. The IP Address range 172.16.1.100 to
172.16.1.240 has been set aside as your dynamically allocated range. In
addition, bestnet.com.au have two print servers that need to obtain settings
diff --git a/docs/textdocs/DIAGNOSIS.txt b/docs/textdocs/DIAGNOSIS.txt
index d709d78870b..90366738e17 100644
--- a/docs/textdocs/DIAGNOSIS.txt
+++ b/docs/textdocs/DIAGNOSIS.txt
@@ -1,5 +1,5 @@
!==
-!== DIAGNOSIS.txt for Samba release 1.9.18p4 28 Mar 1998
+!== DIAGNOSIS.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Andrew Tridgell
Updated: October 14, 1997
diff --git a/docs/textdocs/DNIX.txt b/docs/textdocs/DNIX.txt
index a5c6830cf3c..207c2a67ea8 100644
--- a/docs/textdocs/DNIX.txt
+++ b/docs/textdocs/DNIX.txt
@@ -1,5 +1,5 @@
!==
-!== DNIX.txt for Samba release 1.9.18 08 Jan 1998
+!== DNIX.txt for Samba release 1.9.18p6 11 May 1998
!==
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
diff --git a/docs/textdocs/DOMAIN.txt b/docs/textdocs/DOMAIN.txt
index dec39f3d013..51b997d20f2 100644
--- a/docs/textdocs/DOMAIN.txt
+++ b/docs/textdocs/DOMAIN.txt
@@ -1,5 +1,5 @@
!==
-!== DOMAIN.txt for Samba release 1.9.18 08 Jan 1998
+!== DOMAIN.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Samba Team
Updated: June 27, 1997
diff --git a/docs/textdocs/DOMAIN_CONTROL.txt b/docs/textdocs/DOMAIN_CONTROL.txt
index bbd03873b17..87c739de0a7 100644
--- a/docs/textdocs/DOMAIN_CONTROL.txt
+++ b/docs/textdocs/DOMAIN_CONTROL.txt
@@ -1,5 +1,5 @@
!==
-!== DOMAIN_CONTROL.txt for Samba release 1.9.18 08 Jan 1998
+!== DOMAIN_CONTROL.txt for Samba release 1.9.18p6 11 May 1998
!==
Initial Release: August 22, 1996
Contributor: John H Terpstra <samba-bugs@samba.anu.edu.au>
diff --git a/docs/textdocs/ENCRYPTION.txt b/docs/textdocs/ENCRYPTION.txt
index 352f3457b47..01102cba8ad 100644
--- a/docs/textdocs/ENCRYPTION.txt
+++ b/docs/textdocs/ENCRYPTION.txt
@@ -1,5 +1,5 @@
!==
-!== ENCRYPTION.txt for Samba release 1.9.18p3 19 Feb 1998
+!== ENCRYPTION.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Jeremy Allison <samba-bugs@samba.anu.edu.au>
Updated: March 19, 1998
@@ -223,6 +223,29 @@ access to this file can (with enough knowledge of the protocols) gain
access to your SMB server. The file is thus more sensitive than a
normal unix /etc/passwd file.
+Migrating to encrypted passwords
+--------------------------------
+
+New with Samba 1.9.18p5 and all subsequent versions is a parameter
+written by Bruce Tenison - the "update encrypted" parameter.
+If this parameter is set to "yes" (it defaults to "no") and an smbpasswd
+file exists containing all the valid users of a Samba system but
+no encrypted passwords (ie. the Lanman hash and NT hash entries in
+the file are set to "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), then as
+users log in with plaintext passwords that are matched against
+their UNIX password entries, their plaintext passwords will be
+hashed and entered into the smbpasswd file. After all the users
+have successfully logged in using unencrypted passwords, the
+smbpasswd file will have the Lanman and NT hashes of these users
+UNIX passwords correctly stored. At that point the administrator
+can convert Samba to use encrypted passwords (and configure the
+Windows 95 and NT clients to send only encrypted passwords) and
+migrate to an encrypted setup without having to ask users to re-enter
+all their passwords explicitly. Note that to use this option the
+"encrypt passwords" parameter must be set to "no" when this option
+is set to "yes". See the smb.conf man page for up to date information
+on this parameter.
+
The smbpasswd Command.
----------------------
@@ -247,6 +270,14 @@ on Windows NT servers (this only works when the request is
sent to the NT Primary Domain Controller if you are changing
an NT Domain users password).
+3). smbpasswd can use smbd to change the UNIX password at
+the same time as the SMB password is being changed. For details
+on this see the parameters 'passwd program', 'passwd chat', and
+'unix password sync' in the smb.conf man page. Note that Samba
+must have been compiled with -DALLOW_CHANGE_PASSWORD for this
+to work (and the system must be one in which UNIX password changing
+is supported).
+
To run smbpasswd as a normal user just type :
smbpasswd
diff --git a/docs/textdocs/Faxing.txt b/docs/textdocs/Faxing.txt
index ec6868431e0..f669cdbae74 100644
--- a/docs/textdocs/Faxing.txt
+++ b/docs/textdocs/Faxing.txt
@@ -1,5 +1,5 @@
!==
-!== Faxing.txt for Samba release 1.9.18 08 Jan 1998
+!== Faxing.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Gerhard Zuber <zuber@berlin.snafu.de>
Date: August 5th 1997.
diff --git a/docs/textdocs/GOTCHAS.txt b/docs/textdocs/GOTCHAS.txt
index 7a89383e3e4..bd937fa0a69 100644
--- a/docs/textdocs/GOTCHAS.txt
+++ b/docs/textdocs/GOTCHAS.txt
@@ -1,5 +1,5 @@
!==
-!== GOTCHAS.txt for Samba release 1.9.18 08 Jan 1998
+!== GOTCHAS.txt for Samba release 1.9.18p6 11 May 1998
!==
This file lists Gotchas to watch out for:
=========================================================================
diff --git a/docs/textdocs/HINTS.txt b/docs/textdocs/HINTS.txt
index a47c2a60754..d4b758cccd6 100644
--- a/docs/textdocs/HINTS.txt
+++ b/docs/textdocs/HINTS.txt
@@ -1,5 +1,5 @@
!==
-!== HINTS.txt for Samba release 1.9.18 08 Jan 1998
+!== HINTS.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Many
Updated: Not for a long time!
diff --git a/docs/textdocs/MIRRORS.txt b/docs/textdocs/MIRRORS.txt
index 7c028c06e61..6b13626c38b 100755
--- a/docs/textdocs/MIRRORS.txt
+++ b/docs/textdocs/MIRRORS.txt
@@ -1,5 +1,5 @@
!==
-!== MIRRORS.txt for Samba release 1.9.18 08 Jan 1998
+!== MIRRORS.txt for Samba release 1.9.18p6 11 May 1998
!==
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.
diff --git a/docs/textdocs/NTDOMAIN.txt b/docs/textdocs/NTDOMAIN.txt
index cd0db0eb051..590fe59826c 100644
--- a/docs/textdocs/NTDOMAIN.txt
+++ b/docs/textdocs/NTDOMAIN.txt
@@ -1,155 +1,24 @@
!==
-!== NTDOMAIN.txt for Samba release 1.9.18 08 Jan 1998
+!== NTDOMAIN.txt for Samba release 1.9.18p6 11 May 1998
!==
-Contributor: Luke Kenneth Casson Leighton (samba-bugs@samba.anu.edu.au)
- Copyright (C) 1997 Luke Kenneth Casson Leighton
+Contributor: Luke Kenneth Casson Leighton <samba-bugs@samba.anu.edu.au>
+ Copyright (C) 1997, 1998 Luke Kenneth Casson Leighton
Created: October 20, 1997
-Updated: October 29, 1997
+Updated: March 24, 1998
Subject: NT Domain Logons
===========================================================================
-As of 1.9.18alpha1, Samba supports logins for NT 3.51 and 4.0 Workstations,
-without the need, use or intervention of NT Server. This document describes
-how to set this up. Over the continued development of the 1.9.18alpha
-series, this process (and therefore this document) should become simpler.
+1.9.18p4 does not properly support NT Domains: please see the draft FAQ
+being written by Gerald Carter:
-One useful thing to do is to get this version of Samba up and running
-with Win95 profiles, as you would for the current stable version of
-Samba (currently at 1.9.17p4), and is fully documented. You will need
-to set up encrypted passwords. Even if you don't have any Win95 machines,
-using your Samba Server to store the profile for one of your NT Workstation
-users is a good test that you have 1.9.18alpha1 correctly configured *prior*
-to attempting NT Domain Logons.
+ http://www.eng.auburn.edu/users/cartegw/samba_ntdom_faq.html.
-The support is still experimental, so should be used at your own risk.
+and the Samba NT Domain archives:
-NT is not as robust as you might have been led to believe: during the
-development of the Domain Logon Support, one person reported having to
-reinstall NT from scratch: their workstation had become totally unuseable.
+ http://samba.anu.edu.au/listproc/samba-ntdom
-[further reports on ntsec@iss.net by independent administrators showing
- similar symptoms lead us to believe that the SAM database file may be
- corruptible. this _is_ recoverable (or, at least the machine is accessible),
- by deleting the SAM file, under which circumstances all user account details
- are lost, but at least the Administrator can log in with a blank password.
- this is *not* possible except if the NT system is installed in a FAT
- partition.]
+To obtain a version that does support NT Domains, please see:
-This *has* been reported to the NTBUGTRAQ@LISTSERV.NTBUGTRAQ.COM digest.
-
-
-Domain Logons using 1.9.18alpha1
-================================
-
-1) compile samba with -DNTDOMAIN
-
-2) set up samba with encrypted passwords: see ENCRYPTION.txt (probably out
- of date: you no longer need the DES libraries, but other than that,
- ENCRYPTION.txt is current).
-
- at this point, you ought to test that your samba server is accessible
- correctly with encrypted passwords, before progressing with any of the
- NT workstation-specific bits: it's up to you.
-
-3) [ for each workstation, add a line to smbpasswd with a username of MACHINE$
- and a password of "machine". this process will be automated in further
- releases. lkcl02nov97 - done, as of 1.9.18alpha11! added new options
- "domain hosts allow/deny" too :-) ]
-
-4) if using NT server to log in, run the User Manager for Domains, and
- add the capability to "Log in Locally" to the policies, which you would
- have to do even if you were logging in to another NT PDC instead of a
- Samba PDC.
-
-5) set up the following parameters in smb.conf
-
-; substitute your workgroup here
- workgroup = SAMBA
-
-; a description of domain sids can be found elsewhere.
-; you **MUST** begin the domain SID with S-1-5-21.
-; the rest is up to you.
- domain sid = S-1-5-21-123-456-789-123
-
-; tells workstations to use SAMBA as its Primary Domain Controller.
- domain logons = yes
-
-6) make sure samba is running before the next step is carried out. if
- this is your first time, just for fun you might like to switch the
- debug log level to about 10. the NT pipes produces some very pretty
- output when decoding requests and generating responses, which would
- be particularly useful to see in tcpdump at some point.
-
-7) In the NT Network Settings, change the domain to SAMBA. Do
- not attempt to create an account using the other part of the dialog:
- it will fail at present.
-
- You should get a wonderful message saying "Welcome to the SAMBA Domain."
-
- If you don't, then please first increase your debug log levels and also
- get a tcpdump (or preferably NetMonitor) trace and examine it carefully.
- You should see a NETLOGON, a SAMLOGON on UDP port 138. If you don't,
- then you probably don't have "domain logons = yes" or there is some other
- problem in resolving the NetBIOS name SAMBA<1c>.
-
- On port 139, you should see a LSA_OPEN_POLICY, two LSA_QUERY_INFOs (one
- for a domain SID of S-1-3... and another for S-1-5) and then an LSA_CLOSE
- or two.
-
- You may see a pipe connection to a wksta service being refused: this
- is acceptable, we have found. You may also see a "Net Server Get Info"
- being issued on the srvsvc pipe.
-
- Assuming you got the Welcome message, go through the obligatory reboot...
-
-8) When pressing Ctrl-Alt-Delete, the NT login box should have three entries.
- If there is a delay of about twenty seconds between pressing Ctrl-Alt-Delete
- and the appearance of this login dialog, then there might be a problem:
- at this stage the workstation is issuing an LSA_ENUMTRUSTEDDOMAIN request
-
- The domain box should have two entries: the hostname and the SAMBA domain.
- Any local accounts are under the hostname domain, from which you will be
- able to shut down the machine etc. At present, we do not specify that
- the NT user logging in is a member of any groups, so will have no
- priveleges, including the ability to shut down the machine [lkcl02nov97 -
- done, as of samba-1.9.18alpha3! see "domain admin/guest users" and
- "domain groups" parameters].
-
- Select the SAMBA domain, and type in a valid username and password for
- which there is a valid entry in the samba server's smbpasswd LM/NT OWF
- database. At present, the password is ignored, to allow access to the
- domain, but *not* ignored for accesses to Samba's SMB services: that's
- completely separate from the SAM Logon process. Even if you log in a
- user to a domain, your users will still need to connect to Samba SMB
- shares with valid username / passwords, for that share.
-
- You should see an LSA_REQ_CHAL, followed by LSA_AUTH2, LSA_NET_SRV_PWSET,
- and LSA_SAM_LOGON. The SAM Logon will be particularly large (the response
- can be approximately 600 bytes) as it contains user info.
-
- Also, there will probably be a "Net Server Get Info" and a "Net Share Enum"
- amongst this lot. If the SAM Logon is successful, the dialog should
- disappear, and a standard SMB connection established to download the
- profile specified in the SAM Logon (if it was).
-
- At this point, you _may_ encounter difficulties in creating a remote
- profile, and the login may terminate (generating an LSA_SAM_LOGOFF). If
- this occurs, then either find an existing profile on the samba server and
- copy it into the location specified by the "logon path" smb.conf parameter
- for the user logging in, or log in on the local machine, and use the
- System | Profiles control panel to make a copy of the _local_ profile onto
- the samba server. This process is described and documented in the NT
- Help Files.
-
-9) Play around. Look at the Samba Server: see if it can be found in the
- browse lists. Check that it is accessible; run some applications.
- Generally stress things. Laugh a lot. Logout of the NT machine
- (generating an LSA_SAM_LOGOFF) and log back in again. Try logging in
- two users simultaneously. Try logging the same user in twice.
- Make Samba fall over, and then send bug reports to us, with NTDOM: at
- the start of the subject line, as "samba-bugs@samba.anu.edu.au".
-
-Your reports, testing, patches, criticism and encouragement will help us
-get this right.
+ http://samba.anu.edu.au/cvs.html
diff --git a/docs/textdocs/NetBIOS.txt b/docs/textdocs/NetBIOS.txt
index c8fb385002e..0408bcc33c0 100644
--- a/docs/textdocs/NetBIOS.txt
+++ b/docs/textdocs/NetBIOS.txt
@@ -1,5 +1,5 @@
!==
-!== NetBIOS.txt for Samba release 1.9.18 08 Jan 1998
+!== NetBIOS.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: lkcl - samba-bugs@arvidsjaur.anu.edu.au
Copyright 1997 Luke Kenneth Casson Leighton
diff --git a/docs/textdocs/OS2-Client-HOWTO.txt b/docs/textdocs/OS2-Client-HOWTO.txt
index 9f525eb7264..1027aa078c6 100644
--- a/docs/textdocs/OS2-Client-HOWTO.txt
+++ b/docs/textdocs/OS2-Client-HOWTO.txt
@@ -1,5 +1,5 @@
!==
-!== OS2-Client-HOWTO.txt for Samba release 1.9.18 08 Jan 1998
+!== OS2-Client-HOWTO.txt for Samba release 1.9.18p6 11 May 1998
!==
diff --git a/docs/textdocs/PRINTER_DRIVER.txt b/docs/textdocs/PRINTER_DRIVER.txt
index 19098861f61..5bfe780d675 100644
--- a/docs/textdocs/PRINTER_DRIVER.txt
+++ b/docs/textdocs/PRINTER_DRIVER.txt
@@ -1,5 +1,5 @@
!==
-!== PRINTER_DRIVER.txt for Samba release 1.9.18 08 Jan 1998
+!== PRINTER_DRIVER.txt for Samba release 1.9.18p6 11 May 1998
!==
==========================================================================
Supporting the famous PRINTER$ share
diff --git a/docs/textdocs/PROFILES.txt b/docs/textdocs/PROFILES.txt
index 2cb3852d1cb..a05ed8259ac 100644
--- a/docs/textdocs/PROFILES.txt
+++ b/docs/textdocs/PROFILES.txt
@@ -1,3 +1,6 @@
+!==
+!== PROFILES.txt for Samba release 1.9.18p6 11 May 1998
+!==
Contributors: Bruce Cook <BC3-AU@bigfoot.com>
Copyright (C) 1998 Bruce Cook
diff --git a/docs/textdocs/Passwords.txt b/docs/textdocs/Passwords.txt
index 8d7dddc8bce..bd9cbe26c61 100644
--- a/docs/textdocs/Passwords.txt
+++ b/docs/textdocs/Passwords.txt
@@ -1,5 +1,5 @@
!==
-!== Passwords.txt for Samba release 1.9.18 08 Jan 1998
+!== Passwords.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Unknown
Date: Unknown
diff --git a/docs/textdocs/Printing.txt b/docs/textdocs/Printing.txt
index 98efbb54083..c2413443470 100644
--- a/docs/textdocs/Printing.txt
+++ b/docs/textdocs/Printing.txt
@@ -1,5 +1,5 @@
!==
-!== Printing.txt for Samba release 1.9.18p3 19 Feb 1998
+!== Printing.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Unknown <samba-bugs@samba.anu.edu.au>
Date: Unknown
diff --git a/docs/textdocs/RoutedNetworks.txt b/docs/textdocs/RoutedNetworks.txt
deleted file mode 100644
index 06169d5ed89..00000000000
--- a/docs/textdocs/RoutedNetworks.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-#NOFNR Flag in LMHosts to Communicate Across Routers
-
- Last reviewed: May 5, 1997
- Article ID: Q103765
- The information in this article applies to:
-
- Microsoft Windows NT operating system version 3.1
- Microsoft Windows NT Advanced Server version 3.1
-
- SUMMARY
-
- Some of the LAN Manager for UNIX and Pathworks servers may have
-problems in communicating across routers with
- Windows NT workstations. The use of #NOFNR flag in the LMHosts
-file solves the problem.
-
- MORE INFORMATION
-
- When you are communicating with a server across a router in a IP
-routed environment, the LMHosts file is used to
- resolve Workstation name-to-IP address mapping. The LMHosts
-entry for a remote machine name provides the IP
- address for the remote machine. In Lan Manager 2.x, providing
-the LMHosts entry eliminates the need to do a Name
- Query broadcast to the local domain and instead a TCP session is
-established with the remote machine. Windows NT
- performs the same function in a different way.
-
- When an LMHosts entry exists for a remote server, Windows NT
-will not send a Name Query broadcast to the local
- subnet and instead send a directed Name Query to the remote
-server. If the remote server does not respond to the Name
- Query, further communications (TCP SYN, and so on) will not take
-place. This was done to eliminate the performance
- issues when trying to connect to a remote machine when it was
-not available (down).
-
- Some of the older LAN Manager for UNIX and DEC Pathworks servers
-do not respond to directed Name Queries sent
- by Windows NT. In that case, the users will see an error 53
-(Path not found), even though they have specified the
- LMHosts entries correctly. A new LMHosts flag #NOFNR was added
-to solve this problem. By specifying the
- #NOFNR flag on the same line where the name resolution
-information for the server is provided, the directed Name
- Query can be avoided. For example:
-
- 130.20.1.1 mylmxserver #PRE #NOFNR
-
-
- Note that this will only apply to mylmxserver and not to any
-other entries in the LMHosts file. To set
- a global flag, an entry could be added in the registry. To
-completely remove any directed Name
- Queries sent from a Windows NT machine, create the following
-value in
-
-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Nbt\Parameters:
-
- NoDirectedFNR REG_DWORD 1
-
-
- This will cause the directed Name Queries to not go out for any
-remote machines. \ No newline at end of file
diff --git a/docs/textdocs/SCO.txt b/docs/textdocs/SCO.txt
index b4a5df862bf..3ebfeb95cd6 100644
--- a/docs/textdocs/SCO.txt
+++ b/docs/textdocs/SCO.txt
@@ -1,5 +1,5 @@
!==
-!== SCO.txt for Samba release 1.9.18 08 Jan 1998
+!== SCO.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Geza Makay <makayg@math.u-szeged.hu>
Date: Unknown
diff --git a/docs/textdocs/Speed.txt b/docs/textdocs/Speed.txt
index c156ee1b8e8..3deded5a9c3 100644
--- a/docs/textdocs/Speed.txt
+++ b/docs/textdocs/Speed.txt
@@ -1,5 +1,5 @@
!==
-!== Speed.txt for Samba release 1.9.18 08 Jan 1998
+!== Speed.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Andrew Tridgell
Date: January 1995
diff --git a/docs/textdocs/Speed2.txt b/docs/textdocs/Speed2.txt
index a8c3e7381fd..57046f90b99 100644
--- a/docs/textdocs/Speed2.txt
+++ b/docs/textdocs/Speed2.txt
@@ -1,3 +1,6 @@
+!==
+!== Speed2.txt for Samba release 1.9.18p6 11 May 1998
+!==
Contributor: Paul Cochrane <paulc@dth.scot.nhs.uk>
Organization: Dundee Limb Fitting Centre
Date: Fri, 10 Apr 1998
diff --git a/docs/textdocs/Support.txt b/docs/textdocs/Support.txt
index 3a971af95bb..2f409f01fbd 100644
--- a/docs/textdocs/Support.txt
+++ b/docs/textdocs/Support.txt
@@ -1,5 +1,5 @@
!==
-!== Support.txt for Samba release 1.9.18p3 19 Feb 1998
+!== Support.txt for Samba release 1.9.18p6 11 May 1998
!==
The Samba Consultants List
==========================
@@ -36,9 +36,9 @@ Region Number of entries
AMERICA - CENTRAL & SOUTH 4
AMERICA - USA 36
ASIA 1
- AUSTRALIA & NEW ZEALAND 18
- CANADA 8
- EUROPE 40
+ AUSTRALIA & NEW ZEALAND 19
+ CANADA 9
+ EUROPE 41
MIDDLE EAST 1
AFRICA
@@ -415,19 +415,17 @@ Related Products and Services:
------------------------------------------------------------------------------
FLORIDA - USA
-The PC Doctor
-3009 West Tharpe Street Unit-C
-Tallahassee, Florida 32303
-ph 904.531.0364
-fx 904.531.0128
+Ten Twenty-Six Enterprises, Inc.
+1616 Illinois Street, Orlando FL 32803
+
+http://www.ten26.com/
-Contacts: Andy McRory pcdr@pcdr.com
- David Blodgett david@pcdr.com
+Email: samba@ten26.com
-The PC Doctor specializes in Linux Internet/Workgroup servers and network
-intergration. We have experience in setup and configuration of SAMBA under
-Caldera/RedHat/Slackware Linux as well as SCO and AIX. We offer workgroup
-Internet gateway servers for Windows client based networks.
+Tel: 407 898-2519
+
+We are a commercial network and computer consulting firm providing
+hardware sales and network support.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
@@ -902,12 +900,9 @@ Novell/NT Systems.
------------------------------------------------------------------------------
N.T - AUSTRALIA
-Open Systems Network Support
-
-Server Platforms - Unix/Linux
-Client Platforms - Windows3.1/95/NT, Macintosh, Unix/Linux
-
---
+Open Systems Network SupportServer Platforms -
+Unix/Linux
+Client Platforms - Windows3.1/95/NT, Macintosh, Unix/Linux--
David Schroeder Darwin Network Services
Ph/Fax (08) 8932 1156 PO Box 82383
(Int) +61 8 8932 1156 Casuarina N.T
@@ -968,6 +963,31 @@ Clients for whom we have installed and supported Samba.
------------------------------------------------------------------------------
QUEENSLAND - AUSTRALIA
+OPAL BROOK Pty Ltd.
+Dave Forden
+The Software Systems & Technology Consulting Specialists
+Unit 120 Admiralty Towers 1, 35 Howard Street BRISBANE QLD 4000
+Business: 38318251
+Mobile: 041 996 5577
+email: opalbrk@bit.net.au
+web: http://bit.net.au/~opalbrk
+
+ON SITE: FOCUS98 Project - Queensland Department of Natural Resources
+fordendk@exchange.lands.qld.gov.au
+Unit6 Level3 Anzac Square Building Brisbane
+(07) 3227 6265
+
+My company provides general Unix based development and support services in
+Brisbane.
+
+Personally, I have been using SAMBA for about 2 years and have implemented
+it on several different Unix platforms including HPUX, Linux, Dynix, and
+Solaris.
+------------------------------------------------------------------------------
+
+------------------------------------------------------------------------------
+QUEENSLAND - AUSTRALIA
+
Plugged In Software Pty Ltd
PO Box 4130
4/242 Hawken Drive
@@ -1058,6 +1078,28 @@ CANADA
======
------------------------------------------------------------------------------
+ALBERTA - CANADA
+
+GDS & Associates Systems Ltd.
+1010 First Edmonton Place
+10665 Jasper Ave.
+Edmonton, AB
+Canada T5J 3S9
+
+http://www.gds.ca/
+
++1 403 426 4484
+FAX: 426 2898
+
+Contact: Iain O'Cain <iocain@gds.ca>
+
+GDS is an information management consulting company with headquarters in
+Regina, Saskatchewan, and offices across Western Canada. The Edmonton
+office offers Systems Management services covering a variety of Unix and
+similar server operating systems.
+------------------------------------------------------------------------------
+
+------------------------------------------------------------------------------
ONTARIO - CANADA
Strata Software Limited, Kanata Ontario CANADA
@@ -1772,6 +1814,33 @@ under Linux. We are also an internet provider.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
+ITALY
+
+Sedac S.a.S.
+
+Piazza XX Settembre, 68
+62012 Civitanova Marche (MC)
+Italy
+
+Tel. : +39 (733) 810257-817064
+Fax : +39 (733) 819008
+PPP : +39 (733) 819009
+E-mail : sedac@cognigni.com
+WWW : http://www.cognigni.com/sedac
+
+La Sedac S.a.S. e' specializzata nell'implementazione ed amministrazione di
+reti eterogenee LAN/WAN basate sui sistemi operativi SCO Open Server, SCO
+Unix, Windows NT e Windows 95.
+Su tali piattaforme installiamo, configuriamo e supportiamo pienamente il
+Samba.
+
+Sedac S.a.S. is specialized in the implementation and administration of
+heterogeneous LAN/WAN networks based on SCO Open Server, SCO Unix, Windows
+NT and Windows 95 operating systems.
+On these platforms we fully install, configure and support Samba.
+------------------------------------------------------------------------------
+
+------------------------------------------------------------------------------
TREVISO - ITALY
Company: SMC Computers S.r.l.
diff --git a/docs/textdocs/Tracing.txt b/docs/textdocs/Tracing.txt
index ab6d53a9fb6..f9591acf190 100644
--- a/docs/textdocs/Tracing.txt
+++ b/docs/textdocs/Tracing.txt
@@ -1,5 +1,5 @@
!==
-!== Tracing.txt for Samba release 1.9.18 08 Jan 1998
+!== Tracing.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Andrew Tridgell <samba-bugs@samba.anu.edu.au>
Date: Old
diff --git a/docs/textdocs/UNIX-SMB.txt b/docs/textdocs/UNIX-SMB.txt
index 43cd0875ece..2eef372b3ef 100644
--- a/docs/textdocs/UNIX-SMB.txt
+++ b/docs/textdocs/UNIX-SMB.txt
@@ -1,5 +1,5 @@
!==
-!== UNIX-SMB.txt for Samba release 1.9.18 08 Jan 1998
+!== UNIX-SMB.txt for Samba release 1.9.18p6 11 May 1998
!==
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 43d71b099ea..0c3153bd834 100644
--- a/docs/textdocs/UNIX_INSTALL.txt
+++ b/docs/textdocs/UNIX_INSTALL.txt
@@ -1,5 +1,5 @@
!==
-!== UNIX_INSTALL.txt for Samba release 1.9.18 08 Jan 1998
+!== UNIX_INSTALL.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Andrew Tridgell <samba-bugs@samba.anu.edu.au>
Date: Unknown
diff --git a/docs/textdocs/Win95.txt b/docs/textdocs/Win95.txt
index 0b26079a3cb..02feee12942 100644
--- a/docs/textdocs/Win95.txt
+++ b/docs/textdocs/Win95.txt
@@ -1,5 +1,5 @@
!==
-!== Win95.txt for Samba release 1.9.18 08 Jan 1998
+!== Win95.txt for Samba release 1.9.18p6 11 May 1998
!==
Copyright (C) 1997 - Samba-Team
Contributed Date: August 20, 1997
diff --git a/docs/textdocs/WinNT.txt b/docs/textdocs/WinNT.txt
index 148d7f4df2e..91523134dff 100644
--- a/docs/textdocs/WinNT.txt
+++ b/docs/textdocs/WinNT.txt
@@ -1,5 +1,5 @@
!==
-!== WinNT.txt for Samba release 1.9.18 08 Jan 1998
+!== WinNT.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributors: Various
Password Section - Copyright (C) 1997 - John H Terpstra
diff --git a/docs/textdocs/cifsntdomain.txt b/docs/textdocs/cifsntdomain.txt
index c2a171a9f5f..52694b6f268 100644
--- a/docs/textdocs/cifsntdomain.txt
+++ b/docs/textdocs/cifsntdomain.txt
@@ -1,5 +1,5 @@
!==
-!== cifsntdomain.txt for Samba release 1.9.18 08 Jan 1998
+!== cifsntdomain.txt for Samba release 1.9.18p6 11 May 1998
!==
NT Domain Authentication
------------------------
diff --git a/docs/textdocs/security_level.txt b/docs/textdocs/security_level.txt
index 4c471214cf9..bb0d4d7d57b 100644
--- a/docs/textdocs/security_level.txt
+++ b/docs/textdocs/security_level.txt
@@ -1,5 +1,5 @@
!==
-!== security_level.txt for Samba release 1.9.18 08 Jan 1998
+!== security_level.txt for Samba release 1.9.18p6 11 May 1998
!==
Contributor: Andrew Tridgell
Updated: June 27, 1997
diff --git a/examples/smb.conf.default b/examples/smb.conf.default
index fba4ecca0ac..43ae79770dc 100644
--- a/examples/smb.conf.default
+++ b/examples/smb.conf.default
@@ -14,7 +14,7 @@
#======================= Global Settings =====================================
[global]
-# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
+# workgroup = NT-Domain-Name or Workgroup-Name
workgroup = MYGROUP
# server string is the equivalent of the NT Description field
@@ -61,11 +61,18 @@
# Use password server option only with security = server
; password server = <NT-Server-Name>
+# Password Level allows matching of _n_ characters of the password for
+# all combinations of upper and lower case.
+; password level = 8
+
# 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
+# Unix users can map to different SMB User names
+; username map = /etc/smbusers
+
# 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
@@ -80,6 +87,13 @@
# here. See the man page for details.
; interfaces = 192.168.12.2/24 192.168.13.2/24
+# Configure remote browse list synchronisation here
+# request announcement to, or browse list sync from:
+# a specific host or from / to a whole subnet (see below)
+; remote browse sync = 192.168.3.25 192.168.5.255
+# Cause this host to announce itself to local subnets here
+; remote announce = 192.168.1.255 192.168.2.44
+
# 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
@@ -136,6 +150,15 @@
# this has been changed in version 1.9.18 to no.
dns proxy = no
+# Case Preservation can be handy - system default is _no_
+# NOTE: These can be set on a per share basis
+; preserve case = no
+; short preserve case = no
+# Default case is normally upper case for all DOS files
+; default case = lower
+# Be very careful with case sensitivity - it can break things!
+; case sensitive = no
+
#============================ Share Definitions ==============================
[homes]
comment = Home Directories
diff --git a/packaging/Caldera/Makefile b/packaging/Caldera/Makefile
new file mode 100644
index 00000000000..a181cd5009e
--- /dev/null
+++ b/packaging/Caldera/Makefile
@@ -0,0 +1,873 @@
+###########################################################################
+# Makefile for Samba SMB client/server for unix
+# Copyright Andrew Tridgell 1992-1998
+# Copyright John H Terpstra 1995-1998
+###########################################################################
+
+# The base directory for all samba files
+BASEDIR = /usr
+
+# The base manpages directory to put the man pages in
+# Note: $(MANDIR)/man1, $(MANDIR)/man5 and $(MANDIR)/man8 must exist.
+MANDIR = /usr/man
+
+# The directories to put things in. If you use multiple
+# architectures or share the samba binaries across NFS then
+# you will probably want to change this layout.
+# Note: The SBINDIR is for files you do not want users to access
+# normally only applies to nmbd and smbd
+# SBINDIR implies a secure binary directory
+BINDIR = $(BASEDIR)/bin
+SBINDIR = $(BASEDIR)/sbin
+LIBDIR = /etc
+VARDIR = /var/log/samba
+
+# The permissions to give the executables
+INSTALLPERMS = 0755
+
+# Add any optimisation or debugging flags here
+# add -DSYSLOG for syslog support
+FLAGS1 = -O
+LIBS1 =
+
+# You will need to use a ANSI C compiler. This means under SunOS 4 you can't
+# use cc, instead you will have to use gcc.
+CC = gcc
+
+# This may help with some versions of make
+SHELL = /bin/sh
+
+# The following can be useful for compiling on multiple architectures
+# just uncommment them putting the right directory in.
+# srcdir=./
+# VPATH=$(srcdir)
+
+# set these to where to find various files
+# These can be overridden by command line switches (see smbd(8))
+# or in smb.conf (see smb.conf(5))
+SMBLOGFILE = $(VARDIR)/log.smb
+NMBLOGFILE = $(VARDIR)/log.nmb
+CONFIGFILE = $(LIBDIR)/smb.conf
+LMHOSTSFILE = $(LIBDIR)/lmhosts
+DRIVERFILE = $(LIBDIR)/printers.def
+SMB_PASSWD = $(BINDIR)/smbpasswd
+SMB_PASSWD_FILE = $(LIBDIR)/smbpasswd
+WEB_ROOT = $(BASEDIR)
+
+# the directory where lock files go
+LOCKDIR = /var/lock/samba
+
+# The directory where code page definition files go
+CODEPAGEDIR = $(LIBDIR)/codepages
+# The current codepage definition list.
+CODEPAGELIST= 437 850 852 932 866 949 950 936
+
+# set this to the default group you want your machine to appear in
+# for browsing. This can also be set in nmbd (see nmbd(8))
+WORKGROUP = WORKGROUP
+
+# set this to the name of the default account, which is the one
+# to use when no username or password is specified. This can be overridden
+# in the runtime configuration file (see smb.conf(5))
+# NOTE: The account "nobody" may not be a good one as
+# on many unixes it may not be able to print. Thus you
+# might have to create a separate guest account that can print.
+GUESTACCOUNT = nobody
+
+# where you are going to have the smbrun binary. This defaults to the
+# install directory. This binary is needed for correct printing
+# and magic script execution. This should be an absolute path!
+# Also not that this should include the name "smbrun" on the end (the
+# name of the executable)
+SMBRUN = $(BINDIR)/smbrun
+
+#
+# The following (PAM, AFS, DCE/DFS, Kerberos5, SMB) are the
+# alternate choices for Samba authentication. If you are using
+# the UNIX password database to authenticate users you do not
+# need to uncomment any of them. If you wish to use one of these
+# alternate methods then only uncomment one of them.
+
+# This is for PAM authentication. RedHat Linux uses PAM.
+# If you use PAM, then uncomment the following lines:
+PAM_FLAGS = -DUSE_PAM
+PAM_LIBS = -ldl -lpam
+
+# This is for AFS authentication. If you use AFS then set AFS_BASE
+# according to your system layout, and uncomment the other lines as well.
+# AFS_BASE = /usr/afsws
+# AFS_FLAGS = -DAFS_AUTH -I$(AFS_BASE)/include
+# AFS_LIBDIR = $(AFS_BASE)/lib
+# NOTE: You may need to add -laudit in the line below
+# AFS_LIBS = -L$(AFS_LIBDIR) -L$(AFS_LIBDIR)/afs -lkauth -lprot -lubik \
+# -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err \
+# $(AFS_LIBDIR)/afs/util.a
+
+# This is for DCE/DFS enablement. Uncomment this so that smbd can
+# operate as an authenticated user identity to operate on files that
+# live in the DCE Distributed Filesystem.
+# DCE_BASE = /opt/dcelocal
+# DCE_FLAGS = -DDFS_AUTH -I$(DCE_BASE)/include
+# DCE_LIBDIR = -L$(DCE_BASE)/lib
+# DCE_LIBS =
+
+# This is for Kerberos 5 authentication. Contributed by Nathan Neulinger
+# Univ. of Missouri - Rolla <nneul@umr.edu>
+# KRB5_BASE = /usr/local/krb5
+# KRB5_FLAGS = -DKRB5_AUTH -I$(KRB5_BASE)/include
+# KRB5_LIBS = -L$(KRB5_BASE)/lib -ldes425 -lkrb5 -lcrypto -lcom_err
+
+# This is for Kerberos 4 authentication. Contributed by Johan Hedin
+# Royal Institute of Technology, <johanh@fusion.kth.se>
+# KRB4_BASE = /usr/athena
+# KRB4_FLAGS = -DKRB4_AUTH -I$(KRB4_BASE)/include
+# KRB4_LIBS = -L$(KRB4_BASE)/lib -lkrb -ldes -lresolv
+
+######################################
+# VTP-Support
+#
+# uncomment the following two lines to enable VTP-Support
+#VTP_FLAGS = -DWITH_VTP
+#VTP_OBJ = vt_mode.o
+######################################
+
+######################################
+# WHICH AWK? awk is used for automatic prototype generation. GNU awk works
+# where inferior awks don't. Sun is one manufacturer who supplies both
+# a broken awk called 'awk' and a fixed one called 'nawk'. mkproto.awk will
+# only work with the latter, and even that isn't as good as free GNU awk.
+#
+# Leave this uncommented; the OS-specific stuff will override it if required
+AWK = awk
+######################################
+
+#####################################
+# WHICH OPERATING SYSTEM?
+# UNCOMMENT ONE OF THE SECTIONS BELOW
+# MAKE SURE ONLY *ONE* IS UNCOMMENTED
+#
+# The following are additional flags that may apply
+# -DNETGROUP if your machine supports yp netgroups
+# -DAUTOMOUNT to ask for yp auto.home for users' home directories
+# -DNISPLUS add this to ask nis+ instead of yp for users' home directories
+# -DSHADOW_PWD if you are using shadow passwords
+# -DGETPWANAM if you wish to use getpwanam() call
+# -DPWDAUTH if you have and want to use the pwdauth() call
+# -DUFC_CRYPT if you want the fast crypt routine
+# -DALLOW_CHANGE_PASSWORD if you want users to be able to set their password
+# remotely (only works on some systems)
+# -DQUOTAS for quota support in disk_free(). This probably only works
+# on some systems.
+# -DFAST_SHARE_MODES if you want the fast shared memory instead of the
+# slow description files for share mode locking. This
+# requires the mmap() and fcntl() system calls.
+#
+# NOTE: GETPWANAM & PWDAUTH are mutually exclusive, if you
+# Define one, you should NOT define the other.
+#####################################
+
+#####################################
+# for the JAPANESE EXTENSION
+# select filename's code set for KANJI/KANA in UNIX,
+# apply the following flag
+# -DKANJI=\"<code>\"
+# <code> is select character code set for JAPAN.
+# sjis: if your machine support SJIS
+# euc: if your machine support EUC
+# jis7: if your machine support JIS7
+# jis8: if your machine support JIS8
+# junet: if your machine support jis7 + junet rule
+# hex: if your machine only support 7 bits ascii filename only
+# convert to hexdecimal code preseeding ':'.
+# see also README.jis
+######################################
+
+
+# This is for SUNOS 4. Use the SUNOS5 entry for Solaris 2.
+# Note that you cannot use Suns "cc" compiler
+# as it's not an Ansi-C compiler. Get gcc or acc.
+# Note that if you have adjunct passwords you may need the GETPWANAM
+# or PWDAUTH option. There have been reports that using PWDAUTH may crash
+# your pwdauthd server so GETPWANAM is preferable (and probably faster)
+# contributed by Andrew.Tridgell@anu.edu.au
+# FLAGSM = -DSUNOS4 -DFAST_SHARE_MODES
+# LIBSM =
+# AWK = nawk
+
+# If you are using Linux kernel version 2.1.70 and later, you should
+# uncomment the following line to compile the smbmount utilities
+# together with Samba. If you are using Linux kernel version 2.0.x
+# you must use the smbfs utilities from
+# ftp://ftp.gwdg.de/pub/linux/misc/smbfs
+
+# MOUNT_PROGS = smbmount smbmnt smbumount
+
+# Use this for Linux with shadow passwords - but not using PAM!
+# contributed by Andrew.Tridgell@anu.edu.au
+# add -DLINUX_BIGCRYPT is you have shadow passwords but don't have the
+# right libraries and includes
+# FLAGSM = -DLINUX -DSHADOW_PWD -DFAST_SHARE_MODES
+# LIBSM = -lshadow
+
+# Use this for Linux without shadow passwords or for any Linux
+# system that uses PAM (eg: RedHat) in which case it handles ALL
+# authentication methods that are supported by the version of
+# PAM that is available on your system.
+# contributed by Andrew.Tridgell@anu.edu.au & John.Terpstra@aquasoft.com.au
+# AXPROC defines DEC Alpha Processor
+# FLAGSM = -DLINUX -DAXPROC -DFAST_SHARE_MODES
+FLAGSM = -DLINUX -DFAST_SHARE_MODES
+LIBSM =
+
+# Use this for Linux with shadow passwords and quota - but not using PAM!
+# contributed by xeno@mix.hive.no
+# Tested on the 1.3.57 kernel and ext2fs filesystem.
+# Notes:
+# /usr/include/sys/quota.h must be a symlink to /usr/include/linux/quota.h
+# The directory quota here must be a symlink to your quota package.
+# I just do 'ln -sf /usr/src/quota-1.50 quota' in this directory to get it to work.
+# FLAGSM = -O3 -m486 -DLINUX -DSHADOW_PWD -DQUOTAS -DFAST_SHARE_MODES
+# LIBSM = -lshadow
+
+# Use this for Linux with quota and glibc2 - not using PAM!
+# contributed by Thorvald Natvig <slicer@bimbo.hive.no>
+# Tested on the 2.0.30 kernel and ext2fs filesystem.
+# FLAGSM = -DLINUX -DQUOTAS -DNO_ASMSIGNALH -DGLIBC2 -DFAST_SHARE_MODES
+# LIBSM = -L/lib/libc5-compat -lcrypt
+
+# Use this for Linux with glibc2 (libc6)
+# contributed by Eloy Paris <peloy@ven.ra.rockwell.com>
+# FLAGSM = -DLINUX -DNETGROUP -DSHADOW_PWD -DALLOW_CHANGE_PASSWORD -DFAST_SHARE_MODES -DNO_ASMSIGNALH -DGLIBC2
+# LIBSM = -lnsl -lcrypt
+
+# Use this for Linux with glibc2 (libc6) - RedHat Linux v5.0 with PAM
+# contributed by John H Terpstra <jht@aquasoft.com.au>
+# FLAGSM = -DLINUX -DNETGROUP -DALLOW_CHANGE_PASSWORD -DFAST_SHARE_MODES -DNO_ASMSIGNALH -DGLIBC2
+# LIBSM = -lnsl -lcrypt
+
+# This is for SUNOS5.4 and later (also known as Solaris 2.4 and later)
+# contributed by Andrew.Tridgell@anu.edu.au
+# FLAGSM = -DSUNOS5 -DSHADOW_PWD -DNETGROUP -DFAST_SHARE_MODES
+# LIBSM = -lsocket -lnsl
+# AWK = nawk
+
+# This is for SUNOS 5.2 and 5.3 (also known as Solaris 2.2 and 2.3)
+# contributed by hdsi@newtech.net
+# FLAGSM = -DSUNOS5 -DSHADOW_PWD -DNETGROUP -DNO_STRFTIME -DFAST_SHARE_MODES
+# LIBSM = -lsocket -lnsl
+# AWK = nawk
+
+# This is for UXP/DS
+# contributed by dsfrost@oai6.yk.fujitsu.co.jp
+# FLAGSM = -DSVR4 -DSHADOW_PWD
+# LIBSM = -lsocket -lnsl
+
+# This is for SVR4
+# Contributed by mark@scot1.ucsalf.ac.uk
+# FLAGSM = -DSVR4 -DSHADOW_PWD -DALLOW_CHANGE_PASSWORD
+# LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb
+
+
+# This is for the Motorola 88xxx/9xx range of machines
+# Contributed by RPE@monnet.com
+# FLAGSM = -DSVR4 -DSHADOW_PWD -DGETTIMEOFDAY1
+# LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb
+
+
+# This is for UnixWare 1.x.
+# Contributed by Warren Young <tkennedy@cyberport.com>
+#FLAGSM = -Xa -DSVR4 -DSHADOW_PWD
+#LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb
+
+# This is for UnixWare 2.x WITH libdes support.
+# Contributed by tangent@cyberport.com
+#FLAGSM = -Xa -DSVR4
+#LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb
+
+# This is for UnixWare 2.x WITHOUT libdes support.
+# Contributed by tangent@cyberport.com
+#FLAGSM = -Xa -DSVR4 -DIA_UINFO
+#LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb -lcrypt -liaf
+
+# This is for UNIXWARE 2.x with shadow passwords.
+# Contributed by fja@extratech.com
+#FLAGSM = -Xa -DSVR4 -DSHADOW_PWD
+#LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb -lcrypt -lgen
+
+# This is for ULTRIX. Add -DULTRIX_AUTH for Ultrix enhanced security.
+# contributed by iversen@dsfys1.fi.uib.no
+# FLAGSM = -DULTRIX
+# LIBSM =
+
+
+# This is for OSF1 (Alpha)
+# contributed by errath@balu.kfunigraz.ac.at
+# NOTE: You may need -warning_unresolved if you get unresolved symbols
+# FLAGSM = -DOSF1 -DFAST_SHARE_MODES
+# LIBSM =
+
+# This is for OSF1 with DCE/DFS
+# contributed by Jim Doyle <doyle@oec.com>
+# FLAGSM = -DOSF1 -DDFS_AUTH -DSIGCLD_IGNORE -DNO_SIGNAL_TEST
+# LIBSM = -ldce -lpthreads -lmach -lc_r
+
+# This is for OSF1 (Alpha) with NIS and Fast Crypt
+# contributed by David Gardiner <dgardine@cssip.edu.au>
+# FLAGSM = -DOSF1 -DNETGROUP -DUFC_CRYPT
+# LIBSM =
+
+
+# This is for OSF1 (Alpha) V2.0/V4.0 Enhanced Security
+# contributed by Udo Linauer <ul@eacpc4.tuwien.ac.at>
+# FLAGSM = -DOSF1 -DOSF1_ENH_SEC -DFAST_SHARE_MODES
+# LIBSM = -lsecurity
+
+
+# This is for AIX 3.2.5 (without DCE/DFS)
+# contributed by Miguel Angel Cruz <mcruz@maccsys.org>
+# FLAGSM = -DAIX
+# LIBSM =
+
+# This is for AIX 3.2.5 with DCE/DFS
+# contributed by Jim Doyle <doyle@oec.com>
+# FLAGSM = -DAIX -DDFS_AUTH -DSIGCLD_IGNORE -DNO_SIGNAL_TEST
+# LIBSM = -lc_r -ldce -lpthreads
+# CC = cc_r
+
+# This is for AIX 4.x
+# contributed by tomc@osi.curtin.edu.au
+# FLAGSM = -DAIX -DFAST_SHARE_MODES
+# LIBSM =
+
+# This is for AIX 4.x with quota support
+# contributed by tomc@osi.curtin.edu.au
+# FLAGSM = -DAIX -DFAST_SHARE_MODES -DQUOTAS
+# LIBSM =
+
+# This is for BSDI
+# contributed by tomh@metrics.com
+# versions of BSDI prior to 2.0 may need to add -DUSE_F_FSIZE for
+# disk usage stats to be correct
+# FLAGSM = -DBSDI -DFAST_SHARE_MODES
+# LIBSM =
+
+
+# This is for NetBSD. Add -DNETBSD_1_0 if you are using 1.0
+# contributed by noses@oink.rhein.de
+# FLAGSM = -DNETBSD -DSHADOW_PWD
+# LIBSM = -lcrypt
+
+# This is for NetBSD 1.3
+# contributed by sean@fuzzymagic.com
+# FLAGSM = -DNETBSD -DSHADOW_PWD -DUFC_CRYPT -DALLOW_CHANGE_PASSWORD -DFAST_SHARE_MODES
+# LIBSM = -lcrypt
+
+# This is for SEQUENT.
+# Contributed by fwk@ix.netcom.com (Frank Keeney) and
+# rpwillia@Pentagon-EMH6.army.mil (Ray Williams)
+# tested on DYNIX/ptx(R) V2.1.0
+# FLAGSM = -DSEQUENT -DSHADOW_PWD -DHAVE_TIMEZONE
+# LIBSM = -lrpc -lsocket -lPW -linet -lnsl -lseq -lsec
+
+
+# This is for SEQUENT PTX 4.1.x
+# Contributed by bressler@iftccu.ca.boeing.com (Rick Bressler)
+# based on Keeny and Williams contribution.
+# tested on DYNIX/ptx(R) V4.1.3
+# FLAGSM = -DSEQUENT -DSHADOW_PWD -DHAVE_TIMEZONE -DPTX4
+# LIBSM = -lrpc -lsocket -lPW -lnsl -lseq -lsec
+
+
+# This is for HP-UX 9.x. Note that some systems don't like the -Aa switch.
+# contributed by Pasi.Kaara@atk.tpo.fi
+# You will need -DREPLACE_GETPASS if you use smb encryption
+# FLAGSM = -DHPUX -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE
+# LIBSM =
+
+# This is for HP-UX 10.x. Note that some systems don't like the -Aa switch.
+# contributed by Pasi.Kaara@atk.tpo.fi
+# You will need -DREPLACE_GETPASS if you use smb encryption
+# FLAGSM = -DHPUX -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE -DHPUX10 -DFAST_SHARE_MODES
+# LIBSM =
+
+
+# This is for HP-UX with DCE/DFS
+# contributed by Jim Doyle <doyle@oec.com>
+# Add -DHPUX10 -DFAST_SHARE_MODES if compiling on HPUX 10.x
+# FLAGSM = -DHPUX -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE -DDFS_AUTH -D_REENTRANT -I/usr/include/reentrant
+# LIBSM = -ldce -lM -lc_r
+
+# HP-UX 10.x Trusted System
+# Contributed by David-Michael Lincke (dlincke@sgcl1.unisg.ch)
+# FLAGSM = +O3 -Ae -DHPUX -DHPUX10 -DHPUX_10_TRUSTED -DFAST_SHARE_MODES
+# LIBSM = -lsec
+
+
+# This is for SGI.
+# FOR SGI IRIX 4.x.x, use the following line
+# contributed by lpc@solomon.technet.sg (Michael Chua)
+# FLAGSM = -DSGI4 -DHAVE_TIMEZONE
+# LIBSM = -lsun
+# FLAGS1 = -O -g3
+
+# FOR SGI IRIX 5.x.x, use this line instead
+# Contributed by <unknown>
+# FLAGSM = -DSGI5 -DSHADOW_PWD -DHAVE_TIMEZONE -DFAST_SHARE_MODES
+# LIBSM =
+# FLAGS1 = -O -g3
+
+# FOR SGI IRIX 6.2 using the system compiler (*NOT* gcc), use this line instead
+# Contributed by David.Billinghurst@restech.cra.com.au
+# FLAGSM = -DSGI6 -DSHADOW_PWD -DHAVE_TIMEZONE -DFAST_SHARE_MODES
+# LIBSM =
+# FLAGS1 = -O -n32 -g3
+
+# This is for FreeBSD
+# contributed by kuku@acds.physik.rwth-aachen.de
+# NOTE: You may need to add -DBSD44 if you have password problems
+# FLAGSM = -DFreeBSD -DFAST_SHARE_MODES
+# LIBSM = -lcrypt
+
+# This is for OpenBSD
+# contributed by todd@openbsd.org
+# FLAGSM = -DFAST_SHARE_MODES -DBSD44
+# LIBSM =
+
+# This is for NEXTSTEP Release 2.X
+# No Posix.
+# contributed by brad@cac.washington.edu (Brad Greer)
+# FLAGSM = -DNEXT2
+# LIBSM =
+
+# This is for NEXTSTEP Release 3.0 and greater (including OPENSTEP for Mach).
+# contributed by brad@cac.washington.edu (Brad Greer)
+# additional configuration by pmarcos@next.com (Paul Marcos)
+# For compiling n-way fat executables, you should append the appropriat -arch
+# flags to the FLAGSM variable. Valid flags are:
+# -arch m68k
+# -arch i386
+# -arch hppa
+# -arch sparc
+# To compile 4-way fat, you would append
+# -arch m68k -arch i386 -arch hppa -arch sparc
+# FLAGSM = -DNEXT3_0
+# LIBSM =
+
+
+# NOTE: ISC is also known as "INTERACTIVE"
+# This is for Sunsoft ISC SVR3V4 running in POSIX mode
+# contributed by pim@cti-software.nl (Pim Zandbergen)
+# FLAGSM = -posix -D_SYSV3 -DISC -DSHADOW_PWD
+# LIBSM = -lsec -lcrypt -linet
+
+# This is for Sunsoft ISC SVR3V4 running in iBCS2 mode
+# contributed by pim@cti-software.nl (Pim Zandbergen)
+# FLAGSM = -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_SYSV3\
+# -DISC -DSHADOW_PWD -DREPLACE_GETWD -DREPLACE_RENAME
+# LIBSM = -lsec -lcrypt -linet -lcposix
+
+
+# This is for A/UX 3.0
+# Contributed by root@dolphin.csudh.edu (Jon S. Stevens)
+# FLAGSM = -DAUX
+# LIBSM =
+
+# This is for Altos Series 386/1000
+# Contributed by cal@zls.com
+# FLAGSM = -DALTOS -DHAS_RDCHK
+# LIBSM = -lsocket -lxenix
+
+
+#Note: The SCO entries require the libcrypt library. You can get it via
+#anonymous ftp from ftp.sco.com:/SLS/lng225b.* or ftp.uu.net:/vendors/sco
+#
+# Use this for SCO with shadow passwords. Tested on "Open enterprise 3.0"
+# SCO changes from Heinz Mauelshagen (mauelsha@ez.da.telekom.de)
+# FLAGSM = -DSCO -DSHADOW_PWD -DNETGROUP
+# LIBSM = -lyp -lrpc -lyp -lsec -lsocket -lcrypt_i -lintl
+
+# Use this for SCO with shadow passwords, without YP.
+# Tested on "Open Enterprise Server 3.0" (John Owens john@micros.com)
+# Also, use "CC = cc" above.
+# FLAGSM = -DSCO -DSHADOW_PWD
+# LIBSM = -lsec -lsocket -lcrypt_i
+
+# Use this for SCO with TCB passwords (default).
+# Tested on "Open enterprise 3.0". Contributed by lance@fox.com.
+# CC = cc
+# FLAGSM = -DSCO -DSecureWare
+# LIBSM = -lprot_s -lcrypt -lsocket -lm -lc_s
+
+# Use this for SCO Unix 3.2v2 (ODT 1.1) with TCB passwords (default).
+# Contributed by Stephen.Rothwell@pd.necisa.oz.au
+# N.B. this needs gcc
+# FLAGSM = -DSCO -DSecureWare -DSCO3_2_2
+# LIBSM = -lprot -lcrypt_i -lsocket -lm -lintl
+
+# This is for the european distribution of SCO.
+# Contributed by Urmet.Janes@gwhite.goodwin.ee
+# FLAGSM = -DSCO -DSHADOW_PWD
+# LIBSM = -lsec -lsocket /usr/lib/libcrypt_i.a -lintl
+
+# Use this for SCO OpenServer 5 with TCB passwords (default).
+# contributed by Scott Michel <scottm@intime.intime.com>
+# you may also like to add the -dy switch (recommended by Marnus van
+# Niekerk, mvn@pixie.co.za)
+# CC = cc -Xc
+# FLAGSM = -DSCO -DSecureWare -DEVEREST -DUSE_MMAP
+# LIBSM = -lprot -lcurses -lcrypt -lsocket -lPW -lm -lx -lc_s -lc
+
+
+# This is for intergraph.
+# contributed by cjkiick@flinx.b11.ingr.com
+# modified by ttj@sknsws61.sjo.statkart.no
+# FLAGSM = -DCLIX -D_INGR_EXTENSIONS=1
+# LIBSM = -lbsd -lc_s
+
+# This is for DGUX.
+# Contributed by ross@augie.insci.com (Ross Andrus)
+# FLAGSM = -DDGUX
+# LIBSM =
+
+# This is for DGUX on Intel boxes.
+# Contributed by tim@denmantire.com
+# FLAGSM = -DDGUX
+# LIBSM = -lsocket -lnsl -lresolv
+
+# This is for Apollo Domain/OS sr10.3 (systype = BSD4.3)
+# Added 1994-07-08 Stephen C. Steel <steve@qv3donald.LeidenUniv.nl>
+# additional patches by jmi@csd.cri.dk (John Mills)
+# you may need the "-A ansi" switch to cc
+# FLAGSM = -DAPOLLO -D_INCLUDE_BSD_SOURCE -D_INCLUDE_XOPEN_SOURCE
+# LIBSM =
+
+
+# RiscIX.
+# contributed by Jim Barry <jim@ilp.com> and
+# Charles Gay-Jones <charlie@ilp.com>
+# FLAGSM = -DRiscIX -DNOSTRDUP
+# LIBSM =
+
+
+# This is for System V with some berkely extensions (Motorola 88k R32V3.2).
+# contributed by tonyb@plaza.ds.adp.com (Tony D. Birnseth)
+# FLAGSM = -DM88K_R3
+# LIBSM = -lgen -lbsd -lnsl
+
+
+# This is for DNIX.
+# contributed by Peter Olsson <pol@leissner.se>
+# NOTE: You may need an updated libc.a from your vendor as older
+# versions have broken mktime calls and no initgroups() call
+# NOTE2: You may need -lpasswd if you use shadow passwords
+# NOTE3: Please read the file DNIX.txt in the docs directory. It
+# contains important information about uid handling under DNIX, you may
+# need to patch your C library.
+# FLAGSM = -DDNIX -I/usr/include/bsd
+# LIBSM = -ln
+
+
+# This is for Cray, Unicos 8.0
+# contributed by velo@sesun3.epfl.ch (Martin Ouwehand)
+# FLAGSM = -DCRAY -U__STDC__ -DQUOTAS
+# LIBSM =
+
+# This is for Convex
+# contributed by Victor Balashov <balashov@cv.jinr.dubna.su>
+# and Ulrich Hahn <ulrich.hahn@zdv.uni-tuebingen.de>
+# FLAGSM= -DCONVEX -DSHADOW_PWD
+# LIBSM=
+
+# This is for SMP_DC.OSx v1.1-94c079 on Pyramid S series
+# contributed by jeffrey@itm.org
+# FLAGSM = -DSOLARIS -DSHADOW_PWD -DBSD_COMP
+# LIBSM = -lsocket -lnsl
+
+# This is for QNX 4.22
+# Contributed by eldo@invisa.satlink.net (Eldo Loguzzo)
+# FLAGSM = -DQNX -DGUEST_SESSSETUP=1
+# LIBSM =
+
+
+# This is for SONY NEWS, NEWS-OS 4.2.x
+# contributed by sky@sm.sony.co.jp (Katushi Sato)
+# FLAGSM = -DNEWS42 -DKANJI=\"sjis\"
+# LIBSM =
+
+
+# This is for SONY NEWS, NEWS-OS 6.1.x
+# contributed by kobo@sm.sony.co.jp (Yoichi Kobori)
+# FLAGSM = -Xa -DSVR4 -DNEWS61 -DSHADOW_PWD -DNETGROUP -DGETTIMEOFDAY1 -DKANJI=\"euc\"\ -D_SONYILS_H
+# LIBSM = -lsocket -lnsl
+
+
+# This is for OS/2 using EMX
+# Contributed by jasonr@pec.co.nz (Jason Rumney)
+# Now maintained by Jacco de Leeuw <leeuw@wins.uva.nl>
+# FLAGSM = -DOS2
+# LIBSM = -Zexe -lsocket
+
+
+# This is for LYNX 2.3.0 (gcc v2.6)
+# Contributed by woelfel@hpe.fzk.de (Manfred Woelfel)
+# FLAGSM = -DLYNX -DUFC_CRYPT -mposix
+# LIBSM = -lbsd
+
+
+# This is for MachTen (a unix like system for Macintoshes)
+# contributed by Trevor Strohman (trev@figment.tenon.com)
+# FLAGSM = -DMACHTEN
+# LIBSM =
+
+
+# RISCOs 5.0B
+# contributed by John Agnew <johna@bfs.Unibol.COM>
+# FLAGSM = -systype svr4 -std -DSVR4
+# LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb
+
+
+# This is for B.O.S. (Bull Operating System)
+# Contributed by koine@fileita.it
+# FLAGSM = -DBOS -DNO_RESOURCEH -DUSE_WAITPID
+# LIBSM = -linet
+
+
+# This for Amiga using GCC and ixemul.library 43.0 or later.
+# contributed by Rask Ingemann Lambertsen <rask@k4315.kampsax.dtu.dk>
+# The binaries will support both AmiTCP and AS225R2 compatible
+# protocol stacks because of the use of ixnet.library.
+# Other protocol stacks will be supported automatically if
+# support for them is added to ixnet.library.
+# The binaries will have automatic stack extension :-)
+# smbd must be run from inetd :-(
+# FLAGSM = -DAMIGA -Dfork=vfork -mstackextend
+# LIBSM =
+
+
+
+######################################################################
+# DON'T EDIT BELOW THIS LINE
+######################################################################
+
+PASSWD_FLAGS = -DSMB_PASSWD=\"$(SMB_PASSWD)\" -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\"
+CFLAGS1 = $(FLAGS1) -DSMBLOGFILE=\"$(SMBLOGFILE)\" -DNMBLOGFILE=\"$(NMBLOGFILE)\"
+CFLAGS2 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" -DWEB_ROOT=\"$(WEB_ROOT)\"
+CFLAGS3 = -DLOCKDIR=\"$(LOCKDIR)\" -DSMBRUN=\"$(SMBRUN)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\"
+CFLAGS4 = -DWORKGROUP=\"$(WORKGROUP)\" -DGUEST_ACCOUNT=\"$(GUESTACCOUNT)\" -DDRIVERFILE=\"$(DRIVERFILE)\"
+CFLAGS5 = $(CFLAGS1) $(CFLAGS2) $(CFLAGS3) $(CFLAGS4) $(FLAGSM) $(AFS_FLAGS) $(KRB5_FLAGS) $(KRB4_FLAGS) $(RPM_OPT_FLAGS)
+CFLAGS = $(CFLAGS5) $(PAM_FLAGS) $(DCE_FLAGS) $(DES_FLAGS) $(PASSWD_FLAGS) $(VTP_FLAGS)
+LIBS = $(LIBS1) $(LIBSM) $(PAM_LIBS) $(DCE_LIBS) $(KRB5_LIBS) $(KRB4_LIBS) $(DES_LIB)
+
+INCLUDES1 = $(srcdir)version.h $(srcdir)local.h $(srcdir)includes.h $(srcdir)smb.h
+INCLUDES2 = $(srcdir)trans2.h
+INCLUDES = $(INCLUDES1) $(INCLUDES2)
+
+SPROGS = smbd nmbd
+PROGS1 = smbclient testparm testprns smbrun smbstatus smbpasswd make_smbcodepage
+PROGS = $(PROGS1) nmblookup make_printerdef $(MOUNT_PROGS)
+
+SCRIPTS = smbtar addtosmbpass
+
+
+######################################################################
+# object modules
+######################################################################
+
+# modules in the ubiqx library from Chris Hertel
+UBIOBJ = ubiqx/ubi_dLinkList.o
+
+# client specific object code in the rpc_pipes directory
+RPC_CLI_OBJ = rpc_pipes/ntclientpipe.o rpc_pipes/ntclientlsa.o rpc_pipes/ntclientnet.o
+
+# server specific object code in the rpc_pipes directory
+RPC_SERV_OBJ = rpc_pipes/pipenetlog.o rpc_pipes/pipentlsa.o rpc_pipes/pipesrvsvc.o rpc_pipes/pipewkssvc.o rpc_pipes/pipesamr.o
+
+# server object files in the rpc_pipes subdirectory
+RPC_OBJ1 = rpc_pipes/srvparse.o rpc_pipes/smbparse.o rpc_pipes/lsaparse.o rpc_pipes/pipeutil.o
+RPC_OBJ2 = rpc_pipes/pipe_hnd.o rpc_pipes/samrparse.o rpc_pipes/wksparse.o rpc_pipes/lsa_hnd.o
+RPC_OBJ = $(RPC_OBJ1) $(RPC_OBJ2)
+
+# general utility object files
+UTILOBJ1 = util.o system.o charset.o kanji.o fault.o smbencrypt.o smbdes.o charcnv.o
+UTILOBJ2 = $(UTILOBJ1) md4.o loadparm.o params.o pcap.o username.o time.o namequery.o nmblib.o
+UTILOBJ = $(UTILOBJ2) interface.o replace.o print_svid.o smberr.o mem_man/mem_man.o slprintf.o
+
+# object code for smbd
+SMBDOBJ1 = $(UTILOBJ) trans2.o message.o dir.o printing.o
+SMBDOBJ2 = ipc.o reply.o mangle.o chgpasswd.o password.o quotas.o uid.o
+SMBDOBJ3 = predict.o credentials.o clientgen.o pipes.o server.o access.o
+SMBDOBJ4 = ufc.o smbpass.o
+SMBDOBJ = $(SMBDOBJ1) $(SMBDOBJ2) $(SMBDOBJ3) $(SMBDOBJ4) $(UBIOBJ) $(RPC_OBJ) $(RPC_SERV_OBJ) $(VTP_OBJ) $(LOCKOBJ)
+
+# object code needed for programs that handle the the locking files
+LOCKOBJ = locking_shm.o locking_slow.o locking.o shmem.o shmem_sysv.o
+
+# object code for nmbd
+NMBDOBJ1 = nmbd.o nmbd_packets.o nmbd_lmhosts.o nmbd_become_dmb.o nmbd_logonnames.o
+NMBDOBJ2 = nmbd_browserdb.o nmbd_responserecordsdb.o nmbd_workgroupdb.o nmbd_serverlistdb.o
+NMBDOBJ3 = nmbd_subnetdb.o nmbd_browsesync.o nmbd_nodestatus.o nmbd_mynames.o nmbd_winsproxy.o
+NMBDOBJ4 = nmbd_sendannounce.o nmbd_processlogon.o nmbd_incomingdgrams.o clientgen.o
+NMBDOBJ5 = asyncdns.o smbpass.o nmbd_winsserver.o nmbd_incomingrequests.o nmbd_nameregister.o
+NMBDOBJ6 = nmbd_namerelease.o nmbd_namequery.o nmbd_become_lmb.o nmbd_elections.o nmbd_namelistdb.o
+
+NMBDOBJ = $(UTILOBJ) $(NMBDOBJ1) $(NMBDOBJ2) $(NMBDOBJ3) $(NMBDOBJ4) $(NMBDOBJ5) $(NMBDOBJ6)
+
+# object files for smbclient
+CLIENT_OBJ = client.o ntclient.o credentials.o clientutil.o clitar.o getsmbpass.o $(UTILOBJ) $(RPC_CLI_OBJ) $(RPC_OBJ)
+
+# object files for smbmount
+MOUNT_OBJ = smbmount.o ntclient.o credentials.o clientutil.o getsmbpass.o $(UTILOBJ) $(RPC_CLI_OBJ) $(RPC_OBJ)
+
+# object files for smbmnt
+MNT_OBJ = smbmnt.o
+
+# object files for smbumount
+UMOUNT_OBJ = smbumount.o
+
+# object files for smbstatus
+STATUS_OBJ = status.o $(UTILOBJ) $(LOCKOBJ)
+
+# object files for nmblookup
+LOOKUP_OBJ = nmblookup.o $(UTILOBJ)
+
+
+# object files to be auto-prototyped
+PROTOOBJ = $(UTILOBJ) $(SMBDOBJ) $(NMBDOBJ) $(LOCKOBJ) $(CLIENT_OBJ) $(STATUS_OBJ) cgi.o namequery.o
+
+
+######################################################################
+# now the rules...
+######################################################################
+
+all : CHECK $(SPROGS) $(PROGS)
+
+CHECK :
+ @$(SHELL) $(srcdir)checkos.sh $(FLAGSM)
+ @echo "Using CFLAGS = $(CFLAGS)"
+ @echo "Using LIBS = $(LIBS)"
+
+.SUFFIXES:
+.SUFFIXES: .c .o .h
+
+.c.o: $(INCLUDES)
+ @echo Compiling $*.c
+ @$(CC) $(CFLAGS) -c $(srcdir)$*.c -o $(srcdir)$*.o
+
+smbd: $(SMBDOBJ) $(ARCFOUR_OBJ)
+ @echo Linking smbd
+ @$(CC) $(CFLAGS) -o smbd $(SMBDOBJ) $(ARCFOUR_OBJ) $(LIBS) $(AFS_LIBS)
+
+smbrun: smbrun.o
+ @echo Linking smbrun
+ @$(CC) $(CFLAGS) -o smbrun smbrun.o $(LIBS)
+
+nmblookup: $(LOOKUP_OBJ)
+ @echo Linking nmblookup
+ @$(CC) $(CFLAGS) -o nmblookup $(LOOKUP_OBJ) $(LIBS)
+
+nmbd: $(NMBDOBJ)
+ @echo Linking nmbd
+ @$(CC) $(CFLAGS) -o nmbd $(NMBDOBJ) $(LIBS)
+
+smbclient: $(CLIENT_OBJ) $(ARCFOUR_OBJ)
+ @echo Linking smbclient
+ @$(CC) $(CFLAGS) -o smbclient $(CLIENT_OBJ) $(ARCFOUR_OBJ) $(LIBS)
+
+smbmount: $(MOUNT_OBJ) $(ARCFOUR_OBJ)
+ @echo Linking smbmount
+ @$(CC) $(CFLAGS) -o smbmount $(MOUNT_OBJ) $(ARCFOUR_OBJ) $(LIBS)
+
+smbmnt: $(MNT_OBJ)
+ @echo Linking smbmnt
+ @$(CC) $(CFLAGS) -o smbmnt $(MNT_OBJ)
+
+smbumount: $(UMOUNT_OBJ)
+ @echo Linking smbumount
+ @$(CC) $(CFLAGS) -o smbumount $(UMOUNT_OBJ)
+
+smbtorture: torture.o clientgen.o getsmbpass.o $(UTILOBJ)
+ @echo Linking smbtorture
+ @$(CC) $(CFLAGS) -o smbtorture torture.o clientgen.o getsmbpass.o $(UTILOBJ) $(LIBS)
+
+smbstatus: $(STATUS_OBJ)
+ @echo Linking smbstatus
+ @$(CC) $(CFLAGS) -o smbstatus $(STATUS_OBJ) $(LIBS)
+
+testparm: testparm.o access.o $(UTILOBJ)
+ @echo Linking testparm
+ @$(CC) $(CFLAGS) -o testparm testparm.o access.o $(UTILOBJ) $(LIBS)
+
+testprns: testprns.o $(UTILOBJ)
+ @echo Linking testprns
+ @$(CC) $(CFLAGS) -o testprns testprns.o $(UTILOBJ) $(LIBS)
+
+smbpasswd: smbpasswd.o getsmbpass.o smbpass.o clientgen.o $(UTILOBJ)
+ @echo Linking smbpasswd
+ @$(CC) $(CFLAGS) -o smbpasswd smbpasswd.o getsmbpass.o smbpass.o clientgen.o $(UTILOBJ) $(LIBS)
+
+make_smbcodepage: make_smbcodepage.o $(UTILOBJ)
+ @echo Linking make_smbcodepage
+ @$(CC) $(CFLAGS) -o make_smbcodepage make_smbcodepage.o $(UTILOBJ) $(LIBS)
+
+make_printerdef: make_printerdef.o $(UTILOBJ)
+ @echo Linking make_printerdef
+ @$(CC) $(CFLAGS) -o make_printerdef make_printerdef.o $(UTILOBJ) $(LIBS)
+
+wsmbstatus: wsmbstatus.o $(UTILOBJ)
+ @echo Linking wsmbstatus
+ @$(CC) $(CFLAGS) -o wsmbstatus wsmbstatus.o $(UTILOBJ) $(LIBS)
+
+wsmbconf: wsmbconf.o $(UTILOBJ) cgi.o
+ @echo Linking wsmbconf
+ @$(CC) $(CFLAGS) -o wsmbconf wsmbconf.o $(UTILOBJ) cgi.o $(LIBS)
+
+install: installbin installman installscripts installcp
+
+installbin: all
+ @$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS)
+ @$(SHELL) $(srcdir)installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS)
+
+installscripts:
+ @$(SHELL) $(srcdir)installscripts.sh $(INSTALLPERMS) $(BINDIR) $(SCRIPTS)
+
+installcp:
+ @$(SHELL) $(srcdir)installcp.sh $(LIBDIR) $(CODEPAGEDIR) $(BINDIR) $(CODEPAGELIST)
+
+# revert to the previously installed version
+revert:
+ @$(SHELL) $(srcdir)revert.sh $(SBINDIR) $(SPROGS) $(SCRIPTS)
+ @$(SHELL) $(srcdir)revert.sh $(BINDIR) $(PROGS) $(SCRIPTS)
+
+installman:
+ @$(SHELL) $(srcdir)installman.sh $(MANDIR) $(srcdir)
+
+uninstall: uninstallman uninstallbin uninstallscripts uninstallcp
+
+uninstallman:
+ @$(SHELL) $(srcdir)uninstallman.sh $(MANDIR) $(srcdir)
+
+uninstallbin:
+ @$(SHELL) $(srcdir)uninstallbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS)
+ @$(SHELL) $(srcdir)uninstallbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS)
+
+uninstallscripts:
+ @$(SHELL) $(srcdir)uninstallscripts.sh $(INSTALLPERMS) $(BINDIR) $(SCRIPTS)
+
+uninstallcp:
+ @$(SHELL) $(srcdir)uninstallcp.sh $(CODEPAGEDIR) $(CODEPAGELIST)
+
+clean:
+ rm -f core *.o */*.o *~ $(PROGS) $(SPROGS)
+
+cleandir: clean
+ rm -f .depend tags
+
+proto:
+ @$(SHELL) $(srcdir)checkos.sh $(FLAGSM)
+ $(AWK) -f mkproto.awk `echo $(PROTOOBJ) | sed -e 's/\.o/\.c/g' | tr ' ' '\n' | sort | uniq` > proto.h
+
+tags:
+ etags `find . -name "*.[ch]"`
+
+realclean: clean
+
diff --git a/packaging/Caldera/makeldirs.sh b/packaging/Caldera/makeldirs.sh
new file mode 100755
index 00000000000..1ca312dfc18
--- /dev/null
+++ b/packaging/Caldera/makeldirs.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+RPMDIR=$1
+mkdir $RPMDIR
+for i in etc etc/logrotate.d bin sbin usr usr/bin usr/sbin var var/spool var/log var/lock var/lock/samba
+do
+ if [ ! -x $RPMDIR/$i ]; then
+ mkdir $RPMDIR/$i
+ fi
+ echo Mkdir $RPMDIR/$i ... Done
+done
diff --git a/packaging/Caldera/makerpms.sh b/packaging/Caldera/makerpms.sh
new file mode 100755
index 00000000000..a697fad4957
--- /dev/null
+++ b/packaging/Caldera/makerpms.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) John H Terpstra and Erik Troan - 1997
+#
+# First we move all our gear into place - a noble move!
+RPMDIR=`rpm --showrc | awk '/^rpmdir/ { print $3}'`
+SPECDIR=`rpm --showrc | awk '/^specdir/ { print $3}'`
+SRCDIR=`rpm --showrc | awk '/^sourcedir/ { print $3}'`
+VERSION=1.9.18p6
+
+cd $SRCDIR
+chown -R root.root samba-${VERSION}
+cd $SRCDIR/samba-${VERSION}/source
+mv Makefile Makefile.orig
+cp $SRCDIR/samba-${VERSION}/packaging/Caldera/Makefile .
+cd $SRCDIR
+diff -u samba-${VERSION}/source/Makefile.orig samba-${VERSION}/source/Makefile > $SRCDIR/samba-${VERSION}/packaging/Caldera/samba-make.patch
+cd $SRCDIR/samba-${VERSION}/source
+mv -f Makefile.orig Makefile
+cd $SRCDIR/samba-${VERSION}/packaging/Caldera
+cp -a *.spec $SPECDIR
+cp -a *.patch smb.* samba.log $SRCDIR
+cd $SRCDIR
+tar czvf samba-${VERSION}.tar.gz samba-${VERSION}
+cd $SPECDIR
+rpm --clean -ba samba.spec
diff --git a/packaging/Caldera/samba-make.patch b/packaging/Caldera/samba-make.patch
new file mode 100644
index 00000000000..8ae309bbd8f
--- /dev/null
+++ b/packaging/Caldera/samba-make.patch
@@ -0,0 +1,74 @@
+--- samba-1.9.18p4/source/Makefile.orig Fri Mar 20 09:09:25 1998
++++ samba-1.9.18p4/source/Makefile Fri Mar 27 19:38:50 1998
+@@ -5,11 +5,11 @@
+ ###########################################################################
+
+ # The base directory for all samba files
+-BASEDIR = /usr/local/samba
++BASEDIR = /usr
+
+ # The base manpages directory to put the man pages in
+ # Note: $(MANDIR)/man1, $(MANDIR)/man5 and $(MANDIR)/man8 must exist.
+-MANDIR = /usr/local/man
++MANDIR = /usr/man
+
+ # The directories to put things in. If you use multiple
+ # architectures or share the samba binaries across NFS then
+@@ -18,9 +18,9 @@
+ # normally only applies to nmbd and smbd
+ # SBINDIR implies a secure binary directory
+ BINDIR = $(BASEDIR)/bin
+-SBINDIR = $(BASEDIR)/bin
+-LIBDIR = $(BASEDIR)/lib
+-VARDIR = $(BASEDIR)/var
++SBINDIR = $(BASEDIR)/sbin
++LIBDIR = /etc
++VARDIR = /var/log/samba
+
+ # The permissions to give the executables
+ INSTALLPERMS = 0755
+@@ -32,7 +32,7 @@
+
+ # You will need to use a ANSI C compiler. This means under SunOS 4 you can't
+ # use cc, instead you will have to use gcc.
+-# CC = gcc
++CC = gcc
+
+ # This may help with some versions of make
+ SHELL = /bin/sh
+@@ -51,11 +51,11 @@
+ LMHOSTSFILE = $(LIBDIR)/lmhosts
+ DRIVERFILE = $(LIBDIR)/printers.def
+ SMB_PASSWD = $(BINDIR)/smbpasswd
+-SMB_PASSWD_FILE = $(BASEDIR)/private/smbpasswd
++SMB_PASSWD_FILE = $(LIBDIR)/smbpasswd
+ WEB_ROOT = $(BASEDIR)
+
+ # the directory where lock files go
+-LOCKDIR = $(VARDIR)/locks
++LOCKDIR = /var/lock/samba
+
+ # The directory where code page definition files go
+ CODEPAGEDIR = $(LIBDIR)/codepages
+@@ -90,8 +90,8 @@
+
+ # This is for PAM authentication. RedHat Linux uses PAM.
+ # If you use PAM, then uncomment the following lines:
+-# PAM_FLAGS = -DUSE_PAM
+-# PAM_LIBS = -ldl -lpam
++PAM_FLAGS = -DUSE_PAM
++PAM_LIBS = -ldl -lpam
+
+ # This is for AFS authentication. If you use AFS then set AFS_BASE
+ # according to your system layout, and uncomment the other lines as well.
+@@ -215,8 +215,8 @@
+ # contributed by Andrew.Tridgell@anu.edu.au & John.Terpstra@aquasoft.com.au
+ # AXPROC defines DEC Alpha Processor
+ # FLAGSM = -DLINUX -DAXPROC -DFAST_SHARE_MODES
+-# FLAGSM = -DLINUX -DFAST_SHARE_MODES
+-# LIBSM =
++FLAGSM = -DLINUX -DFAST_SHARE_MODES
++LIBSM =
+
+ # Use this for Linux with shadow passwords and quota - but not using PAM!
+ # contributed by xeno@mix.hive.no
diff --git a/packaging/Caldera/samba.log b/packaging/Caldera/samba.log
new file mode 100644
index 00000000000..c5f2a5b45bc
--- /dev/null
+++ b/packaging/Caldera/samba.log
@@ -0,0 +1,11 @@
+/var/log/samba/log.nmb {
+ postrotate
+ /usr/bin/killall -HUP nmbd
+ endrotate
+}
+
+/var/log/samba/log.smb {
+ postrotate
+ /usr/bin/killall -HUP smbd
+ endrotate
+}
diff --git a/packaging/Caldera/samba.pamd b/packaging/Caldera/samba.pamd
new file mode 100644
index 00000000000..17767cc4f8f
--- /dev/null
+++ b/packaging/Caldera/samba.pamd
@@ -0,0 +1,2 @@
+auth required /lib/security/pam_pwdb.so nullok shadow
+account required /lib/security/pam_unix_acct.so
diff --git a/packaging/Caldera/samba.spec b/packaging/Caldera/samba.spec
new file mode 100644
index 00000000000..9b83ec599ff
--- /dev/null
+++ b/packaging/Caldera/samba.spec
@@ -0,0 +1,206 @@
+Summary: SMB client and server
+Name: samba
+Version: 1.9.18p6
+Release: Caldera.1
+Copyright: GPL
+Group: Networking
+Source: ftp://samba.anu.edu.au/pub/samba/samba-1.9.18p4.tar.gz
+Patch: samba-make.patch
+Packager: John H Terpstra [Samba-Team] <jht@samba.anu.edu.au>
+Requires: libpam >= 0.56
+BuildRoot: /tmp/samba
+
+%description
+Samba provides an SMB server which can be used to provide
+network services to SMB (sometimes called "Lan Manager")
+clients, including various versions of MS Windows, OS/2,
+and other Linux machines. Samba also provides some SMB
+clients, which complement the built-in SMB filesystem
+in Linux. Samba uses NetBIOS over TCP/IP (NetBT) protocols
+and does NOT need NetBEUI (Microsoft Raw NetBIOS frame)
+protocol.
+
+This release is known as the "Locking Update" and has full
+support for Opportunistic File Locking. In addition this update
+includes native support for Microsoft encrypted passwords,
+improved browse list and WINS database management.
+
+Please refer to the WHATSNEW.txt document for fixup information.
+This binary release includes encrypted password support.
+Please read the smb.conf file and ENCRYPTION.txt in the
+docs directory for implementation details.
+
+NOTE: Caldera Open Linux Uses PAM which has integrated support
+for Shadow passwords. Do NOT recompile with the SHADOW_PWD option
+enabled. Caldera Open Linux has built in support for quotas in PAM.
+
+%prep
+%setup
+%patch -p1
+
+%build
+cd source
+make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
+make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" wsmbconf
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/etc
+mkdir -p $RPM_BUILD_ROOT/etc/codepages
+mkdir -p $RPM_BUILD_ROOT/etc/codepages/src
+mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
+mkdir -p $RPM_BUILD_ROOT/etc/pam.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc0.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc1.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc2.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc3.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc5.d
+mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc6.d
+mkdir -p $RPM_BUILD_ROOT/home/samba
+mkdir -p $RPM_BUILD_ROOT/usr/bin
+mkdir -p $RPM_BUILD_ROOT/usr/doc/samba-1.9.18p5-Caldera.2
+mkdir -p $RPM_BUILD_ROOT/usr/sbin
+mkdir -p $RPM_BUILD_ROOT/usr/man/man1
+mkdir -p $RPM_BUILD_ROOT/usr/man/man5
+mkdir -p $RPM_BUILD_ROOT/usr/man/man7
+mkdir -p $RPM_BUILD_ROOT/usr/man/man8
+mkdir -p $RPM_BUILD_ROOT/var/lock/samba
+mkdir -p $RPM_BUILD_ROOT/var/log/samba
+mkdir -p $RPM_BUILD_ROOT/var/spool/samba
+
+for i in nmblookup smbclient smbpasswd smbrun smbstatus testparm testprns
+do
+install -m755 -s source/$i $RPM_BUILD_ROOT/usr/bin
+done
+
+for i in addtosmbpass mksmbpasswd.sh smbtar make_smbcodepage make_printerdef
+do
+install -m755 source/$i $RPM_BUILD_ROOT/usr/bin
+done
+
+for i in smbd nmbd wsmbconf
+do
+install -m755 -s source/$i $RPM_BUILD_ROOT/usr/sbin
+done
+
+for i in smbclient.1 smbrun.1 smbstatus.1 smbtar.1 testparm.1 testprns.1 make_smbcodepage.1
+do
+install -m644 docs/$i $RPM_BUILD_ROOT/usr/man/man1
+done
+
+for i in 437 850 852 866 932 949 950 936
+do
+install -m644 source/codepage_def.$i $RPM_BUILD_ROOT/etc/codepages/src
+done
+
+install -m644 docs/smb.conf.5 $RPM_BUILD_ROOT/usr/man/man5
+install -m644 docs/samba.7 $RPM_BUILD_ROOT/usr/man/man7
+install -m644 docs/smbd.8 $RPM_BUILD_ROOT/usr/man/man8
+install -m644 docs/nmbd.8 $RPM_BUILD_ROOT/usr/man/man8
+install -m644 docs/smbpasswd.8 $RPM_BUILD_ROOT/usr/man/man8
+install -m644 packaging/Caldera/smb.conf $RPM_BUILD_ROOT/etc/smb.conf
+install -m644 packaging/Caldera/smbusers $RPM_BUILD_ROOT/etc/smbusers
+install -m755 packaging/Caldera/smbprint $RPM_BUILD_ROOT/usr/bin
+install -m755 packaging/Caldera/smbadduser $RPM_BUILD_ROOT/usr/bin
+install -m755 packaging/Caldera/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
+install -m755 packaging/Caldera/smb.init $RPM_BUILD_ROOT/usr/sbin/samba
+install -m644 packaging/Caldera/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
+install -m644 packaging/Caldera/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
+
+ln -sf /etc/rc.d/init.d/smb $RPM_BUILD_ROOT/etc/rc.d/rc0.d/K35smb
+ln -sf /etc/rc.d/init.d/smb $RPM_BUILD_ROOT/etc/rc.d/rc1.d/K35smb
+ln -sf /etc/rc.d/init.d/smb $RPM_BUILD_ROOT/etc/rc.d/rc2.d/K35smb
+ln -sf /etc/rc.d/init.d/smb $RPM_BUILD_ROOT/etc/rc.d/rc3.d/S91smb
+ln -sf /etc/rc.d/init.d/smb $RPM_BUILD_ROOT/etc/rc.d/rc5.d/S91smb
+ln -sf /etc/rc.d/init.d/smb $RPM_BUILD_ROOT/etc/rc.d/rc6.d/K35smb
+
+for i in README COPYING Manifest Read-Manifest-Now WHATSNEW.txt Roadmap docs examples
+do
+cp -avf $i $RPM_BUILD_ROOT/usr/doc/samba-1.9.18p5-Caldera.2
+done
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post
+for i in 437 850 852 866 932 949 950 936
+do
+/usr/bin/make_smbcodepage c $i /etc/codepages/src/codepage_def.$i /etc/codepages/codepage.$i
+done
+
+%postun
+if [ -x /etc/pam.d/samba ]; then
+ rm -f /etc/pam.d/samba
+fi
+if [ -e /etc/codepages ]; then
+ rm -rf /etc/codepages
+fi
+if [ -e /var/log/samba ]; then
+ rm -rf /var/log/samba
+fi
+if [ -e /var/lock/samba ]; then
+ rm -rf /var/lock/samba
+fi
+
+%files
+%attr(-,root,root) %doc README COPYING Manifest Read-Manifest-Now
+%attr(-,root,root) %doc WHATSNEW.txt Roadmap
+%attr(-,root,root) %doc docs
+%attr(-,root,root) %doc examples
+%attr(-,root,root) /usr/sbin/smbd
+%attr(-,root,root) /usr/sbin/nmbd
+%attr(2755,root,root) /usr/sbin/wsmbconf
+%attr(-,root,root) /usr/bin/addtosmbpass
+%attr(-,root,root) /usr/bin/mksmbpasswd.sh
+%attr(-,root,root) /usr/bin/smbclient
+%attr(-,root,root) /usr/bin/testparm
+%attr(-,root,root) /usr/bin/testprns
+%attr(-,root,root) /usr/bin/smbrun
+%attr(-,root,root) /usr/bin/smbstatus
+%attr(-,root,root) /usr/bin/nmblookup
+%attr(-,root,root) /usr/bin/make_smbcodepage
+%attr(-,root,root) /usr/bin/make_printerdef
+%attr(-,root,root) /usr/bin/smbpasswd
+%attr(-,root,root) /usr/bin/smbtar
+%attr(-,root,root) /usr/bin/smbprint
+%attr(-,root,root) /usr/bin/smbadduser
+%attr(-,root,root) %config /etc/smb.conf
+%attr(-,root,root) %config /etc/smbusers
+%attr(-,root,root) %config /etc/rc.d/init.d/smb
+%attr(755,root,root) %config /usr/sbin/samba
+%attr(-,root,root) %config /etc/rc.d/rc3.d/S91smb
+%attr(-,root,root) %config /etc/rc.d/rc5.d/S91smb
+%attr(-,root,root) %config /etc/rc.d/rc0.d/K35smb
+%attr(-,root,root) %config /etc/rc.d/rc1.d/K35smb
+%attr(-,root,root) %config /etc/rc.d/rc6.d/K35smb
+%attr(-,root,root) %config /etc/rc.d/rc2.d/K35smb
+%attr(-,root,root) %config /etc/logrotate.d/samba
+%attr(-,root,root) %config /etc/pam.d/samba
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.437
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.850
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.852
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.866
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.932
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.936
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.949
+%attr(-,root,root) %config /etc/codepages/src/codepage_def.950
+%attr(-,root,root) /usr/man/man1/smbstatus.1
+%attr(-,root,root) /usr/man/man1/smbclient.1
+%attr(-,root,root) /usr/man/man1/make_smbcodepage.1
+%attr(-,root,root) /usr/man/man1/smbrun.1
+%attr(-,root,root) /usr/man/man1/smbtar.1
+%attr(-,root,root) /usr/man/man1/testparm.1
+%attr(-,root,root) /usr/man/man1/testprns.1
+%attr(-,root,root) /usr/man/man5/smb.conf.5
+%attr(-,root,root) /usr/man/man7/samba.7
+%attr(-,root,root) /usr/man/man8/smbd.8
+%attr(-,root,root) /usr/man/man8/nmbd.8
+%attr(-,root,root) /usr/man/man8/smbpasswd.8
+%attr(-,root,nobody) %dir /home/samba
+%attr(-,root,root) %dir /etc/codepages
+%attr(-,root,root) %dir /etc/codepages/src
+%attr(-,root,root) %dir /var/lock/samba
+%attr(-,root,root) %dir /var/log/samba
+%attr(777,root,root) %dir /var/spool/samba
diff --git a/packaging/Caldera/smb.conf b/packaging/Caldera/smb.conf
new file mode 100644
index 00000000000..03c7b9f2d83
--- /dev/null
+++ b/packaging/Caldera/smb.conf
@@ -0,0 +1,267 @@
+# 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 = MYGROUP
+
+# server string is the equivalent of the NT Description field
+ server string = Samba Server
+
+# 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
+
+# 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 = /var/log/samba/log.%m
+
+# Put a capping on the size of the log files (in Kb).
+ max log size = 50
+
+# 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
+; password server = <NT-Server-Name>
+
+# Password Level allows matching of _n_ characters of the password for
+# all combinations of upper and lower case.
+; password level = 8
+
+# 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
+; smb passwd file = /etc/smbpasswd
+
+# Unix users can map to different SMB User names
+; username map = /etc/smbusers
+
+# 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 = /etc/smb.conf.%m
+
+# Most people will find that this option gives better performance.
+# See speed.txt and the manual pages for details
+ socket options = TCP_NODELAY
+
+# 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
+
+# Configure remote browse list synchronisation here
+# request announcement to, or browse list sync from:
+# a specific host or from / to a whole subnet (see below)
+; remote browse sync = 192.168.3.25 192.168.5.255
+# Cause this host to announce itself to local subnets here
+; remote announce = 192.168.1.255 192.168.2.44
+
+# 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. 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
+# and gives it a slightly higher chance of winning the election
+; preferred master = yes
+
+# 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>
+
+# Enable this if you want Samba to be a domain logon server for
+# Windows95 workstations.
+; domain logons = yes
+
+# 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 username
+; logon script = %u.bat
+
+# 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
+; 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 = w.x.y.z
+
+# 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
+
+# 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
+
+# Case Preservation can be handy - system default is _no_
+# NOTE: These can be set on a per share basis
+; preserve case = no
+; short preserve case = no
+# Default case is normally upper case for all DOS files
+; default case = lower
+# Be very careful with case sensitivity - it can break things!
+; case sensitive = no
+
+#============================ Share Definitions ==============================
+[homes]
+ comment = Home Directories
+ browseable = no
+ writable = yes
+
+# Un-comment the following and create the netlogon directory for Domain Logons
+; [netlogon]
+; comment = Network Logon Service
+; path = /home/netlogon
+; guest ok = yes
+; writable = no
+; share modes = no
+
+
+# Un-comment the following to provide a specific roving profile share
+# the default is to use the user's home directory
+;[Profiles]
+; path = /home/profiles
+; browseable = no
+; guest ok = yes
+
+
+# NOTE: If you have a BSD-style print system there is no need to
+# specifically define each individual printer
+[printers]
+ comment = All Printers
+ path = /var/spool/samba
+ browseable = no
+# Set public = yes to allow user 'guest account' to print
+ guest ok = no
+ writable = no
+ 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 = @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
+; path = /homes/fred
+; printer = freds_printer
+; public = no
+; writable = no
+; printable = yes
+
+# 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
+; valid users = fred
+; 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.
+;[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.
+;[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.
+;[myshare]
+; comment = Mary's and Fred's stuff
+; path = /usr/somewhere/shared
+; valid users = mary fred
+; public = no
+; writable = yes
+; printable = no
+; create mask = 0765
+
+
diff --git a/packaging/Caldera/smb.init b/packaging/Caldera/smb.init
new file mode 100755
index 00000000000..7863b367d8c
--- /dev/null
+++ b/packaging/Caldera/smb.init
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ ${NETWORKING} = "no" ] && exit 0
+
+# Check smb.conf file exists.
+[ -f /etc/smb.conf ] || exit 0
+
+# See how we were called.
+case "$1" in
+ start)
+ echo -n "Starting SMB services: "
+ daemon smbd -D
+ daemon nmbd -D
+ echo
+ touch /var/lock/subsys/smb
+ ;;
+ stop)
+ echo -n "Shutting down SMB services: "
+ killproc smbd
+ killproc nmbd
+ rm -f /var/lock/subsys/smb
+ echo ""
+ ;;
+ *)
+ echo "Usage: smb {start|stop}"
+ exit 1
+esac
+
diff --git a/packaging/Caldera/smbadduser b/packaging/Caldera/smbadduser
new file mode 100755
index 00000000000..2f38bf28f1a
--- /dev/null
+++ b/packaging/Caldera/smbadduser
@@ -0,0 +1,73 @@
+#!/bin/csh
+#
+# smbadduser - Written by Mike Zakharoff
+#
+unalias *
+set path = ($path)
+
+set smbpasswd = /etc/smbpasswd
+set user_map = /etc/smbusers
+#
+# Set to site specific passwd command
+#
+set passwd = "cat /etc/passwd"
+#set passwd = "niscat passwd.org_dir"
+#set passwd = "ypcat passwd"
+
+set line = "----------------------------------------------------------"
+if ($#argv == 0) then
+ echo $line
+ echo "Written: Mike Zakharoff email: michael.j.zakharoff@boeing.com"
+ echo ""
+ echo " 1) Updates $smbpasswd"
+ echo " 2) Updates $user_map"
+ echo " 3) Executes smbpasswd for each new user"
+ echo ""
+ echo "smbadduser unixid:ntid unixid:ntid ..."
+ echo ""
+ echo "Example: smbadduser zak:zakharoffm johns:smithj"
+ echo $line
+ exit 1
+endif
+
+touch $smbpasswd $user_map
+set new = ()
+foreach one ($argv)
+ echo $one | grep ':' >& /dev/null
+ if ($status != 0) then
+ echo "ERROR: Must use unixid:ntid like -> zak:zakharoffm"
+ continue
+ endif
+ set unix = `echo $one | awk -F: '{print $1}'`
+ set ntid = `echo $one | awk -F: '{print $2}'`
+
+ set usr = `eval $passwd | awk -F: '$1==USR {print $1}' USR=$unix`
+ if ($#usr != 1) then
+ echo "ERROR: $unix Not in passwd database SKIPPING..."
+ continue
+ endif
+ set tmp = `cat $smbpasswd | awk -F: '$1==USR {print $1}' USR=$unix`
+ if ($#tmp != 0) then
+ echo "ERROR: $unix is already in $smbpasswd SKIPPING..."
+ continue
+ endif
+
+ echo "Adding: $unix to $smbpasswd"
+ eval $passwd | \
+ awk -F: '$1==USR { \
+ printf( "%s:%s:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:%s:%s:%s\n", $1, $3, $5, $6, $7) }' USR=$unix >> $smbpasswd
+ if ($unix != $ntid) then
+ echo "Adding: {$unix = $ntid} to $user_map"
+ echo "$unix = $ntid" >> $user_map
+ endif
+ set new = ($new $unix)
+end
+
+#
+# Enter password for new users
+#
+foreach one ($new)
+ echo $line
+ echo "ENTER password for $one"
+ smbpasswd $one
+end
diff --git a/packaging/Caldera/smbprint b/packaging/Caldera/smbprint
new file mode 100755
index 00000000000..51b15706add
--- /dev/null
+++ b/packaging/Caldera/smbprint
@@ -0,0 +1,77 @@
+#!/bin/sh -x
+
+# This script is an input filter for printcap printing on a unix machine. It
+# uses the smbclient program to print the file to the specified smb-based
+# server and service.
+# For example you could have a printcap entry like this
+#
+# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
+#
+# which would create a unix printer called "smb" that will print via this
+# script. You will need to create the spool directory /usr/spool/smb with
+# appropriate permissions and ownerships for your system.
+
+# Set these to the server and service you wish to print to
+# In this example I have a WfWg PC called "lapland" that has a printer
+# exported called "printer" with no password.
+
+#
+# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
+# so that the server, service, and password can be read from
+# a /var/spool/lpd/PRINTNAME/.config file.
+#
+# In order for this to work the /etc/printcap entry must include an
+# accounting file (af=...):
+#
+# cdcolour:\
+# :cm=CD IBM Colorjet on 6th:\
+# :sd=/var/spool/lpd/cdcolour:\
+# :af=/var/spool/lpd/cdcolour/acct:\
+# :if=/usr/local/etc/smbprint:\
+# :mx=0:\
+# :lp=/dev/null:
+#
+# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
+# server=PC_SERVER
+# service=PR_SHARENAME
+# password="password"
+#
+# E.g.
+# server=PAULS_PC
+# service=CJET_371
+# password=""
+
+#
+# Debugging log file, change to /dev/null if you like.
+#
+# logfile=/tmp/smb-print.log
+logfile=/dev/null
+
+
+#
+# The last parameter to the filter is the accounting file name.
+# Extract the directory name from the file name.
+# Concat this with /.config to get the config file.
+#
+eval acct_file=\${$#}
+spool_dir=`dirname $acct_file`
+config_file=$spool_dir/.config
+
+# Should read the following variables set in the config file:
+# server
+# service
+# password
+eval `cat $config_file`
+
+#
+# Some debugging help, change the >> to > if you want to same space.
+#
+echo "server $server, service $service" >> $logfile
+
+(
+# NOTE You may wish to add the line `echo translate' if you want automatic
+# CR/LF translation when printing.
+# echo translate
+ echo "print -"
+ cat
+) | /usr/bin/smbclient "\\\\$server\\$service" $password -U $server -N -P >> $logfile
diff --git a/packaging/Caldera/smbusers b/packaging/Caldera/smbusers
new file mode 100644
index 00000000000..ae3389f53f8
--- /dev/null
+++ b/packaging/Caldera/smbusers
@@ -0,0 +1,3 @@
+# Unix_name = SMB_name1 SMB_name2 ...
+root = administrator admin
+nobody = guest pcguest smbguest
diff --git a/packaging/SGI/.cvsignore b/packaging/SGI/.cvsignore
index 7b74def5aea..b303a93a9a1 100644
--- a/packaging/SGI/.cvsignore
+++ b/packaging/SGI/.cvsignore
@@ -2,7 +2,6 @@ bins
catman
html
codepages
-swat
Makefile
samba.idb
samba.spec
diff --git a/packaging/SGI/idb.pl b/packaging/SGI/idb.pl
index 424c4ed1303..64b2e7bc532 100755
--- a/packaging/SGI/idb.pl
+++ b/packaging/SGI/idb.pl
@@ -49,12 +49,6 @@ if (@codepage) {
chdir $curdir;
@codepage = sort split(' ',@codepage[0]);
}
-# install the swat files
-chdir '../../source';
-system("chmod +x ./installswat.sh");
-system("./installswat.sh ../packaging/SGI/swat ./");
-system("cp ../swat/README ../packaging/SGI/swat");
-chdir $curdir;
# add my local files to the list of binaries to install
@bins = sort (@sprogs,@progs,@progs1,@scripts,("findsmb","sambalp","smbprint"));
@@ -68,13 +62,12 @@ chdir $curdir;
# the "*.doc" files from the source tree
@docs = sort byfilename grep (!/^docs\/$/ & (/^source\/.*\.doc$/ | /^docs\//),@allfiles);
-@swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
@catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
@catman = sort bydirnum @catman;
# strip out all the generated directories and the "*.o" files from the source
# release
-@allfiles = grep(!/^.*\.o$/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/ & !/^packaging\/SGI\/swat/, @allfiles);
+@allfiles = grep(!/^.*\.o$/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/, @allfiles);
open(IDB,">samba.idb") || die "Unable to open samba.idb for output\n";
@@ -103,9 +96,6 @@ while(@bins) {
elsif ($nextfile eq "findsmb") {
print IDB "f 0755 root sys usr/samba/bin/$nextfile packaging/SGI/$nextfile samba.sw.base\n";
}
- elsif ($nextfile eq "swat") {
- print IDB "f 4755 root sys usr/samba/bin/$nextfile source/$nextfile samba.sw.base\n";
- }
elsif ($nextfile eq "sambalp") {
print IDB "f 0755 root sys usr/samba/bin/$nextfile packaging/SGI/$nextfile samba.sw.base\n";
}
@@ -166,19 +156,6 @@ while (@sorted) {
}
}
-print IDB "d 0755 root sys usr/samba/swat/ packaging/SGI/swat samba.sw.base\n";
-while (@swatfiles) {
- $nextfile = shift @swatfiles;
- ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
- next if !$file;
- if (grep(/\/$/,$file)) {
- print IDB "d 0755 root sys usr/samba/swat/$file packaging/SGI/swat/$file samba.sw.base\n";
- }
- else {
- print IDB "f 0444 root sys usr/samba/swat/$file packaging/SGI/swat/$file samba.sw.base\n";
- }
-}
-
print IDB "d 0755 root sys usr/samba/var/ packaging/SGI samba.sw.base\n";
print IDB "d 0755 root sys usr/samba/var/locks/ packaging/SGI samba.sw.base\n";
diff --git a/packaging/SGI/smbprint b/packaging/SGI/smbprint
index 935f98bf923..0db8b6f7e3a 100644
--- a/packaging/SGI/smbprint
+++ b/packaging/SGI/smbprint
@@ -5,46 +5,48 @@
# Version 1.0 13 January 1995
# modified from the original smbprint (bsd) script
#
-# this script is a System 5 printer interface script. It
-# uses the smbclient program to print the file to the specified smb-based
-# server and service.
+# this script is a System 5 printer interface script. It uses the smbclient
+# program to print the file to the specified smb-based server and service.
#
-# To add this to your lp system, copy this file into your samba directory
-# (the example here is /opt/samba), modify the server and service variables
-# and then execute the following command (as root)
+# To add this to your lp system, modify the server and service variables
+# and then execute the following command (as root):
#
-# lpadmin -punixprintername -v/dev/null -i/opt/samba/smbprint
+# lpadmin -punixprintername -v/dev/null -i/usr/samba/bin/smbprint
#
# where unixprintername is the name that the printer will be known as
# on your unix box.
#
# the script smbprint will be copied into your printer administration
-# directory (/usr/lib/lp or /etc/lp) as a new interface
-# (interface/unixprintername)
-# Then you have to enable unixprintername and accept unixprintername
+# directory (/usr/spool/lp) as a new interface (interface/unixprintername)
+# Then you have to execute the following commands:
#
-# This script will then be called by the lp service to print the files
+# enable unixprintername
+# accept unixprintername
+#
+# This script will then be called by the lp service to print the files.
# This script will have 6 or more parameters passed to it by the lp service.
# The first five will contain details of the print job, who queued it etc,
# while parameters 6 onwards are a list of files to print. We just
-# cat these at the samba client.
-#
-# Set these to the server and service you wish to print to
-# In this example I have a WfWg PC called "lapland" that has a printer
-# exported called "printer" with no password.
+# cat these to the samba client.
#
# clear out the unwanted parameters
+
shift;shift;shift;shift;shift
+
# now the argument list is just the files to print
+# Set these to the server and service you wish to print to
+# In this example I have a PC called "admin" that has a printer
+# exported called "hplj2" with no password.
+#
server=admin
service=hplj2
password=""
+# NOTE: The line `echo translate' provides automatic CR/LF translation
+# when printing.
(
-# NOTE You may wish to add the line `echo translate' if you want automatic
-# CR/LF translation when printing.
- echo translate
+ echo translate
echo "print -"
cat $*
) | /usr/samba/bin/smbclient "\\\\$server\\$service" $password -N -P > /dev/null
diff --git a/packaging/SGI/spec.pl b/packaging/SGI/spec.pl
index 5557112df16..ab06da49f88 100755
--- a/packaging/SGI/spec.pl
+++ b/packaging/SGI/spec.pl
@@ -18,10 +18,6 @@ $patch = 0;
if (/alpha/) {
$_ =~ s/alpha/.00./;
}
-elsif (/-HEAD/) {
- $_ =~ s/-HEAD/.01/;
- $_ .= '.99';
-}
elsif (/p/) {
$_ =~ s/p/./;
$_ .= '.00';
diff --git a/packaging/SuSE/5.2/samba-1.9.18p5.dif b/packaging/SuSE/5.2/samba-1.9.18p5.dif
index 39b13f010de..575ed917ca1 100644
--- a/packaging/SuSE/5.2/samba-1.9.18p5.dif
+++ b/packaging/SuSE/5.2/samba-1.9.18p5.dif
@@ -1,6 +1,6 @@
--- Makefile.Linux
-+++ Makefile.Linux 1998/05/06 15:58:42
-@@ -0,0 +1,35 @@
++++ Makefile.Linux 1998/04/27 07:49:10
+@@ -0,0 +1,34 @@
+#
+#
+# Makefile.Linux to integrate package into source tree of S.u.S.E.-Linux
@@ -29,7 +29,6 @@
+ chmod 755 `find $(doc) -type d`
+ install -m 644 smb.conf /etc/smb.conf
+ install rc /sbin/init.d/smb
-+ install -m 755 source/mksmbpasswd.sh /usr/bin/mksmbpasswd.sh
+ ln -sf ../smb /sbin/init.d/rc2.d/S20smb
+ ln -sf ../smb /sbin/init.d/rc2.d/K20smb
+ ln -sf ../smb /sbin/init.d/rc3.d/S20smb
@@ -37,7 +36,7 @@
+ mkdir -p /var/adm/fillup-templates
+ cp rc.config.samba /var/adm/fillup-templates
--- doinst.sh
-+++ doinst.sh 1998/05/06 15:54:52
++++ doinst.sh 1998/04/27 07:49:10
@@ -0,0 +1,15 @@
+#
+# install/doinst.sh - to be done after extraction
@@ -55,7 +54,7 @@
+fi
+
--- rc
-+++ rc 1998/05/06 15:54:52
++++ rc 1998/04/27 07:49:10
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (c) 1996 StarDivision GmbH. All rights reserved.
@@ -90,7 +89,7 @@
+
+exit 0
--- rc.config.samba
-+++ rc.config.samba 1998/05/06 15:54:52
++++ rc.config.samba 1998/04/27 07:49:10
@@ -0,0 +1,5 @@
+#
+# start samba? ("yes" or "no")
@@ -98,7 +97,7 @@
+#
+START_SMB="no"
--- smb.conf
-+++ smb.conf 1998/05/06 15:54:52
++++ smb.conf 1998/04/27 07:49:10
@@ -0,0 +1,48 @@
+[global]
+ workgroup = arbeitsgruppe
@@ -149,7 +148,7 @@
+ create mode = 0700
+ directory = /tmp
--- source/Makefile
-+++ source/Makefile 1998/05/06 15:54:52
++++ source/Makefile 1998/04/27 07:49:10
@@ -5,11 +5,11 @@
###########################################################################
@@ -217,7 +216,7 @@
# Use this for Linux without shadow passwords or for any Linux
--- source/includes.h
-+++ source/includes.h 1998/05/06 15:54:52
++++ source/includes.h 1998/04/27 07:49:10
@@ -244,13 +244,6 @@
#define USE_SETFS
#endif
diff --git a/packaging/SuSE/5.2/samba.spec b/packaging/SuSE/5.2/samba.spec
index 637af1781e1..6ae54b5066d 100644
--- a/packaging/SuSE/5.2/samba.spec
+++ b/packaging/SuSE/5.2/samba.spec
@@ -60,7 +60,6 @@ fi
/sbin/init.d/rc3.d/S20smb
%config /sbin/init.d/smb
/usr/bin/addtosmbpass
-/usr/bin/mksmbpasswd.sh
/usr/bin/make_printerdef
/usr/bin/make_smbcodepage
/usr/bin/nmblookup
diff --git a/source/.cvsignore b/source/.cvsignore
index 1b759d3345e..1e48a541752 100644
--- a/source/.cvsignore
+++ b/source/.cvsignore
@@ -1,22 +1,14 @@
-.cvsignore
Makefile.RPM
-cvs.log
-make_printerdef
-make_smbcodepage
makefile
makefile.sunos5
-memcheck.awk
+make_smbcodepage
+make_printerdef
nmbd
nmblookup
-notes.txt
smbclient
smbd
smbpasswd
smbrun
smbstatus
-smbtorture
-swat
testparm
testprns
-wsmbconf
-wsmbstatus
diff --git a/source/cgi.c b/source/cgi.c
new file mode 100644
index 00000000000..ae60d72b7b7
--- /dev/null
+++ b/source/cgi.c
@@ -0,0 +1,621 @@
+/*
+ some simple CGI helper routines
+ Copyright (C) Andrew Tridgell 1997-1998
+
+ 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 <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pwd.h>
+
+#define MAX_VARIABLES 10000
+
+#ifdef DEBUG_COMMENTS
+extern void print_title(char *fmt, ...);
+#endif
+
+struct var {
+ char *name;
+ char *value;
+};
+
+static struct var variables[MAX_VARIABLES];
+static int num_variables;
+static int content_length;
+static int request_post;
+static int request_get;
+static char *query_string;
+
+static void unescape(char *buf)
+{
+ char *p=buf;
+
+ while ((p=strchr(p,'+')))
+ *p = ' ';
+
+ p = buf;
+
+ while (p && *p && (p=strchr(p,'%'))) {
+ int c1 = p[1];
+ int c2 = p[2];
+
+ 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 {p++; continue;}
+
+ 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 {p++; continue;}
+
+ *p = (c1<<4) | c2;
+
+ memcpy(p+1, p+3, strlen(p+3)+1);
+ p++;
+ }
+}
+
+
+static char *grab_line(FILE *f, int *cl)
+{
+ char *ret;
+ int i = 0;
+ int len = 1024;
+
+ ret = (char *)malloc(len);
+ if (!ret) return NULL;
+
+
+ while ((*cl)) {
+ int c = fgetc(f);
+ (*cl)--;
+
+ if (c == EOF) {
+ (*cl) = 0;
+ break;
+ }
+
+ if (c == '\r') continue;
+
+ if (strchr("\n&", c)) break;
+
+ ret[i++] = c;
+
+ if (i == len-1) {
+ char *ret2;
+ ret2 = (char *)realloc(ret, len*2);
+ if (!ret2) return ret;
+ len *= 2;
+ ret = ret2;
+ }
+ }
+
+
+ ret[i] = 0;
+ return ret;
+}
+
+/***************************************************************************
+ load all the variables passed to the CGI program. May have multiple variables
+ with the same name and the same or different values. Takes a file parameter
+ for simulating CGI invocation eg loading saved preferences.
+ ***************************************************************************/
+void cgi_load_variables(FILE *f1)
+{
+ FILE *f = f1;
+ static char *line;
+ char *p, *s, *tok;
+ int len;
+
+#ifdef DEBUG_COMMENTS
+ char dummy[100]="";
+ print_title(dummy);
+ printf("<!== Start dump in cgi_load_variables() %s ==>\n",__FILE__);
+#endif
+
+ if (!f1) {
+ f = stdin;
+ if (!content_length) {
+ p = getenv("CONTENT_LENGTH");
+ len = p?atoi(p):0;
+ } else {
+ len = content_length;
+ }
+ } else {
+ fseek(f, 0, SEEK_END);
+ len = ftell(f);
+ fseek(f, 0, SEEK_SET);
+ }
+
+
+ if (len > 0 &&
+ (f1 || request_post ||
+ ((s=getenv("REQUEST_METHOD")) &&
+ strcasecmp(s,"POST")==0))) {
+ while (len && (line=grab_line(f, &len))) {
+ p = strchr(line,'=');
+ if (!p) continue;
+
+ *p = 0;
+
+ variables[num_variables].name = strdup(line);
+ variables[num_variables].value = strdup(p+1);
+
+ free(line);
+
+ if (!variables[num_variables].name ||
+ !variables[num_variables].value)
+ continue;
+
+ unescape(variables[num_variables].value);
+ unescape(variables[num_variables].name);
+
+#ifdef DEBUG_COMMENTS
+ printf("<!== POST var %s has value \"%s\" ==>\n",
+ variables[num_variables].name,
+ variables[num_variables].value);
+#endif
+
+ num_variables++;
+ if (num_variables == MAX_VARIABLES) break;
+ }
+ }
+
+ if (f1) {
+#ifdef DEBUG_COMMENTS
+ printf("<!== End dump in cgi_load_variables() ==>\n");
+#endif
+ return;
+ }
+
+ fclose(stdin);
+
+ if ((s=query_string) || (s=getenv("QUERY_STRING"))) {
+ for (tok=strtok(s,"&;");tok;tok=strtok(NULL,"&;")) {
+ p = strchr(tok,'=');
+ if (!p) continue;
+
+ *p = 0;
+
+ variables[num_variables].name = strdup(tok);
+ variables[num_variables].value = strdup(p+1);
+
+ if (!variables[num_variables].name ||
+ !variables[num_variables].value)
+ continue;
+
+ unescape(variables[num_variables].value);
+ unescape(variables[num_variables].name);
+
+#ifdef DEBUG_COMMENTS
+ printf("<!== Commandline var %s has value \"%s\" ==>\n",
+ variables[num_variables].name,
+ variables[num_variables].value);
+#endif
+ num_variables++;
+ if (num_variables == MAX_VARIABLES) break;
+ }
+
+ }
+#ifdef DEBUG_COMMENTS
+ printf("<!== End dump in cgi_load_variables() ==>\n");
+#endif
+}
+
+
+/***************************************************************************
+ find a variable passed via CGI
+ Doesn't quite do what you think in the case of POST text variables, because
+ if they exist they might have a value of "" or even " ", depending on the
+ browser. Also doesn't allow for variables[] containing multiple variables
+ with the same name and the same or different values.
+ ***************************************************************************/
+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 a particular cgi variable
+ ***************************************************************************/
+char *cgi_vnum(int i, char **name)
+{
+ if (i < 0 || i >= num_variables) return NULL;
+ *name = variables[i].name;
+ return variables[i].value;
+}
+
+/***************************************************************************
+ 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;
+}
+
+/***************************************************************************
+like strdup() but quotes < > and &
+ ***************************************************************************/
+char *quotedup(char *s)
+{
+ int i, n=0;
+ int len;
+ char *ret;
+ char *d;
+
+ if (!s) return strdup("");
+
+ len = strlen(s);
+
+ for (i=0;i<len;i++)
+ if (s[i] == '<' || s[i] == '>' || s[i] == '&')
+ n++;
+
+ ret = malloc(len + n*6 + 1);
+
+ if (!ret) return NULL;
+
+ d = ret;
+
+ for (i=0;i<len;i++) {
+ switch (s[i]) {
+ case '<':
+ strcpy(d, "&lt;");
+ d += 4;
+ break;
+
+ case '>':
+ strcpy(d, "&gt;");
+ d += 4;
+ break;
+
+ case '&':
+ strcpy(d, "&amp;");
+ d += 5;
+ break;
+
+ default:
+ *d++ = s[i];
+ }
+ }
+
+ *d = 0;
+
+ return ret;
+}
+
+
+/***************************************************************************
+like strdup() but quotes a wide range of characters
+ ***************************************************************************/
+char *urlquote(char *s)
+{
+ int i, n=0;
+ int len;
+ char *ret;
+ char *d;
+ char *qlist = "\"\n\r'&<> \t+;";
+
+ if (!s) return strdup("");
+
+ len = strlen(s);
+
+ for (i=0;i<len;i++)
+ if (strchr(qlist, s[i])) n++;
+
+ ret = malloc(len + n*2 + 1);
+
+ if (!ret) return NULL;
+
+ d = ret;
+
+ for (i=0;i<len;i++) {
+ if (strchr(qlist,s[i])) {
+ sprintf(d, "%%%02X", (int)s[i]);
+ d += 3;
+ } else {
+ *d++ = s[i];
+ }
+ }
+
+ *d = 0;
+
+ return ret;
+}
+
+
+/***************************************************************************
+like strdup() but quotes " characters
+ ***************************************************************************/
+char *quotequotes(char *s)
+{
+ int i, n=0;
+ int len;
+ char *ret;
+ char *d;
+
+ if (!s) return strdup("");
+
+ len = strlen(s);
+
+ for (i=0;i<len;i++)
+ if (s[i] == '"')
+ n++;
+
+ ret = malloc(len + n*6 + 1);
+
+ if (!ret) return NULL;
+
+ d = ret;
+
+ for (i=0;i<len;i++) {
+ switch (s[i]) {
+ case '"':
+ strcpy(d, "&quot;");
+ d += 6;
+ break;
+
+ default:
+ *d++ = s[i];
+ }
+ }
+
+ *d = 0;
+
+ return ret;
+}
+
+
+/***************************************************************************
+quote spaces in a buffer
+ ***************************************************************************/
+void quote_spaces(char *buf)
+{
+ while (*buf) {
+ if (*buf == ' ') *buf = '+';
+ buf++;
+ }
+}
+
+
+
+/***************************************************************************
+tell a browser about a fatal error in the http processing
+ ***************************************************************************/
+static void cgi_setup_error(char *err, char *header, char *info)
+{
+ printf("HTTP/1.1 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n", err, header, err, err, info);
+ exit(0);
+}
+
+
+/***************************************************************************
+decode a base64 string in-place - simple and slow algorithm
+ ***************************************************************************/
+static void base64_decode(char *s)
+{
+ char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ int bit_offset, byte_offset, idx, i;
+ unsigned char *d = (unsigned char *)s;
+ char *p;
+
+ i=0;
+
+ while (*s && (p=strchr(b64,*s))) {
+ idx = (int)(p - b64);
+ byte_offset = (i*6)/8;
+ bit_offset = (i*6)%8;
+ d[byte_offset] &= ~((1<<(8-bit_offset))-1);
+ if (bit_offset < 3) {
+ d[byte_offset] |= (idx << (2-bit_offset));
+ } else {
+ d[byte_offset] |= (idx >> (bit_offset-2));
+ d[byte_offset+1] = 0;
+ d[byte_offset+1] |= (idx << (8-(bit_offset-2))) & 0xFF;
+ }
+ s++; i++;
+ }
+}
+
+
+/***************************************************************************
+handle a http authentication line
+ ***************************************************************************/
+static int cgi_handle_authorization(char *line)
+{
+ char *p, *user, *pass;
+ struct passwd *pwd;
+ int ret=0;
+
+ if (strncasecmp(line,"Basic ", 6)) {
+ cgi_setup_error("401 Bad Authorization", "",
+ "Only basic authorization is understood");
+ }
+ line += 6;
+ while (line[0] == ' ') line++;
+ base64_decode(line);
+ if (!(p=strchr(line,':'))) {
+ cgi_setup_error("401 Bad Authorization", "",
+ "username/password must be supplied");
+ }
+ *p = 0;
+ user = line;
+ pass = p+1;
+
+ /* currently only allow connections as root */
+ if (strcasecmp(user,"root")) {
+ cgi_setup_error("401 Bad Authorization", "",
+ "incorrect username/password");
+ }
+
+ pwd = getpwnam(user);
+
+ if (!strcmp((char *)crypt(pass, pwd->pw_passwd),pwd->pw_passwd)) {
+ ret = 1;
+ }
+
+ memset(pass, 0, strlen(pass));
+
+ return ret;
+}
+
+
+/***************************************************************************
+handle a file download
+ ***************************************************************************/
+static void cgi_download(char *file)
+{
+ struct stat st;
+ char buf[1024];
+ int fd, l, i;
+ char *p;
+
+ /* sanitise the filename */
+ for (i=0;file[i];i++) {
+ if (!isalnum(file[i]) && !strchr("/.-_", file[i])) {
+ cgi_setup_error("404 File Not Found","",
+ "Illegal character in filename");
+ }
+ }
+
+ if (strstr(file,"..")) {
+ cgi_setup_error("404 File Not Found","",
+ "Relative paths not allowed");
+ }
+
+ if (!file_exist(file, &st)) {
+ cgi_setup_error("404 File Not Found","",
+ "The requested file was not found");
+ }
+ fd = open(file,O_RDONLY);
+ if (fd == -1) {
+ cgi_setup_error("404 File Not Found","",
+ "The requested file was not found");
+ }
+ printf("HTTP/1.1 200 OK\r\n");
+ if ((p=strrchr(file,'.'))) {
+ if (strcmp(p,".gif")==0 || strcmp(p,".jpg")==0) {
+ printf("Content-Type: image/gif\r\n");
+ } else {
+ printf("Content-Type: text/html\r\n");
+ }
+ }
+ printf("Content-Length: %d\r\n\r\n", (int)st.st_size);
+ while ((l=read(fd,buf,sizeof(buf)))>0) {
+ fwrite(buf, 1, l, stdout);
+ }
+ close(fd);
+ exit(0);
+}
+
+
+/***************************************************************************
+setup the cgi framework, handling the possability that this program is either
+run as a true cgi program by a web browser or is itself a mini web server
+ ***************************************************************************/
+void cgi_setup(char *rootdir)
+{
+ int authenticated = 0;
+ char line[1024];
+ char *url=NULL;
+ char *p;
+
+ if (chdir(rootdir)) {
+ cgi_setup_error("400 Server Error", "",
+ "chdir failed - the server is not configured correctly");
+ }
+
+ if (getenv("CONTENT_LENGTH") || getenv("REQUEST_METHOD")) {
+ /* assume we are running under a real web server */
+ return;
+ }
+
+ /* we are a mini-web server. We need to read the request from stdin
+ and handle authentication etc */
+ while (fgets(line, sizeof(line)-1, stdin)) {
+ if (line[0] == '\r' || line[0] == '\n') break;
+ if (strncasecmp(line,"GET ", 4)==0) {
+ request_get = 1;
+ url = strdup(&line[4]);
+ } else if (strncasecmp(line,"POST ", 5)==0) {
+ request_post = 1;
+ url = strdup(&line[5]);
+ } else if (strncasecmp(line,"PUT ", 4)==0) {
+ cgi_setup_error("400 Bad Request", "",
+ "This server does not accept PUT requests");
+ } else if (strncasecmp(line,"Authorization: ", 15)==0) {
+ authenticated = cgi_handle_authorization(&line[15]);
+ } else if (strncasecmp(line,"Content-Length: ", 16)==0) {
+ content_length = atoi(&line[16]);
+ }
+ /* ignore all other requests! */
+ }
+
+ if (!authenticated) {
+ cgi_setup_error("401 Authorization Required",
+ "WWW-Authenticate: Basic realm=\"root\"\r\n",
+ "You must be authenticated to use this service");
+ }
+
+ if (!url) {
+ cgi_setup_error("400 Bad Request", "",
+ "You must specify a GET or POST request");
+ }
+
+ /* trim the URL */
+ if ((p = strchr(url,' ')) || (p=strchr(url,'\t'))) {
+ *p = 0;
+ }
+ while (*url && strchr("\r\n",url[strlen(url)-1])) {
+ url[strlen(url)-1] = 0;
+ }
+
+ /* anything following a ? in the URL is part of the query string */
+ if ((p=strchr(url,'?'))) {
+ query_string = p+1;
+ *p = 0;
+ }
+
+ if (strcmp(url,"/")) {
+ cgi_download(url+1);
+ }
+
+ printf("HTTP/1.1 200 OK\r\nConnection: close\r\n");
+
+}
+
+
diff --git a/source/client/client.c b/source/client/client.c
index 9596a3997a1..c0350e26a1e 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -33,7 +33,7 @@ pstring cur_dir = "\\";
pstring cd_path = "";
extern pstring service;
extern pstring desthost;
-extern pstring global_myname;
+extern pstring myname;
extern pstring myhostname;
extern pstring password;
extern pstring username;
@@ -3716,7 +3716,7 @@ static void usage(char *pname)
}
break;
case 'n':
- strcpy(global_myname,optarg);
+ strcpy(myname,optarg);
break;
case 'N':
got_pass = True;
@@ -3770,7 +3770,7 @@ static void usage(char *pname)
DEBUG(0,("Failed to get my hostname.\n"));
}
- if (!lp_load(servicesf,True,False,False)) {
+ if (!lp_load(servicesf,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
}
@@ -3790,8 +3790,8 @@ static void usage(char *pname)
strcpy(workgroup,lp_workgroup());
load_interfaces();
- get_myname((*global_myname)?NULL:global_myname,NULL);
- strupper(global_myname);
+ get_myname((*myname)?NULL:myname,NULL);
+ strupper(myname);
if(*new_name_resolve_order)
lp_set_name_resolve_order(new_name_resolve_order);
diff --git a/source/client/clientutil.c b/source/client/clientutil.c
index ab1b37c72da..dce34eda2c4 100644
--- a/source/client/clientutil.c
+++ b/source/client/clientutil.c
@@ -31,7 +31,7 @@
pstring service="";
pstring desthost="";
-extern pstring global_myname;
+extern pstring myname;
pstring password = "";
pstring smb_login_passwd = "";
pstring username="";
@@ -331,7 +331,7 @@ BOOL cli_send_session_request(char *inbuf,char *outbuf)
/* and my name */
p = outbuf+len;
- name_mangle(global_myname,p,0);
+ name_mangle(myname,p,0);
len += name_len(p);
/* setup the packet length */
@@ -378,7 +378,7 @@ BOOL cli_send_session_request(char *inbuf,char *outbuf)
{
int ecode = CVAL(inbuf,4);
DEBUG(0,("Session request failed (%d,%d) with myname=%s destname=%s\n",
- CVAL(inbuf,0),ecode,global_myname,desthost));
+ CVAL(inbuf,0),ecode,myname,desthost));
switch (ecode)
{
case 0x80:
@@ -388,7 +388,7 @@ BOOL cli_send_session_request(char *inbuf,char *outbuf)
break;
case 0x81:
DEBUG(0,("Not listening for calling name\n"));
- DEBUG(0,("Try to connect as another name (instead of %s)\n",global_myname));
+ DEBUG(0,("Try to connect as another name (instead of %s)\n",myname));
DEBUG(0,("You may find the -n option useful for this\n"));
break;
case 0x82:
@@ -508,7 +508,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup,
if (CVAL(inbuf,smb_rcls) != 0 || ((int)SVAL(inbuf,smb_vwv0) >= numprots))
{
DEBUG(0,("SMBnegprot failed. myname=%s destname=%s - %s \n",
- global_myname,desthost,smb_errstr(inbuf)));
+ myname,desthost,smb_errstr(inbuf)));
if (was_null)
{
free(inbuf);
@@ -665,7 +665,7 @@ BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup,
}
DEBUG(0,("Session setup failed for username=%s myname=%s destname=%s %s\n",
- username,global_myname,desthost,smb_errstr(inbuf)));
+ username,myname,desthost,smb_errstr(inbuf)));
DEBUG(0,("You might find the -U, -W or -n options useful\n"));
DEBUG(0,("Sometimes you have to use `-n USERNAME' (particularly with OS/2)\n"));
DEBUG(0,("Some servers also insist on uppercase-only passwords\n"));
@@ -882,10 +882,10 @@ BOOL cli_open_sockets(int port )
strcpy(desthost,host);
}
- if (!(*global_myname)) {
- get_myname(global_myname,NULL);
+ if (!(*myname)) {
+ get_myname(myname,NULL);
}
- strupper(global_myname);
+ strupper(myname);
DEBUG(3,("Opening sockets\n"));
diff --git a/source/client/ntclient.c b/source/client/ntclient.c
index bd0d0ccd5a6..54ab49e3a65 100644
--- a/source/client/ntclient.c
+++ b/source/client/ntclient.c
@@ -33,10 +33,13 @@ extern pstring workgroup;
#define CLIENT_TIMEOUT (30*1000)
+#ifdef NTDOMAIN
+
+
/****************************************************************************
experimental nt login.
****************************************************************************/
-BOOL client_do_nt_login(char *desthost, char *myhostname,
+BOOL do_nt_login(char *desthost, char *myhostname,
int Client, int cnum)
{
DOM_CHAL clnt_chal;
@@ -348,3 +351,4 @@ BOOL client_do_nt_login(char *desthost, char *myhostname,
return True;
}
+#endif /* NTDOMAIN */
diff --git a/source/client/smbmount.c b/source/client/smbmount.c
index 51c1ee6310a..1f9ceb1a801 100644
--- a/source/client/smbmount.c
+++ b/source/client/smbmount.c
@@ -44,7 +44,7 @@ pstring cur_dir = "\\";
pstring cd_path = "";
extern pstring service;
extern pstring desthost;
-extern pstring global_myname;
+extern pstring myname;
extern pstring myhostname;
extern pstring password;
extern pstring username;
@@ -818,7 +818,7 @@ static void usage(char *pname)
}
break;
case 'n':
- strcpy(global_myname,optarg);
+ strcpy(myname,optarg);
break;
case 'N':
got_pass = True;
@@ -868,7 +868,7 @@ static void usage(char *pname)
DEBUG(0,("Failed to get my hostname.\n"));
}
- if (!lp_load(servicesf,True,False,False)) {
+ if (!lp_load(servicesf,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
}
@@ -880,8 +880,33 @@ static void usage(char *pname)
strcpy(workgroup,lp_workgroup());
load_interfaces();
- get_myname((*global_myname)?NULL:global_myname,NULL);
- strupper(global_myname);
+ get_myname((*myname)?NULL:myname,NULL);
+ strupper(myname);
+
+#ifdef NTDOMAIN
+
+ if (nt_domain_logon)
+ {
+ int ret = 0;
+ slprintf(service,sizeof(service), "\\\\%s\\IPC$",query_host);
+ strupper(service);
+ connect_as_ipc = True;
+
+ DEBUG(5,("NT Domain Logon. Service: %s\n", service));
+
+ if (cli_open_sockets(port))
+ {
+ if (!cli_send_login(NULL,NULL,True,True,NULL)) return(1);
+
+ do_nt_login(desthost, myhostname, Client, cnum);
+
+ cli_send_logout();
+ close_sockets();
+ }
+
+ return(ret);
+ }
+#endif
if (cli_open_sockets(port))
{
diff --git a/source/include/includes.h b/source/include/includes.h
index 44ed317ae9f..03aa6966b2d 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -26,6 +26,11 @@
and add a section for the new unix below.
*/
+#ifdef NTDOMAIN
+#error WARNING: remove this option (-DNTDOMAIN) from your [Mm]akefile.
+#error Please read NTDOMAIN.txt with _this_ distribution.
+#endif
+
/* the first OS dependent section is to setup what includes will be used.
the main OS dependent section comes later on
@@ -182,10 +187,6 @@
#ifdef POSIX_H
#include <bsd/net/if.h>
#else
-#ifdef OSF1
-#include <net/route.h>
-#include <sys/mbuf.h>
-#endif
#include <net/if.h>
#endif
#endif
@@ -205,9 +206,6 @@
#include <syslog.h>
#endif
-#ifdef HAVE_REGEX_H
-#include <regex.h>
-#endif
/***************************************************************************
@@ -506,22 +504,23 @@ char *mktemp(char *); /* No standard include */
#endif
-#ifdef NETBSD
-#ifdef NetBSD1_3
-#include <string.h>
-#ifdef ALLOW_CHANGE_PASSWORD
-#include <termios.h>
-#endif /* ALLOW_CHANGE_PASSWORD */
+#ifdef NETBSD
+#ifdef NetBSD1_3
+#include <string.h>
+#ifdef ALLOW_CHANGE_PASSWORD
+#include <termios.h>
+#endif /* ALLOW_CHANGE_PASSWORD */
#else /* NetBSD1_3 */
-#include <strings.h>
-#endif /* NetBSD1_3 */
+#include <strings.h>
+#endif /* NetBSD1_3 */
#include <netinet/tcp.h>
/* you may not need this */
-#define NO_GETSPNAM
+#define NO_GETSPNAM
#define SIGNAL_CAST (void (*)())
#define USE_DIRECT
#define REPLACE_INNETGR
-#endif
+#endif
+
#ifdef FreeBSD
@@ -531,7 +530,6 @@ char *mktemp(char *); /* No standard include */
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <termios.h>
-#include <fcntl.h>
#if __FreeBSD__ >= 3
#include <dirent.h>
#else
@@ -547,7 +545,9 @@ char *mktemp(char *); /* No standard include */
#define HAVE_GETTIMEOFDAY
#define HAVE_PATHCONF
#define HAVE_GETGRNAM 1
+#ifndef QSORT_CAST
#define QSORT_CAST (int (*)(const void *, const void *))
+#endif /* QSORT_CAST */
#if !defined(O_SYNC)
#if defined(O_FSYNC)
#define O_SYNC O_FSYNC
@@ -607,6 +607,7 @@ char *mktemp(char *); /* No standard include */
#include <sys/termios.h>
#include <netinet/tcp.h>
#include <arpa/inet.h> /* needed for inet_ntoa proto */
+#include <stropts.h>
#ifdef HPUX_10_TRUSTED
#include <hpsecurity.h>
#include <prot.h>
@@ -1305,7 +1306,7 @@ it works and getting lots of bug reports */
#endif
#ifndef QSORT_CAST
-#define QSORT_CAST (int (*)())
+#define QSORT_CAST (int (*)(void *, void *))
#endif
#ifndef INADDR_LOOPBACK
diff --git a/source/include/local.h b/source/include/local.h
index 144c2d2838b..8bdb1904640 100644
--- a/source/include/local.h
+++ b/source/include/local.h
@@ -20,11 +20,10 @@
refer to the special "printers" service */
#define PRINTERS_NAME "printers"
-/* Yves Gaige <yvesg@hptnodur.grenoble.hp.com> requested this set this */
-/* to a maximum of 8 if old smb clients break because of long printer names. */
+/* Yves Gaige <yvesg@hptnodur.grenoble.hp.com> requested this */
+/* Set to 8 if old clients break because of this, the max value is 15 */
#define MAXPRINTERLEN 15
-
/* define what facility to use for syslog */
#ifndef SYSLOG_FACILITY
#define SYSLOG_FACILITY LOG_DAEMON
@@ -42,8 +41,8 @@
#define SHMEM_SIZE (1024*MAX_OPEN_FILES)
#endif
-/* the max number of simultanous connections to the server by all clients */
-#define MAXSTATUS 100000
+/* the max number of connections that the smbstatus program will show */
+#define MAXSTATUS 1000
/* max number of directories open at once */
/* note that with the new directory code this no longer requires a
@@ -167,8 +166,6 @@
#define LONG_CONNECT_TIMEOUT 30
#define SHORT_CONNECT_TIMEOUT 5
-/* the default netbios keepalive timeout */
-#define DEFAULT_KEEPALIVE 300
/* the directory to sit in when idle */
/* #define IDLE_DIR "/" */
diff --git a/source/include/ntdomain.h b/source/include/ntdomain.h
deleted file mode 100644
index 329cb1e3254..00000000000
--- a/source/include/ntdomain.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- SMB parameters and setup
- Copyright (C) Andrew Tridgell 1992-1997
- Copyright (C) Luke Kenneth Casson Leighton 1996-1997
- Copyright (C) Paul Ashton 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.
-*/
-
-#ifndef _NT_DOMAIN_H /* _NT_DOMAIN_H */
-#define _NT_DOMAIN_H
-
-
-/* dce/rpc support */
-#include "lib/rpc/include/rpc_dce.h"
-
-/* miscellaneous structures / defines */
-#include "lib/rpc/include/rpc_misc.h"
-
-/* different dce/rpc pipes */
-#include "lib/rpc/include/rpc_lsa.h"
-#include "lib/rpc/include/rpc_netlogon.h"
-#include "lib/rpc/include/rpc_reg.h"
-#include "lib/rpc/include/rpc_samr.h"
-#include "lib/rpc/include/rpc_srvsvc.h"
-#include "lib/rpc/include/rpc_wkssvc.h"
-
-/*
- * A bunch of stuff that was put into smb.h
- * in the NTDOM branch - it didn't belong there.
- */
-
-typedef struct
-{
- struct mem_buf *data; /* memory buffer */
- uint32 offset; /* offset currently being accessed in memory buffer */
- uint8 align; /* data alignment */
- BOOL io; /* parsing in or out of data stream */
-
-} prs_struct;
-
-typedef struct
-{
- int cnum;
- int uid;
- BOOL open; /* open connection */
- uint16 device_state;
- fstring name;
- fstring pipe_srv_name;
-
- prs_struct rhdr; /* output header */
- prs_struct rdata; /* output data */
- prs_struct rauth; /* output authentication verifier */
-
- RPC_HDR hdr;
- RPC_HDR_BA hdr_ba;
- RPC_HDR_RB hdr_rb;
- RPC_HDR_REQ hdr_req;
- RPC_HDR_RESP hdr_resp;
-
- RPC_AUTH_NTLMSSP_REQ ntlmssp_req;
- RPC_AUTH_NTLMSSP_RESP ntlmssp_resp;
-
- uint32 file_offset;
- uint32 hdr_offsets;
- uint32 frag_len_left;
- uint32 next_frag_start;
-
-} pipes_struct;
-
-struct acct_info
-{
- fstring acct_name; /* account name */
- uint32 smb_userid; /* domain-relative RID */
-};
-
-struct api_struct
-{
- char *name;
- uint8 opnum;
- void (*fn) (int uid, prs_struct*, prs_struct*);
-};
-
-struct mem_desc
-{
- /* array memory offsets */
- uint32 start;
- uint32 end;
-};
-
-struct mem_buf
-{
- BOOL dynamic; /* True iff data has been dynamically allocated
- (and therefore can be freed) */
- char *data;
- uint32 data_size;
- uint32 data_used;
-
- uint32 margin; /* safety margin when reallocing. */
- /* this can be abused quite nicely */
- uint8 align; /* alignment of data structures (smb, dce/rpc, udp etc) */
-
- struct mem_desc offset;
-
- struct mem_buf *next;
-};
-
-typedef struct
-{
- uint32 rid;
- char *name;
-
-} rid_name;
-
-#endif /* _NT_DOMAIN_H */
-
diff --git a/source/include/nterr.h b/source/include/nterr.h
index 643d93bc93a..92f02612dbc 100644
--- a/source/include/nterr.h
+++ b/source/include/nterr.h
@@ -7,7 +7,6 @@
#define NT_STATUS_INVALID_INFO_CLASS (3)
#define NT_STATUS_INFO_LENGTH_MISMATCH (4)
#define NT_STATUS_ACCESS_VIOLATION (5)
-#define STATUS_BUFFER_OVERFLOW (5)
#define NT_STATUS_IN_PAGE_ERROR (6)
#define NT_STATUS_PAGEFILE_QUOTA (7)
#define NT_STATUS_INVALID_HANDLE (8)
diff --git a/source/include/proto.h b/source/include/proto.h
index 833794a4fb4..d643f3c286f 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -18,6 +18,18 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question,
struct name_record **n);
void kill_async_dns_child(void);
+/*The following definitions come from cgi.c */
+
+void cgi_load_variables(FILE *f1);
+char *cgi_variable(char *name);
+char *cgi_vnum(int i, char **name);
+int cgi_boolean(char *name, int def);
+char *quotedup(char *s);
+char *urlquote(char *s);
+char *quotequotes(char *s);
+void quote_spaces(char *buf);
+void cgi_setup(char *rootdir);
+
/*The following definitions come from charcnv.c */
char *unix2dos_format(char *str,BOOL overwrite);
@@ -36,12 +48,12 @@ BOOL chat_with_program(char *passwordprogram,char *name,char *chatsequence, BOOL
BOOL chgpasswd(char *name,char *oldpass,char *newpass, BOOL as_root);
BOOL chgpasswd(char *name,char *oldpass,char *newpass, BOOL as_root);
BOOL check_lanman_password(char *user, unsigned char *pass1,
- unsigned char *pass2, struct smb_passwd **psampw);
-BOOL change_lanman_password(struct smb_passwd *sampw, unsigned char *pass1, unsigned char *pass2);
+ unsigned char *pass2, struct smb_passwd **psmbpw);
+BOOL change_lanman_password(struct smb_passwd *smbpw, unsigned char *pass1, unsigned char *pass2);
BOOL check_oem_password(char *user, unsigned char *data,
- struct smb_passwd **psampw, char *new_passwd,
+ struct smb_passwd **psmbpw, char *new_passwd,
int new_passwd_size);
-BOOL change_oem_password(struct smb_passwd *sampw, char *new_passwd, BOOL override);
+BOOL change_oem_password(struct smb_passwd *smbpw, char *new_passwd, BOOL override);
/*The following definitions come from client.c */
@@ -51,16 +63,7 @@ void cmd_help(char *dum_in, char *dum_out);
/*The following definitions come from clientgen.c */
-char *cli_smb_errstr(struct cli_state *cli);
-char *cli_errstr(struct cli_state *cli);
-BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
- uint16 *setup, uint32 setup_count, uint32 max_setup_count,
- char *params, uint32 param_count, uint32 max_param_count,
- char *data, uint32 data_count, uint32 max_data_count,
- char **rparam, uint32 *rparam_count,
- char **rdata, uint32 *rdata_count);
BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation);
-BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(char *, uint32, char *));
BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
void (*fn)(char *, uint32, char *));
BOOL cli_session_setup(struct cli_state *cli,
@@ -100,6 +103,7 @@ BOOL cli_session_request(struct cli_state *cli, char *host, int name_type,
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);
+char *cli_errstr(struct cli_state *cli);
void cli_error(struct cli_state *cli, int *eclass, int *num);
void cli_sockopt(struct cli_state *cli, char *options);
int cli_setpid(struct cli_state *cli, int pid);
@@ -138,11 +142,6 @@ int process_tar(char *inbuf, char *outbuf);
int clipfind(char **aret, int ret, char *tok);
int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind);
-/*The following definitions come from connection.c */
-
-BOOL yield_connection(int cnum,char *name,int max_connections);
-BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
-
/*The following definitions come from credentials.c */
char *credstr(uchar *cred);
@@ -190,10 +189,6 @@ void DirCacheFlush( int snum );
void fault_setup(void (*fn)(void *));
-/*The following definitions come from genrand.c */
-
-void generate_random_buffer( unsigned char *out, int len, BOOL re_seed);
-
/*The following definitions come from getsmbpass.c */
char *getsmbpass(char *prompt) ;
@@ -223,701 +218,6 @@ int reply_trans(char *inbuf,char *outbuf, int size, int bufsize);
void interpret_coding_system(char *str);
void initialize_multibyte_vectors( int client_codepage);
-/*The following definitions come from lib/rpc/client/cli_login.c */
-
-BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16]);
-BOOL cli_nt_srv_pwset(struct cli_state *cli, unsigned char *new_hashof_mach_pwd);
-BOOL cli_nt_login_interactive(struct cli_state *cli, char *domain, char *username,
- uint32 smb_userid_low, char *password,
- NET_ID_INFO_CTR *ctr, NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_login_network(struct cli_state *cli, char *domain, char *username,
- uint32 smb_userid_low, char lm_chal[8], char lm_chal_resp[24],
- char nt_chal_resp[24],
- NET_ID_INFO_CTR *ctr, NET_USER_INFO_3 *user_info3);
-BOOL cli_nt_logoff(struct cli_state *cli, NET_ID_INFO_CTR *ctr);
-
-/*The following definitions come from lib/rpc/client/cli_netlogon.c */
-
-BOOL cli_net_logon_ctrl2(struct cli_state *cli, uint32 status_level);
-BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan,
- uint32 neg_flags, DOM_CHAL *srv_chal);
-BOOL cli_net_req_chal(struct cli_state *cli, DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal);
-BOOL cli_net_srv_pwset(struct cli_state *cli, uint8 hashed_mach_pwd[16]);
-BOOL cli_net_sam_logon(struct cli_state *cli, NET_ID_INFO_CTR *ctr,
- NET_USER_INFO_3 *user_info3);
-BOOL cli_net_sam_logoff(struct cli_state *cli, NET_ID_INFO_CTR *ctr);
-
-/*The following definitions come from lib/rpc/client/cli_pipe.c */
-
-uint32 get_rpc_call_id(void);
-BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd,
- prs_struct *param , prs_struct *data,
- prs_struct *rparam, prs_struct *rdata);
-BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num,
- prs_struct *data, prs_struct *rdata);
-BOOL rpc_pipe_set_hnd_state(struct cli_state *cli, char *pipe_name, uint16 device_state);
-BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name,
- RPC_IFACE *abstract, RPC_IFACE *transfer, BOOL ntlmssp_auth);
-BOOL cli_nt_session_open(struct cli_state *cli, char *pipe_name, BOOL encrypted);
-void cli_nt_session_close(struct cli_state *cli);
-
-/*The following definitions come from lib/rpc/parse/parse_lsa.c */
-
-void make_lsa_trans_name(LSA_TRANS_NAME *trn, uint32 sid_name_use, char *name, uint32 idx);
-void lsa_io_trans_name(char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, int depth);
-void lsa_io_dom_r_ref(char *desc, DOM_R_REF *r_r, prs_struct *ps, int depth);
-void make_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, uint32 sec_qos);
-void lsa_io_obj_attr(char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps, int depth);
-void make_q_open_pol(LSA_Q_OPEN_POL *r_q, char *server_name,
- uint32 attributes, uint32 sec_qos,
- uint32 desired_access);
-void lsa_io_q_open_pol(char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps, int depth);
-void lsa_io_r_open_pol(char *desc, LSA_R_OPEN_POL *r_p, prs_struct *ps, int depth);
-void make_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class);
-void lsa_io_q_query(char *desc, LSA_Q_QUERY_INFO *q_q, prs_struct *ps, int depth);
-void lsa_io_q_enum_trust_dom(char *desc, LSA_Q_ENUM_TRUST_DOM *q_e, prs_struct *ps, int depth);
-void make_r_enum_trust_dom(LSA_R_ENUM_TRUST_DOM *r_e,
- uint32 enum_context, char *domain_name, char *domain_sid,
- uint32 status);
-void lsa_io_r_enum_trust_dom(char *desc, LSA_R_ENUM_TRUST_DOM *r_e, prs_struct *ps, int depth);
-void make_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd);
-void lsa_io_q_close(char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth);
-void make_lsa_r_close(LSA_R_CLOSE *q_r, POLICY_HND *hnd);
-void lsa_io_r_close(char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth);
-void lsa_io_r_query(char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps, int depth);
-void lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen, prs_struct *ps, int depth);
-void lsa_io_q_lookup_sids(char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, int depth);
-void lsa_io_trans_names(char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);
-void lsa_io_r_lookup_sids(char *desc, LSA_R_LOOKUP_SIDS *r_s, prs_struct *ps, int depth);
-void lsa_io_q_lookup_rids(char *desc, LSA_Q_LOOKUP_RIDS *q_r, prs_struct *ps, int depth);
-void lsa_io_r_lookup_rids(char *desc, LSA_R_LOOKUP_RIDS *r_r, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_misc.c */
-
-void smb_io_utime(char *desc, UTIME *t, prs_struct *ps, int depth);
-void smb_io_time(char *desc, NTTIME *nttime, prs_struct *ps, int depth);
-void smb_io_lookup_level(char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth);
-uint32 get_enum_hnd(ENUM_HND *enh);
-void make_enum_hnd(ENUM_HND *enh, uint32 hnd);
-void smb_io_enum_hnd(char *desc, ENUM_HND *hnd, prs_struct *ps, int depth);
-void make_dom_sid(DOM_SID *sid, char *str_sid);
-void smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth);
-void make_dom_sid2(DOM_SID2 *sid, char *str_sid);
-void smb_io_dom_sid2(char *desc, DOM_SID2 *sid, prs_struct *ps, int depth);
-void make_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer);
-void smb_io_strhdr(char *desc, STRHDR *hdr, prs_struct *ps, int depth);
-void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint32 buffer);
-void smb_io_unihdr(char *desc, UNIHDR *hdr, prs_struct *ps, int depth);
-void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate);
-void smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth);
-void make_unistr(UNISTR *str, char *buf);
-void smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth);
-void make_uninotstr2(UNINOTSTR2 *str, char *buf, int len);
-void smb_io_uninotstr2(char *desc, UNINOTSTR2 *uni2, uint32 buffer, prs_struct *ps, int depth);
-void make_buf_unistr2(UNISTR2 *str, uint32 *ptr, char *buf);
-void copy_unistr2(UNISTR2 *str, UNISTR2 *from);
-void make_string2(STRING2 *str, char *buf, int len);
-void smb_io_string2(char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth);
-void make_unistr2(UNISTR2 *str, char *buf, int len);
-void smb_io_unistr2(char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth);
-void make_dom_rid2(DOM_RID2 *rid2, uint32 rid);
-void smb_io_dom_rid2(char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth);
-void make_dom_rid3(DOM_RID3 *rid3, uint32 rid);
-void smb_io_dom_rid3(char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth);
-void make_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid);
-void smb_io_dom_rid4(char *desc, DOM_RID4 *rid4, prs_struct *ps, int depth);
-void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name);
-void smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth);
-void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
- uint16 sec_chan, char *comp_name);
-void smb_io_log_info(char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth);
-void smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth);
-void smb_io_cred(char *desc, DOM_CRED *cred, prs_struct *ps, int depth);
-void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
- char *logon_srv, char *comp_name,
- DOM_CRED *clnt_cred);
-void smb_io_clnt_info2(char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth);
-void make_clnt_info(DOM_CLNT_INFO *clnt,
- char *logon_srv, char *acct_name,
- uint16 sec_chan, char *comp_name,
- DOM_CRED *cred);
-void smb_io_clnt_info(char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth);
-void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high);
-void smb_io_logon_id(char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth);
-void make_owf_info(OWF_INFO *hash, uint8 data[16]);
-void smb_io_owf_info(char *desc, OWF_INFO *hash, prs_struct *ps, int depth);
-void smb_io_gid(char *desc, DOM_GID *gid, prs_struct *ps, int depth);
-void smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth);
-void smb_io_dom_query_3(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth);
-void smb_io_dom_query_5(char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth);
-void smb_io_dom_query(char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth);
-void smb_io_dom_name(char *desc, DOM_NAME *name, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_net.c */
-
-void net_io_neg_flags(char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth);
-void make_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts);
-void net_io_netinfo_3(char *desc, NETLOGON_INFO_3 *info, prs_struct *ps, int depth);
-void make_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status);
-void net_io_netinfo_1(char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth);
-void make_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
- uint32 tc_status, char *trusted_dc_name);
-void net_io_netinfo_2(char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth);
-void make_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *server_name,
- uint32 function_code);
-void net_io_q_logon_ctrl2(char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth);
-void make_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
- uint32 flags, uint32 pdc_status, uint32 logon_attempts,
- uint32 tc_status, char *trusted_domain_name);
-void net_io_r_logon_ctrl2(char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth);
-void make_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
- uint32 num_doms, char *dom_name);
-void net_io_r_trust_dom(char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth);
-void make_q_trust_dom(NET_Q_TRUST_DOM_LIST *q_l, char *server_name,
- uint32 function_code);
-void net_io_q_trust_dom(char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, int depth);
-void make_q_req_chal(NET_Q_REQ_CHAL *q_c,
- char *logon_srv, char *logon_clnt,
- DOM_CHAL *clnt_chal);
-void net_io_q_req_chal(char *desc, NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth);
-void net_io_r_req_chal(char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth);
-void make_q_auth_2(NET_Q_AUTH_2 *q_a,
- char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name,
- DOM_CHAL *clnt_chal, uint32 clnt_flgs);
-void net_io_q_auth_2(char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth);
-void net_io_r_auth_2(char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth);
-void make_q_srv_pwset(NET_Q_SRV_PWSET *q_s, char *logon_srv, char *acct_name,
- uint16 sec_chan, char *comp_name, DOM_CRED *cred, char nt_cypher[16]);
-void net_io_q_srv_pwset(char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth);
-void net_io_r_srv_pwset(char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth);
-void make_id_info1(NET_ID_INFO_1 *id, char *domain_name,
- uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
- char *user_name, char *wksta_name,
- char sess_key[16],
- unsigned char lm_cypher[16], unsigned char nt_cypher[16]);
-void net_io_id_info1(char *desc, NET_ID_INFO_1 *id, prs_struct *ps, int depth);
-void make_id_info2(NET_ID_INFO_2 *id, char *domain_name,
- uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
- char *user_name, char *wksta_name,
- unsigned char lm_challenge[8],
- unsigned char lm_chal_resp[24],
- unsigned char nt_chal_resp[24]);
-void net_io_id_info2(char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int depth);
-void make_sam_info(DOM_SAM_INFO *sam,
- char *logon_srv, char *comp_name, DOM_CRED *clnt_cred,
- DOM_CRED *rtn_cred, uint16 logon_level,
- NET_ID_INFO_CTR *ctr, uint16 validation_level);
-void net_io_id_info_ctr(char *desc, NET_ID_INFO_CTR *ctr, prs_struct *ps, int depth);
-void smb_io_sam_info(char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth);
-void make_net_user_info3(NET_USER_INFO_3 *usr,
-
- NTTIME *logon_time,
- NTTIME *logoff_time,
- NTTIME *kickoff_time,
- NTTIME *pass_last_set_time,
- NTTIME *pass_can_change_time,
- NTTIME *pass_must_change_time,
-
- char *user_name,
- char *full_name,
- char *logon_script,
- char *profile_path,
- char *home_dir,
- char *dir_drive,
-
- uint16 logon_count,
- uint16 bad_pw_count,
-
- uint32 user_id,
- uint32 group_id,
- uint32 num_groups,
- DOM_GID *gids,
- uint32 user_flgs,
-
- char sess_key[16],
-
- char *logon_srv,
- char *logon_dom,
-
- char *dom_sid,
- char *other_sids);
-void net_io_user_info3(char *desc, NET_USER_INFO_3 *usr, prs_struct *ps, int depth);
-void net_io_q_sam_logon(char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth);
-void net_io_r_sam_logon(char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth);
-void net_io_q_sam_logoff(char *desc, NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth);
-void net_io_r_sam_logoff(char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_prs.c */
-
-void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name);
-void prs_init(prs_struct *ps, uint32 size,
- uint8 align, uint32 margin,
- BOOL io);
-void prs_mem_free(prs_struct *ps);
-void prs_align(prs_struct *ps);
-BOOL prs_grow(prs_struct *ps);
-BOOL prs_uint8(char *name, prs_struct *ps, int depth, uint8 *data8);
-BOOL prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16);
-BOOL prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32);
-BOOL prs_uint8s(BOOL charmode, char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
-BOOL prs_uint16s(BOOL charmode, char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
-BOOL prs_uint32s(BOOL charmode, char *name, prs_struct *ps, int depth, uint32 *data32s, int len);
-BOOL prs_uninotstr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNINOTSTR2 *str);
-BOOL prs_string2(BOOL charmode, char *name, prs_struct *ps, int depth, STRING2 *str);
-BOOL prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNISTR2 *str);
-BOOL prs_unistr(char *name, prs_struct *ps, int depth, UNISTR *str);
-BOOL prs_string(char *name, prs_struct *ps, int depth, char *str, uint16 len);
-
-/*The following definitions come from lib/rpc/parse/parse_reg.c */
-
-void make_reg_q_open_policy(REG_Q_OPEN_POLICY *r_q,
- uint16 unknown_0, uint32 level, uint16 unknown_1);
-void reg_io_q_open_policy(char *desc, REG_Q_OPEN_POLICY *r_q, prs_struct *ps, int depth);
-void make_reg_r_open_policy(REG_R_OPEN_POLICY *r_r,
- POLICY_HND *pol, uint32 status);
-void reg_io_r_open_policy(char *desc, REG_R_OPEN_POLICY *r_r, prs_struct *ps, int depth);
-void reg_io_q_close(char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth);
-void reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth);
-void make_reg_q_info(REG_Q_INFO *r_q,
- POLICY_HND *pol, char *product_type,
- NTTIME *prod_time, uint8 major_version, uint8 minor_version,
- uint32 unknown);
-void reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth);
-void make_reg_r_info(REG_R_INFO *r_r,
- uint32 level, char *os_type,
- uint32 unknown_0, uint32 unknown_1,
- uint32 status);
-void reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth);
-void make_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q,
- POLICY_HND *pol, char *name,
- uint32 unknown_0, uint32 unknown_1, uint16 unknown_2);
-void reg_io_q_open_entry(char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth);
-void make_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
- POLICY_HND *pol, uint32 status);
-void reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_rpc.c */
-
-void make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
- uint32 call_id, int data_len, int auth_len);
-void smb_io_rpc_hdr(char *desc, RPC_HDR *rpc, prs_struct *ps, int depth);
-void make_rpc_iface(RPC_IFACE *ifc, char data[16], uint32 version);
-void smb_io_rpc_iface(char *desc, RPC_IFACE *ifc, prs_struct *ps, int depth);
-void make_rpc_addr_str(RPC_ADDR_STR *str, char *name);
-void smb_io_rpc_addr_str(char *desc, RPC_ADDR_STR *str, prs_struct *ps, int depth);
-void make_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid);
-void smb_io_rpc_hdr_bba(char *desc, RPC_HDR_BBA *rpc, prs_struct *ps, int depth);
-void make_rpc_hdr_rb(RPC_HDR_RB *rpc,
- uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
- uint32 num_elements, uint16 context_id, uint8 num_syntaxes,
- RPC_IFACE *abstract, RPC_IFACE *transfer);
-void smb_io_rpc_hdr_rb(char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth);
-void make_rpc_results(RPC_RESULTS *res,
- uint8 num_results, uint16 result, uint16 reason);
-void smb_io_rpc_results(char *desc, RPC_RESULTS *res, prs_struct *ps, int depth);
-void make_rpc_hdr_ba(RPC_HDR_BA *rpc,
- uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
- char *pipe_addr,
- uint8 num_results, uint16 result, uint16 reason,
- RPC_IFACE *transfer);
-void smb_io_rpc_hdr_ba(char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth);
-void make_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 data_len, uint16 opnum);
-void smb_io_rpc_hdr_req(char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth);
-void make_rpc_hdr_resp(RPC_HDR_RESP *hdr, uint32 data_len);
-void smb_io_rpc_hdr_resp(char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth);
-void make_rpc_auth_ntlmssp_req(RPC_AUTH_NTLMSSP_REQ *req,
- fstring ntlmssp_str, uint32 ntlmssp_ver,
- uint32 unknown_0, fstring myname, fstring domain);
-void smb_io_rpc_auth_ntlmssp_req(char *desc, RPC_AUTH_NTLMSSP_REQ *req, prs_struct *ps, int depth);
-void make_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp,
- uint8 auth_type, uint8 auth_level, uint8 stub_type_len,
- fstring ntlmssp_str, uint32 ntlmssp_ver,
- uint32 unknown_1, uint32 unknown_2, uint32 unknown_3,
- uint8 data[16]);
-void smb_io_rpc_auth_ntlmssp_resp(char *desc, RPC_AUTH_NTLMSSP_RESP *rsp, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_samr.c */
-
-void make_samr_q_close_hnd(SAMR_Q_CLOSE_HND *q_c, POLICY_HND *hnd);
-void samr_io_q_close_hnd(char *desc, SAMR_Q_CLOSE_HND *q_u, prs_struct *ps, int depth);
-void samr_io_r_close_hnd(char *desc, SAMR_R_CLOSE_HND *r_u, prs_struct *ps, int depth);
-void make_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN *q_u,
- POLICY_HND *connect_pol, uint32 rid, char *sid);
-void samr_io_q_open_domain(char *desc, SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *ps, int depth);
-void samr_io_r_open_domain(char *desc, SAMR_R_OPEN_DOMAIN *r_u, prs_struct *ps, int depth);
-void make_samr_q_unknown_8(SAMR_Q_UNKNOWN_8 *q_u,
- POLICY_HND *domain_pol, uint16 switch_value);
-void samr_io_q_unknown_8(char *desc, SAMR_Q_UNKNOWN_8 *q_u, prs_struct *ps, int depth);
-void make_samr_q_unknown_3(SAMR_Q_UNKNOWN_3 *q_u,
- POLICY_HND *user_pol, uint16 switch_value);
-void samr_io_q_unknown_3(char *desc, SAMR_Q_UNKNOWN_3 *q_u, prs_struct *ps, int depth);
-void make_dom_sid3(DOM_SID3 *sid3, uint16 unk_0, uint16 unk_1, char *sid);
-void sam_io_dom_sid3(char *desc, DOM_SID3 *sid3, prs_struct *ps, int depth);
-void make_sam_sid_stuff(SAM_SID_STUFF *stf,
- uint16 unknown_2, uint16 unknown_3,
- uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
- int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS]);
-void sam_io_sid_stuff(char *desc, SAM_SID_STUFF *stf, prs_struct *ps, int depth);
-void make_samr_r_unknown_3(SAMR_R_UNKNOWN_3 *r_u,
- uint16 unknown_2, uint16 unknown_3,
- uint32 unknown_4, uint16 unknown_6, uint16 unknown_7,
- int num_sid3s, DOM_SID3 sid3[MAX_SAM_SIDS],
- uint32 status);
-void samr_io_r_unknown_3(char *desc, SAMR_R_UNKNOWN_3 *r_u, prs_struct *ps, int depth);
-void make_sam_str1(SAM_STR1 *sam, char *sam_acct, char *sam_name, char *sam_desc);
-void sam_io_sam_str1(char *desc, SAM_STR1 *sam, uint32 acct_buf, uint32 name_buf, uint32 desc_buf, prs_struct *ps, int depth);
-void make_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
- uint32 len_sam_name, uint32 len_sam_full, uint32 len_sam_desc,
- uint32 rid_user, uint16 acb_info);
-void sam_io_sam_entry1(char *desc, SAM_ENTRY1 *sam, prs_struct *ps, int depth);
-void make_sam_str2(SAM_STR2 *sam, char *sam_acct, char *sam_desc);
-void sam_io_sam_str2(char *desc, SAM_STR2 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth);
-void make_sam_entry2(SAM_ENTRY2 *sam, uint32 user_idx,
- uint32 len_sam_name, uint32 len_sam_desc,
- uint32 rid_user, uint16 acb_info);
-void sam_io_sam_entry2(char *desc, SAM_ENTRY2 *sam, prs_struct *ps, int depth);
-void make_sam_str3(SAM_STR3 *sam, char *grp_acct, char *grp_desc);
-void sam_io_sam_str3(char *desc, SAM_STR3 *sam, uint32 acct_buf, uint32 desc_buf, prs_struct *ps, int depth);
-void make_sam_entry3(SAM_ENTRY3 *sam, uint32 grp_idx,
- uint32 len_grp_name, uint32 len_grp_desc, uint32 rid_grp);
-void sam_io_sam_entry3(char *desc, SAM_ENTRY3 *sam, prs_struct *ps, int depth);
-void make_sam_entry(SAM_ENTRY *sam, uint32 len_sam_name, uint32 rid);
-void sam_io_sam_entry(char *desc, SAM_ENTRY *sam, prs_struct *ps, int depth);
-void make_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_e, POLICY_HND *pol,
- uint16 req_num_entries, uint16 unk_0,
- uint16 acb_mask, uint16 unk_1, uint32 size);
-void samr_io_q_enum_dom_users(char *desc, SAMR_Q_ENUM_DOM_USERS *q_e, prs_struct *ps, int depth);
-void make_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS *r_u,
- uint16 total_num_entries, uint16 unk_0,
- uint32 num_sam_entries, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES], uint32 status);
-void samr_io_r_enum_dom_users(char *desc, SAMR_R_ENUM_DOM_USERS *r_u, prs_struct *ps, int depth);
-void make_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_e, POLICY_HND *pol, uint32 size);
-void samr_io_q_enum_dom_aliases(char *desc, SAMR_Q_ENUM_DOM_ALIASES *q_e, prs_struct *ps, int depth);
-void make_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u,
- uint32 num_sam_entries, SAM_USER_INFO_21 grps[MAX_SAM_ENTRIES],
- uint32 status);
-void samr_io_r_enum_dom_aliases(char *desc, SAMR_R_ENUM_DOM_ALIASES *r_u, prs_struct *ps, int depth);
-void make_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_e, POLICY_HND *pol,
- uint16 switch_level, uint32 start_idx, uint32 size);
-void samr_io_q_query_dispinfo(char *desc, SAMR_Q_QUERY_DISPINFO *q_e, prs_struct *ps, int depth);
-void make_sam_info_2(SAM_INFO_2 *sam, uint32 acb_mask,
- uint32 start_idx, uint32 num_sam_entries,
- SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
-void sam_io_sam_info_2(char *desc, SAM_INFO_2 *sam, prs_struct *ps, int depth);
-void make_sam_info_1(SAM_INFO_1 *sam, uint32 acb_mask,
- uint32 start_idx, uint32 num_sam_entries,
- SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]);
-void sam_io_sam_info_1(char *desc, SAM_INFO_1 *sam, prs_struct *ps, int depth);
-void make_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO *r_u,
- uint16 switch_level, SAM_INFO_CTR *ctr, uint32 status);
-void samr_io_r_query_dispinfo(char *desc, SAMR_R_QUERY_DISPINFO *r_u, prs_struct *ps, int depth);
-void make_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_e, POLICY_HND *pol,
- uint16 switch_level, uint32 start_idx, uint32 size);
-void samr_io_q_enum_dom_groups(char *desc, SAMR_Q_ENUM_DOM_GROUPS *q_e, prs_struct *ps, int depth);
-void make_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS *r_u,
- uint32 start_idx, uint32 num_sam_entries,
- SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES],
- uint32 status);
-void samr_io_r_enum_dom_groups(char *desc, SAMR_R_ENUM_DOM_GROUPS *r_u, prs_struct *ps, int depth);
-void make_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_e,
- POLICY_HND *pol,
- uint16 switch_level);
-void samr_io_q_query_aliasinfo(char *desc, SAMR_Q_QUERY_ALIASINFO *q_e, prs_struct *ps, int depth);
-void make_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO *r_u,
- uint16 switch_value, char *acct_desc,
- uint32 status);
-void samr_io_r_query_aliasinfo(char *desc, SAMR_R_QUERY_ALIASINFO *r_u, prs_struct *ps, int depth);
-void samr_io_q_lookup_ids(char *desc, SAMR_Q_LOOKUP_IDS *q_u, prs_struct *ps, int depth);
-void make_samr_r_lookup_ids(SAMR_R_LOOKUP_IDS *r_u,
- uint32 num_rids, uint32 *rid, uint32 status);
-void samr_io_r_lookup_ids(char *desc, SAMR_R_LOOKUP_IDS *r_u, prs_struct *ps, int depth);
-void samr_io_q_lookup_names(char *desc, SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *ps, int depth);
-void make_samr_r_lookup_names(SAMR_R_LOOKUP_NAMES *r_u,
- uint32 num_rids, uint32 *rid, uint32 status);
-void samr_io_r_lookup_names(char *desc, SAMR_R_LOOKUP_NAMES *r_u, prs_struct *ps, int depth);
-void make_samr_q_unknown_12(SAMR_Q_UNKNOWN_12 *q_u,
- POLICY_HND *pol, uint32 rid,
- uint32 num_gids, uint32 *gid);
-void samr_io_q_unknown_12(char *desc, SAMR_Q_UNKNOWN_12 *q_u, prs_struct *ps, int depth);
-void make_samr_r_unknown_12(SAMR_R_UNKNOWN_12 *r_u,
- uint32 num_aliases, fstring *als_name, uint32 *num_als_usrs,
- uint32 status);
-void samr_io_r_unknown_12(char *desc, SAMR_R_UNKNOWN_12 *r_u, prs_struct *ps, int depth);
-void make_samr_q_open_user(SAMR_Q_OPEN_USER *q_u,
- POLICY_HND *pol,
- uint32 unk_0, uint32 rid);
-void samr_io_q_open_user(char *desc, SAMR_Q_OPEN_USER *q_u, prs_struct *ps, int depth);
-void samr_io_r_open_user(char *desc, SAMR_R_OPEN_USER *r_u, prs_struct *ps, int depth);
-void make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
- POLICY_HND *hnd);
-void samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth);
-void make_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS *r_u,
- uint32 num_gids, DOM_GID *gid, uint32 status);
-void samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_struct *ps, int depth);
-void make_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u,
- POLICY_HND *hnd, uint16 switch_value);
-void samr_io_q_query_userinfo(char *desc, SAMR_Q_QUERY_USERINFO *q_u, prs_struct *ps, int depth);
-void sam_io_logon_hrs(char *desc, LOGON_HRS *hrs, prs_struct *ps, int depth);
-void make_sam_user_info11(SAM_USER_INFO_11 *usr,
- NTTIME *expiry,
- char *mach_acct,
- uint32 rid_user,
- uint32 rid_group,
- uint16 acct_ctrl);
-void sam_io_user_info11(char *desc, SAM_USER_INFO_11 *usr, prs_struct *ps, int depth);
-void make_sam_user_info21(SAM_USER_INFO_21 *usr,
-
- NTTIME *logon_time,
- NTTIME *logoff_time,
- NTTIME *kickoff_time,
- NTTIME *pass_last_set_time,
- NTTIME *pass_can_change_time,
- NTTIME *pass_must_change_time,
-
- char *user_name,
- char *full_name,
- char *home_dir,
- char *dir_drive,
- char *logon_script,
- char *profile_path,
- char *description,
- char *workstations,
- char *unknown_str,
- char *munged_dial,
-
- uint32 user_rid,
- uint32 group_rid,
- uint16 acb_info,
-
- uint32 unknown_3,
- uint16 logon_divs,
- LOGON_HRS *hrs,
- uint32 unknown_5,
- uint32 unknown_6);
-void sam_io_user_info21(char *desc, SAM_USER_INFO_21 *usr, prs_struct *ps, int depth);
-void make_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO *r_u,
- uint16 switch_value, void *info, uint32 status);
-void samr_io_r_query_userinfo(char *desc, SAMR_R_QUERY_USERINFO *r_u, prs_struct *ps, int depth);
-void make_samr_q_unknown_21(SAMR_Q_UNKNOWN_21 *q_c,
- POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
-void samr_io_q_unknown_21(char *desc, SAMR_Q_UNKNOWN_21 *q_u, prs_struct *ps, int depth);
-void make_samr_q_unknown_13(SAMR_Q_UNKNOWN_13 *q_c,
- POLICY_HND *hnd, uint16 unk_1, uint16 unk_2);
-void samr_io_q_unknown_13(char *desc, SAMR_Q_UNKNOWN_13 *q_u, prs_struct *ps, int depth);
-void samr_io_q_unknown_32(char *desc, SAMR_Q_UNKNOWN_32 *q_u, prs_struct *ps, int depth);
-void samr_io_r_unknown_32(char *desc, SAMR_R_UNKNOWN_32 *r_u, prs_struct *ps, int depth);
-void make_samr_q_connect(SAMR_Q_CONNECT *q_u,
- char *srv_name, uint32 unknown_0);
-void samr_io_q_connect(char *desc, SAMR_Q_CONNECT *q_u, prs_struct *ps, int depth);
-void samr_io_r_connect(char *desc, SAMR_R_CONNECT *r_u, prs_struct *ps, int depth);
-void make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u,
- uint32 unknown_0, uint32 rid);
-void samr_io_q_open_alias(char *desc, SAMR_Q_OPEN_ALIAS *q_u, prs_struct *ps, int depth);
-void samr_io_r_open_alias(char *desc, SAMR_R_OPEN_ALIAS *r_u, prs_struct *ps, int depth);
-void make_samr_q_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, char *srv_name);
-void samr_io_q_unknown_38(char *desc, SAMR_Q_UNKNOWN_38 *q_u, prs_struct *ps, int depth);
-void make_samr_r_unknown_38(SAMR_R_UNKNOWN_38 *r_u,
- uint16 level, uint32 status);
-void samr_io_r_unknown_38(char *desc, SAMR_R_UNKNOWN_38 *r_u, prs_struct *ps, int depth);
-void samr_io_enc_passwd(char *desc, SAMR_ENC_PASSWD *pwd, prs_struct *ps, int depth);
-void samr_io_enc_hash(char *desc, SAMR_ENC_HASH *hsh, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_srv.c */
-
-void make_srv_share_info1_str(SH_INFO_1_STR *sh1, char *net_name, char *remark);
-void srv_io_share_info1_str(char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth);
-void make_srv_share_info1(SH_INFO_1 *sh1, char *net_name, uint32 type, char *remark);
-void srv_io_share_info1(char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth);
-void srv_io_srv_share_info_1(char *desc, SRV_SHARE_INFO_1 *ctr, prs_struct *ps, int depth);
-void make_srv_share_info2_str(SH_INFO_2_STR *sh2,
- char *net_name, char *remark,
- char *path, char *passwd);
-void srv_io_share_info2_str(char *desc, SH_INFO_2_STR *sh2, prs_struct *ps, int depth);
-void make_srv_share_info2(SH_INFO_2 *sh2,
- char *net_name, uint32 type, char *remark,
- uint32 perms, uint32 max_uses, uint32 num_uses,
- char *path, char *passwd);
-void srv_io_share_info2(char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth);
-void srv_io_srv_share_info_2(char *desc, SRV_SHARE_INFO_2 *ctr, prs_struct *ps, int depth);
-void srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth);
-void make_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n,
- char *srv_name,
- uint32 share_level, SRV_SHARE_INFO_CTR *ctr,
- uint32 preferred_len,
- ENUM_HND *hnd);
-void srv_io_q_net_share_enum(char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth);
-void srv_io_r_net_share_enum(char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth);
-void make_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name);
-void srv_io_sess_info0_str(char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth);
-void make_srv_sess_info0(SESS_INFO_0 *ss0, char *name);
-void srv_io_sess_info0(char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth);
-void srv_io_srv_sess_info_0(char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth);
-void make_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char *user);
-void srv_io_sess_info1_str(char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth);
-void make_srv_sess_info1(SESS_INFO_1 *ss1,
- char *name, char *user,
- uint32 num_opens, uint32 open_time, uint32 idle_time,
- uint32 user_flags);
-void srv_io_sess_info1(char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth);
-void srv_io_srv_sess_info_1(char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth);
-void srv_io_srv_sess_ctr(char *desc, SRV_SESS_INFO_CTR *ctr, prs_struct *ps, int depth);
-void make_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n,
- char *srv_name, char *qual_name,
- uint32 sess_level, SRV_SESS_INFO_CTR *ctr,
- uint32 preferred_len,
- ENUM_HND *hnd);
-void srv_io_q_net_sess_enum(char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth);
-void srv_io_r_net_sess_enum(char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth);
-void make_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id);
-void srv_io_conn_info0(char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth);
-void srv_io_srv_conn_info_0(char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth);
-void make_srv_conn_info1_str(CONN_INFO_1_STR *ss1, char *usr_name, char *net_name);
-void srv_io_conn_info1_str(char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth);
-void make_srv_conn_info1(CONN_INFO_1 *ss1,
- uint32 id, uint32 type,
- uint32 num_opens, uint32 num_users, uint32 open_time,
- char *usr_name, char *net_name);
-void srv_io_conn_info1(char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth);
-void srv_io_srv_conn_info_1(char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth);
-void srv_io_srv_conn_ctr(char *desc, SRV_CONN_INFO_CTR *ctr, prs_struct *ps, int depth);
-void make_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n,
- char *srv_name, char *qual_name,
- uint32 conn_level, SRV_CONN_INFO_CTR *ctr,
- uint32 preferred_len,
- ENUM_HND *hnd);
-void srv_io_q_net_conn_enum(char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth);
-void srv_io_r_net_conn_enum(char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth);
-void make_srv_file_info3_str(FILE_INFO_3_STR *fi3, char *user_name, char *path_name);
-void srv_io_file_info3_str(char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth);
-void make_srv_file_info3(FILE_INFO_3 *fl3,
- uint32 id, uint32 perms, uint32 num_locks,
- char *path_name, char *user_name);
-void srv_io_file_info3(char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth);
-void srv_io_srv_file_info_3(char *desc, SRV_FILE_INFO_3 *fl3, prs_struct *ps, int depth);
-void srv_io_srv_file_ctr(char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth);
-void make_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n,
- char *srv_name, char *qual_name,
- uint32 file_level, SRV_FILE_INFO_CTR *ctr,
- uint32 preferred_len,
- ENUM_HND *hnd);
-void srv_io_q_net_file_enum(char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth);
-void srv_io_r_net_file_enum(char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth);
-void make_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, char *name,
- uint32 ver_major, uint32 ver_minor,
- uint32 srv_type, char *comment);
-void srv_io_info_101(char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth);
-void make_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, char *name,
- char *comment, uint32 ver_major, uint32 ver_minor,
- uint32 srv_type, uint32 users, uint32 disc, uint32 hidden,
- uint32 announce, uint32 ann_delta, uint32 licenses,
- char *usr_path);
-void srv_io_info_102(char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth);
-void srv_io_info_ctr(char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth);
-void make_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv,
- char *server_name, uint32 switch_value);
-void srv_io_q_net_srv_get_info(char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth);
-void make_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv,
- uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status);
-void srv_io_r_net_srv_get_info(char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth);
-void make_srv_q_net_srv_set_info(SRV_Q_NET_SRV_SET_INFO *srv,
- uint32 switch_value, SRV_INFO_CTR *ctr);
-void srv_io_q_net_srv_set_info(char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, prs_struct *ps, int depth);
-void make_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv,
- uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status);
-void srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/parse/parse_wks.c */
-
-void make_wks_q_query_info(WKS_Q_QUERY_INFO *q_u,
- char *server, uint16 switch_value) ;
-void wks_io_q_query_info(char *desc, WKS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth);
-void make_wks_info_100(WKS_INFO_100 *inf,
- uint32 platform_id, uint32 ver_major, uint32 ver_minor,
- char *my_name, char *domain_name);
-void wks_io_wks_info_100(char *desc, WKS_INFO_100 *inf, prs_struct *ps, int depth);
-void make_wks_r_query_info(WKS_R_QUERY_INFO *r_u,
- uint32 switch_value, WKS_INFO_100 *wks100,
- int status) ;
-void wks_io_r_query_info(char *desc, WKS_R_QUERY_INFO *r_u, prs_struct *ps, int depth);
-
-/*The following definitions come from lib/rpc/server/srv_ldap_helpers.c */
-
-BOOL get_ldap_entries(SAM_USER_INFO_21 *pw_buf,
- int *total_entries, int *num_entries,
- int max_num_entries,
- uint16 acb_mask, int switch_level);
-BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid);
-void ldap_helper_dummy(void);
-
-/*The following definitions come from lib/rpc/server/srv_lsa.c */
-
-BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data);
-
-/*The following definitions come from lib/rpc/server/srv_lsa_hnd.c */
-
-void create_pol_hnd(POLICY_HND *hnd);
-void init_lsa_policy_hnd(void);
-BOOL open_lsa_policy_hnd(POLICY_HND *hnd);
-int find_lsa_policy_by_hnd(POLICY_HND *hnd);
-BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid);
-BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status);
-BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid);
-uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd);
-BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name);
-BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name);
-BOOL close_lsa_policy_hnd(POLICY_HND *hnd);
-
-/*The following definitions come from lib/rpc/server/srv_netlog.c */
-
-BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data);
-
-/*The following definitions come from lib/rpc/server/srv_pipe_hnd.c */
-
-void reset_chain_pnum(void);
-void set_chain_pnum(int new_pnum);
-void init_rpc_pipe_hnd(void);
-int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid);
-int read_pipe(uint16 pnum, char *data, uint32 pos, int n);
-BOOL get_rpc_pipe(int pnum, pipes_struct **p);
-char *get_rpc_pipe_hnd_name(int pnum);
-BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state);
-BOOL close_rpc_pipe_hnd(int pnum, int cnum);
-int get_rpc_pipe_num(char *buf, int where);
-
-/*The following definitions come from lib/rpc/server/srv_reg.c */
-
-BOOL api_reg_rpc(pipes_struct *p, prs_struct *data);
-
-/*The following definitions come from lib/rpc/server/srv_samr.c */
-
-BOOL api_samr_rpc(pipes_struct *p, prs_struct *data);
-
-/*The following definitions come from lib/rpc/server/srv_srvsvc.c */
-
-BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data);
-
-/*The following definitions come from lib/rpc/server/srv_util.c */
-
-int make_dom_gids(char *gids_str, DOM_GID *gids);
-void get_domain_user_groups(char *domain_groups, char *user);
-BOOL create_rpc_reply(pipes_struct *p,
- uint32 data_start, uint32 data_end);
-BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds,
- prs_struct *data);
-uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type);
-uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type);
-uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type);
-uint32 lookup_group_rid(char *group_name, uint32 *rid);
-uint32 lookup_alias_rid(char *alias_name, uint32 *rid);
-uint32 lookup_user_rid(char *user_name, uint32 *rid);
-BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid);
-uint32 uid_to_user_rid(uint32 uid);
-uint32 gid_to_group_rid(uint32 gid);
-
-/*The following definitions come from lib/rpc/server/srv_wkssvc.c */
-
-BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data);
-
/*The following definitions come from loadparm.c */
char *lp_string(char *s);
@@ -961,11 +261,6 @@ char *lp_domain_admin_users(void);
char *lp_domain_guest_users(void);
char *lp_domain_hostsallow(void);
char *lp_domain_hostsdeny(void);
-char *lp_ldap_server(void);
-char *lp_ldap_suffix(void);
-char *lp_ldap_filter(void);
-char *lp_ldap_root(void);
-char *lp_ldap_rootpasswd(void);
BOOL lp_dns_proxy(void);
BOOL lp_wins_support(void);
BOOL lp_we_are_a_wins_server(void);
@@ -1019,7 +314,6 @@ int lp_client_code_page(void);
int lp_announce_as(void);
int lp_lm_announce(void);
int lp_lm_interval(void);
-int lp_ldap_port(void);
char *lp_preexec(int );
char *lp_postexec(int );
char *lp_rootpreexec(int );
@@ -1100,16 +394,15 @@ 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);
-void *lp_local_ptr(int snum, void *ptr);
BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue);
-BOOL lp_is_default(int snum, struct parm_struct *parm);
-struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
+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, BOOL save_defaults, BOOL add_ipc);
+BOOL lp_load(char *pszFname,BOOL global_only);
int lp_numservices(void);
-void lp_dump(FILE *f, BOOL show_defaults);
+void lp_dump(FILE *f);
int lp_servicenumber(char *pszServiceName);
char *volume_label(int snum);
void lp_rename_service(int snum, char *new_name);
@@ -1147,13 +440,13 @@ struct share_ops *locking_slow_init(int ronly);
/*The following definitions come from mangle.c */
+int str_checksum(char *s);
+BOOL is_8_3(char *fname, BOOL check_case);
+void reset_mangled_stack( int size );
+BOOL check_mangled_stack(char *s);
BOOL is_mangled( char *s );
-BOOL is_8_3( char *fname, BOOL check_case );
-int str_checksum( char *s );
-void reset_mangled_cache( void );
-BOOL check_mangled_cache( char *s );
-void mangle_name_83( char *s );
-BOOL name_map_mangle( char *OutName, BOOL need83, int snum );
+void mangle_name_83(char *s);
+BOOL name_map_mangle(char *OutName,BOOL need83,int snum);
/*The following definitions come from md4.c */
@@ -1174,24 +467,6 @@ void smb_mem_write_errors(FILE *outfile);
void smb_mem_set_multiplier(int multiplier);
void *smb_mem_resize(void *ptr,size_t newsize);
-/*The following definitions come from membuffer.c */
-
-void mem_init(struct mem_buf *buf, int margin);
-void mem_create(struct mem_buf *buf, char *data, int size, int margin, BOOL dynamic);
-void mem_take(struct mem_buf *mem_to, struct mem_buf *mem_from);
-BOOL mem_alloc_data(struct mem_buf *buf, int size);
-BOOL mem_buf_copy(char *copy_into, struct mem_buf *buf,
- uint32 offset, uint32 len);
-BOOL mem_buf_init(struct mem_buf **buf, uint32 margin);
-void mem_buf_free(struct mem_buf **buf);
-void mem_free_chain(struct mem_buf **buf);
-void mem_free_data(struct mem_buf *buf);
-BOOL mem_realloc_data(struct mem_buf *buf, int new_size);
-BOOL mem_grow_data(struct mem_buf **buf, BOOL io, int new_size, BOOL force_grow);
-BOOL mem_find(struct mem_buf **buf, uint32 offset);
-uint32 mem_buf_len(struct mem_buf *buf);
-char *mem_data(struct mem_buf **buf, uint32 offset);
-
/*The following definitions come from message.c */
int reply_sends(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
@@ -1204,8 +479,9 @@ int reply_sendend(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
struct in_addr to_ip,char *master,char *rname,
void (*fn)(struct packet_struct *));
-struct in_addr *name_query(int fd,char *name,int name_type, BOOL bcast,BOOL recurse,
- struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *));
+struct in_addr *name_query(int fd,char *name,int name_type,
+ BOOL bcast,BOOL recurse, struct in_addr to_ip,
+ int *count, void (*fn)(struct packet_struct *));
FILE *startlmhosts(char *fname);
BOOL getlmhostsent( FILE *fp, char *name, int *name_type, struct in_addr *ipaddr);
void endlmhosts(FILE *fp);
@@ -1548,9 +824,10 @@ BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
BOOL send_packet(struct packet_struct *p);
struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
-/*The following definitions come from nterr.c */
+/*The following definitions come from ntclient.c */
-char *get_nt_error_msg(uint32 nt_code);
+BOOL do_nt_login(char *desthost, char *myhostname,
+ int Client, int cnum);
/*The following definitions come from params.c */
@@ -1558,37 +835,20 @@ BOOL pm_process( char *FileName,
BOOL (*sfunc)(char *),
BOOL (*pfunc)(char *, char *) );
-/*The following definitions come from passdb.c */
-
-struct smb_passwd *getsampwnam(char *name);
-struct smb_passwd *getsampwuid(unsigned int uid);
-void *startsampwent(BOOL update);
-void endsampwent(void *vp);
-struct smb_passwd *getsampwent(void *vp);
-unsigned long getsampwpos(void *vp);
-BOOL setsampwpos(void *vp, unsigned long tok);
-BOOL add_sampwd_entry(struct smb_passwd *newpwd);
-BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override);
-
/*The following definitions come from password.c */
void generate_next_challenge(char *challenge);
BOOL set_challenge(char *challenge);
-BOOL last_challenge(unsigned char *challenge);
+BOOL last_challenge(char *challenge);
user_struct *get_valid_user_struct(uint16 vuid);
void invalidate_vuid(uint16 vuid);
char *validated_username(uint16 vuid);
-int setup_groups(char *user, int uid, int gid, int *p_ngroups,
- int **p_igroups, gid_t **p_groups,
- int **p_attrs);
uint16 register_vuid(int uid,int gid, char *unix_name, char *requested_name, BOOL guest);
void add_session_user(char *user);
-BOOL update_smbpassword_file( char *user, fstring password);
+BOOL update_smbpassword_file( struct passwd *pass, fstring password);
void dfs_unlogin(void);
BOOL password_check(char *password);
BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned char *c8);
-BOOL smb_password_ok(struct smb_passwd *smb_pass,
- uchar lm_pass[24], uchar nt_pass[24]);
BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd);
BOOL user_ok(char *user,int snum);
BOOL authorise_login(int snum,char *user,char *password, int pwlen,
@@ -1599,25 +859,21 @@ struct cli_state *server_cryptkey(void);
BOOL server_validate(char *user, char *domain,
char *pass, int passlen,
char *ntpass, int ntpasslen);
-BOOL domain_client_validate( char *user, char *domain,
- char *smb_apasswd, int smb_apasslen,
- char *smb_ntpasswd, int smb_ntpasslen);
/*The following definitions come from pcap.c */
BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname);
-void pcap_printer_fn(void (*fn)(char *, char *));
-
-/*The following definitions come from pidfile.c */
-
-void pidfile_create(char *name);
-int pidfile_pid(char *name);
+void pcap_printer_fn(void (*fn)(char *, char*));
/*The following definitions come from pipes.c */
int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
int reply_pipe_close(char *inbuf,char *outbuf);
+BOOL api_LsarpcSNPHS(int pnum, int cnum, char *param);
+BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len);
/*The following definitions come from predict.c */
@@ -1663,10 +919,10 @@ int reply_special(char *inbuf,char *outbuf);
int reply_tcon(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize);
int reply_unknown(char *inbuf,char *outbuf);
-int reply_ioctl(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_ioctl(char *inbuf,char *outbuf, int size, int bufsize);
int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize);
int reply_chkpth(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_getatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_getatr(char *inbuf,char *outbuf, int in_size, int buffsize);
int reply_setatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_dskattr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_search(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
@@ -1676,40 +932,315 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize);
int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize);
int reply_mknew(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_ctemp(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_bufsize);
int reply_readbraw(char *inbuf, char *outbuf, int dum_size, int dum_buffsize);
-int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz);
+int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_read(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize);
+int reply_writeunlock(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_write(char *inbuf,char *outbuf,int dum1,int dum2);
int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_lseek(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_unlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_tdis(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_echo(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printopen(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_mkdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_rmdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_setdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_lseek(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_flush(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_exit(char *inbuf,char *outbuf, int size, int bufsize);
+int reply_close(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_writeclose(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_lock(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_unlock(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_tdis(char *inbuf,char *outbuf, int size, int bufsize);
+int reply_echo(char *inbuf,char *outbuf, int size, int bufsize);
+int reply_printopen(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_printclose(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_printqueue(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_printwrite(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_mkdir(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_rmdir(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_mv(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_copy(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_setdir(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize);
int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize);
-int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
-int reply_setattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+int reply_writebmpx(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_writebs(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
+int reply_setattrE(char *inbuf,char *outbuf,int dum_size, int dum_buffsize);
int reply_getattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize);
+/*The following definitions come from rpc_pipes/lsa_hnd.c */
+
+void init_lsa_policy_hnd(void);
+BOOL open_lsa_policy_hnd(LSA_POL_HND *hnd);
+BOOL set_lsa_policy_samr_rid(LSA_POL_HND *hnd, uint32 rid);
+BOOL set_lsa_policy_samr_pol_status(LSA_POL_HND *hnd, uint32 pol_status);
+BOOL set_lsa_policy_samr_sid(LSA_POL_HND *hnd, DOM_SID *sid);
+uint32 get_lsa_policy_samr_rid(LSA_POL_HND *hnd);
+BOOL close_lsa_policy_hnd(LSA_POL_HND *hnd);
+
+/*The following definitions come from rpc_pipes/lsaparse.c */
+
+void make_q_open_pol(LSA_Q_OPEN_POL *r_q, char *server_name,
+ uint32 attributes, uint32 sec_qos,
+ uint16 desired_access);
+char* lsa_io_q_open_pol(BOOL io, LSA_Q_OPEN_POL *r_q, char *q, char *base, int align, int depth);
+char* lsa_io_r_open_pol(BOOL io, LSA_R_OPEN_POL *r_p, char *q, char *base, int align, int depth);
+void make_q_query(LSA_Q_QUERY_INFO *q_q, LSA_POL_HND *hnd, uint16 info_class);
+char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align, int depth);
+char* lsa_io_q_enum_trust_dom(BOOL io, LSA_Q_ENUM_TRUST_DOM *q_e, char *q, char *base, int align, int depth);
+void make_r_enum_trust_dom(LSA_R_ENUM_TRUST_DOM *r_e, LSA_POL_HND *hnd, uint32 status);
+char* lsa_io_r_enum_trust_dom(BOOL io, LSA_R_ENUM_TRUST_DOM *r_e, char *q, char *base, int align, int depth);
+void make_q_close(LSA_Q_CLOSE *q_c, LSA_POL_HND *hnd);
+char* lsa_io_q_close(BOOL io, LSA_Q_CLOSE *q_c, char *q, char *base, int align, int depth);
+void make_r_close(LSA_R_CLOSE *q_r, LSA_POL_HND *hnd);
+char* lsa_io_r_close(BOOL io, LSA_R_CLOSE *r_c, char *q, char *base, int align, int depth);
+char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align, int depth);
+char* lsa_io_q_lookup_sids(BOOL io, LSA_Q_LOOKUP_SIDS *q_s, char *q, char *base, int align, int depth);
+char* lsa_io_r_lookup_sids(BOOL io, LSA_R_LOOKUP_SIDS *r_s, char *q, char *base, int align, int depth);
+char* lsa_io_q_lookup_rids(BOOL io, LSA_Q_LOOKUP_RIDS *q_r, char *q, char *base, int align, int depth);
+char* lsa_io_r_lookup_rids(BOOL io, LSA_R_LOOKUP_RIDS *r_r, char *q, char *base, int align, int depth);
+void make_q_req_chal(LSA_Q_REQ_CHAL *q_c,
+ char *logon_srv, char *logon_clnt,
+ DOM_CHAL *clnt_chal);
+char* lsa_io_q_req_chal(BOOL io, LSA_Q_REQ_CHAL *q_c, char *q, char *base, int align, int depth);
+char* lsa_io_r_req_chal(BOOL io, LSA_R_REQ_CHAL *r_c, char *q, char *base, int align, int depth);
+void make_q_auth_2(LSA_Q_AUTH_2 *q_a,
+ char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name,
+ DOM_CHAL *clnt_chal, uint32 clnt_flgs);
+char* lsa_io_q_auth_2(BOOL io, LSA_Q_AUTH_2 *q_a, char *q, char *base, int align, int depth);
+char* lsa_io_r_auth_2(BOOL io, LSA_R_AUTH_2 *r_a, char *q, char *base, int align, int depth);
+void make_q_srv_pwset(LSA_Q_SRV_PWSET *q_s, char sess_key[8],
+ char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name,
+ DOM_CRED *cred, char nt_cypher[16]);
+char* lsa_io_q_srv_pwset(BOOL io, LSA_Q_SRV_PWSET *q_s, char *q, char *base, int align, int depth);
+char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int align, int depth);
+char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int align, int depth);
+char* lsa_io_q_sam_logon(BOOL io, LSA_Q_SAM_LOGON *q_l, char *q, char *base, int align, int depth);
+char* lsa_io_r_sam_logon(BOOL io, LSA_R_SAM_LOGON *r_l, char *q, char *base, int align, int depth);
+char* lsa_io_q_sam_logoff(BOOL io, LSA_Q_SAM_LOGOFF *q_l, char *q, char *base, int align, int depth);
+char* lsa_io_r_sam_logoff(BOOL io, LSA_R_SAM_LOGOFF *r_l, char *q, char *base, int align, int depth);
+
+/*The following definitions come from rpc_pipes/ntclientlsa.c */
+
+BOOL do_lsa_open_policy(uint16 fnum, uint32 call_id,
+ char *server_name, LSA_POL_HND *hnd);
+BOOL do_lsa_query_info_pol(uint16 fnum, uint32 call_id,
+ LSA_POL_HND *hnd, uint16 info_class,
+ fstring domain_name, pstring domain_sid);
+BOOL do_lsa_close(uint16 fnum, uint32 call_id,
+ LSA_POL_HND *hnd);
+
+/*The following definitions come from rpc_pipes/ntclientnet.c */
+
+BOOL do_lsa_req_chal(uint16 fnum, uint32 call_id,
+ char *desthost, char *myhostname,
+ DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal);
+BOOL do_lsa_auth2(uint16 fnum, uint32 call_id,
+ char *logon_srv, char *acct_name, uint16 sec_chan, char *comp_name,
+ DOM_CHAL *clnt_chal, uint32 neg_flags, DOM_CHAL *srv_chal);
+BOOL do_lsa_srv_pwset(uint16 fnum, uint32 call_id,
+ uchar sess_key[8],
+ char *logon_srv, char *mach_acct, uint16 sec_chan_type, char *comp_name,
+ DOM_CRED *clnt_cred, DOM_CRED *srv_cred,
+ char nt_owf_new_mach_pwd[16]);
+BOOL do_lsa_sam_logon(uint16 fnum, uint32 call_id,
+ uchar sess_key[8], DOM_CRED *sto_clnt_cred,
+ char *logon_srv, char *comp_name,
+ DOM_CRED *clnt_cred, DOM_CRED *rtn_cred,
+ uint16 logon_level, uint16 switch_value, DOM_ID_INFO_1 *id1,
+ LSA_USER_INFO *user_info,
+ DOM_CRED *srv_cred);
+BOOL do_lsa_sam_logoff(uint16 fnum, uint32 call_id,
+ uchar sess_key[8], DOM_CRED *sto_clnt_cred,
+ char *logon_srv, char *comp_name,
+ DOM_CRED *clnt_cred, DOM_CRED *rtn_cred,
+ uint16 logon_level, uint16 switch_value, DOM_ID_INFO_1 *id1,
+ DOM_CRED *srv_cred);
+
+/*The following definitions come from rpc_pipes/ntclientpipe.c */
+
+uint16 rpc_pipe_open(char *inbuf, char *outbuf, char *rname, int Client, int cnum);
+BOOL rpc_pipe_set_hnd_state(char *pipe_name, uint16 fnum, uint16 device_state);
+BOOL rpc_pipe_bind(char *pipe_name, uint16 fnum, uint32 call_id,
+ RPC_IFACE *abstract, RPC_IFACE *transfer);
+
+/*The following definitions come from rpc_pipes/pipe_hnd.c */
+
+void reset_chain_pnum(void);
+void init_rpc_pipe_hnd(void);
+int open_rpc_pipe_hnd(char *pipe_name, int cnum);
+char *get_rpc_pipe_hnd_name(int pnum);
+BOOL set_rpc_pipe_hnd_state(int pnum, int cnum, uint16 device_state);
+BOOL close_rpc_pipe_hnd(int pnum, int cnum);
+int get_rpc_pipe_num(char *buf, int where);
+
+/*The following definitions come from rpc_pipes/pipenetlog.c */
+
+BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len);
+
+/*The following definitions come from rpc_pipes/pipentlsa.c */
+
+BOOL api_ntLsarpcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len);
+
+/*The following definitions come from rpc_pipes/pipesamr.c */
+
+BOOL api_samrTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len);
+
+/*The following definitions come from rpc_pipes/pipesrvsvc.c */
+
+BOOL api_srvsvcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len);
+
+/*The following definitions come from rpc_pipes/pipeutil.c */
+
+void initrpcreply(char *inbuf, char *q);
+void endrpcreply(char *inbuf, char *q, int datalen, int rtnval, int *rlen);
+BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid);
+char *dom_sid_to_string(DOM_SID *sid);
+int make_dom_sids(char *sids_str, DOM_SID *sids, int max_sids);
+int make_dom_gids(char *gids_str, DOM_GID *gids);
+int create_rpc_request(uint32 call_id, uint8 op_num, char *q, int data_len);
+int create_rpc_reply(uint32 call_id, char *q, int data_len);
+
+/*The following definitions come from rpc_pipes/pipewkssvc.c */
+
+BOOL api_wkssvcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len);
+
+/*The following definitions come from rpc_pipes/samrparse.c */
+
+char* samr_io_q_close(BOOL io, SAMR_Q_CLOSE *q_u, char *q, char *base, int align, int depth);
+char* samr_io_r_close(BOOL io, SAMR_R_CLOSE *r_u, char *q, char *base, int align, int depth);
+char* samr_io_q_open_secret(BOOL io, SAMR_Q_OPEN_SECRET *q_u, char *q, char *base, int align, int depth);
+char* samr_io_r_open_secret(BOOL io, SAMR_R_OPEN_SECRET *r_u, char *q, char *base, int align, int depth);
+char* samr_io_q_lookup_rids(BOOL io, SAMR_Q_LOOKUP_RIDS *q_u, char *q, char *base, int align, int depth);
+void make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
+ uint32 num_rids, uint32 rid, uint32 status);
+char* samr_io_r_lookup_rids(BOOL io, SAMR_R_LOOKUP_RIDS *r_u, char *q, char *base, int align, int depth);
+char* samr_io_q_unknown_22(BOOL io, SAMR_Q_UNKNOWN_22 *q_u, char *q, char *base, int align, int depth);
+char* samr_io_r_unknown_22(BOOL io, SAMR_R_UNKNOWN_22 *r_u, char *q, char *base, int align, int depth);
+char* samr_io_q_unknown_24(BOOL io, SAMR_Q_UNKNOWN_24 *q_u, char *q, char *base, int align, int depth);
+void make_samr_r_unknown_24(SAMR_R_UNKNOWN_24 *r_u,
+ uint16 unknown_0, NTTIME *expiry, char *mach_acct,
+ uint32 unknown_id_0, uint32 status);
+char* samr_io_r_unknown_24(BOOL io, SAMR_R_UNKNOWN_24 *r_u, char *q, char *base, int align, int depth);
+char* samr_io_q_unknown_32(BOOL io, SAMR_Q_UNKNOWN_32 *q_u, char *q, char *base, int align, int depth);
+char* samr_io_r_unknown_32(BOOL io, SAMR_R_UNKNOWN_32 *r_u, char *q, char *base, int align, int depth);
+char* samr_io_q_open_policy(BOOL io, SAMR_Q_OPEN_POLICY *q_u, char *q, char *base, int align, int depth);
+char* samr_io_r_open_policy(BOOL io, SAMR_R_OPEN_POLICY *r_u, char *q, char *base, int align, int depth);
+
+/*The following definitions come from rpc_pipes/smbparse.c */
+
+char* smb_io_utime(BOOL io, UTIME *t, char *q, char *base, int align, int depth);
+char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align, int depth);
+void make_dom_sid(DOM_SID *sid, char *domsid);
+char* smb_io_dom_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align, int depth);
+void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint16 terminate);
+char* smb_io_unihdr(BOOL io, UNIHDR *hdr, char *q, char *base, int align, int depth);
+void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate);
+char* smb_io_unihdr2(BOOL io, UNIHDR2 *hdr2, char *q, char *base, int align, int depth);
+void make_unistr(UNISTR *str, char *buf);
+char* smb_io_unistr(BOOL io, UNISTR *uni, char *q, char *base, int align, int depth);
+void make_unistr2(UNISTR2 *str, char *buf, int len);
+char* smb_io_unistr2(BOOL io, UNISTR2 *uni2, char *q, char *base, int align, int depth);
+void make_dom_sid2(DOM_SID2 *sid2, char *sid_str);
+char* smb_io_dom_sid2(BOOL io, DOM_SID2 *sid2, char *q, char *base, int align, int depth);
+void make_dom_rid2(DOM_RID2 *rid2, uint32 rid);
+char* smb_io_dom_rid2(BOOL io, DOM_RID2 *rid2, char *q, char *base, int align, int depth);
+void make_dom_rid3(DOM_RID3 *rid3, uint32 rid);
+char* smb_io_dom_rid3(BOOL io, DOM_RID3 *rid3, char *q, char *base, int align, int depth);
+void make_clnt_srv(DOM_CLNT_SRV *log, char *logon_srv, char *comp_name);
+char* smb_io_clnt_srv(BOOL io, DOM_CLNT_SRV *log, char *q, char *base, int align, int depth);
+void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
+ uint16 sec_chan, char *comp_name);
+char* smb_io_log_info(BOOL io, DOM_LOG_INFO *log, char *q, char *base, int align, int depth);
+char* smb_io_chal(BOOL io, DOM_CHAL *chal, char *q, char *base, int align, int depth);
+char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align, int depth);
+void make_clnt_info2(DOM_CLNT_INFO2 *clnt,
+ char *logon_srv, char *comp_name,
+ DOM_CRED *clnt_cred);
+char* smb_io_clnt_info2(BOOL io, DOM_CLNT_INFO2 *clnt, char *q, char *base, int align, int depth);
+char* make_clnt_info(DOM_CLNT_INFO *clnt,
+ char *logon_srv, char *acct_name,
+ uint16 sec_chan, char *comp_name,
+ DOM_CRED *cred);
+char* smb_io_clnt_info(BOOL io, DOM_CLNT_INFO *clnt, char *q, char *base, int align, int depth);
+void make_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high);
+char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align, int depth);
+void make_arc4_owf(ARC4_OWF *hash, char data[16]);
+char* smb_io_arc4_owf(BOOL io, ARC4_OWF *hash, char *q, char *base, int align, int depth);
+void make_id_info1(DOM_ID_INFO_1 *id, char *domain_name,
+ uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
+ char *user_name, char *wksta_name,
+ char *sess_key,
+ unsigned char lm_cypher[16], unsigned char nt_cypher[16]);
+char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align, int depth);
+void make_sam_info(DOM_SAM_INFO *sam,
+ char *logon_srv, char *comp_name, DOM_CRED *clnt_cred,
+ DOM_CRED *rtn_cred, uint16 logon_level, uint16 switch_value,
+ DOM_ID_INFO_1 *id1);
+char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align, int depth);
+char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align, int depth);
+void make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 frag,
+ uint32 call_id, int data_len);
+char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align, int depth);
+void make_rpc_iface(RPC_IFACE *ifc, char data[16], uint32 version);
+char* smb_io_rpc_iface(BOOL io, RPC_IFACE *ifc, char *q, char *base, int align, int depth);
+void make_rpc_addr_str(RPC_ADDR_STR *str, char *name);
+char* smb_io_rpc_addr_str(BOOL io, RPC_ADDR_STR *str, char *q, char *base, int align, int depth);
+void make_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid);
+char* smb_io_rpc_hdr_bba(BOOL io, RPC_HDR_BBA *rpc, char *q, char *base, int align, int depth);
+void make_rpc_hdr_rb(RPC_HDR_RB *rpc,
+ uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
+ uint32 num_elements, uint16 context_id, uint8 num_syntaxes,
+ RPC_IFACE *abstract, RPC_IFACE *transfer);
+char* smb_io_rpc_hdr_rb(BOOL io, RPC_HDR_RB *rpc, char *q, char *base, int align, int depth);
+void make_rpc_results(RPC_RESULTS *res,
+ uint8 num_results, uint16 result, uint16 reason);
+char* smb_io_rpc_results(BOOL io, RPC_RESULTS *res, char *q, char *base, int align, int depth);
+void make_rpc_hdr_ba(RPC_HDR_BA *rpc,
+ uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
+ char *pipe_addr,
+ uint8 num_results, uint16 result, uint16 reason,
+ RPC_IFACE *transfer);
+char* smb_io_rpc_hdr_ba(BOOL io, RPC_HDR_BA *rpc, char *q, char *base, int align, int depth);
+void make_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, uint32 sec_qos);
+char* smb_io_obj_attr(BOOL io, LSA_OBJ_ATTR *attr, char *q, char *base, int align, int depth);
+void make_rpc_hdr_rr(RPC_HDR_RR *hdr, enum RPC_PKT_TYPE pkt_type,
+ uint32 call_id, int data_len, uint8 opnum);
+char* smb_io_rpc_hdr_rr(BOOL io, RPC_HDR_RR *rpc, char *q, char *base, int align, int depth);
+char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align, int depth);
+char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align, int depth);
+char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align, int depth);
+char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align, int depth);
+char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align, int depth);
+char* smb_io_dom_name(BOOL io, DOM_NAME *name, char *q, char *base, int align, int depth);
+char* smb_io_neg_flags(BOOL io, NEG_FLAGS *neg, char *q, char *base, int align, int depth);
+
+/*The following definitions come from rpc_pipes/srvparse.c */
+
+char* srv_io_share_info1_str(BOOL io, SH_INFO_1_STR *sh1, char *q, char *base, int align, int depth);
+char* srv_io_share_info1(BOOL io, SH_INFO_1 *sh1, char *q, char *base, int align, int depth);
+char* srv_io_share_1_ctr(BOOL io, SHARE_INFO_1_CTR *ctr, char *q, char *base, int align, int depth);
+char* srv_io_q_net_share_enum(BOOL io, SRV_Q_NET_SHARE_ENUM *q_n, char *q, char *base, int align, int depth);
+char* srv_io_r_net_share_enum(BOOL io, SRV_R_NET_SHARE_ENUM *r_n, char *q, char *base, int align, int depth);
+
+/*The following definitions come from rpc_pipes/wksparse.c */
+
+char* wks_io_q_unknown_0(BOOL io, WKS_Q_UNKNOWN_0 *q_u, char *q, char *base, int align, int depth);
+char* wks_io_r_unknown_0(BOOL io, WKS_R_UNKNOWN_0 *r_u, char *q, char *base, int align, int depth);
+
/*The following definitions come from server.c */
void *dflt_sig(void);
@@ -1744,6 +1275,9 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
BOOL receive_next_smb(int smbfd, int oplockfd, char *inbuf, int bufsize, int timeout);
BOOL snum_used(int snum);
BOOL reload_services(BOOL test);
+int setup_groups(char *user, int uid, int gid, int *p_ngroups,
+ int **p_igroups, gid_t **p_groups,
+ int **p_attrs);
int make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid);
int find_free_file(void );
int reply_corep(char *outbuf);
@@ -1752,6 +1286,8 @@ int reply_lanman1(char *outbuf);
int reply_lanman2(char *outbuf);
int reply_nt1(char *outbuf);
void close_cnum(int cnum, uint16 vuid);
+BOOL yield_connection(int cnum,char *name,int max_connections);
+BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
void exit_server(char *reason);
void standard_sub(int cnum,char *str);
char *smb_fn_name(int type);
@@ -1774,7 +1310,6 @@ void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out);
void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key);
void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key);
-void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw);
void SamOEMhash( unsigned char *data, unsigned char *key, int val);
/*The following definitions come from smbencrypt.c */
@@ -1790,21 +1325,11 @@ char *smb_errstr(char *inbuf);
/*The following definitions come from smbpass.c */
-void *startsmbpwent(BOOL update);
-void endsmbpwent(void *vp);
-struct smb_passwd *getsmbpwent(void *vp);
-unsigned long getsmbpwpos(void *vp);
-BOOL setsmbpwpos(void *vp, unsigned long tok);
-struct smb_passwd *getsmbpwnam(char *name);
-struct smb_passwd *getsmbpwuid(unsigned int uid);
-char *encode_acct_ctrl(uint16 acct_ctrl);
-BOOL add_smbpwd_entry(struct smb_passwd *newpwd);
+int pw_file_lock(char *name, int type, int secs);
+int pw_file_unlock(int fd);
+struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid);
+BOOL add_smbpwd_entry(struct smb_passwd* pwd);
BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override);
-BOOL machine_password_lock( char *domain, char *name, BOOL update);
-BOOL machine_password_unlock(void);
-BOOL machine_password_delete( char *domain, char *name );
-BOOL get_machine_account_password( unsigned char *ret_pwd, time_t *pass_last_set_time);
-BOOL set_machine_account_password( unsigned char *md4_new_pwd);
/*The following definitions come from snprintf.c */
@@ -1854,7 +1379,6 @@ 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);
-char *http_timestring(time_t t);
char *timestring(void );
time_t get_create_time(struct stat *st,BOOL fake_dirs);
@@ -1865,6 +1389,9 @@ int reply_findnclose(char *inbuf,char *outbuf,int length,int bufsize);
int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize);
int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize);
+/*The following definitions come from ubiqx/ubi_dLinkList.c */
+
+
/*The following definitions come from ufc.c */
char *ufc_crypt(char *key,char *salt);
@@ -1994,8 +1521,8 @@ uint32 interpret_addr(char *str);
struct in_addr *interpret_addr2(char *str);
BOOL zero_ip(struct in_addr ip);
void reset_globals_after_fork(void);
-char *client_name(int fd);
-char *client_addr(int fd);
+char *client_name(void);
+char *client_addr(void);
char *automount_server(char *user_name);
char *automount_path(char *user_name);
void standard_sub_basic(char *str);
@@ -2032,44 +1559,3 @@ char *align_offset(char *q, char *base, int align_offset_len);
void print_asc(int level, unsigned char *buf,int len);
void dump_data(int level,char *buf1,int len);
char *tab_depth(int depth);
-char *dom_sid_to_string(DOM_SID *sid);
-int gethexpwd(char *p, char *pwd);
-
-/*The following definitions come from web/cgi.c */
-
-void cgi_load_variables(FILE *f1);
-char *cgi_variable(char *name);
-char *cgi_vnum(int i, char **name);
-int cgi_boolean(char *name, int def);
-char *quotedup(char *s);
-char *urlquote(char *s);
-char *quotequotes(char *s);
-void quote_spaces(char *buf);
-void cgi_setup(char *rootdir, int auth_required);
-char *cgi_baseurl(void);
-char *cgi_rooturl(void);
-char *cgi_pathinfo(void);
-char *cgi_remote_host(void);
-char *cgi_remote_addr(void);
-BOOL cgi_waspost(void);
-
-/*The following definitions come from web/diagnose.c */
-
-BOOL nmbd_running(void);
-BOOL smbd_running(void);
-
-/*The following definitions come from web/startstop.c */
-
-void start_smbd(void);
-void start_nmbd(void);
-void stop_smbd(void);
-void stop_nmbd(void);
-void kill_pid(int pid);
-
-/*The following definitions come from web/statuspage.c */
-
-void status_page(void);
-
-/*The following definitions come from web/swat.c */
-
-int main(int argc, char *argv[]);
diff --git a/source/include/smb.h b/source/include/smb.h
index d8fe5a84f7b..527160be2ad 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -36,11 +36,6 @@
#define BOOLSTR(b) ((b) ? "Yes" : "No")
#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
-
-#define IS_BITS_SET_ALL(var,bit) (((var)&(bit))==(bit))
-#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0)
-#define IS_BITS_CLR_ALL(var,bit) (((var)&(~(bit)))==0)
-
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
typedef int BOOL;
@@ -237,8 +232,6 @@ implemented */
typedef char pstring[1024];
typedef char fstring[128];
-typedef fstring string;
-
/* pipe strings */
#define PIPE_LANMAN "\\PIPE\\LANMAN"
@@ -251,20 +244,18 @@ typedef fstring string;
#define PIPE_LSASS "\\PIPE\\lsass"
#define PIPE_LSARPC "\\PIPE\\lsarpc"
-
-/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
-typedef struct nttime_info
+/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
+typedef struct time_info
{
- uint32 low;
- uint32 high;
+ uint32 time;
-} NTTIME;
+} UTIME;
-/* Allowable account control bits */
+/* Allowable account control bits */
#define ACB_DISABLED 0x0001 /* 1 = User account disabled */
#define ACB_HOMDIRREQ 0x0002 /* 1 = Home directory required */
#define ACB_PWNOTREQ 0x0004 /* 1 = User password not required */
-#define ACB_TEMPDUP 0x0008 /* 1 = Temporary duplicate account */
+#define ACB_TEMPDUP 0x0008 /* 1 = Temporary duplicate account */
#define ACB_NORMAL 0x0010 /* 1 = Normal user account */
#define ACB_MNS 0x0020 /* 1 = MNS logon user account */
#define ACB_DOMTRUST 0x0040 /* 1 = Interdomain trust account */
@@ -272,114 +263,41 @@ typedef struct nttime_info
#define ACB_SVRTRUST 0x0100 /* 1 = Server trust account */
#define ACB_PWNOEXP 0x0200 /* 1 = User password does not expire */
#define ACB_AUTOLOCK 0x0400 /* 1 = Account auto locked */
-
-#define MAX_HOURS_LEN 32
-
-struct sam_passwd
-{
- time_t logon_time; /* logon time */
- time_t logoff_time; /* logoff time */
- time_t kickoff_time; /* kickoff time */
- time_t pass_last_set_time; /* password last set time */
- time_t pass_can_change_time; /* password can change time */
- time_t pass_must_change_time; /* password must change time */
-
- char *smb_name; /* username string */
- char *full_name; /* user's full name string */
- char *home_dir; /* home directory string */
- char *dir_drive; /* home directory drive string */
- char *logon_script; /* logon script string */
- char *profile_path; /* profile path string */
- char *acct_desc ; /* user description string */
- char *workstations; /* login from workstations string */
- char *unknown_str ; /* don't know what this is, yet. */
- char *munged_dial ; /* munged path name and dial-back tel number */
-
- int smb_userid; /* this is actually the unix uid_t */
- int smb_grpid; /* this is actually the unix gid_t */
- uint32 user_rid; /* Primary User ID */
- uint32 group_rid; /* Primary Group ID */
-
- unsigned char *smb_passwd; /* Null if no password */
- unsigned char *smb_nt_passwd; /* Null if no password */
-
- uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
- uint32 unknown_3; /* 0x00ff ffff */
-
- uint16 logon_divs; /* 168 - number of hours in a week */
- uint32 hours_len; /* normally 21 bytes */
- uint8 hours[MAX_HOURS_LEN];
-
- uint32 unknown_5; /* 0x0002 0000 */
- uint32 unknown_6; /* 0x0000 04ec */
-};
struct smb_passwd
{
- int smb_userid; /* this is actually the unix uid_t */
- char *smb_name; /* username string */
-
+ int smb_userid;
+ char *smb_name;
unsigned char *smb_passwd; /* Null if no password */
unsigned char *smb_nt_passwd; /* Null if no password */
-
- uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
- time_t pass_last_set_time; /* password last set time */
+ uint16 acct_ctrl;
+ /* Other fields / flags may be added later */
};
-
-/* DOM_CHAL - challenge info */
-typedef struct chal_info
-{
- uchar data[8]; /* credentials */
-} DOM_CHAL;
-
-/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
-typedef struct time_info
-{
- uint32 time;
-} UTIME;
-
-/* DOM_CREDs - timestamped client or server credentials */
-typedef struct cred_info
-{
- DOM_CHAL challenge; /* credentials */
- UTIME timestamp; /* credential time-stamp */
-} DOM_CRED;
-
struct cli_state {
- int fd;
- int cnum;
- int pid;
- int mid;
- int uid;
- int protocol;
- int sec_mode;
- int rap_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;
- /*
- * Only used in NT domain calls.
- */
- uint32 nt_error; /* NT RPC error code. */
- uint16 nt_pipe_fnum; /* Pipe handle. */
- unsigned char sess_key[16]; /* Current session key. */
- DOM_CRED clnt_cred; /* Client credential. */
- fstring mach_acct; /* MYNAME$. */
- fstring srv_name_slash; /* \\remote server. */
- fstring clnt_name_slash; /* \\local client. */
+ 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;
};
@@ -510,6 +428,22 @@ typedef struct
} connection_struct;
+/* NTDOMAIN defines needed here. */
+
+/* DOM_CHAL - challenge info */
+typedef struct chal_info
+{
+ uchar data[8]; /* credentials */
+} DOM_CHAL;
+
+/* DOM_CREDs - timestamped client or server credentials */
+typedef struct cred_info
+{
+ DOM_CHAL challenge; /* credentials */
+ UTIME timestamp; /* credential time-stamp */
+
+} DOM_CRED;
+
/* Domain controller authentication protocol info */
struct dcinfo
{
@@ -522,6 +456,8 @@ struct dcinfo
uchar md4pw[16]; /* md4(machine password) */
};
+/* End of NTDOMAIN defines needed here. */
+
typedef struct
{
int uid; /* uid of a validated user */
@@ -542,8 +478,10 @@ typedef struct
int n_sids;
int *sids;
+#ifdef NTDOMAIN
/* per-user authentication information on NT RPCs */
struct dcinfo dc;
+#endif /* NTDOMAIN */
} user_struct;
@@ -663,46 +601,6 @@ struct connection_options {
uint16 serverzone;
};
-/* the following are used by loadparm for option lists */
-typedef enum
-{
- P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
- P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM,P_SEP
-} parm_type;
-
-typedef enum
-{
- P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
-} parm_class;
-
-struct enum_list {
- int value;
- char *name;
-};
-
-struct parm_struct
-{
- char *label;
- parm_type type;
- parm_class class;
- void *ptr;
- BOOL (*special)(char *, char **);
- struct enum_list *enum_list;
- unsigned flags;
- union {
- BOOL bvalue;
- int ivalue;
- char *svalue;
- char cvalue;
- } def;
-};
-
-
-#define FLAG_BASIC 1 /* fundamental options */
-#define FLAG_HIDE 2 /* options that should be hidden in SWAT */
-#define FLAG_PRINT 4 /* printing options */
-#define FLAG_GLOBAL 8 /* local options that should be globally settable in SWAT */
-
#ifndef LOCKING_VERSION
#define LOCKING_VERSION 4
#endif /* LOCKING_VERSION */
@@ -937,31 +835,6 @@ struct parm_struct
#define smb_droff smb_vwv7
#define smb_drdisp smb_vwv8
-/* these are for the NT trans primary request. */
-#define smb_nt_MaxSetupCount smb_vwv0
-#define smb_nt_Flags (smb_vwv0 + 1)
-#define smb_nt_TotalParameterCount (smb_vwv0 + 3)
-#define smb_nt_TotalDataCount (smb_vwv0 + 7)
-#define smb_nt_MaxParameterCount (smb_vwv0 + 11)
-#define smb_nt_MaxDataCount (smb_vwv0 + 15)
-#define smb_nt_ParameterCount (smb_vwv0 + 19)
-#define smb_nt_ParameterOffset (smb_vwv0 + 23)
-#define smb_nt_DataCount (smb_vwv0 + 27)
-#define smb_nt_DataOffset (smb_vwv0 + 31)
-#define smb_nt_SetupCount (smb_vwv0 + 35)
-#define smb_nt_Function (smb_vwv0 + 36)
-#define smb_nt_SetupStart (smb_vwv0 + 39)
-
-/* these are for the NT trans secondary request. */
-#define smb_nts_TotalParameterCount (smb_vwv0 + 3)
-#define smb_nts_TotalDataCount (smb_vwv0 + 7)
-#define smb_nts_ParameterCount (smb_vwv0 + 11)
-#define smb_nts_ParameterOffset (smb_vwv0 + 15)
-#define smb_nts_ParameterDisplacement (smb_vwv0 + 19)
-#define smb_nts_DataCount (smb_vwv0 + 23)
-#define smb_nts_DataOffset (smb_vwv0 + 27)
-#define smb_nts_DataDisplacement (smb_vwv0 + 31)
-
/* where to find the base of the SMB packet proper */
#define smb_base(buf) (((char *)(buf))+4)
@@ -1110,14 +983,6 @@ char *Strstr(char *s, char *p);
#define BROWSER_ELECTION_VERSION 0x010f
#define BROWSER_CONSTANT 0xaa55
-/* NT Flags2 bits - cifs6.txt section 3.1.2 */
-
-#define FLAGS2_LONG_PATH_COMPONENTS 0x0001
-#define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
-#define FLAGS2_DFS_PATHNAMES 0x1000
-#define FLAGS2_READ_PERMIT_NO_EXECUTE 0x2000
-#define FLAGS2_32_BIT_ERROR_CODES 0x4000
-#define FLAGS2_UNICODE_STRINGS 0x8000
/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
@@ -1139,7 +1004,7 @@ char *Strstr(char *s, char *p);
enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
/* security levels */
-enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};
+enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
/* printing types */
enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
@@ -1219,8 +1084,12 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
extern int unix_ERR_class;
extern int unix_ERR_code;
+/***************************************************************
+ OPLOCK section.
+****************************************************************/
+
/*
- * Map the Core and Extended Oplock requesst bits down
+ * Map the Core and Extended Oplock request bits down
* to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
*/
@@ -1286,8 +1155,1058 @@ extern int unix_ERR_code;
#define CMD_REPLY 0x8000
-#endif /* _SMB_H */
+/***************************************************************
+ End of OPLOCK section.
+****************************************************************/
+
+/***************************************************************
+ NT Domain section.
+****************************************************************/
+
+/* NETLOGON opcodes and data structures */
+
+enum RPC_PKT_TYPE
+{
+ RPC_REQUEST = 0x00,
+ RPC_RESPONSE = 0x02,
+ RPC_BIND = 0x0B,
+ RPC_BINDACK = 0x0C
+};
+
+#define NET_QUERYFORPDC 7 /* Query for PDC */
+#define NET_QUERYFORPDC_R 12 /* Response to Query for PDC */
+#define NET_SAMLOGON 18
+#define NET_SAMLOGON_R 19
+
+#define SAMR_CLOSE 0x01
+#define SAMR_OPEN_SECRET 0x07
+#define SAMR_LOOKUP_RIDS 0x11
+#define SAMR_UNKNOWN_3 0x03
+#define SAMR_UNKNOWN_22 0x22
+#define SAMR_UNKNOWN_24 0x24
+#define SAMR_UNKNOWN_34 0x34
+#define SAMR_OPEN_POLICY 0x39
+
+#define LSA_OPENPOLICY 0x2c
+#define LSA_QUERYINFOPOLICY 0x07
+#define LSA_ENUMTRUSTDOM 0x0d
+#define LSA_REQCHAL 0x04
+#define LSA_SRVPWSET 0x06
+#define LSA_SAMLOGON 0x02
+#define LSA_SAMLOGOFF 0x03
+#define LSA_AUTH2 0x0f
+#define LSA_CLOSE 0x00
+
+/* XXXX these are here to get a compile! */
+
+#define LSA_OPENSECRET 0xFF
+#define LSA_LOOKUPSIDS 0xFE
+#define LSA_LOOKUPRIDS 0xFD
+#define LSA_LOOKUPNAMES 0xFC
+
+/* srvsvc pipe */
+#define NETSERVERGETINFO 0x15
+#define NETSHAREENUM 0x0f
+
+/* well-known RIDs - Relative IDs */
+
+/* RIDs - Well-known users ... */
+#define DOMAIN_USER_RID_ADMIN (0x000001F4L)
+#define DOMAIN_USER_RID_GUEST (0x000001F5L)
+
+/* RIDs - well-known groups ... */
+#define DOMAIN_GROUP_RID_ADMINS (0x00000200L)
+#define DOMAIN_GROUP_RID_USERS (0x00000201L)
+#define DOMAIN_GROUP_RID_GUESTS (0x00000202L)
+
+/* RIDs - well-known aliases ... */
+#define DOMAIN_ALIAS_RID_ADMINS (0x00000220L)
+#define DOMAIN_ALIAS_RID_USERS (0x00000221L)
+#define DOMAIN_ALIAS_RID_GUESTS (0x00000222L)
+#define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L)
+
+#define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L)
+#define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L)
+#define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L)
+#define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L)
+
+#define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L)
+
+/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
+typedef struct nttime_info
+{
+ uint32 low;
+ uint32 high;
+
+} NTTIME;
+
+
+#define MAXSUBAUTHS 15 /* max sub authorities in a SID */
+
+/* DOM_SID - security id */
+typedef struct sid_info
+{
+ uint8 sid_rev_num; /* SID revision number */
+ uint8 num_auths; /* number of sub-authorities */
+ uint8 id_auth[6]; /* Identifier Authority */
+ uint32 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
+
+} DOM_SID;
+
+/* UNIHDR - unicode string header */
+typedef struct unihdr_info
+{
+ uint16 uni_max_len;
+ uint16 uni_str_len;
+ uint32 undoc; /* usually has a value of 4 */
+
+} UNIHDR;
+
+/* UNIHDR2 - unicode string header and undocumented buffer */
+typedef struct unihdr2_info
+{
+ UNIHDR unihdr;
+ uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
+
+} UNIHDR2;
+
+/* clueless as to what maximum length should be */
+#define MAX_UNISTRLEN 1024
+
+/* UNISTR - unicode string size and buffer */
+typedef struct unistr_info
+{
+ uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. ***MUST*** be null-terminated */
+
+} UNISTR;
+
+/* UNISTR2 - unicode string size and buffer */
+typedef struct unistr2_info
+{
+ uint32 uni_max_len;
+ uint32 undoc;
+ uint32 uni_str_len;
+ uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. **NOT** necessarily null-terminated */
+
+} UNISTR2;
+
+/* DOM_SID2 - domain SID structure - SIDs stored in unicode */
+typedef struct domsid2_info
+{
+ uint32 type; /* value is 5 */
+ uint32 undoc; /* value is 0 */
+
+ UNIHDR2 hdr; /* XXXX conflict between hdr and str for length */
+ UNISTR str; /* XXXX conflict between hdr and str for length */
+
+} DOM_SID2;
+
+/* DOM_RID2 - domain RID structure for ntlsa pipe */
+typedef struct domrid2_info
+{
+ uint32 type; /* value is 5 */
+ uint32 undoc; /* value is non-zero */
+ uint32 rid;
+ uint32 rid_idx; /* don't know what this is */
+
+} DOM_RID2;
+
+/* DOM_RID3 - domain RID structure for samr pipe */
+typedef struct domrid3_info
+{
+ uint32 rid; /* domain-relative (to a SID) id */
+ uint32 type1; /* value is 0x1 */
+ uint32 ptr_type; /* undocumented pointer */
+ uint32 type2; /* value is 0x1 */
+
+} DOM_RID3;
+
+/* DOM_CLNT_SRV - client / server names */
+typedef struct clnt_srv_info
+{
+ uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
+ UNISTR2 uni_logon_srv; /* logon server name */
+ uint32 undoc_buffer2; /* undocumented 32 bit buffer pointer */
+ UNISTR2 uni_comp_name; /* client machine name */
+
+} DOM_CLNT_SRV;
+
+/* DOM_LOG_INFO - login info */
+typedef struct log_info
+{
+ uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
+ UNISTR2 uni_logon_srv; /* logon server name */
+ UNISTR2 uni_acct_name; /* account name */
+ uint16 sec_chan; /* secure channel type */
+ UNISTR2 uni_comp_name; /* client machine name */
+
+} DOM_LOG_INFO;
+
+/* DOM_CLNT_INFO - client info */
+typedef struct clnt_info
+{
+ DOM_LOG_INFO login;
+ DOM_CRED cred;
+
+} DOM_CLNT_INFO;
+
+/* DOM_CLNT_INFO2 - client info */
+typedef struct clnt_info2
+{
+ DOM_CLNT_SRV login;
+ uint32 ptr_cred;
+ DOM_CRED cred;
+
+} DOM_CLNT_INFO2;
+
+/* DOM_LOGON_ID - logon id */
+typedef struct logon_info
+{
+ uint32 low;
+ uint32 high;
+
+} DOM_LOGON_ID;
+
+/* ARC4_OWF */
+typedef struct arc4_owf_info
+{
+ uint8 data[16];
+
+} ARC4_OWF;
+
+
+/* DOM_ID_INFO_1 */
+typedef struct id_info_1
+{
+ uint32 ptr_id_info1; /* pointer to id_info_1 */
+ UNIHDR hdr_domain_name; /* domain name unicode header */
+ uint32 param_ctrl; /* param control */
+ DOM_LOGON_ID logon_id; /* logon ID */
+ UNIHDR hdr_user_name; /* user name unicode header */
+ UNIHDR hdr_wksta_name; /* workgroup name unicode header */
+ ARC4_OWF arc4_lm_owf; /* arc4 LM OWF Password */
+ ARC4_OWF arc4_nt_owf; /* arc4 NT OWF Password */
+ UNISTR2 uni_domain_name; /* domain name unicode string */
+ UNISTR2 uni_user_name; /* user name unicode string */
+ UNISTR2 uni_wksta_name; /* workgroup name unicode string */
+
+} DOM_ID_INFO_1;
+
+/* SAM_INFO - sam logon/off id structure */
+typedef struct sam_info
+{
+ DOM_CLNT_INFO2 client;
+ uint32 ptr_rtn_cred; /* pointer to return credentials */
+ DOM_CRED rtn_cred; /* return credentials */
+ uint16 logon_level;
+ uint16 switch_value;
+
+ union
+ {
+ DOM_ID_INFO_1 *id1; /* auth-level 1 */
+
+ } auth;
+
+} DOM_SAM_INFO;
+
+/* DOM_GID - group id + user attributes */
+typedef struct gid_info
+{
+ uint32 g_rid; /* a group RID */
+ uint32 attr;
+
+} DOM_GID;
+
+/* RPC_HDR - ms rpc header */
+typedef struct rpc_hdr_info
+{
+ uint8 major; /* 5 - RPC major version */
+ uint8 minor; /* 0 - RPC minor version */
+ uint8 pkt_type; /* 2 - RPC response packet */
+ uint8 frag; /* 3 - first frag + last frag */
+ uint32 pack_type; /* 0x1000 0000 - packed data representation */
+ uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
+ uint16 auth_len; /* 0 - authentication length */
+ uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */
+
+} RPC_HDR;
+
+/* RPC_HDR_RR - ms request / response rpc header */
+typedef struct rpc_hdr_rr_info
+{
+ RPC_HDR hdr;
+
+ uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
+ uint16 context_id; /* 0 - presentation context identifier */
+ uint8 cancel_count; /* 0 - cancel count */
+ uint8 opnum; /* request: 0 - reserved. response: opnum */
+
+} RPC_HDR_RR;
+
+/* the interfaces are numbered. as yet I haven't seen more than one interface
+ * used on the same pipe name
+ * srvsvc
+ * abstract (0x4B324FC8, 0x01D31670, 0x475A7812, 0x88E16EBF, 0x00000003)
+ * transfer (0x8A885D04, 0x11C91CEB, 0x0008E89F, 0x6048102B, 0x00000002)
+ */
+/* RPC_IFACE */
+typedef struct rpc_iface_info
+{
+ uint8 data[16]; /* 16 bytes of number */
+ uint32 version; /* the interface number */
+
+} RPC_IFACE;
+
+
+/* this seems to be the same string name depending on the name of the pipe,
+ * but is more likely to be linked to the interface name
+ * "srvsvc", "\\PIPE\\ntsvcs"
+ * "samr", "\\PIPE\\lsass"
+ * "wkssvc", "\\PIPE\\wksvcs"
+ * "NETLOGON", "\\PIPE\\NETLOGON"
+ */
+/* RPC_ADDR_STR */
+typedef struct rpc_addr_info
+{
+ uint16 len; /* length of the string including null terminator */
+ fstring str; /* the string above in single byte, null terminated form */
+
+} RPC_ADDR_STR;
+
+/* RPC_HDR_BBA */
+typedef struct rpc_hdr_bba_info
+{
+ uint16 max_tsize; /* maximum transmission fragment size (0x1630) */
+ uint16 max_rsize; /* max receive fragment size (0x1630) */
+ uint32 assoc_gid; /* associated group id (0x0) */
+
+} RPC_HDR_BBA;
+
+/* RPC_BIND_REQ - ms req bind */
+typedef struct rpc_bind_req_info
+{
+ RPC_HDR_BBA bba;
+
+ uint32 num_elements; /* the number of elements (0x1) */
+ uint16 context_id; /* presentation context identifier (0x0) */
+ uint8 num_syntaxes; /* the number of syntaxes (has always been 1?)(0x1) */
+
+ RPC_IFACE abstract; /* num and vers. of interface client is using */
+ RPC_IFACE transfer; /* num and vers. of interface to use for replies */
+
+} RPC_HDR_RB;
+
+/* RPC_RESULTS - can only cope with one reason, right now... */
+typedef struct rpc_results_info
+{
+/* uint8[] # 4-byte alignment padding, against SMB header */
+
+ uint8 num_results; /* the number of results (0x01) */
+
+/* uint8[] # 4-byte alignment padding, against SMB header */
+
+ uint16 result; /* result (0x00 = accept) */
+ uint16 reason; /* reason (0x00 = no reason specified) */
+
+} RPC_RESULTS;
+
+/* RPC_HDR_BA */
+typedef struct rpc_hdr_ba_info
+{
+ RPC_HDR_BBA bba;
+
+ RPC_ADDR_STR addr ; /* the secondary address string, as described earlier */
+ RPC_RESULTS res ; /* results and reasons */
+ RPC_IFACE transfer; /* the transfer syntax from the request */
+
+} RPC_HDR_BA;
+
+
+/* DOM_QUERY - info class 3 and 5 LSA Query response */
+typedef struct dom_query_info
+{
+ uint16 uni_dom_max_len; /* domain name string length * 2 */
+ uint16 uni_dom_str_len; /* domain name string length * 2 */
+ uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */
+ uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */
+ UNISTR2 uni_domain_name; /* domain name (unicode string) */
+ DOM_SID dom_sid; /* domain SID */
+
+} DOM_QUERY;
+
+/* level 5 is same as level 3. we hope. */
+typedef DOM_QUERY DOM_QUERY_3;
+typedef DOM_QUERY DOM_QUERY_5;
+
+#define POL_HND_SIZE 20
+
+/* LSA_POL_HND */
+typedef struct lsa_policy_info
+{
+ uint8 data[POL_HND_SIZE]; /* policy handle */
+
+} LSA_POL_HND;
+
+/* OBJ_ATTR (object attributes) */
+typedef struct object_attributes_info
+{
+ uint32 len; /* 0x18 - length (in bytes) inc. the length field. */
+ uint32 ptr_root_dir; /* 0 - root directory (pointer) */
+ uint32 ptr_obj_name; /* 0 - object name (pointer) */
+ uint32 attributes; /* 0 - attributes (undocumented) */
+ uint32 ptr_sec_desc; /* 0 - security descriptior (pointer) */
+ uint32 sec_qos; /* 0 - security quality of service */
+
+} LSA_OBJ_ATTR;
+
+/* LSA_Q_OPEN_POL - LSA Query Open Policy */
+typedef struct lsa_q_open_pol_info
+{
+ uint32 ptr; /* undocumented buffer pointer */
+ UNISTR2 uni_server_name; /* server name, starting with two '\'s */
+ LSA_OBJ_ATTR attr ; /* object attributes */
+
+ uint32 des_access; /* desired access attributes */
+
+} LSA_Q_OPEN_POL;
+
+/* LSA_R_OPEN_POL - response to LSA Open Policy */
+typedef struct lsa_r_open_pol_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+ uint32 status; /* return code */
+
+} LSA_R_OPEN_POL;
+
+/* LSA_Q_QUERY_INFO - LSA query info policy */
+typedef struct lsa_query_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint16 info_class; /* info class */
+
+} LSA_Q_QUERY_INFO;
+
+/* LSA_R_QUERY_INFO - response to LSA query info policy */
+typedef struct lsa_r_query_info
+{
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+ uint16 info_class; /* info class (same as info class in request) */
+
+ union
+ {
+ DOM_QUERY_3 id3;
+ DOM_QUERY_5 id5;
+
+ } dom;
+
+ uint32 status; /* return code */
+
+} LSA_R_QUERY_INFO;
+
+/* LSA_Q_ENUM_TRUST_DOM - LSA enumerate trusted domains */
+typedef struct lsa_enum_trust_dom_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint32 enum_context; /* enumeration context handle */
+ uint32 preferred_len; /* preferred maximum length */
+
+} LSA_Q_ENUM_TRUST_DOM;
+
+/* LSA_R_ENUM_TRUST_DOM - response to LSA enumerate trusted domains */
+typedef struct lsa_r_enum_trust_dom_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+ uint32 status; /* return code */
+
+} LSA_R_ENUM_TRUST_DOM;
+
+/* LSA_Q_CLOSE */
+typedef struct lsa_q_close_info
+{
+ LSA_POL_HND pol; /* policy handle */
-#include "ntdomain.h"
+} LSA_Q_CLOSE;
+/* LSA_R_CLOSE */
+typedef struct lsa_r_close_info
+{
+ LSA_POL_HND pol; /* policy handle. should be all zeros. */
+
+ uint32 status; /* return code */
+
+} LSA_R_CLOSE;
+
+
+#define MAX_REF_DOMAINS 10
+
+/* DOM_R_REF */
+typedef struct dom_ref_info
+{
+ uint32 undoc_buffer; /* undocumented buffer pointer. */
+ uint32 num_ref_doms_1; /* num referenced domains? */
+ uint32 buffer_dom_name; /* undocumented domain name buffer pointer. */
+ uint32 max_entries; /* 32 - max number of entries */
+ uint32 num_ref_doms_2; /* 4 - num referenced domains? */
+
+ UNIHDR2 hdr_dom_name; /* domain name unicode string header */
+ UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */
+
+ UNISTR uni_dom_name; /* domain name unicode string */
+ DOM_SID ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
+
+} DOM_R_REF;
+
+#define MAX_LOOKUP_SIDS 10
+
+/* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
+typedef struct lsa_q_lookup_sids
+{
+ LSA_POL_HND pol_hnd; /* policy handle */
+ uint32 num_entries;
+ uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
+ uint32 buffer_dom_name; /* undocumented domain name buffer pointer */
+ uint32 buffer_lookup_sids[MAX_LOOKUP_SIDS]; /* undocumented domain SID pointers to be looked up. */
+ DOM_SID dom_sids[MAX_LOOKUP_SIDS]; /* domain SIDs to be looked up. */
+ uint8 undoc[16]; /* completely undocumented 16 bytes */
+
+} LSA_Q_LOOKUP_SIDS;
+
+/* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
+typedef struct lsa_r_lookup_sids
+{
+ DOM_R_REF dom_ref; /* domain reference info */
+
+ uint32 num_entries;
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+ uint32 num_entries2;
+
+ DOM_SID2 dom_sid[MAX_LOOKUP_SIDS]; /* domain SIDs being looked up */
+
+ uint32 num_entries3;
+
+ uint32 status; /* return code */
+
+} LSA_R_LOOKUP_SIDS;
+
+/* DOM_NAME - XXXX not sure about this structure */
+typedef struct dom_name_info
+{
+ uint32 uni_str_len;
+ UNISTR str;
+
+} DOM_NAME;
+
+
+#define UNKNOWN_LEN 1
+
+/* LSA_Q_LOOKUP_RIDS - LSA Lookup RIDs */
+typedef struct lsa_q_lookup_rids
+{
+
+ LSA_POL_HND pol_hnd; /* policy handle */
+ uint32 num_entries;
+ uint32 num_entries2;
+ uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
+ uint32 buffer_dom_name; /* undocumented domain name buffer pointer */
+ DOM_NAME lookup_name[MAX_LOOKUP_SIDS]; /* names to be looked up */
+ uint8 undoc[UNKNOWN_LEN]; /* completely undocumented bytes of unknown length */
+
+} LSA_Q_LOOKUP_RIDS;
+
+/* LSA_R_LOOKUP_RIDS - response to LSA Lookup RIDs by name */
+typedef struct lsa_r_lookup_rids
+{
+ DOM_R_REF dom_ref; /* domain reference info */
+
+ uint32 num_entries;
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+
+ uint32 num_entries2;
+ DOM_RID2 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+
+ uint32 num_entries3;
+
+ uint32 status; /* return code */
+
+} LSA_R_LOOKUP_RIDS;
+
+
+
+/* NEG_FLAGS */
+typedef struct lsa_neg_flags_info
+{
+ uint32 neg_flags; /* negotiated flags */
+
+} NEG_FLAGS;
+
+
+/* LSA_Q_REQ_CHAL */
+typedef struct lsa_q_req_chal_info
+{
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+ UNISTR2 uni_logon_srv; /* logon server unicode string */
+ UNISTR2 uni_logon_clnt; /* logon client unicode string */
+ DOM_CHAL clnt_chal; /* client challenge */
+
+} LSA_Q_REQ_CHAL;
+
+
+/* LSA_R_REQ_CHAL */
+typedef struct lsa_r_req_chal_info
+{
+ DOM_CHAL srv_chal; /* server challenge */
+
+ uint32 status; /* return code */
+
+} LSA_R_REQ_CHAL;
+
+
+
+/* LSA_Q_AUTH_2 */
+typedef struct lsa_q_auth2_info
+{
+ DOM_LOG_INFO clnt_id; /* client identification info */
+ DOM_CHAL clnt_chal; /* client-calculated credentials */
+
+ NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
+
+} LSA_Q_AUTH_2;
+
+
+/* LSA_R_AUTH_2 */
+typedef struct lsa_r_auth2_info
+{
+ DOM_CHAL srv_chal; /* server-calculated credentials */
+ NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
+
+ uint32 status; /* return code */
+
+} LSA_R_AUTH_2;
+
+
+/* LSA_Q_SRV_PWSET */
+typedef struct lsa_q_srv_pwset_info
+{
+ DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
+ char pwd[16]; /* new password - undocumented. */
+
+} LSA_Q_SRV_PWSET;
+
+/* LSA_R_SRV_PWSET */
+typedef struct lsa_r_srv_pwset_info
+{
+ DOM_CRED srv_cred; /* server-calculated credentials */
+
+ uint32 status; /* return code */
+
+} LSA_R_SRV_PWSET;
+
+#define LSA_MAX_GROUPS 32
+#define LSA_MAX_SIDS 32
+
+/* LSA_USER_INFO */
+typedef struct lsa_q_user_info
+{
+ uint32 ptr_user_info;
+
+ NTTIME logon_time; /* logon time */
+ NTTIME logoff_time; /* logoff time */
+ NTTIME kickoff_time; /* kickoff time */
+ NTTIME pass_last_set_time; /* password last set time */
+ NTTIME pass_can_change_time; /* password can change time */
+ NTTIME pass_must_change_time; /* password must change time */
+
+ UNIHDR hdr_user_name; /* username unicode string header */
+ UNIHDR hdr_full_name; /* user's full name unicode string header */
+ UNIHDR hdr_logon_script; /* logon script unicode string header */
+ UNIHDR hdr_profile_path; /* profile path unicode string header */
+ UNIHDR hdr_home_dir; /* home directory unicode string header */
+ UNIHDR hdr_dir_drive; /* home directory drive unicode string header */
+
+ uint16 logon_count; /* logon count */
+ uint16 bad_pw_count; /* bad password count */
+
+ uint32 user_id; /* User ID */
+ uint32 group_id; /* Group ID */
+ uint32 num_groups; /* num groups */
+ uint32 buffer_groups; /* undocumented buffer pointer to groups. */
+ uint32 user_flgs; /* user flags */
+
+ char user_sess_key[16]; /* unused user session key */
+
+ UNIHDR hdr_logon_srv; /* logon server unicode string header */
+ UNIHDR hdr_logon_dom; /* logon domain unicode string header */
+
+ uint32 buffer_dom_id; /* undocumented logon domain id pointer */
+ char padding[40]; /* unused padding bytes. expansion room */
+
+ uint32 num_other_sids; /* 0 - num_sids */
+ uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */
+
+ UNISTR2 uni_user_name; /* username unicode string */
+ UNISTR2 uni_full_name; /* user's full name unicode string */
+ UNISTR2 uni_logon_script; /* logon script unicode string */
+ UNISTR2 uni_profile_path; /* profile path unicode string */
+ UNISTR2 uni_home_dir; /* home directory unicode string */
+ UNISTR2 uni_dir_drive; /* home directory drive unicode string */
+
+ uint32 num_groups2; /* num groups */
+ DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
+
+ UNISTR2 uni_logon_srv; /* logon server unicode string */
+ UNISTR2 uni_logon_dom; /* logon domain unicode string */
+
+ DOM_SID dom_sid; /* domain SID */
+ DOM_SID other_sids[LSA_MAX_SIDS]; /* undocumented - domain SIDs */
+
+} LSA_USER_INFO;
+
+
+/* LSA_Q_SAM_LOGON */
+typedef struct lsa_q_sam_logon_info
+{
+ DOM_SAM_INFO sam_id;
+
+} LSA_Q_SAM_LOGON;
+
+/* LSA_R_SAM_LOGON */
+typedef struct lsa_r_sam_logon_info
+{
+ uint32 buffer_creds; /* undocumented buffer pointer */
+ DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+
+ uint16 switch_value; /* 3 - indicates type of USER INFO */
+ LSA_USER_INFO *user;
+
+ uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
+
+ uint32 status; /* return code */
+
+} LSA_R_SAM_LOGON;
+
+
+/* LSA_Q_SAM_LOGOFF */
+typedef struct lsa_q_sam_logoff_info
+{
+ DOM_SAM_INFO sam_id;
+
+} LSA_Q_SAM_LOGOFF;
+
+/* LSA_R_SAM_LOGOFF */
+typedef struct lsa_r_sam_logoff_info
+{
+ uint32 buffer_creds; /* undocumented buffer pointer */
+ DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+
+ uint32 status; /* return code */
+
+} LSA_R_SAM_LOGOFF;
+
+
+/* SH_INFO_1 (pointers to level 1 share info strings) */
+typedef struct ptr_share_info1
+{
+ uint32 ptr_netname; /* pointer to net name. */
+ uint32 type; /* type of share. 0 - undocumented. */
+ uint32 ptr_remark; /* pointer to comment. */
+
+} SH_INFO_1;
+
+/* SH_INFO_1_STR (level 1 share info strings) */
+typedef struct str_share_info1
+{
+ UNISTR2 uni_netname; /* unicode string of net name */
+ UNISTR2 uni_remark; /* unicode string of comment. */
+
+} SH_INFO_1_STR;
+
+/* oops - this is going to take up a *massive* amount of stack. */
+/* the UNISTR2s already have 1024 uint16 chars in them... */
+#define MAX_SHARE_ENTRIES 32
+
+/* SHARE_INFO_1_CONTAINER */
+typedef struct share_info_ctr
+{
+ uint32 num_entries_read; /* EntriesRead */
+ uint32 ptr_share_info; /* Buffer */
+ uint32 num_entries_read2; /* EntriesRead */
+ SH_INFO_1 info_1 [MAX_SHARE_ENTRIES]; /* share entry pointers */
+ SH_INFO_1_STR info_1_str[MAX_SHARE_ENTRIES]; /* share entry strings */
+ uint32 num_entries_read3; /* EntriesRead2 */
+ uint32 padding; /* padding */
+
+} SHARE_INFO_1_CTR;
+
+
+/* SRV_Q_NET_SHARE_ENUM */
+typedef struct q_net_share_enum_info
+{
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* server name */
+
+ uint32 share_level; /* share level */
+ uint32 switch_value; /* switch value */
+
+ uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
+
+ union
+ {
+ SHARE_INFO_1_CTR info1; /* share info with 0 entries */
+
+ } share;
+
+ uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
+
+} SRV_Q_NET_SHARE_ENUM;
+
+
+/* SRV_R_NET_SHARE_ENUM */
+typedef struct r_net_share_enum_info
+{
+ uint32 share_level; /* share level */
+ uint32 switch_value; /* switch value */
+
+ uint32 ptr_share_info; /* pointer to SHARE_INFO_1_CTR */
+ union
+ {
+ SHARE_INFO_1_CTR info1; /* share info container */
+
+ } share;
+
+ uint32 status; /* return status */
+
+} SRV_R_NET_SHARE_ENUM;
+
+
+/* SAMR_Q_CLOSE - probably a policy handle close */
+typedef struct q_samr_close_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+} SAMR_Q_CLOSE;
+
+
+/* SAMR_R_CLOSE - probably a policy handle close */
+typedef struct r_samr_close_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint32 status; /* return status */
+
+} SAMR_R_CLOSE;
+
+
+/****************************************************************************
+SAMR_Q_OPEN_SECRET - unknown_0 values seen associated with SIDs:
+
+0x0000 0200 and a specific domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
+0x0000 0280 and a well-known domain sid - S-1-5-20
+0x2000 0000 and a well-known domain sid - S-1-5-20
+0x2000 0000 and a specific domain sid - S-1-5-21-44c01ca6-797e5c3d-33f83fd0
+*****************************************************************************/
+
+/* SAMR_Q_OPEN_SECRET - probably an open secret */
+typedef struct q_samr_open_secret_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint32 unknown_0; /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - unknown */
+ DOM_SID dom_sid; /* domain SID */
+
+} SAMR_Q_OPEN_SECRET;
+
+
+/* SAMR_R_OPEN_SECRET - probably an open */
+typedef struct r_samr_open_secret_info
+{
+ LSA_POL_HND pol; /* policy handle associated with the SID */
+ uint32 status; /* return status */
+
+} SAMR_R_OPEN_SECRET;
+
+
+/****************************************************************************
+SAMR_Q_LOOKUP_RIDS - do a conversion (only one!) from name to RID.
+
+the policy handle allocated by an "samr open secret" call is associated
+with a SID. this policy handle is what is queried here, *not* the SID
+itself. the response to the lookup rids is relative to this SID.
+*****************************************************************************/
+/* SAMR_Q_LOOKUP_RIDS - probably a "read SAM entry" */
+typedef struct q_samr_lookup_names_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+ uint32 num_rids1; /* 1 - number of rids being looked up */
+ uint32 rid; /* 0000 03e8 - RID of the server being queried? */
+ uint32 ptr; /* 0 - 32 bit unknown */
+ uint32 num_rids2; /* 1 - number of rids being looked up */
+
+ UNIHDR hdr_mach_acct; /* unicode machine account name header */
+ UNISTR2 uni_mach_acct; /* unicode machine account name */
+
+} SAMR_Q_LOOKUP_RIDS;
+
+
+/* SAMR_R_LOOKUP_RIDS - probably an open */
+typedef struct r_samr_lookup_names_info
+{
+ uint32 num_entries;
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+
+ uint32 num_entries2;
+ DOM_RID3 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+
+ uint32 num_entries3;
+
+ uint32 status; /* return code */
+
+} SAMR_R_LOOKUP_RIDS;
+
+
+/* SAMR_Q_UNKNOWN_22 - probably an open */
+typedef struct q_samr_unknown_22_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint32 unknown_id_0; /* 0x0000 03E8 - 32 bit unknown id */
+
+} SAMR_Q_UNKNOWN_22;
+
+
+/* SAMR_R_UNKNOWN_22 - probably an open */
+typedef struct r_samr_unknown_22_info
+{
+ LSA_POL_HND pol; /* policy handle associated with unknown id */
+ uint32 status; /* return status */
+
+} SAMR_R_UNKNOWN_22;
+
+
+/* SAMR_Q_UNKNOWN_24 - probably a get sam info */
+typedef struct q_samr_unknown_24_info
+{
+ LSA_POL_HND pol; /* policy handle associated with unknown id */
+ uint16 unknown_0; /* 0x0015 or 0x0011 - 16 bit unknown */
+
+} SAMR_Q_UNKNOWN_24;
+
+
+/* SAMR_R_UNKNOWN_24 - probably a get sam info */
+typedef struct r_samr_unknown_24_info
+{
+ uint32 ptr; /* pointer */
+ uint16 unknown_0; /* 0x0015 or 0x0011 - 16 bit unknown (same as above) */
+ uint16 unknown_1; /* 0x8b73 - 16 bit unknown */
+ uint8 padding_0[16]; /* 0 - padding 16 bytes */
+ NTTIME expiry; /* expiry time or something? */
+ uint8 padding_1[24]; /* 0 - padding 24 bytes */
+
+ UNIHDR hdr_mach_acct; /* unicode header for machine account */
+ uint32 padding_2; /* 0 - padding 4 bytes */
+
+ uint32 ptr_1; /* pointer */
+ uint8 padding_3[32]; /* 0 - padding 32 bytes */
+ uint32 padding_4; /* 0 - padding 4 bytes */
+
+ uint32 ptr_2; /* pointer */
+ uint32 padding_5; /* 0 - padding 4 bytes */
+
+ uint32 ptr_3; /* pointer */
+ uint8 padding_6[32]; /* 0 - padding 32 bytes */
+
+ uint32 unknown_id_0; /* unknown id associated with policy handle */
+ uint16 unknown_2; /* 0x0201 - 16 bit unknown */
+ uint32 unknown_3; /* 0x0000 0080 - 32 bit unknown */
+ uint16 unknown_4; /* 0x003f - 16 bit unknown */
+ uint16 unknown_5; /* 0x003c - 16 bit unknown */
+
+ uint8 padding_7[16]; /* 0 - padding 16 bytes */
+ uint32 padding_8; /* 0 - padding 4 bytes */
+
+ UNISTR2 uni_mach_acct; /* unicode string for machine account */
+
+ uint8 padding_9[48]; /* 0 - padding 48 bytes */
+
+ uint32 status; /* return status */
+
+} SAMR_R_UNKNOWN_24;
+
+
+/* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
+typedef struct q_samr_unknown_32_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+ UNIHDR hdr_mach_acct; /* unicode machine account name header */
+ UNISTR2 uni_mach_acct; /* unicode machine account name */
+
+ uint32 unknown_0; /* 32 bit unknown */
+ uint16 unknown_1; /* 16 bit unknown */
+ uint16 unknown_2; /* 16 bit unknown */
+
+} SAMR_Q_UNKNOWN_32;
+
+
+/* SAMR_R_UNKNOWN_32 - probably a "create SAM entry" */
+typedef struct r_samr_unknown_32_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint32 unknown_0; /* 0x0000 0030 - 32 bit unknown */
+ uint32 padding; /* 0 - 4 byte padding */
+
+ uint32 status; /* return status - 0xC000 0099: user exists */
+
+} SAMR_R_UNKNOWN_32;
+
+
+/* SAMR_Q_OPEN_POLICY - probably an open */
+typedef struct q_samr_open_policy_info
+{
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
+
+ uint32 unknown_0; /* 32 bit unknown */
+
+} SAMR_Q_OPEN_POLICY;
+
+
+/* SAMR_R_OPEN_POLICY - probably an open */
+typedef struct r_samr_open_policy_info
+{
+ LSA_POL_HND pol; /* policy handle */
+ uint32 status; /* return status */
+
+} SAMR_R_OPEN_POLICY;
+
+
+/* WKS_Q_UNKNOWN_0 - probably a capabilities request */
+typedef struct q_wks_unknown_0_info
+{
+ uint32 ptr_srv_name; /* pointer (to server name?) */
+ UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
+
+ uint32 unknown_0; /* 0x64 - 32 bit unknown */
+ uint16 unknown_1; /* 16 bit unknown */
+
+} WKS_Q_UNKNOWN_0;
+
+
+/* WKS_R_UNKNOWN_0 - probably a capabilities request */
+typedef struct r_wks_unknown_0_info
+{
+ uint32 unknown_0; /* 64 - unknown */
+ uint32 ptr_1; /* pointer 1 */
+ uint32 unknown_1; /* 0x0000 01f4 - unknown */
+ uint32 ptr_srv_name; /* pointer to server name */
+ uint32 ptr_dom_name; /* pointer to domain name */
+ uint32 unknown_2; /* 4 - unknown */
+ uint32 unknown_3; /* 0 - unknown */
+
+ UNISTR2 uni_srv_name; /* unicode server name */
+ UNISTR2 uni_dom_name; /* unicode domainn name */
+ uint32 status; /* return status */
+
+} WKS_R_UNKNOWN_0;
+
+#endif /* _SMB_H */
/* _SMB_H */
diff --git a/source/include/version.h b/source/include/version.h
index 146d0b7753a..3ed6e85ee05 100644
--- a/source/include/version.h
+++ b/source/include/version.h
@@ -1 +1 @@
-#define VERSION "1.9.19-prealpha"
+#define VERSION "1.9.18p6"
diff --git a/source/lib/access.c b/source/lib/access.c
index fe78700eddd..2fc93f4626b 100644
--- a/source/lib/access.c
+++ b/source/lib/access.c
@@ -60,19 +60,18 @@ BOOL check_access(int snum)
if (!ret)
{
- extern int Client;
- if (allow_access(denyl,allowl,client_name(Client),client_addr(Client)))
+ if (allow_access(denyl,allowl,client_name(),client_addr()))
{
if (snum >= 0)
DEBUG(2,("Allowed connection from %s (%s) to %s\n",
- client_name(Client),client_addr(Client),
+ client_name(),client_addr(),
lp_servicename(snum)));
ret = True;
}
else
if (snum >= 0)
DEBUG(0,("%s Denied connection from %s (%s) to %s\n",
- timestring(), client_name(Client),client_addr(Client),
+ timestring(), client_name(),client_addr(),
lp_servicename(snum)));
}
@@ -118,7 +117,7 @@ BOOL allow_access(char *deny_list,char *allow_list,char *cname,char *caddr)
/* list_match - match an item against a list of tokens with exceptions */
/* (All modifications are marked with the initials "jkf") */
-static int list_match(char *list,char *item, int (*match_fn)(char *, char *))
+static int list_match(char *list,char *item, int (*match_fn)(char *,char *))
{
char *tok;
char *listcopy; /* jkf */
diff --git a/source/lib/genrand.c b/source/lib/genrand.c
deleted file mode 100644
index b09f683e62d..00000000000
--- a/source/lib/genrand.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
-
- Functions to create reasonable random numbers for crypto use.
-
- Copyright (C) Jeremy Allison 1998
-
- 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"
-
-extern int DEBUGLEVEL;
-static uint32 counter = 0;
-
-/****************************************************************
-get a 16 byte hash from the contents of a file
-Note that the hash is not initialised.
-*****************************************************************/
-static void do_filehash(char *fname, unsigned char *hash)
-{
- unsigned char buf[1011]; /* deliberate weird size */
- unsigned char tmp_md4[16];
- int fd, n;
-
- fd = open(fname,O_RDONLY);
- if (fd == -1) return;
-
- while ((n = read(fd, (char *)buf, sizeof(buf))) > 0) {
- mdfour(tmp_md4, buf, n);
- for (n=0;n<16;n++)
- hash[n] ^= tmp_md4[n];
- }
- close(fd);
-}
-
-
-
-/****************************************************************
- Try and get a seed by looking at the atimes of files in a given
- directory. XOR them into the buf array.
-*****************************************************************/
-
-static void do_dirrand(char *name, unsigned char *buf, int buf_len)
-{
- void *dp = sys_opendir(name);
- pstring fullname;
- int len_left;
- int fullname_len;
- char *pos;
-
- pstrcpy(fullname, name);
- fullname_len = strlen(fullname);
-
- if(fullname_len + 2 > sizeof(pstring))
- return;
-
- if(fullname[fullname_len] != '/') {
- fullname[fullname_len] = '/';
- fullname[fullname_len+1] = '\0';
- fullname_len = strlen(fullname);
- }
-
- len_left = sizeof(pstring) - fullname_len - 1;
- pos = &fullname[fullname_len];
-
- if(dp != NULL) {
- char *p;
-
- while ((p = readdirname(dp))) {
- struct stat st;
-
- if(strlen(p) <= len_left)
- strcpy(pos, p);
-
- if(sys_stat(fullname,&st) == 0) {
- SIVAL(buf, ((counter * 4)%(buf_len-4)),
- IVAL(buf,((counter * 4)%(buf_len-4))) ^ st.st_atime);
- counter++;
- DEBUG(10,("do_dirrand: value from file %s.\n", fullname));
- }
- }
- closedir(dp);
- }
-}
-
-/**************************************************************
- Try and get a good random number seed. Try a number of
- different factors. Firstly, try /dev/random and try and
- read from this. If this fails iterate through /tmp and
- /dev and XOR all the file timestamps. Next add in
- a hash of the contents of /etc/shadow and the smb passwd
- file and a combination of pid and time of day (yes I know this
- sucks :-). Finally md4 the result.
-
- The result goes in a 16 byte buffer passed from the caller
-**************************************************************/
-
-static uint32 do_reseed(unsigned char *md4_outbuf)
-{
- unsigned char md4_inbuf[40];
- BOOL got_random = False;
- uint32 v1, v2, ret;
- int fd;
- struct timeval tval;
- pid_t mypid;
- struct passwd *pw;
-
- memset(md4_inbuf, '\0', sizeof(md4_inbuf));
-
- fd = open( "/dev/random", O_RDONLY);
- if(fd >= 0) {
- /*
- * We can use /dev/random !
- */
- if(read(fd, md4_inbuf, 40) == 40) {
- got_random = True;
- DEBUG(10,("do_reseed: got 40 bytes from /dev/random.\n"));
- }
- close(fd);
- }
-
- if(!got_random) {
- /*
- * /dev/random failed - try /tmp and /dev for timestamps.
- */
- do_dirrand("/tmp", md4_inbuf, sizeof(md4_inbuf));
- do_dirrand("/dev", md4_inbuf, sizeof(md4_inbuf));
- }
-
- /* possibly add in some secret file contents */
- do_filehash("/etc/shadow", &md4_inbuf[0]);
- do_filehash(lp_smb_passwd_file(), &md4_inbuf[16]);
-
- /* add in the root encrypted password. On any system where security is taken
- seriously this will be secret */
- pw = getpwnam("root");
- if (pw && pw->pw_passwd) {
- int i;
- unsigned char md4_tmp[16];
- mdfour(md4_tmp, (unsigned char *)pw->pw_passwd, strlen(pw->pw_passwd));
- for (i=0;i<16;i++)
- md4_inbuf[8+i] ^= md4_tmp[i];
- }
-
- /*
- * Finally add the counter, time of day, and pid.
- */
- GetTimeOfDay(&tval);
- mypid = getpid();
- v1 = (counter++) + mypid + tval.tv_sec;
- v2 = (counter++) * mypid + tval.tv_usec;
-
- SIVAL(md4_inbuf, 32, v1 ^ IVAL(md4_inbuf, 32));
- SIVAL(md4_inbuf, 36, v2 ^ IVAL(md4_inbuf, 36));
-
- mdfour(md4_outbuf, md4_inbuf, sizeof(md4_inbuf));
-
- /*
- * Return a 32 bit int created from XORing the
- * 16 bit return buffer.
- */
-
- ret = IVAL(md4_outbuf, 0);
- ret ^= IVAL(md4_outbuf, 4);
- ret ^= IVAL(md4_outbuf, 8);
- return (ret ^ IVAL(md4_outbuf, 12));
-}
-
-/*******************************************************************
- Interface to the (hopefully) good crypto random number generator.
-********************************************************************/
-
-void generate_random_buffer( unsigned char *out, int len, BOOL re_seed)
-{
- static BOOL done_reseed = False;
- static unsigned char md4_buf[16];
- unsigned char tmp_buf[16];
- unsigned char *p;
-
- if(!done_reseed || re_seed) {
- srandom(do_reseed(md4_buf));
- done_reseed = True;
- }
-
- /*
- * Generate random numbers in chunks of 64 bytes,
- * then md4 them & copy to the output buffer.
- * Added XOR with output from random, seeded
- * by the original md4_buf. This is to stop the
- * output from this function being the previous
- * md4_buf md4'ed. The output from this function
- * is often output onto the wire, and so it should
- * not be possible to guess the next output from
- * this function based on the previous output.
- * XORing in the output from random(), seeded by
- * the original md4 hash should stop this. JRA.
- */
-
- p = out;
- while(len > 0) {
- int i;
- int copy_len = len > 16 ? 16 : len;
- mdfour(tmp_buf, md4_buf, sizeof(md4_buf));
- memcpy(md4_buf, tmp_buf, sizeof(md4_buf));
- /* XOR in output from random(). */
- for(i = 0; i < 4; i++)
- SIVAL(tmp_buf, i*4, (IVAL(tmp_buf, i*4) ^ (uint32)random()));
- memcpy(p, tmp_buf, copy_len);
- p += copy_len;
- len -= copy_len;
- }
-}
diff --git a/source/lib/membuffer.c b/source/lib/membuffer.c
deleted file mode 100644
index 90b07047d32..00000000000
--- a/source/lib/membuffer.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- Samba memory buffer functions
- Copyright (C) Andrew Tridgell 1992-1997
- Copyright (C) Luke Kenneth Casson Leighton 1996-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.
-*/
-
-/*******************************************************************
- *
- * Description: memory buffer / stream management.
- * Author : Luke K C Leighton
- * Created : Dec 1997
- *
-
- * this module is intended for use in streaming data in and out of
- * buffers. it is intended that a single data stream be subdivided
- * into manageable sections.
-
- * for example, an rpc header contains a length field, but until the
- * data has been created, the length is unknown. using this module,
- * the header section can be tacked onto the front of the data memory
- * list once the size of the data section preceding it is known.
-
- * the "margin" can be used to over-run and retrospectively lengthen
- * the buffer. this is to save time in some of the loops, where it is
- * not particularly desirable to realloc data by 1, 2 or 4 bytes
- * repetitively...
-
- * each memory buffer contains a start and end offset. the end of
- * one buffer should equal to the start of the next in the chain.
- * (end - start = len, instead of end - start + 1 = len)
-
- * the debug log levels are very high in some of the routines: you
- * have no idea how boring it gets staring at debug output from these
-
- ********************************************************************/
-
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-/*******************************************************************
- initialise a memory buffer.
- ********************************************************************/
-void mem_init(struct mem_buf *buf, int margin)
-{
- buf->dynamic = True;
- buf->data = NULL;
- buf->data_size = 0;
- buf->data_used = 0;
-
- buf->margin = margin;
-
- buf->next = NULL;
-
- buf->offset.start = 0;
- buf->offset.end = 0;
-}
-
-/*******************************************************************
- initialise a memory buffer.
-
- dynamic indicates memory has been dynamically allocated.
- if mem_free is called, the memory will be freed.
- ********************************************************************/
-void mem_create(struct mem_buf *buf, char *data, int size, int margin, BOOL dynamic)
-{
- buf->dynamic = dynamic;
- buf->data = data;
- buf->data_size = size;
- buf->data_used = size;
-
- buf->margin = margin;
-
- buf->next = NULL;
-
- buf->offset.start = 0;
- buf->offset.end = size;
-}
-
-/*******************************************************************
- takes a memory buffer out of one structure: puts it in the other.
- NULLs the one that the buffer is being stolen from.
- ********************************************************************/
-void mem_take(struct mem_buf *mem_to, struct mem_buf *mem_from)
-{
- memcpy(mem_to, mem_from, sizeof(*mem_to));
-
- mem_init(mem_from, mem_from->margin);
-}
-
-/*******************************************************************
- allocate a memory buffer. assume it's empty
- ********************************************************************/
-BOOL mem_alloc_data(struct mem_buf *buf, int size)
-{
- if (!buf->dynamic)
- {
- DEBUG(3,("mem_alloc_data: warning - memory buffer type is set to static\n"));
- }
-
- buf->data_size = size + buf->margin;
- buf->data_used = size;
-
- buf->data = malloc(buf->data_size);
-
- if (buf->data == NULL)
- {
- DEBUG(3,("mem_alloc: could not malloc size %d\n",
- buf->data_size));
- mem_init(buf, buf->margin);
-
- return False;
- }
-
- bzero(buf->data, buf->data_size);
-
- return True;
-}
-
-/*******************************************************************
- allocates a memory buffer structure
- ********************************************************************/
-BOOL mem_buf_copy(char *copy_into, struct mem_buf *buf,
- uint32 offset, uint32 len)
-{
- uint32 end = offset + len;
- char *q = NULL;
- uint32 data_len = mem_buf_len(buf);
- uint32 start_offset = offset;
- struct mem_buf **bcp = &buf;
-
- if (buf == NULL || copy_into == NULL) return False;
-
- DEBUG(200,("mem_buf_copy: data[%d..%d] offset %d len %d\n",
- buf->offset.start, data_len, offset, len));
-
- /* there's probably an off-by-one bug, here, and i haven't even tested the code :-) */
- while (offset < end && ((q = mem_data(bcp, offset)) != NULL))
- {
- uint32 copy_len = (*bcp)->offset.end - offset;
-
- DEBUG(200,("\tdata[%d..%d] - offset %d len %d\n",
- (*bcp)->offset.start, (*bcp)->offset.end,
- offset, copy_len));
-
- memcpy(copy_into, q, copy_len);
-
- offset += copy_len;
- copy_into += copy_len;
- }
-
- if ((*bcp) != NULL)
- {
- DEBUG(200,("mem_buf_copy: copied %d bytes\n", offset - start_offset));
- }
- else
- {
- DEBUG(200,("mem_buf_copy: failed\n"));
- }
-
- return buf != NULL;
-}
-
-/*******************************************************************
- allocates a memory buffer structure
- ********************************************************************/
-BOOL mem_buf_init(struct mem_buf **buf, uint32 margin)
-{
- if (buf == NULL) return False;
-
- if ((*buf) == NULL)
- {
- (*buf) = malloc(sizeof(**buf));
- if ((*buf) != NULL)
- {
- mem_init((*buf), margin);
- return True;
- }
- }
- else
- {
- (*buf)->margin = margin;
- return True;
- }
- return False;
-}
-
-/*******************************************************************
- frees up a memory buffer.
- ********************************************************************/
-void mem_buf_free(struct mem_buf **buf)
-{
- if (buf == NULL) return;
- if ((*buf) == NULL) return;
-
- mem_free_data(*buf); /* delete memory data */
- free(*buf); /* delete item */
- (*buf) = NULL;
-}
-
-/*******************************************************************
- frees a memory buffer chain. assumes that all items are malloced.
- ********************************************************************/
-void mem_free_chain(struct mem_buf **buf)
-{
- if (buf == NULL) return;
- if ((*buf) == NULL) return;
-
- if ((*buf)->next != NULL)
- {
- mem_free_chain(&((*buf)->next)); /* delete all other items in chain */
- }
- mem_buf_free(buf);
-}
-
-/*******************************************************************
- frees a memory buffer.
- ********************************************************************/
-void mem_free_data(struct mem_buf *buf)
-{
- if (buf == NULL) return;
-
- if (buf->data != NULL && buf->dynamic)
- {
- free(buf->data); /* delete data in this structure */
- }
- mem_init(buf, buf->margin);
-}
-
-/*******************************************************************
- reallocate a memory buffer, including a safety margin
- ********************************************************************/
-BOOL mem_realloc_data(struct mem_buf *buf, int new_size)
-{
- char *new_data;
-
- if (!buf->dynamic)
- {
- DEBUG(3,("mem_realloc_data: memory buffer has not been dynamically allocated!\n"));
- return False;
- }
-
- if (new_size == 0)
- {
- mem_free_data(buf);
- return True;
- }
-
- new_data = Realloc(buf->data, new_size + buf->margin);
-
- if (new_data != NULL)
- {
- buf->data = new_data;
- buf->data_size = new_size + buf->margin;
- buf->data_used = new_size;
- }
- else if (buf->data_size <= new_size)
- {
- DEBUG(3,("mem_realloc: warning - could not realloc to %d(+%d)\n",
- new_size, buf->margin));
-
- buf->data_used = new_size;
- }
- else
- {
- DEBUG(3,("mem_realloc: error - could not realloc to %d\n",
- new_size));
-
- mem_free_data(buf);
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
- reallocate a memory buffer, retrospectively :-)
- ********************************************************************/
-BOOL mem_grow_data(struct mem_buf **buf, BOOL io, int new_size, BOOL force_grow)
-{
- if (new_size + (*buf)->margin >= (*buf)->data_size)
- {
- if (io && !force_grow)
- {
- DEBUG(3,("mem_grow_data: cannot resize when reading from a data stream\n"));
- }
- else
- {
- return mem_realloc_data((*buf), new_size);
- }
- }
- return True;
-}
-
-/*******************************************************************
- search for a memory buffer that falls within the specified offset
- ********************************************************************/
-BOOL mem_find(struct mem_buf **buf, uint32 offset)
-{
- struct mem_buf *f;
- if (buf == NULL) return False;
-
- f = *buf;
-
- DEBUG(200,("mem_find: data[%d..%d] offset: %d\n",
- f->offset.start, f->offset.end, offset));
-
- while (f != NULL && offset >= f->offset.end)
- {
- f = f->next;
-
- DEBUG(200,("mem_find: next[%d..%d]\n",
- f->offset.start, f->offset.end));
- }
-
- (*buf) = f;
-
- DEBUG(200,("mem_find: found data[%d..%d]\n",
- (*buf)->offset.start,(*buf)->offset.end));
-
- return f != NULL;
-}
-
-
-/*******************************************************************
- add up the lengths of all sections.
- ********************************************************************/
-uint32 mem_buf_len(struct mem_buf *buf)
-{
- int len = 0;
- while (buf != NULL)
- {
- len += buf->offset.end - buf->offset.start;
- buf = buf->next;
- }
- return len;
-}
-
-
-/*******************************************************************
- return the memory location specified by offset. may return NULL.
- ********************************************************************/
-char *mem_data(struct mem_buf **buf, uint32 offset)
-{
- if (mem_find(buf, offset))
- {
- return &((*buf)->data[offset - (*buf)->offset.start]);
- }
- return NULL;
-}
-
-
diff --git a/source/lib/pidfile.c b/source/lib/pidfile.c
deleted file mode 100644
index 46d6a9d5b8c..00000000000
--- a/source/lib/pidfile.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- pidfile handling
- Copyright (C) Andrew Tridgell 1998
-
- 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"
-
-
-extern int DEBUGLEVEL;
-
-#ifndef O_NONBLOCK
-#define O_NONBLOCK
-#endif
-
-
-/* create a pid file in the lock directory. open it and leave it locked */
-void pidfile_create(char *name)
-{
- int fd;
- char buf[20];
- pstring pidFile;
- int pid;
-
- slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_lockdir(), name);
-
- pid = pidfile_pid(name);
- if (pid > 0 && process_exists(pid)) {
- DEBUG(0,("ERROR: %s is already running\n", name));
- exit(1);
- }
-
- fd = open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY, 0644);
- if (fd < 0) {
- DEBUG(0,("ERROR: can't open %s: %s\n", pidFile,
- strerror(errno)));
- exit(1);
- }
-
- if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False) {
- DEBUG(0,("ERROR: %s is already running\n", name));
- exit(1);
- }
-
- memset(buf, 0, sizeof(buf));
- sprintf(buf, "%u\n", (unsigned int) getpid());
- if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
- DEBUG(0,("ERROR: can't write to %s: %s\n",
- pidFile, strerror(errno)));
- exit(1);
- }
- /* Leave pid file open & locked for the duration... */
-}
-
-
-/* return the pid in a pidfile. return 0 if the process (or pidfile)
- does not exist */
-int pidfile_pid(char *name)
-{
- FILE *f;
- pstring pidFile;
- unsigned ret;
-
- slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_lockdir(), name);
-
- f = fopen(pidFile, "r");
- if (!f) {
- return 0;
- }
-
- if (fscanf(f,"%u", &ret) != 1) {
- fclose(f);
- return 0;
- }
- fclose(f);
-
- if (!process_exists(ret)) return 0;
-
- return ret;
-}
-
diff --git a/source/lib/slprintf.c b/source/lib/slprintf.c
index e2dc0e12354..c493fab37b5 100644
--- a/source/lib/slprintf.c
+++ b/source/lib/slprintf.c
@@ -35,6 +35,10 @@ int vslprintf(char *str, int n, char *format, va_list ap)
static int pagesize;
int ret;
+#ifndef PROT_READ
+#define PROT_READ 1
+#endif
+
if (!len || !buf || (len-pagesize) < n) {
pagesize = getpagesize();
len = (2+(n/pagesize))*pagesize;
diff --git a/source/lib/time.c b/source/lib/time.c
index 716f5d62cc6..a6f99526e78 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -451,21 +451,6 @@ time_t make_unix_date3(void *date_ptr)
return(t);
}
-
-/***************************************************************************
-return a HTTP/1.0 time string
- ***************************************************************************/
-char *http_timestring(time_t t)
-{
- static char buf[40];
- struct tm *tm = LocalTime(&t);
-
- strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
- return buf;
-}
-
-
-
/****************************************************************************
return the date and time as a string
****************************************************************************/
diff --git a/source/lib/util.c b/source/lib/util.c
index ee87d483887..5c6a075e5ea 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -86,8 +86,8 @@ pstring samlogon_user="";
BOOL sam_logon_in_ssb = False;
-pstring global_myname = "";
-fstring global_myworkgroup = "";
+pstring myname = "";
+fstring myworkgroup = "";
char **my_netbios_names;
int smb_read_error = 0;
@@ -97,9 +97,9 @@ static BOOL stdout_logging = False;
static char *filename_dos(char *path,char *buf);
#if defined(SIGUSR2)
-/******************************************************************************
+/**************************************************************************** **
catch a sigusr2 - decrease the debug log level.
- *****************************************************************************/
+ **************************************************************************** */
int sig_usr2(void)
{
BlockSignals( True, SIGUSR2);
@@ -581,7 +581,7 @@ set user socket options
****************************************************************************/
void set_socket_options(int fd, char *options)
{
- string tok;
+ fstring tok;
while (next_token(&options,tok," \t,"))
{
@@ -1257,50 +1257,44 @@ void dos_format(char *fname)
string_replace(fname,'/','\\');
}
+
/*******************************************************************
show a smb message structure
********************************************************************/
void show_msg(char *buf)
{
- int i;
- int bcc=0;
-
- if (DEBUGLEVEL < 5) return;
-
- DEBUG(5,("size=%d\nsmb_com=0x%x\nsmb_rcls=%d\nsmb_reh=%d\nsmb_err=%d\nsmb_flg=%d\nsmb_flg2=%d\n",
- smb_len(buf),
- (int)CVAL(buf,smb_com),
- (int)CVAL(buf,smb_rcls),
- (int)CVAL(buf,smb_reh),
- (int)SVAL(buf,smb_err),
- (int)CVAL(buf,smb_flg),
- (int)SVAL(buf,smb_flg2)));
- DEBUG(5,("smb_tid=%d\nsmb_pid=%d\nsmb_uid=%d\nsmb_mid=%d\nsmt_wct=%d\n",
- (int)SVAL(buf,smb_tid),
- (int)SVAL(buf,smb_pid),
- (int)SVAL(buf,smb_uid),
- (int)SVAL(buf,smb_mid),
- (int)CVAL(buf,smb_wct)));
-
- for (i=0;i<(int)CVAL(buf,smb_wct);i++)
- {
- DEBUG(5,("smb_vwv[%d]=%d (0x%X)\n",i,
- SVAL(buf,smb_vwv+2*i),SVAL(buf,smb_vwv+2*i)));
- }
+ int i;
+ int bcc=0;
- bcc = (int)SVAL(buf,smb_vwv+2*(CVAL(buf,smb_wct)));
+ if (DEBUGLEVEL < 5) return;
- DEBUG(5,("smb_bcc=%d\n",bcc));
+ DEBUG(5,("size=%d\nsmb_com=0x%x\nsmb_rcls=%d\nsmb_reh=%d\nsmb_err=%d\nsmb_flg=%d\nsmb_flg2=%d\n",
+ smb_len(buf),
+ (int)CVAL(buf,smb_com),
+ (int)CVAL(buf,smb_rcls),
+ (int)CVAL(buf,smb_reh),
+ (int)SVAL(buf,smb_err),
+ (int)CVAL(buf,smb_flg),
+ (int)SVAL(buf,smb_flg2)));
+ DEBUG(5,("smb_tid=%d\nsmb_pid=%d\nsmb_uid=%d\nsmb_mid=%d\nsmt_wct=%d\n",
+ (int)SVAL(buf,smb_tid),
+ (int)SVAL(buf,smb_pid),
+ (int)SVAL(buf,smb_uid),
+ (int)SVAL(buf,smb_mid),
+ (int)CVAL(buf,smb_wct)));
- if (DEBUGLEVEL < 10) return;
+ for (i=0;i<(int)CVAL(buf,smb_wct);i++)
+ DEBUG(5,("smb_vwv[%d]=%d (0x%X)\n",i,
+ SVAL(buf,smb_vwv+2*i),SVAL(buf,smb_vwv+2*i)));
- if (DEBUGLEVEL < 50)
- {
- bcc = MIN(bcc, 512);
- }
+ bcc = (int)SVAL(buf,smb_vwv+2*(CVAL(buf,smb_wct)));
+ DEBUG(5,("smb_bcc=%d\n",bcc));
+
+ if (DEBUGLEVEL < 10) return;
- dump_data(10, smb_buf(buf), bcc);
+ dump_data(10, smb_buf(buf), MIN(bcc, 512));
}
+
/*******************************************************************
return the length of an smb packet
********************************************************************/
@@ -3123,7 +3117,7 @@ void become_daemon(void)
{
#ifndef NO_FORK_DEBUG
if (fork())
- _exit(0);
+ exit(0);
/* detach from the terminal */
#ifdef USE_SETSID
@@ -3408,7 +3402,7 @@ BOOL get_myname(char *my_name,struct in_addr *ip)
/* get host info */
if ((hp = Get_Hostbyname(hostname)) == 0)
{
- DEBUG(0,( "Get_Hostbyname: Unknown host %s\n",hostname));
+ DEBUG(0,( "Get_Hostbyname: Unknown host %s.\n",hostname));
return False;
}
@@ -3457,7 +3451,7 @@ int open_socket_in(int type, int port, int dlevel,uint32 socket_addr)
/* get host info */
if ((hp = Get_Hostbyname(host_name)) == 0)
{
- DEBUG(0,( "Get_Hostbyname: Unknown host %s\n",host_name));
+ DEBUG(0,( "Get_Hostbyname: Unknown host. %s\n",host_name));
return -1;
}
@@ -3637,7 +3631,7 @@ uint32 interpret_addr(char *str)
return 0;
}
if(hp->h_addr == NULL) {
- DEBUG(3,("Get_Hostbyname: host address is invalid for host %s\n",str));
+ DEBUG(3,("Get_Hostbyname: host address is invalid for host %s.\n",str));
return 0;
}
putip((char *)&res,(char *)hp->h_addr);
@@ -3733,81 +3727,73 @@ void reset_globals_after_fork(void)
/*******************************************************************
return the DNS name of the client
******************************************************************/
-char *client_name(int fd)
-{
- struct sockaddr sa;
- struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
- int length = sizeof(sa);
- static pstring name_buf;
- struct hostent *hp;
- static int last_fd=-1;
-
- if (global_client_name_done && last_fd == fd)
- return name_buf;
-
- last_fd = fd;
- global_client_name_done = False;
-
- strcpy(name_buf,"UNKNOWN");
-
- if (fd == -1) {
- return name_buf;
- }
-
- if (getpeername(fd, &sa, &length) < 0) {
- DEBUG(0,("getpeername failed\n"));
- return name_buf;
- }
-
- /* Look up the remote host name. */
- if ((hp = gethostbyaddr((char *) &sockin->sin_addr,
- sizeof(sockin->sin_addr),
- AF_INET)) == 0) {
- DEBUG(1,("Gethostbyaddr failed for %s\n",client_addr(fd)));
- StrnCpy(name_buf,client_addr(fd),sizeof(name_buf) - 1);
- } else {
- StrnCpy(name_buf,(char *)hp->h_name,sizeof(name_buf) - 1);
- if (!matchname(name_buf, sockin->sin_addr)) {
- DEBUG(0,("Matchname failed on %s %s\n",name_buf,client_addr(fd)));
- strcpy(name_buf,"UNKNOWN");
- }
- }
- global_client_name_done = True;
- return name_buf;
+char *client_name(void)
+{
+ struct sockaddr sa;
+ struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
+ int length = sizeof(sa);
+ static pstring name_buf;
+ struct hostent *hp;
+
+ if (global_client_name_done)
+ return name_buf;
+
+ strcpy(name_buf,"UNKNOWN");
+
+ if (Client == -1) {
+ return name_buf;
+ }
+
+ if (getpeername(Client, &sa, &length) < 0) {
+ DEBUG(0,("getpeername failed\n"));
+ return name_buf;
+ }
+
+ /* Look up the remote host name. */
+ if ((hp = gethostbyaddr((char *) &sockin->sin_addr,
+ sizeof(sockin->sin_addr),
+ AF_INET)) == 0) {
+ DEBUG(1,("Gethostbyaddr failed for %s\n",client_addr()));
+ StrnCpy(name_buf,client_addr(),sizeof(name_buf) - 1);
+ } else {
+ StrnCpy(name_buf,(char *)hp->h_name,sizeof(name_buf) - 1);
+ if (!matchname(name_buf, sockin->sin_addr)) {
+ DEBUG(0,("Matchname failed on %s %s\n",name_buf,client_addr()));
+ strcpy(name_buf,"UNKNOWN");
+ }
+ }
+ global_client_name_done = True;
+ return name_buf;
}
/*******************************************************************
return the IP addr of the client as a string
******************************************************************/
-char *client_addr(int fd)
+char *client_addr(void)
{
- struct sockaddr sa;
- struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
- int length = sizeof(sa);
- static fstring addr_buf;
- static int last_fd = -1;
+ struct sockaddr sa;
+ struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
+ int length = sizeof(sa);
+ static fstring addr_buf;
- if (global_client_addr_done && fd == last_fd)
- return addr_buf;
+ if (global_client_addr_done)
+ return addr_buf;
- last_fd = fd;
- global_client_addr_done = False;
+ strcpy(addr_buf,"0.0.0.0");
- strcpy(addr_buf,"0.0.0.0");
+ if (Client == -1) {
+ return addr_buf;
+ }
- if (fd == -1) {
- return addr_buf;
- }
-
- if (getpeername(fd, &sa, &length) < 0) {
- DEBUG(0,("getpeername failed\n"));
- return addr_buf;
- }
-
- fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
-
- global_client_addr_done = True;
- return addr_buf;
+ if (getpeername(Client, &sa, &length) < 0) {
+ DEBUG(0,("getpeername failed\n"));
+ return addr_buf;
+ }
+
+ fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
+
+ global_client_addr_done = True;
+ return addr_buf;
}
/*******************************************************************
@@ -3929,15 +3915,14 @@ char *automount_server(char *user_name)
{
static pstring server_name;
- /* use the local machine name as the default */
- /* this will be the default if AUTOMOUNT is not used or fails */
- pstrcpy(server_name, local_machine);
-
#if (defined(NETGROUP) && defined (AUTOMOUNT))
+ int home_server_len;
+
+ /* set to default of local machine */
+ pstrcpy(server_name, local_machine);
if (lp_nis_home_map())
{
- int home_server_len;
char *automount_value = automount_lookup(user_name);
home_server_len = strcspn(automount_value,":");
DEBUG(5, ("NIS lookup succeeded. Home server length: %d\n",home_server_len));
@@ -3948,6 +3933,9 @@ char *automount_server(char *user_name)
strncpy(server_name, automount_value, home_server_len);
server_name[home_server_len] = '\0';
}
+#else
+ /* use the local machine name instead of the auto-map server */
+ pstrcpy(server_name, local_machine);
#endif
DEBUG(4,("Home server: %s\n", server_name));
@@ -3964,16 +3952,14 @@ char *automount_path(char *user_name)
{
static pstring server_path;
- /* use the passwd entry as the default */
- /* this will be the default if AUTOMOUNT is not used or fails */
- /* pstrcpy() copes with get_home_dir() returning NULL */
- pstrcpy(server_path, get_home_dir(user_name));
-
#if (defined(NETGROUP) && defined (AUTOMOUNT))
+ char *home_path_start;
+
+ /* set to default of no string */
+ server_path[0] = 0;
if (lp_nis_home_map())
{
- char *home_path_start;
char *automount_value = automount_lookup(user_name);
home_path_start = strchr(automount_value,':');
if (home_path_start != NULL)
@@ -3983,6 +3969,10 @@ char *automount_path(char *user_name)
strcpy(server_path, home_path_start+1);
}
}
+#else
+ /* use the passwd entry instead of the auto-map server entry */
+ /* pstrcpy() copes with get_home_dir() returning NULL */
+ pstrcpy(server_path, get_home_dir(user_name));
#endif
DEBUG(4,("Home server path: %s\n", server_path));
@@ -4020,13 +4010,13 @@ void standard_sub_basic(char *str)
break;
}
case 'N' : string_sub(p,"%N", automount_server(username)); break;
- case 'I' : string_sub(p,"%I", client_addr(Client)); break;
+ case 'I' : string_sub(p,"%I", client_addr()); break;
case 'L' : string_sub(p,"%L", local_machine); break;
- case 'M' : string_sub(p,"%M", client_name(Client)); break;
+ case 'M' : string_sub(p,"%M", client_name()); break;
case 'R' : string_sub(p,"%R", remote_proto); break;
case 'T' : string_sub(p,"%T", timestring()); break;
- case 'U' : string_sub(p,"%U", username); break;
case 'a' : string_sub(p,"%a", remote_arch); break;
+ case 'U' : string_sub(p,"%U", username); break;
case 'd' :
{
sprintf(pidstr,"%d",(int)getpid());
@@ -4121,8 +4111,7 @@ struct hostent *Get_Hostbyname(char *name)
exit(0);
}
-
- /*
+ /*
* This next test is redundent and causes some systems (with
* broken isalnum() calls) problems.
* JRA.
@@ -4939,56 +4928,4 @@ char *tab_depth(int depth)
return spaces;
}
-/*****************************************************************
- Convert a domain SID to an ascii string. (non-reentrant).
-*****************************************************************/
-
-/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
-char *dom_sid_to_string(DOM_SID *sid)
-{
- static pstring sidstr;
- char subauth[16];
- int i;
- uint32 ia = (sid->id_auth[5]) +
- (sid->id_auth[4] << 8 ) +
- (sid->id_auth[3] << 16) +
- (sid->id_auth[2] << 24);
-
- sprintf(sidstr, "S-%d-%d", sid->sid_rev_num, ia);
-
- for (i = 0; i < sid->num_auths; i++)
- {
- sprintf(subauth, "-%d", sid->sub_auths[i]);
- strcat(sidstr, subauth);
- }
-
- DEBUG(7,("dom_sid_to_string returning %s\n", sidstr));
- return sidstr;
-}
-
-/*************************************************************
- Routine to get the next 32 hex characters and turn them
- into a 16 byte array.
-**************************************************************/
-int gethexpwd(char *p, char *pwd)
-{
- int i;
- unsigned char lonybble, hinybble;
- char *hexchars = "0123456789ABCDEF";
- char *p1, *p2;
- for (i = 0; i < 32; i += 2) {
- hinybble = toupper(p[i]);
- lonybble = toupper(p[i + 1]);
-
- p1 = strchr(hexchars, hinybble);
- p2 = strchr(hexchars, lonybble);
- if (!p1 || !p2)
- return (False);
- hinybble = PTR_DIFF(p1, hexchars);
- lonybble = PTR_DIFF(p2, hexchars);
-
- pwd[i / 2] = (hinybble << 4) | lonybble;
- }
- return (True);
-}
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
index 8b4001827c0..30fb96c1028 100644
--- a/source/libsmb/clientgen.c
+++ b/source/libsmb/clientgen.c
@@ -29,96 +29,11 @@
extern int DEBUGLEVEL;
-/*****************************************************
- RAP error codes - a small start but will be extended.
-*******************************************************/
-
-struct
-{
- int err;
- char *message;
-} rap_errmap[] =
-{
- {5, "User has insufficient privilege" },
- {86, "The specified password is invalid" },
- {2226, "Operation only permitted on a Primary Domain Controller" },
- {2242, "The password of this user has expired." },
- {2243, "The password of this user cannot change." },
- {2244, "This password cannot be used now (password history conflict)." },
- {2245, "The password is shorter than required." },
- {2246, "The password of this user is too recent to change."},
- {0, NULL}
-};
-
-/****************************************************************************
- return a description of an SMB error
-****************************************************************************/
-char *cli_smb_errstr(struct cli_state *cli)
-{
- return smb_errstr(cli->inbuf);
-}
-
-/******************************************************
- Return an error message - either an SMB error or a RAP
- error.
-*******************************************************/
-
-char *cli_errstr(struct cli_state *cli)
-{
- static fstring error_message;
- int errclass;
- int errnum;
- int i;
-
- /*
- * Errors are of three kinds - smb errors,
- * dealt with by cli_smb_errstr, NT errors,
- * whose code is in cli.nt_error, and rap
- * errors, whose error code is in cli.rap_error.
- */
-
- cli_error(cli, &errclass, &errnum);
- if(errclass != 0)
- return cli_smb_errstr(cli);
-
- /*
- * Was it an NT error ?
- */
-
- if(cli->nt_error) {
- char *nt_msg = get_nt_error_msg(cli->nt_error);
-
- if(nt_msg == NULL)
- sprintf(error_message, "NT code %d", cli->nt_error);
- else
- fstrcpy(error_message, nt_msg);
-
- return error_message;
- }
-
- /*
- * Must have been a rap error.
- */
-
- sprintf(error_message, "code %d", cli->rap_error);
-
- for(i = 0; rap_errmap[i].message != NULL; i++) {
- if (rap_errmap[i].err == cli->rap_error) {
- fstrcpy( error_message, rap_errmap[i].message);
- break;
- }
- }
-
- return error_message;
-}
-
/****************************************************************************
setup basics in a outgoing packet
****************************************************************************/
static void cli_setup_packet(struct cli_state *cli)
{
- cli->rap_error = 0;
- cli->nt_error = 0;
SSVAL(cli->outbuf,smb_pid,cli->pid);
SSVAL(cli->outbuf,smb_uid,cli->uid);
SSVAL(cli->outbuf,smb_mid,cli->mid);
@@ -132,12 +47,10 @@ static void cli_setup_packet(struct cli_state *cli)
/****************************************************************************
send a SMB trans or trans2 request
****************************************************************************/
-static BOOL cli_send_trans(struct cli_state *cli, int trans,
- char *name, int pipe_name_len,
- int fid, int flags,
- uint16 *setup, int lsetup, int msetup,
- char *param, int lparam, int mparam,
- char *data, int ldata, int mdata)
+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;
@@ -154,7 +67,7 @@ static BOOL cli_send_trans(struct cli_state *cli, int trans,
SSVAL(cli->outbuf,smb_tid, cli->cnum);
cli_setup_packet(cli);
- outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len+1 : 3);
+ outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? strlen(name)+1 : 3);
outdata = outparam+this_lparam;
/* primary request */
@@ -174,7 +87,7 @@ static BOOL cli_send_trans(struct cli_state *cli, int trans,
SSVAL(cli->outbuf,smb_setup+i*2,setup[i]);
p = smb_buf(cli->outbuf);
if (trans==SMBtrans) {
- memcpy(p,name, pipe_name_len + 1); /* name[] */
+ strcpy(p,name); /* name[] */
} else {
*p++ = 0; /* put in a null smb_name */
*p++ = 'D'; *p++ = ' '; /* observed in OS/2 */
@@ -242,9 +155,9 @@ static BOOL cli_send_trans(struct cli_state *cli, int trans,
/****************************************************************************
receive a SMB trans or trans2 response allocating the necessary memory
****************************************************************************/
-static BOOL cli_receive_trans(struct cli_state *cli,int trans,
- char **param, int *param_len,
- char **data, int *data_len)
+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;
@@ -322,51 +235,23 @@ static BOOL cli_receive_trans(struct cli_state *cli,int trans,
return(True);
}
-/****************************************************************************
-Call a remote api on an arbitrary pipe. takes param, data and setup buffers.
-****************************************************************************/
-BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, int pipe_name_len,
- uint16 *setup, uint32 setup_count, uint32 max_setup_count,
- char *params, uint32 param_count, uint32 max_param_count,
- char *data, uint32 data_count, uint32 max_data_count,
- char **rparam, uint32 *rparam_count,
- char **rdata, uint32 *rdata_count)
-{
- if(pipe_name_len == 0)
- pipe_name_len = strlen(pipe_name);
-
- cli_send_trans(cli, SMBtrans,
- pipe_name, pipe_name_len,
- 0,0, /* fid, flags */
- setup, setup_count, max_setup_count,
- params, param_count, max_param_count,
- data, data_count, max_data_count);
-
- return (cli_receive_trans(cli, SMBtrans,
- rparam, (int *)rparam_count,
- rdata, (int *)rdata_count));
-}
/****************************************************************************
call a remote api
****************************************************************************/
static BOOL cli_api(struct cli_state *cli,
- char *param, int prcnt, int mprcnt,
- char *data, int drcnt, int mdrcnt,
- char **rparam, int *rprcnt,
- char **rdata, int *rdrcnt)
+ 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,strlen(PIPE_LANMAN), /* Name, length */
- 0,0, /* fid, flags */
- NULL,0,0, /* Setup, length, max */
- param, prcnt, mprcnt, /* Params, length, max */
- data, drcnt, mdrcnt /* Data, length, max */
- );
+ cli_send_trans(cli,SMBtrans,PIPE_LANMAN,0,0,
+ data,param,NULL,
+ drcnt,prcnt,0,
+ mdrcnt,mprcnt,0);
return (cli_receive_trans(cli,SMBtrans,
- rparam, rprcnt,
- rdata, rdrcnt));
+ rdrcnt,rprcnt,
+ rdata,rparam));
}
@@ -404,84 +289,30 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
SSVAL(p, 0, BUFFER_SIZE);
p += 2;
- if (cli_api(cli,
- param, PTR_DIFF(p,param),1024, /* param, length, max */
- NULL, 0, BUFFER_SIZE, /* data, length, max */
- &rparam, &rprcnt, /* return params, return size */
- &rdata, &rdrcnt /* return data, return size */
- )) {
- cli->rap_error = SVAL(rparam,0);
+ 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->rap_error == 0) {
+ 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->rap_error));
+ DEBUG(1,("NetwkstaUserLogon gave error %d\n", cli->error));
}
}
if (rparam) free(rparam);
if (rdata) free(rdata);
- return (cli->rap_error == 0);
+ return cli->error == 0;
}
-/****************************************************************************
-call a NetShareEnum - try and browse available connections on a host
-****************************************************************************/
-BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(char *, uint32, char *))
-{
- char *rparam = NULL;
- char *rdata = NULL;
- char *p;
- int rdrcnt,rprcnt;
- pstring param;
- int count = -1;
-
- /* now send a SMBtrans command with api RNetShareEnum */
- p = param;
- SSVAL(p,0,0); /* api number */
- p += 2;
- strcpy(p,"WrLeh");
- p = skip_string(p,1);
- strcpy(p,"B13BWz");
- p = skip_string(p,1);
- SSVAL(p,0,1);
- SSVAL(p,2,BUFFER_SIZE);
- p += 4;
-
- if (cli_api(cli,
- param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */
- NULL, 0, BUFFER_SIZE, /* data, length, maxlen */
- &rparam, &rprcnt, /* return params, length */
- &rdata, &rdrcnt)) /* return data, length */
- {
- int res = SVAL(rparam,0);
- int converter=SVAL(rparam,2);
- int i;
-
- if (res == 0)
- {
- count=SVAL(rparam,4);
- p = rdata;
-
- for (i=0;i<count;i++,p+=20)
- {
- char *sname = p;
- int type = SVAL(p,14);
- int comment_offset = IVAL(p,16) & 0xFFFF;
- char *cmnt = comment_offset?(rdata+comment_offset-converter):"";
- fn(sname, type, cmnt);
- }
- }
- }
-
- if (rparam) free(rparam);
- if (rdata) free(rdata);
-
- return(count>0);
-}
/****************************************************************************
call a NetServerEnum for the specified workgroup and servertype mask.
@@ -521,11 +352,13 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
p = skip_string(p,1);
if (cli_api(cli,
- param, PTR_DIFF(p,param), 8, /* params, length, max */
- NULL, 0, BUFFER_SIZE, /* data, length, max */
- &rparam, &rprcnt, /* return params, return size */
- &rdata, &rdrcnt /* return data, return size */
- )) {
+ PTR_DIFF(p,param), /* param count */
+ 0, /*data count */
+ 8, /* mprcount */
+ BUFFER_SIZE, /* mdrcount */
+ &rprcnt,&rdrcnt,
+ param, NULL,
+ &rparam,&rdata)) {
int res = SVAL(rparam,0);
int converter=SVAL(rparam,2);
int i;
@@ -681,13 +514,13 @@ BOOL cli_ulogoff(struct cli_state *cli)
set_message(cli->outbuf,2,0,True);
CVAL(cli->outbuf,smb_com) = SMBulogoffX;
cli_setup_packet(cli);
- SSVAL(cli->outbuf,smb_vwv0,0xFF);
- SSVAL(cli->outbuf,smb_vwv2,0); /* no additional info */
+ SSVAL(cli->outbuf,smb_vwv0,0xFF);
+ SSVAL(cli->outbuf,smb_vwv2,0); /* no additional info */
send_smb(cli->fd,cli->outbuf);
if (!client_receive_smb(cli->fd,cli->inbuf,cli->timeout))
return False;
-
+
return CVAL(cli->inbuf,smb_rcls) == 0;
}
@@ -1262,19 +1095,15 @@ BOOL cli_qpathinfo(struct cli_state *cli, char *fname,
SSVAL(param, 0, SMB_INFO_STANDARD);
pstrcpy(&param[6], fname);
- if (!cli_send_trans(cli, SMBtrans2,
- NULL, 0, /* Name, length */
- -1, 0, /* fid, flags */
- &setup, 1, 0, /* setup, length, max */
- param, param_len, 10, /* param, length, max */
- NULL, data_len, cli->max_xmit /* data, length, max */
- )) {
+ if (!cli_send_trans(cli, SMBtrans2, NULL, -1, 0,
+ NULL, param, &setup,
+ data_len, param_len, 1,
+ cli->max_xmit, 10, 0)) {
return False;
}
- if (!cli_receive_trans(cli, SMBtrans2,
- &rparam, &param_len,
- &rdata, &data_len)) {
+ if (!cli_receive_trans(cli, SMBtrans2, &data_len, &param_len,
+ &rdata, &rparam)) {
return False;
}
@@ -1319,19 +1148,15 @@ BOOL cli_qpathinfo2(struct cli_state *cli, char *fname,
SSVAL(param, 0, SMB_QUERY_FILE_ALL_INFO);
pstrcpy(&param[6], fname);
- if (!cli_send_trans(cli, SMBtrans2,
- NULL, 0, /* name, length */
- -1, 0, /* fid, flags */
- &setup, 1, 0, /* setup, length, max */
- param, param_len, 10, /* param, length, max */
- NULL, data_len, cli->max_xmit /* data, length, max */
- )) {
+ if (!cli_send_trans(cli, SMBtrans2, NULL, -1, 0,
+ NULL, param, &setup,
+ data_len, param_len, 1,
+ cli->max_xmit, 10, 0)) {
return False;
}
- if (!cli_receive_trans(cli, SMBtrans2,
- &rparam, &param_len,
- &rdata, &data_len)) {
+ if (!cli_receive_trans(cli, SMBtrans2, &data_len, &param_len,
+ &rdata, &rparam)) {
return False;
}
@@ -1379,19 +1204,15 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
SSVAL(param, 0, fnum);
SSVAL(param, 2, SMB_INFO_STANDARD);
- if (!cli_send_trans(cli, SMBtrans2,
- NULL, 0, /* name, length */
- -1, 0, /* fid, flags */
- &setup, 1, 0, /* setup, length, max */
- param, param_len, 2, /* param, length, max */
- NULL, data_len, cli->max_xmit /* data, length, max */
- )) {
+ if (!cli_send_trans(cli, SMBtrans2, NULL, -1, 0,
+ NULL, param, &setup,
+ data_len, param_len, 1,
+ cli->max_xmit, 2, 0)) {
return False;
}
- if (!cli_receive_trans(cli, SMBtrans2,
- &rparam, &param_len,
- &rdata, &data_len)) {
+ if (!cli_receive_trans(cli, SMBtrans2, &data_len, &param_len,
+ &rdata, &rparam)) {
return False;
}
@@ -1438,6 +1259,8 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
char *rdata = NULL;
int rprcnt, rdrcnt;
+ cli->error = -1;
+
if(strlen(user) >= sizeof(fstring)-1) {
DEBUG(0,("cli_oem_change_password: user name %s is too long.\n", user));
return False;
@@ -1463,11 +1286,8 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
/*
* Now setup the data area.
- * We need to generate a random fill
- * for this area to make it harder to
- * decrypt. JRA.
*/
- generate_random_buffer((unsigned char *)data, sizeof(data), False);
+ memset(data, '\0', sizeof(data));
fstrcpy( &data[512 - new_pw_len], new_password);
SIVAL(data, 512, new_pw_len);
@@ -1495,23 +1315,18 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
data_len = 532;
- if(cli_send_trans(cli,SMBtrans,
- PIPE_LANMAN,strlen(PIPE_LANMAN), /* name, length */
- 0,0, /* fid, flags */
- NULL,0,0, /* setup, length, max */
- param,param_len,2, /* param, length, max */
- data,data_len,0 /* data, length, max */
- ) == False) {
+ if(cli_send_trans(cli,SMBtrans,PIPE_LANMAN,0,0,
+ data,param,NULL,
+ data_len , param_len,0,
+ 0,2,0) == False) {
DEBUG(0,("cli_oem_change_password: Failed to send password change for user %s\n",
user ));
return False;
}
- if(cli_receive_trans(cli,SMBtrans,
- &rparam, &rprcnt,
- &rdata, &rdrcnt)) {
+ if(cli_receive_trans(cli,SMBtrans, &rdrcnt, &rprcnt, &rdata, &rparam)) {
if(rparam)
- cli->rap_error = SVAL(rparam,0);
+ cli->error = SVAL(rparam,0);
}
if (rparam)
@@ -1519,7 +1334,7 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
if (rdata)
free(rdata);
- return (cli->rap_error == 0);
+ return (cli->error == 0);
}
/****************************************************************************
@@ -1640,8 +1455,7 @@ BOOL cli_session_request(struct cli_state *cli, char *host, int name_type,
return False;
if (CVAL(cli->inbuf,0) != 0x82) {
- /* This is the wrong place to put the error... JRA. */
- cli->rap_error = CVAL(cli->inbuf,0);
+ cli->error = CVAL(cli->inbuf,0);
return False;
}
return(True);
@@ -1710,6 +1524,14 @@ void cli_shutdown(struct cli_state *cli)
}
/****************************************************************************
+ return a description of the error
+****************************************************************************/
+char *cli_errstr(struct cli_state *cli)
+{
+ return smb_errstr(cli->inbuf);
+}
+
+/****************************************************************************
return error codes for the last packet
****************************************************************************/
void cli_error(struct cli_state *cli, int *eclass, int *num)
diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c
index 4de10f10ce9..cb5538ec0ca 100644
--- a/source/libsmb/namequery.c
+++ b/source/libsmb/namequery.c
@@ -194,8 +194,9 @@ BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
returns an array of IP addresses or NULL if none
*count will be set to the number of addresses returned
****************************************************************************/
-struct in_addr *name_query(int fd,char *name,int name_type, BOOL bcast,BOOL recurse,
- struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *))
+struct in_addr *name_query(int fd,char *name,int name_type,
+ BOOL bcast,BOOL recurse, struct in_addr to_ip,
+ int *count, void (*fn)(struct packet_struct *))
{
BOOL found=False;
int i, retries = 3;
@@ -450,8 +451,6 @@ BOOL resolve_name(char *name, struct in_addr *return_ip)
pstrcpy(name_resolve_list, lp_name_resolve_order());
ptr = name_resolve_list;
- if (!ptr || !*ptr) ptr = "host";
-
while (next_token(&ptr, tok, LIST_SEP)) {
if(strequal(tok, "host") || strequal(tok, "hosts")) {
diff --git a/source/libsmb/nmblib.c b/source/libsmb/nmblib.c
index 5a8a037ce5b..de180d6c6fb 100644
--- a/source/libsmb/nmblib.c
+++ b/source/libsmb/nmblib.c
@@ -27,6 +27,7 @@ extern int DEBUGLEVEL;
int num_good_sends = 0;
int num_good_receives = 0;
extern pstring scope;
+extern pstring myname;
extern struct in_addr ipzero;
static struct opcode_names {
diff --git a/source/libsmb/nterr.c b/source/libsmb/nterr.c
index 0788ae1b60a..bda0f882a64 100644
--- a/source/libsmb/nterr.c
+++ b/source/libsmb/nterr.c
@@ -1,23 +1,18 @@
-/* NT error codes. please read nterr.h */
-#include "includes.h"
#include "nterr.h"
-typedef struct
+static struct
{
char *nt_errstr;
- uint32 nt_errcode;
+ uint16 nt_errcode;
-} nt_err_code_struct;
-
-nt_err_code_struct nt_errs[] =
+} nt_errs[] =
{
{ "NT_STATUS_UNSUCCESSFUL", NT_STATUS_UNSUCCESSFUL },
{ "NT_STATUS_NOT_IMPLEMENTED", NT_STATUS_NOT_IMPLEMENTED },
{ "NT_STATUS_INVALID_INFO_CLASS", NT_STATUS_INVALID_INFO_CLASS },
{ "NT_STATUS_INFO_LENGTH_MISMATCH", NT_STATUS_INFO_LENGTH_MISMATCH },
{ "NT_STATUS_ACCESS_VIOLATION", NT_STATUS_ACCESS_VIOLATION },
- { "STATUS_BUFFER_OVERFLOW", STATUS_BUFFER_OVERFLOW },
{ "NT_STATUS_IN_PAGE_ERROR", NT_STATUS_IN_PAGE_ERROR },
{ "NT_STATUS_PAGEFILE_QUOTA", NT_STATUS_PAGEFILE_QUOTA },
{ "NT_STATUS_INVALID_HANDLE", NT_STATUS_INVALID_HANDLE },
@@ -517,27 +512,3 @@ nt_err_code_struct nt_errs[] =
{ NULL, 0 }
};
-/*****************************************************************************
- returns an NT error message. not amazingly helpful, but better than a number.
- *****************************************************************************/
-char *get_nt_error_msg(uint32 nt_code)
-{
- static pstring msg;
- int idx = 0;
-
- strcpy(msg, "Unknown NT error");
-
- nt_code &= 0xFFFF;
-
- while (nt_errs[idx].nt_errstr != NULL)
- {
- if (nt_errs[idx].nt_errcode == nt_code)
- {
- strcpy(msg, nt_errs[idx].nt_errstr);
- return msg;
- }
- idx++;
- }
- return msg;
-}
-
diff --git a/source/libsmb/smbdes.c b/source/libsmb/smbdes.c
index 4daf616588d..e5d8f4a1e0b 100644
--- a/source/libsmb/smbdes.c
+++ b/source/libsmb/smbdes.c
@@ -347,15 +347,6 @@ void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key)
smbhash(out, buf, key2, 1);
}
-void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw)
-{
- static unsigned char key2[8];
-
- smbhash(out, in, key, forw);
- key2[0] = key[7];
- smbhash(out + 8, in + 8, key2, forw);
-}
-
void SamOEMhash( unsigned char *data, unsigned char *key, int val)
{
unsigned char s_box[256];
diff --git a/source/locking/shmem.c b/source/locking/shmem.c
index 9f24076171b..63d7ebd3d41 100644
--- a/source/locking/shmem.c
+++ b/source/locking/shmem.c
@@ -656,9 +656,6 @@ static BOOL smb_shm_lock_hash_entry( unsigned int entry)
return False;
}
- if (read_only)
- return True;
-
/* Do an exclusive wait lock on the 4 byte region mapping into this entry */
if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(int), F_WRLCK) == False)
{
@@ -682,9 +679,6 @@ static BOOL smb_shm_unlock_hash_entry( unsigned int entry )
DEBUG(0,("ERROR smb_shm_unlock_hash_entry : bad smb_shm_fd (%d)\n",smb_shm_fd));
return False;
}
-
- if (read_only)
- return True;
/* Do a wait lock on the 4 byte region mapping into this entry */
if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(int), F_UNLCK) == False)
diff --git a/source/locking/shmem_sysv.c b/source/locking/shmem_sysv.c
index 20aea9283db..daa6ba55814 100644
--- a/source/locking/shmem_sysv.c
+++ b/source/locking/shmem_sysv.c
@@ -542,8 +542,6 @@ struct shmem_ops *sysv_shm_open(int ronly)
int i;
int pid;
-
-
#ifdef LINUX
if (sizeof(shm_ds) == 52) {
DEBUG(0,("WARNING: You probably have a broken set of glibc2 include files - disabling sysv shared memory\n"));
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index f9519bea18e..5265db76abd 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -40,8 +40,8 @@ int global_nmb_port = -1;
extern pstring myhostname;
static pstring host_file;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern char **my_netbios_names;
extern BOOL global_in_nmbd;
@@ -225,7 +225,7 @@ BOOL reload_services(BOOL test)
if ( test && !lp_file_list_changed() )
return(True);
- ret = lp_load( servicesf, True , False, False);
+ ret = lp_load( servicesf, True );
/* perhaps the config filename is now set */
if ( !test )
@@ -450,23 +450,23 @@ static BOOL init_structs(void)
int nodup;
pstring nbname;
- if (! *global_myname)
+ if (! *myname)
{
- fstrcpy( global_myname, myhostname );
- p = strchr( global_myname, '.' );
+ fstrcpy( myname, myhostname );
+ p = strchr( myname, '.' );
if (p)
*p = 0;
}
- strupper( global_myname );
+ strupper( myname );
/* Add any NETBIOS name aliases. Ensure that the first entry
- is equal to global_myname.
+ is equal to myname.
*/
/* Work out the max number of netbios aliases that we have */
ptr = lp_netbios_aliases();
for( namecount=0; next_token(&ptr,nbname,NULL); namecount++ )
;
- if ( *global_myname )
+ if ( *myname )
namecount++;
/* Allocate space for the netbios aliases */
@@ -477,10 +477,10 @@ static BOOL init_structs(void)
return( False );
}
- /* Use the global_myname string first */
+ /* Use the myname string first */
namecount=0;
- if ( *global_myname )
- my_netbios_names[namecount++] = global_myname;
+ if ( *myname )
+ my_netbios_names[namecount++] = myname;
ptr = lp_netbios_aliases();
while ( next_token( &ptr, nbname, NULL ) )
@@ -508,7 +508,7 @@ static BOOL init_structs(void)
/* Terminate name list */
my_netbios_names[namecount++] = NULL;
- fstrcpy( local_machine, global_myname );
+ fstrcpy( local_machine, myname );
trim_string( local_machine, " ", " " );
p = strchr( local_machine, ' ' );
if (p)
@@ -551,9 +551,12 @@ int main(int argc,char *argv[])
int opt;
extern FILE *dbf;
extern char *optarg;
+ char pidFile[100] = { 0 };
global_nmb_port = NMB_PORT;
+
*host_file = 0;
+
global_in_nmbd = True;
StartupTime = time(NULL);
@@ -577,7 +580,7 @@ int main(int argc,char *argv[])
argc--;
}
- fault_setup((void (*)(void *))fault_continue );
+ fault_setup((void (*)(void *)) fault_continue );
signal( SIGHUP, SIGNAL_CAST sig_hup );
signal( SIGTERM, SIGNAL_CAST sig_term );
@@ -601,6 +604,9 @@ int main(int argc,char *argv[])
{
switch (opt)
{
+ case 'f':
+ strncpy(pidFile, optarg, sizeof(pidFile));
+ break;
case 's':
pstrcpy(servicesf,optarg);
break;
@@ -615,8 +621,8 @@ int main(int argc,char *argv[])
pstrcpy(host_file,optarg);
break;
case 'n':
- pstrcpy(global_myname,optarg);
- strupper(global_myname);
+ pstrcpy(myname,optarg);
+ strupper(myname);
break;
case 'l':
slprintf(debugf,sizeof(debugf)-1, "%s.nmb",optarg);
@@ -674,9 +680,9 @@ int main(int argc,char *argv[])
reload_services( True );
- fstrcpy( global_myworkgroup, lp_workgroup() );
+ fstrcpy( myworkgroup, lp_workgroup() );
- if (strequal(global_myworkgroup,"*"))
+ if (strequal(myworkgroup,"*"))
{
DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
exit(1);
@@ -696,11 +702,40 @@ int main(int argc,char *argv[])
become_daemon();
}
- if (!directory_exist(lp_lockdir(), NULL)) {
- mkdir(lp_lockdir(), 0755);
+ if (!directory_exist(lp_lockdir(), NULL))
+ {
+ mkdir(lp_lockdir(), 0755);
+ }
+
+ if (*pidFile)
+ {
+ int fd;
+ char buf[20];
+
+#ifdef O_NONBLOCK
+ fd = open( pidFile, O_NONBLOCK | O_CREAT | O_WRONLY | O_TRUNC, 0644 );
+#else
+ fd = open( pidFile, O_CREAT | O_WRONLY | O_TRUNC, 0644 );
+#endif
+ if ( fd < 0 )
+ {
+ DEBUG(0,("ERROR: can't open %s: %s\n", pidFile, strerror(errno)));
+ exit(1);
+ }
+ if (fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False)
+ {
+ DEBUG(0,("ERROR: nmbd is already running\n"));
+ exit(1);
+ }
+ sprintf(buf, "%u\n", (unsigned int) getpid());
+ if (write(fd, buf, strlen(buf)) < 0)
+ {
+ DEBUG(0,("ERROR: can't write to %s: %s\n", pidFile, strerror(errno)));
+ exit(1);
+ }
+ /* Leave pid file open & locked for the duration... */
}
- pidfile_create("nmbd");
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
diff --git a/source/nmbd/nmbd_become_dmb.c b/source/nmbd/nmbd_become_dmb.c
index d01bf18310c..52065758bcd 100644
--- a/source/nmbd/nmbd_become_dmb.c
+++ b/source/nmbd/nmbd_become_dmb.c
@@ -27,8 +27,8 @@
extern int DEBUGLEVEL;
extern pstring scope;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern char **my_netbios_names;
extern struct in_addr ipzero;
extern struct in_addr allones_ip;
@@ -56,11 +56,11 @@ static void unbecome_dmb_success(struct subnet_record *subrec,
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("unbecome_dmb_success: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, released_name->name, subrec->subnet_name));
+ myname, released_name->name, subrec->subnet_name));
return;
}
@@ -82,7 +82,7 @@ in workgroup %s on subnet %s\n",
putip((char *)&work->dmb_addr, &ipzero);
DEBUG(0,("\n%s ***** Samba server %s has stopped being a domain master browser \
-for workgroup %s on subnet %s *****\n\n", timestring(), global_myname, work->work_group, subrec->subnet_name));
+for workgroup %s on subnet %s *****\n\n", timestring(), myname, work->work_group, subrec->subnet_name));
}
@@ -157,11 +157,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name));
/* Set the state back to DOMAIN_NONE. */
work->dom_state = DOMAIN_NONE;
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("become_domain_master_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ myname, work->work_group, subrec->subnet_name));
return;
}
@@ -196,11 +196,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("become_domain_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ myname, registered_name->name, subrec->subnet_name));
work->dom_state = DOMAIN_NONE;
return;
}
@@ -215,7 +215,7 @@ in workgroup %s on subnet %s\n",
subrec->work_changed = True;
DEBUG(0,("\n%s ***** Samba server %s is now a domain master browser for \
-workgroup %s on subnet %s *****\n\n", timestring(),global_myname, work->work_group,
+workgroup %s on subnet %s *****\n\n", timestring(),myname, work->work_group,
subrec->subnet_name));
if(subrec == unicast_subnet)
@@ -228,7 +228,7 @@ subrec->subnet_name));
will stop us syncing with ourself if we are also
a local master browser. */
- make_nmb_name(&nmbname, global_myname, 0x20, scope);
+ make_nmb_name(&nmbname, myname, 0x20, scope);
work->dmb_name = nmbname;
/* Pick the first interface ip address as the domain master browser ip. */
@@ -464,9 +464,9 @@ void add_domain_names(time_t t)
1.9.16p2 to 1.9.16p11 - due to a bug in namelogon.c,
cannot provide domain master / domain logon services.
*/
- become_domain_master_browser_wins(global_myworkgroup);
+ become_domain_master_browser_wins(myworkgroup);
}
else
- become_domain_master_browser_bcast(global_myworkgroup);
+ become_domain_master_browser_bcast(myworkgroup);
}
}
diff --git a/source/nmbd/nmbd_become_lmb.c b/source/nmbd/nmbd_become_lmb.c
index c602789fb84..b58244104dc 100644
--- a/source/nmbd/nmbd_become_lmb.c
+++ b/source/nmbd/nmbd_become_lmb.c
@@ -26,7 +26,7 @@
extern int DEBUGLEVEL;
extern pstring scope;
-extern pstring global_myname;
+extern pstring myname;
extern uint16 samba_nb_type; /* Samba's NetBIOS name type. */
@@ -90,11 +90,11 @@ subnet %s.\n", workgroup_name, subrec->subnet_name ));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("reset_workgroup_state: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ myname, work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -146,7 +146,7 @@ void unbecome_local_master_success(struct subnet_record *subrec,
reset_workgroup_state( subrec, released_name->name );
DEBUG(0,("\n%s ***** Samba name server %s has stopped being a local master browser for workgroup %s \
-on subnet %s *****\n\n", timestring(), global_myname, released_name->name, subrec->subnet_name));
+on subnet %s *****\n\n", timestring(), myname, released_name->name, subrec->subnet_name));
}
@@ -171,7 +171,7 @@ Removing from namelist anyway.\n", namestr(fail_name)));
reset_workgroup_state( subrec, fail_name->name );
DEBUG(0,("\n%s ***** Samba name server %s has stopped being a local master browser for workgroup %s \
-on subnet %s *****\n\n", timestring(), global_myname, fail_name->name, subrec->subnet_name));
+on subnet %s *****\n\n", timestring(), myname, fail_name->name, subrec->subnet_name));
}
@@ -254,11 +254,11 @@ void unbecome_local_master_browser(struct subnet_record *subrec, struct work_rec
DEBUG(2,("unbecome_local_master_browser: unbecoming local master for workgroup %s \
on subnet %s\n",work->work_group, subrec->subnet_name));
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("unbecome_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ myname, work->work_group, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -314,11 +314,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("become_local_master_stage2: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ myname, registered_name->name, subrec->subnet_name));
work->mst_state = lp_local_master() ? MST_POTENTIAL : MST_NONE;
return;
}
@@ -336,7 +336,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
subrec->work_changed = True;
/* Add this name to the workgroup as local master browser. */
- set_workgroup_local_master_browser_name( work, global_myname);
+ set_workgroup_local_master_browser_name( work, myname);
/* Count the number of servers we have on our list. If it's
less than 10 (just a heuristic) request the servers
@@ -369,7 +369,7 @@ on subnet %s\n", work->work_group, subrec->subnet_name));
reset_announce_timer();
DEBUG(0,("\n%s ***** Samba name server %s is now a local master browser for workgroup %s \
-on subnet %s *****\n\n", timestring(), global_myname, work->work_group, subrec->subnet_name));
+on subnet %s *****\n\n", timestring(), myname, work->work_group, subrec->subnet_name));
}
@@ -456,11 +456,11 @@ workgroup %s on subnet %s\n", work_name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup(work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup(work, myname)) == NULL)
{
DEBUG(0,("become_local_master_fail1: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ myname, work->work_group, subrec->subnet_name));
return;
}
@@ -499,11 +499,11 @@ void become_local_master_browser(struct subnet_record *subrec, struct work_recor
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("become_local_master_browser: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, work->work_group, subrec->subnet_name));
+ myname, work->work_group, subrec->subnet_name));
return;
}
diff --git a/source/nmbd/nmbd_browsesync.c b/source/nmbd/nmbd_browsesync.c
index c78fdfc5145..94bdecb8fcb 100644
--- a/source/nmbd/nmbd_browsesync.c
+++ b/source/nmbd/nmbd_browsesync.c
@@ -28,8 +28,8 @@
extern int DEBUGLEVEL;
extern pstring scope;
extern struct in_addr ipzero;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
/* This is our local master browser list database. */
extern struct browse_cache_record *lmb_browserlist;
@@ -244,7 +244,7 @@ Do not announce to ourselves.\n", work->work_group ));
CVAL(p,0) = ANN_MasterAnnouncement;
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,myname,15);
strupper(p);
p = skip_string(p,1);
@@ -252,7 +252,7 @@ Do not announce to ourselves.\n", work->work_group ));
to %s for workgroup %s.\n", namestr(&work->dmb_name), work->work_group ));
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, work->dmb_name.name, 0x0, work->dmb_addr, FIRST_SUBNET->myip);
+ myname, 0x0, work->dmb_name.name, 0x0, work->dmb_addr, FIRST_SUBNET->myip);
}
@@ -640,10 +640,10 @@ void collect_all_workgroup_names_from_wins_server(time_t t)
return;
/* Check to see if we are a domain master browser on the unicast subnet. */
- if((work = find_workgroup_on_subnet( unicast_subnet, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet( unicast_subnet, myworkgroup)) == NULL)
{
DEBUG(0,("collect_all_workgroup_names_from_wins_server: Cannot find my workgroup %s on subnet %s.\n",
- global_myworkgroup, unicast_subnet->subnet_name ));
+ myworkgroup, unicast_subnet->subnet_name ));
return;
}
diff --git a/source/nmbd/nmbd_elections.c b/source/nmbd/nmbd_elections.c
index 569b6531290..fa1e5986a8a 100644
--- a/source/nmbd/nmbd_elections.c
+++ b/source/nmbd/nmbd_elections.c
@@ -26,8 +26,8 @@
extern int DEBUGLEVEL;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
/* Election parameters. */
extern time_t StartupTime;
@@ -95,7 +95,7 @@ static void check_for_master_browser_fail( struct subnet_record *subrec,
return;
}
- if (strequal(work->work_group, global_myworkgroup))
+ if (strequal(work->work_group, myworkgroup))
{
if (lp_local_master())
@@ -117,7 +117,7 @@ static void check_for_master_browser_fail( struct subnet_record *subrec,
not to become the local master, but we still need one,
having detected that one doesn't exist.
*/
- send_election_dgram(subrec, work->work_group, 0, 0, global_myname);
+ send_election_dgram(subrec, work->work_group, 0, 0, myname);
}
}
}
@@ -131,7 +131,7 @@ void check_master_browser_exists(time_t t)
{
static time_t lastrun=0;
struct subnet_record *subrec;
- char *workgroup_name = global_myworkgroup;
+ char *workgroup_name = myworkgroup;
if (!lastrun)
lastrun = t;
@@ -186,7 +186,7 @@ void run_elections(time_t t)
if (work->RunningElection)
{
send_election_dgram(subrec, work->work_group, work->ElectionCriterion,
- t - StartupTime, global_myname);
+ t - StartupTime, myname);
if (work->ElectionCount++ >= 4)
{
@@ -225,7 +225,7 @@ static BOOL win_election(struct work_record *work, int version,
version, ELECTION_VERSION,
criterion, mycriterion,
timeup, mytimeup,
- server_name, global_myname));
+ server_name, myname));
if (version > ELECTION_VERSION)
return(False);
@@ -242,7 +242,7 @@ static BOOL win_election(struct work_record *work, int version,
if (timeup < mytimeup)
return(True);
- if (strcasecmp(global_myname, server_name) > 0)
+ if (strcasecmp(myname, server_name) > 0)
return(False);
return(True);
@@ -276,7 +276,7 @@ void process_election(struct subnet_record *subrec, struct packet_struct *p, cha
return;
}
- if (!strequal(work->work_group, global_myworkgroup))
+ if (!strequal(work->work_group, myworkgroup))
{
DEBUG(3,("process_election: ignoring election request for workgroup %s on subnet %s as this \
is not my workgroup.\n", work->work_group, subrec->subnet_name ));
diff --git a/source/nmbd/nmbd_incomingdgrams.c b/source/nmbd/nmbd_incomingdgrams.c
index 62dc444e0c3..80057ef12c9 100644
--- a/source/nmbd/nmbd_incomingdgrams.c
+++ b/source/nmbd/nmbd_incomingdgrams.c
@@ -26,8 +26,8 @@
extern int DEBUGLEVEL;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern BOOL found_lm_clients;
#if 0
@@ -143,8 +143,8 @@ void process_host_announce(struct subnet_record *subrec, struct packet_struct *p
* to be our primary workgroup name.
*/
- if(strequal(work_name, global_myname))
- work_name = global_myworkgroup;
+ if(strequal(work_name, myname))
+ work_name = myworkgroup;
/*
* We are being very agressive here in adding a workgroup
@@ -391,10 +391,10 @@ master - ignoring master announce.\n"));
return;
}
- if((work = find_workgroup_on_subnet(subrec, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(subrec, myworkgroup)) == NULL)
{
DEBUG(0,("process_master_browser_announce: Cannot find workgroup %s on subnet %s\n",
- global_myworkgroup, subrec->subnet_name));
+ myworkgroup, subrec->subnet_name));
return;
}
@@ -481,8 +481,8 @@ originate from OS/2 Warp client. Ignoring packet.\n"));
* not needed in the LanMan announce code, but it won't hurt.
*/
- if(strequal(work_name, global_myname))
- work_name = global_myworkgroup;
+ if(strequal(work_name, myname))
+ work_name = myworkgroup;
/*
* We are being very agressive here in adding a workgroup
@@ -571,7 +571,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
/* We always return at least one name - our own. */
count = 1;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,myname,15);
strupper(p);
p = skip_string(p,1);
@@ -585,7 +585,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
if(count >= (unsigned int)max_number_requested)
break;
- if(strnequal(servrec->serv.name, global_myname,15))
+ if(strnequal(servrec->serv.name, myname,15))
continue;
if(!(servrec->serv.type & SV_TYPE_BACKUP_BROWSER))
@@ -610,7 +610,7 @@ static void send_backup_list_response(struct subnet_record *subrec,
send_mailslot(True, BROWSE_MAILSLOT,
outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0,
+ myname, 0,
send_to_name->name,0,
sendto_ip, subrec->myip);
}
@@ -643,7 +643,7 @@ void process_get_backup_list_request(struct subnet_record *subrec,
for the requested workgroup. That means it must be our
workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, myworkgroup) == False)
{
DEBUG(7,("process_get_backup_list_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
@@ -769,7 +769,7 @@ void process_announce_request(struct subnet_record *subrec, struct packet_struct
namestr(&dgram->dest_name)));
/* We only send announcement requests on our workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, myworkgroup) == False)
{
DEBUG(7,("process_announce_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
@@ -806,7 +806,7 @@ void process_lm_announce_request(struct subnet_record *subrec, struct packet_str
namestr(&dgram->dest_name)));
/* We only send announcement requests on our workgroup. */
- if(strequal(workgroup_name, global_myworkgroup) == False)
+ if(strequal(workgroup_name, myworkgroup) == False)
{
DEBUG(7,("process_lm_announce_request: Ignoring announce request for workgroup %s.\n",
workgroup_name));
diff --git a/source/nmbd/nmbd_incomingrequests.c b/source/nmbd/nmbd_incomingrequests.c
index e1c56f591f4..ae163c60145 100644
--- a/source/nmbd/nmbd_incomingrequests.c
+++ b/source/nmbd/nmbd_incomingrequests.c
@@ -29,7 +29,7 @@
#include "includes.h"
extern int DEBUGLEVEL;
-extern fstring global_myworkgroup;
+extern fstring myworkgroup;
/****************************************************************************
Send a name release response.
@@ -102,7 +102,7 @@ subnet %s from owner IP %s\n",
* names and *don't set the group bit* !!!!!
*/
- if( !group && !ismyip(owner_ip) && strequal(question->name, global_myworkgroup) &&
+ if( !group && !ismyip(owner_ip) && strequal(question->name, myworkgroup) &&
((question->name_type == 0x0) || (question->name_type == 0x1e)))
{
DEBUG(6,("process_name_release_request: FTP OnNet bug workaround. Ignoring \
@@ -290,20 +290,20 @@ We put our own names first, then in alphabetical order.
static int status_compare(char *n1,char *n2)
{
- extern pstring global_myname;
+ extern pstring myname;
int l1,l2,l3;
/* It's a bit tricky because the names are space padded */
for (l1=0;l1<15 && n1[l1] && n1[l1] != ' ';l1++) ;
for (l2=0;l2<15 && n2[l2] && n2[l2] != ' ';l2++) ;
- l3 = strlen(global_myname);
+ l3 = strlen(myname);
- if ((l1==l3) && strncmp(n1,global_myname,l3) == 0 &&
- (l2!=l3 || strncmp(n2,global_myname,l3) != 0))
+ if ((l1==l3) && strncmp(n1,myname,l3) == 0 &&
+ (l2!=l3 || strncmp(n2,myname,l3) != 0))
return -1;
- if ((l2==l3) && strncmp(n2,global_myname,l3) == 0 &&
- (l1!=l3 || strncmp(n1,global_myname,l3) != 0))
+ if ((l2==l3) && strncmp(n2,myname,l3) == 0 &&
+ (l1!=l3 || strncmp(n1,myname,l3) != 0))
return 1;
return memcmp(n1,n2,18);
diff --git a/source/nmbd/nmbd_logonnames.c b/source/nmbd/nmbd_logonnames.c
index dbbb8defafb..8b5bc0defe6 100644
--- a/source/nmbd/nmbd_logonnames.c
+++ b/source/nmbd/nmbd_logonnames.c
@@ -27,8 +27,8 @@
extern int DEBUGLEVEL;
extern pstring scope;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern char **my_netbios_names;
extern struct in_addr ipzero;
extern struct in_addr allones_ip;
@@ -52,11 +52,11 @@ workgroup %s on subnet %s\n", fail_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("become_logon_server_fail: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, fail_name->name, subrec->subnet_name));
+ myname, fail_name->name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -92,11 +92,11 @@ workgroup %s on subnet %s\n", registered_name->name, subrec->subnet_name));
return;
}
- if((servrec = find_server_in_workgroup( work, global_myname)) == NULL)
+ if((servrec = find_server_in_workgroup( work, myname)) == NULL)
{
DEBUG(0,("become_logon_server_success: Error - cannot find server %s \
in workgroup %s on subnet %s\n",
- global_myname, registered_name->name, subrec->subnet_name));
+ myname, registered_name->name, subrec->subnet_name));
work->log_state = LOGON_NONE;
return;
}
@@ -147,17 +147,17 @@ void add_logon_names(void)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, myworkgroup);
if (work && (work->log_state == LOGON_NONE))
{
struct nmb_name nmbname;
- make_nmb_name(&nmbname,global_myworkgroup,0x1c,scope);
+ make_nmb_name(&nmbname,myworkgroup,0x1c,scope);
if (find_name_on_subnet(subrec, &nmbname, FIND_SELF_NAME) == NULL)
{
DEBUG(0,("add_domain_logon_names: At time %s attempting to become \
-logon server for workgroup %s on subnet %s\n", timestring(), global_myworkgroup,
+logon server for workgroup %s on subnet %s\n", timestring(), myworkgroup,
subrec->subnet_name));
become_logon_server(subrec, work);
}
diff --git a/source/nmbd/nmbd_mynames.c b/source/nmbd/nmbd_mynames.c
index 92ea3ea1543..cf21fafd876 100644
--- a/source/nmbd/nmbd_mynames.c
+++ b/source/nmbd/nmbd_mynames.c
@@ -27,7 +27,8 @@
extern int DEBUGLEVEL;
extern char **my_netbios_names;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern pstring scope;
extern uint16 samba_nb_type; /* Samba's NetBIOS type. */
@@ -57,10 +58,10 @@ BOOL register_my_workgroup_and_names(void)
for(subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
/* Create the workgroup on the subnet. */
- if((work = create_workgroup_on_subnet(subrec, global_myworkgroup, PERMANENT_TTL)) == NULL)
+ if((work = create_workgroup_on_subnet(subrec, myworkgroup, PERMANENT_TTL)) == NULL)
{
DEBUG(0,("register_my_workgroup_and_names: Failed to create my workgroup %s on subnet %s. \
-Exiting.\n", global_myworkgroup, subrec->subnet_name));
+Exiting.\n", myworkgroup, subrec->subnet_name));
return False;
}
@@ -127,10 +128,10 @@ Exiting.\n", global_myworkgroup, subrec->subnet_name));
*/
struct nmb_name nmbname;
- make_nmb_name(&nmbname, global_myworkgroup, 0x0, scope);
+ make_nmb_name(&nmbname, myworkgroup, 0x0, scope);
insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
- make_nmb_name(&nmbname, global_myworkgroup, 0x1e, scope);
+ make_nmb_name(&nmbname, myworkgroup, 0x1e, scope);
insert_permanent_name_into_unicast(subrec, &nmbname, samba_nb_type|NB_GROUP);
}
}
diff --git a/source/nmbd/nmbd_nameregister.c b/source/nmbd/nmbd_nameregister.c
index 8eae5e0f1cd..a3e4208cdcd 100644
--- a/source/nmbd/nmbd_nameregister.c
+++ b/source/nmbd/nmbd_nameregister.c
@@ -27,7 +27,7 @@
extern int DEBUGLEVEL;
extern pstring scope;
-extern fstring global_myworkgroup;
+extern fstring myworkgroup;
/****************************************************************************
Deal with a response packet when registering one of our names.
@@ -73,7 +73,7 @@ name %s.\n", namestr(answer_name), namestr(question_name)));
*/
#if 1 /* OLD_SAMBA_SERVER_HACK */
- if((nmb->header.rcode == ACT_ERR) && strequal(global_myworkgroup, answer_name->name) &&
+ if((nmb->header.rcode == ACT_ERR) && strequal(myworkgroup, answer_name->name) &&
(answer_name->name_type == 0x1b))
{
/* Pretend we did not get this. */
diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c
index 50b6052c673..b102f60e65c 100644
--- a/source/nmbd/nmbd_processlogon.c
+++ b/source/nmbd/nmbd_processlogon.c
@@ -28,8 +28,8 @@
extern int DEBUGLEVEL;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
/****************************************************************************
Process a domain logon packet
@@ -68,7 +68,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
return;
}
- strcpy(my_name, global_myname);
+ strcpy(my_name, myname);
strupper(my_name);
code = SVAL(buf,0);
@@ -145,7 +145,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
PutUniCode(q, my_name); /* PDC name */
q = skip_unicode_string(q, 1);
- PutUniCode(q, global_myworkgroup); /* Domain name*/
+ PutUniCode(q, myworkgroup); /* Domain name*/
q = skip_unicode_string(q, 1);
SIVAL(q, 0, ntversion); q += 4;
@@ -201,24 +201,18 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
strcpy(reply_name,"\\\\"); /* Here it wants \\LOGONSERVER. */
strcpy(reply_name+2,my_name);
- smb_pass = getsampwnam(ascuser);
+ smb_pass = get_smbpwd_entry(ascuser, 0);
- if(!smb_pass )
+ if(!smb_pass)
{
DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, not in password file\n",
unistr(unicomp),inet_ntoa(p->ip), ascuser));
return;
}
- else if(smb_pass->acct_ctrl & ACB_DISABLED)
- {
- DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, accound disabled.\n",
- unistr(unicomp),inet_ntoa(p->ip), ascuser));
- return;
- }
else
{
DEBUG(3,("process_logon_packet: SAMLOGON request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n",
- unistr(unicomp),inet_ntoa(p->ip), ascuser, reply_name, global_myworkgroup,
+ unistr(unicomp),inet_ntoa(p->ip), ascuser, reply_name, myworkgroup,
SAMLOGON_R ,lmnttoken));
}
diff --git a/source/nmbd/nmbd_responserecordsdb.c b/source/nmbd/nmbd_responserecordsdb.c
index 6dae0d43e92..ceace36a619 100644
--- a/source/nmbd/nmbd_responserecordsdb.c
+++ b/source/nmbd/nmbd_responserecordsdb.c
@@ -29,6 +29,7 @@ extern int ClientNMB;
extern int DEBUGLEVEL;
extern pstring scope;
+extern pstring myname;
extern struct in_addr ipzero;
int num_response_packets = 0;
diff --git a/source/nmbd/nmbd_sendannounce.c b/source/nmbd/nmbd_sendannounce.c
index 3936b7e92e1..48072650c21 100644
--- a/source/nmbd/nmbd_sendannounce.c
+++ b/source/nmbd/nmbd_sendannounce.c
@@ -28,8 +28,8 @@
#include "includes.h"
extern int DEBUGLEVEL;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern char **my_netbios_names;
extern int updatecount;
extern BOOL found_lm_clients;
@@ -54,7 +54,7 @@ void send_browser_reset(int reset_type, char *to_name, int to_type, struct in_ad
p++;
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip);
+ myname, 0x0, to_name, to_type, to_ip, FIRST_SUBNET->myip);
}
/****************************************************************************
@@ -79,12 +79,12 @@ to subnet %s\n", work->work_group, subrec->subnet_name));
CVAL(p,0) = work->token; /* (local) Unique workgroup token id. */
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,myname,15);
strupper(p);
p = skip_string(p,1);
send_mailslot(False, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip);
+ myname, 0x0, work->work_group,0x1e, subrec->bcast_ip, subrec->myip);
}
/****************************************************************************
@@ -169,14 +169,14 @@ static void send_local_master_announcement(struct subnet_record *subrec, struct
uint32 type = servrec->serv.type & ~SV_TYPE_LOCAL_LIST_ONLY;
DEBUG(3,("send_local_master_announcement: type %x for name %s on subnet %s for workgroup %s\n",
- type, global_myname, subrec->subnet_name, work->work_group));
+ type, myname, subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_LocalMasterAnnouncement,
- global_myname, /* From nbt name. */
+ myname, /* From nbt name. */
work->work_group, 0x1e, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
- global_myname, /* Name to announce. */
+ myname, /* Name to announce. */
type, /* Type field. */
servrec->serv.comment);
}
@@ -191,13 +191,13 @@ static void send_workgroup_announcement(struct subnet_record *subrec, struct wor
subrec->subnet_name, work->work_group));
send_announcement(subrec, ANN_DomainAnnouncement,
- global_myname, /* From nbt name. */
+ myname, /* From nbt name. */
MSBROWSE, 0x1, /* To nbt name. */
subrec->bcast_ip, /* To ip. */
work->announce_interval, /* Time until next announce. */
work->work_group, /* Name to announce. */
SV_TYPE_DOMAIN_ENUM|SV_TYPE_NT, /* workgroup announce flags. */
- global_myname); /* From name as comment. */
+ myname); /* From name as comment. */
}
/****************************************************************************
@@ -256,7 +256,7 @@ static void announce_server(struct subnet_record *subrec, struct work_record *wo
/* Only do domain announcements if we are a master and it's
our primary name we're being asked to announce. */
- if (AM_LOCAL_MASTER_BROWSER(work) && strequal(global_myname,servrec->serv.name))
+ if (AM_LOCAL_MASTER_BROWSER(work) && strequal(myname,servrec->serv.name))
{
send_local_master_announcement(subrec, work, servrec);
send_workgroup_announcement(subrec, work);
@@ -278,7 +278,7 @@ void announce_my_server_names(time_t t)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, myworkgroup);
if(work)
{
@@ -342,7 +342,7 @@ void announce_my_lm_server_names(time_t t)
for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
{
- struct work_record *work = find_workgroup_on_subnet(subrec, global_myworkgroup);
+ struct work_record *work = find_workgroup_on_subnet(subrec, myworkgroup);
if(work)
{
@@ -512,7 +512,7 @@ void announce_remote(time_t t)
if (wgroup)
*wgroup++ = 0;
if (!wgroup || !*wgroup)
- wgroup = global_myworkgroup;
+ wgroup = myworkgroup;
addr = *interpret_addr2(s2);
@@ -568,17 +568,17 @@ void browse_sync_remote(time_t t)
* for our workgroup on the firsst subnet.
*/
- if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(FIRST_SUBNET, myworkgroup)) == NULL)
{
DEBUG(0,("browse_sync_remote: Cannot find workgroup %s on subnet %s\n",
- global_myworkgroup, FIRST_SUBNET->subnet_name ));
+ myworkgroup, FIRST_SUBNET->subnet_name ));
return;
}
if(!AM_LOCAL_MASTER_BROWSER(work))
{
DEBUG(5,("browse_sync_remote: We can only do this if we are a local master browser \
-for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name ));
+for workgroup %s on subnet %s.\n", myworkgroup, FIRST_SUBNET->subnet_name ));
return;
}
@@ -587,7 +587,7 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name
CVAL(p,0) = ANN_MasterAnnouncement;
p++;
- StrnCpy(p,global_myname,15);
+ StrnCpy(p,myname,15);
strupper(p);
p = skip_string(p,1);
@@ -597,9 +597,9 @@ for workgroup %s on subnet %s.\n", global_myworkgroup, FIRST_SUBNET->subnet_name
addr = *interpret_addr2(s2);
DEBUG(5,("announce_remote: Doing remote browse sync announce for server %s to IP %s.\n",
- global_myname, inet_ntoa(addr) ));
+ myname, inet_ntoa(addr) ));
send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
- global_myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip);
+ myname, 0x0, "*", 0x0, addr, FIRST_SUBNET->myip);
}
}
diff --git a/source/nmbd/nmbd_serverlistdb.c b/source/nmbd/nmbd_serverlistdb.c
index 64ca49cdbcc..58b4fbfa95e 100644
--- a/source/nmbd/nmbd_serverlistdb.c
+++ b/source/nmbd/nmbd_serverlistdb.c
@@ -29,7 +29,8 @@ extern int ClientNMB;
extern int DEBUGLEVEL;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern char **my_netbios_names;
int updatecount = 0;
@@ -258,7 +259,7 @@ static uint32 write_this_server_name( struct subnet_record *subrec,
/*******************************************************************
Decide if we should write out a workgroup record for this workgroup.
- We return zero if we should not. Don't write out global_myworkgroup (we've
+ We return zero if we should not. Don't write out myworkgroup (we've
already done it) and also don't write out a second workgroup record
on the unicast subnet that we've already written out on one of the
broadcast subnets.
@@ -269,7 +270,7 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
{
struct subnet_record *ssub;
- if(strequal(global_myworkgroup, work->work_group))
+ if(strequal(myworkgroup, work->work_group))
return 0;
/* This is a workgroup we have seen on a broadcast subnet. All
@@ -357,10 +358,10 @@ void write_browse_list(time_t t, BOOL force_write)
* subnet.
*/
- if((work = find_workgroup_on_subnet(FIRST_SUBNET, global_myworkgroup)) == NULL)
+ if((work = find_workgroup_on_subnet(FIRST_SUBNET, myworkgroup)) == NULL)
{
DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n",
- global_myworkgroup));
+ myworkgroup));
fclose(fp);
return;
}
@@ -385,7 +386,7 @@ void write_browse_list(time_t t, BOOL force_write)
stype = 0;
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
{
- if((work = find_workgroup_on_subnet( subrec, global_myworkgroup )) == NULL)
+ if((work = find_workgroup_on_subnet( subrec, myworkgroup )) == NULL)
continue;
if((servrec = find_server_in_workgroup( work, my_netbios_names[i])) == NULL)
continue;
@@ -399,7 +400,7 @@ void write_browse_list(time_t t, BOOL force_write)
fprintf(fp, "%08x ", stype);
slprintf(tmp, sizeof(tmp)-1, "\"%s\" ", lp_serverstring());
fprintf(fp, "%-30s", tmp);
- fprintf(fp, "\"%s\"\n", global_myworkgroup);
+ fprintf(fp, "\"%s\"\n", myworkgroup);
}
for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec))
diff --git a/source/nmbd/nmbd_subnetdb.c b/source/nmbd/nmbd_subnetdb.c
index 34287bbe699..d8e8dd4ab90 100644
--- a/source/nmbd/nmbd_subnetdb.c
+++ b/source/nmbd/nmbd_subnetdb.c
@@ -33,6 +33,7 @@ extern int global_nmb_port;
extern int DEBUGLEVEL;
+extern pstring myname;
extern fstring myworkgroup;
extern char **my_netbios_names;
extern struct in_addr ipzero;
diff --git a/source/nmbd/nmbd_workgroupdb.c b/source/nmbd/nmbd_workgroupdb.c
index 0b392680df6..b8345257474 100644
--- a/source/nmbd/nmbd_workgroupdb.c
+++ b/source/nmbd/nmbd_workgroupdb.c
@@ -29,8 +29,8 @@ extern int ClientNMB;
extern int DEBUGLEVEL;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
+extern pstring myname;
+extern fstring myworkgroup;
extern char **my_netbios_names;
extern uint16 samba_nb_type;
extern struct in_addr ipzero;
@@ -246,7 +246,7 @@ void initiate_myworkgroup_startup(struct subnet_record *subrec, struct work_reco
{
int i;
- if(!strequal(global_myworkgroup, work->work_group))
+ if(!strequal(myworkgroup, work->work_group))
return;
/* If this is a broadcast subnet then start elections on it
@@ -264,11 +264,11 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));
/* Register the WORKGROUP<0> and WORKGROUP<1e> names on the network. */
- register_name(subrec,global_myworkgroup,0x0,samba_nb_type|NB_GROUP,
+ register_name(subrec,myworkgroup,0x0,samba_nb_type|NB_GROUP,
NULL,
fail_register,NULL);
- register_name(subrec,global_myworkgroup,0x1e,samba_nb_type|NB_GROUP,
+ register_name(subrec,myworkgroup,0x1e,samba_nb_type|NB_GROUP,
NULL,
fail_register,NULL);
@@ -278,7 +278,7 @@ workgroup %s on subnet %s\n", work->work_group, subrec->subnet_name));
int stype = lp_default_server_announce() | (lp_local_master() ?
SV_TYPE_POTENTIAL_BROWSER : 0 );
- if(!strequal(global_myname, name))
+ if(!strequal(myname, name))
stype &= ~(SV_TYPE_MASTER_BROWSER|SV_TYPE_POTENTIAL_BROWSER|
SV_TYPE_DOMAIN_MASTER|SV_TYPE_DOMAIN_MEMBER);
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 1b95005c6c4..8ea725f5e05 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -69,7 +69,7 @@ BOOL bLoaded = False;
extern int DEBUGLEVEL;
extern pstring user_socket_options;
-extern pstring global_myname;
+extern pstring myname;
#ifndef GLOBAL_NAME
#define GLOBAL_NAME "global"
@@ -89,13 +89,23 @@ extern pstring global_myname;
#define LP_SNUM_OK(iService) (((iService) >= 0) && ((iService) < iNumServices) && iSERVICE(iService).valid)
#define VALID(i) iSERVICE(i).valid
-int keepalive=DEFAULT_KEEPALIVE;
+/* these are the types of parameter we have */
+typedef enum
+{
+ P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
+ P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM
+} parm_type;
+
+typedef enum
+{
+ P_LOCAL,P_GLOBAL,P_NONE
+} parm_class;
+
+int keepalive=0;
extern BOOL use_getwd_cache;
extern int extra_time_offset;
-static BOOL defaults_saved=False;
-
/*
* This structure describes global (ie., server-wide) parameters.
*/
@@ -144,11 +154,6 @@ typedef struct
char *szDomainGroups;
char *szDriverFile;
char *szNameResolveOrder;
- char *szLdapServer;
- char *szLdapSuffix;
- char *szLdapFilter;
- char *szLdapRoot;
- char *szLdapRootPassword;
int max_log_size;
int mangled_stack;
int max_xmit;
@@ -172,9 +177,6 @@ typedef struct
int shmem_size;
int client_code_page;
int announce_as; /* This is initialised in init_globals */
-#ifdef USE_LDAP
- int ldap_port;
-#endif /* USE_LDAP */
BOOL bDNSproxy;
BOOL bWINSsupport;
BOOL bWINSproxy;
@@ -406,14 +408,18 @@ static BOOL handle_coding_system(char *pszParmValue,char **ptr);
static void set_default_server_announce_type(void);
+struct enum_list {
+ int value;
+ char *name;
+};
+
static struct enum_list enum_protocol[] = {{PROTOCOL_NT1, "NT1"}, {PROTOCOL_LANMAN2, "LANMAN2"},
{PROTOCOL_LANMAN1, "LANMAN1"}, {PROTOCOL_CORE,"CORE"},
{PROTOCOL_COREPLUS, "COREPLUS"},
{PROTOCOL_COREPLUS, "CORE+"}, {-1, NULL}};
static struct enum_list enum_security[] = {{SEC_SHARE, "SHARE"}, {SEC_USER, "USER"},
- {SEC_SERVER, "SERVER"}, {SEC_DOMAIN, "DOMAIN"},
- {-1, NULL}};
+ {SEC_SERVER, "SERVER"}, {-1, NULL}};
static struct enum_list enum_printing[] = {{PRINT_SYSV, "sysv"}, {PRINT_AIX, "aix"},
{PRINT_HPUX, "hpux"}, {PRINT_BSD, "bsd"},
@@ -428,254 +434,226 @@ static struct enum_list enum_case[] = {{CASE_LOWER, "lower"}, {CASE_UPPER, "uppe
static struct enum_list enum_lm_announce[] = {{0, "False"}, {1, "True"}, {2, "Auto"}, {-1, NULL}};
-/* note that we do not initialise the defaults union - it is not allowed in ANSI C */
-static struct parm_struct parm_table[] =
+static struct parm_struct
{
- {"Base Options", P_SEP, P_SEPARATOR},
- {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL, FLAG_BASIC|FLAG_PRINT},
- {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, FLAG_BASIC|FLAG_PRINT},
- {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL, 0},
- {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL, FLAG_BASIC},
- {"netbios name", P_UGSTRING,P_GLOBAL, global_myname, NULL, NULL, FLAG_BASIC},
- {"netbios aliases", P_STRING, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL, 0},
- {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL, FLAG_BASIC},
- {"interfaces", P_STRING, P_GLOBAL, &Globals.szInterfaces, NULL, NULL, FLAG_BASIC},
- {"bind interfaces only", P_BOOL,P_GLOBAL, &Globals.bBindInterfacesOnly,NULL, NULL, 0},
-
- {"Security Options", P_SEP, P_SEPARATOR},
- {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security, FLAG_BASIC},
- {"encrypt passwords",P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL, FLAG_BASIC},
- {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL, FLAG_BASIC},
- {"use rhosts", P_BOOL, P_GLOBAL, &Globals.bUseRhosts, NULL, NULL, 0},
- {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL, 0},
- {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL, 0},
- {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL, 0},
- {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL, 0},
- {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
- {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
- {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
- {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL, 0},
- {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL, 0},
- {"passwd chat debug",P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL, 0},
- {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL, 0},
- {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL, 0},
- {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL, 0},
- {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL, 0},
- {"alternate permissions",P_BOOL,P_LOCAL, &sDefault.bAlternatePerm, NULL, NULL, FLAG_GLOBAL},
- {"revalidate", P_BOOL, P_LOCAL, &sDefault.bRevalidate, NULL, NULL, FLAG_GLOBAL},
- {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, FLAG_GLOBAL},
- {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, 0},
- {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL, 0},
- {"guest account", P_STRING, P_LOCAL, &sDefault.szGuestaccount, NULL, NULL, FLAG_BASIC|FLAG_PRINT|FLAG_GLOBAL},
- {"invalid users", P_STRING, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL, FLAG_GLOBAL},
- {"valid users", P_STRING, P_LOCAL, &sDefault.szValidUsers, NULL, NULL, FLAG_GLOBAL},
- {"admin users", P_STRING, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL, FLAG_GLOBAL},
- {"read list", P_STRING, P_LOCAL, &sDefault.readlist, NULL, NULL, FLAG_GLOBAL},
- {"write list", P_STRING, P_LOCAL, &sDefault.writelist, NULL, NULL, FLAG_GLOBAL},
- {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL, 0},
- {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, 0},
- {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL, 0},
- {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL, FLAG_BASIC},
- {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
- {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
- {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL, 0},
- {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL},
- {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL, FLAG_GLOBAL},
- {"force create mode",P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL, FLAG_GLOBAL},
- {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL},
- {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL, FLAG_GLOBAL},
- {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL, FLAG_GLOBAL},
- {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, 0},
- {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL, 0},
- {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, FLAG_BASIC|FLAG_PRINT},
- {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL, 0},
- {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL, 0},
- {"hosts allow", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_GLOBAL|FLAG_BASIC|FLAG_PRINT},
- {"allow hosts", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, 0},
- {"hosts deny", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL|FLAG_BASIC|FLAG_PRINT},
- {"deny hosts", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, 0},
-
- {"Logging Options", P_SEP, P_SEPARATOR},
- {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL, FLAG_BASIC},
- {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL, 0},
- {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL, 0},
- {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL, 0},
- {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL, 0},
- {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, 0},
- {"status", P_BOOL, P_LOCAL, &sDefault.status, NULL, NULL, FLAG_GLOBAL},
-
- {"Protocol Options", P_SEP, P_SEPARATOR},
- {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol, 0},
- {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL, 0},
- {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL, 0},
- {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL, 0},
- {"networkstation user login", P_BOOL,P_GLOBAL, &Globals.bNetWkstaUserLogon,NULL, NULL, 0},
- {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL, 0},
- {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as, 0},
- {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL, 0},
- {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL, 0},
- {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL, 0},
- {"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL, 0},
- {"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL, 0},
- {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL, 0},
- {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL, 0},
- {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL, 0},
- {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, 0},
-
- {"Tuning Options", P_SEP, P_SEPARATOR},
- {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL, 0},
- {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL, 0},
- {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, 0},
- {"read prediction", P_BOOL, P_GLOBAL, &Globals.bReadPrediction, NULL, NULL, 0},
- {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL, 0},
- {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL, 0},
- {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, 0},
- {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL, NULL, 0},
- {"shared mem size", P_INTEGER, P_GLOBAL, &Globals.shmem_size, NULL, NULL, 0},
- {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL, 0},
- {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL, 0},
- {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, 0},
-
- {"Printing Options", P_SEP, P_SEPARATOR},
- {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, 0},
- {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, 0},
- {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, 0},
- {"printer driver file", P_STRING, P_GLOBAL, &Globals.szDriverFile, NULL, NULL, 0},
- {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, 0},
- {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, 0},
- {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL, NULL, FLAG_PRINT},
- {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, NULL, enum_printing, FLAG_PRINT|FLAG_GLOBAL},
- {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL, FLAG_PRINT|FLAG_GLOBAL},
- {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL, FLAG_PRINT|FLAG_GLOBAL},
- {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL, FLAG_PRINT|FLAG_GLOBAL},
- {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL, FLAG_GLOBAL},
- {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand,NULL, NULL, FLAG_GLOBAL},
- {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT},
- {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, 0},
- {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL, 0},
- {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL, FLAG_GLOBAL},
-
-
- {"Filename Handling", P_SEP, P_SEPARATOR},
- {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL, NULL, 0},
- {"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set, NULL, 0},
- {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL, NULL, 0},
- {"coding system", P_STRING, P_GLOBAL, &Globals.szCodingSystem, handle_coding_system, NULL, 0},
- {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL, NULL, 0},
- {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case, 0},
- {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, FLAG_GLOBAL},
- {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL, 0},
- {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL, FLAG_GLOBAL},
- {"short preserve case",P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve,NULL, NULL, FLAG_GLOBAL},
- {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL, NULL, FLAG_GLOBAL},
- {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL, FLAG_GLOBAL},
- {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL, FLAG_GLOBAL},
- {"delete veto files",P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL, FLAG_GLOBAL},
- {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL, FLAG_GLOBAL},
- {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL, FLAG_GLOBAL},
- {"veto oplock files",P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles,NULL, NULL, FLAG_GLOBAL},
- {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL, FLAG_GLOBAL},
- {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL, FLAG_GLOBAL},
- {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL, FLAG_GLOBAL},
- {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL, FLAG_GLOBAL},
- {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL, FLAG_GLOBAL},
-
- {"Domain Options", P_SEP, P_SEPARATOR},
- {"domain sid", P_USTRING, P_GLOBAL, &Globals.szDomainSID, NULL, NULL, 0},
- {"domain other sids",P_STRING, P_GLOBAL, &Globals.szDomainOtherSIDs, NULL, NULL, 0},
- {"domain groups", P_STRING, P_GLOBAL, &Globals.szDomainGroups, NULL, NULL, 0},
- {"domain controller",P_BOOL , P_GLOBAL, &Globals.bDomainController,NULL, NULL, 0},
- {"domain admin users",P_STRING, P_GLOBAL, &Globals.szDomainAdminUsers, NULL, NULL, 0},
- {"domain guest users",P_STRING, P_GLOBAL, &Globals.szDomainGuestUsers, NULL, NULL, 0},
- {"domain hosts allow",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL, NULL, 0},
- {"domain allow hosts",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL, NULL, 0},
- {"domain hosts deny", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL, NULL, 0},
- {"domain deny hosts", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL, NULL, 0},
-
- {"Logon Options", P_SEP, P_SEPARATOR},
- {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, 0},
- {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, 0},
- {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL, 0},
- {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL, 0},
- {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL, 0},
-
- {"Browse Options", P_SEP, P_SEPARATOR},
- {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL, FLAG_BASIC},
- {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_lm_announce, 0},
- {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL, 0},
- {"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL, NULL, FLAG_BASIC},
- {"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL, NULL, 0},
- {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL, FLAG_BASIC},
- {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL, NULL, FLAG_BASIC},
- {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL, 0},
- {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, 0},
- {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL, 0},
-
- {"WINS Options", P_SEP, P_SEPARATOR},
- {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, 0},
- {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC},
- {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, 0},
- {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL, NULL, FLAG_BASIC},
-
- {"Locking Options", P_SEP, P_SEPARATOR},
- {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_GLOBAL},
- {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_GLOBAL},
- {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL, FLAG_GLOBAL},
- {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_GLOBAL},
- {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, 0},
-
-#ifdef USE_LDAP
- {"Ldap Options", P_SEP, P_SEPARATOR},
- {"ldap server", P_STRING, P_GLOBAL, &Globals.szLdapServer, NULL, NULL, 0},
- {"ldap port", P_INTEGER, P_GLOBAL, &Globals.ldap_port, NULL, NULL, 0},
- {"ldap suffix", P_STRING, P_GLOBAL, &Globals.szLdapSuffix, NULL, NULL, 0},
- {"ldap filter", P_STRING, P_GLOBAL, &Globals.szLdapFilter, NULL, NULL, 0},
- {"ldap root", P_STRING, P_GLOBAL, &Globals.szLdapRoot, NULL, NULL, 0},
- {"ldap root passwd", P_STRING, P_GLOBAL, &Globals.szLdapRootPassword,NULL, NULL, 0},
-#endif /* USE_LDAP */
-
-
- {"Miscellaneous Options", P_SEP, P_SEPARATOR},
- {"smbrun", P_STRING, P_GLOBAL, &Globals.szSmbrun, NULL, NULL, 0},
- {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
- {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, 0},
- {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, 0},
- {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0},
- {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0},
- {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, 0},
- {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL, 0},
- {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL, 0},
- {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL, 0},
- {"valid chars", P_STRING, P_GLOBAL, &Globals.szValidChars, handle_valid_chars, NULL, 0},
- {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL, 0},
- {"remote browse sync",P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync,NULL, NULL, 0},
- {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL, 0},
- {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL, 0},
- {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL, 0},
- {"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL, NULL, 0},
- {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL, 0},
- {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL, FLAG_HIDE},
- {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL, FLAG_HIDE},
- {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL, FLAG_HIDE},
- {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, 0},
- {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL, 0},
- {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL, 0},
- {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL, 0},
- {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL, 0},
- {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL, 0},
- {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL, 0},
- {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL, 0},
- {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL, FLAG_GLOBAL},
- {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL, FLAG_GLOBAL},
- {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL, 0},
- {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL, 0},
- {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL, 0},
- {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL, FLAG_GLOBAL},
- {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL, FLAG_GLOBAL},
- {"dos filetime resolution",P_BOOL,P_LOCAL,&sDefault.bDosFiletimeResolution, NULL, NULL, FLAG_GLOBAL},
-
- {"fake directory create times", P_BOOL,P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_GLOBAL},
- {NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
+ char *label;
+ parm_type type;
+ parm_class class;
+ void *ptr;
+ BOOL (*special)(char *, char **);
+ struct enum_list *enum_list;
+} parm_table[] =
+{
+ {"debuglevel", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL},
+ {"log level", P_INTEGER, P_GLOBAL, &DEBUGLEVEL, NULL, NULL},
+ {"syslog", P_INTEGER, P_GLOBAL, &Globals.syslog, NULL, NULL},
+ {"syslog only", P_BOOL, P_GLOBAL, &Globals.bSyslogOnly, NULL, NULL},
+ {"protocol", P_ENUM, P_GLOBAL, &Globals.maxprotocol, NULL, enum_protocol},
+ {"security", P_ENUM, P_GLOBAL, &Globals.security, NULL, enum_security},
+ {"max disk size", P_INTEGER, P_GLOBAL, &Globals.maxdisksize, NULL, NULL},
+ {"lpq cache time", P_INTEGER, P_GLOBAL, &Globals.lpqcachetime, NULL, NULL},
+ {"announce as", P_ENUM, P_GLOBAL, &Globals.announce_as, NULL, enum_announce_as},
+ {"encrypt passwords",P_BOOL, P_GLOBAL, &Globals.bEncryptPasswords, NULL, NULL},
+ {"update encrypted", P_BOOL, P_GLOBAL, &Globals.bUpdateEncrypt, NULL, NULL},
+ {"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL},
+ {"read prediction", P_BOOL, P_GLOBAL, &Globals.bReadPrediction, NULL, NULL},
+ {"read bmpx", P_BOOL, P_GLOBAL, &Globals.bReadbmpx, NULL, NULL},
+ {"read raw", P_BOOL, P_GLOBAL, &Globals.bReadRaw, NULL, NULL},
+ {"write raw", P_BOOL, P_GLOBAL, &Globals.bWriteRaw, NULL, NULL},
+ {"use rhosts", P_BOOL, P_GLOBAL, &Globals.bUseRhosts, NULL, NULL},
+ {"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL},
+ {"null passwords", P_BOOL, P_GLOBAL, &Globals.bNullPasswords, NULL, NULL},
+ {"strip dot", P_BOOL, P_GLOBAL, &Globals.bStripDot, NULL, NULL},
+ {"interfaces", P_STRING, P_GLOBAL, &Globals.szInterfaces, NULL, NULL},
+ {"bind interfaces only", P_BOOL,P_GLOBAL, &Globals.bBindInterfacesOnly,NULL, NULL},
+ {"networkstation user login", P_BOOL,P_GLOBAL, &Globals.bNetWkstaUserLogon,NULL, NULL},
+ {"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL},
+ {"socket options", P_GSTRING, P_GLOBAL, user_socket_options, NULL, NULL},
+ {"netbios name", P_UGSTRING,P_GLOBAL, myname, NULL, NULL},
+ {"netbios aliases", P_STRING, P_GLOBAL, &Globals.szNetbiosAliases, NULL, NULL},
+ {"smbrun", P_STRING, P_GLOBAL, &Globals.szSmbrun, NULL, NULL},
+ {"log file", P_STRING, P_GLOBAL, &Globals.szLogFile, NULL, NULL},
+ {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL},
+ {"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL},
+ {"hosts equiv", P_STRING, P_GLOBAL, &Globals.szHostsEquiv, NULL, NULL},
+ {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL},
+ {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL},
+ {"server string", P_STRING, P_GLOBAL, &Globals.szServerString, NULL, NULL},
+ {"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL},
+ {"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL},
+ {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL},
+ {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL},
+ {"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL},
+ {"root dir", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL},
+ {"root", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL},
+ {"default service", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL},
+ {"default", P_STRING, P_GLOBAL, &Globals.szDefaultService, NULL, NULL},
+ {"message command", P_STRING, P_GLOBAL, &Globals.szMsgCommand, NULL, NULL},
+ {"dfree command", P_STRING, P_GLOBAL, &Globals.szDfree, NULL, NULL},
+ {"passwd program", P_STRING, P_GLOBAL, &Globals.szPasswdProgram, NULL, NULL},
+ {"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL, NULL},
+ {"passwd chat debug",P_BOOL, P_GLOBAL, &Globals.bPasswdChatDebug, NULL, NULL},
+ {"valid chars", P_STRING, P_GLOBAL, &Globals.szValidChars, handle_valid_chars, NULL},
+ {"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL, NULL},
+#ifdef NTDOMAIN
+ {"domain sid", P_USTRING, P_GLOBAL, &Globals.szDomainSID, NULL, NULL},
+ {"domain other sids",P_STRING, P_GLOBAL, &Globals.szDomainOtherSIDs, NULL, NULL},
+ {"domain groups", P_STRING, P_GLOBAL, &Globals.szDomainGroups, NULL, NULL},
+ {"domain controller",P_BOOL , P_GLOBAL, &Globals.bDomainController,NULL, NULL},
+ {"domain admin users",P_STRING, P_GLOBAL, &Globals.szDomainAdminUsers, NULL, NULL},
+ {"domain guest users",P_STRING, P_GLOBAL, &Globals.szDomainGuestUsers, NULL, NULL},
+ {"domain hosts allow",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL, NULL},
+ {"domain allow hosts",P_STRING, P_GLOBAL, &Globals.szDomainHostsallow, NULL, NULL},
+ {"domain hosts deny", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL, NULL},
+ {"domain deny hosts", P_STRING, P_GLOBAL, &Globals.szDomainHostsdeny, NULL, NULL},
+#endif /* NTDOMAIN */
+ {"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL, NULL},
+ {"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set, NULL},
+ {"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL},
+ {"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL},
+ {"logon drive", P_STRING, P_GLOBAL, &Globals.szLogonDrive, NULL, NULL},
+ {"logon home", P_STRING, P_GLOBAL, &Globals.szLogonHome, NULL, NULL},
+ {"remote announce", P_STRING, P_GLOBAL, &Globals.szRemoteAnnounce, NULL, NULL},
+ {"remote browse sync",P_STRING, P_GLOBAL, &Globals.szRemoteBrowseSync,NULL, NULL},
+ {"socket address", P_STRING, P_GLOBAL, &Globals.szSocketAddress, NULL, NULL},
+ {"homedir map", P_STRING, P_GLOBAL, &Globals.szNISHomeMapName, NULL, NULL},
+ {"announce version", P_STRING, P_GLOBAL, &Globals.szAnnounceVersion, NULL, NULL},
+ {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL},
+ {"mangled stack", P_INTEGER, P_GLOBAL, &Globals.mangled_stack, NULL, NULL},
+ {"max mux", P_INTEGER, P_GLOBAL, &Globals.max_mux, NULL, NULL},
+ {"max xmit", P_INTEGER, P_GLOBAL, &Globals.max_xmit, NULL, NULL},
+ {"max packet", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL},
+ {"name resolve order", P_STRING, P_GLOBAL, &Globals.szNameResolveOrder, NULL, NULL},
+ {"packet size", P_INTEGER, P_GLOBAL, &Globals.max_packet, NULL, NULL},
+ {"password level", P_INTEGER, P_GLOBAL, &Globals.pwordlevel, NULL, NULL},
+ {"username level", P_INTEGER, P_GLOBAL, &Globals.unamelevel, NULL, NULL},
+ {"keepalive", P_INTEGER, P_GLOBAL, &keepalive, NULL, NULL},
+ {"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL},
+ {"time offset", P_INTEGER, P_GLOBAL, &extra_time_offset, NULL, NULL},
+ {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL, NULL},
+ {"shared mem size", P_INTEGER, P_GLOBAL, &Globals.shmem_size, NULL, NULL},
+ {"coding system", P_STRING, P_GLOBAL, &Globals.szCodingSystem, handle_coding_system, NULL},
+ {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL, NULL},
+ {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL, NULL},
+ {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL, NULL},
+ {"max wins ttl", P_INTEGER, P_GLOBAL, &Globals.max_wins_ttl, NULL, NULL},
+ {"min wins ttl", P_INTEGER, P_GLOBAL, &Globals.min_wins_ttl, NULL, NULL},
+ {"lm announce", P_ENUM, P_GLOBAL, &Globals.lm_announce, NULL, enum_lm_announce},
+ {"lm interval", P_INTEGER, P_GLOBAL, &Globals.lm_interval, NULL, NULL},
+ {"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL},
+ {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL},
+ {"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL},
+ {"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL, NULL},
+ {"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL, NULL},
+ {"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL, NULL},
+ {"local master", P_BOOL, P_GLOBAL, &Globals.bLocalMaster, NULL, NULL},
+ {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL, NULL},
+ {"domain logons", P_BOOL, P_GLOBAL, &Globals.bDomainLogons, NULL, NULL},
+ {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL, NULL},
+ {"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL, NULL},
+ {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL, NULL},
+ {"unix password sync", P_BOOL, P_GLOBAL, &Globals.bUnixPasswdSync, NULL, NULL},
+ {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL},
+ {"printer driver file", P_STRING, P_GLOBAL, &Globals.szDriverFile, NULL, NULL},
+ {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL, NULL},
+ {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, NULL},
+ {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy, NULL},
+ {"include", P_STRING, P_LOCAL, &sDefault.szInclude, handle_include, NULL},
+ {"exec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL},
+ {"preexec", P_STRING, P_LOCAL, &sDefault.szPreExec, NULL, NULL},
+ {"postexec", P_STRING, P_LOCAL, &sDefault.szPostExec, NULL, NULL},
+ {"root preexec", P_STRING, P_LOCAL, &sDefault.szRootPreExec, NULL, NULL},
+ {"root postexec", P_STRING, P_LOCAL, &sDefault.szRootPostExec, NULL, NULL},
+ {"alternate permissions",P_BOOL,P_LOCAL, &sDefault.bAlternatePerm, NULL, NULL},
+ {"revalidate", P_BOOL, P_LOCAL, &sDefault.bRevalidate, NULL, NULL},
+ {"default case", P_ENUM, P_LOCAL, &sDefault.iDefaultCase, NULL, enum_case},
+ {"case sensitive", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL},
+ {"casesignames", P_BOOL, P_LOCAL, &sDefault.bCaseSensitive, NULL, NULL},
+ {"preserve case", P_BOOL, P_LOCAL, &sDefault.bCasePreserve, NULL, NULL},
+ {"short preserve case",P_BOOL, P_LOCAL, &sDefault.bShortCasePreserve,NULL, NULL},
+ {"mangle case", P_BOOL, P_LOCAL, &sDefault.bCaseMangle, NULL, NULL},
+ {"mangling char", P_CHAR, P_LOCAL, &sDefault.magic_char, NULL, NULL},
+ {"browseable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL},
+ {"browsable", P_BOOL, P_LOCAL, &sDefault.bBrowseable, NULL, NULL},
+ {"available", P_BOOL, P_LOCAL, &sDefault.bAvailable, NULL, NULL},
+ {"path", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL},
+ {"directory", P_STRING, P_LOCAL, &sDefault.szPath, NULL, NULL},
+ {"username", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL},
+ {"user", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL},
+ {"users", P_STRING, P_LOCAL, &sDefault.szUsername, NULL, NULL},
+ {"guest account", P_STRING, P_LOCAL, &sDefault.szGuestaccount, NULL, NULL},
+ {"invalid users", P_STRING, P_LOCAL, &sDefault.szInvalidUsers, NULL, NULL},
+ {"valid users", P_STRING, P_LOCAL, &sDefault.szValidUsers, NULL, NULL},
+ {"admin users", P_STRING, P_LOCAL, &sDefault.szAdminUsers, NULL, NULL},
+ {"read list", P_STRING, P_LOCAL, &sDefault.readlist, NULL, NULL},
+ {"write list", P_STRING, P_LOCAL, &sDefault.writelist, NULL, NULL},
+ {"volume", P_STRING, P_LOCAL, &sDefault.volume, NULL, NULL},
+ {"force user", P_STRING, P_LOCAL, &sDefault.force_user, NULL, NULL},
+ {"force group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL},
+ {"group", P_STRING, P_LOCAL, &sDefault.force_group, NULL, NULL},
+ {"read only", P_BOOL, P_LOCAL, &sDefault.bRead_only, NULL, NULL},
+ {"write ok", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL},
+ {"writeable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL},
+ {"writable", P_BOOLREV, P_LOCAL, &sDefault.bRead_only, NULL, NULL},
+ {"max connections", P_INTEGER, P_LOCAL, &sDefault.iMaxConnections, NULL, NULL},
+ {"min print space", P_INTEGER, P_LOCAL, &sDefault.iMinPrintSpace, NULL, NULL},
+ {"create mask", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL},
+ {"create mode", P_OCTAL, P_LOCAL, &sDefault.iCreate_mask, NULL, NULL},
+ {"force create mode",P_OCTAL, P_LOCAL, &sDefault.iCreate_force_mode, NULL, NULL},
+ {"directory mask", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL},
+ {"directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_mask, NULL, NULL},
+ {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.iDir_force_mode, NULL, NULL},
+ {"set directory", P_BOOLREV, P_LOCAL, &sDefault.bNo_set_dir, NULL, NULL},
+ {"status", P_BOOL, P_LOCAL, &sDefault.status, NULL, NULL},
+ {"hide dot files", P_BOOL, P_LOCAL, &sDefault.bHideDotFiles, NULL, NULL},
+ {"delete veto files",P_BOOL, P_LOCAL, &sDefault.bDeleteVetoFiles, NULL, NULL},
+ {"veto files", P_STRING, P_LOCAL, &sDefault.szVetoFiles, NULL, NULL},
+ {"hide files", P_STRING, P_LOCAL, &sDefault.szHideFiles, NULL, NULL},
+ {"veto oplock files",P_STRING, P_LOCAL, &sDefault.szVetoOplockFiles,NULL, NULL},
+ {"guest only", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL},
+ {"only guest", P_BOOL, P_LOCAL, &sDefault.bGuest_only, NULL, NULL},
+ {"guest ok", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL},
+ {"public", P_BOOL, P_LOCAL, &sDefault.bGuest_ok, NULL, NULL},
+ {"print ok", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL},
+ {"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL},
+ {"postscript", P_BOOL, P_LOCAL, &sDefault.bPostscript, NULL, NULL},
+ {"map system", P_BOOL, P_LOCAL, &sDefault.bMap_system, NULL, NULL},
+ {"map hidden", P_BOOL, P_LOCAL, &sDefault.bMap_hidden, NULL, NULL},
+ {"map archive", P_BOOL, P_LOCAL, &sDefault.bMap_archive, NULL, NULL},
+ {"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL},
+ {"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL},
+ {"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL},
+ {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL},
+ {"only user", P_BOOL, P_LOCAL, &sDefault.bOnlyUser, NULL, NULL},
+ {"wide links", P_BOOL, P_LOCAL, &sDefault.bWidelinks, NULL, NULL},
+ {"follow symlinks", P_BOOL, P_LOCAL, &sDefault.bSymlinks, NULL, NULL},
+ {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL},
+ {"mangled names", P_BOOL, P_LOCAL, &sDefault.bMangledNames, NULL, NULL},
+ {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL},
+ {"printing", P_ENUM, P_LOCAL, &sDefault.iPrinting, NULL, enum_printing},
+ {"print command", P_STRING, P_LOCAL, &sDefault.szPrintcommand, NULL, NULL},
+ {"lpq command", P_STRING, P_LOCAL, &sDefault.szLpqcommand, NULL, NULL},
+ {"lprm command", P_STRING, P_LOCAL, &sDefault.szLprmcommand, NULL, NULL},
+ {"lppause command", P_STRING, P_LOCAL, &sDefault.szLppausecommand, NULL, NULL},
+ {"lpresume command", P_STRING, P_LOCAL, &sDefault.szLpresumecommand,NULL, NULL},
+ {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL},
+ {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL},
+ {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL},
+ {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL},
+ {"hosts allow", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL},
+ {"allow hosts", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL, NULL},
+ {"hosts deny", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL},
+ {"deny hosts", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL},
+ {"dont descend", P_STRING, P_LOCAL, &sDefault.szDontdescend, NULL, NULL},
+ {"magic script", P_STRING, P_LOCAL, &sDefault.szMagicScript, NULL, NULL},
+ {"magic output", P_STRING, P_LOCAL, &sDefault.szMagicOutput, NULL, NULL},
+ {"mangled map", P_STRING, P_LOCAL, &sDefault.szMangledMap, NULL, NULL},
+ {"delete readonly", P_BOOL, P_LOCAL, &sDefault.bDeleteReadonly, NULL, NULL},
+ {"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL},
+ {"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution, NULL, NULL},
+ {"fake directory create times", P_BOOL, P_LOCAL, &sDefault.bFakeDirCreateTimes, NULL, NULL},
+
+ {NULL, P_BOOL, P_NONE, NULL, NULL, NULL}
};
@@ -708,7 +686,9 @@ static void init_globals(void)
DEBUG(3,("Initialising global parameters\n"));
+#ifdef SMB_PASSWD_FILE
string_set(&Globals.szSMBPasswdFile, SMB_PASSWD_FILE);
+#endif
string_set(&Globals.szPasswdChat,"*old*password* %o\\n *new*password* %n\\n *new*password* %n\\n *changed*");
string_set(&Globals.szWorkGroup, WORKGROUP);
string_set(&Globals.szPasswdProgram, SMB_PASSWD);
@@ -754,8 +734,8 @@ static void init_globals(void)
Globals.syslog = 1;
Globals.bSyslogOnly = False;
Globals.os_level = 0;
- Globals.max_ttl = 60*60*24*3; /* 3 days default */
- Globals.max_wins_ttl = 60*60*24*6; /* 6 days default */
+ Globals.max_ttl = 60*60*4; /* 4 hours default */
+ Globals.max_wins_ttl = 60*60*24*3; /* 3 days default */
Globals.min_wins_ttl = 60*60*6; /* 6 hours default */
Globals.ReadSize = 16*1024;
Globals.lm_announce = 2; /* = Auto: send only if LM clients found */
@@ -774,17 +754,10 @@ static void init_globals(void)
Globals.client_code_page = DEFAULT_CLIENT_CODE_PAGE;
Globals.bTimeServer = False;
Globals.bBindInterfacesOnly = False;
- Globals.bNetWkstaUserLogon = False; /* This is now set to false by default as
- the code in password.c protects us from this bug. */
+ Globals.bNetWkstaUserLogon = True;
Globals.bUnixPasswdSync = False;
Globals.bPasswdChatDebug = False;
-#ifdef USE_LDAP
- /* default values for ldap */
- string_set(&Globals.szLdapServer, "localhost");
- Globals.ldap_port=389;
-#endif /* USE_LDAP */
-
/* these parameters are set to defaults that are more appropriate
for the increasing samba install base:
@@ -979,6 +952,7 @@ FN_GLOBAL_STRING(lp_announce_version,&Globals.szAnnounceVersion)
FN_GLOBAL_STRING(lp_netbios_aliases,&Globals.szNetbiosAliases)
FN_GLOBAL_STRING(lp_driverfile,&Globals.szDriverFile)
+#ifdef NTDOMAIN
FN_GLOBAL_STRING(lp_domain_sid,&Globals.szDomainSID)
FN_GLOBAL_STRING(lp_domain_other_sids,&Globals.szDomainOtherSIDs)
FN_GLOBAL_STRING(lp_domain_groups,&Globals.szDomainGroups)
@@ -986,14 +960,7 @@ FN_GLOBAL_STRING(lp_domain_admin_users,&Globals.szDomainAdminUsers)
FN_GLOBAL_STRING(lp_domain_guest_users,&Globals.szDomainGuestUsers)
FN_GLOBAL_STRING(lp_domain_hostsallow,&Globals.szDomainHostsallow)
FN_GLOBAL_STRING(lp_domain_hostsdeny,&Globals.szDomainHostsdeny)
-
-#ifdef USE_LDAP
-FN_GLOBAL_STRING(lp_ldap_server,&Globals.szLdapServer);
-FN_GLOBAL_STRING(lp_ldap_suffix,&Globals.szLdapSuffix);
-FN_GLOBAL_STRING(lp_ldap_filter,&Globals.szLdapFilter);
-FN_GLOBAL_STRING(lp_ldap_root,&Globals.szLdapRoot);
-FN_GLOBAL_STRING(lp_ldap_rootpasswd,&Globals.szLdapRootPassword);
-#endif /* USE_LDAP */
+#endif /* NTDOMAIN */
FN_GLOBAL_BOOL(lp_dns_proxy,&Globals.bDNSproxy)
FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport)
@@ -1050,10 +1017,6 @@ FN_GLOBAL_INTEGER(lp_announce_as,&Globals.announce_as)
FN_GLOBAL_INTEGER(lp_lm_announce,&Globals.lm_announce)
FN_GLOBAL_INTEGER(lp_lm_interval,&Globals.lm_interval)
-#ifdef USE_LDAP
-FN_GLOBAL_INTEGER(lp_ldap_port,&Globals.ldap_port)
-#endif /* USE_LDAP */
-
FN_LOCAL_STRING(lp_preexec,szPreExec)
FN_LOCAL_STRING(lp_postexec,szPostExec)
FN_LOCAL_STRING(lp_rootpreexec,szRootPreExec)
@@ -1736,15 +1699,6 @@ static void init_copymap(service *pservice)
/***************************************************************************
- return the local pointer to a parameter given the service number and the
- pointer into the default structure
-***************************************************************************/
-void *lp_local_ptr(int snum, void *ptr)
-{
- return (void *)(((char *)pSERVICE(snum)) + PTR_DIFF(ptr,&sDefault));
-}
-
-/***************************************************************************
Process a parameter for a particular service number. If snum < 0
then assume we are in the globals
***************************************************************************/
@@ -1788,7 +1742,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
/* if it is a special case then go ahead */
if (parm_table[parmnum].special) {
- parm_table[parmnum].special(pszParmValue,(char **)parm_ptr);
+ parm_table[parmnum].special(pszParmValue,parm_ptr);
return(True);
}
@@ -1842,8 +1796,6 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue)
}
}
break;
- case P_SEP:
- break;
}
return(True);
@@ -1909,7 +1861,58 @@ static void print_parameter(struct parm_struct *p,void *ptr, FILE *f)
if (*(char **)ptr)
fprintf(f,"%s",*(char **)ptr);
break;
- case P_SEP:
+ }
+}
+
+
+/***************************************************************************
+print a parameter of the specified type
+***************************************************************************/
+static void parameter_string(struct parm_struct *p,void *ptr,char *s)
+{
+ int i;
+ s[0] = 0;
+
+ switch (p->type) {
+ case P_ENUM:
+ for (i=0;p->enum_list[i].name;i++) {
+ if (*(int *)ptr == p->enum_list[i].value) {
+ sprintf(s,"%s",p->enum_list[i].name);
+ break;
+ }
+ }
+ break;
+
+ 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)
+ slprintf(s, sizeof(pstring)-1, "%s",(char *)ptr);
+ break;
+
+ case P_STRING:
+ case P_USTRING:
+ if (*(char **)ptr)
+ slprintf(s, sizeof(pstring)-1,"%s",*(char **)ptr);
break;
}
}
@@ -1950,8 +1953,6 @@ static BOOL equal_parameter(parm_type type,void *ptr1,void *ptr2)
if (p2 && !*p2) p2 = NULL;
return(p1==p2 || strequal(p1,p2));
}
- case P_SEP:
- break;
}
return(False);
}
@@ -2007,129 +2008,86 @@ static BOOL do_section(char *pszSectionName)
return (bRetval);
}
-
-/***************************************************************************
-determine if a partcular base parameter is currently set to the default value.
-***************************************************************************/
-static BOOL is_default(int i)
-{
- if (!defaults_saved) return False;
- switch (parm_table[i].type) {
- case P_STRING:
- case P_USTRING:
- return strequal(parm_table[i].def.svalue,*(char **)parm_table[i].ptr);
- case P_GSTRING:
- case P_UGSTRING:
- return strequal(parm_table[i].def.svalue,(char *)parm_table[i].ptr);
- case P_BOOL:
- case P_BOOLREV:
- return parm_table[i].def.bvalue == *(BOOL *)parm_table[i].ptr;
- case P_CHAR:
- return parm_table[i].def.cvalue == *(char *)parm_table[i].ptr;
- case P_INTEGER:
- case P_OCTAL:
- case P_ENUM:
- return parm_table[i].def.ivalue == *(int *)parm_table[i].ptr;
- case P_SEP:
- break;
- }
- return False;
-}
-
-
/***************************************************************************
Display the contents of the global structure.
***************************************************************************/
static void dump_globals(FILE *f)
{
- int i;
- fprintf(f, "# 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))) {
- if (defaults_saved && is_default(i)) continue;
- fprintf(f,"\t%s = ",parm_table[i].label);
- print_parameter(&parm_table[i],parm_table[i].ptr, f);
- fprintf(f,"\n");
- }
-}
+ int i;
+ fprintf(f, "# Global parameters\n");
-/***************************************************************************
-return True if a local parameter is currently set to the global default
-***************************************************************************/
-BOOL lp_is_default(int snum, struct parm_struct *parm)
-{
- int pdiff = PTR_DIFF(parm->ptr,&sDefault);
-
- return equal_parameter(parm->type,
- ((char *)pSERVICE(snum)) + pdiff,
- ((char *)&sDefault) + pdiff);
+ 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],parm_table[i].ptr, f);
+ fprintf(f,"\n");
+ }
}
-
/***************************************************************************
Display the contents of a single services record.
***************************************************************************/
static void dump_a_service(service *pService, FILE *f)
{
- int i;
- if (pService != &sDefault)
- fprintf(f,"\n[%s]\n",pService->szService);
-
- for (i=0;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 (pService == &sDefault) {
- if (defaults_saved && is_default(i)) continue;
- } else {
- if (equal_parameter(parm_table[i].type,
- ((char *)pService) + pdiff,
- ((char *)&sDefault) + pdiff))
- continue;
- }
+ int i;
+ if (pService == &sDefault)
+ fprintf(f,"\n\n# Default service parameters\n");
+ else
+ fprintf(f,"\n[%s]\n",pService->szService);
- fprintf(f,"\t%s = ",parm_table[i].label);
- print_parameter(&parm_table[i],
- ((char *)pService) + pdiff, f);
- fprintf(f,"\n");
- }
+ for (i=0;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 (pService == &sDefault || !equal_parameter(parm_table[i].type,
+ ((char *)pService) + pdiff,
+ ((char *)&sDefault) + pdiff))
+ {
+ fprintf(f,"\t%s = ",parm_table[i].label);
+ print_parameter(&parm_table[i],
+ ((char *)pService) + pdiff, f);
+ fprintf(f,"\n");
+ }
+ }
}
/***************************************************************************
-return info about the next service in a service. snum==-1 gives the globals
+return info about the next service in a service. snum==-1 gives the default
+serice and snum==-2 gives the globals
-return NULL when out of parameters
+return 0 when out of parameters
***************************************************************************/
-struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
+int lp_next_parameter(int snum, int *i, char *label,
+ char *value, int allparameters)
{
- if (snum == -1) {
+ if (snum == -2) {
/* do the globals */
- for (;parm_table[*i].label;(*i)++) {
- if (parm_table[*i].class == P_SEPARATOR)
- return &parm_table[(*i)++];
-
- if (!parm_table[*i].ptr || (*parm_table[*i].label == '-'))
- continue;
-
- if ((*i) > 0 && (parm_table[*i].ptr == parm_table[(*i)-1].ptr))
- continue;
-
- return &parm_table[(*i)++];
- }
+ 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],
+ parm_table[*i].ptr,
+ value);
+ (*i)++;
+ return 1;
+ }
+ return 0;
} else {
- service *pService = pSERVICE(snum);
-
- for (;parm_table[*i].label;(*i)++) {
- if (parm_table[*i].class == P_SEPARATOR)
- return &parm_table[(*i)++];
+ 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 != '-') &&
@@ -2137,17 +2095,21 @@ struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters)
(parm_table[*i].ptr != parm_table[(*i)-1].ptr))) {
int pdiff = PTR_DIFF(parm_table[*i].ptr,&sDefault);
- if (allparameters ||
+ if (snum == -1 || allparameters ||
!equal_parameter(parm_table[*i].type,
((char *)pService) + pdiff,
((char *)&sDefault) + pdiff)) {
- return &parm_table[(*i)++];
+ strcpy(label, parm_table[*i].label);
+ parameter_string(&parm_table[*i],
+ ((char *)pService) + pdiff,
+ value);
+ (*i)++;
+ return 1;
}
}
- }
}
- return NULL;
+ return 0;
}
@@ -2196,7 +2158,7 @@ static void lp_add_auto_services(char *str)
s = strdup(str);
if (!s) return;
- homes = lp_servicenumber(HOMES_NAME);
+ homes = lp_servicenumber(HOMES_NAME);
printers = lp_servicenumber(PRINTERS_NAME);
for (p=strtok(s,LIST_SEP);p;p=strtok(NULL,LIST_SEP))
@@ -2268,51 +2230,11 @@ void lp_killunused(BOOL (*snumused)(int ))
}
}
-
-/***************************************************************************
-save the curent values of all global and sDefault parameters into the
-defaults union. This allows swat and testparm to show only the
-changed (ie. non-default) parameters.
-***************************************************************************/
-static void lp_save_defaults(void)
-{
- int i;
- for (i = 0; parm_table[i].label; i++) {
- if (i>0 && parm_table[i].ptr == parm_table[i-1].ptr) continue;
- switch (parm_table[i].type) {
- case P_STRING:
- case P_USTRING:
- parm_table[i].def.svalue = strdup(*(char **)parm_table[i].ptr);
- break;
- case P_GSTRING:
- case P_UGSTRING:
- parm_table[i].def.svalue = strdup((char *)parm_table[i].ptr);
- break;
- case P_BOOL:
- case P_BOOLREV:
- parm_table[i].def.bvalue = *(BOOL *)parm_table[i].ptr;
- break;
- case P_CHAR:
- parm_table[i].def.cvalue = *(char *)parm_table[i].ptr;
- break;
- case P_INTEGER:
- case P_OCTAL:
- case P_ENUM:
- parm_table[i].def.ivalue = *(int *)parm_table[i].ptr;
- break;
- case P_SEP:
- break;
- }
- }
- defaults_saved = True;
-}
-
-
/***************************************************************************
Load the services array from the services file. Return True on success,
False on failure.
***************************************************************************/
-BOOL lp_load(char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc)
+BOOL lp_load(char *pszFname,BOOL global_only)
{
pstring n2;
BOOL bRetval;
@@ -2325,11 +2247,6 @@ BOOL lp_load(char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc)
bGlobalOnly = global_only;
init_globals();
-
- if (save_defaults) {
- init_locals();
- lp_save_defaults();
- }
pstrcpy(n2,pszFname);
standard_sub_basic(n2);
@@ -2348,8 +2265,7 @@ BOOL lp_load(char *pszFname,BOOL global_only, BOOL save_defaults, BOOL add_ipc)
if (lp_load_printers())
lp_add_all_printers();
- if (add_ipc)
- lp_add_ipc();
+ lp_add_ipc();
set_default_server_announce_type();
@@ -2370,14 +2286,10 @@ int lp_numservices(void)
/***************************************************************************
Display the contents of the services array in human-readable form.
***************************************************************************/
-void lp_dump(FILE *f, BOOL show_defaults)
+void lp_dump(FILE *f)
{
int iService;
- if (show_defaults) {
- defaults_saved = False;
- }
-
dump_globals(f);
dump_a_service(&sDefault, f);
@@ -2563,6 +2475,6 @@ int lp_minor_announce_version(void)
************************************************************/
void lp_set_name_resolve_order(char *new_order)
-{
+{
Globals.szNameResolveOrder = new_order;
}
diff --git a/source/passdb/ldap.c b/source/passdb/ldap.c
deleted file mode 100644
index e14742a3aad..00000000000
--- a/source/passdb/ldap.c
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- LDAP protocol helper functions for SAMBA
- Copyright (C) Jean François Micouleau 1998
-
- 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 USE_LDAP
-
-#include "includes.h"
-#include "lber.h"
-#include "ldap.h"
-
-extern int DEBUGLEVEL;
-
-/*******************************************************************
- open a connection to the ldap serve.
-******************************************************************/
-BOOL ldap_open_connection(LDAP **ldap_struct)
-{
- if ( (*ldap_struct = ldap_open(lp_ldap_server(),lp_ldap_port()) )== NULL)
- {
- DEBUG(0,("%s: The LDAP server is not responding !\n",timestring()));
- return(False);
- }
- DEBUG(2,("ldap_open_connection: connection opened\n"));
- return (True);
-}
-
-
-/*******************************************************************
- connect anonymously to the ldap server.
- FIXME: later (jfm)
-******************************************************************/
-static BOOL ldap_connect_anonymous(LDAP *ldap_struct)
-{
- if ( ldap_simple_bind_s(ldap_struct,lp_ldap_root(),lp_ldap_rootpasswd()) != LDAP_SUCCESS)
- {
- DEBUG(0,("%s: Couldn't bind to the LDAP server !\n", timestring() ));
- return(False);
- }
- return (True);
-}
-
-
-/*******************************************************************
- connect to the ldap server under system privileg.
-******************************************************************/
-BOOL ldap_connect_system(LDAP *ldap_struct)
-{
- if ( ldap_simple_bind_s(ldap_struct,lp_ldap_root(),lp_ldap_rootpasswd()) != LDAP_SUCCESS)
- {
- DEBUG(0,("%s: Couldn't bind to the LDAP server !\n", timestring() ));
- return(False);
- }
- DEBUG(2,("ldap_connect_system: succesfull connection to the LDAP server\n"));
- return (True);
-}
-
-/*******************************************************************
- connect to the ldap server under a particular user.
-******************************************************************/
-static BOOL ldap_connect_user(LDAP *ldap_struct, char *user, char *password)
-{
- if ( ldap_simple_bind_s(ldap_struct,lp_ldap_root(),lp_ldap_rootpasswd()) != LDAP_SUCCESS)
- {
- DEBUG(0,("%s: Couldn't bind to the LDAP server !\n", timestring() ));
- return(False);
- }
- DEBUG(2,("ldap_connect_user: succesfull connection to the LDAP server\n"));
- return (True);
-}
-
-/*******************************************************************
- run the search by name.
-******************************************************************/
-static BOOL ldap_search_one_user(LDAP *ldap_struct, char *filter, LDAPMessage **result)
-{
- int scope = LDAP_SCOPE_ONELEVEL;
- int rc;
-
- DEBUG(2,("ldap_search_one_user: searching for:[%s]\n", filter));
-
- rc=ldap_search_s(ldap_struct, lp_ldap_suffix(), scope, filter, NULL, 0, result);
-
- if (rc != LDAP_SUCCESS )
- {
- DEBUG(0,("%s: Problem during the LDAP search\n",timestring()));
- return(False);
- }
- return (True);
-}
-
-/*******************************************************************
- run the search by name.
-******************************************************************/
-BOOL ldap_search_one_user_by_name(LDAP *ldap_struct, char *user, LDAPMessage **result)
-{
- pstring filter;
- /*
- in the filter expression, replace %u with the real name
- so in ldap filter, %u MUST exist :-)
- */
- strcpy(filter,lp_ldap_filter());
- string_sub(filter,"%u",user);
-
- if ( !ldap_search_one_user(ldap_struct, filter, result) )
- {
- return(False);
- }
- return (True);
-}
-
-/*******************************************************************
- run the search by uid.
-******************************************************************/
-BOOL ldap_search_one_user_by_uid(LDAP *ldap_struct, int uid, LDAPMessage **result)
-{
- pstring filter;
- /*
- in the filter expression, replace %u with the real name
- so in ldap filter, %u MUST exist :-)
- */
- snprintf(filter, sizeof(pstring), "uidAccount=%d", uid);
-
- if ( !ldap_search_one_user(ldap_struct, filter, result) )
- {
- return(False);
- }
- return (True);
-}
-
-/*******************************************************************
- search an attribute and return the first value found.
-******************************************************************/
-void get_single_attribute(LDAP *ldap_struct, LDAPMessage *entry, char *attribute, char *value)
-{
- char **valeurs;
-
- if ( (valeurs=ldap_get_values(ldap_struct, entry, attribute)) != NULL)
- {
- strcpy(value, valeurs[0]);
- ldap_value_free(valeurs);
- DEBUG(3,("get_single_attribute: [%s]=[%s]\n", attribute, value));
- }
- else
- {
- value=NULL;
- }
-}
-
-/*******************************************************************
- check if the returned entry is a sambaAccount objectclass.
-******************************************************************/
-BOOL ldap_check_user(LDAP *ldap_struct, LDAPMessage *entry)
-{
- BOOL sambaAccount=False;
- char **valeur;
- int i;
-
- DEBUG(2,("ldap_check_user: "));
- valeur=ldap_get_values(ldap_struct, entry, "objectclass");
- if (valeur!=NULL)
- {
- for (i=0;valeur[i]!=NULL;i++)
- {
- if (!strcmp(valeur[i],"sambaAccount")) sambaAccount=True;
- }
- }
- DEBUG(2,("%s\n",sambaAccount?"yes":"no"));
- ldap_value_free(valeur);
- return (sambaAccount);
-}
-
-/*******************************************************************
- check if the returned entry is a sambaMachine objectclass.
-******************************************************************/
-BOOL ldap_check_machine(LDAP *ldap_struct, LDAPMessage *entry)
-{
- BOOL sambaMachine=False;
- char **valeur;
- int i;
-
- DEBUG(2,("ldap_check_machine: "));
- valeur=ldap_get_values(ldap_struct, entry, "objectclass");
- if (valeur!=NULL)
- {
- for (i=0;valeur[i]!=NULL;i++)
- {
- if (!strcmp(valeur[i],"sambaMachine")) sambaMachine=True;
- }
- }
- DEBUG(2,("%s\n",sambaMachine?"yes":"no"));
- ldap_value_free(valeur);
- return (sambaMachine);
-}
-
-/*******************************************************************
- retrieve the user's info and contruct a smb_passwd structure.
-******************************************************************/
-static void ldap_get_user(LDAP *ldap_struct,LDAPMessage *entry,
- struct smb_passwd *ldap_passwd)
-{
- static pstring user_name;
- static unsigned char ldappwd[16];
- static unsigned char smbntpwd[16];
- char **valeur;
-
- get_single_attribute(ldap_struct, entry, "cn", user_name);
-
- DEBUG(2,("ldap_get_user: user: %s\n",user_name));
-
- if ( (valeur=ldap_get_values(ldap_struct, entry, "uidAccount")) != NULL)
- {
- ldap_passwd->smb_userid=atoi(valeur[0]);
- ldap_value_free(valeur);
- }
-
- if ( (valeur=ldap_get_values(ldap_struct, entry, "userPassword")) != NULL)
- {
- memset(smbntpwd, '\0', 16);
- E_md4hash((uchar *) valeur[0], smbntpwd);
- valeur[0][14] = '\0';
- strupper(valeur[0]);
- memset(ldappwd, '\0', 16);
- E_P16((uchar *) valeur[0], ldappwd);
- ldap_value_free(valeur);
- }
-
- if ( (valeur=ldap_get_values(ldap_struct,entry, "userAccountControl") ) != NULL)
- {
- ldap_passwd->acct_ctrl=atoi(valeur[0]);
- if (ldap_passwd->acct_ctrl & (ACB_DOMTRUST|ACB_WSTRUST|ACB_SVRTRUST) )
- {
- DEBUG(0,("Inconsistency in the LDAP database\n"));
-
- }
- if (ldap_passwd->acct_ctrl & ACB_NORMAL)
- {
- ldap_passwd->smb_name=user_name;
- ldap_passwd->smb_passwd=ldappwd;
- ldap_passwd->smb_nt_passwd=smbntpwd;
- }
- ldap_value_free(valeur);
- }
-
- if ( (valeur=ldap_get_values(ldap_struct,entry, "pwdLastSet")) != NULL)
- {
- ldap_passwd->pass_last_set_time=(time_t)strtol(valeur[0], NULL, 16);
- ldap_value_free(valeur);
- }
-}
-
-/*******************************************************************
- retrieve the machine's info and contruct a smb_passwd structure.
-******************************************************************/
-static void ldap_get_machine(LDAP *ldap_struct,LDAPMessage *entry,
- struct smb_passwd *ldap_passwd)
-{
- static pstring user_name;
- static unsigned char smbntpwd[16];
- char **valeur;
-
- /* by default it's a station */
- ldap_passwd->acct_ctrl = ACB_WSTRUST;
-
- get_single_attribute(ldap_struct, entry, "cn", user_name);
- DEBUG(2,("ldap_get_machine: machine: %s\n", user_name));
-
- if ( (valeur=ldap_get_values(ldap_struct, entry, "uidAccount")) != NULL)
- {
- ldap_passwd->smb_userid=atoi(valeur[0]);
- ldap_value_free(valeur);
- }
-
- if ( (valeur=ldap_get_values(ldap_struct, entry, "machinePassword")) != NULL)
- {
- gethexpwd(valeur[0],smbntpwd);
- ldap_value_free(valeur);
- }
-
- if ( (valeur=ldap_get_values(ldap_struct,entry, "machineRole") ) != NULL)
- {
- if ( !strcmp(valeur[0],"workstation") )
- ldap_passwd->acct_ctrl=ACB_WSTRUST;
- else
- if ( !strcmp(valeur[0],"server") )
- ldap_passwd->acct_ctrl=ACB_SVRTRUST;
- ldap_value_free(valeur);
- }
-
- ldap_passwd->smb_name=user_name;
- ldap_passwd->smb_passwd=smbntpwd;
- ldap_passwd->smb_nt_passwd=smbntpwd;
-}
-
-/*******************************************************************
- find a user or a machine return a smbpass struct.
-******************************************************************/
-static struct smb_passwd *get_ldappwd_entry(char *name, int smb_userid)
-{
- LDAP *ldap_struct;
- LDAPMessage *result;
- LDAPMessage *entry;
- BOOL machine=False;
-
- static struct smb_passwd ldap_passwd;
-
- bzero(&ldap_passwd, sizeof(ldap_passwd));
-
- ldap_passwd.smb_name = NULL;
- ldap_passwd.smb_passwd = NULL;
- ldap_passwd.smb_nt_passwd = NULL;
-
- ldap_passwd.smb_userid = -1;
- ldap_passwd.acct_ctrl = ACB_DISABLED;
- ldap_passwd.pass_last_set_time = (time_t)-1;
-
- ldap_struct=NULL;
-
- if (name != NULL)
- {
- DEBUG(10, ("get_ldappwd_entry: search by name: %s\n", name));
- }
- else
- {
- DEBUG(10, ("get_ldappwd_entry: search by smb_userid: %x\n", smb_userid));
- }
-
- if (!ldap_open_connection(&ldap_struct))
- return (NULL);
- if (!ldap_connect_system(ldap_struct))
- return (NULL);
-
- if (name != NULL)
- {
- if (!ldap_search_one_user_by_name(ldap_struct, name, &result))
- return (NULL);
- }
- else
- {
- if (!ldap_search_one_user_by_uid(ldap_struct, smb_userid, &result))
- return (NULL);
- }
-
- if (ldap_count_entries(ldap_struct, result) == 0)
- {
- DEBUG(2,("%s: Non existant user!\n", timestring() ));
- return (NULL);
- }
-
- if (ldap_count_entries(ldap_struct, result) > 1)
- {
- DEBUG(2,("%s: Strange %d users in the base!\n",
- timestring(), ldap_count_entries(ldap_struct, result) ));
- }
- /* take the first and unique entry */
- entry=ldap_first_entry(ldap_struct, result);
-
- if (name != NULL)
- {
- DEBUG(0,("get_ldappwd_entry: Found user: %s\n",name));
-
- machine = name[strlen(name)-1] == '$';
- }
-
- if (!machine)
- {
- if (ldap_check_user(ldap_struct, entry))
- ldap_get_user(ldap_struct, entry, &ldap_passwd);
- }
- else
- {
- if (ldap_check_machine(ldap_struct, entry))
- ldap_get_machine(ldap_struct, entry, &ldap_passwd);
- }
-
- ldap_msgfree(result);
- result=NULL;
- ldap_unbind(ldap_struct);
-
- return(&ldap_passwd);
-}
-
-/************************************************************************
- Routine to add an entry to the ldap passwd file.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-BOOL add_ldappwd_entry(struct smb_passwd *newpwd)
-{
- return True;
-}
-
-/************************************************************************
- Routine to search the ldap passwd file for an entry matching the username.
- and then modify its password entry. We can't use the startldappwent()/
- getldappwent()/endldappwent() interfaces here as we depend on looking
- in the actual file to decide how much room we have to write data.
- override = False, normal
- override = True, override XXXXXXXX'd out password or NO PASS
-
- do not call this function directly. use passdb.c instead.
-
-************************************************************************/
-BOOL mod_ldappwd_entry(struct smb_passwd* pwd, BOOL override)
-{
- return False;
-}
-
-/************************************************************************
- Routine to search ldap passwd by name.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-
-struct smb_passwd *getldappwnam(char *name)
-{
- return get_ldappwd_entry(name, 0);
-}
-
-/************************************************************************
- Routine to search ldap passwd by uid.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-
-struct smb_passwd *getldappwuid(unsigned int uid)
-{
- return get_ldappwd_entry(NULL, uid);
-}
-
-/***************************************************************
- Start to enumerate the ldap passwd list. Returns a void pointer
- to ensure no modification outside this module.
-
- do not call this function directly. use passdb.c instead.
-
- ****************************************************************/
-
-struct ldap_enum_info
-{
- LDAP *ldap_struct;
- LDAPMessage *result;
- LDAPMessage *entry;
-};
-
-static struct ldap_enum_info ldap_ent;
-
-void *startldappwent(BOOL update)
-{
- int scope = LDAP_SCOPE_ONELEVEL;
- int rc;
-
- char filter[256];
-
- if (!ldap_open_connection(&ldap_ent.ldap_struct)) /* open a connection to the server */
- return NULL;
-
- if (!ldap_connect_system(ldap_ent.ldap_struct)) /* connect as system account */
- return NULL;
-
- /* when the class is known the search is much faster */
- switch (0)
- {
- case 1:
- {
- strcpy(filter, "objectclass=sambaAccount");
- break;
- }
- case 2:
- {
- strcpy(filter, "objectclass=sambaMachine");
- break;
- }
- default:
- {
- strcpy(filter, "(|(objectclass=sambaMachine)(objectclass=sambaAccount))");
- break;
- }
- }
-
- rc=ldap_search_s(ldap_ent.ldap_struct, lp_ldap_suffix(), scope, filter, NULL, 0, &ldap_ent.result);
-
- DEBUG(2,("%d entries in the base!\n", ldap_count_entries(ldap_ent.ldap_struct, ldap_ent.result) ));
-
- ldap_ent.entry = ldap_first_entry(ldap_ent.ldap_struct, ldap_ent.result);
-
- return &ldap_ent;
-}
-
-/*************************************************************************
- Routine to return the next entry in the ldap passwd list.
-
- do not call this function directly. use passdb.c instead.
-
- *************************************************************************/
-struct smb_passwd *getldappwent(void *vp)
-{
-
- struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
- ldap_vp->entry = ldap_next_entry(ldap_vp->ldap_struct, ldap_vp->entry);
-/*
- make_ldap_sam_user_info_21(ldap_struct, entry, &(pw_buf[(*num_entries)]) );
-*/
- return NULL;
-}
-
-/***************************************************************
- End enumeration of the ldap passwd list.
-****************************************************************/
-void endldappwent(void *vp)
-{
- struct ldap_enum_info *ldap_vp = (struct ldap_enum_info *)vp;
- ldap_msgfree(ldap_vp->result);
- ldap_unbind(ldap_vp->ldap_struct);
-}
-
-/*************************************************************************
- Return the current position in the ldap passwd list as an unsigned long.
- This must be treated as an opaque token.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-unsigned long getldappwpos(void *vp)
-{
- return 0;
-}
-
-/*************************************************************************
- Set the current position in the ldap passwd list from unsigned long.
- This must be treated as an opaque token.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-BOOL setldappwpos(void *vp, unsigned long tok)
-{
- return False;
-}
-
-#endif
diff --git a/source/passdb/passdb.c b/source/passdb/passdb.c
deleted file mode 100644
index 9e5b3ef1454..00000000000
--- a/source/passdb/passdb.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- Password and authentication handling
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Luke Kenneth Casson Leighton 1996-1998
-
- 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"
-
-extern int DEBUGLEVEL;
-
-/************************************************************************
- Routine to search sam passwd by name.
-*************************************************************************/
-
-struct smb_passwd *getsampwnam(char *name)
-{
-#ifdef USE_LDAP
- return getldappwnam(name);
-#else
- return getsmbpwnam(name);
-#endif /* USE_LDAP */
-}
-
-/************************************************************************
- Routine to search sam passwd by uid.
-*************************************************************************/
-
-struct smb_passwd *getsampwuid(unsigned int uid)
-{
-#ifdef USE_LDAP
- return getldappwuid(uid);
-#else
- return getsmbpwuid(uid);
-#endif /* USE_LDAP */
-}
-
-/***************************************************************
- Start to enumerate the sam passwd list. Returns a void pointer
- to ensure no modification outside this module.
-****************************************************************/
-
-void *startsampwent(BOOL update)
-{
-#ifdef USE_LDAP
- return startldappwent(update);
-#else
- return startsmbpwent(update);
-#endif /* USE_LDAP */
-}
-
-/***************************************************************
- End enumeration of the sam passwd list.
-****************************************************************/
-
-void endsampwent(void *vp)
-{
-#ifdef USE_LDAP
- endldappwent(vp);
-#else
- endsmbpwent(vp);
-#endif /* USE_LDAP */
-}
-
-/*************************************************************************
- Routine to return the next entry in the sam passwd list.
- *************************************************************************/
-
-struct smb_passwd *getsampwent(void *vp)
-{
-#ifdef USE_LDAP
- return getldappwent(vp);
-#else
- return getsmbpwent(vp);
-#endif /* USE_LDAP */
-}
-
-/*************************************************************************
- Return the current position in the sam passwd list as an unsigned long.
- This must be treated as an opaque token.
- *************************************************************************/
-unsigned long getsampwpos(void *vp)
-{
-#ifdef USE_LDAP
- return getldappwpos(vp);
-#else
- return getsmbpwpos(vp);
-#endif /* USE_LDAP */
-}
-
-/*************************************************************************
- Set the current position in the sam passwd list from unsigned long.
- This must be treated as an opaque token.
- *************************************************************************/
-BOOL setsampwpos(void *vp, unsigned long tok)
-{
-#ifdef USE_LDAP
- return setldappwpos(vp, tok);
-#else
- return setsmbpwpos(vp, tok);
-#endif /* USE_LDAP */
-}
-
-/************************************************************************
- Routine to add an entry to the sam passwd file.
-*************************************************************************/
-
-BOOL add_sampwd_entry(struct smb_passwd *newpwd)
-{
-#ifdef USE_LDAP
- return add_ldappwd_entry(newpwd);
-#else
- return add_smbpwd_entry(newpwd);
-#endif /* USE_LDAP */
-}
-
-/************************************************************************
- Routine to search the sam passwd file for an entry matching the username.
- and then modify its password entry. We can't use the startsampwent()/
- getsampwent()/endsampwent() interfaces here as we depend on looking
- in the actual file to decide how much room we have to write data.
- override = False, normal
- override = True, override XXXXXXXX'd out password or NO PASS
-************************************************************************/
-
-BOOL mod_sampwd_entry(struct smb_passwd* pwd, BOOL override)
-{
-#ifdef USE_LDAP
- return mod_ldappwd_entry(pwd, override);
-#else
- return mod_smbpwd_entry(pwd, override);
-#endif /* USE_LDAP */
-}
-
diff --git a/source/passdb/smbpass.c b/source/passdb/smbpass.c
index cb75d62e429..c3edd572371 100644
--- a/source/passdb/smbpass.c
+++ b/source/passdb/smbpass.c
@@ -19,1246 +19,860 @@
#include "includes.h"
-extern int DEBUGLEVEL;
+extern int DEBUGLEVEL;
-static int gotalarm;
-static char s_readbuf[16 * 1024];
+int gotalarm;
-/***************************************************************
- Signal function to tell us we timed out.
-****************************************************************/
-
-static void gotalarm_sig(void)
+void
+gotalarm_sig(void)
{
- gotalarm = 1;
+ gotalarm = 1;
}
-/***************************************************************
- Lock or unlock a fd for a known lock type. Abandon after waitsecs
- seconds.
-****************************************************************/
-
-static BOOL do_pw_lock(int fd, int waitsecs, int type)
+int
+do_pw_lock(int fd, int waitsecs, int type)
{
- struct flock lock;
- int ret;
-
- gotalarm = 0;
- signal(SIGALRM, SIGNAL_CAST gotalarm_sig);
-
- lock.l_type = type;
- lock.l_whence = SEEK_SET;
- lock.l_start = 0;
- lock.l_len = 1;
- lock.l_pid = 0;
-
- alarm(5);
- ret = fcntl(fd, F_SETLKW, &lock);
- alarm(0);
- signal(SIGALRM, SIGNAL_CAST SIG_DFL);
-
- if (gotalarm) {
- DEBUG(0, ("do_pw_lock: failed to %s SMB passwd file.\n",
- type == F_UNLCK ? "unlock" : "lock"));
- return False;
- }
-
- return (ret == 0);
+ struct flock lock;
+ int ret;
+
+ gotalarm = 0;
+ signal(SIGALRM, SIGNAL_CAST gotalarm_sig);
+
+ lock.l_type = type;
+ lock.l_whence = SEEK_SET;
+ lock.l_start = 0;
+ lock.l_len = 1;
+ lock.l_pid = 0;
+
+ alarm(5);
+ ret = fcntl(fd, F_SETLKW, &lock);
+ alarm(0);
+ signal(SIGALRM, SIGNAL_CAST SIG_DFL);
+
+ if (gotalarm) {
+ DEBUG(0, ("do_pw_lock: failed to %s SMB passwd file.\n",
+ type == F_UNLCK ? "unlock" : "lock"));
+ return -1;
+ }
+ return ret;
}
-static int pw_file_lock_depth;
-
-/***************************************************************
- Lock an fd. Abandon after waitsecs seconds.
-****************************************************************/
-
-static BOOL pw_file_lock(int fd, int type, int secs, int *plock_depth)
+int pw_file_lock(char *name, int type, int secs)
{
- if (fd < 0)
- return False;
-
- (*plock_depth)++;
-
- if(pw_file_lock_depth == 0) {
- if (!do_pw_lock(fd, secs, type)) {
- DEBUG(10,("pw_file_lock: locking file failed, error = %s.\n",
- strerror(errno)));
- return False;
- }
- }
-
- return True;
+ int fd = open(name, O_RDWR | O_CREAT, 0600);
+ if (fd < 0)
+ return (-1);
+ if (do_pw_lock(fd, secs, type)) {
+ close(fd);
+ return -1;
+ }
+ return fd;
}
-/***************************************************************
- Unlock an fd. Abandon after waitsecs seconds.
-****************************************************************/
-
-static BOOL pw_file_unlock(int fd, int *plock_depth)
+int pw_file_unlock(int fd)
{
- BOOL ret;
-
- if(*plock_depth == 1)
- ret = do_pw_lock(fd, 5, F_UNLCK);
-
- (*plock_depth)--;
-
- if(!ret)
- DEBUG(10,("pw_file_unlock: unlocking file failed, error = %s.\n",
- strerror(errno)));
- return ret;
+ do_pw_lock(fd, 5, F_UNLCK);
+ return close(fd);
}
-/***************************************************************
- Start to enumerate the smbpasswd list. Returns a void pointer
- to ensure no modification outside this module.
-
- do not call this function directly. use passdb.c instead.
-
- ****************************************************************/
-void *startsmbpwent(BOOL update)
-{
- FILE *fp = NULL;
- char *pfile = lp_smb_passwd_file();
-
- if (!*pfile) {
- DEBUG(0, ("startsmbpwent: No SMB password file set\n"));
- return (NULL);
- }
- DEBUG(10, ("startsmbpwent: opening file %s\n", pfile));
-
- fp = fopen(pfile, update ? "r+b" : "rb");
-
- if (fp == NULL) {
- DEBUG(0, ("startsmbpwent: unable to open file %s\n", pfile));
- return NULL;
- }
-
- /* Set a 16k buffer to do more efficient reads */
- setvbuf(fp, s_readbuf, _IOFBF, sizeof(s_readbuf));
-
- if (!pw_file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK), 5, &pw_file_lock_depth))
- {
- DEBUG(0, ("startsmbpwent: unable to lock file %s\n", pfile));
- fclose(fp);
- return NULL;
- }
-
- /* Make sure it is only rw by the owner */
- chmod(pfile, 0600);
-
- /* We have a lock on the file. */
- return (void *)fp;
-}
-
-/***************************************************************
- End enumeration of the smbpasswd list.
-****************************************************************/
-
-void endsmbpwent(void *vp)
-{
- FILE *fp = (FILE *)vp;
-
- pw_file_unlock(fileno(fp), &pw_file_lock_depth);
- fclose(fp);
- DEBUG(7, ("endsmbpwent: closed password file.\n"));
-}
-
-/*************************************************************************
- Routine to return the next entry in the smbpasswd list.
-
- do not call this function directly. use passdb.c instead.
-
- *************************************************************************/
-struct smb_passwd *getsmbpwent(void *vp)
-{
- /* Static buffers we will return. */
- static struct smb_passwd pw_buf;
- static pstring user_name;
- static unsigned char smbpwd[16];
- static unsigned char smbntpwd[16];
- FILE *fp = (FILE *)vp;
- char linebuf[256];
- unsigned char c;
- unsigned char *p;
- long uidval;
- long linebuf_len;
-
- if(fp == NULL) {
- DEBUG(0,("getsmbpwent: Bad password file pointer.\n"));
- return NULL;
- }
-
- pw_buf.acct_ctrl = ACB_NORMAL;
- pw_buf.pass_last_set_time = (time_t)-1;
-
- /*
- * Scan the file, a line at a time and check if the name matches.
- */
- while (!feof(fp)) {
- linebuf[0] = '\0';
-
- fgets(linebuf, 256, fp);
- if (ferror(fp)) {
- return NULL;
- }
-
- /*
- * Check if the string is terminated with a newline - if not
- * then we must keep reading and discard until we get one.
- */
- linebuf_len = strlen(linebuf);
- if (linebuf[linebuf_len - 1] != '\n') {
- c = '\0';
- while (!ferror(fp) && !feof(fp)) {
- c = fgetc(fp);
- if (c == '\n')
- break;
- }
- } else
- linebuf[linebuf_len - 1] = '\0';
-
-#ifdef DEBUG_PASSWORD
- DEBUG(100, ("getsmbpwent: got line |%s|\n", linebuf));
-#endif
- if ((linebuf[0] == 0) && feof(fp)) {
- DEBUG(4, ("getsmbpwent: end of file reached\n"));
- break;
- }
- /*
- * The line we have should be of the form :-
- *
- * username:uid:32hex bytes:[Account type]:LCT-12345678....other flags presently
- * ignored....
- *
- * or,
- *
- * username:uid:32hex bytes:32hex bytes:[Account type]:LCT-12345678....ignored....
- *
- * if Windows NT compatible passwords are also present.
- * [Account type] is an ascii encoding of the type of account.
- * LCT-(8 hex digits) is the time_t value of the last change time.
- */
-
- if (linebuf[0] == '#' || linebuf[0] == '\0') {
- DEBUG(6, ("getsmbpwent: skipping comment or blank line\n"));
- continue;
- }
- p = (unsigned char *) strchr(linebuf, ':');
- if (p == NULL) {
- DEBUG(0, ("getsmbpwent: malformed password entry (no :)\n"));
- continue;
- }
- /*
- * As 256 is shorter than a pstring we don't need to check
- * length here - if this ever changes....
- */
- strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
- user_name[PTR_DIFF(p, linebuf)] = '\0';
-
- /* Get smb uid. */
-
- p++; /* Go past ':' */
- if (!isdigit(*p)) {
- DEBUG(0, ("getsmbpwent: malformed password entry (uid not number)\n"));
- continue;
- }
-
- uidval = atoi((char *) p);
-
- while (*p && isdigit(*p))
- p++;
-
- if (*p != ':') {
- DEBUG(0, ("getsmbpwent: malformed password entry (no : after uid)\n"));
- continue;
- }
-
- pw_buf.smb_name = user_name;
- pw_buf.smb_userid = uidval;
-
- /*
- * Now get the password value - this should be 32 hex digits
- * which are the ascii representations of a 16 byte string.
- * Get two at a time and put them into the password.
- */
-
- /* Skip the ':' */
- p++;
-
- if (*p == '*' || *p == 'X') {
- /* Password deliberately invalid - end here. */
- DEBUG(10, ("getsmbpwent: entry invalidated for user %s\n", user_name));
- pw_buf.smb_nt_passwd = NULL;
- pw_buf.smb_passwd = NULL;
- pw_buf.acct_ctrl |= ACB_DISABLED;
- return &pw_buf;
- }
-
- if (linebuf_len < (PTR_DIFF(p, linebuf) + 33)) {
- DEBUG(0, ("getsmbpwent: malformed password entry (passwd too short)\n"));
- continue;
- }
-
- if (p[32] != ':') {
- DEBUG(0, ("getsmbpwent: malformed password entry (no terminating :)\n"));
- continue;
- }
-
- if (!strncasecmp((char *) p, "NO PASSWORD", 11)) {
- pw_buf.smb_passwd = NULL;
- pw_buf.acct_ctrl |= ACB_PWNOTREQ;
- } else {
- if (!gethexpwd((char *)p, (char *)smbpwd)) {
- DEBUG(0, ("getsmbpwent: Malformed Lanman password entry (non hex chars)\n"));
- continue;
- }
- pw_buf.smb_passwd = smbpwd;
- }
-
- /*
- * Now check if the NT compatible password is
- * available.
- */
- pw_buf.smb_nt_passwd = NULL;
-
- p += 33; /* Move to the first character of the line after
- the lanman password. */
- if ((linebuf_len >= (PTR_DIFF(p, linebuf) + 33)) && (p[32] == ':')) {
- if (*p != '*' && *p != 'X') {
- if(gethexpwd((char *)p,(char *)smbntpwd))
- pw_buf.smb_nt_passwd = smbntpwd;
- }
- p += 33; /* Move to the first character of the line after
- the NT password. */
- }
-
- DEBUG(5, ("getsmbpwent: returning passwd entry for user %s, uid %d\n",
- user_name, uidval));
-
- /*
- * Check if the account type bits have been encoded after the
- * NT password (in the form [NDHTUWSLXI]).
- */
-
- if (*p == '[') {
- BOOL finished = False;
-
- pw_buf.acct_ctrl = 0;
-
- for(p++;*p && !finished; p++) {
- switch (*p) {
-#if 0
- /*
- * Hmmm. Don't allow these to be set/read independently
- * of the actual password fields. We don't want a mismatch.
- * JRA.
- */
- case 'N':
- /* 'N'o password. */
- pw_buf.acct_ctrl |= ACB_PWNOTREQ;
- break;
- case 'D':
- /* 'D'isabled. */
- pw_buf.acct_ctrl |= ACB_DISABLED;
- break;
-#endif
- case 'H':
- /* 'H'omedir required. */
- pw_buf.acct_ctrl |= ACB_HOMDIRREQ;
- break;
- case 'T':
- /* 'T'emp account. */
- pw_buf.acct_ctrl |= ACB_TEMPDUP;
- break;
- case 'U':
- /* 'U'ser account (normal). */
- pw_buf.acct_ctrl |= ACB_NORMAL;
- break;
- case 'M':
- /* 'M'NS logon user account. What is this ? */
- pw_buf.acct_ctrl |= ACB_MNS;
- break;
- case 'W':
- /* 'W'orkstation account. */
- pw_buf.acct_ctrl |= ACB_WSTRUST;
- break;
- case 'S':
- /* 'S'erver account. */
- pw_buf.acct_ctrl |= ACB_SVRTRUST;
- break;
- case 'L':
- /* 'L'ocked account. */
- pw_buf.acct_ctrl |= ACB_AUTOLOCK;
- break;
- case 'X':
- /* No 'X'piry. */
- pw_buf.acct_ctrl |= ACB_PWNOEXP;
- break;
- case 'I':
- /* 'I'nterdomain trust account. */
- pw_buf.acct_ctrl |= ACB_DOMTRUST;
- break;
-
- case ':':
- case '\n':
- case '\0':
- case ']':
- default:
- finished = True;
- }
- }
-
- /* Must have some account type set. */
- if(pw_buf.acct_ctrl == 0)
- pw_buf.acct_ctrl = ACB_NORMAL;
-
- /* Now try and get the last change time. */
- if(*p == ']')
- p++;
- if(*p == ':') {
- p++;
- if(*p && StrnCaseCmp((char *)p, "LCT-", 4)) {
- int i;
- p += 4;
- for(i = 0; i < 8; i++) {
- if(p[i] == '\0' || !isxdigit(p[i]))
- break;
- }
- if(i == 8) {
- /*
- * p points at 8 characters of hex digits -
- * read into a time_t as the seconds since
- * 1970 that the password was last changed.
- */
- pw_buf.pass_last_set_time = (time_t)strtol((char *)p, NULL, 16);
- }
- }
- }
- } else {
- /* 'Old' style file. Fake up based on user name. */
- /*
- * Currently machine accounts are kept in the same
- * password file as 'normal accounts'. If this changes
- * we will have to fix this code. JRA.
- */
- if(pw_buf.smb_name[strlen(pw_buf.smb_name) - 1] == '$') {
- pw_buf.acct_ctrl &= ~ACB_NORMAL;
- pw_buf.acct_ctrl |= ACB_WSTRUST;
- }
- }
-
- return &pw_buf;
- }
-
- DEBUG(5,("getsmbpwent: end of file reached.\n"));
- return NULL;
-}
-
-/*************************************************************************
- Return the current position in the smbpasswd list as an unsigned long.
- This must be treated as an opaque token.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-unsigned long getsmbpwpos(void *vp)
-{
- return (unsigned long)ftell((FILE *)vp);
-}
-
-/*************************************************************************
- Set the current position in the smbpasswd list from unsigned long.
- This must be treated as an opaque token.
-
- do not call this function directly. use passdb.c instead.
+/*
+ * Routine to get the next 32 hex characters and turn them
+ * into a 16 byte array.
+ */
-*************************************************************************/
-BOOL setsmbpwpos(void *vp, unsigned long tok)
+static int gethexpwd(char *p, char *pwd)
{
- return !fseek((FILE *)vp, tok, SEEK_SET);
+ int i;
+ unsigned char lonybble, hinybble;
+ char *hexchars = "0123456789ABCDEF";
+ char *p1, *p2;
+
+ for (i = 0; i < 32; i += 2) {
+ hinybble = toupper(p[i]);
+ lonybble = toupper(p[i + 1]);
+
+ p1 = strchr(hexchars, hinybble);
+ p2 = strchr(hexchars, lonybble);
+ if (!p1 || !p2)
+ return (False);
+ hinybble = PTR_DIFF(p1, hexchars);
+ lonybble = PTR_DIFF(p2, hexchars);
+
+ pwd[i / 2] = (hinybble << 4) | lonybble;
+ }
+ return (True);
}
/*************************************************************************
Routine to search the smbpasswd file for an entry matching the username
or user id. if the name is NULL, then the smb_uid is used instead.
*************************************************************************/
-static struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid)
-{
- struct smb_passwd *pwd = NULL;
- FILE *fp = NULL;
-
- if (name != NULL) {
- DEBUG(10, ("get_smbpwd_entry: search by name: %s\n", name));
- } else {
- DEBUG(10, ("get_smbpwd_entry: search by smb_userid: %x\n", smb_userid));
- }
-
- /* Open the smbpassword file - not for update. */
- fp = startsmbpwent(False);
-
- if (fp == NULL) {
- DEBUG(0, ("get_smbpwd_entry: unable to open password file.\n"));
- return NULL;
- }
-
- /*
- * Scan the file, a line at a time and check if the name
- * or uid matches.
- */
-
- while ((pwd = getsmbpwent(fp)) != NULL) {
- if (name != NULL) {
- /* Search is by user name */
- if (!strequal(pwd->smb_name, name))
- continue;
- DEBUG(10, ("get_smbpwd_entry: found by name: %s\n", name));
- break;
- } else {
- /* Search is by user id */
- if (pwd->smb_userid != smb_userid)
- continue;
- DEBUG(10, ("get_smbpwd_entry: found by smb_userid: %x\n", smb_userid));
- break;
- }
- }
-
- endsmbpwent(fp);
- return pwd;
-}
-
-/************************************************************************
- Routine to search smb passwd by name.
-*************************************************************************/
-
-struct smb_passwd *getsmbpwnam(char *name)
-{
- return get_smbpwd_entry(name, 0);
-}
-
-
-/************************************************************************
- Routine to search smb passwd by uid.
-*************************************************************************/
-
-struct smb_passwd *getsmbpwuid(unsigned int uid)
+struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid)
{
- return get_smbpwd_entry(NULL, uid);
-}
+ /* Static buffers we will return. */
+ static struct smb_passwd pw_buf;
+ static pstring user_name;
+ static unsigned char smbpwd[16];
+ static unsigned char smbntpwd[16];
+ char linebuf[256];
+ char readbuf[16 * 1024];
+ unsigned char c;
+ unsigned char *p;
+ long uidval;
+ long linebuf_len;
+ FILE *fp;
+ int lockfd;
+ char *pfile = lp_smb_passwd_file();
-
-/**********************************************************
- Encode the account control bits into a string.
-**********************************************************/
-
-char *encode_acct_ctrl(uint16 acct_ctrl)
-{
- static fstring acct_str;
- char *p = acct_str;
-
- *p++ = '[';
-
- if (acct_ctrl & ACB_HOMDIRREQ) *p++ = 'H';
- if (acct_ctrl & ACB_TEMPDUP ) *p++ = 'T';
- if (acct_ctrl & ACB_NORMAL ) *p++ = 'U';
- if (acct_ctrl & ACB_MNS ) *p++ = 'M';
- if (acct_ctrl & ACB_WSTRUST ) *p++ = 'W';
- if (acct_ctrl & ACB_SVRTRUST ) *p++ = 'S';
- if (acct_ctrl & ACB_AUTOLOCK ) *p++ = 'L';
- if (acct_ctrl & ACB_PWNOEXP ) *p++ = 'X';
- if (acct_ctrl & ACB_DOMTRUST ) *p++ = 'I';
-
- *p++ = ']';
- *p = '\0';
- return acct_str;
-}
-
-/************************************************************************
- Routine to add an entry to the smbpasswd file.
-
- do not call this function directly. use passdb.c instead.
-
-*************************************************************************/
-
-BOOL add_smbpwd_entry(struct smb_passwd *newpwd)
-{
- char *pfile = lp_smb_passwd_file();
- struct smb_passwd *pwd = NULL;
- FILE *fp = NULL;
-
- int i;
- int wr_len;
-
- int fd;
- int new_entry_length;
- char *new_entry;
- long offpos;
- unsigned char *p;
-
- /* Open the smbpassword file - for update. */
- fp = startsmbpwent(True);
-
- if (fp == NULL) {
- DEBUG(0, ("add_smbpwd_entry: unable to open file.\n"));
- return False;
- }
-
- /*
- * Scan the file, a line at a time and check if the name matches.
- */
-
- while ((pwd = getsmbpwent(fp)) != NULL) {
- if (strequal(newpwd->smb_name, pwd->smb_name)) {
- DEBUG(0, ("add_smbpwd_entry: entry with name %s already exists\n", pwd->smb_name));
- endsmbpwent(fp);
- return False;
- }
- }
-
- /* Ok - entry doesn't exist. We can add it */
-
- /* Create a new smb passwd entry and set it to the given password. */
- /*
- * The add user write needs to be atomic - so get the fd from
- * the fp and do a raw write() call.
- */
- fd = fileno(fp);
-
- if((offpos = lseek(fd, 0, SEEK_END)) == -1) {
- DEBUG(0, ("add_smbpwd_entry(lseek): Failed to add entry for user %s to file %s. \
-Error was %s\n", newpwd->smb_name, pfile, strerror(errno)));
- endsmbpwent(fp);
- return False;
- }
-
- new_entry_length = strlen(newpwd->smb_name) + 1 + 15 + 1 + 32 + 1 + 32 + 1 + 5 + 1 + 13 + 2;
-
- if((new_entry = (char *)malloc( new_entry_length )) == NULL) {
- DEBUG(0, ("add_smbpwd_entry(malloc): Failed to add entry for user %s to file %s. \
-Error was %s\n", newpwd->smb_name, pfile, strerror(errno)));
- endsmbpwent(fp);
- return False;
- }
-
- sprintf(new_entry, "%s:%u:", newpwd->smb_name, (unsigned)newpwd->smb_userid);
- p = (unsigned char *)&new_entry[strlen(new_entry)];
-
- if(newpwd->smb_passwd != NULL) {
- for( i = 0; i < 16; i++) {
- sprintf((char *)&p[i*2], "%02X", newpwd->smb_passwd[i]);
- }
- } else {
- i=0;
- if(newpwd->acct_ctrl & ACB_PWNOTREQ)
- sprintf((char *)p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX");
- else
- sprintf((char *)p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
- }
-
- p += 32;
-
- *p++ = ':';
-
- if(newpwd->smb_nt_passwd != NULL) {
- for( i = 0; i < 16; i++) {
- sprintf((char *)&p[i*2], "%02X", newpwd->smb_nt_passwd[i]);
- }
- } else {
- if(newpwd->acct_ctrl & ACB_PWNOTREQ)
- sprintf((char *)p, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX");
- else
- sprintf((char *)p, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
- }
-
- p += 32;
-
- *p++ = ':';
-
- /* Add the account encoding and the last change time. */
- sprintf((char *)p, "%s:LCT-%08X:\n", encode_acct_ctrl(newpwd->acct_ctrl),
- (uint32)time(NULL));
+ pw_buf.acct_ctrl = ACB_NORMAL;
+ pw_buf.smb_passwd = NULL;
+ pw_buf.smb_nt_passwd = NULL;
+
+ if (!*pfile) {
+ DEBUG(0, ("No SMB password file set\n"));
+ return (NULL);
+ }
+ DEBUG(10, ("get_smbpwd_entry: opening file %s\n", pfile));
+
+ if (name != NULL)
+ {
+ DEBUG(10, ("get_smbpwd_entry: search by name: %s\n", name));
+ }
+ else
+ {
+ DEBUG(10, ("get_smbpwd_entry: search by smb_userid: %x\n", smb_userid));
+ }
+
+ fp = fopen(pfile, "r");
+
+ if (fp == NULL) {
+ DEBUG(0, ("get_smbpwd_entry: unable to open file %s\n", pfile));
+ return NULL;
+ }
+ /* Set a 16k buffer to do more efficient reads */
+ setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
+
+ if ((lockfd = pw_file_lock(pfile, F_RDLCK, 5)) < 0) {
+ DEBUG(0, ("get_smbpwd_entry: unable to lock file %s\n", pfile));
+ fclose(fp);
+ return NULL;
+ }
+ /* make sure it is only rw by the owner */
+ chmod(pfile, 0600);
+
+ /* We have a read lock on the file. */
+ /*
+ * Scan the file, a line at a time and check if the name matches.
+ */
+ while (!feof(fp)) {
+ linebuf[0] = '\0';
+
+ fgets(linebuf, 256, fp);
+ if (ferror(fp)) {
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return NULL;
+ }
+ /*
+ * Check if the string is terminated with a newline - if not
+ * then we must keep reading and discard until we get one.
+ */
+ linebuf_len = strlen(linebuf);
+ if (linebuf[linebuf_len - 1] != '\n') {
+ c = '\0';
+ while (!ferror(fp) && !feof(fp)) {
+ c = fgetc(fp);
+ if (c == '\n')
+ break;
+ }
+ } else
+ linebuf[linebuf_len - 1] = '\0';
#ifdef DEBUG_PASSWORD
- DEBUG(100, ("add_smbpwd_entry(%d): new_entry_len %d entry_len %d made line |%s|",
- fd, new_entry_length, strlen(new_entry), new_entry));
+ DEBUG(100, ("get_smbpwd_entry: got line |%s|\n", linebuf));
#endif
+ if ((linebuf[0] == 0) && feof(fp)) {
+ DEBUG(4, ("get_smbpwd_entry: end of file reached\n"));
+ break;
+ }
+ /*
+ * The line we have should be of the form :-
+ *
+ * username:uid:[32hex bytes]:....other flags presently
+ * ignored....
+ *
+ * or,
+ *
+ * username:uid:[32hex bytes]:[32hex bytes]:....ignored....
+ *
+ * if Windows NT compatible passwords are also present.
+ */
+
+ if (linebuf[0] == '#' || linebuf[0] == '\0') {
+ DEBUG(6, ("get_smbpwd_entry: skipping comment or blank line\n"));
+ continue;
+ }
+ p = (unsigned char *) strchr(linebuf, ':');
+ if (p == NULL) {
+ DEBUG(0, ("get_smbpwd_entry: malformed password entry (no :)\n"));
+ continue;
+ }
+ /*
+ * As 256 is shorter than a pstring we don't need to check
+ * length here - if this ever changes....
+ */
+ strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
+ user_name[PTR_DIFF(p, linebuf)] = '\0';
+
+ /* get smb uid */
+
+ p++; /* Go past ':' */
+ if (!isdigit(*p)) {
+ DEBUG(0, ("get_smbpwd_entry: malformed password entry (uid not number)\n"));
+ continue;
+ }
+
+ uidval = atoi((char *) p);
+
+ while (*p && isdigit(*p))
+ {
+ p++;
+ }
+
+ if (*p != ':')
+ {
+ DEBUG(0, ("get_smbpwd_entry: malformed password entry (no : after uid)\n"));
+ continue;
+ }
+
+ if (name != NULL)
+ {
+ /* search is by user name */
+ if (!strequal(user_name, name)) continue;
+ DEBUG(10, ("get_smbpwd_entry: found by name: %s\n", user_name));
+ }
+ else
+ {
+ /* search is by user id */
+ if (uidval != smb_userid) continue;
+ DEBUG(10, ("get_smbpwd_entry: found by smb_userid: %x\n", uidval));
+ }
+
+ /* if we're here, the entry has been found (either by name or uid) */
+
+ /*
+ * Now get the password value - this should be 32 hex digits
+ * which are the ascii representations of a 16 byte string.
+ * Get two at a time and put them into the password.
+ */
+
+ /* skip the ':' */
+ p++;
+
+ if (*p == '*' || *p == 'X')
+ {
+ /* Password deliberately invalid - end here. */
+ DEBUG(10, ("get_smbpwd_entry: entry invalidated for user %s\n", user_name));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return NULL;
+ }
+
+ if (linebuf_len < (PTR_DIFF(p, linebuf) + 33))
+ {
+ DEBUG(0, ("get_smbpwd_entry: malformed password entry (passwd too short)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return (False);
+ }
+
+ if (p[32] != ':')
+ {
+ DEBUG(0, ("get_smbpwd_entry: malformed password entry (no terminating :)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return NULL;
+ }
+
+ if (!strncasecmp((char *) p, "NO PASSWORD", 11))
+ {
+ pw_buf.smb_passwd = NULL;
+ /*
+ * We set this so that the caller can tell
+ * that there was no old password.
+ */
+ pw_buf.acct_ctrl |= ACB_PWNOTREQ;
+ }
+ else
+ {
+ if (!gethexpwd((char *)p, (char *)smbpwd))
+ {
+ DEBUG(0, ("Malformed Lanman password entry (non hex chars)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return NULL;
+ }
+ pw_buf.smb_passwd = smbpwd;
+ }
+
+ pw_buf.smb_name = user_name;
+ pw_buf.smb_userid = uidval;
+ pw_buf.smb_nt_passwd = NULL;
+
+ /* Now check if the NT compatible password is
+ available. */
+ p += 33; /* Move to the first character of the line after
+ the lanman password. */
+ if ((linebuf_len >= (PTR_DIFF(p, linebuf) + 33)) && (p[32] == ':')) {
+ if (*p != '*' && *p != 'X') {
+ if(gethexpwd((char *)p,(char *)smbntpwd))
+ pw_buf.smb_nt_passwd = smbntpwd;
+ }
+ }
+
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ DEBUG(5, ("get_smbpwd_entry: returning passwd entry for user %s, uid %d\n",
+ user_name, uidval));
+ return &pw_buf;
+ }
- if ((wr_len = write(fd, new_entry, strlen(new_entry))) != strlen(new_entry)) {
- DEBUG(0, ("add_smbpwd_entry(write): %d Failed to add entry for user %s to file %s. \
-Error was %s\n", wr_len, newpwd->smb_name, pfile, strerror(errno)));
-
- /* Remove the entry we just wrote. */
- if(ftruncate(fd, offpos) == -1) {
- DEBUG(0, ("add_smbpwd_entry: ERROR failed to ftruncate file %s. \
-Error was %s. Password file may be corrupt ! Please examine by hand !\n",
- newpwd->smb_name, strerror(errno)));
- }
-
- endsmbpwent(fp);
- return False;
- }
-
- endsmbpwent(fp);
- return True;
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return NULL;
}
-/************************************************************************
- Routine to search the smbpasswd file for an entry matching the username.
- and then modify its password entry. We can't use the startsmbpwent()/
- getsmbpwent()/endsmbpwent() interfaces here as we depend on looking
- in the actual file to decide how much room we have to write data.
- override = False, normal
- override = True, override XXXXXXXX'd out password or NO PASS
-
- do not call this function directly. use passdb.c instead.
-
-************************************************************************/
-
-BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override)
+/*
+ * Routine to search the smbpasswd file for an entry matching the username.
+ */
+BOOL add_smbpwd_entry(struct smb_passwd* pwd)
{
- /* Static buffers we will return. */
- static pstring user_name;
-
- char linebuf[256];
- char readbuf[16 * 1024];
- unsigned char c;
- fstring ascii_p16;
- fstring encode_bits;
- unsigned char *p = NULL;
- long linebuf_len = 0;
- FILE *fp;
- int lockfd;
- char *pfile = lp_smb_passwd_file();
- BOOL found_entry = False;
- BOOL got_pass_last_set_time = False;
-
- long pwd_seekpos = 0;
-
- int i;
- int wr_len;
- int fd;
-
- if (!*pfile) {
- DEBUG(0, ("No SMB password file set\n"));
- return False;
- }
- DEBUG(10, ("mod_smbpwd_entry: opening file %s\n", pfile));
-
- fp = fopen(pfile, "r+");
-
- if (fp == NULL) {
- DEBUG(0, ("mod_smbpwd_entry: unable to open file %s\n", pfile));
- return False;
- }
- /* Set a 16k buffer to do more efficient reads */
- setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
-
- lockfd = fileno(fp);
-
- if (!pw_file_lock(lockfd, F_WRLCK, 5, &pw_file_lock_depth)) {
- DEBUG(0, ("mod_smbpwd_entry: unable to lock file %s\n", pfile));
- fclose(fp);
- return False;
- }
-
- /* Make sure it is only rw by the owner */
- chmod(pfile, 0600);
-
- /* We have a write lock on the file. */
- /*
- * Scan the file, a line at a time and check if the name matches.
- */
- while (!feof(fp)) {
- pwd_seekpos = ftell(fp);
-
- linebuf[0] = '\0';
-
- fgets(linebuf, sizeof(linebuf), fp);
- if (ferror(fp)) {
- pw_file_unlock(lockfd, &pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- /*
- * Check if the string is terminated with a newline - if not
- * then we must keep reading and discard until we get one.
- */
- linebuf_len = strlen(linebuf);
- if (linebuf[linebuf_len - 1] != '\n') {
- c = '\0';
- while (!ferror(fp) && !feof(fp)) {
- c = fgetc(fp);
- if (c == '\n') {
- break;
- }
- }
- } else {
- linebuf[linebuf_len - 1] = '\0';
- }
+ /* Static buffers we will return. */
+ static pstring user_name;
+
+ char linebuf[256];
+ char readbuf[16 * 1024];
+ unsigned char c;
+ unsigned char *p;
+ long linebuf_len;
+ FILE *fp;
+ int lockfd;
+ char *pfile = lp_smb_passwd_file();
+
+ int i;
+ int wr_len;
+
+ int fd;
+ int new_entry_length;
+ char *new_entry;
+ long offpos;
+
+ if (!*pfile)
+ {
+ DEBUG(0, ("No SMB password file set\n"));
+ return False;
+ }
+ DEBUG(10, ("add_smbpwd_entry: opening file %s\n", pfile));
+
+ fp = fopen(pfile, "r+");
+
+ if (fp == NULL)
+ {
+ DEBUG(0, ("add_smbpwd_entry: unable to open file %s\n", pfile));
+ return False;
+ }
+ /* Set a 16k buffer to do more efficient reads */
+ setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
+
+ if ((lockfd = pw_file_lock(pfile, F_WRLCK, 5)) < 0)
+ {
+ DEBUG(0, ("add_smbpwd_entry: unable to lock file %s\n", pfile));
+ fclose(fp);
+ return False;
+ }
+ /* make sure it is only rw by the owner */
+ chmod(pfile, 0600);
+
+ /* We have a write lock on the file. */
+ /*
+ * Scan the file, a line at a time and check if the name matches.
+ */
+ while (!feof(fp))
+ {
+ linebuf[0] = '\0';
+
+ fgets(linebuf, 256, fp);
+ if (ferror(fp))
+ {
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ /*
+ * Check if the string is terminated with a newline - if not
+ * then we must keep reading and discard until we get one.
+ */
+ linebuf_len = strlen(linebuf);
+ if (linebuf[linebuf_len - 1] != '\n')
+ {
+ c = '\0';
+ while (!ferror(fp) && !feof(fp))
+ {
+ c = fgetc(fp);
+ if (c == '\n')
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ linebuf[linebuf_len - 1] = '\0';
+ }
#ifdef DEBUG_PASSWORD
- DEBUG(100, ("mod_smbpwd_entry: got line |%s|\n", linebuf));
+ DEBUG(100, ("add_smbpwd_entry: got line |%s|\n", linebuf));
#endif
- if ((linebuf[0] == 0) && feof(fp)) {
- DEBUG(4, ("mod_smbpwd_entry: end of file reached\n"));
- break;
- }
-
- /*
- * The line we have should be of the form :-
- *
- * username:uid:[32hex bytes]:....other flags presently
- * ignored....
- *
- * or,
- *
- * username:uid:[32hex bytes]:[32hex bytes]:....ignored....
- *
- * if Windows NT compatible passwords are also present.
- */
-
- if (linebuf[0] == '#' || linebuf[0] == '\0') {
- DEBUG(6, ("mod_smbpwd_entry: skipping comment or blank line\n"));
- continue;
- }
-
- p = (unsigned char *) strchr(linebuf, ':');
-
- if (p == NULL) {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no :)\n"));
- continue;
- }
-
- /*
- * As 256 is shorter than a pstring we don't need to check
- * length here - if this ever changes....
- */
- strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
- user_name[PTR_DIFF(p, linebuf)] = '\0';
- if (strequal(user_name, pwd->smb_name)) {
- found_entry = True;
- break;
- }
- }
-
- if (!found_entry) return False;
-
- DEBUG(6, ("mod_smbpwd_entry: entry exists\n"));
-
- /* User name matches - get uid and password */
- p++; /* Go past ':' */
-
- if (!isdigit(*p)) {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (uid not number)\n"));
- pw_file_unlock(lockfd, &pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- while (*p && isdigit(*p))
- p++;
- if (*p != ':') {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no : after uid)\n"));
- pw_file_unlock(lockfd, &pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- /*
- * Now get the password value - this should be 32 hex digits
- * which are the ascii representations of a 16 byte string.
- * Get two at a time and put them into the password.
- */
- p++;
-
- /* Record exact password position */
- pwd_seekpos += PTR_DIFF(p, linebuf);
-
- if (!override && (*p == '*' || *p == 'X')) {
- /* Password deliberately invalid - end here. */
- DEBUG(10, ("mod_smbpwd_entry: entry invalidated for user %s\n", user_name));
- pw_file_unlock(lockfd, &pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- if (linebuf_len < (PTR_DIFF(p, linebuf) + 33)) {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (passwd too short)\n"));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return (False);
- }
-
- if (p[32] != ':') {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no terminating :)\n"));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- if (!override && (*p == '*' || *p == 'X')) {
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- /* Now check if the NT compatible password is
- available. */
- p += 33; /* Move to the first character of the line after
- the lanman password. */
- if (linebuf_len < (PTR_DIFF(p, linebuf) + 33)) {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (passwd too short)\n"));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return (False);
- }
-
- if (p[32] != ':') {
- DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no terminating :)\n"));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- /*
- * Now check if the account info and the password last
- * change time is available.
- */
- p += 33; /* Move to the first character of the line after
- the NT password. */
-
- if (*p == '[') {
-
- i = 0;
- p++;
- while((linebuf_len > PTR_DIFF(p, linebuf)) && (*p != ']'))
- encode_bits[i++] = *p++;
-
- encode_bits[i] = '\0';
-
- /* Go past the ']' */
- if(linebuf_len > PTR_DIFF(p, linebuf))
- p++;
-
- if((linebuf_len > PTR_DIFF(p, linebuf)) && (*p == ':')) {
- p++;
-
- /* We should be pointing at the TLC entry. */
- if((linebuf_len > (PTR_DIFF(p, linebuf) + 13)) && StrnCaseCmp((char *)p, "LCT-", 4)) {
-
- p += 4;
- for(i = 0; i < 8; i++) {
- if(p[i] == '\0' || !isxdigit(p[i]))
- break;
- }
- if(i == 8) {
- /*
- * p points at 8 characters of hex digits -
- * read into a time_t as the seconds since
- * 1970 that the password was last changed.
- */
- got_pass_last_set_time = True;
- } /* i == 8 */
- } /* *p && StrnCaseCmp() */
- } /* p == ':' */
- } /* p == '[' */
-
- /* Entry is correctly formed. */
-
- /*
- * Do an atomic write into the file at the position defined by
- * seekpos.
- */
-
- /* The mod user write needs to be atomic - so get the fd from
- the fp and do a raw write() call.
- */
-
- fd = fileno(fp);
-
- if (lseek(fd, pwd_seekpos - 1, SEEK_SET) != pwd_seekpos - 1) {
- DEBUG(0, ("mod_smbpwd_entry: seek fail on file %s.\n", pfile));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- /* Sanity check - ensure the character is a ':' */
- if (read(fd, &c, 1) != 1) {
- DEBUG(0, ("mod_smbpwd_entry: read fail on file %s.\n", pfile));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- if (c != ':') {
- DEBUG(0, ("mod_smbpwd_entry: check on passwd file %s failed.\n", pfile));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- /* Create the 32 byte representation of the new p16 */
- if(pwd->smb_passwd != NULL) {
- for (i = 0; i < 16; i++) {
- sprintf(&ascii_p16[i*2], "%02X", (uchar) pwd->smb_passwd[i]);
- }
- } else {
- if(pwd->acct_ctrl & ACB_PWNOTREQ)
- sprintf(ascii_p16, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX");
- else
- sprintf(ascii_p16, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
- }
-
- /* Add on the NT md4 hash */
- ascii_p16[32] = ':';
- wr_len = 65;
- if (pwd->smb_nt_passwd != NULL) {
- for (i = 0; i < 16; i++) {
- sprintf(&ascii_p16[(i*2)+33], "%02X", (uchar) pwd->smb_nt_passwd[i]);
- }
- } else {
- if(pwd->acct_ctrl & ACB_PWNOTREQ)
- sprintf(&ascii_p16[33], "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX");
- else
- sprintf(&ascii_p16[33], "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
- }
-
- /* Add on the account info bits and the time of last
- password change. */
-
- pwd->pass_last_set_time = time(NULL);
-
- if(got_pass_last_set_time) {
- slprintf(&ascii_p16[strlen(ascii_p16)],
- sizeof(ascii_p16)-(strlen(ascii_p16)+1),
- ":[%s]:TLC-%08X:",
- encode_bits, (uint32)pwd->pass_last_set_time );
- wr_len = strlen(ascii_p16);
- }
+ if ((linebuf[0] == 0) && feof(fp))
+ {
+ DEBUG(4, ("add_smbpwd_entry: end of file reached\n"));
+ break;
+ }
+
+ /*
+ * The line we have should be of the form :-
+ *
+ * username:uid:[32hex bytes]:....other flags presently
+ * ignored....
+ *
+ * or,
+ *
+ * username:uid:[32hex bytes]:[32hex bytes]:....ignored....
+ *
+ * if Windows NT compatible passwords are also present.
+ */
+
+ if (linebuf[0] == '#' || linebuf[0] == '\0')
+ {
+ DEBUG(6, ("add_smbpwd_entry: skipping comment or blank line\n"));
+ continue;
+ }
+
+ p = (unsigned char *) strchr(linebuf, ':');
+
+ if (p == NULL)
+ {
+ DEBUG(0, ("add_smbpwd_entry: malformed password entry (no :)\n"));
+ continue;
+ }
+
+ /*
+ * As 256 is shorter than a pstring we don't need to check
+ * length here - if this ever changes....
+ */
+ strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
+ user_name[PTR_DIFF(p, linebuf)] = '\0';
+ if (strequal(user_name, pwd->smb_name))
+ {
+ DEBUG(6, ("add_smbpwd_entry: entry already exists\n"));
+ return False;
+ }
+ }
+
+ /* ok - entry doesn't exist. we can add it */
+
+ /* Create a new smb passwd entry and set it to the given password. */
+ /* The add user write needs to be atomic - so get the fd from
+ the fp and do a raw write() call.
+ */
+ fd = fileno(fp);
+
+ if((offpos = lseek(fd, 0, SEEK_END)) == -1)
+ {
+ DEBUG(0, ("add_smbpwd_entry(lseek): Failed to add entry for user %s to file %s. \
+Error was %s\n", pwd->smb_name, pfile, strerror(errno)));
+
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ new_entry_length = strlen(pwd->smb_name) + 1 + 15 + 1 + 32 + 1 + 32 + 1 + 2;
+
+ if((new_entry = (char *)malloc( new_entry_length )) == 0)
+ {
+ DEBUG(0, ("add_smbpwd_entry(malloc): Failed to add entry for user %s to file %s. \
+Error was %s\n",
+ pwd->smb_name, pfile, strerror(errno)));
+
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ sprintf(new_entry, "%s:%u:", pwd->smb_name, (unsigned)pwd->smb_userid);
+ p = (unsigned char *)&new_entry[strlen(new_entry)];
+
+ for( i = 0; i < 16; i++)
+ {
+ sprintf((char *)&p[i*2], "%02X", pwd->smb_passwd[i]);
+ }
+ p += 32;
+
+ *p++ = ':';
+
+ for( i = 0; i < 16; i++)
+ {
+ sprintf((char *)&p[i*2], "%02X", pwd->smb_nt_passwd[i]);
+ }
+ p += 32;
+
+ *p++ = ':';
+ sprintf((char *)p,"\n");
#ifdef DEBUG_PASSWORD
- DEBUG(100,("mod_smbpwd_entry: "));
- dump_data(100, ascii_p16, wr_len);
+ DEBUG(100, ("add_smbpwd_entry(%d): new_entry_len %d entry_len %d made line |%s|\n",
+ fd, new_entry_length, strlen(new_entry), new_entry));
#endif
- if (write(fd, ascii_p16, wr_len) != wr_len) {
- DEBUG(0, ("mod_smbpwd_entry: write failed in passwd file %s\n", pfile));
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return False;
- }
-
- pw_file_unlock(lockfd,&pw_file_lock_depth);
- fclose(fp);
- return True;
-}
-
-static int mach_passwd_lock_depth;
-static FILE *mach_passwd_fp;
-
-/************************************************************************
- Routine to get the name for a machine account file.
-************************************************************************/
-
-static void get_machine_account_file_name( char *domain, char *name, char *mac_file)
-{
- unsigned int mac_file_len;
- char *p;
-
- pstrcpy(mac_file, lp_smb_passwd_file());
- p = strrchr(mac_file, '/');
- if(p != NULL)
- *++p = '\0';
-
- mac_file_len = strlen(mac_file);
-
- if ((int)(sizeof(pstring) - mac_file_len - strlen(domain) - strlen(name) - 6) < 0)
- {
- DEBUG(0,("machine_password_lock: path %s too long to add machine details.\n",
- mac_file));
- return;
- }
-
- strcat(mac_file, domain);
- strcat(mac_file, ".");
- strcat(mac_file, name);
- strcat(mac_file, ".mac");
-}
-
-/************************************************************************
- Routine to lock the machine account password file for a domain.
-************************************************************************/
-
-BOOL machine_password_lock( char *domain, char *name, BOOL update)
-{
- pstring mac_file;
-
- if(mach_passwd_lock_depth == 0) {
+ if ((wr_len = write(fd, new_entry, strlen(new_entry))) != strlen(new_entry))
+ {
+ DEBUG(0, ("add_smbpwd_entry(write): %d Failed to add entry for user %s to file %s. \
+Error was %s\n", wr_len, pwd->smb_name, pfile, strerror(errno)));
- get_machine_account_file_name( domain, name, mac_file);
-
- if((mach_passwd_fp = fopen(mac_file, "r+b")) == NULL) {
- if(errno == ENOENT && update) {
- mach_passwd_fp = fopen(mac_file, "w+b");
- }
-
- if(mach_passwd_fp == NULL) {
- DEBUG(0,("machine_password_lock: cannot open file %s - Error was %s.\n",
- mac_file, strerror(errno) ));
- return False;
- }
- }
-
- chmod(mac_file, 0600);
-
- if(!pw_file_lock(fileno(mach_passwd_fp), (update ? F_WRLCK : F_RDLCK),
- 60, &mach_passwd_lock_depth))
- {
- DEBUG(0,("machine_password_lock: cannot lock file %s\n", mac_file));
- fclose(mach_passwd_fp);
- return False;
- }
-
- }
-
- return True;
-}
+ /* Remove the entry we just wrote. */
+ if(ftruncate(fd, offpos) == -1)
+ {
+ DEBUG(0, ("add_smbpwd_entry: ERROR failed to ftruncate file %s. \
+Error was %s. Password file may be corrupt ! Please examine by hand !\n",
+ pwd->smb_name, strerror(errno)));
+ }
-/************************************************************************
- Routine to unlock the machine account password file for a domain.
-************************************************************************/
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
-BOOL machine_password_unlock(void)
-{
- BOOL ret = pw_file_unlock(fileno(mach_passwd_fp), &mach_passwd_lock_depth);
- if(mach_passwd_lock_depth == 0)
- fclose(mach_passwd_fp);
- return ret;
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return True;
}
+/*
+ * Routine to search the smbpasswd file for an entry matching the username.
+ * and then modify its password entry
+ * override = 0, normal
+ * override = 1, don't care about XXXXXXXX'd out password or NO PASS
+ */
-/************************************************************************
- Routine to delete the machine account password file for a domain.
-************************************************************************/
-
-BOOL machine_password_delete( char *domain, char *name )
+BOOL mod_smbpwd_entry(struct smb_passwd* pwd, BOOL override)
{
- pstring mac_file;
-
- get_machine_account_file_name( domain, name, mac_file);
- return (unlink( mac_file ) == 0);
-}
-
-/************************************************************************
- Routine to get the machine account password for a domain.
- The user of this function must have locked the machine password file.
-************************************************************************/
+ /* Static buffers we will return. */
+ static pstring user_name;
+
+ char linebuf[256];
+ char readbuf[16 * 1024];
+ unsigned char c;
+ char ascii_p16[66];
+ unsigned char *p = NULL;
+ long linebuf_len = 0;
+ FILE *fp;
+ int lockfd;
+ char *pfile = lp_smb_passwd_file();
+ BOOL found_entry = False;
+
+ long pwd_seekpos = 0;
+
+ int i;
+ int wr_len;
+ int fd;
+
+ if (!*pfile)
+ {
+ DEBUG(0, ("No SMB password file set\n"));
+ return False;
+ }
+ DEBUG(10, ("mod_smbpwd_entry: opening file %s\n", pfile));
+
+ fp = fopen(pfile, "r+");
+
+ if (fp == NULL)
+ {
+ DEBUG(0, ("mod_smbpwd_entry: unable to open file %s\n", pfile));
+ return False;
+ }
+ /* Set a 16k buffer to do more efficient reads */
+ setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
+
+ if ((lockfd = pw_file_lock(pfile, F_WRLCK, 5)) < 0)
+ {
+ DEBUG(0, ("mod_smbpwd_entry: unable to lock file %s\n", pfile));
+ fclose(fp);
+ return False;
+ }
+ /* make sure it is only rw by the owner */
+ chmod(pfile, 0600);
+
+ /* We have a write lock on the file. */
+ /*
+ * Scan the file, a line at a time and check if the name matches.
+ */
+ while (!feof(fp))
+ {
+ pwd_seekpos = ftell(fp);
+
+ linebuf[0] = '\0';
+
+ fgets(linebuf, 256, fp);
+ if (ferror(fp))
+ {
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ /*
+ * Check if the string is terminated with a newline - if not
+ * then we must keep reading and discard until we get one.
+ */
+ linebuf_len = strlen(linebuf);
+ if (linebuf[linebuf_len - 1] != '\n')
+ {
+ c = '\0';
+ while (!ferror(fp) && !feof(fp))
+ {
+ c = fgetc(fp);
+ if (c == '\n')
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ linebuf[linebuf_len - 1] = '\0';
+ }
-BOOL get_machine_account_password( unsigned char *ret_pwd, time_t *pass_last_set_time)
-{
- char linebuf[256];
- char *p;
- int i;
-
- linebuf[0] = '\0';
-
- *pass_last_set_time = (time_t)0;
- memset(ret_pwd, '\0', 16);
-
- if(fseek( mach_passwd_fp, 0L, SEEK_SET) == -1) {
- DEBUG(0,("get_machine_account_password: Failed to seek to start of file. Error was %s.\n",
- strerror(errno) ));
- return False;
- }
-
- fgets(linebuf, sizeof(linebuf), mach_passwd_fp);
- if(ferror(mach_passwd_fp)) {
- DEBUG(0,("get_machine_account_password: Failed to read password. Error was %s.\n",
- strerror(errno) ));
- return False;
- }
-
- /*
- * The length of the line read
- * must be 45 bytes ( <---XXXX 32 bytes-->:TLC-12345678
- */
-
- if(strlen(linebuf) != 45) {
- DEBUG(0,("get_machine_account_password: Malformed machine password file (wrong length).\n"));
#ifdef DEBUG_PASSWORD
- DEBUG(100,("get_machine_account_password: line = |%s|\n", linebuf));
+ DEBUG(100, ("mod_smbpwd_entry: got line |%s|\n", linebuf));
#endif
- return False;
- }
-
- /*
- * Get the hex password.
- */
- if (!gethexpwd((char *)linebuf, (char *)ret_pwd) || linebuf[32] != ':' ||
- strncmp(&linebuf[33], "TLC-", 4)) {
- DEBUG(0,("get_machine_account_password: Malformed machine password file (incorrect format).\n"));
-#ifdef DEBUG_PASSWORD
- DEBUG(100,("get_machine_account_password: line = |%s|\n", linebuf));
+ if ((linebuf[0] == 0) && feof(fp))
+ {
+ DEBUG(4, ("mod_smbpwd_entry: end of file reached\n"));
+ break;
+ }
+
+ /*
+ * The line we have should be of the form :-
+ *
+ * username:uid:[32hex bytes]:....other flags presently
+ * ignored....
+ *
+ * or,
+ *
+ * username:uid:[32hex bytes]:[32hex bytes]:....ignored....
+ *
+ * if Windows NT compatible passwords are also present.
+ */
+
+ if (linebuf[0] == '#' || linebuf[0] == '\0')
+ {
+ DEBUG(6, ("mod_smbpwd_entry: skipping comment or blank line\n"));
+ continue;
+ }
+
+ p = (unsigned char *) strchr(linebuf, ':');
+
+ if (p == NULL)
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no :)\n"));
+ continue;
+ }
+
+ /*
+ * As 256 is shorter than a pstring we don't need to check
+ * length here - if this ever changes....
+ */
+ strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
+ user_name[PTR_DIFF(p, linebuf)] = '\0';
+ if (strequal(user_name, pwd->smb_name))
+ {
+ found_entry = True;
+ break;
+ }
+ }
+
+ if (!found_entry) return False;
+
+ DEBUG(6, ("mod_smbpwd_entry: entry exists\n"));
+
+ /* User name matches - get uid and password */
+ p++; /* Go past ':' */
+
+ if (!isdigit(*p))
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (uid not number)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ while (*p && isdigit(*p))
+ p++;
+ if (*p != ':')
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no : after uid)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+ /*
+ * Now get the password value - this should be 32 hex digits
+ * which are the ascii representations of a 16 byte string.
+ * Get two at a time and put them into the password.
+ */
+ p++;
+
+ /* record exact password position */
+ pwd_seekpos += PTR_DIFF(p, linebuf);
+
+ if (!override && (*p == '*' || *p == 'X'))
+ {
+ /* Password deliberately invalid - end here. */
+ DEBUG(10, ("get_smbpwd_entry: entry invalidated for user %s\n", user_name));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ if (linebuf_len < (PTR_DIFF(p, linebuf) + 33))
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (passwd too short)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return (False);
+ }
+
+ if (p[32] != ':')
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no terminating :)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ if (!override && (*p == '*' || *p == 'X'))
+ {
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ /* Now check if the NT compatible password is
+ available. */
+ p += 33; /* Move to the first character of the line after
+ the lanman password. */
+ if (linebuf_len < (PTR_DIFF(p, linebuf) + 33))
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (passwd too short)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return (False);
+ }
+
+ if (p[32] != ':')
+ {
+ DEBUG(0, ("mod_smbpwd_entry: malformed password entry (no terminating :)\n"));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ /* The following check is wrong - the NT hash is optional. */
+#if 0
+ if (*p == '*' || *p == 'X')
+ {
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
#endif
- return False;
- }
- /*
- * Get the last changed time.
- */
- p = &linebuf[37];
+ /* whew. entry is correctly formed. */
+
+ /*
+ * Do an atomic write into the file at the position defined by
+ * seekpos.
+ */
+
+ /* The mod user write needs to be atomic - so get the fd from
+ the fp and do a raw write() call.
+ */
+
+ fd = fileno(fp);
+
+ if (lseek(fd, pwd_seekpos - 1, SEEK_SET) != pwd_seekpos - 1)
+ {
+ DEBUG(1, ("mod_smbpwd_entry: seek fail on file %s.\n", pfile));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ /* Sanity check - ensure the character is a ':' */
+ if (read(fd, &c, 1) != 1)
+ {
+ DEBUG(1, ("mod_smbpwd_entry: read fail on file %s.\n", pfile));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ if (c != ':')
+ {
+ DEBUG(1, ("mod_smbpwd_entry: check on passwd file %s failed.\n", pfile));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ /* Create the 32 byte representation of the new p16 */
+ for (i = 0; i < 16; i++)
+ {
+ sprintf(&ascii_p16[i*2], "%02X", (uchar) pwd->smb_passwd[i]);
+ }
+ /* Add on the NT md4 hash */
+ ascii_p16[32] = ':';
+ wr_len = 65;
+ if (pwd->smb_nt_passwd != NULL)
+ {
+ for (i = 0; i < 16; i++)
+ {
+ sprintf(&ascii_p16[(i*2)+33], "%02X", (uchar) pwd->smb_nt_passwd[i]);
+ }
+ }
+ else
+ {
+ /* No NT hash - write out an 'invalid' string. */
+ strcpy(&ascii_p16[33], "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+ }
- for(i = 0; i < 8; i++) {
- if(p[i] == '\0' || !isxdigit(p[i])) {
- DEBUG(0,("get_machine_account_password: Malformed machine password file (no timestamp).\n"));
#ifdef DEBUG_PASSWORD
- DEBUG(100,("get_machine_account_password: line = |%s|\n", linebuf));
+ DEBUG(100,("mod_smbpwd_entry: "));
+ dump_data(100, ascii_p16, wr_len);
#endif
- return False;
- }
- }
-
- /*
- * p points at 8 characters of hex digits -
- * read into a time_t as the seconds since
- * 1970 that the password was last changed.
- */
-
- *pass_last_set_time = (time_t)strtol(p, NULL, 16);
-
- return True;
-}
-
-/************************************************************************
- Routine to get the machine account password for a domain.
- The user of this function must have locked the machine password file.
-************************************************************************/
-
-BOOL set_machine_account_password( unsigned char *md4_new_pwd)
-{
- char linebuf[64];
- int i;
-
- if(fseek( mach_passwd_fp, 0L, SEEK_SET) == -1) {
- DEBUG(0,("set_machine_account_password: Failed to seek to start of file. Error was %s.\n",
- strerror(errno) ));
- return False;
- }
-
- for (i = 0; i < 16; i++)
- sprintf(&linebuf[(i*2)], "%02X", md4_new_pwd[i]);
-
- sprintf(&linebuf[32], ":TLC-%08X\n", (unsigned)time(NULL));
-
- if(fwrite( linebuf, 1, 45, mach_passwd_fp)!= 45) {
- DEBUG(0,("set_machine_account_password: Failed to write file. Warning - the machine \
-machine account is now invalid. Please recreate. Error was %s.\n", strerror(errno) ));
- return False;
- }
- fflush(mach_passwd_fp);
- return True;
+ if (write(fd, ascii_p16, wr_len) != wr_len)
+ {
+ DEBUG(1, ("mod_smbpwd_entry: write failed in passwd file %s\n", pfile));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return False;
+ }
+
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ return True;
}
diff --git a/source/printing/pcap.c b/source/printing/pcap.c
index 0b3ad2b1362..b3520d8b1e6 100644
--- a/source/printing/pcap.c
+++ b/source/printing/pcap.c
@@ -91,7 +91,7 @@ static int strlocate(char *xpLine,char *xpS)
/* ******************************************************************* */
/* * Scan qconfig and search all virtual printer (device printer) * */
/* ******************************************************************* */
-static void ScanQconfig_fn(char *psz,void (*fn)())
+static void ScanQconfig_fn(char *psz,void (*fn)(char *, char *))
{
int iLg,iEtat;
FILE *pfile;
@@ -313,7 +313,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
run a function on each printer name in the printcap file. The function is
passed the primary name and the comment (if possible)
***************************************************************************/
-void pcap_printer_fn(void (*fn)(char *, char *))
+void pcap_printer_fn(void (*fn)(char *, char*))
{
pstring name,comment;
char *line;
diff --git a/source/printing/print_svid.c b/source/printing/print_svid.c
index f2126f25acd..88a919c821e 100644
--- a/source/printing/print_svid.c
+++ b/source/printing/print_svid.c
@@ -45,7 +45,7 @@ typedef struct printer {
} printer_t;
static printer_t *printers = NULL;
-static void populate_printers(void)
+static void populate_printers()
{
FILE *fp;
diff --git a/source/printing/printing.c b/source/printing/printing.c
index 278c54933d3..f0ace2b7aeb 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -146,7 +146,7 @@ static char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
/*******************************************************************
process time fields
********************************************************************/
-static time_t EntryTime(string tok[], int ptr, int count, int minimum)
+static time_t EntryTime(fstring tok[], int ptr, int count, int minimum)
{
time_t jobtime,jobtime1;
@@ -223,7 +223,7 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
#define NTOK 5
#endif /* OSF1 */
- string tok[NTOK];
+ fstring tok[NTOK];
int count=0;
#ifdef OSF1
@@ -253,7 +253,7 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
/* only take the last part of the filename */
{
- string tmp;
+ fstring tmp;
char *p = strrchr(tok[FILETOK],'/');
if (p)
{
@@ -282,7 +282,7 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
LPRng_time modifies the current date by inserting the hour and minute from
the lpq output. The lpq time looks like "23:15:07"
*/
-static time_t LPRng_time(string tok[],int pos)
+static time_t LPRng_time(fstring tok[],int pos)
{
time_t jobtime;
struct tm *t;
@@ -381,7 +381,7 @@ LPRng source changes. This is from version 2.3.0. Magnus */
#define JOBSIZE_POS FILE_POS+FILE_W
- string tok[LPRNG_NTOK];
+ fstring tok[LPRNG_NTOK];
int count=0;
#ifdef OLD_LPRNG
@@ -424,7 +424,7 @@ A long spool-path will just waste significant chars of the file name.
/* only take the last part of the filename */
{
- string tmp;
+ fstring tmp;
char *p = strrchr(tok[LPRNG_FILETOK],'/');
if (p)
{
@@ -473,7 +473,7 @@ lazer lazer RUNNING 537 6297doc.A kvintus@IE 0 10 2445 1 1
********************************************************************/
static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
{
- string tok[11];
+ fstring tok[11];
int count=0;
/* handle the case of "(standard input)" as a filename */
@@ -497,7 +497,7 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
/* only take the last part of the filename */
{
- string tmp;
+ fstring tmp;
char *p = strrchr(tok[2],'/');
if (p)
{
@@ -531,7 +531,7 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
/* only take the last part of the filename */
{
- string tmp;
+ fstring tmp;
char *p = strrchr(tok[4],'/');
if (p)
{
@@ -568,7 +568,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
{
/* must read two lines to process, therefore keep some values static */
static BOOL header_line_ok=False, base_prio_reset=False;
- static string jobuser;
+ static fstring jobuser;
static int jobid;
static int jobprio;
static time_t jobtime;
@@ -579,7 +579,7 @@ static BOOL parse_lpq_hpux(char * line, print_queue_struct *buf, BOOL first)
int count;
char TAB = '\011';
- string tok[12];
+ fstring tok[12];
/* If a line begins with a horizontal TAB, it is a subline type */
@@ -674,7 +674,7 @@ dcslw-897 tridge 4712 Dec 20 10:30:30 being held
****************************************************************************/
static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
{
- string tok[9];
+ fstring tok[9];
int count=0;
char *p;
@@ -694,7 +694,7 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
/* if the user contains a ! then trim the first part of it */
if ((p=strchr(tok[2],'!')))
{
- string tmp;
+ fstring tmp;
fstrcpy(tmp,p+1);
fstrcpy(tok[2],tmp);
}
@@ -727,7 +727,7 @@ Printer: txt (ready)
****************************************************************************/
static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
{
- string tok[7];
+ fstring tok[7];
int count=0;
DEBUG(0,("antes [%s]\n", line));
@@ -756,7 +756,7 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
/* only take the last part of the filename */
{
- string tmp;
+ fstring tmp;
char *p = strrchr(tok[6],'/');
if (p)
{
@@ -792,7 +792,7 @@ Local Printer 'lp2' (fjall):
****************************************************************************/
static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
{
- string tok[11];
+ fstring tok[11];
int count=0;
/* handle the case of "(standard input)" as a filename */
@@ -820,7 +820,7 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
/* only take the last part of the filename */
{
- string tmp;
+ fstring tmp;
char *p = strrchr(tok[6],'/');
if (p)
{
@@ -862,7 +862,7 @@ Total: 21268 bytes in queue
****************************************************************************/
static BOOL parse_lpq_softq(char *line,print_queue_struct *buf,BOOL first)
{
- string tok[10];
+ fstring tok[10];
int count=0;
/* mung all the ":"s to spaces*/
diff --git a/source/script/installswat.sh b/source/script/installswat.sh
deleted file mode 100755
index a51fd56272c..00000000000
--- a/source/script/installswat.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-#fist version March 1998, Andrew Tridgell
-
-SWATDIR=$1
-SRCDIR=$2
-
-echo Installing the Samba Web Admisistration Tool
-
-for d in $SWATDIR $SWATDIR/help $SWATDIR/images; do
-if [ ! -d $d ]; then
- mkdir $d
-if [ ! -d $d ]; then
- echo Failed to make directory $d, does $USER have privileges?
- exit 1
-fi
-fi
-done
-
-for f in $SRCDIR../swat/images/*.gif; do
- FNAME=$SWATDIR/images/`basename $f`
- echo $FNAME
- cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
- chmod 0644 $FNAME
-done
-
-for f in $SRCDIR../swat/images/*.jpg; do
- FNAME=$SWATDIR/images/`basename $f`
- echo $FNAME
- cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
- chmod 0644 $FNAME
-done
-
-for f in $SRCDIR../swat/help/*.html; do
- FNAME=$SWATDIR/help/`basename $f`
- echo $FNAME
- cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges?
- chmod 0644 $FNAME
-done
-
-cat << EOF
-======================================================================
-The SWAT files have been installed. Remember to read the swat/README
-for information on enabling and using SWAT
-======================================================================
-EOF
-
-exit 0
-
diff --git a/source/smbd/chgpasswd.c b/source/smbd/chgpasswd.c
index e466455aeb8..3b8af512f70 100644
--- a/source/smbd/chgpasswd.c
+++ b/source/smbd/chgpasswd.c
@@ -132,15 +132,15 @@ static int dochild(int master,char *slavedev, char *name, char *passwordprogram,
slavedev));
return(False);
}
-#if defined(SVR4) || defined(SUNOS5) || defined(SCO)
+#if defined(SVR4) || defined(SUNOS5) || defined(SCO) || defined(HPUX)
ioctl(slave, I_PUSH, "ptem");
ioctl(slave, I_PUSH, "ldterm");
-#else /* defined(SVR4) || defined(SUNOS5) || defined(SCO) */
+#else /* defined(SVR4) || defined(SUNOS5) || defined(SCO) || defined(HPUX) */
if (ioctl(slave,TIOCSCTTY,0) <0) {
DEBUG(3,("Error in ioctl call for slave pty\n"));
/* return(False); */
}
-#endif /* defined(SVR4) || defined(SUNOS5) || defined(SCO) */
+#endif /* defined(SVR4) || defined(SUNOS5) || defined(SCO) || defined(HPUX) */
/* Close master. */
close(master);
@@ -440,56 +440,56 @@ BOOL chgpasswd(char *name,char *oldpass,char *newpass, BOOL as_root)
************************************************************/
BOOL check_lanman_password(char *user, unsigned char *pass1,
- unsigned char *pass2, struct smb_passwd **psampw)
+ unsigned char *pass2, struct smb_passwd **psmbpw)
{
unsigned char unenc_new_pw[16];
unsigned char unenc_old_pw[16];
unsigned char null_pw[16];
- struct smb_passwd *sampw;
+ struct smb_passwd *smbpw;
- *psampw = NULL;
+ *psmbpw = NULL;
become_root(0);
- sampw = getsampwnam(user);
+ smbpw = get_smbpwd_entry(user, 0);
unbecome_root(0);
- if(sampw == NULL)
+ if(smbpw == NULL)
{
- DEBUG(0,("check_lanman_password: getsampwnam returned NULL\n"));
+ DEBUG(0,("check_lanman_password: get_smbpwd_entry returned NULL\n"));
return False;
}
- if(sampw->acct_ctrl & ACB_DISABLED)
+ if(smbpw->acct_ctrl & ACB_DISABLED)
{
DEBUG(0,("check_lanman_password: account %s disabled.\n", user));
return False;
}
- if((sampw->smb_passwd == NULL) && (sampw->acct_ctrl & ACB_PWNOTREQ))
+ if((smbpw->smb_passwd == NULL) && (smbpw->acct_ctrl & ACB_PWNOTREQ))
{
unsigned char no_pw[14];
memset(no_pw, '\0', 14);
E_P16((uchar *)no_pw, (uchar *)null_pw);
- sampw->smb_passwd = null_pw;
- } else if (sampw->smb_passwd == NULL) {
+ smbpw->smb_passwd = null_pw;
+ } else if (smbpw->smb_passwd == NULL) {
DEBUG(0,("check_lanman_password: no lanman password !\n"));
return False;
}
/* Get the new lanman hash. */
- D_P16(sampw->smb_passwd, pass2, unenc_new_pw);
+ D_P16(smbpw->smb_passwd, pass2, unenc_new_pw);
/* Use this to get the old lanman hash. */
D_P16(unenc_new_pw, pass1, unenc_old_pw);
/* Check that the two old passwords match. */
- if(memcmp(sampw->smb_passwd, unenc_old_pw, 16))
+ if(memcmp(smbpw->smb_passwd, unenc_old_pw, 16))
{
DEBUG(0,("check_lanman_password: old password doesn't match.\n"));
return False;
}
- *psampw = sampw;
+ *psmbpw = smbpw;
return True;
}
@@ -499,44 +499,44 @@ BOOL check_lanman_password(char *user, unsigned char *pass1,
no longer be valid.
************************************************************/
-BOOL change_lanman_password(struct smb_passwd *sampw, unsigned char *pass1, unsigned char *pass2)
+BOOL change_lanman_password(struct smb_passwd *smbpw, unsigned char *pass1, unsigned char *pass2)
{
unsigned char unenc_new_pw[16];
unsigned char null_pw[16];
BOOL ret;
- if(sampw == NULL)
+ if(smbpw == NULL)
{
- DEBUG(0,("change_lanman_password: no smb password entry.\n"));
+ DEBUG(0,("change_lanman_password: get_smbpwd_entry returned NULL\n"));
return False;
}
- if(sampw->acct_ctrl & ACB_DISABLED)
+ if(smbpw->acct_ctrl & ACB_DISABLED)
{
- DEBUG(0,("change_lanman_password: account %s disabled.\n", sampw->smb_name));
+ DEBUG(0,("change_lanman_password: account %s disabled.\n", smbpw->smb_name));
return False;
}
- if((sampw->smb_passwd == NULL) && (sampw->acct_ctrl & ACB_PWNOTREQ))
+ if((smbpw->smb_passwd == NULL) && (smbpw->acct_ctrl & ACB_PWNOTREQ))
{
unsigned char no_pw[14];
memset(no_pw, '\0', 14);
E_P16((uchar *)no_pw, (uchar *)null_pw);
- sampw->smb_passwd = null_pw;
- } else if (sampw->smb_passwd == NULL) {
+ smbpw->smb_passwd = null_pw;
+ } else if (smbpw->smb_passwd == NULL) {
DEBUG(0,("change_lanman_password: no lanman password !\n"));
return False;
}
/* Get the new lanman hash. */
- D_P16(sampw->smb_passwd, pass2, unenc_new_pw);
+ D_P16(smbpw->smb_passwd, pass2, unenc_new_pw);
- sampw->smb_passwd = unenc_new_pw;
- sampw->smb_nt_passwd = NULL; /* We lose the NT hash. Sorry. */
+ smbpw->smb_passwd = unenc_new_pw;
+ smbpw->smb_nt_passwd = NULL; /* We lose the NT hash. Sorry. */
/* Now write it into the file. */
become_root(0);
- ret = mod_sampwd_entry(sampw,False);
+ ret = mod_smbpwd_entry(smbpw, False);
unbecome_root(0);
return ret;
@@ -547,10 +547,10 @@ BOOL change_lanman_password(struct smb_passwd *sampw, unsigned char *pass1, unsi
************************************************************/
BOOL check_oem_password(char *user, unsigned char *data,
- struct smb_passwd **psampw, char *new_passwd,
+ struct smb_passwd **psmbpw, char *new_passwd,
int new_passwd_size)
{
- struct smb_passwd *sampw = NULL;
+ struct smb_passwd *smbpw = NULL;
int new_pw_len;
fstring upper_case_new_passwd;
unsigned char new_p16[16];
@@ -558,28 +558,28 @@ BOOL check_oem_password(char *user, unsigned char *data,
unsigned char null_pw[16];
become_root(0);
- *psampw = sampw = getsampwnam(user);
+ *psmbpw = smbpw = get_smbpwd_entry(user, 0);
unbecome_root(0);
- if(sampw == NULL)
+ if(smbpw == NULL)
{
- DEBUG(0,("check_oem_password: getsampwnam returned NULL\n"));
+ DEBUG(0,("check_oem_password: get_smbpwd_entry returned NULL\n"));
return False;
}
- if(sampw->acct_ctrl & ACB_DISABLED)
+ if(smbpw->acct_ctrl & ACB_DISABLED)
{
DEBUG(0,("check_lanman_password: account %s disabled.\n", user));
return False;
}
- if((sampw->smb_passwd == NULL) && (sampw->acct_ctrl & ACB_PWNOTREQ))
+ if((smbpw->smb_passwd == NULL) && (smbpw->acct_ctrl & ACB_PWNOTREQ))
{
unsigned char no_pw[14];
memset(no_pw, '\0', 14);
E_P16((uchar *)no_pw, (uchar *)null_pw);
- sampw->smb_passwd = null_pw;
- } else if (sampw->smb_passwd == NULL) {
+ smbpw->smb_passwd = null_pw;
+ } else if (smbpw->smb_passwd == NULL) {
DEBUG(0,("check_oem_password: no lanman password !\n"));
return False;
}
@@ -587,7 +587,7 @@ BOOL check_oem_password(char *user, unsigned char *data,
/*
* Call the hash function to get the new password.
*/
- SamOEMhash( (unsigned char *)data, (unsigned char *)sampw->smb_passwd, True);
+ SamOEMhash( (unsigned char *)data, (unsigned char *)smbpw->smb_passwd, True);
/*
* The length of the new password is in the last 4 bytes of
@@ -619,7 +619,7 @@ BOOL check_oem_password(char *user, unsigned char *data,
*/
D_P16(new_p16, &data[516], unenc_old_pw);
- if(memcmp(sampw->smb_passwd, unenc_old_pw, 16)) {
+ if(memcmp(smbpw->smb_passwd, unenc_old_pw, 16)) {
DEBUG(0,("check_oem_password: old password doesn't match.\n"));
return False;
}
@@ -636,7 +636,7 @@ BOOL check_oem_password(char *user, unsigned char *data,
override = True, override XXXXXXXXXX'd password
************************************************************/
-BOOL change_oem_password(struct smb_passwd *sampw, char *new_passwd, BOOL override)
+BOOL change_oem_password(struct smb_passwd *smbpw, char *new_passwd, BOOL override)
{
int ret;
fstring upper_case_new_passwd;
@@ -649,14 +649,14 @@ BOOL change_oem_password(struct smb_passwd *sampw, char *new_passwd, BOOL overri
E_P16((uchar *)upper_case_new_passwd, new_p16);
- sampw->smb_passwd = new_p16;
+ smbpw->smb_passwd = new_p16;
E_md4hash((uchar *) new_passwd, new_nt_p16);
- sampw->smb_nt_passwd = new_nt_p16;
+ smbpw->smb_nt_passwd = new_nt_p16;
/* Now write it into the file. */
become_root(0);
- ret = mod_sampwd_entry(sampw,override);
+ ret = mod_smbpwd_entry(smbpw, override);
unbecome_root(0);
memset(upper_case_new_passwd, '\0', strlen(upper_case_new_passwd));
diff --git a/source/smbd/connection.c b/source/smbd/connection.c
deleted file mode 100644
index 5cf8b800f2c..00000000000
--- a/source/smbd/connection.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- connection claim routines
- Copyright (C) Andrew Tridgell 1998
-
- 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"
-
-
-extern connection_struct Connections[MAX_CONNECTIONS];
-extern fstring remote_machine;
-
-extern int DEBUGLEVEL;
-
-/****************************************************************************
-simple routines to do connection counting
-****************************************************************************/
-BOOL yield_connection(int cnum,char *name,int max_connections)
-{
- struct connect_record crec;
- pstring fname;
- int fd;
- int mypid = getpid();
- int i;
-
- DEBUG(3,("Yielding connection to %d %s\n",cnum,name));
-
- if (max_connections <= 0)
- return(True);
-
- bzero(&crec,sizeof(crec));
-
- pstrcpy(fname,lp_lockdir());
- trim_string(fname,"","/");
-
- strcat(fname,"/");
- strcat(fname,name);
- strcat(fname,".LCK");
-
- fd = open(fname,O_RDWR);
- if (fd == -1) {
- DEBUG(2,("Couldn't open lock file %s (%s)\n",fname,strerror(errno)));
- return(False);
- }
-
- if (fcntl_lock(fd,F_SETLKW,0,1,F_WRLCK)==False) {
- DEBUG(0,("ERROR: can't get lock on %s\n", fname));
- return False;
- }
-
- /* find the right spot */
- for (i=0;i<max_connections;i++) {
- if (read(fd, &crec,sizeof(crec)) != sizeof(crec)) {
- DEBUG(2,("Entry not found in lock file %s\n",fname));
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
- close(fd);
- return(False);
- }
- if (crec.pid == mypid && crec.cnum == cnum)
- break;
- }
-
- if (crec.pid != mypid || crec.cnum != cnum) {
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
- close(fd);
- DEBUG(2,("Entry not found in lock file %s\n",fname));
- return(False);
- }
-
- bzero((void *)&crec,sizeof(crec));
-
- /* remove our mark */
- if (lseek(fd,i*sizeof(crec),SEEK_SET) != i*sizeof(crec) ||
- write(fd, &crec,sizeof(crec)) != sizeof(crec)) {
- DEBUG(2,("Couldn't update lock file %s (%s)\n",fname,strerror(errno)));
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
- close(fd);
- return(False);
- }
-
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
-
- DEBUG(3,("Yield successful\n"));
-
- close(fd);
- return(True);
-}
-
-
-/****************************************************************************
-simple routines to do connection counting
-****************************************************************************/
-BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear)
-{
- extern int Client;
- struct connect_record crec;
- pstring fname;
- int fd=-1;
- int i,foundi= -1;
- int total_recs;
-
- if (max_connections <= 0)
- return(True);
-
- DEBUG(5,("trying claim %s %s %d\n",lp_lockdir(),name,max_connections));
-
- pstrcpy(fname,lp_lockdir());
- trim_string(fname,"","/");
-
- if (!directory_exist(fname,NULL))
- mkdir(fname,0755);
-
- strcat(fname,"/");
- strcat(fname,name);
- strcat(fname,".LCK");
-
- if (!file_exist(fname,NULL)) {
- fd = open(fname,O_RDWR|O_CREAT|O_EXCL, 0644);
- }
-
- if (fd == -1) {
- fd = open(fname,O_RDWR);
- }
-
- if (fd == -1) {
- DEBUG(1,("couldn't open lock file %s\n",fname));
- return(False);
- }
-
- if (fcntl_lock(fd,F_SETLKW,0,1,F_WRLCK)==False) {
- DEBUG(0,("ERROR: can't get lock on %s\n", fname));
- return False;
- }
-
- total_recs = file_size(fname) / sizeof(crec);
-
- /* find a free spot */
- for (i=0;i<max_connections;i++) {
- if (i>=total_recs ||
- lseek(fd,i*sizeof(crec),SEEK_SET) != i*sizeof(crec) ||
- read(fd,&crec,sizeof(crec)) != sizeof(crec)) {
- if (foundi < 0) foundi = i;
- break;
- }
-
- if (Clear && crec.pid && !process_exists(crec.pid)) {
- lseek(fd,i*sizeof(crec),SEEK_SET);
- bzero((void *)&crec,sizeof(crec));
- write(fd, &crec,sizeof(crec));
- if (foundi < 0) foundi = i;
- continue;
- }
- if (foundi < 0 && (!crec.pid || !process_exists(crec.pid))) {
- foundi=i;
- if (!Clear) break;
- }
- }
-
- if (foundi < 0) {
- DEBUG(3,("no free locks in %s\n",fname));
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
- close(fd);
- return(False);
- }
-
- /* fill in the crec */
- bzero((void *)&crec,sizeof(crec));
- crec.magic = 0x280267;
- crec.pid = getpid();
- crec.cnum = cnum;
- if (cnum != -1) {
- crec.uid = Connections[cnum].uid;
- crec.gid = Connections[cnum].gid;
- StrnCpy(crec.name,lp_servicename(SNUM(cnum)),sizeof(crec.name)-1);
- }
- crec.start = time(NULL);
-
- StrnCpy(crec.machine,remote_machine,sizeof(crec.machine)-1);
- StrnCpy(crec.addr,client_addr(Client),sizeof(crec.addr)-1);
-
- /* make our mark */
- if (lseek(fd,foundi*sizeof(crec),SEEK_SET) != foundi*sizeof(crec) ||
- write(fd, &crec,sizeof(crec)) != sizeof(crec)) {
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
- close(fd);
- return(False);
- }
-
- if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
- DEBUG(0,("ERROR: can't release lock on %s\n", fname));
- }
-
- close(fd);
- return(True);
-}
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index 8be9c10a13f..cc8f9b9afd9 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -27,7 +27,6 @@
*/
#include "includes.h"
-#include "nterr.h"
#ifdef CHECK_TYPES
#undef CHECK_TYPES
@@ -40,7 +39,7 @@ extern files_struct Files[];
extern connection_struct Connections[];
extern fstring local_machine;
-extern fstring global_myworkgroup;
+extern fstring myworkgroup;
#define NERR_Success 0
#define NERR_badpass 86
@@ -132,128 +131,79 @@ static BOOL prefix_ok(char *str,char *prefix)
return(strncmp(str,prefix,strlen(prefix)) == 0);
}
-/*******************************************************************
- copies parameters and data, as needed, into the smb buffer
-
- *both* the data and params sections should be aligned. this
- is fudged in the rpc pipes by
- at present, only the data section is. this may be a possible
- cause of some of the ipc problems being experienced. lkcl26dec97
-
- ******************************************************************/
-static void copy_trans_params_and_data(char *outbuf, int align,
- struct mem_buf *rparam, struct mem_buf *rdata,
- int param_offset, int data_offset,
- int param_len, int data_len)
-{
- char *copy_into = smb_buf(outbuf);
-
- DEBUG(5,("copy_trans_params_and_data: params[%d..%d] data[%d..%d]\n",
- param_offset, param_offset + param_len,
- data_offset , data_offset + data_len));
-
- if (param_len) mem_buf_copy(copy_into, rparam, param_offset, param_len);
- copy_into += param_len + align;
- if (data_len ) mem_buf_copy(copy_into, rdata , data_offset , data_len);
-}
/****************************************************************************
send a trans reply
****************************************************************************/
-static void send_trans_reply(char *outbuf,
- struct mem_buf *rdata,
- struct mem_buf *rparam,
- uint16 *setup, int lsetup, int max_data_ret)
+static void send_trans_reply(char *outbuf,char *data,char *param,uint16 *setup,
+ int ldata,int lparam,int lsetup)
{
- int i;
- int this_ldata,this_lparam;
- int tot_data=0,tot_param=0;
- int align;
-
- int ldata = rdata ? mem_buf_len(rdata ) : 0;
- int lparam = rparam ? mem_buf_len(rparam) : 0;
-
- BOOL buffer_too_large = max_data_ret ? ldata > max_data_ret : False;
-
- if (buffer_too_large)
- {
- DEBUG(5,("send_trans_reply: buffer %d too large %d\n", ldata, max_data_ret));
- ldata = max_data_ret;
- }
+ int i;
+ int this_ldata,this_lparam;
+ int tot_data=0,tot_param=0;
+ int align;
- this_lparam = MIN(lparam,max_send - (500+lsetup*SIZEOFWORD)); /* hack */
- this_ldata = MIN(ldata,max_send - (500+lsetup*SIZEOFWORD+this_lparam));
+ this_lparam = MIN(lparam,max_send - (500+lsetup*SIZEOFWORD)); /* hack */
+ this_ldata = MIN(ldata,max_send - (500+lsetup*SIZEOFWORD+this_lparam));
#ifdef CONFUSE_NETMONITOR_MSRPC_DECODING
- /* if you don't want Net Monitor to decode your packets, do this!!! */
- align = ((this_lparam+1)%4);
+ /* if you don't want Net Monitor to decode your packets, do this!!! */
+ align = ((this_lparam+1)%4);
#else
- align = (this_lparam%4);
+ align = (this_lparam%4);
#endif
- set_message(outbuf,10+lsetup,align+this_ldata+this_lparam,True);
-
- if (buffer_too_large)
- {
- /* issue a buffer size warning. on a DCE/RPC pipe, expect an SMBreadX... */
- SIVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- SIVAL(outbuf, smb_rcls, 0x80000000 | NT_STATUS_ACCESS_VIOLATION);
- }
-
- copy_trans_params_and_data(outbuf, align,
- rparam , rdata,
- tot_param , tot_data,
- this_lparam, this_ldata);
-
- SSVAL(outbuf,smb_vwv0,lparam);
- SSVAL(outbuf,smb_vwv1,ldata);
- SSVAL(outbuf,smb_vwv3,this_lparam);
- SSVAL(outbuf,smb_vwv4,smb_offset(smb_buf(outbuf),outbuf));
- SSVAL(outbuf,smb_vwv5,0);
- SSVAL(outbuf,smb_vwv6,this_ldata);
- SSVAL(outbuf,smb_vwv7,smb_offset(smb_buf(outbuf)+this_lparam+align,outbuf));
- SSVAL(outbuf,smb_vwv8,0);
- SSVAL(outbuf,smb_vwv9,lsetup);
-
- for (i=0;i<lsetup;i++)
- {
- SSVAL(outbuf,smb_vwv10+i*SIZEOFWORD,setup[i]);
- }
-
- show_msg(outbuf);
- send_smb(Client,outbuf);
-
- tot_data = this_ldata;
- tot_param = this_lparam;
-
- while (tot_data < ldata || tot_param < lparam)
- {
- this_lparam = MIN(lparam-tot_param, max_send - 500); /* hack */
- this_ldata = MIN(ldata -tot_data , max_send - (500+this_lparam));
-
- align = (this_lparam%4);
+ set_message(outbuf,10+lsetup,align+this_ldata+this_lparam,True);
+ if (this_lparam)
+ memcpy(smb_buf(outbuf),param,this_lparam);
+ if (this_ldata)
+ memcpy(smb_buf(outbuf)+this_lparam+align,data,this_ldata);
+
+ SSVAL(outbuf,smb_vwv0,lparam);
+ SSVAL(outbuf,smb_vwv1,ldata);
+ SSVAL(outbuf,smb_vwv3,this_lparam);
+ SSVAL(outbuf,smb_vwv4,smb_offset(smb_buf(outbuf),outbuf));
+ SSVAL(outbuf,smb_vwv5,0);
+ SSVAL(outbuf,smb_vwv6,this_ldata);
+ SSVAL(outbuf,smb_vwv7,smb_offset(smb_buf(outbuf)+this_lparam+align,outbuf));
+ SSVAL(outbuf,smb_vwv8,0);
+ SSVAL(outbuf,smb_vwv9,lsetup);
+ for (i=0;i<lsetup;i++)
+ SSVAL(outbuf,smb_vwv10+i*SIZEOFWORD,setup[i]);
+
+ show_msg(outbuf);
+ send_smb(Client,outbuf);
+
+ tot_data = this_ldata;
+ tot_param = this_lparam;
+
+ while (tot_data < ldata || tot_param < lparam)
+ {
+ this_lparam = MIN(lparam-tot_param,max_send - 500); /* hack */
+ this_ldata = MIN(ldata-tot_data,max_send - (500+this_lparam));
- set_message(outbuf,10,this_ldata+this_lparam+align,False);
+ align = (this_lparam%4);
- copy_trans_params_and_data(outbuf, align,
- rparam , rdata,
- tot_param , tot_data,
- this_lparam, this_ldata);
+ set_message(outbuf,10,this_ldata+this_lparam+align,False);
+ if (this_lparam)
+ memcpy(smb_buf(outbuf),param+tot_param,this_lparam);
+ if (this_ldata)
+ memcpy(smb_buf(outbuf)+this_lparam+align,data+tot_data,this_ldata);
- SSVAL(outbuf,smb_vwv3,this_lparam);
- SSVAL(outbuf,smb_vwv4,smb_offset(smb_buf(outbuf),outbuf));
- SSVAL(outbuf,smb_vwv5,tot_param);
- SSVAL(outbuf,smb_vwv6,this_ldata);
- SSVAL(outbuf,smb_vwv7,smb_offset(smb_buf(outbuf)+this_lparam+align,outbuf));
- SSVAL(outbuf,smb_vwv8,tot_data);
- SSVAL(outbuf,smb_vwv9,0);
+ SSVAL(outbuf,smb_vwv3,this_lparam);
+ SSVAL(outbuf,smb_vwv4,smb_offset(smb_buf(outbuf),outbuf));
+ SSVAL(outbuf,smb_vwv5,tot_param);
+ SSVAL(outbuf,smb_vwv6,this_ldata);
+ SSVAL(outbuf,smb_vwv7,smb_offset(smb_buf(outbuf)+this_lparam+align,outbuf));
+ SSVAL(outbuf,smb_vwv8,tot_data);
+ SSVAL(outbuf,smb_vwv9,0);
- show_msg(outbuf);
- send_smb(Client,outbuf);
+ show_msg(outbuf);
+ send_smb(Client,outbuf);
- tot_data += this_ldata;
- tot_param += this_lparam;
- }
+ tot_data += this_ldata;
+ tot_param += this_lparam;
+ }
}
struct pack_desc {
@@ -1036,7 +986,7 @@ static int get_server_info(uint32 servertype,
if (!next_token(&ptr,s->comment, NULL)) continue;
if (!next_token(&ptr,s->domain , NULL)) {
/* this allows us to cope with an old nmbd */
- strcpy(s->domain,global_myworkgroup);
+ strcpy(s->domain,myworkgroup);
}
if (sscanf(stype,"%X",&s->type) != 1) {
@@ -1232,7 +1182,7 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
if (strcmp(str1, "WrLehDz") == 0) {
StrnCpy(domain, p, sizeof(fstring)-1);
} else {
- StrnCpy(domain, global_myworkgroup, sizeof(fstring)-1);
+ StrnCpy(domain, myworkgroup, sizeof(fstring)-1);
}
if (lp_browse_list())
@@ -1304,39 +1254,6 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
return(True);
}
-/****************************************************************************
- command 0x34 - suspected of being a "Lookup Names" stub api
- ****************************************************************************/
-static BOOL api_RNetGroupGetUsers(int cnum, uint16 vuid, char *param, char *data,
- int mdrcnt, int mprcnt, char **rdata,
- char **rparam, int *rdata_len, int *rparam_len)
-{
- char *str1 = param+2;
- char *str2 = skip_string(str1,1);
- char *p = skip_string(str2,1);
- int uLevel = SVAL(p,0);
- int buf_len = SVAL(p,2);
- int counted=0;
- int missed=0;
-
- DEBUG(5,("RNetGroupGetUsers: %s %s %s %d %d\n",
- str1, str2, p, uLevel, buf_len));
-
- if (!prefix_ok(str1,"zWrLeh")) return False;
-
- *rdata_len = 0;
- *rdata = NULL;
-
- *rparam_len = 8;
- *rparam = REALLOC(*rparam,*rparam_len);
-
- SSVAL(*rparam,0,0x08AC); /* informational warning message */
- SSVAL(*rparam,2,0);
- SSVAL(*rparam,4,counted);
- SSVAL(*rparam,6,counted+missed);
-
- return(True);
-}
/****************************************************************************
get info about a share
@@ -1649,10 +1566,10 @@ static BOOL api_SetUserPassword(int cnum,uint16 vuid, char *param,char *data,
if(SVAL(*rparam,0) != NERR_Success)
{
- struct smb_passwd *sampw = NULL;
+ struct smb_passwd *smbpw = NULL;
- if(check_lanman_password(user,(unsigned char *)pass1,(unsigned char *)pass2, &sampw) &&
- change_lanman_password(sampw,(unsigned char *)pass1,(unsigned char *)pass2))
+ if(check_lanman_password(user,(unsigned char *)pass1,(unsigned char *)pass2, &smbpw) &&
+ change_lanman_password(smbpw,(unsigned char *)pass1,(unsigned char *)pass2))
{
SSVAL(*rparam,0,NERR_Success);
}
@@ -1675,7 +1592,7 @@ static BOOL api_SamOEMChangePassword(int cnum,uint16 vuid, char *param,char *dat
{
fstring user;
fstring new_passwd;
- struct smb_passwd *sampw = NULL;
+ struct smb_passwd *smbpw = NULL;
char *p = param + 2;
*rparam_len = 2;
@@ -1703,7 +1620,7 @@ static BOOL api_SamOEMChangePassword(int cnum,uint16 vuid, char *param,char *dat
fstrcpy(user,p);
p = skip_string(p,1);
- if(check_oem_password( user, (unsigned char *)data, &sampw,
+ if(check_oem_password( user, (unsigned char *)data, &smbpw,
new_passwd, (int)sizeof(new_passwd)) == False) {
return True;
}
@@ -1716,11 +1633,10 @@ static BOOL api_SamOEMChangePassword(int cnum,uint16 vuid, char *param,char *dat
* as the plaintext of the old users password is not
* available. JRA.
*/
-
if(lp_unix_password_sync())
chgpasswd(user,"", new_passwd, True);
-
- if(change_oem_password( sampw, new_passwd, False)) {
+
+ if(change_oem_password( smbpw, new_passwd, False)) {
SSVAL(*rparam,0,NERR_Success);
}
@@ -2040,7 +1956,7 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
pstrcpy(comment,lp_serverstring());
- if ((count=get_server_info(SV_TYPE_ALL,&servers,global_myworkgroup))>0) {
+ if ((count=get_server_info(SV_TYPE_ALL,&servers,myworkgroup))>0) {
for (i=0;i<count;i++)
if (strequal(servers[i].name,local_machine))
{
@@ -2126,7 +2042,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data,
p += 4;
SIVAL(p,0,PTR_DIFF(p2,*rdata)); /* login domain */
- strcpy(p2,global_myworkgroup);
+ strcpy(p2,myworkgroup);
strupper(p2);
p2 = skip_string(p2,1);
p += 4;
@@ -2136,7 +2052,7 @@ static BOOL api_NetWkstaGetInfo(int cnum,uint16 vuid, char *param,char *data,
p += 2;
SIVAL(p,0,PTR_DIFF(p2,*rdata));
- strcpy(p2,global_myworkgroup); /* don't know. login domain?? */
+ strcpy(p2,myworkgroup); /* don't know. login domain?? */
p2 = skip_string(p2,1);
p += 4;
@@ -2387,7 +2303,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
/* EEK! the cifsrap.txt doesn't have this in!!!! */
SIVAL(p,usri11_full_name,PTR_DIFF(p2,p)); /* full name */
- strcpy(p2,((vuser != NULL) ? vuser->real_name : UserName));
+ strcpy(p2,((vuser != NULL) ? vuser->real_name : UserName)); /* simeon */
p2 = skip_string(p2,1);
}
@@ -2579,7 +2495,7 @@ static BOOL api_WWkstaUserLogon(int cnum,uint16 vuid, char *param,char *data,
strupper(mypath);
PACKS(&desc,"z",mypath); /* computer */
}
- PACKS(&desc,"z",global_myworkgroup);/* domain */
+ 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 */
@@ -3071,334 +2987,175 @@ static BOOL api_WPrintPortEnum(int cnum,uint16 vuid, char *param,char *data,
return(True);
}
-struct api_cmd
+
+struct
{
+ char * name;
char * pipe_clnt_name;
+#ifdef NTDOMAIN
char * pipe_srv_name;
- BOOL (*fn) (pipes_struct *, prs_struct *);
-};
-
-static struct api_cmd api_fd_commands[] =
-{
- { "lsarpc", "lsass", api_ntlsa_rpc },
- { "samr", "lsass", api_samr_rpc },
- { "srvsvc", "ntsvcs", api_srvsvc_rpc },
- { "wkssvc", "ntsvcs", api_wkssvc_rpc },
- { "NETLOGON", "lsass", api_netlog_rpc },
- { "winreg", "winreg", api_reg_rpc },
- { NULL, NULL, NULL }
-};
-
-static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd)
-{
- BOOL ntlmssp_auth = False;
- fstring ack_pipe_name;
- int i = 0;
-
- DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__));
-
- for (i = 0; api_fd_commands[i].pipe_clnt_name; i++)
- {
- if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) &&
- api_fd_commands[i].fn != NULL)
- {
- DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n",
- api_fd_commands[i].pipe_clnt_name,
- api_fd_commands[i].pipe_srv_name));
- fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name);
- break;
- }
- }
-
- if (api_fd_commands[i].fn == NULL) return False;
-
- /* decode the bind request */
- smb_io_rpc_hdr_rb("", &p->hdr_rb, pd, 0);
-
- if (pd->offset == 0) return False;
-
- if (p->hdr.auth_len != 0)
- {
- /* decode the authentication verifier */
- smb_io_rpc_auth_ntlmssp_req("", &p->ntlmssp_req, pd, 0);
-
- if (pd->offset == 0) return False;
-
- /* ignore the version number for now */
- ntlmssp_auth = strequal(p->ntlmssp_req.ntlmssp_str, "NTLMSSP");
- }
-
- /* name has to be \PIPE\xxxxx */
- strcpy(ack_pipe_name, "\\PIPE\\");
- strcat(ack_pipe_name, p->pipe_srv_name);
-
- DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__));
-
- prs_init(&(p->rdata), 1024, 4, 0, False);
- prs_init(&(p->rhdr ), 0x10, 4, 0, False);
- prs_init(&(p->rauth), 1024, 4, 0, False);
-
- /***/
- /*** do the bind ack first ***/
- /***/
-
- make_rpc_hdr_ba(&p->hdr_ba,
- p->hdr_rb.bba.max_tsize,
- p->hdr_rb.bba.max_rsize,
- p->hdr_rb.bba.assoc_gid,
- ack_pipe_name,
- 0x1, 0x0, 0x0,
- &(p->hdr_rb.transfer));
-
- smb_io_rpc_hdr_ba("", &p->hdr_ba, &p->rdata, 0);
- mem_realloc_data(p->rdata.data, p->rdata.offset);
-
- /***/
- /*** now the authentication ***/
- /***/
-
- if (ntlmssp_auth)
- {
- uint8 data[16];
- bzero(data, sizeof(data)); /* first 8 bytes are non-zero */
-
- make_rpc_auth_ntlmssp_resp(&p->ntlmssp_resp,
- 0x0a, 0x06, 0,
- "NTLMSSP", 2,
- 0x00000000, 0x0000b2b3, 0x000082b1,
- data);
- smb_io_rpc_auth_ntlmssp_resp("", &p->ntlmssp_resp, &p->rauth, 0);
- mem_realloc_data(p->rauth.data, p->rauth.offset);
- }
-
- /***/
- /*** then do the header, now we know the length ***/
- /***/
-
- make_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST,
- p->hdr.call_id,
- p->rdata.offset + p->rauth.offset,
- p->rauth.offset);
-
- smb_io_rpc_hdr("", &p->hdr, &p->rhdr, 0);
- mem_realloc_data(p->rhdr.data, p->rdata.offset);
-
- /***/
- /*** link rpc header, bind acknowledgment and authentication responses ***/
- /***/
-
- p->rhdr.data->offset.start = 0;
- p->rhdr.data->offset.end = p->rhdr.offset;
- p->rhdr.data->next = p->rdata.data;
-
- if (ntlmssp_auth)
- {
- p->rdata.data->offset.start = p->rhdr.offset;
- p->rdata.data->offset.end = p->rhdr.offset + p->rdata.offset;
- p->rdata.data->next = p->rauth.data;
-
- p->rauth.data->offset.start = p->rhdr.offset + p->rdata.offset;
- p->rauth.data->offset.end = p->rhdr.offset + p->rauth.offset + p->rdata.offset;
- p->rauth.data->next = NULL;
- }
- else
- {
- p->rdata.data->offset.start = p->rhdr.offset;
- p->rdata.data->offset.end = p->rhdr.offset + p->rdata.offset;
- p->rdata.data->next = NULL;
- }
-
- return True;
-}
-
-static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd)
-{
- int i = 0;
-
- for (i = 0; api_fd_commands[i].pipe_clnt_name; i++)
- {
- if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) &&
- api_fd_commands[i].fn != NULL)
- {
- DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name));
- return api_fd_commands[i].fn(p, pd);
- }
- }
- return False;
-}
-
-static BOOL api_dce_rpc_command(char *outbuf,
- pipes_struct *p,
- prs_struct *pd)
-{
- BOOL reply = False;
- if (pd->data == NULL) return False;
-
- /* process the rpc header */
- smb_io_rpc_hdr("", &p->hdr, pd, 0);
-
- if (pd->offset == 0) return False;
-
- switch (p->hdr.pkt_type)
- {
- case RPC_BIND :
- {
- reply = api_pipe_bind_req(p, pd);
- break;
- }
- case RPC_REQUEST:
- {
- reply = api_pipe_request (p, pd);
- break;
- }
- }
-
- if (reply)
- {
- /* now send the reply */
- send_trans_reply(outbuf, p->rhdr.data, NULL, NULL, 0, p->file_offset);
-
- if (mem_buf_len(p->rhdr.data) <= p->file_offset)
- {
- /* all of data was sent: no need to wait for SMBreadX calls */
- mem_free_data(p->rhdr .data);
- mem_free_data(p->rdata.data);
- }
- }
-
- return reply;
-}
-
-/****************************************************************************
- SetNamedPipeHandleState
-****************************************************************************/
-static BOOL api_SNPHS(char *outbuf, pipes_struct *p, char *param)
-{
- uint16 id;
-
- if (!param) return False;
-
- id = param[0] + (param[1] << 8);
- DEBUG(4,("lsarpc SetNamedPipeHandleState to code %x\n", id));
-
- if (set_rpc_pipe_hnd_state(p, id))
- {
- /* now send the reply */
- send_trans_reply(outbuf, NULL, NULL, NULL, 0, p->file_offset);
-
- return True;
- }
- return False;
-}
-
+#endif
+ int subcommand;
+ BOOL (*fn)(int,...);
+} api_fd_commands [] =
+ {
+#ifdef NTDOMAIN
+ { "TransactNmPipe", "lsarpc", "lsass", 0x26, api_ntLsarpcTNP },
+ { "TransactNmPipe", "samr", "lsass", 0x26, api_samrTNP },
+ { "TransactNmPipe", "srvsvc", "lsass", 0x26, api_srvsvcTNP },
+ { "TransactNmPipe", "wkssvc", "ntsvcs", 0x26, api_wkssvcTNP },
+ { "TransactNmPipe", "NETLOGON", "NETLOGON", 0x26, api_netlogrpcTNP },
+ { NULL, NULL, NULL, -1, api_Unsupported }
+#else
+ { "TransactNmPipe" , "lsarpc", 0x26, (BOOL (*)(int,...)) api_LsarpcTNP },
+ { NULL, NULL, -1, (BOOL (*)(int,...)) api_Unsupported }
+#endif
+ };
/****************************************************************************
- when no reply is generated, indicate unsupported.
- ****************************************************************************/
-static BOOL api_no_reply(char *outbuf, int max_rdata_len)
+ handle remote api calls delivered to a named pipe already opened.
+ ****************************************************************************/
+static int api_fd_reply(int cnum,uint16 vuid,char *outbuf,
+ uint16 *setup,char *data,char *params,
+ int suwcnt,int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
{
- struct mem_buf rparam;
+ char *rdata = NULL;
+ char *rparam = NULL;
+ int rdata_len = 0;
+ int rparam_len = 0;
- mem_init(&rparam, 0);
- mem_alloc_data(&rparam, 4);
+ BOOL reply = False;
+ BOOL bind_req = False;
+ BOOL set_nphs = False;
- rparam.offset.start = 0;
- rparam.offset.end = 4;
+ int i;
+ int fd;
+ int subcommand;
+ char *pipe_name;
+
+ DEBUG(5,("api_fd_reply\n"));
+ /* First find out the name of this file. */
+ if (suwcnt != 2)
+ {
+ DEBUG(0,("Unexpected named pipe transaction.\n"));
+ return(-1);
+ }
+
+ /* Get the file handle and hence the file name. */
+ fd = setup[1];
+ subcommand = setup[0];
+ pipe_name = get_rpc_pipe_hnd_name(fd);
- /* unsupported */
- SSVAL(rparam.data,0,NERR_notsupported);
- SSVAL(rparam.data,2,0); /* converter word */
+ if (pipe_name == NULL)
+ {
+ DEBUG(1,("api_fd_reply: INVALID PIPE HANDLE: %x\n", fd));
+ }
- DEBUG(3,("Unsupported API fd command\n"));
+ DEBUG(3,("Got API command %d on pipe %s (fd %x)",
+ subcommand, pipe_name, fd));
+ DEBUG(3,("(tdscnt=%d,tpscnt=%d,mdrcnt=%d,mprcnt=%d,cnum=%d,vuid=%d)\n",
+ tdscnt,tpscnt,mdrcnt,mprcnt,cnum,vuid));
+
+ for (i = 0; api_fd_commands[i].name; i++)
+ {
+ if (strequal(api_fd_commands[i].pipe_clnt_name, pipe_name) &&
+ api_fd_commands[i].subcommand == subcommand &&
+ api_fd_commands[i].fn)
+ {
+ DEBUG(3,("Doing %s\n", api_fd_commands[i].name));
+ break;
+ }
+ }
+
+ rdata = (char *)malloc(1024); if (rdata ) bzero(rdata ,1024);
+ rparam = (char *)malloc(1024); if (rparam) bzero(rparam,1024);
+
+#ifdef NTDOMAIN
+ /* RPC Pipe command 0x26. */
+ if (data != NULL && api_fd_commands[i].subcommand == 0x26)
+ {
+ RPC_HDR hdr;
- /* now send the reply */
- send_trans_reply(outbuf, NULL, &rparam, NULL, 0, max_rdata_len);
+ /* process the rpc header */
+ char *q = smb_io_rpc_hdr(True, &hdr, data, data, 4, 0);
+
+ /* bind request received */
+ if ((bind_req = ((q != NULL) && (hdr.pkt_type == RPC_BIND))))
+ {
+ RPC_HDR_RB hdr_rb;
- mem_free_data(&rparam);
+ /* decode the bind request */
+ char *p = smb_io_rpc_hdr_rb(True, &hdr_rb, q, data, 4, 0);
- return(-1);
-}
+ if ((bind_req = (p != NULL)))
+ {
+ RPC_HDR_BA hdr_ba;
+ fstring ack_pipe_name;
-/****************************************************************************
- handle remote api calls delivered to a named pipe already opened.
- ****************************************************************************/
-static int api_fd_reply(int cnum,uint16 vuid,char *outbuf,
- uint16 *setup,char *data,char *params,
- int suwcnt,int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
-{
- BOOL reply = False;
+ /* name has to be \PIPE\xxxxx */
+ strcpy(ack_pipe_name, "\\PIPE\\");
+ strcat(ack_pipe_name, api_fd_commands[i].pipe_srv_name);
- int pnum;
- int subcommand;
- pipes_struct *p = NULL;
- prs_struct pd;
- struct mem_buf data_buf;
+ /* make a bind acknowledgement */
+ make_rpc_hdr_ba(&hdr_ba,
+ hdr_rb.bba.max_tsize, hdr_rb.bba.max_rsize, hdr_rb.bba.assoc_gid,
+ ack_pipe_name,
+ 0x1, 0x0, 0x0,
+ &(hdr_rb.transfer));
- DEBUG(5,("api_fd_reply\n"));
+ p = smb_io_rpc_hdr_ba(False, &hdr_ba, rdata + 0x10, rdata, 4, 0);
- /* fake up a data buffer from the api_fd_reply data parameters */
- mem_create(&data_buf, data, tdscnt, 0, False);
- data_buf.offset.start = 0;
- data_buf.offset.end = tdscnt;
+ rdata_len = PTR_DIFF(p, rdata);
- /* fake up a parsing structure */
- pd.data = &data_buf;
- pd.align = 4;
- pd.io = True;
- pd.offset = 0;
+ make_rpc_hdr(&hdr, RPC_BINDACK, 0x0, hdr.call_id, rdata_len);
- /* First find out the name of this file. */
- if (suwcnt != 2)
- {
- DEBUG(0,("Unexpected named pipe transaction.\n"));
- return(-1);
- }
+ p = smb_io_rpc_hdr(False, &hdr, rdata, rdata, 4, 0);
+
+ reply = (p != NULL);
+ }
+ }
+ }
+#endif
- /* Get the file handle and hence the file name. */
- pnum = setup[1];
- subcommand = setup[0];
- get_rpc_pipe(pnum, &p);
+ /* Set Named Pipe Handle state */
+ if (subcommand == 0x1)
+ {
+ set_nphs = True;
+ reply = api_LsarpcSNPHS(fd, cnum, params);
+ }
- if (p != NULL)
- {
- DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)",
- subcommand, p->name, pnum));
- DEBUG(3,("(tdscnt=%d,tpscnt=%d,mdrcnt=%d,mprcnt=%d,cnum=%d,vuid=%d)\n",
- tdscnt,tpscnt,mdrcnt,mprcnt,cnum,vuid));
+ if (!bind_req && !set_nphs)
+ {
+ DEBUG(10,("calling api_fd_command\n"));
- /* record maximum data length that can be transmitted in an SMBtrans */
- p->file_offset = mdrcnt;
+ reply = api_fd_commands[i].fn(cnum,vuid,params,data,mdrcnt,mprcnt,
+ &rdata,&rparam,&rdata_len,&rparam_len);
+ DEBUG(10,("called api_fd_command\n"));
+ }
- DEBUG(10,("api_fd_reply: p:%p file_offset: %d\n",
- p, p->file_offset));
+ if (rdata_len > mdrcnt || rparam_len > mprcnt)
+ {
+ reply = api_TooSmall(cnum,vuid,params,data,mdrcnt,mprcnt,
+ &rdata,&rparam,&rdata_len,&rparam_len);
+ }
+
+ /* if we get False back then it's actually unsupported */
+ if (!reply)
+ {
+ api_Unsupported(cnum,vuid,params,data,mdrcnt,mprcnt,
+ &rdata,&rparam,&rdata_len,&rparam_len);
+ }
+
+ /* now send the reply */
+ send_trans_reply(outbuf,rdata,rparam,NULL,rdata_len,rparam_len,0);
+
+ if (rdata ) free(rdata );
+ if (rparam) free(rparam);
+
+ return(-1);
+}
- switch (subcommand)
- {
- case 0x26:
- {
- /* dce/rpc command */
- reply = api_dce_rpc_command(outbuf, p, &pd);
- break;
- }
- case 0x01:
- {
- /* Set Named Pipe Handle state */
- reply = api_SNPHS(outbuf, p, params);
- break;
- }
- }
- }
- else
- {
- DEBUG(1,("api_fd_reply: INVALID PIPE HANDLE: %x\n", pnum));
- }
- if (!reply)
- {
- return api_no_reply(outbuf, mdrcnt);
- }
- return -1;
-}
/****************************************************************************
the buffer was too small
@@ -3455,7 +3212,6 @@ struct
{"RNetShareEnum", 0, api_RNetShareEnum,0},
{"RNetShareGetInfo", 1, api_RNetShareGetInfo,0},
{"RNetServerGetInfo", 13, api_RNetServerGetInfo,0},
- {"RNetGroupGetUsers", 52, api_RNetGroupGetUsers,0},
{"RNetUserGetInfo", 56, api_RNetUserGetInfo,0},
{"NetUserGetGroups", 59, api_NetUserGetGroups,0},
{"NetWkstaGetInfo", 63, api_NetWkstaGetInfo,0},
@@ -3489,8 +3245,6 @@ static int api_reply(int cnum,uint16 vuid,char *outbuf,char *data,char *params,
int tdscnt,int tpscnt,int mdrcnt,int mprcnt)
{
int api_command = SVAL(params,0);
- struct mem_buf rdata_buf;
- struct mem_buf rparam_buf;
char *rdata = NULL;
char *rparam = NULL;
int rdata_len = 0;
@@ -3530,20 +3284,14 @@ static int api_reply(int cnum,uint16 vuid,char *outbuf,char *data,char *params,
&rdata,&rparam,&rdata_len,&rparam_len);
- mem_create(&rdata_buf , rdata , rdata_len , 0, False);
- mem_create(&rparam_buf, rparam, rparam_len, 0, False);
-
- rdata_buf.offset.start = 0;
- rdata_buf.offset.end = rdata_len;
-
- rparam_buf.offset.start = 0;
- rparam_buf.offset.end = rparam_len;
/* now send the reply */
- send_trans_reply(outbuf, &rdata_buf, &rparam_buf, NULL, 0, 0);
+ send_trans_reply(outbuf,rdata,rparam,NULL,rdata_len,rparam_len,0);
- if (rdata ) free(rdata);
- if (rparam) free(rparam);
+ if (rdata)
+ free(rdata);
+ if (rparam)
+ free(rparam);
return(-1);
}
diff --git a/source/smbd/mangle.c b/source/smbd/mangle.c
index eb267faab3a..8aa53bc35ad 100644
--- a/source/smbd/mangle.c
+++ b/source/smbd/mangle.c
@@ -19,159 +19,39 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* -------------------------------------------------------------------------- **
- * Notable problems...
- *
- * March/April 1998 CRH
- * - Many of the functions in this module overwrite string buffers passed to
- * them. This causes a variety of problems and is, generally speaking,
- * dangerous and scarry. See the kludge notes in name_map_mangle()
- * below.
- * - It seems that something is calling name_map_mangle() twice. The
- * first call is probably some sort of test. Names which contain
- * illegal characters are being doubly mangled. I'm not sure, but
- * I'm guessing the problem is in server.c.
- *
- * -------------------------------------------------------------------------- **
- */
-
-/* -------------------------------------------------------------------------- **
- * History...
- *
- * March/April 1998 CRH
- * Updated a bit. Rewrote is_mangled() to be a bit more selective.
- * Rewrote the mangled name cache. Added comments here and there.
- * &c.
- * -------------------------------------------------------------------------- **
- */
-
#include "includes.h"
-#include "ubiqx/ubi_Cache.h"
-
-
-/* -------------------------------------------------------------------------- **
- * External Variables...
- */
-
-extern int DEBUGLEVEL; /* Global debug level. */
-extern int case_default; /* Are conforming 8.3 names all upper or lower? */
-extern BOOL case_mangle; /* If true, all chars in 8.3 should be same case. */
-
-/* -------------------------------------------------------------------------- **
- * Other stuff...
- *
- * magic_char - This is the magic char used for mangling. It's
- * global. There is a call to lp_magicchar() in server.c
- * that is used to override the initial value.
- *
- * basechars - The set of 36 characters used for name mangling. This
- * is static (scope is this file only).
- *
- * base36() - Macro used to select a character from basechars (i.e.,
- * base36(n) will return the nth digit, modulo 36).
- *
- * chartest - array 0..255. The index range is the set of all possible
- * values of a byte. For each byte value, the content is a
- * two nibble pair. See BASECHAR_MASK and ILLEGAL_MASK,
- * below.
- *
- * ct_initialized - False until the chartest array has been initialized via
- * a call to init_chartest().
- *
- * BASECHAR_MASK - Masks the upper nibble of a one-byte value.
- *
- * ILLEGAL_MASK - Masks the lower nibble of a one-byte value.
- *
- * isbasecahr() - Given a character, check the chartest array to see
- * if that character is in the basechars set. This is
- * faster than using strchr().
- *
- * isillegal() - Given a character, check the chartest array to see
- * if that character is in the illegal characters set.
- * This is faster than using strchr().
- *
- * mangled_cache - Cache header used for storing mangled -> original
- * reverse maps.
- *
- * mc_initialized - False until the mangled_cache structure has been
- * initialized via a call to reset_mangled_cache().
- *
- * MANGLED_CACHE_MAX_ENTRIES - Default maximum number of entries for the
- * cache. A value of 0 indicates "infinite".
- *
- * MANGLED_CACHE_MAX_MEMORY - Default maximum amount of memory for the
- * cache. When the cache was kept as an array of 256
- * byte strings, the default cache size was 50 entries.
- * This required a fixed 12.5Kbytes of memory. The
- * mangled stack parameter is no longer used (though
- * this might change). We're now using a fixed 16Kbyte
- * maximum cache size. This will probably be much more
- * than 50 entries.
- */
-
-char magic_char = '~';
-
-static char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-static unsigned char chartest[256] = { 0 };
-static BOOL ct_initialized = False;
+extern int DEBUGLEVEL;
+extern int case_default;
+extern BOOL case_mangle;
-#define base36(V) ((char)(basechars[(V) % 36]))
-#define BASECHAR_MASK 0xf0
-#define ILLEGAL_MASK 0x0f
-#define isbasechar(C) ( (chartest[ ((C) & 0xff) ]) & BASECHAR_MASK )
-#define isillegal(C) ( (chartest[ ((C) & 0xff) ]) & ILLEGAL_MASK )
-
-static ubi_cacheRoot mangled_cache[1] = { { { 0 }, 0, 0, 0, 0, 0, 0} };
-static BOOL mc_initialized = False;
-#define MANGLED_CACHE_MAX_ENTRIES 0
-#define MANGLED_CACHE_MAX_MEMORY 16384
-
-
-/* -------------------------------------------------------------------------- **
- * Functions...
- */
-
-/* ************************************************************************** **
- * Initialize the static character test array.
- *
- * Input: none
- *
- * Output: none
+/****************************************************************************
+ * Provide a checksum on a string
*
- * Notes: This function changes (loads) the contents of the <chartest>
- * array. The scope of <chartest> is this file.
+ * Input: s - the nul-terminated character string for which the checksum
+ * will be calculated.
+ * Output: The checksum value calculated for s.
*
- * ************************************************************************** **
- */
-static void init_chartest( void )
+ ****************************************************************************/
+int str_checksum(char *s)
{
- char *illegalchars = "*\\/?<>|\":";
- unsigned char *s;
-
- bzero( (char *)chartest, 256 );
-
- for( s = (unsigned char *)illegalchars; *s; s++ )
- chartest[*s] = ILLEGAL_MASK;
-
- for( s = (unsigned char *)basechars; *s; s++ )
- chartest[*s] |= BASECHAR_MASK;
+ int res = 0;
+ int c;
+ int i=0;
- ct_initialized = True;
- } /* init_chartest */
+ while( *s )
+ {
+ c = *s;
+ res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
+ s++; i++;
+ }
+ return(res);
+ } /* str_checksum */
-/* ************************************************************************** **
- * Return True if a name is a special msdos reserved name.
- *
- * Input: fname - String containing the name to be tested.
- *
- * Output: True, if the name matches one of the list of reserved names.
- *
- * Notes: This is a static function called by is_8_3(), below.
- *
- * ************************************************************************** **
- */
-static BOOL is_reserved_msdos( char *fname )
+/****************************************************************************
+return True if a name is a special msdos reserved name
+****************************************************************************/
+static BOOL is_reserved_msdos(char *fname)
{
char upperFname[13];
char *p;
@@ -179,186 +59,67 @@ static BOOL is_reserved_msdos( char *fname )
StrnCpy (upperFname, fname, 12);
/* lpt1.txt and con.txt etc are also illegal */
- p = strchr(upperFname,'.');
- if( p )
- *p = '\0';
-
- strupper( upperFname );
- p = upperFname + 1;
- switch( upperFname[0] )
- {
- case 'A':
- if( 0 == strcmp( p, "UX" ) )
- return( True );
- break;
- case 'C':
- if( (0 == strcmp( p, "LOCK$" ))
- || (0 == strcmp( p, "ON" ))
- || (0 == strcmp( p, "OM1" ))
- || (0 == strcmp( p, "OM2" ))
- || (0 == strcmp( p, "OM3" ))
- || (0 == strcmp( p, "OM4" ))
- )
- return( True );
- break;
- case 'L':
- if( (0 == strcmp( p, "PT1" ))
- || (0 == strcmp( p, "PT2" ))
- || (0 == strcmp( p, "PT3" ))
- )
- return( True );
- break;
- case 'N':
- if( 0 == strcmp( p, "UL" ) )
- return( True );
- break;
- case 'P':
- if( 0 == strcmp( p, "RN" ) )
- return( True );
- break;
- }
-
- return( False );
+ p=strchr(upperFname,'.');
+ if (p)
+ *p='\0';
+ strupper (upperFname);
+ if ((strcmp(upperFname,"CLOCK$") == 0) ||
+ (strcmp(upperFname,"CON") == 0) ||
+ (strcmp(upperFname,"AUX") == 0) ||
+ (strcmp(upperFname,"COM1") == 0) ||
+ (strcmp(upperFname,"COM2") == 0) ||
+ (strcmp(upperFname,"COM3") == 0) ||
+ (strcmp(upperFname,"COM4") == 0) ||
+ (strcmp(upperFname,"LPT1") == 0) ||
+ (strcmp(upperFname,"LPT2") == 0) ||
+ (strcmp(upperFname,"LPT3") == 0) ||
+ (strcmp(upperFname,"NUL") == 0) ||
+ (strcmp(upperFname,"PRN") == 0))
+ return (True) ;
+
+ return (False);
} /* is_reserved_msdos */
-/* ************************************************************************** **
- * Determine whether or not a given name contains illegal characters, even
- * long names.
- *
- * Input: name - The name to be tested.
- *
- * Output: True if an illegal character was found in <name>, else False.
- *
- * Notes: This is used to test a name on the host system, long or short,
- * for characters that would be illegal on most client systems,
- * particularly DOS and Windows systems. Unix and AmigaOS, for
- * example, allow a filenames which contain such oddities as
- * quotes ("). If a name is found which does contain an illegal
- * character, it is mangled even if it conforms to the 8.3
- * format.
- *
- * ************************************************************************** **
- */
-static BOOL is_illegal_name( char *name )
- {
- unsigned char *s;
- int skip;
-
- if( !name )
- return( True );
-
- if( !ct_initialized )
- init_chartest();
-
- s = (unsigned char *)name;
- while( *s )
- {
- skip = skip_multibyte_char( *s );
- if( skip != 0 )
- {
- s += skip;
- }
- else
- {
- if( isillegal( *s ) )
- return( True );
- else
- s++;
- }
- }
-
- return( False );
- } /* is_illegal_name */
-
-/* ************************************************************************** **
- * Return True if the name *could be* a mangled name.
- *
- * Input: s - A file name.
- *
- * Output: True if the name matches the pattern described below in the
- * notes, else False.
- *
- * Notes: The input name is *not* tested for 8.3 compliance. This must be
- * done separately. This function returns true if the name contains
- * a magic character followed by excactly two characters from the
- * basechars list (above), which in turn are followed either by the
- * nul (end of string) byte or a dot (extension).
- *
- * ************************************************************************** **
- */
-BOOL is_mangled( char *s )
- {
- char *magic;
-
- if( !ct_initialized )
- init_chartest();
- magic = strchr( s, magic_char );
- while( magic && magic[1] && magic[2] ) /* 3 chars, 1st is magic. */
- {
- if( ('.' == magic[3] || !(magic[3])) /* Ends with '.' or nul? */
- && isbasechar( toupper(magic[1]) ) /* is 2nd char basechar? */
- && isbasechar( toupper(magic[2]) ) ) /* is 3rd char basechar? */
- return( True ); /* If all above, then true, */
- magic = strchr( magic+1, magic_char ); /* else seek next magic. */
- }
- return( False );
- } /* is_mangled */
-/* ************************************************************************** **
- * Return True if the name is a valid DOS name in 8.3 DOS format.
- *
- * Input: fname - File name to be checked.
- * check_case - If True, and if case_mangle is True, then the
- * name will be checked to see if all characters
- * are the correct case. See case_mangle and
- * case_default above.
- *
- * Output: True if the name is a valid DOS name, else FALSE.
- *
- * ************************************************************************** **
- */
-BOOL is_8_3( char *fname, BOOL check_case )
+/****************************************************************************
+return True if a name is in 8.3 dos format
+****************************************************************************/
+BOOL is_8_3(char *fname, BOOL check_case)
{
- int len;
- int l;
- int skip;
- char *p;
+ int len;
char *dot_pos;
- char *slash_pos = strrchr( fname, '/' );
+ char *slash_pos = strrchr(fname,'/');
+ int l;
- /* If there is a directory path, skip it. */
if( slash_pos )
- fname = slash_pos + 1;
- len = strlen( fname );
-
- DEBUG( 5, ( "Checking %s for 8.3\n", fname ) );
-
- /* Can't be 0 chars or longer than 12 chars */
- if( (len == 0) || (len > 12) )
- return( False );
+ fname = slash_pos+1;
+ len = strlen(fname);
- /* Mustn't be an MS-DOS Special file such as lpt1 or even lpt1.txt */
- if( is_reserved_msdos( fname ) )
- return( False );
+ DEBUG(5,("checking %s for 8.3\n",fname));
- /* Check that all characters are the correct case, if asked to do so. */
if( check_case && case_mangle )
{
- switch( case_default )
+ switch (case_default)
{
case CASE_LOWER:
- if( strhasupper( fname ) )
- return(False);
+ if (strhasupper(fname)) return(False);
break;
case CASE_UPPER:
- if( strhaslower( fname ) )
- return(False);
+ if (strhaslower(fname)) return(False);
break;
}
}
- /* Can't contain invalid dos chars */
+ /* can't be longer than 12 chars */
+ if( len == 0 || len > 12 )
+ return(False);
+
+ /* can't be an MS-DOS Special file such as lpt1 or even lpt1.txt */
+ if( is_reserved_msdos(fname) )
+ return(False);
+
+ /* can't contain invalid dos chars */
/* Windows use the ANSI charset.
But filenames are translated in the PC charset.
This Translation may be more or less relaxed depending
@@ -367,301 +128,203 @@ BOOL is_8_3( char *fname, BOOL check_case )
/* %%% A nice improvment to name mangling would be to translate
filename to ANSI charset on the smb server host */
- p = fname;
- dot_pos = NULL;
- while( *p )
+ dot_pos = strchr(fname,'.');
+
+ {
+ char *p = fname;
+ int skip;
+
+ dot_pos = 0;
+ while (*p)
{
- if( (skip = skip_multibyte_char( *p )) != 0 )
- p += skip;
- else
+ if((skip = skip_multibyte_char( *p )) != 0)
+ p += skip;
+ else
{
- if( *p == '.' && !dot_pos )
- dot_pos = (char *)p;
- else
- if( !isdoschar( *p ) )
- return( False );
- p++;
+ if (*p == '.' && !dot_pos)
+ dot_pos = (char *) p;
+ if (!isdoschar(*p))
+ return(False);
+ p++;
}
}
+ }
/* no dot and less than 9 means OK */
- if( !dot_pos )
- return( len <= 8 );
+ if (!dot_pos)
+ return(len <= 8);
- l = PTR_DIFF( dot_pos, fname );
+ l = PTR_DIFF(dot_pos,fname);
/* base must be at least 1 char except special cases . and .. */
if( l == 0 )
- return( 0 == strcmp( fname, "." ) || 0 == strcmp( fname, ".." ) );
+ return(strcmp(fname,".") == 0 || strcmp(fname,"..") == 0);
/* base can't be greater than 8 */
if( l > 8 )
- return( False );
+ return(False);
- /* see smb.conf(5) for a description of the 'strip dot' parameter. */
- if( lp_strip_dot()
- && len - l == 1
- && !strchr( dot_pos + 1, '.' ) )
+ if( lp_strip_dot() &&
+ len - l == 1 &&
+ !strchr(dot_pos+1,'.') )
{
*dot_pos = 0;
- return( True );
+ return(True);
}
/* extension must be between 1 and 3 */
if( (len - l < 2 ) || (len - l > 4) )
- return( False );
+ return(False);
- /* extensions may not have a dot */
- if( strchr( dot_pos+1, '.' ) )
- return( False );
+ /* extension can't have a dot */
+ if( strchr(dot_pos+1,'.') )
+ return(False);
/* must be in 8.3 format */
- return( True );
+ return(True);
} /* is_8_3 */
-/* ************************************************************************** **
- * Provide a checksum on a string
- *
- * Input: s - the nul-terminated character string for which the checksum
- * will be calculated.
- *
- * Output: The checksum value calculated for s.
- *
- * ************************************************************************** **
- */
-int str_checksum( char *s )
- {
- int res = 0;
- int c;
- int i=0;
-
- while( *s )
- {
- c = *s;
- res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
- s++;
- i++;
- }
- return(res);
- } /* str_checksum */
-
-/* ************************************************************************** **
- * Compare two cache keys and return a value indicating their ordinal
- * relationship.
- *
- * Input: ItemPtr - Pointer to a comparison key. In this case, this will
- * be a mangled name string.
- * NodePtr - Pointer to a node in the cache. The node structure
- * will be followed in memory by a mangled name string.
- *
- * Output: A signed integer, as follows:
- * (x < 0) <==> Key1 less than Key2
- * (x == 0) <==> Key1 equals Key2
- * (x > 0) <==> Key1 greater than Key2
- *
- * Notes: This is a ubiqx-style comparison routine. See ubi_BinTree for
- * more info.
- *
- * ************************************************************************** **
+/* -------------------------------------------------------------------------- **
+ * This section creates and maintains a stack of name mangling results.
+ * The original comments read: "keep a stack of name mangling results - just
+ * so file moves and copies have a chance of working" (whatever that means).
+ *
+ * There are three functions to manage the stack:
+ * reset_mangled_stack() -
+ * push_mangled_name() -
+ * check_mangled_stack() -
*/
-static signed int cache_compare( ubi_btItemPtr ItemPtr, ubi_btNodePtr NodePtr )
- {
- char *Key1 = (char *)ItemPtr;
- char *Key2 = (char *)(((ubi_cacheEntryPtr)NodePtr) + 1);
- return( StrCaseCmp( Key1, Key2 ) );
- } /* cache_compare */
+fstring *mangled_stack = NULL;
+int mangled_stack_size = 0;
+int mangled_stack_len = 0;
-/* ************************************************************************** **
- * Free a cache entry.
- *
- * Input: WarrenZevon - Pointer to the entry that is to be returned to
- * Nirvana.
- * Output: none.
- *
- * Notes: This function gets around the possibility that the standard
- * free() function may be implemented as a macro, or other evil
- * subversions (oh, so much fun).
- *
- * ************************************************************************** **
- */
-static void cache_free_entry( ubi_trNodePtr WarrenZevon )
+/****************************************************************************
+ * create the mangled stack CRH
+ ****************************************************************************/
+void reset_mangled_stack( int size )
{
- free( WarrenZevon );
- } /* cache_free_entry */
-
-/* ************************************************************************** **
- * Initializes or clears the mangled cache.
- *
- * Input: none.
- * Output: none.
- *
- * Notes: There is a section below that is commented out. It shows how
- * one might use lp_ calls to set the maximum memory and entry size
- * of the cache. You might also want to remove the constants used
- * in ubi_cacheInit() and replace them with lp_ calls. If so, then
- * the calls to ubi_cacheSetMax*() would be moved into the else
- * clause. Another option would be to pass in the max_entries and
- * max_memory values as parameters. crh 09-Apr-1998.
- *
- * ************************************************************************** **
- */
-void reset_mangled_cache( void )
- {
- if( !mc_initialized )
+ if( mangled_stack )
{
- (void)ubi_cacheInit( mangled_cache,
- cache_compare,
- cache_free_entry,
- MANGLED_CACHE_MAX_ENTRIES,
- MANGLED_CACHE_MAX_MEMORY );
- mc_initialized = True;
+ free(mangled_stack);
+ mangled_stack_size = 0;
+ mangled_stack_len = 0;
}
- else
+
+ if( size > 0 )
{
- (void)ubi_cacheClear( mangled_cache );
+ mangled_stack = (fstring *)malloc( sizeof(fstring) * size );
+ if( mangled_stack )
+ mangled_stack_size = size;
}
+ else
+ mangled_stack = NULL;
+ } /* create_mangled_stack */
- /*
- (void)ubi_cacheSetMaxEntries( mangled_cache, lp_mangled_cache_entries() );
- (void)ubi_cacheSetMaxMemory( mangled_cache, lp_mangled_cache_memory() );
- */
- } /* reset_mangled_cache */
-
-
-/* ************************************************************************** **
- * Add a mangled name into the cache.
- *
- * Notes: If the mangled cache has not been initialized, then the
- * function will simply fail. It could initialize the cache,
- * but that's not the way it was done before I changed the
- * cache mechanism, so I'm sticking with the old method.
- *
- * If the extension of the raw name maps directly to the
- * extension of the mangled name, then we'll store both names
- * *without* extensions. That way, we can provide consistant
- * reverse mangling for all names that match. The test here is
- * a bit more careful than the one done in earlier versions of
- * mangle.c:
- *
- * - the extension must exist on the raw name,
- * - it must be all lower case
- * - it must match the mangled extension (to prove that no
- * mangling occurred).
- *
- * crh 07-Apr-1998
- *
- * ************************************************************************** **
- */
-static void cache_mangled_name( char *mangled_name, char *raw_name )
+/****************************************************************************
+ * push a mangled name onto the stack CRH
+ ****************************************************************************/
+static void push_mangled_name(char *s)
{
- ubi_cacheEntryPtr new_entry;
- char *s1;
- char *s2;
- int mangled_len;
- int raw_len;
- int i;
-
- /* If the cache isn't initialized, give up. */
- if( !mc_initialized )
- return;
+ int i;
+ char *p;
- /* Init the string lengths. */
- mangled_len = strlen( mangled_name );
- raw_len = strlen( raw_name );
+ /* If the stack doesn't exist... Fail. */
+ if( !mangled_stack )
+ return;
- /* See if the extensions are unmangled. If so, store the entry
- * without the extension, thus creating a "group" reverse map.
- */
- s1 = strrchr( mangled_name, '.' );
- if( s1 && (s2 = strrchr( raw_name, '.' )) )
+ /* If name <s> is already on the stack, move it to the top. */
+ for( i=0; i<mangled_stack_len; i++ )
{
- i = 1;
- while( s1[i] && (tolower( s1[1] ) == s2[i]) )
- i++;
- if( !s1[i] && !s2[i] )
+ if( strcmp( s, mangled_stack[i] ) == 0 )
{
- mangled_len -= i;
- raw_len -= i;
+ array_promote( mangled_stack[0],sizeof(fstring), i );
+ return;
}
}
- /* Allocate a new cache entry. If the allcoation fails, just return. */
- i = sizeof( ubi_cacheEntry ) + mangled_len + raw_len + 2;
- new_entry = malloc( i );
- if( !new_entry )
- return;
+ /* If name <s> wasn't already there, add it to the top of the stack. */
+ memmove( mangled_stack[1], mangled_stack[0],
+ sizeof(fstring) * MIN(mangled_stack_len, mangled_stack_size-1) );
+ strcpy( mangled_stack[0], s );
+ mangled_stack_len = MIN( mangled_stack_size, mangled_stack_len+1 );
+
+ /* Hmmm...
+ * Find the last dot '.' in the name,
+ * if there are any upper case characters past the last dot
+ * and there are no more than three characters past the last dot
+ * then terminate the name *at* the last dot.
+ */
+ p = strrchr( mangled_stack[0], '.' );
+ if( p && (!strhasupper(p+1)) && (strlen(p+1) < (size_t)4) )
+ *p = 0;
- /* Fill the new cache entry, and add it to the cache. */
- s1 = (char *)(new_entry + 1);
- s2 = (char *)&(s1[mangled_len + 1]);
- (void)StrnCpy( s1, mangled_name, mangled_len );
- (void)StrnCpy( s2, raw_name, raw_len );
- ubi_cachePut( mangled_cache, i, new_entry, s1 );
- } /* cache_mangled_name */
+ } /* push_mangled_name */
-/* ************************************************************************** **
- * Check for a name on the mangled name stack
- *
- * Input: s - Input *and* output string buffer.
- *
- * Output: True if the name was found in the cache, else False.
- *
- * Notes: If a reverse map is found, the function will overwrite the string
- * space indicated by the input pointer <s>. This is frightening.
- * It should be rewritten to return NULL if the long name was not
- * found, and a pointer to the long name if it was found.
- *
- * ************************************************************************** **
- */
-BOOL check_mangled_cache( char *s )
+/****************************************************************************
+ * check for a name on the mangled name stack CRH
+ ****************************************************************************/
+BOOL check_mangled_stack(char *s)
{
- ubi_cacheEntryPtr FoundPtr;
- char *ext_start = NULL;
- char *found_name;
+ int i;
+ pstring tmpname;
+ char extension[5];
+ char *p = strrchr( s, '.' );
+ BOOL check_extension = False;
- /* If the cache isn't initialized, give up. */
- if( !mc_initialized )
- return( False );
+ extension[0] = 0;
- FoundPtr = ubi_cacheGet( mangled_cache, (ubi_trItemPtr)s );
+ /* If the stack doesn't exist, fail. */
+ if( !mangled_stack )
+ return(False);
+
+ /* If there is a file extension, then we need to play with it, too. */
+ if( p )
+ {
+ check_extension = True;
+ StrnCpy( extension, p, 4 );
+ strlower( extension ); /* XXXXXXX */
+ }
- /* If we didn't find the name *with* the extension, try without. */
- if( !FoundPtr )
+ for( i=0; i<mangled_stack_len; i++ )
{
- ext_start = strrchr( s, '.' );
- if( ext_start )
+ strcpy(tmpname,mangled_stack[i]);
+ mangle_name_83(tmpname);
+ if( strequal(tmpname,s) )
{
- *ext_start = '\0';
- FoundPtr = ubi_cacheGet( mangled_cache, (ubi_trItemPtr)s );
- *ext_start = '.';
+ strcpy(s,mangled_stack[i]);
+ break;
+ }
+ if( check_extension && !strchr(mangled_stack[i],'.') )
+ {
+ pstrcpy(tmpname,mangled_stack[i]);
+ strcat(tmpname,extension);
+ mangle_name_83(tmpname);
+ if( strequal(tmpname,s) )
+ {
+ strcpy(s,mangled_stack[i]);
+ strcat(s,extension);
+ break;
+ }
}
}
- /* Okay, if we haven't found it we're done. */
- if( !FoundPtr )
- return( False );
-
- /* If we *did* find it, we need to copy it into the string buffer. */
- found_name = (char *)(FoundPtr + 1);
- found_name += (strlen( found_name ) + 1);
-
- DEBUG( 3, ("Found %s on mangled stack ", s) );
+ if( i < mangled_stack_len )
+ {
+ DEBUG(3,("Found %s on mangled stack as %s\n",s,mangled_stack[i]));
+ array_promote(mangled_stack[0],sizeof(fstring),i);
+ return(True);
+ }
- (void)strcpy( s, found_name );
- if( ext_start )
- (void)strcat( s, ext_start );
+ return(False);
+ } /* check_mangled_stack */
- DEBUG( 3, ("as %s\n", s) );
- return( True );
- } /* check_mangled_cache */
+/* End of the mangled stack section.
+ * -------------------------------------------------------------------------- **
+ */
-/* ************************************************************************** **
- * Used only in do_fwd_mangled_map(), below.
- * ************************************************************************** **
- */
static char *map_filename( char *s, /* This is null terminated */
char *pattern, /* This isn't. */
int len ) /* This is the length of pattern. */
@@ -673,19 +336,19 @@ static char *map_filename( char *s, /* This is null terminated */
char *match_start; /* Where the matching bit starts. */
pstring pat;
- StrnCpy( pat, pattern, len ); /* Get pattern into a proper string! */
- pstrcpy( matching_bit, "" ); /* Match but no star gets this. */
- pp = pat; /* Initialize the pointers. */
+ StrnCpy(pat, pattern, len); /* Get pattern into a proper string! */
+ pstrcpy(matching_bit,""); /* Match but no star gets this. */
+ pp = pat; /* Initialise the pointers. */
sp = s;
if( (len == 1) && (*pattern == '*') )
{
return NULL; /* Impossible, too ambiguous for */
} /* words! */
- while( (*sp) /* Not the end of the string. */
- && (*pp) /* Not the end of the pattern. */
- && (*sp == *pp) /* The two match. */
- && (*pp != '*') ) /* No wildcard. */
+ while ((*sp) /* Not the end of the string. */
+ && (*pp) /* Not the end of the pattern. */
+ && (*sp == *pp) /* The two match. */
+ && (*pp != '*')) /* No wildcard. */
{
sp++; /* Keep looking. */
pp++;
@@ -694,14 +357,14 @@ static char *map_filename( char *s, /* This is null terminated */
if( !*sp && !*pp ) /* End of pattern. */
return( matching_bit ); /* Simple match. Return empty string. */
- if( *pp == '*' )
+ if (*pp == '*')
{
pp++; /* Always interrested in the chacter */
/* after the '*' */
- if( !*pp ) /* It is at the end of the pattern. */
+ if (!*pp) /* It is at the end of the pattern. */
{
- StrnCpy( matching_bit, s, sp-s );
- return( matching_bit );
+ StrnCpy(matching_bit, s, sp-s);
+ return matching_bit;
}
else
{
@@ -709,11 +372,11 @@ static char *map_filename( char *s, /* This is null terminated */
/* along s than sp so look for that character. */
match_start = sp;
while( (*sp) /* Not the end of s. */
- && (*sp != *pp) ) /* Not the same */
+ && (*sp != *pp)) /* Not the same */
sp++; /* Keep looking. */
- if( !*sp ) /* Got to the end without a match. */
+ if (!*sp) /* Got to the end without a match. */
{
- return( NULL );
+ return NULL;
} /* Still hope for a match. */
else
{
@@ -721,116 +384,144 @@ static char *map_filename( char *s, /* This is null terminated */
StrnCpy(matching_bit, match_start, sp-match_start);
/* Back to needing a stright match again. */
while( (*sp) /* Not the end of the string. */
- && (*pp) /* Not the end of the pattern. */
- && (*sp == *pp) ) /* The two match. */
+ && (*pp) /* Not the end of the pattern. */
+ && (*sp == *pp) ) /* The two match. */
{
sp++; /* Keep looking. */
pp++;
}
- if( !*sp && !*pp ) /* Both at end so it matched */
- return( matching_bit );
+ if (!*sp && !*pp) /* Both at end so it matched */
+ return matching_bit;
else
- return( NULL );
+ return NULL;
}
}
}
- return( NULL ); /* No match. */
+ return NULL; /* No match. */
} /* map_filename */
-/* ************************************************************************** **
- * MangledMap is a series of name pairs in () separated by spaces.
- * If s matches the first of the pair then the name given is the
- * second of the pair. A * means any number of any character and if
- * present in the second of the pair as well as the first the
- * matching part of the first string takes the place of the * in the
- * second.
- *
- * I wanted this so that we could have RCS files which can be used
- * by UNIX and DOS programs. My mapping string is (RCS rcs) which
- * converts the UNIX RCS file subdirectory to lowercase thus
- * preventing mangling.
- *
- * (I think Andrew wrote the above, but I'm not sure. -- CRH)
- *
- * See 'mangled map' in smb.conf(5).
- *
- * ************************************************************************** **
- */
+/* this is the magic char used for mangling */
+char magic_char = '~';
+
+
+/****************************************************************************
+return True if the name could be a mangled name
+****************************************************************************/
+BOOL is_mangled( char *s )
+ {
+ char *m = strchr(s,magic_char);
+
+ if( !m )
+ return(False);
+
+ /* we use two base 36 chars before the extension */
+ if( m[1] == '.' || m[1] == 0 ||
+ m[2] == '.' || m[2] == 0 ||
+ (m[3] != '.' && m[3] != 0) )
+ return( is_mangled(m+1) );
+
+ /* it could be */
+ return(True);
+ } /* is_mangled */
+
+
+
+/****************************************************************************
+return a base 36 character. v must be from 0 to 35.
+****************************************************************************/
+static char base36(unsigned int v)
+ {
+ static char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ return basechars[v % 36];
+ } /* base36 */
+
+
static void do_fwd_mangled_map(char *s, char *MangledMap)
{
+ /* MangledMap is a series of name pairs in () separated by spaces.
+ * If s matches the first of the pair then the name given is the
+ * second of the pair. A * means any number of any character and if
+ * present in the second of the pair as well as the first the
+ * matching part of the first string takes the place of the * in the
+ * second.
+ *
+ * I wanted this so that we could have RCS files which can be used
+ * by UNIX and DOS programs. My mapping string is (RCS rcs) which
+ * converts the UNIX RCS file subdirectory to lowercase thus
+ * preventing mangling.
+ */
char *start=MangledMap; /* Use this to search for mappings. */
char *end; /* Used to find the end of strings. */
char *match_string;
pstring new_string; /* Make up the result here. */
char *np; /* Points into new_string. */
- DEBUG( 5, ("Mangled Mapping '%s' map '%s'\n", s, MangledMap) );
- while( *start )
+ DEBUG(5,("Mangled Mapping '%s' map '%s'\n", s, MangledMap));
+ while (*start)
{
- while( (*start) && (*start != '(') )
+ while ((*start) && (*start != '('))
start++;
- if( !*start )
+ if (!*start)
continue; /* Always check for the end. */
start++; /* Skip the ( */
end = start; /* Search for the ' ' or a ')' */
- DEBUG( 5, ("Start of first in pair '%s'\n", start) );
- while( (*end) && !((*end == ' ') || (*end == ')')) )
+ DEBUG(5,("Start of first in pair '%s'\n", start));
+ while ((*end) && !((*end == ' ') || (*end == ')')))
end++;
- if( !*end )
+ if (!*end)
{
start = end;
continue; /* Always check for the end. */
}
- DEBUG( 5, ("End of first in pair '%s'\n", end) );
- if( (match_string = map_filename( s, start, end-start )) )
+ DEBUG(5,("End of first in pair '%s'\n", end));
+ if ((match_string = map_filename(s, start, end-start)))
{
- DEBUG( 5, ("Found a match\n") );
+ DEBUG(5,("Found a match\n"));
/* Found a match. */
- start = end + 1; /* Point to start of what it is to become. */
- DEBUG( 5, ("Start of second in pair '%s'\n", start) );
+ start = end+1; /* Point to start of what it is to become. */
+ DEBUG(5,("Start of second in pair '%s'\n", start));
end = start;
np = new_string;
- while( (*end) /* Not the end of string. */
- && (*end != ')') /* Not the end of the pattern. */
- && (*end != '*') ) /* Not a wildcard. */
+ while ((*end) /* Not the end of string. */
+ && (*end != ')') /* Not the end of the pattern. */
+ && (*end != '*')) /* Not a wildcard. */
*np++ = *end++;
- if( !*end )
+ if (!*end)
{
start = end;
continue; /* Always check for the end. */
}
- if( *end == '*' )
+ if (*end == '*')
{
- pstrcpy( np, match_string );
- np += strlen( match_string );
+ pstrcpy(np, match_string);
+ np += strlen(match_string);
end++; /* Skip the '*' */
- while( (*end) /* Not the end of string. */
- && (*end != ')') /* Not the end of the pattern. */
- && (*end != '*') ) /* Not a wildcard. */
+ while ((*end) /* Not the end of string. */
+ && (*end != ')') /* Not the end of the pattern. */
+ && (*end != '*')) /* Not a wildcard. */
*np++ = *end++;
}
- if( !*end )
+ if (!*end)
{
start = end;
continue; /* Always check for the end. */
}
*np++ = '\0'; /* NULL terminate it. */
DEBUG(5,("End of second in pair '%s'\n", end));
- pstrcpy( s, new_string ); /* Substitute with the new name. */
- DEBUG( 5, ("s is now '%s'\n", s) );
+ pstrcpy(s, new_string); /* Substitute with the new name. */
+ DEBUG(5,("s is now '%s'\n", s));
}
- start = end; /* Skip a bit which cannot be wanted anymore. */
+ start = end; /* Skip a bit which cannot be wanted */
+ /* anymore. */
start++;
}
} /* do_fwd_mangled_map */
-/* ************************************************************************** **
- * do the actual mangling to 8.3 format
- *
- * ************************************************************************** **
- */
-void mangle_name_83( char *s )
+/****************************************************************************
+do the actual mangling to 8.3 format
+****************************************************************************/
+void mangle_name_83(char *s)
{
int csum = str_checksum(s);
char *p;
@@ -840,59 +531,59 @@ void mangle_name_83( char *s )
int extlen = 0;
int skip;
- extension[0] = 0;
- base[0] = 0;
+ extension[0]=0;
+ base[0]=0;
p = strrchr(s,'.');
if( p && (strlen(p+1) < (size_t)4) )
{
- BOOL all_normal = ( strisnormal(p+1) ); /* XXXXXXXXX */
+ BOOL all_normal = (strisnormal(p+1)); /* XXXXXXXXX */
- if( all_normal && p[1] != 0 )
+ if (all_normal && p[1] != 0)
{
*p = 0;
- csum = str_checksum( s );
- *p = '.';
+ csum = str_checksum(s);
+ *p = '.';
}
}
- strupper( s );
+ strupper(s);
- DEBUG( 5, ("Mangling name %s to ",s) );
+ DEBUG(5,("Mangling name %s to ",s));
if( p )
{
- if( p == s )
- strcpy( extension, "___" );
+ if (p == s)
+ strcpy(extension,"___");
else
{
*p++ = 0;
- while( *p && extlen < 3 )
+ while (*p && extlen < 3)
{
- skip = skip_multibyte_char( *p );
- switch( skip )
+ skip = skip_multibyte_char(*p);
+ if (skip == 2)
{
- case 2:
- if( extlen < 2 )
- {
- extension[extlen++] = p[0];
- extension[extlen++] = p[1];
- }
- else
- {
- extension[extlen++] = base36( (unsigned char)*p );
- }
- p += 2;
- break;
- case 1:
+ if (extlen < 2)
+ {
extension[extlen++] = p[0];
- p++;
- break;
- default:
- if( isdoschar (*p) && *p != '.' )
- extension[extlen++] = p[0];
- p++;
- break;
+ extension[extlen++] = p[1];
+ }
+ else
+ {
+ extension[extlen++] = base36 (((unsigned char) *p) % 36);
+ }
+ p += 2;
+ }
+ else if( skip == 1 )
+ {
+ extension[extlen++] = p[0];
+ p++;
+ }
+ else
+ {
+ if (isdoschar (*p) && *p != '.')
+ extension[extlen++] = p[0];
+ p++;
}
}
extension[extlen] = 0;
@@ -901,111 +592,117 @@ void mangle_name_83( char *s )
p = s;
- while( *p && baselen < 5 )
+ while (*p && baselen < 5)
{
- skip = skip_multibyte_char(*p);
- switch( skip )
- {
- case 2:
- if( baselen < 4 )
+ skip = skip_multibyte_char(*p);
+ if (skip == 2)
+ {
+ if (baselen < 4)
{
base[baselen++] = p[0];
base[baselen++] = p[1];
}
else
{
- base[baselen++] = base36( (unsigned char)*p );
+ base[baselen++] = base36 (((unsigned char) *p) % 36);
}
p += 2;
- break;
- case 1:
+ }
+ else if( skip == 1)
+ {
base[baselen++] = p[0];
p++;
- break;
- default:
- if( isdoschar( *p ) && *p != '.' )
+ }
+ else
+ {
+ if (isdoschar (*p) && *p != '.')
base[baselen++] = p[0];
p++;
- break;
- }
+ }
}
base[baselen] = 0;
csum = csum % (36*36);
- (void)sprintf( s, "%s%c%c%c",
- base, magic_char, base36( csum/36 ), base36( csum ) );
+ sprintf(s,"%s%c%c%c",base,magic_char,base36(csum/36),base36(csum%36));
if( *extension )
{
- (void)strcat( s, "." );
- (void)strcat( s, extension );
+ strcat(s,".");
+ strcat(s,extension);
}
+ DEBUG(5,("%s\n",s));
- DEBUG( 5, ( "%s\n", s ) );
} /* mangle_name_83 */
-/* ************************************************************************** **
- * Convert a filename to DOS format. Return True if successful.
- *
- * Input: OutName - Source *and* destination buffer.
- *
- * NOTE that OutName must point to a memory space that
- * is at least 13 bytes in size!
- *
- * need83 - If False, name mangling will be skipped unless the
- * name contains illegal characters. Mapping will still
- * be done, if appropriate. This is probably used to
- * signal that a client does not require name mangling,
- * thus skipping the name mangling even on shares which
- * have name-mangling turned on.
- * snum - Share number. This identifies the share in which the
- * name exists.
- *
- * Output: Returns False only if the name wanted mangling but the share does
- * not have name mangling turned on.
- *
- * ************************************************************************** **
- */
-BOOL name_map_mangle( char *OutName, BOOL need83, int snum )
+
+
+/*******************************************************************
+ work out if a name is illegal, even for long names
+ ******************************************************************/
+static BOOL illegal_name(char *name)
{
- DEBUG(5,
- ("name_map_mangle( %s, %s, %d )\n", OutName, need83?"TRUE":"FALSE", snum) );
+ static unsigned char illegal[256];
+ static BOOL initialised=False;
+ unsigned char *s;
+ int skip;
+
+ if( !initialised )
+ {
+ char *ill = "*\\/?<>|\":";
+ initialised = True;
+
+ bzero((char *)illegal,256);
+ for( s = (unsigned char *)ill; *s; s++ )
+ illegal[*s] = True;
+ }
+
+ for (s = (unsigned char *)name; *s;)
+ {
+ skip = skip_multibyte_char( *s );
+ if (skip != 0)
+ s += skip;
+ else
+ {
+ if (illegal[*s])
+ return(True);
+ else
+ s++;
+ }
+ }
+
+ return(False);
+ } /* illegal_name */
+
+/****************************************************************************
+convert a filename to DOS format. return True if successful.
+****************************************************************************/
+BOOL name_map_mangle(char *OutName,BOOL need83,int snum)
+ {
#ifdef MANGLE_LONG_FILENAMES
- if( !need83 && is_illegal_name(OutName) )
+ if( !need83 && illegal_name(OutName) )
need83 = True;
#endif
/* apply any name mappings */
{
- char *map = lp_mangled_map( snum );
+ char *map = lp_mangled_map(snum);
- if( map && *map )
- do_fwd_mangled_map( OutName, map );
+ if (map && *map)
+ do_fwd_mangled_map(OutName,map);
}
/* check if it's already in 8.3 format */
- if( need83 && !is_8_3( OutName, True ) )
+ if( need83 && !is_8_3(OutName, True) )
{
- char *tmp; /* kludge -- mangle_name_83() overwrites the source string */
- /* but cache_mangled_name() needs both. crh 09-Apr-1998 */
-
- if( !lp_manglednames( snum ) )
- return( False );
+ if( !lp_manglednames(snum) )
+ return(False);
/* mangle it into 8.3 */
- tmp = strdup( OutName );
- mangle_name_83( OutName );
- if( tmp )
- {
- cache_mangled_name( OutName, tmp );
- free( tmp );
- }
+ push_mangled_name(OutName);
+ mangle_name_83(OutName);
}
-
- DEBUG( 5, ("name_map_mangle() ==> [%s]\n", OutName) );
- return( True );
+
+ return(True);
} /* name_map_mangle */
-
-/* ========================================================================== */
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
deleted file mode 100644
index 73f6786a04d..00000000000
--- a/source/smbd/nttrans.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- SMB NT transaction handling
- Copyright (C) Jeremy Allison 1994-1998
-
- 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"
-
-extern int DEBUGLEVEL;
-extern int Protocol;
-extern connection_struct Connections[];
-extern files_struct Files[];
-extern int Client;
-extern int oplock_sock;
-extern int smb_read_error;
-extern int global_oplock_break;
-
-static char *known_nt_pipes[] = {
- "\\LANMAN",
- "\\srvsvc",
- "\\samr",
- "\\wkssvc",
- "\\NETLOGON",
- "\\ntlsa",
- "\\ntsvcs",
- "\\lsass",
- "\\lsarpc",
- NULL
-};
-
-
-/****************************************************************************
- reply to an unsolicited SMBNTtranss - just ignore it!
-****************************************************************************/
-
-int reply_nttranss(char *inbuf,char *outbuf,int length,int bufsize)
-{
- DEBUG(4,("Ignoring nttranss of length %d\n",length));
- return(-1);
-}
-
-/****************************************************************************
- reply to a SMBNTtrans
-****************************************************************************/
-
-int reply_nttrans(char *inbuf,char *outbuf,int length,int bufsize)
-{
- int outsize = 0;
- int cnum = SVAL(inbuf,smb_tid);
-#if 0
- uint16 max_setup_count = CVAL(inbuf, smb_nt_MaxSetupCount);
- uint32 max_parameter_count = IVAL(inbuf, smb_nt_MaxParameterCount);
- uint32 max_data_count = IVAL(inbuf,smb_nt_MaxDataCount);
-#endif
- uint32 total_parameter_count = IVAL(inbuf, smb_nt_TotalParameterCount);
- uint32 total_data_count = IVAL(inbuf, smb_nt_TotalDataCount);
- uint32 parameter_count = IVAL(inbuf,smb_nt_ParameterCount);
- uint32 parameter_offset = IVAL(inbuf,smb_nt_ParameterOffset);
- uint32 data_count = IVAL(inbuf,smb_nt_DataCount);
- uint32 data_offset = IVAL(inbuf,smb_nt_DataOffset);
- uint16 setup_count = SVAL(inbuf,smb_nt_SetupCount);
- uint16 function_code = SVAL( inbuf, smb_nt_Function);
- char *params = NULL, *data = NULL, *setup = NULL;
- uint32 num_params_sofar, num_data_sofar;
-
- if(global_oplock_break && (function_code == NT_TRANSACT_CREATE)) {
- /*
- * Queue this open message as we are the process of an oplock break.
- */
-
- DEBUG(2,("%s: reply_nttrans: queueing message NT_TRANSACT_CREATE \
-due to being in oplock break state.\n", timestring() ));
-
- push_smb_message( inbuf, length);
- return -1;
- }
-
- outsize = set_message(outbuf,0,0,True);
-
- /*
- * All nttrans messages we handle have smb_wcnt == 19 + setup_count.
- * Ensure this is so as a sanity check.
- */
-
- if(CVAL(inbuf, smb_wcnt) != 19 + setup_count) {
- DEBUG(2,("Invalid smb_wcnt in trans2 call\n"));
- return(ERROR(ERRSRV,ERRerror));
- }
-
- /* Allocate the space for the setup, the maximum needed parameters and data */
-
- if(setup_count > 0)
- setup = (char *)malloc(setup_count);
- if (total_parameter_count > 0)
- params = (char *)malloc(total_parameter_count);
- if (total_data_count > 0)
- data = (char *)malloc(total_data_count);
-
- if ((total_parameter_count && !params) || (total_data_count && !data) ||
- (setup_count && !setup)) {
- DEBUG(0,("reply_nttrans : Out of memory\n"));
- return(ERROR(ERRDOS,ERRnomem));
- }
-
- /* Copy the param and data bytes sent with this request into
- the params buffer */
- num_params_sofar = parameter_count;
- num_data_sofar = data_count;
-
- if (parameter_count > total_parameter_count || data_count > total_data_count)
- exit_server("reply_nttrans: invalid sizes in packet.\n");
-
- if(setup)
- memcpy( setup, &inbuf[smb_nt_SetupStart], setup_count);
- if(params)
- memcpy( params, smb_base(inbuf) + parameter_offset, parameter_count);
- if(data)
- memcpy( data, smb_base(inbuf) + data_offset, data_count);
-
- if(num_data_sofar < total_data_count || num_params_sofar < total_parameter_count) {
- /* We need to send an interim response then receive the rest
- of the parameter/data bytes */
- outsize = set_message(outbuf,0,0,True);
- send_smb(Client,outbuf);
-
- while( num_data_sofar < total_data_count || num_params_sofar < total_parameter_count) {
- BOOL ret;
-
- ret = receive_next_smb(Client,oplock_sock,inbuf,bufsize,
- SMB_SECONDARY_WAIT);
-
- if((ret && (CVAL(inbuf, smb_com) != SMBnttranss)) || !ret) {
- outsize = set_message(outbuf,0,0,True);
- if(ret)
- DEBUG(0,("reply_nttrans: Invalid secondary nttrans packet\n"));
- else
- DEBUG(0,("reply_nttrans: %s in getting secondary nttrans response.\n",
- (smb_read_error == READ_ERROR) ? "error" : "timeout" ));
- if(params)
- free(params);
- if(data)
- free(data);
- if(setup)
- free(setup);
- return(ERROR(ERRSRV,ERRerror));
- }
-
- /* Revise total_params and total_data in case they have changed downwards */
- total_parameter_count = SIVAL(inbuf, smb_nts_TotalParameterCount);
- total_data_count = SIVAL(inbuf, smb_nts_TotalDataCount);
- num_params_sofar += (parameter_count = SIVAL(inbuf,smb_nts_ParameterCount));
- num_data_sofar += ( data_count = SIVAL(inbuf, smb_nts_DataCount));
- if (num_params_sofar > total_parameter_count || num_data_sofar > total_data_count)
- exit_server("reply_nttrans2: data overflow in secondary nttrans packet\n");
-
- memcpy( &params[ SIVAL(inbuf, smb_nts_ParameterDisplacement)],
- smb_base(inbuf) + SVAL(inbuf, smb_nts_ParameterOffset), parameter_count);
- memcpy( &data[SVAL(inbuf, smb_nts_DataDisplacement)],
- smb_base(inbuf)+ SVAL(inbuf, smb_nts_DataOffset), data_count);
- }
- }
-
- if (Protocol >= PROTOCOL_NT1) {
- uint16 flg2 = SVAL(outbuf,smb_flg2);
- SSVAL(outbuf,smb_flg2,flg2 | 0x40); /* IS_LONG_NAME */
- }
-
- /* Now we must call the relevant NT_TRANS function */
- switch(function_code) {
- case NT_TRANSACT_CREATE:
- outsize = call_nt_transact_create(inbuf, outbuf, bufsize, cnum,
- &setup, &params, &data);
- break;
- case NT_TRANSACT_IOCTL:
- outsize = call_nt_transact_ioctl(inbuf, outbuf, bufsize, cnum,
- &setup, &params, &data);
- break;
- case NT_TRANSACT_SET_SECURITY_DESC:
- outsize = call_nt_transact_set_security_desc(inbuf, outbuf, length, bufsize, cnum,
- &setup, &params, &data);
- break;
- case NT_TRANSACT_NOTIFY_CHANGE:
- outsize = call_nt_transact_notify_change(inbuf, outbuf, length, bufsize, cnum,
- &setup, &params, &data);
- break;
- case NT_TRANSACT_RENAME:
- outsize = call_nt_transact_rename(inbuf, outbuf, length, bufsize, cnum,
- &setup, &params, &data);
- break;
- case NT_TRANSACT_QUERY_SECURITY_DESC:
- outsize = call_nt_transact_query_security_desc(inbuf, outbuf, length, bufsize, cnum,
- &setup, &params, &data, total_data);
- break;
- default:
- /* Error in request */
- DEBUG(0,("reply_nttrans: %s Unknown request %d in nttrans call\n",timestring(),
- tran_call));
- if(setup)
- free(setup);
- if(params)
- free(params);
- if(data)
- free(data);
- return (ERROR(ERRSRV,ERRerror));
- }
-
- /* As we do not know how many data packets will need to be
- returned here the various call_nt_transact_xxxx calls
- must send their own. Thus a call_nt_transact_xxxx routine only
- returns a value other than -1 when it wants to send
- an error packet.
- */
-
- if(setup)
- free(setup);
- if(params)
- free(params);
- if(data)
- free(data);
- return outsize; /* If a correct response was needed the call_nt_transact_xxxx
- calls have already sent it. If outsize != -1 then it is
- returning an error packet. */
-}
diff --git a/source/smbd/password.c b/source/smbd/password.c
index 67de0523e81..673cc8aa364 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -31,9 +31,6 @@ extern int Protocol;
/* users from session setup */
static pstring session_users="";
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
/* these are kept here to keep the string_combinations function simple */
static char this_user[100]="";
static char this_salt[100]="";
@@ -48,12 +45,6 @@ Get the next challenge value - no repeats.
********************************************************************/
void generate_next_challenge(char *challenge)
{
-#if 0
- /*
- * Leave this ifdef'd out while we test
- * the new crypto random number generator.
- * JRA.
- */
unsigned char buf[16];
static int counter = 0;
struct timeval tval;
@@ -68,11 +59,7 @@ void generate_next_challenge(char *challenge)
/* mash it up with md4 */
mdfour(buf, (unsigned char *)challenge, 8);
-#else
- unsigned char buf[8];
- generate_random_buffer(buf,8,False);
-#endif
memcpy(saved_challenge, buf, 8);
memcpy(challenge,buf,8);
challenge_sent = True;
@@ -91,7 +78,7 @@ BOOL set_challenge(char *challenge)
/*******************************************************************
get the last challenge sent
********************************************************************/
-BOOL last_challenge(unsigned char *challenge)
+BOOL last_challenge(char *challenge)
{
if (!challenge_sent) return(False);
memcpy(challenge,saved_challenge,8);
@@ -160,92 +147,6 @@ char *validated_username(uint16 vuid)
return(vuser->name);
}
-
-/****************************************************************************
-Setup the groups a user belongs to.
-****************************************************************************/
-int setup_groups(char *user, int uid, int gid, int *p_ngroups,
- int **p_igroups, gid_t **p_groups,
- int **p_attrs)
-{
- if (-1 == initgroups(user,gid))
- {
- if (getuid() == 0)
- {
- DEBUG(0,("Unable to initgroups!\n"));
- if (gid < 0 || gid > 16000 || uid < 0 || uid > 16000)
- DEBUG(0,("This is probably a problem with the account %s\n",user));
- }
- }
- else
- {
- int i,ngroups;
- int *igroups;
- int *attrs;
- gid_t grp = 0;
- ngroups = getgroups(0,&grp);
- if (ngroups <= 0)
- ngroups = 32;
- igroups = (int *)malloc(sizeof(int)*ngroups);
- attrs = (int *)malloc(sizeof(int)*ngroups);
- for (i=0;i<ngroups;i++)
- {
- attrs [i] = 0x7; /* XXXX don't know what NT user attributes are yet! */
- igroups[i] = 0x42424242;
- }
- ngroups = getgroups(ngroups,(gid_t *)igroups);
-
- if (igroups[0] == 0x42424242)
- ngroups = 0;
-
- *p_ngroups = ngroups;
- *p_attrs = attrs;
-
- /* The following bit of code is very strange. It is due to the
- fact that some OSes use int* and some use gid_t* for
- getgroups, and some (like SunOS) use both, one in prototypes,
- and one in man pages and the actual code. Thus we detect it
- dynamically using some very ugly code */
- if (ngroups > 0)
- {
- /* does getgroups return ints or gid_t ?? */
- static BOOL groups_use_ints = True;
-
- if (groups_use_ints &&
- ngroups == 1 &&
- SVAL(igroups,2) == 0x4242)
- groups_use_ints = False;
-
- for (i=0;groups_use_ints && i<ngroups;i++)
- if (igroups[i] == 0x42424242)
- groups_use_ints = False;
-
- if (groups_use_ints)
- {
- *p_igroups = igroups;
- *p_groups = (gid_t *)igroups;
- }
- else
- {
- gid_t *groups = (gid_t *)igroups;
- igroups = (int *)malloc(sizeof(int)*ngroups);
- for (i=0;i<ngroups;i++)
- {
- igroups[i] = groups[i];
- }
- *p_igroups = igroups;
- *p_groups = (gid_t *)groups;
- }
- }
- DEBUG(3,("%s is in %d groups\n",user,ngroups));
- for (i=0;i<ngroups;i++)
- DEBUG(3,("%d ",igroups[i]));
- DEBUG(3,("\n"));
- }
- return 0;
-}
-
-
/****************************************************************************
register a uid/name pair as being valid and that a valid password
has been given. vuid is biased by an offset. This allows us to
@@ -427,26 +328,23 @@ static char *osf1_bigcrypt(char *password,char *salt1)
/****************************************************************************
update the encrypted smbpasswd file from the plaintext username and password
*****************************************************************************/
-BOOL update_smbpassword_file( char *user, fstring password)
+BOOL update_smbpassword_file( struct passwd *pass, fstring password)
{
- struct smb_passwd *sampw;
+ struct smb_passwd smbpw;
BOOL ret;
- become_root(0);
- sampw = getsampwnam(user);
- unbecome_root(0);
+ /* Fake up an smb_passwd. */
+ smbpw.smb_userid = pass->pw_uid;
+ smbpw.smb_name = pass->pw_name;
+ smbpw.smb_passwd = NULL;
+ smbpw.smb_nt_passwd = NULL;
+ smbpw.acct_ctrl = ACB_NORMAL;
- if(sampw == NULL)
- {
- DEBUG(0,("update_smbpassword_file: getsampwnam returned NULL\n"));
- return False;
- }
-
/* Here, the flag is one, because we want to ignore the XXXXXXX'd out password */
- ret = change_oem_password( sampw, password, True);
+ ret = change_oem_password( &smbpw, password, 1);
if (ret == False)
- DEBUG(3,("update_smbpasswd_file: change_oem_password returned False\n"));
-
+ DEBUG(3,("update_smbpasswd_entry: change_oem_password returned False\n"));
+
return ret;
}
@@ -1013,68 +911,6 @@ BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned cha
}
/****************************************************************************
- Do a specific test for an smb password being correct, given a smb_password and
- the lanman and NT responses.
-****************************************************************************/
-
-BOOL smb_password_ok(struct smb_passwd *smb_pass,
- uchar lm_pass[24], uchar nt_pass[24])
-{
- uchar challenge[8];
-
- if (!lm_pass || !smb_pass) return(False);
-
- if(smb_pass->acct_ctrl & ACB_DISABLED)
- {
- DEBUG(3,("smb_password_ok: account for user %s was disabled.\n", smb_pass->smb_name));
- return(False);
- }
-
- if (!last_challenge(challenge))
- {
- DEBUG(1,("smb_password_ok: no challenge done - password failed\n"));
- return False;
- }
-
- DEBUG(4,("smb_password_ok: Checking SMB password for user %s\n", smb_pass->smb_name));
-
- if ((Protocol >= PROTOCOL_NT1) && (smb_pass->smb_nt_passwd != NULL))
- {
- /* We have the NT MD4 hash challenge available - see if we can
- use it (ie. does it exist in the smbpasswd file).
- */
- DEBUG(4,("smb_password_ok: Checking NT MD4 password\n"));
- if (smb_password_check((char *)nt_pass, (uchar *)smb_pass->smb_nt_passwd, challenge))
- {
- DEBUG(4,("smb_password_ok: NT MD4 password check succeeded\n"));
- return(True);
- }
- DEBUG(4,("smb_password_ok: NT MD4 password check failed\n"));
- }
-
- /* Try against the lanman password. smb_pass->smb_passwd == NULL means
- no password, allow access. */
-
- DEBUG(4,("Checking LM MD4 password\n"));
-
- if((smb_pass->smb_passwd == NULL) && (smb_pass->acct_ctrl & ACB_PWNOTREQ))
- {
- DEBUG(4,("smb_password_ok: no password required for user %s\n", smb_pass->smb_name));
- return True;
- }
-
- if((smb_pass->smb_passwd != NULL) && smb_password_check((char *)lm_pass, (uchar *)smb_pass->smb_passwd, challenge))
- {
- DEBUG(4,("smb_password_ok: LM MD4 password check succeeded\n"));
- return(True);
- }
-
- DEBUG(4,("smb_password_ok: LM MD4 password check failed\n"));
-
- return False;
-}
-
-/****************************************************************************
check if a username/password is OK
****************************************************************************/
BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
@@ -1082,9 +918,9 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
pstring pass2;
int level = lp_passwordlevel();
struct passwd *pass;
- uchar challenge[8];
- struct smb_passwd *smb_pass;
+ char challenge[8];
BOOL update_encrypted = lp_update_encrypted();
+ struct smb_passwd *smb_pass;
BOOL challenge_done = False;
if (password) password[pwlen] = 0;
@@ -1131,21 +967,14 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
return(False);
}
- smb_pass = getsampwnam(user);
-
+ /* non-null username indicates search by username not smb userid */
+ smb_pass = get_smbpwd_entry(user, 0);
if (!smb_pass)
{
DEBUG(3,("Couldn't find user %s in smb_passwd file.\n", user));
return(False);
}
- /* Quit if the account was disabled. */
- if(smb_pass->acct_ctrl & ACB_DISABLED)
- {
- DEBUG(3,("password_ok: account for user %s was disabled.\n", user));
- return(False);
- }
-
/* Ensure the uid's match */
if (smb_pass->smb_userid != pass->pw_uid)
{
@@ -1153,13 +982,35 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
return(False);
}
- if(smb_password_ok( smb_pass, (unsigned char *)password,(uchar *)password))
- {
- update_protected_database(user,True);
- return(True);
- }
+ if (Protocol >= PROTOCOL_NT1)
+ {
+ /* We have the NT MD4 hash challenge available - see if we can
+ use it (ie. does it exist in the smbpasswd file).
+ */
+ if (smb_pass->smb_nt_passwd != NULL)
+ {
+ DEBUG(4,("Checking NT MD4 password\n"));
+ if (smb_password_check(password,
+ smb_pass->smb_nt_passwd,
+ (unsigned char *)challenge))
+ {
+ update_protected_database(user,True);
+ return(True);
+ }
+ DEBUG(4,("NT MD4 password check failed\n"));
+ }
+ }
+
+ /* Try against the lanman password */
+
+ if (smb_password_check(password,
+ smb_pass->smb_passwd,
+ (unsigned char *)challenge)) {
+ update_protected_database(user,True);
+ return(True);
+ }
- DEBUG(3,("Error smb_password_check failed\n"));
+ DEBUG(3,("Error smb_password_check failed\n"));
}
DEBUG(4,("Checking password for user %s (l=%d)\n",user,pwlen));
@@ -1265,8 +1116,8 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
if (password_check(password))
{
update_protected_database(user,True);
- if (update_encrypted)
- update_smbpassword_file(user,password);
+ if (pass && update_encrypted)
+ update_smbpassword_file(pass,password);
return(True);
}
@@ -1284,8 +1135,8 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
if (password_check(password))
{
update_protected_database(user,True);
- if (update_encrypted)
- update_smbpassword_file(user,password);
+ if (pass && update_encrypted)
+ update_smbpassword_file(pass,password);
return(True);
}
@@ -1306,8 +1157,8 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd)
if (string_combinations(password,password_check,level))
{
update_protected_database(user,True);
- if (update_encrypted)
- update_smbpassword_file(user,password);
+ if (pass && update_encrypted)
+ update_smbpassword_file(pass,password);
return(True);
}
@@ -1693,35 +1544,35 @@ BOOL check_hosts_equiv(char *user)
fname = lp_hosts_equiv();
/* note: don't allow hosts.equiv on root */
- if (fname && *fname && (pass->pw_uid != 0)) {
- extern int Client;
- if (check_user_equiv(user,client_name(Client),fname))
- return(True);
- }
+ if (fname && *fname && (pass->pw_uid != 0))
+ {
+ if (check_user_equiv(user,client_name(),fname))
+ return(True);
+ }
if (lp_use_rhosts())
{
char *home = get_home_dir(user);
- if (home) {
- extern int Client;
- slprintf(rhostsfile, sizeof(rhostsfile)-1, "%s/.rhosts", home);
- if (check_user_equiv(user,client_name(Client),rhostsfile))
- return(True);
- }
+ if (home)
+ {
+ slprintf(rhostsfile, sizeof(rhostsfile)-1, "%s/.rhosts", home);
+ if (check_user_equiv(user,client_name(),rhostsfile))
+ return(True);
+ }
}
return(False);
}
-static struct cli_state pw_cli;
+static struct cli_state cli;
/****************************************************************************
return the client state structure
****************************************************************************/
struct cli_state *server_client(void)
{
- return &pw_cli;
+ return &cli;
}
/****************************************************************************
@@ -1733,63 +1584,61 @@ struct cli_state *server_cryptkey(void)
struct in_addr dest_ip;
extern fstring local_machine;
char *p;
- BOOL connected_ok = False;
- if (!cli_initialise(&pw_cli))
+ if (!cli_initialise(&cli))
return NULL;
-
- p = lp_passwordserver();
- while(p && next_token( &p, desthost, LIST_SEP)) {
+
+ for (p=strtok(lp_passwordserver(),LIST_SEP); p ; p = strtok(NULL,LIST_SEP)) {
+ fstrcpy(desthost,p);
standard_sub_basic(desthost);
strupper(desthost);
if(!resolve_name( desthost, &dest_ip)) {
- DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",desthost));
- continue;
- }
+ DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",p));
+ continue;
+ }
if (ismyip(dest_ip)) {
- DEBUG(1,("Password server loop - disabling password server %s\n",desthost));
+ DEBUG(1,("Password server loop - disabling password server %s\n",p));
continue;
}
- if (cli_connect(&pw_cli, desthost, &dest_ip)) {
- DEBUG(3,("connected to password server %s\n",desthost));
- connected_ok = True;
+ if (cli_connect(&cli, desthost, &dest_ip)) {
+ DEBUG(3,("connected to password server %s\n",p));
break;
}
}
- if (!connected_ok) {
- DEBUG(0,("password server not available\n"));
- cli_shutdown(&pw_cli);
+ if (!p) {
+ DEBUG(1,("password server not available\n"));
+ cli_shutdown(&cli);
return NULL;
}
- if (!cli_session_request(&pw_cli, desthost, 0x20, local_machine)) {
+ if (!cli_session_request(&cli, desthost, 0x20, local_machine)) {
DEBUG(1,("%s rejected the session\n",desthost));
- cli_shutdown(&pw_cli);
+ cli_shutdown(&cli);
return NULL;
}
DEBUG(3,("got session\n"));
- if (!cli_negprot(&pw_cli)) {
+ if (!cli_negprot(&cli)) {
DEBUG(1,("%s rejected the negprot\n",desthost));
- cli_shutdown(&pw_cli);
+ cli_shutdown(&cli);
return NULL;
}
- if (pw_cli.protocol < PROTOCOL_LANMAN2 ||
- !(pw_cli.sec_mode & 1)) {
+ if (cli.protocol < PROTOCOL_LANMAN2 ||
+ !(cli.sec_mode & 1)) {
DEBUG(1,("%s isn't in user level security mode\n",desthost));
- cli_shutdown(&pw_cli);
+ cli_shutdown(&cli);
return NULL;
}
DEBUG(3,("password server OK\n"));
- return &pw_cli;
+ return &cli;
}
/****************************************************************************
@@ -1802,8 +1651,8 @@ BOOL server_validate(char *user, char *domain,
extern fstring local_machine;
static unsigned char badpass[24];
- if (!pw_cli.initialised) {
- DEBUG(1,("password server %s is not connected\n", pw_cli.desthost));
+ if (!cli.initialised) {
+ DEBUG(1,("password server %s is not connected\n", cli.desthost));
return(False);
}
@@ -1824,17 +1673,17 @@ BOOL server_validate(char *user, char *domain,
* need to detect this as some versions of NT4.x are broken. JRA.
*/
- if (cli_session_setup(&pw_cli, user, (char *)badpass, sizeof(badpass),
+ if (cli_session_setup(&cli, user, (char *)badpass, sizeof(badpass),
(char *)badpass, sizeof(badpass), domain)) {
- if ((SVAL(pw_cli.inbuf,smb_vwv2) & 1) == 0) {
+ if ((SVAL(cli.inbuf,smb_vwv2) & 1) == 0) {
DEBUG(0,("server_validate: password server %s allows users as non-guest \
-with a bad password.\n", pw_cli.desthost));
+with a bad password.\n", cli.desthost));
DEBUG(0,("server_validate: This is broken (and insecure) behaviour. Please do not \
use this machine as the password server.\n"));
- cli_ulogoff(&pw_cli);
+ cli_ulogoff(&cli);
return False;
}
- cli_ulogoff(&pw_cli);
+ cli_ulogoff(&cli);
}
/*
@@ -1842,18 +1691,18 @@ use this machine as the password server.\n"));
* not guest enabled, we can try with the real password.
*/
- if (!cli_session_setup(&pw_cli, user, pass, passlen, ntpass, ntpasslen, domain)) {
- DEBUG(1,("password server %s rejected the password\n", pw_cli.desthost));
+ if (!cli_session_setup(&cli, user, pass, passlen, ntpass, ntpasslen, domain)) {
+ DEBUG(1,("password server %s rejected the password\n", cli.desthost));
return False;
}
/* if logged in as guest then reject */
- if ((SVAL(pw_cli.inbuf,smb_vwv2) & 1) != 0) {
- DEBUG(1,("password server %s gave us guest only\n", pw_cli.desthost));
- cli_ulogoff(&pw_cli);
+ if ((SVAL(cli.inbuf,smb_vwv2) & 1) != 0) {
+ DEBUG(0,("password server %s gave us guest only\n", cli.desthost));
return(False);
}
+
/*
* This patch from Rob Nielsen <ran@adc.com> makes doing
* the NetWksaUserLogon a dynamic, rather than compile-time
@@ -1864,302 +1713,42 @@ use this machine as the password server.\n"));
*/
if (lp_net_wksta_user_logon()) {
- DEBUG(3,("trying NetWkstaUserLogon with password server %s\n", pw_cli.desthost));
-
- if (!cli_send_tconX(&pw_cli, "IPC$", "IPC", "", 1)) {
- DEBUG(0,("password server %s refused IPC$ connect\n", pw_cli.desthost));
- cli_ulogoff(&pw_cli);
+ DEBUG(3,("trying NetWkstaUserLogon with password server %s\n", cli.desthost));
+ if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
+ DEBUG(0,("password server %s refused IPC$ connect\n", cli.desthost));
return False;
}
- if (!cli_NetWkstaUserLogon(&pw_cli,user,local_machine)) {
- DEBUG(0,("password server %s failed NetWkstaUserLogon\n", pw_cli.desthost));
- cli_tdis(&pw_cli);
- cli_ulogoff(&pw_cli);
+ if (!cli_NetWkstaUserLogon(&cli,user,local_machine)) {
+ DEBUG(0,("password server %s failed NetWkstaUserLogon\n", cli.desthost));
+ cli_tdis(&cli);
return False;
}
- if (pw_cli.privilages == 0) {
- DEBUG(0,("password server %s gave guest privilages\n", pw_cli.desthost));
- cli_tdis(&pw_cli);
- cli_ulogoff(&pw_cli);
+ if (cli.privilages == 0) {
+ DEBUG(0,("password server %s gave guest privilages\n", cli.desthost));
+ cli_tdis(&cli);
return False;
}
- if (!strequal(pw_cli.eff_name, user)) {
+ if (!strequal(cli.eff_name, user)) {
DEBUG(0,("password server %s gave different username %s\n",
- pw_cli.desthost,
- pw_cli.eff_name));
- cli_tdis(&pw_cli);
- cli_ulogoff(&pw_cli);
+ cli.desthost,
+ cli.eff_name));
+ cli_tdis(&cli);
return False;
}
- cli_tdis(&pw_cli);
+ cli_tdis(&cli);
}
else {
- DEBUG(3,("skipping NetWkstaUserLogon with password server %s\n", pw_cli.desthost));
+ DEBUG(3,("skipping NetWkstaUserLogon with password server %s\n", cli.desthost));
}
- DEBUG(3,("password server %s accepted the password\n", pw_cli.desthost));
+ DEBUG(3,("password server %s accepted the password\n", cli.desthost));
- cli_ulogoff(&pw_cli);
+ cli_ulogoff(&cli);
return(True);
}
-/***********************************************************************
- Do the same as security=server, but using NT Domain calls and a session
- key from the machine password.
-************************************************************************/
-
-BOOL domain_client_validate( char *user, char *domain,
- char *smb_apasswd, int smb_apasslen,
- char *smb_ntpasswd, int smb_ntpasslen)
-{
- unsigned char local_challenge[8];
- unsigned char local_lm_response[24];
- unsigned char local_nt_reponse[24];
- unsigned char machine_passwd[16];
- time_t lct;
- fstring remote_machine;
- char *p;
- struct in_addr dest_ip;
- NET_ID_INFO_CTR ctr;
- NET_USER_INFO_3 info3;
- struct cli_state cli;
- uint32 smb_uid_low;
- BOOL connected_ok = False;
-
- /*
- * Check that the requested domain is not our own machine name.
- * If it is, we should never check the PDC here, we use our own local
- * password file.
- */
-
- if(strequal( domain, global_myname)) {
- DEBUG(3,("domain_client_validate: Requested domain was for this machine.\n"));
- return False;
- }
-
- /*
- * Next, check that the passwords given were encrypted.
- */
-
- if(smb_apasslen != 24 || smb_ntpasslen != 24) {
-
- /*
- * Not encrypted - do so.
- */
-
- DEBUG(3,("domain_client_validate: User passwords not in encrypted format.\n"));
- generate_random_buffer( local_challenge, 8, False);
- SMBencrypt( (uchar *)smb_apasswd, local_challenge, local_lm_response);
- SMBNTencrypt((uchar *)smb_ntpasswd, local_challenge, local_nt_reponse);
- smb_apasslen = 24;
- smb_ntpasslen = 24;
- smb_apasswd = (char *)local_lm_response;
- smb_ntpasswd = (char *)local_nt_reponse;
- } else {
-
- /*
- * Encrypted - get the challenge we sent for these
- * responses.
- */
-
- if (!last_challenge(local_challenge)) {
- DEBUG(0,("domain_client_validate: no challenge done - password failed\n"));
- return False;
- }
- }
-
- become_root(False);
-
- /*
- * Get the machine account password.
- */
- if(!machine_password_lock( global_myworkgroup, global_myname, False)) {
- DEBUG(0,("domain_client_validate: unable to open the machine account password file for \
-machine %s in domain %s.\n", global_myname, global_myworkgroup ));
- return False;
- }
-
- if(get_machine_account_password( machine_passwd, &lct) == False) {
- DEBUG(0,("domain_client_validate: unable to read the machine account password for \
-machine %s in domain %s.\n", global_myname, global_myworkgroup ));
- machine_password_unlock();
- return False;
- }
-
- machine_password_unlock();
-
- unbecome_root(False);
-
- /*
- * Here we should check the last change time to see if the machine
- * password needs changing..... TODO... JRA.
- */
-
- /*
- * At this point, smb_apasswd points to the lanman response to
- * the challenge in local_challenge, and smb_ntpasswd points to
- * the NT response to the challenge in local_challenge. Ship
- * these over the secure channel to a domain controller and
- * see if they were valid.
- */
-
- memset(&cli, '\0', sizeof(struct cli_state));
- if(cli_initialise(&cli) == False) {
- DEBUG(0,("domain_client_validate: unable to initialize client connection.\n"));
- return False;
- }
-
- /*
- * Treat each name in the 'password server =' line as a potential
- * PDC/BDC. Contact each in turn and try and authenticate.
- */
-
- p = lp_passwordserver();
- while(p && next_token( &p, remote_machine, LIST_SEP)) {
-
- standard_sub_basic(remote_machine);
- strupper(remote_machine);
-
- if(!resolve_name( remote_machine, &dest_ip)) {
- DEBUG(1,("domain_client_validate: Can't resolve address for %s\n", remote_machine));
- continue;
- }
-
- if (ismyip(dest_ip)) {
- DEBUG(1,("domain_client_validate: Password server loop - not using password server %s\n",remote_machine));
- continue;
- }
-
- if (!cli_connect(&cli, remote_machine, &dest_ip)) {
- DEBUG(0,("domain_client_validate: unable to connect to SMB server on \
-machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
- continue;
- }
-
- if (!cli_session_request(&cli, remote_machine, 0x20, global_myname)) {
- DEBUG(0,("domain_client_validate: machine %s rejected the session setup. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
- cli_shutdown(&cli);
- continue;
- }
-
- cli.protocol = PROTOCOL_NT1;
-
- if (!cli_negprot(&cli)) {
- DEBUG(0,("domain_client_validate: machine %s rejected the negotiate protocol. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
- cli_shutdown(&cli);
- continue;
- }
-
- if (cli.protocol != PROTOCOL_NT1) {
- DEBUG(0,("domain_client_validate: machine %s didn't negotiate NT protocol.\n",
- remote_machine));
- cli_shutdown(&cli);
- continue;
- }
-
- /*
- * Do an anonymous session setup.
- */
-
- if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) {
- DEBUG(0,("domain_client_validate: machine %s rejected the session setup. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
- cli_shutdown(&cli);
- continue;
- }
-
- if (!(cli.sec_mode & 1)) {
- DEBUG(1,("domain_client_validate: machine %s isn't in user level security mode\n",
- remote_machine));
- cli_shutdown(&cli);
- continue;
- }
-
- if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
- DEBUG(0,("domain_client_validate: machine %s rejected the tconX on the IPC$ share. \
-Error was : %s.\n", remote_machine, cli_errstr(&cli) ));
- cli_shutdown(&cli);
- continue;
- }
-
- /*
- * We have an anonymous connection to IPC$.
- */
- connected_ok = True;
- break;
- }
-
- if (!connected_ok) {
- DEBUG(0,("domain_client_validate: Domain password server not available.\n"));
- cli_shutdown(&cli);
- return False;
- }
-
- /*
- * Ok - we have an anonymous connection to the IPC$ share.
- * Now start the NT Domain stuff :-).
- */
-
- if(cli_nt_session_open(&cli, PIPE_NETLOGON, False) == False) {
- DEBUG(0,("domain_client_validate: unable to open the domain client session to \
-machine %s. Error was : %s.\n", remote_machine, cli_errstr(&cli)));
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-
- if(cli_nt_setup_creds(&cli, machine_passwd) == False) {
- DEBUG(0,("domain_client_validate: unable to setup the PDC credentials to machine \
-%s. Error was : %s.\n", remote_machine, cli_errstr(&cli)));
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-
- /* We really don't care what LUID we give the user. */
- generate_random_buffer( (unsigned char *)&smb_uid_low, 4, False);
-
- if(cli_nt_login_network(&cli, domain, user, smb_uid_low, (char *)local_challenge,
- smb_apasswd, smb_ntpasswd, &ctr, &info3) == False) {
- DEBUG(0,("domain_client_validate: unable to validate password for user %s in domain \
-%s to Domain controller %s. Error was %s.\n", user, domain, remote_machine, cli_errstr(&cli)));
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-
- /*
- * Here, if we really want it, we have lots of info about the user in info3.
- */
-
-#if 0
- /*
- * We don't actually need to do this - plus it fails currently with
- * NT_STATUS_INVALID_INFO_CLASS - we need to know *exactly* what to
- * send here. JRA.
- */
- if(cli_nt_logoff(&cli, &ctr) == False) {
- DEBUG(0,("domain_client_validate: unable to log off user %s in domain \
-%s to Domain controller %s. Error was %s.\n", user, domain, remote_machine, cli_errstr(&cli)));
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-#endif /* 0 */
-
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return True;
-}
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index fa11060adec..b5f9700f339 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -41,6 +41,7 @@ extern char magic_char;
extern BOOL case_sensitive;
extern pstring sesssetup_user;
extern int Client;
+extern fstring myworkgroup;
#define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES))
#define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && Pipes[pnum].open)
@@ -50,7 +51,17 @@ extern int Client;
a packet to ensure chaining works correctly */
#define GETPNUM(buf,where) (chain_pnum!= -1?chain_pnum:SVAL(buf,where))
-extern struct pipe_id_info pipe_names[];
+char * known_pipes [] =
+{
+ "lsarpc",
+#if NTDOMAIN
+ "NETLOGON",
+ "srvsvc",
+ "wkssvc",
+ "samr",
+#endif
+ NULL
+};
/****************************************************************************
reply to an open and X on a named pipe
@@ -61,8 +72,7 @@ extern struct pipe_id_info pipe_names[];
int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
{
pstring fname;
- uint16 cnum = SVAL(inbuf, smb_tid);
- uint16 vuid = SVAL(inbuf, smb_uid);
+ int cnum = SVAL(inbuf,smb_tid);
int pnum = -1;
int smb_ofun = SVAL(inbuf,smb_vwv8);
int size=0,fmode=0,mtime=0,rmode=0;
@@ -79,23 +89,23 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
DEBUG(4,("Opening pipe %s.\n", fname));
+ /* Strip \PIPE\ off the name. */
+ pstrcpy(fname,smb_buf(inbuf) + PIPELEN);
+
/* See if it is one we want to handle. */
- for( i = 0; pipe_names[i].client_pipe ; i++ )
- if( strcmp(fname,pipe_names[i].client_pipe) == 0 )
+ for( i = 0; known_pipes[i] ; i++ )
+ if( strcmp(fname,known_pipes[i]) == 0 )
break;
- if ( pipe_names[i].client_pipe == NULL )
+ if ( known_pipes[i] == NULL )
return(ERROR(ERRSRV,ERRaccess));
- /* Strip \PIPE\ off the name. */
- pstrcpy(fname,smb_buf(inbuf) + PIPELEN);
-
/* Known pipes arrive with DIR attribs. Remove it so a regular file */
/* can be opened and add it in after the open. */
DEBUG(3,("Known pipe %s opening.\n",fname));
smb_ofun |= 0x10; /* Add Create it not exists flag */
- pnum = open_rpc_pipe_hnd(fname, cnum, vuid);
+ pnum = open_rpc_pipe_hnd(fname, cnum);
if (pnum < 0) return(ERROR(ERRSRV,ERRnofids));
/* Prepare the reply */
@@ -123,65 +133,190 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
/****************************************************************************
- reply to a read and X
-
- This code is basically stolen from reply_read_and_X with some
- wrinkles to handle pipes.
+ reply to a close
****************************************************************************/
-int reply_pipe_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
+int reply_pipe_close(char *inbuf,char *outbuf)
{
- int pnum = get_rpc_pipe_num(inbuf,smb_vwv2);
- uint32 smb_offs = IVAL(inbuf,smb_vwv3);
- int smb_maxcnt = SVAL(inbuf,smb_vwv5);
- int smb_mincnt = SVAL(inbuf,smb_vwv6);
- int cnum;
- int nread = -1;
- char *data;
- BOOL ok = False;
+ int pnum = get_rpc_pipe_num(inbuf,smb_vwv0);
+ int cnum = SVAL(inbuf,smb_tid);
+ int outsize = set_message(outbuf,0,0,True);
- cnum = SVAL(inbuf,smb_tid);
+ DEBUG(5,("reply_pipe_close: pnum:%x cnum:%x\n", pnum, cnum));
-/*
- CHECK_FNUM(fnum,cnum);
- CHECK_READ(fnum);
- CHECK_ERROR(fnum);
-*/
+ if (!close_rpc_pipe_hnd(pnum, cnum)) return(ERROR(ERRDOS,ERRbadfid));
- set_message(outbuf,12,0,True);
- data = smb_buf(outbuf);
+ return(outsize);
+}
- nread = read_pipe(pnum, data, smb_offs, smb_maxcnt);
- ok = True;
-
- if (nread < 0)
- return(UNIXERROR(ERRDOS,ERRnoaccess));
-
- SSVAL(outbuf,smb_vwv5,nread);
- SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
- SSVAL(smb_buf(outbuf),-2,nread);
-
- DEBUG(3,("%s readX pnum=%04x cnum=%d min=%d max=%d nread=%d\n",
- timestring(),pnum,cnum,
- smb_mincnt,smb_maxcnt,nread));
+/****************************************************************************
+ api_LsarpcSNPHS
- set_chain_pnum(pnum);
+ SetNamedPipeHandleState on \PIPE\lsarpc.
+****************************************************************************/
+BOOL api_LsarpcSNPHS(int pnum, int cnum, char *param)
+{
+ uint16 id;
- return chain_reply(inbuf,outbuf,length,bufsize);
+ if (!param) return False;
+
+ id = param[0] + (param[1] << 8);
+ DEBUG(4,("lsarpc SetNamedPipeHandleState to code %x\n",id));
+
+ return set_rpc_pipe_hnd_state(pnum, cnum, id);
}
+
+
/****************************************************************************
- reply to a close
+ api_LsarpcTNP
+
+ TransactNamedPipe on \PIPE\lsarpc.
****************************************************************************/
-int reply_pipe_close(char *inbuf,char *outbuf)
+static void LsarpcTNP1(char *data,char **rdata, int *rdata_len)
{
- int pnum = get_rpc_pipe_num(inbuf,smb_vwv0);
- int cnum = SVAL(inbuf,smb_tid);
- int outsize = set_message(outbuf,0,0,True);
+ uint32 dword1, dword2;
+ char pname[] = "\\PIPE\\lsass";
- DEBUG(5,("reply_pipe_close: pnum:%x cnum:%x\n", pnum, cnum));
+ /* All kinds of mysterious numbers here */
+ *rdata_len = 68;
+ *rdata = REALLOC(*rdata,*rdata_len);
- if (!close_rpc_pipe_hnd(pnum, cnum)) return(ERROR(ERRDOS,ERRbadfid));
+ dword1 = IVAL(data,0xC);
+ dword2 = IVAL(data,0x10);
- return(outsize);
+ SIVAL(*rdata,0,0xc0005);
+ SIVAL(*rdata,4,0x10);
+ SIVAL(*rdata,8,0x44);
+ SIVAL(*rdata,0xC,dword1);
+
+ SIVAL(*rdata,0x10,dword2);
+ SIVAL(*rdata,0x14,0x15);
+ SSVAL(*rdata,0x18,sizeof(pname));
+ strcpy(*rdata + 0x1a,pname);
+ SIVAL(*rdata,0x28,1);
+ memcpy(*rdata + 0x30, data + 0x34, 0x14);
+}
+
+static void LsarpcTNP2(char *data,char **rdata, int *rdata_len)
+{
+ uint32 dword1;
+
+ /* All kinds of mysterious numbers here */
+ *rdata_len = 48;
+ *rdata = REALLOC(*rdata,*rdata_len);
+
+ dword1 = IVAL(data,0xC);
+
+ SIVAL(*rdata,0,0x03020005);
+ SIVAL(*rdata,4,0x10);
+ SIVAL(*rdata,8,0x30);
+ SIVAL(*rdata,0xC,dword1);
+ SIVAL(*rdata,0x10,0x18);
+ SIVAL(*rdata,0x1c,0x44332211);
+ SIVAL(*rdata,0x20,0x88776655);
+ SIVAL(*rdata,0x24,0xCCBBAA99);
+ SIVAL(*rdata,0x28,0x11FFEEDD);
+}
+
+static void LsarpcTNP3(char *data,char **rdata, int *rdata_len)
+{
+ uint32 dword1;
+ uint16 word1;
+ char * workgroup = myworkgroup;
+ int wglen = strlen(workgroup);
+ int i;
+
+ /* All kinds of mysterious numbers here */
+ *rdata_len = 90 + 2 * wglen;
+ *rdata = REALLOC(*rdata,*rdata_len);
+
+ dword1 = IVAL(data,0xC);
+ word1 = SVAL(data,0x2C);
+
+ SIVAL(*rdata,0,0x03020005);
+ SIVAL(*rdata,4,0x10);
+ SIVAL(*rdata,8,0x60);
+ SIVAL(*rdata,0xC,dword1);
+ SIVAL(*rdata,0x10,0x48);
+ SSVAL(*rdata,0x18,0x5988); /* This changes */
+ SSVAL(*rdata,0x1A,0x15);
+ SSVAL(*rdata,0x1C,word1);
+ SSVAL(*rdata,0x20,6);
+ SSVAL(*rdata,0x22,8);
+ SSVAL(*rdata,0x24,0x8E8); /* So does this */
+ SSVAL(*rdata,0x26,0x15);
+ SSVAL(*rdata,0x28,0x4D48); /* And this */
+ SSVAL(*rdata,0x2A,0x15);
+ SIVAL(*rdata,0x2C,4);
+ SIVAL(*rdata,0x34,wglen);
+ for ( i = 0 ; i < wglen ; i++ )
+ (*rdata)[0x38 + i * 2] = workgroup[i];
+
+ /* Now fill in the rest */
+ i = 0x38 + wglen * 2;
+ SSVAL(*rdata,i,0x648);
+ SIVAL(*rdata,i+2,4);
+ SIVAL(*rdata,i+6,0x401);
+ SSVAL(*rdata,i+0xC,0x500);
+ SIVAL(*rdata,i+0xE,0x15);
+ SIVAL(*rdata,i+0x12,0x2372FE1);
+ SIVAL(*rdata,i+0x16,0x7E831BEF);
+ SIVAL(*rdata,i+0x1A,0x4B454B2);
+}
+
+static void LsarpcTNP4(char *data,char **rdata, int *rdata_len)
+{
+ uint32 dword1;
+
+ /* All kinds of mysterious numbers here */
+ *rdata_len = 48;
+ *rdata = REALLOC(*rdata,*rdata_len);
+
+ dword1 = IVAL(data,0xC);
+
+ SIVAL(*rdata,0,0x03020005);
+ SIVAL(*rdata,4,0x10);
+ SIVAL(*rdata,8,0x30);
+ SIVAL(*rdata,0xC,dword1);
+ SIVAL(*rdata,0x10,0x18);
+}
+
+
+BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len)
+{
+ uint32 id,id2;
+
+ id = IVAL(data,0);
+
+ DEBUG(4,("lsarpc TransactNamedPipe id %lx\n",id));
+ switch (id)
+ {
+ case 0xb0005:
+ LsarpcTNP1(data,rdata,rdata_len);
+ break;
+
+ case 0x03000005:
+ id2 = IVAL(data,8);
+ DEBUG(4,("\t- Suboperation %lx\n",id2));
+ switch (id2 & 0xF)
+ {
+ case 8:
+ LsarpcTNP2(data,rdata,rdata_len);
+ break;
+
+ case 0xC:
+ LsarpcTNP4(data,rdata,rdata_len);
+ break;
+
+ case 0xE:
+ LsarpcTNP3(data,rdata,rdata_len);
+ break;
+ }
+ break;
+ }
+ return(True);
}
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index b8270495fd0..cfce2826caf 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -41,7 +41,7 @@ extern BOOL case_sensitive;
extern BOOL case_preserve;
extern BOOL short_case_preserve;
extern pstring sesssetup_user;
-extern fstring global_myworkgroup;
+extern fstring myworkgroup;
extern int Client;
extern int global_oplock_break;
@@ -57,7 +57,7 @@ static void overflow_attack(int len)
{
DEBUG(0,("%s: ERROR: Invalid password length %d\n", timestring(), len));
DEBUG(0,("your machine may be under attack by a user exploiting an old bug\n"));
- DEBUG(0,("Attack was from IP=%s\n", client_addr(Client)));
+ DEBUG(0,("Attack was from IP=%s\n", client_addr()));
exit_server("possible attack");
}
@@ -120,10 +120,6 @@ int reply_special(char *inbuf,char *outbuf)
reload_services(True);
reopen_logs();
- if (lp_status(-1)) {
- claim_connection(-1,"STATUS.",MAXSTATUS,True);
- }
-
break;
case 0x89: /* session keepalive request
@@ -312,7 +308,7 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
}
else
{
- char *fsname = FSTYPE_STRING;
+ char *fsname = "SAMBA";
char *p;
set_message(outbuf,3,3,True);
@@ -358,7 +354,7 @@ int reply_unknown(char *inbuf,char *outbuf)
/****************************************************************************
reply to an ioctl
****************************************************************************/
-int reply_ioctl(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_ioctl(char *inbuf,char *outbuf, int size, int bufsize)
{
DEBUG(3,("ignoring ioctl\n"));
#if 0
@@ -370,75 +366,6 @@ int reply_ioctl(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
#endif
}
-/****************************************************************************
- always return an error: it's just a matter of which one...
- ****************************************************************************/
-static int session_trust_account(char *inbuf, char *outbuf, char *user,
- char *smb_passwd, int smb_passlen,
- char *smb_nt_passwd, int smb_nt_passlen)
-{
- struct smb_passwd *sam_trust_acct = NULL; /* check if trust account exists */
- if (lp_security() == SEC_USER)
- {
- sam_trust_acct = getsampwnam(user);
- }
- else
- {
- DEBUG(0,("session_trust_account: Trust account %s only supported with security = user\n", user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_LOGON_FAILURE));
- }
-
- if (sam_trust_acct == NULL)
- {
- /* lkclXXXX: workstation entry doesn't exist */
- DEBUG(0,("session_trust_account: Trust account %s user doesn't exist\n",user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_NO_SUCH_USER));
- }
- else
- {
- if ((smb_passlen != 24) || (smb_nt_passlen != 24))
- {
- DEBUG(0,("session_trust_account: Trust account %s - password length wrong.\n", user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_LOGON_FAILURE));
- }
-
- if (!smb_password_ok(sam_trust_acct, (unsigned char *)smb_passwd, (unsigned char *)smb_nt_passwd))
- {
- DEBUG(0,("session_trust_account: Trust Account %s - password failed\n", user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_LOGON_FAILURE));
- }
-
- if (IS_BITS_SET_ALL(sam_trust_acct->acct_ctrl, ACB_DOMTRUST))
- {
- DEBUG(0,("session_trust_account: Domain trust account %s denied by server\n",user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT));
- }
-
- if (IS_BITS_SET_ALL(sam_trust_acct->acct_ctrl, ACB_SVRTRUST))
- {
- DEBUG(0,("session_trust_account: Server trust account %s denied by server\n",user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT));
- }
-
- if (IS_BITS_SET_ALL(sam_trust_acct->acct_ctrl, ACB_WSTRUST))
- {
- DEBUG(4,("session_trust_account: Wksta trust account %s denied by server\n", user));
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT));
- }
- }
-
- /* don't know what to do: indicate logon failure */
- SSVAL(outbuf, smb_flg2, FLAGS2_32_BIT_ERROR_CODES);
- return(ERROR(0, 0xc0000000|NT_STATUS_LOGON_FAILURE));
-}
-
/****************************************************************************
reply to a session setup command
@@ -459,6 +386,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
BOOL valid_nt_password = False;
pstring user;
BOOL guest=False;
+ BOOL computer_id=False;
static BOOL done_sesssetup = False;
BOOL doencrypt = SMBENCRYPT();
char *domain = "";
@@ -516,7 +444,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
passlen1 = MIN(passlen1, MAX_PASS_LEN);
passlen2 = MIN(passlen2, MAX_PASS_LEN);
- if(doencrypt || ((lp_security() == SEC_SERVER) || (lp_security() == SEC_DOMAIN))) {
+ if(doencrypt || (lp_security() == SEC_SERVER)) {
/* Save the lanman2 password and the NT md4 password. */
smb_apasslen = passlen1;
memcpy(smb_apasswd,p,smb_apasslen);
@@ -568,13 +496,48 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
/* If name ends in $ then I think it's asking about whether a */
/* computer with that name (minus the $) has access. For now */
/* say yes to everything ending in $. */
- if ((user[strlen(user) - 1] == '$') && (smb_apasslen == 24) && (smb_ntpasslen == 24))
+ if (user[strlen(user) - 1] == '$')
{
- return session_trust_account(inbuf, outbuf, user,
- smb_apasswd, smb_apasslen,
- smb_ntpasswd, smb_ntpasslen);
+#ifdef NTDOMAIN
+ struct smb_passwd *smb_pass; /* To check if machine account exists */
+/*
+ PAXX: Ack. We don't want to do this. The workstation trust account
+ with a $ on the end should exist in the local password database
+ or be mapped to something generic, but not modified. For NT
+ domain support we must reject this used in certain circumstances
+ with a code to indicate to the client that it is an invalid use
+ of a workstation trust account. NTWKS needs this error to join
+ a domain. This may be the source of future bugs if we cannot
+ be sure whether to reject this or not.
+*/
+ /* non-null user name indicates search by username not by smb userid */
+ smb_pass = get_smbpwd_entry(user, 0);
+
+ if (!smb_pass)
+ {
+ /* lkclXXXX: if workstation entry doesn't exist, indicate logon failure */
+ DEBUG(4,("Workstation trust account %s doesn't exist.",user));
+ SSVAL(outbuf, smb_flg2, 0xc003); /* PAXX: Someone please unhack this */
+ CVAL(outbuf, smb_reh) = 1; /* PAXX: Someone please unhack this */
+ return(ERROR(NT_STATUS_LOGON_FAILURE, 0xc000)); /* decimal 109 NT error, 0xc000 */
+ }
+ else
+ {
+ /* PAXX: This is the NO LOGON workstation trust account stuff */
+ /* lkclXXXX: if the workstation *does* exist, indicate failure differently! */
+ DEBUG(4,("No Workstation trust account %s",user));
+ SSVAL(outbuf, smb_flg2, 0xc003); /* PAXX: Someone please unhack this */
+ CVAL(outbuf, smb_reh) = 1; /* PAXX: Someone please unhack this */
+ return(ERROR(NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT, 0xc000)); /* decimal 409 NT error, 0xc000 */
+ }
+
+ computer_id = True;
+#else /* not NTDOMAIN, leave this in. PAXX: Someone get rid of this */
+ user[strlen(user) - 1] = '\0';
+#endif
}
+
/* If no username is sent use the guest account */
if (!*user)
{
@@ -586,7 +549,14 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
strlower(user);
- strcpy(sesssetup_user,user);
+ /*
+ * In share level security, only overwrite sesssetup_use if
+ * it's a non null-session share. Helps keep %U and %G
+ * working.
+ */
+
+ if((lp_security() != SEC_SHARE) || *user)
+ strcpy(sesssetup_user,user);
reload_services(True);
@@ -604,10 +574,6 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
server_validate(user, domain,
smb_apasswd, smb_apasslen,
smb_ntpasswd, smb_ntpasslen)) &&
- !(lp_security() == SEC_DOMAIN &&
- domain_client_validate(user, domain,
- smb_apasswd, smb_apasslen,
- smb_ntpasswd, smb_ntpasslen)) &&
!check_hosts_equiv(user))
{
@@ -624,7 +590,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
}
if (!valid_nt_password && !password_ok(user,smb_apasswd,smb_apasslen,NULL))
{
- if (lp_security() >= SEC_USER) {
+ if (!computer_id && lp_security() >= SEC_USER) {
#if (GUEST_SESSSETUP == 0)
return(ERROR(ERRSRV,ERRbadpw));
#endif
@@ -665,7 +631,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
p = smb_buf(outbuf);
strcpy(p,"Unix"); p = skip_string(p,1);
strcpy(p,"Samba "); strcat(p,VERSION); p = skip_string(p,1);
- strcpy(p,global_myworkgroup); p = skip_string(p,1);
+ strcpy(p,myworkgroup); p = skip_string(p,1);
set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
/* perhaps grab OS version here?? */
}
@@ -684,7 +650,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
uid = pw->pw_uid;
}
- if (guest)
+ if (guest && !computer_id)
SSVAL(outbuf,smb_vwv2,1);
/* register the name and uid as being validated, so further connections
@@ -763,7 +729,7 @@ int reply_chkpth(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a getatr
****************************************************************************/
-int reply_getatr(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_getatr(char *inbuf,char *outbuf, int in_size, int buffsize)
{
pstring fname;
int cnum;
@@ -1643,7 +1609,7 @@ static BOOL can_delete(char *fname,int cnum,int dirtype)
/****************************************************************************
reply to a unlink
****************************************************************************/
-int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_bufsize)
{
int outsize = 0;
pstring name;
@@ -1680,7 +1646,7 @@ int reply_unlink(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
}
if (is_mangled(mask))
- check_mangled_cache( mask );
+ check_mangled_stack(mask);
has_wild = strchr(mask,'*') || strchr(mask,'?');
@@ -1858,7 +1824,7 @@ int reply_readbraw(char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a lockread (core+ protocol)
****************************************************************************/
-int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz)
+int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int cnum,fnum;
int nread = -1;
@@ -1963,10 +1929,6 @@ int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
cnum = SVAL(inbuf,smb_tid);
- /* If it's an IPC, pass off the pipe handler. */
- if (IS_IPC(cnum))
- return reply_pipe_read_and_X(inbuf,outbuf,length,bufsize);
-
CHECK_FNUM(fnum,cnum);
CHECK_READ(fnum);
CHECK_ERROR(fnum);
@@ -2106,7 +2068,7 @@ int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a writeunlock (core+)
****************************************************************************/
-int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writeunlock(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,fnum;
int nwritten = -1;
@@ -2163,7 +2125,7 @@ int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a write
****************************************************************************/
-int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
+int reply_write(char *inbuf,char *outbuf,int dum1,int dum2)
{
int cnum,numtowrite,fnum;
int nwritten = -1;
@@ -2171,6 +2133,9 @@ int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
int startpos;
char *data;
+ dum1 = dum2 = 0;
+
+
cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
@@ -2278,7 +2243,7 @@ int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize)
/****************************************************************************
reply to a lseek
****************************************************************************/
-int reply_lseek(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_lseek(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,fnum;
uint32 startpos;
@@ -2319,7 +2284,7 @@ int reply_lseek(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a flush
****************************************************************************/
-int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_flush(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum, fnum;
int outsize = set_message(outbuf,0,0,True);
@@ -2350,7 +2315,7 @@ int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a exit
****************************************************************************/
-int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_exit(char *inbuf,char *outbuf, int size, int bufsize)
{
int outsize = set_message(outbuf,0,0,True);
DEBUG(3,("%s exit\n",timestring()));
@@ -2362,7 +2327,7 @@ int reply_exit(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a close
****************************************************************************/
-int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_close(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int fnum,cnum;
int outsize = 0;
@@ -2408,7 +2373,7 @@ int reply_close(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a writeclose (Core+ protocol)
****************************************************************************/
-int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writeclose(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,numtowrite,fnum;
int nwritten = -1;
@@ -2438,12 +2403,12 @@ int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
set_filetime(cnum, Files[fnum].name,mtime);
- close_file(fnum,True);
-
DEBUG(3,("%s writeclose fnum=%d cnum=%d num=%d wrote=%d (numopen=%d)\n",
timestring(),fnum,cnum,numtowrite,nwritten,
Connections[cnum].num_files_open));
+ close_file(fnum,True);
+
if (nwritten <= 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -2457,7 +2422,7 @@ int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a lock
****************************************************************************/
-int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_lock(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int fnum,cnum;
int outsize = set_message(outbuf,0,0,True);
@@ -2486,7 +2451,7 @@ int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a unlock
****************************************************************************/
-int reply_unlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_unlock(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int fnum,cnum;
int outsize = set_message(outbuf,0,0,True);
@@ -2515,7 +2480,7 @@ int reply_unlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a tdis
****************************************************************************/
-int reply_tdis(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_tdis(char *inbuf,char *outbuf, int size, int bufsize)
{
int cnum;
int outsize = set_message(outbuf,0,0,True);
@@ -2543,7 +2508,7 @@ int reply_tdis(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a echo
****************************************************************************/
-int reply_echo(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_echo(char *inbuf,char *outbuf, int size, int bufsize)
{
int cnum;
int smb_reverb = SVAL(inbuf,smb_vwv0);
@@ -2593,7 +2558,7 @@ int reply_echo(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a printopen
****************************************************************************/
-int reply_printopen(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printopen(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
pstring fname;
pstring fname2;
@@ -2660,7 +2625,7 @@ int reply_printopen(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a printclose
****************************************************************************/
-int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printclose(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int fnum,cnum;
int outsize = set_message(outbuf,0,0,True);
@@ -2677,7 +2642,7 @@ int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
DEBUG(3,("%s printclose fd=%d fnum=%d cnum=%d\n",timestring(),Files[fnum].fd_ptr->fd,fnum,cnum));
close_file(fnum,True);
-
+
return(outsize);
}
@@ -2685,7 +2650,7 @@ int reply_printclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a printqueue
****************************************************************************/
-int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printqueue(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum;
int outsize = set_message(outbuf,2,3,True);
@@ -2779,7 +2744,7 @@ int reply_printqueue(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a printwrite
****************************************************************************/
-int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_printwrite(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,numtowrite,fnum;
int outsize = set_message(outbuf,0,0,True);
@@ -2811,7 +2776,7 @@ int reply_printwrite(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a mkdir
****************************************************************************/
-int reply_mkdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_mkdir(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
pstring directory;
int cnum;
@@ -2906,7 +2871,7 @@ static BOOL recursive_rmdir(char *directory)
/****************************************************************************
reply to a rmdir
****************************************************************************/
-int reply_rmdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_rmdir(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
pstring directory;
int cnum;
@@ -3098,7 +3063,7 @@ static BOOL can_rename(char *fname,int cnum)
/****************************************************************************
reply to a mv
****************************************************************************/
-int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_mv(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int outsize = 0;
pstring name;
@@ -3147,7 +3112,7 @@ int reply_mv(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
}
if (is_mangled(mask))
- check_mangled_cache( mask );
+ check_mangled_stack(mask);
has_wild = strchr(mask,'*') || strchr(mask,'?');
@@ -3353,7 +3318,7 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
/****************************************************************************
reply to a file copy.
****************************************************************************/
-int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_copy(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int outsize = 0;
pstring name;
@@ -3417,7 +3382,7 @@ int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
}
if (is_mangled(mask))
- check_mangled_cache( mask );
+ check_mangled_stack(mask);
has_wild = strchr(mask,'*') || strchr(mask,'?');
@@ -3487,7 +3452,7 @@ int reply_copy(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a setdir
****************************************************************************/
-int reply_setdir(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_setdir(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,snum;
int outsize = 0;
@@ -3716,7 +3681,7 @@ int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize)
/****************************************************************************
reply to a SMBwritebmpx (write block multiplex primary) request
****************************************************************************/
-int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writebmpx(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,numtowrite,fnum;
int nwritten = -1;
@@ -3809,7 +3774,7 @@ int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a SMBwritebs (write block multiplex secondary) request
****************************************************************************/
-int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_writebs(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,numtowrite,fnum;
int nwritten = -1;
@@ -3890,7 +3855,7 @@ int reply_writebs(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
/****************************************************************************
reply to a SMBsetattrE
****************************************************************************/
-int reply_setattrE(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+int reply_setattrE(char *inbuf,char *outbuf,int dum_size, int dum_buffsize)
{
int cnum,fnum;
struct utimbuf unix_times;
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 7788b142e09..b672de0f899 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -25,8 +25,7 @@
pstring servicesf = CONFIGFILE;
extern pstring debugf;
extern pstring sesssetup_user;
-extern fstring global_myworkgroup;
-extern pstring global_myname;
+extern fstring myworkgroup;
char *InBuffer = NULL;
char *OutBuffer = NULL;
@@ -465,7 +464,7 @@ static BOOL scan_directory(char *path, char *name,int cnum,BOOL docache)
* (JRA).
*/
if (mangled)
- mangled = !check_mangled_cache( name );
+ mangled = !check_mangled_stack(name);
/* open the directory */
if (!(cur_dir = OpenDir(cnum, path, True)))
@@ -660,7 +659,7 @@ BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_pa
/* check on the mangled stack to see if we can recover the
base of the filename */
if (is_mangled(start))
- check_mangled_cache( start );
+ check_mangled_stack(start);
DEBUG(5,("New file %s\n",start));
return(True);
@@ -1836,12 +1835,6 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
flags = O_RDONLY;
break;
}
-
-#if defined(O_SYNC)
- if (share_mode&(1<<14)) {
- flags2 |= O_SYNC;
- }
-#endif /* O_SYNC */
if (flags != O_RDONLY && file_existed &&
(!CAN_WRITE(cnum) || IS_DOS_READONLY(dos_mode(cnum,fname,&sbuf))))
@@ -2347,21 +2340,13 @@ int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int
int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line)
{
int outsize = set_message(outbuf,0,0,True);
- int cmd = CVAL(inbuf,smb_com);
- int flgs2 = SVAL(outbuf,smb_flg2);
-
- if ((flgs2 & FLAGS2_32_BIT_ERROR_CODES) == FLAGS2_32_BIT_ERROR_CODES)
- {
- SIVAL(outbuf,smb_rcls,error_code);
-
- DEBUG(3,("%s 32 bit error packet at line %d cmd=%d (%s) eclass=%08x [%s]\n",
- timestring(), line, cmd, smb_fn_name(cmd), error_code, smb_errstr(outbuf)));
- }
- else
- {
- CVAL(outbuf,smb_rcls) = error_class;
- SSVAL(outbuf,smb_err,error_code);
- DEBUG(3,("%s error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n",
+ int cmd;
+ cmd = CVAL(inbuf,smb_com);
+
+ CVAL(outbuf,smb_rcls) = error_class;
+ SSVAL(outbuf,smb_err,error_code);
+
+ DEBUG(3,("%s error packet at line %d cmd=%d (%s) eclass=%d ecode=%d\n",
timestring(),
line,
(int)CVAL(inbuf,smb_com),
@@ -2369,8 +2354,6 @@ int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int
error_class,
error_code));
- }
-
if (errno != 0)
DEBUG(3,("error string = %s\n",strerror(errno)));
@@ -2657,7 +2640,7 @@ static void process_smb(char *inbuf, char *outbuf)
name" */
static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81};
DEBUG(1,("%s Connection denied from %s\n",
- timestring(),client_addr(Client)));
+ timestring(),client_addr()));
send_smb(Client,(char *)buf);
exit_server("connection denied");
}
@@ -3289,7 +3272,7 @@ BOOL reload_services(BOOL test)
lp_killunused(snum_used);
- ret = lp_load(servicesf,False,False,True);
+ ret = lp_load(servicesf,False);
/* perhaps the config filename is now set */
if (!test)
@@ -3307,7 +3290,7 @@ BOOL reload_services(BOOL test)
}
}
- reset_mangled_cache();
+ reset_mangled_stack( lp_mangledstack() );
/* this forces service parameters to be flushed */
become_service(-1,True);
@@ -3332,6 +3315,89 @@ static int sig_hup(void)
return(0);
}
+/****************************************************************************
+Setup the groups a user belongs to.
+****************************************************************************/
+int setup_groups(char *user, int uid, int gid, int *p_ngroups,
+ int **p_igroups, gid_t **p_groups,
+ int **p_attrs)
+{
+ if (-1 == initgroups(user,gid))
+ {
+ if (getuid() == 0)
+ {
+ DEBUG(0,("Unable to initgroups!\n"));
+ if (gid < 0 || gid > 16000 || uid < 0 || uid > 16000)
+ DEBUG(0,("This is probably a problem with the account %s\n",user));
+ }
+ }
+ else
+ {
+ int i,ngroups;
+ int *igroups;
+ int *attrs;
+ gid_t grp = 0;
+ ngroups = getgroups(0,&grp);
+ if (ngroups <= 0)
+ ngroups = 32;
+ igroups = (int *)malloc(sizeof(int)*ngroups);
+ attrs = (int *)malloc(sizeof(int)*ngroups);
+ for (i=0;i<ngroups;i++)
+ {
+ attrs [i] = 0x7; /* XXXX don't know what NT user attributes are yet! */
+ igroups[i] = 0x42424242;
+ }
+ ngroups = getgroups(ngroups,(gid_t *)igroups);
+
+ if (igroups[0] == 0x42424242)
+ ngroups = 0;
+
+ *p_ngroups = ngroups;
+ *p_attrs = attrs;
+
+ /* The following bit of code is very strange. It is due to the
+ fact that some OSes use int* and some use gid_t* for
+ getgroups, and some (like SunOS) use both, one in prototypes,
+ and one in man pages and the actual code. Thus we detect it
+ dynamically using some very ugly code */
+ if (ngroups > 0)
+ {
+ /* does getgroups return ints or gid_t ?? */
+ static BOOL groups_use_ints = True;
+
+ if (groups_use_ints &&
+ ngroups == 1 &&
+ SVAL(igroups,2) == 0x4242)
+ groups_use_ints = False;
+
+ for (i=0;groups_use_ints && i<ngroups;i++)
+ if (igroups[i] == 0x42424242)
+ groups_use_ints = False;
+
+ if (groups_use_ints)
+ {
+ *p_igroups = igroups;
+ *p_groups = (gid_t *)igroups;
+ }
+ else
+ {
+ gid_t *groups = (gid_t *)igroups;
+ igroups = (int *)malloc(sizeof(int)*ngroups);
+ for (i=0;i<ngroups;i++)
+ {
+ igroups[i] = groups[i];
+ }
+ *p_igroups = igroups;
+ *p_groups = (gid_t *)groups;
+ }
+ }
+ DEBUG(3,("%s is in %d groups\n",user,ngroups));
+ for (i=0;i<ngroups;i++)
+ DEBUG(3,("%d ",igroups[i]));
+ DEBUG(3,("\n"));
+ }
+ return 0;
+}
/****************************************************************************
make a connection to a service
@@ -3344,20 +3410,20 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
connection_struct *pcon;
BOOL guest = False;
BOOL force = False;
+ static BOOL first_connection = True;
strlower(service);
snum = find_service(service);
if (snum < 0)
{
- extern int Client;
if (strequal(service,"IPC$"))
{
DEBUG(3,("%s refusing IPC connection\n",timestring()));
return(-3);
}
- DEBUG(0,("%s %s (%s) couldn't find service %s\n",timestring(),remote_machine,client_addr(Client),service));
+ DEBUG(0,("%s %s (%s) couldn't find service %s\n",timestring(),remote_machine,client_addr(),service));
return(-2);
}
@@ -3564,7 +3630,9 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
}
if (lp_status(SNUM(cnum)))
- claim_connection(cnum,"STATUS.",MAXSTATUS,False);
+ claim_connection(cnum,"STATUS.",MAXSTATUS,first_connection);
+
+ first_connection = False;
} /* IS_IPC */
pcon->open = True;
@@ -3644,11 +3712,10 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
}
{
- extern int Client;
DEBUG(IS_IPC(cnum)?3:1,("%s %s (%s) connect to service %s as user %s (uid=%d,gid=%d) (pid %d)\n",
timestring(),
remote_machine,
- client_addr(Client),
+ client_addr(),
lp_servicename(SNUM(cnum)),user,
pcon->uid,
pcon->gid,
@@ -3917,7 +3984,7 @@ reply for the nt protocol
int reply_nt1(char *outbuf)
{
/* dual names + lock_and_read + nt SMBs + remote API calls */
- int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ|CAP_RPC_REMOTE_APIS;
+ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ;
/*
other valid capabilities which we may support at some time...
CAP_LARGE_FILES|CAP_NT_SMBS|CAP_RPC_REMOTE_APIS;
@@ -3961,10 +4028,10 @@ int reply_nt1(char *outbuf)
/* decide where (if) to put the encryption challenge, and
follow it with the OEM'd domain name
*/
- data_len = crypt_len + strlen(global_myworkgroup) + 1;
+ data_len = crypt_len + strlen(myworkgroup) + 1;
set_message(outbuf,17,data_len,True);
- strcpy(smb_buf(outbuf)+crypt_len, global_myworkgroup);
+ strcpy(smb_buf(outbuf)+crypt_len, myworkgroup);
CVAL(outbuf,smb_vwv1) = secword;
SSVALS(outbuf,smb_vwv16+1,crypt_len);
@@ -3976,7 +4043,7 @@ int reply_nt1(char *outbuf)
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! */
- SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
+ SIVAL(outbuf,smb_vwv5+1,0xffff); /* raw size. LOTS! */
SIVAL(outbuf,smb_vwv7+1,getpid()); /* session key */
SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
put_long_date(outbuf+smb_vwv11+1,t);
@@ -4068,7 +4135,7 @@ struct {
/****************************************************************************
reply to a negprot
****************************************************************************/
-static int reply_negprot(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+static int reply_negprot(char *inbuf,char *outbuf, int size, int bufsize)
{
int outsize = set_message(outbuf,1,0,True);
int Index=0;
@@ -4133,7 +4200,7 @@ static int reply_negprot(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz
/* a special case to stop password server loops */
if (Index == 1 && strequal(remote_machine,myhostname) &&
- (lp_security()==SEC_SERVER || lp_security()==SEC_DOMAIN))
+ lp_security()==SEC_SERVER)
exit_server("Password server loop!");
/* Check for protocols, most desirable first */
@@ -4191,7 +4258,6 @@ close a cnum
****************************************************************************/
void close_cnum(int cnum, uint16 vuid)
{
- extern int Client;
DirCacheFlush(SNUM(cnum));
unbecome_user();
@@ -4204,7 +4270,7 @@ void close_cnum(int cnum, uint16 vuid)
DEBUG(IS_IPC(cnum)?3:1,("%s %s (%s) closed connection to service %s\n",
timestring(),
- remote_machine,client_addr(Client),
+ remote_machine,client_addr(),
lp_servicename(SNUM(cnum))));
yield_connection(cnum,
@@ -4259,6 +4325,183 @@ void close_cnum(int cnum, uint16 vuid)
}
+/****************************************************************************
+simple routines to do connection counting
+****************************************************************************/
+BOOL yield_connection(int cnum,char *name,int max_connections)
+{
+ struct connect_record crec;
+ pstring fname;
+ FILE *f;
+ int mypid = getpid();
+ int i;
+
+ DEBUG(3,("Yielding connection to %d %s\n",cnum,name));
+
+ if (max_connections <= 0)
+ return(True);
+
+ bzero(&crec,sizeof(crec));
+
+ pstrcpy(fname,lp_lockdir());
+ standard_sub(cnum,fname);
+ trim_string(fname,"","/");
+
+ strcat(fname,"/");
+ strcat(fname,name);
+ strcat(fname,".LCK");
+
+ f = fopen(fname,"r+");
+ if (!f)
+ {
+ DEBUG(2,("Couldn't open lock file %s (%s)\n",fname,strerror(errno)));
+ return(False);
+ }
+
+ fseek(f,0,SEEK_SET);
+
+ /* find a free spot */
+ for (i=0;i<max_connections;i++)
+ {
+ if (fread(&crec,sizeof(crec),1,f) != 1)
+ {
+ DEBUG(2,("Entry not found in lock file %s\n",fname));
+ fclose(f);
+ return(False);
+ }
+ if (crec.pid == mypid && crec.cnum == cnum)
+ break;
+ }
+
+ if (crec.pid != mypid || crec.cnum != cnum)
+ {
+ fclose(f);
+ DEBUG(2,("Entry not found in lock file %s\n",fname));
+ return(False);
+ }
+
+ bzero((void *)&crec,sizeof(crec));
+
+ /* remove our mark */
+ if (fseek(f,i*sizeof(crec),SEEK_SET) != 0 ||
+ fwrite(&crec,sizeof(crec),1,f) != 1)
+ {
+ DEBUG(2,("Couldn't update lock file %s (%s)\n",fname,strerror(errno)));
+ fclose(f);
+ return(False);
+ }
+
+ DEBUG(3,("Yield successful\n"));
+
+ fclose(f);
+ return(True);
+}
+
+
+/****************************************************************************
+simple routines to do connection counting
+****************************************************************************/
+BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear)
+{
+ struct connect_record crec;
+ pstring fname;
+ FILE *f;
+ int snum = SNUM(cnum);
+ int i,foundi= -1;
+ int total_recs;
+
+ if (max_connections <= 0)
+ return(True);
+
+ DEBUG(5,("trying claim %s %s %d\n",lp_lockdir(),name,max_connections));
+
+ pstrcpy(fname,lp_lockdir());
+ standard_sub(cnum,fname);
+ trim_string(fname,"","/");
+
+ if (!directory_exist(fname,NULL))
+ mkdir(fname,0755);
+
+ strcat(fname,"/");
+ strcat(fname,name);
+ strcat(fname,".LCK");
+
+ if (!file_exist(fname,NULL))
+ {
+ int oldmask = umask(022);
+ f = fopen(fname,"w");
+ if (f) fclose(f);
+ umask(oldmask);
+ }
+
+ total_recs = file_size(fname) / sizeof(crec);
+
+ f = fopen(fname,"r+");
+
+ if (!f)
+ {
+ DEBUG(1,("couldn't open lock file %s\n",fname));
+ return(False);
+ }
+
+ /* find a free spot */
+ for (i=0;i<max_connections;i++)
+ {
+
+ if (i>=total_recs ||
+ fseek(f,i*sizeof(crec),SEEK_SET) != 0 ||
+ fread(&crec,sizeof(crec),1,f) != 1)
+ {
+ if (foundi < 0) foundi = i;
+ break;
+ }
+
+ if (Clear && crec.pid && !process_exists(crec.pid))
+ {
+ fseek(f,i*sizeof(crec),SEEK_SET);
+ bzero((void *)&crec,sizeof(crec));
+ fwrite(&crec,sizeof(crec),1,f);
+ if (foundi < 0) foundi = i;
+ continue;
+ }
+ if (foundi < 0 && (!crec.pid || !process_exists(crec.pid)))
+ {
+ foundi=i;
+ if (!Clear) break;
+ }
+ }
+
+ if (foundi < 0)
+ {
+ DEBUG(3,("no free locks in %s\n",fname));
+ fclose(f);
+ return(False);
+ }
+
+ /* fill in the crec */
+ bzero((void *)&crec,sizeof(crec));
+ crec.magic = 0x280267;
+ crec.pid = getpid();
+ crec.cnum = cnum;
+ crec.uid = Connections[cnum].uid;
+ crec.gid = Connections[cnum].gid;
+ StrnCpy(crec.name,lp_servicename(snum),sizeof(crec.name)-1);
+ crec.start = time(NULL);
+
+ StrnCpy(crec.machine,remote_machine,sizeof(crec.machine)-1);
+ StrnCpy(crec.addr,client_addr(),sizeof(crec.addr)-1);
+
+ /* make our mark */
+ if (fseek(f,foundi*sizeof(crec),SEEK_SET) != 0 ||
+ fwrite(&crec,sizeof(crec),1,f) != 1)
+ {
+ fclose(f);
+ return(False);
+ }
+
+ fclose(f);
+ return(True);
+}
#if DUMP_CORE
/*******************************************************************
@@ -4390,6 +4633,7 @@ force write permissions on print services.
functions. Any message that has a NULL function is unimplemented -
please feel free to contribute implementations!
*/
+
struct smb_message_struct
{
int code;
@@ -4412,7 +4656,7 @@ struct smb_message_struct
{SMBecho,"SMBecho",reply_echo,0},
{SMBsesssetupX,"SMBsesssetupX",reply_sesssetup_and_X,0},
{SMBtconX,"SMBtconX",reply_tcon_and_X,0},
- {SMBulogoffX, "SMBulogoffX", reply_ulogoffX, 0}, /* ulogoff doesn't give a valid TID */
+ {SMBulogoffX, "SMBulogoffX",reply_ulogoffX, 0}, /* ulogoff doesn't give a valid TID */
{SMBgetatr,"SMBgetatr",reply_getatr,AS_USER},
{SMBsetatr,"SMBsetatr",reply_setatr,AS_USER | NEED_WRITE},
{SMBchkpth,"SMBchkpth",reply_chkpth,AS_USER},
@@ -4470,7 +4714,7 @@ struct smb_message_struct
{SMBmove,"SMBmove",NULL,AS_USER | NEED_WRITE | QUEUE_IN_OPLOCK },
{SMBopenX,"SMBopenX",reply_open_and_X,AS_USER | CAN_IPC | QUEUE_IN_OPLOCK },
- {SMBreadX,"SMBreadX",reply_read_and_X,AS_USER | CAN_IPC },
+ {SMBreadX,"SMBreadX",reply_read_and_X,AS_USER},
{SMBwriteX,"SMBwriteX",reply_write_and_X,AS_USER},
{SMBlockingX,"SMBlockingX",reply_lockingX,AS_USER},
@@ -4479,10 +4723,10 @@ struct smb_message_struct
{SMBfclose,"SMBfclose",reply_fclose,AS_USER},
/* LANMAN2.0 PROTOCOL FOLLOWS */
- {SMBfindnclose, "SMBfindnclose", reply_findnclose, AS_USER},
- {SMBfindclose, "SMBfindclose", reply_findclose,AS_USER},
- {SMBtrans2, "SMBtrans2", reply_trans2, AS_USER },
- {SMBtranss2, "SMBtranss2", reply_transs2, AS_USER},
+ {SMBfindnclose, "SMBfindnclose",reply_findnclose, AS_USER},
+ {SMBfindclose, "SMBfindclose",reply_findclose,AS_USER},
+ {SMBtrans2, "SMBtrans2",reply_trans2, AS_USER},
+ {SMBtranss2, "SMBtranss2",reply_transs2, AS_USER},
/* messaging routines */
{SMBsends,"SMBsends",reply_sends,AS_GUEST},
@@ -4601,7 +4845,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
last_session_tag = session_tag;
if(session_tag != UID_FIELD_INVALID)
- vuser = get_valid_user_struct(session_tag);
+ vuser = get_valid_user_struct(session_tag);
if(vuser != NULL)
pstrcpy( sesssetup_user, vuser->requested_name);
}
@@ -4962,21 +5206,6 @@ static void init_structs(void )
int i;
get_myname(myhostname,NULL);
- /*
- * Set the machine NETBIOS name if not already
- * set from the config file.
- */
-
- if (!*global_myname)
- {
- char *p;
- fstrcpy( global_myname, myhostname );
- p = strchr( global_myname, '.' );
- if (p)
- *p = 0;
- }
- strupper( global_myname );
-
for (i=0;i<MAX_CONNECTIONS;i++)
{
Connections[i].open = False;
@@ -4993,6 +5222,7 @@ static void init_structs(void )
{
Files[i].open = False;
string_init(&Files[i].name,"");
+
}
for (i=0;i<MAX_OPEN_FILES;i++)
@@ -5010,8 +5240,10 @@ static void init_structs(void )
/* for RPC pipes */
init_rpc_pipe_hnd();
+#ifdef NTDOMAIN
/* for LSA handles */
init_lsa_policy_hnd();
+#endif
init_dptrs();
}
@@ -5047,6 +5279,9 @@ static void usage(char *pname)
int port = SMB_PORT;
int opt;
extern char *optarg;
+ char pidFile[100];
+
+ *pidFile = '\0';
#ifdef NEED_AUTH_PARAMETERS
set_auth_parameters(argc,argv);
@@ -5100,6 +5335,9 @@ static void usage(char *pname)
while ((opt = getopt(argc, argv, "O:i:l:s:d:Dp:hPaf:")) != EOF)
switch (opt)
{
+ case 'f':
+ strncpy(pidFile, optarg, sizeof(pidFile));
+ break;
case 'O':
strcpy(user_socket_options,optarg);
break;
@@ -5185,7 +5423,7 @@ static void usage(char *pname)
codepage_initialise(lp_client_code_page());
- strcpy(global_myworkgroup, lp_workgroup());
+ strcpy(myworkgroup, lp_workgroup());
#ifndef NO_SIGNAL_TEST
signal(SIGHUP,SIGNAL_CAST sig_hup);
@@ -5225,9 +5463,33 @@ static void usage(char *pname)
mkdir(lp_lockdir(), 0755);
}
- if (is_daemon) {
- pidfile_create("smbd");
- }
+ if (*pidFile)
+ {
+ int fd;
+ char buf[20];
+
+ if ((fd = open(pidFile,
+#ifdef O_NONBLOCK
+ O_NONBLOCK |
+#endif
+ O_CREAT | O_WRONLY | O_TRUNC, 0644)) < 0)
+ {
+ DEBUG(0,("ERROR: can't open %s: %s\n", pidFile, strerror(errno)));
+ exit(1);
+ }
+ if(fcntl_lock(fd,F_SETLK,0,1,F_WRLCK)==False)
+ {
+ DEBUG(0,("ERROR: smbd is already running\n"));
+ exit(1);
+ }
+ sprintf(buf, "%u\n", (unsigned int) getpid());
+ if (write(fd, buf, strlen(buf)) < 0)
+ {
+ DEBUG(0,("ERROR: can't write to %s: %s\n", pidFile, strerror(errno)));
+ exit(1);
+ }
+ /* Leave pid file open & locked for the duration... */
+ }
if (!open_sockets(is_daemon,port))
exit(1);
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index fb45efcc0b2..ab25b5a748b 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -1748,7 +1748,7 @@ int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize)
{
/*
* Queue this open message as we are the process of an oplock break.
- */
+ */
DEBUG(2,("%s: reply_trans2: queueing message trans2open due to being in oplock break state.\n",
timestring() ));
@@ -1787,10 +1787,8 @@ int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize)
if (num_params > total_params || num_data > total_data)
exit_server("invalid params in reply_trans2");
- if(params)
- memcpy( params, smb_base(inbuf) + SVAL(inbuf, smb_psoff), num_params);
- if(data)
- memcpy( data, smb_base(inbuf) + SVAL(inbuf, smb_dsoff), num_data);
+ memcpy( params, smb_base(inbuf) + SVAL(inbuf, smb_psoff), num_params);
+ memcpy( data, smb_base(inbuf) + SVAL(inbuf, smb_dsoff), num_data);
if(num_data_sofar < total_data || num_params_sofar < total_params)
{
@@ -1814,10 +1812,8 @@ int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize)
else
DEBUG(0,("reply_trans2: %s in getting secondary trans2 response.\n",
(smb_read_error == READ_ERROR) ? "error" : "timeout" ));
- if(params)
- free(params);
- if(data)
- free(data);
+ free(params);
+ free(data);
return(ERROR(ERRSRV,ERRerror));
}
diff --git a/source/smbd/uid.c b/source/smbd/uid.c
index 749248ac862..95c22022d20 100644
--- a/source/smbd/uid.c
+++ b/source/smbd/uid.c
@@ -276,7 +276,7 @@ BOOL become_user(connection_struct *conn, int cnum, uint16 vuid)
current_user.cnum = cnum;
current_user.vuid = vuid;
-
+
DEBUG(5,("become_user uid=(%d,%d) gid=(%d,%d)\n",
getuid(),geteuid(),getgid(),getegid()));
diff --git a/source/ubiqx/README.UBI b/source/ubiqx/README.UBI
index 205296f5ae5..2c1c0430fb9 100644
--- a/source/ubiqx/README.UBI
+++ b/source/ubiqx/README.UBI
@@ -1,15 +1,15 @@
-Fri Apr 17 10:21:56 CDT 1998
+Thu Oct 16 11:07:18 CDT 1997
-The C code files in the samba/source/ubiqx directory are licensed under
-the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL). A copy of the
-LGPL should also be included in this directory under the name COPYING.LIB.
-If this file is not present, you can obtain a copy of the LGPL by writing
-to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA.
+Files in the samba/source/ubiqx directory which begin with the prefix
+"ubi_" are licensed under the terms of the GNU LIBRARY GENERAL PUBLIC
+LICENSE (LGPL). A copy of the LGPL should also be included in this
+directory under the name COPYING.LIB. If this file is not present, you
+can obtain a copy of the LGPL by writing to the Free Software Foundation,
+Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
See http://www.interads.co.uk/~crh/ubiqx/ for more info and additional
available modules.
Chris Hertel
Samba Team
-ubiqx@ubiqx.mn.org
+samba-bugs@samba.anu.edu.au
diff --git a/source/ubiqx/ubi_AVLtree.c b/source/ubiqx/ubi_AVLtree.c
index c02765f4413..2cd8d1cbedf 100644
--- a/source/ubiqx/ubi_AVLtree.c
+++ b/source/ubiqx/ubi_AVLtree.c
@@ -1,7 +1,7 @@
/* ========================================================================== **
* ubi_AVLtree.c
*
- * Copyright (C) 1991-1998 by Christopher R. Hertel
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -32,14 +32,6 @@
* -------------------------------------------------------------------------- **
*
* Log: ubi_AVLtree.c,v
- * Revision 4.0 1998/03/10 03:37:09 crh
- * Major changes.
- * By adding the AVL balance field to the base ubi_btNode structure, I no
- * longer need AVL-specific ReplaceNode(), SwapNodes(), and InitNode()
- * functions. The Remove() function is also simplified. It's all much
- * cleaner.
- * This is rev. 4.0. The 3.x series was dropped.
- *
* Revision 2.5 1997/12/23 04:00:42 crh
* In this version, all constants & macros defined in the header file have
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
@@ -100,9 +92,10 @@
*
* To further complicate matters, only those portions of the base module
* (ubi_BinTree) that were superceeded in the new module had the new names.
- * For example, if you were using ubi_SplayTree, the locate function was
- * called "ubi_sptLocate", but the next and previous functions remained
- * "ubi_btNext" and "ubi_btPrev".
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
*
* This was not too terrible if you were familiar with the modules and knew
* exactly which tree model you wanted to use. If you wanted to be able to
@@ -136,8 +129,8 @@
*/
static char ModuleID[] = "ubi_AVLtree\n\
-\tRevision: 4.0\n\
-\tDate: 1998/03/10 03:37:09\n\
+\tRevision: 2.5\n\
+\tDate: 1997/12/23 04:00:42\n\
\tAuthor: crh\n";
/* ========================================================================== **
@@ -154,7 +147,7 @@ static char ModuleID[] = "ubi_AVLtree\n\
* -------------------------------------------------------------------------- **
*/
-static ubi_btNodePtr L1( ubi_btNodePtr p )
+static ubi_avlNodePtr L1( ubi_avlNodePtr p )
/* ------------------------------------------------------------------------ **
* Single rotate left.
*
@@ -164,7 +157,7 @@ static ubi_btNodePtr L1( ubi_btNodePtr p )
* ------------------------------------------------------------------------ **
*/
{
- ubi_btNodePtr tmp;
+ ubi_avlNodePtr tmp;
tmp = p->Link[ubi_trRIGHT];
p->Link[ubi_trRIGHT] = tmp->Link[ubi_trLEFT];
@@ -186,7 +179,7 @@ static ubi_btNodePtr L1( ubi_btNodePtr p )
return( tmp );
} /* L1 */
-static ubi_btNodePtr R1( ubi_btNodePtr p )
+static ubi_avlNodePtr R1( ubi_avlNodePtr p )
/* ------------------------------------------------------------------------ **
* Single rotate right.
*
@@ -196,7 +189,7 @@ static ubi_btNodePtr R1( ubi_btNodePtr p )
* ------------------------------------------------------------------------ **
*/
{
- ubi_btNodePtr tmp;
+ ubi_avlNodePtr tmp;
tmp = p->Link[ubi_trLEFT];
p->Link[ubi_trLEFT] = tmp->Link[ubi_trRIGHT];
@@ -218,7 +211,7 @@ static ubi_btNodePtr R1( ubi_btNodePtr p )
return( tmp );
} /* R1 */
-static ubi_btNodePtr L2( ubi_btNodePtr tree )
+static ubi_avlNodePtr L2( ubi_avlNodePtr tree )
/* ------------------------------------------------------------------------ **
* Double rotate left.
*
@@ -228,7 +221,7 @@ static ubi_btNodePtr L2( ubi_btNodePtr tree )
* ------------------------------------------------------------------------ **
*/
{
- ubi_btNodePtr tmp, newroot;
+ ubi_avlNodePtr tmp, newroot;
tmp = tree->Link[ubi_trRIGHT];
newroot = tmp->Link[ubi_trLEFT];
@@ -270,7 +263,7 @@ static ubi_btNodePtr L2( ubi_btNodePtr tree )
return( newroot );
} /* L2 */
-static ubi_btNodePtr R2( ubi_btNodePtr tree )
+static ubi_avlNodePtr R2( ubi_avlNodePtr tree )
/* ------------------------------------------------------------------------ **
* Double rotate right.
*
@@ -280,7 +273,7 @@ static ubi_btNodePtr R2( ubi_btNodePtr tree )
* ------------------------------------------------------------------------ **
*/
{
- ubi_btNodePtr tmp, newroot;
+ ubi_avlNodePtr tmp, newroot;
tmp = tree->Link[ubi_trLEFT];
newroot = tmp->Link[ubi_trRIGHT];
@@ -323,7 +316,7 @@ static ubi_btNodePtr R2( ubi_btNodePtr tree )
} /* R2 */
-static ubi_btNodePtr Adjust( ubi_btNodePtr p, char LorR )
+static ubi_avlNodePtr Adjust( ubi_avlNodePtr p, char LorR )
/* ------------------------------------------------------------------------ **
* Adjust the balance value at node *p. If necessary, rotate the subtree
* rooted at p.
@@ -356,9 +349,9 @@ static ubi_btNodePtr Adjust( ubi_btNodePtr p, char LorR )
return( p );
} /* Adjust */
-static ubi_btNodePtr Rebalance( ubi_btNodePtr Root,
- ubi_btNodePtr subtree,
- char LorR )
+static ubi_avlNodePtr Rebalance( ubi_avlNodePtr Root,
+ ubi_avlNodePtr subtree,
+ char LorR )
/* ------------------------------------------------------------------------ **
* Rebalance the tree following an insertion.
*
@@ -394,9 +387,9 @@ static ubi_btNodePtr Rebalance( ubi_btNodePtr Root,
return( Root );
} /* Rebalance */
-static ubi_btNodePtr Debalance( ubi_btNodePtr Root,
- ubi_btNodePtr subtree,
- char LorR )
+static ubi_avlNodePtr Debalance( ubi_avlNodePtr Root,
+ ubi_avlNodePtr subtree,
+ char LorR )
/* ------------------------------------------------------------------------ **
* Rebalance the tree following a deletion.
*
@@ -435,22 +428,125 @@ static ubi_btNodePtr Debalance( ubi_btNodePtr Root,
return( Root );
} /* Debalance */
+
+/* -------------------------------------------------------------------------- **
+ * The next two functions are used for general tree manipulation. They are
+ * each slightly different from their ubi_BinTree counterparts.
+ * -------------------------------------------------------------------------- **
+ */
+
+static void ReplaceNode( ubi_avlNodePtr *parent,
+ ubi_avlNodePtr oldnode,
+ ubi_avlNodePtr newnode )
+ /* ------------------------------------------------------------------------ **
+ * Remove node oldnode from the tree, replacing it with node newnode.
+ *
+ * Input:
+ * parent - A pointer to he parent pointer of the node to be
+ * replaced. <parent> may point to the Link[] field of
+ * a parent node, or it may indicate the root pointer at
+ * the top of the tree.
+ * oldnode - A pointer to the node that is to be replaced.
+ * newnode - A pointer to the node that is to be installed in the
+ * place of <*oldnode>.
+ *
+ * Notes: Don't forget to free oldnode.
+ * The only difference between this function and the ubi_bt
+ * version is that the node size is sizeof( ubi_avlNode ), not
+ * sizeof( ubi_btNode ).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ register int i;
+ register int avlNodeSize = sizeof( ubi_avlNode );
+
+ for( i = 0; i < avlNodeSize; i++ )
+ ((unsigned char *)newnode)[i] = ((unsigned char *)oldnode)[i];
+ (*parent) = newnode;
+
+ if(oldnode->Link[ubi_trLEFT ] )
+ (oldnode->Link[ubi_trLEFT ])->Link[ubi_trPARENT] = newnode;
+ if(oldnode->Link[ubi_trRIGHT] )
+ (oldnode->Link[ubi_trRIGHT])->Link[ubi_trPARENT] = newnode;
+ } /* ReplaceNode */
+
+static void SwapNodes( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr Node1,
+ ubi_avlNodePtr Node2 )
+ /* ------------------------------------------------------------------------ **
+ * This function swaps two nodes in the tree. Node1 will take the place of
+ * Node2, and Node2 will fill in the space left vacant by Node 1.
+ *
+ * Input:
+ * RootPtr - pointer to the tree header structure for this tree.
+ * Node1 - \
+ * > These are the two nodes which are to be swapped.
+ * Node2 - /
+ *
+ * Notes:
+ * This function does a three step swap, using a dummy node as a place
+ * holder. This function is used by ubi_avlRemove().
+ * The only difference between this function and its ubi_bt counterpart
+ * is that the nodes are ubi_avlNodes, not ubi_btNodes.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr *Parent;
+ ubi_avlNode dummy;
+ ubi_avlNodePtr dummy_p = &dummy;
+
+ if( Node1->Link[ubi_trPARENT] )
+ Parent = &((Node1->Link[ubi_trPARENT])->Link[(int)(Node1->gender)]);
+ else
+ Parent = (ubi_avlNodePtr *)&(RootPtr->root);
+ ReplaceNode( Parent, Node1, dummy_p );
+
+ if( Node2->Link[ubi_trPARENT] )
+ Parent = &((Node2->Link[ubi_trPARENT])->Link[(int)(Node2->gender)]);
+ else
+ Parent = (ubi_avlNodePtr *)&(RootPtr->root);
+ ReplaceNode( Parent, Node2, Node1 );
+
+ if( dummy_p->Link[ubi_trPARENT] )
+ Parent = &((dummy_p->Link[ubi_trPARENT])->Link[(int)(dummy_p->gender)]);
+ else
+ Parent = (ubi_avlNodePtr *)&(RootPtr->root);
+ ReplaceNode( Parent, dummy_p, Node2 );
+ } /* SwapNodes */
+
+
/* ========================================================================== **
* Public, exported (ie. not static-ly declared) functions...
* -------------------------------------------------------------------------- **
*/
-ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
- ubi_btNodePtr NewNode,
- ubi_btItemPtr ItemPtr,
- ubi_btNodePtr *OldNode )
+ubi_avlNodePtr ubi_avlInitNode( ubi_avlNodePtr NodePtr )
+ /* ------------------------------------------------------------------------ **
+ * Initialize a tree node.
+ *
+ * Input: NodePtr - pointer to a ubi_btNode structure to be
+ * initialized.
+ * Output: a pointer to the initialized ubi_avlNode structure (ie. the
+ * same as the input pointer).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ (void)ubi_btInitNode( (ubi_btNodePtr)NodePtr );
+ NodePtr->balance = ubi_trEQUAL;
+ return( NodePtr );
+ } /* ubi_avlInitNode */
+
+ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr NewNode,
+ ubi_btItemPtr ItemPtr,
+ ubi_avlNodePtr *OldNode )
/* ------------------------------------------------------------------------ **
* This function uses a non-recursive algorithm to add a new element to
* the tree.
*
* Input: RootPtr - a pointer to the ubi_btRoot structure that indicates
* the root of the tree to which NewNode is to be added.
- * NewNode - a pointer to an ubi_btNode structure that is NOT
+ * NewNode - a pointer to an ubi_avlNode structure that is NOT
* part of any tree.
* ItemPtr - A pointer to the sort key that is stored within
* *NewNode. ItemPtr MUST point to information stored
@@ -489,10 +585,9 @@ ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
* ------------------------------------------------------------------------ **
*/
{
- ubi_btNodePtr OtherP;
+ ubi_avlNodePtr OtherP;
- if( !(OldNode) )
- OldNode = &OtherP;
+ if( !(OldNode) ) OldNode = &OtherP;
if( ubi_btInsert( RootPtr,
(ubi_btNodePtr)NewNode,
ItemPtr,
@@ -503,7 +598,7 @@ ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
else
{
NewNode->balance = ubi_trEQUAL;
- RootPtr->root = (ubi_btNodePtr)Rebalance( (ubi_btNodePtr)RootPtr->root,
+ RootPtr->root = (ubi_btNodePtr)Rebalance( (ubi_avlNodePtr)RootPtr->root,
NewNode->Link[ubi_trPARENT],
NewNode->gender );
}
@@ -512,8 +607,8 @@ ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
return( ubi_trFALSE ); /* Failure: could not replace an existing node. */
} /* ubi_avlInsert */
-ubi_btNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
- ubi_btNodePtr DeadNode )
+ubi_avlNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr DeadNode )
/* ------------------------------------------------------------------------ **
* This function removes the indicated node from the tree, after which the
* tree is rebalanced.
@@ -527,15 +622,45 @@ ubi_btNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
*
* Note: The node MUST be in the tree indicated by RootPtr. If not,
* strange and evil things will happen to your trees.
- *
* ------------------------------------------------------------------------ **
*/
{
- /* Let the base binary tree module do the removal, then rebalance. */
- if( ubi_btRemove( RootPtr, DeadNode ) )
- RootPtr->root = Debalance( RootPtr->root,
- DeadNode->Link[ubi_trPARENT],
- DeadNode->gender );
+ ubi_btNodePtr p,
+ *parentp;
+
+ /* if the node has both left and right subtrees, then we have to swap
+ * it with another node.
+ */
+ if( (DeadNode->Link[ubi_trLEFT]) && (DeadNode->Link[ubi_trRIGHT]) )
+ SwapNodes( RootPtr, DeadNode, ubi_trPrev( DeadNode ) );
+
+ /* The parent of the node to be deleted may be another node, or it may be
+ * the root of the tree. Since we're not sure, it's best just to have
+ * a pointer to the parent pointer, whatever it is.
+ */
+ if( DeadNode->Link[ubi_trPARENT] )
+ parentp = (ubi_btNodePtr *)
+ &((DeadNode->Link[ubi_trPARENT])->Link[(int)(DeadNode->gender)]);
+ else
+ parentp = &( RootPtr->root );
+
+ /* Now link the parent to the only grand-child. Patch up the gender and
+ * such, and rebalance.
+ */
+ if( ubi_trEQUAL == DeadNode->balance )
+ (*parentp) = NULL;
+ else
+ {
+ p = (ubi_btNodePtr)(DeadNode->Link[(int)(DeadNode->balance)]);
+ p->Link[ubi_trPARENT] = (ubi_btNodePtr)DeadNode->Link[ubi_trPARENT];
+ p->gender = DeadNode->gender;
+ (*parentp) = p;
+ }
+ RootPtr->root = (ubi_btNodePtr)Debalance( (ubi_avlNodePtr)RootPtr->root,
+ DeadNode->Link[ubi_trPARENT],
+ DeadNode->gender );
+
+ (RootPtr->count)--;
return( DeadNode );
} /* ubi_avlRemove */
diff --git a/source/ubiqx/ubi_AVLtree.h b/source/ubiqx/ubi_AVLtree.h
index f99a78aa267..ebae7f3c131 100644
--- a/source/ubiqx/ubi_AVLtree.h
+++ b/source/ubiqx/ubi_AVLtree.h
@@ -3,7 +3,7 @@
/* ========================================================================== **
* ubi_AVLtree.h
*
- * Copyright (C) 1991-1998 by Christopher R. Hertel
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -35,14 +35,6 @@
*
* -------------------------------------------------------------------------- **
* Log: ubi_AVLtree.h,v
- * Revision 4.0 1998/03/10 03:34:45 crh
- * Major changes.
- * By adding the AVL balance field to the base ubi_btNode structure, I no
- * longer need AVL-specific ReplaceNode(), SwapNodes(), and InitNode()
- * functions. The Remove() function is also simplified. It's all much
- * cleaner.
- * This is rev. 4.0. The 3.x series was dropped.
- *
* Revision 2.5 1997/12/23 04:00:15 crh
* In this version, all constants & macros defined in the header file have
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
@@ -103,9 +95,10 @@
*
* To further complicate matters, only those portions of the base module
* (ubi_BinTree) that were superceeded in the new module had the new names.
- * For example, if you were using ubi_SplayTree, the locate function was
- * called "ubi_sptLocate", but the next and previous functions remained
- * "ubi_btNext" and "ubi_btPrev".
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
*
* This was not too terrible if you were familiar with the modules and knew
* exactly which tree model you wanted to use. If you wanted to be able to
@@ -133,22 +126,70 @@
#include "ubi_BinTree.h" /* Base erg binary tree support. */
+/* ------------------------------------------------------------------------- **
+ * AVL Tree Node Structure: This structure defines the basic elements of
+ * the AVL tree nodes. In general you *SHOULD NOT PLAY WITH THESE
+ * FIELDS*! But, of course, I have to put the structure into this
+ * header so that you can use the structure as a building block.
+ *
+ * The fields are as follows:
+ * Link - An array of pointers. These pointers are manipulated by the
+ * BT and AVL routines, and indicate the left and right child
+ * nodes, plus the parent node. By keeping track of the parent
+ * pointer, we avoid the need for recursive routines or hand-
+ * tooled stacks to keep track of our path back to the root.
+ * The use of these pointers is subject to change without
+ * notice.
+ * gender - For tree rebalancing purposes, it is necessary that each node
+ * know whether it is the left or right child of its parent, or
+ * if it is the root. This information is stored in this field.
+ * balance - This field is also needed for AVL balancing purposes. It
+ * indicates which subtree of the current node is longer, or if
+ * the subtrees are, in fact, balanced with respect to each
+ * other.
+ * ------------------------------------------------------------------------- **
+ */
+
+typedef struct ubi_avlNodeStruct {
+ struct ubi_avlNodeStruct
+ *Link[3]; /* Normal Binary Tree Node type. */
+ char gender; /* The node is either the RIGHT or LEFT child of its */
+ /* parent, or is the root node. */
+ char balance; /* In an AVL tree, each node is the root of a subtree */
+ /* that may be balanced, or be one node longer to the */
+ /* right or left. This field keeps track of the */
+ /* balance value of each node. */
+ } ubi_avlNode;
+
+typedef ubi_avlNode *ubi_avlNodePtr; /* a Pointer to an AVL node */
+
/* -------------------------------------------------------------------------- **
* Function prototypes.
* -------------------------------------------------------------------------- **
*/
-ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
- ubi_btNodePtr NewNode,
- ubi_btItemPtr ItemPtr,
- ubi_btNodePtr *OldNode );
+ubi_avlNodePtr ubi_avlInitNode( ubi_avlNodePtr NodePtr );
+ /* ------------------------------------------------------------------------ **
+ * Initialize a tree node.
+ *
+ * Input: NodePtr - a pointer to a ubi_btNode structure to be
+ * initialized.
+ * Output: a pointer to the initialized ubi_avlNode structure (ie. the
+ * same as the input pointer).
+ * ------------------------------------------------------------------------ **
+ */
+
+ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr NewNode,
+ ubi_btItemPtr ItemPtr,
+ ubi_avlNodePtr *OldNode );
/* ------------------------------------------------------------------------ **
* This function uses a non-recursive algorithm to add a new element to
* the tree.
*
* Input: RootPtr - a pointer to the ubi_btRoot structure that indicates
* the root of the tree to which NewNode is to be added.
- * NewNode - a pointer to an ubi_btNode structure that is NOT
+ * NewNode - a pointer to an ubi_avlNode structure that is NOT
* part of any tree.
* ItemPtr - A pointer to the sort key that is stored within
* *NewNode. ItemPtr MUST point to information stored
@@ -187,8 +228,8 @@ ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
* ------------------------------------------------------------------------ **
*/
-ubi_btNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
- ubi_btNodePtr DeadNode );
+ubi_avlNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr DeadNode );
/* ------------------------------------------------------------------------ **
* This function removes the indicated node from the tree, after which the
* tree is rebalanced.
@@ -232,14 +273,60 @@ int ubi_avlModuleID( int size, char *list[] );
* type by including the appropriate module header.
*/
+#undef ubi_trNode
+#undef ubi_trNodePtr
+#define ubi_trNode ubi_avlNode
+#define ubi_trNodePtr ubi_avlNodePtr
+
+#undef ubi_trInitNode
+#define ubi_trInitNode( Np ) ubi_avlInitNode( (ubi_avlNodePtr)(Np) )
+
#undef ubi_trInsert
#define ubi_trInsert( Rp, Nn, Ip, On ) \
- ubi_avlInsert( (ubi_btRootPtr)(Rp), (ubi_btNodePtr)(Nn), \
- (ubi_btItemPtr)(Ip), (ubi_btNodePtr *)(On) )
+ ubi_avlInsert( (ubi_btRootPtr)(Rp), (ubi_avlNodePtr)(Nn), \
+ (ubi_btItemPtr)(Ip), (ubi_avlNodePtr *)(On) )
#undef ubi_trRemove
#define ubi_trRemove( Rp, Dn ) \
- ubi_avlRemove( (ubi_btRootPtr)(Rp), (ubi_btNodePtr)(Dn) )
+ ubi_avlRemove( (ubi_btRootPtr)(Rp), (ubi_avlNodePtr)(Dn) )
+
+#undef ubi_trLocate
+#define ubi_trLocate( Rp, Ip, Op ) \
+ (ubi_avlNodePtr)ubi_btLocate( (ubi_btRootPtr)(Rp), \
+ (ubi_btItemPtr)(Ip), \
+ (ubi_trCompOps)(Op) )
+
+#undef ubi_trFind
+#define ubi_trFind( Rp, Ip ) \
+ (ubi_avlNodePtr)ubi_btFind( (ubi_btRootPtr)(Rp), (ubi_btItemPtr)(Ip) )
+
+#undef ubi_trNext
+#define ubi_trNext( P ) (ubi_avlNodePtr)ubi_btNext( (ubi_btNodePtr)(P) )
+
+#undef ubi_trPrev
+#define ubi_trPrev( P ) (ubi_avlNodePtr)ubi_btPrev( (ubi_btNodePtr)(P) )
+
+#undef ubi_trFirst
+#define ubi_trFirst( P ) (ubi_avlNodePtr)ubi_btFirst( (ubi_btNodePtr)(P) )
+
+#undef ubi_trLast
+#define ubi_trLast( P ) (ubi_avlNodePtr)ubi_btLast( (ubi_btNodePtr)(P) )
+
+#undef ubi_trFirstOf
+#define ubi_trFirstOf( Rp, Ip, P ) \
+ (ubi_avlNodePtr)ubi_btFirstOf( (ubi_btRootPtr)(Rp), \
+ (ubi_btItemPtr)(Ip), \
+ (ubi_btNodePtr)(P) )
+
+#undef ubi_trLastOf
+#define ubi_trLastOf( Rp, Ip, P ) \
+ (ubi_avlNodePtr)ubi_btLastOf( (ubi_btRootPtr)(Rp), \
+ (ubi_btItemPtr)(Ip), \
+ (ubi_btNodePtr)(P) )
+
+#undef ubi_trLeafNode
+#define ubi_trLeafNode( Nd ) \
+ (ubi_avlNodePtr)ubi_btLeafNode( (ubi_btNodePtr)(Nd) )
#undef ubi_trModuleID
#define ubi_trModuleID( s, l ) ubi_avlModuleID( s, l )
diff --git a/source/ubiqx/ubi_BinTree.c b/source/ubiqx/ubi_BinTree.c
index ed565bbfbaa..501f3eeca79 100644
--- a/source/ubiqx/ubi_BinTree.c
+++ b/source/ubiqx/ubi_BinTree.c
@@ -1,7 +1,7 @@
/* ========================================================================== **
* ubi_BinTree.c
*
- * Copyright (C) 1991-1998 by Christopher R. Hertel
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -27,21 +27,6 @@
* -------------------------------------------------------------------------- **
*
* Log: ubi_BinTree.c,v
- * Revision 4.1 1998/03/31 06:11:57 crh
- * Thomas Aglassinger sent E'mail pointing out errors in the
- * dereferencing of function pointers, and a missing typecast.
- * Thanks, Thomas!
- *
- * Revision 4.0 1998/03/10 03:19:22 crh
- * Added the AVL field 'balance' to the ubi_btNode structure. This means
- * that all BinTree modules now use the same basic node structure, which
- * greatly simplifies the AVL module.
- * Decided that this was a big enough change to justify a new major revision
- * number. 3.0 was an error, so we're at 4.0.
- *
- * Revision 2.6 1998/01/24 06:27:46 crh
- * Added ubi_trCount() macro.
- *
* Revision 2.5 1997/12/23 03:56:29 crh
* In this version, all constants & macros defined in the header file have
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
@@ -94,9 +79,10 @@
*
* To further complicate matters, only those portions of the base module
* (ubi_BinTree) that were superceeded in the new module had the new names.
- * For example, if you were using ubi_SplayTree, the locate function was
- * called "ubi_sptLocate", but the next and previous functions remained
- * "ubi_btNext" and "ubi_btPrev".
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
*
* This was not too terrible if you were familiar with the modules and knew
* exactly which tree model you wanted to use. If you wanted to be able to
@@ -130,8 +116,8 @@
*/
static char ModuleID[] = "ubi_BinTree\n\
-\tRevision: 4.1\n\
-\tDate: 1998/03/31 06:11:57\n\
+\tRevision: 2.5\n\
+\tDate: 1997/12/23 03:56:29\n\
\tAuthor: crh\n";
/* ========================================================================== **
@@ -203,16 +189,16 @@ static ubi_btNodePtr TreeFind( ubi_btItemPtr findme,
* ------------------------------------------------------------------------ **
*/
{
- register ubi_btNodePtr tmp_p = p;
- ubi_btNodePtr tmp_pp = NULL;
- signed char tmp_gender = ubi_trEQUAL;
- int tmp_cmp;
+ register ubi_btNodePtr tmp_p = p;
+ ubi_btNodePtr tmp_pp = NULL;
+ int tmp_gender = ubi_trEQUAL;
+ int tmp_cmp;
while( tmp_p
&& (ubi_trEQUAL != (tmp_cmp = ubi_trAbNormal((*CmpFunc)(findme, tmp_p)))) )
{
tmp_pp = tmp_p; /* Keep track of previous node. */
- tmp_gender = (signed char)tmp_cmp; /* Keep track of sex of child. */
+ tmp_gender = tmp_cmp; /* Keep track of sex of child. */
tmp_p = tmp_p->Link[tmp_cmp]; /* Go to child. */
}
*parentp = tmp_pp; /* Return results. */
@@ -223,7 +209,7 @@ static ubi_btNodePtr TreeFind( ubi_btItemPtr findme,
static void ReplaceNode( ubi_btNodePtr *parent,
ubi_btNodePtr oldnode,
ubi_btNodePtr newnode )
- /* ------------------------------------------------------------------------ **
+ /* ------------------------------------------------------------------ *
* Remove node oldnode from the tree, replacing it with node newnode.
*
* Input:
@@ -241,7 +227,7 @@ static void ReplaceNode( ubi_btNodePtr *parent,
* that now reads:
* ((unsigned char *)newnode)[i] = ((unsigned char *)oldnode)[i];
* Bleah!
- * ------------------------------------------------------------------------ **
+ * ------------------------------------------------------------------ *
*/
{
register int i;
@@ -470,7 +456,6 @@ ubi_btNodePtr ubi_btInitNode( ubi_btNodePtr NodePtr )
NodePtr->Link[ ubi_trPARENT ] = NULL;
NodePtr->Link[ ubi_trRIGHT ] = NULL;
NodePtr->gender = ubi_trEQUAL;
- NodePtr->balance = ubi_trEQUAL;
return( NodePtr );
} /* ubi_btInitNode */
@@ -931,7 +916,7 @@ ubi_trBool ubi_btTraverse( ubi_btRootPtr RootPtr,
while( p )
{
- (*EachNode)( p, UserData );
+ EachNode( p, UserData );
p = ubi_btNext( p );
}
return( ubi_trTRUE );
@@ -969,7 +954,7 @@ ubi_trBool ubi_btKillTree( ubi_btRootPtr RootPtr,
p = q->Link[ubi_trPARENT];
if( p )
p->Link[ ((p->Link[ubi_trLEFT] == q)?ubi_trLEFT:ubi_trRIGHT) ] = NULL;
- (*FreeNode)((void *)q);
+ FreeNode((void *)q);
}
(void)ubi_btInitTree( RootPtr,
diff --git a/source/ubiqx/ubi_BinTree.h b/source/ubiqx/ubi_BinTree.h
index 8a99f28045c..4b918a46096 100644
--- a/source/ubiqx/ubi_BinTree.h
+++ b/source/ubiqx/ubi_BinTree.h
@@ -3,7 +3,7 @@
/* ========================================================================== **
* ubi_BinTree.h
*
- * Copyright (C) 1991-1998 by Christopher R. Hertel
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -29,21 +29,6 @@
* -------------------------------------------------------------------------- **
*
* Log: ubi_BinTree.h,v
- * Revision 4.1 1998/03/31 06:13:47 crh
- * Thomas Aglassinger sent E'mail pointing out errors in the
- * dereferencing of function pointers, and a missing typecast.
- * Thanks, Thomas!
- *
- * Revision 4.0 1998/03/10 03:16:04 crh
- * Added the AVL field 'balance' to the ubi_btNode structure. This means
- * that all BinTree modules now use the same basic node structure, which
- * greatly simplifies the AVL module.
- * Decided that this was a big enough change to justify a new major revision
- * number. 3.0 was an error, so we're at 4.0.
- *
- * Revision 2.6 1998/01/24 06:27:30 crh
- * Added ubi_trCount() macro.
- *
* Revision 2.5 1997/12/23 03:59:21 crh
* In this version, all constants & macros defined in the header file have
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
@@ -96,9 +81,10 @@
*
* To further complicate matters, only those portions of the base module
* (ubi_BinTree) that were superceeded in the new module had the new names.
- * For example, if you were using ubi_SplayTree, the locate function was
- * called "ubi_sptLocate", but the next and previous functions remained
- * "ubi_btNext" and "ubi_btPrev".
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
*
* This was not too terrible if you were familiar with the modules and knew
* exactly which tree model you wanted to use. If you wanted to be able to
@@ -198,8 +184,7 @@ typedef enum {
* -------------------------------------------------------------------------- **
*/
#define ubi_trNormalize(W) ((char)( (W) - ubi_trEQUAL ))
-#define ubi_trAbNormal(W) ((char)( ((char)ubi_btSgn( (long)(W) )) \
- + ubi_trEQUAL ))
+#define ubi_trAbNormal(W) ((char)( ((char)ubi_btSgn( W )) + ubi_trEQUAL ))
#define ubi_trRevWay(W) ((char)( ubi_trEQUAL - ((W) - ubi_trEQUAL) ))
/* -------------------------------------------------------------------------- **
@@ -213,16 +198,6 @@ typedef enum {
((ubi_trOVERWRITE & ((A)->flags))?(ubi_trTRUE):(ubi_trFALSE))
/* -------------------------------------------------------------------------- **
- * A quickie for consistency.
- * ubi_trCount() - Given a pointer to a tree root, this macro returns the
- * number of nodes currently in the tree.
- *
- * -------------------------------------------------------------------------- **
- */
-
-#define ubi_trCount( R ) (((ubi_trRootPtr)(R))->count)
-
-/* -------------------------------------------------------------------------- **
* Typedefs...
*
* ubi_trBool - Your typcial true or false...
@@ -236,7 +211,7 @@ typedef enum {
typedef unsigned char ubi_trBool;
-typedef void *ubi_btItemPtr; /* A pointer to key data within a node. */
+typedef void *ubi_btItemPtr; /* A pointer to data within a node. */
/* ------------------------------------------------------------------------- **
* Binary Tree Node Structure: This structure defines the basic elements of
@@ -255,16 +230,11 @@ typedef void *ubi_btItemPtr; /* A pointer to key data within a node. */
* gender - a one-byte field indicating whether the node is the RIGHT or
* LEFT child of its parent. If the node is the root of the
* tree, gender will be PARENT.
- * balance - only used by the AVL tree module. This field indicates
- * the height balance at a given node. See ubi_AVLtree for
- * details.
- *
* ------------------------------------------------------------------------- **
*/
typedef struct ubi_btNodeStruct {
struct ubi_btNodeStruct *Link[ 3 ];
- signed char gender;
- signed char balance;
+ char gender;
} ubi_btNode;
typedef ubi_btNode *ubi_btNodePtr; /* Pointer to an ubi_btNode structure. */
@@ -302,8 +272,8 @@ typedef void (*ubi_btKillNodeRtn)( ubi_btNodePtr );
/* -------------------------------------------------------------------------- **
* Tree Root Structure: This structure gives us a convenient handle for
- * accessing whole binary trees. The fields are:
- * root - A pointer to the root node of the tree.
+ * accessing whole AVL trees. The fields are:
+ * root - A pointer to the root node of the AVL tree.
* count - A count of the number of nodes stored in the tree.
* cmp - A pointer to the comparison routine to be used when building or
* searching the tree.
@@ -324,8 +294,8 @@ typedef void (*ubi_btKillNodeRtn)( ubi_btNodePtr );
typedef struct {
ubi_btNodePtr root; /* A pointer to the root node of the tree */
- ubi_btCompFunc cmp; /* A pointer to the tree's comparison function */
unsigned long count; /* A count of the number of nodes in the tree */
+ ubi_btCompFunc cmp; /* A pointer to the tree's comparison function */
unsigned char flags; /* Overwrite Y|N, Duplicate keys Y|N... */
} ubi_btRoot;
diff --git a/source/ubiqx/ubi_Cache.c b/source/ubiqx/ubi_Cache.c
index e566e6c7daf..4b65e3eda65 100644
--- a/source/ubiqx/ubi_Cache.c
+++ b/source/ubiqx/ubi_Cache.c
@@ -104,6 +104,12 @@
* Static data...
*/
+static char ModuleID[] =
+"ubi_Cache\n\
+\tRevision: 0.0\n\
+\tDate: 1997/12/18 06:24:33 GMT\n\
+\tAuthor: crh\n";
+
/* -------------------------------------------------------------------------- **
* Internal functions...
*/
diff --git a/source/ubiqx/ubi_SplayTree.c b/source/ubiqx/ubi_SplayTree.c
index 89ddfb988ac..799996b6cc3 100644
--- a/source/ubiqx/ubi_SplayTree.c
+++ b/source/ubiqx/ubi_SplayTree.c
@@ -1,7 +1,7 @@
/* ========================================================================== **
* ubi_SplayTree.c
*
- * Copyright (C) 1993-1998 by Christopher R. Hertel
+ * Copyright (C) 1993-1995 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -16,8 +16,6 @@
* Robert Tarjan. Journal of the Association for Computing
* Machinery Vol 32, No. 3, July 1985 pp. 652-686
*
- * See also: http://www.cs.cmu.edu/~sleator/
- *
* -------------------------------------------------------------------------- **
*
* This library is free software; you can redistribute it and/or
@@ -37,13 +35,6 @@
* -------------------------------------------------------------------------- **
*
* Log: ubi_SplayTree.c,v
- * Revision 4.0 1998/03/10 03:41:33 crh
- * Minor comment changes. The revision number is now 4.0 to match the
- * BinTree and AVLtree modules.
- *
- * Revision 2.7 1998/01/24 06:37:08 crh
- * Added a URL for more information.
- *
* Revision 2.6 1997/12/23 04:01:12 crh
* In this version, all constants & macros defined in the header file have
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
@@ -89,9 +80,10 @@
*
* To further complicate matters, only those portions of the base module
* (ubi_BinTree) that were superceeded in the new module had the new names.
- * For example, if you were using ubi_SplayTree, the locate function was
- * called "ubi_sptLocate", but the next and previous functions remained
- * "ubi_btNext" and "ubi_btPrev".
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
*
* This was not too terrible if you were familiar with the modules and knew
* exactly which tree model you wanted to use. If you wanted to be able to
@@ -131,8 +123,8 @@
*/
static char ModuleID[] = "ubi_SplayTree\n\
-\tRevision: 4.0\n\
-\tDate: 1998/03/10 03:41:33\n\
+\tRevision: 2.6\n\
+\tDate: 1997/12/23 04:01:12\n\
\tAuthor: crh\n";
@@ -474,4 +466,3 @@ int ubi_sptModuleID( int size, char *list[] )
} /* ubi_sptModuleID */
/* ================================ The End ================================= */
-
diff --git a/source/ubiqx/ubi_SplayTree.h b/source/ubiqx/ubi_SplayTree.h
index 9e557347020..d45c32fce83 100644
--- a/source/ubiqx/ubi_SplayTree.h
+++ b/source/ubiqx/ubi_SplayTree.h
@@ -3,7 +3,7 @@
/* ========================================================================== **
* ubi_SplayTree.h
*
- * Copyright (C) 1993-1998 by Christopher R. Hertel
+ * Copyright (C) 1993,1995 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -18,8 +18,6 @@
* Robert Tarjan. Journal of the Association for Computing
* Machinery Vol 32, No. 3, July 1985 pp. 652-686
*
- * See also: http://www.cs.cmu.edu/~sleator/
- *
* -------------------------------------------------------------------------- **
*
* This library is free software; you can redistribute it and/or
@@ -39,13 +37,6 @@
* -------------------------------------------------------------------------- **
*
* Log: ubi_SplayTree.h,v
- * Revision 4.0 1998/03/10 03:40:57 crh
- * Minor comment changes. The revision number is now 4.0 to match the
- * BinTree and AVLtree modules.
- *
- * Revision 2.7 1998/01/24 06:37:57 crh
- * Added a URL for more information.
- *
* Revision 2.6 1997/12/23 04:02:20 crh
* In this version, all constants & macros defined in the header file have
* the ubi_tr prefix. Also cleaned up anything that gcc complained about
@@ -88,9 +79,10 @@
*
* To further complicate matters, only those portions of the base module
* (ubi_BinTree) that were superceeded in the new module had the new names.
- * For example, if you were using ubi_SplayTree, the locate function was
- * called "ubi_sptLocate", but the next and previous functions remained
- * "ubi_btNext" and "ubi_btPrev".
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
*
* This was not too terrible if you were familiar with the modules and knew
* exactly which tree model you wanted to use. If you wanted to be able to
@@ -336,3 +328,8 @@ int ubi_sptModuleID( int size, char *list[] );
/* ================================ The End ================================= */
#endif /* ubi_SplayTree_H */
+
+
+
+
+
diff --git a/source/ubiqx/ubi_StackQueue.c b/source/ubiqx/ubi_StackQueue.c
new file mode 100644
index 00000000000..19e4f785a0b
--- /dev/null
+++ b/source/ubiqx/ubi_StackQueue.c
@@ -0,0 +1,149 @@
+/* ========================================================================== **
+ * ubi_StackQueue.c
+ *
+ * Copyright (C) 1997 by Christopher R. Hertel
+ *
+ * Email: crh@ubiqx.mn.org
+ * -------------------------------------------------------------------------- **
+ * This module implements simple queues and stacks using a singly linked
+ * list.
+ * -------------------------------------------------------------------------- **
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * -------------------------------------------------------------------------- **
+ * This module uses a singly-linked list to implement both a queue and a
+ * stack. For a queue, entries are added at the tail and removed from the
+ * head of the list. For a stack, the entries are entered and removed from
+ * the head of the list. A traversal of the list will always start at the
+ * head of the list and proceed toward the tail. This is all mind-numbingly
+ * simple, but I'm surprised by the number of programs out there which
+ * re-implement this a dozen or so times.
+ *
+ * Note: When the list header is initialized, the Tail pointer is set to
+ * point to the Head pointer. This simplifies the InsTail function
+ * at little or no cost to InsHead or Remove. The one problem is
+ * that you can't initialize a stack or queue headerby simply zeroing
+ * it out. One sure way to initialize the header is to call
+ * ubi_sqInit(). Another option would be something like this:
+ *
+ * static ubi_sqList MyList = { NULL, (ubi_sqNodePtr)&MyList, 0 };
+ *
+ * See ubi_sqInit() and the ubi_sqList structure for more info.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * Revision 0.1 1997/10/24 02:47:52 crh
+ * Initial revision.
+ *
+ * ========================================================================== **
+ */
+
+#include "ubi_StackQueue.h"
+
+/* ========================================================================== **
+ * Functions...
+ */
+
+ubi_sqListPtr ubi_sqInit( ubi_sqListPtr ListPtr )
+ /* ------------------------------------------------------------------------ **
+ * Initialize a stack & queue header.
+ *
+ * Input: ListPtr - A pointer to the list header that is to be
+ * initialized for use.
+ *
+ * Output: A pointer to the initialized list header (i.e., same as
+ * <ListPtr>).
+ *
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ListPtr->Head = NULL;
+ ListPtr->Tail = (ubi_sqNodePtr)ListPtr;
+ ListPtr->count = 0;
+ return( ListPtr );
+ } /* ubi_sqInit */
+
+ubi_sqNodePtr ubi_sqInsHead( ubi_sqListPtr ListPtr, ubi_sqNodePtr New )
+ /* ------------------------------------------------------------------------ **
+ * Insert a new node at the head of the list (push).
+ *
+ * Input: ListPtr - A pointer to the stack into which the node is to
+ * be inserted.
+ * New - Pointer to the node that is to be pushed onto the
+ * stack.
+ *
+ * Output: A pointer to the node that was added to the list (i.e., same
+ * same as <New>).
+ *
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ if( NULL == ListPtr->Head ) /* If list is empty, must change tail ptr. */
+ ListPtr->Tail = New;
+ New->Next = ListPtr->Head;
+ ListPtr->Head = New;
+ ++(ListPtr->count);
+ return( New );
+ } /* ubi_sqInsHead */
+
+ubi_sqNodePtr ubi_sqInsTail( ubi_sqListPtr ListPtr, ubi_sqNodePtr New )
+ /* ------------------------------------------------------------------------ **
+ * Add a new node to the tail of the list (enqueue).
+ *
+ * Input: ListPtr - A pointer to the queue into which the node is to
+ * be inserted.
+ * New - Pointer to the node that is to be enqueued.
+ *
+ * Output: A pointer to the node that was inserted into the queue (i.e.,
+ * the same as <New>).
+ *
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ListPtr->Tail->Next = New;
+ ListPtr->Tail = New;
+ New->Next = NULL;
+ ++(ListPtr->count);
+ return( New );
+ } /* ubi_sqInsTail */
+
+ubi_sqNodePtr ubi_sqRemove( ubi_sqListPtr ListPtr )
+ /* ------------------------------------------------------------------------ **
+ * Remove the frontmost entry from the queue, or topmost entry from the
+ * stack.
+ *
+ * Input: ListPtr - A pointer to the list from which the node is to be
+ * removed.
+ *
+ * Output: A pointer to the node that was removed.
+ *
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_sqNodePtr Old = ListPtr->Head;
+
+ if( NULL != Old )
+ {
+ if( NULL == Old->Next )
+ ListPtr->Tail = (ubi_sqNodePtr)ListPtr;
+ ListPtr->Head = Old->Next;
+ --(ListPtr->count);
+ }
+ return( Old );
+ } /* ubi_sqRemove */
+
+
+/* ================================ The End ================================= */
diff --git a/source/ubiqx/ubi_StackQueue.h b/source/ubiqx/ubi_StackQueue.h
new file mode 100644
index 00000000000..69fe7bebe5e
--- /dev/null
+++ b/source/ubiqx/ubi_StackQueue.h
@@ -0,0 +1,180 @@
+#ifndef ubi_StackQueue_H
+#define ubi_StackQueue_H
+/* ========================================================================== **
+ * ubi_StackQueue.h
+ *
+ * Copyright (C) 1997 by Christopher R. Hertel
+ *
+ * Email: crh@ubiqx.mn.org
+ * -------------------------------------------------------------------------- **
+ * This module implements simple queues and stacks using a singly linked
+ * list.
+ * -------------------------------------------------------------------------- **
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * -------------------------------------------------------------------------- **
+ * This module uses a singly-linked list to implement both a queue and a
+ * stack. For a queue, entries are added at the tail and removed from the
+ * head of the list. For a stack, the entries are entered and removed from
+ * the head of the list. A traversal of the list will always start at the
+ * head of the list and proceed toward the tail. This is all mind-numbingly
+ * simple, but I'm surprised by the number of programs out there which
+ * re-implement this a dozen or so times.
+ *
+ * Note: When the list header is initialized, the Tail pointer is set to
+ * point to the Head pointer. This simplifies the InsTail function
+ * at little or no cost to InsHead or Remove. The one problem is
+ * that you can't initialize a stack or queue headerby simply zeroing
+ * it out. One sure way to initialize the header is to call
+ * ubi_sqInit(). Another option would be something like this:
+ *
+ * static ubi_sqList MyList = { NULL, (ubi_sqNodePtr)&MyList, 0 };
+ *
+ * See ubi_sqInit() and the ubi_sqList structure for more info.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * Revision 0.1 1997/10/24 02:48:23 crh
+ * Initial revision.
+ *
+ * ========================================================================== **
+ */
+
+#include <stdlib.h>
+
+
+/* ========================================================================== **
+ * Typedefs...
+ *
+ * ubi_sqNode - This is the basic node structure.
+ * ubi_sqNodePtr - Pointer to a node.
+ * ubi_sqList - This is the stack & queue header structure.
+ * ubi_sqListPtr - Pointer to a stack & queue header.
+ *
+ */
+
+typedef struct ubi_sqListNode
+ {
+ struct ubi_sqListNode *Next;
+ } ubi_sqNode;
+
+typedef ubi_sqNode *ubi_sqNodePtr;
+
+typedef struct
+ {
+ ubi_sqNodePtr Head;
+ ubi_sqNodePtr Tail;
+ unsigned long count;
+ } ubi_sqList;
+
+typedef ubi_sqList *ubi_sqListPtr;
+
+/* ========================================================================== **
+ * Macros...
+ *
+ * ubi_sqEnqueue - Add a new node at the tail of a queue.
+ * ubi_sqDequeue - Remove a node from the head of the queue.
+ * ubi_sqPush - Add a new node at the head of the queue.
+ * ubi_sqPop - Remove a node from the head of the queue (same as Dequeue).
+ * ubi_sqFirst - Return a pointer to the frontmost node in the queue.
+ * ubi_sqNext - Given a node, return a pointer to the next node.
+ * ubi_sqLast - Return a pointer to the last (valid) node in the queue.
+ *
+ * Note that all of these provide type casting of the parameters. The
+ * Enqueue/Dequeue macros are nothing more than nice front-ends to the
+ * Insert and Remove operations.
+ *
+ */
+
+#define ubi_sqEnqueue( L, N ) \
+ ubi_sqInsTail( (ubi_sqListPtr)(L), (ubi_sqNodePtr)(N) )
+
+#define ubi_sqDequeue( L ) ubi_sqRemove( (ubi_sqListPtr)(L) )
+
+#define ubi_sqPush( L, N ) \
+ ubi_sqInsHead( (ubi_sqListPtr)(L), (ubi_sqNodePtr)(N) )
+
+#define ubi_sqPop ubi_sqDequeue
+
+#define ubi_sqFirst( L ) (((ubi_sqListPtr)(L))->Head)
+
+#define ubi_sqNext( N ) (((ubi_sqNodePtr)(N))->Next)
+
+#define ubi_sqLast( L ) \
+ ( (((ubi_sqListPtr)(L))->Head) ? (((ubi_sqListPtr)(L))->Tail) : NULL )
+
+
+/* ========================================================================== **
+ * Function prototypes...
+ */
+
+ubi_sqListPtr ubi_sqInit( ubi_sqListPtr ListPtr );
+ /* ------------------------------------------------------------------------ **
+ * Initialize a stack & queue header.
+ *
+ * Input: ListPtr - A pointer to the list header that is to be
+ * initialized for use.
+ *
+ * Output: A pointer to the initialized list header (i.e., same as
+ * <ListPtr>).
+ *
+ * ------------------------------------------------------------------------ **
+ */
+
+ubi_sqNodePtr ubi_sqInsHead( ubi_sqListPtr ListPtr, ubi_sqNodePtr New );
+ /* ------------------------------------------------------------------------ **
+ * Insert a new node at the head of the list (push).
+ *
+ * Input: ListPtr - A pointer to the stack into which the node is to
+ * be inserted.
+ * New - Pointer to the node that is to be pushed onto the
+ * stack.
+ *
+ * Output: A pointer to the node that was added to the list (i.e., same
+ * same as <New>).
+ *
+ * ------------------------------------------------------------------------ **
+ */
+
+ubi_sqNodePtr ubi_sqInsTail( ubi_sqListPtr ListPtr, ubi_sqNodePtr New );
+ /* ------------------------------------------------------------------------ **
+ * Add a new node to the tail of the list (enqueue).
+ *
+ * Input: ListPtr - A pointer to the queue into which the node is to
+ * be inserted.
+ * New - Pointer to the node that is to be enqueued.
+ *
+ * Output: A pointer to the node that was inserted into the queue (i.e.,
+ * the same as <New>).
+ *
+ * ------------------------------------------------------------------------ **
+ */
+
+ubi_sqNodePtr ubi_sqRemove( ubi_sqListPtr ListPtr );
+ /* ------------------------------------------------------------------------ **
+ * Remove the frontmost entry from the queue, or topmost entry from the
+ * stack.
+ *
+ * Input: ListPtr - A pointer to the list from which the node is to be
+ * removed.
+ *
+ * Output: A pointer to the node that was removed.
+ *
+ * ------------------------------------------------------------------------ **
+ */
+
+/* ================================ The End ================================= */
+#endif /* ubi_StackQueue_H */
diff --git a/source/ubiqx/ubi_dLinkList.c b/source/ubiqx/ubi_dLinkList.c
index c903dcbc042..5d970a9ca13 100644
--- a/source/ubiqx/ubi_dLinkList.c
+++ b/source/ubiqx/ubi_dLinkList.c
@@ -1,7 +1,7 @@
/* ========================================================================== **
* ubi_dLinkList.c
*
- * Copyright (C) 1997, 1998 by Christopher R. Hertel
+ * Copyright (C) 1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -24,13 +24,6 @@
*
* -------------------------------------------------------------------------- **
*
- * Log: ubi_dLinkList.c,v
- * Revision 0.5 1998/03/10 02:55:00 crh
- * Simplified the code and added macros for stack & queue manipulations.
- *
- * Revision 0.4 1998/01/03 01:53:56 crh
- * Added ubi_dlCount() macro.
- *
* Revision 0.3 1997/10/15 03:05:39 crh
* Added some handy type casting to the macros. Added AddHere and RemThis
* macros.
@@ -42,16 +35,11 @@
* Revision 0.1 1997/10/07 04:34:07 crh
* Initial Revision.
*
- * -------------------------------------------------------------------------- **
- * This module is similar to the ubi_sLinkList module, but it is neither a
- * descendant type nor an easy drop-in replacement for the latter. One key
- * difference is that the ubi_dlRemove() function removes the indicated node,
- * while the ubi_slRemove() function (in ubi_sLinkList) removes the node
- * *following* the indicated node.
*
* ========================================================================== **
*/
+#include "../includes.h"
#include "ubi_dLinkList.h"
/* ========================================================================== **
@@ -97,17 +85,28 @@ ubi_dlNodePtr ubi_dlInsert( ubi_dlListPtr ListPtr,
* ------------------------------------------------------------------------ **
*/
{
- ubi_dlNodePtr PredNode = After ? After : (ubi_dlNodePtr)ListPtr;
-
- New->Next = PredNode->Next;
- New->Prev = After;
- PredNode->Next = New;
- if( New->Next )
- New->Next->Prev = New;
+ if( NULL == After )
+ {
+ New->Next = ListPtr->Head;
+ New->Prev = NULL;
+ if( NULL != ListPtr->Head )
+ ListPtr->Head->Prev = New;
+ else
+ ListPtr->Tail = New;
+ ListPtr->Head = New;
+ }
else
- ListPtr->Tail = New;
+ {
+ New->Next = After->Next;
+ New->Prev = After;
+ if( NULL != After->Next )
+ After->Next->Prev = New;
+ else
+ ListPtr->Tail = New;
+ After->Next = New;
+ }
- (ListPtr->count)++;
+ ++(ListPtr->count);
return( New );
} /* ubi_dlInsert */
@@ -126,7 +125,7 @@ ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old )
* ------------------------------------------------------------------------ **
*/
{
- if( Old )
+ if( NULL != Old )
{
if( Old->Next )
Old->Next->Prev = Old->Prev;
@@ -138,10 +137,11 @@ ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old )
else
ListPtr->Head = Old->Next;
- (ListPtr->count)--;
+ --(ListPtr->count);
}
return( Old );
} /* ubi_dlRemove */
+
/* ================================ The End ================================= */
diff --git a/source/ubiqx/ubi_dLinkList.h b/source/ubiqx/ubi_dLinkList.h
index 9c6a3be2e2a..1facf92d3b1 100644
--- a/source/ubiqx/ubi_dLinkList.h
+++ b/source/ubiqx/ubi_dLinkList.h
@@ -3,7 +3,7 @@
/* ========================================================================== **
* ubi_dLinkList.h
*
- * Copyright (C) 1997, 1998 by Christopher R. Hertel
+ * Copyright (C) 1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
@@ -26,13 +26,6 @@
*
* -------------------------------------------------------------------------- **
*
- * Log: ubi_dLinkList.h,v
- * Revision 0.5 1998/03/10 02:54:04 crh
- * Simplified the code and added macros for stack & queue manipulations.
- *
- * Revision 0.4 1998/01/03 01:53:44 crh
- * Added ubi_dlCount() macro.
- *
* Revision 0.3 1997/10/15 03:04:31 crh
* Added some handy type casting to the macros. Added AddHere and RemThis
* macros.
@@ -44,12 +37,6 @@
* Revision 0.1 1997/10/07 04:34:38 crh
* Initial Revision.
*
- * -------------------------------------------------------------------------- **
- * This module is similar to the ubi_sLinkList module, but it is neither a
- * descendant type nor an easy drop-in replacement for the latter. One key
- * difference is that the ubi_dlRemove() function removes the indicated node,
- * while the ubi_slRemove() function (in ubi_sLinkList) removes the node
- * *following* the indicated node.
*
* ========================================================================== **
*/
@@ -86,63 +73,46 @@ typedef ubi_dlList *ubi_dlListPtr;
/* ========================================================================== **
* Macros...
- *
- * ubi_dlCount - Return the number of entries currently in the list.
- *
+ *
* ubi_dlAddHead - Add a new node at the head of the list.
- * ubi_dlAddNext - Add a node following the given node.
* ubi_dlAddTail - Add a new node at the tail of the list.
- * Note: AddTail evaluates the L parameter twice.
- *
+ * ubi_dlAddHere - Add a node following the given node.
* ubi_dlRemHead - Remove the node at the head of the list, if any.
- * Note: RemHead evaluates the L parameter twice.
- * ubi_dlRemThis - Remove the indicated node.
* ubi_dlRemTail - Remove the node at the tail of the list, if any.
- * Note: RemTail evaluates the L parameter twice.
- *
+ * ubi_dlRemThis - Remove the indicated node.
* ubi_dlFirst - Return a pointer to the first node in the list, if any.
* ubi_dlLast - Return a pointer to the last node in the list, if any.
* ubi_dlNext - Given a node, return a pointer to the next node.
* ubi_dlPrev - Given a node, return a pointer to the previous node.
*
- * ubi_dlPush - Add a node at the head of the list (synonym of AddHead).
- * ubi_dlPop - Remove a node at the head of the list (synonym of RemHead).
- * ubi_dlEnqueue - Add a node at the tail of the list (sysnonym of AddTail).
- * ubi_dlDequeue - Remove a node at the head of the list (synonym of RemHead).
- *
* Note that all of these provide type casting of the parameters. The
* Add and Rem macros are nothing more than nice front-ends to the
* Insert and Remove operations.
*
- * Also note that there the First, Next and Last macros do no parameter
- * checking!
- *
*/
-#define ubi_dlCount( L ) (((ubi_dlListPtr)(L))->count)
-
#define ubi_dlAddHead( L, N ) \
ubi_dlInsert( (ubi_dlListPtr)(L), (ubi_dlNodePtr)(N), NULL )
-#define ubi_dlAddNext( L, N, A ) \
+#define ubi_dlAddTail( L, N ) \
ubi_dlInsert( (ubi_dlListPtr)(L), \
(ubi_dlNodePtr)(N), \
- (ubi_dlNodePtr)(A) )
+ (((ubi_dlListPtr)(L))->Tail) )
-#define ubi_dlAddTail( L, N ) \
+#define ubi_dlAddHere( L, N, P ) \
ubi_dlInsert( (ubi_dlListPtr)(L), \
(ubi_dlNodePtr)(N), \
- (((ubi_dlListPtr)(L))->Tail) )
+ (ubi_dlNodePtr)(P) )
#define ubi_dlRemHead( L ) ubi_dlRemove( (ubi_dlListPtr)(L), \
(((ubi_dlListPtr)(L))->Head) )
-#define ubi_dlRemThis( L, N ) ubi_dlRemove( (ubi_dlListPtr)(L), \
- (ubi_dlNodePtr)(N) )
-
#define ubi_dlRemTail( L ) ubi_dlRemove( (ubi_dlListPtr)(L), \
(((ubi_dlListPtr)(L))->Tail) )
+#define ubi_dlRemThis( L, N ) ubi_dlRemove( (ubi_dlListPtr)(L), \
+ (ubi_dlNodePtr)(N) )
+
#define ubi_dlFirst( L ) (((ubi_dlListPtr)(L))->Head)
#define ubi_dlLast( L ) (((ubi_dlListPtr)(L))->Tail)
@@ -151,10 +121,6 @@ typedef ubi_dlList *ubi_dlListPtr;
#define ubi_dlPrev( N ) (((ubi_dlNodePtr)(N))->Prev)
-#define ubi_dlPush ubi_dlAddHead
-#define ubi_dlPop ubi_dlRemHead
-#define ubi_dlEnqueue ubi_dlAddTail
-#define ubi_dlDequeue ubi_dlRemHead
/* ========================================================================== **
* Function prototypes...
@@ -207,5 +173,6 @@ ubi_dlNodePtr ubi_dlRemove( ubi_dlListPtr ListPtr, ubi_dlNodePtr Old );
* ------------------------------------------------------------------------ **
*/
+
/* ================================ The End ================================= */
#endif /* ubi_dLinkList_H */
diff --git a/source/ubiqx/ubi_sLinkList.c b/source/ubiqx/ubi_sLinkList.c
index 3dc4f0640cb..5414d5f71de 100644
--- a/source/ubiqx/ubi_sLinkList.c
+++ b/source/ubiqx/ubi_sLinkList.c
@@ -1,11 +1,11 @@
/* ========================================================================== **
* ubi_sLinkList.c
*
- * Copyright (C) 1997, 1998 by Christopher R. Hertel
+ * Copyright (C) 1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
- * This module implements a simple singly-linked list.
+ * This module implements a really simple singly-linked list.
* -------------------------------------------------------------------------- **
*
* This library is free software; you can redistribute it and/or
@@ -24,14 +24,6 @@
*
* -------------------------------------------------------------------------- **
*
- * Log: ubi_sLinkList.c,v
- * Revision 0.4 1998/03/10 02:23:20 crh
- * Combined ubi_StackQueue and ubi_sLinkList into one module. Redesigned
- * the functions and macros. Not a complete rewrite but close to it.
- *
- * Revision 0.3 1998/01/03 01:59:52 crh
- * Added ubi_slCount() macro.
- *
* Revision 0.2 1997/10/21 03:35:18 crh
* Added parameter <After> in function Insert(). Made necessary changes
* to macro AddHead() and added macro AddHere().
@@ -39,36 +31,6 @@
* Revision 0.1 1997/10/16 02:53:45 crh
* Initial Revision.
*
- * -------------------------------------------------------------------------- **
- * This module implements a singly-linked list which may also be used as a
- * queue or a stack. For a queue, entries are added at the tail and removed
- * from the head of the list. For a stack, the entries are entered and
- * removed from the head of the list. A traversal of the list will always
- * start at the head of the list and proceed toward the tail. This is all
- * mind-numbingly simple, but I'm surprised by the number of programs out
- * there which re-implement this a dozen or so times.
- *
- * Notes: When the list header is initialized, the Tail pointer is set to
- * point to the Head pointer. This simplifies things a great deal,
- * except that you can't initialize a stack or queue by simply
- * zeroing it out. One sure way to initialize the header is to call
- * ubi_slInit(). Another option would be something like this:
- *
- * static ubi_slList MyList = { NULL, (ubi_slNodePtr)&MyList, 0 };
- *
- * See ubi_slInit() and the ubi_slList structure for more info.
- *
- * + Also, note that this module is similar to the ubi_dLinkList
- * module. There are three key differences:
- * - This is a singly-linked list, the other is a doubly-linked
- * list.
- * - In this module, if the list is empty, the tail pointer will
- * point back to the head of the list as described above. This
- * is not done in ubi_dLinkList.
- * - The ubi_slRemove() function, by necessity, removed the 'next'
- * node. In ubi_dLinkList, the ubi_dlRemove() function removes
- * the 'current' node.
- *
* ========================================================================== **
*/
@@ -92,7 +54,6 @@ ubi_slListPtr ubi_slInitList( ubi_slListPtr ListPtr )
*/
{
ListPtr->Head = NULL;
- ListPtr->Tail = (ubi_slNodePtr)ListPtr;
ListPtr->count = 0;
return( ListPtr );
} /* ubi_slInitList */
@@ -101,7 +62,7 @@ ubi_slNodePtr ubi_slInsert( ubi_slListPtr ListPtr,
ubi_slNodePtr New,
ubi_slNodePtr After )
/* ------------------------------------------------------------------------ **
- * Add a node to the list.
+ * Insert a new node at the head of the list.
*
* Input: ListPtr - A pointer to the list into which the node is to
* be inserted.
@@ -116,43 +77,36 @@ ubi_slNodePtr ubi_slInsert( ubi_slListPtr ListPtr,
* ------------------------------------------------------------------------ **
*/
{
- After = After ? After : (ubi_slNodePtr)ListPtr;
- New->Next = After->Next;
- After->Next = New;
- if( !(New->Next) )
- ListPtr->Tail = New;
- (ListPtr->count)++;
+ ubi_slNodePtr *PredPtr;
+
+ PredPtr = ( NULL == After ) ? &(ListPtr->Head) : &(After->Next);
+ New->Next = *PredPtr;
+ *PredPtr = New;
+ ++(ListPtr->count);
return( New );
} /* ubi_slInsert */
-ubi_slNodePtr ubi_slRemove( ubi_slListPtr ListPtr, ubi_slNodePtr After )
+ubi_slNodePtr ubi_slRemove( ubi_slListPtr ListPtr )
/* ------------------------------------------------------------------------ **
- * Remove the node followng <After>. If <After> is NULL, remove from the
- * head of the list.
+ * Remove a node from the head of the list.
*
* Input: ListPtr - A pointer to the list from which the node is to be
* removed.
- * After - Pointer to the node preceeding the node to be
- * removed.
*
- * Output: A pointer to the node that was removed, or NULL if the list is
- * empty.
+ * Output: A pointer to the node that was removed.
*
* ------------------------------------------------------------------------ **
*/
{
- ubi_slNodePtr DelNode;
+ ubi_slNodePtr Old = ListPtr->Head;
- After = After ? After : (ubi_slNodePtr)ListPtr;
- DelNode = After->Next;
- if( DelNode )
+ if( NULL != Old )
{
- if( !(DelNode->Next) )
- ListPtr->Tail = After;
- After->Next = DelNode->Next;
- (ListPtr->count)--;
+ ListPtr->Head = Old->Next;
+ --(ListPtr->count);
}
- return( DelNode );
+ return( Old );
} /* ubi_slRemove */
+
/* ================================ The End ================================= */
diff --git a/source/ubiqx/ubi_sLinkList.h b/source/ubiqx/ubi_sLinkList.h
index 2275d852da1..7d546f06e95 100644
--- a/source/ubiqx/ubi_sLinkList.h
+++ b/source/ubiqx/ubi_sLinkList.h
@@ -3,11 +3,11 @@
/* ========================================================================== **
* ubi_sLinkList.h
*
- * Copyright (C) 1997, 1998 by Christopher R. Hertel
+ * Copyright (C) 1997 by Christopher R. Hertel
*
* Email: crh@ubiqx.mn.org
* -------------------------------------------------------------------------- **
- * This module implements a simple singly-linked list.
+ * This module implements a really simple singly-linked list.
* -------------------------------------------------------------------------- **
*
* This library is free software; you can redistribute it and/or
@@ -26,14 +26,6 @@
*
* -------------------------------------------------------------------------- **
*
- * Log: ubi_sLinkList.h,v
- * Revision 0.4 1998/03/10 02:22:39 crh
- * Combined ubi_StackQueue and ubi_sLinkList into one module. Redesigned
- * the functions and macros. Not a complete rewrite but close to it.
- *
- * Revision 0.3 1998/01/03 02:00:02 crh
- * Added ubi_slCount() macro.
- *
* Revision 0.2 1997/10/21 03:36:14 crh
* Added parameter <After> in function Insert(). Made necessary changes
* to macro AddHead() and added macro AddHere().
@@ -41,36 +33,6 @@
* Revision 0.1 1997/10/16 02:54:08 crh
* Initial Revision.
*
- * -------------------------------------------------------------------------- **
- * This module implements a singly-linked list which may also be used as a
- * queue or a stack. For a queue, entries are added at the tail and removed
- * from the head of the list. For a stack, the entries are entered and
- * removed from the head of the list. A traversal of the list will always
- * start at the head of the list and proceed toward the tail. This is all
- * mind-numbingly simple, but I'm surprised by the number of programs out
- * there which re-implement this a dozen or so times.
- *
- * Note: When the list header is initialized, the Tail pointer is set to
- * point to the Head pointer. This simplifies things a great deal,
- * except that you can't initialize a stack or queue by simply
- * zeroing it out. One sure way to initialize the header is to call
- * ubi_slInit(). Another option would be something like this:
- *
- * static ubi_slList MyList = { NULL, (ubi_slNodePtr)&MyList, 0 };
- *
- * See ubi_slInit() and the ubi_slList structure for more info.
- *
- * + Also, note that this module is similar to the ubi_dLinkList
- * module. There are three key differences:
- * - This is a singly-linked list, the other is a doubly-linked
- * list.
- * - In this module, if the list is empty, the tail pointer will
- * point back to the head of the list as described above. This
- * is not done in ubi_dLinkList.
- * - The ubi_slRemove() function, by necessity, removed the 'next'
- * node. In ubi_dLinkList, the ubi_dlRemove() function removes
- * the 'current' node.
- *
* ========================================================================== **
*/
@@ -97,7 +59,6 @@ typedef ubi_slNode *ubi_slNodePtr;
typedef struct
{
ubi_slNodePtr Head;
- ubi_slNodePtr Tail;
unsigned long count;
} ubi_slList;
@@ -106,64 +67,31 @@ typedef ubi_slList *ubi_slListPtr;
/* ========================================================================== **
* Macros...
*
- * ubi_slCount - Returns the current number of entries in the list.
- *
* ubi_slAddHead - Add a new node at the head of the list.
- * ubi_slAddNext - Add a new node following the indicated node.
- * ubi_slAddTail - Add a new node to the tail of the list.
- * Note: AddTail evaluates the L parameter twice.
- *
* ubi_slRemHead - Remove the node at the head of the list, if any.
- * ubi_slRemNext - Remove the node following the given node.
- *
* ubi_slFirst - Return a pointer to the first node in the list, if any.
* ubi_slNext - Given a node, return a pointer to the next node.
- * ubi_slLast - Return a pointer to the last node in the list, if any.
- *
- * ubi_slPush - Add a node at the head of the list (synonym of AddHead).
- * ubi_slPop - Remove a node at the head of the list (synonym of RemHead).
- * ubi_slEnqueue - Add a node at the tail of the list (sysnonym of AddTail).
- * ubi_slDequeue - Remove a node at the head of the list (synonym of RemHead).
*
* Note that all of these provide type casting of the parameters. The
* Add and Rem macros are nothing more than nice front-ends to the
- * Insert and Remove functions.
- *
- * Also note that there the First, Next and Last macros do no parameter
- * checking!
+ * Insert and Remove operations.
*
*/
-#define ubi_slCount( L ) (((ubi_slListPtr)(L))->count)
-
#define ubi_slAddHead( L, N ) \
ubi_slInsert( (ubi_slListPtr)(L), (ubi_slNodePtr)(N), NULL )
-#define ubi_slAddNext( L, N, A ) \
- ubi_slInsert( (ubi_slListPtr)(L), \
- (ubi_slNodePtr)(N), \
- (ubi_slNodePtr)(A) )
-
-#define ubi_slAddTail( L, N ) \
+#define ubi_slAddHere( L, N, P ) \
ubi_slInsert( (ubi_slListPtr)(L), \
(ubi_slNodePtr)(N), \
- ((ubi_slListPtr)(L))->Tail )
-
-#define ubi_slRemHead( L ) ubi_slRemove( (ubi_slListPtr)(L), NULL )
+ (ubi_slNodePtr)(P) )
-#define ubi_slRemNext( L, N ) \
- ubi_slRemove( (ubi_slListPtr)(L), (ubi_slNodePtr)(N) )
+#define ubi_slRemHead( L ) ubi_slRemove( (ubi_slListPtr)(L) )
#define ubi_slFirst( L ) (((ubi_slListPtr)(L))->Head)
#define ubi_slNext( N ) (((ubi_slNodePtr)(N))->Next)
-#define ubi_slLast( L ) (((ubi_slListPtr)(L))->Tail)
-
-#define ubi_slPush ubi_slAddHead
-#define ubi_slPop ubi_slRemHead
-#define ubi_slEnqueue ubi_slAddTail
-#define ubi_slDequeue ubi_slRemHead
/* ========================================================================== **
* Function prototypes...
@@ -186,7 +114,7 @@ ubi_slNodePtr ubi_slInsert( ubi_slListPtr ListPtr,
ubi_slNodePtr New,
ubi_slNodePtr After );
/* ------------------------------------------------------------------------ **
- * Add a node to the list.
+ * Insert a new node at the head of the list.
*
* Input: ListPtr - A pointer to the list into which the node is to
* be inserted.
@@ -201,18 +129,14 @@ ubi_slNodePtr ubi_slInsert( ubi_slListPtr ListPtr,
* ------------------------------------------------------------------------ **
*/
-ubi_slNodePtr ubi_slRemove( ubi_slListPtr ListPtr, ubi_slNodePtr After );
+ubi_slNodePtr ubi_slRemove( ubi_slListPtr ListPtr );
/* ------------------------------------------------------------------------ **
- * Remove the node followng <After>. If <After> is NULL, remove from the
- * head of the list.
+ * Remove a node from the head of the list.
*
* Input: ListPtr - A pointer to the list from which the node is to be
* removed.
- * After - Pointer to the node preceeding the node to be
- * removed.
*
- * Output: A pointer to the node that was removed, or NULL if the list is
- * empty.
+ * Output: A pointer to the node that was removed.
*
* ------------------------------------------------------------------------ **
*/
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index 4c9132ee75b..a73a35cd56c 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -172,7 +172,7 @@ int main(int argc,char *argv[])
init_structs();
- if (!lp_load(servicesf,True,False,False)) {
+ if (!lp_load(servicesf,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
}
diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c
index 77dcfb0d43c..dc38d4f7472 100644
--- a/source/utils/smbpasswd.c
+++ b/source/utils/smbpasswd.c
@@ -19,269 +19,279 @@
#include "includes.h"
-extern pstring myhostname;
-extern pstring global_myname;
-extern fstring global_myworkgroup;
-
-static char *prog_name;
-
-/*********************************************************
- Print command usage on stderr and die.
-**********************************************************/
+/*
+ * Password changing error codes.
+ */
-static void usage(char *name, BOOL is_root)
+struct
{
- if(is_root)
- fprintf(stderr, "Usage is : %s [-D DEBUGLEVEL] [-a] [-d] [-m] [-n] [username] [password]\n\
-%s: [-R <name resolve order>] [-D DEBUGLEVEL] [-j DOMAINNAME] [-r machine] [username] [password]\n%s: [-h]\n", name, name, name);
- else
- fprintf(stderr, "Usage is : %s [-h] [-D DEBUGLEVEL] [-r machine] [password]\n", name);
- exit(1);
-}
-
-/*********************************************************
-Join a domain.
-**********************************************************/
-
-static int setup_account( char *domain, char *remote_machine,
- unsigned char orig_machine_passwd_hash[16],
- unsigned char new_machine_passwd_hash[16])
+ int err;
+ char *message;
+} pw_change_errmap[] =
{
- struct in_addr dest_ip;
- struct cli_state cli;
-
- memset(&cli, '\0', sizeof(struct cli_state));
- if(cli_initialise(&cli) == False) {
- fprintf(stderr, "%s: unable to initialize client connection.\n", prog_name);
- return 1;
- }
-
- if(!resolve_name( remote_machine, &dest_ip)) {
- fprintf(stderr, "%s: Can't resolve address for %s\n", prog_name, remote_machine);
- return 1;
- }
-
- if (ismyip(dest_ip)) {
- fprintf(stderr,"%s: Machine %s is one of our addresses. Cannot add to ourselves.\n", prog_name,
- remote_machine);
- return 1;
- }
-
- if (!cli_connect(&cli, remote_machine, &dest_ip)) {
- fprintf(stderr, "%s: unable to connect to SMB server on \
-machine %s. Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli) );
- return 1;
- }
-
- if (!cli_session_request(&cli, remote_machine, 0x20, global_myname)) {
- fprintf(stderr, "%s: machine %s rejected the session setup. \
-Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli) );
- cli_shutdown(&cli);
- return 1;
- }
-
- cli.protocol = PROTOCOL_NT1;
-
- if (!cli_negprot(&cli)) {
- fprintf(stderr, "%s: machine %s rejected the negotiate protocol. \
-Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli) );
- cli_shutdown(&cli);
- return 1;
- }
- if (cli.protocol != PROTOCOL_NT1) {
- fprintf(stderr, "%s: machine %s didn't negotiate NT protocol.\n", prog_name, remote_machine);
- cli_shutdown(&cli);
- return 1;
- }
-
- /*
- * Do an anonymous session setup.
- */
-
- if (!cli_session_setup(&cli, "", "", 0, "", 0, "")) {
- fprintf(stderr, "%s: machine %s rejected the session setup. \
-Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli) );
- cli_shutdown(&cli);
- return 1;
- }
-
- if (!(cli.sec_mode & 1)) {
- fprintf(stderr, "%s: machine %s isn't in user level security mode\n", prog_name, remote_machine);
- cli_shutdown(&cli);
- return 1;
- }
-
- if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
- fprintf(stderr, "%s: machine %s rejected the tconX on the IPC$ share. \
-Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli) );
- cli_shutdown(&cli);
- return 1;
- }
-
- /*
- * Ok - we have an anonymous connection to the IPC$ share.
- * Now start the NT Domain stuff :-).
- */
-
- if(cli_nt_session_open(&cli, PIPE_NETLOGON, False) == False) {
- fprintf(stderr, "%s: unable to open the domain client session to \
-machine %s. Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli));
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return 1;
- }
-
- if(cli_nt_setup_creds(&cli, orig_machine_passwd_hash) == False) {
- fprintf(stderr, "%s: unable to setup the PDC credentials to machine \
-%s. Error was : %s.\n", prog_name, remote_machine, cli_errstr(&cli));
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return 1;
- }
-
- if( cli_nt_srv_pwset( &cli,new_machine_passwd_hash ) == False) {
- fprintf(stderr, "%s: unable to change password for machine %s in domain \
-%s to Domain controller %s. Error was %s.\n", prog_name, global_myname, domain, remote_machine,
- cli_errstr(&cli));
- cli_close(&cli, cli.nt_pipe_fnum);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return 1;
- }
-
- cli_nt_session_close(&cli);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
-
- return 0;
-}
-
-/*********************************************************
-Join a domain.
-**********************************************************/
-
-static int join_domain( char *domain, char *remote)
+ {5, "User has insufficient privilege" },
+ {86, "The specified password is invalid" },
+ {2226, "Operation only permitted on a Primary Domain Controller" },
+ {2242, "The password of this user has expired." },
+ {2243, "The password of this user cannot change." },
+ {2244, "This password cannot be used now (password history conflict)." },
+ {2245, "The password is shorter than required." },
+ {2246, "The password of this user is too recent to change."},
+ {0, NULL}
+};
+
+char *get_error_message(struct cli_state *cli)
{
- fstring remote_machine;
- char *p;
- fstring machine_passwd;
- unsigned char machine_passwd_hash[16];
- unsigned char new_machine_passwd_hash[16];
- int ret = 1;
-
- fstrcpy(remote_machine, remote ? remote : "");
- fstrcpy(machine_passwd, global_myname);
- strlower(machine_passwd);
- E_md4hash((uchar *)machine_passwd, machine_passwd_hash);
-
- generate_random_buffer( new_machine_passwd_hash, 16, True);
-
- /* Ensure that we are not trying to join a
- domain if we are locally set up as a domain
- controller. */
-
- if(lp_domain_controller() && strequal(lp_workgroup(), domain)) {
- fprintf(stderr, "%s: Cannot join domain %s as we already configured as domain controller \
-for that domain.\n", prog_name, domain);
- return 1;
- }
-
- /*
- * Write the new machine password.
- */
-
- /*
- * Get the machine account password.
- */
- if(!machine_password_lock( domain, global_myname, True)) {
- fprintf(stderr, "%s: unable to open the machine account password file for \
-machine %s in domain %s.\n", prog_name, global_myname, domain);
- return 1;
- }
-
- if(!set_machine_account_password( new_machine_passwd_hash)) {
- fprintf(stderr, "%s: unable to read the machine account password for \
-machine %s in domain %s.\n", prog_name, global_myname, domain);
- machine_password_unlock();
- return 1;
- }
-
- machine_password_unlock();
+ static fstring error_message;
+ int errclass;
+ int errnum;
+ int i;
- /*
- * If we are given a remote machine assume this is the PDC.
+ /*
+ * Errors are of two kinds - smb errors,
+ * dealt with by cli_errstr, and rap
+ * errors, whose error code is in cli.error.
*/
- if(remote != NULL) {
- strupper(remote_machine);
- ret = setup_account( domain, remote_machine, machine_passwd_hash, new_machine_passwd_hash);
- if(ret == 0)
- printf("%s: Joined domain %s.\n", prog_name, domain);
- } else {
- /*
- * Treat each name in the 'password server =' line as a potential
- * PDC/BDC. Contact each in turn and try and authenticate and
- * change the machine account password.
- */
-
- p = lp_passwordserver();
-
- if(!*p)
- fprintf(stderr, "%s: No password server list given in smb.conf - \
-unable to join domain.\n", prog_name);
-
- while(p && next_token( &p, remote_machine, LIST_SEP)) {
+ cli_error(cli, &errclass, &errnum);
+ if(errclass != 0)
+ return cli_errstr(cli);
- strupper(remote_machine);
- if(setup_account( domain, remote_machine, machine_passwd_hash, new_machine_passwd_hash) == 0) {
- printf("%s: Joined domain %s.\n", prog_name, domain);
- return 0;
- }
+ sprintf(error_message, "code %d", cli->error);
+
+ for(i = 0; pw_change_errmap[i].message != NULL; i++) {
+ if (pw_change_errmap[i].err == cli->error) {
+ fstrcpy( error_message, pw_change_errmap[i].message);
+ break;
}
}
- if(ret) {
- machine_password_delete( domain, global_myname);
- fprintf(stderr,"%s: Unable to join domain %s.\n", prog_name, domain);
- }
+ return error_message;
+}
+
+static int gethexpwd(char *p, char *pwd)
+{
+ int i;
+ unsigned char lonybble, hinybble;
+ char *hexchars = "0123456789ABCDEF";
+ char *p1, *p2;
+ for (i = 0; i < 32; i += 2) {
+ hinybble = toupper(p[i]);
+ lonybble = toupper(p[i + 1]);
+
+ p1 = strchr(hexchars, hinybble);
+ p2 = strchr(hexchars, lonybble);
+ if (!p1 || !p2)
+ return (False);
+
+ hinybble = PTR_DIFF(p1, hexchars);
+ lonybble = PTR_DIFF(p2, hexchars);
+
+ pwd[i / 2] = (hinybble << 4) | lonybble;
+ }
+ return (True);
+}
- return ret;
+static struct smb_passwd *
+_my_get_smbpwnam(FILE * fp, char *name, BOOL * valid_old_pwd,
+ BOOL *got_valid_nt_entry, long *pwd_seekpos)
+{
+ /* Static buffers we will return. */
+ static struct smb_passwd pw_buf;
+ static pstring user_name;
+ static unsigned char smbpwd[16];
+ static unsigned char smbntpwd[16];
+
+ char linebuf[256];
+ unsigned char c;
+ unsigned char *p;
+ long uidval;
+ long linebuf_len;
+
+ /*
+ * Scan the file, a line at a time and check if the name matches.
+ */
+ while (!feof(fp)) {
+ linebuf[0] = '\0';
+ *pwd_seekpos = ftell(fp);
+
+ fgets(linebuf, 256, fp);
+ if (ferror(fp))
+ return NULL;
+
+ /*
+ * Check if the string is terminated with a newline - if not
+ * then we must keep reading and discard until we get one.
+ */
+ linebuf_len = strlen(linebuf);
+ if (linebuf[linebuf_len - 1] != '\n') {
+ c = '\0';
+ while (!ferror(fp) && !feof(fp)) {
+ c = fgetc(fp);
+ if (c == '\n')
+ break;
+ }
+ } else
+ linebuf[linebuf_len - 1] = '\0';
+
+ if ((linebuf[0] == 0) && feof(fp))
+ break;
+ /*
+ * The line we have should be of the form :-
+ *
+ * username:uid:[32hex bytes]:....other flags presently
+ * ignored....
+ *
+ * or,
+ *
+ * username:uid:[32hex bytes]:[32hex bytes]:....ignored....
+ *
+ * if Windows NT compatible passwords are also present.
+ */
+
+ if (linebuf[0] == '#' || linebuf[0] == '\0')
+ continue;
+ p = (unsigned char *) strchr(linebuf, ':');
+ if (p == NULL)
+ continue;
+ /*
+ * As 256 is shorter than a pstring we don't need to check
+ * length here - if this ever changes....
+ */
+ strncpy(user_name, linebuf, PTR_DIFF(p, linebuf));
+ user_name[PTR_DIFF(p, linebuf)] = '\0';
+ if (!strequal(user_name, name))
+ continue;
+
+ /* User name matches - get uid and password */
+ p++; /* Go past ':' */
+ if (!isdigit(*p))
+ return (False);
+
+ uidval = atoi((char *) p);
+ while (*p && isdigit(*p))
+ p++;
+
+ if (*p != ':')
+ return (False);
+
+ /*
+ * Now get the password value - this should be 32 hex digits
+ * which are the ascii representations of a 16 byte string.
+ * Get two at a time and put them into the password.
+ */
+ p++;
+ *pwd_seekpos += PTR_DIFF(p, linebuf); /* Save exact position
+ * of passwd in file -
+ * this is used by
+ * smbpasswd.c */
+ if (*p == '*' || *p == 'X') {
+ /* Password deliberately invalid - end here. */
+ *valid_old_pwd = False;
+ *got_valid_nt_entry = False;
+ pw_buf.smb_nt_passwd = NULL; /* No NT password (yet)*/
+
+ /* Now check if the NT compatible password is
+ available. */
+ p += 33; /* Move to the first character of the line after
+ the lanman password. */
+ if ((linebuf_len >= (PTR_DIFF(p, linebuf) + 33)) && (p[32] == ':')) {
+ /* NT Entry was valid - even if 'X' or '*', can be overwritten */
+ *got_valid_nt_entry = True;
+ if (*p != '*' && *p != 'X') {
+ if (gethexpwd((char *)p,(char *)smbntpwd))
+ pw_buf.smb_nt_passwd = smbntpwd;
+ }
+ }
+ pw_buf.smb_name = user_name;
+ pw_buf.smb_userid = uidval;
+ pw_buf.smb_passwd = NULL; /* No password */
+ return (&pw_buf);
+ }
+ if (linebuf_len < (PTR_DIFF(p, linebuf) + 33))
+ return (False);
+
+ if (p[32] != ':')
+ return (False);
+
+ if (!strncasecmp((char *)p, "NO PASSWORD", 11)) {
+ pw_buf.smb_passwd = NULL; /* No password */
+ } else {
+ if(!gethexpwd((char *)p,(char *)smbpwd))
+ return False;
+ pw_buf.smb_passwd = smbpwd;
+ }
+
+ pw_buf.smb_name = user_name;
+ pw_buf.smb_userid = uidval;
+ pw_buf.smb_nt_passwd = NULL;
+ *got_valid_nt_entry = False;
+ *valid_old_pwd = True;
+
+ /* Now check if the NT compatible password is
+ available. */
+ p += 33; /* Move to the first character of the line after
+ the lanman password. */
+ if ((linebuf_len >= (PTR_DIFF(p, linebuf) + 33)) && (p[32] == ':')) {
+ /* NT Entry was valid - even if 'X' or '*', can be overwritten */
+ *got_valid_nt_entry = True;
+ if (*p != '*' && *p != 'X') {
+ if (gethexpwd((char *)p,(char *)smbntpwd))
+ pw_buf.smb_nt_passwd = smbntpwd;
+ }
+ }
+ return &pw_buf;
+ }
+ return NULL;
}
-/*********************************************************
- Start here.
-**********************************************************/
+/*
+ * Print command usage on stderr and die.
+ */
+static void usage(char *name, BOOL is_root)
+{
+ if(is_root)
+ fprintf(stderr, "Usage is : %s [-a] [-D DEBUGLEVEL] [username] [password]\n\
+%s: [-r machine] [-D DEBUGLEVEL] [username] [password]\n%s: [-h]\n", name, name, name);
+ else
+ fprintf(stderr, "Usage is : %s [-h] [-D DEBUGLEVEL] [-r machine] [password]\n", name);
+ exit(1);
+}
int main(int argc, char **argv)
{
extern char *optarg;
extern int optind;
extern int DEBUGLEVEL;
+ char *prog_name;
int real_uid;
struct passwd *pwd;
fstring old_passwd;
+ uchar old_p16[16];
+ uchar old_nt_p16[16];
fstring new_passwd;
uchar new_p16[16];
uchar new_nt_p16[16];
char *p;
struct smb_passwd *smb_pwent;
FILE *fp;
+ BOOL valid_old_pwd = False;
+ BOOL got_valid_nt_entry = False;
+ long seekpos;
+ int pwfd;
+ char ascii_p16[66];
+ char c;
int ch;
- int err;
+ int ret, i, err, writelen;
+ int lockfd = -1;
+ char *pfile = SMB_PASSWD_FILE;
+ char readbuf[16 * 1024];
BOOL is_root = False;
pstring user_name;
char *remote_machine = NULL;
- BOOL add_user = False;
- BOOL got_new_pass = False;
- BOOL machine_account = False;
- BOOL disable_user = False;
- BOOL set_no_password = False;
- BOOL joining_domain = False;
- char *new_domain = NULL;
+ BOOL add_user = False;
+ BOOL got_new_pass = False;
pstring servicesf = CONFIGFILE;
- void *vp;
new_passwd[0] = '\0';
user_name[0] = '\0';
@@ -297,29 +307,10 @@ int main(int argc, char **argv)
charset_initialise();
- if (!lp_load(servicesf,True,False,False)) {
+ if (!lp_load(servicesf,True)) {
fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", prog_name, servicesf);
}
-
- if(!get_myname(myhostname,NULL)) {
- fprintf(stderr, "%s: unable to get my hostname.\n", prog_name );
- exit(1);
- }
-
- /*
- * Set the machine NETBIOS name if not already
- * set from the config file.
- */
- if (!*global_myname)
- {
- fstrcpy( global_myname, myhostname );
- p = strchr( global_myname, '.' );
- if (p)
- *p = 0;
- }
- strupper( global_myname );
-
codepage_initialise(lp_client_code_page());
/* Get the real uid */
@@ -333,54 +324,16 @@ int main(int argc, char **argv)
is_root = (real_uid == 0);
- while ((ch = getopt(argc, argv, "adhmnj:r:R:D:")) != EOF) {
+ while ((ch = getopt(argc, argv, "ahr:D:")) != EOF) {
switch(ch) {
case 'a':
- if(is_root)
- add_user = True;
- else
- usage(prog_name, is_root);
- break;
- case 'd':
- if(is_root) {
- disable_user = True;
- got_new_pass = True;
- strcpy(new_passwd, "XXXXXX");
- } else
- usage(prog_name, is_root);
+ add_user = True;
break;
- case 'D':
- DEBUGLEVEL = atoi(optarg);
- break;
- case 'n':
- if(is_root) {
- set_no_password = True;
- got_new_pass = True;
- strcpy(new_passwd, "NO PASSWORD");
- } else
- usage(prog_name, is_root);
case 'r':
remote_machine = optarg;
break;
- case 'R':
- if(is_root) {
- lp_set_name_resolve_order(optarg);
- break;
- } else
- usage(prog_name, is_root);
- case 'm':
- if(is_root) {
- machine_account = True;
- } else
- usage(prog_name, is_root);
- break;
- case 'j':
- if(is_root) {
- new_domain = optarg;
- strupper(new_domain);
- joining_domain = True;
- } else
- usage(prog_name, is_root);
+ case 'D':
+ DEBUGLEVEL = atoi(optarg);
break;
case 'h':
default:
@@ -392,24 +345,13 @@ int main(int argc, char **argv)
argv += optind;
/*
- * Ensure add_user and either remote machine or join domain are
+ * Ensure add_user and remote machine are
* not both set.
*/
-
- if(add_user && ((remote_machine != NULL) || joining_domain))
- usage(prog_name, True);
-
- /*
- * Deal with joining a domain.
- */
- if(joining_domain && argc != 0)
+ if(add_user && (remote_machine != NULL))
usage(prog_name, True);
- if(joining_domain) {
- return join_domain( new_domain, remote_machine);
- }
-
- if(is_root) {
+ if( is_root ) {
/*
* Deal with root - can add a user, but only locally.
@@ -432,25 +374,6 @@ int main(int argc, char **argv)
}
if(*user_name) {
-
- if(machine_account) {
- int username_len = strlen(user_name);
- if(username_len >= sizeof(pstring) - 1) {
- fprintf(stderr, "%s: machine account name too long.\n", user_name);
- exit(1);
- }
-
- if(user_name[username_len-1] != '$') {
- user_name[username_len] = '$';
- user_name[username_len+1] = '\0';
- }
- }
-
- /*
- * Setup the pwd struct to point to known
- * values for a machine account (it doesn't
- * exist in /etc/passwd).
- */
if((pwd = getpwnam(user_name)) == NULL) {
fprintf(stderr, "%s: User \"%s\" was not found in system password file.\n",
prog_name, user_name);
@@ -494,21 +417,6 @@ int main(int argc, char **argv)
exit(1);
}
- /*
- * If we are adding a machine account then pretend
- * we already have the new password, we will be using
- * the machinename as the password.
- */
-
- if(add_user && machine_account) {
- got_new_pass = True;
- strncpy(new_passwd, user_name, sizeof(fstring));
- new_passwd[sizeof(fstring)-1] = '\0';
- strlower(new_passwd);
- if(new_passwd[strlen(new_passwd)-1] == '$')
- new_passwd[strlen(new_passwd)-1] = '\0';
- }
-
/*
* If we are root we don't ask for the old password (unless it's on a
* remote machine.
@@ -550,6 +458,12 @@ int main(int argc, char **argv)
if(remote_machine != NULL) {
struct cli_state cli;
struct in_addr ip;
+ fstring myname;
+
+ if(get_myname(myname,NULL) == False) {
+ fprintf(stderr, "%s: unable to get my hostname.\n", prog_name );
+ exit(1);
+ }
if(!resolve_name( remote_machine, &ip)) {
fprintf(stderr, "%s: unable to find an IP address for machine %s.\n",
@@ -561,13 +475,13 @@ int main(int argc, char **argv)
if (!cli_initialise(&cli) || !cli_connect(&cli, remote_machine, &ip)) {
fprintf(stderr, "%s: unable to connect to SMB server on machine %s. Error was : %s.\n",
- prog_name, remote_machine, cli_errstr(&cli) );
+ prog_name, remote_machine, get_error_message(&cli) );
exit(1);
}
- if (!cli_session_request(&cli, remote_machine, 0x20, global_myname)) {
- fprintf(stderr, "%s: machine %s rejected the session setup. Error was : %s.\n",
- prog_name, remote_machine, cli_errstr(&cli) );
+ if (!cli_session_request(&cli, remote_machine, 0x20, myname)) {
+ fprintf(stderr, "%s: machine %s rejected the session request. Error was : %s.\n",
+ prog_name, remote_machine, get_error_message(&cli) );
cli_shutdown(&cli);
exit(1);
}
@@ -576,7 +490,7 @@ int main(int argc, char **argv)
if (!cli_negprot(&cli)) {
fprintf(stderr, "%s: machine %s rejected the negotiate protocol. Error was : %s.\n",
- prog_name, remote_machine, cli_errstr(&cli) );
+ prog_name, remote_machine, get_error_message(&cli) );
cli_shutdown(&cli);
exit(1);
}
@@ -584,21 +498,21 @@ int main(int argc, char **argv)
if (!cli_session_setup(&cli, user_name, old_passwd, strlen(old_passwd),
"", 0, "")) {
fprintf(stderr, "%s: machine %s rejected the session setup. Error was : %s.\n",
- prog_name, remote_machine, cli_errstr(&cli) );
+ prog_name, remote_machine, get_error_message(&cli) );
cli_shutdown(&cli);
exit(1);
}
if (!cli_send_tconX(&cli, "IPC$", "IPC", "", 1)) {
fprintf(stderr, "%s: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n",
- prog_name, remote_machine, cli_errstr(&cli) );
+ prog_name, remote_machine, get_error_message(&cli) );
cli_shutdown(&cli);
exit(1);
}
if(!cli_oem_change_password(&cli, user_name, new_passwd, old_passwd)) {
fprintf(stderr, "%s: machine %s rejected the password change: Error was : %s.\n",
- prog_name, remote_machine, cli_errstr(&cli) );
+ prog_name, remote_machine, get_error_message(&cli) );
cli_shutdown(&cli);
exit(1);
}
@@ -607,92 +521,139 @@ int main(int argc, char **argv)
exit(0);
}
- /*
- * Check for a machine account.
- */
-
- if(machine_account && !pwd) {
- fprintf(stderr, "%s: User %s does not exist in system password file \
-(usually /etc/passwd). Cannot add machine account without a valid system user.\n",
- prog_name, user_name);
- exit(1);
- }
-
- /* Calculate the MD4 hash (NT compatible) of the new password. */
+ /* Calculate the MD4 hash (NT compatible) of the old and new passwords */
+ memset(old_nt_p16, '\0', 16);
+ E_md4hash((uchar *)old_passwd, old_nt_p16);
memset(new_nt_p16, '\0', 16);
E_md4hash((uchar *) new_passwd, new_nt_p16);
- /* Mangle the password into Lanman format */
+ /* Mangle the passwords into Lanman format */
+ old_passwd[14] = '\0';
+ strupper(old_passwd);
new_passwd[14] = '\0';
strupper(new_passwd);
/*
- * Calculate the SMB (lanman) hash functions of the new password.
+ * Calculate the SMB (lanman) hash functions of both old and new passwords.
*/
+ memset(old_p16, '\0', 16);
+ E_P16((uchar *) old_passwd, old_p16);
+
memset(new_p16, '\0', 16);
E_P16((uchar *) new_passwd, new_p16);
/*
- * Open the smbpaswd file.
+ * Open the smbpaswd file XXXX - we need to parse smb.conf to get the
+ * filename
*/
- vp = startsampwent(True);
- if (!vp && errno == ENOENT) {
- fp = fopen(lp_smb_passwd_file(), "w");
+ fp = fopen(pfile, "r+");
+ if (!fp && errno == ENOENT) {
+ fp = fopen(pfile, "w");
if (fp) {
fprintf(fp, "# Samba SMB password file\n");
fclose(fp);
- vp = startsampwent(True);
+ fp = fopen(pfile, "r+");
}
}
if (!fp) {
err = errno;
fprintf(stderr, "%s: Failed to open password file %s.\n",
- prog_name, lp_smb_passwd_file());
+ prog_name, pfile);
errno = err;
perror(prog_name);
exit(err);
}
+ /* Set read buffer to 16k for effiecient reads */
+ setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf));
+
+ /* make sure it is only rw by the owner */
+ chmod(pfile, 0600);
+
+ /* Lock the smbpasswd file for write. */
+ if ((lockfd = pw_file_lock(pfile, F_WRLCK, 5)) < 0) {
+ err = errno;
+ fprintf(stderr, "%s: Failed to lock password file %s.\n",
+ prog_name, pfile);
+ fclose(fp);
+ errno = err;
+ perror(prog_name);
+ exit(err);
+ }
/* Get the smb passwd entry for this user */
- smb_pwent = getsampwnam(user_name);
+ smb_pwent = _my_get_smbpwnam(fp, user_name, &valid_old_pwd,
+ &got_valid_nt_entry, &seekpos);
if (smb_pwent == NULL) {
if(add_user == False) {
- fprintf(stderr, "%s: Failed to find entry for user %s.\n",
- prog_name, pwd->pw_name);
- endsampwent(vp);
+ fprintf(stderr, "%s: Failed to find entry for user %s in file %s.\n",
+ prog_name, pwd->pw_name, pfile);
+ fclose(fp);
+ pw_file_unlock(lockfd);
exit(1);
}
/* Create a new smb passwd entry and set it to the given password. */
{
- struct smb_passwd new_smb_pwent;
-
- new_smb_pwent.smb_userid = pwd->pw_uid;
- new_smb_pwent.smb_name = pwd->pw_name;
- new_smb_pwent.smb_passwd = NULL;
- new_smb_pwent.smb_nt_passwd = NULL;
- new_smb_pwent.acct_ctrl = (machine_account ? ACB_WSTRUST : ACB_NORMAL);
-
- if(disable_user) {
- new_smb_pwent.acct_ctrl |= ACB_DISABLED;
- } else if (set_no_password) {
- new_smb_pwent.acct_ctrl |= ACB_PWNOTREQ;
- } else {
- new_smb_pwent.smb_passwd = new_p16;
- new_smb_pwent.smb_nt_passwd = new_nt_p16;
+ int fd;
+ int new_entry_length;
+ char *new_entry;
+ long offpos;
+
+ /* The add user write needs to be atomic - so get the fd from
+ the fp and do a raw write() call.
+ */
+ fd = fileno(fp);
+
+ 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", prog_name, pwd->pw_name, pfile, strerror(errno));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ exit(1);
}
- if(add_sampwd_entry(&new_smb_pwent) == False) {
- fprintf(stderr, "%s: Failed to add entry for user %s.\n",
- prog_name, pwd->pw_name);
- endsampwent(vp);
+ new_entry_length = strlen(pwd->pw_name) + 1 + 15 + 1 +
+ 32 + 1 + 32 + 1 + strlen(pwd->pw_gecos) +
+ 1 + strlen(pwd->pw_dir) + 1 +
+ 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", prog_name, pwd->pw_name, pfile, strerror(errno));
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ exit(1);
+ }
+
+ sprintf(new_entry, "%s:%u:", pwd->pw_name, (unsigned)pwd->pw_uid);
+ p = &new_entry[strlen(new_entry)];
+ for( i = 0; i < 16; i++)
+ sprintf(&p[i*2], "%02X", new_p16[i]);
+ p += 32;
+ *p++ = ':';
+ for( i = 0; i < 16; i++)
+ sprintf(&p[i*2], "%02X", new_nt_p16[i]);
+ p += 32;
+ *p++ = ':';
+ sprintf(p, "%s:%s:%s\n", pwd->pw_gecos,
+ 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", prog_name, pwd->pw_name, pfile, strerror(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",
+ prog_name, pwd->pw_name, strerror(errno));
+ }
+ fclose(fp);
+ pw_file_unlock(lockfd);
exit(1);
}
- endsampwent(vp);
- printf("%s: Added user %s.\n", prog_name, user_name);
+ fclose(fp);
+ pw_file_unlock(lockfd);
exit(0);
}
} else {
@@ -701,44 +662,68 @@ int main(int argc, char **argv)
}
/*
- * We are root - just write the new password
- * and the valid last change time.
+ * We are root - just write the new password.
*/
- if(disable_user) {
- /*
- * This currently won't work as it means changing
- * the length of the record. JRA.
- */
- smb_pwent->acct_ctrl |= ACB_DISABLED;
- smb_pwent->smb_passwd = NULL;
- smb_pwent->smb_nt_passwd = NULL;
- } else if (set_no_password) {
- /*
- * This currently won't work as it means changing
- * the length of the record. JRA.
- */
- smb_pwent->acct_ctrl |= ACB_PWNOTREQ;
- smb_pwent->smb_passwd = NULL;
- smb_pwent->smb_nt_passwd = NULL;
- } else {
- smb_pwent->smb_passwd = new_p16;
- smb_pwent->smb_nt_passwd = new_nt_p16;
+ /* Create the 32 byte representation of the new p16 */
+ for (i = 0; i < 16; i++) {
+ sprintf(&ascii_p16[i * 2], "%02X", (uchar) new_p16[i]);
}
-
- if(mod_sampwd_entry(smb_pwent,True) == False) {
- fprintf(stderr, "%s: Failed to modify entry for user %s.\n",
- prog_name, pwd->pw_name);
- endsampwent(vp);
+ if(got_valid_nt_entry) {
+ /* Add on the NT md4 hash */
+ ascii_p16[32] = ':';
+ for (i = 0; i < 16; i++) {
+ sprintf(&ascii_p16[(i * 2)+33], "%02X", (uchar) new_nt_p16[i]);
+ }
+ }
+ /*
+ * Do an atomic write into the file at the position defined by
+ * seekpos.
+ */
+ pwfd = fileno(fp);
+ ret = lseek(pwfd, seekpos - 1, SEEK_SET);
+ if (ret != seekpos - 1) {
+ err = errno;
+ fprintf(stderr, "%s: seek fail on file %s.\n",
+ prog_name, pfile);
+ fclose(fp);
+ errno = err;
+ perror(prog_name);
+ pw_file_unlock(lockfd);
exit(1);
}
-
- endsampwent(vp);
- if(disable_user)
- printf("User %s disabled.\n", user_name);
- else if (set_no_password)
- printf("User %s - set to no password.\n", user_name);
- else
- printf("Password changed for user %s.\n", user_name);
+ /* Sanity check - ensure the character is a ':' */
+ if (read(pwfd, &c, 1) != 1) {
+ err = errno;
+ fprintf(stderr, "%s: read fail on file %s.\n",
+ prog_name, pfile);
+ fclose(fp);
+ errno = err;
+ perror(prog_name);
+ pw_file_unlock(lockfd);
+ exit(1);
+ }
+ if (c != ':') {
+ fprintf(stderr, "%s: sanity check on passwd file %s failed.\n",
+ prog_name, pfile);
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ exit(1);
+ }
+ writelen = (got_valid_nt_entry) ? 65 : 32;
+ if (write(pwfd, ascii_p16, writelen) != writelen) {
+ err = errno;
+ fprintf(stderr, "%s: write fail in file %s.\n",
+ prog_name, pfile);
+ fclose(fp);
+ errno = err;
+ perror(prog_name);
+ pw_file_unlock(lockfd);
+ exit(err);
+ }
+ fclose(fp);
+ pw_file_unlock(lockfd);
+ printf("Password changed\n");
return 0;
}
+
diff --git a/source/utils/status.c b/source/utils/status.c
index 40bafbe0c27..401dd25c895 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -120,7 +120,7 @@ static void print_share_mode(share_mode_entry *e, char *fname)
charset_initialise();
DEBUGLEVEL = 0;
- dbf = stderr;
+ dbf = fopen("/dev/null","w");
if (getuid() != geteuid()) {
printf("smbstatus should not be run setuid\n");
@@ -152,7 +152,7 @@ static void print_share_mode(share_mode_entry *e, char *fname)
get_myname(myhostname, NULL);
- if (!lp_load(servicesf,False,False,False)) {
+ if (!lp_load(servicesf,False)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
return (-1);
}
@@ -199,7 +199,6 @@ static void print_share_mode(share_mode_entry *e, char *fname)
{
if (fread(&crec,sizeof(crec),1,f) != 1)
break;
- if (crec.cnum == -1) continue;
if ( crec.magic == 0x280267 && process_exists(crec.pid)
&& Ucrit_checkUsername(uidtoname(crec.uid)) /* added by OH */
)
diff --git a/source/utils/testparm.c b/source/utils/testparm.c
index 83d4d7fbb5e..a35a3fd71e0 100644
--- a/source/utils/testparm.c
+++ b/source/utils/testparm.c
@@ -67,7 +67,7 @@ extern pstring myhostname;
return(1);
}
- if (!lp_load(configfile,False,True,False))
+ if (!lp_load(configfile,False))
{
printf("Error loading services.\n");
return(1);
@@ -89,7 +89,7 @@ extern pstring myhostname;
printf("Press enter to see a dump of your service definitions\n");
fflush(stdout);
getc(stdin);
- lp_dump(stdout,False);
+ lp_dump(stdout);
}
if (argc == 4)
diff --git a/source/utils/torture.c b/source/utils/torture.c
index ede801afe96..049a414eb94 100644
--- a/source/utils/torture.c
+++ b/source/utils/torture.c
@@ -32,12 +32,12 @@ static char *sockops="";
static struct timeval tp1,tp2;
-static void start_timer(void)
+static void start_timer()
{
gettimeofday(&tp1,NULL);
}
-static double end_timer(void)
+static double end_timer()
{
gettimeofday(&tp2,NULL);
return((tp2.tv_sec - tp1.tv_sec) +
@@ -116,8 +116,7 @@ static BOOL rw_torture(struct cli_state *c, int numops)
int fnum;
int fnum2;
int pid2, pid = getpid();
- int i, j;
- char buf[1024];
+ int i;
fnum2 = cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
DENY_NONE);
@@ -150,14 +149,6 @@ static BOOL rw_torture(struct cli_state *c, int numops)
printf("write failed (%s)\n", cli_errstr(c));
}
- for (j=0;j<50;j++) {
- if (cli_write(c, fnum, (char *)buf,
- sizeof(pid)+(j*sizeof(buf)),
- sizeof(buf)) != sizeof(buf)) {
- printf("write failed (%s)\n", cli_errstr(c));
- }
- }
-
pid2 = 0;
if (cli_read(c, fnum, (char *)&pid2, 0, sizeof(pid)) != sizeof(pid)) {
@@ -191,7 +182,7 @@ static BOOL rw_torture(struct cli_state *c, int numops)
static void usage(void)
{
- printf("Usage: smbtorture //server/share <options>\n");
+ printf("Usage: smbtorture \\\\server\\share <options>\n");
printf("\t-U user%%pass\n");
printf("\t-N numprocs\n");
@@ -841,16 +832,12 @@ static void create_procs(int nprocs, int numops)
usage();
}
- for(p = argv[1]; *p; p++)
- if(*p == '\\')
- *p = '/';
-
- if (strncmp(argv[1], "//", 2)) {
+ if (strncmp(argv[1], "\\\\", 2)) {
usage();
}
fstrcpy(host, &argv[1][2]);
- p = strchr(&host[2],'/');
+ p = strchr(&host[2],'\\');
if (!p) {
usage();
}
diff --git a/source/web/cgi.c b/source/web/cgi.c
index a1aa4d753dc..ae60d72b7b7 100644
--- a/source/web/cgi.c
+++ b/source/web/cgi.c
@@ -18,16 +18,16 @@
*/
-#include "includes.h"
-#include "smb.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pwd.h>
#define MAX_VARIABLES 10000
-/* set the expiry on fixed pages */
-#define EXPIRY_TIME (60*60*24*7)
-
-#define CGI_LOGGING 0
-
#ifdef DEBUG_COMMENTS
extern void print_title(char *fmt, ...);
#endif
@@ -43,8 +43,6 @@ static int content_length;
static int request_post;
static int request_get;
static char *query_string;
-static char *baseurl;
-static char *pathinfo;
static void unescape(char *buf)
{
@@ -460,6 +458,8 @@ handle a http authentication line
static int cgi_handle_authorization(char *line)
{
char *p, *user, *pass;
+ struct passwd *pwd;
+ int ret=0;
if (strncasecmp(line,"Basic ", 6)) {
cgi_setup_error("401 Bad Authorization", "",
@@ -477,13 +477,20 @@ static int cgi_handle_authorization(char *line)
pass = p+1;
/* currently only allow connections as root */
- if (strcmp(user,"root")) {
+ if (strcasecmp(user,"root")) {
cgi_setup_error("401 Bad Authorization", "",
"incorrect username/password");
}
+
+ pwd = getpwnam(user);
+ if (!strcmp((char *)crypt(pass, pwd->pw_passwd),pwd->pw_passwd)) {
+ ret = 1;
+ }
- return password_ok(user, pass, strlen(pass), NULL);
+ memset(pass, 0, strlen(pass));
+
+ return ret;
}
@@ -505,6 +512,11 @@ static void cgi_download(char *file)
}
}
+ if (strstr(file,"..")) {
+ cgi_setup_error("404 File Not Found","",
+ "Relative paths not allowed");
+ }
+
if (!file_exist(file, &st)) {
cgi_setup_error("404 File Not Found","",
"The requested file was not found");
@@ -516,16 +528,12 @@ static void cgi_download(char *file)
}
printf("HTTP/1.1 200 OK\r\n");
if ((p=strrchr(file,'.'))) {
- if (strcmp(p,".gif")==0) {
+ if (strcmp(p,".gif")==0 || strcmp(p,".jpg")==0) {
printf("Content-Type: image/gif\r\n");
- } else if (strcmp(p,".jpg")==0) {
- printf("Content-Type: image/jpeg\r\n");
} else {
printf("Content-Type: text/html\r\n");
}
}
- printf("Expires: %s\r\n", http_timestring(time(NULL)+EXPIRY_TIME));
-
printf("Content-Length: %d\r\n\r\n", (int)st.st_size);
while ((l=read(fd,buf,sizeof(buf)))>0) {
fwrite(buf, 1, l, stdout);
@@ -539,15 +547,12 @@ static void cgi_download(char *file)
setup the cgi framework, handling the possability that this program is either
run as a true cgi program by a web browser or is itself a mini web server
***************************************************************************/
-void cgi_setup(char *rootdir, int auth_required)
+void cgi_setup(char *rootdir)
{
int authenticated = 0;
char line[1024];
char *url=NULL;
char *p;
-#if CGI_LOGGING
- FILE *f;
-#endif
if (chdir(rootdir)) {
cgi_setup_error("400 Server Error", "",
@@ -559,19 +564,9 @@ void cgi_setup(char *rootdir, int auth_required)
return;
}
-#if CGI_LOGGING
- f = fopen("/tmp/cgi.log", "a");
- if (f) fprintf(f,"\n[Date: %s %s (%s)]\n",
- http_timestring(time(NULL)),
- client_name(1), client_addr(1));
-#endif
-
/* we are a mini-web server. We need to read the request from stdin
and handle authentication etc */
while (fgets(line, sizeof(line)-1, stdin)) {
-#if CGI_LOGGING
- if (f) fputs(line, f);
-#endif
if (line[0] == '\r' || line[0] == '\n') break;
if (strncasecmp(line,"GET ", 4)==0) {
request_get = 1;
@@ -589,11 +584,8 @@ void cgi_setup(char *rootdir, int auth_required)
}
/* ignore all other requests! */
}
-#if CGI_LOGGING
- if (f) fclose(f);
-#endif
- if (auth_required && !authenticated) {
+ if (!authenticated) {
cgi_setup_error("401 Authorization Required",
"WWW-Authenticate: Basic realm=\"root\"\r\n",
"You must be authenticated to use this service");
@@ -618,85 +610,12 @@ void cgi_setup(char *rootdir, int auth_required)
*p = 0;
}
- if (strstr(url+1,"..")==0 && file_exist(url+1, NULL)) {
+ if (strcmp(url,"/")) {
cgi_download(url+1);
}
printf("HTTP/1.1 200 OK\r\nConnection: close\r\n");
- printf("Date: %s\r\n", http_timestring(time(NULL)));
- baseurl = "";
- pathinfo = url+1;
-}
-
-
-/***************************************************************************
-return the current pages URL
- ***************************************************************************/
-char *cgi_baseurl(void)
-{
- if (baseurl) {
- return baseurl;
- }
- return getenv("SCRIPT_NAME");
-}
-
-/***************************************************************************
-return the root URL for images etc
- ***************************************************************************/
-char *cgi_rooturl(void)
-{
- if (baseurl) {
- return "/";
- }
- return "/swat/";
-}
-
-
-/***************************************************************************
-return the current pages path info
- ***************************************************************************/
-char *cgi_pathinfo(void)
-{
- char *r;
- if (pathinfo) {
- return pathinfo;
- }
- r = getenv("PATH_INFO");
- if (!r) return "";
- if (*r == '/') r++;
- return r;
-}
-
-/***************************************************************************
-return the hostname of the client
- ***************************************************************************/
-char *cgi_remote_host(void)
-{
- if (baseurl) {
- return client_name(1);
- }
- return getenv("REMOTE_HOST");
-}
-
-/***************************************************************************
-return the hostname of the client
- ***************************************************************************/
-char *cgi_remote_addr(void)
-{
- if (baseurl) {
- return client_addr(1);
- }
- return getenv("REMOTE_ADDR");
+
}
-/***************************************************************************
-return True if the request was a POST
- ***************************************************************************/
-BOOL cgi_waspost(void)
-{
- if (baseurl) {
- return request_post;
- }
- return strequal(getenv("REQUEST_METHOD"), "POST");
-}
diff --git a/source/web/diagnose.c b/source/web/diagnose.c
deleted file mode 100644
index 054de2a631d..00000000000
--- a/source/web/diagnose.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- diagnosis tools for web admin
- Copyright (C) Andrew Tridgell 1998
-
- 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"
-#include "smb.h"
-
-
-/* check to see if nmbd is running on localhost by looking for a __SAMBA__
- response */
-BOOL nmbd_running(void)
-{
- extern struct in_addr loopback_ip;
- int fd, count;
- struct in_addr *ip_list;
-
- if ((fd = open_socket_in(SOCK_DGRAM, 0, 3,
- interpret_addr("127.0.0.1"))) != -1) {
- if ((ip_list = name_query(fd, "__SAMBA__", 0,
- True, True, loopback_ip,
- &count,0)) != NULL) {
- free(ip_list);
- close(fd);
- return True;
- }
- close (fd);
- }
-
- return False;
-}
-
-
-/* check to see if smbd is running on localhost by trying to open a connection
- then closing it */
-BOOL smbd_running(void)
-{
- static struct cli_state cli;
- extern struct in_addr loopback_ip;
-
- if (!cli_initialise(&cli))
- return False;
-
- if (!cli_connect(&cli, "localhost", &loopback_ip)) {
- cli_shutdown(&cli);
- return False;
- }
-
- cli_shutdown(&cli);
- return True;
-}
diff --git a/source/web/startstop.c b/source/web/startstop.c
deleted file mode 100644
index 7ac66f21800..00000000000
--- a/source/web/startstop.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- start/stop nmbd and smbd
- Copyright (C) Andrew Tridgell 1998
-
- 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"
-#include "smb.h"
-
-/* need to wait for daemons to startup */
-#define SLEEP_TIME 3
-
-/* startup smbd */
-void start_smbd(void)
-{
- pstring binfile;
-
- if (geteuid() != 0) return;
-
- if (fork()) {
- sleep(SLEEP_TIME);
- return;
- }
-
- sprintf(binfile,"%s/smbd", SBINDIR);
-
- become_daemon();
-
- execl(binfile, binfile, "-D", NULL);
-
- exit(0);
-}
-
-/* startup nmbd */
-void start_nmbd(void)
-{
- pstring binfile;
-
- if (geteuid() != 0) return;
-
- if (fork()) {
- sleep(SLEEP_TIME);
- return;
- }
-
- sprintf(binfile,"%s/nmbd", SBINDIR);
-
- become_daemon();
-
- execl(binfile, binfile, "-D", NULL);
-
- exit(0);
-}
-
-
-/* stop smbd */
-void stop_smbd(void)
-{
- unsigned pid = pidfile_pid("smbd");
-
- if (geteuid() != 0) return;
-
- if (pid == 0) return;
-
- kill(pid, SIGTERM);
-}
-
-/* stop nmbd */
-void stop_nmbd(void)
-{
- unsigned pid = pidfile_pid("nmbd");
-
- if (geteuid() != 0) return;
-
- if (pid == 0) return;
-
- kill(pid, SIGTERM);
-}
-
-/* kill a specified process */
-void kill_pid(int pid)
-{
- if (geteuid() != 0) return;
-
- if (pid <= 0) return;
-
- kill(pid, SIGTERM);
- sleep(SLEEP_TIME);
-}
diff --git a/source/web/statuspage.c b/source/web/statuspage.c
deleted file mode 100644
index 9bcc99a6af1..00000000000
--- a/source/web/statuspage.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- web status page
- Copyright (C) Andrew Tridgell 1997-1998
-
- 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 *tstring(time_t t)
-{
- static pstring buf;
- pstrcpy(buf, asctime(LocalTime(&t)));
- string_sub(buf," ","&nbsp;");
- return buf;
-}
-
-static void print_share_mode(share_mode_entry *e, char *fname)
-{
- printf("<tr><td>%d</td>",e->pid);
- printf("<td>");
- switch ((e->share_mode>>4)&0xF) {
- case DENY_NONE: printf("DENY_NONE"); break;
- case DENY_ALL: printf("DENY_ALL "); break;
- case DENY_DOS: printf("DENY_DOS "); break;
- case DENY_READ: printf("DENY_READ "); break;
- case DENY_WRITE:printf("DENY_WRITE "); break;
- }
- printf("</td>");
-
- printf("<td>");
- switch (e->share_mode&0xF) {
- case 0: printf("RDONLY "); break;
- case 1: printf("WRONLY "); break;
- case 2: printf("RDWR "); break;
- }
- printf("</td>");
-
- printf("<td>");
- if((e->op_type &
- (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) ==
- (EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
- printf("EXCLUSIVE+BATCH ");
- else if (e->op_type & EXCLUSIVE_OPLOCK)
- printf("EXCLUSIVE ");
- else if (e->op_type & BATCH_OPLOCK)
- printf("BATCH ");
- else
- printf("NONE ");
- printf("</td>");
-
- printf("<td>%s</td><td>%s</td></tr>\n",
- fname,tstring(e->time.tv_sec));
-}
-
-
-/* show the current server status */
-void status_page(void)
-{
- struct connect_record crec;
- pstring fname;
- FILE *f;
- char *v;
- int autorefresh=0;
- int refresh_interval=30;
-
- if (cgi_variable("smbd_restart")) {
- if (smbd_running())
- stop_smbd();
- start_smbd();
- }
-
- if (cgi_variable("smbd_start")) {
- start_smbd();
- }
-
- if (cgi_variable("smbd_stop")) {
- stop_smbd();
- }
-
- if (cgi_variable("nmbd_restart")) {
- if (nmbd_running())
- stop_nmbd();
- start_nmbd();
- }
- if (cgi_variable("nmbd_start")) {
- start_nmbd();
- }
-
- if (cgi_variable("nmbd_stop")) {
- stop_nmbd();
- }
-
- if (cgi_variable("autorefresh")) {
- autorefresh = 1;
- } else if (cgi_variable("norefresh")) {
- autorefresh = 0;
- } else if (cgi_variable("refresh")) {
- autorefresh = 1;
- }
-
- if ((v=cgi_variable("refresh_interval"))) {
- refresh_interval = atoi(v);
- }
-
- pstrcpy(fname,lp_lockdir());
- standard_sub_basic(fname);
- trim_string(fname,"","/");
- strcat(fname,"/STATUS..LCK");
-
-
- f = fopen(fname,"r");
- if (f) {
- while (!feof(f)) {
- if (fread(&crec,sizeof(crec),1,f) != 1) break;
- if (crec.magic == 0x280267 && crec.cnum == -1 &&
- process_exists(crec.pid)) {
- char buf[30];
- sprintf(buf,"kill_%d", crec.pid);
- if (cgi_variable(buf)) {
- kill_pid(crec.pid);
- }
- }
- }
- fclose(f);
- }
-
- printf("<H2>Server Status</H2>\n");
-
- printf("<FORM method=post>\n");
-
- if (!autorefresh) {
- printf("<input type=submit value=\"Auto Refresh\" name=autorefresh>\n");
- printf("<br>Refresh Interval: ");
- printf("<input type=text size=2 name=\"refresh_interval\" value=%d>\n",
- refresh_interval);
- } else {
- printf("<input type=submit value=\"Stop Refreshing\" name=norefresh>\n");
- printf("<br>Refresh Interval: %d\n", refresh_interval);
- printf("<input type=hidden name=refresh value=1>\n");
- }
-
- printf("<p>\n");
-
- 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("<table>\n");
-
- printf("<tr><td>version:</td><td>%s</td></tr>",VERSION);
-
- fflush(stdout);
- if (smbd_running()) {
- printf("<tr><td>smbd:</td><td>running</td><td><input type=submit name=\"smbd_stop\" value=\"Stop smbd\"></td><td><input type=submit name=\"smbd_restart\" value=\"Restart smbd\"></td></tr>\n");
- } else {
- printf("<tr><td>smbd:</td><td>not running</td><td><input type=submit name=\"smbd_start\" value=\"Start smbd\"></td>><td><input type=submit name=\"smbd_restart\" value=\"Restart smbd\"></td></tr>\n");
- }
-
- fflush(stdout);
- if (nmbd_running()) {
- printf("<tr><td>nmbd:</td><td>running</td><td><input type=submit name=\"nmbd_stop\" value=\"Stop nmbd\"></td><td><input type=submit name=\"nmbd_restart\" value=\"Restart nmbd\"></td></tr>\n");
- } else {
- printf("<tr><td>nmbd:</td><td>not running</td><td><input type=submit name=\"nmbd_start\" value=\"Start nmbd\"></td><td><input type=submit name=\"nmbd_restart\" value=\"Restart nmbd\"></td></tr>\n");
- }
-
- printf("</table>\n");
- fflush(stdout);
-
-
- if (geteuid() != 0)
- printf("<b>NOTE: You are not logged in as root and won't be able to start/stop the server</b><p>\n");
-
- printf("<p><h3>Active Connections</h3>\n");
- printf("<table border=1>\n");
- printf("<tr><th>PID</th><th>Client</th><th>IP address</th><th>Date</th><th>Kill</th></tr>\n");
-
- while (!feof(f)) {
- if (fread(&crec,sizeof(crec),1,f) != 1)
- break;
- if (crec.magic == 0x280267 &&
- crec.cnum == -1 &&
- process_exists(crec.pid)) {
- printf("<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td><input type=submit value=\"X\" name=\"kill_%d\"></td></tr>\n",
- crec.pid,
- crec.machine,crec.addr,
- tstring(crec.start),
- crec.pid);
- }
- }
-
- printf("</table><p>\n");
-
- fseek(f, 0, SEEK_SET);
-
- printf("<p><h3>Active Shares</h3>\n");
- printf("<table border=1>\n");
- printf("<tr><th>Share</th><th>User</th><th>Group</th><th>PID</th><th>Client</th><th>Date</th></tr>\n\n");
-
- while (!feof(f)) {
- if (fread(&crec,sizeof(crec),1,f) != 1)
- break;
- if (crec.cnum == -1) continue;
- if (crec.magic == 0x280267 && process_exists(crec.pid)) {
- printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td></tr>\n",
- crec.name,uidtoname(crec.uid),
- gidtoname(crec.gid),crec.pid,
- crec.machine,
- tstring(crec.start));
- }
- }
-
- printf("</table><p>\n");
-
- printf("<h3>Open Files</h3>\n");
- printf("<table border=1>\n");
- printf("<tr><th>PID</th><th>Sharing</th><th>R/W</th><th>Oplock</th><th>File</th><th>Date</th></tr>\n");
-
- locking_init(1);
- share_mode_forall(print_share_mode);
- locking_end();
- printf("</table>\n");
-
- fclose(f);
-
- printf("</FORM>\n");
-
- if (autorefresh) {
- /* this little JavaScript allows for automatic refresh
- of the page. There are other methods but this seems
- to be the best alternative */
- printf("<script language=\"JavaScript\">\n");
- printf("<!--\nsetTimeout('window.location.replace(\"%s/status?refresh_interval=%d&refresh=1\")', %d)\n",
- cgi_baseurl(),
- refresh_interval,
- refresh_interval*1000);
- printf("//-->\n</script>\n");
- }
-}
-
diff --git a/source/web/swat.c b/source/web/swat.c
deleted file mode 100644
index 78c1fa4f198..00000000000
--- a/source/web/swat.c
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- Samba Web Administration Tool
- Copyright (C) Andrew Tridgell 1997-1998
-
- 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 GLOBALS_SNUM -1
-
-static pstring servicesf = CONFIGFILE;
-
-
-/* we need these because we link to locking*.o */
- void become_root(BOOL save_dir) {}
- void unbecome_root(BOOL restore_dir) {}
-/* We need this because we link to password.o */
-BOOL change_oem_password(struct smb_passwd *smbpw, char *new_passwd, BOOL override) {return False;}
-connection_struct Connections[MAX_CONNECTIONS];
-files_struct Files[MAX_OPEN_FILES];
-struct current_user current_user;
-
-static int enum_index(int value, struct enum_list *enumlist)
-{
-int i;
- for (i=0;enumlist[i].name;i++)
- if (value == enumlist[i].value) break;
- return(i);
-}
-
-static char *fix_backslash(char *str)
-{
-static char newstring[1024];
-char *p = newstring;
-
- *p = '\0';
- while (*str) {
- if (*str == '\\') {*p++ = '\\';*p++ = '\\';}
- else *p++ = *str;
- ++str;
- *p = '\0';
- }
- return newstring;
-}
-
-static char *make_parm_name(char *label)
-{
-static char parmname[1024];
-char *p = parmname;
-
- while (*label) {
- if (*label == ' ') *p++ = '_';
- else *p++ = *label;
- ++label;
- *p = '\0';
- }
- return parmname;
-}
-
-/* start the page with standard stuff */
-static void print_header(void)
-{
- if (!cgi_waspost()) {
- printf("Expires: 0\r\n");
- }
- printf("Content-type: text/html\r\n\r\n");
- printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n");
- printf("<HTML>\n<HEAD>\n<TITLE>Samba Web Administration Tool</TITLE>\n</HEAD>\n<BODY background=\"%simages/background.jpg\">\n\n", cgi_rooturl());
-}
-
-
-/* finish off the page */
-static void print_footer(void)
-{
- printf("\n</BODY>\n</HTML>\n");
-}
-
-/* include a lump of html in a page */
-static void include_html(char *fname)
-{
- FILE *f = fopen(fname,"r");
- char buf[1024];
- int ret;
-
- if (!f) {
- printf("ERROR: Can't open %s\n", fname);
- return;
- }
-
- while (!feof(f)) {
- ret = fread(buf, 1, sizeof(buf), f);
- if (ret <= 0) break;
- fwrite(buf, 1, ret, stdout);
- }
-
- fclose(f);
-}
-
-
-/* display one editable parameter in a form */
-static void show_parameter(int snum, struct parm_struct *parm)
-{
- int i;
- void *ptr = parm->ptr;
-
- if (parm->class == P_LOCAL && snum >= 0) {
- ptr = lp_local_ptr(snum, ptr);
- }
-
- printf("<tr><td><A HREF=\"%shelp/parameters.html#%s\">?</A> %s</td><td>",
- cgi_rooturl(), parm->label, parm->label);
-
- switch (parm->type) {
- case P_CHAR:
- printf("<input type=text size=2 name=\"parm_%s\" value=\"%c\">",
- make_parm_name(parm->label), *(char *)ptr);
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%c\'\">",
- make_parm_name(parm->label),(char)(parm->def.cvalue));
- break;
-
- case P_STRING:
- case P_USTRING:
- printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">",
- make_parm_name(parm->label), *(char **)ptr);
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%s\'\">",
- make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue)));
- break;
-
- case P_GSTRING:
- case P_UGSTRING:
- printf("<input type=text size=40 name=\"parm_%s\" value=\"%s\">",
- make_parm_name(parm->label), (char *)ptr);
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%s\'\">",
- make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue)));
- break;
-
- case P_BOOL:
- printf("<select name=\"parm_%s\">",make_parm_name(parm->label));
- printf("<option %s>Yes", (*(BOOL *)ptr)?"selected":"");
- printf("<option %s>No", (*(BOOL *)ptr)?"":"selected");
- printf("</select>");
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">",
- make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?0:1);
- break;
-
- case P_BOOLREV:
- printf("<select name=\"parm_%s\">",make_parm_name(parm->label));
- printf("<option %s>Yes", (*(BOOL *)ptr)?"":"selected");
- printf("<option %s>No", (*(BOOL *)ptr)?"selected":"");
- printf("</select>");
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">",
- make_parm_name(parm->label),(BOOL)(parm->def.bvalue)?1:0);
- break;
-
- case P_INTEGER:
- printf("<input type=text size=8 name=\"parm_%s\" value=%d>", make_parm_name(parm->label), *(int *)ptr);
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'%d\'\">",
- make_parm_name(parm->label),(int)(parm->def.ivalue));
- break;
-
- case P_OCTAL:
- printf("<input type=text size=8 name=\"parm_%s\" value=0%o>", make_parm_name(parm->label), *(int *)ptr);
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.value=\'0%o\'\">",
- make_parm_name(parm->label),(int)(parm->def.ivalue));
- break;
-
- case P_ENUM:
- printf("<select name=\"parm_%s\">",make_parm_name(parm->label));
- for (i=0;parm->enum_list[i].name;i++)
- printf("<option %s>%s",(*(int *)ptr)==parm->enum_list[i].value?"selected":"",parm->enum_list[i].name);
- printf("</select>");
- printf("<input type=button value=\"Set Default\" onClick=\"swatform.parm_%s.selectedIndex=\'%d\'\">",
- make_parm_name(parm->label),enum_index((int)(parm->def.ivalue),parm->enum_list));
- break;
- case P_SEP:
- break;
- }
- printf("</td></tr>\n");
-}
-
-/* display a set of parameters for a service */
-static void show_parameters(int snum, int allparameters, int advanced, int printers)
-{
- int i = 0;
- struct parm_struct *parm;
- char *heading = NULL;
- char *last_heading = NULL;
-
- while ((parm = lp_next_parameter(snum, &i, allparameters))) {
- if (snum < 0 && parm->class == P_LOCAL && !(parm->flags & FLAG_GLOBAL))
- continue;
- if (parm->class == P_SEPARATOR) {
- heading = parm->label;
- continue;
- }
- if (parm->flags & FLAG_HIDE) continue;
- if (!advanced) {
- if (!printers && !(parm->flags & FLAG_BASIC)) {
- void *ptr = parm->ptr;
-
- switch (parm->type) {
- case P_CHAR:
- if (*(char *)ptr == (char)(parm->def.cvalue)) continue;
- break;
-
- case P_STRING:
- case P_USTRING:
- if (!strcmp(*(char **)ptr,(char *)(parm->def.svalue))) continue;
- break;
-
- case P_GSTRING:
- case P_UGSTRING:
- if (!strcmp((char *)ptr,(char *)(parm->def.svalue))) continue;
- break;
-
- case P_BOOL:
- case P_BOOLREV:
- if (*(BOOL *)ptr == (BOOL)(parm->def.bvalue)) continue;
- break;
-
- case P_INTEGER:
- case P_OCTAL:
- if (*(int *)ptr == (int)(parm->def.ivalue)) continue;
- break;
-
-
- case P_ENUM:
- if (*(int *)ptr == (int)(parm->def.ivalue)) continue;
- break;
- case P_SEP:
- continue;
- }
- }
- if (printers && !(parm->flags & FLAG_PRINT)) continue;
- }
- if (heading && heading != last_heading) {
- printf("<tr><td></td></tr><tr><td><b><u>%s</u></b></td></tr>\n", heading);
- last_heading = heading;
- }
- show_parameter(snum, parm);
- }
-}
-
-
-/* write a config file */
-static void write_config(FILE *f, BOOL show_defaults)
-{
- fprintf(f, "# Samba config file created using SWAT\n");
- fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr());
- fprintf(f, "# Date: %s\n\n", timestring());
-
- lp_dump(f, show_defaults);
-}
-
-
-/* save and reoad the smb.conf config file */
-static int save_reload(void)
-{
- FILE *f;
-
- f = fopen(servicesf,"w");
- if (!f) {
- printf("failed to open %s for writing\n", servicesf);
- return 0;
- }
-
- write_config(f, False);
- fclose(f);
-
- lp_killunused(NULL);
-
- if (!lp_load(servicesf,False,False,False)) {
- printf("Can't reload %s\n", servicesf);
- return 0;
- }
-
- return 1;
-}
-
-
-
-/* commit one parameter */
-static void commit_parameter(int snum, struct parm_struct *parm, char *v)
-{
- int i;
- char *s;
-
- if (snum < 0 && parm->class == P_LOCAL) {
- /* this handles the case where we are changing a local
- variable globally. We need to change the parameter in
- all shares where it is currently set to the default */
- for (i=0;i<lp_numservices();i++) {
- s = lp_servicename(i);
- if (s && (*s) && lp_is_default(i, parm)) {
- lp_do_parameter(i, parm->label, v);
- }
- }
- }
-
- lp_do_parameter(snum, parm->label, v);
-}
-
-/* commit a set of parameters for a service */
-static void commit_parameters(int snum)
-{
- int i = 0;
- struct parm_struct *parm;
- pstring label;
- char *v;
-
- while ((parm = lp_next_parameter(snum, &i, 1))) {
- slprintf(label, sizeof(label)-1, "parm_%s", make_parm_name(parm->label));
- if ((v = cgi_variable(label))) {
- if (parm->flags & FLAG_HIDE) continue;
- commit_parameter(snum, parm, v);
- }
- }
-}
-
-
-/* load the smb.conf file into loadparm. */
-static void load_config(void)
-{
- if (!lp_load(servicesf,False,True,False)) {
- printf("<b>Can't load %s - using defaults</b><p>\n",
- servicesf);
- }
-}
-
-/* spit out the html for a link with an image */
-static void image_link(char *name,char *hlink, char *src, int width, int height)
-{
- printf("<A HREF=\"%s/%s\"><img width=%d height=%d src=\"%s%s\" alt=\"%s\"></A>\n",
- cgi_baseurl(),
- hlink, width, height,
- cgi_rooturl(),
- src, name);
-}
-
-/* display the main navigation controls at the top of each page along
- with a title */
-static void show_main_buttons(void)
-{
- printf("<H2 align=center>Samba Web Administration Tool</H2>\n");
-
- image_link("Home", "", "images/home.gif", 50, 50);
- image_link("Globals", "globals", "images/globals.gif", 50, 50);
- image_link("Shares", "shares", "images/shares.gif", 50, 50);
- image_link("Printers", "printers", "images/printers.gif", 50, 50);
- image_link("Status", "status", "images/status.gif", 50, 50);
- image_link("View Config", "viewconfig", "images/viewconfig.gif", 50, 50);
-
- printf("<HR>\n");
-}
-
-/* display a welcome page */
-static void welcome_page(void)
-{
- include_html("help/welcome.html");
-}
-
-
-/* display the current smb.conf */
-static void viewconfig_page(void)
-{
- int full_view=0;
-
- if (cgi_variable("full_view")) {
- full_view = 1;
- }
-
- printf("<H2>Current Config</H2>\n");
- printf("<form method=post>\n");
-
- if (full_view) {
- printf("<input type=submit name=\"normal_view\" value=\"Normal View\">\n");
- } else {
- printf("<input type=submit name=\"full_view\" value=\"Full View\">\n");
- }
-
- printf("<p><pre>");
- write_config(stdout, full_view);
- printf("</pre>");
- printf("</form>\n");
-}
-
-
-/* display a globals editing page */
-static void globals_page(void)
-{
- int advanced = 0;
-
- printf("<H2>Global Variables</H2>\n");
-
- if (cgi_variable("Advanced") && !cgi_variable("Basic"))
- advanced = 1;
-
- if (cgi_variable("Commit")) {
- commit_parameters(GLOBALS_SNUM);
- save_reload();
- }
-
- printf("<FORM name=\"swatform\" method=post>\n");
-
- printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n");
- printf("<input type=reset name=\"Reset Values\" value=\"Reset Values\">\n");
- if (advanced == 0) {
- printf("<input type=submit name=\"Advanced\" value=\"Advanced View\">\n");
- } else {
- printf("<input type=submit name=\"Basic\" value=\"Basic View\">\n");
- }
- printf("<p>\n");
-
- printf("<table>\n");
- show_parameters(GLOBALS_SNUM, 1, advanced, 0);
- printf("</table>\n");
-
- if (advanced) {
- printf("<input type=hidden name=\"Advanced\" value=1>\n");
- }
-
- printf("</FORM>\n");
-}
-
-/* display a shares editing page */
-static void shares_page(void)
-{
- char *share = cgi_variable("share");
- char *s;
- int snum=-1;
- int i;
- int advanced = 0;
-
- if (share)
- snum = lp_servicenumber(share);
-
- printf("<H2>Share Parameters</H2>\n");
-
- if (cgi_variable("Advanced") && !cgi_variable("Basic"))
- advanced = 1;
-
- if (cgi_variable("Commit") && snum >= 0) {
- commit_parameters(snum);
- save_reload();
- }
-
- if (cgi_variable("Delete") && snum >= 0) {
- lp_remove_service(snum);
- save_reload();
- share = NULL;
- snum = -1;
- }
-
- if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) {
- lp_copy_service(GLOBALS_SNUM, share);
- save_reload();
- snum = lp_servicenumber(share);
- }
-
- printf("<FORM name=\"swatform\" method=post>\n");
-
- printf("<table>\n");
- printf("<tr><td><input type=submit name=selectshare value=\"Choose Share\"></td>\n");
- printf("<td><select name=share>\n");
- if (snum < 0)
- printf("<option value=\" \"> \n");
- for (i=0;i<lp_numservices();i++) {
- s = lp_servicename(i);
- if (s && (*s) && strcmp(s,"IPC$") && !lp_print_ok(i)) {
- printf("<option %s value=\"%s\">%s\n",
- (share && strcmp(share,s)==0)?"SELECTED":"",
- s, s);
- }
- }
- printf("</select></td></tr><p>");
-
- printf("<tr><td><input type=submit name=createshare value=\"Create Share\"></td>\n");
- printf("<td><input type=text size=30 name=newshare></td></tr>\n");
- printf("</table>");
-
-
- if (snum >= 0) {
- printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n");
- printf("<input type=submit name=\"Delete\" value=\"Delete Share\">\n");
- if (advanced == 0) {
- printf("<input type=submit name=\"Advanced\" value=\"Advanced View\">\n");
- } else {
- printf("<input type=submit name=\"Basic\" value=\"Basic View\">\n");
- }
- printf("<p>\n");
- }
-
- if (snum >= 0) {
- printf("<table>\n");
- show_parameters(snum, 1, advanced, 0);
- printf("</table>\n");
- }
-
- if (advanced) {
- printf("<input type=hidden name=\"Advanced\" value=1>\n");
- }
-
- printf("</FORM>\n");
-}
-
-
-/* display a printers editing page */
-static void printers_page(void)
-{
- char *share = cgi_variable("share");
- char *s;
- int snum=-1;
- int i;
- int advanced = 0;
-
- if (share)
- snum = lp_servicenumber(share);
-
- printf("<H2>Printer Parameters</H2>\n");
-
- if (cgi_variable("Advanced") && !cgi_variable("Basic"))
- advanced = 1;
-
- if (cgi_variable("Commit") && snum >= 0) {
- commit_parameters(snum);
- save_reload();
- }
-
- if (cgi_variable("Delete") && snum >= 0) {
- lp_remove_service(snum);
- save_reload();
- share = NULL;
- snum = -1;
- }
-
- if (cgi_variable("createshare") && (share=cgi_variable("newshare"))) {
- lp_copy_service(GLOBALS_SNUM, share);
- snum = lp_servicenumber(share);
- lp_do_parameter(snum, "print ok", "Yes");
- save_reload();
- snum = lp_servicenumber(share);
- }
-
- printf("<FORM name=\"swatform\" method=post>\n");
-
- printf("<table>\n");
- printf("<tr><td><input type=submit name=selectshare value=\"Choose Printer\"></td>\n");
- printf("<td><select name=share>\n");
- if (snum < 0 || !lp_print_ok(snum))
- printf("<option value=\" \"> \n");
- for (i=0;i<lp_numservices();i++) {
- s = lp_servicename(i);
- if (s && (*s) && strcmp(s,"IPC$") && lp_print_ok(i)) {
- printf("<option %s value=\"%s\">%s\n",
- (share && strcmp(share,s)==0)?"SELECTED":"",
- s, s);
- }
- }
- printf("</select></td></tr><p>");
-
- printf("<tr><td><input type=submit name=createshare value=\"Create Printer\"></td>\n");
- printf("<td><input type=text size=30 name=newshare></td></tr>\n");
- printf("</table>");
-
-
- if (snum >= 0) {
- printf("<input type=submit name=\"Commit\" value=\"Commit Changes\">\n");
- printf("<input type=submit name=\"Delete\" value=\"Delete Printer\">\n");
- if (advanced == 0) {
- printf("<input type=submit name=\"Advanced\" value=\"Advanced View\">\n");
- } else {
- printf("<input type=submit name=\"Basic\" value=\"Basic View\">\n");
- }
- printf("<p>\n");
- }
-
- if (snum >= 0) {
- printf("<table>\n");
- show_parameters(snum, 1, advanced, 1);
- printf("</table>\n");
- }
-
- if (advanced) {
- printf("<input type=hidden name=\"Advanced\" value=1>\n");
- }
-
- printf("</FORM>\n");
-}
-
-
-
-int main(int argc, char *argv[])
-{
- extern char *optarg;
- extern int optind;
- extern FILE *dbf;
- int opt;
- char *page;
- int auth_required = 1;
-
- /* just in case it goes wild ... */
- alarm(300);
-
- dbf = fopen("/dev/null", "w");
-
- if (!dbf) dbf = stderr;
-
- while ((opt = getopt(argc, argv,"s:a")) != EOF) {
- switch (opt) {
- case 's':
- pstrcpy(servicesf,optarg);
- break;
- case 'a':
- auth_required = 0;
- break;
- }
- }
-
- cgi_setup(SWATDIR, auth_required);
-
- print_header();
-
- charset_initialise();
-
- /* if this binary is setuid then run completely as root */
- setuid(0);
-
- load_config();
-
- cgi_load_variables(NULL);
-
- show_main_buttons();
-
- page = cgi_pathinfo();
-
- if (strcmp(page, "globals")==0) {
- globals_page();
- } else if (strcmp(page,"shares")==0) {
- shares_page();
- } else if (strcmp(page,"printers")==0) {
- printers_page();
- } else if (strcmp(page,"status")==0) {
- status_page();
- } else if (strcmp(page,"viewconfig")==0) {
- viewconfig_page();
- } else {
- welcome_page();
- }
-
- print_footer();
- return 0;
-}
-
-
diff --git a/source/wsmbconf.c b/source/wsmbconf.c
new file mode 100644
index 00000000000..566b899c8fa
--- /dev/null
+++ b/source/wsmbconf.c
@@ -0,0 +1,238 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ html smb.conf editing - prototype only
+ Copyright (C) Andrew Tridgell 1997-1998
+
+ 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
+
+static pstring servicesf = CONFIGFILE;
+
+
+/* start the page with standard stuff */
+static void print_header(void)
+{
+ printf("Content-type: text/html\r\n\r\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");
+}
+
+/* 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. */
+static int load_config(void)
+{
+ setuid(0);
+ if (!lp_load(servicesf,False)) {
+ printf("<b>Can't load %s - using defaults</b><p>\n",
+ servicesf);
+ }
+ return 1;
+}
+
+
+static int save_reload(void)
+{
+ FILE *f;
+
+ f = fopen(servicesf,"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(servicesf,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 char *optarg;
+ extern int optind;
+ extern FILE *dbf;
+ int opt;
+
+ dbf = fopen("/dev/null", "w");
+
+ if (!dbf) dbf = stderr;
+
+ cgi_setup(WEB_ROOT);
+
+
+ while ((opt = getopt(argc, argv,"s:")) != EOF) {
+ switch (opt) {
+ case 's':
+ pstrcpy(servicesf,optarg);
+ break;
+ }
+ }
+
+
+ print_header();
+
+ charset_initialise();
+
+ if (load_config()) {
+ cgi_load_variables(NULL);
+ process_requests();
+ show_services();
+ }
+ print_footer();
+ return 0;
+}
diff --git a/source/wsmbstatus.c b/source/wsmbstatus.c
new file mode 100644
index 00000000000..60c35357b21
--- /dev/null
+++ b/source/wsmbstatus.c
@@ -0,0 +1,93 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ html status reporting
+ Copyright (C) Andrew Tridgell 1997-1998
+
+ 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(!get_myname(myhostname,NULL))
+ {
+ printf("Failed to get my hostname.\n");
+ return;
+ }
+
+ 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;
+}