mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
2nd phase of head branch sync with SAMBA_2_0 - this delets all the files that were in the head branch but weren't in SAMBA_2_0
(This used to be commit d7b2087865
)
This commit is contained in:
parent
3db52feb1f
commit
32a965e09c
@ -1,9 +0,0 @@
|
||||
!==
|
||||
!== VFS.txt
|
||||
!==
|
||||
Contributor: Tim Potter
|
||||
Updated: April 5, 1999
|
||||
|
||||
Subject: Implementing a virtual filesystem for Samba
|
||||
===========================================================
|
||||
|
@ -1,147 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<html><head><title>LDAP Support in Samba</title>
|
||||
|
||||
<link rev="made" href="mailto:samba-bugs@samba.org">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<hr>
|
||||
|
||||
<h1>LDAP Support in Samba</h1>
|
||||
<h2>Matthew Chapman</h2>
|
||||
<h2>29th November 1998
|
||||
<p> <hr> <h2>
|
||||
WARNING: This is experimental code. Use at your own risk, and please report
|
||||
any bugs (after reading BUGS.txt).
|
||||
</h2> <br>
|
||||
</h2>
|
||||
|
||||
|
||||
<a href="LDAP.html#l1"><h2>1: What is LDAP?</h2> </a>
|
||||
<a href="LDAP.html#l2"><h2>2: Why LDAP and Samba?</h2> </a>
|
||||
<a href="LDAP.html#l3"><h2>3: Using LDAP with Samba</h2> </a>
|
||||
<a href="LDAP.html#l4"><h2>4: Using LDAP for Unix authentication</h2> </a>
|
||||
<a href="LDAP.html#l5"><h2>5: Compatibility with Active Directory</h2> </a>
|
||||
|
||||
<p><hr><p><br>
|
||||
<p>
|
||||
<a name="l1"></a>
|
||||
<h2>1: What is LDAP?</h2>
|
||||
A directory is a type of hierarchical database optimised for simple query
|
||||
operations, often used for storing user information. LDAP is the
|
||||
Lightweight Directory Access Protocol, a protocol which is rapidly
|
||||
becoming the Internet standard for accessing directories.<p>
|
||||
Many client applications now support LDAP (including Microsoft's Active
|
||||
Directory), and there are a number of servers available. The most popular
|
||||
implementation for Unix is from the <em>University of Michigan</em>; its
|
||||
homepage is at <a href="http://www.umich.edu/~dirsvcs/ldap/"><code>http://www.umich.edu/~dirsvcs/ldap/</code></a>.<p>
|
||||
Information in an LDAP tree always comes in <code>attribute=value</code> pairs.
|
||||
The following is an example of a Samba user entry:<p>
|
||||
<pre>
|
||||
uid=jbloggs, dc=samba, dc=org
|
||||
objectclass=sambaAccount
|
||||
uid=jbloggs
|
||||
cn=Joe Bloggs
|
||||
description=Samba User
|
||||
uidNumber=500
|
||||
gidNumber=500
|
||||
rid=2000
|
||||
grouprid=2001
|
||||
lmPassword=46E389809F8D55BB78A48108148AD508
|
||||
ntPassword=1944CCE1AD6F80D8AEC9FC5BE77696F4
|
||||
pwdLastSet=35C11F1B
|
||||
smbHome=\\samba1\jbloggs
|
||||
homeDrive=Z
|
||||
script=logon.bat
|
||||
profile=\\samba1\jbloggs\profile
|
||||
workstations=JOE
|
||||
</pre>
|
||||
<p>
|
||||
Note that the top line is a special set of attributes called a
|
||||
<em>distinguished name</em> which identifies the location of this entry beneath
|
||||
the directory's root node. Recent Internet standards suggest the use of
|
||||
domain-based naming using <code>dc</code> attributes (for instance, a microsoft.com
|
||||
directory should have a root node of <code>dc=microsoft, dc=com</code>), although
|
||||
this is not strictly necessary for isolated servers.<p>
|
||||
There are a number of LDAP-related FAQ's on the internet, although
|
||||
generally the best source of information is the documentation for the
|
||||
individual servers.<p>
|
||||
<br>
|
||||
<a name="l2"></a>
|
||||
<h2>2: Why LDAP and Samba?</h2><p>
|
||||
Using an LDAP directory allows Samba to store user and group information
|
||||
more reliably and flexibly than the current combination of smbpasswd,
|
||||
smbgroup, groupdb and aliasdb with the Unix databases. If a need emerges
|
||||
for extra user information to be stored, this can easily be added without
|
||||
loss of backwards compatibility.<p>
|
||||
In addition, the Samba LDAP schema is compatible with RFC2307, allowing
|
||||
Unix password database information to be stored in the same entries. This
|
||||
provides a single, consistent repository for both Unix and Windows user
|
||||
information.<p>
|
||||
<br>
|
||||
<a name="l3"></a>
|
||||
<h2>3: Using LDAP with Samba</h2><p>
|
||||
<ol><p>
|
||||
<li> Install and configure an LDAP server if you do not already have
|
||||
one. You should read your LDAP server's documentation and set up the
|
||||
configuration file and access control as desired.<p>
|
||||
<li> Build Samba (latest CVS is required) with:<p>
|
||||
<pre>
|
||||
./configure --with-ldap
|
||||
make clean; make install
|
||||
</pre>
|
||||
<p>
|
||||
<li> Add the following options to the global section of <code>smb.conf</code> as
|
||||
required.<p>
|
||||
<ul>
|
||||
<li><strong>ldap suffix</strong><p>
|
||||
This parameter specifies the node of the LDAP tree beneath which
|
||||
Samba should store its information. This parameter MUST be provided
|
||||
when using LDAP with Samba.<p>
|
||||
<strong>Default:</strong> <code>none</code><p>
|
||||
<strong>Example:</strong> <code>ldap suffix = "dc=mydomain, dc=org"</code><p>
|
||||
<li><strong>ldap bind as</strong><p>
|
||||
This parameter specifies the entity to bind to an LDAP directory as.
|
||||
Usually it should be safe to use the LDAP root account; for larger
|
||||
installations it may be preferable to restrict Samba's access.<p>
|
||||
<strong>Default:</strong> <code>none (bind anonymously)</code><p>
|
||||
<strong>Example:</strong> <code>ldap bind as = "uid=root, dc=mydomain, dc=org"</code><p>
|
||||
<li><strong>ldap passwd file</strong><p>
|
||||
This parameter specifies a file containing the password with which
|
||||
Samba should bind to an LDAP server. For obvious security reasons
|
||||
this file must be set to mode 700 or less.<p>
|
||||
<strong>Default:</strong> <code>none (bind anonymously)</code><p>
|
||||
<strong>Example:</strong> <code>ldap passwd file = /usr/local/samba/private/ldappasswd</code><p>
|
||||
<li><strong>ldap server</strong><p>
|
||||
This parameter specifies the DNS name of the LDAP server to use
|
||||
when storing and retrieving information about Samba users and
|
||||
groups.<p>
|
||||
<strong>Default:</strong> <code>ldap server = localhost</code><p>
|
||||
<li><strong>ldap port</strong><p>
|
||||
This parameter specifies the TCP port number of the LDAP server.<p>
|
||||
<strong>Default:</strong> <code>ldap port = 389</code><p>
|
||||
</ul><p>
|
||||
<li> You should then be able to use the normal smbpasswd(8) command for
|
||||
account administration (or User Manager in the near future).<p>
|
||||
</ol><p>
|
||||
<br>
|
||||
<a name="l4"></a>
|
||||
<h2>4: Using LDAP for Unix authentication</h2><p>
|
||||
The Samba LDAP code was designed to utilise RFC2307-compliant directory
|
||||
entries if available. RFC2307 is a proposed standard for LDAP user
|
||||
information which has been adopted by a number of vendors. Further
|
||||
information is available at <a href="http://www.xedoc.com.au/~lukeh/ldap"><code>http://www.xedoc.com.au/~lukeh/ldap/</code></a>.<p>
|
||||
Of particular interest is Luke Howard's nameservice switch module
|
||||
(nss_ldap) and PAM module (pam_ldap) implementing this standard, providing
|
||||
LDAP-based password databases for Unix. If you are setting up a server to
|
||||
provide integrated Unix/NT services than these are worth investigating.<p>
|
||||
<br>
|
||||
<a name="l5"></a>
|
||||
<h2>5: Compatibility with Active Directory</h2><p>
|
||||
The current implementation is not designed to be used with Microsoft
|
||||
Active Directory, although compatibility may be added in the future.<p>
|
||||
</body>
|
||||
</html>
|
@ -1,68 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html><head><title>debug2html(1)</title>
|
||||
|
||||
<link rev="made" href="mailto:samba-bugs@samba.org">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<hr>
|
||||
|
||||
<h1>debug2html(1)</h1>
|
||||
<h2>Samba</h2>
|
||||
<h2>29 Dec 1998</h2>
|
||||
|
||||
|
||||
|
||||
|
||||
<p><br><a name="NAME"></a>
|
||||
<h2>NAME</h2>
|
||||
debug2html - Samba DEBUG to HTML translation filter
|
||||
<p><br><a name="SYNOPSIS"></a>
|
||||
<h2>SYNOPSIS</h2>
|
||||
|
||||
<p><br>debug2html [input-file [output-file]]
|
||||
<p><br><a name="DESCRIPTION"></a>
|
||||
<h2>DESCRIPTION</h2>
|
||||
|
||||
<p><br>This program is part of the <strong>Samba</strong> suite.
|
||||
<p><br><strong>debug2html</strong> generates HTML files from Samba log files. Log files
|
||||
produced by <strong>nmbd</strong>(8) or <strong>smbd</strong>(8) may then be viewed by a web
|
||||
browser. The output conforms to the HTML 3.2 specification.
|
||||
<p><br>The filenames specified on the command line are optional. If the
|
||||
output-file is ommitted, output will go to <strong>stdout</strong>. If the input-file
|
||||
is ommitted, <strong>debug2html</strong> will read from <strong>stdin</strong>. The filename "-"
|
||||
can be used to indicate that input should be read from <strong>stdin</strong>. For
|
||||
example:
|
||||
<p><br><code>cat /usr/local/samba/var/log.nmb | debug2html - nmblog.html</code> <br>
|
||||
<p><br><a name="VERSION"></a>
|
||||
<h2>VERSION</h2>
|
||||
|
||||
<p><br>This man page is correct for version 2.0 of the Samba suite.
|
||||
<p><br><a name="SEEALSO"></a>
|
||||
<h2>SEE ALSO</h2>
|
||||
|
||||
<p><br><a href="nmbd.8.html"><strong>nmbd</strong>(8)</a>, <a href="smbd.8.html"><strong>smbd</strong>(8)</a>,
|
||||
<a href="samba.7.html"><strong>samba</strong>(7)</a>.
|
||||
<p><br><a name="AUTHOR"></a>
|
||||
<h2>AUTHOR</h2>
|
||||
|
||||
<p><br>The original Samba software and related utilities were created by
|
||||
Andrew Tridgell <a href="mailto:samba-bugs@samba.org"><em>samba-bugs@samba.org</em></a>. Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed.
|
||||
<p><br>The original Samba man pages were written by Karl Auer. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
<a href="ftp://ftp.icce.rug.nl/pub/unix/"><strong>ftp://ftp.icce.rug.nl/pub/unix/</strong></a>)
|
||||
and updated for the Samba2.0 release by Jeremy Allison.
|
||||
<a href="mailto:samba-bugs@samba.org"><em>samba-bugs@samba.org</em></a>.
|
||||
<p><br><strong>debug2html</strong> was added by Chris Hertel.
|
||||
<p><br>See <a href="samba.7.html"><strong>samba</strong>(7)</a> to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc.
|
||||
</body>
|
||||
</html>
|
@ -1,651 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html><head><title>rpcclient (1)</title>
|
||||
|
||||
<link rev="made" href="mailto:samba-bugs@samba.org">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<hr>
|
||||
|
||||
<h1>rpcclient (1)</h1>
|
||||
<h2>Samba</h2>
|
||||
<h2>23 Oct 1998</h2>
|
||||
|
||||
|
||||
|
||||
|
||||
<p><br><a name="NAME"></a>
|
||||
<h2>NAME</h2>
|
||||
rpcclient - utility to manage MSRPC resources on servers
|
||||
<p><br><a name="SYNOPSIS"></a>
|
||||
<h2>SYNOPSIS</h2>
|
||||
|
||||
<p><br><strong>rpcclient</strong>
|
||||
[<a href="rpcclient.1.html#password">password</a>]
|
||||
<a href="rpcclient.1.html#servername">-S servername</a>
|
||||
[<a href="rpcclient.1.html#minusU">-U [username][%][password]</a>]
|
||||
[<a href="rpcclient.1.html#minusW">-W domain</a>]
|
||||
[<a href="rpcclient.1.html#minusl">-l log basename</a>]
|
||||
[<a href="rpcclient.1.html#minusd">-d debuglevel</a>]
|
||||
[<a href="rpcclient.1.html#minusO">-O socket options</a>]
|
||||
[<a href="rpcclient.1.html#minusi">-i scope</a>]
|
||||
[<a href="rpcclient.1.html#minusN">-N</a>]
|
||||
[<a href="rpcclient.1.html#minusn">-n NetBIOS name</a>]
|
||||
[<a href="rpcclient.1.html#minush">-h</a>]
|
||||
[<a href="rpcclient.1.html#minusI">-I dest IP</a>]
|
||||
[<a href="rpcclient.1.html#minusE">-E</a>]
|
||||
[<a href="rpcclient.1.html#minust">-t terminal code</a>]
|
||||
[<a href="rpcclient.1.html#minusc">-c command string</a>]
|
||||
[<a href="rpcclient.1.html#minusB">-B IP addr</a>]
|
||||
[<a href="rpcclient.1.html#minuss">-s smb.conf</a>]
|
||||
[<a href="rpcclient.1.html#minusm">-m max protocol</a>]
|
||||
<p><br><a name="DESCRIPTION"></a>
|
||||
<h2>DESCRIPTION</h2>
|
||||
|
||||
<p><br>This program is part of the <strong>Samba</strong> suite.
|
||||
<p><br><strong>rpcclient</strong> is a client that can 'talk' to an SMB/CIFS MSRPC server.
|
||||
Operations include things like managing a SAM Database (users, groups
|
||||
and aliases) in the same way as the Windows NT programs
|
||||
<strong>User Manager for Domains</strong> and <strong>Server Manager for Domains</strong>;
|
||||
managing a remote registry in the same way as the Windows NT programs
|
||||
<strong>REGEDT32.EXE</strong> and <strong>REGEDIT.EXE</strong>; viewing a remote event log (same
|
||||
as <strong>EVENTVWR.EXE</strong>) etc.
|
||||
<p><br>Typical usage is like this: <br>
|
||||
<code>rpcclient -I 192.168.32.1 -S "*SMBSERVER" -U fred%secret -l log</code>
|
||||
<br>
|
||||
<p><br><a name="OPTIONS"></a>
|
||||
<h2>OPTIONS</h2>
|
||||
|
||||
<p><br><ul>
|
||||
<p><br><a name="servername"></a>
|
||||
<li><strong><strong>servername</strong></strong> servername is the name of the server you want
|
||||
to use on the server. This should be the NetBIOS name of the SMB/CIFS
|
||||
server, which can be <strong>*SMBSERVER</strong> on Windows NT 4.0 or Samba Servers.
|
||||
<p><br>Note that the server name required is NOT necessarily the IP (DNS)
|
||||
host name of the server! The name required is a NetBIOS server name,
|
||||
which may or may not be the same as the IP hostname of the machine
|
||||
running the server. Also, remember that having a period in a NetBIOS
|
||||
name (such as an IP hostname) may cause connectivity problems on your
|
||||
network: NT tends to strip NetBIOS names from the leading period
|
||||
onwards.
|
||||
<p><br>The server name is looked up according to either the
|
||||
<a href="rpcclient.1.html#minusR"><strong>-R</strong></a> parameter to <strong>rpcclient</strong> or using the
|
||||
<a href="smb.conf.5.html#nameresolveorder"><strong>name resolve order</strong></a>
|
||||
parameter in the smb.conf file, allowing an administrator to change
|
||||
the order and methods by which server names are looked up.
|
||||
<p><br><a name="password"></a>
|
||||
<li><strong><strong>password</strong></strong> password is the password required to access the
|
||||
specified service on the specified server. If this parameter is
|
||||
supplied, the <a href="rpcclient.1.html#minusN"><strong>-N</strong></a> option (suppress password prompt) is assumed.
|
||||
<p><br>There is no default password. If no password is supplied on the
|
||||
command line (either by using this parameter or adding a password to
|
||||
the <a href="rpcclient.1.html#minusU"><strong>-U</strong></a> option (see below)) and the <a href="rpcclient.1.html#minusN"><strong>-N</strong></a> option is not specified,
|
||||
the client will prompt for a password, even if the desired service
|
||||
does not require one. (If no password is required, simply press ENTER
|
||||
to provide a null password.)
|
||||
<p><br>Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password. Lowercase or mixed case passwords may be
|
||||
rejected by these servers.
|
||||
<p><br>Be cautious about including passwords in scripts.
|
||||
<p><br><a name="minuss"></a>
|
||||
<li><strong><strong>-s smb.conf</strong></strong> This parameter specifies the pathname to the
|
||||
Samba configuration file, smb.conf. This file controls all aspects of
|
||||
the Samba setup on the machine and rpcclient also needs to read this
|
||||
file.
|
||||
<p><br><a name="minusB"></a>
|
||||
<li><strong><strong>-B IP addr</strong></strong> The IP address to use when sending a broadcast packet.
|
||||
<p><br><a name="minusO"></a>
|
||||
<li><strong><strong>-O socket options</strong></strong> TCP socket options to set on the client
|
||||
socket. See the <a href="smb.conf.5.html#socketoptions">socket options</a>
|
||||
parameter in the <a href="smb.conf.5.html"><strong>smb.conf (5)</strong></a> manpage for
|
||||
the list of valid options.
|
||||
<p><br><a name="minusR"></a>
|
||||
<li><strong><strong>-R name resolve order</strong></strong> This option allows the user of
|
||||
rpcclient to determine what name resolution services to use when
|
||||
looking up the NetBIOS name of the host being connected to.
|
||||
<p><br>The options are :"lmhosts", "host", "wins" and "bcast". They cause
|
||||
names to be resolved as follows :
|
||||
<p><br><ul>
|
||||
<p><br><li > <strong>lmhosts</strong> : Lookup an IP address in the Samba lmhosts file.
|
||||
The lmhosts file is stored in the same directory as the
|
||||
<a href="smb.conf.5.html"><strong>smb.conf</strong></a> file.
|
||||
<p><br><li > <strong>host</strong> : Do a standard host name to IP address resolution,
|
||||
using the system /etc/hosts, NIS, or DNS lookups. This method of name
|
||||
resolution is operating system depended for instance on IRIX or
|
||||
Solaris this may be controlled by the <em>/etc/nsswitch.conf</em> file).
|
||||
<p><br><li > <strong>wins</strong> : Query a name with the IP address listed in the <a href="smb.conf.5.html#winsserver"><strong>wins
|
||||
server</strong></a> parameter in the smb.conf file. If
|
||||
no WINS server has been specified this method will be ignored.
|
||||
<p><br><li > <strong>bcast</strong> : Do a broadcast on each of the known local interfaces
|
||||
listed in the <a href="smb.conf.5.html#interfaces"><strong>interfaces</strong></a> parameter
|
||||
in the smb.conf file. This is the least reliable of the name resolution
|
||||
methods as it depends on the target host being on a locally connected
|
||||
subnet. To specify a particular broadcast address the <a href="rpcclient.1.html#minusB"><strong>-B</strong></a> option
|
||||
may be used.
|
||||
<p><br></ul>
|
||||
<p><br>If this parameter is not set then the name resolve order defined
|
||||
in the <a href="smb.conf.5.html"><strong>smb.conf</strong></a> file parameter
|
||||
<a href="smb.conf.5.html#nameresolveorder">(<strong>name resolve order</strong>)</a>
|
||||
will be used.
|
||||
<p><br>The default order is lmhosts, host, wins, bcast and without this
|
||||
parameter or any entry in the <a href="smb.conf.5.html#nameresolveorder"><strong>"name resolve
|
||||
order"</strong></a> parameter of the
|
||||
<a href="smb.conf.5.html"><strong>smb.conf</strong></a> file the name resolution methods
|
||||
will be attempted in this order.
|
||||
<p><br><a name="minusi"></a>
|
||||
<li><strong><strong>-i scope</strong></strong> This specifies a NetBIOS scope that rpcclient will use
|
||||
to communicate with when generating NetBIOS names. For details on the
|
||||
use of NetBIOS scopes, see rfc1001.txt and rfc1002.txt. NetBIOS scopes
|
||||
are <em>very</em> rarely used, only set this parameter if you are the
|
||||
system administrator in charge of all the NetBIOS systems you
|
||||
communicate with.
|
||||
<p><br><a name="minusN"></a>
|
||||
<li><strong><strong>-N</strong></strong> If specified, this parameter suppresses the normal
|
||||
password prompt from the client to the user. This is useful when
|
||||
accessing a service that does not require a password.
|
||||
<p><br>Unless a password is specified on the command line or this parameter
|
||||
is specified, the client will request a password.
|
||||
<p><br><a name="minusn"></a>
|
||||
<li><strong><strong>-n NetBIOS name</strong></strong> By default, the client will use the local
|
||||
machine's hostname (in uppercase) as its NetBIOS name. This parameter
|
||||
allows you to override the host name and use whatever NetBIOS name you
|
||||
wish.
|
||||
<p><br><a name="minusd"></a>
|
||||
<li><strong><strong>-d debuglevel</strong></strong> debuglevel is an integer from 0 to 10, or the
|
||||
letter 'A'.
|
||||
<p><br>The default value if this parameter is not specified is zero.
|
||||
<p><br>The higher this value, the more detail will be logged to the log files
|
||||
about the activities of the client. At level 0, only critical errors
|
||||
and serious warnings will be logged. Level 1 is a reasonable level for
|
||||
day to day running - it generates a small amount of information about
|
||||
operations carried out.
|
||||
<p><br>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 debuglevel is set to the
|
||||
letter 'A', then <em>all</em> debug messages will be printed. This setting
|
||||
is for developers only (and people who <em>really</em> want to know how the
|
||||
code works internally).
|
||||
<p><br>Note that specifying this parameter here will override the <a href="smb.conf.5.html#loglevel"><strong>log
|
||||
level</strong></a> parameter in the <a href="smb.conf.5.html"><strong>smb.conf
|
||||
(5)</strong></a> file.
|
||||
<p><br><a name="minusp"></a>
|
||||
<li><strong><strong>-p port</strong></strong> This number is the TCP port number that will be used
|
||||
when making connections to the server. The standard (well-known) TCP
|
||||
port number for an SMB/CIFS server is 139, which is the default.
|
||||
<p><br><a name="minusl"></a>
|
||||
<li><strong><strong>-l logfilename</strong></strong> If specified, logfilename specifies a base
|
||||
filename into which operational data from the running client will be
|
||||
logged.
|
||||
<p><br>The default base name is specified at compile time.
|
||||
<p><br>The base name is used to generate actual log file names. For example,
|
||||
if the name specified was "log", the debug file would be
|
||||
<code>log.client</code>.
|
||||
<p><br>The log file generated is never removed by the client.
|
||||
<p><br><a name="minush"></a>
|
||||
<li><strong><strong>-h</strong></strong> Print the usage message for the client.
|
||||
<p><br><a name="minusI"></a>
|
||||
<li><strong><strong>-I IP address</strong></strong> IP address is the address of the server to
|
||||
connect to. It should be specified in standard "a.b.c.d" notation.
|
||||
<p><br>Normally the client would attempt to locate a named SMB/CIFS server by
|
||||
looking it up via the NetBIOS name resolution mechanism described
|
||||
above in the <a href="rpcclient.1.html#minusR"><strong>name resolve order</strong></a> parameter
|
||||
above. Using this parameter will force the client to assume that the
|
||||
server is on the machine with the specified IP address and the NetBIOS
|
||||
name component of the resource being connected to will be ignored.
|
||||
<p><br>There is no default for this parameter. If not supplied, it will be
|
||||
determined automatically by the client as described above.
|
||||
<p><br><a name="minusE"></a>
|
||||
<li><strong><strong>-E</strong></strong> This parameter causes the client to write messages to the
|
||||
standard error stream (stderr) rather than to the standard output
|
||||
stream.
|
||||
<p><br>By default, the client writes messages to standard output - typically
|
||||
the user's tty.
|
||||
<p><br>Note that by default, debug information is always sent to stderr.
|
||||
Debug information can instead be sent to a file, using the
|
||||
<a href="rpcclient.1.html#minusl">-l log basename</a> option.
|
||||
<p><br><a name="minusU"></a>
|
||||
<li><strong><strong>-U username</strong></strong> This specifies the user name that will be used by
|
||||
the client to make a connection, assuming your server is not a downlevel
|
||||
server that is running a protocol level that uses passwords on shares,
|
||||
not on usernames.
|
||||
<p><br>Some servers are fussy about the case of this name, and some insist
|
||||
that it must be a valid NetBIOS name.
|
||||
<p><br>If no username is supplied, it will default to an uppercase version of
|
||||
the environment variable <code>USER</code> or <code>LOGNAME</code> in that order. If no
|
||||
username is supplied and neither environment variable exists the
|
||||
username "GUEST" will be used.
|
||||
<p><br>If the <code>USER</code> environment variable contains a '%' character,
|
||||
everything after that will be treated as a password. This allows you
|
||||
to set the environment variable to be <code>USER=username%password</code> so
|
||||
that a password is not passed on the command line (where it may be
|
||||
seen by the ps command).
|
||||
<p><br>If the service you are connecting to requires a password, it can be
|
||||
supplied using the <a href="rpcclient.1.html#minusU"><strong>-U</strong></a> option, by appending a percent symbol ("%")
|
||||
then the password to username. For example, to attach to a service as
|
||||
user <code>"fred"</code> with password <code>"secret"</code>, you would specify. <br>
|
||||
<p><br><code>-U fred%secret</code> <br>
|
||||
<p><br>on the command line. Note that there are no spaces around the percent
|
||||
symbol.
|
||||
<p><br>If you specify the password as part of username then the <a href="rpcclient.1.html#minusN"><strong>-N</strong></a> option
|
||||
(suppress password prompt) is assumed.
|
||||
<p><br>If you specify the password as a parameter <em>AND</em> as part of username
|
||||
then the password as part of username will take precedence. Putting
|
||||
nothing before or nothing after the percent symbol will cause an empty
|
||||
username or an empty password to be used, respectively.
|
||||
<p><br>The password may also be specified by setting up an environment
|
||||
variable called <code>PASSWORD</code> that contains the users password. Note
|
||||
that this may be very insecure on some systems but on others allows
|
||||
users to script rpcclient commands without having a password appear in
|
||||
the command line of a process listing.
|
||||
<p><br>Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password. Lowercase or mixed case passwords may be
|
||||
rejected by these servers.
|
||||
<p><br>Be cautious about including passwords in scripts or in the
|
||||
<code>PASSWORD</code> environment variable. Also, on many systems the command
|
||||
line of a running process may be seen via the <code>ps</code> command to be
|
||||
safe always allow rpcclient to prompt for a password and type it in
|
||||
directly.
|
||||
<p><br><a name="minust"></a>
|
||||
<li><strong><strong>-t terminal code</strong></strong> This option tells rpcclient how to interpret
|
||||
filenames coming from the remote server. Usually Asian language
|
||||
multibyte UNIX implementations use different character sets than
|
||||
SMB/CIFS servers (<em>EUC</em> instead of <em>SJIS</em> for example). Setting
|
||||
this parameter will let rpcclient convert between the UNIX filenames
|
||||
and the SMB filenames correctly. This option has not been seriously
|
||||
tested and may have some problems.
|
||||
<p><br>The terminal codes include <code>sjis</code>, <code>euc</code>, <code>jis7</code>, <code>jis8</code>,
|
||||
<code>junet</code>, <code>hex</code>, <code>cap</code>. This is not a complete list, check the
|
||||
Samba source code for the complete list.
|
||||
<p><br><a name="minusm"></a>
|
||||
<li><strong><strong>-m max protocol level</strong></strong> With the new code in Samba2.0,
|
||||
<strong>rpcclient</strong> always attempts to connect at the maximum
|
||||
protocols level the server supports. This parameter is
|
||||
preserved for backwards compatibility, but any string
|
||||
following the <strong>-m</strong> will be ignored.
|
||||
<p><br><a name="minusW"></a>
|
||||
<li><strong><strong>-W Domain</strong></strong> Override the default Domain, which is the remote server's
|
||||
Domain. This option may be needed to connect to some servers. It is also
|
||||
possible to specify the remote server name as the Domain, which will
|
||||
force the username and password to be authenticated against the remote
|
||||
server's local SAM instead of the Domain SAM.
|
||||
<p><br><a name="minusc"></a>
|
||||
<li><strong><strong>-c command string</strong></strong> command string is a semicolon separated
|
||||
list of commands to be executed instead of prompting from stdin.
|
||||
<a href="rpcclient.1.html#minusN"><strong>-N</strong></a> is implied by <strong>-c</strong>.
|
||||
<p><br>This is particularly useful in scripts, e.g. <code>-c 'lsaquery; enumusers -u'</code>.
|
||||
<p><br></ul>
|
||||
<p><br><a name="OPERATIONS"></a>
|
||||
<h2>OPERATIONS</h2>
|
||||
|
||||
<p><br>Once the client is running, the user is presented with a prompt :
|
||||
<p><br><code>smb:\></code>
|
||||
<p><br>The prompt indicates that the client is ready and waiting to carry out
|
||||
a user command. Each command is a single word, optionally followed by
|
||||
parameters specific to that command. Command and parameters are
|
||||
space-delimited unless these notes specifically state otherwise. All
|
||||
commands are case-insensitive. Parameters to commands may or may not
|
||||
be case sensitive, depending on the command.
|
||||
<p><br>You can specify names (e.g registry keys; user or group names;
|
||||
service names) which have spaces in them by quoting the
|
||||
name with double quotes, for example "dRMON SmartAgent".
|
||||
<p><br>Parameters shown in square brackets (e.g., "[parameter]") are
|
||||
optional. If not given, the command will use suitable
|
||||
defaults. Parameters shown in angle brackets (e.g., "<parameter>") are
|
||||
required.
|
||||
<p><br>Note that all commands operating on the server are actually performed
|
||||
by issuing a request to the server. Thus the behavior may vary from
|
||||
server to server, depending on how the server was implemented.
|
||||
<p><br>The commands available are listed in groups relating to different services:
|
||||
<p><br><ul>
|
||||
<p><br><li><strong>Misccellaneous</strong>
|
||||
<p><br><ul>
|
||||
<p><br><a name="questionmark"></a> <li><strong><strong>? [command]</strong></strong> If "command" is specified,
|
||||
the <strong>?</strong> command will display a brief informative message about the
|
||||
specified command. If no command is specified, a list of available
|
||||
commands will be displayed.
|
||||
<p><br><a name="exclaimationmark"></a> <li><strong><strong>! [shell command]</strong></strong> If "shell command"
|
||||
is specified, the <strong>!</strong> command will execute a shell locally and run
|
||||
the specified shell command. If no command is specified, a local shell
|
||||
will be run.
|
||||
<p><br><a name="exit"></a> <li><strong><strong>exit</strong></strong> Terminate the connection with the server and
|
||||
exit from the program.
|
||||
<p><br><a name="help"></a> <li><strong><strong>help [command]</strong></strong> See the <a href="rpcclient.1.html#questionmark"><strong>?</strong></a>
|
||||
command above.
|
||||
<p><br><a name="quit"></a> <li><strong><strong>quit</strong></strong> See the <a href="rpcclient.1.html#exit"><strong>exit</strong></a> command.
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Event Log</strong>
|
||||
<p><br><ul>
|
||||
<p><br><a name="eventlog"></a> <li><strong><strong>eventlog</strong></strong>
|
||||
list the events
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Service Control</strong>
|
||||
<p><br>These commands provide functionality similar to the Windows
|
||||
NT Service Control Manager.
|
||||
<p><br>It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Service names, by pressing the
|
||||
tab key.
|
||||
<p><br><ul>
|
||||
<p><br><a name="svcenum"></a> <li><strong><strong>svcenum</strong></strong>
|
||||
[-i] Lists Services.
|
||||
<p><br><a name="svcinfo"></a> <li><strong><strong>svcinfo</strong></strong>
|
||||
<service> Service Information
|
||||
<p><br><a name="svcstart"></a> <li><strong><strong>svcstart</strong></strong>
|
||||
<service> [arg 0] [arg 1] ... Start Service
|
||||
<p><br><a name="svcstop"></a> <li><strong><strong>svcstop</strong></strong>
|
||||
<service> Stop Service
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Scheduler</strong>
|
||||
<p><br><ul>
|
||||
<p><br><a name="at"></a> <li><strong><strong>at</strong></strong>
|
||||
Scheduler control (at /? for syntax)
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Registry</strong>
|
||||
<p><br>It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for registry key and value names,
|
||||
by pressing the tab key.
|
||||
<p><br><ul>
|
||||
<p><br><a name="regenum"></a> <li><strong><strong>regenum</strong></strong>
|
||||
<keyname> Registry Enumeration (keys, values)
|
||||
<p><br><a name="regdeletekey"></a> <li><strong><strong>regdeletekey</strong></strong>
|
||||
<keyname> Registry Key Delete
|
||||
<p><br><a name="regcreatekey"></a> <li><strong><strong>regcreatekey</strong></strong>
|
||||
<keyname> [keyclass] Registry Key Create
|
||||
<p><br><a name="shutdown"></a> <li><strong><strong>shutdown</strong></strong>
|
||||
[-m message] [-t timeout] [-r or --reboot] Server Shutdown
|
||||
<p><br><a name="regqueryval"></a> <li><strong><strong>regqueryval</strong></strong>
|
||||
<valname> Registry Value Query
|
||||
<p><br><a name="regquerykey"></a> <li><strong><strong>regquerykey</strong></strong>
|
||||
<keyname> Registry Key Query
|
||||
<p><br><a name="regdeleteval"></a> <li><strong><strong>regdeleteval</strong></strong>
|
||||
<valname> Registry Value Delete
|
||||
<p><br><a name="regcreateval"></a> <li><strong><strong>regcreateval</strong></strong>
|
||||
<valname> <valtype> <value> Registry Key Create
|
||||
<p><br><a name="reggetsec"></a> <li><strong><strong>reggetsec</strong></strong>
|
||||
<keyname> Registry Key Security
|
||||
<p><br><a name="regtestsec"></a> <li><strong><strong>regtestsec</strong></strong>
|
||||
<keyname> Test Registry Key Security
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Printing</strong>
|
||||
<p><br>It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Printer and job names, by
|
||||
pressing the tab key.
|
||||
<p><br><ul>
|
||||
<p><br><a name="spoolenum"></a> <li><strong><strong>spoolenum</strong></strong>
|
||||
Enumerate Printers. This experimental command lists
|
||||
all printers available on a remote spooler service.
|
||||
<p><br><a name="spooljobs"></a> <li><strong><strong>spooljobs</strong></strong>
|
||||
<printer name> Enumerate Printer Jobs. This
|
||||
experimental command lists all jobs, and their
|
||||
status, currently queued on a remote spooler
|
||||
service.
|
||||
<p><br><a name="spoolopen"></a> <li><strong><strong>spoolopen</strong></strong>
|
||||
<printer name> Spool Printer Open Test. Experimental.
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Server</strong>
|
||||
<p><br><ul>
|
||||
<p><br><a name="time"></a> <li><strong><strong>time</strong></strong>
|
||||
Display remote time
|
||||
<p><br><a name="brsinfo"></a> <li><strong><strong>brsinfo</strong></strong>
|
||||
Browser Query Info
|
||||
<p><br><a name="wksinfo"></a> <li><strong><strong>wksinfo</strong></strong>
|
||||
Workstation Query Info
|
||||
<p><br><a name="srvinfo"></a> <li><strong><strong>srvinfo</strong></strong>
|
||||
Server Query Info
|
||||
<p><br><a name="srvsessions"></a> <li><strong><strong>srvsessions</strong></strong>
|
||||
List sessions on a server
|
||||
<p><br><a name="srvshares"></a> <li><strong><strong>srvshares</strong></strong>
|
||||
List shares on a server
|
||||
<p><br><a name="srvtransports"></a> <li><strong><strong>srvtransports</strong></strong>
|
||||
List transports on a server
|
||||
<p><br><a name="srvconnections"></a> <li><strong><strong>srvconnections</strong></strong>
|
||||
List connections on a server
|
||||
<p><br><a name="srvfiles"></a> <li><strong><strong>srvfiles</strong></strong>
|
||||
List files on a server
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>Local Security Authority</strong>
|
||||
<p><br><ul>
|
||||
<p><br><a name="lsaquery"></a> <li><strong><strong>lsaquery</strong></strong>
|
||||
Query Info Policy (domain member or server). Obtains
|
||||
the SID and name of the SAM database that a server
|
||||
is responsible for (i.e a workstation's local SAM
|
||||
database or the PDC SAM database). Also obtains the
|
||||
SID and name of the SAM database that a server is
|
||||
a member of.
|
||||
<p><br><a name="lsaenumdomains"></a> <li><strong><strong>lsaenumdomains</strong></strong>
|
||||
Enumerate Trusted Domains. Lists all Trusted and
|
||||
Trusting Domains with which the remote PDC has
|
||||
trust relationships established.
|
||||
<p><br><a name="lookupsids"></a> <li><strong><strong>lookupsids</strong></strong>
|
||||
<rid1 or sid1> <rid1 or sid2> ... Resolve names from SIDs.
|
||||
Mostly to be used by developers or for troubleshooting,
|
||||
this command can take either Security Identifiers or Relative
|
||||
Identifiers, and look them up in the local SAM database
|
||||
(or look them up in a remote Trusting or Trusted PDC's SAM
|
||||
database if there is an appropriate Trust Relationship
|
||||
established). The result is a list of names, of the
|
||||
format: <br>
|
||||
<code>[TRUST_DOMAIN\]name</code>. <br>
|
||||
the <a href="rpcclient.1.html#lsaquery"><strong>lsaquery</strong></a> command must have been
|
||||
issued first if you wish to use lookupsids to resolve
|
||||
RIDs. The only RIDs that will be resolved will be those
|
||||
in the SAM database of the server to which you are connected.
|
||||
<p><br><a name="lookupnames"></a> <li><strong><strong>lookupnames</strong></strong>
|
||||
<name1> <name2> ... Resolve SIDs from names.
|
||||
Mostly to be used by developers or for troubleshooting,
|
||||
this command can take names of the following format: <br>
|
||||
<code>[DOMAIN_NAME\]name</code>. <br>
|
||||
The names, which can be user, group or alias names, will
|
||||
either be looked up in the local SAM database or in a remote
|
||||
Trusting or Trusted PDC's SAM database, if there is an
|
||||
appropriate Trust Relationship established. The optional
|
||||
Domain name component is the name of a SAM database, which
|
||||
can include a workstation's local SAM database or a Trusted
|
||||
Domain.
|
||||
Example Usage: <br>
|
||||
<code>lookupnames WKSTANAME\Administrator "Domain Guests"</code> <br>
|
||||
<p><br><a name="querysecret"></a> <li><strong><strong>querysecret</strong></strong>
|
||||
LSA Query Secret (developer use). This command only appears
|
||||
to work against NT4 SP3 and below. Due to its potential
|
||||
for misuse, it looks like Microsoft modified their
|
||||
implementation of the LsaRetrievePrivateData call to
|
||||
always return NT_STATUS_ACCESS_DENIED.
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>NETLOGON</strong>
|
||||
<p><br><ul>
|
||||
<p><br><a name="ntlogin"></a> <li><strong><strong>ntlogin</strong></strong>
|
||||
[username] [password] NT Domain login test. Demonstrates
|
||||
how NT-style logins work. Mainly for developer usage,
|
||||
it can also be used to verify that a user can log in
|
||||
from a workstation. If you cannot ever get pam_ntdom
|
||||
to work, try this command first.
|
||||
<p><br><a name="domtrust"></a> <li><strong><strong>domtrust</strong></strong>
|
||||
<domain> NT Inter-Domain test. Demonstrates how NT-style
|
||||
Inter-Domain Trust relationships work. Mainly for
|
||||
developer usage, it can also be used to verify that a
|
||||
Trust Relationship is correctly established with a
|
||||
remote PDC.
|
||||
<p><br><a name="samsync"></a> <li><strong><strong>samsync</strong></strong>
|
||||
SAM Synchronisation Test (experimental). This command
|
||||
is used to manually synchronise a SAM database from a
|
||||
remote PDC, when Samba is set up as a Backup Domain
|
||||
Controller.
|
||||
<p><br></ul>
|
||||
<p><br><li><strong>SAM Database</strong>
|
||||
<p><br>It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for user, group, alias and domain
|
||||
names, by pressing the tab key.
|
||||
<p><br><ul>
|
||||
<p><br><a name="lookupdomain"></a> <li><strong><strong>lookupdomain</strong></strong>
|
||||
Obtain SID for a local domain
|
||||
<p><br><a name="enumusers"></a> <li><strong><strong>enumusers</strong></strong>
|
||||
SAM User Database Query (experimental!)
|
||||
<p><br><a name="addgroupmem"></a> <li><strong><strong>addgroupmem</strong></strong>
|
||||
<group rid> [user] [user] ... SAM Add Domain Group Member
|
||||
<p><br><a name="addaliasmem"></a> <li><strong><strong>addaliasmem</strong></strong>
|
||||
<alias rid> [member sid1] [member sid2] ... SAM Add Domain Alias Member
|
||||
<p><br><a name="delgroupmem"></a> <li><strong><strong>delgroupmem</strong></strong>
|
||||
<group rid> [user] [user] ... SAM Delete Domain Group Member
|
||||
<p><br><a name="delaliasmem"></a> <li><strong><strong>delaliasmem</strong></strong>
|
||||
<alias rid> [member sid1] [member sid2] ... SAM Delete Domain Alias Member
|
||||
<p><br><a name="creategroup"></a> <li><strong><strong>creategroup</strong></strong>
|
||||
SAM Create Domain Group
|
||||
<p><br><a name="createalias"></a> <li><strong><strong>createalias</strong></strong>
|
||||
SAM Create Domain Alias
|
||||
<p><br><a name="createuser"></a> <li><strong><strong>createuser</strong></strong>
|
||||
<username> SAM Create Domain User
|
||||
<p><br><a name="delgroup"></a> <li><strong><strong>delgroup</strong></strong>
|
||||
SAM Delete Domain Group
|
||||
<p><br><a name="delalias"></a> <li><strong><strong>delalias</strong></strong>
|
||||
SAM Delete Domain Alias
|
||||
<p><br><a name="ntpass"></a> <li><strong><strong>ntpass</strong></strong>
|
||||
NT SAM Password Change
|
||||
<p><br><a name="samuserset2"></a> <li><strong><strong>samuserset2</strong></strong>
|
||||
<username> [-s acb_bits] SAM User Set Info 2 (experimental!)
|
||||
<p><br><a name="samuserset"></a> <li><strong><strong>samuserset</strong></strong>
|
||||
<username> [-p password] SAM User Set Info (experimental!)
|
||||
<p><br><a name="samuser"></a> <li><strong><strong>samuser</strong></strong>
|
||||
<username> SAM User Query (experimental!)
|
||||
<p><br><a name="samgroup"></a> <li><strong><strong>samgroup</strong></strong>
|
||||
<groupname> SAM Group Query (experimental!)
|
||||
<p><br><a name="samalias"></a> <li><strong><strong>samalias</strong></strong>
|
||||
<aliasname> SAM Alias Query
|
||||
<p><br><a name="samaliasmem"></a> <li><strong><strong>samaliasmem</strong></strong>
|
||||
<aliasname> SAM Alias Members
|
||||
<p><br><a name="samgroupmem"></a> <li><strong><strong>samgroupmem</strong></strong>
|
||||
SAM Group Members
|
||||
<p><br><a name="samtest"></a> <li><strong><strong>samtest</strong></strong>
|
||||
SAM User Encrypted RPC test (experimental!)
|
||||
<p><br><a name="enumaliases"></a> <li><strong><strong>enumaliases</strong></strong>
|
||||
SAM Aliases Database Query (experimental!)
|
||||
<p><br><a name="enumdomains"></a> <li><strong><strong>enumdomains</strong></strong>
|
||||
SAM Domains Database Query (experimental!)
|
||||
<p><br><a name="enumgroups"></a> <li><strong><strong>enumgroups</strong></strong>
|
||||
SAM Group Database Query (experimental!)
|
||||
<p><br><a name="dominfo"></a> <li><strong><strong>dominfo</strong></strong>
|
||||
SAM Query Domain Info
|
||||
<p><br><a name="dispinfo"></a> <li><strong><strong>dispinfo</strong></strong>
|
||||
SAM Query Display Info
|
||||
<p><br></ul>
|
||||
<p><br></ul>
|
||||
<p><br><a name="NOTES"></a>
|
||||
<h2>NOTES</h2>
|
||||
|
||||
<p><br>Some servers are fussy about the case of supplied usernames,
|
||||
passwords, share names (AKA service names) and machine names. If you
|
||||
fail to connect try giving all parameters in uppercase.
|
||||
<p><br>It is often necessary to use the <a href="rpcclient.1.html#minusn"><strong>-n</strong></a> option when connecting
|
||||
to some types of servers. For example OS/2 LanManager insists on a valid
|
||||
NetBIOS name being used, so you need to supply a valid name that would
|
||||
be known to the server.
|
||||
<p><br>rpcclient only works on servers that support MSRPC over SMB. This includes
|
||||
all versions of Windows NT, including the ports to Unix such as AS/U and
|
||||
AFPS. Support for MSRPC over SMB in other servers is currently rare and
|
||||
patchy, for example Samba 2.0 only supports a limited set of MSRPC commands,
|
||||
and some of those are not supported very well.
|
||||
<p><br><a name="ENVIRONMENTVARIABLES"></a>
|
||||
<h2>ENVIRONMENT VARIABLES</h2>
|
||||
|
||||
<p><br>The variable <strong>USER</strong> may contain the username of the person using the
|
||||
client. This information is used only if the protocol level is high
|
||||
enough to support session-level passwords.
|
||||
<p><br>The variable <strong>PASSWORD</strong> may contain the password of the person using
|
||||
the client. This information is used only if the protocol level is
|
||||
high enough to support session-level passwords.
|
||||
<p><br><a name="INSTALLATION"></a>
|
||||
<h2>INSTALLATION</h2>
|
||||
|
||||
<p><br>The location of the client program is a matter for individual system
|
||||
administrators. The following are thus suggestions only.
|
||||
<p><br>It is recommended that the rpcclient software be installed in the
|
||||
/usr/local/samba/bin or /usr/samba/bin directory, this directory
|
||||
readable by all, writeable only by root. The client program itself
|
||||
should be executable by all. The client should <em>NOT</em> be setuid or
|
||||
setgid!
|
||||
<p><br>The client log files should be put in a directory readable and
|
||||
writeable only by the user.
|
||||
<p><br>To test the client, you will need to know the name of a running
|
||||
SMB/CIFS server. It is possible to run <a href="smbd.8.html"><strong>smbd (8)</strong></a>
|
||||
an ordinary user - running that server as a daemon on a
|
||||
user-accessible port (typically any port number over 1024) would
|
||||
provide a suitable test server.
|
||||
<p><br><a name="DIAGNOSTICS"></a>
|
||||
<h2>DIAGNOSTICS</h2>
|
||||
|
||||
<p><br>Most diagnostics issued by the client are logged in a specified log
|
||||
file. The log file name is specified at compile time, but may be
|
||||
overridden on the command line.
|
||||
<p><br>The number and nature of diagnostics available depends on the debug
|
||||
level used by the client. If you have problems, set the debug level to
|
||||
3 and peruse the log files.
|
||||
<p><br><a name="VERSION"></a>
|
||||
<h2>VERSION</h2>
|
||||
|
||||
<p><br>This man page is correct for version 2.0 of the Samba suite.
|
||||
<p><br><a name="BUGS"></a>
|
||||
<h2>BUGS</h2>
|
||||
|
||||
<p><br><ul>
|
||||
<li><strong>WARNING!</strong>
|
||||
The MSPRC over SMB code has been developed from examining Network traces.
|
||||
No documentation is available from the original creators (Microsoft) on
|
||||
how MSRPC over SMB works, or how the individual MSRPC services work.
|
||||
Microsoft's implementation of these services has been demonstrated (and
|
||||
reported) to be... a bit flakey in places.
|
||||
<p><br>The development of Samba's implementation of these services is <em>also</em>
|
||||
a bit rough, and as more of the services are understood, it can even result
|
||||
in versions of <a href="smbd.8.html"><strong>smbd (8)</strong></a> and rpcclient that are
|
||||
incompatible for some commands or services. Additionally, the developers
|
||||
are sending reports to Microsoft, and problems found by or reported to
|
||||
Microsoft are fixed in Service Packs, which may also result in
|
||||
incompatibilities.
|
||||
<p><br>It is therefore not guaranteed that the execution of an rpcclient command will
|
||||
work. It is also not guaranteed that the target server will continue to
|
||||
operate, i.e the execution of an MSRPC command may cause a remote service to
|
||||
fail, or even cause the remote server to fail. Usual rules apply, of course:
|
||||
the developers bear absolutely no responsibility for the use, misuse, or
|
||||
lack of use of rpcclient, by any person or persons, whether legal,
|
||||
illegal, accidental, deliberate, intentional, malicious, curious, etc.
|
||||
<p><br><li><strong>Command Completion</strong>
|
||||
Command-completion (available if you have the GNU readline library) used on
|
||||
certain commands may not operate correctly if the word being completed (such as a registry key) contains a space. Typically, the name will be completed, but
|
||||
you will have to go back and put quotes round it, yourself.
|
||||
<p><br><li><strong>SAM Database command-completion</strong>
|
||||
Command-completion (available if you have the GNU readline library) of user,
|
||||
group and alias names does not work on remote Domains, which would normally
|
||||
be specified like this: <br>
|
||||
<code>DOMAIN_name\user_name</code>. <br>
|
||||
The only names that can be completed in this fashion are the local names
|
||||
in the SAM database of the target server.
|
||||
<p><br><li><strong><a href="rpcclient.1.html#spoolenum"><strong>spoolenum</strong></a></strong>
|
||||
Due to current limitations in the rpcclient MSRPC / SMB code, and due to
|
||||
the extremely poor MSRPC implementation (by Microsoft) of the spooler
|
||||
service, if there are a large number of printers (or the names / comment
|
||||
fields associated with the printers), this command will fail. The
|
||||
limitations require further research to be carried out; we're stuck with
|
||||
the poor \PIPE\spoolss design.
|
||||
<p><br></ul>
|
||||
<p><br><a name="AUTHOR"></a>
|
||||
<h2>AUTHOR</h2>
|
||||
|
||||
<p><br>The original Samba software and related utilities were created by
|
||||
Andrew Tridgell <a href="mailto:samba-bugs@samba.org"><em>samba-bugs@samba.org</em></a>. Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed.
|
||||
<p><br>The original Samba man pages were written by Karl Auer. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
<a href="ftp://ftp.icce.rug.nl/pub/unix/"><strong>ftp://ftp.icce.rug.nl/pub/unix/</strong></a>)
|
||||
and updated for the Samba2.0 release by Jeremy Allison. This man page
|
||||
was developed cut-and-paste style from the smbclient man page, by
|
||||
Luke Kenneth Casson Leighton.
|
||||
<a href="mailto:samba-bugs@samba.org"><em>samba-bugs@samba.org</em></a>.
|
||||
<p><br>See <a href="samba.7.html"><strong>samba (7)</strong></a> to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc.
|
||||
<p><br></body>
|
||||
</html>
|
@ -1,54 +0,0 @@
|
||||
.TH "debug2html" "1" "29 Dec 1998" "Samba" "SAMBA"
|
||||
.PP
|
||||
.SH "NAME"
|
||||
debug2html \- Samba DEBUG to HTML translation filter
|
||||
.PP
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
debug2html [input-file [output-file]]
|
||||
.PP
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
This program is part of the \fBSamba\fP suite\&.
|
||||
.PP
|
||||
\fBdebug2html\fP generates HTML files from Samba log files\&. Log files
|
||||
produced by \fBnmbd\fP(8) or \fBsmbd\fP(8) may then be viewed by a web
|
||||
browser\&. The output conforms to the HTML 3\&.2 specification\&.
|
||||
.PP
|
||||
The filenames specified on the command line are optional\&. If the
|
||||
output-file is ommitted, output will go to \fBstdout\fP\&. If the input-file
|
||||
is ommitted, \fBdebug2html\fP will read from \fBstdin\fP\&. The filename "-"
|
||||
can be used to indicate that input should be read from \fBstdin\fP\&. For
|
||||
example:
|
||||
.PP
|
||||
\f(CWcat /usr/local/samba/var/log\&.nmb | debug2html - nmblog\&.html\fP
|
||||
.br
|
||||
.PP
|
||||
.SH "VERSION"
|
||||
.PP
|
||||
This man page is correct for version 2\&.0 of the Samba suite\&.
|
||||
.PP
|
||||
.SH "SEE ALSO"
|
||||
.PP
|
||||
\fBnmbd\fP(8), \fBsmbd\fP(8),
|
||||
\fBsamba\fP(7)\&.
|
||||
.PP
|
||||
.SH "AUTHOR"
|
||||
.PP
|
||||
The original Samba software and related utilities were created by
|
||||
Andrew Tridgell \fIsamba-bugs@samba\&.org\fP\&. Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed\&.
|
||||
.PP
|
||||
The original Samba man pages were written by Karl Auer\&. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
\fBftp://ftp\&.icce\&.rug\&.nl/pub/unix/\fP)
|
||||
and updated for the Samba2\&.0 release by Jeremy Allison\&.
|
||||
\fIsamba-bugs@samba\&.org\fP\&.
|
||||
.PP
|
||||
\fBdebug2html\fP was added by Chris Hertel\&.
|
||||
.PP
|
||||
See \fBsamba\fP(7) to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc\&.
|
@ -1,809 +0,0 @@
|
||||
.TH "rpcclient " "1" "23 Oct 1998" "Samba" "SAMBA"
|
||||
.PP
|
||||
.SH "NAME"
|
||||
rpcclient \- utility to manage MSRPC resources on servers
|
||||
.PP
|
||||
.SH "SYNOPSIS"
|
||||
.PP
|
||||
\fBrpcclient\fP
|
||||
[password]
|
||||
-S servername
|
||||
[-U [username][%][password]]
|
||||
[-W domain]
|
||||
[-l log basename]
|
||||
[-d debuglevel]
|
||||
[-O socket options]
|
||||
[-i scope]
|
||||
[-N]
|
||||
[-n NetBIOS name]
|
||||
[-h]
|
||||
[-I dest IP]
|
||||
[-E]
|
||||
[-t terminal code]
|
||||
[-c command string]
|
||||
[-B IP addr]
|
||||
[-s smb\&.conf]
|
||||
[-m max protocol]
|
||||
.PP
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
This program is part of the \fBSamba\fP suite\&.
|
||||
.PP
|
||||
\fBrpcclient\fP is a client that can \'talk\' to an SMB/CIFS MSRPC server\&.
|
||||
Operations include things like managing a SAM Database (users, groups
|
||||
and aliases) in the same way as the Windows NT programs
|
||||
\fBUser Manager for Domains\fP and \fBServer Manager for Domains\fP;
|
||||
managing a remote registry in the same way as the Windows NT programs
|
||||
\fBREGEDT32\&.EXE\fP and \fBREGEDIT\&.EXE\fP; viewing a remote event log (same
|
||||
as \fBEVENTVWR\&.EXE\fP) etc\&.
|
||||
.PP
|
||||
Typical usage is like this:
|
||||
.br
|
||||
\f(CWrpcclient -I 192\&.168\&.32\&.1 -S "*SMBSERVER" -U fred%secret -l log\fP
|
||||
.br
|
||||
.PP
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
.IP
|
||||
.IP "\fBservername\fP"
|
||||
servername is the name of the server you want
|
||||
to use on the server\&. This should be the NetBIOS name of the SMB/CIFS
|
||||
server, which can be \fB*SMBSERVER\fP on Windows NT 4\&.0 or Samba Servers\&.
|
||||
.IP
|
||||
Note that the server name required is NOT necessarily the IP (DNS)
|
||||
host name of the server! The name required is a NetBIOS server name,
|
||||
which may or may not be the same as the IP hostname of the machine
|
||||
running the server\&. Also, remember that having a period in a NetBIOS
|
||||
name (such as an IP hostname) may cause connectivity problems on your
|
||||
network: NT tends to strip NetBIOS names from the leading period
|
||||
onwards\&.
|
||||
.IP
|
||||
The server name is looked up according to either the
|
||||
\fB-R\fP parameter to \fBrpcclient\fP or using the
|
||||
\fBname resolve order\fP
|
||||
parameter in the smb\&.conf file, allowing an administrator to change
|
||||
the order and methods by which server names are looked up\&.
|
||||
.IP
|
||||
.IP "\fBpassword\fP"
|
||||
password is the password required to access the
|
||||
specified service on the specified server\&. If this parameter is
|
||||
supplied, the \fB-N\fP option (suppress password prompt) is assumed\&.
|
||||
.IP
|
||||
There is no default password\&. If no password is supplied on the
|
||||
command line (either by using this parameter or adding a password to
|
||||
the \fB-U\fP option (see below)) and the \fB-N\fP option is not specified,
|
||||
the client will prompt for a password, even if the desired service
|
||||
does not require one\&. (If no password is required, simply press ENTER
|
||||
to provide a null password\&.)
|
||||
.IP
|
||||
Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password\&. Lowercase or mixed case passwords may be
|
||||
rejected by these servers\&.
|
||||
.IP
|
||||
Be cautious about including passwords in scripts\&.
|
||||
.IP
|
||||
.IP "\fB-s smb\&.conf\fP"
|
||||
This parameter specifies the pathname to the
|
||||
Samba configuration file, smb\&.conf\&. This file controls all aspects of
|
||||
the Samba setup on the machine and rpcclient also needs to read this
|
||||
file\&.
|
||||
.IP
|
||||
.IP "\fB-B IP addr\fP"
|
||||
The IP address to use when sending a broadcast packet\&.
|
||||
.IP
|
||||
.IP "\fB-O socket options\fP"
|
||||
TCP socket options to set on the client
|
||||
socket\&. See the socket options
|
||||
parameter in the \fBsmb\&.conf (5)\fP manpage for
|
||||
the list of valid options\&.
|
||||
.IP
|
||||
.IP "\fB-R name resolve order\fP"
|
||||
This option allows the user of
|
||||
rpcclient to determine what name resolution services to use when
|
||||
looking up the NetBIOS name of the host being connected to\&.
|
||||
.IP
|
||||
The options are :"lmhosts", "host", "wins" and "bcast"\&. They cause
|
||||
names to be resolved as follows :
|
||||
.IP
|
||||
.IP
|
||||
.IP o
|
||||
\fBlmhosts\fP : Lookup an IP address in the Samba lmhosts file\&.
|
||||
The lmhosts file is stored in the same directory as the
|
||||
\fBsmb\&.conf\fP file\&.
|
||||
.IP
|
||||
.IP o
|
||||
\fBhost\fP : Do a standard host name to IP address resolution,
|
||||
using the system /etc/hosts, NIS, or DNS lookups\&. This method of name
|
||||
resolution is operating system depended for instance on IRIX or
|
||||
Solaris this may be controlled by the \fI/etc/nsswitch\&.conf\fP file)\&.
|
||||
.IP
|
||||
.IP o
|
||||
\fBwins\fP : Query a name with the IP address listed in the \fBwins
|
||||
server\fP parameter in the smb\&.conf file\&. If
|
||||
no WINS server has been specified this method will be ignored\&.
|
||||
.IP
|
||||
.IP o
|
||||
\fBbcast\fP : Do a broadcast on each of the known local interfaces
|
||||
listed in the \fBinterfaces\fP parameter
|
||||
in the smb\&.conf file\&. This is the least reliable of the name resolution
|
||||
methods as it depends on the target host being on a locally connected
|
||||
subnet\&. To specify a particular broadcast address the \fB-B\fP option
|
||||
may be used\&.
|
||||
.IP
|
||||
.IP
|
||||
If this parameter is not set then the name resolve order defined
|
||||
in the \fBsmb\&.conf\fP file parameter
|
||||
(\fBname resolve order\fP)
|
||||
will be used\&.
|
||||
.IP
|
||||
The default order is lmhosts, host, wins, bcast and without this
|
||||
parameter or any entry in the \fB"name resolve
|
||||
order"\fP parameter of the
|
||||
\fBsmb\&.conf\fP file the name resolution methods
|
||||
will be attempted in this order\&.
|
||||
.IP
|
||||
.IP "\fB-i scope\fP"
|
||||
This specifies a NetBIOS scope that rpcclient will use
|
||||
to communicate with when generating NetBIOS names\&. For details on the
|
||||
use of NetBIOS scopes, see rfc1001\&.txt and rfc1002\&.txt\&. NetBIOS scopes
|
||||
are \fIvery\fP rarely used, only set this parameter if you are the
|
||||
system administrator in charge of all the NetBIOS systems you
|
||||
communicate with\&.
|
||||
.IP
|
||||
.IP "\fB-N\fP"
|
||||
If specified, this parameter suppresses the normal
|
||||
password prompt from the client to the user\&. This is useful when
|
||||
accessing a service that does not require a password\&.
|
||||
.IP
|
||||
Unless a password is specified on the command line or this parameter
|
||||
is specified, the client will request a password\&.
|
||||
.IP
|
||||
.IP "\fB-n NetBIOS name\fP"
|
||||
By default, the client will use the local
|
||||
machine\'s hostname (in uppercase) as its NetBIOS name\&. This parameter
|
||||
allows you to override the host name and use whatever NetBIOS name you
|
||||
wish\&.
|
||||
.IP
|
||||
.IP "\fB-d debuglevel\fP"
|
||||
debuglevel is an integer from 0 to 10, or the
|
||||
letter \'A\'\&.
|
||||
.IP
|
||||
The default value if this parameter is not specified is zero\&.
|
||||
.IP
|
||||
The higher this value, the more detail will be logged to the log files
|
||||
about the activities of the client\&. At level 0, only critical errors
|
||||
and serious warnings will be logged\&. Level 1 is a reasonable level for
|
||||
day to day running - it generates a small amount of information about
|
||||
operations carried out\&.
|
||||
.IP
|
||||
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 debuglevel is set to the
|
||||
letter \'A\', then \fIall\fP debug messages will be printed\&. This setting
|
||||
is for developers only (and people who \fIreally\fP want to know how the
|
||||
code works internally)\&.
|
||||
.IP
|
||||
Note that specifying this parameter here will override the \fBlog
|
||||
level\fP parameter in the \fBsmb\&.conf
|
||||
(5)\fP file\&.
|
||||
.IP
|
||||
.IP "\fB-p port\fP"
|
||||
This number is the TCP port number that will be used
|
||||
when making connections to the server\&. The standard (well-known) TCP
|
||||
port number for an SMB/CIFS server is 139, which is the default\&.
|
||||
.IP
|
||||
.IP "\fB-l logfilename\fP"
|
||||
If specified, logfilename specifies a base
|
||||
filename into which operational data from the running client will be
|
||||
logged\&.
|
||||
.IP
|
||||
The default base name is specified at compile time\&.
|
||||
.IP
|
||||
The base name is used to generate actual log file names\&. For example,
|
||||
if the name specified was "log", the debug file would be
|
||||
\f(CWlog\&.client\fP\&.
|
||||
.IP
|
||||
The log file generated is never removed by the client\&.
|
||||
.IP
|
||||
.IP "\fB-h\fP"
|
||||
Print the usage message for the client\&.
|
||||
.IP
|
||||
.IP "\fB-I IP address\fP"
|
||||
IP address is the address of the server to
|
||||
connect to\&. It should be specified in standard "a\&.b\&.c\&.d" notation\&.
|
||||
.IP
|
||||
Normally the client would attempt to locate a named SMB/CIFS server by
|
||||
looking it up via the NetBIOS name resolution mechanism described
|
||||
above in the \fBname resolve order\fP parameter
|
||||
above\&. Using this parameter will force the client to assume that the
|
||||
server is on the machine with the specified IP address and the NetBIOS
|
||||
name component of the resource being connected to will be ignored\&.
|
||||
.IP
|
||||
There is no default for this parameter\&. If not supplied, it will be
|
||||
determined automatically by the client as described above\&.
|
||||
.IP
|
||||
.IP "\fB-E\fP"
|
||||
This parameter causes the client to write messages to the
|
||||
standard error stream (stderr) rather than to the standard output
|
||||
stream\&.
|
||||
.IP
|
||||
By default, the client writes messages to standard output - typically
|
||||
the user\'s tty\&.
|
||||
.IP
|
||||
Note that by default, debug information is always sent to stderr\&.
|
||||
Debug information can instead be sent to a file, using the
|
||||
-l log basename option\&.
|
||||
.IP
|
||||
.IP "\fB-U username\fP"
|
||||
This specifies the user name that will be used by
|
||||
the client to make a connection, assuming your server is not a downlevel
|
||||
server that is running a protocol level that uses passwords on shares,
|
||||
not on usernames\&.
|
||||
.IP
|
||||
Some servers are fussy about the case of this name, and some insist
|
||||
that it must be a valid NetBIOS name\&.
|
||||
.IP
|
||||
If no username is supplied, it will default to an uppercase version of
|
||||
the environment variable \f(CWUSER\fP or \f(CWLOGNAME\fP in that order\&. If no
|
||||
username is supplied and neither environment variable exists the
|
||||
username "GUEST" will be used\&.
|
||||
.IP
|
||||
If the \f(CWUSER\fP environment variable contains a \'%\' character,
|
||||
everything after that will be treated as a password\&. This allows you
|
||||
to set the environment variable to be \f(CWUSER=username%password\fP so
|
||||
that a password is not passed on the command line (where it may be
|
||||
seen by the ps command)\&.
|
||||
.IP
|
||||
If the service you are connecting to requires a password, it can be
|
||||
supplied using the \fB-U\fP option, by appending a percent symbol ("%")
|
||||
then the password to username\&. For example, to attach to a service as
|
||||
user \f(CW"fred"\fP with password \f(CW"secret"\fP, you would specify\&.
|
||||
.br
|
||||
.IP
|
||||
\f(CW-U fred%secret\fP
|
||||
.br
|
||||
.IP
|
||||
on the command line\&. Note that there are no spaces around the percent
|
||||
symbol\&.
|
||||
.IP
|
||||
If you specify the password as part of username then the \fB-N\fP option
|
||||
(suppress password prompt) is assumed\&.
|
||||
.IP
|
||||
If you specify the password as a parameter \fIAND\fP as part of username
|
||||
then the password as part of username will take precedence\&. Putting
|
||||
nothing before or nothing after the percent symbol will cause an empty
|
||||
username or an empty password to be used, respectively\&.
|
||||
.IP
|
||||
The password may also be specified by setting up an environment
|
||||
variable called \f(CWPASSWORD\fP that contains the users password\&. Note
|
||||
that this may be very insecure on some systems but on others allows
|
||||
users to script rpcclient commands without having a password appear in
|
||||
the command line of a process listing\&.
|
||||
.IP
|
||||
Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password\&. Lowercase or mixed case passwords may be
|
||||
rejected by these servers\&.
|
||||
.IP
|
||||
Be cautious about including passwords in scripts or in the
|
||||
\f(CWPASSWORD\fP environment variable\&. Also, on many systems the command
|
||||
line of a running process may be seen via the \f(CWps\fP command to be
|
||||
safe always allow rpcclient to prompt for a password and type it in
|
||||
directly\&.
|
||||
.IP
|
||||
.IP "\fB-t terminal code\fP"
|
||||
This option tells rpcclient how to interpret
|
||||
filenames coming from the remote server\&. Usually Asian language
|
||||
multibyte UNIX implementations use different character sets than
|
||||
SMB/CIFS servers (\fIEUC\fP instead of \fISJIS\fP for example)\&. Setting
|
||||
this parameter will let rpcclient convert between the UNIX filenames
|
||||
and the SMB filenames correctly\&. This option has not been seriously
|
||||
tested and may have some problems\&.
|
||||
.IP
|
||||
The terminal codes include \f(CWsjis\fP, \f(CWeuc\fP, \f(CWjis7\fP, \f(CWjis8\fP,
|
||||
\f(CWjunet\fP, \f(CWhex\fP, \f(CWcap\fP\&. This is not a complete list, check the
|
||||
Samba source code for the complete list\&.
|
||||
.IP
|
||||
.IP "\fB-m max protocol level\fP"
|
||||
With the new code in Samba2\&.0,
|
||||
\fBrpcclient\fP always attempts to connect at the maximum
|
||||
protocols level the server supports\&. This parameter is
|
||||
preserved for backwards compatibility, but any string
|
||||
following the \fB-m\fP will be ignored\&.
|
||||
.IP
|
||||
.IP "\fB-W Domain\fP"
|
||||
Override the default Domain, which is the remote server\'s
|
||||
Domain\&. This option may be needed to connect to some servers\&. It is also
|
||||
possible to specify the remote server name as the Domain, which will
|
||||
force the username and password to be authenticated against the remote
|
||||
server\'s local SAM instead of the Domain SAM\&.
|
||||
.IP
|
||||
.IP "\fB-c command string\fP"
|
||||
command string is a semicolon separated
|
||||
list of commands to be executed instead of prompting from stdin\&.
|
||||
\fB-N\fP is implied by \fB-c\fP\&.
|
||||
.IP
|
||||
This is particularly useful in scripts, e\&.g\&. \f(CW-c \'lsaquery; enumusers -u\'\fP\&.
|
||||
.IP
|
||||
.PP
|
||||
.SH "OPERATIONS"
|
||||
.PP
|
||||
Once the client is running, the user is presented with a prompt :
|
||||
.PP
|
||||
\f(CWsmb:\e>\fP
|
||||
.PP
|
||||
The prompt indicates that the client is ready and waiting to carry out
|
||||
a user command\&. Each command is a single word, optionally followed by
|
||||
parameters specific to that command\&. Command and parameters are
|
||||
space-delimited unless these notes specifically state otherwise\&. All
|
||||
commands are case-insensitive\&. Parameters to commands may or may not
|
||||
be case sensitive, depending on the command\&.
|
||||
.PP
|
||||
You can specify names (e\&.g registry keys; user or group names;
|
||||
service names) which have spaces in them by quoting the
|
||||
name with double quotes, for example "dRMON SmartAgent"\&.
|
||||
.PP
|
||||
Parameters shown in square brackets (e\&.g\&., "[parameter]") are
|
||||
optional\&. If not given, the command will use suitable
|
||||
defaults\&. Parameters shown in angle brackets (e\&.g\&., "<parameter>") are
|
||||
required\&.
|
||||
.PP
|
||||
Note that all commands operating on the server are actually performed
|
||||
by issuing a request to the server\&. Thus the behavior may vary from
|
||||
server to server, depending on how the server was implemented\&.
|
||||
.PP
|
||||
The commands available are listed in groups relating to different services:
|
||||
.PP
|
||||
.IP
|
||||
.IP "Misccellaneous"
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fB? [command]\fP"
|
||||
If "command" is specified,
|
||||
the \fB?\fP command will display a brief informative message about the
|
||||
specified command\&. If no command is specified, a list of available
|
||||
commands will be displayed\&.
|
||||
.IP
|
||||
.IP "\fB! [shell command]\fP"
|
||||
If "shell command"
|
||||
is specified, the \fB!\fP command will execute a shell locally and run
|
||||
the specified shell command\&. If no command is specified, a local shell
|
||||
will be run\&.
|
||||
.IP
|
||||
.IP "\fBexit\fP"
|
||||
Terminate the connection with the server and
|
||||
exit from the program\&.
|
||||
.IP
|
||||
.IP "\fBhelp [command]\fP"
|
||||
See the \fB?\fP
|
||||
command above\&.
|
||||
.IP
|
||||
.IP "\fBquit\fP"
|
||||
See the \fBexit\fP command\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "Event Log"
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBeventlog\fP"
|
||||
list the events
|
||||
.IP
|
||||
.IP
|
||||
.IP "Service Control"
|
||||
.IP
|
||||
These commands provide functionality similar to the Windows
|
||||
NT Service Control Manager\&.
|
||||
.IP
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Service names, by pressing the
|
||||
tab key\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBsvcenum\fP"
|
||||
[-i] Lists Services\&.
|
||||
.IP
|
||||
.IP "\fBsvcinfo\fP"
|
||||
<service> Service Information
|
||||
.IP
|
||||
.IP "\fBsvcstart\fP"
|
||||
<service> [arg 0] [arg 1] \&.\&.\&. Start Service
|
||||
.IP
|
||||
.IP "\fBsvcstop\fP"
|
||||
<service> Stop Service
|
||||
.IP
|
||||
.IP
|
||||
.IP "Scheduler"
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBat\fP"
|
||||
Scheduler control (at /? for syntax)
|
||||
.IP
|
||||
.IP
|
||||
.IP "Registry"
|
||||
.IP
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for registry key and value names,
|
||||
by pressing the tab key\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBregenum\fP"
|
||||
<keyname> Registry Enumeration (keys, values)
|
||||
.IP
|
||||
.IP "\fBregdeletekey\fP"
|
||||
<keyname> Registry Key Delete
|
||||
.IP
|
||||
.IP "\fBregcreatekey\fP"
|
||||
<keyname> [keyclass] Registry Key Create
|
||||
.IP
|
||||
.IP "\fBshutdown\fP"
|
||||
[-m message] [-t timeout] [-r or --reboot] Server Shutdown
|
||||
.IP
|
||||
.IP "\fBregqueryval\fP"
|
||||
<valname> Registry Value Query
|
||||
.IP
|
||||
.IP "\fBregquerykey\fP"
|
||||
<keyname> Registry Key Query
|
||||
.IP
|
||||
.IP "\fBregdeleteval\fP"
|
||||
<valname> Registry Value Delete
|
||||
.IP
|
||||
.IP "\fBregcreateval\fP"
|
||||
<valname> <valtype> <value> Registry Key Create
|
||||
.IP
|
||||
.IP "\fBreggetsec\fP"
|
||||
<keyname> Registry Key Security
|
||||
.IP
|
||||
.IP "\fBregtestsec\fP"
|
||||
<keyname> Test Registry Key Security
|
||||
.IP
|
||||
.IP
|
||||
.IP "Printing"
|
||||
.IP
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Printer and job names, by
|
||||
pressing the tab key\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBspoolenum\fP"
|
||||
Enumerate Printers\&. This experimental command lists
|
||||
all printers available on a remote spooler service\&.
|
||||
.IP
|
||||
.IP "\fBspooljobs\fP"
|
||||
<printer name> Enumerate Printer Jobs\&. This
|
||||
experimental command lists all jobs, and their
|
||||
status, currently queued on a remote spooler
|
||||
service\&.
|
||||
.IP
|
||||
.IP "\fBspoolopen\fP"
|
||||
<printer name> Spool Printer Open Test\&. Experimental\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "Server"
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBtime\fP"
|
||||
Display remote time
|
||||
.IP
|
||||
.IP "\fBbrsinfo\fP"
|
||||
Browser Query Info
|
||||
.IP
|
||||
.IP "\fBwksinfo\fP"
|
||||
Workstation Query Info
|
||||
.IP
|
||||
.IP "\fBsrvinfo\fP"
|
||||
Server Query Info
|
||||
.IP
|
||||
.IP "\fBsrvsessions\fP"
|
||||
List sessions on a server
|
||||
.IP
|
||||
.IP "\fBsrvshares\fP"
|
||||
List shares on a server
|
||||
.IP
|
||||
.IP "\fBsrvtransports\fP"
|
||||
List transports on a server
|
||||
.IP
|
||||
.IP "\fBsrvconnections\fP"
|
||||
List connections on a server
|
||||
.IP
|
||||
.IP "\fBsrvfiles\fP"
|
||||
List files on a server
|
||||
.IP
|
||||
.IP
|
||||
.IP "Local Security Authority"
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBlsaquery\fP"
|
||||
Query Info Policy (domain member or server)\&. Obtains
|
||||
the SID and name of the SAM database that a server
|
||||
is responsible for (i\&.e a workstation\'s local SAM
|
||||
database or the PDC SAM database)\&. Also obtains the
|
||||
SID and name of the SAM database that a server is
|
||||
a member of\&.
|
||||
.IP
|
||||
.IP "\fBlsaenumdomains\fP"
|
||||
Enumerate Trusted Domains\&. Lists all Trusted and
|
||||
Trusting Domains with which the remote PDC has
|
||||
trust relationships established\&.
|
||||
.IP
|
||||
.IP "\fBlookupsids\fP"
|
||||
<rid1 or sid1> <rid1 or sid2> \&.\&.\&. Resolve names from SIDs\&.
|
||||
Mostly to be used by developers or for troubleshooting,
|
||||
this command can take either Security Identifiers or Relative
|
||||
Identifiers, and look them up in the local SAM database
|
||||
(or look them up in a remote Trusting or Trusted PDC\'s SAM
|
||||
database if there is an appropriate Trust Relationship
|
||||
established)\&. The result is a list of names, of the
|
||||
format:
|
||||
.br
|
||||
\f(CW[TRUST_DOMAIN\e]name\fP\&.
|
||||
.br
|
||||
the \fBlsaquery\fP command must have been
|
||||
issued first if you wish to use lookupsids to resolve
|
||||
RIDs\&. The only RIDs that will be resolved will be those
|
||||
in the SAM database of the server to which you are connected\&.
|
||||
.IP
|
||||
.IP "\fBlookupnames\fP"
|
||||
<name1> <name2> \&.\&.\&. Resolve SIDs from names\&.
|
||||
Mostly to be used by developers or for troubleshooting,
|
||||
this command can take names of the following format:
|
||||
.br
|
||||
\f(CW[DOMAIN_NAME\e]name\fP\&.
|
||||
.br
|
||||
The names, which can be user, group or alias names, will
|
||||
either be looked up in the local SAM database or in a remote
|
||||
Trusting or Trusted PDC\'s SAM database, if there is an
|
||||
appropriate Trust Relationship established\&. The optional
|
||||
Domain name component is the name of a SAM database, which
|
||||
can include a workstation\'s local SAM database or a Trusted
|
||||
Domain\&.
|
||||
Example Usage:
|
||||
.br
|
||||
\f(CWlookupnames WKSTANAME\eAdministrator "Domain Guests"\fP
|
||||
.br
|
||||
.IP
|
||||
.IP "\fBquerysecret\fP"
|
||||
LSA Query Secret (developer use)\&. This command only appears
|
||||
to work against NT4 SP3 and below\&. Due to its potential
|
||||
for misuse, it looks like Microsoft modified their
|
||||
implementation of the LsaRetrievePrivateData call to
|
||||
always return NT_STATUS_ACCESS_DENIED\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "NETLOGON"
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBntlogin\fP"
|
||||
[username] [password] NT Domain login test\&. Demonstrates
|
||||
how NT-style logins work\&. Mainly for developer usage,
|
||||
it can also be used to verify that a user can log in
|
||||
from a workstation\&. If you cannot ever get pam_ntdom
|
||||
to work, try this command first\&.
|
||||
.IP
|
||||
.IP "\fBdomtrust\fP"
|
||||
<domain> NT Inter-Domain test\&. Demonstrates how NT-style
|
||||
Inter-Domain Trust relationships work\&. Mainly for
|
||||
developer usage, it can also be used to verify that a
|
||||
Trust Relationship is correctly established with a
|
||||
remote PDC\&.
|
||||
.IP
|
||||
.IP "\fBsamsync\fP"
|
||||
SAM Synchronisation Test (experimental)\&. This command
|
||||
is used to manually synchronise a SAM database from a
|
||||
remote PDC, when Samba is set up as a Backup Domain
|
||||
Controller\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "SAM Database"
|
||||
.IP
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for user, group, alias and domain
|
||||
names, by pressing the tab key\&.
|
||||
.IP
|
||||
.IP
|
||||
.IP "\fBlookupdomain\fP"
|
||||
Obtain SID for a local domain
|
||||
.IP
|
||||
.IP "\fBenumusers\fP"
|
||||
SAM User Database Query (experimental!)
|
||||
.IP
|
||||
.IP "\fBaddgroupmem\fP"
|
||||
<group rid> [user] [user] \&.\&.\&. SAM Add Domain Group Member
|
||||
.IP
|
||||
.IP "\fBaddaliasmem\fP"
|
||||
<alias rid> [member sid1] [member sid2] \&.\&.\&. SAM Add Domain Alias Member
|
||||
.IP
|
||||
.IP "\fBdelgroupmem\fP"
|
||||
<group rid> [user] [user] \&.\&.\&. SAM Delete Domain Group Member
|
||||
.IP
|
||||
.IP "\fBdelaliasmem\fP"
|
||||
<alias rid> [member sid1] [member sid2] \&.\&.\&. SAM Delete Domain Alias Member
|
||||
.IP
|
||||
.IP "\fBcreategroup\fP"
|
||||
SAM Create Domain Group
|
||||
.IP
|
||||
.IP "\fBcreatealias\fP"
|
||||
SAM Create Domain Alias
|
||||
.IP
|
||||
.IP "\fBcreateuser\fP"
|
||||
<username> SAM Create Domain User
|
||||
.IP
|
||||
.IP "\fBdelgroup\fP"
|
||||
SAM Delete Domain Group
|
||||
.IP
|
||||
.IP "\fBdelalias\fP"
|
||||
SAM Delete Domain Alias
|
||||
.IP
|
||||
.IP "\fBntpass\fP"
|
||||
NT SAM Password Change
|
||||
.IP
|
||||
.IP "\fBsamuserset2\fP"
|
||||
<username> [-s acb_bits] SAM User Set Info 2 (experimental!)
|
||||
.IP
|
||||
.IP "\fBsamuserset\fP"
|
||||
<username> [-p password] SAM User Set Info (experimental!)
|
||||
.IP
|
||||
.IP "\fBsamuser\fP"
|
||||
<username> SAM User Query (experimental!)
|
||||
.IP
|
||||
.IP "\fBsamgroup\fP"
|
||||
<groupname> SAM Group Query (experimental!)
|
||||
.IP
|
||||
.IP "\fBsamalias\fP"
|
||||
<aliasname> SAM Alias Query
|
||||
.IP
|
||||
.IP "\fBsamaliasmem\fP"
|
||||
<aliasname> SAM Alias Members
|
||||
.IP
|
||||
.IP "\fBsamgroupmem\fP"
|
||||
SAM Group Members
|
||||
.IP
|
||||
.IP "\fBsamtest\fP"
|
||||
SAM User Encrypted RPC test (experimental!)
|
||||
.IP
|
||||
.IP "\fBenumaliases\fP"
|
||||
SAM Aliases Database Query (experimental!)
|
||||
.IP
|
||||
.IP "\fBenumdomains\fP"
|
||||
SAM Domains Database Query (experimental!)
|
||||
.IP
|
||||
.IP "\fBenumgroups\fP"
|
||||
SAM Group Database Query (experimental!)
|
||||
.IP
|
||||
.IP "\fBdominfo\fP"
|
||||
SAM Query Domain Info
|
||||
.IP
|
||||
.IP "\fBdispinfo\fP"
|
||||
SAM Query Display Info
|
||||
.IP
|
||||
.IP
|
||||
.PP
|
||||
.SH "NOTES"
|
||||
.PP
|
||||
Some servers are fussy about the case of supplied usernames,
|
||||
passwords, share names (AKA service names) and machine names\&. If you
|
||||
fail to connect try giving all parameters in uppercase\&.
|
||||
.PP
|
||||
It is often necessary to use the \fB-n\fP option when connecting
|
||||
to some types of servers\&. For example OS/2 LanManager insists on a valid
|
||||
NetBIOS name being used, so you need to supply a valid name that would
|
||||
be known to the server\&.
|
||||
.PP
|
||||
rpcclient only works on servers that support MSRPC over SMB\&. This includes
|
||||
all versions of Windows NT, including the ports to Unix such as AS/U and
|
||||
AFPS\&. Support for MSRPC over SMB in other servers is currently rare and
|
||||
patchy, for example Samba 2\&.0 only supports a limited set of MSRPC commands,
|
||||
and some of those are not supported very well\&.
|
||||
.PP
|
||||
.SH "ENVIRONMENT VARIABLES"
|
||||
.PP
|
||||
The variable \fBUSER\fP may contain the username of the person using the
|
||||
client\&. This information is used only if the protocol level is high
|
||||
enough to support session-level passwords\&.
|
||||
.PP
|
||||
The variable \fBPASSWORD\fP may contain the password of the person using
|
||||
the client\&. This information is used only if the protocol level is
|
||||
high enough to support session-level passwords\&.
|
||||
.PP
|
||||
.SH "INSTALLATION"
|
||||
.PP
|
||||
The location of the client program is a matter for individual system
|
||||
administrators\&. The following are thus suggestions only\&.
|
||||
.PP
|
||||
It is recommended that the rpcclient software be installed in the
|
||||
/usr/local/samba/bin or /usr/samba/bin directory, this directory
|
||||
readable by all, writeable only by root\&. The client program itself
|
||||
should be executable by all\&. The client should \fINOT\fP be setuid or
|
||||
setgid!
|
||||
.PP
|
||||
The client log files should be put in a directory readable and
|
||||
writeable only by the user\&.
|
||||
.PP
|
||||
To test the client, you will need to know the name of a running
|
||||
SMB/CIFS server\&. It is possible to run \fBsmbd (8)\fP
|
||||
an ordinary user - running that server as a daemon on a
|
||||
user-accessible port (typically any port number over 1024) would
|
||||
provide a suitable test server\&.
|
||||
.PP
|
||||
.SH "DIAGNOSTICS"
|
||||
.PP
|
||||
Most diagnostics issued by the client are logged in a specified log
|
||||
file\&. The log file name is specified at compile time, but may be
|
||||
overridden on the command line\&.
|
||||
.PP
|
||||
The number and nature of diagnostics available depends on the debug
|
||||
level used by the client\&. If you have problems, set the debug level to
|
||||
3 and peruse the log files\&.
|
||||
.PP
|
||||
.SH "VERSION"
|
||||
.PP
|
||||
This man page is correct for version 2\&.0 of the Samba suite\&.
|
||||
.PP
|
||||
.SH "BUGS"
|
||||
.PP
|
||||
.IP "WARNING!"
|
||||
The MSPRC over SMB code has been developed from examining Network traces\&.
|
||||
No documentation is available from the original creators (Microsoft) on
|
||||
how MSRPC over SMB works, or how the individual MSRPC services work\&.
|
||||
Microsoft\'s implementation of these services has been demonstrated (and
|
||||
reported) to be\&.\&.\&. a bit flakey in places\&.
|
||||
.IP
|
||||
The development of Samba\'s implementation of these services is \fIalso\fP
|
||||
a bit rough, and as more of the services are understood, it can even result
|
||||
in versions of \fBsmbd (8)\fP and rpcclient that are
|
||||
incompatible for some commands or services\&. Additionally, the developers
|
||||
are sending reports to Microsoft, and problems found by or reported to
|
||||
Microsoft are fixed in Service Packs, which may also result in
|
||||
incompatibilities\&.
|
||||
.IP
|
||||
It is therefore not guaranteed that the execution of an rpcclient command will
|
||||
work\&. It is also not guaranteed that the target server will continue to
|
||||
operate, i\&.e the execution of an MSRPC command may cause a remote service to
|
||||
fail, or even cause the remote server to fail\&. Usual rules apply, of course:
|
||||
the developers bear absolutely no responsibility for the use, misuse, or
|
||||
lack of use of rpcclient, by any person or persons, whether legal,
|
||||
illegal, accidental, deliberate, intentional, malicious, curious, etc\&.
|
||||
.IP
|
||||
.IP "Command Completion"
|
||||
Command-completion (available if you have the GNU readline library) used on
|
||||
certain commands may not operate correctly if the word being completed (such as a registry key) contains a space\&. Typically, the name will be completed, but
|
||||
you will have to go back and put quotes round it, yourself\&.
|
||||
.IP
|
||||
.IP "SAM Database command-completion"
|
||||
Command-completion (available if you have the GNU readline library) of user,
|
||||
group and alias names does not work on remote Domains, which would normally
|
||||
be specified like this:
|
||||
.br
|
||||
\f(CWDOMAIN_name\euser_name\fP\&.
|
||||
.br
|
||||
The only names that can be completed in this fashion are the local names
|
||||
in the SAM database of the target server\&.
|
||||
.IP
|
||||
.IP "\fBspoolenum\fP"
|
||||
Due to current limitations in the rpcclient MSRPC / SMB code, and due to
|
||||
the extremely poor MSRPC implementation (by Microsoft) of the spooler
|
||||
service, if there are a large number of printers (or the names / comment
|
||||
fields associated with the printers), this command will fail\&. The
|
||||
limitations require further research to be carried out; we\'re stuck with
|
||||
the poor \ePIPE\espoolss design\&.
|
||||
.IP
|
||||
.PP
|
||||
.SH "AUTHOR"
|
||||
.PP
|
||||
The original Samba software and related utilities were created by
|
||||
Andrew Tridgell \fIsamba-bugs@samba\&.org\fP\&. Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed\&.
|
||||
.PP
|
||||
The original Samba man pages were written by Karl Auer\&. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
\fBftp://ftp\&.icce\&.rug\&.nl/pub/unix/\fP)
|
||||
and updated for the Samba2\&.0 release by Jeremy Allison\&. This man page
|
||||
was developed cut-and-paste style from the smbclient man page, by
|
||||
Luke Kenneth Casson Leighton\&.
|
||||
\fIsamba-bugs@samba\&.org\fP\&.
|
||||
.PP
|
||||
See \fBsamba (7)\fP to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc\&.
|
||||
.PP
|
@ -1,150 +0,0 @@
|
||||
|
||||
TITLE INFORMATION: LDAP Support in Samba
|
||||
AUTHOR INFORMATION: Matthew Chapman
|
||||
DATE INFORMATION: 29th November 1998
|
||||
|
||||
WARNING: This is experimental code. Use at your own risk, and please report
|
||||
any bugs (after reading BUGS.txt).
|
||||
|
||||
Contents
|
||||
|
||||
1: What is LDAP?
|
||||
2: Why LDAP and Samba?
|
||||
3: Using LDAP with Samba
|
||||
4: Using LDAP for Unix authentication
|
||||
5: Compatibility with Active Directory
|
||||
|
||||
1: What is LDAP?
|
||||
|
||||
A directory is a type of hierarchical database optimised for simple query
|
||||
operations, often used for storing user information. LDAP is the
|
||||
Lightweight Directory Access Protocol, a protocol which is rapidly
|
||||
becoming the Internet standard for accessing directories.
|
||||
|
||||
Many client applications now support LDAP (including Microsoft's Active
|
||||
Directory), and there are a number of servers available. The most popular
|
||||
implementation for Unix is from the University of Michigan; its
|
||||
homepage is at http://www.umich.edu/~dirsvcs/ldap/.
|
||||
|
||||
Information in an LDAP tree always comes in attribute=value pairs.
|
||||
The following is an example of a Samba user entry:
|
||||
|
||||
uid=jbloggs, dc=samba, dc=org
|
||||
objectclass=sambaAccount
|
||||
uid=jbloggs
|
||||
cn=Joe Bloggs
|
||||
description=Samba User
|
||||
uidNumber=500
|
||||
gidNumber=500
|
||||
rid=2000
|
||||
grouprid=2001
|
||||
lmPassword=46E389809F8D55BB78A48108148AD508
|
||||
ntPassword=1944CCE1AD6F80D8AEC9FC5BE77696F4
|
||||
pwdLastSet=35C11F1B
|
||||
smbHome=\\samba1\jbloggs
|
||||
homeDrive=Z
|
||||
script=logon.bat
|
||||
profile=\\samba1\jbloggs\profile
|
||||
workstations=JOE
|
||||
|
||||
Note that the top line is a special set of attributes called a
|
||||
distinguished name which identifies the location of this entry beneath
|
||||
the directory's root node. Recent Internet standards suggest the use of
|
||||
domain-based naming using dc attributes (for instance, a microsoft.com
|
||||
directory should have a root node of dc=microsoft, dc=com), although
|
||||
this is not strictly necessary for isolated servers.
|
||||
|
||||
There are a number of LDAP-related FAQ's on the internet, although
|
||||
generally the best source of information is the documentation for the
|
||||
individual servers.
|
||||
|
||||
2: Why LDAP and Samba?
|
||||
|
||||
Using an LDAP directory allows Samba to store user and group information
|
||||
more reliably and flexibly than the current combination of smbpasswd,
|
||||
smbgroup, groupdb and aliasdb with the Unix databases. If a need emerges
|
||||
for extra user information to be stored, this can easily be added without
|
||||
loss of backwards compatibility.
|
||||
|
||||
In addition, the Samba LDAP schema is compatible with RFC2307, allowing
|
||||
Unix password database information to be stored in the same entries. This
|
||||
provides a single, consistent repository for both Unix and Windows user
|
||||
information.
|
||||
|
||||
3: Using LDAP with Samba
|
||||
|
||||
1 Install and configure an LDAP server if you do not already have
|
||||
one. You should read your LDAP server's documentation and set up the
|
||||
configuration file and access control as desired.
|
||||
|
||||
2 Build Samba (latest CVS is required) with:
|
||||
|
||||
./configure --with-ldap
|
||||
make clean; make install
|
||||
|
||||
3 Add the following options to the global section of smb.conf as
|
||||
required.
|
||||
|
||||
o ldap suffix
|
||||
|
||||
This parameter specifies the node of the LDAP tree beneath which
|
||||
Samba should store its information. This parameter MUST be provided
|
||||
when using LDAP with Samba.
|
||||
|
||||
Default: none
|
||||
|
||||
Example: ldap suffix = "dc=mydomain, dc=org"
|
||||
|
||||
o ldap bind as
|
||||
|
||||
This parameter specifies the entity to bind to an LDAP directory as.
|
||||
Usually it should be safe to use the LDAP root account; for larger
|
||||
installations it may be preferable to restrict Samba's access.
|
||||
|
||||
Default: none (bind anonymously)
|
||||
|
||||
Example: ldap bind as = "uid=root, dc=mydomain, dc=org"
|
||||
|
||||
o ldap passwd file
|
||||
|
||||
This parameter specifies a file containing the password with which
|
||||
Samba should bind to an LDAP server. For obvious security reasons
|
||||
this file must be set to mode 700 or less.
|
||||
|
||||
Default: none (bind anonymously)
|
||||
|
||||
Example: ldap passwd file = /usr/local/samba/private/ldappasswd
|
||||
|
||||
o ldap server
|
||||
|
||||
This parameter specifies the DNS name of the LDAP server to use
|
||||
when storing and retrieving information about Samba users and
|
||||
groups.
|
||||
|
||||
Default: ldap server = localhost
|
||||
|
||||
o ldap port
|
||||
|
||||
This parameter specifies the TCP port number of the LDAP server.
|
||||
|
||||
Default: ldap port = 389
|
||||
|
||||
4 You should then be able to use the normal smbpasswd(8) command for
|
||||
account administration (or User Manager in the near future).
|
||||
|
||||
4: Using LDAP for Unix authentication
|
||||
|
||||
The Samba LDAP code was designed to utilise RFC2307-compliant directory
|
||||
entries if available. RFC2307 is a proposed standard for LDAP user
|
||||
information which has been adopted by a number of vendors. Further
|
||||
information is available at http://www.xedoc.com.au/~lukeh/ldap/.
|
||||
|
||||
Of particular interest is Luke Howard's nameservice switch module
|
||||
(nss_ldap) and PAM module (pam_ldap) implementing this standard, providing
|
||||
LDAP-based password databases for Unix. If you are setting up a server to
|
||||
provide integrated Unix/NT services than these are worth investigating.
|
||||
|
||||
5: Compatibility with Active Directory
|
||||
|
||||
The current implementation is not designed to be used with Microsoft
|
||||
Active Directory, although compatibility may be added in the future.
|
@ -1,51 +0,0 @@
|
||||
Date: February 26, 1999
|
||||
|
||||
Subject: smbmount / smbmnt / smbumount
|
||||
=============================================================================
|
||||
|
||||
The Samba-Team wishes to make known that the above programs are a part of
|
||||
the SMBFS software package for the Linux operating system. They are very
|
||||
definitely NOT part of Samba and are in general NOT supported by the
|
||||
Samba-Team.
|
||||
|
||||
In repsonse to flames to comp.protocols.smb and to feedback to
|
||||
samba-bugs@samba.org we wish to place on record that the reason for which
|
||||
these programs have not received the attention that some folks expect
|
||||
from the Samba-Team is as stated above, they are NOT part of samba.
|
||||
|
||||
Out of empathy for the Samba user base we have taken the liberty of
|
||||
including patched source code for the above "SMBFS package" utilities
|
||||
in the Samba tarball.
|
||||
|
||||
Mike Warfield is temporary caretaker of SMBFS and may be contacted at
|
||||
mike@samba.org.
|
||||
|
||||
In deference to the fact that these programs are NOT part of Samba
|
||||
the default binary packaging facilities included in the samba tarball
|
||||
do NOT automatically create the updates needed for the Linux 2.2.x
|
||||
kernel. If you require the updated smbmount / smbmnt / smbumount tools
|
||||
then it will be necessary to modify the samba2.spec file to include
|
||||
the --with-smbmount option to the samba "configure" script _AND_
|
||||
you will need to add these files to the appropriate locations in the "install"
|
||||
and "files" sections also. The platform specific RPM SPEC files that you
|
||||
will need to modify may be found under ~samba/packaging/"platform".
|
||||
|
||||
The Samba-Team has considered the alternatives. These are:
|
||||
1) Include all SMBFS code with Samba:
|
||||
- rejected because we do not have the resources to support it.
|
||||
- SMBFS is specific and limited to Linux
|
||||
2) Just build the smbmount / smbmnt / smbumount binaries:
|
||||
- doing this will break RPM dependencies for the SMBFS package
|
||||
- this is not a good option either
|
||||
3) Encourage people to use the "smbsh" utility that is part of samba
|
||||
and is being developed to replace the need for "SMBFS"
|
||||
- this is portable to platforms other than Linux
|
||||
- it allows each user to authenticate as themselves instead
|
||||
of allowing all users to use an SMB session that is
|
||||
authenticated as just one user.
|
||||
|
||||
We have chosen the later and hope that our users will understand and support
|
||||
the decision that has been made.
|
||||
|
||||
For and on behalf of the Samba-Team
|
||||
John H Terpstra
|
@ -1,685 +0,0 @@
|
||||
|
||||
TITLE INFORMATION: rpcclient (1)
|
||||
AUTHOR INFORMATION: Samba SAMBA
|
||||
DATE INFORMATION: 23 Oct 1998
|
||||
|
||||
NAME
|
||||
rpcclient - utility to manage MSRPC resources on servers
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
rpcclient
|
||||
[password]
|
||||
-S servername
|
||||
[-U [username][%][password]]
|
||||
[-W domain]
|
||||
[-l log basename]
|
||||
[-d debuglevel]
|
||||
[-O socket options]
|
||||
[-i scope]
|
||||
[-N]
|
||||
[-n NetBIOS name]
|
||||
[-h]
|
||||
[-I dest IP]
|
||||
[-E]
|
||||
[-t terminal code]
|
||||
[-c command string]
|
||||
[-B IP addr]
|
||||
[-s smb.conf]
|
||||
[-m max protocol]
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
This program is part of the Samba suite.
|
||||
|
||||
rpcclient is a client that can 'talk' to an SMB/CIFS MSRPC server.
|
||||
Operations include things like managing a SAM Database (users, groups
|
||||
and aliases) in the same way as the Windows NT programs
|
||||
User Manager for Domains and Server Manager for Domains;
|
||||
managing a remote registry in the same way as the Windows NT programs
|
||||
REGEDT32.EXE and REGEDIT.EXE; viewing a remote event log (same
|
||||
as EVENTVWR.EXE) etc.
|
||||
|
||||
Typical usage is like this:
|
||||
|
||||
rpcclient -I 192.168.32.1 -S "*SMBSERVER" -U fred%secret -l log
|
||||
|
||||
OPTIONS
|
||||
|
||||
o servername servername is the name of the server you want
|
||||
to use on the server. This should be the NetBIOS name of the SMB/CIFS
|
||||
server, which can be *SMBSERVER on Windows NT 4.0 or Samba Servers.
|
||||
|
||||
Note that the server name required is NOT necessarily the IP (DNS)
|
||||
host name of the server! The name required is a NetBIOS server name,
|
||||
which may or may not be the same as the IP hostname of the machine
|
||||
running the server. Also, remember that having a period in a NetBIOS
|
||||
name (such as an IP hostname) may cause connectivity problems on your
|
||||
network: NT tends to strip NetBIOS names from the leading period
|
||||
onwards.
|
||||
|
||||
The server name is looked up according to either the
|
||||
-R parameter to rpcclient or using the
|
||||
name resolve order
|
||||
parameter in the smb.conf file, allowing an administrator to change
|
||||
the order and methods by which server names are looked up.
|
||||
|
||||
o password password is the password required to access the
|
||||
specified service on the specified server. If this parameter is
|
||||
supplied, the -N option (suppress password prompt) is assumed.
|
||||
|
||||
There is no default password. If no password is supplied on the
|
||||
command line (either by using this parameter or adding a password to
|
||||
the -U option (see below)) and the -N option is not specified,
|
||||
the client will prompt for a password, even if the desired service
|
||||
does not require one. (If no password is required, simply press ENTER
|
||||
to provide a null password.)
|
||||
|
||||
Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password. Lowercase or mixed case passwords may be
|
||||
rejected by these servers.
|
||||
|
||||
Be cautious about including passwords in scripts.
|
||||
|
||||
o -s smb.conf This parameter specifies the pathname to the
|
||||
Samba configuration file, smb.conf. This file controls all aspects of
|
||||
the Samba setup on the machine and rpcclient also needs to read this
|
||||
file.
|
||||
|
||||
o -B IP addr The IP address to use when sending a broadcast packet.
|
||||
|
||||
o -O socket options TCP socket options to set on the client
|
||||
socket. See the socket options
|
||||
parameter in the smb.conf (5) manpage for
|
||||
the list of valid options.
|
||||
|
||||
o -R name resolve order This option allows the user of
|
||||
rpcclient to determine what name resolution services to use when
|
||||
looking up the NetBIOS name of the host being connected to.
|
||||
|
||||
The options are :"lmhosts", "host", "wins" and "bcast". They cause
|
||||
names to be resolved as follows :
|
||||
|
||||
o lmhosts : Lookup an IP address in the Samba lmhosts file.
|
||||
The lmhosts file is stored in the same directory as the
|
||||
smb.conf file.
|
||||
|
||||
o host : Do a standard host name to IP address resolution,
|
||||
using the system /etc/hosts, NIS, or DNS lookups. This method of name
|
||||
resolution is operating system depended for instance on IRIX or
|
||||
Solaris this may be controlled by the /etc/nsswitch.conf file).
|
||||
|
||||
o wins : Query a name with the IP address listed in the wins
|
||||
server parameter in the smb.conf file. If
|
||||
no WINS server has been specified this method will be ignored.
|
||||
|
||||
o bcast : Do a broadcast on each of the known local interfaces
|
||||
listed in the interfaces parameter
|
||||
in the smb.conf file. This is the least reliable of the name resolution
|
||||
methods as it depends on the target host being on a locally connected
|
||||
subnet. To specify a particular broadcast address the -B option
|
||||
may be used.
|
||||
|
||||
If this parameter is not set then the name resolve order defined
|
||||
in the smb.conf file parameter
|
||||
(name resolve order)
|
||||
will be used.
|
||||
|
||||
The default order is lmhosts, host, wins, bcast and without this
|
||||
parameter or any entry in the "name resolve
|
||||
order" parameter of the
|
||||
smb.conf file the name resolution methods
|
||||
will be attempted in this order.
|
||||
|
||||
o -i scope This specifies a NetBIOS scope that rpcclient will use
|
||||
to communicate with when generating NetBIOS names. For details on the
|
||||
use of NetBIOS scopes, see rfc1001.txt and rfc1002.txt. NetBIOS scopes
|
||||
are very rarely used, only set this parameter if you are the
|
||||
system administrator in charge of all the NetBIOS systems you
|
||||
communicate with.
|
||||
|
||||
o -N If specified, this parameter suppresses the normal
|
||||
password prompt from the client to the user. This is useful when
|
||||
accessing a service that does not require a password.
|
||||
|
||||
Unless a password is specified on the command line or this parameter
|
||||
is specified, the client will request a password.
|
||||
|
||||
o -n NetBIOS name By default, the client will use the local
|
||||
machine's hostname (in uppercase) as its NetBIOS name. This parameter
|
||||
allows you to override the host name and use whatever NetBIOS name you
|
||||
wish.
|
||||
|
||||
o -d debuglevel debuglevel is an integer from 0 to 10, or the
|
||||
letter 'A'.
|
||||
|
||||
The default value if this parameter is not specified is zero.
|
||||
|
||||
The higher this value, the more detail will be logged to the log files
|
||||
about the activities of the client. At level 0, only critical errors
|
||||
and serious warnings will be logged. Level 1 is a reasonable level for
|
||||
day to day running - it generates a small amount of information about
|
||||
operations carried out.
|
||||
|
||||
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 debuglevel is set to the
|
||||
letter 'A', then all debug messages will be printed. This setting
|
||||
is for developers only (and people who really want to know how the
|
||||
code works internally).
|
||||
|
||||
Note that specifying this parameter here will override the log
|
||||
level parameter in the smb.conf
|
||||
(5) file.
|
||||
|
||||
o -p port This number is the TCP port number that will be used
|
||||
when making connections to the server. The standard (well-known) TCP
|
||||
port number for an SMB/CIFS server is 139, which is the default.
|
||||
|
||||
o -l logfilename If specified, logfilename specifies a base
|
||||
filename into which operational data from the running client will be
|
||||
logged.
|
||||
|
||||
The default base name is specified at compile time.
|
||||
|
||||
The base name is used to generate actual log file names. For example,
|
||||
if the name specified was "log", the debug file would be
|
||||
log.client.
|
||||
|
||||
The log file generated is never removed by the client.
|
||||
|
||||
o -h Print the usage message for the client.
|
||||
|
||||
o -I IP address IP address is the address of the server to
|
||||
connect to. It should be specified in standard "a.b.c.d" notation.
|
||||
|
||||
Normally the client would attempt to locate a named SMB/CIFS server by
|
||||
looking it up via the NetBIOS name resolution mechanism described
|
||||
above in the name resolve order parameter
|
||||
above. Using this parameter will force the client to assume that the
|
||||
server is on the machine with the specified IP address and the NetBIOS
|
||||
name component of the resource being connected to will be ignored.
|
||||
|
||||
There is no default for this parameter. If not supplied, it will be
|
||||
determined automatically by the client as described above.
|
||||
|
||||
o -E This parameter causes the client to write messages to the
|
||||
standard error stream (stderr) rather than to the standard output
|
||||
stream.
|
||||
|
||||
By default, the client writes messages to standard output - typically
|
||||
the user's tty.
|
||||
|
||||
Note that by default, debug information is always sent to stderr.
|
||||
Debug information can instead be sent to a file, using the
|
||||
-l log basename option.
|
||||
|
||||
o -U username This specifies the user name that will be used by
|
||||
the client to make a connection, assuming your server is not a downlevel
|
||||
server that is running a protocol level that uses passwords on shares,
|
||||
not on usernames.
|
||||
|
||||
Some servers are fussy about the case of this name, and some insist
|
||||
that it must be a valid NetBIOS name.
|
||||
|
||||
If no username is supplied, it will default to an uppercase version of
|
||||
the environment variable USER or LOGNAME in that order. If no
|
||||
username is supplied and neither environment variable exists the
|
||||
username "GUEST" will be used.
|
||||
|
||||
If the USER environment variable contains a '%' character,
|
||||
everything after that will be treated as a password. This allows you
|
||||
to set the environment variable to be USER=username%password so
|
||||
that a password is not passed on the command line (where it may be
|
||||
seen by the ps command).
|
||||
|
||||
If the service you are connecting to requires a password, it can be
|
||||
supplied using the -U option, by appending a percent symbol ("%")
|
||||
then the password to username. For example, to attach to a service as
|
||||
user "fred" with password "secret", you would specify.
|
||||
|
||||
-U fred%secret
|
||||
|
||||
on the command line. Note that there are no spaces around the percent
|
||||
symbol.
|
||||
|
||||
If you specify the password as part of username then the -N option
|
||||
(suppress password prompt) is assumed.
|
||||
|
||||
If you specify the password as a parameter AND as part of username
|
||||
then the password as part of username will take precedence. Putting
|
||||
nothing before or nothing after the percent symbol will cause an empty
|
||||
username or an empty password to be used, respectively.
|
||||
|
||||
The password may also be specified by setting up an environment
|
||||
variable called PASSWORD that contains the users password. Note
|
||||
that this may be very insecure on some systems but on others allows
|
||||
users to script rpcclient commands without having a password appear in
|
||||
the command line of a process listing.
|
||||
|
||||
Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password. Lowercase or mixed case passwords may be
|
||||
rejected by these servers.
|
||||
|
||||
Be cautious about including passwords in scripts or in the
|
||||
PASSWORD environment variable. Also, on many systems the command
|
||||
line of a running process may be seen via the ps command to be
|
||||
safe always allow rpcclient to prompt for a password and type it in
|
||||
directly.
|
||||
|
||||
o -t terminal code This option tells rpcclient how to interpret
|
||||
filenames coming from the remote server. Usually Asian language
|
||||
multibyte UNIX implementations use different character sets than
|
||||
SMB/CIFS servers (EUC instead of SJIS for example). Setting
|
||||
this parameter will let rpcclient convert between the UNIX filenames
|
||||
and the SMB filenames correctly. This option has not been seriously
|
||||
tested and may have some problems.
|
||||
|
||||
The terminal codes include sjis, euc, jis7, jis8,
|
||||
junet, hex, cap. This is not a complete list, check the
|
||||
Samba source code for the complete list.
|
||||
|
||||
o -m max protocol level With the new code in Samba2.0,
|
||||
rpcclient always attempts to connect at the maximum
|
||||
protocols level the server supports. This parameter is
|
||||
preserved for backwards compatibility, but any string
|
||||
following the -m will be ignored.
|
||||
|
||||
o -W Domain Override the default Domain, which is the remote server's
|
||||
Domain. This option may be needed to connect to some servers. It is also
|
||||
possible to specify the remote server name as the Domain, which will
|
||||
force the username and password to be authenticated against the remote
|
||||
server's local SAM instead of the Domain SAM.
|
||||
|
||||
o -c command string command string is a semicolon separated
|
||||
list of commands to be executed instead of prompting from stdin.
|
||||
-N is implied by -c.
|
||||
|
||||
This is particularly useful in scripts, e.g. -c 'lsaquery; enumusers -u'.
|
||||
|
||||
OPERATIONS
|
||||
|
||||
Once the client is running, the user is presented with a prompt :
|
||||
|
||||
smb:\>
|
||||
|
||||
The prompt indicates that the client is ready and waiting to carry out
|
||||
a user command. Each command is a single word, optionally followed by
|
||||
parameters specific to that command. Command and parameters are
|
||||
space-delimited unless these notes specifically state otherwise. All
|
||||
commands are case-insensitive. Parameters to commands may or may not
|
||||
be case sensitive, depending on the command.
|
||||
|
||||
You can specify names (e.g registry keys; user or group names;
|
||||
service names) which have spaces in them by quoting the
|
||||
name with double quotes, for example "dRMON SmartAgent".
|
||||
|
||||
Parameters shown in square brackets (e.g., "[parameter]") are
|
||||
optional. If not given, the command will use suitable
|
||||
defaults. Parameters shown in angle brackets (e.g., "<parameter>") are
|
||||
required.
|
||||
|
||||
Note that all commands operating on the server are actually performed
|
||||
by issuing a request to the server. Thus the behavior may vary from
|
||||
server to server, depending on how the server was implemented.
|
||||
|
||||
The commands available are listed in groups relating to different services:
|
||||
|
||||
o Misccellaneous
|
||||
|
||||
o ? [command] If "command" is specified,
|
||||
the ? command will display a brief informative message about the
|
||||
specified command. If no command is specified, a list of available
|
||||
commands will be displayed.
|
||||
|
||||
o ! [shell command] If "shell command"
|
||||
is specified, the ! command will execute a shell locally and run
|
||||
the specified shell command. If no command is specified, a local shell
|
||||
will be run.
|
||||
|
||||
o exit Terminate the connection with the server and
|
||||
exit from the program.
|
||||
|
||||
o help [command] See the ?
|
||||
command above.
|
||||
|
||||
o quit See the exit command.
|
||||
|
||||
o Event Log
|
||||
|
||||
o eventlog
|
||||
list the events
|
||||
|
||||
o Service Control
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Service names, by pressing the
|
||||
tab key.
|
||||
|
||||
o svcenum
|
||||
[-i] Lists Services Manager
|
||||
|
||||
o svcinfo
|
||||
<service> Service Information
|
||||
|
||||
o svcstart
|
||||
<service> [arg 0] [arg 1] ... Start Service
|
||||
|
||||
o svcstop
|
||||
<service> Stop Service
|
||||
|
||||
o Scheduler
|
||||
|
||||
o at
|
||||
Scheduler control (at /? for syntax)
|
||||
|
||||
o Registry
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for registry key and value names,
|
||||
by pressing the tab key.
|
||||
|
||||
o regenum
|
||||
<keyname> Registry Enumeration (keys, values)
|
||||
|
||||
o regdeletekey
|
||||
<keyname> Registry Key Delete
|
||||
|
||||
o regcreatekey
|
||||
<keyname> [keyclass] Registry Key Create
|
||||
|
||||
o shutdown
|
||||
[-m message] [-t timeout] [-r or --reboot] Server Shutdown
|
||||
|
||||
o regqueryval
|
||||
<valname> Registry Value Query
|
||||
|
||||
o regquerykey
|
||||
<keyname> Registry Key Query
|
||||
|
||||
o regdeleteval
|
||||
<valname> Registry Value Delete
|
||||
|
||||
o regcreateval
|
||||
<valname> <valtype> <value> Registry Key Create
|
||||
|
||||
o reggetsec
|
||||
<keyname> Registry Key Security
|
||||
|
||||
o regtestsec
|
||||
<keyname> Test Registry Key Security
|
||||
|
||||
o Printing
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Printer and job names, by
|
||||
pressing the tab key.
|
||||
|
||||
o spoolenum
|
||||
Enumerate Printers
|
||||
|
||||
o spooljobs
|
||||
<printer name> Enumerate Printer Jobs
|
||||
|
||||
o spoolopen
|
||||
<printer name> Spool Printer Open Test
|
||||
|
||||
o Server
|
||||
|
||||
o time
|
||||
Display remote time
|
||||
|
||||
o brsinfo
|
||||
Browser Query Info
|
||||
|
||||
o wksinfo
|
||||
Workstation Query Info
|
||||
|
||||
o srvinfo
|
||||
Server Query Info
|
||||
|
||||
o srvsessions
|
||||
List sessions on a server
|
||||
|
||||
o srvshares
|
||||
List shares on a server
|
||||
|
||||
o srvtransports
|
||||
List transports on a server
|
||||
|
||||
o srvconnections
|
||||
List connections on a server
|
||||
|
||||
o srvfiles
|
||||
List files on a server
|
||||
|
||||
o Local Security Authority
|
||||
|
||||
o lsaquery
|
||||
Query Info Policy (domain member or server)
|
||||
|
||||
o lsaenumdomains
|
||||
Enumerate Trusted Domains
|
||||
|
||||
o lookupsids
|
||||
Resolve names from SIDs
|
||||
|
||||
o lookupnames
|
||||
Resolve SIDs from names
|
||||
|
||||
o querysecret
|
||||
LSA Query Secret (developer use)
|
||||
|
||||
o NETLOGON
|
||||
|
||||
o ntlogin
|
||||
[username] [password] NT Domain login test
|
||||
|
||||
o domtrust
|
||||
<domain> NT Inter-Domain test
|
||||
|
||||
o samsync
|
||||
SAM Synchronization Test (experimental)
|
||||
|
||||
o SAM Database
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for user, group, alias and domain
|
||||
names, by pressing the tab key.
|
||||
|
||||
o lookupdomain
|
||||
Obtain SID for a local domain
|
||||
|
||||
o enumusers
|
||||
SAM User Database Query (experimental!)
|
||||
|
||||
o addgroupmem
|
||||
<group rid> [user] [user] ... SAM Add Domain Group Member
|
||||
|
||||
o addaliasmem
|
||||
<alias rid> [member sid1] [member sid2] ... SAM Add Domain Alias Member
|
||||
|
||||
o delgroupmem
|
||||
<group rid> [user] [user] ... SAM Delete Domain Group Member
|
||||
|
||||
o delaliasmem
|
||||
<alias rid> [member sid1] [member sid2] ... SAM Delete Domain Alias Member
|
||||
|
||||
o creategroup
|
||||
SAM Create Domain Group
|
||||
|
||||
o createalias
|
||||
SAM Create Domain Alias
|
||||
|
||||
o createuser
|
||||
<username> SAM Create Domain User
|
||||
|
||||
o delgroup
|
||||
SAM Delete Domain Group
|
||||
|
||||
o delalias
|
||||
SAM Delete Domain Alias
|
||||
|
||||
o ntpass
|
||||
NT SAM Password Change
|
||||
|
||||
o samuserset2
|
||||
<username> [-s acb_bits] SAM User Set Info 2 (experimental!)
|
||||
|
||||
o samuserset
|
||||
<username> [-p password] SAM User Set Info (experimental!)
|
||||
|
||||
o samuser
|
||||
<username> SAM User Query (experimental!)
|
||||
|
||||
o samgroup
|
||||
<groupname> SAM Group Query (experimental!)
|
||||
|
||||
o samalias
|
||||
<aliasname> SAM Alias Query
|
||||
|
||||
o samaliasmem
|
||||
<aliasname> SAM Alias Members
|
||||
|
||||
o samgroupmem
|
||||
SAM Group Members
|
||||
|
||||
o samtest
|
||||
SAM User Encrypted RPC test (experimental!)
|
||||
|
||||
o enumaliases
|
||||
SAM Aliases Database Query (experimental!)
|
||||
|
||||
o enumdomains
|
||||
SAM Domains Database Query (experimental!)
|
||||
|
||||
o enumgroups
|
||||
SAM Group Database Query (experimental!)
|
||||
|
||||
o dominfo
|
||||
SAM Query Domain Info
|
||||
|
||||
o dispinfo
|
||||
SAM Query Display Info
|
||||
|
||||
NOTES
|
||||
|
||||
Some servers are fussy about the case of supplied usernames,
|
||||
passwords, share names (AKA service names) and machine names. If you
|
||||
fail to connect try giving all parameters in uppercase.
|
||||
|
||||
It is often necessary to use the -n option when connecting
|
||||
to some types of servers. For example OS/2 LanManager insists on a valid
|
||||
NetBIOS name being used, so you need to supply a valid name that would
|
||||
be known to the server.
|
||||
|
||||
rpcclient only works on servers that support MSRPC over SMB. This includes
|
||||
all versions of Windows NT, including the ports to Unix such as AS/U and
|
||||
AFPS. Support for MSRPC over SMB in other servers is currently rare and
|
||||
patchy, for example Samba 2.0 only supports a limited set of MSRPC commands,
|
||||
and some of those are not supported very well.
|
||||
|
||||
ENVIRONMENT VARIABLES
|
||||
|
||||
The variable USER may contain the username of the person using the
|
||||
client. This information is used only if the protocol level is high
|
||||
enough to support session-level passwords.
|
||||
|
||||
The variable PASSWORD may contain the password of the person using
|
||||
the client. This information is used only if the protocol level is
|
||||
high enough to support session-level passwords.
|
||||
|
||||
INSTALLATION
|
||||
|
||||
The location of the client program is a matter for individual system
|
||||
administrators. The following are thus suggestions only.
|
||||
|
||||
It is recommended that the rpcclient software be installed in the
|
||||
/usr/local/samba/bin or /usr/samba/bin directory, this directory
|
||||
readable by all, writeable only by root. The client program itself
|
||||
should be executable by all. The client should NOT be setuid or
|
||||
setgid!
|
||||
|
||||
The client log files should be put in a directory readable and
|
||||
writeable only by the user.
|
||||
|
||||
To test the client, you will need to know the name of a running
|
||||
SMB/CIFS server. It is possible to run smbd (8)
|
||||
an ordinary user - running that server as a daemon on a
|
||||
user-accessible port (typically any port number over 1024) would
|
||||
provide a suitable test server.
|
||||
|
||||
DIAGNOSTICS
|
||||
|
||||
Most diagnostics issued by the client are logged in a specified log
|
||||
file. The log file name is specified at compile time, but may be
|
||||
overridden on the command line.
|
||||
|
||||
The number and nature of diagnostics available depends on the debug
|
||||
level used by the client. If you have problems, set the debug level to
|
||||
3 and peruse the log files.
|
||||
|
||||
VERSION
|
||||
|
||||
This man page is correct for version 2.0 of the Samba suite.
|
||||
|
||||
BUGS
|
||||
|
||||
o WARNING!
|
||||
The MSPRC over SMB code has been developed from examining Network traces.
|
||||
No documentation is available from the original creators (Microsoft) on
|
||||
how MSRPC over SMB works, or how the individual MSRPC services work.
|
||||
Microsoft's implementation of these services has been demonstrated (and
|
||||
reported) to be... a bit flakey in places.
|
||||
|
||||
The development of Samba's implementation of these services is also
|
||||
a bit rough, and as more of the services are understood, it can even result
|
||||
in versions of smbd (8) and rpcclient that are
|
||||
incompatible for some commands or services. Additionally, the developers
|
||||
are sending reports to Microsoft, and problems found by or reported to
|
||||
Microsoft are fixed in Service Packs, which may also result in
|
||||
incompatibilities.
|
||||
|
||||
It is therefore not guaranteed that the execution of an rpcclient command will
|
||||
work. It is also not guaranteed that the target server will continue to
|
||||
operate, i.e the execution of an MSRPC command may cause a remote service to
|
||||
fail, or even cause the remote server to fail. Usual rules apply, of course:
|
||||
the developers bear absolutely no responsibility for the use, misuse, or
|
||||
lack of use of rpcclient, by any person or persons, whether legal,
|
||||
illegal, accidental, deliberate, intentional, malicious, curious, etc.
|
||||
|
||||
o Command Completion
|
||||
Command-completion (available if you have the GNU readline library) used on
|
||||
certain commands may not operate correctly if the word being completed (such as a registry key) contains a space. Typically, the name will be completed, but
|
||||
you will have to go back and put quotes round it, yourself.
|
||||
|
||||
o SAM Database command-completion
|
||||
Command-completion (available if you have the GNU readline library) of user,
|
||||
group and alias names does not work on remote Domains, which would normally
|
||||
be specified like this:
|
||||
|
||||
DOMAIN_name\\user_name.
|
||||
|
||||
The only names that can be completed in this fashion are the local names
|
||||
in the SAM database of the target server.
|
||||
|
||||
AUTHOR
|
||||
|
||||
The original Samba software and related utilities were created by
|
||||
Andrew Tridgell samba-bugs@samba.org. Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed.
|
||||
|
||||
The original Samba man pages were written by Karl Auer. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
ftp://ftp.icce.rug.nl/pub/unix/)
|
||||
and updated for the Samba2.0 release by Jeremy Allison. This man page
|
||||
was developed cut-and-paste style from the smbclient man page, by
|
||||
Luke Kenneth Casson Leighton.
|
||||
samba-bugs@samba.org.
|
||||
|
||||
See samba (7) to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc.
|
@ -1,161 +0,0 @@
|
||||
mailto(samba-bugs@samba.org)
|
||||
article(LDAP Support in Samba)(Matthew Chapman)(29th November 1998
|
||||
htmltag(p)(1) htmltag(hr)(1) htmltag(h2)(1)
|
||||
WARNING: This is experimental code. Use at your own risk, and please report
|
||||
any bugs (after reading BUGS.txt).
|
||||
htmltag(h2)(0) htmltag(br)(1)
|
||||
)
|
||||
redef(PARAGRAPH)(0)(htmlcommand(<p>
|
||||
) txtcommand(
|
||||
|
||||
))
|
||||
|
||||
sect(What is LDAP?)
|
||||
A directory is a type of hierarchical database optimised for simple query
|
||||
operations, often used for storing user information. LDAP is the
|
||||
Lightweight Directory Access Protocol, a protocol which is rapidly
|
||||
becoming the Internet standard for accessing directories.
|
||||
|
||||
Many client applications now support LDAP (including Microsoft's Active
|
||||
Directory), and there are a number of servers available. The most popular
|
||||
implementation for Unix is from the em(University of Michigan); its
|
||||
homepage is at url(tt(http://www.umich.edu/~dirsvcs/ldap/))(http://www.umich.edu/~dirsvcs/ldap/).
|
||||
|
||||
Information in an LDAP tree always comes in tt(attribute=value) pairs.
|
||||
The following is an example of a Samba user entry:
|
||||
|
||||
verb(uid=jbloggs, dc=samba, dc=org
|
||||
objectclass=sambaAccount
|
||||
uid=jbloggs
|
||||
cn=Joe Bloggs
|
||||
description=Samba User
|
||||
uidNumber=500
|
||||
gidNumber=500
|
||||
rid=2000
|
||||
grouprid=2001
|
||||
lmPassword=46E389809F8D55BB78A48108148AD508
|
||||
ntPassword=1944CCE1AD6F80D8AEC9FC5BE77696F4
|
||||
pwdLastSet=35C11F1B
|
||||
smbHome=\\samba1\jbloggs
|
||||
homeDrive=Z
|
||||
script=logon.bat
|
||||
profile=\\samba1\jbloggs\profile
|
||||
workstations=JOE)
|
||||
|
||||
Note that the top line is a special set of attributes called a
|
||||
em(distinguished name) which identifies the location of this entry beneath
|
||||
the directory's root node. Recent Internet standards suggest the use of
|
||||
domain-based naming using tt(dc) attributes (for instance, a microsoft.com
|
||||
directory should have a root node of tt(dc=microsoft, dc=com)), although
|
||||
this is not strictly necessary for isolated servers.
|
||||
|
||||
There are a number of LDAP-related FAQ's on the internet, although
|
||||
generally the best source of information is the documentation for the
|
||||
individual servers.
|
||||
|
||||
|
||||
nl()
|
||||
sect(Why LDAP and Samba?)
|
||||
|
||||
Using an LDAP directory allows Samba to store user and group information
|
||||
more reliably and flexibly than the current combination of smbpasswd,
|
||||
smbgroup, groupdb and aliasdb with the Unix databases. If a need emerges
|
||||
for extra user information to be stored, this can easily be added without
|
||||
loss of backwards compatibility.
|
||||
|
||||
In addition, the Samba LDAP schema is compatible with RFC2307, allowing
|
||||
Unix password database information to be stored in the same entries. This
|
||||
provides a single, consistent repository for both Unix and Windows user
|
||||
information.
|
||||
|
||||
|
||||
nl()
|
||||
sect(Using LDAP with Samba)
|
||||
|
||||
starteit()
|
||||
|
||||
eit() Install and configure an LDAP server if you do not already have
|
||||
one. You should read your LDAP server's documentation and set up the
|
||||
configuration file and access control as desired.
|
||||
|
||||
eit() Build Samba (latest CVS is required) with:
|
||||
|
||||
verb( ./configure --with-ldap
|
||||
make clean; make install)
|
||||
|
||||
eit() Add the following options to the global section of tt(smb.conf) as
|
||||
required.
|
||||
|
||||
startdit()
|
||||
dit(ldap suffix)
|
||||
|
||||
This parameter specifies the node of the LDAP tree beneath which
|
||||
Samba should store its information. This parameter MUST be provided
|
||||
when using LDAP with Samba.
|
||||
|
||||
bf(Default:) tt(none)
|
||||
|
||||
bf(Example:) tt(ldap suffix = "dc=mydomain, dc=org")
|
||||
|
||||
dit(ldap bind as)
|
||||
|
||||
This parameter specifies the entity to bind to an LDAP directory as.
|
||||
Usually it should be safe to use the LDAP root account; for larger
|
||||
installations it may be preferable to restrict Samba's access.
|
||||
|
||||
bf(Default:) tt(none (bind anonymously))
|
||||
|
||||
bf(Example:) tt(ldap bind as = "uid=root, dc=mydomain, dc=org")
|
||||
|
||||
dit(ldap passwd file)
|
||||
|
||||
This parameter specifies a file containing the password with which
|
||||
Samba should bind to an LDAP server. For obvious security reasons
|
||||
this file must be set to mode 700 or less.
|
||||
|
||||
bf(Default:) tt(none (bind anonymously))
|
||||
|
||||
bf(Example:) tt(ldap passwd file = /usr/local/samba/private/ldappasswd)
|
||||
|
||||
dit(ldap server)
|
||||
|
||||
This parameter specifies the DNS name of the LDAP server to use
|
||||
when storing and retrieving information about Samba users and
|
||||
groups.
|
||||
|
||||
bf(Default:) tt(ldap server = localhost)
|
||||
|
||||
dit(ldap port)
|
||||
|
||||
This parameter specifies the TCP port number of the LDAP server.
|
||||
|
||||
bf(Default:) tt(ldap port = 389)
|
||||
|
||||
enddit()
|
||||
|
||||
eit() You should then be able to use the normal smbpasswd(8) command for
|
||||
account administration (or User Manager in the near future).
|
||||
|
||||
endeit()
|
||||
|
||||
|
||||
nl()
|
||||
sect(Using LDAP for Unix authentication)
|
||||
|
||||
The Samba LDAP code was designed to utilise RFC2307-compliant directory
|
||||
entries if available. RFC2307 is a proposed standard for LDAP user
|
||||
information which has been adopted by a number of vendors. Further
|
||||
information is available at url(tt(http://www.xedoc.com.au/~lukeh/ldap/))(http://www.xedoc.com.au/~lukeh/ldap).
|
||||
|
||||
Of particular interest is Luke Howard's nameservice switch module
|
||||
(nss_ldap) and PAM module (pam_ldap) implementing this standard, providing
|
||||
LDAP-based password databases for Unix. If you are setting up a server to
|
||||
provide integrated Unix/NT services than these are worth investigating.
|
||||
|
||||
|
||||
nl()
|
||||
sect(Compatibility with Active Directory)
|
||||
|
||||
The current implementation is not designed to be used with Microsoft
|
||||
Active Directory, although compatibility may be added in the future.
|
||||
|
@ -1,62 +0,0 @@
|
||||
mailto(samba-bugs@samba.org)
|
||||
|
||||
IFDEF(html)\
|
||||
(manpage(htmlcommand(debug2html(1)))(1)(29 Dec 1998)(Samba)(SAMBA))\
|
||||
(manpage(debug2html)(1)(29 Dec 1998)(Samba)(SAMBA))
|
||||
|
||||
label(NAME)
|
||||
manpagename(debug2html)(Samba DEBUG to HTML translation filter)
|
||||
|
||||
label(SYNOPSIS)
|
||||
manpagesynopsis()
|
||||
|
||||
debug2html [input-file [output-file]]
|
||||
|
||||
label(DESCRIPTION)
|
||||
manpagedescription()
|
||||
|
||||
This program is part of the bf(Samba) suite.
|
||||
|
||||
bf(debug2html) generates HTML files from Samba log files. Log files
|
||||
produced by bf(nmbd)(8) or bf(smbd)(8) may then be viewed by a web
|
||||
browser. The output conforms to the HTML 3.2 specification.
|
||||
|
||||
The filenames specified on the command line are optional. If the
|
||||
output-file is ommitted, output will go to bf(stdout). If the input-file
|
||||
is ommitted, bf(debug2html) will read from bf(stdin). The filename "-"
|
||||
can be used to indicate that input should be read from bf(stdin). For
|
||||
example:
|
||||
|
||||
tt(cat /usr/local/samba/var/log.nmb | debug2html - nmblog.html) nl()
|
||||
|
||||
label(VERSION)
|
||||
manpagesection(VERSION)
|
||||
|
||||
This man page is correct for version 2.0 of the Samba suite.
|
||||
|
||||
label(SEEALSO)
|
||||
manpageseealso()
|
||||
|
||||
url(bf(nmbd)(8))(nmbd.8.html), url(bf(smbd)(8))(smbd.8.html),
|
||||
url(bf(samba)(7))(samba.7.html).
|
||||
|
||||
label(AUTHOR)
|
||||
manpageauthor()
|
||||
|
||||
The original Samba software and related utilities were created by
|
||||
Andrew Tridgell email(samba-bugs@samba.org). Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed.
|
||||
|
||||
The original Samba man pages were written by Karl Auer. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
url(bf(ftp://ftp.icce.rug.nl/pub/unix/))(ftp://ftp.icce.rug.nl/pub/unix/))
|
||||
and updated for the Samba2.0 release by Jeremy Allison.
|
||||
email(samba-bugs@samba.org).
|
||||
|
||||
bf(debug2html) was added by Chris Hertel.
|
||||
|
||||
See url(bf(samba)(7))(samba.7.html) to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc.
|
@ -1,861 +0,0 @@
|
||||
mailto(samba-bugs@samba.org)
|
||||
|
||||
manpage(rpcclient htmlcommand((1)))(1)(23 Oct 1998)(Samba)(SAMBA)
|
||||
|
||||
label(NAME)
|
||||
manpagename(rpcclient)(utility to manage MSRPC resources on servers)
|
||||
|
||||
label(SYNOPSIS)
|
||||
manpagesynopsis()
|
||||
|
||||
bf(rpcclient)
|
||||
[link(password)(password)]
|
||||
link(-S servername)(servername)
|
||||
[link(-U [username][%][password])(minusU)]
|
||||
[link(-W domain)(minusW)]
|
||||
[link(-l log basename)(minusl)]
|
||||
[link(-d debuglevel)(minusd)]
|
||||
[link(-O socket options)(minusO)]
|
||||
[link(-i scope)(minusi)]
|
||||
[link(-N)(minusN)]
|
||||
[link(-n NetBIOS name)(minusn)]
|
||||
[link(-h)(minush)]
|
||||
[link(-I dest IP)(minusI)]
|
||||
[link(-E)(minusE)]
|
||||
[link(-t terminal code)(minust)]
|
||||
[link(-c command string)(minusc)]
|
||||
[link(-B IP addr)(minusB)]
|
||||
[link(-s smb.conf)(minuss)]
|
||||
[link(-m max protocol)(minusm)]
|
||||
|
||||
label(DESCRIPTION)
|
||||
manpagedescription()
|
||||
|
||||
This program is part of the bf(Samba) suite.
|
||||
|
||||
bf(rpcclient) is a client that can 'talk' to an SMB/CIFS MSRPC server.
|
||||
Operations include things like managing a SAM Database (users, groups
|
||||
and aliases) in the same way as the Windows NT programs
|
||||
bf(User Manager for Domains) and bf(Server Manager for Domains);
|
||||
managing a remote registry in the same way as the Windows NT programs
|
||||
bf(REGEDT32.EXE) and bf(REGEDIT.EXE); viewing a remote event log (same
|
||||
as bf(EVENTVWR.EXE)) etc.
|
||||
|
||||
Typical usage is like this: nl()
|
||||
tt(rpcclient -I 192.168.32.1 -S "*SMBSERVER" -U fred%secret -l log)
|
||||
nl()
|
||||
|
||||
bf(rpcclient) is em(not) suitable for usage on single-user systems
|
||||
such as Windows 9X, as Windows 9X does not support MSRPC services.
|
||||
Therefore, if you have problems using bf(rpcclient) with Windows 9X,
|
||||
we don't want to hear about it.
|
||||
|
||||
label(OPTIONS)
|
||||
manpageoptions()
|
||||
|
||||
startdit()
|
||||
|
||||
label(servername)
|
||||
dit(bf(servername)) servername is the name of the server you want
|
||||
to use on the server. This should be the NetBIOS name of the SMB/CIFS
|
||||
server, which can be bf(*SMBSERVER) on Windows NT 4.0 or Samba Servers.
|
||||
|
||||
Note that the server name required is NOT necessarily the IP (DNS)
|
||||
host name of the server! The name required is a NetBIOS server name,
|
||||
which may or may not be the same as the IP hostname of the machine
|
||||
running the server. Also, remember that having a period in a NetBIOS
|
||||
name (such as an IP hostname) may cause connectivity problems on your
|
||||
network: NT tends to strip NetBIOS names from the leading period
|
||||
onwards.
|
||||
|
||||
The server name is looked up according to either the
|
||||
link(bf(-R))(minusR) parameter to bf(rpcclient) or using the
|
||||
url(bf(name resolve order))(smb.conf.5.html#nameresolveorder)
|
||||
parameter in the smb.conf file, allowing an administrator to change
|
||||
the order and methods by which server names are looked up.
|
||||
|
||||
label(password)
|
||||
dit(bf(password)) password is the password required to access the
|
||||
specified service on the specified server. If this parameter is
|
||||
supplied, the link(bf(-N))(minusN) option (suppress password prompt) is assumed.
|
||||
|
||||
There is no default password. If no password is supplied on the
|
||||
command line (either by using this parameter or adding a password to
|
||||
the link(bf(-U))(minusU) option (see below)) and the link(bf(-N))(minusN) option is not specified,
|
||||
the client will prompt for a password, even if the desired service
|
||||
does not require one. (If no password is required, simply press ENTER
|
||||
to provide a null password.)
|
||||
|
||||
Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password. Lowercase or mixed case passwords may be
|
||||
rejected by these servers.
|
||||
|
||||
Be cautious about including passwords in scripts.
|
||||
|
||||
label(minuss)
|
||||
dit(bf(-s smb.conf)) This parameter specifies the pathname to the
|
||||
Samba configuration file, smb.conf. This file controls all aspects of
|
||||
the Samba setup on the machine and rpcclient also needs to read this
|
||||
file.
|
||||
|
||||
label(minusB)
|
||||
dit(bf(-B IP addr)) The IP address to use when sending a broadcast packet.
|
||||
|
||||
label(minusO)
|
||||
dit(bf(-O socket options)) TCP socket options to set on the client
|
||||
socket. See the url(socket options)(smb.conf.5.html#socketoptions)
|
||||
parameter in the url(bf(smb.conf (5)))(smb.conf.5.html) manpage for
|
||||
the list of valid options.
|
||||
|
||||
label(minusR)
|
||||
dit(bf(-R name resolve order)) This option allows the user of
|
||||
rpcclient to determine what name resolution services to use when
|
||||
looking up the NetBIOS name of the host being connected to.
|
||||
|
||||
The options are :"lmhosts", "host", "wins" and "bcast". They cause
|
||||
names to be resolved as follows :
|
||||
|
||||
startit()
|
||||
|
||||
it() bf(lmhosts) : Lookup an IP address in the Samba lmhosts file.
|
||||
The lmhosts file is stored in the same directory as the
|
||||
url(bf(smb.conf))(smb.conf.5.html) file.
|
||||
|
||||
it() bf(host) : Do a standard host name to IP address resolution,
|
||||
using the system /etc/hosts, NIS, or DNS lookups. This method of name
|
||||
resolution is operating system depended for instance on IRIX or
|
||||
Solaris this may be controlled by the em(/etc/nsswitch.conf) file).
|
||||
|
||||
it() bf(wins) : Query a name with the IP address listed in the url(bf(wins
|
||||
server))(smb.conf.5.html#winsserver) parameter in the smb.conf file. If
|
||||
no WINS server has been specified this method will be ignored.
|
||||
|
||||
it() bf(bcast) : Do a broadcast on each of the known local interfaces
|
||||
listed in the url(bf(interfaces))(smb.conf.5.html#interfaces) parameter
|
||||
in the smb.conf file. This is the least reliable of the name resolution
|
||||
methods as it depends on the target host being on a locally connected
|
||||
subnet. To specify a particular broadcast address the link(bf(-B))(minusB) option
|
||||
may be used.
|
||||
|
||||
endit()
|
||||
|
||||
If this parameter is not set then the name resolve order defined
|
||||
in the url(bf(smb.conf))(smb.conf.5.html) file parameter
|
||||
url((bf(name resolve order)))(smb.conf.5.html#nameresolveorder)
|
||||
will be used.
|
||||
|
||||
The default order is lmhosts, host, wins, bcast and without this
|
||||
parameter or any entry in the url(bf("name resolve
|
||||
order"))(smb.conf.5.html#nameresolveorder) parameter of the
|
||||
url(bf(smb.conf))(smb.conf.5.html) file the name resolution methods
|
||||
will be attempted in this order.
|
||||
|
||||
label(minusi)
|
||||
dit(bf(-i scope)) This specifies a NetBIOS scope that rpcclient will use
|
||||
to communicate with when generating NetBIOS names. For details on the
|
||||
use of NetBIOS scopes, see rfc1001.txt and rfc1002.txt. NetBIOS scopes
|
||||
are em(very) rarely used, only set this parameter if you are the
|
||||
system administrator in charge of all the NetBIOS systems you
|
||||
communicate with.
|
||||
|
||||
label(minusN)
|
||||
dit(bf(-N)) If specified, this parameter suppresses the normal
|
||||
password prompt from the client to the user. This is useful when
|
||||
accessing a service that does not require a password.
|
||||
|
||||
Unless a password is specified on the command line or this parameter
|
||||
is specified, the client will request a password.
|
||||
|
||||
label(minusn)
|
||||
dit(bf(-n NetBIOS name)) By default, the client will use the local
|
||||
machine's hostname (in uppercase) as its NetBIOS name. This parameter
|
||||
allows you to override the host name and use whatever NetBIOS name you
|
||||
wish.
|
||||
|
||||
label(minusd)
|
||||
dit(bf(-d debuglevel)) debuglevel is an integer from 0 to 10, or the
|
||||
letter 'A'.
|
||||
|
||||
The default value if this parameter is not specified is zero.
|
||||
|
||||
The higher this value, the more detail will be logged to the log files
|
||||
about the activities of the client. At level 0, only critical errors
|
||||
and serious warnings will be logged. Level 1 is a reasonable level for
|
||||
day to day running - it generates a small amount of information about
|
||||
operations carried out.
|
||||
|
||||
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 debuglevel is set to the
|
||||
letter 'A', then em(all) debug messages will be printed. This setting
|
||||
is for developers only (and people who em(really) want to know how the
|
||||
code works internally).
|
||||
|
||||
Note that specifying this parameter here will override the url(bf(log
|
||||
level))(smb.conf.5.html#loglevel) parameter in the url(bf(smb.conf
|
||||
(5)))(smb.conf.5.html) file.
|
||||
|
||||
label(minusp)
|
||||
dit(bf(-p port)) This number is the TCP port number that will be used
|
||||
when making connections to the server. The standard (well-known) TCP
|
||||
port number for an SMB/CIFS server is 139, which is the default.
|
||||
|
||||
label(minusl)
|
||||
dit(bf(-l logfilename)) If specified, logfilename specifies a base
|
||||
filename into which operational data from the running client will be
|
||||
logged.
|
||||
|
||||
The default base name is specified at compile time.
|
||||
|
||||
The base name is used to generate actual log file names. For example,
|
||||
if the name specified was "log", the debug file would be
|
||||
tt(log.client).
|
||||
|
||||
The log file generated is never removed by the client.
|
||||
|
||||
label(minush)
|
||||
dit(bf(-h)) Print the usage message for the client.
|
||||
|
||||
label(minusI)
|
||||
dit(bf(-I IP address)) IP address is the address of the server to
|
||||
connect to. It should be specified in standard "a.b.c.d" notation.
|
||||
|
||||
Normally the client would attempt to locate a named SMB/CIFS server by
|
||||
looking it up via the NetBIOS name resolution mechanism described
|
||||
above in the link(bf(name resolve order))(minusR) parameter
|
||||
above. Using this parameter will force the client to assume that the
|
||||
server is on the machine with the specified IP address and the NetBIOS
|
||||
name component of the resource being connected to will be ignored.
|
||||
|
||||
There is no default for this parameter. If not supplied, it will be
|
||||
determined automatically by the client as described above.
|
||||
|
||||
label(minusE)
|
||||
dit(bf(-E)) This parameter causes the client to write messages to the
|
||||
standard error stream (stderr) rather than to the standard output
|
||||
stream.
|
||||
|
||||
By default, the client writes messages to standard output - typically
|
||||
the user's tty.
|
||||
|
||||
Note that by default, debug information is always sent to stderr.
|
||||
Debug information can instead be sent to a file, using the
|
||||
link(-l log basename)(minusl) option.
|
||||
|
||||
label(minusU)
|
||||
dit(bf(-U username)) This specifies the user name that will be used by
|
||||
the client to make a connection, assuming your server is not a downlevel
|
||||
server that is running a protocol level that uses passwords on shares,
|
||||
not on usernames.
|
||||
|
||||
Some servers are fussy about the case of this name, and some insist
|
||||
that it must be a valid NetBIOS name.
|
||||
|
||||
If no username is supplied, it will default to an uppercase version of
|
||||
the environment variable tt(USER) or tt(LOGNAME) in that order. If no
|
||||
username is supplied and neither environment variable exists the
|
||||
username "GUEST" will be used.
|
||||
|
||||
If the tt(USER) environment variable contains a '%' character,
|
||||
everything after that will be treated as a password. This allows you
|
||||
to set the environment variable to be tt(USER=username%password) so
|
||||
that a password is not passed on the command line (where it may be
|
||||
seen by the ps command).
|
||||
|
||||
If the service you are connecting to requires a password, it can be
|
||||
supplied using the link(bf(-U))(minusU) option, by appending a percent symbol ("%")
|
||||
then the password to username. For example, to attach to a service as
|
||||
user tt("fred") with password tt("secret"), you would specify. nl()
|
||||
|
||||
tt(-U fred%secret) nl()
|
||||
|
||||
on the command line. Note that there are no spaces around the percent
|
||||
symbol.
|
||||
|
||||
If you specify the password as part of username then the link(bf(-N))(minusN) option
|
||||
(suppress password prompt) is assumed.
|
||||
|
||||
If you specify the password as a parameter em(AND) as part of username
|
||||
then the password as part of username will take precedence. Putting
|
||||
nothing before or nothing after the percent symbol will cause an empty
|
||||
username or an empty password to be used, respectively.
|
||||
|
||||
The password may also be specified by setting up an environment
|
||||
variable called tt(PASSWORD) that contains the users password. Note
|
||||
that this may be very insecure on some systems but on others allows
|
||||
users to script rpcclient commands without having a password appear in
|
||||
the command line of a process listing.
|
||||
|
||||
Note: Some servers (including OS/2 and Windows for Workgroups) insist
|
||||
on an uppercase password. Lowercase or mixed case passwords may be
|
||||
rejected by these servers.
|
||||
|
||||
Be cautious about including passwords in scripts or in the
|
||||
tt(PASSWORD) environment variable. Also, on many systems the command
|
||||
line of a running process may be seen via the tt(ps) command to be
|
||||
safe always allow rpcclient to prompt for a password and type it in
|
||||
directly.
|
||||
|
||||
label(minust)
|
||||
dit(bf(-t terminal code)) This option tells rpcclient how to interpret
|
||||
filenames coming from the remote server. Usually Asian language
|
||||
multibyte UNIX implementations use different character sets than
|
||||
SMB/CIFS servers (em(EUC) instead of em(SJIS) for example). Setting
|
||||
this parameter will let rpcclient convert between the UNIX filenames
|
||||
and the SMB filenames correctly. This option has not been seriously
|
||||
tested and may have some problems.
|
||||
|
||||
The terminal codes include tt(sjis), tt(euc), tt(jis7), tt(jis8),
|
||||
tt(junet), tt(hex), tt(cap). This is not a complete list, check the
|
||||
Samba source code for the complete list.
|
||||
|
||||
label(minusm)
|
||||
dit(bf(-m max protocol level)) With the new code in Samba2.0,
|
||||
bf(rpcclient) always attempts to connect at the maximum
|
||||
protocols level the server supports. This parameter is
|
||||
preserved for backwards compatibility, but any string
|
||||
following the bf(-m) will be ignored.
|
||||
|
||||
label(minusW)
|
||||
dit(bf(-W Domain)) Override the default Domain, which is the remote server's
|
||||
Domain. This option may be needed to connect to some servers. It is also
|
||||
possible to specify the remote server name as the Domain, which will
|
||||
force the username and password to be authenticated against the remote
|
||||
server's local SAM instead of the Domain SAM.
|
||||
|
||||
label(minusc)
|
||||
dit(bf(-c command string)) command string is a semicolon separated
|
||||
list of commands to be executed instead of prompting from stdin.
|
||||
link(bf(-N))(minusN) is implied by bf(-c).
|
||||
|
||||
This is particularly useful in scripts, e.g. tt(-c 'lsaquery; enumusers -u').
|
||||
|
||||
enddit()
|
||||
|
||||
label(OPERATIONS)
|
||||
manpagesection(OPERATIONS)
|
||||
|
||||
Once the client is running, the user is presented with a prompt :
|
||||
|
||||
tt(smb:\>)
|
||||
|
||||
The prompt indicates that the client is ready and waiting to carry out
|
||||
a user command. Each command is a single word, optionally followed by
|
||||
parameters specific to that command. Command and parameters are
|
||||
space-delimited unless these notes specifically state otherwise. All
|
||||
commands are case-insensitive. Parameters to commands may or may not
|
||||
be case sensitive, depending on the command.
|
||||
|
||||
You can specify names (e.g registry keys; user or group names;
|
||||
service names) which have spaces in them by quoting the
|
||||
name with double quotes, for example "dRMON SmartAgent".
|
||||
|
||||
Parameters shown in square brackets (e.g., "[parameter]") are
|
||||
optional. If not given, the command will use suitable
|
||||
defaults. Parameters shown in angle brackets (e.g., "<parameter>") are
|
||||
required.
|
||||
|
||||
Note that all commands operating on the server are actually performed
|
||||
by issuing a request to the server. Thus the behavior may vary from
|
||||
server to server, depending on how the server was implemented.
|
||||
|
||||
The commands available are listed in groups relating to different services:
|
||||
|
||||
startdit()
|
||||
|
||||
dit(Misccellaneous)
|
||||
|
||||
startdit()
|
||||
|
||||
label(questionmark) dit(bf(? [command])) If "command" is specified,
|
||||
the bf(?) command will display a brief informative message about the
|
||||
specified command. If no command is specified, a list of available
|
||||
commands will be displayed.
|
||||
|
||||
label(exclaimationmark) dit(bf(! [shell command])) If "shell command"
|
||||
is specified, the bf(!) command will execute a shell locally and run
|
||||
the specified shell command. If no command is specified, a local shell
|
||||
will be run.
|
||||
|
||||
label(exit) dit(bf(exit)) Terminate the connection with the server and
|
||||
exit from the program.
|
||||
|
||||
label(help) dit(bf(help [command])) See the link(bf(?))(questionmark)
|
||||
command above.
|
||||
|
||||
label(quit) dit(bf(quit)) See the link(bf(exit))(exit) command.
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Event Log)
|
||||
|
||||
startdit()
|
||||
|
||||
label(eventlog) dit(bf(eventlog))
|
||||
list the events
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Service Control)
|
||||
|
||||
These commands provide functionality similar to the Windows
|
||||
NT Service Control Manager.
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Service names, by pressing the
|
||||
tab key.
|
||||
|
||||
startdit()
|
||||
|
||||
label(svcenum) dit(bf(svcenum))
|
||||
[-i] Lists Services.
|
||||
|
||||
label(svcinfo) dit(bf(svcinfo))
|
||||
<service> Service Information
|
||||
|
||||
label(svcstart) dit(bf(svcstart))
|
||||
<service> [arg 0] [arg 1] ... Start Service
|
||||
|
||||
label(svcstop) dit(bf(svcstop))
|
||||
<service> Stop Service
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Scheduler)
|
||||
|
||||
startdit()
|
||||
|
||||
label(at) dit(bf(at))
|
||||
Scheduler control (at /? for syntax)
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Registry)
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for registry key and value names,
|
||||
by pressing the tab key.
|
||||
|
||||
startdit()
|
||||
|
||||
label(regenum) dit(bf(regenum))
|
||||
<keyname> Registry Enumeration (keys, values)
|
||||
|
||||
label(regdeletekey) dit(bf(regdeletekey))
|
||||
<keyname> Registry Key Delete
|
||||
|
||||
label(regcreatekey) dit(bf(regcreatekey))
|
||||
<keyname> [keyclass] Registry Key Create
|
||||
|
||||
label(shutdown) dit(bf(shutdown))
|
||||
[-m message] [-t timeout] [-r or --reboot] Server Shutdown
|
||||
|
||||
label(regqueryval) dit(bf(regqueryval))
|
||||
<valname> Registry Value Query
|
||||
|
||||
label(regquerykey) dit(bf(regquerykey))
|
||||
<keyname> Registry Key Query
|
||||
|
||||
label(regdeleteval) dit(bf(regdeleteval))
|
||||
<valname> Registry Value Delete
|
||||
|
||||
label(regcreateval) dit(bf(regcreateval))
|
||||
<valname> <valtype> <value> Registry Key Create
|
||||
|
||||
label(reggetsec) dit(bf(reggetsec))
|
||||
<keyname> Registry Key Security
|
||||
|
||||
label(regtestsec) dit(bf(regtestsec))
|
||||
<keyname> Test Registry Key Security
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Printing)
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for Printer and job names, by
|
||||
pressing the tab key.
|
||||
|
||||
startdit()
|
||||
|
||||
label(spoolenum) dit(bf(spoolenum))
|
||||
Enumerate Printers. This experimental command lists
|
||||
all printers available on a remote spooler service.
|
||||
|
||||
label(spooljobs) dit(bf(spooljobs))
|
||||
<printer name> Enumerate Printer Jobs. This
|
||||
experimental command lists all jobs, and their
|
||||
status, currently queued on a remote spooler
|
||||
service.
|
||||
|
||||
label(spoolopen) dit(bf(spoolopen))
|
||||
<printer name> Spool Printer Open Test. Experimental.
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Server)
|
||||
|
||||
startdit()
|
||||
|
||||
label(time) dit(bf(time))
|
||||
Display remote time
|
||||
|
||||
label(brsinfo) dit(bf(brsinfo))
|
||||
Browser Query Info
|
||||
|
||||
label(wksinfo) dit(bf(wksinfo))
|
||||
Workstation Query Info
|
||||
|
||||
label(srvinfo) dit(bf(srvinfo))
|
||||
Server Query Info
|
||||
|
||||
label(srvsessions) dit(bf(srvsessions))
|
||||
List sessions on a server
|
||||
|
||||
label(srvshares) dit(bf(srvshares))
|
||||
List shares on a server
|
||||
|
||||
label(srvtransports) dit(bf(srvtransports))
|
||||
List transports on a server
|
||||
|
||||
label(srvconnections) dit(bf(srvconnections))
|
||||
List connections on a server
|
||||
|
||||
label(srvfiles) dit(bf(srvfiles))
|
||||
List files on a server
|
||||
|
||||
enddit()
|
||||
|
||||
dit(Local Security Authority)
|
||||
|
||||
startdit()
|
||||
|
||||
label(lsaquery) dit(bf(lsaquery))
|
||||
Query Info Policy (domain member or server). Obtains
|
||||
the SID and name of the SAM database that a server
|
||||
is responsible for (i.e a workstation's local SAM
|
||||
database or the PDC SAM database). Also obtains the
|
||||
SID and name of the SAM database that a server is
|
||||
a member of.
|
||||
|
||||
label(lsaenumdomains) dit(bf(lsaenumdomains))
|
||||
Enumerate Trusted Domains. Lists all Trusted and
|
||||
Trusting Domains with which the remote PDC has
|
||||
trust relationships established.
|
||||
|
||||
label(lookupsids) dit(bf(lookupsids))
|
||||
<rid1 or sid1> <rid1 or sid2> ... Resolve names from SIDs.
|
||||
Mostly to be used by developers or for troubleshooting,
|
||||
this command can take either Security Identifiers or Relative
|
||||
Identifiers, and look them up in the local SAM database
|
||||
(or look them up in a remote Trusting or Trusted PDC's SAM
|
||||
database if there is an appropriate Trust Relationship
|
||||
established). The result is a list of names, of the
|
||||
format: nl()
|
||||
tt([TRUST_DOMAIN\]name). nl()
|
||||
the link(bf(lsaquery))(lsaquery) command must have been
|
||||
issued first if you wish to use lookupsids to resolve
|
||||
RIDs. The only RIDs that will be resolved will be those
|
||||
in the SAM database of the server to which you are connected.
|
||||
|
||||
label(lookupnames) dit(bf(lookupnames))
|
||||
<name1> <name2> ... Resolve SIDs from names.
|
||||
Mostly to be used by developers or for troubleshooting,
|
||||
this command can take names of the following format: nl()
|
||||
tt([DOMAIN_NAME\]name). nl()
|
||||
The names, which can be user, group or alias names, will
|
||||
either be looked up in the local SAM database or in a remote
|
||||
Trusting or Trusted PDC's SAM database, if there is an
|
||||
appropriate Trust Relationship established. The optional
|
||||
Domain name component is the name of a SAM database, which
|
||||
can include a workstation's local SAM database or a Trusted
|
||||
Domain.
|
||||
Example Usage: nl()
|
||||
tt(lookupnames WKSTANAME\Administrator "Domain Guests") nl()
|
||||
|
||||
label(querysecret) dit(bf(querysecret))
|
||||
LSA Query Secret (developer use). This command only appears
|
||||
to work against NT4 SP3 and below. Due to its potential
|
||||
for misuse, it looks like Microsoft modified their
|
||||
implementation of the LsaRetrievePrivateData call to
|
||||
always return NT_STATUS_ACCESS_DENIED.
|
||||
|
||||
enddit()
|
||||
|
||||
dit(NETLOGON)
|
||||
|
||||
startdit()
|
||||
|
||||
label(ntlogin) dit(bf(ntlogin))
|
||||
[username] [password] NT Domain login test. Demonstrates
|
||||
how NT-style logins work. Mainly for developer usage,
|
||||
it can also be used to verify that a user can log in
|
||||
from a workstation. If you cannot ever get pam_ntdom
|
||||
to work, try this command first.
|
||||
|
||||
label(domtrust) dit(bf(domtrust))
|
||||
<domain> NT Inter-Domain test. Demonstrates how NT-style
|
||||
Inter-Domain Trust relationships work. Mainly for
|
||||
developer usage, it can also be used to verify that a
|
||||
Trust Relationship is correctly established with a
|
||||
remote PDC.
|
||||
|
||||
label(samsync) dit(bf(samsync))
|
||||
SAM Synchronisation Test (experimental). This command
|
||||
is used to manually synchronise a SAM database from a
|
||||
remote PDC, when Samba is set up as a Backup Domain
|
||||
Controller.
|
||||
|
||||
enddit()
|
||||
|
||||
dit(SAM Database)
|
||||
|
||||
The SAM Database holds user, group and alias information.
|
||||
The commands listed below allow operations such as adding
|
||||
user accounts and changing their password; listing known
|
||||
Domains; listing user, group and alias accounts; listing the
|
||||
members of groups and aliases; adding or removing members
|
||||
from groups and aliases.
|
||||
|
||||
The commands that make changes are protected by Access Control
|
||||
permissions on the remote server. You will therefore need to
|
||||
be in the right NT group in order to perform certain operations.
|
||||
If you find that a command fails with an NT_STATUS_ACCESS_DENIED
|
||||
error and you think you should be able to perform that command,
|
||||
talk to your Administrator: your username is probably not in the
|
||||
correct NT alias or group (e.g Account Operators; Domain Admin).
|
||||
|
||||
The commands that view information usually require less
|
||||
user privileges. However, a particular remote server may be
|
||||
configured with better security settings, so a command that
|
||||
succeeds on one server may not succeed on another.
|
||||
|
||||
It is possible to use command-line completion (if you have
|
||||
the GNU readline library) for user, group, alias and domain
|
||||
names, by pressing the tab key.
|
||||
|
||||
startdit()
|
||||
|
||||
label(lookupdomain) dit(bf(lookupdomain))
|
||||
Obtain SID for a local domain
|
||||
|
||||
label(enumusers) dit(bf(enumusers))
|
||||
SAM User Database Query (experimental!)
|
||||
|
||||
label(addgroupmem) dit(bf(addgroupmem))
|
||||
<group rid> [user] [user] ... SAM Add Domain Group Member
|
||||
|
||||
label(addaliasmem) dit(bf(addaliasmem))
|
||||
<alias rid> [member sid1] [member sid2] ... SAM Add Domain Alias Member
|
||||
|
||||
label(delgroupmem) dit(bf(delgroupmem))
|
||||
<group rid> [user] [user] ... SAM Delete Domain Group Member
|
||||
|
||||
label(delaliasmem) dit(bf(delaliasmem))
|
||||
<alias rid> [member sid1] [member sid2] ... SAM Delete Domain Alias Member
|
||||
|
||||
label(creategroup) dit(bf(creategroup))
|
||||
SAM Create Domain Group
|
||||
|
||||
label(createalias) dit(bf(createalias))
|
||||
SAM Create Domain Alias
|
||||
|
||||
label(createuser) dit(bf(createuser))
|
||||
<username> SAM Create Domain User
|
||||
|
||||
label(delgroup) dit(bf(delgroup))
|
||||
SAM Delete Domain Group
|
||||
|
||||
label(delalias) dit(bf(delalias))
|
||||
SAM Delete Domain Alias
|
||||
|
||||
label(ntpass) dit(bf(ntpass))
|
||||
NT SAM Password Change
|
||||
|
||||
label(samuserset2) dit(bf(samuserset2))
|
||||
<username> [-s acb_bits] SAM User Set Info 2 (experimental!)
|
||||
|
||||
label(samuserset) dit(bf(samuserset))
|
||||
<username> [-p password] SAM User Set Info (experimental!)
|
||||
|
||||
label(samuser) dit(bf(samuser))
|
||||
<username> SAM User Query (experimental!)
|
||||
|
||||
label(samgroup) dit(bf(samgroup))
|
||||
<groupname> SAM Group Query (experimental!)
|
||||
|
||||
label(samalias) dit(bf(samalias))
|
||||
<aliasname> SAM Alias Query
|
||||
|
||||
label(samaliasmem) dit(bf(samaliasmem))
|
||||
<aliasname> SAM Alias Members
|
||||
|
||||
label(samgroupmem) dit(bf(samgroupmem))
|
||||
SAM Group Members
|
||||
|
||||
label(samtest) dit(bf(samtest))
|
||||
SAM User Encrypted RPC test (experimental!)
|
||||
|
||||
label(enumaliases) dit(bf(enumaliases))
|
||||
SAM Aliases Database Query (experimental!)
|
||||
|
||||
label(enumdomains) dit(bf(enumdomains))
|
||||
SAM Domains Database Query (experimental!)
|
||||
|
||||
label(enumgroups) dit(bf(enumgroups))
|
||||
SAM Group Database Query (experimental!)
|
||||
|
||||
label(dominfo) dit(bf(dominfo))
|
||||
SAM Query Domain Info
|
||||
|
||||
label(dispinfo) dit(bf(dispinfo))
|
||||
SAM Query Display Info
|
||||
|
||||
enddit()
|
||||
|
||||
enddit()
|
||||
|
||||
|
||||
label(NOTES)
|
||||
manpagesection(NOTES)
|
||||
|
||||
Some servers are fussy about the case of supplied usernames,
|
||||
passwords, share names (AKA service names) and machine names. If you
|
||||
fail to connect try giving all parameters in uppercase.
|
||||
|
||||
It is often necessary to use the link(bf(-n))(minusn) option when connecting
|
||||
to some types of servers. For example OS/2 LanManager insists on a valid
|
||||
NetBIOS name being used, so you need to supply a valid name that would
|
||||
be known to the server.
|
||||
|
||||
rpcclient only works on servers that support MSRPC over SMB. This includes
|
||||
all versions of Windows NT, including the ports to Unix such as AS/U and
|
||||
AFPS. Support for MSRPC over SMB in other servers is currently rare and
|
||||
patchy, for example Samba 2.0 only supports a limited set of MSRPC commands,
|
||||
and some of those are not supported very well.
|
||||
|
||||
label(ENVIRONMENTVARIABLES)
|
||||
manpagesection(ENVIRONMENT VARIABLES)
|
||||
|
||||
The variable bf(USER) may contain the username of the person using the
|
||||
client. This information is used only if the protocol level is high
|
||||
enough to support session-level passwords.
|
||||
|
||||
The variable bf(PASSWORD) may contain the password of the person using
|
||||
the client. This information is used only if the protocol level is
|
||||
high enough to support session-level passwords.
|
||||
|
||||
label(INSTALLATION)
|
||||
manpagesection(INSTALLATION)
|
||||
|
||||
The location of the client program is a matter for individual system
|
||||
administrators. The following are thus suggestions only.
|
||||
|
||||
It is recommended that the rpcclient software be installed in the
|
||||
/usr/local/samba/bin or /usr/samba/bin directory, this directory
|
||||
readable by all, writeable only by root. The client program itself
|
||||
should be executable by all. The client should em(NOT) be setuid or
|
||||
setgid!
|
||||
|
||||
The client log files should be put in a directory readable and
|
||||
writeable only by the user.
|
||||
|
||||
To test the client, you will need to know the name of a running
|
||||
SMB/CIFS server. It is possible to run url(bf(smbd (8)))(smbd.8.html)
|
||||
an ordinary user - running that server as a daemon on a
|
||||
user-accessible port (typically any port number over 1024) would
|
||||
provide a suitable test server.
|
||||
|
||||
label(DIAGNOSTICS)
|
||||
manpagesection(DIAGNOSTICS)
|
||||
|
||||
Most diagnostics issued by the client are logged in a specified log
|
||||
file. The log file name is specified at compile time, but may be
|
||||
overridden on the command line.
|
||||
|
||||
The number and nature of diagnostics available depends on the debug
|
||||
level used by the client. If you have problems, set the debug level to
|
||||
3 and peruse the log files.
|
||||
|
||||
label(VERSION)
|
||||
manpagesection(VERSION)
|
||||
|
||||
This man page is correct for version 2.0 of the Samba suite.
|
||||
|
||||
label(BUGS)
|
||||
manpagesection(BUGS)
|
||||
|
||||
startdit()
|
||||
dit(WARNING!)
|
||||
The MSPRC over SMB code has been developed from examining Network traces.
|
||||
No documentation is available from the original creators (Microsoft) on
|
||||
how MSRPC over SMB works, or how the individual MSRPC services work.
|
||||
Microsoft's implementation of these services has been demonstrated (and
|
||||
reported) to be... a bit flakey in places.
|
||||
|
||||
The development of Samba's implementation of these services is em(also)
|
||||
a bit rough, and as more of the services are understood, it can even result
|
||||
in versions of url(bf(smbd (8)))(smbd.8.html) and rpcclient that are
|
||||
backwards-incompatible for some commands or services. Additionally, the
|
||||
developers are sending reports to Microsoft, and problems found by or
|
||||
reported to Microsoft are fixed in Service Packs, which may also result in
|
||||
incompatibilities.
|
||||
|
||||
It is therefore not guaranteed that the execution of an rpcclient command will
|
||||
work. It is also not guaranteed that the target server will continue to
|
||||
operate, i.e the execution of an MSRPC command may cause a remote service to
|
||||
fail, or even cause the remote server to fail. Usual rules apply, of course:
|
||||
the developers bear absolutely no responsibility or liability for the use,
|
||||
misuse, or lack of use of rpcclient, by any person or persons, whether legal,
|
||||
illegal, accidental, deliberate, intentional, malicious, curious, etc.
|
||||
|
||||
This em(particularly) applies to the registry and SAM database commands.
|
||||
As you are using a command-line tool not a mouse-clicky tool, you have
|
||||
already proven yourself to be savvy, however if you don't know what you're
|
||||
doing, then em(don't do it!).
|
||||
|
||||
dit(Command Completion)
|
||||
Command-completion (available if you have the GNU readline library) used on
|
||||
certain commands may not operate correctly if the word being completed (such as a registry key) contains a space. Typically, the name will be completed, but
|
||||
you will have to go back and put quotes round it, yourself.
|
||||
|
||||
dit(SAM Database command-completion)
|
||||
Command-completion (available if you have the GNU readline library) of user,
|
||||
group and alias names does not work on remote Domains, which would normally
|
||||
be specified like this: nl()
|
||||
tt(DOMAIN_name\user_name). nl()
|
||||
The only names that can be completed in this fashion are the local names
|
||||
in the SAM database of the target server.
|
||||
|
||||
dit(link(bf(spoolenum))(spoolenum))
|
||||
Due to current limitations in the rpcclient MSRPC / SMB code, and due to
|
||||
the extremely poor MSRPC implementation (by Microsoft) of the spooler
|
||||
service, if there are a large number of printers (or the names / comment
|
||||
fields associated with the printers), this command will fail. The
|
||||
limitations require further research to be carried out; we're stuck with
|
||||
the poor \PIPE\spoolss design.
|
||||
|
||||
endit()
|
||||
|
||||
label(AUTHOR)
|
||||
manpageauthor()
|
||||
|
||||
The original Samba software and related utilities were created by
|
||||
Andrew Tridgell email(samba-bugs@samba.org). Samba is now developed
|
||||
by the Samba Team as an Open Source project similar to the way the
|
||||
Linux kernel is developed.
|
||||
|
||||
The original Samba man pages were written by Karl Auer. The man page
|
||||
sources were converted to YODL format (another excellent piece of Open
|
||||
Source software, available at
|
||||
url(bf(ftp://ftp.icce.rug.nl/pub/unix/))(ftp://ftp.icce.rug.nl/pub/unix/))
|
||||
and updated for the Samba2.0 release by Jeremy Allison. This man page
|
||||
was developed cut-and-paste style from the smbclient man page, by
|
||||
Luke Kenneth Casson Leighton.
|
||||
email(samba-bugs@samba.org).
|
||||
|
||||
See url(bf(samba (7)))(samba.7.html) to find out how to get a full
|
||||
list of contributors and details on how to submit bug reports,
|
||||
comments etc.
|
||||
|
@ -1,65 +0,0 @@
|
||||
Date: Tue, 07 Apr 1998
|
||||
Contributor: Christoph L. Spiel <Christoph_Spiel@physik.tu-muenchen.de>
|
||||
Organization: Munich Institute of Technology, Institute E10
|
||||
Subject: WISHES:LINUX:smbmount
|
||||
===============================================================================
|
||||
Machine Arch: i386
|
||||
Machine OS: linux
|
||||
Kernel: 2.1.85
|
||||
Samba Version: Version 1.9.18p3
|
||||
Mount Version: 2.7i
|
||||
Autofs Version: 0.3.14
|
||||
|
||||
|
||||
Hi SAMBA developers!
|
||||
|
||||
I have written a shell script that marries smbmount and mount
|
||||
on a Linux-machine with a 2.1.55+ kernel (i.e., a newer developper
|
||||
kernel. Especially it makes smbmount compatible
|
||||
with autofs! Now, You (when root :-) can say
|
||||
mount -t smb /win-machine/my-share /mntpt
|
||||
Concerning the management of the user/password-pairs I have already
|
||||
made a step in the right direction, but there is still a lot of
|
||||
brain-work to do :-(
|
||||
|
||||
The primary problem with the Win passwords
|
||||
is that they are under user-control, and not under admin-control
|
||||
as the Linux passwords are. Therfore, I give every SAMBA user
|
||||
a
|
||||
~/smb-pass
|
||||
file where she can manage her usernames and passwords herself.
|
||||
The fundamental mount-tables /etc/fstab and /etc/auto.* only
|
||||
list the mount-point and the respective options. The user´s
|
||||
password file is adressed via the uuname=<user_name>-option.
|
||||
|
||||
An important "side-effect" is that the password file need not to
|
||||
be word-readable. In fact my script tests for user-only rights of
|
||||
this file to close this potential security-hole.
|
||||
|
||||
The script mount.smb has to be installed in /sbin and given mode 755.
|
||||
No suid is necessary! I attached an automount table that is currently
|
||||
in use on my machine. A user´s password file looks like this:
|
||||
|
||||
$ cat ~/smb-pass
|
||||
supra:/cspiel cspiel secret
|
||||
helium:/c cspiel sesame
|
||||
^ ^ ^
|
||||
| | +- password
|
||||
| +- username
|
||||
+- share-name as in fundamental mount-table.
|
||||
|
||||
It would be nice, if someone else tests my script. Maybe, You have
|
||||
already found a better solution than mine. If You find it useful,
|
||||
I would be glad to donate it to the SAMBA-project.
|
||||
|
||||
BUGS:
|
||||
(1) There is no documentation yet. (Yes, I consider this a bug!)
|
||||
(2) When used with autofs the automounter overruns mount.smb.
|
||||
This means when accessing an automounted share for the 1st time
|
||||
You may get an empty directory. Retrying several times will
|
||||
cause the mount to complete successfully.
|
||||
|
||||
|
||||
Best,
|
||||
Christoph Spiel
|
||||
|
@ -1,441 +0,0 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
|
||||
# name: mount.smb -- interface between mount and smbmount
|
||||
# author: Ch. L. Spiel (cspiel@physik.tu-muenchen.de)
|
||||
# $Id: mount.smb,v 1.1 1998/04/13 12:31:10 jht Exp $
|
||||
|
||||
# bash version: 1.14.7(1)
|
||||
# mount version: 2.7i
|
||||
# smbmount version: 1.9.18p3
|
||||
|
||||
|
||||
myname=`basename $0`
|
||||
passwd_filename="smb-pass" # name of user smb-password file
|
||||
lock_file="/var/lock/$myname"
|
||||
log_file="/tmp/mount.smb.log"
|
||||
|
||||
PATH=/usr/local/samba/bin:/usr/bin:/bin
|
||||
|
||||
# check for an existing lock-file quickly(!)
|
||||
if [ -e "$lock_file" ]; then
|
||||
# exit, but don´t touch lock-file
|
||||
exit 0
|
||||
fi
|
||||
# set up new lock-file
|
||||
echo > $lock_file
|
||||
|
||||
# initialise log-file
|
||||
echo "logging of $myname started at `date`" > $log_file
|
||||
chmod --silent 600 $log_file
|
||||
echo "called with: $@" >> $log_file
|
||||
exec >> $log_file 2>&1
|
||||
|
||||
|
||||
|
||||
# set default and initial values
|
||||
verbose=false # be silent
|
||||
fake=false # really do the mount
|
||||
fmode="-f 600" # default file mode
|
||||
dmode="-d 700" # default dir mode
|
||||
|
||||
#uid="-u `id | sed 's/^uid=\([0-9]*\).*$/\1/'`"
|
||||
uid="-u 0"
|
||||
#gid="-g `id | sed 's/^.*gid=\([0-9]*\).*$/\1/'`"
|
||||
gid="-g 0"
|
||||
|
||||
|
||||
#
|
||||
# functions
|
||||
#
|
||||
|
||||
# exitproc(int exit_code)
|
||||
function exit_proc
|
||||
{
|
||||
if [ -n "$lock_file" ]; then
|
||||
# remove current lock-file
|
||||
rm "$lock_file"
|
||||
fi
|
||||
# update log-file
|
||||
echo "" >> $log_file
|
||||
echo "$myname´s return value is $1." >> $log_file
|
||||
echo "logging of $myname ended at `date`." >> $log_file
|
||||
# done.
|
||||
exit $1
|
||||
}
|
||||
|
||||
|
||||
# split_arg(arg)
|
||||
# arg ::= id '=' val
|
||||
# set id and val on return
|
||||
function split_arg
|
||||
{
|
||||
id="$1"
|
||||
val="$2"
|
||||
extra="$3"
|
||||
} # end of split_arg
|
||||
|
||||
|
||||
# split_passwdline(uline)
|
||||
function split_passwdline
|
||||
{
|
||||
user_name=$1
|
||||
real_password=$2
|
||||
user_id=$3
|
||||
group_id=$4
|
||||
full_name=$5
|
||||
home_dir=$6
|
||||
shell_name=$7
|
||||
}
|
||||
|
||||
|
||||
# get_homedir(username)
|
||||
function get_homedir
|
||||
{
|
||||
local temp_ifs
|
||||
|
||||
temp_ifs="$IFS"
|
||||
uline=`grep "^$1" /etc/passwd`
|
||||
if [ -z "$uline" ]; then
|
||||
echo "$myname: unknown user \"$1\""
|
||||
exit_proc 1
|
||||
fi
|
||||
IFS=":"
|
||||
split_passwdline $uline
|
||||
if [ -z "$home_dir" ]; then
|
||||
echo "$myname: user \"$1\" has no home directory"
|
||||
exit_proc 1
|
||||
fi
|
||||
echo "$home_dir"
|
||||
IFS="$temp_ifs"
|
||||
}
|
||||
|
||||
|
||||
# get_uid(username)
|
||||
function get_uid
|
||||
{
|
||||
local temp_ifs
|
||||
|
||||
temp_ifs="$IFS"
|
||||
uline=`grep "^$1" /etc/passwd`
|
||||
if [ -z "$uline" ]; then
|
||||
echo "$myname: unknown user \"$1\""
|
||||
exit_proc 1
|
||||
fi
|
||||
IFS=":"
|
||||
split_passwdline $uline
|
||||
echo "$user_id"
|
||||
IFS="$temp_ifs"
|
||||
}
|
||||
|
||||
|
||||
# get_gid(username)
|
||||
function get_gid
|
||||
{
|
||||
local temp_ifs
|
||||
|
||||
temp_ifs="$IFS"
|
||||
uline=`grep "^$1" /etc/passwd`
|
||||
if [ -z "$uline" ]; then
|
||||
echo "$myname: unknown user \"$1\""
|
||||
exit_proc 1
|
||||
fi
|
||||
IFS=":"
|
||||
split_passwdline $uline
|
||||
echo "$group_id"
|
||||
IFS="$temp_ifs"
|
||||
}
|
||||
|
||||
|
||||
# read_passwd_file(sharename)
|
||||
function read_passwd_file
|
||||
{
|
||||
local pwd_filename pwd_entry temp_ifs share_name fmod
|
||||
|
||||
pwd_filename=`get_homedir $uuname`/$passwd_filename
|
||||
# use uid and gid of user´s /etc/password entry
|
||||
uid="-u `get_uid $uuname`"
|
||||
gid="-g `get_gid $uuname`"
|
||||
# check existence of password file
|
||||
if [ ! -f "$pwd_filename" -o ! -r "$pwd_filename" ]; then
|
||||
echo "$myname: cannot read from user password file \"$pwd_filename\""
|
||||
exit_proc 1
|
||||
fi
|
||||
# check file permissions
|
||||
for f in $pwd_filename{,~,%,.BAK,.bak,.new,.old,.orig,.sav}; do
|
||||
if [ ! -f $f ]; then continue; fi
|
||||
/bin/ls -l $f | grep -q -- "^-r\(w\|-\)------"
|
||||
if [ $? = 1 ]; then
|
||||
echo "$myname: Found security hole: mode of file \"$f\""
|
||||
echo "$myname: Password file must have permission 400 or 600."
|
||||
echo "$myname: Please fix the file´s mode."
|
||||
exit_proc 1
|
||||
fi
|
||||
done
|
||||
|
||||
share_name="$1" # sharename in smb-format!
|
||||
pwd_entry=`grep -v '^#' "$pwd_filename" | grep -i "^$share_name"`
|
||||
if [ -z "$pwd_entry" ]; then
|
||||
# try uni*-like sharename
|
||||
share_name=`echo $share_name | sed -e 's,^//,,' -e 's,/,:/,'`
|
||||
pwd_entry=`grep -v '^#' "$pwd_filename" | grep -i "^$share_name"`
|
||||
fi
|
||||
if [ -z "$pwd_entry" ]; then
|
||||
# sharename was not found in user´s password file
|
||||
echo "$myname: cannot authentify share named \"$1\" via file \"$pwd_filename\""
|
||||
exit_proc 1
|
||||
fi
|
||||
|
||||
# pwd_entry has the form:
|
||||
# sharename username password
|
||||
temp_ifs="$IFS"
|
||||
IFS=" " # <tab> and <space>
|
||||
split_arg $pwd_entry
|
||||
options="$options -U $val"
|
||||
password="$extra"
|
||||
IFS="$temp_ifs"
|
||||
}
|
||||
|
||||
|
||||
# process_options(opt1, opt2, ..., optN)
|
||||
function process_options
|
||||
{
|
||||
local temp_ifs
|
||||
|
||||
for j; do
|
||||
temp_ifs="$IFS" # save current internal-field separator
|
||||
IFS="=" # set new separator
|
||||
split_arg $j # split argument into identifier and value
|
||||
IFS="$temp_ifs" # reset old separator
|
||||
case "$id" in
|
||||
port)
|
||||
options="$options -p $val"
|
||||
;;
|
||||
debug)
|
||||
options="$options -d $val"
|
||||
;;
|
||||
log)
|
||||
options="$options -l $val"
|
||||
;;
|
||||
nbname)
|
||||
options="$options -n $val"
|
||||
;;
|
||||
nopwd)
|
||||
options="$options -N"
|
||||
;;
|
||||
maxproto)
|
||||
options="$options -m $val"
|
||||
;;
|
||||
ip)
|
||||
options="$options -I $val"
|
||||
;;
|
||||
uname)
|
||||
options="$options -U $val"
|
||||
;;
|
||||
wrkgrp)
|
||||
options="$options -W $val"
|
||||
;;
|
||||
term)
|
||||
options="$options -t $val"
|
||||
;;
|
||||
sdir)
|
||||
options="$options -D $val"
|
||||
;;
|
||||
pwd)
|
||||
# DO NOT USE THIS OPTION! It is a severe scurity hole.
|
||||
password="$val"
|
||||
;;
|
||||
uuname)
|
||||
# consult user´s smb-password file
|
||||
uuname="$val" # uni* user name
|
||||
read_passwd_file "$server_service"
|
||||
;;
|
||||
|
||||
# ignored options
|
||||
async)
|
||||
# do nothing
|
||||
;;
|
||||
atime)
|
||||
# do nothing
|
||||
;;
|
||||
auto)
|
||||
# do nothing
|
||||
;;
|
||||
defaults)
|
||||
# do nothing
|
||||
;;
|
||||
dev)
|
||||
# do nothing
|
||||
;;
|
||||
exec)
|
||||
# do nothing
|
||||
;;
|
||||
noatime)
|
||||
# do nothing
|
||||
;;
|
||||
noauto)
|
||||
# do nothing
|
||||
;;
|
||||
nodev)
|
||||
# do nothing
|
||||
;;
|
||||
noexec)
|
||||
# do nothing
|
||||
;;
|
||||
nosuid)
|
||||
# do nothing
|
||||
;;
|
||||
nouser)
|
||||
# do nothing
|
||||
;;
|
||||
ro)
|
||||
# do nothing
|
||||
;;
|
||||
rw)
|
||||
# do nothing
|
||||
;;
|
||||
suid)
|
||||
# do nothing
|
||||
;;
|
||||
sync)
|
||||
# do nothing
|
||||
;;
|
||||
user)
|
||||
# do nothing
|
||||
;;
|
||||
|
||||
# fs options
|
||||
fmod)
|
||||
fmode="-f $val"
|
||||
;;
|
||||
dmod)
|
||||
dmode="-d $val"
|
||||
;;
|
||||
uid)
|
||||
uid="-u $val"
|
||||
;;
|
||||
gid)
|
||||
gid="-g $val"
|
||||
;;
|
||||
|
||||
# fallthrough
|
||||
*)
|
||||
echo "$myname: unrecognized option $id"
|
||||
exit_proc 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
} # end of split_options
|
||||
|
||||
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
|
||||
|
||||
|
||||
if [ "$verbose" != "false" ]; then
|
||||
# show how we have been called
|
||||
echo "$myname: $*"
|
||||
fi
|
||||
|
||||
# some checks of the input parameters
|
||||
if [ "$#" -lt 2 ]; then
|
||||
echo "$myname: need at least service and mountpoint"
|
||||
exit_proc 1
|
||||
fi
|
||||
|
||||
if `echo "$2" | grep -vq "^/"`; then
|
||||
echo "$myname: mount point must be an absolut path"
|
||||
exit_proc 1
|
||||
fi
|
||||
|
||||
|
||||
# copy arguments
|
||||
if `echo "$1" | grep -q ":/"`; then
|
||||
# non--standard format, i.e., server:/service
|
||||
server_service=`echo "//$1" | sed -e "sx:/x/x"`
|
||||
else
|
||||
# standard format, i.e, //server/service
|
||||
server_service="$1"
|
||||
fi
|
||||
mntpt="$2"
|
||||
|
||||
# copy options
|
||||
shift 2 # skip arguments: //server/service and /mnt-point
|
||||
for i; do
|
||||
case "$i" in
|
||||
-f | --fake)
|
||||
fake=true
|
||||
;;
|
||||
-h | --help)
|
||||
echo "usage: mount.smb service [password] mountpoint [options]"
|
||||
exit_proc 0
|
||||
;;
|
||||
-v | --verbose)
|
||||
verbose=true
|
||||
;;
|
||||
-V | --version)
|
||||
echo "$myname: mount.smb-0.1.0"
|
||||
exit_proc 0
|
||||
;;
|
||||
-o)
|
||||
shift # skip leading -o
|
||||
temp_ifs="$IFS" # save current internal-field separator
|
||||
IFS="," # set new separator
|
||||
process_options $*
|
||||
IFS="$temp_ifs" # reset old separator
|
||||
break # mount places options at the end -> we are done
|
||||
;;
|
||||
*)
|
||||
echo "$myname: unrecognized option $i"
|
||||
exit_proc 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
IFS=' '
|
||||
|
||||
|
||||
#
|
||||
# be careful...
|
||||
#
|
||||
|
||||
|
||||
# nmblookup server: is node up and running?
|
||||
srv=`echo $server_service | sed 's,^//\(.*\)/.*$,\1,'` # server´s name
|
||||
nmblookup "$srv" | grep -q "failed to find name"
|
||||
if [ "$?" = 0 ]; then
|
||||
echo "$myname: failed to find server \"$srv\"."
|
||||
exit_proc 1
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# perform mount
|
||||
#
|
||||
|
||||
|
||||
fs_options="$fmode $dmode $uid $gid" # all options concerning the mounted fs
|
||||
if [ "$verbose" = "true" ]; then
|
||||
# display what we would do. Do not show the password, only show "xxx".
|
||||
echo -n "smbmount $server_service "
|
||||
if [ -n "$password" ]; then # password is set
|
||||
echo -n "xxx " # ... but we don´t show it ;-)
|
||||
fi
|
||||
echo "-c \"mount $mntpt $fs_options\" $options"
|
||||
#else
|
||||
# supress further messages
|
||||
# exec > /dev/null 2>&1
|
||||
#:
|
||||
fi
|
||||
|
||||
if [ "$fake" != "true" ]; then
|
||||
smbmount $server_service $password -c "mount $mntpt $fs_options" $options
|
||||
echo "smbmount´s exit code was $?."
|
||||
fi
|
||||
|
||||
# clean up and exit
|
||||
exit_proc 0
|
||||
|
@ -1,11 +0,0 @@
|
||||
This directory contains example programs and scripts that have been written by
|
||||
Samba rpcclient administrators and users. You may, or may not, find
|
||||
some of them useful. They have been submitted here for use at your own
|
||||
risk, and no responsibility is accepted for their use or mis-use.
|
||||
|
||||
Program Author Purpose
|
||||
------- ------ -------
|
||||
|
||||
ntsd.c David Bannon. Pings several workstations and shuts them down.
|
||||
Used by David in a lab environment to kick students
|
||||
off workstations from a cron job.
|
@ -1,259 +0,0 @@
|
||||
/* This is an experiemental programme to shutdown a group of NTws in a
|
||||
Samba domain via rpcclient.
|
||||
|
||||
Copyright (c) David Bannon 1999
|
||||
David Bannon, D.Bannon@latrobe.edu.au, 4th November, 1999
|
||||
|
||||
Full permission is granted to use this code (for what that is worth) in
|
||||
any way you wish, strictly at your own risk.
|
||||
|
||||
I use it from a cron a job to close a computer lab down at 5:00 pm.
|
||||
|
||||
It has some serious security implications, make sure you understand
|
||||
them before using this code !
|
||||
|
||||
If you find a way to make this 'power down' a machine that is set up to
|
||||
do power down correctly please let me know !!
|
||||
|
||||
Machines to be shutdown must be members of a samba (or NT) domain.
|
||||
You are going to have to offer your domain admin user name/password
|
||||
(see below).
|
||||
|
||||
As you probably don't want your domain admin password appearing in the
|
||||
crontab file or popping up in a 'ps' list, it can be encrypted and the
|
||||
programme will tell you what it should look like. i.e :
|
||||
|
||||
[root@bclab shutdown]# ./ntsd -e
|
||||
Domain Admin User name :dbannon
|
||||
Domain Admin Password
|
||||
Use the string between [] after a -p : [1HCeTcXqOfo7R[hg]
|
||||
[root@bclab shutdown]#
|
||||
|
||||
Now a crontab entry would look like this :
|
||||
|
||||
00 17 * * 1-5 /usr/local/sbin/ntsd -p'1HCeTcXqOfo7R[hg' -a
|
||||
|
||||
The -p indicates passwd (actually user name and password) and the
|
||||
-a says shutdown all machines. Note that the password string must
|
||||
have inverted commas around it so the shell does not try and expand
|
||||
any special charachers that it is likely to contain.
|
||||
|
||||
Security Alert !!
|
||||
The encryption is pretty weak and its reversable ! Change the key
|
||||
strings, compile and change the key strings again ! You don't need
|
||||
to remember the key but if you leave the unchanged source around
|
||||
someone may use it to reverse the encryption. The Keys are in lumps
|
||||
to stop someone doing a 'cat ntsd' and seeing the key string.
|
||||
(yeah, I know its not very clever, but they should not be able to
|
||||
read the binary or your crontab anyway)
|
||||
|
||||
Ping
|
||||
I ping the target machines before trying to shut them down, you
|
||||
dont't need to, just let rpcclient time out. If you want to ping
|
||||
first (because its nicer !) you need :
|
||||
1. First element of IP name should be the netbios name. (makes sense)
|
||||
2. If the server you will run the cron job from does not have the
|
||||
same default domain name as machines being shutdown then you will
|
||||
need to define USE_DOMAIN and put in appropriate ip domain info.
|
||||
This code does ping, get busy with vi if you don't want to.
|
||||
|
||||
Machine Names
|
||||
For this system to be practical, the machine names must be in some
|
||||
sort of sequence, ie bclab1, bclab2, bclab3, not more creative like
|
||||
grumpy, dopey, sneezy. See the code in main() to see how the names
|
||||
are built.
|
||||
|
||||
Configuration
|
||||
|
||||
Machine Names
|
||||
If you have used a naming scheme like mine then you may need to
|
||||
change only LASTMACHINE and PREFIX, otherwise look at main().
|
||||
|
||||
Binary locations.
|
||||
We need to find the rpcclient and ping binaries. The values below
|
||||
are typical. Better check first.
|
||||
|
||||
Compile
|
||||
Known to compile cleanly on linux (RH5.0 - RH6.1) and DEC 4.0. Does
|
||||
not do anything fancy so should compile on most systems easily
|
||||
enough.
|
||||
|
||||
Install
|
||||
Rename the binary (ie ntsd) and put it somewhere safe. It should
|
||||
be rwx root only. Comes up with basic help if run without command
|
||||
line switch, prompts for admin user name and password if used
|
||||
without the -p switch.
|
||||
(Typically)Put entry in your crontab (crontab -e) and watch the
|
||||
fun. Remember, it does not keep them shutdown, try an entry every
|
||||
5 minutes for a while (or until door is locked).
|
||||
*/
|
||||
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<unistd.h>
|
||||
#include<pwd.h>
|
||||
|
||||
#define PING "/bin/ping"
|
||||
#define RPCCLIENT "/usr/local/samba/bin/rpcclient"
|
||||
|
||||
|
||||
#define LASTMACHINE 14 /* ie, scans bclab1 through to bclab14 */
|
||||
#define PREFIX "bclab"
|
||||
|
||||
/* #define USE_DOMAIN Only if you need full ip name to ping machines */
|
||||
|
||||
#ifdef USE_DOMAIN
|
||||
#define DOMAIN ".biochem.latrobe.edu.au" /* required by ping, possibly.
|
||||
*/
|
||||
#endif
|
||||
|
||||
#define KEY1 "Please"
|
||||
#define KEY2 "don't leave"
|
||||
#define KEY3 "this"
|
||||
#define KEY4 "as it is"
|
||||
#define KEY5 "here"
|
||||
#define KEY6 "silly."
|
||||
|
||||
|
||||
int Shutdown(char *machine, char *PassWord) {
|
||||
char Buff[128], *Ptr;
|
||||
int Res;
|
||||
/* printf("Shutting down %s\n", machine); */
|
||||
sprintf(Buff, "/bin/ping -c 1 -q %s > /dev/null", machine);
|
||||
Res = system(Buff);
|
||||
if (Res == 0) { /* its turned on */
|
||||
Ptr = machine;
|
||||
/* first 'word' in ip name = netbios name, get rid of rest */
|
||||
while (*++Ptr != 0) if (*Ptr == '.') *Ptr = 0;
|
||||
printf("Shutting down %s\n", machine);
|
||||
sprintf(Buff, "%s -c shutdown -U%s -S %s", RPCCLIENT, PassWord,
|
||||
machine);
|
||||
system(Buff);
|
||||
}
|
||||
}
|
||||
|
||||
int Usage(char *prog) {
|
||||
printf("Programme to shutdown NTs in domain.\n");
|
||||
printf("Normally called from cron (using encrypted passwd, see -e and
|
||||
-p).\n");
|
||||
printf("Usage \n");
|
||||
printf(" -a shutdown all machines %s1 to %s%d. \n",
|
||||
PREFIX, PREFIX, LASTMACHINE);
|
||||
printf(" -m machine shutdown [machine] (might need full ip
|
||||
name).\n");
|
||||
printf(" -e tell me my encrypted name and password to
|
||||
use with -p.\n");
|
||||
printf(" -p'pw_string' use encrypted name & password as given by
|
||||
-e.\n");
|
||||
printf(" You must have single inverted commas around
|
||||
the pw string !");
|
||||
printf(" -h help, give this message.\n");
|
||||
printf("Typical cron line : 00 17 * * 1-5 /usr/local/sbin/ntsd
|
||||
-p1HCeTcXqOfo7R[hg -a\n");
|
||||
printf(" David Bannon,
|
||||
Nov 1999\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int GetPassWord(char *Passwd) {
|
||||
char *ptr, *p;
|
||||
char User[128];
|
||||
printf("Domain Admin User name :");
|
||||
fgets(User, 127, stdin);
|
||||
if (strlen(User) < 3) {
|
||||
printf("Short user name, exiting.\n");
|
||||
exit(1);
|
||||
}
|
||||
p = User;
|
||||
while (*p != '\n') p++; /* get rid of newline */
|
||||
*p = 0;
|
||||
ptr = getpass("Domain Admin Password ");
|
||||
if (strlen(ptr) < 3) {
|
||||
printf("Short password, exiting.\n");
|
||||
exit(1);
|
||||
}
|
||||
strcpy(Passwd, User); /* do this with sprintf */
|
||||
strcat(Passwd, "%");
|
||||
strcat(Passwd, ptr);
|
||||
*ptr = 0; /* clean up system buffer */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Encrypt(char *InPass) {
|
||||
char Pass[128], Enc[128];
|
||||
int Temp;
|
||||
char *Hash;
|
||||
int Offset = 0;
|
||||
Hash = malloc(256);
|
||||
/* so it a bit harder than just 'cat ntsd' */
|
||||
sprintf(Hash, "%s%s%s%s%s%s", KEY4, KEY3, KEY2, KEY5, KEY1, KEY6);
|
||||
if (InPass == 0) {
|
||||
GetPassWord(Pass); /* may not return */
|
||||
while (*(Pass + Offset) != 0) {
|
||||
Temp = *(Pass + Offset) + *(Hash + Offset) - ' ';
|
||||
if (Temp > '~') Temp = Temp - 95;
|
||||
*(Pass+Offset++) = Temp;
|
||||
}
|
||||
printf("Use the string between [] after a -p : ['%s']\n", Pass);
|
||||
exit(0);
|
||||
} else {
|
||||
while (*(InPass + Offset) != 0) {
|
||||
Temp = *(InPass + Offset) - *(Hash + Offset) + ' ';
|
||||
if (Temp < ' ') Temp = Temp + 95;
|
||||
*(InPass+Offset++) = Temp;
|
||||
}
|
||||
}
|
||||
free(Hash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
int Ch;
|
||||
static char *prog_name;
|
||||
int MachineNo = 0, AllMachines = 0;
|
||||
char Machine[128], PassWord[128];
|
||||
uid_t UID = getuid();
|
||||
prog_name = argv[0];
|
||||
if (UID != 0) {
|
||||
printf("Sorry, this programme can only be run as root.\n");
|
||||
exit(1);
|
||||
}
|
||||
*Machine = 0;
|
||||
*PassWord = 0;
|
||||
if (argc < 2) Usage(prog_name);
|
||||
while ((Ch = getopt(argc, argv, "haem:p:")) != EOF) {
|
||||
switch(Ch) {
|
||||
case 'e': Encrypt(NULL); break; /* Does not return */
|
||||
case 'a': AllMachines = 1; break;
|
||||
case 'm': strcpy(Machine, optarg); break;
|
||||
case 'p': strcpy(PassWord, optarg); break;
|
||||
case 'h': Usage(prog_name);
|
||||
default: Usage(prog_name);
|
||||
}
|
||||
}
|
||||
if (*PassWord == 0) GetPassWord(PassWord); /* may not return */
|
||||
else Encrypt(PassWord);
|
||||
if (*Machine != 0) {
|
||||
Shutdown(Machine, PassWord);
|
||||
exit(0);
|
||||
}
|
||||
/* printf("exit for safety = %s.\n", PassWord);
|
||||
exit(0); */
|
||||
while (++MachineNo < LASTMACHINE+1) {
|
||||
pid_t Proc;
|
||||
#ifdef USE_DOMAIN
|
||||
sprintf(Machine, "%s%d%s", PREFIX, MachineNo, DOMAIN);
|
||||
#else
|
||||
sprintf(Machine, "%s%d", PREFIX, MachineNo);
|
||||
#endif
|
||||
Proc = fork();
|
||||
if (Proc == 0) { /* in child process */
|
||||
Shutdown(Machine, PassWord);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
printf("Shutdowns initiated.\n");
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
Preparation Date: Mon November 16 1998
|
||||
Preparer: John H Terpstra <jht@samba.org>
|
||||
|
||||
Instructions: Preparing Samba Packages for Caldera OpenLinux 1.2
|
||||
==================================================================
|
||||
|
||||
We provide support only for current versions of Caldera OpenLinux.
|
||||
|
||||
To produce the RPMS simply type:
|
||||
sh makerpms.sh
|
||||
|
@ -1,141 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Prints info on all smb responding machines on a subnet.
|
||||
# This script needs to be run on a machine without nmbd running and be
|
||||
# run as root to get correct info from WIN95 clients.
|
||||
#
|
||||
# syntax:
|
||||
# findsmb [subnet broadcast address]
|
||||
#
|
||||
# with no agrument it will list machines on the current subnet
|
||||
#
|
||||
# There will be a "+" in front of the workgroup name for machines that are
|
||||
# local master browsers for that workgroup. There will be an "*" in front
|
||||
# of the workgroup name for machines that are the domain master browser for
|
||||
# that workgroup.
|
||||
#
|
||||
|
||||
$SAMBABIN = "/usr/bin";
|
||||
|
||||
for ($i = 0; $i < 2; $i++) { # test for -d option and broadcast address
|
||||
$_ = shift;
|
||||
if (m/-d|-D/) {
|
||||
$DEBUG = 1;
|
||||
} else {
|
||||
if ($_) {
|
||||
$BCAST = "-B $_";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub ipsort # do numeric sort on last field of IP address
|
||||
{
|
||||
@t1 = split(/\./,$a);
|
||||
@t2 = split(/\./,$b);
|
||||
@t1[3] <=> @t2[3];
|
||||
}
|
||||
|
||||
# look for all machines that respond to a name lookup
|
||||
|
||||
open(NMBLOOKUP,"$SAMBABIN/nmblookup $BCAST '*'|") ||
|
||||
die("Can't run nmblookup '*'.\n");
|
||||
|
||||
# get rid of all lines that are not a response IP address,
|
||||
# strip everything but IP address and sort by last field in address
|
||||
|
||||
@ipaddrs = sort ipsort grep(s/ \*<00>.*$//,<NMBLOOKUP>);
|
||||
|
||||
# print header info
|
||||
|
||||
print "\nIP ADDR NETBIOS NAME WORKGROUP/OS/VERSION $BCAST\n";
|
||||
print "---------------------------------------------------------------------\n";
|
||||
|
||||
foreach $ip (@ipaddrs) # loop through each IP address found
|
||||
{
|
||||
$ip =~ s/\n//; # strip newline from IP address
|
||||
|
||||
# find the netbios names registered by each machine
|
||||
|
||||
open(NMBLOOKUP,"$SAMBABIN/nmblookup -r -A $ip|") ||
|
||||
die("Can't get nmb name list.\n");
|
||||
@nmblookup = <NMBLOOKUP>;
|
||||
close NMBLOOKUP;
|
||||
|
||||
# get the first <00> name
|
||||
|
||||
@name = grep(/<00>/,@nmblookup);
|
||||
$_ = @name[0];
|
||||
if ($_) { # we have a netbios name
|
||||
if (/GROUP/) { # is it a group name
|
||||
($name, $aliases, $type, $length, @addresses) =
|
||||
gethostbyaddr(pack('C4',split('\.',$ip)),2);
|
||||
if (! $name) { # could not get name
|
||||
$name = "unknown nis name";
|
||||
}
|
||||
} else {
|
||||
/(\S+)/;
|
||||
$name = $1;
|
||||
}
|
||||
|
||||
# do an smbclient command on the netbios name.
|
||||
|
||||
open(SMB,"$SAMBABIN/smbclient -N -L $name -I $ip -U% |") ||
|
||||
die("Can't do smbclient command.\n");
|
||||
@smb = <SMB>;
|
||||
close SMB;
|
||||
|
||||
if ($DEBUG) { # if -d flag print results of nmblookup and smbclient
|
||||
print "===============================================================\n";
|
||||
print @nmblookup;
|
||||
print @smb;
|
||||
}
|
||||
|
||||
# look for the OS= string
|
||||
|
||||
@info = grep(/OS=/,@smb);
|
||||
$_ = @info[0];
|
||||
if ($_) { # we found response
|
||||
s/Domain=|OS=|Server=|\n//g; # strip out descriptions to make line shorter
|
||||
|
||||
} else { # no OS= string in response (WIN95 client)
|
||||
|
||||
# for WIN95 clients get workgroup name from nmblookup response
|
||||
@name = grep(/<00> - <GROUP>/,@nmblookup);
|
||||
$_ = @name[0];
|
||||
if ($_) {
|
||||
/(\S+)/;
|
||||
$_ = "[$1]";
|
||||
} else {
|
||||
$_ = "Unknown Workgroup";
|
||||
}
|
||||
}
|
||||
|
||||
# see if machine registered a local master browser name
|
||||
if (grep(/<1d>/,@nmblookup)) {
|
||||
$master = '+'; # indicate local master browser
|
||||
if (grep(/<1b>/,@nmblookup)) { # how about domain master browser?
|
||||
$master = '*'; # indicate domain master browser
|
||||
}
|
||||
} else {
|
||||
$master = ' '; # not a browse master
|
||||
}
|
||||
|
||||
# line up info in 3 columns
|
||||
|
||||
print "$ip".' 'x(16-length($ip))."$name".' 'x(14-length($name))."$master"."$_\n";
|
||||
|
||||
} else { # no netbios name found
|
||||
# try getting the host name
|
||||
($name, $aliases, $type, $length, @addresses) =
|
||||
gethostbyaddr(pack('C4',split('\.',$ip)),2);
|
||||
if (! $name) { # could not get name
|
||||
$name = "unknown nis name";
|
||||
}
|
||||
if ($DEBUG) { # if -d flag print results of nmblookup
|
||||
print "===============================================================\n";
|
||||
print @nmblookup;
|
||||
}
|
||||
print "$ip".' 'x(16-length($ip))."$name\n";
|
||||
}
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
diff -uNr samba-PVERSION/source/Makefile.in samba-kgc/source/Makefile.in
|
||||
--- samba-PVERSION/source/Makefile.in Wed Dec 2 14:35:18 1998
|
||||
+++ samba-kgc/source/Makefile.in Wed Dec 2 15:06:02 1998
|
||||
@@ -27,7 +27,7 @@
|
||||
# the previous releases of Samba
|
||||
SBINDIR = @bindir@
|
||||
LIBDIR = @libdir@
|
||||
-VARDIR = $(BASEDIR)/var
|
||||
+VARDIR = /var
|
||||
MANDIR = @mandir@
|
||||
|
||||
# The permissions to give the executables
|
||||
@@ -36,23 +36,23 @@
|
||||
# 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
|
||||
+SMBLOGFILE = $(VARDIR)/log/samba/log.smb
|
||||
+NMBLOGFILE = $(VARDIR)/log/samba/log.nmb
|
||||
CONFIGFILE = $(LIBDIR)/smb.conf
|
||||
LMHOSTSFILE = $(LIBDIR)/lmhosts
|
||||
DRIVERFILE = $(LIBDIR)/printers.def
|
||||
PASSWD_PROGRAM = /bin/passwd
|
||||
-SMB_PASSWD_FILE = $(BASEDIR)/private/smbpasswd
|
||||
-SMB_PASSGRP_FILE = $(BASEDIR)/private/smbpassgrp
|
||||
-SMB_GROUP_FILE = $(BASEDIR)/private/smbgroup
|
||||
-SMB_ALIAS_FILE = $(BASEDIR)/private/smbalias
|
||||
+SMB_PASSWD_FILE = $(LIBDIR)/smbpasswd
|
||||
+SMB_PASSGRP_FILE = $(LIBDIR)/smbpassgrp
|
||||
+SMB_GROUP_FILE = $(LIBDIR)/smbgroup
|
||||
+SMB_ALIAS_FILE = $(LIBDIR)/smbalias
|
||||
SMB_PASSWD_PROGRAM = $(BINDIR)/smbpasswd
|
||||
|
||||
# This is where SWAT images and help files go
|
||||
-SWATDIR = $(BASEDIR)/swat
|
||||
+SWATDIR = $(BASEDIR)/share/swat
|
||||
|
||||
# the directory where lock files go
|
||||
-LOCKDIR = $(VARDIR)/locks
|
||||
+LOCKDIR = $(VARDIR)/lock/samba
|
||||
|
||||
# The directory where code page definition files go
|
||||
CODEPAGEDIR = $(LIBDIR)/codepages
|
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) John H Terpstra 1998
|
||||
#
|
||||
RPMDIR=`rpm --showrc | awk '/^rpmdir/ { print $3}'`
|
||||
SPECDIR=`rpm --showrc | awk '/^specdir/ { print $3}'`
|
||||
SRCDIR=`rpm --showrc | awk '/^sourcedir/ { print $3}'`
|
||||
|
||||
( cd ../../.. ; tar czvf ${SRCDIR}/samba-PVERSION.tar.gz samba-PVERSION )
|
||||
cp -a *.spec $SPECDIR
|
||||
cp -a *.patch smb.* samba.log $SRCDIR
|
||||
cd $SRCDIR
|
||||
chown -R root.root samba-PVERSION
|
||||
cd $SPECDIR
|
||||
rpm -ba -v samba2.spec
|
@ -1,11 +0,0 @@
|
||||
/var/log/samba/log.nmb {
|
||||
postrotate
|
||||
/usr/bin/killall -HUP nmbd
|
||||
endrotate
|
||||
}
|
||||
|
||||
/var/log/samba/log.smb {
|
||||
postrotate
|
||||
/usr/bin/killall -HUP smbd
|
||||
endrotate
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
auth required /lib/security/pam_pwdb.so nullok shadow
|
||||
account required /lib/security/pam_pwdb.so
|
@ -1,282 +0,0 @@
|
||||
Summary: Samba SMB client and server
|
||||
Name: samba
|
||||
Version: PVERSION
|
||||
Release: PRELEASE
|
||||
Copyright: GNU GPL version 2
|
||||
Group: Networking
|
||||
Source: ftp://samba.org/pub/samba/samba-PVERSION.tar.gz
|
||||
Patch: makefile-path.patch
|
||||
Patch1: smbw.patch
|
||||
Packager: John H Terpstra [Samba-Team] <jht@samba.org>
|
||||
BuildRoot: /var/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.
|
||||
|
||||
Samba-2 features an almost working NT Domain Control
|
||||
capability and includes the new SWAT (Samba Web Administration
|
||||
Tool) that allows samba's smb.conf file to be remotely managed
|
||||
using your favourite web browser. For the time being this is
|
||||
being enabled on TCP port 901 via inetd.
|
||||
|
||||
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.
|
||||
|
||||
%changelog
|
||||
* Mon Nov 16 1998 John H Terpstra <jht@samba.org>
|
||||
- Ported to Cadera OpenLinux
|
||||
|
||||
%prep
|
||||
%setup
|
||||
%patch -p1
|
||||
%patch1 -p1
|
||||
|
||||
%build
|
||||
cd source
|
||||
./configure --prefix=/usr --libdir=/etc
|
||||
make all
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/codepages/src
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d}
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/{init.d,rc0.d,rc1.d,rc2.d,rc3.d,rc5.d,rc6.d}
|
||||
mkdir -p $RPM_BUILD_ROOT/home/samba
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/{bin,sbin}
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/swat/{images,help,include}
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/man/{man1,man5,man7,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
|
||||
|
||||
# Install standard binary files
|
||||
for i in nmblookup smbclient smbpasswd smbrun smbstatus testparm testprns \
|
||||
make_smbcodepage make_printerdef rpcclient
|
||||
do
|
||||
install -m755 -s source/bin/$i $RPM_BUILD_ROOT/usr/bin
|
||||
done
|
||||
for i in addtosmbpass mksmbpasswd.sh smbtar
|
||||
do
|
||||
install -m755 source/script/$i $RPM_BUILD_ROOT/usr/bin
|
||||
done
|
||||
|
||||
# Install secure binary files
|
||||
for i in smbd nmbd swat
|
||||
do
|
||||
install -m755 -s source/bin/$i $RPM_BUILD_ROOT/usr/sbin
|
||||
done
|
||||
|
||||
# Install level 1 man pages
|
||||
for i in smbclient.1 smbrun.1 smbstatus.1 smbtar.1 testparm.1 testprns.1 make_smbcodepage.1 nmblookup.1
|
||||
do
|
||||
install -m644 docs/manpages/$i $RPM_BUILD_ROOT/usr/man/man1
|
||||
done
|
||||
|
||||
# Install codepage source files
|
||||
for i in 437 737 850 852 861 866 932 936 949 950
|
||||
do
|
||||
install -m644 source/codepages/codepage_def.$i $RPM_BUILD_ROOT/etc/codepages/src
|
||||
done
|
||||
|
||||
# Install SWAT helper files
|
||||
for i in swat/help/*.html docs/htmldocs/*.html
|
||||
do
|
||||
install -m644 $i $RPM_BUILD_ROOT/usr/share/swat/help
|
||||
done
|
||||
for i in swat/images/*.gif
|
||||
do
|
||||
install -m644 $i $RPM_BUILD_ROOT/usr/share/swat/images
|
||||
done
|
||||
for i in swat/include/*.html
|
||||
do
|
||||
install -m644 $i $RPM_BUILD_ROOT/usr/share/swat/include
|
||||
done
|
||||
|
||||
# Install the miscellany
|
||||
install -m644 swat/README $RPM_BUILD_ROOT/usr/share/swat
|
||||
install -m644 docs/manpages/smb.conf.5 $RPM_BUILD_ROOT/usr/man/man5
|
||||
install -m644 docs/manpages/lmhosts.5 $RPM_BUILD_ROOT/usr/man/man5
|
||||
install -m644 docs/manpages/smbpasswd.5 $RPM_BUILD_ROOT/usr/man/man5
|
||||
install -m644 docs/manpages/samba.7 $RPM_BUILD_ROOT/usr/man/man7
|
||||
install -m644 docs/manpages/smbd.8 $RPM_BUILD_ROOT/usr/man/man8
|
||||
install -m644 docs/manpages/nmbd.8 $RPM_BUILD_ROOT/usr/man/man8
|
||||
install -m644 docs/manpages/swat.8 $RPM_BUILD_ROOT/usr/man/man8
|
||||
install -m644 docs/manpages/smbpasswd.8 $RPM_BUILD_ROOT/usr/man/man8
|
||||
install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/smb.conf
|
||||
install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/smbusers
|
||||
install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT/usr/bin
|
||||
install -m755 packaging/RedHat/findsmb $RPM_BUILD_ROOT/usr/bin
|
||||
install -m755 packaging/RedHat/smbadduser $RPM_BUILD_ROOT/usr/bin
|
||||
install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
|
||||
install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/usr/sbin/samba
|
||||
install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
|
||||
install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
|
||||
echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/lmhosts
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
/sbin/chkconfig --add smb
|
||||
|
||||
# Build codepage load files
|
||||
for i in 437 737 850 852 861 866 932 936 949 950
|
||||
do
|
||||
/usr/bin/make_smbcodepage c $i /etc/codepages/src/codepage_def.$i /etc/codepages/codepage.$i
|
||||
done
|
||||
|
||||
# Add swat entry to /etc/services if not already there
|
||||
if !( grep ^[:space:]*swat /etc/services > /dev/null ) then
|
||||
echo 'swat 901/tcp # Add swat service used via inetd' >> /etc/services
|
||||
fi
|
||||
|
||||
# Add swat entry to /etc/inetd.conf if needed
|
||||
if !( grep ^[:space:]*swat /etc/inetd.conf > /dev/null ) then
|
||||
echo 'swat stream tcp nowait.400 root /usr/sbin/swat swat' >> /etc/inetd.conf
|
||||
killall -1 inetd || :
|
||||
fi
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ] ; then
|
||||
/sbin/chkconfig --del smb
|
||||
|
||||
for n in /etc/codepages/*; do
|
||||
if [ $n != /etc/codepages/src ]; then
|
||||
rm -rf $n
|
||||
fi
|
||||
done
|
||||
# We want to remove the browse.dat and wins.dat files so they can not interfer with a new version of samba!
|
||||
if [ -e /var/lock/samba/browse.dat ]; then
|
||||
rm -f /var/lock/samba/browse.dat
|
||||
fi
|
||||
if [ -e /var/lock/samba/wins.dat ]; then
|
||||
rm -f /var/lock/samba/wins.dat
|
||||
fi
|
||||
fi
|
||||
|
||||
%postun
|
||||
# Only delete remnants of samba if this is the final deletion.
|
||||
if [ $1 != 0 ] ; then
|
||||
exit 0
|
||||
|
||||
if [ -x /etc/pam.d/samba ]; then
|
||||
rm -f /etc/pam.d/samba
|
||||
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
|
||||
|
||||
# Remove swat entries from /etc/inetd.conf and /etc/services
|
||||
cd /etc
|
||||
tmpfile=/etc/tmp.$$
|
||||
sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
|
||||
mv $tmpfile inetd.conf
|
||||
sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
|
||||
mv $tmpfile services
|
||||
fi
|
||||
|
||||
%files
|
||||
%doc README COPYING Manifest Read-Manifest-Now
|
||||
%doc WHATSNEW.txt Roadmap
|
||||
%doc docs
|
||||
%doc swat/README
|
||||
%doc examples
|
||||
%attr(-,root,root) /usr/sbin/smbd
|
||||
%attr(-,root,root) /usr/sbin/nmbd
|
||||
%attr(-,root,root) /usr/sbin/swat
|
||||
%attr(0750,root,root) /usr/sbin/samba
|
||||
%attr(-,root,root) /usr/bin/addtosmbpass
|
||||
%attr(-,root,root) /usr/bin/mksmbpasswd.sh
|
||||
%attr(-,root,root) /usr/bin/smbclient
|
||||
%attr(-,root,root) /usr/bin/rpcclient
|
||||
%attr(-,root,root) /usr/bin/testparm
|
||||
%attr(-,root,root) /usr/bin/testprns
|
||||
%attr(-,root,root) /usr/bin/smbrun
|
||||
%attr(-,root,root) /usr/bin/findsmb
|
||||
%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) /usr/share/swat/help/welcome.html
|
||||
%attr(-,root,root) /usr/share/swat/help/DOMAIN_MEMBER.html
|
||||
%attr(-,root,root) /usr/share/swat/help/lmhosts.5.html
|
||||
%attr(-,root,root) /usr/share/swat/help/make_smbcodepage.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/nmbd.8.html
|
||||
%attr(-,root,root) /usr/share/swat/help/nmblookup.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/samba.7.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smb.conf.5.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbclient.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbd.8.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbpasswd.5.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbpasswd.8.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbrun.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbstatus.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/smbtar.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/swat.8.html
|
||||
%attr(-,root,root) /usr/share/swat/help/testparm.1.html
|
||||
%attr(-,root,root) /usr/share/swat/help/testprns.1.html
|
||||
%attr(-,root,root) /usr/share/swat/images/globals.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/home.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/passwd.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/printers.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/shares.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/samba.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/status.gif
|
||||
%attr(-,root,root) /usr/share/swat/images/viewconfig.gif
|
||||
%attr(-,root,root) /usr/share/swat/include/header.html
|
||||
%attr(-,root,root) /usr/share/swat/include/footer.html
|
||||
%attr(-,root,root) %config(noreplace) /etc/lmhosts
|
||||
%attr(-,root,root) %config(noreplace) /etc/smb.conf
|
||||
%attr(-,root,root) %config(noreplace) /etc/smbusers
|
||||
%attr(-,root,root) /etc/rc.d/init.d/smb
|
||||
%attr(-,root,root) /etc/logrotate.d/samba
|
||||
%attr(-,root,root) /etc/pam.d/samba
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.437
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.737
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.850
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.852
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.861
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.866
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.932
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.936
|
||||
%attr(-,root,root) /etc/codepages/src/codepage_def.949
|
||||
%attr(-,root,root) /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/man1/nmblookup.1
|
||||
%attr(-,root,root) /usr/man/man5/smb.conf.5
|
||||
%attr(-,root,root) /usr/man/man5/lmhosts.5
|
||||
%attr(-,root,root) /usr/man/man5/smbpasswd.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,root) /usr/man/man8/swat.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(1777,root,root) %dir /var/spool/samba
|
@ -1,291 +0,0 @@
|
||||
# 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
|
||||
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
|
||||
; username 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
|
||||
|
||||
# The following are needed to allow password changing from Windows to
|
||||
# update the Linux sytsem password also.
|
||||
# NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above.
|
||||
# NOTE2: You do NOT need these to allow workstations to change only
|
||||
# the encrypted SMB passwords. They allow the Unix password
|
||||
# to be kept in sync with the SMB password.
|
||||
; unix password sync = Yes
|
||||
; passwd program = /usr/bin/passwd %u
|
||||
; passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*
|
||||
|
||||
# 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
|
||||
|
||||
# All NetBIOS names must be resolved to IP Addresses
|
||||
# 'Name Resolve Order' allows the named resolution mechanism to be specified
|
||||
# the default order is "host lmhosts wins bcast". "host" means use the unix
|
||||
# system gethostbyname() function call that will use either /etc/hosts OR
|
||||
# DNS or NIS depending on the settings of /etc/host.config, /etc/nsswitch.conf
|
||||
# and the /etc/resolv.conf file. "host" therefore is system configuration
|
||||
# dependant. This parameter is most often of use to prevent DNS lookups
|
||||
# in order to resolve NetBIOS names to IP Addresses. Use with care!
|
||||
# The example below excludes use of name resolution for machines that are NOT
|
||||
# on the local network segment
|
||||
# - OR - are not deliberately to be known via lmhosts or via WINS.
|
||||
; name resolve order = wins lmhosts bcast
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# description: Starts and stops the Samba smbd and nmbd daemons \
|
||||
# used to provide SMB network services.
|
||||
|
||||
# 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 that smb.conf exists.
|
||||
[ -f /etc/smb.conf ] || exit 0
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting SMB services: "
|
||||
smbd -D
|
||||
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 ""
|
||||
;;
|
||||
status)
|
||||
status smbd
|
||||
status nmbd
|
||||
;;
|
||||
restart)
|
||||
echo -n "Restarting SMB services: "
|
||||
$0 stop
|
||||
$0 start
|
||||
echo "done."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: smb {start|stop|restart|status}"
|
||||
exit 1
|
||||
esac
|
||||
|
@ -1,73 +0,0 @@
|
||||
#!/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
|
@ -1,77 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# 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
|
@ -1,3 +0,0 @@
|
||||
# Unix_name = SMB_name1 SMB_name2 ...
|
||||
root = administrator admin
|
||||
nobody = guest pcguest smbguest
|
@ -1,10 +0,0 @@
|
||||
--- samba-2.0.0/source/smbwrapper/smbsh.in.orig Mon Oct 5 22:37:01 1998
|
||||
+++ samba-2.0.0/source/smbwrapper/smbsh.in Mon Oct 5 22:37:51 1998
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
|
||||
-SMBW_LIBDIR=${SMBW_LIBDIR-@builddir@/smbwrapper}
|
||||
+SMBW_LIBDIR=${SMBW_LIBDIR-/usr/bin}
|
||||
|
||||
if [ ! -f ${SMBW_LIBDIR}/smbwrapper.so ]; then
|
||||
echo You need to set LIBDIR in smbsh
|
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
./mkprototype
|
||||
pkgmk -o -d /tmp -b `pwd` -f ./prototype
|
||||
cd /tmp
|
||||
pkgtrans . samba.pkg samba
|
@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
# this creates prototype files
|
||||
pkgproto * > prototype
|
||||
nawk 'BEGIN { print "# d directory"
|
||||
print "# e a file to be edited upon installation or removal"
|
||||
print "# f a standard executable or data file"
|
||||
print "# i installation script or information file"
|
||||
print "# l linked file"
|
||||
print "# s symbolic link"
|
||||
print "# v volatile file (one whose contents are expected to
|
||||
change)"
|
||||
print "#" }
|
||||
/ pkginfo / { print "i pkginfo" ; next }
|
||||
/ postinstall / { print "i postinstall" ; next }
|
||||
/ postremove / { print "i postremove" ; next }
|
||||
/d none usr / { print "d none usr ? ? ?" ; next }
|
||||
/d none usr\/local / { print "d none usr/local ? ? ?" ; next }
|
||||
/d none etc / { print "d none etc ? ? ?" ; next }
|
||||
/f none etc\// { $1 = "v" }
|
||||
/d none opt / { print "d none opt ? ? ?" ; next }
|
||||
/d none var / { print "d none var ? ? ?" ; next }
|
||||
/none prototype / { next }
|
||||
/none mkprototype / { next }
|
||||
/ src[ \/]/ { next }
|
||||
/^[dfv]/ { $5 = "bin"
|
||||
$6 = "bin"
|
||||
print
|
||||
next }
|
||||
{ print }' prototype >/tmp/prototype.$$
|
||||
mv /tmp/prototype.$$ prototype
|
||||
|
@ -1,37 +0,0 @@
|
||||
#!/bin/sh
|
||||
# install samba
|
||||
|
||||
nawk '/^netbios-[ns]*[ ]/ {next}
|
||||
{print}
|
||||
END { print "netbios-ssn 139/tcp"
|
||||
print "netbios-ns 137/udp # samba service" }' \
|
||||
${PKG_INSTALL_ROOT}/etc/inet/services > /tmp/services.$$ && \
|
||||
mv -f /tmp/services.$$ ${PKG_INSTALL_ROOT}/etc/inet/services &&
|
||||
\
|
||||
chmod 644 ${PKG_INSTALL_ROOT}/etc/inet/services && \
|
||||
echo "Updated ${PKG_INSTALL_ROOT}/etc/inet/services"
|
||||
|
||||
nawk '/samba.*mbd[ ]/ { next }
|
||||
{print}
|
||||
END { print "# samba connections are handled by smbd and nmbd"
|
||||
print "netbios-ssn stream tcp nowait root /opt/samba/bin/smbd
|
||||
smbd"
|
||||
print "netbios-ns dgram udp wait root /opt/samba/bin/nmbd nmbd" }'
|
||||
\
|
||||
${PKG_INSTALL_ROOT}/etc/inet/inetd.conf > /tmp/inetd.conf.$$ &&
|
||||
\
|
||||
mv -f /tmp/inetd.conf.$$ ${PKG_INSTALL_ROOT}/etc/inet/inetd.conf
|
||||
&& \
|
||||
chmod 644 ${PKG_INSTALL_ROOT}/etc/inet/inetd.conf && \
|
||||
echo "Updated ${PKG_INSTALL_ROOT}/etc/inet/inetd.conf"
|
||||
|
||||
echo "Installed samba service into ${PKG_INSTALL_ROOT:-/}"
|
||||
|
||||
inetpid=`/bin/ps -ef | awk '/ \/usr\/sbin\/inetd / { print $2 } '`
|
||||
if [ "X$inetpid" = "X" ]; then
|
||||
echo "inetd not running"
|
||||
else
|
||||
echo "Restarting inetd($inetpid)"
|
||||
kill -HUP $inetpid
|
||||
fi
|
||||
|
@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
# remove samba
|
||||
|
||||
nawk '/^netbios-[ns]*[ ]/ {next}
|
||||
{print} ' \
|
||||
${PKG_INSTALL_ROOT}/etc/inet/services > /tmp/services.$$ && \
|
||||
mv -f /tmp/services.$$ ${PKG_INSTALL_ROOT}/etc/inet/services &&
|
||||
\
|
||||
chmod 644 ${PKG_INSTALL_ROOT}/etc/inet/services && \
|
||||
echo "Updated ${PKG_INSTALL_ROOT}/etc/inet/services"
|
||||
|
||||
nawk '/samba.*mbd[ ]/ { next }
|
||||
{print} ' \
|
||||
${PKG_INSTALL_ROOT}/etc/inet/inetd.conf > /tmp/inetd.conf.$$ &&
|
||||
\
|
||||
mv -f /tmp/inetd.conf.$$ ${PKG_INSTALL_ROOT}/etc/inet/inetd.conf
|
||||
&& \
|
||||
chmod 644 ${PKG_INSTALL_ROOT}/etc/inet/inetd.conf && \
|
||||
echo "Updated ${PKG_INSTALL_ROOT}/etc/inet/inetd.conf"
|
||||
|
||||
echo "Removed samba service from ${PKG_INSTALL_ROOT:-/}"
|
||||
|
||||
inetpid=`/bin/ps -ef | awk '/ \/usr\/sbin\/inetd / { print $2 } '`
|
||||
if [ "X$inetpid" = "X" ]; then
|
||||
echo "inetd not running"
|
||||
else
|
||||
echo "Restarting inetd($inetpid)"
|
||||
kill -HUP $inetpid
|
||||
fi
|
||||
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Main SMB server routines
|
||||
Copyright (C) Andrew Tridgell 1992-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"
|
||||
|
||||
fstring pipe_name;
|
||||
|
||||
pstring servicesf = CONFIGFILE;
|
||||
extern pstring debugf;
|
||||
extern BOOL append_log;
|
||||
|
||||
/*************************************************************************
|
||||
initialise an msrpc service
|
||||
*************************************************************************/
|
||||
void msrpc_service_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
reload the services file
|
||||
**************************************************************************/
|
||||
BOOL reload_services(BOOL test)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if (lp_loaded()) {
|
||||
pstring fname;
|
||||
pstrcpy(fname,lp_configfile());
|
||||
if (file_exist(fname,NULL) && !strcsequal(fname,servicesf)) {
|
||||
pstrcpy(servicesf,fname);
|
||||
test = False;
|
||||
}
|
||||
}
|
||||
|
||||
reopen_logs();
|
||||
|
||||
if (test && !lp_file_list_changed())
|
||||
return(True);
|
||||
|
||||
lp_killunused(NULL);
|
||||
|
||||
ret = lp_load(servicesf,False,False,True);
|
||||
|
||||
/* perhaps the config filename is now set */
|
||||
if (!test)
|
||||
reload_services(True);
|
||||
|
||||
reopen_logs();
|
||||
|
||||
load_interfaces();
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
main program
|
||||
****************************************************************************/
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
#ifdef HAVE_SET_AUTH_PARAMETERS
|
||||
set_auth_parameters(argc,argv);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETLUID
|
||||
/* needed for SecureWare on SCO */
|
||||
setluid(0);
|
||||
#endif
|
||||
|
||||
append_log = True;
|
||||
|
||||
TimeInit();
|
||||
|
||||
setup_logging(argv[0],False);
|
||||
fstrcpy(pipe_name, "browser");
|
||||
slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name);
|
||||
add_msrpc_command_processor( pipe_name, argv[0], api_brs_rpc );
|
||||
|
||||
return msrpc_main(argc, argv);
|
||||
}
|
@ -1,975 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB client
|
||||
Copyright (C) Andrew Tridgell 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.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifndef REGISTER
|
||||
#define REGISTER 0
|
||||
#endif
|
||||
|
||||
pstring service="";
|
||||
pstring desthost="";
|
||||
extern pstring global_myname;
|
||||
pstring password = "";
|
||||
pstring smb_login_passwd = "";
|
||||
pstring username="";
|
||||
pstring workgroup=WORKGROUP;
|
||||
BOOL got_pass = False;
|
||||
BOOL no_pass = False;
|
||||
BOOL connect_as_printer = False;
|
||||
BOOL connect_as_ipc = False;
|
||||
|
||||
char cryptkey[8];
|
||||
BOOL doencrypt=False;
|
||||
|
||||
extern pstring user_socket_options;
|
||||
|
||||
/* 30 second timeout on most commands */
|
||||
#define CLIENT_TIMEOUT (30*1000)
|
||||
#define SHORT_TIMEOUT (5*1000)
|
||||
|
||||
int name_type = 0x20;
|
||||
|
||||
int max_protocol = PROTOCOL_NT1;
|
||||
|
||||
BOOL readbraw_supported = False;
|
||||
BOOL writebraw_supported = False;
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
uint16 cnum = 0;
|
||||
uint16 pid = 0;
|
||||
uint16 vuid = 0;
|
||||
uint16 mid = 0;
|
||||
|
||||
int max_xmit = BUFFER_SIZE;
|
||||
|
||||
BOOL have_ip = False;
|
||||
|
||||
extern struct in_addr dest_ip;
|
||||
|
||||
extern int Protocol;
|
||||
|
||||
extern int Client;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
setup basics in a outgoing packet
|
||||
****************************************************************************/
|
||||
void cli_setup_pkt(char *outbuf)
|
||||
{
|
||||
SSVAL(outbuf,smb_pid,pid);
|
||||
SSVAL(outbuf,smb_uid,vuid);
|
||||
SSVAL(outbuf,smb_mid,mid);
|
||||
if (Protocol > PROTOCOL_COREPLUS)
|
||||
{
|
||||
SCVAL(outbuf,smb_flg,0x8);
|
||||
SSVAL(outbuf,smb_flg2,0x1);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
call a remote api
|
||||
****************************************************************************/
|
||||
BOOL cli_call_api(char *pipe_name, int pipe_name_len,
|
||||
int prcnt,int drcnt, int srcnt,
|
||||
int mprcnt,int mdrcnt,
|
||||
int *rprcnt,int *rdrcnt,
|
||||
char *param,char *data, uint16 *setup,
|
||||
char **rparam,char **rdata)
|
||||
{
|
||||
static char *inbuf=NULL;
|
||||
static char *outbuf=NULL;
|
||||
|
||||
if (!inbuf) inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
|
||||
if (!outbuf) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
|
||||
|
||||
if(!inbuf || !outbuf) {
|
||||
DEBUG(0,("cli_call_api: malloc fail.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (pipe_name_len == 0) pipe_name_len = strlen(pipe_name);
|
||||
|
||||
cli_send_trans_request(outbuf,SMBtrans,pipe_name, pipe_name_len, 0,0,
|
||||
data, param, setup,
|
||||
drcnt, prcnt, srcnt,
|
||||
mdrcnt, mprcnt, 0);
|
||||
|
||||
return (cli_receive_trans_response(inbuf,SMBtrans,
|
||||
rdrcnt,rprcnt,
|
||||
rdata,rparam));
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
receive a SMB trans or trans2 response allocating the necessary memory
|
||||
****************************************************************************/
|
||||
BOOL cli_receive_trans_response(char *inbuf,int trans,
|
||||
int *data_len,int *param_len,
|
||||
char **data,char **param)
|
||||
{
|
||||
int total_data=0;
|
||||
int total_param=0;
|
||||
int this_data,this_param;
|
||||
|
||||
*data_len = *param_len = 0;
|
||||
|
||||
client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
|
||||
show_msg(inbuf);
|
||||
|
||||
/* sanity check */
|
||||
if (CVAL(inbuf,smb_com) != trans)
|
||||
{
|
||||
DEBUG(0,("Expected %s response, got command 0x%02x\n",
|
||||
trans==SMBtrans?"SMBtrans":"SMBtrans2", CVAL(inbuf,smb_com)));
|
||||
return(False);
|
||||
}
|
||||
if (CVAL(inbuf,smb_rcls) != 0)
|
||||
return(False);
|
||||
|
||||
/* parse out the lengths */
|
||||
total_data = SVAL(inbuf,smb_tdrcnt);
|
||||
total_param = SVAL(inbuf,smb_tprcnt);
|
||||
|
||||
/* allocate it */
|
||||
*data = Realloc(*data,total_data);
|
||||
*param = Realloc(*param,total_param);
|
||||
|
||||
if((total_data && !data) || (total_param && !param)) {
|
||||
DEBUG(0,("cli_receive_trans_response: Realloc fail !\n"));
|
||||
return(False);
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
this_data = SVAL(inbuf,smb_drcnt);
|
||||
this_param = SVAL(inbuf,smb_prcnt);
|
||||
if (this_data)
|
||||
memcpy(*data + SVAL(inbuf,smb_drdisp),
|
||||
smb_base(inbuf) + SVAL(inbuf,smb_droff),
|
||||
this_data);
|
||||
if (this_param)
|
||||
memcpy(*param + SVAL(inbuf,smb_prdisp),
|
||||
smb_base(inbuf) + SVAL(inbuf,smb_proff),
|
||||
this_param);
|
||||
*data_len += this_data;
|
||||
*param_len += this_param;
|
||||
|
||||
/* parse out the total lengths again - they can shrink! */
|
||||
total_data = SVAL(inbuf,smb_tdrcnt);
|
||||
total_param = SVAL(inbuf,smb_tprcnt);
|
||||
|
||||
if (total_data <= *data_len && total_param <= *param_len)
|
||||
break;
|
||||
|
||||
client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
|
||||
show_msg(inbuf);
|
||||
|
||||
/* sanity check */
|
||||
if (CVAL(inbuf,smb_com) != trans)
|
||||
{
|
||||
DEBUG(0,("Expected %s response, got command 0x%02x\n",
|
||||
trans==SMBtrans?"SMBtrans":"SMBtrans2", CVAL(inbuf,smb_com)));
|
||||
return(False);
|
||||
}
|
||||
if (CVAL(inbuf,smb_rcls) != 0)
|
||||
return(False);
|
||||
}
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
send a SMB trans or trans2 request
|
||||
****************************************************************************/
|
||||
BOOL cli_send_trans_request(char *outbuf,int trans,
|
||||
char *name,int namelen, int fid,int flags,
|
||||
char *data,char *param,uint16 *setup,
|
||||
int ldata,int lparam,int lsetup,
|
||||
int mdata,int mparam,int msetup)
|
||||
{
|
||||
int i;
|
||||
int this_ldata,this_lparam;
|
||||
int tot_data=0,tot_param=0;
|
||||
char *outdata,*outparam;
|
||||
pstring inbuf;
|
||||
char *p;
|
||||
|
||||
this_lparam = MIN(lparam,max_xmit - (500+lsetup*SIZEOFWORD)); /* hack */
|
||||
this_ldata = MIN(ldata,max_xmit - (500+lsetup*SIZEOFWORD+this_lparam));
|
||||
|
||||
bzero(outbuf,smb_size);
|
||||
set_message(outbuf,14+lsetup,0,True);
|
||||
CVAL(outbuf,smb_com) = trans;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
outparam = smb_buf(outbuf)+(trans==SMBtrans ? namelen+1 : 3);
|
||||
outdata = outparam+this_lparam;
|
||||
|
||||
/* primary request */
|
||||
SSVAL(outbuf,smb_tpscnt,lparam); /* tpscnt */
|
||||
SSVAL(outbuf,smb_tdscnt,ldata); /* tdscnt */
|
||||
SSVAL(outbuf,smb_mprcnt,mparam); /* mprcnt */
|
||||
SSVAL(outbuf,smb_mdrcnt,mdata); /* mdrcnt */
|
||||
SCVAL(outbuf,smb_msrcnt,msetup); /* msrcnt */
|
||||
SSVAL(outbuf,smb_flags,flags); /* flags */
|
||||
SIVAL(outbuf,smb_timeout,0); /* timeout */
|
||||
SSVAL(outbuf,smb_pscnt,this_lparam); /* pscnt */
|
||||
SSVAL(outbuf,smb_psoff,smb_offset(outparam,outbuf)); /* psoff */
|
||||
SSVAL(outbuf,smb_dscnt,this_ldata); /* dscnt */
|
||||
SSVAL(outbuf,smb_dsoff,smb_offset(outdata,outbuf)); /* dsoff */
|
||||
SCVAL(outbuf,smb_suwcnt,lsetup); /* suwcnt */
|
||||
for (i=0;i<lsetup;i++) /* setup[] */
|
||||
SSVAL(outbuf,smb_setup+i*SIZEOFWORD,setup[i]);
|
||||
p = smb_buf(outbuf);
|
||||
if (trans==SMBtrans)
|
||||
memcpy(p,name, namelen+1); /* name[] */
|
||||
else
|
||||
{
|
||||
*p++ = 0; /* put in a null smb_name */
|
||||
*p++ = 'D'; *p++ = ' '; /* this was added because OS/2 does it */
|
||||
}
|
||||
if (this_lparam) /* param[] */
|
||||
memcpy(outparam,param,this_lparam);
|
||||
if (this_ldata) /* data[] */
|
||||
memcpy(outdata,data,this_ldata);
|
||||
set_message(outbuf,14+lsetup, /* wcnt, bcc */
|
||||
PTR_DIFF(outdata+this_ldata,smb_buf(outbuf)),False);
|
||||
|
||||
show_msg(outbuf);
|
||||
send_smb(Client,outbuf);
|
||||
|
||||
if (this_ldata < ldata || this_lparam < lparam)
|
||||
{
|
||||
/* receive interim response */
|
||||
if (!client_receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0)
|
||||
{
|
||||
DEBUG(0,("%s request failed (%s)\n",
|
||||
trans==SMBtrans?"SMBtrans":"SMBtrans2", smb_errstr(inbuf)));
|
||||
return(False);
|
||||
}
|
||||
|
||||
tot_data = this_ldata;
|
||||
tot_param = this_lparam;
|
||||
|
||||
while (tot_data < ldata || tot_param < lparam)
|
||||
{
|
||||
this_lparam = MIN(lparam-tot_param,max_xmit - 500); /* hack */
|
||||
this_ldata = MIN(ldata-tot_data,max_xmit - (500+this_lparam));
|
||||
|
||||
set_message(outbuf,trans==SMBtrans?8:9,0,True);
|
||||
CVAL(outbuf,smb_com) = trans==SMBtrans ? SMBtranss : SMBtranss2;
|
||||
|
||||
outparam = smb_buf(outbuf);
|
||||
outdata = outparam+this_lparam;
|
||||
|
||||
/* secondary request */
|
||||
SSVAL(outbuf,smb_tpscnt,lparam); /* tpscnt */
|
||||
SSVAL(outbuf,smb_tdscnt,ldata); /* tdscnt */
|
||||
SSVAL(outbuf,smb_spscnt,this_lparam); /* pscnt */
|
||||
SSVAL(outbuf,smb_spsoff,smb_offset(outparam,outbuf)); /* psoff */
|
||||
SSVAL(outbuf,smb_spsdisp,tot_param); /* psdisp */
|
||||
SSVAL(outbuf,smb_sdscnt,this_ldata); /* dscnt */
|
||||
SSVAL(outbuf,smb_sdsoff,smb_offset(outdata,outbuf)); /* dsoff */
|
||||
SSVAL(outbuf,smb_sdsdisp,tot_data); /* dsdisp */
|
||||
if (trans==SMBtrans2)
|
||||
SSVAL(outbuf,smb_sfid,fid); /* fid */
|
||||
if (this_lparam) /* param[] */
|
||||
memcpy(outparam,param,this_lparam);
|
||||
if (this_ldata) /* data[] */
|
||||
memcpy(outdata,data,this_ldata);
|
||||
set_message(outbuf,trans==SMBtrans?8:9, /* wcnt, bcc */
|
||||
PTR_DIFF(outdata+this_ldata,smb_buf(outbuf)),False);
|
||||
|
||||
show_msg(outbuf);
|
||||
send_smb(Client,outbuf);
|
||||
|
||||
tot_data += this_ldata;
|
||||
tot_param += this_lparam;
|
||||
}
|
||||
}
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
send a session request
|
||||
****************************************************************************/
|
||||
BOOL cli_send_session_request(char *inbuf,char *outbuf)
|
||||
{
|
||||
fstring dest;
|
||||
char *p;
|
||||
int len = 4;
|
||||
/* send a session request (RFC 8002) */
|
||||
|
||||
fstrcpy(dest,desthost);
|
||||
p = strchr(dest,'.');
|
||||
if (p) *p = 0;
|
||||
|
||||
/* put in the destination name */
|
||||
p = outbuf+len;
|
||||
name_mangle(dest,p,name_type); /* 0x20 is the SMB server NetBIOS type. */
|
||||
len += name_len(p);
|
||||
|
||||
/* and my name */
|
||||
p = outbuf+len;
|
||||
name_mangle(global_myname,p,0);
|
||||
len += name_len(p);
|
||||
|
||||
/* setup the packet length */
|
||||
_smb_setlen(outbuf,len);
|
||||
CVAL(outbuf,0) = 0x81;
|
||||
|
||||
#ifdef WITH_SSL
|
||||
retry:
|
||||
#endif /* WITH_SSL */
|
||||
|
||||
send_smb(Client,outbuf);
|
||||
DEBUG(5,("Sent session request\n"));
|
||||
|
||||
client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
|
||||
|
||||
if (CVAL(inbuf,0) == 0x84) /* C. Hoch 9/14/95 Start */
|
||||
{
|
||||
/* For information, here is the response structure.
|
||||
* We do the byte-twiddling to for portability.
|
||||
struct RetargetResponse{
|
||||
unsigned char type;
|
||||
unsigned char flags;
|
||||
int16 length;
|
||||
int32 ip_addr;
|
||||
int16 port;
|
||||
};
|
||||
*/
|
||||
extern int Client;
|
||||
int port = (CVAL(inbuf,8)<<8)+CVAL(inbuf,9);
|
||||
/* SESSION RETARGET */
|
||||
putip((char *)&dest_ip,inbuf+4);
|
||||
|
||||
close_sockets();
|
||||
Client = open_socket_out(SOCK_STREAM, &dest_ip, port, LONG_CONNECT_TIMEOUT);
|
||||
if (Client == -1)
|
||||
return False;
|
||||
|
||||
DEBUG(3,("Retargeted\n"));
|
||||
|
||||
set_socket_options(Client,user_socket_options);
|
||||
|
||||
/* Try again */
|
||||
return cli_send_session_request(inbuf,outbuf);
|
||||
} /* C. Hoch 9/14/95 End */
|
||||
|
||||
#ifdef WITH_SSL
|
||||
if(CVAL(inbuf,0) == 0x83 && CVAL(inbuf,4) == 0x8e) { /* use ssl */
|
||||
fprintf(stderr, "Making secure connection\n");
|
||||
if(!sslutil_fd_is_ssl(Client)){
|
||||
if(sslutil_connect(Client) == 0)
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (CVAL(inbuf,0) != 0x82)
|
||||
{
|
||||
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));
|
||||
switch (ecode)
|
||||
{
|
||||
case 0x80:
|
||||
DEBUG(0,("Not listening on called name\n"));
|
||||
DEBUG(0,("Try to connect to another name (instead of %s)\n",desthost));
|
||||
DEBUG(0,("You may find the -I option useful for this\n"));
|
||||
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,("You may find the -n option useful for this\n"));
|
||||
break;
|
||||
case 0x82:
|
||||
DEBUG(0,("Called name not present\n"));
|
||||
DEBUG(0,("Try to connect to another name (instead of %s)\n",desthost));
|
||||
DEBUG(0,("You may find the -I option useful for this\n"));
|
||||
break;
|
||||
case 0x83:
|
||||
DEBUG(0,("Called name present, but insufficient resources\n"));
|
||||
DEBUG(0,("Perhaps you should try again later?\n"));
|
||||
break;
|
||||
default:
|
||||
DEBUG(0,("Unspecified error 0x%X\n",ecode));
|
||||
DEBUG(0,("Your server software is being unfriendly\n"));
|
||||
break;
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
|
||||
static struct {
|
||||
int prot;
|
||||
char *name;
|
||||
} prots[] = {
|
||||
{PROTOCOL_CORE,"PC NETWORK PROGRAM 1.0"},
|
||||
{PROTOCOL_COREPLUS,"MICROSOFT NETWORKS 1.03"},
|
||||
{PROTOCOL_LANMAN1,"MICROSOFT NETWORKS 3.0"},
|
||||
{PROTOCOL_LANMAN1,"LANMAN1.0"},
|
||||
{PROTOCOL_LANMAN2,"LM1.2X002"},
|
||||
{PROTOCOL_LANMAN2,"Samba"},
|
||||
{PROTOCOL_NT1,"NT LM 0.12"},
|
||||
{PROTOCOL_NT1,"NT LANMAN 1.0"},
|
||||
{-1,NULL}
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
send a login command.
|
||||
****************************************************************************/
|
||||
BOOL cli_send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setup, struct connection_options *options)
|
||||
{
|
||||
BOOL was_null = (!inbuf && !outbuf);
|
||||
time_t servertime = 0;
|
||||
extern int serverzone;
|
||||
int crypt_len=0;
|
||||
char *pass = NULL;
|
||||
uchar enc_ntpass[24];
|
||||
int ntpasslen = 0;
|
||||
pstring dev;
|
||||
char *p;
|
||||
int numprots;
|
||||
int tries=0;
|
||||
struct connection_options opt;
|
||||
|
||||
bzero(&opt, sizeof(opt));
|
||||
|
||||
if (was_null)
|
||||
{
|
||||
inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
|
||||
outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
|
||||
|
||||
if(!inbuf || !outbuf) {
|
||||
DEBUG(0,("cli_send_login: malloc fail !\n"));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
if (strstr(service,"IPC$")) connect_as_ipc = True;
|
||||
|
||||
pstrcpy(dev,"A:");
|
||||
if (connect_as_printer)
|
||||
pstrcpy(dev,"LPT1:");
|
||||
if (connect_as_ipc)
|
||||
pstrcpy(dev,"IPC");
|
||||
|
||||
|
||||
if (start_session && !cli_send_session_request(inbuf,outbuf))
|
||||
{
|
||||
if (was_null)
|
||||
{
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
bzero(outbuf,smb_size);
|
||||
|
||||
/* setup the protocol strings */
|
||||
{
|
||||
int plength;
|
||||
|
||||
for (plength=0,numprots=0;
|
||||
prots[numprots].name && prots[numprots].prot<=max_protocol;
|
||||
numprots++)
|
||||
plength += strlen(prots[numprots].name)+2;
|
||||
|
||||
set_message(outbuf,0,plength,True);
|
||||
|
||||
p = smb_buf(outbuf);
|
||||
for (numprots=0;
|
||||
prots[numprots].name && prots[numprots].prot<=max_protocol;
|
||||
numprots++)
|
||||
{
|
||||
*p++ = 2;
|
||||
pstrcpy(p,prots[numprots].name);
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
CVAL(outbuf,smb_com) = SMBnegprot;
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
CVAL(smb_buf(outbuf),0) = 2;
|
||||
|
||||
send_smb(Client,outbuf);
|
||||
client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
|
||||
|
||||
show_msg(inbuf);
|
||||
|
||||
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)));
|
||||
if (was_null)
|
||||
{
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
opt.protocol = Protocol = prots[SVAL(inbuf,smb_vwv0)].prot;
|
||||
|
||||
|
||||
if (Protocol < PROTOCOL_LANMAN1) {
|
||||
/* no extra params */
|
||||
} else if (Protocol < PROTOCOL_NT1) {
|
||||
opt.sec_mode = SVAL(inbuf,smb_vwv1);
|
||||
opt.max_xmit = max_xmit = SVAL(inbuf,smb_vwv2);
|
||||
opt.sesskey = IVAL(inbuf,smb_vwv6);
|
||||
opt.serverzone = serverzone = SVALS(inbuf,smb_vwv10)*60;
|
||||
/* this time is converted to GMT by make_unix_date */
|
||||
servertime = make_unix_date(inbuf+smb_vwv8);
|
||||
if (Protocol >= PROTOCOL_COREPLUS) {
|
||||
opt.rawmode = SVAL(inbuf,smb_vwv5);
|
||||
readbraw_supported = ((SVAL(inbuf,smb_vwv5) & 0x1) != 0);
|
||||
writebraw_supported = ((SVAL(inbuf,smb_vwv5) & 0x2) != 0);
|
||||
}
|
||||
crypt_len = smb_buflen(inbuf);
|
||||
memcpy(cryptkey,smb_buf(inbuf),8);
|
||||
DEBUG(3,("max mux %d\n",SVAL(inbuf,smb_vwv3)));
|
||||
opt.max_vcs = SVAL(inbuf,smb_vwv4);
|
||||
DEBUG(3,("max vcs %d\n",opt.max_vcs));
|
||||
DEBUG(3,("max blk %d\n",SVAL(inbuf,smb_vwv5)));
|
||||
} else {
|
||||
/* NT protocol */
|
||||
opt.sec_mode = CVAL(inbuf,smb_vwv1);
|
||||
opt.max_xmit = max_xmit = IVAL(inbuf,smb_vwv3+1);
|
||||
opt.sesskey = IVAL(inbuf,smb_vwv7+1);
|
||||
opt.serverzone = SVALS(inbuf,smb_vwv15+1)*60;
|
||||
/* this time arrives in real GMT */
|
||||
servertime = interpret_long_date(inbuf+smb_vwv11+1);
|
||||
crypt_len = CVAL(inbuf,smb_vwv16+1);
|
||||
memcpy(cryptkey,smb_buf(inbuf),8);
|
||||
if (IVAL(inbuf,smb_vwv9+1) & 1)
|
||||
readbraw_supported = writebraw_supported = True;
|
||||
DEBUG(3,("max mux %d\n",SVAL(inbuf,smb_vwv1+1)));
|
||||
opt.max_vcs = SVAL(inbuf,smb_vwv2+1);
|
||||
DEBUG(3,("max vcs %d\n",opt.max_vcs));
|
||||
DEBUG(3,("max raw %d\n",IVAL(inbuf,smb_vwv5+1)));
|
||||
DEBUG(3,("capabilities 0x%x\n",IVAL(inbuf,smb_vwv9+1)));
|
||||
}
|
||||
|
||||
DEBUG(3,("Sec mode %d\n",SVAL(inbuf,smb_vwv1)));
|
||||
DEBUG(3,("max xmt %d\n",max_xmit));
|
||||
DEBUG(3,("Got %d byte crypt key\n",crypt_len));
|
||||
DEBUG(3,("Chose protocol [%s]\n",prots[SVAL(inbuf,smb_vwv0)].name));
|
||||
|
||||
doencrypt = ((opt.sec_mode & 2) != 0);
|
||||
|
||||
if (servertime) {
|
||||
static BOOL done_time = False;
|
||||
if (!done_time) {
|
||||
DEBUG(1,("Server time is %sTimezone is UTC%+02.1f\n",
|
||||
asctime(LocalTime(&servertime)),
|
||||
-(double)(serverzone/3600.0)));
|
||||
done_time = True;
|
||||
}
|
||||
}
|
||||
|
||||
get_pass:
|
||||
|
||||
if (got_pass)
|
||||
pass = password;
|
||||
else
|
||||
pass = (char *)getpass("Password: ");
|
||||
|
||||
if(!pass)
|
||||
pass = "";
|
||||
|
||||
pstrcpy(smb_login_passwd, pass);
|
||||
|
||||
/* use a blank username for the 2nd try with a blank password */
|
||||
if (tries++ && !*pass)
|
||||
*username = 0;
|
||||
|
||||
if (Protocol >= PROTOCOL_LANMAN1 && use_setup)
|
||||
{
|
||||
fstring pword;
|
||||
int passlen = strlen(pass)+1;
|
||||
fstrcpy(pword,pass);
|
||||
|
||||
if (doencrypt && *pass)
|
||||
{
|
||||
DEBUG(3,("Using encrypted passwords\n"));
|
||||
passlen = 24;
|
||||
SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword);
|
||||
ntpasslen = 24;
|
||||
SMBNTencrypt((uchar *)pass,(uchar *)cryptkey,enc_ntpass);
|
||||
}
|
||||
|
||||
/* if in share level security then don't send a password now */
|
||||
if (!(opt.sec_mode & 1)) {fstrcpy(pword, "");passlen=1;}
|
||||
|
||||
/* send a session setup command */
|
||||
bzero(outbuf,smb_size);
|
||||
|
||||
if (Protocol < PROTOCOL_NT1)
|
||||
{
|
||||
set_message(outbuf,10,1 + strlen(username) + passlen,True);
|
||||
CVAL(outbuf,smb_com) = SMBsesssetupX;
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
CVAL(outbuf,smb_vwv0) = 0xFF;
|
||||
SSVAL(outbuf,smb_vwv2,max_xmit);
|
||||
SSVAL(outbuf,smb_vwv3,2);
|
||||
SSVAL(outbuf,smb_vwv4,opt.max_vcs-1);
|
||||
SIVAL(outbuf,smb_vwv5,opt.sesskey);
|
||||
SSVAL(outbuf,smb_vwv7,passlen);
|
||||
p = smb_buf(outbuf);
|
||||
memcpy(p,pword,passlen);
|
||||
p += passlen;
|
||||
pstrcpy(p,username);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!doencrypt) passlen--;
|
||||
/* for Win95 */
|
||||
set_message(outbuf,13,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBsesssetupX;
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
CVAL(outbuf,smb_vwv0) = 0xFF;
|
||||
SSVAL(outbuf,smb_vwv2,BUFFER_SIZE);
|
||||
SSVAL(outbuf,smb_vwv3,2);
|
||||
SSVAL(outbuf,smb_vwv4,getpid());
|
||||
SIVAL(outbuf,smb_vwv5,opt.sesskey);
|
||||
SSVAL(outbuf,smb_vwv7,passlen);
|
||||
SSVAL(outbuf,smb_vwv8,doencrypt ? ntpasslen : 0);
|
||||
p = smb_buf(outbuf);
|
||||
memcpy(p,pword,passlen); p += SVAL(outbuf,smb_vwv7);
|
||||
if(doencrypt)
|
||||
memcpy(p,enc_ntpass,ntpasslen); p += SVAL(outbuf,smb_vwv8);
|
||||
pstrcpy(p,username);p = skip_string(p,1);
|
||||
pstrcpy(p,workgroup);p = skip_string(p,1);
|
||||
pstrcpy(p,"Unix");p = skip_string(p,1);
|
||||
pstrcpy(p,"Samba");p = skip_string(p,1);
|
||||
set_message(outbuf,13,PTR_DIFF(p,smb_buf(outbuf)),False);
|
||||
}
|
||||
|
||||
send_smb(Client,outbuf);
|
||||
client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
|
||||
|
||||
show_msg(inbuf);
|
||||
|
||||
if (CVAL(inbuf,smb_rcls) != 0)
|
||||
{
|
||||
if (! *pass &&
|
||||
((CVAL(inbuf,smb_rcls) == ERRDOS &&
|
||||
SVAL(inbuf,smb_err) == ERRnoaccess) ||
|
||||
(CVAL(inbuf,smb_rcls) == ERRSRV &&
|
||||
SVAL(inbuf,smb_err) == ERRbadpw)))
|
||||
{
|
||||
got_pass = False;
|
||||
DEBUG(3,("resending login\n"));
|
||||
if (! no_pass)
|
||||
goto get_pass;
|
||||
}
|
||||
|
||||
DEBUG(0,("Session setup failed for username=%s myname=%s destname=%s %s\n",
|
||||
username,global_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"));
|
||||
if (was_null)
|
||||
{
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
if (Protocol >= PROTOCOL_NT1)
|
||||
{
|
||||
char *domain,*os,*lanman;
|
||||
p = smb_buf(inbuf);
|
||||
os = p;
|
||||
lanman = skip_string(os,1);
|
||||
domain = skip_string(lanman,1);
|
||||
if (*domain || *os || *lanman)
|
||||
DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n",domain,os,lanman));
|
||||
}
|
||||
|
||||
/* use the returned uid from now on */
|
||||
if (SVAL(inbuf,smb_uid) != vuid)
|
||||
DEBUG(3,("Server gave us a UID of %d. We gave %d\n",
|
||||
SVAL(inbuf,smb_uid),(int)vuid));
|
||||
opt.server_vuid = vuid = SVAL(inbuf,smb_uid);
|
||||
}
|
||||
|
||||
if (opt.sec_mode & 1) {
|
||||
if (SVAL(inbuf, smb_vwv2) & 1)
|
||||
DEBUG(1,("connected as guest "));
|
||||
DEBUG(1,("security=user\n"));
|
||||
} else {
|
||||
DEBUG(1,("security=share\n"));
|
||||
}
|
||||
|
||||
/* now we've got a connection - send a tcon message */
|
||||
bzero(outbuf,smb_size);
|
||||
|
||||
if (strncmp(service,"\\\\",2) != 0)
|
||||
{
|
||||
DEBUG(0,("\nWarning: Your service name doesn't start with \\\\. This is probably incorrect.\n"));
|
||||
DEBUG(0,("Perhaps try replacing each \\ with \\\\ on the command line?\n\n"));
|
||||
}
|
||||
|
||||
|
||||
again2:
|
||||
|
||||
{
|
||||
int passlen = strlen(pass)+1;
|
||||
fstring pword;
|
||||
fstrcpy(pword,pass);
|
||||
|
||||
if (doencrypt && *pass) {
|
||||
passlen=24;
|
||||
SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword);
|
||||
}
|
||||
|
||||
/* if in user level security then don't send a password now */
|
||||
if ((opt.sec_mode & 1)) {
|
||||
fstrcpy(pword, ""); passlen=1;
|
||||
}
|
||||
|
||||
if (Protocol <= PROTOCOL_COREPLUS) {
|
||||
set_message(outbuf,0,6 + strlen(service) + passlen + strlen(dev),True);
|
||||
CVAL(outbuf,smb_com) = SMBtcon;
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
p = smb_buf(outbuf);
|
||||
*p++ = 0x04;
|
||||
pstrcpy(p, service);
|
||||
p = skip_string(p,1);
|
||||
*p++ = 0x04;
|
||||
memcpy(p,pword,passlen);
|
||||
p += passlen;
|
||||
*p++ = 0x04;
|
||||
pstrcpy(p, dev);
|
||||
}
|
||||
else {
|
||||
set_message(outbuf,4,2 + strlen(service) + passlen + strlen(dev),True);
|
||||
CVAL(outbuf,smb_com) = SMBtconX;
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
SSVAL(outbuf,smb_vwv0,0xFF);
|
||||
SSVAL(outbuf,smb_vwv3,passlen);
|
||||
|
||||
p = smb_buf(outbuf);
|
||||
memcpy(p,pword,passlen);
|
||||
p += passlen;
|
||||
pstrcpy(p,service);
|
||||
p = skip_string(p,1);
|
||||
pstrcpy(p,dev);
|
||||
}
|
||||
}
|
||||
|
||||
send_smb(Client,outbuf);
|
||||
client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
|
||||
|
||||
/* trying again with a blank password */
|
||||
if (CVAL(inbuf,smb_rcls) != 0 &&
|
||||
(int)strlen(pass) > 0 &&
|
||||
!doencrypt &&
|
||||
Protocol >= PROTOCOL_LANMAN1)
|
||||
{
|
||||
DEBUG(2,("first SMBtconX failed, trying again. %s\n",smb_errstr(inbuf)));
|
||||
pstrcpy(pass,"");
|
||||
goto again2;
|
||||
}
|
||||
|
||||
if (CVAL(inbuf,smb_rcls) != 0)
|
||||
{
|
||||
DEBUG(0,("SMBtconX failed. %s\n",smb_errstr(inbuf)));
|
||||
DEBUG(0,("Perhaps you are using the wrong sharename, username or password?\n"));
|
||||
DEBUG(0,("Some servers insist that these be in uppercase\n"));
|
||||
if (was_null)
|
||||
{
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
|
||||
if (Protocol <= PROTOCOL_COREPLUS) {
|
||||
max_xmit = SVAL(inbuf,smb_vwv0);
|
||||
|
||||
cnum = SVAL(inbuf,smb_vwv1);
|
||||
}
|
||||
else {
|
||||
max_xmit = MIN(max_xmit,BUFFER_SIZE-4);
|
||||
if (max_xmit <= 0)
|
||||
max_xmit = BUFFER_SIZE - 4;
|
||||
|
||||
cnum = SVAL(inbuf,smb_tid);
|
||||
}
|
||||
opt.max_xmit = max_xmit;
|
||||
opt.tid = cnum;
|
||||
|
||||
DEBUG(3,("Connected with cnum=%d max_xmit=%d\n",cnum,max_xmit));
|
||||
|
||||
if (was_null)
|
||||
{
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
}
|
||||
|
||||
if (options != NULL)
|
||||
{
|
||||
*options = opt;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
send a logout command
|
||||
****************************************************************************/
|
||||
void cli_send_logout(char *dum_in, char *dum_out)
|
||||
{
|
||||
pstring inbuf,outbuf;
|
||||
|
||||
DEBUG(5,("cli_send_logout\n"));
|
||||
|
||||
bzero(outbuf,smb_size);
|
||||
set_message(outbuf,0,0,True);
|
||||
CVAL(outbuf,smb_com) = SMBtdis;
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
send_smb(Client,outbuf);
|
||||
client_receive_smb(Client,inbuf,SHORT_TIMEOUT);
|
||||
|
||||
if (CVAL(inbuf,smb_rcls) != 0)
|
||||
{
|
||||
DEBUG(0,("SMBtdis failed %s\n",smb_errstr(inbuf)));
|
||||
}
|
||||
|
||||
|
||||
#ifdef STATS
|
||||
stats_report();
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
open the client sockets
|
||||
****************************************************************************/
|
||||
BOOL cli_open_sockets(int port )
|
||||
{
|
||||
static int last_port;
|
||||
char *host;
|
||||
pstring service2;
|
||||
extern int Client;
|
||||
|
||||
if (port == 0) port=last_port;
|
||||
last_port=port;
|
||||
|
||||
strupper(service);
|
||||
|
||||
if (*desthost)
|
||||
{
|
||||
host = desthost;
|
||||
}
|
||||
else
|
||||
{
|
||||
pstrcpy(service2,service);
|
||||
host = strtok(service2,"\\/");
|
||||
if (!host) {
|
||||
DEBUG(0,("Badly formed host name\n"));
|
||||
return(False);
|
||||
}
|
||||
pstrcpy(desthost,host);
|
||||
}
|
||||
|
||||
if (!(*global_myname)) {
|
||||
get_myname(global_myname,NULL);
|
||||
}
|
||||
strupper(global_myname);
|
||||
|
||||
DEBUG(3,("Opening sockets\n"));
|
||||
|
||||
if (!have_ip)
|
||||
{
|
||||
if(!resolve_name( host, &dest_ip, 0x20))
|
||||
{
|
||||
DEBUG(0,("cli_open_sockets: Unknown host %s.\n",host));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
Client = open_socket_out(SOCK_STREAM, &dest_ip, port, LONG_CONNECT_TIMEOUT);
|
||||
if (Client == -1)
|
||||
return False;
|
||||
|
||||
DEBUG(3,("Connected\n"));
|
||||
|
||||
set_socket_options(Client,user_socket_options);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
close and open the connection again
|
||||
****************************************************************************/
|
||||
BOOL cli_reopen_connection(char *inbuf,char *outbuf)
|
||||
{
|
||||
static int open_count=0;
|
||||
|
||||
open_count++;
|
||||
|
||||
if (open_count>5) return(False);
|
||||
|
||||
DEBUG(1,("Trying to re-open connection\n"));
|
||||
|
||||
set_message(outbuf,0,0,True);
|
||||
SCVAL(outbuf,smb_com,SMBtdis);
|
||||
SSVAL(outbuf,smb_tid,cnum);
|
||||
cli_setup_pkt(outbuf);
|
||||
|
||||
send_smb(Client,outbuf);
|
||||
client_receive_smb(Client,inbuf,SHORT_TIMEOUT);
|
||||
|
||||
close_sockets();
|
||||
if (!cli_open_sockets(0)) return(False);
|
||||
|
||||
return(cli_send_login(inbuf,outbuf,True,True,NULL));
|
||||
}
|
||||
|
@ -1,425 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.0.
|
||||
LDAP local group database for SAMBA
|
||||
Copyright (C) Matthew Chapman 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"
|
||||
|
||||
#ifdef WITH_LDAP
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* Internal state */
|
||||
extern LDAP *ldap_struct;
|
||||
extern LDAPMessage *ldap_results;
|
||||
extern LDAPMessage *ldap_entry;
|
||||
|
||||
/* Static structure filled for requests */
|
||||
static LOCAL_GRP localgrp;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Get group and membership information.
|
||||
****************************************************************/
|
||||
|
||||
static LOCAL_GRP *ldapalias_getgrp(LOCAL_GRP *group,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring temp;
|
||||
char **values;
|
||||
LOCAL_GRP_MEMBER *memblist;
|
||||
char *value, *sep;
|
||||
int i;
|
||||
|
||||
if(!ldap_entry)
|
||||
return NULL;
|
||||
|
||||
if(!ldap_get_attribute("cn", group->name)) {
|
||||
DEBUG(0, ("Missing cn\n"));
|
||||
return NULL; }
|
||||
|
||||
DEBUG(2,("Retrieving alias [%s]\n", group->name));
|
||||
|
||||
if(ldap_get_attribute("rid", temp)) {
|
||||
group->rid = strtol(temp, NULL, 16);
|
||||
} else {
|
||||
DEBUG(0, ("Missing rid\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!ldap_get_attribute("description", group->comment))
|
||||
group->comment[0] = 0;
|
||||
|
||||
if(!members || !num_membs) {
|
||||
ldap_entry = ldap_next_entry(ldap_struct, ldap_entry);
|
||||
return group;
|
||||
}
|
||||
|
||||
if(values = ldap_get_values(ldap_struct, ldap_entry, "member")) {
|
||||
|
||||
*num_membs = i = ldap_count_values(values);
|
||||
*members = memblist = malloc(i * sizeof(LOCAL_GRP_MEMBER));
|
||||
|
||||
do {
|
||||
value = values[--i];
|
||||
|
||||
if(!(sep = strchr(value, ','))) {
|
||||
DEBUG(0, ("Malformed alias member\n"));
|
||||
return NULL;
|
||||
}
|
||||
*(sep++) = 0;
|
||||
fstrcpy(memblist[i].name, value);
|
||||
|
||||
if(!(value = strchr(sep, ','))) {
|
||||
DEBUG(0, ("Malformed alias member\n"));
|
||||
return NULL;
|
||||
}
|
||||
*(value++) = 0;
|
||||
string_to_sid(&memblist[i].sid, sep);
|
||||
|
||||
if((memblist[i].sid_use = atoi(value))
|
||||
>= SID_NAME_UNKNOWN)
|
||||
DEBUG(0, ("Invalid SID use in alias"));
|
||||
|
||||
} while(i > 0);
|
||||
|
||||
ldap_value_free(values);
|
||||
|
||||
} else {
|
||||
*num_membs = 0;
|
||||
*members = NULL;
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Queues the necessary modifications to save a LOCAL_GRP structure
|
||||
************************************************************************/
|
||||
|
||||
static void ldapalias_grpmods(LOCAL_GRP *group, LDAPMod ***mods, int operation)
|
||||
{
|
||||
fstring temp;
|
||||
|
||||
*mods = NULL;
|
||||
|
||||
if(operation == LDAP_MOD_ADD) { /* immutable attributes */
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "objectClass", "sambaAlias");
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "cn", group->name);
|
||||
|
||||
slprintf(temp, sizeof(temp)-1, "%x", group->rid);
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "rid", temp);
|
||||
}
|
||||
|
||||
ldap_make_mod(mods, operation, "description", group->comment);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Create a alias member entry
|
||||
************************************************************************/
|
||||
|
||||
static BOOL ldapalias_memmods(DOM_SID *user_sid, LDAPMod ***mods,
|
||||
int operation)
|
||||
{
|
||||
pstring member;
|
||||
pstring sid_str;
|
||||
fstring name;
|
||||
uint8 type;
|
||||
|
||||
if (lookup_sid(user_sid, name, &type))
|
||||
return (False);
|
||||
sid_to_string(sid_str, user_sid);
|
||||
|
||||
slprintf(member, sizeof(member)-1, "%s,%s,%d", name, sid_str, type);
|
||||
|
||||
*mods = NULL;
|
||||
ldap_make_mod(mods, operation, "member", member);
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Begin/end smbgrp enumeration.
|
||||
****************************************************************/
|
||||
|
||||
static void *ldapalias_enumfirst(BOOL update)
|
||||
{
|
||||
if (lp_server_role() == ROLE_DOMAIN_NONE)
|
||||
return NULL;
|
||||
|
||||
if (!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_for("objectClass=sambaAlias");
|
||||
|
||||
return ldap_struct;
|
||||
}
|
||||
|
||||
static void ldapalias_enumclose(void *vp)
|
||||
{
|
||||
ldap_disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Save/restore the current position in a query
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT ldapalias_getdbpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)((ulong)ldap_entry);
|
||||
}
|
||||
|
||||
static BOOL ldapalias_setdbpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
ldap_entry = (LDAPMessage *)((ulong)tok);
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return limited smb_passwd information, and group membership.
|
||||
*************************************************************************/
|
||||
|
||||
static LOCAL_GRP *ldapalias_getgrpbynam(const char *name,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
LOCAL_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(cn=%s)(objectClass=sambaAlias))", name);
|
||||
ldap_search_for(filter);
|
||||
|
||||
ret = ldapalias_getgrp(&localgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LOCAL_GRP *ldapalias_getgrpbygid(gid_t grp_id,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
LOCAL_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(gidNumber=%d)(objectClass=sambaAlias))", grp_id);
|
||||
ldap_search_for(filter);
|
||||
ret = ldapalias_getgrp(&localgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LOCAL_GRP *ldapalias_getgrpbyrid(uint32 grp_rid,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
LOCAL_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectClass=sambaAlias))", grp_rid);
|
||||
ldap_search_for(filter);
|
||||
ret = ldapalias_getgrp(&localgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LOCAL_GRP *ldapalias_getcurrentgrp(void *vp,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
return ldapalias_getgrp(&localgrp, members, num_membs);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Add/modify/delete aliases.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapalias_addgrp(LOCAL_GRP *group)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
if (!ldap_allocaterid(&group->rid))
|
||||
{
|
||||
DEBUG(0,("RID generation failed\n"));
|
||||
return (False);
|
||||
}
|
||||
|
||||
ldapalias_grpmods(group, &mods, LDAP_MOD_ADD);
|
||||
return ldap_makemods("cn", group->name, mods, True);
|
||||
}
|
||||
|
||||
static BOOL ldapalias_modgrp(LOCAL_GRP *group)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
ldapalias_grpmods(group, &mods, LDAP_MOD_REPLACE);
|
||||
return ldap_makemods("cn", group->name, mods, False);
|
||||
}
|
||||
|
||||
static BOOL ldapalias_delgrp(uint32 grp_rid)
|
||||
{
|
||||
fstring filter;
|
||||
char *dn;
|
||||
int err;
|
||||
|
||||
if (!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectClass=sambaAlias))", grp_rid);
|
||||
ldap_search_for(filter);
|
||||
|
||||
if (!ldap_entry || !(dn = ldap_get_dn(ldap_struct, ldap_entry)))
|
||||
{
|
||||
ldap_disconnect();
|
||||
return (False);
|
||||
}
|
||||
|
||||
err = ldap_delete_s(ldap_struct, dn);
|
||||
free(dn);
|
||||
ldap_disconnect();
|
||||
|
||||
if (err != LDAP_SUCCESS)
|
||||
{
|
||||
DEBUG(0, ("delete: %s\n", ldap_err2string(err)));
|
||||
return (False);
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Add users to/remove users from aliases.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapalias_addmem(uint32 grp_rid, DOM_SID *user_sid)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
fstring rid_str;
|
||||
|
||||
slprintf(rid_str, sizeof(rid_str)-1, "%x", grp_rid);
|
||||
|
||||
if(!ldapalias_memmods(user_sid, &mods, LDAP_MOD_ADD))
|
||||
return (False);
|
||||
|
||||
return ldap_makemods("rid", rid_str, mods, False);
|
||||
}
|
||||
|
||||
static BOOL ldapalias_delmem(uint32 grp_rid, DOM_SID *user_sid)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
fstring rid_str;
|
||||
|
||||
slprintf(rid_str, sizeof(rid_str)-1, "%x", grp_rid);
|
||||
|
||||
if(!ldapalias_memmods(user_sid, &mods, LDAP_MOD_DELETE))
|
||||
return (False);
|
||||
|
||||
return ldap_makemods("rid", rid_str, mods, False);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return aliases that a user is in.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapalias_getusergroups(const char *name, LOCAL_GRP **groups,
|
||||
int *num_grps)
|
||||
{
|
||||
LOCAL_GRP *grouplist;
|
||||
fstring filter;
|
||||
int i;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(pstring)-1,
|
||||
"(&(member=%s,*)(objectclass=sambaAlias))", name);
|
||||
ldap_search_for(filter);
|
||||
|
||||
*num_grps = i = ldap_count_entries(ldap_struct, ldap_results);
|
||||
|
||||
if(!i) {
|
||||
*groups = NULL;
|
||||
ldap_disconnect();
|
||||
return (True);
|
||||
}
|
||||
|
||||
*groups = grouplist = malloc(i * sizeof(LOCAL_GRP));
|
||||
do {
|
||||
i--;
|
||||
} while(ldapalias_getgrp(&grouplist[i], NULL, NULL) && (i > 0));
|
||||
|
||||
ldap_disconnect();
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
static struct aliasdb_ops ldapalias_ops =
|
||||
{
|
||||
ldapalias_enumfirst,
|
||||
ldapalias_enumclose,
|
||||
ldapalias_getdbpos,
|
||||
ldapalias_setdbpos,
|
||||
|
||||
ldapalias_getgrpbynam,
|
||||
ldapalias_getgrpbygid,
|
||||
ldapalias_getgrpbyrid,
|
||||
ldapalias_getcurrentgrp,
|
||||
|
||||
ldapalias_addgrp,
|
||||
ldapalias_modgrp,
|
||||
ldapalias_delgrp,
|
||||
|
||||
ldapalias_addmem,
|
||||
ldapalias_delmem,
|
||||
|
||||
ldapalias_getusergroups
|
||||
};
|
||||
|
||||
struct aliasdb_ops *ldap_initialise_alias_db(void)
|
||||
{
|
||||
return &ldapalias_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void aliasldap_dummy_function(void);
|
||||
void aliasldap_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif
|
||||
|
@ -1,334 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef USE_SMBUNIX_DB
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
extern DOM_SID global_sam_sid;
|
||||
extern fstring global_sam_name;
|
||||
|
||||
struct unix_entries
|
||||
{
|
||||
struct group *grps;
|
||||
int num_grps;
|
||||
int grp_idx;
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the alspasswd list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
****************************************************************/
|
||||
|
||||
static void *startalsunixpwent(BOOL update)
|
||||
{
|
||||
struct unix_entries *grps;
|
||||
grps = (struct unix_entries*)malloc(sizeof(struct unix_entries));
|
||||
|
||||
if (grps == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!get_unix_grps(&grps->num_grps, &grps->grps))
|
||||
{
|
||||
free(grps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grps->grp_idx = 0;
|
||||
|
||||
return (void*)grps;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the alspasswd list.
|
||||
****************************************************************/
|
||||
|
||||
static void endalsunixpwent(void *vp)
|
||||
{
|
||||
struct unix_entries *grps = (struct unix_entries *)vp;
|
||||
|
||||
if (grps != NULL)
|
||||
{
|
||||
free_unix_grps(grps->num_grps, grps->grps);
|
||||
free(vp);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Return the current position in the alspasswd list as an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
static SMB_BIG_UINT getalsunixpwpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Set the current position in the alspasswd list from an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
static BOOL setalsunixpwpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the smbdomainalias list.
|
||||
*************************************************************************/
|
||||
BOOL get_unixalias_members(struct group *grp,
|
||||
int *num_mem, LOCAL_GRP_MEMBER **members)
|
||||
{
|
||||
int i;
|
||||
char *unix_name;
|
||||
|
||||
if (num_mem == NULL || members == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
(*num_mem) = 0;
|
||||
(*members) = NULL;
|
||||
|
||||
for (i = 0; (unix_name = grp->gr_mem[i]) != NULL; i++)
|
||||
{
|
||||
fstring name;
|
||||
DOM_NAME_MAP gmep;
|
||||
LOCAL_GRP_MEMBER *mem;
|
||||
|
||||
fstrcpy(name, unix_name);
|
||||
|
||||
if (!lookupsmbpwnam (name, &gmep) &&
|
||||
!lookupsmbgrpnam(name, &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sid_front_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
DEBUG(0,("alias database: could not resolve name %s (wrong Domain SID)\n",
|
||||
name));
|
||||
continue;
|
||||
}
|
||||
|
||||
(*num_mem)++;
|
||||
(*members) = Realloc((*members), (*num_mem) * sizeof(LOCAL_GRP_MEMBER));
|
||||
if ((*members) == NULL)
|
||||
{
|
||||
DEBUG(0,("get_unixalias_members: could not realloc LOCAL_GRP_MEMBERs\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
mem = &(*members)[(*num_mem)-1];
|
||||
slprintf(mem->name, sizeof(mem->name)-1, "%s\\%s",
|
||||
gmep.nt_domain, gmep.nt_name);
|
||||
sid_copy(&mem->sid, &gmep.sid);
|
||||
mem->sid_use = gmep.type;
|
||||
|
||||
DEBUG(10,("get_unixalias_members: adding alias %s\n",
|
||||
mem->name));
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the domain alias list.
|
||||
|
||||
when we are a PDC or BDC, then unix groups that are explicitly NOT mapped
|
||||
to aliases are treated as DOMAIN groups (see groupunix.c).
|
||||
|
||||
when we are a member of a domain (not a PDC or BDC) then unix groups
|
||||
that are explicitly NOT mapped to aliases (map_alias_gid) are treated
|
||||
as LOCAL groups.
|
||||
|
||||
the reasoning behind this is to make it as simple as possible (not an easy
|
||||
task) for people to set up a domain-aware samba server, in each role that
|
||||
the server can take.
|
||||
|
||||
*************************************************************************/
|
||||
static LOCAL_GRP *getalsunixpwent(void *vp, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
/* Static buffers we will return. */
|
||||
static LOCAL_GRP gp_buf;
|
||||
struct group unix_grp;
|
||||
struct unix_entries *grps = (struct unix_entries *)vp;
|
||||
|
||||
if (lp_server_role() == ROLE_DOMAIN_NONE)
|
||||
{
|
||||
/*
|
||||
* no domain role, no domain aliases (or domain groups,
|
||||
* but that's dealt with by groupdb...).
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
aldb_init_als(&gp_buf);
|
||||
|
||||
/* get array of unix names + gids. this function does NOT
|
||||
get a copy of the unix group members
|
||||
*/
|
||||
|
||||
/* cycle through unix groups */
|
||||
for (; grps->grp_idx < grps->num_grps; grps->grp_idx++)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
fstring sid_str;
|
||||
|
||||
memcpy(&unix_grp, &grps->grps[grps->grp_idx], sizeof(unix_grp));
|
||||
|
||||
DEBUG(10,("getgrpunixpwent: enum unix group entry %s\n",
|
||||
unix_grp.gr_name));
|
||||
|
||||
if (!lookupsmbgrpgid(unix_grp.gr_gid, &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_to_string(sid_str, &gmep.sid);
|
||||
DEBUG(10,("group %s found, sid %s type %d\n",
|
||||
gmep.nt_name, sid_str, gmep.type));
|
||||
|
||||
if (gmep.type != SID_NAME_ALIAS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_split_rid(&gmep.sid, &gp_buf.rid);
|
||||
if (!sid_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fstrcpy(gp_buf.name, gmep.nt_name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (grps->grp_idx >= grps->num_grps)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get the user's domain aliases. there are a maximum of 32 */
|
||||
|
||||
if (mem != NULL && num_mem != NULL)
|
||||
{
|
||||
(*mem) = NULL;
|
||||
(*num_mem) = 0;
|
||||
|
||||
memcpy(&unix_grp, getgrgid(unix_grp.gr_gid), sizeof(unix_grp));
|
||||
get_unixalias_members(&unix_grp, num_mem, mem);
|
||||
}
|
||||
|
||||
{
|
||||
pstring linebuf;
|
||||
make_alias_line(linebuf, sizeof(linebuf), &gp_buf, mem, num_mem);
|
||||
DEBUG(10,("line: '%s'\n", linebuf));
|
||||
}
|
||||
|
||||
grps->grp_idx++; /* advance so next enum gets next entry */
|
||||
return &gp_buf;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add an entry to the alspasswd file.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL add_alsunixgrp_entry(LOCAL_GRP *newals)
|
||||
{
|
||||
DEBUG(0, ("add_alsunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search the alspasswd file for an entry matching the aliasname.
|
||||
and then modify its alias entry.
|
||||
************************************************************************/
|
||||
|
||||
static BOOL mod_alsunixgrp_entry(LOCAL_GRP* als)
|
||||
{
|
||||
DEBUG(0, ("mod_alsunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search the grppasswd file for an entry matching the rid.
|
||||
and then delete it.
|
||||
************************************************************************/
|
||||
|
||||
static BOOL del_alsunixgrp_entry(uint32 rid)
|
||||
{
|
||||
DEBUG(0, ("del_alsunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add a member to an entry to the grppasswd file.
|
||||
*************************************************************************/
|
||||
static BOOL add_alsunixgrp_member(uint32 rid, DOM_SID *member_sid)
|
||||
{
|
||||
DEBUG(0, ("add_alsunixgrp_member: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to delete a member from an entry to the grppasswd file.
|
||||
*************************************************************************/
|
||||
static BOOL del_alsunixgrp_member(uint32 rid, DOM_SID *member_sid)
|
||||
{
|
||||
DEBUG(0, ("del_alsunixgrp_member: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
static struct aliasdb_ops unix_ops =
|
||||
{
|
||||
startalsunixpwent,
|
||||
endalsunixpwent,
|
||||
getalsunixpwpos,
|
||||
setalsunixpwpos,
|
||||
|
||||
iterate_getaliasntnam, /* In aliasdb.c */
|
||||
iterate_getaliasgid, /* In aliasdb.c */
|
||||
iterate_getaliasrid, /* In aliasdb.c */
|
||||
getalsunixpwent,
|
||||
|
||||
add_alsunixgrp_entry,
|
||||
mod_alsunixgrp_entry,
|
||||
del_alsunixgrp_entry,
|
||||
|
||||
add_alsunixgrp_member,
|
||||
del_alsunixgrp_member,
|
||||
|
||||
iterate_getuseraliasntnam /* in aliasdb.c */
|
||||
};
|
||||
|
||||
struct aliasdb_ops *unix_initialise_alias_db(void)
|
||||
{
|
||||
return &unix_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
|
||||
void unix_alspass_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif /* USE_SMBPASS_DB */
|
@ -1,475 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Pasesword and authentication handling
|
||||
Copyright (C) Jeremy Allison 1996-1998
|
||||
Copyright (C) Luke Kenneth Caseson 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 Mases Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "nterr.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
extern fstring global_sam_name;
|
||||
extern DOM_SID global_sam_sid;
|
||||
|
||||
/*
|
||||
* NOTE. All these functions are abstracted into a structure
|
||||
* that points to the correct function for the selected database. JRA.
|
||||
*/
|
||||
|
||||
static struct aliasdb_ops *bidb_ops = NULL;
|
||||
|
||||
/***************************************************************
|
||||
Initialise the builtin db operations.
|
||||
***************************************************************/
|
||||
|
||||
BOOL initialise_builtin_db(void)
|
||||
{
|
||||
if (bidb_ops)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
#ifdef WITH_NISPLUS
|
||||
bidb_ops = nisplus_initialise_builtin_db();
|
||||
#elif defined(WITH_LDAP)
|
||||
bidb_ops = ldap_initialise_builtin_db();
|
||||
#elif defined(USE_SMBUNIX_DB)
|
||||
bidb_ops = unix_initialise_builtin_db();
|
||||
#endif
|
||||
|
||||
return (bidb_ops != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions that return/manipulate a LOCAL_GRP.
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
Utility function to search builtin database by gid: the LOCAL_GRP
|
||||
structure does not have a gid member, so we have to convert here
|
||||
from gid to builtin rid.
|
||||
*************************************************************************/
|
||||
LOCAL_GRP *iterate_getbuiltingid(gid_t gid, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
uint32 rid;
|
||||
if (!lookupsmbgrpgid(gid, &gmep))
|
||||
{
|
||||
DEBUG(0,("iterate_getbuiltingid: gid %d does not map to one of our Domain's Aliases\n", gid));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (gmep.type != SID_NAME_ALIAS )
|
||||
{
|
||||
DEBUG(0,("iterate_getbuiltingid: gid %d does not map to one of our Domain's Aliases\n", gid));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sid_split_rid(&gmep.sid, &rid);
|
||||
if (!sid_equal(&gmep.sid, &global_sam_sid))
|
||||
{
|
||||
DEBUG(0,("iterate_getbuiltingid: gid %d does not map into our Domain SID\n", gid));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return iterate_getbuiltinrid(rid, mem, num_mem);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Utility function to search builtin database by rid. use this if your database
|
||||
does not have search facilities.
|
||||
*************************************************************************/
|
||||
LOCAL_GRP *iterate_getbuiltinrid(uint32 rid, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
LOCAL_GRP *blt = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search by rid: 0x%x\n", rid));
|
||||
|
||||
/* Open the builtin database file - not for update. */
|
||||
fp = startbuiltinent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open builtin database.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((blt = getbuiltinent(fp, mem, num_mem)) != NULL && blt->rid != rid)
|
||||
{
|
||||
DEBUG(10,("iterate: %s 0x%x", blt->name, blt->rid));
|
||||
}
|
||||
|
||||
if (blt != NULL)
|
||||
{
|
||||
DEBUG(10, ("found builtin %s by rid: 0x%x\n", blt->name, rid));
|
||||
}
|
||||
|
||||
endbuiltinent(fp);
|
||||
return blt;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Utility function to search builtin database by name. use this if your database
|
||||
does not have search facilities.
|
||||
*************************************************************************/
|
||||
LOCAL_GRP *iterate_getbuiltinntnam(const char *name, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
LOCAL_GRP *blt = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search by name: %s\n", name));
|
||||
|
||||
/* Open the builtin database file - not for update. */
|
||||
fp = startbuiltinent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open builtin database.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((blt = getbuiltinent(fp, mem, num_mem)) != NULL && !strequal(blt->name, name))
|
||||
{
|
||||
}
|
||||
|
||||
if (blt != NULL)
|
||||
{
|
||||
DEBUG(10, ("found by name: %s\n", name));
|
||||
}
|
||||
|
||||
endbuiltinent(fp);
|
||||
return blt;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the smbdomainbuiltin list.
|
||||
*************************************************************************/
|
||||
BOOL add_domain_builtin(LOCAL_GRP **blts, int *num_blts, LOCAL_GRP *blt)
|
||||
{
|
||||
if (blts == NULL || num_blts == NULL || blt == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
(*blts) = Realloc((*blts), ((*num_blts)+1) * sizeof(LOCAL_GRP));
|
||||
if ((*blts) == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
DEBUG(10,("adding builtin %s(%s)\n", blt->name, blt->comment));
|
||||
|
||||
fstrcpy((*blts)[(*num_blts)].name , blt->name);
|
||||
fstrcpy((*blts)[(*num_blts)].comment, blt->comment);
|
||||
(*blts)[(*num_blts)].rid = blt->rid;
|
||||
|
||||
(*num_blts)++;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
checks to see if a user is a member of a domain builtin
|
||||
*************************************************************************/
|
||||
static BOOL user_is_member(const char *user_name, LOCAL_GRP_MEMBER *mem, int num_mem)
|
||||
{
|
||||
int i;
|
||||
pstring name;
|
||||
slprintf(name, sizeof(name)-1, "%s\\%s", global_sam_name, user_name);
|
||||
|
||||
for (i = 0; i < num_mem; i++)
|
||||
{
|
||||
DEBUG(10,("searching against user %s...\n", mem[i].name));
|
||||
if (strequal(mem[i].name, name))
|
||||
{
|
||||
DEBUG(10,("searching for user %s: found\n", name));
|
||||
return True;
|
||||
}
|
||||
}
|
||||
DEBUG(10,("searching for user %s: not found\n", name));
|
||||
return False;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
gets an array of builtin aliases that a user is in. use this if your database
|
||||
does not have search facilities
|
||||
*************************************************************************/
|
||||
BOOL iterate_getuserbuiltinntnam(const char *user_name, LOCAL_GRP **blts, int *num_blts)
|
||||
{
|
||||
LOCAL_GRP *blt = NULL;
|
||||
LOCAL_GRP_MEMBER *mem = NULL;
|
||||
int num_mem = 0;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search for userbuiltin by name: %s\n", user_name));
|
||||
|
||||
if (user_name == NULL || blts == NULL || num_blts == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
(*blts) = NULL;
|
||||
(*num_blts) = 0;
|
||||
|
||||
/* Open the builtin database file - not for update. */
|
||||
fp = startbuiltinent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open builtin database.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/* iterate through all builtin aliases. search members for required user */
|
||||
while ((blt = getbuiltinent(fp, &mem, &num_mem)) != NULL)
|
||||
{
|
||||
DEBUG(5,("builtin name %s members: %d\n", blt->name, num_mem));
|
||||
if (num_mem != 0 && mem != NULL)
|
||||
{
|
||||
BOOL ret = True;
|
||||
if (user_is_member(user_name, mem, num_mem))
|
||||
{
|
||||
ret = add_domain_builtin(blts, num_blts, blt);
|
||||
}
|
||||
|
||||
free(mem);
|
||||
mem = NULL;
|
||||
num_mem = 0;
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
(*num_blts) = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((*num_blts) != 0)
|
||||
{
|
||||
DEBUG(10, ("found %d user builtin aliases:\n", (*num_blts)));
|
||||
}
|
||||
|
||||
endbuiltinent(fp);
|
||||
return True;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
gets an array of builtin aliases that a user is in. use this if your database
|
||||
does not have search facilities
|
||||
*************************************************************************/
|
||||
BOOL enumdombuiltins(LOCAL_GRP **blts, int *num_blts)
|
||||
{
|
||||
LOCAL_GRP *blt = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("enum user builtin aliases\n"));
|
||||
|
||||
if (blts == NULL || num_blts == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
(*blts) = NULL;
|
||||
(*num_blts) = 0;
|
||||
|
||||
/* Open the builtin database file - not for update. */
|
||||
fp = startbuiltinent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open builtin database.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/* iterate through all builtin aliases. */
|
||||
while ((blt = getbuiltinent(fp, NULL, NULL)) != NULL)
|
||||
{
|
||||
if (!add_domain_builtin(blts, num_blts, blt))
|
||||
{
|
||||
DEBUG(0,("unable to add builtin while enumerating\n"));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
if ((*num_blts) != 0)
|
||||
{
|
||||
DEBUG(10, ("found %d user builtin aliases:\n", (*num_blts)));
|
||||
}
|
||||
|
||||
endbuiltinent(fp);
|
||||
return True;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the builtin database list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
****************************************************************/
|
||||
|
||||
void *startbuiltinent(BOOL update)
|
||||
{
|
||||
return bidb_ops->startaliasent(update);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the builtin database list.
|
||||
****************************************************************/
|
||||
|
||||
void endbuiltinent(void *vp)
|
||||
{
|
||||
bidb_ops->endaliasent(vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the builtin database list.
|
||||
*************************************************************************/
|
||||
|
||||
LOCAL_GRP *getbuiltinent(void *vp, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
return bidb_ops->getaliasent(vp, mem, num_mem);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add an entry to the builtin database file.
|
||||
*************************************************************************/
|
||||
|
||||
BOOL add_builtin_entry(LOCAL_GRP *newblt)
|
||||
{
|
||||
return bidb_ops->add_alias_entry(newblt);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search the builtin database file for an entry matching the builtinname.
|
||||
and then replace the entry.
|
||||
************************************************************************/
|
||||
|
||||
BOOL mod_builtin_entry(LOCAL_GRP* blt)
|
||||
{
|
||||
return bidb_ops->mod_alias_entry(blt);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add a member to an entry in the builtin database file.
|
||||
*************************************************************************/
|
||||
BOOL add_builtin_member(uint32 rid, DOM_SID *member_sid)
|
||||
{
|
||||
return bidb_ops->add_alias_member(rid, member_sid);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to delete a member from an entry in the builtindatabase file.
|
||||
*************************************************************************/
|
||||
BOOL del_builtin_member(uint32 rid, DOM_SID *member_sid)
|
||||
{
|
||||
return bidb_ops->del_alias_member(rid, member_sid);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search builtin database by name.
|
||||
*************************************************************************/
|
||||
|
||||
LOCAL_GRP *getbuiltinntnam(const char *name, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
return bidb_ops->getaliasntnam(name, mem, num_mem);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search builtin database by builtin rid.
|
||||
*************************************************************************/
|
||||
|
||||
LOCAL_GRP *getbuiltinrid(uint32 builtin_rid, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
return bidb_ops->getaliasrid(builtin_rid, mem, num_mem);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search builtin database by gid.
|
||||
*************************************************************************/
|
||||
|
||||
LOCAL_GRP *getbuiltingid(gid_t gid, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
return bidb_ops->getaliasgid(gid, mem, num_mem);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
gets an array of builtin aliases that a user is in.
|
||||
*************************************************************************/
|
||||
BOOL getuserbuiltinntnam(const char *user_name, LOCAL_GRP **blt, int *num_blts)
|
||||
{
|
||||
return bidb_ops->getuseraliasntnam(user_name, blt, num_blts);
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
initialises a LOCAL_GRP.
|
||||
**************************************************************/
|
||||
void bidb_init_blt(LOCAL_GRP *blt)
|
||||
{
|
||||
if (blt == NULL) return;
|
||||
ZERO_STRUCTP(blt);
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
turns an builtin entry into a string.
|
||||
**************************************************************/
|
||||
BOOL make_builtin_line(char *p, int max_len,
|
||||
LOCAL_GRP *blt,
|
||||
LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
int i;
|
||||
int len;
|
||||
len = slprintf(p, max_len-1, "%s:%s:%d:", blt->name, blt->comment, blt->rid);
|
||||
|
||||
if (len == -1)
|
||||
{
|
||||
DEBUG(0,("make_builtin_line: cannot create entry\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
p += len;
|
||||
max_len -= len;
|
||||
|
||||
if (mem == NULL || num_mem == NULL)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
for (i = 0; i < (*num_mem); i++)
|
||||
{
|
||||
len = strlen((*mem)[i].name);
|
||||
p = safe_strcpy(p, (*mem)[i].name, max_len);
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
DEBUG(0, ("make_builtin_line: out of space for builtin aliases!\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
max_len -= len;
|
||||
|
||||
if (i != (*num_mem)-1)
|
||||
{
|
||||
*p = ',';
|
||||
p++;
|
||||
max_len--;
|
||||
}
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
@ -1,426 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.0.
|
||||
LDAP builtin group database for SAMBA
|
||||
Copyright (C) Matthew Chapman 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"
|
||||
|
||||
#ifdef WITH_LDAP
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* Internal state */
|
||||
extern LDAP *ldap_struct;
|
||||
extern LDAPMessage *ldap_results;
|
||||
extern LDAPMessage *ldap_entry;
|
||||
|
||||
/* Static structure filled for requests */
|
||||
static LOCAL_GRP localgrp;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Get group and membership information.
|
||||
****************************************************************/
|
||||
|
||||
static LOCAL_GRP *ldapbuiltin_getgrp(LOCAL_GRP *group,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring temp;
|
||||
char **values;
|
||||
LOCAL_GRP_MEMBER *memblist;
|
||||
char *value, *sep;
|
||||
int i;
|
||||
|
||||
if(!ldap_entry)
|
||||
return NULL;
|
||||
|
||||
if(!ldap_get_attribute("cn", group->name)) {
|
||||
DEBUG(0, ("Missing cn\n"));
|
||||
return NULL; }
|
||||
|
||||
DEBUG(2,("Retrieving builtin alias [%s]\n", group->name));
|
||||
|
||||
if(ldap_get_attribute("rid", temp)) {
|
||||
group->rid = strtol(temp, NULL, 16);
|
||||
} else {
|
||||
DEBUG(0, ("Missing rid\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!ldap_get_attribute("description", group->comment))
|
||||
group->comment[0] = 0;
|
||||
|
||||
if(!members || !num_membs) {
|
||||
ldap_entry = ldap_next_entry(ldap_struct, ldap_entry);
|
||||
return group;
|
||||
}
|
||||
|
||||
if(values = ldap_get_values(ldap_struct, ldap_entry, "member")) {
|
||||
|
||||
*num_membs = i = ldap_count_values(values);
|
||||
*members = memblist = malloc(i * sizeof(LOCAL_GRP_MEMBER));
|
||||
|
||||
do {
|
||||
value = values[--i];
|
||||
|
||||
if(!(sep = strchr(value, ','))) {
|
||||
DEBUG(0, ("Malformed alias member\n"));
|
||||
return NULL;
|
||||
}
|
||||
*(sep++) = 0;
|
||||
fstrcpy(memblist[i].name, value);
|
||||
|
||||
if(!(value = strchr(sep, ','))) {
|
||||
DEBUG(0, ("Malformed alias member\n"));
|
||||
return NULL;
|
||||
}
|
||||
*(value++) = 0;
|
||||
string_to_sid(&memblist[i].sid, sep);
|
||||
|
||||
if((memblist[i].sid_use = atoi(value))
|
||||
>= SID_NAME_UNKNOWN)
|
||||
DEBUG(0, ("Invalid SID use in alias"));
|
||||
|
||||
} while(i > 0);
|
||||
|
||||
ldap_value_free(values);
|
||||
|
||||
} else {
|
||||
*num_membs = 0;
|
||||
*members = NULL;
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Queues the necessary modifications to save a LOCAL_GRP structure
|
||||
************************************************************************/
|
||||
|
||||
static void ldapbuiltin_grpmods(LOCAL_GRP *group, LDAPMod ***mods,
|
||||
int operation)
|
||||
{
|
||||
fstring temp;
|
||||
|
||||
*mods = NULL;
|
||||
|
||||
if(operation == LDAP_MOD_ADD) { /* immutable attributes */
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "objectClass", "sambaBuiltin");
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "cn", group->name);
|
||||
|
||||
slprintf(temp, sizeof(temp)-1, "%x", group->rid);
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "rid", temp);
|
||||
}
|
||||
|
||||
ldap_make_mod(mods, operation, "description", group->comment);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Create a builtin alias member entry
|
||||
************************************************************************/
|
||||
|
||||
static BOOL ldapbuiltin_memmods(DOM_SID *user_sid, LDAPMod ***mods,
|
||||
int operation)
|
||||
{
|
||||
pstring member;
|
||||
pstring sid_str;
|
||||
fstring name;
|
||||
uint8 type;
|
||||
|
||||
if (lookup_sid(user_sid, name, &type))
|
||||
return (False);
|
||||
sid_to_string(sid_str, user_sid);
|
||||
|
||||
slprintf(member, sizeof(member)-1, "%s,%s,%d", name, sid_str, type);
|
||||
|
||||
*mods = NULL;
|
||||
ldap_make_mod(mods, operation, "member", member);
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Begin/end smbgrp enumeration.
|
||||
****************************************************************/
|
||||
|
||||
static void *ldapbuiltin_enumfirst(BOOL update)
|
||||
{
|
||||
if (lp_server_role() == ROLE_DOMAIN_NONE)
|
||||
return NULL;
|
||||
|
||||
if (!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_for("objectClass=sambaBuiltin");
|
||||
|
||||
return ldap_struct;
|
||||
}
|
||||
|
||||
static void ldapbuiltin_enumclose(void *vp)
|
||||
{
|
||||
ldap_disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Save/restore the current position in a query
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT ldapbuiltin_getdbpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)((ulong)ldap_entry);
|
||||
}
|
||||
|
||||
static BOOL ldapbuiltin_setdbpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
ldap_entry = (LDAPMessage *)((ulong)tok);
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return limited smb_passwd information, and group membership.
|
||||
*************************************************************************/
|
||||
|
||||
static LOCAL_GRP *ldapbuiltin_getgrpbynam(const char *name,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
LOCAL_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(cn=%s)(objectClass=sambaBuiltin))", name);
|
||||
ldap_search_for(filter);
|
||||
|
||||
ret = ldapbuiltin_getgrp(&localgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LOCAL_GRP *ldapbuiltin_getgrpbygid(gid_t grp_id,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
LOCAL_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(gidNumber=%d)(objectClass=sambaBuiltin))", grp_id);
|
||||
ldap_search_for(filter);
|
||||
ret = ldapbuiltin_getgrp(&localgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LOCAL_GRP *ldapbuiltin_getgrpbyrid(uint32 grp_rid,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
LOCAL_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectClass=sambaBuiltin))", grp_rid);
|
||||
ldap_search_for(filter);
|
||||
ret = ldapbuiltin_getgrp(&localgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static LOCAL_GRP *ldapbuiltin_getcurrentgrp(void *vp,
|
||||
LOCAL_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
return ldapbuiltin_getgrp(&localgrp, members, num_membs);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Add/modify/delete builtin aliases.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapbuiltin_addgrp(LOCAL_GRP *group)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
if (!ldap_allocaterid(&group->rid))
|
||||
{
|
||||
DEBUG(0,("RID generation failed\n"));
|
||||
return (False);
|
||||
}
|
||||
|
||||
ldapbuiltin_grpmods(group, &mods, LDAP_MOD_ADD);
|
||||
return ldap_makemods("cn", group->name, mods, True);
|
||||
}
|
||||
|
||||
static BOOL ldapbuiltin_modgrp(LOCAL_GRP *group)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
ldapbuiltin_grpmods(group, &mods, LDAP_MOD_REPLACE);
|
||||
return ldap_makemods("cn", group->name, mods, False);
|
||||
}
|
||||
|
||||
static BOOL ldapbuiltin_delgrp(uint32 grp_rid)
|
||||
{
|
||||
fstring filter;
|
||||
char *dn;
|
||||
int err;
|
||||
|
||||
if (!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectClass=sambaBuiltin))", grp_rid);
|
||||
ldap_search_for(filter);
|
||||
|
||||
if (!ldap_entry || !(dn = ldap_get_dn(ldap_struct, ldap_entry)))
|
||||
{
|
||||
ldap_disconnect();
|
||||
return (False);
|
||||
}
|
||||
|
||||
err = ldap_delete_s(ldap_struct, dn);
|
||||
free(dn);
|
||||
ldap_disconnect();
|
||||
|
||||
if (err != LDAP_SUCCESS)
|
||||
{
|
||||
DEBUG(0, ("delete: %s\n", ldap_err2string(err)));
|
||||
return (False);
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Add users to/remove users from aliases.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapbuiltin_addmem(uint32 grp_rid, DOM_SID *user_sid)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
fstring rid_str;
|
||||
|
||||
slprintf(rid_str, sizeof(rid_str)-1, "%x", grp_rid);
|
||||
|
||||
if(!ldapbuiltin_memmods(user_sid, &mods, LDAP_MOD_ADD))
|
||||
return (False);
|
||||
|
||||
return ldap_makemods("rid", rid_str, mods, False);
|
||||
}
|
||||
|
||||
static BOOL ldapbuiltin_delmem(uint32 grp_rid, DOM_SID *user_sid)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
fstring rid_str;
|
||||
|
||||
slprintf(rid_str, sizeof(rid_str)-1, "%x", grp_rid);
|
||||
|
||||
if(!ldapbuiltin_memmods(user_sid, &mods, LDAP_MOD_DELETE))
|
||||
return (False);
|
||||
|
||||
return ldap_makemods("rid", rid_str, mods, False);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return builtin aliases that a user is in.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapbuiltin_getusergroups(const char *name,
|
||||
LOCAL_GRP **groups, int *num_grps)
|
||||
{
|
||||
LOCAL_GRP *grouplist;
|
||||
fstring filter;
|
||||
int i;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(pstring)-1,
|
||||
"(&(member=%s,*)(objectclass=sambaBuiltin))", name);
|
||||
ldap_search_for(filter);
|
||||
|
||||
*num_grps = i = ldap_count_entries(ldap_struct, ldap_results);
|
||||
|
||||
if(!i) {
|
||||
*groups = NULL;
|
||||
ldap_disconnect();
|
||||
return (True);
|
||||
}
|
||||
|
||||
*groups = grouplist = malloc(i * sizeof(LOCAL_GRP));
|
||||
do {
|
||||
i--;
|
||||
} while(ldapbuiltin_getgrp(&grouplist[i], NULL, NULL) && (i > 0));
|
||||
|
||||
ldap_disconnect();
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
static struct aliasdb_ops ldapbuiltin_ops =
|
||||
{
|
||||
ldapbuiltin_enumfirst,
|
||||
ldapbuiltin_enumclose,
|
||||
ldapbuiltin_getdbpos,
|
||||
ldapbuiltin_setdbpos,
|
||||
|
||||
ldapbuiltin_getgrpbynam,
|
||||
ldapbuiltin_getgrpbygid,
|
||||
ldapbuiltin_getgrpbyrid,
|
||||
ldapbuiltin_getcurrentgrp,
|
||||
|
||||
ldapbuiltin_addgrp,
|
||||
ldapbuiltin_modgrp,
|
||||
ldapbuiltin_delgrp,
|
||||
|
||||
ldapbuiltin_addmem,
|
||||
ldapbuiltin_delmem,
|
||||
|
||||
ldapbuiltin_getusergroups
|
||||
};
|
||||
|
||||
struct aliasdb_ops *ldap_initialise_builtin_db(void)
|
||||
{
|
||||
return &ldapbuiltin_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void builtinldap_dummy_function(void);
|
||||
void builtinldap_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif
|
||||
|
@ -1,327 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef USE_SMBUNIX_DB
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
struct unix_entries
|
||||
{
|
||||
struct group *grps;
|
||||
int num_grps;
|
||||
int grp_idx;
|
||||
};
|
||||
|
||||
extern DOM_SID global_sid_S_1_5_20;
|
||||
extern DOM_SID global_sam_sid;
|
||||
extern fstring global_sam_name;
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the bltpasswd list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
****************************************************************/
|
||||
|
||||
static void *startbltunixpwent(BOOL update)
|
||||
{
|
||||
struct unix_entries *grps;
|
||||
grps = (struct unix_entries*)malloc(sizeof(struct unix_entries));
|
||||
|
||||
if (grps == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!get_unix_grps(&grps->num_grps, &grps->grps))
|
||||
{
|
||||
free(grps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grps->grp_idx = 0;
|
||||
|
||||
return (void*)grps;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the bltpasswd list.
|
||||
****************************************************************/
|
||||
|
||||
static void endbltunixpwent(void *vp)
|
||||
{
|
||||
struct unix_entries *grps = (struct unix_entries *)vp;
|
||||
|
||||
if (grps != NULL)
|
||||
{
|
||||
free_unix_grps(grps->num_grps, grps->grps);
|
||||
free(vp);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Return the current position in the bltpasswd list as an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
static SMB_BIG_UINT getbltunixpwpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Set the current position in the bltpasswd list from an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
static BOOL setbltunixpwpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the smbdomainbuiltin list.
|
||||
*************************************************************************/
|
||||
BOOL get_unixbuiltin_members(struct group *grp,
|
||||
int *num_mem, LOCAL_GRP_MEMBER **members)
|
||||
{
|
||||
int i;
|
||||
char *unix_name;
|
||||
|
||||
if (num_mem == NULL || members == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
(*num_mem) = 0;
|
||||
(*members) = NULL;
|
||||
|
||||
for (i = 0; (unix_name = grp->gr_mem[i]) != NULL; i++)
|
||||
{
|
||||
fstring name;
|
||||
DOM_NAME_MAP gmep;
|
||||
LOCAL_GRP_MEMBER *mem;
|
||||
|
||||
fstrcpy(name, unix_name);
|
||||
|
||||
if (!lookupsmbpwnam (name, &gmep) &&
|
||||
!lookupsmbgrpnam(name, &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sid_front_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
DEBUG(0,("builtin database: could not resolve name %s (wrong Domain SID)\n",
|
||||
name));
|
||||
continue;
|
||||
}
|
||||
|
||||
(*num_mem)++;
|
||||
(*members) = Realloc((*members), (*num_mem) * sizeof(LOCAL_GRP_MEMBER));
|
||||
if ((*members) == NULL)
|
||||
{
|
||||
DEBUG(0,("get_unixbuiltin_members: could not realloc LOCAL_GRP_MEMBERs\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
mem = &(*members)[(*num_mem)-1];
|
||||
slprintf(mem->name, sizeof(mem->name)-1, "%s\\%s",
|
||||
gmep.nt_domain, gmep.nt_name);
|
||||
sid_copy(&mem->sid, &gmep.sid);
|
||||
mem->sid_use = gmep.type;
|
||||
|
||||
DEBUG(10,("get_unixbuiltin_members: adding to builtin alias %s\n",
|
||||
mem->name));
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the domain builtin list.
|
||||
|
||||
when we are a PDC or BDC, then unix groups that are explicitly NOT mapped
|
||||
to builtin aliases are treated as DOMAIN groups (see groupunix.c).
|
||||
|
||||
when we are a member of a domain (not a PDC or BDC) then unix groups
|
||||
that are explicitly NOT mapped to builtin aliases are treated
|
||||
as LOCAL groups.
|
||||
|
||||
the reasoning behind this is to make it as simple as possible (not an easy
|
||||
task) for people to set up a domain-aware samba server, in each role that
|
||||
the server can take.
|
||||
|
||||
*************************************************************************/
|
||||
static LOCAL_GRP *getbltunixpwent(void *vp, LOCAL_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
/* Static buffers we will return. */
|
||||
static LOCAL_GRP gp_buf;
|
||||
struct group unix_grp;
|
||||
struct unix_entries *grps = (struct unix_entries *)vp;
|
||||
|
||||
if (grps == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lp_server_role() == ROLE_DOMAIN_NONE)
|
||||
{
|
||||
/*
|
||||
* no domain role, no domain aliases (or domain groups,
|
||||
* but that's dealt with by groupdb...).
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bidb_init_blt(&gp_buf);
|
||||
|
||||
/* get array of unix names + gids. this function does NOT
|
||||
get a copy of the unix group members
|
||||
*/
|
||||
|
||||
/* cycle through unix groups */
|
||||
for (; grps->grp_idx < grps->num_grps; grps->grp_idx++)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
fstring sid_str;
|
||||
|
||||
memcpy(&unix_grp, &grps->grps[grps->grp_idx], sizeof(unix_grp));
|
||||
|
||||
DEBUG(10,("getgrpunixpwent: enum unix group entry %s\n",
|
||||
unix_grp.gr_name));
|
||||
|
||||
if (!lookupsmbgrpgid(unix_grp.gr_gid, &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_to_string(sid_str, &gmep.sid);
|
||||
DEBUG(10,("group %s found, sid %s type %d\n",
|
||||
gmep.nt_name, sid_str, gmep.type));
|
||||
|
||||
if (gmep.type != SID_NAME_ALIAS)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_split_rid(&gmep.sid, &gp_buf.rid);
|
||||
if (!sid_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fstrcpy(gp_buf.name, gmep.nt_name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (grps->grp_idx >= grps->num_grps)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get the user's domain aliases. there are a maximum of 32 */
|
||||
|
||||
if (mem != NULL && num_mem != NULL)
|
||||
{
|
||||
(*mem) = NULL;
|
||||
(*num_mem) = 0;
|
||||
|
||||
memcpy(&unix_grp, getgrgid(unix_grp.gr_gid), sizeof(unix_grp));
|
||||
get_unixbuiltin_members(&unix_grp, num_mem, mem);
|
||||
}
|
||||
|
||||
{
|
||||
pstring linebuf;
|
||||
make_alias_line(linebuf, sizeof(linebuf), &gp_buf, mem, num_mem);
|
||||
DEBUG(10,("line: '%s'\n", linebuf));
|
||||
}
|
||||
|
||||
grps->grp_idx++; /* advance so next enum gets next entry */
|
||||
return &gp_buf;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add an entry to the bltpasswd file.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL add_bltunixgrp_entry(LOCAL_GRP *newblt)
|
||||
{
|
||||
DEBUG(0, ("add_bltunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search the bltpasswd file for an entry matching the builtinname.
|
||||
and then modify its builtin entry.
|
||||
************************************************************************/
|
||||
|
||||
static BOOL mod_bltunixgrp_entry(LOCAL_GRP* blt)
|
||||
{
|
||||
DEBUG(0, ("mod_bltunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add a member to an entry to the bltpasswd file.
|
||||
*************************************************************************/
|
||||
static BOOL add_bltunixgrp_member(uint32 rid, DOM_SID *member_sid)
|
||||
{
|
||||
DEBUG(0, ("add_bltunixgrp_member: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to delete a member from an entry to the bltpasswd file.
|
||||
*************************************************************************/
|
||||
static BOOL del_bltunixgrp_member(uint32 rid, DOM_SID *member_sid)
|
||||
{
|
||||
DEBUG(0, ("del_bltunixgrp_member: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
static struct aliasdb_ops unix_ops =
|
||||
{
|
||||
startbltunixpwent,
|
||||
endbltunixpwent,
|
||||
getbltunixpwpos,
|
||||
setbltunixpwpos,
|
||||
|
||||
iterate_getbuiltinntnam, /* In builtindb.c */
|
||||
iterate_getbuiltingid, /* In builtindb.c */
|
||||
iterate_getbuiltinrid, /* In builtindb.c */
|
||||
getbltunixpwent,
|
||||
|
||||
add_bltunixgrp_entry,
|
||||
mod_bltunixgrp_entry,
|
||||
NULL, /* deliberately NULL: you can't delete builtin aliases */
|
||||
|
||||
add_bltunixgrp_member,
|
||||
del_bltunixgrp_member,
|
||||
|
||||
iterate_getuserbuiltinntnam /* in builtindb.c */
|
||||
};
|
||||
|
||||
struct aliasdb_ops *unix_initialise_builtin_db(void)
|
||||
{
|
||||
return &unix_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
|
||||
void unix_bltpass_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif /* USE_SMBPASS_DB */
|
@ -1,436 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.0.
|
||||
LDAP domain group database for SAMBA
|
||||
Copyright (C) Matthew Chapman 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"
|
||||
|
||||
#ifdef WITH_LDAP
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern DOM_SID global_sam_sid;
|
||||
|
||||
/* Internal state */
|
||||
extern LDAP *ldap_struct;
|
||||
extern LDAPMessage *ldap_results;
|
||||
extern LDAPMessage *ldap_entry;
|
||||
|
||||
/* Static structure filled for requests */
|
||||
static DOMAIN_GRP domgrp;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Get group and membership information.
|
||||
****************************************************************/
|
||||
|
||||
static DOMAIN_GRP *ldapgroup_getgrp(DOMAIN_GRP *group,
|
||||
DOMAIN_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring temp;
|
||||
char **values;
|
||||
DOMAIN_GRP_MEMBER *memblist;
|
||||
char *value, *sep;
|
||||
int i;
|
||||
|
||||
if(!ldap_entry)
|
||||
return NULL;
|
||||
|
||||
if(!ldap_get_attribute("cn", group->name)) {
|
||||
DEBUG(0, ("Missing cn\n"));
|
||||
return NULL; }
|
||||
|
||||
DEBUG(2,("Retrieving group [%s]\n", group->name));
|
||||
|
||||
if(ldap_get_attribute("rid", temp)) {
|
||||
group->rid = strtol(temp, NULL, 16);
|
||||
} else {
|
||||
DEBUG(0, ("Missing rid\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!ldap_get_attribute("description", group->comment))
|
||||
group->comment[0] = 0;
|
||||
|
||||
group->attr = 0x7;
|
||||
|
||||
if(!members || !num_membs) {
|
||||
ldap_entry = ldap_next_entry(ldap_struct, ldap_entry);
|
||||
return group;
|
||||
}
|
||||
|
||||
if(values = ldap_get_values(ldap_struct, ldap_entry, "member")) {
|
||||
|
||||
*num_membs = i = ldap_count_values(values);
|
||||
*members = memblist = malloc(i * sizeof(DOMAIN_GRP_MEMBER));
|
||||
|
||||
do {
|
||||
value = values[--i];
|
||||
|
||||
if(!(sep = strchr(value, ','))) {
|
||||
DEBUG(0, ("Malformed group member\n"));
|
||||
return NULL;
|
||||
}
|
||||
*(sep++) = 0;
|
||||
fstrcpy(memblist[i].name, value);
|
||||
|
||||
if(!(value = strchr(sep, ','))) {
|
||||
DEBUG(0, ("Malformed group member\n"));
|
||||
return NULL;
|
||||
}
|
||||
memblist[i].rid = strtol(sep, &value, 16);
|
||||
|
||||
if((memblist[i].sid_use = atoi(value+1))
|
||||
>= SID_NAME_UNKNOWN)
|
||||
DEBUG(0, ("Invalid SID use in group"));
|
||||
|
||||
memblist[i].attr = 0x7;
|
||||
|
||||
} while(i > 0);
|
||||
|
||||
ldap_value_free(values);
|
||||
|
||||
} else {
|
||||
*num_membs = 0;
|
||||
*members = NULL;
|
||||
}
|
||||
|
||||
ldap_entry = ldap_next_entry(ldap_struct, ldap_entry);
|
||||
return group;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Queues the necessary modifications to save a DOMAIN_GRP structure
|
||||
************************************************************************/
|
||||
|
||||
static void ldapgroup_grpmods(DOMAIN_GRP *group, LDAPMod ***mods,
|
||||
int operation)
|
||||
{
|
||||
fstring temp;
|
||||
|
||||
*mods = NULL;
|
||||
|
||||
if(operation == LDAP_MOD_ADD) { /* immutable attributes */
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "objectClass", "sambaGroup");
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "cn", group->name);
|
||||
|
||||
slprintf(temp, sizeof(temp)-1, "%x", group->rid);
|
||||
ldap_make_mod(mods, LDAP_MOD_ADD, "rid", temp);
|
||||
}
|
||||
|
||||
ldap_make_mod(mods, operation, "description", group->comment);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Create a group member entry
|
||||
************************************************************************/
|
||||
|
||||
static BOOL ldapgroup_memmods(uint32 user_rid, LDAPMod ***mods, int operation)
|
||||
{
|
||||
pstring member;
|
||||
fstring name;
|
||||
DOM_SID sid;
|
||||
uint8 type;
|
||||
|
||||
sid_copy(&sid, &global_sam_sid);
|
||||
sid_append_rid(&sid, user_rid);
|
||||
if (lookup_sid(&sid, name, &type))
|
||||
return (False);
|
||||
|
||||
slprintf(member, sizeof(member)-1, "%s,%x,%d", name, user_rid, type);
|
||||
|
||||
*mods = NULL;
|
||||
ldap_make_mod(mods, operation, "member", member);
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Begin/end domain group enumeration.
|
||||
****************************************************************/
|
||||
|
||||
static void *ldapgroup_enumfirst(BOOL update)
|
||||
{
|
||||
int server_role = lp_server_role();
|
||||
|
||||
if (server_role == ROLE_DOMAIN_NONE ||
|
||||
server_role == ROLE_DOMAIN_MEMBER)
|
||||
return NULL;
|
||||
|
||||
if (!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_for("objectclass=sambaGroup");
|
||||
|
||||
return ldap_struct;
|
||||
}
|
||||
|
||||
static void ldapgroup_enumclose(void *vp)
|
||||
{
|
||||
ldap_disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Save/restore the current position in a query
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT ldapgroup_getdbpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)((ulong)ldap_entry);
|
||||
}
|
||||
|
||||
static BOOL ldapgroup_setdbpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
ldap_entry = (LDAPMessage *)((ulong)tok);
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return information about domain groups and their members.
|
||||
*************************************************************************/
|
||||
|
||||
static DOMAIN_GRP *ldapgroup_getgrpbynam(const char *name,
|
||||
DOMAIN_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
DOMAIN_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(cn=%s*)(objectClass=sambaGroup))", name);
|
||||
ldap_search_for(filter);
|
||||
|
||||
ret = ldapgroup_getgrp(&domgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DOMAIN_GRP *ldapgroup_getgrpbygid(gid_t grp_id,
|
||||
DOMAIN_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
DOMAIN_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(gidNumber=%d)(objectClass=sambaGroup))", grp_id);
|
||||
ldap_search_for(filter);
|
||||
|
||||
ret = ldapgroup_getgrp(&domgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DOMAIN_GRP *ldapgroup_getgrpbyrid(uint32 grp_rid,
|
||||
DOMAIN_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
fstring filter;
|
||||
DOMAIN_GRP *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectClass=sambaGroup))", grp_rid);
|
||||
ldap_search_for(filter);
|
||||
|
||||
ret = ldapgroup_getgrp(&domgrp, members, num_membs);
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static DOMAIN_GRP *ldapgroup_getcurrentgrp(void *vp,
|
||||
DOMAIN_GRP_MEMBER **members, int *num_membs)
|
||||
{
|
||||
return ldapgroup_getgrp(&domgrp, members, num_membs);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Add/modify/delete domain groups.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapgroup_addgrp(DOMAIN_GRP *group)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
if (!ldap_allocaterid(&group->rid))
|
||||
{
|
||||
DEBUG(0,("RID generation failed\n"));
|
||||
return (False);
|
||||
}
|
||||
|
||||
ldapgroup_grpmods(group, &mods, LDAP_MOD_ADD);
|
||||
return ldap_makemods("cn", group->name, mods, True);
|
||||
}
|
||||
|
||||
static BOOL ldapgroup_modgrp(DOMAIN_GRP *group)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
ldapgroup_grpmods(group, &mods, LDAP_MOD_REPLACE);
|
||||
return ldap_makemods("cn", group->name, mods, False);
|
||||
}
|
||||
|
||||
static BOOL ldapgroup_delgrp(uint32 grp_rid)
|
||||
{
|
||||
fstring filter;
|
||||
char *dn;
|
||||
int err;
|
||||
|
||||
if (!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectClass=sambaGroup))", grp_rid);
|
||||
ldap_search_for(filter);
|
||||
|
||||
if (!ldap_entry || !(dn = ldap_get_dn(ldap_struct, ldap_entry)))
|
||||
{
|
||||
ldap_disconnect();
|
||||
return (False);
|
||||
}
|
||||
|
||||
err = ldap_delete_s(ldap_struct, dn);
|
||||
free(dn);
|
||||
ldap_disconnect();
|
||||
|
||||
if (err != LDAP_SUCCESS)
|
||||
{
|
||||
DEBUG(0, ("delete: %s\n", ldap_err2string(err)));
|
||||
return (False);
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Add users to/remove users from groups.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapgroup_addmem(uint32 grp_rid, uint32 user_rid)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
fstring rid_str;
|
||||
|
||||
slprintf(rid_str, sizeof(rid_str)-1, "%x", grp_rid);
|
||||
|
||||
if(!ldapgroup_memmods(user_rid, &mods, LDAP_MOD_ADD))
|
||||
return (False);
|
||||
|
||||
return ldap_makemods("rid", rid_str, mods, False);
|
||||
}
|
||||
|
||||
static BOOL ldapgroup_delmem(uint32 grp_rid, uint32 user_rid)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
fstring rid_str;
|
||||
|
||||
slprintf(rid_str, sizeof(rid_str)-1, "%x", grp_rid);
|
||||
|
||||
if(!ldapgroup_memmods(user_rid, &mods, LDAP_MOD_DELETE))
|
||||
return (False);
|
||||
|
||||
return ldap_makemods("rid", rid_str, mods, False);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return domain groups that a user is in.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapgroup_getusergroups(const char *name, DOMAIN_GRP **groups,
|
||||
int *num_grps)
|
||||
{
|
||||
DOMAIN_GRP *grouplist;
|
||||
fstring filter;
|
||||
int i;
|
||||
|
||||
if(!ldap_connect())
|
||||
return (False);
|
||||
|
||||
slprintf(filter, sizeof(pstring)-1,
|
||||
"(&(member=%s,*)(objectclass=sambaGroup))", name);
|
||||
ldap_search_for(filter);
|
||||
|
||||
*num_grps = i = ldap_count_entries(ldap_struct, ldap_results);
|
||||
|
||||
if(!i) {
|
||||
*groups = NULL;
|
||||
ldap_disconnect();
|
||||
return (True);
|
||||
}
|
||||
|
||||
*groups = grouplist = malloc(i * sizeof(DOMAIN_GRP));
|
||||
do {
|
||||
i--;
|
||||
} while(ldapgroup_getgrp(&grouplist[i], NULL, NULL) && (i > 0));
|
||||
|
||||
ldap_disconnect();
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
static struct groupdb_ops ldapgroup_ops =
|
||||
{
|
||||
ldapgroup_enumfirst,
|
||||
ldapgroup_enumclose,
|
||||
ldapgroup_getdbpos,
|
||||
ldapgroup_setdbpos,
|
||||
|
||||
ldapgroup_getgrpbynam,
|
||||
ldapgroup_getgrpbygid,
|
||||
ldapgroup_getgrpbyrid,
|
||||
ldapgroup_getcurrentgrp,
|
||||
|
||||
ldapgroup_addgrp,
|
||||
ldapgroup_modgrp,
|
||||
ldapgroup_delgrp,
|
||||
|
||||
ldapgroup_addmem,
|
||||
ldapgroup_delmem,
|
||||
|
||||
ldapgroup_getusergroups
|
||||
};
|
||||
|
||||
struct groupdb_ops *ldap_initialise_group_db(void)
|
||||
{
|
||||
return &ldapgroup_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void groupldap_dummy_function(void);
|
||||
void groupldap_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif
|
||||
|
@ -1,339 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef USE_SMBUNIX_DB
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
extern DOM_SID global_sam_sid;
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the grppasswd list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
****************************************************************/
|
||||
|
||||
struct unix_entries
|
||||
{
|
||||
struct group *grps;
|
||||
int num_grps;
|
||||
int grp_idx;
|
||||
};
|
||||
|
||||
static void *startgrpunixpwent(BOOL update)
|
||||
{
|
||||
struct unix_entries *grps;
|
||||
grps = (struct unix_entries*)malloc(sizeof(struct unix_entries));
|
||||
|
||||
if (grps == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!get_unix_grps(&grps->num_grps, &grps->grps))
|
||||
{
|
||||
free(grps);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grps->grp_idx = 0;
|
||||
|
||||
return (void*)grps;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the grppasswd list.
|
||||
****************************************************************/
|
||||
|
||||
static void endgrpunixpwent(void *vp)
|
||||
{
|
||||
struct unix_entries *grps = (struct unix_entries *)vp;
|
||||
|
||||
if (grps != NULL)
|
||||
{
|
||||
free_unix_grps(grps->num_grps, grps->grps);
|
||||
free(vp);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Return the current position in the grppasswd list as an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
static SMB_BIG_UINT getgrpunixpwpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Set the current position in the grppasswd list from an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
static BOOL setgrpunixpwpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the smbdomaingroup list.
|
||||
*************************************************************************/
|
||||
BOOL get_unixgroup_members(struct group *grp,
|
||||
int *num_mem, DOMAIN_GRP_MEMBER **members)
|
||||
{
|
||||
int i;
|
||||
char *unix_name;
|
||||
|
||||
if (num_mem == NULL || members == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
(*num_mem) = 0;
|
||||
(*members) = NULL;
|
||||
|
||||
for (i = 0; (unix_name = grp->gr_mem[i]) != NULL; i++)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
DOMAIN_GRP_MEMBER *mem;
|
||||
uint32 rid;
|
||||
|
||||
if (!lookupsmbpwnam (unix_name, &gmep) &&
|
||||
!lookupsmbgrpnam(unix_name, &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gmep.type != SID_NAME_DOM_GRP &&
|
||||
gmep.type != SID_NAME_USER &&
|
||||
gmep.type != SID_NAME_WKN_GRP)
|
||||
{
|
||||
DEBUG(0,("group database: name %s is not in a Domain Group\n",
|
||||
unix_name));
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_split_rid(&gmep.sid, &rid);
|
||||
if (!sid_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
DEBUG(0,("group database: could not resolve name %s (wrong Domain SID)\n",
|
||||
unix_name));
|
||||
continue;
|
||||
}
|
||||
|
||||
(*members) = Realloc((*members), ((*num_mem)+1) * sizeof(DOMAIN_GRP_MEMBER));
|
||||
if ((*members) == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
mem = &(*members)[(*num_mem)];
|
||||
(*num_mem)++;
|
||||
|
||||
fstrcpy(mem->name, gmep.nt_name);
|
||||
mem->attr = 0x07;
|
||||
mem->sid_use = gmep.type;
|
||||
mem->rid = rid;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the domain group list.
|
||||
|
||||
if we are not a PDC or BDC, then we do NOT support Domain groups, only
|
||||
aliases. try running MUSRMGR.EXE or running USRMGR.EXE selected on a
|
||||
workstation, you will find that no Domain groups are listed: only aliases.
|
||||
|
||||
so, as a PDC or BDC, all unix groups not explicitly mapped using
|
||||
map_group_gid() are treated as Domain groups.
|
||||
|
||||
*************************************************************************/
|
||||
static DOMAIN_GRP *getgrpunixpwent(void *vp, DOMAIN_GRP_MEMBER **mem, int *num_mem)
|
||||
{
|
||||
/* Static buffers we will return. */
|
||||
static DOMAIN_GRP gp_buf;
|
||||
struct group unix_grp;
|
||||
struct unix_entries *grps = (struct unix_entries *)vp;
|
||||
|
||||
if (grps == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lp_server_role() == ROLE_DOMAIN_NONE ||
|
||||
lp_server_role() == ROLE_DOMAIN_MEMBER)
|
||||
{
|
||||
/*
|
||||
* only PDC and BDC have domain groups in the SAM.
|
||||
* (however as member of domain you can have LOCAL groups,
|
||||
* but that's dealt with in the aliasdb...)
|
||||
*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gpdb_init_grp(&gp_buf);
|
||||
|
||||
fstrcpy(gp_buf.comment, "");
|
||||
gp_buf.attr = 0x07;
|
||||
|
||||
/* get array of unix names + gids. this function does NOT
|
||||
get a copy of the unix group members
|
||||
*/
|
||||
|
||||
/* cycle through unix groups */
|
||||
for (; grps->grp_idx < grps->num_grps; grps->grp_idx++)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
|
||||
memcpy(&unix_grp, &grps->grps[grps->grp_idx], sizeof(unix_grp));
|
||||
|
||||
DEBUG(10,("getgrpunixpwent: enum unix group entry %s\n",
|
||||
unix_grp.gr_name));
|
||||
|
||||
if (!lookupsmbgrpgid(unix_grp.gr_gid, &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gmep.type != SID_NAME_DOM_GRP &&
|
||||
gmep.type != SID_NAME_WKN_GRP)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_split_rid(&gmep.sid, &gp_buf.rid);
|
||||
if (!sid_equal(&gmep.sid, &global_sam_sid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fstrcpy(gp_buf.name, gmep.nt_name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (grps->grp_idx >= grps->num_grps)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get the user's domain groups. there are a maximum of 32 */
|
||||
|
||||
if (mem != NULL && num_mem != NULL)
|
||||
{
|
||||
(*mem) = NULL;
|
||||
(*num_mem) = 0;
|
||||
|
||||
memcpy(&unix_grp, getgrgid(unix_grp.gr_gid), sizeof(unix_grp));
|
||||
get_unixgroup_members(&unix_grp, num_mem, mem);
|
||||
}
|
||||
|
||||
{
|
||||
pstring linebuf;
|
||||
make_group_line(linebuf, sizeof(linebuf), &gp_buf, mem, num_mem);
|
||||
DEBUG(10,("line: '%s'\n", linebuf));
|
||||
}
|
||||
|
||||
grps->grp_idx++; /* advance so next enum gets next entry */
|
||||
return &gp_buf;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add an entry to the grppasswd file.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL add_grpunixgrp_entry(DOMAIN_GRP *newgrp)
|
||||
{
|
||||
DEBUG(0, ("add_grpunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search database for entry matching the groupname and/or rid.
|
||||
and then modify its group entry.
|
||||
************************************************************************/
|
||||
|
||||
static BOOL mod_grpunixgrp_entry(DOMAIN_GRP* grp)
|
||||
{
|
||||
DEBUG(0, ("mod_grpunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search the grppasswd file for an entry matching the rid.
|
||||
and then delete it.
|
||||
************************************************************************/
|
||||
|
||||
static BOOL del_grpunixgrp_entry(uint32 rid)
|
||||
{
|
||||
DEBUG(0, ("del_grpunixgrp_entry: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to add a member to an entry to the grppasswd file.
|
||||
*************************************************************************/
|
||||
static BOOL add_grpunixgrp_member(uint32 rid, uint32 member_rid)
|
||||
{
|
||||
DEBUG(0, ("add_grpunixgrp_member: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to delete a member from an entry to the grppasswd file.
|
||||
*************************************************************************/
|
||||
static BOOL del_grpunixgrp_member(uint32 rid, uint32 member_rid)
|
||||
{
|
||||
DEBUG(0, ("del_grpunixgrp_member: NOT IMPLEMENTED\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
static struct groupdb_ops unix_ops =
|
||||
{
|
||||
startgrpunixpwent,
|
||||
endgrpunixpwent,
|
||||
getgrpunixpwpos,
|
||||
setgrpunixpwpos,
|
||||
|
||||
iterate_getgroupntnam, /* In groupdb.c */
|
||||
iterate_getgroupgid, /* In groupdb.c */
|
||||
iterate_getgrouprid, /* In groupdb.c */
|
||||
getgrpunixpwent,
|
||||
|
||||
add_grpunixgrp_entry,
|
||||
mod_grpunixgrp_entry,
|
||||
del_grpunixgrp_entry,
|
||||
|
||||
add_grpunixgrp_member,
|
||||
del_grpunixgrp_member,
|
||||
|
||||
iterate_getusergroupsnam /* in groupdb.c */
|
||||
};
|
||||
|
||||
struct groupdb_ops *unix_initialise_group_db(void)
|
||||
{
|
||||
return &unix_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
|
||||
void unix_grppass_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif /* USE_SMBPASS_DB */
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
service (connection) opening and closing
|
||||
Copyright (C) Andrew Tridgell 1992-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.
|
||||
*/
|
||||
|
||||
|
||||
#define DESKTOPDB_FOLDER "./.streams/.DesktopDBFolder/"
|
||||
#define DESKTOPDB_DF_PATH "./.streams/.DesktopDBFolder/DesktopDF"
|
||||
#define THE_ZERO_DB_ENTRY "ZERO_DB"
|
||||
|
||||
typedef struct IconKey
|
||||
{
|
||||
uint32 ftype; /* The file type */
|
||||
uint32 isize; /* Size of the Icon */
|
||||
uint16 itype; /* Icon Type */
|
||||
} IconKey;
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB debug stuff
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Copyright (C) John H Terpstra 1996-1998
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
|
||||
Copyright (C) Paul Ashton 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.
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_H
|
||||
#define _DEBUG_H
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* Debugging code. See also debug.c
|
||||
*/
|
||||
|
||||
/* mkproto.awk has trouble with ifdef'd function definitions (it ignores
|
||||
* the #ifdef directive and will read both definitions, thus creating two
|
||||
* diffferent prototype declarations), so we must do these by hand.
|
||||
*/
|
||||
/* I know the __attribute__ stuff is ugly, but it does ensure we get the
|
||||
arguemnts to DEBUG() right. We have got them wrong too often in the
|
||||
past.
|
||||
*/
|
||||
#ifdef HAVE_STDARG_H
|
||||
int Debug1( char *, ... )
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
BOOL dbgtext( char *, ... )
|
||||
#ifdef __GNUC__
|
||||
__attribute__ ((format (printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
#else
|
||||
int Debug1();
|
||||
BOOL dbgtext();
|
||||
#endif
|
||||
|
||||
/* If we have these macros, we can add additional info to the header. */
|
||||
#ifdef HAVE_FILE_MACRO
|
||||
#define FILE_MACRO (__FILE__)
|
||||
#else
|
||||
#define FILE_MACRO ("")
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FUNCTION_MACRO
|
||||
#define FUNCTION_MACRO (__FUNCTION__)
|
||||
#else
|
||||
#define FUNCTION_MACRO ("")
|
||||
#endif
|
||||
|
||||
/* Debugging macros.
|
||||
* DEBUGLVL() - If level is <= the system-wide DEBUGLEVEL then generate a
|
||||
* header using the default macros for file, line, and
|
||||
* function name.
|
||||
* Returns True if the debug level was <= DEBUGLEVEL.
|
||||
* Example usage:
|
||||
* if( DEBUGLVL( 2 ) )
|
||||
* dbgtext( "Some text.\n" );
|
||||
* DEGUG() - Good old DEBUG(). Each call to DEBUG() will generate a new
|
||||
* header *unless* the previous debug output was unterminated
|
||||
* (i.e., no '\n'). See debug.c:dbghdr() for more info.
|
||||
* Example usage:
|
||||
* DEBUG( 2, ("Some text.\n") );
|
||||
* DEBUGADD() - If level <= DEBUGLEVEL, then the text is appended to the
|
||||
* current message (i.e., no header).
|
||||
* Usage:
|
||||
* DEBUGADD( 2, ("Some additional text.\n") );
|
||||
*/
|
||||
#define DEBUGLVL( level ) \
|
||||
( (DEBUGLEVEL >= (level)) \
|
||||
&& dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
|
||||
|
||||
#define DEBUG( level, body ) \
|
||||
(void)( (DEBUGLEVEL >= (level)) \
|
||||
&& (dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) )) \
|
||||
&& (dbgtext body) )
|
||||
|
||||
#define DEBUGADD( level, body ) \
|
||||
(void)( (DEBUGLEVEL >= (level)) && (dbgtext body) )
|
||||
|
||||
/* -------------------------------------------------------------------------- **
|
||||
* These are the tokens returned by dbg_char2token().
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
dbg_null = 0,
|
||||
dbg_ignore,
|
||||
dbg_header,
|
||||
dbg_timestamp,
|
||||
dbg_level,
|
||||
dbg_sourcefile,
|
||||
dbg_function,
|
||||
dbg_lineno,
|
||||
dbg_message,
|
||||
dbg_eof
|
||||
} dbg_Token;
|
||||
|
||||
/* End Debugging code section.
|
||||
* -------------------------------------------------------------------------- **
|
||||
*/
|
||||
|
||||
#endif
|
@ -1,53 +0,0 @@
|
||||
|
||||
typedef struct _referal_trans_param
|
||||
{
|
||||
uint16 level;
|
||||
char directory[255];
|
||||
uint16 type;
|
||||
} referal_trans_param;
|
||||
|
||||
typedef struct _referal_ver_2
|
||||
{
|
||||
uint16 version;
|
||||
uint16 size;
|
||||
uint16 server_type;
|
||||
uint16 flags;
|
||||
uint32 proximity;
|
||||
uint32 ttl;
|
||||
uint16 filename_offset;
|
||||
uint16 mangledname_offset;
|
||||
uint16 sharename_offset;
|
||||
char sharename[255];
|
||||
} referal_ver_2;
|
||||
|
||||
typedef struct _dfs_response
|
||||
{
|
||||
uint16 path_consumed;
|
||||
uint16 number_of_referal;
|
||||
uint32 server_function;
|
||||
referal_ver_2 *referal;
|
||||
char filename[255];
|
||||
char mangledname[255];
|
||||
struct _dfs_response *next;
|
||||
} dfs_response;
|
||||
|
||||
|
||||
typedef struct _dfs_internal_table
|
||||
{
|
||||
pstring localpath;
|
||||
pstring mangledpath;
|
||||
pstring sharename;
|
||||
unsigned int proximity;
|
||||
unsigned int type;
|
||||
int localpath_length;
|
||||
int mangledpath_length;
|
||||
int sharename_length;
|
||||
} dfs_internal_table;
|
||||
|
||||
typedef struct _dfs_internal
|
||||
{
|
||||
|
||||
dfs_internal_table *table;
|
||||
int size;
|
||||
BOOL ready;
|
||||
} dfs_internal;
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Interface header: Scheduler service
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
|
||||
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 _HMAC_MD5_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
uchar k_ipad[65];
|
||||
uchar k_opad[65];
|
||||
|
||||
} HMACMD5Context;
|
||||
|
||||
#endif /* _HMAC_MD5_H */
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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 MD5_H
|
||||
#define MD5_H
|
||||
|
||||
struct MD5Context
|
||||
{
|
||||
uint32 buf[4];
|
||||
uint32 bits[2];
|
||||
uchar in[64];
|
||||
};
|
||||
|
||||
#endif /* !MD5_H */
|
@ -1,102 +0,0 @@
|
||||
typedef struct nt_printer_driver_info_level_3
|
||||
{
|
||||
uint32 cversion;
|
||||
|
||||
fstring name;
|
||||
fstring environment;
|
||||
fstring driverpath;
|
||||
fstring datafile;
|
||||
fstring configfile;
|
||||
fstring helpfile;
|
||||
fstring monitorname;
|
||||
fstring defaultdatatype;
|
||||
char **dependentfiles;
|
||||
|
||||
} NT_PRINTER_DRIVER_INFO_LEVEL_3;
|
||||
|
||||
typedef struct nt_printer_driver_info_level
|
||||
{
|
||||
NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3;
|
||||
} NT_PRINTER_DRIVER_INFO_LEVEL;
|
||||
|
||||
typedef struct nt_printer_param
|
||||
{
|
||||
fstring value;
|
||||
uint32 type;
|
||||
uint8 *data;
|
||||
int data_len;
|
||||
struct nt_printer_param *next;
|
||||
} NT_PRINTER_PARAM;
|
||||
|
||||
typedef struct ntdevicemode
|
||||
{
|
||||
fstring devicename;
|
||||
uint16 specversion;
|
||||
uint16 driverversion;
|
||||
uint16 size;
|
||||
uint16 driverextra;
|
||||
uint32 fields;
|
||||
uint16 orientation;
|
||||
uint16 papersize;
|
||||
uint16 paperlength;
|
||||
uint16 paperwidth;
|
||||
uint16 scale;
|
||||
uint16 copies;
|
||||
uint16 defaultsource;
|
||||
uint16 printquality;
|
||||
uint16 color;
|
||||
uint16 duplex;
|
||||
uint16 yresolution;
|
||||
uint16 ttoption;
|
||||
uint16 collate;
|
||||
fstring formname;
|
||||
uint16 logpixels;
|
||||
uint32 bitsperpel;
|
||||
uint32 pelswidth;
|
||||
uint32 pelsheight;
|
||||
uint32 displayflags;
|
||||
uint32 displayfrequency;
|
||||
uint32 icmmethod;
|
||||
uint32 icmintent;
|
||||
uint32 mediatype;
|
||||
uint32 dithertype;
|
||||
uint32 reserved1;
|
||||
uint32 reserved2;
|
||||
uint32 panningwidth;
|
||||
uint32 panningheight;
|
||||
uint8 *private;
|
||||
} NT_DEVICEMODE;
|
||||
|
||||
typedef struct nt_printer_info_level_2
|
||||
{
|
||||
uint32 attributes;
|
||||
uint32 priority;
|
||||
uint32 default_priority;
|
||||
uint32 starttime;
|
||||
uint32 untiltime;
|
||||
uint32 status;
|
||||
uint32 cjobs;
|
||||
uint32 averageppm;
|
||||
fstring servername;
|
||||
fstring printername;
|
||||
fstring sharename;
|
||||
fstring portname;
|
||||
fstring drivername;
|
||||
fstring comment;
|
||||
fstring location;
|
||||
NT_DEVICEMODE *devmode;
|
||||
fstring sepfile;
|
||||
fstring printprocessor;
|
||||
fstring datatype;
|
||||
fstring parameters;
|
||||
NT_PRINTER_PARAM *specific;
|
||||
/* SEC_DESC_BUF *secdesc; */
|
||||
/* not used but ... and how ??? */
|
||||
} NT_PRINTER_INFO_LEVEL_2;
|
||||
|
||||
typedef struct nt_printer_info_level
|
||||
{
|
||||
NT_PRINTER_INFO_LEVEL_2 *info_2;
|
||||
} NT_PRINTER_INFO_LEVEL;
|
||||
|
||||
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Interface header: Scheduler service
|
||||
Copyright (C) Matthew Chapman 1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
|
||||
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 _RPC_ATSVC_H
|
||||
#define _RPC_ATSVC_H
|
||||
|
||||
#define AT_ADD_JOB 0x00
|
||||
#define AT_DEL_JOB 0x01
|
||||
#define AT_ENUM_JOBS 0x02
|
||||
#define AT_QUERY_JOB 0x03
|
||||
|
||||
|
||||
#define JOB_PERIODIC 0x01
|
||||
#define JOB_EXEC_ERR 0x02
|
||||
#define JOB_RUNS_TODAY 0x04
|
||||
#define JOB_INCLUDE_TODAY 0x08
|
||||
#define JOB_NONINTERACTIVE 0x10
|
||||
|
||||
/* AT_JOB_INFO */
|
||||
typedef struct at_job_info_info
|
||||
{
|
||||
uint32 time; /* milliseconds after midnight */
|
||||
uint32 monthdays; /* bitmask of days of month */
|
||||
uint8 weekdays; /* bitmask of days of week */
|
||||
uint8 flags; /* JOB_xx */
|
||||
|
||||
uint32 ptr_command;
|
||||
|
||||
} AT_JOB_INFO;
|
||||
|
||||
/* AT_Q_ADD_JOB */
|
||||
typedef struct q_at_add_job_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
AT_JOB_INFO info;
|
||||
UNISTR2 command;
|
||||
|
||||
} AT_Q_ADD_JOB;
|
||||
|
||||
/* AT_R_ADD_JOB */
|
||||
typedef struct r_at_add_job_info
|
||||
{
|
||||
uint32 jobid;
|
||||
uint32 status;
|
||||
|
||||
} AT_R_ADD_JOB;
|
||||
|
||||
|
||||
/* AT_Q_DEL_JOB */
|
||||
typedef struct q_at_del_job_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
uint32 min_jobid;
|
||||
uint32 max_jobid;
|
||||
|
||||
} AT_Q_DEL_JOB;
|
||||
|
||||
/* AT_R_DEL_JOB */
|
||||
typedef struct r_at_del_job_info
|
||||
{
|
||||
uint32 status;
|
||||
|
||||
} AT_R_DEL_JOB;
|
||||
|
||||
|
||||
/* AT_Q_ENUM_JOBS */
|
||||
typedef struct q_at_enum_jobs_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
uint32 unknown0; /* 0 */
|
||||
uint32 unknown1; /* 0 */
|
||||
uint32 max_len; /* preferred max length */
|
||||
|
||||
uint32 ptr_resume;
|
||||
uint32 hnd_resume; /* resume handle */
|
||||
|
||||
} AT_Q_ENUM_JOBS;
|
||||
|
||||
/* AT_ENUM_INFO */
|
||||
typedef struct q_at_enum_info_info
|
||||
{
|
||||
uint32 jobid;
|
||||
AT_JOB_INFO info;
|
||||
|
||||
} AT_ENUM_INFO;
|
||||
|
||||
#define AT_MAX_JOBS 256
|
||||
|
||||
/* AT_R_ENUM_JOBS */
|
||||
typedef struct r_at_enum_jobs_info
|
||||
{
|
||||
uint32 num_entries; /* entries returned */
|
||||
uint32 ptr_entries;
|
||||
uint32 num_entries2;
|
||||
|
||||
AT_ENUM_INFO info[AT_MAX_JOBS];
|
||||
UNISTR2 command[AT_MAX_JOBS];
|
||||
|
||||
uint32 total_entries; /* total entries */
|
||||
uint32 ptr_resume;
|
||||
uint32 hnd_resume; /* resume handle */
|
||||
|
||||
uint32 status;
|
||||
|
||||
} AT_R_ENUM_JOBS;
|
||||
|
||||
|
||||
/* AT_Q_QUERY_JOB */
|
||||
typedef struct q_at_query_job_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
uint32 jobid;
|
||||
|
||||
} AT_Q_QUERY_JOB;
|
||||
|
||||
/* AT_R_QUERY_JOB */
|
||||
typedef struct r_at_query_job_info
|
||||
{
|
||||
uint32 ptr_info;
|
||||
AT_JOB_INFO info;
|
||||
UNISTR2 command;
|
||||
|
||||
uint32 status;
|
||||
|
||||
} AT_R_QUERY_JOB;
|
||||
|
||||
#endif /* _RPC_ATSVC_H */
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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 _RPC_BRS_H /* _RPC_BRS_H */
|
||||
#define _RPC_BRS_H
|
||||
|
||||
|
||||
/* brssvc pipe */
|
||||
#define BRS_QUERY_INFO 0x02
|
||||
|
||||
|
||||
/* BRS_Q_QUERY_INFO - probably a capabilities request */
|
||||
typedef struct q_brs_query_info_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
|
||||
|
||||
uint16 switch_value1; /* info level 100 (0x64) */
|
||||
/* align */
|
||||
uint16 switch_value2; /* info level 100 (0x64) */
|
||||
|
||||
uint32 ptr;
|
||||
uint32 pad1;
|
||||
uint32 pad2;
|
||||
|
||||
} BRS_Q_QUERY_INFO;
|
||||
|
||||
|
||||
/* BRS_INFO_100 - level 100 info */
|
||||
typedef struct brs_info_100_info
|
||||
{
|
||||
uint32 pad1;
|
||||
uint32 ptr2;
|
||||
uint32 pad2;
|
||||
uint32 pad3;
|
||||
|
||||
} BRS_INFO_100;
|
||||
|
||||
|
||||
/* BRS_R_QUERY_INFO - probably a capabilities request */
|
||||
typedef struct r_brs_query_info_info
|
||||
{
|
||||
uint16 switch_value1; /* 100 (0x64) - switch value */
|
||||
/* align */
|
||||
uint16 switch_value2; /* info level 100 (0x64) */
|
||||
|
||||
/* for now, only level 100 is supported. this should be an enum container */
|
||||
uint32 ptr_1; /* pointer 1 */
|
||||
|
||||
union
|
||||
{
|
||||
BRS_INFO_100 *brs100; /* browser info level 100 */
|
||||
void *id;
|
||||
|
||||
} info;
|
||||
|
||||
uint32 status; /* return status */
|
||||
|
||||
} BRS_R_QUERY_INFO;
|
||||
|
||||
#endif /* _RPC_BRS_H */
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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 _RPC_CREDS_H /* _RPC_CREDS_H */
|
||||
#define _RPC_CREDS_H
|
||||
|
||||
typedef struct ntuser_creds
|
||||
{
|
||||
fstring user_name;
|
||||
fstring domain;
|
||||
struct pwd_info pwd;
|
||||
|
||||
uint32 ntlmssp_flags;
|
||||
|
||||
} CREDS_NT;
|
||||
|
||||
typedef struct unixuser_creds
|
||||
{
|
||||
fstring user_name;
|
||||
fstring requested_name;
|
||||
fstring real_name;
|
||||
BOOL guest;
|
||||
|
||||
} CREDS_UNIX;
|
||||
|
||||
typedef struct unixsec_creds
|
||||
{
|
||||
uint32 uid;
|
||||
uint32 gid;
|
||||
int num_grps;
|
||||
uint32 *grps;
|
||||
|
||||
} CREDS_UNIX_SEC;
|
||||
|
||||
typedef struct ntsec_creds
|
||||
{
|
||||
DOM_SID sid;
|
||||
uint32 num_grps;
|
||||
uint32 *grp_rids;
|
||||
|
||||
} CREDS_NT_SEC;
|
||||
|
||||
typedef struct user_creds
|
||||
{
|
||||
BOOL reuse;
|
||||
uint32 ptr_ntc;
|
||||
uint32 ptr_uxc;
|
||||
uint32 ptr_nts;
|
||||
uint32 ptr_uxs;
|
||||
|
||||
CREDS_NT ntc;
|
||||
CREDS_UNIX uxc;
|
||||
|
||||
CREDS_NT_SEC nts;
|
||||
CREDS_UNIX_SEC uxs;
|
||||
|
||||
|
||||
} CREDS_HYBRID;
|
||||
|
||||
typedef struct cred_command
|
||||
{
|
||||
uint16 version;
|
||||
uint16 command;
|
||||
|
||||
fstring name;
|
||||
|
||||
uint32 ptr_creds;
|
||||
CREDS_HYBRID *cred;
|
||||
|
||||
} CREDS_CMD;
|
||||
|
||||
#endif /* _RPC_CREDS_H */
|
||||
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Interface header: Scheduler service
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
|
||||
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 _RPC_EVENTLOG_H
|
||||
#define _RPC_EVENTLOG_H
|
||||
|
||||
#define EVENTLOG_OPEN 0x07
|
||||
#define EVENTLOG_CLOSE 0x02
|
||||
#define EVENTLOG_NUMOFEVENTLOGRECORDS 0x04
|
||||
#define EVENTLOG_READEVENTLOG 0x0a
|
||||
|
||||
#define EVENTLOG_READ_SEQUENTIAL 0x01
|
||||
#define EVENTLOG_READ_SEEK 0x02
|
||||
#define EVENTLOG_READ_FORWARD 0x04
|
||||
#define EVENTLOG_READ_BACKWARD 0x08
|
||||
|
||||
#define EVENTLOG_OK 0X00
|
||||
#define EVENTLOG_ERROR 0x01
|
||||
#define EVENTLOG_WARNING 0x02
|
||||
#define EVENTLOG_INFORMATION 0x04
|
||||
#define EVENTLOG_AUDIT_OK 0x08
|
||||
#define EVENTLOG_AUDIT_ERROR 0x10
|
||||
|
||||
typedef struct eventlogrecord
|
||||
{
|
||||
uint32 size;
|
||||
uint32 reserved;
|
||||
uint32 recordnumber;
|
||||
uint32 creationtime;
|
||||
uint32 writetime;
|
||||
uint32 eventnumber;
|
||||
uint16 eventtype;
|
||||
uint16 num_of_strings;
|
||||
uint16 category;
|
||||
uint16 reserved_flag;
|
||||
uint32 closingrecord;
|
||||
uint32 stringoffset;
|
||||
uint32 sid_length;
|
||||
uint32 sid_offset;
|
||||
uint32 data_length;
|
||||
uint32 data_offset;
|
||||
UNISTR sourcename;
|
||||
UNISTR computername;
|
||||
UNISTR sid;
|
||||
UNISTR strings;
|
||||
UNISTR data;
|
||||
uint32 size2;
|
||||
} EVENTLOGRECORD;
|
||||
|
||||
typedef struct eventlog_q_open
|
||||
{
|
||||
uint32 ptr0;
|
||||
|
||||
uint16 unk0;
|
||||
uint16 unk1;
|
||||
|
||||
UNIHDR hdr_source;
|
||||
UNISTR2 uni_source;
|
||||
|
||||
UNIHDR hdr_unk;
|
||||
UNISTR2 uni_unk;
|
||||
|
||||
uint32 unk6;
|
||||
uint32 unk7;
|
||||
|
||||
} EVENTLOG_Q_OPEN;
|
||||
|
||||
typedef struct eventlog_r_open
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 status;
|
||||
|
||||
} EVENTLOG_R_OPEN;
|
||||
|
||||
typedef struct eventlog_q_close
|
||||
{
|
||||
POLICY_HND pol;
|
||||
} EVENTLOG_Q_CLOSE;
|
||||
|
||||
typedef struct eventlog_r_close
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 status;
|
||||
} EVENTLOG_R_CLOSE;
|
||||
|
||||
typedef struct eventlog_q_numofeventlogrec
|
||||
{
|
||||
POLICY_HND pol;
|
||||
} EVENTLOG_Q_NUMOFEVENTLOGREC;
|
||||
|
||||
typedef struct eventlog_r_numofeventlogrec
|
||||
{
|
||||
uint32 number;
|
||||
uint32 status;
|
||||
} EVENTLOG_R_NUMOFEVENTLOGREC;
|
||||
|
||||
typedef struct eventlog_q_readeventlog
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 flags;
|
||||
uint32 offset;
|
||||
uint32 number_of_bytes;
|
||||
} EVENTLOG_Q_READEVENTLOG;
|
||||
|
||||
typedef struct eventlog_r_readeventlog
|
||||
{
|
||||
uint32 number_of_bytes;
|
||||
EVENTLOGRECORD *event;
|
||||
uint32 sent_size;
|
||||
uint32 real_size;
|
||||
uint32 status;
|
||||
} EVENTLOG_R_READEVENTLOG;
|
||||
|
||||
#endif /* _RPC_EVENTLOG_H */
|
File diff suppressed because it is too large
Load Diff
@ -1,288 +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 _RPC_SVCCTL_H /* _RPC_SVCCTL_H */
|
||||
#define _RPC_SVCCTL_H
|
||||
|
||||
|
||||
/* svcctl pipe */
|
||||
#define SVC_OPEN_SC_MAN 0x0f
|
||||
#define SVC_ENUM_SVCS_STATUS 0x0e
|
||||
#define SVC_QUERY_SVC_CONFIG 0x11
|
||||
#define SVC_QUERY_DISP_NAME 0x14
|
||||
#define SVC_CHANGE_SVC_CONFIG 0x0b
|
||||
#define SVC_OPEN_SERVICE 0x10
|
||||
#define SVC_START_SERVICE 0x13
|
||||
#define SVC_STOP_SERVICE 0x01
|
||||
#define SVC_CLOSE 0x00
|
||||
|
||||
|
||||
/* SVC_Q_OPEN_SC_MAN */
|
||||
typedef struct q_svc_open_sc_man_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
|
||||
|
||||
uint32 ptr_db_name; /* pointer (to database name?) */
|
||||
UNISTR2 uni_db_name; /* unicode database name */
|
||||
|
||||
uint32 des_access; /* 0x80000004 - SC_MANAGER_xxxx */
|
||||
|
||||
} SVC_Q_OPEN_SC_MAN;
|
||||
|
||||
/* SVC_R_OPEN_SC_MAN */
|
||||
typedef struct r_svc_open_sc_man_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SVC_R_OPEN_SC_MAN;
|
||||
|
||||
/* SVC_Q_OPEN_SERVICE */
|
||||
typedef struct q_svc_open_service_info
|
||||
{
|
||||
POLICY_HND scman_pol;
|
||||
UNISTR2 uni_svc_name; /* unicode service name */
|
||||
uint32 des_access; /* 0x8000 0001 */
|
||||
|
||||
} SVC_Q_OPEN_SERVICE;
|
||||
|
||||
/* SVC_R_OPEN_SERVICE */
|
||||
typedef struct r_svc_open_service_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SVC_R_OPEN_SERVICE;
|
||||
|
||||
#define MAX_SVC_ARGS 10
|
||||
|
||||
/* SVC_Q_STOP_SERVICE */
|
||||
typedef struct q_svc_stop_service_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
|
||||
uint32 unknown;
|
||||
|
||||
} SVC_Q_STOP_SERVICE;
|
||||
|
||||
/* SVC_R_STOP_SERVICE */
|
||||
typedef struct r_svc_stop_service_info
|
||||
{
|
||||
uint32 unknown0; /* 0x00000020 */
|
||||
uint32 unknown1; /* 0x00000001 */
|
||||
uint32 unknown2; /* 0x00000001 */
|
||||
uint32 unknown3; /* 0x00000000 */
|
||||
uint32 unknown4; /* 0x00000000 */
|
||||
uint32 unknown5; /* 0x00000000 */
|
||||
uint32 unknown6; /* 0x00000000 */
|
||||
uint32 status;
|
||||
|
||||
} SVC_R_STOP_SERVICE;
|
||||
|
||||
/* SVC_Q_START_SERVICE */
|
||||
typedef struct q_svc_start_service_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
|
||||
uint32 argc;
|
||||
uint32 ptr_args;
|
||||
uint32 argc2;
|
||||
uint32 ptr_argv[MAX_SVC_ARGS];
|
||||
UNISTR2 argv[MAX_SVC_ARGS];
|
||||
|
||||
} SVC_Q_START_SERVICE;
|
||||
|
||||
/* SVC_R_START_SERVICE */
|
||||
typedef struct r_svc_start_service_info
|
||||
{
|
||||
uint32 status;
|
||||
|
||||
} SVC_R_START_SERVICE;
|
||||
|
||||
|
||||
/* QUERY_SERVICE_CONFIG */
|
||||
typedef struct query_service_config_info
|
||||
{
|
||||
uint32 service_type;
|
||||
uint32 start_type;
|
||||
uint32 error_control;
|
||||
uint32 ptr_bin_path_name;
|
||||
uint32 ptr_load_order_grp;
|
||||
uint32 tag_id;
|
||||
uint32 ptr_dependencies;
|
||||
uint32 ptr_service_start_name;
|
||||
uint32 ptr_display_name;
|
||||
|
||||
UNISTR2 uni_bin_path_name;
|
||||
UNISTR2 uni_load_order_grp;
|
||||
UNISTR2 uni_dependencies;
|
||||
UNISTR2 uni_service_start_name;
|
||||
UNISTR2 uni_display_name;
|
||||
|
||||
} QUERY_SERVICE_CONFIG;
|
||||
|
||||
/* SVC_STATUS */
|
||||
typedef struct svc_status_info
|
||||
{
|
||||
uint32 svc_type;
|
||||
uint32 current_state;
|
||||
uint32 controls_accepted;
|
||||
uint32 win32_exit_code;
|
||||
uint32 svc_specific_exit_code;
|
||||
uint32 check_point;
|
||||
uint32 wait_hint;
|
||||
|
||||
} SVC_STATUS;
|
||||
|
||||
/* ENUM_SRVC_STATUS */
|
||||
typedef struct enum_svc_status_info
|
||||
{
|
||||
UNISTR uni_srvc_name;
|
||||
UNISTR uni_disp_name;
|
||||
SVC_STATUS status;
|
||||
|
||||
} ENUM_SRVC_STATUS;
|
||||
|
||||
/* SVC_Q_ENUM_SVCS_STATUS */
|
||||
typedef struct q_svc_enum_svcs_status_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 service_type; /* 0x00000030 - win32 | 0x0000000b - driver */
|
||||
uint32 service_state; /* 0x00000003 - state_all */
|
||||
uint32 buf_size; /* max service buffer size */
|
||||
ENUM_HND resume_hnd; /* resume handle */
|
||||
|
||||
} SVC_Q_ENUM_SVCS_STATUS;
|
||||
|
||||
/* SVC_R_ENUM_SVCS_STATUS */
|
||||
typedef struct r_svc_enum_svcs_status_info
|
||||
{
|
||||
uint32 buf_size; /* service buffer size */
|
||||
ENUM_SRVC_STATUS *svcs;
|
||||
uint32 more_buf_size;
|
||||
uint32 num_svcs;
|
||||
ENUM_HND resume_hnd; /* resume handle */
|
||||
uint32 dos_status; /* return status, DOS error code (wow!) */
|
||||
|
||||
} SVC_R_ENUM_SVCS_STATUS;
|
||||
|
||||
|
||||
/* SVC_Q_QUERY_SVC_CONFIG */
|
||||
typedef struct q_svc_query_svc_cfg_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 buf_size;
|
||||
|
||||
} SVC_Q_QUERY_SVC_CONFIG;
|
||||
|
||||
|
||||
/* SVC_R_QUERY_SVC_CONFIG */
|
||||
typedef struct r_svc_query_svc_cfg_info
|
||||
{
|
||||
QUERY_SERVICE_CONFIG *cfg;
|
||||
uint32 buf_size;
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SVC_R_QUERY_SVC_CONFIG;
|
||||
|
||||
|
||||
/* SVC_Q_QUERY_DISP_NAME */
|
||||
typedef struct q_svc_query_disp_name_info
|
||||
{
|
||||
POLICY_HND scman_pol;
|
||||
UNISTR2 uni_svc_name;
|
||||
uint32 buf_size;
|
||||
|
||||
} SVC_Q_QUERY_DISP_NAME;
|
||||
|
||||
|
||||
/* SVC_R_QUERY_DISP_NAME */
|
||||
typedef struct r_svc_query_disp_name_info
|
||||
{
|
||||
UNISTR2 uni_disp_name;
|
||||
uint32 buf_size;
|
||||
uint32 status;
|
||||
|
||||
} SVC_R_QUERY_DISP_NAME;
|
||||
|
||||
|
||||
/* SVC_Q_CLOSE */
|
||||
typedef struct q_svc_close_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
|
||||
} SVC_Q_CLOSE;
|
||||
|
||||
|
||||
|
||||
/* SVC_R_CLOSE */
|
||||
typedef struct r_svc_close_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SVC_R_CLOSE;
|
||||
|
||||
/* SVC_Q_CHANGE_SVC_CONFIG */
|
||||
typedef struct q_svc_change_svc_cfg_info
|
||||
{
|
||||
POLICY_HND pol;
|
||||
uint32 service_type;
|
||||
uint32 start_type;
|
||||
uint32 unknown_0;
|
||||
uint32 error_control;
|
||||
|
||||
uint32 ptr_bin_path_name;
|
||||
UNISTR2 uni_bin_path_name;
|
||||
|
||||
uint32 ptr_load_order_grp;
|
||||
UNISTR2 uni_load_order_grp;
|
||||
|
||||
uint32 tag_id;
|
||||
|
||||
uint32 ptr_dependencies;
|
||||
UNISTR2 uni_dependencies;
|
||||
|
||||
uint32 ptr_service_start_name;
|
||||
UNISTR2 uni_service_start_name;
|
||||
|
||||
uint32 ptr_password;
|
||||
STRING2 str_password;
|
||||
|
||||
uint32 ptr_display_name;
|
||||
UNISTR2 uni_display_name;
|
||||
|
||||
} SVC_Q_CHANGE_SVC_CONFIG;
|
||||
|
||||
/* SVC_R_CHANGE_SVC_CONFIG */
|
||||
typedef struct r_svc_change_svc_cfg_info
|
||||
{
|
||||
uint32 unknown_0; /* */
|
||||
uint32 status; /* return status */
|
||||
|
||||
} SVC_R_CHANGE_SVC_CONFIG;
|
||||
|
||||
|
||||
#endif /* _RPC_SVCCTL_H */
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Safe string handling routines.
|
||||
Copyright (C) Andrew Tridgell 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.
|
||||
*/
|
||||
|
||||
#ifndef _SAFE_STRING_H
|
||||
#define _SAFE_STRING_H
|
||||
|
||||
#ifdef strcpy
|
||||
#undef strcpy
|
||||
#endif /* strcpy */
|
||||
#define strcpy(dest,src) __ERROR__XX__NEVER_USE_STRCPY___;
|
||||
|
||||
#ifdef strcat
|
||||
#undef strcat
|
||||
#endif /* strcat */
|
||||
#define strcat(dest,src) __ERROR__XX__NEVER_USE_STRCAT___;
|
||||
|
||||
#ifdef sprintf
|
||||
#undef sprintf
|
||||
#endif /* sprintf */
|
||||
#define sprintf __ERROR__XX__NEVER_USE_SPRINTF__;
|
||||
|
||||
#define pstrcpy(d,s) safe_strcpy((d),(s),sizeof(pstring)-1)
|
||||
#define pstrcat(d,s) safe_strcat((d),(s),sizeof(pstring)-1)
|
||||
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
|
||||
#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
|
||||
|
||||
#endif
|
@ -1,154 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) John H Terpstra 1996-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
Copyright (C) Paul Ashton 1998 - 1999
|
||||
|
||||
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 _SMB_MACROS_H
|
||||
#define _SMB_MACROS_H
|
||||
|
||||
/* Misc bit macros */
|
||||
#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 IS_BITS_CLR_SOME(var,bit) (((var)&(bit))!=(bit))
|
||||
|
||||
/* for readability... */
|
||||
#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0)
|
||||
#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0)
|
||||
#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0)
|
||||
#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0)
|
||||
#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0)
|
||||
|
||||
/* zero a structure */
|
||||
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
|
||||
|
||||
/* zero a structure given a pointer to the structure */
|
||||
#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); }
|
||||
|
||||
/* zero an array - note that sizeof(array) must work - ie. it must not be a
|
||||
pointer */
|
||||
#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
|
||||
|
||||
/* pointer difference macro */
|
||||
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
|
||||
|
||||
/* assert macros */
|
||||
#define SMB_ASSERT(b) ((b)?(void)0: \
|
||||
(DEBUG(0,("PANIC: assert failed at %s(%d)\n", \
|
||||
__FILE__, __LINE__)), smb_panic("assert failed")))
|
||||
#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n))
|
||||
|
||||
/* these are useful macros for checking validity of handles */
|
||||
#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory)
|
||||
#define OPEN_CONN(conn) ((conn) && (conn)->open)
|
||||
#define IS_IPC(conn) ((conn) && (conn)->ipc)
|
||||
#define IS_PRINT(conn) ((conn) && (conn)->printer)
|
||||
#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn)
|
||||
|
||||
#define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \
|
||||
return(ERROR(ERRDOS,ERRbadfid))
|
||||
#define CHECK_READ(fsp) if (!(fsp)->can_read) \
|
||||
return(ERROR(ERRDOS,ERRbadaccess))
|
||||
#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \
|
||||
return(ERROR(ERRDOS,ERRbadaccess))
|
||||
#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \
|
||||
return(CACHED_ERROR(fsp))
|
||||
|
||||
/* translates a connection number into a service number */
|
||||
#define SNUM(conn) ((conn)?(conn)->service:-1)
|
||||
|
||||
/* access various service details */
|
||||
#define SERVICE(snum) (lp_servicename(snum))
|
||||
#define PRINTCAP (lp_printcapname())
|
||||
#define PRINTCOMMAND(snum) (lp_printcommand(snum))
|
||||
#define PRINTERNAME(snum) (lp_printername(snum))
|
||||
#define CAN_WRITE(conn) (!conn->read_only)
|
||||
#define VALID_SNUM(snum) (lp_snum_ok(snum))
|
||||
#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
|
||||
#define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum))
|
||||
#define CAN_SETDIR(snum) (!lp_no_set_dir(snum))
|
||||
#define CAN_PRINT(conn) ((conn) && lp_print_ok((conn)->service))
|
||||
#define MAP_HIDDEN(conn) ((conn) && lp_map_hidden((conn)->service))
|
||||
#define MAP_SYSTEM(conn) ((conn) && lp_map_system((conn)->service))
|
||||
#define MAP_ARCHIVE(conn) ((conn) && lp_map_archive((conn)->service))
|
||||
#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list))
|
||||
#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list))
|
||||
#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list))
|
||||
|
||||
/*
|
||||
* Used by the stat cache code to check if a returned
|
||||
* stat structure is valid.
|
||||
*/
|
||||
|
||||
#define VALID_STAT(st) (st.st_nlink != 0)
|
||||
#define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR(st.st_mode))
|
||||
|
||||
#define SMBENCRYPT() (lp_encrypted_passwords())
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) ((a)>0?(a):(-(a)))
|
||||
#endif
|
||||
|
||||
/* Macros to get at offsets within smb_lkrng and smb_unlkrng
|
||||
structures. We cannot define these as actual structures
|
||||
due to possible differences in structure packing
|
||||
on different machines/compilers. */
|
||||
|
||||
#define SMB_LPID_OFFSET(indx) (10 * (indx))
|
||||
#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
|
||||
#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
|
||||
#define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx)))
|
||||
#define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx)))
|
||||
#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))
|
||||
#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))
|
||||
|
||||
/* Macro to cache an error in a write_bmpx_struct */
|
||||
#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
|
||||
w->wr_discard = True, -1)
|
||||
/* Macro to test if an error has been cached for this fnum */
|
||||
#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \
|
||||
(fsp)->wbmpx_ptr->wr_discard)
|
||||
/* Macro to turn the cached error into an error packet */
|
||||
#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__)
|
||||
|
||||
/* these are the datagram types */
|
||||
#define DGRAM_DIRECT_UNIQUE 0x10
|
||||
|
||||
#define ERROR(class,x) error_packet(inbuf,outbuf,class,x,__LINE__)
|
||||
|
||||
/* this is how errors are generated */
|
||||
#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,__LINE__)
|
||||
|
||||
#define SMB_ROUNDUP(x,g) (((x)+((g)-1))&~((g)-1))
|
||||
|
||||
#endif /* _SMB_MACROS_H */
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Vagent structures and parameters
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1999
|
||||
|
||||
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 _VAGENT_H
|
||||
#define _VAGENT_H
|
||||
|
||||
/* Vagent operations structure */
|
||||
|
||||
struct sock_redir
|
||||
{
|
||||
int c;
|
||||
int s;
|
||||
int c_id;
|
||||
int s_id;
|
||||
void *n;
|
||||
};
|
||||
|
||||
struct vagent_ops
|
||||
{
|
||||
void (*free_sock)(void* sock);
|
||||
int (*get_agent_sock)(char* id);
|
||||
|
||||
BOOL (*process_cli_sock)(struct sock_redir **socks, uint32 num_socks,
|
||||
struct sock_redir *sock);
|
||||
BOOL (*process_srv_sock)(struct sock_redir **socks, uint32 num_socks,
|
||||
int fd);
|
||||
|
||||
char* id;
|
||||
struct sock_redir **socks;
|
||||
uint32 num_socks;
|
||||
};
|
||||
|
||||
#endif /* _VAGENT_H */
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
VFS structures and parameters
|
||||
Copyright (C) Tim Potter 1999
|
||||
|
||||
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 _VFS_H
|
||||
#define _VFS_H
|
||||
|
||||
/* Types used in the definition of VFS operations. These are included
|
||||
here so the vfs.h file can be included by VFS modules without
|
||||
having to pull in unnecessary amounts of other stuff. Note to VFS
|
||||
writers: you must include config.h before including this file.
|
||||
The following type definitions reference the HAVE_* symbols which
|
||||
are defined in config.h */
|
||||
|
||||
#ifndef SMB_OFF_T
|
||||
# ifdef HAVE_OFF64_T
|
||||
# define SMB_OFF_T off64_t
|
||||
# else
|
||||
# define SMB_OFF_T off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SMB_STRUCT_STAT
|
||||
# if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
|
||||
# define SMB_STRUCT_STAT struct stat64
|
||||
# else
|
||||
# define SMB_STRUCT_STAT struct stat
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _BOOL
|
||||
typedef int BOOL;
|
||||
#endif
|
||||
|
||||
#ifndef _PSTRING
|
||||
#define PSTRING_LEN 1024
|
||||
#define FSTRING_LEN 128
|
||||
|
||||
typedef char pstring[PSTRING_LEN];
|
||||
typedef char fstring[FSTRING_LEN];
|
||||
#define _PSTRING
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONGLONG)
|
||||
#define SMB_BIG_UINT unsigned long long
|
||||
#else
|
||||
#define SMB_BIG_UINT unsigned long
|
||||
#endif
|
||||
|
||||
/* Information from the connection_struct passed to the vfs layer */
|
||||
|
||||
struct vfs_connection_struct {
|
||||
|
||||
/* Connection information */
|
||||
|
||||
BOOL printer;
|
||||
BOOL ipc;
|
||||
BOOL read_only;
|
||||
BOOL admin_user;
|
||||
|
||||
/* Paths */
|
||||
|
||||
pstring dirpath;
|
||||
pstring connectpath;
|
||||
pstring origpath;
|
||||
pstring service;
|
||||
|
||||
/* Information on user who *opened* this connection */
|
||||
|
||||
pstring user;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
int ngroups;
|
||||
gid_t *groups;
|
||||
};
|
||||
|
||||
/* Avoid conflict with an AIX include file */
|
||||
|
||||
#ifdef vfs_ops
|
||||
#undef vfs_ops
|
||||
#endif
|
||||
|
||||
/* VFS operations structure */
|
||||
|
||||
struct vfs_ops {
|
||||
|
||||
/* Disk operations */
|
||||
|
||||
int (*connect)(struct vfs_connection_struct *conn, char *service,
|
||||
char *user);
|
||||
void (*disconnect)(void);
|
||||
SMB_BIG_UINT (*disk_free)(char *path, SMB_BIG_UINT *bsize,
|
||||
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
|
||||
|
||||
/* Directory operations */
|
||||
|
||||
DIR *(*opendir)(char *fname);
|
||||
struct dirent *(*readdir)(DIR *dirp);
|
||||
int (*mkdir)(char *path, mode_t mode);
|
||||
int (*rmdir)(char *path);
|
||||
int (*closedir)(DIR *dir);
|
||||
|
||||
/* File operations */
|
||||
|
||||
int (*open)(char *fname, int flags, mode_t mode);
|
||||
int (*close)(int fd);
|
||||
ssize_t (*read)(int fd, char *data, size_t n);
|
||||
ssize_t (*write)(int fd, char *data, size_t n);
|
||||
SMB_OFF_T (*lseek)(int filedes, SMB_OFF_T offset, int whence);
|
||||
int (*rename)(char *old, char *new);
|
||||
void (*sync)(int fd);
|
||||
int (*stat)(char *fname, SMB_STRUCT_STAT *sbuf);
|
||||
int (*fstat)(int fd, SMB_STRUCT_STAT *sbuf);
|
||||
int (*lstat)(char *path, SMB_STRUCT_STAT *sbuf);
|
||||
BOOL (*lock)(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
|
||||
int (*unlink)(char *path);
|
||||
int (*chmod)(char *path, mode_t mode);
|
||||
int (*utime)(char *path, struct utimbuf *times);
|
||||
};
|
||||
|
||||
/* VFS options for configuration file */
|
||||
|
||||
struct vfs_options {
|
||||
struct vfs_options *prev, *next;
|
||||
char *name;
|
||||
char *value;
|
||||
};
|
||||
|
||||
#endif /* _VFS_H */
|
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Interface header: Scheduler service
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* taken direct from rfc2104 implementation and modified for suitable use
|
||||
* for ntlmv2.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/***********************************************************************
|
||||
the rfc 2104 version of hmac_md5 initialisation.
|
||||
***********************************************************************/
|
||||
void hmac_md5_init_rfc2104(uchar* key, int key_len, HMACMD5Context *ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* if key is longer than 64 bytes reset it to key=MD5(key) */
|
||||
if (key_len > 64)
|
||||
{
|
||||
uchar tk[16];
|
||||
struct MD5Context tctx;
|
||||
|
||||
MD5Init(&tctx);
|
||||
MD5Update(&tctx, key, key_len);
|
||||
MD5Final(tk, &tctx);
|
||||
|
||||
key = tk;
|
||||
key_len = 16;
|
||||
}
|
||||
|
||||
/* start out by storing key in pads */
|
||||
bzero( ctx->k_ipad, sizeof ctx->k_ipad);
|
||||
bzero( ctx->k_opad, sizeof ctx->k_opad);
|
||||
bcopy( key, ctx->k_ipad, key_len);
|
||||
bcopy( key, ctx->k_opad, key_len);
|
||||
|
||||
/* XOR key with ipad and opad values */
|
||||
for (i=0; i<64; i++)
|
||||
{
|
||||
ctx->k_ipad[i] ^= 0x36;
|
||||
ctx->k_opad[i] ^= 0x5c;
|
||||
}
|
||||
|
||||
MD5Init(&ctx->ctx);
|
||||
MD5Update(&ctx->ctx, ctx->k_ipad, 64);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
the microsoft version of hmac_md5 initialisation.
|
||||
***********************************************************************/
|
||||
void hmac_md5_init_limK_to_64(const uchar* key, int key_len,
|
||||
HMACMD5Context *ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* if key is longer than 64 bytes truncate it */
|
||||
if (key_len > 64)
|
||||
{
|
||||
key_len = 64;
|
||||
}
|
||||
|
||||
/* start out by storing key in pads */
|
||||
bzero( ctx->k_ipad, sizeof ctx->k_ipad);
|
||||
bzero( ctx->k_opad, sizeof ctx->k_opad);
|
||||
bcopy( key, ctx->k_ipad, key_len);
|
||||
bcopy( key, ctx->k_opad, key_len);
|
||||
|
||||
/* XOR key with ipad and opad values */
|
||||
for (i=0; i<64; i++)
|
||||
{
|
||||
ctx->k_ipad[i] ^= 0x36;
|
||||
ctx->k_opad[i] ^= 0x5c;
|
||||
}
|
||||
|
||||
MD5Init(&ctx->ctx);
|
||||
MD5Update(&ctx->ctx, ctx->k_ipad, 64);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
update hmac_md5 "inner" buffer
|
||||
***********************************************************************/
|
||||
void hmac_md5_update(const uchar* text, int text_len, HMACMD5Context *ctx)
|
||||
{
|
||||
MD5Update(&ctx->ctx, text, text_len); /* then text of datagram */
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
finish off hmac_md5 "inner" buffer and generate outer one.
|
||||
***********************************************************************/
|
||||
void hmac_md5_final(uchar *digest, HMACMD5Context *ctx)
|
||||
|
||||
{
|
||||
struct MD5Context ctx_o;
|
||||
|
||||
MD5Final(digest, &ctx->ctx);
|
||||
|
||||
MD5Init(&ctx_o);
|
||||
MD5Update(&ctx_o, ctx->k_opad, 64);
|
||||
MD5Update(&ctx_o, digest, 16);
|
||||
MD5Final(digest, &ctx_o);
|
||||
}
|
@ -1,315 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* This code has been heavily hacked by Tatu Ylonen <ylo@cs.hut.fi> to
|
||||
make it compile on machines like Cray that don't have a 32 bit integer
|
||||
type. */
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifndef _GETPUT_H
|
||||
/*
|
||||
|
||||
getput.h
|
||||
|
||||
Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
|
||||
Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
All rights reserved
|
||||
|
||||
Created: Wed Jun 28 22:36:30 1995 ylo
|
||||
|
||||
Macros for storing and retrieving data in msb first and lsb first order.
|
||||
|
||||
*/
|
||||
|
||||
/*------------ macros for storing/extracting msb first words -------------*/
|
||||
|
||||
#define GET_32BIT(cp) (((uint32)(uchar)(cp)[0] << 24) | \
|
||||
((uint32)(uchar)(cp)[1] << 16) | \
|
||||
((uint32)(uchar)(cp)[2] << 8) | \
|
||||
((uint32)(uchar)(cp)[3]))
|
||||
|
||||
#define GET_16BIT(cp) (((uint32)(uchar)(cp)[0] << 8) | \
|
||||
((uint32)(uchar)(cp)[1]))
|
||||
|
||||
#define PUT_32BIT(cp, value) do { \
|
||||
(cp)[0] = (value) >> 24; \
|
||||
(cp)[1] = (value) >> 16; \
|
||||
(cp)[2] = (value) >> 8; \
|
||||
(cp)[3] = (value); } while (0)
|
||||
|
||||
#define PUT_16BIT(cp, value) do { \
|
||||
(cp)[0] = (value) >> 8; \
|
||||
(cp)[1] = (value); } while (0)
|
||||
|
||||
/*------------ macros for storing/extracting lsb first words -------------*/
|
||||
|
||||
#define GET_32BIT_LSB_FIRST(cp) \
|
||||
(((uint32)(uchar)(cp)[0]) | \
|
||||
((uint32)(uchar)(cp)[1] << 8) | \
|
||||
((uint32)(uchar)(cp)[2] << 16) | \
|
||||
((uint32)(uchar)(cp)[3] << 24))
|
||||
|
||||
#define GET_16BIT_LSB_FIRST(cp) \
|
||||
(((uint32)(uchar)(cp)[0]) | \
|
||||
((uint32)(uchar)(cp)[1] << 8))
|
||||
|
||||
#define PUT_32BIT_LSB_FIRST(cp, value) do { \
|
||||
(cp)[0] = (value); \
|
||||
(cp)[1] = (value) >> 8; \
|
||||
(cp)[2] = (value) >> 16; \
|
||||
(cp)[3] = (value) >> 24; } while (0)
|
||||
|
||||
#define PUT_16BIT_LSB_FIRST(cp, value) do { \
|
||||
(cp)[0] = (value); \
|
||||
(cp)[1] = (value) >> 8; } while (0)
|
||||
|
||||
#endif /* _GETPUT_H */
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
void MD5Init(struct MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
void MD5Update(struct MD5Context *ctx, uchar const *buf, unsigned len)
|
||||
{
|
||||
uint32 t;
|
||||
|
||||
/* Update bitcount */
|
||||
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = (t + ((uint32)len << 3)) & 0xffffffff) < t)
|
||||
ctx->bits[1]++; /* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if (t) {
|
||||
uchar *p = ctx->in + t;
|
||||
|
||||
t = 64 - t;
|
||||
if (len < t) {
|
||||
memcpy(p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void MD5Final(uchar digest[16], struct MD5Context *ctx)
|
||||
{
|
||||
unsigned count;
|
||||
uchar *p;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8) {
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset(p, 0, count);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
/* Pad block to 56 bytes */
|
||||
memset(p, 0, count - 8);
|
||||
}
|
||||
|
||||
/* Append length in bits and transform */
|
||||
PUT_32BIT_LSB_FIRST(ctx->in + 56, ctx->bits[0]);
|
||||
PUT_32BIT_LSB_FIRST(ctx->in + 60, ctx->bits[1]);
|
||||
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
PUT_32BIT_LSB_FIRST(digest, ctx->buf[0]);
|
||||
PUT_32BIT_LSB_FIRST(digest + 4, ctx->buf[1]);
|
||||
PUT_32BIT_LSB_FIRST(digest + 8, ctx->buf[2]);
|
||||
PUT_32BIT_LSB_FIRST(digest + 12, ctx->buf[3]);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
void MD5Transform(uint32 buf[4], const uchar inext[64])
|
||||
{
|
||||
register uint32 a, b, c, d, i;
|
||||
uint32 in[16];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
in[i] = GET_32BIT_LSB_FIRST(inext + 4 * i);
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,367 +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 = 0x0;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
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 offset, 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 = offset;
|
||||
buf->offset.end = offset + size;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
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 = (char*)malloc(buf->data_size);
|
||||
|
||||
if (buf->data == NULL && size != 0)
|
||||
{
|
||||
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);
|
||||
buf->offset.end = buf->offset.start + 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) = (struct mem_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.
|
||||
********************************************************************/
|
||||
static 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 */
|
||||
buf->data = NULL;
|
||||
}
|
||||
mem_init(buf, buf->margin);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reallocate a memory buffer, including a safety margin
|
||||
********************************************************************/
|
||||
BOOL mem_realloc_data(struct mem_buf *buf, size_t 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 = (char*)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;
|
||||
}
|
||||
|
||||
buf->offset.end = buf->offset.start + new_size;
|
||||
|
||||
DEBUG(150,("mem_realloc_data: size: %d start: %d end: %d\n",
|
||||
new_size, buf->offset.start, buf->offset.end));
|
||||
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)
|
||||
{
|
||||
/* writing or forge realloc */
|
||||
return mem_realloc_data((*buf), new_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
search for a memory buffer that falls within the specified offset
|
||||
********************************************************************/
|
||||
static 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)
|
||||
{
|
||||
DEBUG(200,("mem_find: next[%d..%d]\n",
|
||||
f->offset.start, f->offset.end));
|
||||
|
||||
f = f->next;
|
||||
}
|
||||
|
||||
(*buf) = f;
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,251 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2
|
||||
SMB agent/socket plugin
|
||||
Copyright (C) Andrew Tridgell 1999
|
||||
|
||||
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"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
static char packet[BUFFER_SIZE];
|
||||
|
||||
/****************************************************************************
|
||||
terminate sockent connection
|
||||
****************************************************************************/
|
||||
static void free_sock(void *sock)
|
||||
{
|
||||
if (sock != NULL)
|
||||
{
|
||||
struct msrpc_state *n = (struct msrpc_state*)sock;
|
||||
msrpc_use_del(n->pipe_name, &n->usr, False, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static struct msrpc_state *init_client_connection(int c)
|
||||
{
|
||||
pstring buf;
|
||||
fstring pipe_name;
|
||||
struct user_creds usr;
|
||||
int rl;
|
||||
uint32 len;
|
||||
BOOL new_con = False;
|
||||
struct msrpc_state *n = NULL;
|
||||
|
||||
CREDS_CMD cmd;
|
||||
prs_struct ps;
|
||||
|
||||
ZERO_STRUCT(usr);
|
||||
ZERO_STRUCT(cmd);
|
||||
cmd.cred = &usr;
|
||||
|
||||
DEBUG(10,("init_client_connection: first request\n"));
|
||||
|
||||
rl = read(c, &buf, sizeof(len));
|
||||
|
||||
if (rl != sizeof(len))
|
||||
{
|
||||
DEBUG(0,("Unable to read length\n"));
|
||||
dump_data(0, buf, sizeof(len));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = IVAL(buf, 0);
|
||||
|
||||
if (len > sizeof(buf))
|
||||
{
|
||||
DEBUG(0,("length %d too long\n", len));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rl = read(c, buf, len);
|
||||
|
||||
if (rl < 0)
|
||||
{
|
||||
DEBUG(0,("Unable to read from connection\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
dump_data(100, buf, rl);
|
||||
#endif
|
||||
|
||||
/* make a static data parsing structure from the api_fd_reply data */
|
||||
prs_init(&ps, 0, 4, 0, True);
|
||||
mem_create(ps.data, buf, 0, len, 0, False);
|
||||
|
||||
if (!creds_io_cmd("creds", &cmd, &ps, 0))
|
||||
{
|
||||
DEBUG(0,("Unable to parse credentials\n"));
|
||||
mem_free_data(ps.data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mem_free_data(ps.data);
|
||||
|
||||
if (ps.offset != rl)
|
||||
{
|
||||
DEBUG(0,("Buffer size %d %d!\n", ps.offset, rl));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (cmd.command)
|
||||
{
|
||||
case AGENT_CMD_CON:
|
||||
case AGENT_CMD_CON_ANON:
|
||||
{
|
||||
new_con = True;
|
||||
break;
|
||||
}
|
||||
case AGENT_CMD_CON_REUSE:
|
||||
{
|
||||
new_con = True;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG(0,("unknown command %d\n", cmd.command));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_con)
|
||||
{
|
||||
uint32 status = 0;
|
||||
n = msrpc_use_add(pipe_name, &usr, False);
|
||||
|
||||
if (n == NULL)
|
||||
{
|
||||
DEBUG(0,("Unable to connect to %s\n", pipe_name));
|
||||
status = 0x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fstrcpy(n->pipe_name, pipe_name);
|
||||
copy_user_creds(&n->usr, &usr);
|
||||
}
|
||||
|
||||
if (write(c, &status, sizeof(status)) != sizeof(status))
|
||||
{
|
||||
DEBUG(0,("Could not write connection down pipe.\n"));
|
||||
if (n != NULL)
|
||||
{
|
||||
msrpc_use_del(pipe_name, &usr, False, NULL);
|
||||
n = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
free_user_creds(&usr);
|
||||
return n;
|
||||
}
|
||||
|
||||
static BOOL process_cli_sock(struct sock_redir **socks, uint32 num_socks,
|
||||
struct sock_redir *sock)
|
||||
{
|
||||
struct msrpc_state *n = (struct msrpc_state*)sock->n;
|
||||
if (n == NULL)
|
||||
{
|
||||
n = init_client_connection(sock->c);
|
||||
if (n == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
sock->n = (void*)n;
|
||||
sock->s = n->fd;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!receive_smb(sock->c, packet, 0))
|
||||
{
|
||||
DEBUG(0,("client closed connection\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!send_smb(sock->s, packet))
|
||||
{
|
||||
DEBUG(0,("server is dead\n"));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
static BOOL process_srv_sock(struct sock_redir **socks, uint32 num_socks,
|
||||
int fd)
|
||||
{
|
||||
int i;
|
||||
if (!receive_smb(fd, packet, 0))
|
||||
{
|
||||
DEBUG(0,("server closed connection\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
DEBUG(10,("process_srv_sock:\tfd:\t%d\n", fd));
|
||||
|
||||
for (i = 0; i < num_socks; i++)
|
||||
{
|
||||
struct msrpc_state *n;
|
||||
if (socks[i] == NULL || socks[i]->n == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
n = (struct msrpc_state*)socks[i]->n;
|
||||
DEBUG(10,("list:\tfd:\t%d\n",
|
||||
socks[i]->s));
|
||||
if (!send_smb(socks[i]->c, packet))
|
||||
{
|
||||
DEBUG(0,("client is dead\n"));
|
||||
return False;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
static int get_agent_sock(char *pipe_name)
|
||||
{
|
||||
fstring path;
|
||||
fstring dir;
|
||||
|
||||
slprintf(dir, sizeof(dir)-1, "/tmp/.msrpc/.%s", pipe_name);
|
||||
slprintf(path, sizeof(path)-1, "%s/agent", dir);
|
||||
|
||||
return create_pipe_socket(dir, S_IRUSR|S_IWUSR|S_IXUSR, path, 0);
|
||||
}
|
||||
|
||||
void start_msrpc_agent(char *pipe_name)
|
||||
{
|
||||
struct vagent_ops va =
|
||||
{
|
||||
free_sock,
|
||||
get_agent_sock,
|
||||
process_cli_sock,
|
||||
process_srv_sock,
|
||||
pipe_name,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
|
||||
if (fork() == 0)
|
||||
{
|
||||
/* child */
|
||||
start_agent(&va);
|
||||
}
|
||||
}
|
||||
|
@ -1,384 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB msrpcent generic functions
|
||||
Copyright (C) Andrew Tridgell 1994-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/****************************************************************************
|
||||
recv an smb
|
||||
****************************************************************************/
|
||||
BOOL msrpc_receive(struct msrpc_state *msrpc)
|
||||
{
|
||||
return receive_smb(msrpc->fd,msrpc->inbuf,0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send an smb to a fd and re-establish if necessary
|
||||
****************************************************************************/
|
||||
BOOL msrpc_send_prs(struct msrpc_state *msrpc, prs_struct *ps)
|
||||
{
|
||||
size_t len = mem_buf_len(ps->data);
|
||||
|
||||
DEBUG(10,("msrpc_send_prs: len %d\n", len));
|
||||
dbgflush();
|
||||
|
||||
_smb_setlen(msrpc->outbuf, len);
|
||||
mem_buf_copy(&msrpc->outbuf[4], ps->data, 0, len);
|
||||
|
||||
if (msrpc_send(msrpc, True))
|
||||
{
|
||||
prs_mem_free(ps);
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
receive msrpc packet
|
||||
****************************************************************************/
|
||||
BOOL msrpc_receive_prs(struct msrpc_state *msrpc, prs_struct *ps)
|
||||
{
|
||||
int len;
|
||||
char *data;
|
||||
|
||||
if (!msrpc_receive(msrpc))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
len = smb_len(msrpc->inbuf);
|
||||
|
||||
dump_data(10, msrpc->inbuf, len+4);
|
||||
|
||||
prs_init(ps, len, 4, 0, False);
|
||||
ps->offset = len;
|
||||
data = mem_data(&ps->data, 0);
|
||||
if (data == NULL || len <= 0)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
memcpy(data, smb_base(msrpc->inbuf), len);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send an smb to a fd and re-establish if necessary
|
||||
****************************************************************************/
|
||||
BOOL msrpc_send(struct msrpc_state *msrpc, BOOL show)
|
||||
{
|
||||
size_t len;
|
||||
size_t nwritten=0;
|
||||
ssize_t ret;
|
||||
|
||||
len = smb_len(msrpc->outbuf) + 4;
|
||||
|
||||
dump_data(10, msrpc->outbuf, len);
|
||||
|
||||
while (nwritten < len)
|
||||
{
|
||||
ret = write_socket(msrpc->fd,msrpc->outbuf+nwritten,len - nwritten);
|
||||
if (ret <= 0)
|
||||
{
|
||||
DEBUG(0,("Error writing %d bytes to msrpcent. %d. Exiting\n",
|
||||
len,ret));
|
||||
return False;
|
||||
}
|
||||
nwritten += ret;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
open the msrpcent sockets
|
||||
****************************************************************************/
|
||||
BOOL msrpc_connect(struct msrpc_state *msrpc, const char *pipe_name)
|
||||
{
|
||||
fstring path;
|
||||
slprintf(path, sizeof(path)-1, "/tmp/.msrpc/%s", pipe_name);
|
||||
|
||||
fstrcpy(msrpc->pipe_name, pipe_name);
|
||||
|
||||
msrpc->fd = open_pipe_sock(path);
|
||||
|
||||
if (msrpc->fd == -1)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
initialise a msrpcent structure
|
||||
****************************************************************************/
|
||||
void msrpc_init_creds(struct msrpc_state *msrpc, const struct user_creds *usr)
|
||||
{
|
||||
copy_user_creds(&msrpc->usr, usr);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
close the socket descriptor
|
||||
****************************************************************************/
|
||||
void msrpc_close_socket(struct msrpc_state *msrpc)
|
||||
{
|
||||
if (msrpc->fd != -1)
|
||||
{
|
||||
close(msrpc->fd);
|
||||
}
|
||||
msrpc->fd = -1;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
set socket options on a open connection
|
||||
****************************************************************************/
|
||||
void msrpc_sockopt(struct msrpc_state *msrpc, char *options)
|
||||
{
|
||||
set_socket_options(msrpc->fd, options);
|
||||
}
|
||||
|
||||
|
||||
static BOOL msrpc_authenticate(struct msrpc_state *msrpc,
|
||||
const struct user_creds *usr)
|
||||
{
|
||||
struct msrpc_state msrpc_redir;
|
||||
|
||||
int sock = msrpc->fd;
|
||||
char *data;
|
||||
prs_struct ps;
|
||||
uint32 len;
|
||||
char *in = msrpc->inbuf;
|
||||
char *out = msrpc->outbuf;
|
||||
uint16 command;
|
||||
|
||||
command = usr != NULL ? AGENT_CMD_CON : AGENT_CMD_CON_ANON;
|
||||
|
||||
if (!create_user_creds(&ps, msrpc->pipe_name, 0x0, command, usr))
|
||||
{
|
||||
DEBUG(0,("could not parse credentials\n"));
|
||||
close(sock);
|
||||
return False;
|
||||
}
|
||||
|
||||
len = ps.offset;
|
||||
data = mem_data(&ps.data, 0);
|
||||
|
||||
SIVAL(data, 0, len);
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("data len: %d\n", len));
|
||||
dump_data(100, data, len);
|
||||
#endif
|
||||
|
||||
if (write(sock, data, len) <= 0)
|
||||
{
|
||||
DEBUG(0,("write failed\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (msrpc->redirect)
|
||||
{
|
||||
len = read(sock, &msrpc_redir, sizeof(msrpc_redir));
|
||||
|
||||
if (len != sizeof(msrpc_redir))
|
||||
{
|
||||
DEBUG(0,("read failed\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
memcpy(msrpc, &msrpc_redir, sizeof(msrpc_redir));
|
||||
msrpc->inbuf = in;
|
||||
msrpc->outbuf = out;
|
||||
msrpc->fd = sock;
|
||||
msrpc->usr.reuse = False;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 status;
|
||||
len = read(sock, &status, sizeof(status));
|
||||
|
||||
return len == sizeof(status) && status == 0x0;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
static BOOL msrpc_init_redirect(struct msrpc_state *msrpc,
|
||||
const char* pipe_name,
|
||||
const struct user_creds *usr)
|
||||
{
|
||||
int sock;
|
||||
fstring path;
|
||||
|
||||
slprintf(path, sizeof(path)-1, "/tmp/.msrpc/.%s/agent", pipe_name);
|
||||
|
||||
sock = open_pipe_sock(path);
|
||||
|
||||
if (sock < 0)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
msrpc->fd = sock;
|
||||
|
||||
if (!msrpc_authenticate(msrpc, usr))
|
||||
{
|
||||
DEBUG(0,("authenticate failed\n"));
|
||||
close(msrpc->fd);
|
||||
msrpc->fd = -1;
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL msrpc_connect_auth(struct msrpc_state *msrpc,
|
||||
const char* pipename,
|
||||
const struct user_creds *usr)
|
||||
{
|
||||
ZERO_STRUCTP(msrpc);
|
||||
if (!msrpc_initialise(msrpc))
|
||||
{
|
||||
DEBUG(0,("unable to initialise msrpcent connection.\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
msrpc_init_creds(msrpc, usr);
|
||||
|
||||
if (!msrpc_establish_connection(msrpc, pipename))
|
||||
{
|
||||
msrpc_shutdown(msrpc);
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initialise a msrpcent structure
|
||||
****************************************************************************/
|
||||
struct msrpc_state *msrpc_initialise(struct msrpc_state *msrpc)
|
||||
{
|
||||
if (!msrpc) {
|
||||
msrpc = (struct msrpc_state *)malloc(sizeof(*msrpc));
|
||||
if (!msrpc)
|
||||
return NULL;
|
||||
ZERO_STRUCTP(msrpc);
|
||||
}
|
||||
|
||||
if (msrpc->initialised) {
|
||||
msrpc_shutdown(msrpc);
|
||||
}
|
||||
|
||||
ZERO_STRUCTP(msrpc);
|
||||
|
||||
msrpc->fd = -1;
|
||||
msrpc->outbuf = (char *)malloc(CLI_BUFFER_SIZE+4);
|
||||
msrpc->inbuf = (char *)malloc(CLI_BUFFER_SIZE+4);
|
||||
if (!msrpc->outbuf || !msrpc->inbuf)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
msrpc->initialised = 1;
|
||||
msrpc_init_creds(msrpc, NULL);
|
||||
|
||||
return msrpc;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
shutdown a msrpcent structure
|
||||
****************************************************************************/
|
||||
void msrpc_shutdown(struct msrpc_state *msrpc)
|
||||
{
|
||||
DEBUG(10,("msrpc_shutdown\n"));
|
||||
if (msrpc->outbuf)
|
||||
{
|
||||
free(msrpc->outbuf);
|
||||
}
|
||||
if (msrpc->inbuf)
|
||||
{
|
||||
free(msrpc->inbuf);
|
||||
}
|
||||
msrpc_close_socket(msrpc);
|
||||
memset(msrpc, 0, sizeof(*msrpc));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
establishes a connection right up to doing tconX, reading in a password.
|
||||
****************************************************************************/
|
||||
BOOL msrpc_establish_connection(struct msrpc_state *msrpc,
|
||||
const char *pipe_name)
|
||||
{
|
||||
DEBUG(5,("msrpc_establish_connection: connecting to %s (%s) - %s\n",
|
||||
pipe_name,
|
||||
msrpc->usr.ntc.user_name, msrpc->usr.ntc.domain));
|
||||
|
||||
/* establish connection */
|
||||
|
||||
if ((!msrpc->initialised))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (msrpc->fd == -1 && msrpc->redirect)
|
||||
{
|
||||
if (msrpc_init_redirect(msrpc, pipe_name, &msrpc->usr))
|
||||
{
|
||||
DEBUG(10,("msrpc_establish_connection: redirected OK\n"));
|
||||
return True;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(10,("redirect FAILED\n"));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
if (msrpc->fd == -1)
|
||||
{
|
||||
if (!msrpc_connect(msrpc, pipe_name))
|
||||
{
|
||||
DEBUG(1,("msrpc_establish_connection: failed %s)\n",
|
||||
pipe_name));
|
||||
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
if (!msrpc_authenticate(msrpc, &msrpc->usr))
|
||||
{
|
||||
DEBUG(0,("authenticate failed\n"));
|
||||
close(msrpc->fd);
|
||||
msrpc->fd = -1;
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
@ -1,321 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB client generic functions
|
||||
Copyright (C) Andrew Tridgell 1994-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
#include "trans2.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern pstring scope;
|
||||
extern pstring global_myname;
|
||||
|
||||
struct msrpc_use
|
||||
{
|
||||
struct msrpc_state *cli;
|
||||
uint32 num_users;
|
||||
};
|
||||
|
||||
static struct msrpc_use **msrpcs = NULL;
|
||||
uint32 num_msrpcs = 0;
|
||||
|
||||
/****************************************************************************
|
||||
terminate client connection
|
||||
****************************************************************************/
|
||||
static void msrpc_use_free(struct msrpc_use *cli)
|
||||
{
|
||||
if (cli->cli != NULL)
|
||||
{
|
||||
if (cli->cli->initialised)
|
||||
{
|
||||
msrpc_shutdown(cli->cli);
|
||||
}
|
||||
free(cli->cli);
|
||||
}
|
||||
|
||||
free(cli);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
free a client array
|
||||
****************************************************************************/
|
||||
static void free_msrpc_array(uint32 num_entries, struct msrpc_use **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&msrpc_use_free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
add a client state to the array
|
||||
****************************************************************************/
|
||||
static struct msrpc_use* add_msrpc_to_array(uint32 *len,
|
||||
struct msrpc_use ***array,
|
||||
struct msrpc_use *cli)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_msrpcs; i++)
|
||||
{
|
||||
if (msrpcs[i] == NULL)
|
||||
{
|
||||
msrpcs[i] = cli;
|
||||
return cli;
|
||||
}
|
||||
}
|
||||
|
||||
return (struct msrpc_use*)add_item_to_array(len,
|
||||
(void***)array, (void*)cli);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initiate client array
|
||||
****************************************************************************/
|
||||
void init_msrpc_use(void)
|
||||
{
|
||||
msrpcs = NULL;
|
||||
num_msrpcs = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
terminate client array
|
||||
****************************************************************************/
|
||||
void free_msrpc_use(void)
|
||||
{
|
||||
free_msrpc_array(num_msrpcs, msrpcs);
|
||||
init_msrpc_use();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
find client state. server name, user name, domain name and password must all
|
||||
match.
|
||||
****************************************************************************/
|
||||
static struct msrpc_use *msrpc_find(const char* pipe_name,
|
||||
const struct user_creds *usr_creds)
|
||||
{
|
||||
int i;
|
||||
struct user_creds null_usr;
|
||||
|
||||
copy_user_creds(&null_usr, usr_creds);
|
||||
usr_creds = &null_usr;
|
||||
|
||||
DEBUG(10,("msrpc_find: %s %s %s\n",
|
||||
pipe_name,
|
||||
usr_creds->ntc.user_name,
|
||||
usr_creds->ntc.domain));
|
||||
|
||||
for (i = 0; i < num_msrpcs; i++)
|
||||
{
|
||||
char *msrpc_name = NULL;
|
||||
struct msrpc_use *c = msrpcs[i];
|
||||
|
||||
if (c == NULL) continue;
|
||||
|
||||
msrpc_name = c->cli->pipe_name;
|
||||
|
||||
DEBUG(10,("msrpc_find[%d]: %s %s %s\n",
|
||||
i, msrpc_name,
|
||||
c->cli->usr.ntc.user_name,
|
||||
c->cli->usr.ntc.domain));
|
||||
|
||||
if (!strequal(msrpc_name, pipe_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!strequal(usr_creds->ntc.user_name, c->cli->usr.ntc.user_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!usr_creds->reuse &&
|
||||
!pwd_compare(&usr_creds->ntc.pwd, &c->cli->usr.ntc.pwd))
|
||||
{
|
||||
DEBUG(100,("password doesn't match\n"));
|
||||
continue;
|
||||
}
|
||||
if (usr_creds->ntc.domain[0] == 0)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
if (strequal(usr_creds->ntc.domain, c->cli->usr.ntc.domain))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
create a new client state from user credentials
|
||||
****************************************************************************/
|
||||
static struct msrpc_use *msrpc_use_get(const char* pipe_name,
|
||||
const struct user_creds *usr_creds)
|
||||
{
|
||||
struct msrpc_use *cli = (struct msrpc_use*)malloc(sizeof(*cli));
|
||||
|
||||
if (cli == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(cli, 0, sizeof(*cli));
|
||||
|
||||
cli->cli = msrpc_initialise(NULL);
|
||||
|
||||
if (cli->cli == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msrpc_init_creds(cli->cli, usr_creds);
|
||||
|
||||
return cli;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
init client state
|
||||
****************************************************************************/
|
||||
struct msrpc_state *msrpc_use_add(const char* pipe_name,
|
||||
const struct user_creds *usr_creds,
|
||||
BOOL redir)
|
||||
{
|
||||
struct msrpc_use *cli = msrpc_find(pipe_name, usr_creds);
|
||||
|
||||
if (cli != NULL)
|
||||
{
|
||||
cli->num_users++;
|
||||
return cli->cli;
|
||||
}
|
||||
|
||||
/* reuse an existing connection requested, and one was not found */
|
||||
if (usr_creds != NULL && usr_creds->reuse && !redir)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate
|
||||
*/
|
||||
|
||||
cli = msrpc_use_get(pipe_name, usr_creds);
|
||||
cli->cli->redirect = redir;
|
||||
|
||||
if (!msrpc_establish_connection(cli->cli, pipe_name))
|
||||
{
|
||||
DEBUG(0,("msrpc_net_use_add: connection failed\n"));
|
||||
cli->cli = NULL;
|
||||
msrpc_use_free(cli);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
add_msrpc_to_array(&num_msrpcs, &msrpcs, cli);
|
||||
cli->num_users++;
|
||||
|
||||
return cli->cli;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
delete a client state
|
||||
****************************************************************************/
|
||||
BOOL msrpc_use_del(const char* pipe_name,
|
||||
const struct user_creds *usr_creds,
|
||||
BOOL force_close,
|
||||
BOOL *connection_closed)
|
||||
{
|
||||
int i;
|
||||
|
||||
DEBUG(10,("msrpc_net_use_del: %s. force close: %s\n",
|
||||
pipe_name, BOOLSTR(force_close)));
|
||||
|
||||
if (connection_closed != NULL)
|
||||
{
|
||||
*connection_closed = False;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_msrpcs; i++)
|
||||
{
|
||||
char *msrpc_name = NULL;
|
||||
|
||||
if (msrpcs[i] == NULL) continue;
|
||||
if (msrpcs[i]->cli == NULL) continue;
|
||||
|
||||
msrpc_name = msrpcs[i]->cli->pipe_name;
|
||||
|
||||
if (!strequal(msrpc_name, pipe_name)) continue;
|
||||
|
||||
if (strequal(usr_creds->ntc.user_name,
|
||||
msrpcs[i]->cli->usr.ntc.user_name) &&
|
||||
strequal(usr_creds->ntc.domain,
|
||||
msrpcs[i]->cli->usr.ntc.domain))
|
||||
{
|
||||
/* decrement number of users */
|
||||
msrpcs[i]->num_users--;
|
||||
|
||||
DEBUG(10,("idx: %i num_users now: %d\n",
|
||||
i, msrpcs[i]->num_users));
|
||||
|
||||
if (force_close || msrpcs[i]->num_users == 0)
|
||||
{
|
||||
msrpc_use_free(msrpcs[i]);
|
||||
msrpcs[i] = NULL;
|
||||
if (connection_closed != NULL)
|
||||
{
|
||||
*connection_closed = True;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
enumerate client states
|
||||
****************************************************************************/
|
||||
void msrpc_net_use_enum(uint32 *num_cons, struct use_info ***use)
|
||||
{
|
||||
int i;
|
||||
|
||||
*num_cons = 0;
|
||||
*use = NULL;
|
||||
|
||||
for (i = 0; i < num_msrpcs; i++)
|
||||
{
|
||||
struct use_info item;
|
||||
|
||||
ZERO_STRUCT(item);
|
||||
|
||||
if (msrpcs[i] == NULL) continue;
|
||||
|
||||
item.connected = msrpcs[i]->cli != NULL ? True : False;
|
||||
|
||||
if (item.connected)
|
||||
{
|
||||
item.srv_name = msrpcs[i]->cli->pipe_name;
|
||||
item.user_name = msrpcs[i]->cli->usr.ntc.user_name;
|
||||
item.domain = msrpcs[i]->cli->usr.ntc.domain;
|
||||
}
|
||||
|
||||
add_use_info_to_array(num_cons, use, &item);
|
||||
}
|
||||
}
|
||||
|
@ -1,358 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
code to query kernel netmask
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
/* working out the netmask for an interface is an incredibly non-portable
|
||||
thing. We have several possible implementations below, and autoconf
|
||||
tries each of them to see what works
|
||||
|
||||
Note that this file does _not_ include includes.h. That is so this code
|
||||
can be called directly from the autoconf tests. That also means
|
||||
this code cannot use any of the normal Samba debug stuff or defines.
|
||||
This is standalone code.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef AUTOCONF
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETMASK_IFCONF
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifndef SIOCGIFCONF
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Prototype for gcc in fussy mode.
|
||||
*/
|
||||
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask);
|
||||
|
||||
/****************************************************************************
|
||||
get the netmask address for a local interface
|
||||
****************************************************************************/
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
struct ifconf ifc;
|
||||
char buff[2048];
|
||||
int fd, i, n;
|
||||
struct ifreq *ifr=NULL;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"socket failed\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifc.ifc_len = sizeof(buff);
|
||||
ifc.ifc_buf = buff;
|
||||
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifr = ifc.ifc_req;
|
||||
|
||||
n = ifc.ifc_len / sizeof(struct ifreq);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"%d interfaces - looking for %s\n",
|
||||
n, inet_ntoa(*ipaddr));
|
||||
#endif
|
||||
|
||||
/* Loop through interfaces, looking for given IP address */
|
||||
for (i=n-1;i>=0;i--) {
|
||||
if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFADDR failed\n");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface %s\n",
|
||||
inet_ntoa((*(struct sockaddr_in *)&ifr[i].ifr_addr).sin_addr));
|
||||
#endif
|
||||
if (ipaddr->s_addr !=
|
||||
(*(struct sockaddr_in *)&ifr[i].ifr_addr).sin_addr.s_addr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFNETMASK failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
(*nmask) = ((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface not found\n");
|
||||
#endif
|
||||
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_NETMASK_IFREQ)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifndef SIOCGIFCONF
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
#ifndef I_STR
|
||||
#include <sys/stropts.h>
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
this should cover most of the rest of systems
|
||||
****************************************************************************/
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
struct ifreq ifreq;
|
||||
struct strioctl strioctl;
|
||||
struct ifconf *ifc;
|
||||
char buff[2048];
|
||||
int fd, i, n;
|
||||
struct ifreq *ifr=NULL;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"socket failed\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifc = (struct ifconf *)buff;
|
||||
ifc->ifc_len = BUFSIZ - sizeof(struct ifconf);
|
||||
strioctl.ic_cmd = SIOCGIFCONF;
|
||||
strioctl.ic_dp = (char *)ifc;
|
||||
strioctl.ic_len = sizeof(buff);
|
||||
if (ioctl(fd, I_STR, &strioctl) < 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifr = (struct ifreq *)ifc->ifc_req;
|
||||
|
||||
/* Loop through interfaces, looking for given IP address */
|
||||
n = ifc->ifc_len / sizeof(struct ifreq);
|
||||
|
||||
for (i = 0; i<n; i++, ifr++) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface %s\n",
|
||||
inet_ntoa((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr.s_addr));
|
||||
#endif
|
||||
if (ipaddr->s_addr ==
|
||||
(*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (i == n) {
|
||||
fprintf(stderr,"interface not found\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ifreq = *ifr;
|
||||
|
||||
strioctl.ic_cmd = SIOCGIFNETMASK;
|
||||
strioctl.ic_dp = (char *)&ifreq;
|
||||
strioctl.ic_len = sizeof(struct ifreq);
|
||||
if (ioctl(fd, I_STR, &strioctl) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"Failed SIOCGIFNETMASK\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
*nmask = ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_NETMASK_AIX)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#ifndef SIOCGIFCONF
|
||||
#include <sys/sockio.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
this one is for AIX
|
||||
****************************************************************************/
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
char buff[2048];
|
||||
int fd, i, n;
|
||||
struct ifconf ifc;
|
||||
struct ifreq *ifr=NULL;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"socket failed\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ifc.ifc_len = sizeof(buff);
|
||||
ifc.ifc_buf = buff;
|
||||
|
||||
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifr = ifc.ifc_req;
|
||||
/* Loop through interfaces, looking for given IP address */
|
||||
i = ifc.ifc_len;
|
||||
while (i > 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"interface %s\n",
|
||||
inet_ntoa((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr));
|
||||
#endif
|
||||
if (ipaddr->s_addr ==
|
||||
(*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr) {
|
||||
break;
|
||||
}
|
||||
i -= ifr->ifr_addr.sa_len + IFNAMSIZ;
|
||||
ifr = (struct ifreq*) ((char*) ifr + ifr->ifr_addr.sa_len +
|
||||
IFNAMSIZ);
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
if (i <= 0) {
|
||||
fprintf(stderr,"interface not found\n");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"SIOCGIFNETMASK failed\n");
|
||||
#endif
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
(*nmask) = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* a dummy version */
|
||||
struct in_addr; /* it may not have been declared before */
|
||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef AUTOCONF
|
||||
/* this is the autoconf driver to test get_netmask() */
|
||||
|
||||
main()
|
||||
{
|
||||
char buf[1024];
|
||||
struct hostent *hp;
|
||||
struct in_addr ip, nmask;
|
||||
|
||||
if (gethostname(buf, sizeof(buf)-1) != 0) {
|
||||
fprintf(stderr,"gethostname failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
hp = gethostbyname(buf);
|
||||
|
||||
if (!hp) {
|
||||
fprintf(stderr,"gethostbyname failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memcpy((char *)&ip, (char *)hp->h_addr, hp->h_length);
|
||||
|
||||
if (get_netmask(&ip, &nmask) == 0) exit(0);
|
||||
|
||||
fprintf(stderr,"get_netmask failed\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
@ -1,289 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Password and authentication handling
|
||||
Copyright (C) Andrew Tridgell 1992-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 pstring scope;
|
||||
extern pstring global_myname;
|
||||
extern fstring global_myworkgroup;
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
core of smb password checking routine.
|
||||
****************************************************************************/
|
||||
static BOOL smb_pwd_check_ntlmv1(char *password, unsigned char *part_passwd,
|
||||
unsigned char *c8,
|
||||
uchar user_sess_key[16])
|
||||
{
|
||||
/* Finish the encryption of part_passwd. */
|
||||
unsigned char p24[24];
|
||||
|
||||
if (part_passwd == NULL)
|
||||
DEBUG(10,("No password set - allowing access\n"));
|
||||
/* No password set - always true ! */
|
||||
if (part_passwd == NULL)
|
||||
return True;
|
||||
|
||||
SMBOWFencrypt(part_passwd, c8, p24);
|
||||
if (user_sess_key != NULL)
|
||||
{
|
||||
SMBsesskeygen_ntv1(part_passwd, NULL, user_sess_key);
|
||||
}
|
||||
|
||||
#if DEBUG_PASSWORD
|
||||
DEBUG(100,("Part password (P16) was |"));
|
||||
dump_data(100, part_passwd, 16);
|
||||
DEBUG(100,("Password from client was |"));
|
||||
dump_data(100, password, 24);
|
||||
DEBUG(100,("Given challenge was |"));
|
||||
dump_data(100, c8, 8);
|
||||
DEBUG(100,("Value from encryption was |"));
|
||||
dump_data(100, p24, 24);
|
||||
#endif
|
||||
return (memcmp(p24, password, 24) == 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
core of smb password checking routine.
|
||||
****************************************************************************/
|
||||
static BOOL smb_pwd_check_ntlmv2(char *password, size_t pwd_len,
|
||||
unsigned char *part_passwd,
|
||||
unsigned char const *c8,
|
||||
const char *user, const char *domain,
|
||||
char *user_sess_key)
|
||||
{
|
||||
/* Finish the encryption of part_passwd. */
|
||||
unsigned char kr[16];
|
||||
unsigned char resp[16];
|
||||
|
||||
if (part_passwd == NULL)
|
||||
{
|
||||
DEBUG(10,("No password set - allowing access\n"));
|
||||
}
|
||||
/* No password set - always true ! */
|
||||
if (part_passwd == NULL)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
ntv2_owf_gen(part_passwd, user, domain, kr);
|
||||
SMBOWFencrypt_ntv2(kr, c8, 8, password+16, pwd_len-16, resp);
|
||||
if (user_sess_key != NULL)
|
||||
{
|
||||
SMBsesskeygen_ntv2(kr, resp, user_sess_key);
|
||||
}
|
||||
|
||||
#if DEBUG_PASSWORD
|
||||
DEBUG(100,("Part password (P16) was |"));
|
||||
dump_data(100, part_passwd, 16);
|
||||
DEBUG(100,("Password from client was |"));
|
||||
dump_data(100, password, pwd_len);
|
||||
DEBUG(100,("Given challenge was |"));
|
||||
dump_data(100, c8, 8);
|
||||
DEBUG(100,("Value from encryption was |"));
|
||||
dump_data(100, resp, 16);
|
||||
#endif
|
||||
|
||||
return (memcmp(resp, password, 16) == 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
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 challenge[8],
|
||||
const char *user, const char *domain,
|
||||
uchar *lm_pass, size_t lm_pwd_len,
|
||||
uchar *nt_pass, size_t nt_pwd_len,
|
||||
uchar user_sess_key[16])
|
||||
{
|
||||
if (smb_pass == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
DEBUG(4,("Checking SMB password for user %s\n",
|
||||
smb_pass->unix_name));
|
||||
|
||||
if (smb_pass->acct_ctrl & ACB_DISABLED)
|
||||
{
|
||||
DEBUG(3,("account for user %s was disabled.\n",
|
||||
smb_pass->unix_name));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (challenge == NULL)
|
||||
{
|
||||
DEBUG(1,("no challenge available - password failed\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
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).
|
||||
*/
|
||||
if (lp_server_ntlmv2() != False && nt_pwd_len > 24)
|
||||
{
|
||||
DEBUG(4,("smb_password_ok: Check NTLMv2 password\n"));
|
||||
if (smb_pwd_check_ntlmv2(nt_pass, nt_pwd_len,
|
||||
(uchar *)smb_pass->smb_nt_passwd,
|
||||
challenge, user, domain,
|
||||
user_sess_key))
|
||||
{
|
||||
return True;
|
||||
}
|
||||
}
|
||||
if (lp_server_ntlmv2() != True && nt_pwd_len == 24)
|
||||
{
|
||||
DEBUG(4,("smb_password_ok: Check NT MD4 password\n"));
|
||||
if (smb_pwd_check_ntlmv1((char *)nt_pass,
|
||||
(uchar *)smb_pass->smb_nt_passwd,
|
||||
challenge,
|
||||
user_sess_key))
|
||||
{
|
||||
DEBUG(4,("NT MD4 password check succeeded\n"));
|
||||
return True;
|
||||
}
|
||||
}
|
||||
DEBUG(4,("NT MD4 password check failed\n"));
|
||||
}
|
||||
|
||||
if (lp_server_ntlmv2() == True)
|
||||
{
|
||||
DEBUG(4,("Not checking LM MD4 password\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/* 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,("no password required for user %s\n",
|
||||
smb_pass->unix_name));
|
||||
return True;
|
||||
}
|
||||
|
||||
if ((smb_pass->smb_passwd != NULL) &&
|
||||
smb_pwd_check_ntlmv1((char *)lm_pass,
|
||||
(uchar *)smb_pass->smb_passwd,
|
||||
challenge, NULL))
|
||||
{
|
||||
DEBUG(4,("LM MD4 password check succeeded\n"));
|
||||
return(True);
|
||||
}
|
||||
|
||||
DEBUG(4,("LM MD4 password check failed\n"));
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
check if a username/password is OK assuming the password is a 24 byte
|
||||
SMB hash
|
||||
return True if the password is correct, False otherwise
|
||||
****************************************************************************/
|
||||
BOOL pass_check_smb(struct smb_passwd *smb_pass, char *domain, uchar *chal,
|
||||
uchar *lm_pwd, size_t lm_pwd_len,
|
||||
uchar *nt_pwd, size_t nt_pwd_len,
|
||||
struct passwd *pwd, uchar user_sess_key[16])
|
||||
{
|
||||
const struct passwd *pass;
|
||||
struct passwd pw;
|
||||
char *user = NULL;
|
||||
|
||||
if (smb_pass == NULL)
|
||||
{
|
||||
DEBUG(3,("Couldn't find user %s in smb_passwd file.\n", user));
|
||||
return False;
|
||||
}
|
||||
|
||||
user = smb_pass->unix_name;
|
||||
|
||||
if (lm_pwd == NULL || nt_pwd == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (pwd != NULL && user == NULL)
|
||||
{
|
||||
pass = (struct passwd *) pwd;
|
||||
user = pass->pw_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
pass = Get_Pwnam(user,True);
|
||||
if (pass == NULL)
|
||||
{
|
||||
DEBUG(3,("Couldn't find user %s\n",user));
|
||||
return False;
|
||||
}
|
||||
memcpy(&pw, pass, sizeof(struct passwd));
|
||||
pass = &pw;
|
||||
}
|
||||
|
||||
/* Quit if the account was disabled. */
|
||||
if (smb_pass->acct_ctrl & ACB_DISABLED) {
|
||||
DEBUG(3,("account for user %s was disabled.\n", user));
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Ensure the uid's match */
|
||||
if (smb_pass->unix_uid != pass->pw_uid)
|
||||
{
|
||||
DEBUG(3,("Error : UNIX (%d) and SMB (%d) uids in password files do not match !\n", pass->pw_uid, smb_pass->unix_uid));
|
||||
return False;
|
||||
}
|
||||
|
||||
if (lm_pwd[0] == '\0' && IS_BITS_SET_ALL(smb_pass->acct_ctrl, ACB_PWNOTREQ) && lp_null_passwords())
|
||||
{
|
||||
DEBUG(3,("account for user %s has no password and null passwords are allowed.\n", smb_pass->unix_name));
|
||||
return(True);
|
||||
}
|
||||
|
||||
if (smb_password_ok(smb_pass, chal, user, domain,
|
||||
lm_pwd, lm_pwd_len,
|
||||
nt_pwd, nt_pwd_len,
|
||||
user_sess_key))
|
||||
{
|
||||
if (user_sess_key != NULL)
|
||||
{
|
||||
#ifdef DEBUG_PASSWORD
|
||||
DEBUG(100,("user session key: "));
|
||||
dump_data(100, user_sess_key, 16);
|
||||
#endif
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
|
||||
DEBUG(3,("Error pass_check_smb failed\n"));
|
||||
return False;
|
||||
}
|
||||
|
@ -1,523 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-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 pstring scope;
|
||||
extern pstring global_myname;
|
||||
|
||||
/*
|
||||
* This is set on startup - it defines the SID for this
|
||||
* machine, and therefore the SAM database for which it is
|
||||
* responsible.
|
||||
*/
|
||||
|
||||
DOM_SID global_sam_sid;
|
||||
|
||||
/*
|
||||
* This is the name associated with the SAM database for
|
||||
* which this machine is responsible. In the case of a PDC
|
||||
* or PDC, this name is the same as the workgroup. In the
|
||||
* case of "security = domain" mode, this is the same as
|
||||
* the name of the server (global_myname).
|
||||
*/
|
||||
|
||||
fstring global_sam_name;
|
||||
|
||||
/*
|
||||
* This is obtained on startup - it defines the SID for which
|
||||
* this machine is a member. It is therefore only set, and
|
||||
* used, in "security = domain" mode.
|
||||
*/
|
||||
|
||||
DOM_SID global_member_sid;
|
||||
|
||||
/*
|
||||
* note the lack of a "global_member_name" - this is because
|
||||
* this is the same as "global_myworkgroup".
|
||||
*/
|
||||
|
||||
extern fstring global_myworkgroup;
|
||||
/* fstring global_member_dom_name; */
|
||||
|
||||
/*
|
||||
* some useful sids
|
||||
*/
|
||||
|
||||
DOM_SID global_sid_S_1_5_20; /* local well-known domain */
|
||||
DOM_SID global_sid_S_1_1; /* everyone */
|
||||
DOM_SID global_sid_S_1_3; /* Creator Owner */
|
||||
DOM_SID global_sid_S_1_5; /* NT Authority */
|
||||
|
||||
struct sid_map
|
||||
{
|
||||
DOM_SID *sid;
|
||||
char *name;
|
||||
|
||||
};
|
||||
|
||||
struct sid_map static_sid_name_map[] =
|
||||
{
|
||||
{ &global_sid_S_1_5_20, "BUILTIN" },
|
||||
{ &global_sid_S_1_1 , "Everyone" },
|
||||
{ &global_sid_S_1_3 , "Creator Owner" },
|
||||
{ &global_sid_S_1_5 , "NT Authority" },
|
||||
{ &global_sam_sid , global_sam_name },
|
||||
{ &global_member_sid , global_myworkgroup },
|
||||
{ NULL , NULL }
|
||||
};
|
||||
|
||||
struct sid_map **sid_name_map = NULL;
|
||||
uint32 num_maps = 0;
|
||||
|
||||
static struct sid_map *sid_map_dup(const struct sid_map *from)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
struct sid_map *copy = (struct sid_map *)
|
||||
malloc(sizeof(struct sid_map));
|
||||
if (copy != NULL)
|
||||
{
|
||||
ZERO_STRUCTP(copy);
|
||||
if (from->name != NULL)
|
||||
{
|
||||
copy->name = strdup(from->name );
|
||||
}
|
||||
if (from->sid != NULL)
|
||||
{
|
||||
copy->sid = sid_dup(from->sid);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void sid_map_free(struct sid_map *map)
|
||||
{
|
||||
if (map->name != NULL)
|
||||
{
|
||||
free(map->name);
|
||||
}
|
||||
if (map->sid != NULL)
|
||||
{
|
||||
free(map->sid);
|
||||
}
|
||||
free(map);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
free a sid map array
|
||||
****************************************************************************/
|
||||
static void free_sidmap_array(uint32 num_entries, struct sid_map **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&sid_map_free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
add a sid map state to the array
|
||||
****************************************************************************/
|
||||
struct sid_map* add_sidmap_to_array(uint32 *len, struct sid_map ***array,
|
||||
const struct sid_map *name)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&sid_map_dup;
|
||||
return (struct sid_map*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)name, *fn, False);
|
||||
|
||||
}
|
||||
/****************************************************************************
|
||||
sets up the name associated with the SAM database for which we are responsible
|
||||
****************************************************************************/
|
||||
void get_sam_domain_name(void)
|
||||
{
|
||||
switch (lp_server_role())
|
||||
{
|
||||
case ROLE_DOMAIN_PDC:
|
||||
case ROLE_DOMAIN_BDC:
|
||||
{
|
||||
/* we are PDC (or BDC) for a Domain */
|
||||
fstrcpy(global_sam_name, lp_workgroup());
|
||||
break;
|
||||
}
|
||||
case ROLE_DOMAIN_MEMBER:
|
||||
{
|
||||
/* we are a "PDC", but FOR LOCAL SAM DATABASE ONLY */
|
||||
fstrcpy(global_sam_name, global_myname);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
/* no domain role, probably due to "security = share" */
|
||||
memset(global_sam_name, 0, sizeof(global_sam_name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
obtain the sid from the PDC.
|
||||
****************************************************************************/
|
||||
BOOL get_member_domain_sid(void)
|
||||
{
|
||||
switch (lp_server_role())
|
||||
{
|
||||
case ROLE_DOMAIN_NONE:
|
||||
{
|
||||
ZERO_STRUCT(global_member_sid);
|
||||
return True;
|
||||
}
|
||||
case ROLE_DOMAIN_PDC:
|
||||
{
|
||||
sid_copy(&global_member_sid, &global_sam_sid);
|
||||
return True;
|
||||
}
|
||||
default:
|
||||
{
|
||||
/* member or BDC, we're going for connection to PDC */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return get_domain_sids(lp_workgroup(), NULL, &global_member_sid);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
creates some useful well known sids
|
||||
****************************************************************************/
|
||||
void generate_wellknown_sids(void)
|
||||
{
|
||||
string_to_sid(&global_sid_S_1_5_20, "S-1-5-32");
|
||||
string_to_sid(&global_sid_S_1_1 , "S-1-1" );
|
||||
string_to_sid(&global_sid_S_1_3 , "S-1-3" );
|
||||
string_to_sid(&global_sid_S_1_5 , "S-1-5" );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
create a sid map table
|
||||
****************************************************************************/
|
||||
BOOL create_sidmap_table(void)
|
||||
{
|
||||
int i;
|
||||
char **doms = NULL;
|
||||
uint32 num_doms = 0;
|
||||
|
||||
for (i = 0; static_sid_name_map[i].name != NULL; i++)
|
||||
{
|
||||
add_sidmap_to_array(&num_maps, &sid_name_map,
|
||||
&static_sid_name_map[i]);
|
||||
}
|
||||
|
||||
enumtrustdoms(&doms, &num_doms);
|
||||
|
||||
for (i = 0; i < num_doms; i++)
|
||||
{
|
||||
struct sid_map map;
|
||||
DOM_SID sid;
|
||||
|
||||
map.name = doms[i];
|
||||
map.sid = &sid;
|
||||
|
||||
if (!read_sid(map.name, map.sid))
|
||||
{
|
||||
DEBUG(0,("Could not read Domain SID %s\n", map.name));
|
||||
return False;
|
||||
}
|
||||
add_sidmap_to_array(&num_maps, &sid_name_map, &map);
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < num_maps; i++)
|
||||
{
|
||||
fstring sidstr;
|
||||
sid_to_string(sidstr, sid_name_map[i]->sid);
|
||||
DEBUG(10,("Map:\tDomain:\t%s\tSID:\t%s\n",
|
||||
sid_name_map[i]->name, sidstr));
|
||||
}
|
||||
|
||||
|
||||
free_char_array(num_doms, doms);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Generate the global machine sid. Look for the DOMAINNAME.SID file first, if
|
||||
not found then look in smb.conf and use it to create the DOMAINNAME.SID file.
|
||||
****************************************************************************/
|
||||
BOOL generate_sam_sid(char *domain_name, DOM_SID *sid)
|
||||
{
|
||||
char *p;
|
||||
pstring sid_file;
|
||||
pstring machine_sid_file;
|
||||
fstring file_name;
|
||||
|
||||
pstrcpy(sid_file, lp_smb_passwd_file());
|
||||
|
||||
if (sid_file[0] == 0)
|
||||
{
|
||||
DEBUG(0,("cannot find smb passwd file\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
p = strrchr(sid_file, '/');
|
||||
if (p != NULL)
|
||||
{
|
||||
*++p = '\0';
|
||||
}
|
||||
|
||||
if (!directory_exist(sid_file, NULL)) {
|
||||
if (mkdir(sid_file, 0700) != 0) {
|
||||
DEBUG(0,("can't create private directory %s : %s\n",
|
||||
sid_file, strerror(errno)));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
pstrcpy(machine_sid_file, sid_file);
|
||||
pstrcat(machine_sid_file, "MACHINE.SID");
|
||||
|
||||
slprintf(file_name, sizeof(file_name)-1, "%s.SID", domain_name);
|
||||
strupper(file_name);
|
||||
pstrcat(sid_file, file_name);
|
||||
|
||||
if (file_exist(machine_sid_file, NULL))
|
||||
{
|
||||
if (file_exist(sid_file, NULL))
|
||||
{
|
||||
DEBUG(0,("both %s and %s exist when only one should, unable to continue\n",
|
||||
machine_sid_file, sid_file));
|
||||
return False;
|
||||
}
|
||||
if (file_rename(machine_sid_file, sid_file))
|
||||
{
|
||||
DEBUG(0,("could not rename %s to %s. Error was %s\n",
|
||||
machine_sid_file, sid_file, strerror(errno)));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/* attempt to read the SID from the file */
|
||||
if (read_sid(domain_name, sid))
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
if (!create_new_sid(sid))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
/* attempt to read the SID from the file */
|
||||
if (!write_sid(domain_name, sid))
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
/* during the attempt to write, someone else wrote? */
|
||||
|
||||
/* attempt to read the SID from the file */
|
||||
if (read_sid(domain_name, sid))
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
turns a domain name into a SID.
|
||||
|
||||
*** side-effect: if the domain name is NULL, it is set to our domain ***
|
||||
|
||||
***************************************************************************/
|
||||
BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (nt_domain == NULL)
|
||||
{
|
||||
sid_copy(sid, &global_sam_sid);
|
||||
return True;
|
||||
}
|
||||
|
||||
if ((*nt_domain) == NULL)
|
||||
{
|
||||
DEBUG(5,("map_domain_name_to_sid: overriding NULL name to %s\n",
|
||||
global_sam_name));
|
||||
(*nt_domain) = strdup(global_sam_name);
|
||||
sid_copy(sid, &global_sam_sid);
|
||||
return True;
|
||||
}
|
||||
|
||||
if ((*nt_domain)[0] == 0)
|
||||
{
|
||||
free(*nt_domain);
|
||||
(*nt_domain) = strdup(global_sam_name);
|
||||
DEBUG(5,("map_domain_name_to_sid: overriding blank name to %s\n",
|
||||
(*nt_domain)));
|
||||
sid_copy(sid, &global_sam_sid);
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(5,("map_domain_name_to_sid: %s\n", (*nt_domain)));
|
||||
|
||||
for (i = 0; sid_name_map[i]->name != NULL; i++)
|
||||
{
|
||||
DEBUG(5,("compare: %s\n", sid_name_map[i]->name));
|
||||
if (strequal(sid_name_map[i]->name, (*nt_domain)))
|
||||
{
|
||||
fstring sid_str;
|
||||
sid_copy(sid, sid_name_map[i]->sid);
|
||||
sid_to_string(sid_str, sid_name_map[i]->sid);
|
||||
DEBUG(5,("found %s\n", sid_str));
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(0,("map_domain_name_to_sid: mapping to %s NOT IMPLEMENTED\n",
|
||||
(*nt_domain)));
|
||||
return False;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
turns a domain SID into a name.
|
||||
|
||||
***************************************************************************/
|
||||
BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain)
|
||||
{
|
||||
fstring sid_str;
|
||||
int i = 0;
|
||||
sid_to_string(sid_str, sid);
|
||||
|
||||
DEBUG(5,("map_domain_sid_to_name: %s\n", sid_str));
|
||||
|
||||
if (nt_domain == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
for (i = 0; sid_name_map[i]->sid != NULL; i++)
|
||||
{
|
||||
sid_to_string(sid_str, sid_name_map[i]->sid);
|
||||
DEBUG(5,("compare: %s\n", sid_str));
|
||||
if (sid_equal(sid_name_map[i]->sid, sid))
|
||||
{
|
||||
fstrcpy(nt_domain, sid_name_map[i]->name);
|
||||
DEBUG(5,("found %s\n", nt_domain));
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(0,("map_domain_sid_to_name: mapping NOT IMPLEMENTED\n"));
|
||||
|
||||
return False;
|
||||
}
|
||||
/**************************************************************************
|
||||
turns a domain SID into a domain controller name.
|
||||
***************************************************************************/
|
||||
BOOL map_domain_sid_to_any_dc(DOM_SID *sid, char *dc_name)
|
||||
{
|
||||
fstring domain;
|
||||
|
||||
if (!map_domain_sid_to_name(sid, domain))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return get_any_dc_name(domain, dc_name);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
splits a name of format \DOMAIN\name or name into its two components.
|
||||
sets the DOMAIN name to global_sam_name if it has not been specified.
|
||||
***************************************************************************/
|
||||
BOOL split_domain_name(const char *fullname, char *domain, char *name)
|
||||
{
|
||||
fstring full_name;
|
||||
char *p;
|
||||
|
||||
if (fullname == NULL || domain == NULL || name == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (fullname[0] == '\\')
|
||||
{
|
||||
fullname++;
|
||||
}
|
||||
fstrcpy(full_name, fullname);
|
||||
p = strchr(full_name+1, '\\');
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
*p = 0;
|
||||
fstrcpy(domain, full_name);
|
||||
fstrcpy(name, p+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fstrcpy(domain, global_sam_name);
|
||||
fstrcpy(name, full_name);
|
||||
}
|
||||
|
||||
DEBUG(10,("name '%s' split into domain:%s and nt name:%s'\n", fullname, domain, name));
|
||||
return True;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
enumerates all trusted domains
|
||||
***************************************************************************/
|
||||
BOOL enumtrustdoms(char ***doms, uint32 *num_entries)
|
||||
{
|
||||
fstring tmp;
|
||||
char *tok;
|
||||
|
||||
/* add trusted domains */
|
||||
|
||||
tok = lp_trusted_domains();
|
||||
if (next_token(&tok, tmp, NULL, sizeof(tmp)))
|
||||
{
|
||||
do
|
||||
{
|
||||
fstring domain;
|
||||
split_at_first_component(tmp, domain, '=', NULL);
|
||||
add_chars_to_array(num_entries, doms, domain);
|
||||
|
||||
} while (next_token(NULL, tmp, NULL, sizeof(tmp)));
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
enumerates all domains for which the SAM server is responsible
|
||||
***************************************************************************/
|
||||
BOOL enumdomains(char ***doms, uint32 *num_entries)
|
||||
{
|
||||
add_chars_to_array(num_entries, doms, global_sam_name);
|
||||
add_chars_to_array(num_entries, doms, "Builtin");
|
||||
|
||||
return True;
|
||||
}
|
||||
|
@ -1,140 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-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 "MacExtensions.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/*
|
||||
** Given a path to file/directory build a path to the stream in question.
|
||||
** If it is not a directory they place the .streams folder after the last
|
||||
** slash then add the filename with the stream cat on. If it is a directory
|
||||
** then just cat the .streams folder and the stream on it. If mode is true
|
||||
** then force the .streams directory to be created.
|
||||
**
|
||||
** Some examples.
|
||||
** input::
|
||||
** fname = folder1/folder2/filea
|
||||
** stream = :AFP_Resource:$DATA the resource fork
|
||||
** isDir = False
|
||||
** output::
|
||||
** streampath = folder1/folder2/.streams/filea:AFP_Resource:$DATA
|
||||
**
|
||||
** input::
|
||||
** fname = folder1/folder2
|
||||
** stream = :AFP_AfpInfo:$DATA the Finder Info
|
||||
** isDir = True
|
||||
** output::
|
||||
** streampath = folder1/folder2/.streams/:AFP_Resource:$DATA
|
||||
**
|
||||
*/
|
||||
void makestreampath(char *fname, char *stream, char *streampath, int mode, int isDir, int dirOnly)
|
||||
{
|
||||
char *cptr;
|
||||
|
||||
pstrcpy(streampath, fname);
|
||||
if (!isDir)
|
||||
{
|
||||
cptr = strrchr(streampath, '/');
|
||||
if (cptr) *(cptr+1) = 0;
|
||||
else streampath[0] = 0;
|
||||
}
|
||||
else
|
||||
if (streampath[0] == 0) /* Start at the current position */
|
||||
pstrcat(streampath, "./");
|
||||
else pstrcat(streampath, "/");
|
||||
|
||||
pstrcat(streampath, STREAM_FOLDER_SLASH);
|
||||
if (mode)
|
||||
(void)mkdir(streampath, 0777);
|
||||
if (! dirOnly)
|
||||
{
|
||||
cptr = strrchr(fname, '/');
|
||||
if (!isDir)
|
||||
{
|
||||
cptr = strrchr(fname, '/');
|
||||
if (cptr) pstrcat(streampath, cptr+1);
|
||||
else pstrcat(streampath, fname);
|
||||
}
|
||||
pstrcat(streampath, stream);
|
||||
}
|
||||
DEBUG(4,("MACEXTENSION-makestreampath: streampath = %s\n", streampath));
|
||||
}
|
||||
|
||||
/*
|
||||
** Given a path to file/directory open the stream in question.
|
||||
*/
|
||||
int openstream(char *fname, char *stream, int oflag, int mode, int isDir)
|
||||
{
|
||||
pstring streampath;
|
||||
char *cptr;
|
||||
|
||||
makestreampath(fname, stream, streampath, mode, isDir, False);
|
||||
return(open(streampath, oflag, mode));
|
||||
}
|
||||
|
||||
/*
|
||||
** Fill in the AFP structure with the default values and
|
||||
** then write it out.
|
||||
*/
|
||||
void writedefaultafp(int fd, SambaAfpInfo *safp, int writeit)
|
||||
{
|
||||
safp->afp.afpi_Signature = AFP_Signature; /* Must be *(PDWORD)"AFP" */
|
||||
safp->afp.afpi_Version = AFP_Version; /* Must be 0x00010000 */
|
||||
safp->afp.afpi_Reserved1 = 0;
|
||||
safp->afp.afpi_BackupTime = AFP_BackupTime; /* Backup time for the file/dir */
|
||||
bzero(safp->afp.afpi_FinderInfo, AFP_FinderSize); /* Finder Info (32 bytes) */
|
||||
bzero(safp->afp.afpi_ProDosInfo, 6); /* ProDos Info (6 bytes) # */
|
||||
bzero(safp->afp.afpi_Reserved2, 6);
|
||||
safp->createtime = time(NULL);
|
||||
if (writeit) (void)write(fd, safp, sizeof(*safp));
|
||||
}
|
||||
|
||||
/*
|
||||
** Check to see if the fname has a stream component.
|
||||
** If it does then check to see if it is the data fork
|
||||
** stream. If so then just remove the stream since we
|
||||
** treat them the same otherwise build a path to the
|
||||
** streams folder.
|
||||
** Return true if it is a stream
|
||||
** Return false no stream and the name has not been touched.
|
||||
*/
|
||||
int CheckForStream(char *fname)
|
||||
{
|
||||
pstring streampath;
|
||||
char *cptr;
|
||||
|
||||
cptr = strrchr(fname, ':');
|
||||
/* Must be a streams file */
|
||||
if (cptr && strequal(cptr, DefaultStreamTest))
|
||||
{
|
||||
cptr = strstr(fname, AFPDATA_STREAM);
|
||||
if (cptr) *cptr = 0;/* The datafork just remove the stream name */
|
||||
else /* Build the streams path */
|
||||
{
|
||||
makestreampath(fname, "", streampath, 1, False, False);
|
||||
pstrcpy(fname, streampath);
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
return(False);
|
||||
}
|
@ -1,303 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
uid/user handling
|
||||
Copyright (C) Andrew Tridgell 1992-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 uid_t initial_uid;
|
||||
static gid_t initial_gid;
|
||||
|
||||
/* what context is current */
|
||||
struct unix_sec_ctxt curr_ctxt;
|
||||
|
||||
/****************************************************************************
|
||||
initialise the security context routines
|
||||
****************************************************************************/
|
||||
void init_sec_ctxt(void)
|
||||
{
|
||||
initial_uid = curr_ctxt.uid = geteuid();
|
||||
initial_gid = curr_ctxt.gid = getegid();
|
||||
|
||||
if (initial_gid != 0 && initial_uid == 0) {
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresgid(0,0,0);
|
||||
#else
|
||||
setgid(0);
|
||||
setegid(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
initial_uid = geteuid();
|
||||
initial_gid = getegid();
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
become the specified uid
|
||||
****************************************************************************/
|
||||
static BOOL become_uid(uid_t uid)
|
||||
{
|
||||
if (initial_uid != 0)
|
||||
{
|
||||
return(True);
|
||||
}
|
||||
|
||||
if (uid == (uid_t)-1 || ((sizeof(uid_t) == 2) && (uid == (uid_t)65535)))
|
||||
{
|
||||
static int done;
|
||||
if (!done) {
|
||||
DEBUG(1,("WARNING: using uid %d is a security risk\n",(int)uid));
|
||||
done=1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_TRAPDOOR_UID
|
||||
#ifdef HAVE_SETUIDX
|
||||
/* AIX3 has setuidx which is NOT a trapoor function (tridge) */
|
||||
if (setuidx(ID_EFFECTIVE, uid) != 0) {
|
||||
if (seteuid(uid) != 0) {
|
||||
DEBUG(1,("Can't set uid %d (setuidx)\n", (int)uid));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETRESUID
|
||||
if (setresuid(-1,uid,-1) != 0)
|
||||
#else
|
||||
if ((seteuid(uid) != 0) &&
|
||||
(setuid(uid) != 0))
|
||||
#endif
|
||||
{
|
||||
DEBUG(0,("Couldn't set uid %d currently set to (%d,%d)\n",
|
||||
(int)uid,(int)getuid(), (int)geteuid()));
|
||||
if (uid > (uid_t)32000) {
|
||||
DEBUG(0,("Looks like your OS doesn't like high uid values - try using a different account\n"));
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
if (((uid == (uid_t)-1) || ((sizeof(uid_t) == 2) && (uid == 65535))) && (geteuid() != uid))
|
||||
{
|
||||
DEBUG(0,("Invalid uid -1. perhaps you have a account with uid 65535?\n"));
|
||||
return(False);
|
||||
}
|
||||
|
||||
curr_ctxt.uid = uid;
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
become the specified gid
|
||||
****************************************************************************/
|
||||
static BOOL become_gid(gid_t gid)
|
||||
{
|
||||
if (initial_uid != 0)
|
||||
return(True);
|
||||
|
||||
if (gid == (gid_t)-1 || ((sizeof(gid_t) == 2) && (gid == (gid_t)65535))) {
|
||||
DEBUG(1,("WARNING: using gid %d is a security risk\n",(int)gid));
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETRESUID
|
||||
if (setresgid(-1,gid,-1) != 0)
|
||||
#else
|
||||
if (setgid(gid) != 0)
|
||||
#endif
|
||||
{
|
||||
DEBUG(0,("Couldn't set gid %d currently set to (%d,%d)\n",
|
||||
(int)gid,(int)getgid(),(int)getegid()));
|
||||
if (gid > 32000) {
|
||||
DEBUG(0,("Looks like your OS doesn't like high gid values - try using a different account\n"));
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
curr_ctxt.gid = gid;
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
become the user of a connection number
|
||||
****************************************************************************/
|
||||
BOOL become_unix_sec_ctxt(struct unix_sec_ctxt const *ctxt)
|
||||
{
|
||||
if (curr_ctxt.uid == ctxt->uid)
|
||||
{
|
||||
DEBUG(4,("Skipping become_unix_sec_ctxt - already user\n"));
|
||||
return(True);
|
||||
}
|
||||
|
||||
unbecome_unix_sec_ctxt();
|
||||
|
||||
curr_ctxt.ngroups = ctxt->ngroups;
|
||||
curr_ctxt.groups = ctxt->groups;
|
||||
curr_ctxt.name = ctxt->name;
|
||||
|
||||
if (initial_uid == 0)
|
||||
{
|
||||
if (!become_uid(ctxt->uid)) return(False);
|
||||
#ifdef HAVE_SETGROUPS
|
||||
if (curr_ctxt.ngroups > 0)
|
||||
{
|
||||
if (setgroups(curr_ctxt.ngroups,
|
||||
curr_ctxt.groups) < 0)
|
||||
{
|
||||
DEBUG(0,("setgroups call failed!\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!become_gid(ctxt->gid)) return(False);
|
||||
|
||||
}
|
||||
|
||||
DEBUG(5,("become_unix_sec_ctxt uid=(%d,%d) gid=(%d,%d)\n",
|
||||
(int)getuid(),(int)geteuid(),(int)getgid(),(int)getegid()));
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
unbecome the user of a connection number
|
||||
****************************************************************************/
|
||||
BOOL unbecome_unix_sec_ctxt(void)
|
||||
{
|
||||
if (initial_uid == 0)
|
||||
{
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresuid(-1,getuid(),-1);
|
||||
setresgid(-1,getgid(),-1);
|
||||
#else
|
||||
if (seteuid(initial_uid) != 0)
|
||||
setuid(initial_uid);
|
||||
setgid(initial_gid);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NO_EID
|
||||
if (initial_uid == 0)
|
||||
DEBUG(2,("Running with no EID\n"));
|
||||
initial_uid = getuid();
|
||||
initial_gid = getgid();
|
||||
#else
|
||||
if (geteuid() != initial_uid) {
|
||||
DEBUG(0,("Warning: You appear to have a trapdoor uid system\n"));
|
||||
initial_uid = geteuid();
|
||||
}
|
||||
if (getegid() != initial_gid) {
|
||||
DEBUG(0,("Warning: You appear to have a trapdoor gid system\n"));
|
||||
initial_gid = getegid();
|
||||
}
|
||||
#endif
|
||||
|
||||
curr_ctxt.uid = initial_uid;
|
||||
curr_ctxt.gid = initial_gid;
|
||||
curr_ctxt.name = NULL;
|
||||
|
||||
curr_ctxt.ngroups = 0;
|
||||
curr_ctxt.groups = NULL;
|
||||
|
||||
DEBUG(5,("unbecome_unix_sec_ctxt now uid=(%d,%d) gid=(%d,%d)\n",
|
||||
(int)getuid(),(int)geteuid(),(int)getgid(),(int)getegid()));
|
||||
|
||||
return(True);
|
||||
}
|
||||
|
||||
static struct unix_sec_ctxt curr_ctxt_saved;
|
||||
static int become_root_depth;
|
||||
|
||||
/****************************************************************************
|
||||
This is used when we need to do a privileged operation (such as mucking
|
||||
with share mode files) and temporarily need root access to do it. This
|
||||
call should always be paired with an unbecome_root() call immediately
|
||||
after the operation
|
||||
|
||||
Set save_dir if you also need to save/restore the CWD
|
||||
****************************************************************************/
|
||||
void become_unix_root_sec_ctxt(void)
|
||||
{
|
||||
if (become_root_depth) {
|
||||
DEBUG(0,("ERROR: become root depth is non zero\n"));
|
||||
}
|
||||
|
||||
curr_ctxt_saved = curr_ctxt;
|
||||
become_root_depth = 1;
|
||||
|
||||
become_uid(0);
|
||||
become_gid(0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
When the privileged operation is over call this
|
||||
|
||||
Set save_dir if you also need to save/restore the CWD
|
||||
****************************************************************************/
|
||||
void unbecome_unix_root_sec_ctxt(void)
|
||||
{
|
||||
if (become_root_depth != 1)
|
||||
{
|
||||
DEBUG(0,("ERROR: unbecome root depth is %d\n",
|
||||
become_root_depth));
|
||||
}
|
||||
|
||||
/* we might have done a become_user() while running as root,
|
||||
if we have then become root again in order to become
|
||||
non root! */
|
||||
if (curr_ctxt.uid != 0)
|
||||
{
|
||||
become_uid(0);
|
||||
}
|
||||
|
||||
/* restore our gid first */
|
||||
if (!become_gid(curr_ctxt_saved.gid))
|
||||
{
|
||||
DEBUG(0,("ERROR: Failed to restore gid\n"));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SETGROUPS
|
||||
if (curr_ctxt_saved.ngroups > 0)
|
||||
{
|
||||
if (setgroups(curr_ctxt_saved.ngroups,
|
||||
curr_ctxt_saved.groups) < 0)
|
||||
{
|
||||
DEBUG(0,("setgroups call failed!\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* now restore our uid */
|
||||
if (!become_uid(curr_ctxt_saved.uid))
|
||||
{
|
||||
DEBUG(0,("ERROR: Failed to restore uid\n"));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
curr_ctxt = curr_ctxt_saved;
|
||||
|
||||
become_root_depth = 0;
|
||||
}
|
||||
|
@ -1,350 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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"
|
||||
|
||||
void free_void_array(uint32 num_entries, void **entries,
|
||||
void(free_item)(void*))
|
||||
{
|
||||
uint32 i;
|
||||
if (entries != NULL)
|
||||
{
|
||||
for (i = 0; i < num_entries; i++)
|
||||
{
|
||||
if (entries[i] != NULL)
|
||||
{
|
||||
free_item(entries[i]);
|
||||
}
|
||||
}
|
||||
free(entries);
|
||||
}
|
||||
}
|
||||
|
||||
void* add_copy_to_array(uint32 *len, void ***array, const void *item,
|
||||
void*(item_dup)(const void*), BOOL alloc_anyway)
|
||||
{
|
||||
void* copy = NULL;
|
||||
if (len == NULL || array == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (item != NULL || alloc_anyway)
|
||||
{
|
||||
copy = item_dup(item);
|
||||
return add_item_to_array(len, array, copy);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
void* add_item_to_array(uint32 *len, void ***array, void *item)
|
||||
{
|
||||
if (len == NULL || array == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
(*array) = (void**)Realloc((*array), ((*len)+1)*sizeof((*array)[0]));
|
||||
|
||||
if ((*array) != NULL)
|
||||
{
|
||||
(*array)[(*len)] = item;
|
||||
(*len)++;
|
||||
return item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void use_info_free(struct use_info *item)
|
||||
{
|
||||
if (item != NULL)
|
||||
{
|
||||
if (item->srv_name != NULL)
|
||||
{
|
||||
free(item->srv_name);
|
||||
}
|
||||
if (item->user_name != NULL)
|
||||
{
|
||||
free(item->user_name);
|
||||
}
|
||||
if (item->domain != NULL)
|
||||
{
|
||||
free(item->domain);
|
||||
}
|
||||
free(item);
|
||||
}
|
||||
}
|
||||
|
||||
static struct use_info *use_info_dup(const struct use_info *from)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
struct use_info *copy = (struct use_info *)
|
||||
malloc(sizeof(struct use_info));
|
||||
if (copy != NULL)
|
||||
{
|
||||
ZERO_STRUCTP(copy);
|
||||
copy->connected = from->connected;
|
||||
if (from->srv_name != NULL)
|
||||
{
|
||||
copy->srv_name = strdup(from->srv_name );
|
||||
}
|
||||
if (from->user_name != NULL)
|
||||
{
|
||||
copy->user_name = strdup(from->user_name);
|
||||
}
|
||||
if (from->domain != NULL)
|
||||
{
|
||||
copy->domain = strdup(from->domain );
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void free_use_info_array(uint32 num_entries, struct use_info **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&use_info_free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array,
|
||||
const struct use_info *name)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&use_info_dup;
|
||||
return (struct use_info*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)name, *fn, False);
|
||||
|
||||
}
|
||||
|
||||
void free_char_array(uint32 num_entries, char **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
char* add_chars_to_array(uint32 *len, char ***array, const char *name)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&strdup;
|
||||
return (char*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)name, *fn, False);
|
||||
|
||||
}
|
||||
|
||||
static uint32 *uint32_dup(const uint32* from)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
uint32 *copy = (uint32 *)malloc(sizeof(uint32));
|
||||
if (copy != NULL)
|
||||
{
|
||||
memcpy(copy, from, sizeof(*copy));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void free_uint32_array(uint32 num_entries, uint32 **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&uint32_dup;
|
||||
return (uint32*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)name, *fn, False);
|
||||
|
||||
}
|
||||
|
||||
void free_unistr_array(uint32 num_entries, UNISTR2 **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&unistr2_free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *name)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&unistr2_dup;
|
||||
return (UNISTR2*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)name, *fn, False);
|
||||
}
|
||||
|
||||
void free_sid_array(uint32 num_entries, DOM_SID **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&sid_dup;
|
||||
return (DOM_SID*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)sid, *fn, False);
|
||||
}
|
||||
|
||||
void free_devmode(DEVICEMODE *devmode)
|
||||
{
|
||||
if (devmode!=NULL)
|
||||
{
|
||||
if (devmode->private!=NULL)
|
||||
free(devmode->private);
|
||||
free(devmode);
|
||||
}
|
||||
}
|
||||
|
||||
void free_printer_info_2(PRINTER_INFO_2 *printer)
|
||||
{
|
||||
if (printer!=NULL)
|
||||
{
|
||||
free_devmode(printer->devmode);
|
||||
free(printer);
|
||||
}
|
||||
}
|
||||
|
||||
static PRINTER_INFO_2 *prt2_dup(const PRINTER_INFO_2* from)
|
||||
{
|
||||
PRINTER_INFO_2 *copy = (PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2));
|
||||
if (copy != NULL)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
memcpy(copy, from, sizeof(*copy));
|
||||
}
|
||||
else
|
||||
{
|
||||
ZERO_STRUCTP(copy);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
void free_print2_array(uint32 num_entries, PRINTER_INFO_2 **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free_printer_info_2;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
PRINTER_INFO_2 *add_print2_to_array(uint32 *len, PRINTER_INFO_2 ***array,
|
||||
const PRINTER_INFO_2 *prt)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&prt2_dup;
|
||||
return (PRINTER_INFO_2*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)prt, *fn, True);
|
||||
}
|
||||
|
||||
static PRINTER_INFO_1 *prt1_dup(const PRINTER_INFO_1* from)
|
||||
{
|
||||
PRINTER_INFO_1 *copy = (PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1));
|
||||
if (copy != NULL)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
memcpy(copy, from, sizeof(*copy));
|
||||
}
|
||||
else
|
||||
{
|
||||
ZERO_STRUCTP(copy);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
void free_print1_array(uint32 num_entries, PRINTER_INFO_1 **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
PRINTER_INFO_1 *add_print1_to_array(uint32 *len, PRINTER_INFO_1 ***array,
|
||||
const PRINTER_INFO_1 *prt)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&prt1_dup;
|
||||
return (PRINTER_INFO_1*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)prt, *fn, True);
|
||||
}
|
||||
|
||||
static JOB_INFO_1 *job1_dup(const JOB_INFO_1* from)
|
||||
{
|
||||
JOB_INFO_1 *copy = (JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1));
|
||||
if (copy != NULL)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
memcpy(copy, from, sizeof(*copy));
|
||||
}
|
||||
else
|
||||
{
|
||||
ZERO_STRUCTP(copy);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
void free_job1_array(uint32 num_entries, JOB_INFO_1 **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
JOB_INFO_1 *add_job1_to_array(uint32 *len, JOB_INFO_1 ***array,
|
||||
const JOB_INFO_1 *job)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&job1_dup;
|
||||
return (JOB_INFO_1*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)job, *fn, True);
|
||||
}
|
||||
|
||||
static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from)
|
||||
{
|
||||
JOB_INFO_2 *copy = (JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2));
|
||||
if (copy != NULL)
|
||||
{
|
||||
if (from != NULL)
|
||||
{
|
||||
memcpy(copy, from, sizeof(*copy));
|
||||
}
|
||||
else
|
||||
{
|
||||
ZERO_STRUCTP(copy);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
void free_job2_array(uint32 num_entries, JOB_INFO_2 **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
JOB_INFO_2 *add_job2_to_array(uint32 *len, JOB_INFO_2 ***array,
|
||||
const JOB_INFO_2 *job)
|
||||
{
|
||||
void*(*fn)(const void*) = (void*(*)(const void*))&job2_dup;
|
||||
return (JOB_INFO_2*)add_copy_to_array(len,
|
||||
(void***)array, (const void*)job, *fn, True);
|
||||
}
|
||||
|
@ -1,472 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* RPC Pipe client / server routines
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
#ifndef MAX_OPEN_POLS
|
||||
#define MAX_OPEN_POLS 64
|
||||
#endif
|
||||
|
||||
#define POL_NO_INFO 0
|
||||
#define POL_REG_INFO 1
|
||||
#define POL_SAMR_INFO 2
|
||||
#define POL_CLI_INFO 3
|
||||
|
||||
struct reg_info
|
||||
{
|
||||
/* for use by \PIPE\winreg */
|
||||
fstring name; /* name of registry key */
|
||||
};
|
||||
|
||||
struct samr_info
|
||||
{
|
||||
/* for use by the \PIPE\samr policy */
|
||||
DOM_SID sid;
|
||||
uint32 rid; /* relative id associated with the pol_hnd */
|
||||
uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */
|
||||
};
|
||||
|
||||
struct con_info
|
||||
{
|
||||
struct cli_connection *con;
|
||||
void (*free)(struct cli_connection*);
|
||||
};
|
||||
|
||||
static struct policy
|
||||
{
|
||||
struct policy *next, *prev;
|
||||
int pnum;
|
||||
BOOL open;
|
||||
POLICY_HND pol_hnd;
|
||||
int type;
|
||||
|
||||
union {
|
||||
struct samr_info *samr;
|
||||
struct reg_info *reg;
|
||||
struct con_info *con;
|
||||
|
||||
} dev;
|
||||
|
||||
} *Policy;
|
||||
|
||||
static struct bitmap *bmap;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
create a unique policy handle
|
||||
****************************************************************************/
|
||||
static void create_pol_hnd(POLICY_HND *hnd)
|
||||
{
|
||||
static uint32 pol_hnd_low = 0;
|
||||
static uint32 pol_hnd_high = 0;
|
||||
|
||||
if (hnd == NULL) return;
|
||||
|
||||
/* i severely doubt that pol_hnd_high will ever be non-zero... */
|
||||
pol_hnd_low++;
|
||||
if (pol_hnd_low == 0) pol_hnd_high++;
|
||||
|
||||
SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */
|
||||
SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */
|
||||
SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */
|
||||
SIVAL(hnd->data, 12, time(NULL)); /* something random */
|
||||
SIVAL(hnd->data, 16, getpid()); /* something more random */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initialise policy handle states...
|
||||
****************************************************************************/
|
||||
BOOL init_policy_hnd(int num_pol_hnds)
|
||||
{
|
||||
bmap = bitmap_allocate(num_pol_hnds);
|
||||
|
||||
return bmap != NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
find first available policy slot. creates a policy handle for you.
|
||||
****************************************************************************/
|
||||
BOOL register_policy_hnd(POLICY_HND *hnd)
|
||||
{
|
||||
int i;
|
||||
struct policy *p;
|
||||
|
||||
i = bitmap_find(bmap, 1);
|
||||
|
||||
if (i == -1) {
|
||||
DEBUG(0,("ERROR: out of Policy Handles!\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
p = (struct policy *)malloc(sizeof(*p));
|
||||
if (!p) {
|
||||
DEBUG(0,("ERROR: out of memory!\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
ZERO_STRUCTP(p);
|
||||
|
||||
p->open = True;
|
||||
p->pnum = i;
|
||||
p->type = POL_NO_INFO;
|
||||
|
||||
memcpy(&p->pol_hnd, hnd, sizeof(*hnd));
|
||||
|
||||
bitmap_set(bmap, i);
|
||||
|
||||
DLIST_ADD(Policy, p);
|
||||
|
||||
DEBUG(4,("Opened policy hnd[%x] ", i));
|
||||
dump_data(4, (char *)hnd->data, sizeof(hnd->data));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
find first available policy slot. creates a policy handle for you.
|
||||
****************************************************************************/
|
||||
BOOL open_policy_hnd(POLICY_HND *hnd)
|
||||
{
|
||||
create_pol_hnd(hnd);
|
||||
return register_policy_hnd(hnd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
find policy by handle
|
||||
****************************************************************************/
|
||||
static struct policy *find_policy(const POLICY_HND *hnd)
|
||||
{
|
||||
struct policy *p;
|
||||
|
||||
for (p=Policy;p;p=p->next) {
|
||||
if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) {
|
||||
DEBUG(4,("Found policy hnd[%x] ", p->pnum));
|
||||
dump_data(4, (const char *)hnd->data,
|
||||
sizeof(hnd->data));
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(4,("Policy not found: "));
|
||||
dump_data(4, (const char *)hnd->data, sizeof(hnd->data));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
find policy index by handle
|
||||
****************************************************************************/
|
||||
int find_policy_by_hnd(const POLICY_HND *hnd)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
return p?p->pnum:-1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
set samr rid
|
||||
****************************************************************************/
|
||||
BOOL set_policy_samr_rid(POLICY_HND *hnd, uint32 rid)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open)
|
||||
{
|
||||
DEBUG(3,("Setting policy device rid=%x pnum=%x\n",
|
||||
rid, p->pnum));
|
||||
|
||||
if (p->dev.samr == NULL)
|
||||
{
|
||||
p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr));
|
||||
}
|
||||
if (p->dev.samr == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
p->dev.samr->rid = rid;
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error setting policy rid=%x\n",rid));
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
set samr pol status. absolutely no idea what this is.
|
||||
****************************************************************************/
|
||||
BOOL set_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open)
|
||||
{
|
||||
DEBUG(3,("Setting policy status=%x pnum=%x\n",
|
||||
pol_status, p->pnum));
|
||||
|
||||
if (p->dev.samr == NULL)
|
||||
{
|
||||
p->type = POL_SAMR_INFO;
|
||||
p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr));
|
||||
}
|
||||
if (p->dev.samr == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
p->dev.samr->status = pol_status;
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error setting policy status=%x\n",
|
||||
pol_status));
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
set samr sid
|
||||
****************************************************************************/
|
||||
BOOL set_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid)
|
||||
{
|
||||
pstring sidstr;
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open) {
|
||||
DEBUG(3,("Setting policy sid=%s pnum=%x\n",
|
||||
sid_to_string(sidstr, sid), p->pnum));
|
||||
|
||||
if (p->dev.samr == NULL)
|
||||
{
|
||||
p->type = POL_SAMR_INFO;
|
||||
p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr));
|
||||
}
|
||||
if (p->dev.samr == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
memcpy(&p->dev.samr->sid, sid, sizeof(*sid));
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error setting policy sid=%s\n",
|
||||
sid_to_string(sidstr, sid)));
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get samr sid
|
||||
****************************************************************************/
|
||||
BOOL get_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p != NULL && p->open)
|
||||
{
|
||||
pstring sidstr;
|
||||
memcpy(sid, &p->dev.samr->sid, sizeof(*sid));
|
||||
DEBUG(3,("Getting policy sid=%s pnum=%x\n",
|
||||
sid_to_string(sidstr, sid), p->pnum));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error getting policy\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get samr rid
|
||||
****************************************************************************/
|
||||
uint32 get_policy_samr_rid(POLICY_HND *hnd)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open) {
|
||||
uint32 rid = p->dev.samr->rid;
|
||||
DEBUG(3,("Getting policy device rid=%x pnum=%x\n",
|
||||
rid, p->pnum));
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error getting policy\n"));
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
set reg name
|
||||
****************************************************************************/
|
||||
BOOL set_policy_reg_name(POLICY_HND *hnd, fstring name)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open)
|
||||
{
|
||||
DEBUG(3,("Getting policy pnum=%x\n",
|
||||
p->pnum));
|
||||
|
||||
if (p->dev.reg == NULL)
|
||||
{
|
||||
p->type = POL_REG_INFO;
|
||||
p->dev.reg = (struct reg_info*)malloc(sizeof(*p->dev.reg));
|
||||
}
|
||||
if (p->dev.reg == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
fstrcpy(p->dev.reg->name, name);
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error setting policy name=%s\n", name));
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
set reg name
|
||||
****************************************************************************/
|
||||
BOOL get_policy_reg_name(POLICY_HND *hnd, fstring name)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open)
|
||||
{
|
||||
DEBUG(3,("Setting policy pnum=%x name=%s\n",
|
||||
p->pnum, name));
|
||||
|
||||
fstrcpy(name, p->dev.reg->name);
|
||||
DEBUG(5,("getting policy reg name=%s\n", name));
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error getting policy reg name\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
set con state
|
||||
****************************************************************************/
|
||||
BOOL set_policy_con(POLICY_HND *hnd, struct cli_connection *con,
|
||||
void (*free_fn)(struct cli_connection *))
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p && p->open)
|
||||
{
|
||||
DEBUG(3,("Setting policy con state pnum=%x\n", p->pnum));
|
||||
|
||||
if (p->dev.con == NULL)
|
||||
{
|
||||
p->type = POL_CLI_INFO;
|
||||
p->dev.con = (struct con_info*)malloc(sizeof(*p->dev.con));
|
||||
}
|
||||
if (p->dev.con == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
p->dev.con->con = con;
|
||||
p->dev.con->free = free_fn;
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error setting policy con state\n"));
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get con state
|
||||
****************************************************************************/
|
||||
BOOL get_policy_con(const POLICY_HND *hnd, struct cli_connection **con)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (p != NULL && p->open)
|
||||
{
|
||||
DEBUG(3,("Getting con state pnum=%x\n", p->pnum));
|
||||
|
||||
if (con != NULL)
|
||||
{
|
||||
(*con ) = p->dev.con->con;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
DEBUG(3,("Error getting policy\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
close an lsa policy
|
||||
****************************************************************************/
|
||||
BOOL close_policy_hnd(POLICY_HND *hnd)
|
||||
{
|
||||
struct policy *p = find_policy(hnd);
|
||||
|
||||
if (!p)
|
||||
{
|
||||
DEBUG(3,("Error closing policy\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
DEBUG(3,("Closed policy name pnum=%x\n", p->pnum));
|
||||
|
||||
DLIST_REMOVE(Policy, p);
|
||||
|
||||
bitmap_clear(bmap, p->pnum);
|
||||
|
||||
ZERO_STRUCTP(p);
|
||||
ZERO_STRUCTP(hnd);
|
||||
|
||||
switch (p->type)
|
||||
{
|
||||
case POL_REG_INFO:
|
||||
{
|
||||
free(p->dev.reg);
|
||||
break;
|
||||
}
|
||||
case POL_SAMR_INFO:
|
||||
{
|
||||
free(p->dev.samr);
|
||||
break;
|
||||
}
|
||||
case POL_CLI_INFO:
|
||||
{
|
||||
if (p->dev.con->free != NULL)
|
||||
{
|
||||
p->dev.con->free(p->dev.con->con);
|
||||
}
|
||||
free(p->dev.con);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
@ -1,435 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Password and authentication handling
|
||||
Copyright (C) Jeremy Allison 1996-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"
|
||||
#include "nterr.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern DOM_SID global_sam_sid;
|
||||
extern fstring global_sam_name;
|
||||
|
||||
extern DOM_SID global_member_sid;
|
||||
extern fstring global_myworkgroup;
|
||||
|
||||
extern DOM_SID global_sid_S_1_5_20;
|
||||
|
||||
extern pstring global_myname;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 rid;
|
||||
char *defaultname;
|
||||
char *name;
|
||||
} rid_name;
|
||||
|
||||
/*
|
||||
* A list of the rids of well known BUILTIN and Domain users
|
||||
* and groups.
|
||||
*/
|
||||
|
||||
static rid_name builtin_alias_rids[] =
|
||||
{
|
||||
{ BUILTIN_ALIAS_RID_ADMINS , "Administrators" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_USERS , "Users" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_GUESTS , "Guests" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" , NULL },
|
||||
|
||||
{ BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" , NULL },
|
||||
{ BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" , NULL },
|
||||
{ 0 , NULL , NULL}
|
||||
};
|
||||
|
||||
/* array lookup of well-known Domain RID users. */
|
||||
static rid_name domain_user_rids[] =
|
||||
{
|
||||
{ DOMAIN_USER_RID_ADMIN , "Administrator" , NULL },
|
||||
{ DOMAIN_USER_RID_GUEST , "Guest" , NULL },
|
||||
{ 0 , NULL , NULL}
|
||||
};
|
||||
|
||||
/* array lookup of well-known Domain RID groups. */
|
||||
static rid_name domain_group_rids[] =
|
||||
{
|
||||
{ DOMAIN_GROUP_RID_ADMINS , "Domain Admins" , NULL },
|
||||
{ DOMAIN_GROUP_RID_USERS , "Domain Users" , NULL },
|
||||
{ DOMAIN_GROUP_RID_GUESTS , "Domain Guests" , NULL },
|
||||
{ 0 , NULL , NULL}
|
||||
};
|
||||
|
||||
/*******************************************************************
|
||||
make an entry in wk name map
|
||||
the name is strdup()ed!
|
||||
*******************************************************************/
|
||||
static BOOL make_alias_entry(rid_name *map, char *defaultname, char *name)
|
||||
{
|
||||
if(isdigit(*defaultname))
|
||||
{
|
||||
long rid = -1;
|
||||
char *s;
|
||||
|
||||
if(*defaultname == '0')
|
||||
{
|
||||
if(defaultname[1] == 'x')
|
||||
{
|
||||
s = "%lx";
|
||||
defaultname += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = "%lo";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = "%ld";
|
||||
}
|
||||
|
||||
sscanf(defaultname, s, &rid);
|
||||
|
||||
for( ; map->rid; map++)
|
||||
{
|
||||
if(map->rid == rid) {
|
||||
map->name = strdup(name);
|
||||
DEBUG(5, ("make_alias_entry: mapping %s (rid 0x%x) to %s\n",
|
||||
map->defaultname, map->rid, map->name));
|
||||
return True;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
for( ; map->rid; map++)
|
||||
{
|
||||
if(!StrCaseCmp(map->name, defaultname)) {
|
||||
map->name = strdup(name);
|
||||
DEBUG(5, ("make_alias_entry: mapping %s (rid 0x%x) to %s\n",
|
||||
map->defaultname, map->rid, map->name));
|
||||
return True;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reset wk map to default values
|
||||
*******************************************************************/
|
||||
static void reset_wk_map(rid_name *map)
|
||||
{
|
||||
for( ; map->rid; map++)
|
||||
{
|
||||
if(map->name != NULL && map->name != map->defaultname)
|
||||
free(map->name);
|
||||
map->name = map->defaultname;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reset all wk maps
|
||||
*******************************************************************/
|
||||
static void reset_wk_maps(void)
|
||||
{
|
||||
DEBUG(4, ("reset_wk_maps: Initializing maps\n"));
|
||||
reset_wk_map(builtin_alias_rids);
|
||||
reset_wk_map(domain_user_rids);
|
||||
reset_wk_map(domain_group_rids);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Load builtin alias map
|
||||
*******************************************************************/
|
||||
static BOOL load_wk_rid_map(void)
|
||||
{
|
||||
static int map_initialized = 0;
|
||||
static time_t builtin_rid_file_last_modified = (time_t)0;
|
||||
char *builtin_rid_file = lp_builtinrid_file();
|
||||
|
||||
FILE *fp;
|
||||
char *s;
|
||||
pstring buf;
|
||||
|
||||
if (!map_initialized)
|
||||
{
|
||||
reset_wk_maps();
|
||||
map_initialized = 1;
|
||||
}
|
||||
|
||||
if (!*builtin_rid_file)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
fp = open_file_if_modified(builtin_rid_file, "r", &builtin_rid_file_last_modified);
|
||||
if(!fp)
|
||||
{
|
||||
DEBUG(0,("load_wk_rid_map: can't open name map %s. Error was %s\n",
|
||||
builtin_rid_file, strerror(errno)));
|
||||
return False;
|
||||
}
|
||||
|
||||
reset_wk_maps();
|
||||
DEBUG(4,("load_wk_rid_map: Scanning builtin rid map %s\n",builtin_rid_file));
|
||||
|
||||
while ((s = fgets_slash(buf, sizeof(buf), fp)) != NULL)
|
||||
{
|
||||
pstring defaultname;
|
||||
pstring name;
|
||||
|
||||
DEBUG(10,("Read line |%s|\n", s));
|
||||
|
||||
if (!*s || strchr("#;",*s))
|
||||
continue;
|
||||
|
||||
if (!next_token(&s,name, "\t\n\r=", sizeof(defaultname)))
|
||||
continue;
|
||||
|
||||
if (!next_token(&s,defaultname, "\t\n\r=", sizeof(name)))
|
||||
continue;
|
||||
|
||||
trim_string(defaultname, " ", " ");
|
||||
trim_string(name, " ", " ");
|
||||
|
||||
if (!*defaultname || !*name)
|
||||
continue;
|
||||
|
||||
if(make_alias_entry(builtin_alias_rids, defaultname, name))
|
||||
continue;
|
||||
if(make_alias_entry(domain_user_rids, defaultname, name))
|
||||
continue;
|
||||
if(make_alias_entry(domain_group_rids, defaultname, name))
|
||||
continue;
|
||||
|
||||
DEBUG(0,("load_wk_rid_map: Unknown alias %s in map %s\n",
|
||||
defaultname, builtin_rid_file));
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
lookup_wk_group_name
|
||||
********************************************************************/
|
||||
uint32 lookup_wk_group_name(const char *group_name, const char *domain,
|
||||
DOM_SID *sid, uint8 *type)
|
||||
{
|
||||
char *grp_name;
|
||||
int i = -1; /* start do loop at -1 */
|
||||
uint32 rid;
|
||||
(*type) = SID_NAME_DOM_GRP;
|
||||
|
||||
if (strequal(domain, global_sam_name))
|
||||
{
|
||||
sid_copy(sid, &global_sam_sid);
|
||||
}
|
||||
else if (strequal(domain, "BUILTIN"))
|
||||
{
|
||||
sid_copy(sid, &global_sid_S_1_5_20);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0xC0000000 | NT_STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
load_wk_rid_map();
|
||||
|
||||
do /* find, if it exists, a group rid for the group name */
|
||||
{
|
||||
i++;
|
||||
rid = domain_group_rids[i].rid;
|
||||
grp_name = domain_group_rids[i].name;
|
||||
|
||||
if (strequal(grp_name, group_name))
|
||||
{
|
||||
sid_append_rid(sid, rid);
|
||||
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
} while (grp_name != NULL);
|
||||
|
||||
return 0xC0000000 | NT_STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
lookup_wk_user_name
|
||||
********************************************************************/
|
||||
uint32 lookup_wk_user_name(const char *user_name, const char *domain,
|
||||
DOM_SID *sid, uint8 *type)
|
||||
{
|
||||
char *usr_name;
|
||||
int i = -1; /* start do loop at -1 */
|
||||
(*type) = SID_NAME_USER;
|
||||
|
||||
if (strequal(domain, global_sam_name))
|
||||
{
|
||||
sid_copy(sid, &global_sam_sid);
|
||||
}
|
||||
else if (strequal(domain, "BUILTIN"))
|
||||
{
|
||||
sid_copy(sid, &global_sid_S_1_5_20);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0xC0000000 | NT_STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
load_wk_rid_map();
|
||||
|
||||
do /* find, if it exists, a alias rid for the alias name */
|
||||
{
|
||||
i++;
|
||||
usr_name = domain_user_rids[i].name;
|
||||
|
||||
} while (usr_name != NULL && !strequal(usr_name, user_name));
|
||||
|
||||
if (usr_name != NULL)
|
||||
{
|
||||
sid_append_rid(sid, domain_user_rids[i].rid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0xC0000000 | NT_STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
lookup_builtin_alias_name
|
||||
********************************************************************/
|
||||
uint32 lookup_builtin_alias_name(const char *alias_name, const char *domain,
|
||||
DOM_SID *sid, uint8 *type)
|
||||
{
|
||||
char *als_name;
|
||||
int i = 0;
|
||||
uint32 rid;
|
||||
|
||||
if (strequal(domain, "BUILTIN"))
|
||||
{
|
||||
if (sid != NULL)
|
||||
{
|
||||
sid_copy(sid, &global_sid_S_1_5_20);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0xC0000000 | NT_STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
load_wk_rid_map();
|
||||
|
||||
do /* find, if it exists, a alias rid for the alias name*/
|
||||
{
|
||||
rid = builtin_alias_rids[i].rid;
|
||||
als_name = builtin_alias_rids[i].name;
|
||||
|
||||
if (strequal(als_name, alias_name))
|
||||
{
|
||||
if (sid != NULL)
|
||||
{
|
||||
sid_append_rid(sid, rid);
|
||||
}
|
||||
|
||||
if (type != NULL)
|
||||
{
|
||||
(*type) = SID_NAME_ALIAS;
|
||||
}
|
||||
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
} while (als_name != NULL);
|
||||
|
||||
return 0xC0000000 | NT_STATUS_NONE_MAPPED;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
initialise password databases, domain names, domain sid.
|
||||
**************************************************************/
|
||||
BOOL pwdb_initialise(BOOL is_server)
|
||||
{
|
||||
get_sam_domain_name();
|
||||
|
||||
if (!init_myworkgroup())
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
generate_wellknown_sids();
|
||||
|
||||
if (is_server)
|
||||
{
|
||||
if (!generate_sam_sid(global_sam_name, &global_sam_sid))
|
||||
{
|
||||
DEBUG(0,("ERROR: Samba cannot create a SAM SID for its domain (%s).\n",
|
||||
global_sam_name));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!get_domain_sids(lp_workgroup(), &global_member_sid,
|
||||
&global_sam_sid))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
create_sidmap_table();
|
||||
|
||||
return initialise_password_db();
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
the following functions lookup wk rid's.
|
||||
these may be unnecessary...
|
||||
**************************************************************/
|
||||
static char *lookup_wk_rid(uint32 rid, rid_name *table)
|
||||
{
|
||||
load_wk_rid_map();
|
||||
for( ; table->rid ; table++)
|
||||
{
|
||||
if(table->rid == rid)
|
||||
{
|
||||
return table->name;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *lookup_wk_alias_rid(uint32 rid)
|
||||
{
|
||||
return lookup_wk_rid(rid, builtin_alias_rids);
|
||||
}
|
||||
|
||||
char *lookup_wk_user_rid(uint32 rid)
|
||||
{
|
||||
return lookup_wk_rid(rid, domain_user_rids);
|
||||
}
|
||||
|
||||
char *lookup_wk_group_rid(uint32 rid)
|
||||
{
|
||||
return lookup_wk_rid(rid, domain_group_rids);
|
||||
}
|
||||
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Samba connection status utility functions
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Michael Glauche 1999
|
||||
|
||||
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;
|
||||
|
||||
/*******************************************************************
|
||||
parse the STATUS..LCK file. caller is responsible for freeing *crec.
|
||||
********************************************************************/
|
||||
BOOL get_connection_status(struct connect_record **crec,
|
||||
uint32 *connection_count)
|
||||
{
|
||||
int fd;
|
||||
pstring fname;
|
||||
int conn;
|
||||
int num_recs;
|
||||
struct connect_record *c;
|
||||
int i;
|
||||
|
||||
if (crec == NULL || connection_count == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
pstrcpy(fname,lp_lockdir());
|
||||
standard_sub_basic(fname);
|
||||
trim_string(fname,"","/");
|
||||
pstrcat(fname,"/STATUS..LCK");
|
||||
|
||||
fd = sys_open(fname,O_RDONLY, 0);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
DEBUG(0,("Couldn't open status file %s\n",fname));
|
||||
return False;
|
||||
}
|
||||
|
||||
(*crec) = NULL;
|
||||
|
||||
num_recs = file_size(fname) / sizeof(*c);
|
||||
|
||||
DEBUG(5,("Opened status file %s, record count %d\n",fname, num_recs));
|
||||
|
||||
for (i = 0, conn = 0; i < num_recs; i++)
|
||||
{
|
||||
(*crec) = Realloc((*crec), (conn+1) * sizeof((*crec)[conn]));
|
||||
if ((*crec) == NULL)
|
||||
{
|
||||
DEBUG(0,("Realloc failed in get_connection_status\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
c = &((*crec)[conn]);
|
||||
if (sys_lseek(fd,i*sizeof(*c),SEEK_SET) != i*sizeof(*c) ||
|
||||
read(fd,c,sizeof(*c)) != sizeof(*c))
|
||||
{
|
||||
DEBUG(0,("unable to read a crec in get_connection_status\n"));
|
||||
break;
|
||||
}
|
||||
DEBUG(10,("cnum:%u. pid: %d magic: %x\n",
|
||||
c->cnum, c->pid, c->magic));
|
||||
|
||||
/* valid connection, smbd process still going, connection still going */
|
||||
if ( c->magic == 0x280267 && process_exists(c->pid) && c->cnum != -1 )
|
||||
{
|
||||
conn++;
|
||||
}
|
||||
|
||||
}
|
||||
close(fd);
|
||||
(*connection_count)=conn;
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Get the number of open Sessions. Not optimal yet. Has at least O(n*log(n)).
|
||||
********************************************************************/
|
||||
BOOL get_session_count(struct connect_record **srec,uint32 *session_count)
|
||||
{
|
||||
struct connect_record *crec = NULL;
|
||||
struct connect_record *c;
|
||||
|
||||
uint32 connection_count;
|
||||
uint32 conn;
|
||||
int *pid;
|
||||
int i;
|
||||
int MaxPid;
|
||||
BOOL found;
|
||||
|
||||
(*srec) = NULL;
|
||||
pid = NULL;
|
||||
if (get_connection_status(&crec, &connection_count))
|
||||
{
|
||||
MaxPid = 0;
|
||||
for (conn = 0; conn < connection_count; conn++)
|
||||
{
|
||||
DEBUG(10,("Connection nr : %u\n",conn));
|
||||
found=False;
|
||||
for (i = 0; i < MaxPid; i++)
|
||||
{
|
||||
if (crec[conn].pid == pid[i])
|
||||
{
|
||||
found = True;
|
||||
i=MaxPid;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
(*srec) = Realloc((*srec), (MaxPid+1) * sizeof((*srec)[MaxPid]));
|
||||
if ((*srec) == NULL)
|
||||
{
|
||||
DEBUG(0,("Realloc failed in get_connection_status\n"));
|
||||
return False;
|
||||
}
|
||||
pid = Realloc(pid, (MaxPid+1) * sizeof(int));
|
||||
if (pid == NULL)
|
||||
{
|
||||
DEBUG(0,("Realloc failed in get_session_count\n"));
|
||||
free(crec);
|
||||
return False;
|
||||
}
|
||||
c = &((*srec)[MaxPid]);
|
||||
pid[MaxPid]=crec[conn].pid;
|
||||
pstrcpy(c->machine,crec[conn].machine);
|
||||
c->uid = crec[conn].uid;
|
||||
c->pid = crec[conn].pid;
|
||||
c->cnum = crec[conn].cnum;
|
||||
pstrcpy(c->name,crec[conn].name);
|
||||
|
||||
MaxPid++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* crec is not valid, so no need to free it here */
|
||||
return False;
|
||||
}
|
||||
free(crec);
|
||||
(*session_count) = MaxPid;
|
||||
return True;
|
||||
}
|
||||
|
@ -1,242 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2
|
||||
SMB agent/socket plugin
|
||||
Copyright (C) Andrew Tridgell 1999
|
||||
|
||||
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"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
terminate socket connection
|
||||
****************************************************************************/
|
||||
static void sock_redir_free(struct vagent_ops *va, struct sock_redir *sock)
|
||||
{
|
||||
if (sock->c != -1)
|
||||
{
|
||||
close(sock->c);
|
||||
sock->c = -1;
|
||||
}
|
||||
if (sock->n != NULL)
|
||||
{
|
||||
va->free_sock(sock->n);
|
||||
sock->n = NULL;
|
||||
}
|
||||
free(sock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
free a sockent array
|
||||
****************************************************************************/
|
||||
static void free_sock_array(struct vagent_ops*va)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&va->free_sock;
|
||||
free_void_array(va->num_socks, (void**)va->socks, *fn);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
add a sockent state to the array
|
||||
****************************************************************************/
|
||||
static struct sock_redir* add_sock_to_array(uint32 *len,
|
||||
struct sock_redir ***array,
|
||||
struct sock_redir *sock)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (*len); i++)
|
||||
{
|
||||
if ((*array)[i] == NULL)
|
||||
{
|
||||
(*array)[i] = sock;
|
||||
return sock;
|
||||
}
|
||||
}
|
||||
|
||||
return (struct sock_redir*)add_item_to_array(len,
|
||||
(void***)array, (void*)sock);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initiate sockent array
|
||||
****************************************************************************/
|
||||
void init_sock_redir(struct vagent_ops*va)
|
||||
{
|
||||
va->socks = NULL;
|
||||
va->num_socks = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
terminate sockent array
|
||||
****************************************************************************/
|
||||
void free_sock_redir(struct vagent_ops*va)
|
||||
{
|
||||
free_sock_array(va);
|
||||
init_sock_redir(va);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
create a new sockent state from user credentials
|
||||
****************************************************************************/
|
||||
static struct sock_redir *sock_redir_get(struct vagent_ops *va, int fd)
|
||||
{
|
||||
struct sock_redir *sock = (struct sock_redir*)malloc(sizeof(*sock));
|
||||
|
||||
if (sock == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZERO_STRUCTP(sock);
|
||||
|
||||
sock->c = fd;
|
||||
sock->n = NULL;
|
||||
|
||||
DEBUG(10,("sock_redir_get:\tfd:\t%d\n", fd));
|
||||
|
||||
return sock;
|
||||
}
|
||||
/****************************************************************************
|
||||
init sock state
|
||||
****************************************************************************/
|
||||
static void sock_add(struct vagent_ops *va, int fd)
|
||||
{
|
||||
struct sock_redir *sock;
|
||||
sock = sock_redir_get(va, fd);
|
||||
if (sock != NULL)
|
||||
{
|
||||
add_sock_to_array(&va->num_socks, &va->socks, sock);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
delete a sockent state
|
||||
****************************************************************************/
|
||||
static BOOL sock_del(struct vagent_ops *va, int fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < va->num_socks; i++)
|
||||
{
|
||||
if (va->socks[i] == NULL) continue;
|
||||
if (va->socks[i]->c == fd)
|
||||
{
|
||||
sock_redir_free(va, va->socks[i]);
|
||||
va->socks[i] = NULL;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
void start_agent(struct vagent_ops *va)
|
||||
{
|
||||
int s, c;
|
||||
|
||||
s = va->get_agent_sock(va->id);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int i;
|
||||
fd_set fds;
|
||||
int num;
|
||||
struct sockaddr_un addr;
|
||||
int in_addrlen = sizeof(addr);
|
||||
int maxfd = s;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(s, &fds);
|
||||
|
||||
for (i = 0; i < va->num_socks; i++)
|
||||
{
|
||||
if (va->socks[i] != NULL)
|
||||
{
|
||||
int fd = va->socks[i]->c;
|
||||
FD_SET(fd, &fds);
|
||||
maxfd = MAX(maxfd, fd);
|
||||
|
||||
if (va->socks[i]->n != NULL)
|
||||
{
|
||||
fd = va->socks[i]->s;
|
||||
FD_SET(fd, &fds);
|
||||
maxfd = MAX(fd, maxfd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbgflush();
|
||||
num = sys_select(maxfd+1,&fds,NULL, NULL);
|
||||
|
||||
if (num <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FD_ISSET(s, &fds))
|
||||
{
|
||||
FD_CLR(s, &fds);
|
||||
c = accept(s, (struct sockaddr*)&addr, &in_addrlen);
|
||||
if (c != -1)
|
||||
{
|
||||
sock_add(va, c);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < va->num_socks; i++)
|
||||
{
|
||||
if (va->socks[i] == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (FD_ISSET(va->socks[i]->c, &fds))
|
||||
{
|
||||
FD_CLR(va->socks[i]->c, &fds);
|
||||
if (!va->process_cli_sock(va->socks,
|
||||
va->num_socks,
|
||||
va->socks[i]))
|
||||
{
|
||||
sock_redir_free(va, va->socks[i]);
|
||||
va->socks[i] = NULL;
|
||||
}
|
||||
}
|
||||
if (va->socks[i] == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (va->socks[i]->n == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (FD_ISSET(va->socks[i]->s, &fds))
|
||||
{
|
||||
FD_CLR(va->socks[i]->s, &fds);
|
||||
if (!va->process_srv_sock(va->socks,
|
||||
va->num_socks,
|
||||
va->socks[i]->s))
|
||||
{
|
||||
sock_redir_free(va, va->socks[i]);
|
||||
va->socks[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,195 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Password and authentication handling
|
||||
Copyright (C) Andrew Tridgell 1992-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;
|
||||
|
||||
/* this holds info on user ids that are already validated for this VC */
|
||||
static user_struct *validated_users = NULL;
|
||||
static int num_validated_users = 0;
|
||||
|
||||
/****************************************************************************
|
||||
check if a uid has been validated, and return an pointer to the user_struct
|
||||
if it has. NULL if not. vuid is biased by an offset. This allows us to
|
||||
tell random client vuid's (normally zero) from valid vuids.
|
||||
****************************************************************************/
|
||||
user_struct *get_valid_user_struct(uint16 vuid)
|
||||
{
|
||||
if (vuid == UID_FIELD_INVALID)
|
||||
return NULL;
|
||||
vuid -= VUID_OFFSET;
|
||||
if ((vuid >= (uint16)num_validated_users) ||
|
||||
(validated_users[vuid].uid == (uid_t)-1) || (validated_users[vuid].gid == (gid_t)-1))
|
||||
return NULL;
|
||||
return &validated_users[vuid];
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
invalidate a uid
|
||||
****************************************************************************/
|
||||
void invalidate_vuid(uint16 vuid)
|
||||
{
|
||||
user_struct *vuser = get_valid_user_struct(vuid);
|
||||
|
||||
if (vuser == NULL) return;
|
||||
|
||||
vuser->uid = (uid_t)-1;
|
||||
vuser->gid = (gid_t)-1;
|
||||
|
||||
/* same number of igroups as groups */
|
||||
vuser->n_groups = 0;
|
||||
|
||||
if (vuser->groups)
|
||||
free((char *)vuser->groups);
|
||||
|
||||
vuser->groups = NULL;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
return a validated username
|
||||
****************************************************************************/
|
||||
char *validated_username(uint16 vuid)
|
||||
{
|
||||
user_struct *vuser = get_valid_user_struct(vuid);
|
||||
if (vuser == NULL)
|
||||
return 0;
|
||||
return(vuser->name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
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
|
||||
tell random client vuid's (normally zero) from valid vuids.
|
||||
****************************************************************************/
|
||||
uint16 create_vuid(uid_t uid, gid_t gid, int n_groups, gid_t *groups,
|
||||
char *unix_name, char *requested_name,
|
||||
char *real_name,
|
||||
BOOL guest, uchar user_sess_key[16])
|
||||
{
|
||||
user_struct *vuser;
|
||||
|
||||
validated_users = (user_struct *)Realloc(validated_users,
|
||||
sizeof(user_struct)*
|
||||
(num_validated_users+1));
|
||||
|
||||
if (!validated_users)
|
||||
{
|
||||
DEBUG(0,("Failed to realloc users struct!\n"));
|
||||
num_validated_users = 0;
|
||||
return UID_FIELD_INVALID;
|
||||
}
|
||||
|
||||
vuser = &validated_users[num_validated_users];
|
||||
num_validated_users++;
|
||||
|
||||
vuser->uid = uid;
|
||||
vuser->gid = gid;
|
||||
vuser->guest = guest;
|
||||
fstrcpy(vuser->name,unix_name);
|
||||
fstrcpy(vuser->requested_name,requested_name);
|
||||
fstrcpy(vuser->real_name,real_name);
|
||||
memcpy(vuser->user_sess_key, user_sess_key, sizeof(vuser->user_sess_key));
|
||||
|
||||
vuser->n_groups = n_groups;
|
||||
vuser->groups = groups;
|
||||
|
||||
DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name));
|
||||
|
||||
return (uint16)((num_validated_users - 1) + VUID_OFFSET);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
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
|
||||
tell random client vuid's (normally zero) from valid vuids.
|
||||
****************************************************************************/
|
||||
uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, BOOL guest, uchar user_sess_key[16])
|
||||
{
|
||||
int n_groups;
|
||||
gid_t *groups;
|
||||
fstring real_name;
|
||||
struct passwd *pwfile; /* for getting real name from passwd file */
|
||||
|
||||
/* Ensure no vuid gets registered in share level security. */
|
||||
if(lp_security() == SEC_SHARE)
|
||||
return UID_FIELD_INVALID;
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* After observing MS-Exchange services writing to a Samba share
|
||||
* I belive this code is incorrect. Each service does its own
|
||||
* sessionsetup_and_X for the same user, and as each service shuts
|
||||
* down, it does a user_logoff_and_X. As we are consolidating multiple
|
||||
* sessionsetup_and_X's onto the same vuid here, when the first service
|
||||
* shuts down, it invalidates all the open files for the other services.
|
||||
* Hence I am removing this code and forcing each sessionsetup_and_X
|
||||
* to get a new vuid.
|
||||
* Jeremy Allison. (jallison@whistle.com).
|
||||
*/
|
||||
|
||||
int i;
|
||||
for(i = 0; i < num_validated_users; i++) {
|
||||
vuser = &validated_users[i];
|
||||
if ( vuser->uid == uid )
|
||||
return (uint16)(i + VUID_OFFSET); /* User already validated */
|
||||
}
|
||||
#endif
|
||||
|
||||
validated_users = (user_struct *)Realloc(validated_users,
|
||||
sizeof(user_struct)*
|
||||
(num_validated_users+1));
|
||||
|
||||
if (!validated_users)
|
||||
{
|
||||
DEBUG(0,("Failed to realloc users struct!\n"));
|
||||
num_validated_users = 0;
|
||||
return UID_FIELD_INVALID;
|
||||
}
|
||||
|
||||
/* Find all the groups this uid is in and store them.
|
||||
Used by become_user() */
|
||||
get_unixgroups(unix_name,uid,gid,
|
||||
&n_groups,
|
||||
&groups);
|
||||
|
||||
DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name));
|
||||
|
||||
DEBUG(3, ("Clearing default real name\n"));
|
||||
fstrcpy(real_name, "<Full Name>\0");
|
||||
if (lp_unix_realname())
|
||||
{
|
||||
if ((pwfile=hashed_getpwnam(unix_name))!= NULL)
|
||||
{
|
||||
DEBUG(3, ("User name: %s\tReal name: %s\n",unix_name,pwfile->pw_gecos));
|
||||
fstrcpy(real_name, pwfile->pw_gecos);
|
||||
}
|
||||
}
|
||||
|
||||
return create_vuid(uid, gid, n_groups, groups,
|
||||
unix_name, requested_name,
|
||||
real_name,
|
||||
guest, user_sess_key);
|
||||
}
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1997,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
|
||||
* Copyright (C) Paul Ashton 1997.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef SYSLOG
|
||||
#undef SYSLOG
|
||||
#endif
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern pstring scope;
|
||||
extern pstring global_myname;
|
||||
|
||||
/*********************************************************
|
||||
Change the domain password on the PDC.
|
||||
**********************************************************/
|
||||
|
||||
static BOOL modify_trust_password( char *domain, char *remote_machine,
|
||||
unsigned char orig_trust_passwd_hash[16],
|
||||
unsigned char new_trust_passwd_hash[16],
|
||||
uint16 sec_chan)
|
||||
{
|
||||
struct nmb_name calling, called;
|
||||
fstring trust_acct;
|
||||
fstring srv_name;
|
||||
|
||||
fstrcpy(srv_name, "\\\\");
|
||||
fstrcat(srv_name, remote_machine);
|
||||
strupper(srv_name);
|
||||
|
||||
fstrcpy(trust_acct, global_myname);
|
||||
fstrcat(trust_acct, "$");
|
||||
|
||||
make_nmb_name(&calling, global_myname , 0x0 , scope);
|
||||
make_nmb_name(&called , remote_machine, 0x20, scope);
|
||||
|
||||
if (cli_nt_setup_creds(srv_name, global_myname, trust_acct,
|
||||
orig_trust_passwd_hash, sec_chan) != 0x0)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (!cli_nt_srv_pwset( srv_name, global_myname, trust_acct,
|
||||
new_trust_passwd_hash,
|
||||
sec_chan ) )
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Change the trust account password for a domain.
|
||||
The user of this function must have locked the trust password file for
|
||||
update.
|
||||
************************************************************************/
|
||||
|
||||
BOOL change_trust_account_password(char *domain, char *remote_machine_list,
|
||||
uint16 sec_chan)
|
||||
{
|
||||
fstring remote_machine;
|
||||
unsigned char old_trust_passwd_hash[16];
|
||||
unsigned char new_trust_passwd_hash[16];
|
||||
time_t lct;
|
||||
BOOL res;
|
||||
|
||||
if(!get_trust_account_password( old_trust_passwd_hash, &lct)) {
|
||||
DEBUG(0,("change_trust_account_password: unable to read the machine \
|
||||
account password for domain %s.\n", domain));
|
||||
return False;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the new (random) password.
|
||||
*/
|
||||
generate_random_buffer( new_trust_passwd_hash, 16, True);
|
||||
|
||||
while(remote_machine_list &&
|
||||
next_token(&remote_machine_list, remote_machine,
|
||||
LIST_SEP, sizeof(remote_machine))) {
|
||||
strupper(remote_machine);
|
||||
if(modify_trust_password( domain, remote_machine,
|
||||
old_trust_passwd_hash, new_trust_passwd_hash, sec_chan)) {
|
||||
DEBUG(0,("%s : change_trust_account_password: Changed password for \
|
||||
domain %s.\n", timestring(), domain));
|
||||
/*
|
||||
* Return the result of trying to write the new password
|
||||
* back into the trust account file.
|
||||
*/
|
||||
res = set_trust_account_password(new_trust_passwd_hash);
|
||||
memset(new_trust_passwd_hash, 0, 16);
|
||||
memset(old_trust_passwd_hash, 0, 16);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
memset(new_trust_passwd_hash, 0, 16);
|
||||
memset(old_trust_passwd_hash, 0, 16);
|
||||
|
||||
DEBUG(0,("%s : change_trust_account_password: Failed to change password for \
|
||||
domain %s.\n", timestring(), domain));
|
||||
return False;
|
||||
}
|
||||
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Main SMB server routines
|
||||
Copyright (C) Andrew Tridgell 1992-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"
|
||||
|
||||
fstring pipe_name;
|
||||
|
||||
pstring servicesf = CONFIGFILE;
|
||||
extern pstring debugf;
|
||||
extern BOOL append_log;
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
void msrpc_service_init(void)
|
||||
{
|
||||
if (!pwdb_initialise(True))
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_sam_password_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_passgrp_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_group_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_alias_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_builtin_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!get_member_domain_sid())
|
||||
{
|
||||
DEBUG(0,("ERROR: Samba cannot obtain PDC SID from PDC(s) %s.\n",
|
||||
lp_passwordserver()));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
reload the services file
|
||||
**************************************************************************/
|
||||
BOOL reload_services(BOOL test)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if (lp_loaded()) {
|
||||
pstring fname;
|
||||
pstrcpy(fname,lp_configfile());
|
||||
if (file_exist(fname,NULL) && !strcsequal(fname,servicesf)) {
|
||||
pstrcpy(servicesf,fname);
|
||||
test = False;
|
||||
}
|
||||
}
|
||||
|
||||
reopen_logs();
|
||||
|
||||
if (test && !lp_file_list_changed())
|
||||
return(True);
|
||||
|
||||
lp_killunused(NULL);
|
||||
|
||||
ret = lp_load(servicesf,False,False,True);
|
||||
|
||||
/* perhaps the config filename is now set */
|
||||
if (!test)
|
||||
reload_services(True);
|
||||
|
||||
reopen_logs();
|
||||
|
||||
load_interfaces();
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
main program
|
||||
****************************************************************************/
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
#ifdef HAVE_SET_AUTH_PARAMETERS
|
||||
set_auth_parameters(argc,argv);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETLUID
|
||||
/* needed for SecureWare on SCO */
|
||||
setluid(0);
|
||||
#endif
|
||||
|
||||
append_log = True;
|
||||
|
||||
TimeInit();
|
||||
|
||||
fstrcpy(pipe_name, "lsarpc");
|
||||
setup_logging(argv[0],False);
|
||||
slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name);
|
||||
add_msrpc_command_processor( pipe_name, argv[0], api_ntlsa_rpc );
|
||||
|
||||
return msrpc_main(argc, argv);
|
||||
}
|
@ -1,571 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Main SMB server routines
|
||||
Copyright (C) Andrew Tridgell 1992-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 "trans2.h"
|
||||
|
||||
extern pstring servicesf;
|
||||
extern pstring debugf;
|
||||
extern pstring global_myname;
|
||||
|
||||
int am_parent = 1;
|
||||
|
||||
/* the last message the was processed */
|
||||
int last_message = -1;
|
||||
|
||||
/* a useful macro to debug the last message processed */
|
||||
#define LAST_MESSAGE() smb_fn_name(last_message)
|
||||
|
||||
extern pstring scope;
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
extern fstring remote_machine;
|
||||
extern pstring myhostname;
|
||||
extern pstring pipe_name;
|
||||
|
||||
extern pstring OriginalDir;
|
||||
|
||||
/****************************************************************************
|
||||
when exiting, take the whole family
|
||||
****************************************************************************/
|
||||
static void *dflt_sig(void)
|
||||
{
|
||||
exit_server("caught signal");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Send a SIGTERM to our process group.
|
||||
*****************************************************************************/
|
||||
static void killkids(void)
|
||||
{
|
||||
if(am_parent) kill(0,SIGTERM);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
open and listen to a socket
|
||||
****************************************************************************/
|
||||
static int open_server_socket(void)
|
||||
{
|
||||
int s;
|
||||
fstring dir;
|
||||
fstring path;
|
||||
|
||||
slprintf(dir, sizeof(dir)-1, "/tmp/.msrpc");
|
||||
slprintf(path, sizeof(path)-1, "%s/%s", dir, pipe_name);
|
||||
|
||||
s = create_pipe_socket(dir, 0777, path, 0777);
|
||||
|
||||
if (s == -1)
|
||||
return -1;
|
||||
/* ready to listen */
|
||||
if (listen(s, 5) == -1) {
|
||||
DEBUG(0,("listen: %s\n", strerror(errno)));
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
open the socket communication
|
||||
****************************************************************************/
|
||||
static int open_sockets(BOOL is_daemon)
|
||||
{
|
||||
int ClientMSRPC;
|
||||
int num_interfaces = iface_count();
|
||||
int fd_listenset;
|
||||
fd_set listen_set;
|
||||
int s;
|
||||
|
||||
memset(&fd_listenset, 0, sizeof(fd_listenset));
|
||||
|
||||
#ifdef HAVE_ATEXIT
|
||||
{
|
||||
static int atexit_set;
|
||||
if(atexit_set == 0) {
|
||||
atexit_set=1;
|
||||
atexit(killkids);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Stop zombies */
|
||||
CatchChild();
|
||||
|
||||
|
||||
FD_ZERO(&listen_set);
|
||||
|
||||
/* Just bind to 0.0.0.0 - accept connections
|
||||
from anywhere. */
|
||||
num_interfaces = 1;
|
||||
|
||||
/* open an incoming socket */
|
||||
s = open_server_socket();
|
||||
if (s == -1)
|
||||
return -1;
|
||||
fd_listenset = s;
|
||||
FD_SET(s,&listen_set);
|
||||
|
||||
/* now accept incoming connections - forking a new process
|
||||
for each incoming connection */
|
||||
DEBUG(2,("waiting for a connection\n"));
|
||||
while (1)
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
int in_addrlen = sizeof(addr);
|
||||
fd_set lfds;
|
||||
int num;
|
||||
|
||||
memcpy((char *)&lfds, (char *)&listen_set,
|
||||
sizeof(listen_set));
|
||||
|
||||
num = sys_select(256,&lfds,NULL, NULL);
|
||||
|
||||
if (num == -1 && errno == EINTR)
|
||||
continue;
|
||||
|
||||
/* Find the sockets that are read-ready -
|
||||
accept on these. */
|
||||
|
||||
s = -1;
|
||||
if(FD_ISSET(fd_listenset,&lfds))
|
||||
{
|
||||
s = fd_listenset;
|
||||
}
|
||||
|
||||
/* Clear this so we don't look at it again. */
|
||||
FD_CLR(s,&lfds);
|
||||
|
||||
ClientMSRPC = accept(s,(struct sockaddr*)&addr,&in_addrlen);
|
||||
|
||||
if (ClientMSRPC == -1 && errno == EINTR)
|
||||
continue;
|
||||
|
||||
if (ClientMSRPC == -1)
|
||||
{
|
||||
DEBUG(0,("open_sockets: accept: %s\n",
|
||||
strerror(errno)));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ClientMSRPC != -1 && fork()==0)
|
||||
{
|
||||
/* Child code ... */
|
||||
|
||||
/* close the listening socket(s) */
|
||||
close(fd_listenset);
|
||||
|
||||
/* close our standard file
|
||||
descriptors */
|
||||
close_low_fds();
|
||||
am_parent = 0;
|
||||
|
||||
/* Reset global variables in util.c so
|
||||
that client substitutions will be
|
||||
done correctly in the process. */
|
||||
reset_globals_after_fork();
|
||||
|
||||
return ClientMSRPC;
|
||||
}
|
||||
/* The parent doesn't need this socket */
|
||||
close(ClientMSRPC);
|
||||
|
||||
/* Force parent to check log size after
|
||||
* spawning child. Fix from
|
||||
* klausr@ITAP.Physik.Uni-Stuttgart.De. The
|
||||
* parent daemon will log to logserver.smb. It
|
||||
* writes only two messages for each child
|
||||
* started/finished. But each child writes,
|
||||
* say, 50 messages also in logserver.smb,
|
||||
* begining with the debug_count of the
|
||||
* parent, before the child opens its own log
|
||||
* file logserver.client. In a worst case
|
||||
* scenario the size of logserver.smb would be
|
||||
* checked after about 50*50=2500 messages
|
||||
* (ca. 100kb).
|
||||
* */
|
||||
force_check_log_size();
|
||||
|
||||
} /* end while 1 */
|
||||
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
this prevents zombie child processes
|
||||
****************************************************************************/
|
||||
BOOL reload_after_sighup = False;
|
||||
|
||||
static void sig_hup(int sig)
|
||||
{
|
||||
BlockSignals(True,SIGHUP);
|
||||
DEBUG(0,("Got SIGHUP\n"));
|
||||
|
||||
/*
|
||||
* Fix from <branko.cibej@hermes.si> here.
|
||||
* We used to reload in the signal handler - this
|
||||
* is a *BIG* no-no.
|
||||
*/
|
||||
|
||||
reload_after_sighup = True;
|
||||
BlockSignals(False,SIGHUP);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if DUMP_CORE
|
||||
/*******************************************************************
|
||||
prepare to dump a core file - carefully!
|
||||
********************************************************************/
|
||||
static BOOL dump_core(void)
|
||||
{
|
||||
char *p;
|
||||
pstring dname;
|
||||
pstrcpy(dname,debugf);
|
||||
if ((p=strrchr(dname,'/'))) *p=0;
|
||||
pstrcat(dname,"/corefiles");
|
||||
mkdir(dname,0700);
|
||||
sys_chown(dname,getuid(),getgid());
|
||||
chmod(dname,0700);
|
||||
if (chdir(dname)) return(False);
|
||||
umask(~(0700));
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
#ifdef RLIMIT_CORE
|
||||
{
|
||||
struct rlimit rlp;
|
||||
getrlimit(RLIMIT_CORE, &rlp);
|
||||
rlp.rlim_cur = MAX(4*1024*1024,rlp.rlim_cur);
|
||||
setrlimit(RLIMIT_CORE, &rlp);
|
||||
getrlimit(RLIMIT_CORE, &rlp);
|
||||
DEBUG(3,("Core limits now %d %d\n",
|
||||
(int)rlp.rlim_cur,(int)rlp.rlim_max));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
DEBUG(0,("Dumping core in %s\n",dname));
|
||||
abort();
|
||||
return(True);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
exit the server
|
||||
****************************************************************************/
|
||||
void exit_server(char *reason)
|
||||
{
|
||||
static int firsttime=1;
|
||||
extern char *last_inbuf;
|
||||
|
||||
|
||||
if (!firsttime) exit(0);
|
||||
firsttime = 0;
|
||||
|
||||
unbecome_vuser();
|
||||
DEBUG(2,("Closing connections\n"));
|
||||
|
||||
#ifdef WITH_DFS
|
||||
if (dcelogin_atmost_once) {
|
||||
dfs_unlogin();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!reason) {
|
||||
int oldlevel = DEBUGLEVEL;
|
||||
DEBUGLEVEL = 10;
|
||||
if (last_inbuf)
|
||||
show_msg(last_inbuf);
|
||||
DEBUGLEVEL = oldlevel;
|
||||
DEBUG(0,("===============================================================\n"));
|
||||
#if DUMP_CORE
|
||||
if (dump_core()) return;
|
||||
#endif
|
||||
}
|
||||
|
||||
locking_end();
|
||||
|
||||
DEBUG(3,("Server exit (%s)\n", (reason ? reason : "")));
|
||||
#ifdef MEM_MAN
|
||||
{
|
||||
extern FILE *dbf;
|
||||
smb_mem_write_verbose(dbf);
|
||||
dbgflush();
|
||||
}
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
initialise connect, service and file structs
|
||||
****************************************************************************/
|
||||
static void init_structs(void)
|
||||
{
|
||||
#if 0
|
||||
conn_init();
|
||||
#endif
|
||||
init_rpc_pipe_hnd(); /* for RPC pipes */
|
||||
if (!init_policy_hnd(MAX_SERVER_POLICY_HANDLES))
|
||||
{
|
||||
exit_server("could not allocate policy handles\n");
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
usage on the program
|
||||
****************************************************************************/
|
||||
static void usage(char *pname)
|
||||
{
|
||||
DEBUG(0,("Incorrect program usage - are you sure the command line is correct?\n"));
|
||||
|
||||
printf("Usage: %s [-D] [-p port] [-d debuglevel] ", pname);
|
||||
printf("[-l log basename] [-s services file]\n" );
|
||||
printf("Version %s\n",VERSION);
|
||||
printf("\t-D become a daemon\n");
|
||||
printf("\t-p port listen on the specified port\n");
|
||||
printf("\t-d debuglevel set the debuglevel\n");
|
||||
printf("\t-l log basename. Basename for log/debug files\n");
|
||||
printf("\t-s services file. Filename of services file\n");
|
||||
printf("\t-P passive only\n");
|
||||
printf("\t-a append to log file (default)\n");
|
||||
printf("\t-o overwrite log file, don't append\n");
|
||||
printf("\t-i scope NetBIOS scope to use (default none)\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
main program
|
||||
****************************************************************************/
|
||||
int msrpc_main(int argc,char *argv[])
|
||||
{
|
||||
extern BOOL append_log;
|
||||
/* shall I run as a daemon */
|
||||
BOOL is_daemon = False;
|
||||
int opt;
|
||||
extern char *optarg;
|
||||
int ClientMSRPC = -1;
|
||||
pipes_struct static_pipe;
|
||||
|
||||
pstrcpy(remote_machine, pipe_name);
|
||||
|
||||
charset_initialise();
|
||||
|
||||
/* make absolutely sure we run as root - to handle cases where people
|
||||
are crazy enough to have it setuid */
|
||||
#ifdef HAVE_SETRESUID
|
||||
setresuid(0,0,0);
|
||||
#else
|
||||
setuid(0);
|
||||
seteuid(0);
|
||||
setuid(0);
|
||||
seteuid(0);
|
||||
#endif
|
||||
|
||||
fault_setup((void (*)(void *))exit_server);
|
||||
CatchSignal(SIGTERM , SIGNAL_CAST dflt_sig);
|
||||
|
||||
/* we are never interested in SIGPIPE */
|
||||
BlockSignals(True,SIGPIPE);
|
||||
|
||||
/* we want total control over the permissions on created files,
|
||||
so set our umask to 0 */
|
||||
umask(0);
|
||||
|
||||
dos_GetWd(OriginalDir);
|
||||
|
||||
init_uid();
|
||||
|
||||
/* this is for people who can't start the program correctly */
|
||||
while (argc > 1 && (*argv[1] != '-')) {
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
|
||||
while ( EOF != (opt = getopt(argc, argv, "i:l:s:d:Dh?Paof:")) )
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
pstrcpy(scope,optarg);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
{
|
||||
extern BOOL passive;
|
||||
passive = True;
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
pstrcpy(servicesf,optarg);
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
pstrcpy(debugf,optarg);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
append_log = True;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
append_log = False;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
is_daemon = True;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (*optarg == 'A')
|
||||
DEBUGLEVEL = 10000;
|
||||
else
|
||||
DEBUGLEVEL = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
reopen_logs();
|
||||
|
||||
DEBUG(1,( "%s version %s started.\n", argv[0], VERSION));
|
||||
DEBUGADD(1,( "Copyright Andrew Tridgell 1992-1999\n"));
|
||||
|
||||
DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n",
|
||||
(int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid()));
|
||||
|
||||
if (sizeof(uint16) < 2 || sizeof(uint32) < 4) {
|
||||
DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
get_myname(myhostname,NULL);
|
||||
|
||||
if (!reload_services(False))
|
||||
return(-1);
|
||||
|
||||
init_structs();
|
||||
|
||||
#ifdef WITH_PROFILE
|
||||
if (!profile_setup(False)) {
|
||||
DEBUG(0,("ERROR: failed to setup profiling\n"));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the machine NETBIOS name if not already
|
||||
* set from the config file.
|
||||
*/
|
||||
if (!*global_myname)
|
||||
{
|
||||
fstrcpy(global_myname, dns_to_netbios_name(myhostname));
|
||||
}
|
||||
strupper(global_myname);
|
||||
|
||||
codepage_initialise(lp_client_code_page());
|
||||
|
||||
CatchSignal(SIGHUP,SIGNAL_CAST sig_hup);
|
||||
|
||||
/* Setup the signals that allow the debug log level
|
||||
to by dynamically changed. */
|
||||
|
||||
/* If we are using the malloc debug code we can't use
|
||||
SIGUSR1 and SIGUSR2 to do debug level changes. */
|
||||
|
||||
#ifndef MEM_MAN
|
||||
#if defined(SIGUSR1)
|
||||
CatchSignal( SIGUSR1, SIGNAL_CAST sig_usr1 );
|
||||
#endif /* SIGUSR1 */
|
||||
|
||||
#if defined(SIGUSR2)
|
||||
CatchSignal( SIGUSR2, SIGNAL_CAST sig_usr2 );
|
||||
#endif /* SIGUSR2 */
|
||||
#endif /* MEM_MAN */
|
||||
|
||||
DEBUG(3,( "loaded services\n"));
|
||||
|
||||
if (!is_daemon && !is_a_socket(0)) {
|
||||
DEBUG(0,("standard input is not a socket, assuming -D option\n"));
|
||||
is_daemon = True;
|
||||
}
|
||||
|
||||
if (is_daemon) {
|
||||
DEBUG( 3, ( "Becoming a daemon.\n" ) );
|
||||
become_daemon();
|
||||
}
|
||||
|
||||
if (!directory_exist(lp_lockdir(), NULL)) {
|
||||
mkdir(lp_lockdir(), 0755);
|
||||
}
|
||||
|
||||
if (is_daemon) {
|
||||
pidfile_create(pipe_name);
|
||||
}
|
||||
|
||||
ClientMSRPC = open_sockets(is_daemon);
|
||||
if (ClientMSRPC == -1)
|
||||
{
|
||||
exit_server("open socket failed");
|
||||
}
|
||||
|
||||
if (!locking_init(0))
|
||||
exit(1);
|
||||
|
||||
/* possibly reload the services file. */
|
||||
reload_services(True);
|
||||
|
||||
if (*lp_rootdir()) {
|
||||
if (sys_chroot(lp_rootdir()) == 0)
|
||||
DEBUG(2,("Changed root to %s\n", lp_rootdir()));
|
||||
}
|
||||
|
||||
msrpc_service_init();
|
||||
|
||||
ZERO_STRUCT(static_pipe);
|
||||
fstrcpy(static_pipe.name, pipe_name);
|
||||
if (msrpcd_init(ClientMSRPC, &static_pipe))
|
||||
{
|
||||
reload_services(True);
|
||||
msrpcd_process(ClientMSRPC, &static_pipe);
|
||||
}
|
||||
if (ClientMSRPC != -1)
|
||||
{
|
||||
close(ClientMSRPC);
|
||||
}
|
||||
|
||||
exit_server("normal exit");
|
||||
return(0);
|
||||
}
|
@ -1,515 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
process incoming packets - main loop
|
||||
Copyright (C) Andrew Tridgell 1992-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;
|
||||
|
||||
time_t smb_last_time=(time_t)0;
|
||||
|
||||
char *InBuffer = NULL;
|
||||
char *OutBuffer = NULL;
|
||||
char *last_inbuf = NULL;
|
||||
|
||||
/*
|
||||
* Size of data we can send to client. Set
|
||||
* by the client for all protocols above CORE.
|
||||
* Set by us for CORE protocol.
|
||||
*/
|
||||
int max_send = BUFFER_SIZE;
|
||||
/*
|
||||
* Size of the data we can receive. Set by us.
|
||||
* Can be modified by the max xmit parameter.
|
||||
*/
|
||||
int max_recv = BUFFER_SIZE;
|
||||
|
||||
extern int last_message;
|
||||
extern pstring sesssetup_user;
|
||||
extern char *last_inbuf;
|
||||
extern char *InBuffer;
|
||||
extern char *OutBuffer;
|
||||
extern int smb_read_error;
|
||||
extern BOOL reload_after_sighup;
|
||||
extern int max_send;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
Do a select on an two fd's - with timeout.
|
||||
|
||||
If a local udp message has been pushed onto the
|
||||
queue (this can only happen during oplock break
|
||||
processing) return this first.
|
||||
|
||||
If a pending smb message has been pushed onto the
|
||||
queue (this can only happen during oplock break
|
||||
processing) return this next.
|
||||
|
||||
If the first smbfd is ready then read an smb from it.
|
||||
if the second (loopback UDP) fd is ready then read a message
|
||||
from it and setup the buffer header to identify the length
|
||||
and from address.
|
||||
Returns False on timeout or error.
|
||||
Else returns True.
|
||||
|
||||
The timeout is in milli seconds
|
||||
****************************************************************************/
|
||||
|
||||
static BOOL receive_message_or_msrpc(int c, char *buffer, int buffer_len,
|
||||
int timeout, BOOL *got_smb)
|
||||
{
|
||||
fd_set fds;
|
||||
int selrtn;
|
||||
struct timeval to;
|
||||
int maxfd;
|
||||
|
||||
smb_read_error = 0;
|
||||
|
||||
*got_smb = False;
|
||||
|
||||
/*
|
||||
* Check to see if we already have a message on the smb queue.
|
||||
* If so - copy and return it.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Setup the select read fd set.
|
||||
*/
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(c,&fds);
|
||||
maxfd = 0;
|
||||
|
||||
to.tv_sec = timeout / 1000;
|
||||
to.tv_usec = (timeout % 1000) * 1000;
|
||||
|
||||
selrtn = sys_select(MAX(maxfd,c)+1,&fds,NULL, timeout>0?&to:NULL);
|
||||
|
||||
/* Check if error */
|
||||
if(selrtn == -1) {
|
||||
/* something is wrong. Maybe the socket is dead? */
|
||||
smb_read_error = READ_ERROR;
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Did we timeout ? */
|
||||
if (selrtn == 0) {
|
||||
smb_read_error = READ_TIMEOUT;
|
||||
return False;
|
||||
}
|
||||
|
||||
if (FD_ISSET(c,&fds))
|
||||
{
|
||||
*got_smb = True;
|
||||
return receive_smb(c, buffer, 0);
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
These flags determine some of the permissions required to do an operation
|
||||
|
||||
Note that I don't set NEED_WRITE on some write operations because they
|
||||
are used by some brain-dead clients when printing, and I don't want to
|
||||
force write permissions on print services.
|
||||
*/
|
||||
#define AS_USER (1<<0)
|
||||
#define NEED_WRITE (1<<1)
|
||||
#define TIME_INIT (1<<2)
|
||||
#define CAN_IPC (1<<3)
|
||||
#define AS_GUEST (1<<5)
|
||||
#define QUEUE_IN_OPLOCK (1<<6)
|
||||
|
||||
/*
|
||||
define a list of possible SMB messages and their corresponding
|
||||
functions. Any message that has a NULL function is unimplemented -
|
||||
please feel free to contribute implementations!
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
do a switch on the message type, and return the response size
|
||||
****************************************************************************/
|
||||
static int do_message(pipes_struct *p,
|
||||
char *inbuf,char *outbuf,int size,int bufsize)
|
||||
{
|
||||
static int pid= -1;
|
||||
|
||||
prs_struct pd;
|
||||
int outsize = -1;
|
||||
|
||||
/* make a static data parsing structure from the api_fd_reply data */
|
||||
prs_init(&pd, 0, 4, 0, True);
|
||||
mem_create(pd.data, smb_base(inbuf), 0, smb_len(inbuf), 0, False);
|
||||
|
||||
if (pid == -1)
|
||||
pid = getpid();
|
||||
|
||||
/* dce/rpc command */
|
||||
if (rpc_to_smb(p, smb_base(inbuf), smb_len(inbuf)))
|
||||
{
|
||||
char *copy_into = smb_base(outbuf);
|
||||
outsize = mem_buf_len(p->rsmb_pdu.data);
|
||||
if (!mem_buf_copy(copy_into, p->rsmb_pdu.data, 0, outsize))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
mem_free_data(p->rsmb_pdu.data);
|
||||
}
|
||||
|
||||
return outsize;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
construct a reply to the incoming packet
|
||||
****************************************************************************/
|
||||
static int construct_reply(pipes_struct *p,
|
||||
char *inbuf,char *outbuf,int size,int bufsize)
|
||||
{
|
||||
int outsize = 0;
|
||||
smb_last_time = time(NULL);
|
||||
|
||||
outsize = do_message(p, inbuf,outbuf,size,bufsize) + 4;
|
||||
|
||||
if(outsize > 4)
|
||||
_smb_setlen(outbuf,outsize - 4);
|
||||
return(outsize);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
process an smb from the client - split out from the process() code so
|
||||
it can be used by the oplock break code.
|
||||
****************************************************************************/
|
||||
static void process_msrpc(pipes_struct *p, int c, char *inbuf, char *outbuf)
|
||||
{
|
||||
static int trans_num;
|
||||
int32 len = smb_len(inbuf);
|
||||
int nread = len + 4;
|
||||
|
||||
if (trans_num == 0) {
|
||||
/* on the first packet, check the global hosts allow/ hosts
|
||||
deny parameters before doing any parsing of the packet
|
||||
passed to us by the client. This prevents attacks on our
|
||||
parsing code from hosts not in the hosts allow list */
|
||||
if (!check_access(c, lp_hostsallow(-1), lp_hostsdeny(-1))) {
|
||||
/* send a negative session response "not listining on calling
|
||||
name" */
|
||||
DEBUG( 1, ( "Connection denied from %s\n",
|
||||
client_addr(c) ) );
|
||||
exit_server("connection denied");
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG( 6, ( "got message of len 0x%x\n", len ) );
|
||||
DEBUG( 3, ( "Transaction %d of length %d\n", trans_num, nread ) );
|
||||
|
||||
dump_data(10, inbuf, len);
|
||||
|
||||
#ifdef WITH_VTP
|
||||
if(trans_num == 1 && VT_Check(inbuf))
|
||||
{
|
||||
VT_Process();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
nread = construct_reply(p, inbuf,outbuf,nread,max_send);
|
||||
|
||||
if(nread > 0)
|
||||
{
|
||||
dump_data(10, outbuf, nread);
|
||||
|
||||
if (nread != smb_len(outbuf) + 4)
|
||||
{
|
||||
DEBUG(0,("ERROR: Invalid message response size! %d %d\n",
|
||||
nread, smb_len(outbuf)));
|
||||
}
|
||||
else
|
||||
send_smb(c,outbuf);
|
||||
}
|
||||
trans_num++;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
reads user credentials from the socket
|
||||
****************************************************************************/
|
||||
BOOL get_user_creds(int c, struct user_creds *usr)
|
||||
{
|
||||
pstring buf;
|
||||
int rl;
|
||||
uint32 len;
|
||||
BOOL new_con = False;
|
||||
uint32 status;
|
||||
|
||||
CREDS_CMD cmd;
|
||||
prs_struct ps;
|
||||
|
||||
ZERO_STRUCTP(usr);
|
||||
ZERO_STRUCT(cmd);
|
||||
cmd.cred = usr;
|
||||
|
||||
DEBUG(10,("get_user_creds: first request\n"));
|
||||
|
||||
rl = read(c, &buf, sizeof(len));
|
||||
|
||||
if (rl != sizeof(len))
|
||||
{
|
||||
DEBUG(0,("Unable to read length\n"));
|
||||
dump_data(0, buf, sizeof(len));
|
||||
return False;
|
||||
}
|
||||
|
||||
len = IVAL(buf, 0);
|
||||
|
||||
if (len > sizeof(buf))
|
||||
{
|
||||
DEBUG(0,("length %d too long\n", len));
|
||||
return False;
|
||||
}
|
||||
|
||||
rl = read(c, buf, len);
|
||||
|
||||
if (rl < 0)
|
||||
{
|
||||
DEBUG(0,("Unable to read from connection\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PASSWORD
|
||||
dump_data(100, buf, rl);
|
||||
#endif
|
||||
|
||||
/* make a static data parsing structure from the api_fd_reply data */
|
||||
prs_init(&ps, 0, 4, 0, True);
|
||||
mem_create(ps.data, buf, 0, len, 0, False);
|
||||
|
||||
if (!creds_io_cmd("creds", &cmd, &ps, 0))
|
||||
{
|
||||
DEBUG(0,("Unable to parse credentials\n"));
|
||||
mem_free_data(ps.data);
|
||||
return False;
|
||||
}
|
||||
|
||||
mem_free_data(ps.data);
|
||||
|
||||
if (ps.offset != rl)
|
||||
{
|
||||
DEBUG(0,("Buffer size %d %d!\n", ps.offset, rl));
|
||||
return False;
|
||||
}
|
||||
|
||||
switch (cmd.command)
|
||||
{
|
||||
case AGENT_CMD_CON:
|
||||
case AGENT_CMD_CON_ANON:
|
||||
{
|
||||
new_con = True;
|
||||
break;
|
||||
}
|
||||
case AGENT_CMD_CON_REUSE:
|
||||
{
|
||||
new_con = True;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DEBUG(0,("unknown command %d\n", cmd.command));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
status = new_con ? 0x0 : 0x1;
|
||||
|
||||
if (write(c, &status, sizeof(status)) !=
|
||||
sizeof(status))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return new_con;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initialise from pipe
|
||||
****************************************************************************/
|
||||
BOOL msrpcd_init(int c, pipes_struct *p)
|
||||
{
|
||||
struct user_creds usr;
|
||||
gid_t *groups = NULL;
|
||||
char *user;
|
||||
|
||||
if (!get_user_creds(c, &usr))
|
||||
{
|
||||
DEBUG(0,("authentication failed\n"));
|
||||
free_user_creds(&usr);
|
||||
return False;
|
||||
}
|
||||
|
||||
if (usr.uxs.num_grps != 0)
|
||||
{
|
||||
int i;
|
||||
groups = malloc(usr.uxs.num_grps * sizeof(groups[0]));
|
||||
if (groups == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
for (i = 0; i < usr.uxs.num_grps; i++)
|
||||
{
|
||||
groups[i] = (gid_t)usr.uxs.grps[i];
|
||||
}
|
||||
}
|
||||
|
||||
p->vuid = create_vuid(usr.uxs.uid, usr.uxs.gid,
|
||||
usr.uxs.num_grps, groups,
|
||||
usr.uxc.user_name,
|
||||
usr.uxc.requested_name,
|
||||
usr.uxc.real_name,
|
||||
usr.uxc.guest,
|
||||
usr.ntc.pwd.sess_key);
|
||||
|
||||
if (p->vuid == UID_FIELD_INVALID)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
free_user_creds(&usr);
|
||||
|
||||
if (!become_vuser(p->vuid))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
p->l = malloc(sizeof(*p->l));
|
||||
if (p->l == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
ZERO_STRUCTP(p->l);
|
||||
|
||||
user = usr.uxc.user_name;
|
||||
if (!strequal(user,lp_guestaccount(-1)) &&
|
||||
lp_servicenumber(user) < 0)
|
||||
{
|
||||
int homes = lp_servicenumber(HOMES_NAME);
|
||||
char *home = get_unixhome_dir(user);
|
||||
if (homes >= 0 && home)
|
||||
{
|
||||
pstring home_dir;
|
||||
fstrcpy(home_dir, home);
|
||||
lp_add_home(user,homes,home_dir);
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
process commands from the client
|
||||
****************************************************************************/
|
||||
void msrpcd_process(int c, pipes_struct *p)
|
||||
{
|
||||
InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
|
||||
OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
|
||||
if ((InBuffer == NULL) || (OutBuffer == NULL))
|
||||
return;
|
||||
|
||||
InBuffer += SMB_ALIGNMENT;
|
||||
OutBuffer += SMB_ALIGNMENT;
|
||||
|
||||
max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
|
||||
|
||||
/* re-initialise the timezone */
|
||||
TimeInit();
|
||||
|
||||
while (True)
|
||||
{
|
||||
int counter;
|
||||
int service_load_counter = 0;
|
||||
BOOL got_smb = False;
|
||||
|
||||
errno = 0;
|
||||
|
||||
for (counter=SMBD_SELECT_LOOP;
|
||||
!receive_message_or_msrpc(c, InBuffer,BUFFER_SIZE,
|
||||
SMBD_SELECT_LOOP*1000,&got_smb);
|
||||
counter += SMBD_SELECT_LOOP)
|
||||
{
|
||||
time_t t;
|
||||
|
||||
if (counter > 365 * 3600) /* big number of seconds. */
|
||||
{
|
||||
counter = 0;
|
||||
service_load_counter = 0;
|
||||
}
|
||||
|
||||
if (smb_read_error == READ_EOF)
|
||||
{
|
||||
DEBUG(3,("end of file from client\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (smb_read_error == READ_ERROR)
|
||||
{
|
||||
DEBUG(3,("receive_smb error (%s) exiting\n",
|
||||
strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
/* check for smb.conf reload */
|
||||
if (counter >= service_load_counter + SMBD_RELOAD_CHECK)
|
||||
{
|
||||
service_load_counter = counter;
|
||||
|
||||
/* reload services, if files have changed. */
|
||||
reload_services(True);
|
||||
}
|
||||
|
||||
/*
|
||||
* If reload_after_sighup == True then we got a SIGHUP
|
||||
* and are being asked to reload. Fix from <branko.cibej@hermes.si>
|
||||
*/
|
||||
|
||||
if (reload_after_sighup)
|
||||
{
|
||||
DEBUG(0,("Reloading services after SIGHUP\n"));
|
||||
reload_services(False);
|
||||
reload_after_sighup = False;
|
||||
/*
|
||||
* Use this as an excuse to print some stats.
|
||||
*/
|
||||
}
|
||||
|
||||
/* automatic timeout if all connections are closed */
|
||||
if (counter >= IDLE_CLOSED_TIMEOUT)
|
||||
{
|
||||
DEBUG( 2, ( "Closing idle connection\n" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(got_smb)
|
||||
process_msrpc(p, c, InBuffer, OutBuffer);
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Main SMB server routines
|
||||
Copyright (C) Andrew Tridgell 1992-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"
|
||||
|
||||
fstring pipe_name;
|
||||
|
||||
pstring servicesf = CONFIGFILE;
|
||||
extern pstring debugf;
|
||||
extern BOOL append_log;
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/*************************************************************************
|
||||
initialise an msrpc service
|
||||
*************************************************************************/
|
||||
void msrpc_service_init(void)
|
||||
{
|
||||
if (!pwdb_initialise(True))
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_sam_password_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_passgrp_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_group_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_alias_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(!initialise_builtin_db())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!get_member_domain_sid())
|
||||
{
|
||||
DEBUG(0,("ERROR: Samba cannot obtain PDC SID from PDC(s) %s.\n",
|
||||
lp_passwordserver()));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
reload the services file
|
||||
**************************************************************************/
|
||||
BOOL reload_services(BOOL test)
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
if (lp_loaded()) {
|
||||
pstring fname;
|
||||
pstrcpy(fname,lp_configfile());
|
||||
if (file_exist(fname,NULL) && !strcsequal(fname,servicesf)) {
|
||||
pstrcpy(servicesf,fname);
|
||||
test = False;
|
||||
}
|
||||
}
|
||||
|
||||
reopen_logs();
|
||||
|
||||
if (test && !lp_file_list_changed())
|
||||
return(True);
|
||||
|
||||
lp_killunused(NULL);
|
||||
|
||||
ret = lp_load(servicesf,False,False,True);
|
||||
|
||||
/* perhaps the config filename is now set */
|
||||
if (!test)
|
||||
reload_services(True);
|
||||
|
||||
reopen_logs();
|
||||
|
||||
load_interfaces();
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
main program
|
||||
****************************************************************************/
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
#ifdef HAVE_SET_AUTH_PARAMETERS
|
||||
set_auth_parameters(argc,argv);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETLUID
|
||||
/* needed for SecureWare on SCO */
|
||||
setluid(0);
|
||||
#endif
|
||||
|
||||
append_log = True;
|
||||
|
||||
TimeInit();
|
||||
|
||||
setup_logging(argv[0],False);
|
||||
fstrcpy(pipe_name, "NETLOGON");
|
||||
slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name);
|
||||
add_msrpc_command_processor( pipe_name, argv[0], api_netlog_rpc );
|
||||
|
||||
return msrpc_main(argc, argv);
|
||||
}
|
@ -1,673 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* Samba MYSQL SAM Database, by Benjamin Kuit.
|
||||
* Copyright (C) Benjamin Kuit 1999,
|
||||
* Copyright (C) Andrew Tridgell 1992-1999,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
#define UNIX_NAME(row) ((*row)[0])
|
||||
#define UNIX_UID(row) ((*row)[1])
|
||||
#define NT_NAME(row) ((*row)[2])
|
||||
#define RID(row) ((*row)[3])
|
||||
#define LM_HASH(row) ((*row)[4])
|
||||
#define NT_HASH(row) ((*row)[5])
|
||||
#define FLAGS(row) ((*row)[6])
|
||||
#define CHANGE_TIME(row) ((*row)[7])
|
||||
|
||||
static fstring mysql_table = { 0 };
|
||||
|
||||
struct mysql_struct {
|
||||
MYSQL handle;
|
||||
MYSQL_RES *result;
|
||||
uint current_row;
|
||||
};
|
||||
typedef struct mysql_struct mysql_ctrl;
|
||||
|
||||
static char *mysql_retrieve_password(char *passfile)
|
||||
{
|
||||
static fstring pass;
|
||||
static time_t last_checked = (time_t)0;
|
||||
static char pass_chars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_-+=|~`\\{}[]:;\"'?/>.<,";
|
||||
fstring temppass;
|
||||
FILE *filep;
|
||||
int length;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( passfile == NULL ) {
|
||||
pass[0]=0;
|
||||
return pass;
|
||||
}
|
||||
|
||||
if ( time(NULL) - last_checked <= 60 ) {
|
||||
return pass;
|
||||
}
|
||||
|
||||
if ( file_modtime(passfile) < last_checked ) {
|
||||
return pass;
|
||||
}
|
||||
|
||||
filep = sys_fopen(passfile,"r");
|
||||
|
||||
if ( filep == NULL ) {
|
||||
return pass;
|
||||
}
|
||||
|
||||
memset(temppass,0,sizeof(temppass));
|
||||
|
||||
if ( fgets( temppass, sizeof(temppass)-1, filep) == NULL ) {
|
||||
fclose(filep);
|
||||
return pass;
|
||||
}
|
||||
|
||||
fclose(filep);
|
||||
|
||||
length = strspn( temppass, pass_chars );
|
||||
temppass[length<sizeof(temppass)-1?length:sizeof(temppass)-1] = '\0';
|
||||
|
||||
fstrcpy( pass, temppass );
|
||||
|
||||
last_checked = time(NULL);
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
static int mysql_db_connect( MYSQL *handle )
|
||||
{
|
||||
char *password;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
password = mysql_retrieve_password(lp_mysql_passfile());
|
||||
|
||||
if ( !mysql_connect(handle, lp_mysql_host(), lp_mysql_user(), password) ) {
|
||||
DEBUG(0,("mysql_connect: %s\n",mysql_error(handle)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mysql_select_db( handle, lp_mysql_db()) ) {
|
||||
DEBUG(0,("mysql_connect: %s\n",mysql_error(handle)));
|
||||
mysql_close(handle);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fstrcpy(mysql_table,lp_mysql_table());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mysql_lock_table( MYSQL *handle, BOOL write_access )
|
||||
{
|
||||
fstring query;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
slprintf( query, sizeof(query), "lock tables %s %s", mysql_table, write_access==True?"write":"read");
|
||||
|
||||
if ( mysql_query( handle, query ) ) {
|
||||
DEBUG(0,("Cannot get lock: %s: %s\n",query,mysql_error(handle) ));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mysql_db_lock_connect( MYSQL *handle )
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( mysql_db_connect( handle ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mysql_lock_table( handle, True ) ) {
|
||||
mysql_close( handle );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MYSQL_RES *mysql_select_results( MYSQL *handle, char *selection )
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
pstring query;
|
||||
int query_length;
|
||||
char select[] = "select ";
|
||||
char where[] = " where ";
|
||||
char from[] = " from ";
|
||||
char mysql_query_string[] = "unix_name, unix_uid, nt_name, user_rid, smb_passwd, smb_nt_passwd, acct_ctrl, pass_last_set_time";
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
query_length = sizeof( select ) + sizeof( mysql_query_string ) + sizeof(from ) + strlen( mysql_table );
|
||||
|
||||
if ( selection != NULL && *selection != '\0' ) {
|
||||
query_length += sizeof( where ) + strlen( selection );
|
||||
}
|
||||
|
||||
if ( query_length >= sizeof( query ) ) {
|
||||
DEBUG(0,("Query string too long\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pstrcpy( query, select);
|
||||
pstrcat( query, mysql_query_string );
|
||||
pstrcat( query, from );
|
||||
pstrcat( query, mysql_table );
|
||||
|
||||
if ( selection != NULL && *selection != '\0' ) {
|
||||
pstrcat( query, where );
|
||||
pstrcat( query, selection );
|
||||
}
|
||||
|
||||
DEBUG(5,("mysql> %s\n",query));
|
||||
if ( mysql_query( handle, query ) ) {
|
||||
DEBUG(0,("%s: %s\n", query, mysql_error(handle) ));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = mysql_store_result( handle );
|
||||
|
||||
if ( mysql_num_fields( result ) != 8 ) {
|
||||
DEBUG(0,("mysql_num_result = %d (!=8)\n",mysql_num_fields( result )));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( result == NULL ) {
|
||||
DEBUG(0,("mysql_store_result: %s\n",mysql_error(handle)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void *mysql_startpwent( BOOL update )
|
||||
{
|
||||
mysql_ctrl *mysql;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
mysql = (mysql_ctrl *)malloc( sizeof(mysql_ctrl) );
|
||||
if ( mysql == NULL ) {
|
||||
DEBUG(0,("malloc: Out of memory\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset( mysql, 0, sizeof(mysql_ctrl) );
|
||||
|
||||
if ( mysql_db_connect( &mysql->handle ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( mysql_lock_table( &mysql->handle, update ) ) {
|
||||
mysql_close( &mysql->handle );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mysql->result = mysql_select_results( &mysql->handle, NULL );
|
||||
|
||||
if ( mysql->result == NULL ) {
|
||||
mysql_close( &mysql->handle );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mysql->current_row = 0;
|
||||
|
||||
return (void*)mysql;
|
||||
}
|
||||
|
||||
void mysql_endpwent( void *ptr )
|
||||
{
|
||||
mysql_ctrl *handle;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
handle = (mysql_ctrl *)ptr;
|
||||
|
||||
mysql_free_result( handle->result );
|
||||
|
||||
mysql_close( &handle->handle );
|
||||
|
||||
free( handle );
|
||||
}
|
||||
|
||||
SMB_BIG_UINT mysql_getpwpos(void *vp)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return ((mysql_ctrl *)vp)->current_row;
|
||||
}
|
||||
|
||||
BOOL mysql_setpwpos(void *vp, SMB_BIG_UINT pos)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
mysql_data_seek( ((mysql_ctrl*)vp)->result, (uint)pos );
|
||||
((mysql_ctrl *)vp)->current_row=(uint)pos;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
static void quote_hash( char *target, unsigned char *passwd )
|
||||
{
|
||||
char hex[] = "0123456789ABCDEF";
|
||||
int i;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( passwd == NULL ) {
|
||||
fstrcpy(target,"NULL");
|
||||
}
|
||||
else {
|
||||
target[0]='\'';
|
||||
for (i=0;i<32;i++) {
|
||||
target[i+1] = hex[(passwd[i>>1]>>(((~i)&1)<<2))&15];
|
||||
}
|
||||
target[33] = '\'';
|
||||
target[34] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char *decode_hash( char *hash, unsigned char *buffer )
|
||||
{
|
||||
char hex[] = "0123456789ABCDEF";
|
||||
int pos, v1, v2;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( hash == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (pos=0;pos<16;pos++) {
|
||||
for( v1 = 0; v1 < sizeof(hex) && hash[0] != hex[v1]; v1++ );
|
||||
for( v2 = 0; v2 < sizeof(hex) && hash[1] != hex[v2]; v2++ );
|
||||
|
||||
if ( v1 == sizeof(hex) || v2 == sizeof(hex) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer[pos] = (v1<<4)|v2;
|
||||
hash += 2;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void *mysql_fill_smb_passwd( MYSQL_ROW *row )
|
||||
{
|
||||
static struct smb_passwd pw_buf;
|
||||
static fstring unix_name;
|
||||
static fstring nt_name;
|
||||
static unsigned char smbpwd[16];
|
||||
static unsigned char smbntpwd[16];
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
pwdb_init_smb(&pw_buf);
|
||||
|
||||
fstrcpy( unix_name, UNIX_NAME(row) );
|
||||
pw_buf.unix_name = unix_name;
|
||||
pw_buf.unix_uid = get_number( UNIX_UID(row) );
|
||||
|
||||
if ( NT_NAME(row) != NULL ) {
|
||||
fstrcpy( nt_name, NT_NAME(row) );
|
||||
pw_buf.nt_name = nt_name;
|
||||
}
|
||||
|
||||
if ( RID(row) != NULL ) {
|
||||
pw_buf.user_rid = get_number( RID(row) );
|
||||
}
|
||||
|
||||
pw_buf.smb_passwd = decode_hash( LM_HASH(row), smbpwd );
|
||||
if ( !pw_buf.smb_passwd ) {
|
||||
DEBUG(4, ("entry invalidated for unix user %s\n", unix_name ));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pw_buf.smb_nt_passwd = decode_hash( NT_HASH(row), smbntpwd );
|
||||
|
||||
if ( FLAGS(row) != NULL ) {
|
||||
pw_buf.acct_ctrl = get_number( FLAGS(row) );
|
||||
}
|
||||
|
||||
if ( pw_buf.acct_ctrl == 0 ) {
|
||||
pw_buf.acct_ctrl = ACB_NORMAL;
|
||||
}
|
||||
|
||||
pw_buf.pass_last_set_time = get_number( CHANGE_TIME(row) );
|
||||
|
||||
return (void*)&pw_buf;
|
||||
}
|
||||
|
||||
MYSQL_ROW *mysql_getpwent(void *vp)
|
||||
{
|
||||
mysql_ctrl *mysql;
|
||||
static MYSQL_ROW row;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
mysql = (mysql_ctrl*)vp;
|
||||
row = mysql_fetch_row( mysql->result );
|
||||
|
||||
if ( row == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mysql->current_row++;
|
||||
|
||||
return &row;
|
||||
}
|
||||
|
||||
struct smb_passwd *mysql_getsmbpwent(void *vp)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return (struct smb_passwd*)mysql_fill_smb_passwd( mysql_getpwent(vp) );
|
||||
}
|
||||
|
||||
void *mysql_fetch_passwd( void *(*filler)(MYSQL_ROW*), char *where )
|
||||
{
|
||||
void *retval;
|
||||
MYSQL handle;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( filler == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( where == NULL || *where == '\0' ) {
|
||||
DEBUG(0,("Null or empty query\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( mysql_db_connect( &handle ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = mysql_select_results( &handle, where );
|
||||
if ( result == NULL ) {
|
||||
mysql_close( &handle );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
row = mysql_fetch_row ( result );
|
||||
if ( row == NULL ) {
|
||||
mysql_free_result( result );
|
||||
mysql_close( &handle );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( DEBUGLEVEL >= 7 ) {
|
||||
int field;
|
||||
for (field=0; field< mysql_num_fields( result ); field++ ) {
|
||||
DEBUG(7,(" row[%d] = \"%s\"\n",field,row[field]?row[field]:"NULL"));
|
||||
}
|
||||
}
|
||||
|
||||
retval = (*filler)( &row );
|
||||
|
||||
mysql_free_result( result );
|
||||
mysql_close( &handle );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void *mysql_getpwuid(void *(*filler)(MYSQL_ROW *), uid_t uid)
|
||||
{
|
||||
fstring where;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
slprintf( where, sizeof(where), "unix_uid=%lu", uid);
|
||||
|
||||
return mysql_fetch_passwd(filler,where);
|
||||
}
|
||||
|
||||
struct smb_passwd *mysql_getsmbpwuid(uid_t uid)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return (struct smb_passwd *)mysql_getpwuid( mysql_fill_smb_passwd, uid );
|
||||
}
|
||||
|
||||
void *mysql_getpwnam(void *(*filler)(MYSQL_ROW *), char *field, const char *name)
|
||||
{
|
||||
fstring where;
|
||||
char format[] = "%s='%s'";
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( filler == NULL ) {
|
||||
DEBUG(0,("Empty fill opteration\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( field == NULL || *field == '\0' ) {
|
||||
DEBUG(0,("Empty or NULL field name\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( name == NULL || *name == '\0' ) {
|
||||
DEBUG(0,("Empty or NULL query\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( sizeof(format) + strlen(name) + strlen(field) > sizeof(where) ) {
|
||||
DEBUG(0,("Query string too long\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
slprintf(where, sizeof( where ), format, field, name );
|
||||
|
||||
return mysql_fetch_passwd( filler, where );
|
||||
}
|
||||
|
||||
struct smb_passwd *mysql_getsmbpwnam(const char *unix_name)
|
||||
{
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return mysql_getpwnam( mysql_fill_smb_passwd, "unix_name", unix_name );
|
||||
}
|
||||
|
||||
static void quote_string(char *target, char *string)
|
||||
{
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( string == NULL ) {
|
||||
fstrcpy( target, "NULL" );
|
||||
}
|
||||
else {
|
||||
target[0] = '\'';
|
||||
safe_strcpy(&target[1],string,sizeof(fstring)-2);
|
||||
safe_strcpy(&target[strlen(target)],"'",2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL mysql_del_smb( MYSQL *handle, char *unix_name )
|
||||
{
|
||||
pstring query;
|
||||
char format[] = "delete from %s where unix_name='%s'";
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if (strlen( format ) + strlen(mysql_table) + strlen(unix_name)) {
|
||||
return False;
|
||||
}
|
||||
|
||||
slprintf( query, sizeof(query), format, mysql_table, unix_name);
|
||||
|
||||
if ( mysql_query( handle, query ) ) {
|
||||
DEBUG(0,("%s: %s\n", query, mysql_error(handle) ));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL mysql_add_smb( MYSQL *handle, struct smb_passwd *smb )
|
||||
{
|
||||
pstring query;
|
||||
char format[] = "insert into %s (unix_name, unix_uid) values ( '%s', %lu )";
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( strlen(format) + strlen(mysql_table) + strlen(smb->unix_name) + 10 > sizeof(query) ) {
|
||||
DEBUG(0,("Query too long\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
slprintf( query, sizeof(query), "insert into %s (unix_name,unix_uid) values ('%s', %lu)", mysql_table, smb->unix_name, smb->unix_uid);
|
||||
|
||||
if ( mysql_query( handle, query ) ) {
|
||||
DEBUG(0,("%s: %s\n",query,mysql_error(handle) ));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL mysql_mod_smb( MYSQL *handle, struct smb_passwd *smb, BOOL override )
|
||||
{
|
||||
pstring query;
|
||||
fstring smb_passwd;
|
||||
fstring smb_nt_passwd;
|
||||
fstring nt_name;
|
||||
|
||||
char format[] = "update %s set nt_name=%s, user_rid=%lu, smb_passwd=%s, smb_nt_passwd=%s, acct_ctrl=%u, pass_last_set_time=unix_timestamp() where unix_name='%s'";
|
||||
char extra[] = " and not ISNULL(smb_passwd)";
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( strlen(format) + 2*20 + 3*10 + 2*32 + strlen(mysql_table) >= sizeof( query ) + strlen( extra ) ) {
|
||||
DEBUG(0,("Query string too long\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
quote_hash(smb_passwd, smb->smb_passwd);
|
||||
quote_hash(smb_nt_passwd, smb->smb_nt_passwd);
|
||||
|
||||
quote_string(nt_name, smb->nt_name);
|
||||
|
||||
slprintf( query, sizeof(query), format, mysql_table, nt_name, (long unsigned)smb->user_rid, smb_passwd, smb_nt_passwd, smb->acct_ctrl, smb->unix_name);
|
||||
|
||||
if ( override != True ) {
|
||||
pstrcat( query, extra );
|
||||
}
|
||||
|
||||
if ( mysql_query( handle, query ) ) {
|
||||
DEBUG(0,("%s: %s\n",query,mysql_error(handle) ));
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( mysql_affected_rows( handle ) < 1 ) {
|
||||
DEBUG(3,("No entries changed\n"));
|
||||
return False;
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL mysql_add_smbpwd_entry(struct smb_passwd *smb)
|
||||
{
|
||||
MYSQL handle;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( smb == NULL ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( mysql_db_lock_connect( &handle ) ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_add_smb( &handle, smb ) ) {
|
||||
mysql_close( &handle );
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_mod_smb( &handle, smb, True ) ) {
|
||||
mysql_del_smb( &handle, smb->unix_name );
|
||||
mysql_close( &handle );
|
||||
return False;
|
||||
}
|
||||
|
||||
mysql_close(&handle);
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL mysql_mod_smbpwd_entry(struct smb_passwd *smb, BOOL override)
|
||||
{
|
||||
MYSQL handle;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
if ( smb == NULL ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( mysql_db_lock_connect( &handle ) ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_mod_smb( &handle, smb, override ) ) {
|
||||
mysql_close(&handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
mysql_close(&handle);
|
||||
return True;
|
||||
}
|
||||
|
||||
static struct smb_passdb_ops mysql_ops = {
|
||||
mysql_startpwent,
|
||||
mysql_endpwent,
|
||||
mysql_getpwpos,
|
||||
mysql_setpwpos,
|
||||
mysql_getsmbpwnam,
|
||||
mysql_getsmbpwuid,
|
||||
mysql_getsmbpwent,
|
||||
mysql_add_smbpwd_entry,
|
||||
mysql_mod_smbpwd_entry
|
||||
};
|
||||
|
||||
struct smb_passdb_ops *mysql_initialise_password_db(void)
|
||||
{
|
||||
(void*)mysql_retrieve_password(NULL);
|
||||
return &mysql_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void mysql_dummy_smb_function(void) { }
|
||||
#endif
|
@ -1,260 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* Samba MYSQL SAM Database, by Benjamin Kuit.
|
||||
* Copyright (C) Benjamin Kuit 1999,
|
||||
* Copyright (C) Andrew Tridgell 1992-1999,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
MYSQL_ROW *mysql_getpwent(void *vp);
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
extern pstring samlogon_user;
|
||||
extern BOOL sam_logon_in_ssb;
|
||||
|
||||
void *mysql_fill_sam_passwd( MYSQL_ROW *row )
|
||||
{
|
||||
static struct sam_passwd *user;
|
||||
|
||||
static pstring full_name;
|
||||
static pstring home_dir;
|
||||
static pstring home_drive;
|
||||
static pstring logon_script;
|
||||
static pstring profile_path;
|
||||
static pstring acct_desc;
|
||||
static pstring workstations;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
user = pwdb_smb_to_sam((struct smb_passwd *)mysql_fill_smb_passwd(row));
|
||||
|
||||
if ( user == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 'Researched' from sampass.c =) */
|
||||
|
||||
pstrcpy(samlogon_user, user->unix_name);
|
||||
|
||||
if (samlogon_user[strlen(samlogon_user)-1] == '$' &&
|
||||
user->group_rid != DOMAIN_GROUP_RID_USERS)
|
||||
{
|
||||
DEBUG(0,("trust account %s should be in DOMAIN_GROUP_RID_USERS\n", samlogon_user));
|
||||
}
|
||||
|
||||
/* XXXX hack to get standard_sub_basic() to use sam logon username */
|
||||
/* possibly a better way would be to do a become_user() call */
|
||||
sam_logon_in_ssb = True;
|
||||
|
||||
pstrcpy(full_name , "");
|
||||
pstrcpy(logon_script , lp_logon_script ());
|
||||
pstrcpy(profile_path , lp_logon_path ());
|
||||
pstrcpy(home_drive , lp_logon_drive ());
|
||||
pstrcpy(home_dir , lp_logon_home ());
|
||||
pstrcpy(acct_desc , "");
|
||||
pstrcpy(workstations , "");
|
||||
|
||||
sam_logon_in_ssb = False;
|
||||
|
||||
user->full_name = full_name;
|
||||
user->home_dir = home_dir;
|
||||
user->dir_drive = home_drive;
|
||||
user->logon_script = logon_script;
|
||||
user->profile_path = profile_path;
|
||||
user->acct_desc = acct_desc;
|
||||
user->workstations = workstations;
|
||||
|
||||
user->unknown_str = NULL; /* don't know, yet! */
|
||||
user->munged_dial = NULL; /* "munged" dial-back telephone number */
|
||||
|
||||
user->unknown_3 = 0xffffff; /* don't know */
|
||||
user->logon_divs = 168; /* hours per week */
|
||||
user->hours_len = 21; /* 21 times 8 bits = 168 */
|
||||
memset(user->hours, 0xff, user->hours_len); /* available at all hours */
|
||||
user->unknown_5 = 0x00020000; /* don't know */
|
||||
user->unknown_6 = 0x000004ec; /* don't know */
|
||||
|
||||
return (void*)user;
|
||||
}
|
||||
|
||||
struct sam_passwd *mysql_getsampwent(void *vp)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return (struct sam_passwd*)mysql_fill_sam_passwd( mysql_getpwent(vp) );
|
||||
}
|
||||
|
||||
struct sam_passwd *mysql_getsampwrid(uint32 rid)
|
||||
{
|
||||
fstring where;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
slprintf( where, sizeof(where), "user_rid=%lu", (long unsigned)rid);
|
||||
|
||||
return (struct sam_passwd *)mysql_fetch_passwd( mysql_fill_sam_passwd, where );
|
||||
}
|
||||
|
||||
struct sam_passwd *mysql_getsampwuid(uid_t uid)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return (struct sam_passwd *)mysql_getpwuid( mysql_fill_sam_passwd, uid );
|
||||
}
|
||||
|
||||
struct sam_passwd *mysql_getsampwntnam(const char *nt_name)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return (struct sam_passwd *)mysql_getpwnam( mysql_fill_sam_passwd, "nt_name", nt_name);
|
||||
}
|
||||
|
||||
struct sam_disp_info *mysql_getsamdispntnam(const char *nt_name)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return pwdb_sam_to_dispinfo(mysql_getsampwntnam(nt_name));
|
||||
}
|
||||
|
||||
struct sam_disp_info *mysql_getsamdisprid(uint32 rid)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return pwdb_sam_to_dispinfo(mysql_getsampwrid(rid));
|
||||
}
|
||||
|
||||
struct sam_disp_info *mysql_getsamdispent(void *vp)
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return pwdb_sam_to_dispinfo(mysql_getsampwent(vp));
|
||||
}
|
||||
|
||||
static BOOL mysql_mod_sam( MYSQL *handle, struct sam_passwd *sam, BOOL override )
|
||||
{
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL mysql_add_sampwd_entry(struct sam_passwd *sam)
|
||||
{
|
||||
MYSQL handle;
|
||||
struct smb_passwd *smb;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
smb = pwdb_sam_to_smb( sam );
|
||||
|
||||
if ( smb == NULL ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( mysql_db_lock_connect( &handle ) ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_add_smb( &handle, smb ) ) {
|
||||
mysql_close(&handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_mod_smb( &handle, smb, True ) ) {
|
||||
mysql_del_smb( &handle, smb->unix_name );
|
||||
mysql_close(&handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_mod_sam( &handle, sam, True ) ) {
|
||||
mysql_del_smb( &handle, smb->unix_name );
|
||||
mysql_close(&handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
mysql_close(&handle);
|
||||
return True;
|
||||
}
|
||||
|
||||
BOOL mysql_mod_sampwd_entry(struct sam_passwd *sam, BOOL override)
|
||||
{
|
||||
MYSQL handle;
|
||||
struct smb_passwd *smb;
|
||||
|
||||
DEBUG(5,("%s\n",FUNCTION_MACRO));
|
||||
|
||||
smb = pwdb_sam_to_smb(sam);
|
||||
|
||||
if ( smb == NULL ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( mysql_db_lock_connect( &handle ) ) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_mod_smb( &handle, smb, override ) ) {
|
||||
mysql_close(&handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
if ( !mysql_mod_sam( &handle, sam, override ) ) {
|
||||
mysql_close(&handle);
|
||||
return False;
|
||||
}
|
||||
|
||||
mysql_close(&handle);
|
||||
return True;
|
||||
}
|
||||
|
||||
static struct sam_passdb_ops sam_mysql_ops =
|
||||
{
|
||||
mysql_startpwent,
|
||||
mysql_endpwent,
|
||||
mysql_getpwpos,
|
||||
mysql_setpwpos,
|
||||
mysql_getsampwntnam,
|
||||
mysql_getsampwuid,
|
||||
mysql_getsampwrid,
|
||||
mysql_getsampwent,
|
||||
mysql_add_sampwd_entry,
|
||||
mysql_mod_sampwd_entry,
|
||||
mysql_getsamdispntnam,
|
||||
mysql_getsamdisprid,
|
||||
mysql_getsamdispent
|
||||
};
|
||||
|
||||
struct sam_passdb_ops *mysql_initialise_sam_password_db(void)
|
||||
{
|
||||
return &sam_mysql_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void mysql_dummy_sam_function(void) { }
|
||||
#endif
|
@ -1,190 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.0.
|
||||
LDAP passgrp database for SAMBA
|
||||
Copyright (C) Matthew Chapman 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"
|
||||
|
||||
#ifdef WITH_LDAP
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* Internal state */
|
||||
extern LDAP *ldap_struct;
|
||||
extern LDAPMessage *ldap_results;
|
||||
extern LDAPMessage *ldap_entry;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Enumerate RIDs of groups which user is a member of, of type
|
||||
given by attribute.
|
||||
****************************************************************/
|
||||
|
||||
static void ldappassgrp_member(char *attribute, uint32 **rids, int *numrids)
|
||||
{
|
||||
char **values;
|
||||
uint32 *ridlist;
|
||||
int i;
|
||||
|
||||
if((values = ldap_get_values(ldap_struct, ldap_entry, attribute))) {
|
||||
*numrids = i = ldap_count_values(values);
|
||||
*rids = ridlist = malloc(i * sizeof(uint32));
|
||||
do {
|
||||
ridlist[--i] = atoi(values[i]);
|
||||
} while(i > 0);
|
||||
ldap_value_free(values);
|
||||
} else {
|
||||
*numrids = 0;
|
||||
*rids = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Begin/end smbgrp enumeration.
|
||||
****************************************************************/
|
||||
|
||||
static void *ldappassgrp_enumfirst(BOOL update)
|
||||
{
|
||||
if (!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_for("&(objectclass=sambaAccount)(|(group=*)(alias=*))");
|
||||
|
||||
return ldap_struct;
|
||||
}
|
||||
|
||||
static void ldappassgrp_enumclose(void *vp)
|
||||
{
|
||||
ldap_disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Save/restore the current position in a query
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT ldappassgrp_getdbpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)((ulong)ldap_entry);
|
||||
}
|
||||
|
||||
static BOOL ldappassgrp_setdbpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
ldap_entry = (LDAPMessage *)((ulong)tok);
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return limited smb_passwd information, and group membership.
|
||||
*************************************************************************/
|
||||
|
||||
static struct smb_passwd *ldappassgrp_getpwbynam(const char *name,
|
||||
uint32 **grp_rids, int *num_grps,
|
||||
uint32 **als_rids, int *num_alss)
|
||||
{
|
||||
struct smb_passwd *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_ntname(name);
|
||||
ldappassgrp_member("group", grp_rids, num_grps);
|
||||
ldappassgrp_member("alias", als_rids, num_alss);
|
||||
ret = ldap_getpw();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct smb_passwd *ldappassgrp_getpwbyuid(uid_t userid,
|
||||
uint32 **grp_rids, int *num_grps,
|
||||
uint32 **als_rids, int *num_alss)
|
||||
{
|
||||
struct smb_passwd *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_uid(userid);
|
||||
ldappassgrp_member("group", grp_rids, num_grps);
|
||||
ldappassgrp_member("alias", als_rids, num_alss);
|
||||
ret = ldap_getpw();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct smb_passwd *ldappassgrp_getpwbyrid(uint32 user_rid,
|
||||
uint32 **grp_rids, int *num_grps,
|
||||
uint32 **als_rids, int *num_alss)
|
||||
{
|
||||
struct smb_passwd *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_rid(user_rid);
|
||||
ldappassgrp_member("group", grp_rids, num_grps);
|
||||
ldappassgrp_member("alias", als_rids, num_alss);
|
||||
ret = ldap_getpw();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct smb_passwd *ldappassgrp_getcurrentpw(void *vp,
|
||||
uint32 **grp_rids, int *num_grps,
|
||||
uint32 **als_rids, int *num_alss)
|
||||
{
|
||||
ldappassgrp_member("group", grp_rids, num_grps);
|
||||
ldappassgrp_member("alias", als_rids, num_alss);
|
||||
return ldap_getpw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct passgrp_ops ldappassgrp_ops =
|
||||
{
|
||||
ldappassgrp_enumfirst,
|
||||
ldappassgrp_enumclose,
|
||||
ldappassgrp_getdbpos,
|
||||
ldappassgrp_setdbpos,
|
||||
|
||||
ldappassgrp_getpwbynam,
|
||||
ldappassgrp_getpwbyuid,
|
||||
ldappassgrp_getpwbyrid,
|
||||
ldappassgrp_getcurrentpw,
|
||||
};
|
||||
|
||||
struct passgrp_ops *ldap_initialise_password_grp(void)
|
||||
{
|
||||
return &ldappassgrp_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void passgrpldap_dummy_function(void);
|
||||
void passgrpldap_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif
|
||||
|
@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef USE_SMBPASS_DB
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern pstring samlogon_user;
|
||||
extern BOOL sam_logon_in_ssb;
|
||||
|
||||
extern DOM_SID global_sam_sid;
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the smbpasswd list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
****************************************************************/
|
||||
|
||||
static void *startsamfilepwent(BOOL update)
|
||||
{
|
||||
return startsmbpwent(update);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the smbpasswd list.
|
||||
****************************************************************/
|
||||
|
||||
static void endsamfilepwent(void *vp)
|
||||
{
|
||||
endsmbpwent(vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Return the current position in the smbpasswd list as an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT getsamfilepwpos(void *vp)
|
||||
{
|
||||
return getsmbpwpos(vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Set the current position in the smbpasswd list from an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL setsamfilepwpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
return setsmbpwpos(vp, tok);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the smbpasswd list.
|
||||
this function is a nice, messy combination of reading:
|
||||
- the smbpasswd file
|
||||
- the unix password database
|
||||
- smb.conf options (not done at present).
|
||||
*************************************************************************/
|
||||
|
||||
static struct sam_passwd *getsamfile21pwent(void *vp)
|
||||
{
|
||||
struct sam_passwd *user;
|
||||
|
||||
static pstring full_name;
|
||||
static pstring home_dir;
|
||||
static pstring home_drive;
|
||||
static pstring logon_script;
|
||||
static pstring profile_path;
|
||||
static pstring acct_desc;
|
||||
static pstring workstations;
|
||||
|
||||
DEBUG(5,("getsamfile21pwent\n"));
|
||||
|
||||
user = pwdb_smb_to_sam(getsmbfilepwent(vp));
|
||||
if (user == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* get all the other gubbins we need. substitute unix name for %U
|
||||
* as putting the nt name in is a bit meaningless.
|
||||
*/
|
||||
|
||||
pstrcpy(samlogon_user, user->unix_name);
|
||||
|
||||
if (samlogon_user[strlen(samlogon_user)-1] == '$' &&
|
||||
user->group_rid != DOMAIN_GROUP_RID_USERS)
|
||||
{
|
||||
DEBUG(0,("trust account %s should be in DOMAIN_GROUP_RID_USERS\n",
|
||||
samlogon_user));
|
||||
}
|
||||
|
||||
/* XXXX hack to get standard_sub_basic() to use sam logon username */
|
||||
/* possibly a better way would be to do a become_user() call */
|
||||
sam_logon_in_ssb = True;
|
||||
|
||||
pstrcpy(full_name , "");
|
||||
pstrcpy(logon_script , lp_logon_script ());
|
||||
pstrcpy(profile_path , lp_logon_path ());
|
||||
pstrcpy(home_drive , lp_logon_drive ());
|
||||
pstrcpy(home_dir , lp_logon_home ());
|
||||
pstrcpy(acct_desc , "");
|
||||
pstrcpy(workstations , "");
|
||||
|
||||
sam_logon_in_ssb = False;
|
||||
|
||||
/*
|
||||
only overwrite values with defaults IIF specific backend
|
||||
didn't filled the values
|
||||
*/
|
||||
|
||||
if (user->full_name == NULL)
|
||||
user->full_name = full_name;
|
||||
if (user->home_dir == NULL)
|
||||
user->home_dir = home_dir;
|
||||
if (user->dir_drive == NULL)
|
||||
user->dir_drive = home_drive;
|
||||
if (user->logon_script == NULL)
|
||||
user->logon_script = logon_script;
|
||||
if (user->profile_path == NULL)
|
||||
user->profile_path = profile_path;
|
||||
if (user->acct_desc == NULL)
|
||||
user->acct_desc = acct_desc;
|
||||
if (user->workstations == NULL)
|
||||
user->workstations = workstations;
|
||||
|
||||
user->unknown_str = NULL; /* don't know, yet! */
|
||||
user->munged_dial = NULL; /* "munged" dial-back telephone number */
|
||||
|
||||
user->unknown_3 = 0xffffff; /* don't know */
|
||||
user->logon_divs = 168; /* hours per week */
|
||||
user->hours_len = 21; /* 21 times 8 bits = 168 */
|
||||
memset(user->hours, 0xff, user->hours_len); /* available at all hours */
|
||||
user->unknown_5 = 0x00020000; /* don't know */
|
||||
user->unknown_6 = 0x000004ec; /* don't know */
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
search sam db by uid.
|
||||
*************************************************************************/
|
||||
static struct sam_passwd *getsamfilepwuid(uid_t uid)
|
||||
{
|
||||
struct sam_passwd *pwd = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search by uid: %x\n", (int)uid));
|
||||
|
||||
/* Open the smb password file - not for update. */
|
||||
fp = startsam21pwent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open sam password database.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((pwd = getsamfile21pwent(fp)) != NULL && pwd->unix_uid != uid)
|
||||
{
|
||||
}
|
||||
|
||||
if (pwd != NULL)
|
||||
{
|
||||
DEBUG(10, ("found by unix_uid: %x\n", (int)uid));
|
||||
}
|
||||
|
||||
endsam21pwent(fp);
|
||||
|
||||
return pwd;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
search sam db by rid.
|
||||
*************************************************************************/
|
||||
static struct sam_passwd *getsamfilepwrid(uint32 user_rid)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
DOM_SID sid;
|
||||
sid_copy(&sid, &global_sam_sid);
|
||||
sid_append_rid(&sid, user_rid);
|
||||
|
||||
if (!lookupsmbpwsid(&sid, &gmep))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return getsamfilepwuid((uid_t)gmep.unix_id);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
search sam db by nt name.
|
||||
*************************************************************************/
|
||||
static struct sam_passwd *getsamfilepwntnam(const char *nt_name)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
|
||||
if (!lookupsmbpwntnam(nt_name, &gmep))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return getsamfilepwuid((uid_t)gmep.unix_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Stub functions - implemented in terms of others.
|
||||
*/
|
||||
|
||||
static BOOL mod_samfile21pwd_entry(struct sam_passwd* pwd, BOOL override)
|
||||
{
|
||||
return mod_smbpwd_entry(pwdb_sam_to_smb(pwd), override);
|
||||
}
|
||||
|
||||
static BOOL add_samfile21pwd_entry(struct sam_passwd *newpwd)
|
||||
{
|
||||
return add_smbpwd_entry(pwdb_sam_to_smb(newpwd));
|
||||
}
|
||||
|
||||
static struct sam_disp_info *getsamfiledispntnam(const char *ntname)
|
||||
{
|
||||
return pwdb_sam_to_dispinfo(getsam21pwntnam(ntname));
|
||||
}
|
||||
|
||||
static struct sam_disp_info *getsamfiledisprid(uint32 rid)
|
||||
{
|
||||
return pwdb_sam_to_dispinfo(getsam21pwrid(rid));
|
||||
}
|
||||
|
||||
static struct sam_disp_info *getsamfiledispent(void *vp)
|
||||
{
|
||||
return pwdb_sam_to_dispinfo(getsam21pwent(vp));
|
||||
}
|
||||
|
||||
static struct sam_passdb_ops sam_file_ops =
|
||||
{
|
||||
startsamfilepwent,
|
||||
endsamfilepwent,
|
||||
getsamfilepwpos,
|
||||
setsamfilepwpos,
|
||||
getsamfilepwntnam,
|
||||
getsamfilepwuid,
|
||||
getsamfilepwrid,
|
||||
getsamfile21pwent,
|
||||
add_samfile21pwd_entry,
|
||||
mod_samfile21pwd_entry,
|
||||
getsamfiledispntnam,
|
||||
getsamfiledisprid,
|
||||
getsamfiledispent
|
||||
};
|
||||
|
||||
struct sam_passdb_ops *file_initialise_sam_password_db(void)
|
||||
{
|
||||
return &sam_file_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
|
||||
void sampass_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif /* USE_SMBPASS_DB */
|
@ -1,793 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
Password and authentication handling
|
||||
Copyright (C) Jeremy Allison 1996-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"
|
||||
#include "nterr.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern DOM_SID global_sam_sid;
|
||||
|
||||
/*
|
||||
* NOTE. All these functions are abstracted into a structure
|
||||
* that points to the correct function for the selected database. JRA.
|
||||
*
|
||||
* NOTE. for the get/mod/add functions, there are two sets of functions.
|
||||
* one supports struct sam_passwd, the other supports struct smb_passwd.
|
||||
* for speed optimisation it is best to support both these sets.
|
||||
*
|
||||
* it is, however, optional to support one set but not the other: there
|
||||
* is conversion-capability built in to passdb.c, and run-time error
|
||||
* detection for when neither are supported.
|
||||
*
|
||||
* password database writers are recommended to implement the sam_passwd
|
||||
* functions in a first pass, as struct sam_passwd contains more
|
||||
* information, needed by the NT Domain support.
|
||||
*
|
||||
* an API writer is expected to create either one set (struct smb_passwd) or
|
||||
* the other (struct sam_passwd) OR both, and optionally also to write display
|
||||
* info routines * (struct sam_disp_info). functions which the API writer
|
||||
* chooses NOT to write must be wrapped in conversion functions (pwdb_x_to_y)
|
||||
* such that API users can call any function and still get valid results.
|
||||
*
|
||||
* the password API does NOT fill in the gaps if you set an API function
|
||||
* to NULL: it will deliberately attempt to call the NULL function.
|
||||
*
|
||||
*/
|
||||
|
||||
static struct sam_passdb_ops *pwdb_ops;
|
||||
|
||||
/***************************************************************
|
||||
Initialise the password db operations.
|
||||
***************************************************************/
|
||||
|
||||
BOOL initialise_sam_password_db(void)
|
||||
{
|
||||
if (pwdb_ops)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
#ifdef WITH_NISPLUS
|
||||
pwdb_ops = nisplus_initialise_sam_password_db();
|
||||
#elif defined(WITH_LDAP)
|
||||
pwdb_ops = ldap_initialise_sam_password_db();
|
||||
#elif defined(HAVE_MYSQL_H) && defined(WITH_MYSQLSAM)
|
||||
pwdb_ops = mysql_initialise_sam_password_db();
|
||||
#elif defined(USE_SMBPASS_DB)
|
||||
pwdb_ops = file_initialise_sam_password_db();
|
||||
#endif
|
||||
|
||||
return (pwdb_ops != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions that return/manipulate a struct sam_passwd.
|
||||
*/
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the smb or sam passwd list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
|
||||
Note that currently it is being assumed that a pointer returned
|
||||
from this function may be used to enumerate struct sam_passwd
|
||||
entries as well as struct smb_passwd entries. This may need
|
||||
to change. JRA.
|
||||
|
||||
****************************************************************/
|
||||
|
||||
void *startsam21pwent(BOOL update)
|
||||
{
|
||||
return pwdb_ops->startsam21pwent(update);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the sam passwd list.
|
||||
|
||||
Note that currently it is being assumed that a pointer returned
|
||||
from this function may be used to enumerate struct sam_passwd
|
||||
entries as well as struct smb_passwd entries. This may need
|
||||
to change. JRA.
|
||||
|
||||
****************************************************************/
|
||||
|
||||
void endsam21pwent(void *vp)
|
||||
{
|
||||
pwdb_ops->endsam21pwent(vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the smb passwd list.
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_passwd *getsam21pwent(void *vp)
|
||||
{
|
||||
return pwdb_sam_map_names(pwdb_ops->getsam21pwent(vp));
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search the smb 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_sam21pwd_entry(struct sam_passwd* pwd, BOOL override)
|
||||
{
|
||||
struct sam_passwd *mapped;
|
||||
|
||||
DEBUG(10,("mod_sam21pwd_entry: unix user %s rid %d\n",
|
||||
pwd->unix_name, pwd->user_rid));
|
||||
|
||||
mapped = pwdb_sam_map_names(pwd);
|
||||
if (mapped != NULL)
|
||||
{
|
||||
return pwdb_ops->mod_sam21pwd_entry(mapped, override);
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Utility function to search sam passwd by name. use this if your database
|
||||
does not have search facilities.
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_passwd *iterate_getsam21pwntnam(const char *ntname)
|
||||
{
|
||||
fstring nt_name;
|
||||
struct sam_passwd *pwd = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search by name: %s\n", ntname));
|
||||
|
||||
fstrcpy(nt_name, ntname);
|
||||
|
||||
/* Open the smb password database - not for update. */
|
||||
fp = startsmbpwent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open sam password database.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((pwd = getsam21pwent(fp)) != NULL && !strequal(pwd->nt_name, nt_name))
|
||||
{
|
||||
DEBUG(10, ("iterate: %s 0x%x\n", pwd->nt_name, pwd->user_rid));
|
||||
}
|
||||
|
||||
if (pwd != NULL)
|
||||
{
|
||||
DEBUG(10, ("found by name: %s\n", nt_name));
|
||||
}
|
||||
|
||||
endsmbpwent(fp);
|
||||
return pwd;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Utility function to search sam passwd by rid. use this if your database
|
||||
does not have search facilities.
|
||||
|
||||
search capability by both rid and uid are needed as the rid <-> uid
|
||||
mapping may be non-monotonic.
|
||||
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_passwd *iterate_getsam21pwrid(uint32 rid)
|
||||
{
|
||||
struct sam_passwd *pwd = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search by rid: %x\n", rid));
|
||||
|
||||
/* Open the smb password file - not for update. */
|
||||
fp = startsmbpwent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open sam password database.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((pwd = getsam21pwent(fp)) != NULL && pwd->user_rid != rid)
|
||||
{
|
||||
DEBUG(10, ("iterate: %s 0x%x\n", pwd->nt_name, pwd->user_rid));
|
||||
}
|
||||
|
||||
if (pwd != NULL)
|
||||
{
|
||||
DEBUG(10, ("found by user_rid: %x\n", rid));
|
||||
}
|
||||
|
||||
endsmbpwent(fp);
|
||||
return pwd;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Utility function to search sam passwd by uid. use this if your database
|
||||
does not have search facilities.
|
||||
|
||||
search capability by both rid and uid are needed as the rid <-> uid
|
||||
mapping may be non-monotonic.
|
||||
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_passwd *iterate_getsam21pwuid(uid_t uid)
|
||||
{
|
||||
struct sam_passwd *pwd = NULL;
|
||||
void *fp = NULL;
|
||||
|
||||
DEBUG(10, ("search by uid: %x\n", (int)uid));
|
||||
|
||||
/* Open the smb password file - not for update. */
|
||||
fp = startsmbpwent(False);
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
DEBUG(0, ("unable to open sam password database.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((pwd = getsam21pwent(fp)) != NULL && pwd->unix_uid != uid)
|
||||
{
|
||||
}
|
||||
|
||||
if (pwd != NULL)
|
||||
{
|
||||
DEBUG(10, ("found by unix_uid: %x\n", (int)uid));
|
||||
}
|
||||
|
||||
endsmbpwent(fp);
|
||||
return pwd;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return a display info structure, by rid
|
||||
*************************************************************************/
|
||||
struct sam_disp_info *getsamdisprid(uint32 rid)
|
||||
{
|
||||
return pwdb_ops->getsamdisprid(rid);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search sam passwd by name.
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_passwd *getsam21pwntnam(const char *name)
|
||||
{
|
||||
return pwdb_sam_map_names(pwdb_ops->getsam21pwntnam(name));
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Routine to search sam passwd by rid.
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_passwd *getsam21pwrid(uint32 rid)
|
||||
{
|
||||
return pwdb_sam_map_names(pwdb_ops->getsam21pwrid(rid));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************
|
||||
**********************************************************
|
||||
|
||||
utility routines which are likely to be useful to all password
|
||||
databases
|
||||
|
||||
**********************************************************
|
||||
**********************************************************/
|
||||
|
||||
/*************************************************************
|
||||
initialises a struct sam_disp_info.
|
||||
**************************************************************/
|
||||
|
||||
static void pwdb_init_dispinfo(struct sam_disp_info *user)
|
||||
{
|
||||
if (user == NULL) return;
|
||||
bzero(user, sizeof(*user));
|
||||
user->user_rid = 0xffffffff;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
initialises a struct sam_passwd.
|
||||
**************************************************************/
|
||||
void pwdb_init_sam(struct sam_passwd *user)
|
||||
{
|
||||
if (user == NULL) return;
|
||||
bzero(user, sizeof(*user));
|
||||
|
||||
init_nt_time(&user->logon_time);
|
||||
init_nt_time(&user->logoff_time);
|
||||
init_nt_time(&user->kickoff_time);
|
||||
init_nt_time(&user->pass_last_set_time);
|
||||
init_nt_time(&user->pass_can_change_time);
|
||||
init_nt_time(&user->pass_must_change_time);
|
||||
|
||||
user->unix_uid = (uid_t)-1;
|
||||
user->unix_gid = (gid_t)-1;
|
||||
user->user_rid = 0xffffffff;
|
||||
user->group_rid = 0xffffffff;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next entry in the sam passwd list.
|
||||
*************************************************************************/
|
||||
|
||||
struct sam_disp_info *pwdb_sam_to_dispinfo(struct sam_passwd *user)
|
||||
{
|
||||
static struct sam_disp_info disp_info;
|
||||
|
||||
if (user == NULL) return NULL;
|
||||
|
||||
pwdb_init_dispinfo(&disp_info);
|
||||
|
||||
disp_info.nt_name = user->nt_name;
|
||||
disp_info.full_name = user->full_name;
|
||||
disp_info.user_rid = user->user_rid;
|
||||
|
||||
return &disp_info;
|
||||
}
|
||||
|
||||
static void select_name(fstring *string, char **name, const UNISTR2 *from)
|
||||
{
|
||||
if (from->buffer != 0)
|
||||
{
|
||||
unistr2_to_ascii(*string, from, sizeof(*string));
|
||||
*name = *string;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
copies a sam passwd.
|
||||
**************************************************************/
|
||||
void copy_id23_to_sam_passwd(struct sam_passwd *to, const SAM_USER_INFO_23 *from)
|
||||
{
|
||||
static fstring nt_name;
|
||||
static fstring full_name;
|
||||
static fstring home_dir;
|
||||
static fstring dir_drive;
|
||||
static fstring logon_script;
|
||||
static fstring profile_path;
|
||||
static fstring acct_desc;
|
||||
static fstring workstations;
|
||||
static fstring unknown_str;
|
||||
static fstring munged_dial;
|
||||
|
||||
if (from == NULL || to == NULL) return;
|
||||
|
||||
to->logon_time = from->logon_time;
|
||||
to->logoff_time = from->logoff_time;
|
||||
to->kickoff_time = from->kickoff_time;
|
||||
to->pass_last_set_time = from->pass_last_set_time;
|
||||
to->pass_can_change_time = from->pass_can_change_time;
|
||||
to->pass_must_change_time = from->pass_must_change_time;
|
||||
|
||||
select_name(&nt_name , &to->nt_name , &from->uni_user_name );
|
||||
select_name(&full_name , &to->full_name , &from->uni_full_name );
|
||||
select_name(&home_dir , &to->home_dir , &from->uni_home_dir );
|
||||
select_name(&dir_drive , &to->dir_drive , &from->uni_dir_drive );
|
||||
select_name(&logon_script, &to->logon_script, &from->uni_logon_script);
|
||||
select_name(&profile_path, &to->profile_path, &from->uni_profile_path);
|
||||
select_name(&acct_desc , &to->acct_desc , &from->uni_acct_desc );
|
||||
select_name(&workstations, &to->workstations, &from->uni_workstations);
|
||||
select_name(&unknown_str , &to->unknown_str , &from->uni_unknown_str );
|
||||
select_name(&munged_dial , &to->munged_dial , &from->uni_munged_dial );
|
||||
|
||||
to->unix_uid = (uid_t)-1;
|
||||
to->unix_gid = (gid_t)-1;
|
||||
to->user_rid = from->user_rid;
|
||||
to->group_rid = from->group_rid;
|
||||
|
||||
to->smb_passwd = NULL;
|
||||
to->smb_nt_passwd = NULL;
|
||||
|
||||
to->acct_ctrl = from->acb_info;
|
||||
to->unknown_3 = from->unknown_3;
|
||||
|
||||
to->logon_divs = from->logon_divs;
|
||||
to->hours_len = from->logon_hrs.len;
|
||||
memcpy(to->hours, from->logon_hrs.hours, MAX_HOURS_LEN);
|
||||
|
||||
to->unknown_5 = from->unknown_5;
|
||||
to->unknown_6 = from->unknown_6;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
copies a sam passwd.
|
||||
**************************************************************/
|
||||
void copy_sam_passwd(struct sam_passwd *to, const struct sam_passwd *from)
|
||||
{
|
||||
static fstring nt_name;
|
||||
static fstring unix_name;
|
||||
static fstring full_name;
|
||||
static fstring home_dir;
|
||||
static fstring dir_drive;
|
||||
static fstring logon_script;
|
||||
static fstring profile_path;
|
||||
static fstring acct_desc;
|
||||
static fstring workstations;
|
||||
static fstring unknown_str;
|
||||
static fstring munged_dial;
|
||||
|
||||
if (from == NULL || to == NULL) return;
|
||||
|
||||
memcpy(to, from, sizeof(*from));
|
||||
|
||||
if (from->nt_name != NULL)
|
||||
{
|
||||
fstrcpy(nt_name , from->nt_name);
|
||||
to->nt_name = nt_name;
|
||||
}
|
||||
else if (to->nt_name != NULL)
|
||||
{
|
||||
fstrcpy(nt_name , to->nt_name);
|
||||
to->nt_name = nt_name;
|
||||
}
|
||||
|
||||
if (from->unix_name != NULL)
|
||||
{
|
||||
fstrcpy(unix_name, from->unix_name);
|
||||
to->unix_name = unix_name;
|
||||
}
|
||||
else if (to->unix_name != NULL)
|
||||
{
|
||||
fstrcpy(unix_name, to->unix_name);
|
||||
to->unix_name = unix_name;
|
||||
}
|
||||
|
||||
if (from->full_name != NULL)
|
||||
{
|
||||
fstrcpy(full_name, from->full_name);
|
||||
to->full_name = full_name;
|
||||
}
|
||||
else if (to->full_name != NULL)
|
||||
{
|
||||
fstrcpy(full_name, to->full_name);
|
||||
to->full_name = full_name;
|
||||
}
|
||||
|
||||
if (from->home_dir != NULL)
|
||||
{
|
||||
fstrcpy(home_dir , from->home_dir);
|
||||
to->home_dir = home_dir;
|
||||
}
|
||||
else if (to->home_dir != NULL)
|
||||
{
|
||||
fstrcpy(home_dir , to->home_dir);
|
||||
to->home_dir = home_dir;
|
||||
}
|
||||
|
||||
if (from->dir_drive != NULL)
|
||||
{
|
||||
fstrcpy(dir_drive , from->dir_drive);
|
||||
to->dir_drive = dir_drive;
|
||||
}
|
||||
else if (to->dir_drive != NULL)
|
||||
{
|
||||
fstrcpy(dir_drive , to->dir_drive);
|
||||
to->dir_drive = dir_drive;
|
||||
}
|
||||
|
||||
if (from->logon_script != NULL)
|
||||
{
|
||||
fstrcpy(logon_script , from->logon_script);
|
||||
to->logon_script = logon_script;
|
||||
}
|
||||
else if (to->logon_script != NULL)
|
||||
{
|
||||
fstrcpy(logon_script , to->logon_script);
|
||||
to->logon_script = logon_script;
|
||||
}
|
||||
|
||||
if (from->profile_path != NULL)
|
||||
{
|
||||
fstrcpy(profile_path , from->profile_path);
|
||||
to->profile_path = profile_path;
|
||||
}
|
||||
else if (to->profile_path != NULL)
|
||||
{
|
||||
fstrcpy(profile_path , to->profile_path);
|
||||
to->profile_path = profile_path;
|
||||
}
|
||||
|
||||
if (from->acct_desc != NULL)
|
||||
{
|
||||
fstrcpy(acct_desc , from->acct_desc);
|
||||
to->acct_desc = acct_desc;
|
||||
}
|
||||
else if (to->acct_desc != NULL)
|
||||
{
|
||||
fstrcpy(acct_desc , to->acct_desc);
|
||||
to->acct_desc = acct_desc;
|
||||
}
|
||||
|
||||
if (from->workstations != NULL)
|
||||
{
|
||||
fstrcpy(workstations , from->workstations);
|
||||
to->workstations = workstations;
|
||||
}
|
||||
else if (to->workstations != NULL)
|
||||
{
|
||||
fstrcpy(workstations , to->workstations);
|
||||
to->workstations = workstations;
|
||||
}
|
||||
|
||||
if (from->unknown_str != NULL)
|
||||
{
|
||||
fstrcpy(unknown_str , from->unknown_str);
|
||||
to->unknown_str = unknown_str;
|
||||
}
|
||||
else if (to->unknown_str != NULL)
|
||||
{
|
||||
fstrcpy(unknown_str , to->unknown_str);
|
||||
to->unknown_str = unknown_str;
|
||||
}
|
||||
|
||||
if (from->munged_dial != NULL)
|
||||
{
|
||||
fstrcpy(munged_dial , from->munged_dial);
|
||||
to->munged_dial = munged_dial;
|
||||
}
|
||||
else if (to->munged_dial != NULL)
|
||||
{
|
||||
fstrcpy(munged_dial , to->munged_dial);
|
||||
to->munged_dial = munged_dial;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
converts a sam_passwd structure to a smb_passwd structure.
|
||||
**************************************************************/
|
||||
struct smb_passwd *pwdb_sam_to_smb(struct sam_passwd *user)
|
||||
{
|
||||
static struct smb_passwd pw_buf;
|
||||
static fstring nt_name;
|
||||
static fstring unix_name;
|
||||
|
||||
if (user == NULL) return NULL;
|
||||
|
||||
pwdb_init_smb(&pw_buf);
|
||||
|
||||
if (user->nt_name != NULL)
|
||||
{
|
||||
fstrcpy(nt_name , user->nt_name);
|
||||
pw_buf.nt_name = nt_name;
|
||||
}
|
||||
if (user->unix_name != NULL)
|
||||
{
|
||||
fstrcpy(unix_name, user->unix_name);
|
||||
pw_buf.unix_name = unix_name;
|
||||
}
|
||||
pw_buf.unix_uid = user->unix_uid;
|
||||
pw_buf.user_rid = user->user_rid;
|
||||
pw_buf.smb_passwd = user->smb_passwd;
|
||||
pw_buf.smb_nt_passwd = user->smb_nt_passwd;
|
||||
pw_buf.acct_ctrl = user->acct_ctrl;
|
||||
pw_buf.pass_last_set_time = nt_time_to_unix(&user->pass_last_set_time);
|
||||
|
||||
return &pw_buf;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
converts a smb_passwd structure to a sam_passwd structure.
|
||||
**************************************************************/
|
||||
|
||||
struct sam_passwd *pwdb_smb_to_sam(struct smb_passwd *user)
|
||||
{
|
||||
static struct sam_passwd pw_buf;
|
||||
struct passwd *pass=NULL;
|
||||
static fstring nt_name;
|
||||
static fstring unix_name;
|
||||
static pstring unix_gecos;
|
||||
|
||||
if (user == NULL) return NULL;
|
||||
|
||||
pwdb_init_sam(&pw_buf);
|
||||
|
||||
if (user->nt_name != NULL)
|
||||
{
|
||||
fstrcpy(nt_name , user->nt_name);
|
||||
pw_buf.nt_name = nt_name;
|
||||
}
|
||||
if (user->unix_name != NULL)
|
||||
{
|
||||
fstrcpy(unix_name, user->unix_name);
|
||||
pw_buf.unix_name = unix_name;
|
||||
}
|
||||
pw_buf.unix_uid = user->unix_uid;
|
||||
pw_buf.user_rid = user->user_rid;
|
||||
pw_buf.smb_passwd = user->smb_passwd;
|
||||
pw_buf.smb_nt_passwd = user->smb_nt_passwd;
|
||||
pw_buf.acct_ctrl = user->acct_ctrl;
|
||||
|
||||
pass = hashed_getpwnam(unix_name);
|
||||
if (pass != NULL)
|
||||
{
|
||||
pstrcpy(unix_gecos, pass->pw_gecos);
|
||||
pw_buf.full_name=unix_gecos;
|
||||
}
|
||||
|
||||
if ( user->pass_last_set_time != (time_t)-1 )
|
||||
{
|
||||
unix_to_nt_time(&pw_buf.pass_last_set_time, user->pass_last_set_time);
|
||||
unix_to_nt_time(&pw_buf.pass_can_change_time, user->pass_last_set_time);
|
||||
}
|
||||
|
||||
return &pw_buf;
|
||||
}
|
||||
|
||||
static BOOL trust_account_warning_done = False;
|
||||
|
||||
/*************************************************************
|
||||
fills in missing details. one set of details _must_ exist.
|
||||
**************************************************************/
|
||||
struct sam_passwd *pwdb_sam_map_names(struct sam_passwd *sam)
|
||||
{
|
||||
DOM_NAME_MAP gmep;
|
||||
BOOL found = False;
|
||||
DOM_SID sid;
|
||||
static fstring unix_name;
|
||||
static fstring nt_name;
|
||||
|
||||
/*
|
||||
* name details
|
||||
*/
|
||||
|
||||
if (sam == NULL)
|
||||
{
|
||||
DEBUG(10,("pwdb_sam_map_names: NULL\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG(10,("pwdb_sam_map_names: unix %s nt %s unix %d nt%d\n",
|
||||
sam->unix_name != NULL ? sam->unix_name : "NULL",
|
||||
sam->nt_name != NULL ? sam->nt_name : "NULL",
|
||||
sam->unix_uid, sam->user_rid));
|
||||
|
||||
if (!found && sam->unix_name != NULL)
|
||||
{
|
||||
found = lookupsmbpwnam(sam->unix_name, &gmep);
|
||||
}
|
||||
if (!found && sam->unix_uid != (uid_t)-1)
|
||||
{
|
||||
found = lookupsmbpwuid(sam->unix_uid , &gmep);
|
||||
}
|
||||
if (!found && sam->user_rid != 0xffffffff)
|
||||
{
|
||||
sid_copy(&sid, &global_sam_sid);
|
||||
sid_append_rid(&sid, sam->user_rid);
|
||||
found = lookupsmbpwsid (&sid , &gmep);
|
||||
}
|
||||
if (!found && sam->nt_name != NULL)
|
||||
{
|
||||
found = lookupsmbpwntnam(sam->nt_name, &gmep);
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!sid_front_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fstrcpy(unix_name, gmep.unix_name);
|
||||
fstrcpy(nt_name , gmep.nt_name );
|
||||
if (sam->unix_name == NULL ) sam->unix_name = unix_name;
|
||||
if (sam->nt_name == NULL ) sam->nt_name = nt_name ;
|
||||
if (sam->unix_uid == (uid_t)-1 ) sam->unix_uid = (uid_t)gmep.unix_id;
|
||||
if (sam->user_rid == 0xffffffff) sid_split_rid(&gmep.sid, &sam->user_rid);
|
||||
|
||||
DEBUG(10,("pwdb_sam_map_name: found unix user %s nt %s uid %d rid 0x%x\n",
|
||||
sam->unix_name, sam->nt_name, sam->unix_uid, sam->user_rid));
|
||||
|
||||
/*
|
||||
* group details
|
||||
*/
|
||||
|
||||
found = False;
|
||||
|
||||
if (sam->unix_gid != (gid_t)-1 && sam->group_rid != 0xffffffff)
|
||||
{
|
||||
return sam;
|
||||
}
|
||||
|
||||
if (sam->unix_gid == (gid_t)-1 && sam->group_rid == 0xffffffff)
|
||||
{
|
||||
struct passwd *pass = hashed_getpwnam(unix_name);
|
||||
if (pass != NULL)
|
||||
{
|
||||
sam->unix_gid = pass->pw_gid;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(0,("pwdb_sam_map_names: no unix password entry for %s\n",
|
||||
unix_name));
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && sam->unix_gid != (gid_t)-1)
|
||||
{
|
||||
found = lookupsmbgrpgid(sam->unix_gid , &gmep);
|
||||
}
|
||||
if (!found && sam->group_rid != 0xffffffff)
|
||||
{
|
||||
sid_copy(&sid, &global_sam_sid);
|
||||
sid_append_rid(&sid, sam->group_rid);
|
||||
found = lookupsmbgrpsid(&sid , &gmep);
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
if (IS_BITS_SET_SOME(sam->acct_ctrl, ACB_WSTRUST|ACB_DOMTRUST|ACB_SVRTRUST))
|
||||
{
|
||||
if (!trust_account_warning_done)
|
||||
{
|
||||
trust_account_warning_done = True;
|
||||
DEBUG(0, ("\
|
||||
pwdb_sam_map_names: your unix password database appears to have difficulties\n\
|
||||
resolving trust account %s, probably because it ends in a '$'.\n\
|
||||
you will get this warning only once (for all trust accounts)\n", unix_name));
|
||||
}
|
||||
/*
|
||||
* oh, dear.
|
||||
*/
|
||||
if (sam->unix_gid != (gid_t)-1)
|
||||
{
|
||||
sam->unix_gid = (gid_t)-1;
|
||||
}
|
||||
sam->group_rid = DOMAIN_GROUP_RID_USERS;
|
||||
|
||||
return sam;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG(0, ("pwdb_sam_map_names: could not find Primary Group for %s\n",
|
||||
unix_name));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sid_front_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
fstring sid_str;
|
||||
sid_to_string(sid_str, &gmep.sid);
|
||||
DEBUG(0,("UNIX User %s Primary Group is in the wrong domain! %s\n",
|
||||
sam->unix_name, sid_str));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sam->unix_gid == (gid_t)-1 ) sam->unix_gid = (gid_t)gmep.unix_id;
|
||||
if (sam->group_rid == 0xffffffff) sid_split_rid(&gmep.sid, &sam->group_rid);
|
||||
|
||||
DEBUG(10,("pwdb_sam_map_name: found gid %d and group rid 0x%x for unix user %s\n",
|
||||
sam->unix_gid, sam->group_rid, sam->unix_name));
|
||||
|
||||
return sam;
|
||||
}
|
@ -1,422 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.0.
|
||||
LDAP protocol helper functions for SAMBA
|
||||
Copyright (C) Matthew Chapman 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"
|
||||
|
||||
#ifdef WITH_LDAP
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/* Internal state */
|
||||
extern LDAP *ldap_struct;
|
||||
extern LDAPMessage *ldap_results;
|
||||
extern LDAPMessage *ldap_entry;
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
NT name/RID search functions.
|
||||
******************************************************************/
|
||||
|
||||
BOOL ldap_search_by_rid(uint32 rid)
|
||||
{
|
||||
fstring filter;
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(rid=%x)(objectclass=sambaAccount))", rid);
|
||||
return ldap_search_for(filter);
|
||||
}
|
||||
|
||||
BOOL ldap_search_by_ntname(const char *ntname)
|
||||
{
|
||||
fstring filter;
|
||||
|
||||
slprintf(filter, sizeof(filter)-1,
|
||||
"(&(ntuid=%s)(objectclass=sambaAccount))", ntname);
|
||||
return ldap_search_for(filter);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Store NTTIMEs as time_t's.
|
||||
******************************************************************/
|
||||
|
||||
static void ldap_save_time(LDAPMod ***modlist, int modop, char *attribute,
|
||||
NTTIME *nttime)
|
||||
{
|
||||
fstring tstr;
|
||||
time_t t;
|
||||
|
||||
t = nt_time_to_unix(nttime);
|
||||
|
||||
if(t == -1)
|
||||
return;
|
||||
|
||||
slprintf(tstr, sizeof(tstr)-1, "%08X", t);
|
||||
ldap_make_mod(modlist, modop, attribute, tstr);
|
||||
}
|
||||
|
||||
static void ldap_read_time(char *attribute, NTTIME *nttime)
|
||||
{
|
||||
fstring timestr;
|
||||
time_t t;
|
||||
|
||||
if(ldap_get_attribute(attribute, timestr))
|
||||
{
|
||||
t = (time_t)strtol(timestr, NULL, 16);
|
||||
unix_to_nt_time(nttime, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Contruct a sam_passwd structure.
|
||||
******************************************************************/
|
||||
|
||||
static struct sam_passwd *ldapsam_getsam()
|
||||
{
|
||||
static pstring full_name;
|
||||
static pstring acct_desc;
|
||||
static pstring home_dir;
|
||||
static pstring home_drive;
|
||||
static pstring logon_script;
|
||||
static pstring profile_path;
|
||||
static pstring workstations;
|
||||
pstring temp;
|
||||
struct sam_passwd *sam21;
|
||||
struct smb_passwd *smbpw;
|
||||
|
||||
if(!ldap_entry)
|
||||
return NULL;
|
||||
|
||||
smbpw = ldap_getpw();
|
||||
sam21 = pwdb_smb_to_sam(smbpw);
|
||||
|
||||
if(ldap_get_attribute("gidNumber", temp))
|
||||
sam21->unix_gid = atoi(temp);
|
||||
|
||||
if(ldap_get_attribute("grouprid", temp))
|
||||
sam21->group_rid = strtol(temp, NULL, 16);
|
||||
|
||||
if(ldap_get_attribute("cn", full_name))
|
||||
sam21->full_name = full_name;
|
||||
|
||||
if(ldap_get_attribute("description", acct_desc))
|
||||
sam21->acct_desc = acct_desc;
|
||||
|
||||
if(ldap_get_attribute("smbHome", home_dir))
|
||||
sam21->home_dir = home_dir;
|
||||
|
||||
if(ldap_get_attribute("homeDrive", home_drive))
|
||||
sam21->dir_drive = home_drive;
|
||||
|
||||
if(ldap_get_attribute("script", logon_script))
|
||||
sam21->logon_script = logon_script;
|
||||
|
||||
if(ldap_get_attribute("profile", profile_path))
|
||||
sam21->profile_path = profile_path;
|
||||
|
||||
if(ldap_get_attribute("workstations", workstations))
|
||||
sam21->workstations = workstations;
|
||||
|
||||
ldap_read_time("pwdCanChange", &sam21->pass_can_change_time);
|
||||
ldap_read_time("pwdMustChange", &sam21->pass_must_change_time);
|
||||
ldap_read_time("logonTime", &sam21->logon_time);
|
||||
ldap_read_time("logoffTime", &sam21->logoff_time);
|
||||
ldap_read_time("kickoffTime", &sam21->kickoff_time);
|
||||
|
||||
sam21->unknown_3 = 0xffffff; /* don't know */
|
||||
sam21->logon_divs = 168; /* hours per week */
|
||||
sam21->hours_len = 21; /* 21 times 8 bits = 168 */
|
||||
memset(sam21->hours, 0xff, sam21->hours_len); /* all hours */
|
||||
sam21->unknown_5 = 0x00020000; /* don't know */
|
||||
sam21->unknown_6 = 0x000004ec; /* don't know */
|
||||
sam21->unknown_str = NULL;
|
||||
sam21->munged_dial = NULL;
|
||||
|
||||
ldap_entry = ldap_next_entry(ldap_struct, ldap_entry);
|
||||
return sam21;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Contruct a sam_disp_info structure.
|
||||
******************************************************************/
|
||||
|
||||
static struct sam_disp_info *ldapsam_getdispinfo()
|
||||
{
|
||||
static struct sam_disp_info dispinfo;
|
||||
static pstring nt_name;
|
||||
static pstring full_name;
|
||||
pstring temp;
|
||||
|
||||
if(!ldap_entry)
|
||||
return NULL;
|
||||
|
||||
if(!ldap_get_attribute("ntuid", nt_name) &&
|
||||
!ldap_get_attribute("uid", nt_name)) {
|
||||
DEBUG(0,("Missing uid\n"));
|
||||
return NULL; }
|
||||
dispinfo.nt_name = nt_name;
|
||||
|
||||
DEBUG(2,("Retrieving account [%s]\n",nt_name));
|
||||
|
||||
if(ldap_get_attribute("rid", temp))
|
||||
dispinfo.user_rid = strtol(temp, NULL, 16);
|
||||
else {
|
||||
DEBUG(0,("Missing rid\n"));
|
||||
return NULL; }
|
||||
|
||||
if(ldap_get_attribute("cn", full_name))
|
||||
dispinfo.full_name = full_name;
|
||||
else
|
||||
dispinfo.full_name = NULL;
|
||||
|
||||
ldap_entry = ldap_next_entry(ldap_struct, ldap_entry);
|
||||
return &dispinfo;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Queues the necessary modifications to save a sam_passwd structure
|
||||
************************************************************************/
|
||||
|
||||
static void ldapsam_sammods(struct sam_passwd *newpwd, LDAPMod ***mods,
|
||||
int operation)
|
||||
{
|
||||
struct smb_passwd *smbpw;
|
||||
pstring temp;
|
||||
|
||||
smbpw = pwdb_sam_to_smb(newpwd);
|
||||
ldap_smbpwmods(smbpw, mods, operation);
|
||||
|
||||
slprintf(temp, sizeof(temp)-1, "%d", newpwd->unix_gid);
|
||||
ldap_make_mod(mods, operation, "gidNumber", temp);
|
||||
|
||||
slprintf(temp, sizeof(temp)-1, "%x", newpwd->group_rid);
|
||||
ldap_make_mod(mods, operation, "grouprid", temp);
|
||||
|
||||
ldap_make_mod(mods, operation, "cn", newpwd->full_name);
|
||||
ldap_make_mod(mods, operation, "description", newpwd->acct_desc);
|
||||
ldap_make_mod(mods, operation, "smbHome", newpwd->home_dir);
|
||||
ldap_make_mod(mods, operation, "homeDrive", newpwd->dir_drive);
|
||||
ldap_make_mod(mods, operation, "script", newpwd->logon_script);
|
||||
ldap_make_mod(mods, operation, "profile", newpwd->profile_path);
|
||||
ldap_make_mod(mods, operation, "workstations", newpwd->workstations);
|
||||
|
||||
ldap_save_time(mods, operation, "pwdCanChange",
|
||||
&newpwd->pass_can_change_time);
|
||||
ldap_save_time(mods, operation, "pwdMustChange",
|
||||
&newpwd->pass_must_change_time);
|
||||
ldap_save_time(mods, operation, "logonTime",
|
||||
&newpwd->logon_time);
|
||||
ldap_save_time(mods, operation, "logoffTime",
|
||||
&newpwd->logoff_time);
|
||||
ldap_save_time(mods, operation, "kickoffTime",
|
||||
&newpwd->kickoff_time);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
Begin/end account enumeration.
|
||||
****************************************************************/
|
||||
|
||||
static void *ldapsam_enumfirst(BOOL update)
|
||||
{
|
||||
if (!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_for("objectclass=sambaAccount");
|
||||
|
||||
return ldap_struct;
|
||||
}
|
||||
|
||||
static void ldapsam_enumclose(void *vp)
|
||||
{
|
||||
ldap_disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Save/restore the current position in a query
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT ldapsam_getdbpos(void *vp)
|
||||
{
|
||||
return (SMB_BIG_UINT)((ulong)ldap_entry);
|
||||
}
|
||||
|
||||
static BOOL ldapsam_setdbpos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
ldap_entry = (LDAPMessage *)((ulong)tok);
|
||||
return (True);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return sam_passwd information.
|
||||
*************************************************************************/
|
||||
|
||||
static struct sam_passwd *ldapsam_getsambynam(const char *name)
|
||||
{
|
||||
struct sam_passwd *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_ntname(name);
|
||||
ret = ldapsam_getsam();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sam_passwd *ldapsam_getsambyuid(uid_t userid)
|
||||
{
|
||||
struct sam_passwd *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_uid(userid);
|
||||
ret = ldapsam_getsam();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sam_passwd *ldapsam_getsambyrid(uint32 user_rid)
|
||||
{
|
||||
struct sam_passwd *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_rid(user_rid);
|
||||
ret = ldapsam_getsam();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sam_passwd *ldapsam_getcurrentsam(void *vp)
|
||||
{
|
||||
return ldapsam_getsam();
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Modify user information given a sam_passwd struct.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL ldapsam_addsam(struct sam_passwd *newpwd)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
if (!newpwd || !ldap_allocaterid(&newpwd->user_rid))
|
||||
return (False);
|
||||
|
||||
ldapsam_sammods(newpwd, &mods, LDAP_MOD_ADD);
|
||||
return ldap_makemods("uid", newpwd->unix_name, mods, True);
|
||||
}
|
||||
|
||||
static BOOL ldapsam_modsam(struct sam_passwd *pwd, BOOL override)
|
||||
{
|
||||
LDAPMod **mods;
|
||||
|
||||
if (!pwd)
|
||||
return (False);
|
||||
|
||||
ldapsam_sammods(pwd, &mods, LDAP_MOD_REPLACE);
|
||||
return ldap_makemods("uid", pwd->unix_name, mods, False);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Return sam_disp_info information.
|
||||
*************************************************************************/
|
||||
|
||||
static struct sam_disp_info *ldapsam_getdispbynam(const char *name)
|
||||
{
|
||||
struct sam_disp_info *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_ntname(name);
|
||||
ret = ldapsam_getdispinfo();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sam_disp_info *ldapsam_getdispbyrid(uint32 user_rid)
|
||||
{
|
||||
struct sam_disp_info *ret;
|
||||
|
||||
if(!ldap_connect())
|
||||
return NULL;
|
||||
|
||||
ldap_search_by_rid(user_rid);
|
||||
ret = ldapsam_getdispinfo();
|
||||
|
||||
ldap_disconnect();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct sam_disp_info *ldapsam_getcurrentdisp(void *vp)
|
||||
{
|
||||
return ldapsam_getdispinfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct sam_passdb_ops ldapsam_ops =
|
||||
{
|
||||
ldapsam_enumfirst,
|
||||
ldapsam_enumclose,
|
||||
ldapsam_getdbpos,
|
||||
ldapsam_setdbpos,
|
||||
|
||||
ldapsam_getsambynam,
|
||||
ldapsam_getsambyuid,
|
||||
ldapsam_getsambyrid,
|
||||
ldapsam_getcurrentsam,
|
||||
ldapsam_addsam,
|
||||
ldapsam_modsam,
|
||||
|
||||
ldapsam_getdispbynam,
|
||||
ldapsam_getdispbyrid,
|
||||
ldapsam_getcurrentdisp
|
||||
};
|
||||
|
||||
struct sam_passdb_ops *ldap_initialise_sam_password_db(void)
|
||||
{
|
||||
return &ldapsam_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
void sampassldap_dummy_function(void);
|
||||
void sampassldap_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif
|
@ -1,227 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup
|
||||
* Copyright (C) Andrew Tridgell 1992-1998 Modified by Jeremy Allison 1995.
|
||||
*
|
||||
* 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"
|
||||
|
||||
#ifdef USE_SMBUNIX_DB
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern DOM_SID global_sam_sid;
|
||||
|
||||
/***************************************************************
|
||||
Start to enumerate the smbpasswd list. Returns a void pointer
|
||||
to ensure no modification outside this module.
|
||||
****************************************************************/
|
||||
|
||||
static void *startsmbunixgrpent(BOOL update)
|
||||
{
|
||||
return startsmbpwent(False);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
End enumeration of the smbpasswd list.
|
||||
****************************************************************/
|
||||
|
||||
static void endsmbunixgrpent(void *vp)
|
||||
{
|
||||
endsmbpwent(vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Return the current position in the smbpasswd list as an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
|
||||
static SMB_BIG_UINT getsmbunixgrppos(void *vp)
|
||||
{
|
||||
return getsmbpwpos(vp);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Set the current position in the smbpasswd list from an SMB_BIG_UINT.
|
||||
This must be treated as an opaque token.
|
||||
*************************************************************************/
|
||||
|
||||
static BOOL setsmbunixgrppos(void *vp, SMB_BIG_UINT tok)
|
||||
{
|
||||
return setsmbpwpos(vp, tok);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Routine to return the next smbpassgroup entry
|
||||
*************************************************************************/
|
||||
static struct smb_passwd *getsmbunixgrpent(void *vp,
|
||||
uint32 **grp_rids, int *num_grps,
|
||||
uint32 **als_rids, int *num_alss)
|
||||
{
|
||||
/* Static buffers we will return. */
|
||||
struct sam_passwd *pw_buf;
|
||||
fstring unix_name;
|
||||
int i;
|
||||
int unixgrps;
|
||||
gid_t *grps;
|
||||
BOOL failed = False;
|
||||
|
||||
if (vp == NULL)
|
||||
{
|
||||
DEBUG(0,("getsmbunixgrpent: Bad password file pointer.\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pw_buf = getsam21pwent(vp);
|
||||
|
||||
if (pw_buf == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fstrcpy(unix_name, pw_buf->unix_name);
|
||||
|
||||
if (grp_rids != NULL)
|
||||
{
|
||||
(*grp_rids) = NULL;
|
||||
(*num_grps) = 0;
|
||||
}
|
||||
|
||||
if (als_rids != NULL)
|
||||
{
|
||||
(*als_rids) = NULL;
|
||||
(*num_alss) = 0;
|
||||
}
|
||||
|
||||
if (als_rids == NULL && grp_rids == NULL)
|
||||
{
|
||||
/* they didn't want to know the members. */
|
||||
return pwdb_sam_to_smb(pw_buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* find all unix groups
|
||||
*/
|
||||
|
||||
if (get_unixgroups(unix_name, pw_buf->unix_uid, pw_buf->unix_gid, &unixgrps, &grps))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* check each unix group for a mapping as an nt alias or an nt group
|
||||
*/
|
||||
|
||||
for (i = 0; i < unixgrps && !failed; i++)
|
||||
{
|
||||
uint32 rid;
|
||||
|
||||
/*
|
||||
* find the unix name for each user's group.
|
||||
* assume the unix group is an nt name (alias? group? user?)
|
||||
* (user or not our own domain will be an error).
|
||||
*
|
||||
* oh, oh, can anyone spot what's missing heeere?
|
||||
* you guessed it: built-in aliases. those are in
|
||||
* Domain S-1-5-20, and NT Domain Users can only
|
||||
* have lists of RIDs as groups.
|
||||
*
|
||||
* doesn't stop you making NT Domain Users a member
|
||||
* of a BUILTIN Alias (e.g "Administrators" or "Power Users")
|
||||
* it's just that there's no way to tell that from this
|
||||
* API call: wrong domain, sorry.
|
||||
*
|
||||
*/
|
||||
|
||||
DOM_NAME_MAP gmep;
|
||||
|
||||
if (!lookupsmbgrpgid(grps[i], &gmep))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sid_split_rid(&gmep.sid, &rid);
|
||||
if (!sid_equal(&global_sam_sid, &gmep.sid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (gmep.type)
|
||||
{
|
||||
case SID_NAME_ALIAS:
|
||||
{
|
||||
if (als_rids != NULL && add_num_to_list(als_rids, num_alss, rid) == NULL)
|
||||
{
|
||||
failed = True;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SID_NAME_DOM_GRP:
|
||||
case SID_NAME_WKN_GRP:
|
||||
{
|
||||
if (grp_rids != NULL && add_num_to_list(grp_rids, num_grps, rid) == NULL)
|
||||
{
|
||||
failed = True;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
if (grp_rids != NULL && (*grp_rids) != NULL)
|
||||
{
|
||||
free(*grp_rids);
|
||||
(*num_grps) = 0;
|
||||
}
|
||||
|
||||
if (als_rids != NULL && (*als_rids) != NULL)
|
||||
{
|
||||
free(*als_rids);
|
||||
(*num_alss) = 0;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pwdb_sam_to_smb(pw_buf);
|
||||
}
|
||||
|
||||
static struct passgrp_ops smbunixgrp_ops =
|
||||
{
|
||||
startsmbunixgrpent,
|
||||
endsmbunixgrpent,
|
||||
getsmbunixgrppos,
|
||||
setsmbunixgrppos,
|
||||
iterate_getsmbgrpntnam, /* In passgrp.c */
|
||||
iterate_getsmbgrpuid, /* In passgrp.c */
|
||||
iterate_getsmbgrprid, /* In passgrp.c */
|
||||
getsmbunixgrpent
|
||||
};
|
||||
|
||||
struct passgrp_ops *unix_initialise_password_grp(void)
|
||||
{
|
||||
return &smbunixgrp_ops;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
|
||||
void smbpassgroupunix_dummy_function(void) { } /* stop some compilers complaining */
|
||||
#endif /* USE_SMBPASS_DB */
|
File diff suppressed because it is too large
Load Diff
@ -1,277 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 2.1.
|
||||
* RPC client routines: scheduler service
|
||||
* Copyright (C) Matthew Chapman 1999,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
|
||||
* Copyright (C) Andrew Tridgell 1992-1999.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/****************************************************************************
|
||||
add a job to the scheduler
|
||||
****************************************************************************/
|
||||
BOOL at_add_job(
|
||||
char *srv_name, AT_JOB_INFO *info, char *command,
|
||||
uint32 *jobid)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
AT_Q_ADD_JOB q_a;
|
||||
BOOL p = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api AT_ADD_JOB */
|
||||
|
||||
DEBUG(4,("Scheduler Add Job\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_at_q_add_job(&q_a, srv_name, info, command);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
at_io_q_add_job("", &q_a, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, AT_ADD_JOB, &buf, &rbuf))
|
||||
{
|
||||
AT_R_ADD_JOB r_a;
|
||||
|
||||
at_io_r_add_job("", &r_a, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_a.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("AT_R_ADD_JOB: %s\n", get_nt_error_msg(r_a.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
*jobid = r_a.jobid;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
dequeue a job
|
||||
****************************************************************************/
|
||||
BOOL at_del_job( char *srv_name, uint32 min_jobid, uint32 max_jobid)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
AT_Q_DEL_JOB q_d;
|
||||
BOOL p = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api AT_DEL_JOB */
|
||||
|
||||
DEBUG(4,("Scheduler Delete Job\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_at_q_del_job(&q_d, srv_name, min_jobid, max_jobid);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
at_io_q_del_job("", &q_d, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, AT_DEL_JOB, &buf, &rbuf))
|
||||
{
|
||||
AT_R_DEL_JOB r_d;
|
||||
|
||||
at_io_r_del_job("", &r_d, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_d.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("AT_R_DEL_JOB: %s\n", get_nt_error_msg(r_d.status)));
|
||||
p = False;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
enumerate scheduled jobs
|
||||
****************************************************************************/
|
||||
BOOL at_enum_jobs( char *srv_name, uint32 *num_jobs,
|
||||
AT_ENUM_INFO *jobs, char ***commands)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
AT_Q_ENUM_JOBS q_e;
|
||||
BOOL p = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api AT_DEL_JOB */
|
||||
|
||||
DEBUG(4,("Scheduler Enumerate Jobs\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_at_q_enum_jobs(&q_e, srv_name);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
at_io_q_enum_jobs("", &q_e, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, AT_ENUM_JOBS, &buf, &rbuf))
|
||||
{
|
||||
AT_R_ENUM_JOBS r_e;
|
||||
|
||||
at_io_r_enum_jobs("", &r_e, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_e.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("AT_R_ENUM_JOBS: %s\n", get_nt_error_msg(r_e.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
int i;
|
||||
|
||||
*num_jobs = 0;
|
||||
memcpy(jobs, &r_e.info, r_e.num_entries * sizeof(AT_ENUM_INFO));
|
||||
|
||||
for (i = 0; i < r_e.num_entries; i++)
|
||||
{
|
||||
fstring cmd;
|
||||
unistr2_to_ascii(cmd, &r_e.command[i], sizeof(cmd));
|
||||
add_chars_to_array(num_jobs, commands, cmd);
|
||||
}
|
||||
if ((*num_jobs) != r_e.num_entries)
|
||||
{
|
||||
p = False;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
query job information
|
||||
****************************************************************************/
|
||||
BOOL at_query_job(char *srv_name,
|
||||
uint32 jobid, AT_JOB_INFO *job, fstring command)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
AT_Q_QUERY_JOB q_q;
|
||||
BOOL p = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_ATSVC, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api AT_QUERY_JOB */
|
||||
|
||||
DEBUG(4,("Scheduler Query Job\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_at_q_query_job(&q_q, srv_name, jobid);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
at_io_q_query_job("", &q_q, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, AT_QUERY_JOB, &buf, &rbuf))
|
||||
{
|
||||
AT_R_QUERY_JOB r_q;
|
||||
|
||||
at_io_r_query_job("", &r_q, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_q.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("AT_R_QUERY_JOB: %s\n", get_nt_error_msg(r_q.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
memcpy(job, &r_q.info, sizeof(AT_JOB_INFO));
|
||||
unistr2_to_ascii(command, &r_q.command,
|
||||
sizeof(fstring)-1);
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return p;
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1999,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef SYSLOG
|
||||
#undef SYSLOG
|
||||
#endif
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/****************************************************************************
|
||||
do a BRS Query
|
||||
****************************************************************************/
|
||||
BOOL brs_query_info( const char *srv_name, uint32 switch_value,
|
||||
void *id)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
BRS_Q_QUERY_INFO q_o;
|
||||
BOOL valid_info = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_BROWSER, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (id == NULL) return False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api BRS_QUERY_INFO */
|
||||
|
||||
DEBUG(4,("BRS Query Info\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_brs_q_query_info(&q_o, srv_name, switch_value);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
brs_io_q_query_info("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, BRS_QUERY_INFO, &buf, &rbuf))
|
||||
{
|
||||
BRS_R_QUERY_INFO r_o;
|
||||
BOOL p;
|
||||
|
||||
r_o.info.id = id;
|
||||
|
||||
brs_io_r_query_info("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("BRS_R_QUERY_INFO: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
valid_info = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return valid_info;
|
||||
}
|
||||
|
@ -1,427 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB client generic functions
|
||||
Copyright (C) Andrew Tridgell 1994-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
struct ntuser_creds *usr_creds = NULL;
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern pstring scope;
|
||||
extern pstring global_myname;
|
||||
|
||||
struct cli_connection
|
||||
{
|
||||
uint32 num_connections;
|
||||
char *srv_name;
|
||||
char *pipe_name;
|
||||
struct ntuser_creds usr_creds;
|
||||
struct cli_state *cli;
|
||||
uint16 fnum;
|
||||
};
|
||||
|
||||
static struct cli_connection **con_list = NULL;
|
||||
uint32 num_cons = 0;
|
||||
|
||||
void init_connections(void)
|
||||
{
|
||||
con_list = NULL;
|
||||
num_cons = 0;
|
||||
|
||||
init_cli_use();
|
||||
}
|
||||
|
||||
static void free_con_array(uint32 num_entries, struct cli_connection **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&cli_connection_free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
static struct cli_connection* add_con_to_array(uint32 *len,
|
||||
struct cli_connection ***array,
|
||||
struct cli_connection *con)
|
||||
{
|
||||
return (struct cli_connection*)add_item_to_array(len,
|
||||
(void***)array, (void*)con);
|
||||
|
||||
}
|
||||
void free_connections(void)
|
||||
{
|
||||
free_con_array(num_cons, con_list);
|
||||
free_cli_use();
|
||||
|
||||
init_connections();
|
||||
}
|
||||
|
||||
static struct cli_connection *cli_con_get(const char* srv_name,
|
||||
const char* pipe_name, BOOL reuse)
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
con = (struct cli_connection*)malloc(sizeof(*con));
|
||||
|
||||
if (con == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(con, 0, sizeof(*con));
|
||||
|
||||
if (srv_name != NULL)
|
||||
{
|
||||
con->srv_name = strdup(srv_name);
|
||||
}
|
||||
if (pipe_name != NULL)
|
||||
{
|
||||
con->pipe_name = strdup(pipe_name);
|
||||
}
|
||||
|
||||
con->cli = cli_net_use_add(srv_name, usr_creds, True, reuse);
|
||||
|
||||
if (con->cli == NULL)
|
||||
{
|
||||
cli_connection_free(con);
|
||||
return NULL;
|
||||
}
|
||||
add_con_to_array(&num_cons, &con_list, con);
|
||||
return con;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
terminate client connection
|
||||
****************************************************************************/
|
||||
void cli_connection_free(struct cli_connection *con)
|
||||
{
|
||||
BOOL closed;
|
||||
int i;
|
||||
|
||||
if (con->cli != NULL)
|
||||
{
|
||||
cli_nt_session_close(con->cli, con->fnum);
|
||||
cli_net_use_del(con->srv_name, &con->usr_creds, False, &closed);
|
||||
}
|
||||
|
||||
if (closed)
|
||||
{
|
||||
for (i = 0; i < num_cons; i++)
|
||||
{
|
||||
if (con_list[i] != NULL &&
|
||||
con != con_list[i] &&
|
||||
con_list[i]->cli == con->cli)
|
||||
{
|
||||
/* WHOOPS! fnum already open: too bad!!! */
|
||||
con_list[i]->cli = NULL;
|
||||
con_list[i]->fnum = 0xffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
con->cli = NULL;
|
||||
|
||||
if (con->srv_name != NULL)
|
||||
{
|
||||
free(con->srv_name);
|
||||
con->srv_name = NULL;
|
||||
}
|
||||
if (con->pipe_name != NULL)
|
||||
{
|
||||
free(con->pipe_name);
|
||||
con->pipe_name = NULL;
|
||||
}
|
||||
|
||||
memset(&con->usr_creds, 0, sizeof(con->usr_creds));
|
||||
|
||||
for (i = 0; i < num_cons; i++)
|
||||
{
|
||||
if (con == con_list[i])
|
||||
{
|
||||
con_list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free(con);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
terminate client state
|
||||
****************************************************************************/
|
||||
void cli_connection_unlink(struct cli_connection *con)
|
||||
{
|
||||
if (con != NULL)
|
||||
{
|
||||
cli_connection_free(con);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
init client state
|
||||
****************************************************************************/
|
||||
BOOL cli_connection_init(const char* srv_name, const char* pipe_name,
|
||||
struct cli_connection **con)
|
||||
{
|
||||
BOOL res = True;
|
||||
BOOL reuse = False;
|
||||
|
||||
/*
|
||||
* allocate
|
||||
*/
|
||||
|
||||
*con = cli_con_get(srv_name, pipe_name, reuse);
|
||||
|
||||
if ((*con) == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
res = res ? cli_nt_session_open((*con)->cli, pipe_name,
|
||||
&(*con)->fnum) : False;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
obtain client state
|
||||
****************************************************************************/
|
||||
BOOL cli_connection_getsrv(const char* srv_name, const char* pipe_name,
|
||||
struct cli_connection **con)
|
||||
{
|
||||
int i;
|
||||
if (con_list == NULL || num_cons == 0)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_cons; i++)
|
||||
{
|
||||
if (con_list[i] != NULL &&
|
||||
strequal(con_list[i]->srv_name , srv_name ) &&
|
||||
strequal(con_list[i]->pipe_name, pipe_name))
|
||||
{
|
||||
(*con) = con_list[i];
|
||||
return True;
|
||||
}
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
obtain client state
|
||||
****************************************************************************/
|
||||
BOOL cli_connection_get(const POLICY_HND *pol, struct cli_connection **con)
|
||||
{
|
||||
return get_policy_con(pol, con);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
link a child policy handle to a parent one
|
||||
****************************************************************************/
|
||||
BOOL cli_pol_link(POLICY_HND *to, const POLICY_HND *from)
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(from, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return register_policy_hnd(to) && set_policy_con(to, con, NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_get_con_usr_sesskey(struct cli_connection *con, uchar usr_sess_key[16])
|
||||
{
|
||||
if (con == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
memcpy(usr_sess_key, con->cli->usr.pwd.sess_key, 16);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_get_con_sesskey(struct cli_connection *con, uchar sess_key[16])
|
||||
{
|
||||
if (con == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
memcpy(sess_key, con->cli->sess_key, sizeof(con->cli->sess_key));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_con_get_srvname(struct cli_connection *con, char *srv_name)
|
||||
{
|
||||
if (con == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (strnequal("\\\\", con->cli->desthost, 2))
|
||||
{
|
||||
fstrcpy(srv_name, con->cli->desthost);
|
||||
}
|
||||
else
|
||||
{
|
||||
fstrcpy(srv_name, "\\\\");
|
||||
fstrcat(srv_name, con->cli->desthost);
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_get_usr_sesskey(const POLICY_HND *pol, uchar usr_sess_key[16])
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(pol, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return cli_get_con_usr_sesskey(con, usr_sess_key);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_get_sesskey(const POLICY_HND *pol, uchar sess_key[16])
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(pol, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return cli_get_con_sesskey(con, sess_key);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_get_sesskey_srv(const char* srv_name, uchar sess_key[16])
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_getsrv(srv_name, PIPE_NETLOGON, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return cli_get_con_sesskey(con, sess_key);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
void cli_con_gen_next_creds(struct cli_connection *con,
|
||||
DOM_CRED *new_clnt_cred)
|
||||
{
|
||||
gen_next_creds(con->cli, new_clnt_cred);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
void cli_con_get_cli_cred(struct cli_connection *con,
|
||||
DOM_CRED *clnt_cred)
|
||||
{
|
||||
memcpy(clnt_cred, &con->cli->clnt_cred, sizeof(*clnt_cred));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_con_deal_with_creds(struct cli_connection *con,
|
||||
DOM_CRED *rcv_srv_cred)
|
||||
{
|
||||
return clnt_deal_with_creds(con->cli->sess_key, &con->cli->clnt_cred,
|
||||
rcv_srv_cred);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
get a user session key associated with a connection associated with a
|
||||
policy handle.
|
||||
****************************************************************************/
|
||||
BOOL cli_con_set_creds(const char* srv_name, const uchar sess_key[16],
|
||||
DOM_CRED *cred)
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_getsrv(srv_name, PIPE_NETLOGON, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
memcpy(con->cli->sess_key, sess_key, 16);
|
||||
memcpy(&con->cli->clnt_cred, cred, sizeof(*cred));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send a request on an rpc pipe.
|
||||
****************************************************************************/
|
||||
BOOL rpc_hnd_pipe_req(const POLICY_HND *hnd, uint8 op_num,
|
||||
prs_struct *data, prs_struct *rdata)
|
||||
{
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
return rpc_con_pipe_req(con, op_num, data, rdata);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
send a request on an rpc pipe.
|
||||
****************************************************************************/
|
||||
BOOL rpc_con_pipe_req(struct cli_connection *con, uint8 op_num,
|
||||
prs_struct *data, prs_struct *rdata)
|
||||
{
|
||||
return rpc_api_pipe_req(con->cli, con->fnum, op_num, data, rdata);
|
||||
}
|
@ -1,212 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 2.1.
|
||||
* RPC client routines: scheduler service
|
||||
* Copyright (C) Jean Francois Micouleau 1998-1999,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
|
||||
* Copyright (C) Andrew Tridgell 1992-1999.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
BOOL event_open(const char* srv_name, const char *log, POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
EVENTLOG_Q_OPEN q;
|
||||
BOOL p = False;
|
||||
BOOL valid_pol = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_EVENTLOG, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* store the parameters */
|
||||
make_eventlog_q_open(&q, log, NULL);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
eventlog_io_q_open("", &q, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, EVENTLOG_OPEN, &buf, &rbuf))
|
||||
{
|
||||
EVENTLOG_R_OPEN r;
|
||||
|
||||
eventlog_io_r_open("", &r, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("event_open: %s\n", get_nt_error_msg(r.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/*copy handle */
|
||||
memcpy(hnd->data, r.pol.data, sizeof(hnd->data));
|
||||
valid_pol = register_policy_hnd(hnd) &&
|
||||
set_policy_con(hnd, con,
|
||||
cli_connection_unlink);
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
BOOL event_close( POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
EVENTLOG_Q_CLOSE q;
|
||||
BOOL p = False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* store the parameters */
|
||||
make_eventlog_q_close(&q, hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
eventlog_io_q_close("", &q, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_hnd_pipe_req(hnd, EVENTLOG_CLOSE, &buf, &rbuf))
|
||||
{
|
||||
EVENTLOG_R_CLOSE r;
|
||||
|
||||
eventlog_io_r_close("", &r, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
close_policy_hnd(hnd);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
BOOL event_numofeventlogrec( POLICY_HND *hnd, uint32 *number)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
EVENTLOG_Q_NUMOFEVENTLOGREC q;
|
||||
BOOL p = False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* store the parameters */
|
||||
make_eventlog_q_numofeventlogrec(&q, hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
eventlog_io_q_numofeventlogrec("", &q, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_hnd_pipe_req(hnd, EVENTLOG_NUMOFEVENTLOGRECORDS, &buf, &rbuf))
|
||||
{
|
||||
EVENTLOG_R_NUMOFEVENTLOGREC r;
|
||||
|
||||
eventlog_io_r_numofeventlogrec("", &r, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("event_close: %s\n", get_nt_error_msg(r.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
*number=r.number;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
BOOL event_readeventlog(POLICY_HND *hnd,
|
||||
uint32 number, uint32 flags, uint32 offset,
|
||||
uint32 *number_of_bytes, EVENTLOGRECORD *ev)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
EVENTLOG_Q_READEVENTLOG q;
|
||||
EVENTLOG_R_READEVENTLOG r;
|
||||
BOOL p = False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* store the parameters */
|
||||
make_eventlog_q_readeventlog(&q, hnd, flags, offset, *number_of_bytes);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
eventlog_io_q_readeventlog("", &q, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_hnd_pipe_req(hnd, EVENTLOG_READEVENTLOG, &buf, &rbuf))
|
||||
{
|
||||
r.event=ev;
|
||||
eventlog_io_r_readeventlog("", &r, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p)
|
||||
{
|
||||
*number_of_bytes=r.real_size;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1999,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
|
||||
* Copyright (C) Matthew Chapman 1999,
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef SYSLOG
|
||||
#undef SYSLOG
|
||||
#endif
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern pstring global_myname;
|
||||
|
||||
BOOL synchronise_passdb(void)
|
||||
{
|
||||
SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS];
|
||||
SAM_DELTA_CTR deltas[MAX_SAM_DELTAS];
|
||||
uint32 num;
|
||||
|
||||
SAM_ACCOUNT_INFO *acc;
|
||||
struct smb_passwd pwd;
|
||||
fstring nt_name;
|
||||
unsigned char smb_passwd[16];
|
||||
unsigned char smb_nt_passwd[16];
|
||||
uchar trust_passwd[16];
|
||||
fstring trust_acct;
|
||||
|
||||
char *mode;
|
||||
BOOL success;
|
||||
BOOL ret;
|
||||
int i;
|
||||
|
||||
fstrcpy(trust_acct, global_myname);
|
||||
fstrcat(trust_acct, "$");
|
||||
|
||||
if (!trust_get_passwd(trust_passwd, lp_workgroup(), global_myname))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
ret = net_sam_sync(lp_passwordserver(), global_myname, trust_acct,
|
||||
trust_passwd,
|
||||
hdr_deltas, deltas, &num);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
/* Currently only interested in accounts */
|
||||
if (hdr_deltas[i].type != 5)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
acc = &deltas[i].account_info;
|
||||
pwdb_init_smb(&pwd);
|
||||
|
||||
pwd.user_rid = acc->user_rid;
|
||||
unistr2_to_ascii(nt_name, &(acc->uni_acct_name), sizeof(fstring)-1);
|
||||
pwd.nt_name = nt_name;
|
||||
pwd.acct_ctrl = acc->acb_info;
|
||||
pwd.pass_last_set_time = nt_time_to_unix(&(acc->pwd_last_set_time));
|
||||
|
||||
sam_pwd_hash(acc->user_rid, smb_passwd, acc->pass.buf_lm_pwd, 0);
|
||||
sam_pwd_hash(acc->user_rid, smb_nt_passwd, acc->pass.buf_nt_pwd, 0);
|
||||
pwd.smb_passwd = smb_passwd;
|
||||
pwd.smb_nt_passwd = smb_nt_passwd;
|
||||
|
||||
mode = "modify";
|
||||
success = mod_smbpwd_entry(&pwd, True);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
mode = "add";
|
||||
success = add_smbpwd_entry(&pwd);
|
||||
}
|
||||
|
||||
DEBUG(0, ("Attempted to %s account for %s: %s\n", mode,
|
||||
nt_name, success ? "OK" : "FAILED"));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,329 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* RPC Pipe client / server routines
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef SYSLOG
|
||||
#undef SYSLOG
|
||||
#endif
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SPOOLSS Enum Printers
|
||||
****************************************************************************/
|
||||
BOOL spoolss_enum_printers(uint32 flags, const char *srv_name,
|
||||
uint32 level,
|
||||
uint32 *count,
|
||||
void ***printers)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SPOOL_Q_ENUMPRINTERS q_o;
|
||||
BOOL valid_pol = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (count == NULL || printers == NULL) return False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
|
||||
|
||||
DEBUG(5,("SPOOLSS Enum Printers (Server: %s level: %d)\n",
|
||||
srv_name, level));
|
||||
|
||||
make_spoolss_q_enumprinters(&q_o, flags, srv_name, level, 0x200);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
spoolss_io_q_enumprinters("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERS, &buf, &rbuf))
|
||||
{
|
||||
SPOOL_R_ENUMPRINTERS r_o;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT(r_o);
|
||||
|
||||
r_o.level = level; /* i can't believe you have to this */
|
||||
|
||||
spoolss_io_r_enumprinters("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(5,("SPOOLSS_ENUM_PRINTERS: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* ok, at last: we're happy. return the policy handle */
|
||||
(*count) = r_o.returned;
|
||||
(*printers) = r_o.printer.info;
|
||||
valid_pol = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return valid_pol;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a SPOOLSS Enum Jobs
|
||||
****************************************************************************/
|
||||
uint32 spoolss_enum_jobs( const POLICY_HND *hnd,
|
||||
uint32 firstjob,
|
||||
uint32 numofjobs,
|
||||
uint32 level,
|
||||
uint32 *buf_size,
|
||||
uint32 *count,
|
||||
void ***jobs)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SPOOL_Q_ENUMJOBS q_o;
|
||||
uint32 status = 0x0;
|
||||
|
||||
if (hnd == NULL || count == NULL || jobs == NULL)
|
||||
{
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
|
||||
|
||||
DEBUG(5,("SPOOLSS Enum Jobs level: %d)\n", level));
|
||||
|
||||
make_spoolss_q_enumjobs(&q_o, hnd,
|
||||
firstjob, numofjobs,
|
||||
level, *buf_size);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
spoolss_io_q_enumjobs("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMJOBS, &buf, &rbuf))
|
||||
{
|
||||
SPOOL_R_ENUMJOBS r_o;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT(r_o);
|
||||
|
||||
r_o.level = level; /* i can't believe you have to this */
|
||||
|
||||
spoolss_io_r_enumjobs("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
status = r_o.status;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(5,("SPOOLSS_ENUM_JOBS: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = status = ERROR_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* ok, at last: we're happy. return the policy handle */
|
||||
(*count) = r_o.numofjobs;
|
||||
(*jobs) = r_o.job.info;
|
||||
(*buf_size) = r_o.offered;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a SPOOLSS Open Printer Ex
|
||||
****************************************************************************/
|
||||
BOOL spoolss_open_printer_ex( const char *printername,
|
||||
uint32 cbbuf, uint32 devmod, uint32 des_access,
|
||||
const char *station, const char *username,
|
||||
POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SPOOL_Q_OPEN_PRINTER_EX q_o;
|
||||
BOOL valid_pol = False;
|
||||
fstring srv_name;
|
||||
char *s;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
memset(srv_name, 0, sizeof(srv_name));
|
||||
fstrcpy(srv_name, printername);
|
||||
|
||||
s = strchr(&srv_name[2], '\\');
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SPOOLSS_OPENPRINTEREX */
|
||||
|
||||
DEBUG(5,("SPOOLSS Open Printer Ex\n"));
|
||||
|
||||
make_spoolss_q_open_printer_ex(&q_o, printername,
|
||||
cbbuf, devmod, des_access,
|
||||
station, username);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
spoolss_io_q_open_printer_ex("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SPOOLSS_OPENPRINTEREX, &buf, &rbuf))
|
||||
{
|
||||
SPOOL_R_OPEN_PRINTER_EX r_o;
|
||||
BOOL p;
|
||||
|
||||
spoolss_io_r_open_printer_ex("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(5,("SPOOLSS_OPENPRINTEREX: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* ok, at last: we're happy. return the policy handle */
|
||||
memcpy(hnd, r_o.handle.data, sizeof(hnd->data));
|
||||
|
||||
valid_pol = register_policy_hnd(hnd) &&
|
||||
set_policy_con(hnd, con,
|
||||
cli_connection_unlink);
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_pol;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a SPOOL Close
|
||||
****************************************************************************/
|
||||
BOOL spoolss_closeprinter(POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SPOOL_Q_CLOSEPRINTER q_c;
|
||||
BOOL valid_close = False;
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
/* create and send a MSRPC command with api SPOOLSS_CLOSEPRINTER */
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
DEBUG(4,("SPOOL Close Printer\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_spoolss_q_closeprinter(&q_c, hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
spoolss_io_q_closeprinter("", &q_c, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_hnd_pipe_req(hnd, SPOOLSS_CLOSEPRINTER, &buf, &rbuf))
|
||||
{
|
||||
SPOOL_R_CLOSEPRINTER r_c;
|
||||
BOOL p;
|
||||
|
||||
spoolss_io_r_closeprinter("", &r_c, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_c.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("SPOOL_CLOSEPRINTER: %s\n", get_nt_error_msg(r_c.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* check that the returned policy handle is all zeros */
|
||||
uint32 i;
|
||||
valid_close = True;
|
||||
|
||||
for (i = 0; i < sizeof(r_c.handle.data); i++)
|
||||
{
|
||||
if (r_c.handle.data[i] != 0)
|
||||
{
|
||||
valid_close = False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid_close)
|
||||
{
|
||||
DEBUG(0,("SPOOL_CLOSEPRINTER: non-zero handle returned\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
close_policy_hnd(hnd);
|
||||
|
||||
return valid_close;
|
||||
}
|
||||
|
@ -1,604 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 1.9.
|
||||
* RPC Pipe client / server routines
|
||||
* Copyright (C) Andrew Tridgell 1992-1998,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
|
||||
* Copyright (C) Paul Ashton 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"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Open Policy
|
||||
****************************************************************************/
|
||||
BOOL svc_open_sc_man( const char *srv_name, char *db_name,
|
||||
uint32 des_access,
|
||||
POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_OPEN_SC_MAN q_o;
|
||||
BOOL valid_pol = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_SVCCTL, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SVC_OPEN_SC_MAN */
|
||||
|
||||
DEBUG(4,("SVC Open SC_MAN\n"));
|
||||
|
||||
make_svc_q_open_sc_man(&q_o, srv_name, db_name, des_access);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_open_sc_man("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_OPEN_SC_MAN, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_OPEN_SC_MAN r_o;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT(r_o);
|
||||
|
||||
svc_io_r_open_sc_man("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* ok, at last: we're happy. return the policy handle */
|
||||
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
|
||||
valid_pol = True;
|
||||
valid_pol = register_policy_hnd(hnd) &&
|
||||
set_policy_con(hnd, con,
|
||||
cli_connection_unlink);
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_pol;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Open Service
|
||||
****************************************************************************/
|
||||
BOOL svc_open_service( POLICY_HND *scm_hnd,
|
||||
const char *srv_name,
|
||||
uint32 des_access,
|
||||
POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_OPEN_SERVICE q_o;
|
||||
BOOL valid_pol = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(scm_hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL || scm_hnd == NULL) return False;
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SVC_OPEN_SERVICE */
|
||||
|
||||
DEBUG(4,("SVC Open Service\n"));
|
||||
|
||||
make_svc_q_open_service(&q_o, scm_hnd, srv_name, des_access);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_open_service("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_OPEN_SERVICE, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_OPEN_SERVICE r_o;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT(r_o);
|
||||
|
||||
svc_io_r_open_service("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_o.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* ok, at last: we're happy. return the policy handle */
|
||||
memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
|
||||
valid_pol = register_policy_hnd(hnd) &&
|
||||
set_policy_con(hnd, con, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_pol;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Enumerate Services
|
||||
****************************************************************************/
|
||||
BOOL svc_enum_svcs( POLICY_HND *hnd,
|
||||
uint32 services_type, uint32 services_state,
|
||||
uint32 *buf_size, uint32 *resume_hnd,
|
||||
uint32 *dos_error,
|
||||
ENUM_SRVC_STATUS **svcs, uint32 *num_svcs)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_ENUM_SVCS_STATUS q_o;
|
||||
BOOL valid_pol = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL || buf_size == NULL || dos_error == NULL || num_svcs == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
/* create and send a MSRPC command with api SVC_ENUM_SVCS_STATUS */
|
||||
|
||||
DEBUG(4,("SVC Enum Services Status\n"));
|
||||
|
||||
make_svc_q_enum_svcs_status(&q_o, hnd,
|
||||
services_type, services_state,
|
||||
*buf_size, *resume_hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_enum_svcs_status("", &q_o, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_ENUM_SVCS_STATUS, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_ENUM_SVCS_STATUS r_o;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT(r_o);
|
||||
|
||||
svc_io_r_enum_svcs_status("", &r_o, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_o.dos_status != 0)
|
||||
{
|
||||
fstring errmsg;
|
||||
|
||||
if (r_o.dos_status != ERRmoredata)
|
||||
{
|
||||
smb_safe_err_msg(ERRDOS, r_o.dos_status,
|
||||
errmsg, sizeof(errmsg));
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg));
|
||||
}
|
||||
p = r_o.dos_status == ERRmoredata;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
(*svcs) = r_o.svcs;
|
||||
(*num_svcs) = r_o.num_svcs;
|
||||
(*resume_hnd) = get_enum_hnd(&r_o.resume_hnd);
|
||||
(*buf_size) = r_o.more_buf_size;
|
||||
(*dos_error) = r_o.dos_status;
|
||||
valid_pol = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_pol;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Stop Service
|
||||
****************************************************************************/
|
||||
BOOL svc_stop_service( POLICY_HND *hnd,
|
||||
uint32 unknown)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_STOP_SERVICE q_c;
|
||||
BOOL valid_cfg = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
/* create and send a MSRPC command with api SVC_STOP_SERVICE */
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
DEBUG(4,("SVC Stop Service\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_svc_q_stop_service(&q_c, hnd, unknown);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_stop_service("", &q_c, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_STOP_SERVICE, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_STOP_SERVICE r_c;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT (r_c);
|
||||
|
||||
svc_io_r_stop_service("", &r_c, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_c.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
valid_cfg = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_cfg;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Start Service
|
||||
****************************************************************************/
|
||||
BOOL svc_start_service( POLICY_HND *hnd,
|
||||
uint32 argc,
|
||||
char **argv)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_START_SERVICE q_c;
|
||||
BOOL valid_cfg = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
/* create and send a MSRPC command with api SVC_START_SERVICE */
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
DEBUG(4,("SVC Start Service\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_svc_q_start_service(&q_c, hnd, argc, argv);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_start_service("", &q_c, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_START_SERVICE, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_START_SERVICE r_c;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT (r_c);
|
||||
|
||||
svc_io_r_start_service("", &r_c, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_c.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_START_SERVICE: %s\n", get_nt_error_msg(r_c.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
valid_cfg = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_cfg;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Query Service Config
|
||||
****************************************************************************/
|
||||
BOOL svc_query_svc_cfg( POLICY_HND *hnd,
|
||||
QUERY_SERVICE_CONFIG *cfg,
|
||||
uint32 *buf_size)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_QUERY_SVC_CONFIG q_c;
|
||||
BOOL valid_cfg = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL || buf_size == NULL) return False;
|
||||
|
||||
/* create and send a MSRPC command with api SVC_QUERY_SVC_CONFIG */
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
DEBUG(4,("SVC Query Service Config\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_svc_q_query_svc_config(&q_c, hnd, *buf_size);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_query_svc_config("", &q_c, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_QUERY_SVC_CONFIG, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_QUERY_SVC_CONFIG r_c;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT (r_c);
|
||||
ZERO_STRUCTP(cfg);
|
||||
|
||||
r_c.cfg = cfg;
|
||||
|
||||
svc_io_r_query_svc_config("", &r_c, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_c.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
valid_cfg = r_c.buf_size != 0;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_cfg;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Close
|
||||
****************************************************************************/
|
||||
BOOL svc_close(POLICY_HND *hnd)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_CLOSE q_c;
|
||||
BOOL valid_close = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
/* create and send a MSRPC command with api SVC_CLOSE */
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
DEBUG(4,("SVC Close\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_svc_q_close(&q_c, hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_close("", &q_c, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_CLOSE, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_CLOSE r_c;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT(r_c);
|
||||
|
||||
svc_io_r_close("", &r_c, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_c.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
/* check that the returned policy handle is all zeros */
|
||||
uint32 i;
|
||||
valid_close = True;
|
||||
|
||||
for (i = 0; i < sizeof(r_c.pol.data); i++)
|
||||
{
|
||||
if (r_c.pol.data[i] != 0)
|
||||
{
|
||||
valid_close = False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid_close)
|
||||
{
|
||||
DEBUG(1,("SVC_CLOSE: non-zero handle returned\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_policy_hnd(hnd);
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_close;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a SVC Change Service Config
|
||||
****************************************************************************/
|
||||
BOOL svc_change_svc_cfg( POLICY_HND *hnd,
|
||||
uint32 service_type, uint32 start_type,
|
||||
uint32 unknown_0,
|
||||
uint32 error_control,
|
||||
char* bin_path_name, char* load_order_grp,
|
||||
uint32 tag_id,
|
||||
char* dependencies, char* service_start_name,
|
||||
char* password,
|
||||
char* disp_name)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_CHANGE_SVC_CONFIG q_c;
|
||||
BOOL valid_cfg = False;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_get(hnd, &con))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
|
||||
/* create and send a MSRPC command with api SVC_CHANGE_SVC_CONFIG */
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
|
||||
DEBUG(4,("SVC Change Service Config\n"));
|
||||
|
||||
/* store the parameters */
|
||||
make_svc_q_change_svc_config(&q_c, hnd,
|
||||
service_type, start_type,
|
||||
unknown_0, error_control,
|
||||
bin_path_name, load_order_grp,
|
||||
tag_id,
|
||||
dependencies, service_start_name,
|
||||
password, disp_name);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_change_svc_config("", &q_c, &buf, 0);
|
||||
|
||||
/* send the data on \PIPE\ */
|
||||
if (rpc_con_pipe_req(con, SVC_CHANGE_SVC_CONFIG, &buf, &rbuf))
|
||||
{
|
||||
SVC_R_CHANGE_SVC_CONFIG r_c;
|
||||
BOOL p;
|
||||
|
||||
ZERO_STRUCT (r_c);
|
||||
|
||||
svc_io_r_change_svc_config("", &r_c, &rbuf, 0);
|
||||
p = rbuf.offset != 0;
|
||||
|
||||
if (p && r_c.status != 0)
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(1,("SVC_CHANGE_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status)));
|
||||
p = False;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
valid_cfg = True;
|
||||
}
|
||||
}
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
return valid_cfg;
|
||||
}
|
@ -1,418 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
SMB client generic functions
|
||||
Copyright (C) Andrew Tridgell 1994-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#define NO_SYSLOG
|
||||
|
||||
#include "includes.h"
|
||||
#include "trans2.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
extern pstring scope;
|
||||
extern pstring global_myname;
|
||||
|
||||
struct cli_use
|
||||
{
|
||||
struct cli_state *cli;
|
||||
uint32 num_users;
|
||||
};
|
||||
|
||||
static struct cli_use **clis = NULL;
|
||||
uint32 num_clis = 0;
|
||||
|
||||
/****************************************************************************
|
||||
terminate client connection
|
||||
****************************************************************************/
|
||||
static void cli_use_free(struct cli_use *cli)
|
||||
{
|
||||
if (cli->cli != NULL)
|
||||
{
|
||||
if (cli->cli->initialised)
|
||||
{
|
||||
cli_ulogoff(cli->cli);
|
||||
cli_shutdown(cli->cli);
|
||||
}
|
||||
free(cli->cli);
|
||||
}
|
||||
|
||||
free(cli);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
free a client array
|
||||
****************************************************************************/
|
||||
static void free_cli_array(uint32 num_entries, struct cli_use **entries)
|
||||
{
|
||||
void(*fn)(void*) = (void(*)(void*))&cli_use_free;
|
||||
free_void_array(num_entries, (void**)entries, *fn);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
add a client state to the array
|
||||
****************************************************************************/
|
||||
static struct cli_use* add_cli_to_array(uint32 *len,
|
||||
struct cli_use ***array,
|
||||
struct cli_use *cli)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_clis; i++)
|
||||
{
|
||||
if (clis[i] == NULL)
|
||||
{
|
||||
clis[i] = cli;
|
||||
return cli;
|
||||
}
|
||||
}
|
||||
|
||||
return (struct cli_use*)add_item_to_array(len,
|
||||
(void***)array, (void*)cli);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
initiate client array
|
||||
****************************************************************************/
|
||||
void init_cli_use(void)
|
||||
{
|
||||
clis = NULL;
|
||||
num_clis = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
terminate client array
|
||||
****************************************************************************/
|
||||
void free_cli_use(void)
|
||||
{
|
||||
free_cli_array(num_clis, clis);
|
||||
init_cli_use();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
find client state. server name, user name, domain name and password must all
|
||||
match.
|
||||
****************************************************************************/
|
||||
static struct cli_use *cli_find(const char* srv_name,
|
||||
const struct ntuser_creds *usr_creds,
|
||||
BOOL reuse)
|
||||
{
|
||||
int i;
|
||||
const char *sv_name = srv_name;
|
||||
struct ntuser_creds null_usr;
|
||||
|
||||
copy_nt_creds(&null_usr, usr_creds);
|
||||
usr_creds = &null_usr;
|
||||
|
||||
if (strnequal("\\\\", sv_name, 2))
|
||||
{
|
||||
sv_name = &sv_name[2];
|
||||
}
|
||||
|
||||
DEBUG(10,("cli_find: %s %s %s\n",
|
||||
srv_name,
|
||||
usr_creds->user_name,
|
||||
usr_creds->domain));
|
||||
|
||||
for (i = 0; i < num_clis; i++)
|
||||
{
|
||||
char *cli_name = NULL;
|
||||
struct cli_use *c = clis[i];
|
||||
|
||||
if (c == NULL) continue;
|
||||
|
||||
cli_name = c->cli->desthost;
|
||||
|
||||
DEBUG(10,("cli_find[%d]: %s %s %s\n",
|
||||
i, cli_name,
|
||||
c->cli->usr.user_name,
|
||||
c->cli->usr.domain));
|
||||
|
||||
if (strnequal("\\\\", cli_name, 2))
|
||||
{
|
||||
cli_name = &cli_name[2];
|
||||
}
|
||||
|
||||
if (!strequal(cli_name, sv_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!strequal(usr_creds->user_name, c->cli->usr.user_name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!reuse &&
|
||||
!pwd_compare(&usr_creds->pwd, &c->cli->usr.pwd))
|
||||
{
|
||||
DEBUG(100,("password doesn't match\n"));
|
||||
continue;
|
||||
}
|
||||
if (usr_creds->domain[0] == 0)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
if (strequal(usr_creds->domain, c->cli->usr.domain))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
create a new client state from user credentials
|
||||
****************************************************************************/
|
||||
static struct cli_use *cli_use_get(const char* srv_name,
|
||||
const struct ntuser_creds *usr_creds)
|
||||
{
|
||||
struct cli_use *cli = (struct cli_use*)malloc(sizeof(*cli));
|
||||
|
||||
if (cli == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(cli, 0, sizeof(*cli));
|
||||
|
||||
cli->cli = cli_initialise(NULL);
|
||||
|
||||
if (cli->cli == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cli_init_creds(cli->cli, usr_creds);
|
||||
|
||||
return cli;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
init client state
|
||||
****************************************************************************/
|
||||
struct cli_state *cli_net_use_add(const char* srv_name,
|
||||
const struct ntuser_creds *usr_creds,
|
||||
BOOL redir,
|
||||
BOOL reuse)
|
||||
{
|
||||
struct nmb_name calling;
|
||||
struct nmb_name called;
|
||||
struct in_addr *dest_ip = NULL;
|
||||
fstring dest_host;
|
||||
struct in_addr ip;
|
||||
|
||||
struct cli_use *cli = cli_find(srv_name, usr_creds, reuse);
|
||||
|
||||
if (cli != NULL)
|
||||
{
|
||||
cli->num_users++;
|
||||
return cli->cli;
|
||||
}
|
||||
|
||||
/* reuse an existing connection requested, and one was not found */
|
||||
if (usr_creds != NULL && reuse && !redir)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate
|
||||
*/
|
||||
|
||||
cli = cli_use_get(srv_name, usr_creds);
|
||||
cli->cli->redirect = redir;
|
||||
|
||||
if (resolve_srv_name(srv_name, dest_host, &ip))
|
||||
{
|
||||
dest_ip = &ip;
|
||||
}
|
||||
else
|
||||
{
|
||||
cli_use_free(cli);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
make_nmb_name(&called , dns_to_netbios_name(dest_host ), 32, scope);
|
||||
make_nmb_name(&calling, dns_to_netbios_name(global_myname), 0, scope);
|
||||
|
||||
/*
|
||||
* connect
|
||||
*/
|
||||
|
||||
if (!cli_establish_connection(cli->cli,
|
||||
dest_host, dest_ip,
|
||||
&calling, &called,
|
||||
"IPC$", "IPC",
|
||||
False, True))
|
||||
{
|
||||
DEBUG(0,("cli_net_use_add: connection failed\n"));
|
||||
cli->cli = NULL;
|
||||
cli_use_free(cli);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cli->cli->ntlmssp_cli_flgs = 0x0;
|
||||
|
||||
add_cli_to_array(&num_clis, &clis, cli);
|
||||
cli->num_users++;
|
||||
|
||||
return cli->cli;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
delete a client state
|
||||
****************************************************************************/
|
||||
BOOL cli_net_use_del(const char* srv_name,
|
||||
const struct ntuser_creds *usr_creds,
|
||||
BOOL force_close,
|
||||
BOOL *connection_closed)
|
||||
{
|
||||
int i;
|
||||
const char *sv_name = srv_name;
|
||||
|
||||
DEBUG(10,("cli_net_use_del: %s. force close: %s\n",
|
||||
srv_name, BOOLSTR(force_close)));
|
||||
|
||||
if (strnequal("\\\\", sv_name, 2))
|
||||
{
|
||||
sv_name = &sv_name[2];
|
||||
}
|
||||
|
||||
if (connection_closed != NULL)
|
||||
{
|
||||
*connection_closed = False;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_clis; i++)
|
||||
{
|
||||
char *cli_name = NULL;
|
||||
|
||||
if (clis[i] == NULL) continue;
|
||||
if (clis[i]->cli == NULL) continue;
|
||||
|
||||
cli_name = clis[i]->cli->desthost;
|
||||
if (strnequal("\\\\", cli_name, 2))
|
||||
{
|
||||
cli_name = &cli_name[2];
|
||||
}
|
||||
|
||||
if (!strequal(cli_name, sv_name)) continue;
|
||||
|
||||
if (strequal(usr_creds->user_name,
|
||||
clis[i]->cli->usr.user_name) &&
|
||||
strequal(usr_creds->domain,
|
||||
clis[i]->cli->usr.domain))
|
||||
{
|
||||
/* decrement number of users */
|
||||
clis[i]->num_users--;
|
||||
|
||||
DEBUG(10,("idx: %i num_users now: %d\n",
|
||||
i, clis[i]->num_users));
|
||||
|
||||
if (force_close || clis[i]->num_users == 0)
|
||||
{
|
||||
cli_use_free(clis[i]);
|
||||
clis[i] = NULL;
|
||||
if (connection_closed != NULL)
|
||||
{
|
||||
*connection_closed = True;
|
||||
}
|
||||
}
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
enumerate client states
|
||||
****************************************************************************/
|
||||
void cli_net_use_enum(uint32 *num_cons, struct use_info ***use)
|
||||
{
|
||||
int i;
|
||||
|
||||
*num_cons = 0;
|
||||
*use = NULL;
|
||||
|
||||
for (i = 0; i < num_clis; i++)
|
||||
{
|
||||
struct use_info item;
|
||||
|
||||
ZERO_STRUCT(item);
|
||||
|
||||
if (clis[i] == NULL) continue;
|
||||
|
||||
item.connected = clis[i]->cli != NULL ? True : False;
|
||||
|
||||
if (item.connected)
|
||||
{
|
||||
item.srv_name = clis[i]->cli->desthost;
|
||||
item.user_name = clis[i]->cli->usr.user_name;
|
||||
item.domain = clis[i]->cli->usr.domain;
|
||||
}
|
||||
|
||||
add_use_info_to_array(num_cons, use, &item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
wait for keyboard activity, swallowing network packets on all client states.
|
||||
****************************************************************************/
|
||||
void cli_use_wait_keyboard(void)
|
||||
{
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int i;
|
||||
int maxfd = fileno(stdin);
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fileno(stdin),&fds);
|
||||
for (i = 0; i < num_clis; i++)
|
||||
{
|
||||
if (clis[i] != NULL && clis[i]->cli != NULL)
|
||||
{
|
||||
int fd = clis[i]->cli->fd;
|
||||
FD_SET(fd,&fds);
|
||||
maxfd = MAX(fd, maxfd);
|
||||
}
|
||||
}
|
||||
|
||||
timeout.tv_sec = 20;
|
||||
timeout.tv_usec = 0;
|
||||
sys_select(maxfd+1,NULL, &fds,&timeout);
|
||||
|
||||
if (FD_ISSET(fileno(stdin),&fds))
|
||||
return;
|
||||
|
||||
/* We deliberately use receive_smb instead of
|
||||
client_receive_smb as we want to receive
|
||||
session keepalives and then drop them here.
|
||||
*/
|
||||
for (i = 0; i < num_clis; i++)
|
||||
{
|
||||
int fd = clis[i]->cli->fd;
|
||||
if (FD_ISSET(fd,&fds))
|
||||
receive_smb(fd,clis[i]->cli->inbuf,0);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 1.9.
|
||||
NT Domain Authentication SMB / MSRPC client
|
||||
Copyright (C) Andrew Tridgell 1994-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
|
||||
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 "nterr.h"
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
#define DEBUG_TESTING
|
||||
|
||||
/****************************************************************************
|
||||
nt lsa query secret
|
||||
****************************************************************************/
|
||||
BOOL msrpc_lsa_query_secret(const char* srv_name,
|
||||
const char* secret_name,
|
||||
STRING2 *secret,
|
||||
NTTIME *last_update)
|
||||
{
|
||||
BOOL res = True;
|
||||
BOOL res1;
|
||||
BOOL res2;
|
||||
|
||||
POLICY_HND pol_sec;
|
||||
POLICY_HND lsa_pol;
|
||||
|
||||
/* lookup domain controller; receive a policy handle */
|
||||
res = res ? lsa_open_policy2( srv_name,
|
||||
&lsa_pol, False) : False;
|
||||
|
||||
/* lookup domain controller; receive a policy handle */
|
||||
res1 = res ? lsa_open_secret( &lsa_pol,
|
||||
secret_name, 0x02000000, &pol_sec) : False;
|
||||
|
||||
res2 = res1 ? lsa_query_secret(&pol_sec, secret, last_update) : False;
|
||||
|
||||
res1 = res1 ? lsa_close(&pol_sec) : False;
|
||||
|
||||
res = res ? lsa_close(&lsa_pol) : False;
|
||||
|
||||
return res2;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,299 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/Netbios implementation.
|
||||
* Version 2.1.
|
||||
* RPC parsing routines: scheduler service
|
||||
* Copyright (C) Matthew Chapman 1999,
|
||||
* Copyright (C) Luke Kenneth Casson Leighton 1996-1999,
|
||||
* Copyright (C) Andrew Tridgell 1992-1999.
|
||||
*
|
||||
* 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;
|
||||
|
||||
/*******************************************************************
|
||||
make_at_q_add_job
|
||||
********************************************************************/
|
||||
BOOL make_at_q_add_job(AT_Q_ADD_JOB *q_a, char *server,
|
||||
AT_JOB_INFO *info, char *command)
|
||||
{
|
||||
DEBUG(5,("make_at_q_add_job\n"));
|
||||
|
||||
make_buf_unistr2(&(q_a->uni_srv_name), &(q_a->ptr_srv_name), server);
|
||||
memcpy(&(q_a->info), info, sizeof(q_a->info));
|
||||
make_unistr2(&(q_a->command), command, strlen(command)+1);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_JOB_INFO structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_job_info(char *desc, AT_JOB_INFO *info, prs_struct *ps, int depth)
|
||||
{
|
||||
if (info == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_io_job_info");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("time", ps, depth, &(info->time));
|
||||
prs_uint32("monthdays", ps, depth, &(info->monthdays));
|
||||
prs_uint8("weekdays", ps, depth, &(info->weekdays));
|
||||
prs_uint8("flags", ps, depth, &(info->flags));
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("ptr_command", ps, depth, &(info->ptr_command));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_Q_ADD_JOB structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_q_add_job(char *desc, AT_Q_ADD_JOB *q_a, prs_struct *ps, int depth)
|
||||
{
|
||||
if (q_a == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_q_add_job");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("ptr_srv_name", ps, depth, &(q_a->ptr_srv_name));
|
||||
smb_io_unistr2("", &(q_a->uni_srv_name), q_a->ptr_srv_name, ps, depth);
|
||||
at_io_job_info("", &(q_a->info), ps, depth);
|
||||
smb_io_unistr2("", &(q_a->command), q_a->info.ptr_command, ps, depth);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_R_ADD_JOB structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_r_add_job(char *desc, AT_R_ADD_JOB *r_a, prs_struct *ps, int depth)
|
||||
{
|
||||
if (r_a == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_r_add_job");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("jobid", ps, depth, &(r_a->jobid));
|
||||
prs_uint32("status", ps, depth, &(r_a->status));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
make_at_q_del_job
|
||||
********************************************************************/
|
||||
BOOL make_at_q_del_job(AT_Q_DEL_JOB *q_a, char *server, uint32 min_jobid,
|
||||
uint32 max_jobid)
|
||||
{
|
||||
DEBUG(5,("make_at_q_del_job\n"));
|
||||
|
||||
make_buf_unistr2(&(q_a->uni_srv_name), &(q_a->ptr_srv_name), server);
|
||||
q_a->min_jobid = min_jobid;
|
||||
q_a->max_jobid = max_jobid;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_Q_DEL_JOB structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_q_del_job(char *desc, AT_Q_DEL_JOB *q_d, prs_struct *ps, int depth)
|
||||
{
|
||||
if (q_d == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_q_del_job");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
|
||||
prs_uint32("ptr_srv_name", ps, depth, &(q_d->ptr_srv_name));
|
||||
smb_io_unistr2("", &(q_d->uni_srv_name), q_d->ptr_srv_name, ps, depth);
|
||||
prs_align(ps);
|
||||
prs_uint32("min_jobid", ps, depth, &(q_d->min_jobid));
|
||||
prs_uint32("max_jobid", ps, depth, &(q_d->max_jobid));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_R_DEL_JOB structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_r_del_job(char *desc, AT_R_DEL_JOB *r_d, prs_struct *ps, int depth)
|
||||
{
|
||||
if (r_d == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_r_del_job");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("status", ps, depth, &(r_d->status));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
make_at_q_enum_jobs
|
||||
********************************************************************/
|
||||
BOOL make_at_q_enum_jobs(AT_Q_ENUM_JOBS *q_e, char *server)
|
||||
{
|
||||
DEBUG(5,("make_at_q_enum_jobs\n"));
|
||||
|
||||
make_buf_unistr2(&(q_e->uni_srv_name), &(q_e->ptr_srv_name), server);
|
||||
q_e->unknown0 = 0;
|
||||
q_e->unknown1 = 0;
|
||||
q_e->max_len = 0xffff;
|
||||
q_e->ptr_resume = 1;
|
||||
q_e->hnd_resume = 0;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_Q_ENUM_JOBS structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_q_enum_jobs(char *desc, AT_Q_ENUM_JOBS *q_e, prs_struct *ps, int depth)
|
||||
{
|
||||
if (q_e == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_q_enum_jobs");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("ptr_srv_name", ps, depth, &(q_e->ptr_srv_name));
|
||||
smb_io_unistr2("", &(q_e->uni_srv_name), q_e->ptr_srv_name, ps, depth);
|
||||
prs_align(ps);
|
||||
prs_uint32("unknown0", ps, depth, &(q_e->unknown0));
|
||||
prs_uint32("unknown1", ps, depth, &(q_e->unknown1));
|
||||
prs_uint32("max_len" , ps, depth, &(q_e->max_len ));
|
||||
|
||||
prs_uint32("ptr_resume", ps, depth, &(q_e->ptr_resume));
|
||||
prs_uint32("hnd_resume", ps, depth, &(q_e->hnd_resume));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_R_ENUM_JOBS structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_r_enum_jobs(char *desc, AT_R_ENUM_JOBS *r_e, prs_struct *ps, int depth)
|
||||
{
|
||||
if (r_e == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_r_enum_jobs");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("num_entries", ps, depth, &(r_e->num_entries));
|
||||
prs_uint32("ptr_entries", ps, depth, &(r_e->ptr_entries));
|
||||
|
||||
if (r_e->ptr_entries != 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
prs_uint32("num_entries2", ps, depth, &(r_e->num_entries2));
|
||||
if (r_e->num_entries2 != r_e->num_entries)
|
||||
{
|
||||
/* RPC fault */
|
||||
return False;
|
||||
}
|
||||
|
||||
SMB_ASSERT_ARRAY(r_e->info, r_e->num_entries2);
|
||||
|
||||
for (i = 0; i < r_e->num_entries2; i++)
|
||||
{
|
||||
prs_uint32("jobid", ps, depth, &(r_e->info[i].jobid));
|
||||
at_io_job_info("", &(r_e->info[i].info), ps, depth);
|
||||
}
|
||||
|
||||
for (i = 0; i < r_e->num_entries2; i++)
|
||||
{
|
||||
smb_io_unistr2("", &(r_e->command[i]),
|
||||
r_e->info[i].info.ptr_command, ps, depth);
|
||||
}
|
||||
}
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("total_entries", ps, depth, &(r_e->total_entries));
|
||||
prs_uint32("ptr_resume" , ps, depth, &(r_e->ptr_resume ));
|
||||
prs_uint32("hnd_resume" , ps, depth, &(r_e->hnd_resume ));
|
||||
|
||||
prs_uint32("status", ps, depth, &(r_e->status));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
make_at_q_query_job
|
||||
********************************************************************/
|
||||
BOOL make_at_q_query_job(AT_Q_QUERY_JOB *q_q, char *server, uint32 jobid)
|
||||
{
|
||||
DEBUG(5,("make_at_q_query_job\n"));
|
||||
|
||||
make_buf_unistr2(&(q_q->uni_srv_name), &(q_q->ptr_srv_name), server);
|
||||
q_q->jobid = jobid;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_Q_QUERY_JOB structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_q_query_job(char *desc, AT_Q_QUERY_JOB *q_q, prs_struct *ps, int depth)
|
||||
{
|
||||
if (q_q == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_q_query_job");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("ptr_srv_name", ps, depth, &(q_q->ptr_srv_name));
|
||||
smb_io_unistr2("", &(q_q->uni_srv_name), q_q->ptr_srv_name, ps, depth);
|
||||
prs_align(ps);
|
||||
prs_uint32("jobid", ps, depth, &(q_q->jobid));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
reads or writes a AT_R_QUERY_JOB structure.
|
||||
********************************************************************/
|
||||
BOOL at_io_r_query_job(char *desc, AT_R_QUERY_JOB *r_q, prs_struct *ps, int depth)
|
||||
{
|
||||
if (r_q == NULL) return False;
|
||||
|
||||
prs_debug(ps, depth, desc, "at_r_query_job");
|
||||
depth++;
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("ptr_info", ps, depth, &(r_q->ptr_info));
|
||||
if (r_q->ptr_info != 0)
|
||||
{
|
||||
at_io_job_info("", &(r_q->info), ps, depth);
|
||||
smb_io_unistr2("", &(r_q->command), r_q->info.ptr_command, ps, depth);
|
||||
}
|
||||
|
||||
prs_align(ps);
|
||||
prs_uint32("status", ps, depth, &(r_q->status));
|
||||
|
||||
return True;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user