diff options
author | Andrew Tridgell <tridge@samba.org> | 1999-12-13 13:35:20 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1999-12-13 13:35:20 +0000 |
commit | d7b208786590b5a28618590172b8d523627dda09 (patch) | |
tree | e011be5c2c2cbb61c2011bce741613556fcf116a | |
parent | 453a822a76780063dff23526c35408866d0c0154 (diff) | |
download | samba-d7b208786590b5a28618590172b8d523627dda09.tar.gz |
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
137 files changed, 0 insertions, 47004 deletions
diff --git a/docs/VFS.txt b/docs/VFS.txt deleted file mode 100644 index 455fde910ad..00000000000 --- a/docs/VFS.txt +++ /dev/null @@ -1,9 +0,0 @@ -!== -!== VFS.txt -!== -Contributor: Tim Potter -Updated: April 5, 1999 - -Subject: Implementing a virtual filesystem for Samba -=========================================================== - diff --git a/docs/htmldocs/LDAP.html b/docs/htmldocs/LDAP.html deleted file mode 100644 index 1cc8f8213fd..00000000000 --- a/docs/htmldocs/LDAP.html +++ /dev/null @@ -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> diff --git a/docs/htmldocs/debug2html.1.html b/docs/htmldocs/debug2html.1.html deleted file mode 100644 index d0d6373a3d1..00000000000 --- a/docs/htmldocs/debug2html.1.html +++ /dev/null @@ -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> diff --git a/docs/htmldocs/rpcclient.1.html b/docs/htmldocs/rpcclient.1.html deleted file mode 100644 index 6e5cf888661..00000000000 --- a/docs/htmldocs/rpcclient.1.html +++ /dev/null @@ -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> diff --git a/docs/manpages/debug2html.1 b/docs/manpages/debug2html.1 deleted file mode 100644 index a1071cfd883..00000000000 --- a/docs/manpages/debug2html.1 +++ /dev/null @@ -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\&. diff --git a/docs/manpages/rpcclient.1 b/docs/manpages/rpcclient.1 deleted file mode 100644 index 65517c84fb9..00000000000 --- a/docs/manpages/rpcclient.1 +++ /dev/null @@ -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 diff --git a/docs/textdocs/LDAP.txt b/docs/textdocs/LDAP.txt deleted file mode 100644 index 9c419b00f3b..00000000000 --- a/docs/textdocs/LDAP.txt +++ /dev/null @@ -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. diff --git a/docs/textdocs/README.smbmount b/docs/textdocs/README.smbmount deleted file mode 100644 index 0c9d9bbe50f..00000000000 --- a/docs/textdocs/README.smbmount +++ /dev/null @@ -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 diff --git a/docs/textdocs/rpcclient.1.txt b/docs/textdocs/rpcclient.1.txt deleted file mode 100644 index 78aaca02bcd..00000000000 --- a/docs/textdocs/rpcclient.1.txt +++ /dev/null @@ -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. diff --git a/docs/yodldocs/LDAP.yo b/docs/yodldocs/LDAP.yo deleted file mode 100644 index cf454904d33..00000000000 --- a/docs/yodldocs/LDAP.yo +++ /dev/null @@ -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. - diff --git a/docs/yodldocs/debug2html.1.yo b/docs/yodldocs/debug2html.1.yo deleted file mode 100644 index ffbd3c5b0e7..00000000000 --- a/docs/yodldocs/debug2html.1.yo +++ /dev/null @@ -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. diff --git a/docs/yodldocs/rpcclient.1.yo b/docs/yodldocs/rpcclient.1.yo deleted file mode 100644 index 88b21047422..00000000000 --- a/docs/yodldocs/rpcclient.1.yo +++ /dev/null @@ -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. - diff --git a/examples/autofs/mount-smb.doc b/examples/autofs/mount-smb.doc deleted file mode 100644 index 7eee74fce0d..00000000000 --- a/examples/autofs/mount-smb.doc +++ /dev/null @@ -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 - diff --git a/examples/autofs/mount.smb b/examples/autofs/mount.smb deleted file mode 100644 index 76f1a596e35..00000000000 --- a/examples/autofs/mount.smb +++ /dev/null @@ -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 - diff --git a/examples/rpcclient/README b/examples/rpcclient/README deleted file mode 100644 index bdff5821a75..00000000000 --- a/examples/rpcclient/README +++ /dev/null @@ -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. diff --git a/examples/rpcclient/ntsd.c b/examples/rpcclient/ntsd.c deleted file mode 100644 index 37976edaa5e..00000000000 --- a/examples/rpcclient/ntsd.c +++ /dev/null @@ -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"); -} diff --git a/packaging/Caldera/README b/packaging/Caldera/README deleted file mode 100644 index ec6806645c5..00000000000 --- a/packaging/Caldera/README +++ /dev/null @@ -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 - diff --git a/packaging/Caldera/findsmb b/packaging/Caldera/findsmb deleted file mode 100644 index 986c2481779..00000000000 --- a/packaging/Caldera/findsmb +++ /dev/null @@ -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"; - } -} - diff --git a/packaging/Caldera/makefile-path.patch b/packaging/Caldera/makefile-path.patch deleted file mode 100644 index 5fddb7cbfb4..00000000000 --- a/packaging/Caldera/makefile-path.patch +++ /dev/null @@ -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 diff --git a/packaging/Caldera/makerpms.sh.tmpl b/packaging/Caldera/makerpms.sh.tmpl deleted file mode 100644 index fa69370dff0..00000000000 --- a/packaging/Caldera/makerpms.sh.tmpl +++ /dev/null @@ -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 diff --git a/packaging/Caldera/samba.log b/packaging/Caldera/samba.log deleted file mode 100644 index c5f2a5b45bc..00000000000 --- a/packaging/Caldera/samba.log +++ /dev/null @@ -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 -} diff --git a/packaging/Caldera/samba.pamd b/packaging/Caldera/samba.pamd deleted file mode 100644 index f38e70184af..00000000000 --- a/packaging/Caldera/samba.pamd +++ /dev/null @@ -1,2 +0,0 @@ -auth required /lib/security/pam_pwdb.so nullok shadow -account required /lib/security/pam_pwdb.so diff --git a/packaging/Caldera/samba2.spec.tmpl b/packaging/Caldera/samba2.spec.tmpl deleted file mode 100644 index 84fe3dcd3b0..00000000000 --- a/packaging/Caldera/samba2.spec.tmpl +++ /dev/null @@ -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 diff --git a/packaging/Caldera/smb.conf b/packaging/Caldera/smb.conf deleted file mode 100644 index bd9a8e15bcc..00000000000 --- a/packaging/Caldera/smb.conf +++ /dev/null @@ -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 - - diff --git a/packaging/Caldera/smb.init b/packaging/Caldera/smb.init deleted file mode 100755 index 828c19b069d..00000000000 --- a/packaging/Caldera/smb.init +++ /dev/null @@ -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 - diff --git a/packaging/Caldera/smbadduser b/packaging/Caldera/smbadduser deleted file mode 100755 index 2f38bf28f1a..00000000000 --- a/packaging/Caldera/smbadduser +++ /dev/null @@ -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 diff --git a/packaging/Caldera/smbprint b/packaging/Caldera/smbprint deleted file mode 100755 index ec083eede62..00000000000 --- a/packaging/Caldera/smbprint +++ /dev/null @@ -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 diff --git a/packaging/Caldera/smbusers b/packaging/Caldera/smbusers deleted file mode 100644 index ae3389f53f8..00000000000 --- a/packaging/Caldera/smbusers +++ /dev/null @@ -1,3 +0,0 @@ -# Unix_name = SMB_name1 SMB_name2 ... -root = administrator admin -nobody = guest pcguest smbguest diff --git a/packaging/Caldera/smbw.patch b/packaging/Caldera/smbw.patch deleted file mode 100644 index 0abbfdf73f6..00000000000 --- a/packaging/Caldera/smbw.patch +++ /dev/null @@ -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 diff --git a/packaging/Solaris/pkg-specs/Packaging.script b/packaging/Solaris/pkg-specs/Packaging.script deleted file mode 100644 index 6f182c33e52..00000000000 --- a/packaging/Solaris/pkg-specs/Packaging.script +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -./mkprototype -pkgmk -o -d /tmp -b `pwd` -f ./prototype -cd /tmp -pkgtrans . samba.pkg samba diff --git a/packaging/Solaris/pkg-specs/mkprototype b/packaging/Solaris/pkg-specs/mkprototype deleted file mode 100644 index 5ca0746beea..00000000000 --- a/packaging/Solaris/pkg-specs/mkprototype +++ /dev/null @@ -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 - diff --git a/packaging/Solaris/pkg-specs/postinstall b/packaging/Solaris/pkg-specs/postinstall deleted file mode 100644 index 0fbe9da10b5..00000000000 --- a/packaging/Solaris/pkg-specs/postinstall +++ /dev/null @@ -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 - diff --git a/packaging/Solaris/pkg-specs/postremove b/packaging/Solaris/pkg-specs/postremove deleted file mode 100644 index 7f7a5c1f8e4..00000000000 --- a/packaging/Solaris/pkg-specs/postremove +++ /dev/null @@ -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 - diff --git a/source/browserd/browserd.c b/source/browserd/browserd.c deleted file mode 100644 index dde62721ead..00000000000 --- a/source/browserd/browserd.c +++ /dev/null @@ -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); -} diff --git a/source/client/clientutil.c b/source/client/clientutil.c deleted file mode 100644 index efa836dede5..00000000000 --- a/source/client/clientutil.c +++ /dev/null @@ -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)); -} - diff --git a/source/groupdb/aliasldap.c b/source/groupdb/aliasldap.c deleted file mode 100644 index 1e9a72a9d41..00000000000 --- a/source/groupdb/aliasldap.c +++ /dev/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 - diff --git a/source/groupdb/aliasunix.c b/source/groupdb/aliasunix.c deleted file mode 100644 index c53692f3282..00000000000 --- a/source/groupdb/aliasunix.c +++ /dev/null @@ -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 */ diff --git a/source/groupdb/builtindb.c b/source/groupdb/builtindb.c deleted file mode 100644 index 3b09b6225d8..00000000000 --- a/source/groupdb/builtindb.c +++ /dev/null @@ -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; -} diff --git a/source/groupdb/builtinldap.c b/source/groupdb/builtinldap.c deleted file mode 100644 index baac82f1bab..00000000000 --- a/source/groupdb/builtinldap.c +++ /dev/null @@ -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 - diff --git a/source/groupdb/builtinunix.c b/source/groupdb/builtinunix.c deleted file mode 100644 index 57421cc449b..00000000000 --- a/source/groupdb/builtinunix.c +++ /dev/null @@ -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 */ diff --git a/source/groupdb/groupldap.c b/source/groupdb/groupldap.c deleted file mode 100644 index d32332e1abf..00000000000 --- a/source/groupdb/groupldap.c +++ /dev/null @@ -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 - diff --git a/source/groupdb/groupunix.c b/source/groupdb/groupunix.c deleted file mode 100644 index 306e499858c..00000000000 --- a/source/groupdb/groupunix.c +++ /dev/null @@ -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 */ diff --git a/source/include/DesktopDB.h b/source/include/DesktopDB.h deleted file mode 100644 index c0efa2b4a46..00000000000 --- a/source/include/DesktopDB.h +++ /dev/null @@ -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; diff --git a/source/include/debug.h b/source/include/debug.h deleted file mode 100644 index df74da0b415..00000000000 --- a/source/include/debug.h +++ /dev/null @@ -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 diff --git a/source/include/dfs.h b/source/include/dfs.h deleted file mode 100644 index 1bf26e230b1..00000000000 --- a/source/include/dfs.h +++ /dev/null @@ -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; diff --git a/source/include/hmacmd5.h b/source/include/hmacmd5.h deleted file mode 100644 index adb52058a89..00000000000 --- a/source/include/hmacmd5.h +++ /dev/null @@ -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 */ diff --git a/source/include/md5.h b/source/include/md5.h deleted file mode 100644 index 070d8c307da..00000000000 --- a/source/include/md5.h +++ /dev/null @@ -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 */ diff --git a/source/include/nt_printing.h b/source/include/nt_printing.h deleted file mode 100644 index a575c01e496..00000000000 --- a/source/include/nt_printing.h +++ /dev/null @@ -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; - - diff --git a/source/include/rpc_atsvc.h b/source/include/rpc_atsvc.h deleted file mode 100644 index 2b983f438e5..00000000000 --- a/source/include/rpc_atsvc.h +++ /dev/null @@ -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 */ diff --git a/source/include/rpc_brs.h b/source/include/rpc_brs.h deleted file mode 100644 index 36d89ec151c..00000000000 --- a/source/include/rpc_brs.h +++ /dev/null @@ -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 */ - diff --git a/source/include/rpc_creds.h b/source/include/rpc_creds.h deleted file mode 100644 index c389c64d1d7..00000000000 --- a/source/include/rpc_creds.h +++ /dev/null @@ -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 */ - diff --git a/source/include/rpc_eventlog.h b/source/include/rpc_eventlog.h deleted file mode 100644 index 14e5570c9b6..00000000000 --- a/source/include/rpc_eventlog.h +++ /dev/null @@ -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 */ diff --git a/source/include/rpc_spoolss.h b/source/include/rpc_spoolss.h deleted file mode 100755 index 5143b389fc6..00000000000 --- a/source/include/rpc_spoolss.h +++ /dev/null @@ -1,1492 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1998 - Copyright (C) Luke Kenneth Casson Leighton 1996-1998 - Copyright (C) Jean Francois Micouleau 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 _RPC_SPOOLSS_H /* _RPC_SPOOLSS_H */ -#define _RPC_SPOOLSS_H - -#define INTEGER 1 -#define STRING 2 - -/* spoolss pipe: this are the calls which are not implemented ... -#define SPOOLSS_OPENPRINTER 0x01 -#define SPOOLSS_DELETEPRINTER 0x06 -#define SPOOLSS_GETPRINTERDRIVER 0x0b -#define SPOOLSS_DELETEPRINTERDRIVER 0x0d -#define SPOOLSS_ADDPRINTPROCESSOR 0x0e -#define SPOOLSS_GETPRINTPROCESSORDIRECTORY 0x10 -#define SPOOLSS_ABORTPRINTER 0x15 -#define SPOOLSS_READPRINTER 0x16 -#define SPOOLSS_WAITFORPRINTERCHANGE 0x1c -#define SPOOLSS_DELETEFORM 0x1f -#define SPOOLSS_GETFORM 0x20 -#define SPOOLSS_ADDPORT 0x25 -#define SPOOLSS_CONFIGUREPORT 0x26 -#define SPOOLSS_DELETEPORT 0x27 -#define SPOOLSS_CREATEPRINTERIC 0x28 -#define SPOOLSS_PLAYGDISCRIPTONPRINTERIC 0x29 -#define SPOOLSS_DELETEPRINTERIC 0x2a -#define SPOOLSS_ADDPRINTERCONNECTION 0x2b -#define SPOOLSS_DELETEPRINTERCONNECTION 0x2c -#define SPOOLSS_PRINTERMESSAGEBOX 0x2d -#define SPOOLSS_ADDMONITOR 0x2e -#define SPOOLSS_DELETEMONITOR 0x2f -#define SPOOLSS_DELETEPRINTPROCESSOR 0x30 -#define SPOOLSS_ADDPRINTPROVIDOR 0x31 -#define SPOOLSS_DELETEPRINTPROVIDOR 0x32 -#define SPOOLSS_RESETPRINTER 0x34 -#define SPOOLSS_FINDFIRSTPRINTERCHANGENOTIFICATION 0x36 -#define SPOOLSS_FINDNEXTPRINTERCHANGENOTIFICATION 0x37 -#define SPOOLSS_ROUTERFINDFIRSTPRINTERNOTIFICATIONOLD 0x39 -#define SPOOLSS_REPLYOPENPRINTER 0x3a -#define SPOOLSS_ROUTERREPLYPRINTER 0x3b -#define SPOOLSS_REPLYCLOSEPRINTER 0x3c -#define SPOOLSS_ADDPORTEX 0x3d -#define SPOOLSS_REMOTEFINDFIRSTPRINTERCHANGENOTIFICATION0x3e -#define SPOOLSS_SPOOLERINIT 0x3f -#define SPOOLSS_RESETPRINTEREX 0x40 -#define SPOOLSS_ROUTERREFRESHPRINTERCHANGENOTIFICATION 0x42 -*/ - -/* those are implemented */ - -#define SPOOLSS_ENUMPRINTERS 0x00 -#define SPOOLSS_SETJOB 0x02 -#define SPOOLSS_GETJOB 0x03 -#define SPOOLSS_ENUMJOBS 0x04 -#define SPOOLSS_ADDPRINTER 0x05 -#define SPOOLSS_SETPRINTER 0x07 -#define SPOOLSS_GETPRINTER 0x08 -#define SPOOLSS_ADDPRINTERDRIVER 0x09 -#define SPOOLSS_ENUMPRINTERDRIVERS 0x0a -#define SPOOLSS_GETPRINTERDRIVERDIRECTORY 0x0c -#define SPOOLSS_ENUMPRINTPROCESSORS 0x0f -#define SPOOLSS_STARTDOCPRINTER 0x11 -#define SPOOLSS_STARTPAGEPRINTER 0x12 -#define SPOOLSS_WRITEPRINTER 0x13 -#define SPOOLSS_ENDPAGEPRINTER 0x14 -#define SPOOLSS_ENDDOCPRINTER 0x17 -#define SPOOLSS_ADDJOB 0x18 -#define SPOOLSS_SCHEDULEJOB 0x19 -#define SPOOLSS_GETPRINTERDATA 0x1a -#define SPOOLSS_SETPRINTERDATA 0x1b -#define SPOOLSS_CLOSEPRINTER 0x1d -#define SPOOLSS_ADDFORM 0x1e -#define SPOOLSS_SETFORM 0x21 -#define SPOOLSS_ENUMFORMS 0x22 -#define SPOOLSS_ENUMPORTS 0x23 -#define SPOOLSS_ENUMMONITORS 0x24 -#define SPOOLSS_ENUMPRINTPROCESSORDATATYPES 0x33 -#define SPOOLSS_GETPRINTERDRIVER2 0x35 -/* find close printer notification */ -#define SPOOLSS_FCPN 0x38 -/* remote find first printer change notifyEx */ -#define SPOOLSS_RFFPCNEX 0x41 -/* remote find next printer change notifyEx */ -#define SPOOLSS_RFNPCNEX 0x43 -#define SPOOLSS_OPENPRINTEREX 0x45 -#define SPOOLSS_ADDPRINTEREX 0x46 -#define SPOOLSS_ENUMPRINTERDATA 0x48 - - -#define SERVER_ACCESS_ADMINISTER 0x00000001 -#define SERVER_ACCESS_ENUMERATE 0x00000002 - -#define PRINTER_ACCESS_ADMINISTER 0x00000004 -#define PRINTER_ACCESS_USE 0x00000008 - -#define PRINTER_CONTROL_UNPAUSE 0x00000000 -#define PRINTER_CONTROL_PAUSE 0x00000001 -#define PRINTER_CONTROL_RESUME 0x00000002 -#define PRINTER_CONTROL_PURGE 0x00000003 -#define PRINTER_CONTROL_SET_STATUS 0x00000004 - -#define PRINTER_STATUS_PAUSED 0x00000001 -#define PRINTER_STATUS_ERROR 0x00000002 -#define PRINTER_STATUS_PENDING_DELETION 0x00000004 -#define PRINTER_STATUS_PAPER_JAM 0x00000008 - -#define PRINTER_STATUS_PAPER_OUT 0x00000010 -#define PRINTER_STATUS_MANUAL_FEED 0x00000020 -#define PRINTER_STATUS_PAPER_PROBLEM 0x00000040 -#define PRINTER_STATUS_OFFLINE 0x00000080 - -#define PRINTER_STATUS_IO_ACTIVE 0x00000100 -#define PRINTER_STATUS_BUSY 0x00000200 -#define PRINTER_STATUS_PRINTING 0x00000400 -#define PRINTER_STATUS_OUTPUT_BIN_FULL 0x00000800 - -#define PRINTER_STATUS_NOT_AVAILABLE 0x00001000 -#define PRINTER_STATUS_WAITING 0x00002000 -#define PRINTER_STATUS_PROCESSING 0x00004000 -#define PRINTER_STATUS_INITIALIZING 0x00008000 - -#define PRINTER_STATUS_WARMING_UP 0x00010000 -#define PRINTER_STATUS_TONER_LOW 0x00020000 -#define PRINTER_STATUS_NO_TONER 0x00040000 -#define PRINTER_STATUS_PAGE_PUNT 0x00080000 - -#define PRINTER_STATUS_USER_INTERVENTION 0x00100000 -#define PRINTER_STATUS_OUT_OF_MEMORY 0x00200000 -#define PRINTER_STATUS_DOOR_OPEN 0x00400000 -#define PRINTER_STATUS_SERVER_UNKNOWN 0x00800000 - -#define PRINTER_STATUS_POWER_SAVE 0x01000000 - -#define JOB_ACCESS_ADMINISTER 0x00000010 - -#define STANDARD_RIGHTS_READ 0x00020000 -#define STANDARD_RIGHTS_WRITE STANDARD_RIGHTS_READ -#define STANDARD_RIGHTS_EXECUTE STANDARD_RIGHTS_READ -#define STANDARD_RIGHTS_REQUIRED 0x000F0000 - -/* Access rights for print servers */ -#define SERVER_ALL_ACCESS STANDARD_RIGHTS_REQUIRED|SERVER_ACCESS_ADMINISTER|SERVER_ACCESS_ENUMERATE -#define SERVER_READ STANDARD_RIGHTS_READ|SERVER_ACCESS_ENUMERATE -#define SERVER_WRITE STANDARD_RIGHTS_WRITE|SERVER_ACCESS_ADMINISTER|SERVER_ACCESS_ENUMERATE -#define SERVER_EXECUTE STANDARD_RIGHTS_EXECUTE|SERVER_ACCESS_ENUMERATE - -/* Access rights for printers */ -#define PRINTER_ALL_ACCESS STANDARD_RIGHTS_REQUIRED|PRINTER_ACCESS_ADMINISTER|PRINTER_ACCESS_USE -#define PRINTER_READ STANDARD_RIGHTS_READ|PRINTER_ACCESS_USE -#define PRINTER_WRITE STANDARD_RIGHTS_WRITE|PRINTER_ACCESS_USE -#define PRINTER_EXECUTE STANDARD_RIGHTS_EXECUTE|PRINTER_ACCESS_USE - -/* Access rights for jobs */ -#define JOB_ALL_ACCESS STANDARD_RIGHTS_REQUIRED|JOB_ACCESS_ADMINISTER -#define JOB_READ STANDARD_RIGHTS_READ|JOB_ACCESS_ADMINISTER -#define JOB_WRITE STANDARD_RIGHTS_WRITE|JOB_ACCESS_ADMINISTER -#define JOB_EXECUTE STANDARD_RIGHTS_EXECUTE|JOB_ACCESS_ADMINISTER - -#define POLICY_HND_SIZE 20 - -#define ONE_VALUE 01 -#define TWO_VALUE 02 -#define POINTER 03 - -#define PRINTER_NOTIFY_TYPE 0x00 -#define JOB_NOTIFY_TYPE 0x01 - -#define MAX_PRINTER_NOTIFY 26 - -#define PRINTER_NOTIFY_SERVER_NAME 0x00 -#define PRINTER_NOTIFY_PRINTER_NAME 0x01 -#define PRINTER_NOTIFY_SHARE_NAME 0x02 -#define PRINTER_NOTIFY_PORT_NAME 0x03 -#define PRINTER_NOTIFY_DRIVER_NAME 0x04 -#define PRINTER_NOTIFY_COMMENT 0x05 -#define PRINTER_NOTIFY_LOCATION 0x06 -#define PRINTER_NOTIFY_DEVMODE 0x07 -#define PRINTER_NOTIFY_SEPFILE 0x08 -#define PRINTER_NOTIFY_PRINT_PROCESSOR 0x09 -#define PRINTER_NOTIFY_PARAMETERS 0x0A -#define PRINTER_NOTIFY_DATATYPE 0x0B -#define PRINTER_NOTIFY_SECURITY_DESCRIPTOR 0x0C -#define PRINTER_NOTIFY_ATTRIBUTES 0x0D -#define PRINTER_NOTIFY_PRIORITY 0x0E -#define PRINTER_NOTIFY_DEFAULT_PRIORITY 0x0F -#define PRINTER_NOTIFY_START_TIME 0x10 -#define PRINTER_NOTIFY_UNTIL_TIME 0x11 -#define PRINTER_NOTIFY_STATUS 0x12 -#define PRINTER_NOTIFY_STATUS_STRING 0x13 -#define PRINTER_NOTIFY_CJOBS 0x14 -#define PRINTER_NOTIFY_AVERAGE_PPM 0x15 -#define PRINTER_NOTIFY_TOTAL_PAGES 0x16 -#define PRINTER_NOTIFY_PAGES_PRINTED 0x17 -#define PRINTER_NOTIFY_TOTAL_BYTES 0x18 -#define PRINTER_NOTIFY_BYTES_PRINTED 0x19 - -#define MAX_JOB_NOTIFY 24 - -#define JOB_NOTIFY_PRINTER_NAME 0x00 -#define JOB_NOTIFY_MACHINE_NAME 0x01 -#define JOB_NOTIFY_PORT_NAME 0x02 -#define JOB_NOTIFY_USER_NAME 0x03 -#define JOB_NOTIFY_NOTIFY_NAME 0x04 -#define JOB_NOTIFY_DATATYPE 0x05 -#define JOB_NOTIFY_PRINT_PROCESSOR 0x06 -#define JOB_NOTIFY_PARAMETERS 0x07 -#define JOB_NOTIFY_DRIVER_NAME 0x08 -#define JOB_NOTIFY_DEVMODE 0x09 -#define JOB_NOTIFY_STATUS 0x0A -#define JOB_NOTIFY_STATUS_STRING 0x0B -#define JOB_NOTIFY_SECURITY_DESCRIPTOR 0x0C -#define JOB_NOTIFY_DOCUMENT 0x0D -#define JOB_NOTIFY_PRIORITY 0x0E -#define JOB_NOTIFY_POSITION 0x0F -#define JOB_NOTIFY_SUBMITTED 0x10 -#define JOB_NOTIFY_START_TIME 0x11 -#define JOB_NOTIFY_UNTIL_TIME 0x12 -#define JOB_NOTIFY_TIME 0x13 -#define JOB_NOTIFY_TOTAL_PAGES 0x14 -#define JOB_NOTIFY_PAGES_PRINTED 0x15 -#define JOB_NOTIFY_TOTAL_BYTES 0x16 -#define JOB_NOTIFY_BYTES_PRINTED 0x17 - -/* - * The printer attributes. - * I #defined all of them (grabbed form MSDN) - * I'm only using: - * ( SHARED | NETWORK | RAW_ONLY ) - * RAW_ONLY _MUST_ be present otherwise NT will send an EMF file - */ - -#define PRINTER_ATTRIBUTE_QUEUED 0x00000001 -#define PRINTER_ATTRIBUTE_DIRECT 0x00000002 -#define PRINTER_ATTRIBUTE_DEFAULT 0x00000004 -#define PRINTER_ATTRIBUTE_SHARED 0x00000008 - -#define PRINTER_ATTRIBUTE_NETWORK 0x00000010 -#define PRINTER_ATTRIBUTE_HIDDEN 0x00000020 -#define PRINTER_ATTRIBUTE_LOCAL 0x00000040 -#define PRINTER_ATTRIBUTE_ENABLE_DEVQ 0x00000080 - -#define PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS 0x00000100 -#define PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST 0x00000200 -#define PRINTER_ATTRIBUTE_WORK_OFFLINE 0x00000400 -#define PRINTER_ATTRIBUTE_ENABLE_BIDI 0x00000800 - -#define PRINTER_ATTRIBUTE_RAW_ONLY 0x00001000 - -#define NO_PRIORITY 0 -#define MAX_PRIORITY 99 -#define MIN_PRIORITY 1 -#define DEF_PRIORITY 1 - -#define PRINTER_ENUM_DEFAULT 0x00000001 -#define PRINTER_ENUM_LOCAL 0x00000002 -#define PRINTER_ENUM_CONNECTIONS 0x00000004 -#define PRINTER_ENUM_FAVORITE 0x00000004 -#define PRINTER_ENUM_NAME 0x00000008 -#define PRINTER_ENUM_REMOTE 0x00000010 -#define PRINTER_ENUM_SHARED 0x00000020 -#define PRINTER_ENUM_NETWORK 0x00000040 - -#define PRINTER_ENUM_EXPAND 0x00004000 -#define PRINTER_ENUM_CONTAINER 0x00008000 - -#define PRINTER_ENUM_ICONMASK 0x00ff0000 -#define PRINTER_ENUM_ICON1 0x00010000 -#define PRINTER_ENUM_ICON2 0x00020000 -#define PRINTER_ENUM_ICON3 0x00040000 -#define PRINTER_ENUM_ICON4 0x00080000 -#define PRINTER_ENUM_ICON5 0x00100000 -#define PRINTER_ENUM_ICON6 0x00200000 -#define PRINTER_ENUM_ICON7 0x00400000 -#define PRINTER_ENUM_ICON8 0x00800000 - -typedef struct -{ - char name[100]; - uint32 flag; - uint32 width; - uint32 length; - uint32 left; - uint32 top; - uint32 right; - uint32 bottom; -} nt_forms_struct; - -typedef struct -{ - char name[100]; - char architecture[100]; - uint32 version; - char default_form[30]; - uint32 color_flag; - char driver[100]; - char datafile[100]; - char configfile[100]; - char helpfile[100]; - char monitor[100]; - char monitor_name[100]; - char **dependant; -} nt_drivers_struct; - -typedef struct devicemode -{ - UNISTR 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; - UNISTR 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; -} DEVICEMODE; - -typedef struct devicemode_container -{ - DEVICEMODE *dm; - uint8 *buffer; - uint32 size_of_buffer; -} DEVICEMODE_CONTAINER; - -#define ORIENTATION 0x00000001L -#define PAPERSIZE 0x00000002L -#define PAPERLENGTH 0x00000004L -#define PAPERWIDTH 0x00000008L -#define SCALE 0x00000010L -#define COPIES 0x00000100L -#define DEFAULTSOURCE 0x00000200L -#define PRINTQUALITY 0x00000400L -#define COLOR 0x00000800L -#define DUPLEX 0x00001000L -#define YRESOLUTION 0x00002000L -#define TTOPTION 0x00004000L -#define COLLATE 0x00008000L -#define FORMNAME 0x00010000L -#define LOGPIXELS 0x00020000L -#define BITSPERPEL 0x00040000L -#define PELSWIDTH 0x00080000L -#define PELSHEIGHT 0x00100000L -#define DISPLAYFLAGS 0x00200000L -#define DISPLAYFREQUENCY 0x00400000L -#define PANNINGWIDTH 0x00800000L -#define PANNINGHEIGHT 0x01000000L - -#define ORIENT_PORTRAIT 1 -#define ORIENT_LANDSCAPE 2 - -#define PAPER_FIRST PAPER_LETTER -#define PAPER_LETTER 1 /* Letter 8 1/2 x 11 in */ -#define PAPER_LETTERSMALL 2 /* Letter Small 8 1/2 x 11 in */ -#define PAPER_TABLOID 3 /* Tabloid 11 x 17 in */ -#define PAPER_LEDGER 4 /* Ledger 17 x 11 in */ -#define PAPER_LEGAL 5 /* Legal 8 1/2 x 14 in */ -#define PAPER_STATEMENT 6 /* Statement 5 1/2 x 8 1/2 in */ -#define PAPER_EXECUTIVE 7 /* Executive 7 1/4 x 10 1/2 in */ -#define PAPER_A3 8 /* A3 297 x 420 mm */ -#define PAPER_A4 9 /* A4 210 x 297 mm */ -#define PAPER_A4SMALL 10 /* A4 Small 210 x 297 mm */ -#define PAPER_A5 11 /* A5 148 x 210 mm */ -#define PAPER_B4 12 /* B4 (JIS) 250 x 354 */ -#define PAPER_B5 13 /* B5 (JIS) 182 x 257 mm */ -#define PAPER_FOLIO 14 /* Folio 8 1/2 x 13 in */ -#define PAPER_QUARTO 15 /* Quarto 215 x 275 mm */ -#define PAPER_10X14 16 /* 10x14 in */ -#define PAPER_11X17 17 /* 11x17 in */ -#define PAPER_NOTE 18 /* Note 8 1/2 x 11 in */ -#define PAPER_ENV_9 19 /* Envelope #9 3 7/8 x 8 7/8 */ -#define PAPER_ENV_10 20 /* Envelope #10 4 1/8 x 9 1/2 */ -#define PAPER_ENV_11 21 /* Envelope #11 4 1/2 x 10 3/8 */ -#define PAPER_ENV_12 22 /* Envelope #12 4 \276 x 11 */ -#define PAPER_ENV_14 23 /* Envelope #14 5 x 11 1/2 */ -#define PAPER_CSHEET 24 /* C size sheet */ -#define PAPER_DSHEET 25 /* D size sheet */ -#define PAPER_ESHEET 26 /* E size sheet */ -#define PAPER_ENV_DL 27 /* Envelope DL 110 x 220mm */ -#define PAPER_ENV_C5 28 /* Envelope C5 162 x 229 mm */ -#define PAPER_ENV_C3 29 /* Envelope C3 324 x 458 mm */ -#define PAPER_ENV_C4 30 /* Envelope C4 229 x 324 mm */ -#define PAPER_ENV_C6 31 /* Envelope C6 114 x 162 mm */ -#define PAPER_ENV_C65 32 /* Envelope C65 114 x 229 mm */ -#define PAPER_ENV_B4 33 /* Envelope B4 250 x 353 mm */ -#define PAPER_ENV_B5 34 /* Envelope B5 176 x 250 mm */ -#define PAPER_ENV_B6 35 /* Envelope B6 176 x 125 mm */ -#define PAPER_ENV_ITALY 36 /* Envelope 110 x 230 mm */ -#define PAPER_ENV_MONARCH 37 /* Envelope Monarch 3.875 x 7.5 in */ -#define PAPER_ENV_PERSONAL 38 /* 6 3/4 Envelope 3 5/8 x 6 1/2 in */ -#define PAPER_FANFOLD_US 39 /* US Std Fanfold 14 7/8 x 11 in */ -#define PAPER_FANFOLD_STD_GERMAN 40 /* German Std Fanfold 8 1/2 x 12 in */ -#define PAPER_FANFOLD_LGL_GERMAN 41 /* German Legal Fanfold 8 1/2 x 13 in */ - -#define PAPER_LAST PAPER_FANFOLD_LGL_GERMAN -#define PAPER_USER 256 - -#define BIN_FIRST BIN_UPPER -#define BIN_UPPER 1 -#define BIN_ONLYONE 1 -#define BIN_LOWER 2 -#define BIN_MIDDLE 3 -#define BIN_MANUAL 4 -#define BIN_ENVELOPE 5 -#define BIN_ENVMANUAL 6 -#define BIN_AUTO 7 -#define BIN_TRACTOR 8 -#define BIN_SMALLFMT 9 -#define BIN_LARGEFMT 10 -#define BIN_LARGECAPACITY 11 -#define BIN_CASSETTE 14 -#define BIN_FORMSOURCE 15 -#define BIN_LAST BIN_FORMSOURCE - -#define BIN_USER 256 /* device specific bins start here */ - -#define RES_DRAFT (-1) -#define RES_LOW (-2) -#define RES_MEDIUM (-3) -#define RES_HIGH (-4) - -#define COLOR_MONOCHROME 1 -#define COLOR_COLOR 2 - -#define DUP_SIMPLEX 1 -#define DUP_VERTICAL 2 -#define DUP_HORIZONTAL 3 - -#define TT_BITMAP 1 /* print TT fonts as graphics */ -#define TT_DOWNLOAD 2 /* download TT fonts as soft fonts */ -#define TT_SUBDEV 3 /* substitute device fonts for TT fonts */ - -#define COLLATE_FALSE 0 -#define COLLATE_TRUE 1 - -typedef struct s_header_type -{ - uint32 type; - union - { - uint32 value; - UNISTR string; - } data; -} HEADER_TYPE; - -typedef struct s_buffer -{ - uint32 ptr; - uint32 size; - uint32 count; - uint8 *data; - HEADER_TYPE *header; -} BUFFER; - - -/* SPOOL_Q_OPEN_PRINTER_EX request to open a printer */ -typedef struct spool_q_open_printer_ex -{ - uint32 ptr; - UNISTR2 printername; - uint32 unknown0; - uint32 cbbuf; - uint32 devmod; - uint32 access_required; - uint32 unknown1; /* 0x0000 0001 */ - uint32 unknown2; /* 0x0000 0001 */ - uint32 unknown3; /* ??? pointer? */ - uint32 unknown4; /* 0x0000 001c */ - uint32 unknown5; /* ??? e.g 0xb94dd0 */ - uint32 unknown6; /* ??? pointer? */ - uint32 unknown7; /* 0x0000 0565 */ - uint32 unknown8; /* 0x0000 0002 */ - uint32 unknown9; /* 0x0000 0000 */ - uint32 unknown10; /* 0x0000 0000 */ - UNISTR2 station; - UNISTR2 username; - -} SPOOL_Q_OPEN_PRINTER_EX; - -/* SPOOL_Q_OPEN_PRINTER_EX reply to an open printer */ -typedef struct spool_r_open_printer_ex -{ - POLICY_HND handle; /* handle used along all transactions (20*uint8) */ - uint32 status; - -} SPOOL_R_OPEN_PRINTER_EX; - -typedef struct spool_q_getprinterdata -{ - POLICY_HND handle; - UNISTR2 valuename; - uint32 size; -} SPOOL_Q_GETPRINTERDATA; - -typedef struct spool_r_getprinterdata -{ - uint32 type; - uint32 size; - uint8 *data; - uint32 numeric_data; - uint32 needed; - uint32 status; -} SPOOL_R_GETPRINTERDATA; - -typedef struct spool_q_closeprinter -{ - POLICY_HND handle; -} SPOOL_Q_CLOSEPRINTER; - -typedef struct spool_r_closeprinter -{ - POLICY_HND handle; - uint32 status; -} SPOOL_R_CLOSEPRINTER; - -typedef struct spool_q_startpageprinter -{ - POLICY_HND handle; -} SPOOL_Q_STARTPAGEPRINTER; - -typedef struct spool_r_startpageprinter -{ - uint32 status; -} SPOOL_R_STARTPAGEPRINTER; - -typedef struct spool_q_endpageprinter -{ - POLICY_HND handle; -} SPOOL_Q_ENDPAGEPRINTER; - -typedef struct spool_r_endpageprinter -{ - uint32 status; -} SPOOL_R_ENDPAGEPRINTER; - -typedef struct spool_doc_info_1 -{ - uint32 p_docname; - uint32 p_outputfile; - uint32 p_datatype; - UNISTR2 docname; - UNISTR2 outputfile; - UNISTR2 datatype; -} DOC_INFO_1; - -typedef struct spool_doc_info -{ - uint32 switch_value; - DOC_INFO_1 doc_info_1; -} DOC_INFO; - -typedef struct spool_doc_info_container -{ - uint32 level; - DOC_INFO docinfo; -} DOC_INFO_CONTAINER; - -typedef struct spool_q_startdocprinter -{ - POLICY_HND handle; - DOC_INFO_CONTAINER doc_info_container; -} SPOOL_Q_STARTDOCPRINTER; - -typedef struct spool_r_startdocprinter -{ - uint32 jobid; - uint32 status; -} SPOOL_R_STARTDOCPRINTER; - -typedef struct spool_q_enddocprinter -{ - POLICY_HND handle; -} SPOOL_Q_ENDDOCPRINTER; - -typedef struct spool_r_enddocprinter -{ - uint32 status; -} SPOOL_R_ENDDOCPRINTER; - -typedef struct spool_q_writeprinter -{ - POLICY_HND handle; - uint32 buffer_size; - uint8 *buffer; - uint32 buffer_size2; -} SPOOL_Q_WRITEPRINTER; - -typedef struct spool_r_writeprinter -{ - uint32 buffer_written; - uint32 status; -} SPOOL_R_WRITEPRINTER; - -typedef struct spool_notify_option_type -{ - uint16 type; - uint16 reserved0; - uint32 reserved1; - uint32 reserved2; - uint32 count; - uint16 fields[16]; -} SPOOL_NOTIFY_OPTION_TYPE; - -typedef struct spool_notify_option -{ - uint32 version; - uint32 reserved; - uint32 count; - SPOOL_NOTIFY_OPTION_TYPE type[16]; /* totally arbitrary !!! */ -} SPOOL_NOTIFY_OPTION; - -typedef struct spool_notify_info_data -{ - uint16 type; - uint16 field; - uint32 reserved; - uint32 id; - union - { - uint32 value[2]; - struct - { - uint32 length; - uint16 string[1024]; - } data; - } notify_data; - uint32 size; - BOOL enc_type; -} SPOOL_NOTIFY_INFO_DATA; - -typedef struct spool_notify_info -{ - uint32 version; - uint32 flags; - uint32 count; - SPOOL_NOTIFY_INFO_DATA data[26*16]; - /* 26 differents data types */ - /* so size it for 16 printers at max */ - /* jfmxxxx: Have to make it dynamic !!!*/ -} SPOOL_NOTIFY_INFO; - -/* If the struct name looks obscure, yes it is ! */ -/* RemoteFindFirstPrinterChangeNotificationEx query struct */ -typedef struct spoolss_q_rffpcnex -{ - POLICY_HND handle; - uint32 flags; - uint32 options; - UNISTR2 localmachine; - uint32 printerlocal; - SPOOL_NOTIFY_OPTION option; -} SPOOL_Q_RFFPCNEX; - -typedef struct spool_r_rffpcnex -{ - uint32 status; -} SPOOL_R_RFFPCNEX; - -/* Remote Find Next Printer Change Notify Ex */ -typedef struct spool_q_rfnpcnex -{ - POLICY_HND handle; - uint32 change; - SPOOL_NOTIFY_OPTION option; -} SPOOL_Q_RFNPCNEX; - -typedef struct spool_r_rfnpcnex -{ - uint32 count; - SPOOL_NOTIFY_INFO info; -} SPOOL_R_RFNPCNEX; - -/* Find Close Printer Notify */ -typedef struct spool_q_fcpn -{ - POLICY_HND handle; -} SPOOL_Q_FCPN; - -typedef struct spool_r_fcpn -{ - uint32 status; -} SPOOL_R_FCPN; - - -typedef struct printer_info_0 -{ - UNISTR printername; - UNISTR servername; - uint32 cjobs; - uint32 attributes; - uint32 unknown0; - uint32 unknown1; - uint32 unknown2; - uint32 unknown3; - uint32 unknown4; - uint32 unknown5; - uint32 unknown6; - uint16 majorversion; - uint16 buildversion; - uint32 unknown7; - uint32 unknown8; - uint32 unknown9; - uint32 unknown10; - uint32 unknown11; - uint32 unknown12; - uint32 unknown13; - uint32 unknown14; - uint32 unknown15; - uint32 unknown16; - uint32 unknown17; - uint32 unknown18; - uint32 status; - uint32 unknown20; - uint32 unknown21; - uint16 unknown22; - uint32 unknown23; -} PRINTER_INFO_0; - -typedef struct printer_info_1 -{ - uint32 flags; - UNISTR description; - UNISTR name; - UNISTR comment; -} PRINTER_INFO_1; - -typedef struct printer_info_2 -{ - UNISTR servername; - UNISTR printername; - UNISTR sharename; - UNISTR portname; - UNISTR drivername; - UNISTR comment; - UNISTR location; - DEVICEMODE *devmode; - UNISTR sepfile; - UNISTR printprocessor; - UNISTR datatype; - UNISTR parameters; - /*SECURITY_DESCRIPTOR securitydescriptor;*/ - uint32 attributes; - uint32 priority; - uint32 defaultpriority; - uint32 starttime; - uint32 untiltime; - uint32 status; - uint32 cjobs; - uint32 averageppm; -} PRINTER_INFO_2; - -typedef struct spool_q_enumprinters -{ - uint32 flags; - UNISTR2 servername; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMPRINTERS; - -typedef struct spool_r_enumprinters -{ - uint32 offered; /* number of bytes offered */ - uint32 needed; /* bytes needed */ - uint32 returned; /* number of printers */ - uint32 status; - uint32 level; - UNISTR servername; - union { - PRINTER_INFO_1 **printers_1; - PRINTER_INFO_2 **printers_2; - void *info; - } printer; -} SPOOL_R_ENUMPRINTERS; - - -typedef struct spool_q_getprinter -{ - POLICY_HND handle; - uint32 level; - uint8* buffer; - uint32 offered; - -} SPOOL_Q_GETPRINTER; - -typedef struct spool_r_getprinter -{ - POLICY_HND handle; - uint32 level; - - uint32 offered; - uint32 needed; - uint32 status; - union { - PRINTER_INFO_0 *info0; - PRINTER_INFO_1 *info1; - PRINTER_INFO_2 *info2; - void *info; - } printer; -} SPOOL_R_GETPRINTER; - -struct s_notify_info_data_table -{ - uint16 type; - uint16 field; - char *name; - uint32 size; - void (*fn) (int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer); -}; - -typedef struct spool_q_getprinterdriver2 -{ - POLICY_HND handle; - UNISTR2 architecture; - uint32 level; - BUFFER buffer; - uint32 buf_size; - uint32 status; -} SPOOL_Q_GETPRINTERDRIVER2; - -typedef struct driver_info_1 -{ - UNISTR name; -} DRIVER_INFO_1; - -typedef struct driver_info_2 -{ - uint32 version; - UNISTR name; - UNISTR architecture; - UNISTR driverpath; - UNISTR datafile; - UNISTR configfile; -} DRIVER_INFO_2; - -typedef struct driver_info_3 -{ - uint32 version; - UNISTR name; - UNISTR architecture; - UNISTR driverpath; - UNISTR datafile; - UNISTR configfile; - UNISTR helpfile; - UNISTR **dependentfiles; - UNISTR monitorname; - UNISTR defaultdatatype; -} DRIVER_INFO_3; - -typedef struct spool_r_getprinterdriver2 -{ - uint32 needed; - uint32 offered; - uint32 returned; - uint32 status; - uint32 level; - union { - DRIVER_INFO_1 *info1; - DRIVER_INFO_2 *info2; - DRIVER_INFO_3 *info3; - } printer; -} SPOOL_R_GETPRINTERDRIVER2; - -typedef struct add_jobinfo_1 -{ - UNISTR path; - uint32 job_number; -} ADD_JOBINFO_1; - - -typedef struct spool_q_addjob -{ - POLICY_HND handle; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ADDJOB; - -typedef struct spool_r_addjob -{ - uint32 status; -} SPOOL_R_ADDJOB; - -/* - * I'm really wondering how many different time formats - * I will have to cope with - * - * JFM, 09/13/98 In a mad mood ;-( -*/ -typedef struct systemtime -{ - uint16 year; - uint16 month; - uint16 dayofweek; - uint16 day; - uint16 hour; - uint16 minute; - uint16 second; - uint16 milliseconds; -} SYSTEMTIME; - -typedef struct s_job_info_1 -{ - uint32 jobid; - UNISTR printername; - UNISTR machinename; - UNISTR username; - UNISTR document; - UNISTR datatype; - UNISTR text_status; - uint32 status; - uint32 priority; - uint32 position; - uint32 totalpages; - uint32 pagesprinted; - SYSTEMTIME submitted; -} JOB_INFO_1; - -typedef struct s_job_info_2 -{ - uint32 jobid; - UNISTR printername; - UNISTR machinename; - UNISTR username; - UNISTR document; - UNISTR notifyname; - UNISTR datatype; - UNISTR printprocessor; - UNISTR parameters; - UNISTR drivername; - DEVICEMODE *devmode; - UNISTR text_status; -/* SEC_DESC sec_desc;*/ - uint32 status; - uint32 priority; - uint32 position; - uint32 starttime; - uint32 untiltime; - uint32 totalpages; - uint32 size; - SYSTEMTIME submitted; - uint32 timeelapsed; - uint32 pagesprinted; -} JOB_INFO_2; - -typedef struct spool_q_enumjobs -{ - POLICY_HND handle; - uint32 firstjob; - uint32 numofjobs; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMJOBS; - -typedef struct spool_r_enumjobs -{ - uint32 level; - union { - JOB_INFO_1 **job_info_1; - JOB_INFO_2 **job_info_2; - void *info; - } job; - uint32 offered; - uint32 numofjobs; - uint32 status; -} SPOOL_R_ENUMJOBS; - -typedef struct spool_q_schedulejob -{ - POLICY_HND handle; - uint32 jobid; -} SPOOL_Q_SCHEDULEJOB; - -typedef struct spool_r_schedulejob -{ - uint32 status; -} SPOOL_R_SCHEDULEJOB; - -typedef struct s_port_info_1 -{ - UNISTR port_name; -} PORT_INFO_1; - -typedef struct s_port_info_2 -{ - UNISTR port_name; - UNISTR monitor_name; - UNISTR description; - uint32 port_type; - uint32 reserved; -} PORT_INFO_2; - -typedef struct spool_q_enumports -{ - UNISTR2 name; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMPORTS; - -typedef struct spool_r_enumports -{ - uint32 level; - union { - PORT_INFO_1 *port_info_1; - PORT_INFO_2 *port_info_2; - } port; - uint32 offered; - uint32 numofports; - uint32 status; -} SPOOL_R_ENUMPORTS; - -#define JOB_CONTROL_PAUSE 1 -#define JOB_CONTROL_RESUME 2 -#define JOB_CONTROL_CANCEL 3 -#define JOB_CONTROL_RESTART 4 -#define JOB_CONTROL_DELETE 5 - -typedef struct spool_q_setjob -{ - POLICY_HND handle; - uint32 jobid; - uint32 level; - union { - JOB_INFO_1 job_info_1; - JOB_INFO_2 job_info_2; - } job; - uint32 command; -} SPOOL_Q_SETJOB; - -typedef struct spool_r_setjob -{ - uint32 status; -} SPOOL_R_SETJOB; - -typedef struct spool_q_enumprinterdrivers -{ - UNISTR2 name; - UNISTR2 environment; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMPRINTERDRIVERS; - -typedef struct spool_r_enumprinterdrivers -{ - uint32 level; - union { - DRIVER_INFO_1 *driver_info_1; - DRIVER_INFO_2 *driver_info_2; - DRIVER_INFO_3 *driver_info_3; - } driver; - uint32 offered; - uint32 numofdrivers; - uint32 status; -} SPOOL_R_ENUMPRINTERDRIVERS; - -typedef struct spool_form_1 -{ - uint32 flag; - UNISTR name; - uint32 width; - uint32 length; - uint32 left; - uint32 top; - uint32 right; - uint32 bottom; -} FORM_1; - -typedef struct spool_q_enumforms -{ - POLICY_HND handle; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMFORMS; - -typedef struct spool_r_enumforms -{ - uint32 level; - FORM_1 *forms_1; - uint32 offered; - uint32 numofforms; - uint32 status; -} SPOOL_R_ENUMFORMS; - - -typedef struct spool_printer_info_level_2 -{ - uint32 servername_ptr; - uint32 printername_ptr; - uint32 sharename_ptr; - uint32 portname_ptr; - uint32 drivername_ptr; - uint32 comment_ptr; - uint32 location_ptr; - uint32 devmode_ptr; - uint32 sepfile_ptr; - uint32 printprocessor_ptr; - uint32 datatype_ptr; - uint32 parameters_ptr; - uint32 secdesc_ptr; - uint32 attributes; - uint32 priority; - uint32 default_priority; - uint32 starttime; - uint32 untiltime; - uint32 status; - uint32 cjobs; - uint32 averageppm; - UNISTR2 servername; - UNISTR2 printername; - UNISTR2 sharename; - UNISTR2 portname; - UNISTR2 drivername; - UNISTR2 comment; - UNISTR2 location; - UNISTR2 sepfile; - UNISTR2 printprocessor; - UNISTR2 datatype; - UNISTR2 parameters; - SEC_DESC_BUF *secdesc; -} SPOOL_PRINTER_INFO_LEVEL_2; - -typedef struct spool_printer_info_level -{ - SPOOL_PRINTER_INFO_LEVEL_2 *info_2; -} SPOOL_PRINTER_INFO_LEVEL; - -typedef struct spool_printer_driver_info_level_3 -{ - uint32 cversion; - uint32 name_ptr; - uint32 environment_ptr; - uint32 driverpath_ptr; - uint32 datafile_ptr; - uint32 configfile_ptr; - uint32 helpfile_ptr; - uint32 monitorname_ptr; - uint32 defaultdatatype_ptr; - uint32 dependentfilessize; - uint32 dependentfiles_ptr; - - UNISTR2 name; - UNISTR2 environment; - UNISTR2 driverpath; - UNISTR2 datafile; - UNISTR2 configfile; - UNISTR2 helpfile; - UNISTR2 monitorname; - UNISTR2 defaultdatatype; - BUFFER5 dependentfiles; - -} SPOOL_PRINTER_DRIVER_INFO_LEVEL_3; - -typedef struct spool_printer_driver_info_level -{ - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *info_3; -} SPOOL_PRINTER_DRIVER_INFO_LEVEL; - - -/* this struct is undocumented */ -/* thanks to the ddk ... */ -typedef struct spool_user_level_1 -{ - uint32 size; - uint32 client_name_ptr; - uint32 user_name_ptr; - uint32 build; - uint32 major; - uint32 minor; - uint32 processor; - UNISTR2 client_name; - UNISTR2 user_name; -} SPOOL_USER_LEVEL_1; - -typedef struct spool_user_level -{ - SPOOL_USER_LEVEL_1 *user_level_1; -} SPOOL_USER_LEVEL; - -typedef struct spool_q_setprinter -{ - POLICY_HND handle; - uint32 level; - SPOOL_PRINTER_INFO_LEVEL info; - - DEVICEMODE *devmode; - struct - { - uint32 size_of_buffer; - uint32 data; - } security; - - uint32 command; -} SPOOL_Q_SETPRINTER; - -typedef struct spool_r_setprinter -{ - uint32 status; -} SPOOL_R_SETPRINTER; - -typedef struct spool_q_addprinter -{ - UNISTR2 server_name; - uint32 level; - SPOOL_PRINTER_INFO_LEVEL info; - uint32 unk0; - uint32 unk1; - uint32 unk2; - uint32 unk3; - uint32 user_level; - SPOOL_USER_LEVEL user; -} SPOOL_Q_ADDPRINTER; - -typedef struct spool_r_addprinter -{ - uint32 status; -} SPOOL_R_ADDPRINTER; - -typedef struct spool_q_addprinterex -{ - UNISTR2 server_name; - uint32 level; - SPOOL_PRINTER_INFO_LEVEL info; - uint32 unk0; - uint32 unk1; - uint32 unk2; - uint32 unk3; - uint32 user_level; - SPOOL_USER_LEVEL user; -} SPOOL_Q_ADDPRINTEREX; - - -typedef struct spool_r_addprinterex -{ - POLICY_HND handle; - uint32 status; -} SPOOL_R_ADDPRINTEREX; - -typedef struct spool_q_addprinterdriver -{ - UNISTR2 server_name; - uint32 level; - SPOOL_PRINTER_DRIVER_INFO_LEVEL info; -} SPOOL_Q_ADDPRINTERDRIVER; - -typedef struct spool_r_addprinterdriver -{ - uint32 status; -} SPOOL_R_ADDPRINTERDRIVER; - -typedef struct spool_q_getprinterdriverdirectory -{ - UNISTR2 name; - UNISTR2 environment; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_GETPRINTERDRIVERDIR; - -typedef struct driver_directory_1 -{ - UNISTR name; -} DRIVER_DIRECTORY_1 ; - -typedef struct spool_r_getprinterdriverdirectory -{ - uint32 level; - union { - DRIVER_DIRECTORY_1 driver_info_1; - } driver; - uint32 offered; - uint32 status; -} SPOOL_R_GETPRINTERDRIVERDIR; - -typedef struct spool_q_enumprintprocessors -{ - UNISTR2 name; - UNISTR2 environment; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMPRINTPROCESSORS; - -typedef struct printprocessor_1 -{ - UNISTR name; -} PRINTPROCESSOR_1; - -typedef struct spool_r_enumprintprocessors -{ - uint32 level; - PRINTPROCESSOR_1 *info_1; - uint32 offered; - uint32 numofprintprocessors; - uint32 status; -} SPOOL_R_ENUMPRINTPROCESSORS; - -typedef struct spool_q_enumprintprocessordatatypes -{ - UNISTR2 name; - UNISTR2 printprocessor; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMPRINTPROCESSORDATATYPES; - -typedef struct ppdatatype_1 -{ - UNISTR name; -} PPDATATYPE_1; - -typedef struct spool_r_enumprintprocessordatatypes -{ - uint32 level; - PPDATATYPE_1 *info_1; - uint32 offered; - uint32 numofppdatatypes; - uint32 status; -} SPOOL_R_ENUMPRINTPROCESSORDATATYPES; - -typedef struct spool_q_enumprintmonitors -{ - UNISTR2 name; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_ENUMPRINTMONITORS; - -typedef struct printmonitor_1 -{ - UNISTR name; -} PRINTMONITOR_1; - -typedef struct spool_r_enumprintmonitors -{ - uint32 level; - PRINTMONITOR_1 *info_1; - uint32 offered; - uint32 numofprintmonitors; - uint32 status; -} SPOOL_R_ENUMPRINTMONITORS; - -typedef struct spool_q_enumprinterdata -{ - POLICY_HND handle; - uint32 index; - uint32 valuesize; - uint32 datasize; -} SPOOL_Q_ENUMPRINTERDATA; - -typedef struct spool_r_enumprinterdata -{ - uint32 valuesize; - UNISTR value; - uint32 realvaluesize; - uint32 type; - uint32 datasize; - uint8 *data; - uint32 realdatasize; - uint32 status; -} SPOOL_R_ENUMPRINTERDATA; - -typedef struct spool_q_setprinterdata -{ - POLICY_HND handle; - UNISTR2 value; - uint32 type; - uint32 max_len; - uint8 *data; - uint32 real_len; - uint32 numeric_data; -} SPOOL_Q_SETPRINTERDATA; - -typedef struct spool_r_setprinterdata -{ - uint32 status; -} SPOOL_R_SETPRINTERDATA; - -typedef struct _form -{ - uint32 flags; - uint32 name_ptr; - uint32 size_x; - uint32 size_y; - uint32 left; - uint32 top; - uint32 right; - uint32 bottom; - UNISTR2 name; -} FORM; - -typedef struct spool_q_addform -{ - POLICY_HND handle; - uint32 level; - uint32 level2; - FORM form; -} SPOOL_Q_ADDFORM; - -typedef struct spool_r_addform -{ - uint32 status; -} SPOOL_R_ADDFORM; - -typedef struct spool_q_setform -{ - POLICY_HND handle; - UNISTR2 name; - uint32 level; - uint32 level2; - FORM form; -} SPOOL_Q_SETFORM; - -typedef struct spool_r_setform -{ - uint32 status; -} SPOOL_R_SETFORM; - -typedef struct spool_q_getjob -{ - POLICY_HND handle; - uint32 jobid; - uint32 level; - BUFFER buffer; - uint32 buf_size; -} SPOOL_Q_GETJOB; - -typedef struct spool_r_getjob -{ - uint32 level; - union { - JOB_INFO_1 *job_info_1; - JOB_INFO_2 *job_info_2; - } job; - uint32 offered; - uint32 status; -} SPOOL_R_GETJOB; - -#define PRINTER_DRIVER_VERSION 2 -#define PRINTER_DRIVER_ARCHITECTURE "Windows NT x86" - - -#endif /* _RPC_SPOOLSS_H */ - diff --git a/source/include/rpc_svcctl.h b/source/include/rpc_svcctl.h deleted file mode 100644 index ecd1188fe82..00000000000 --- a/source/include/rpc_svcctl.h +++ /dev/null @@ -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 */ - diff --git a/source/include/safe_string.h b/source/include/safe_string.h deleted file mode 100644 index 3b2f2c32d6d..00000000000 --- a/source/include/safe_string.h +++ /dev/null @@ -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 diff --git a/source/include/smb_macros.h b/source/include/smb_macros.h deleted file mode 100644 index 979aec1d2c7..00000000000 --- a/source/include/smb_macros.h +++ /dev/null @@ -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 */ diff --git a/source/include/vagent.h b/source/include/vagent.h deleted file mode 100644 index c8b85181e4e..00000000000 --- a/source/include/vagent.h +++ /dev/null @@ -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 */ diff --git a/source/include/vfs.h b/source/include/vfs.h deleted file mode 100644 index d4ca8823ca1..00000000000 --- a/source/include/vfs.h +++ /dev/null @@ -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 */ diff --git a/source/lib/domain_namemap.c b/source/lib/domain_namemap.c deleted file mode 100644 index 9c947832395..00000000000 --- a/source/lib/domain_namemap.c +++ /dev/null @@ -1,1315 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - Groupname handling - 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. -*/ - -/* - * UNIX gid and Local or Domain SID resolution. This module resolves - * only those entries in the map files, it is *NOT* responsible for - * resolving UNIX groups not listed: that is an entirely different - * matter, altogether... - */ - -/* - * - * - - format of the file is: - - unixname NT Group name - unixname Domain Admins (well-known Domain Group) - unixname DOMAIN_NAME\NT Group name - unixname OTHER_DOMAIN_NAME\NT Group name - unixname DOMAIN_NAME\Domain Admins (well-known Domain Group) - .... - - if the DOMAIN_NAME\ component is left off, then your own domain is assumed. - - * - * - */ - - -#include "includes.h" -extern int DEBUGLEVEL; - -extern fstring global_myworkgroup; -extern DOM_SID global_member_sid; -extern fstring global_sam_name; -extern DOM_SID global_sam_sid; -extern DOM_SID global_sid_S_1_5_20; - -/******************************************************************* - converts UNIX uid to an NT User RID. NOTE: IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uid_t pwdb_user_rid_to_uid(uint32 user_rid) -{ - return ((user_rid & (~RID_TYPE_USER))- 1000)/RID_MULTIPLIER; -} - -/******************************************************************* - converts NT Group RID to a UNIX uid. NOTE: IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uint32 pwdb_group_rid_to_gid(uint32 group_rid) -{ - return ((group_rid & (~RID_TYPE_GROUP))- 1000)/RID_MULTIPLIER; -} - -/******************************************************************* - converts NT Alias RID to a UNIX uid. NOTE: IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uint32 pwdb_alias_rid_to_gid(uint32 alias_rid) -{ - return ((alias_rid & (~RID_TYPE_ALIAS))- 1000)/RID_MULTIPLIER; -} - -/******************************************************************* - converts NT Group RID to a UNIX uid. NOTE: IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uint32 pwdb_gid_to_group_rid(uint32 gid) -{ - uint32 grp_rid = ((((gid)*RID_MULTIPLIER) + 1000) | RID_TYPE_GROUP); - return grp_rid; -} - -/****************************************************************** - converts UNIX gid to an NT Alias RID. NOTE: IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uint32 pwdb_gid_to_alias_rid(uint32 gid) -{ - uint32 alias_rid = ((((gid)*RID_MULTIPLIER) + 1000) | RID_TYPE_ALIAS); - return alias_rid; -} - -/******************************************************************* - converts UNIX uid to an NT User RID. NOTE: IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uint32 pwdb_uid_to_user_rid(uint32 uid) -{ - uint32 user_rid = ((((uid)*RID_MULTIPLIER) + 1000) | RID_TYPE_USER); - return user_rid; -} - -/****************************************************************** - converts SID + SID_NAME_USE type to a UNIX id. the Domain SID is, - and can only be, our own SID. - ********************************************************************/ -static BOOL pwdb_sam_sid_to_unixid(DOM_SID *sid, uint8 type, uint32 *id) -{ - DOM_SID tmp_sid; - uint32 rid; - - sid_copy(&tmp_sid, sid); - sid_split_rid(&tmp_sid, &rid); - if (!sid_equal(&global_sam_sid, &tmp_sid)) - { - return False; - } - - switch (type) - { - case SID_NAME_USER: - { - *id = pwdb_user_rid_to_uid(rid); - return True; - } - case SID_NAME_ALIAS: - { - *id = pwdb_alias_rid_to_gid(rid); - return True; - } - case SID_NAME_DOM_GRP: - case SID_NAME_WKN_GRP: - { - *id = pwdb_group_rid_to_gid(rid); - return True; - } - } - return False; -} - -/****************************************************************** - converts UNIX gid + SID_NAME_USE type to a SID. the Domain SID is, - and can only be, our own SID. - ********************************************************************/ -static BOOL pwdb_unixid_to_sam_sid(uint32 id, uint8 type, DOM_SID *sid) -{ - sid_copy(sid, &global_sam_sid); - switch (type) - { - case SID_NAME_USER: - { - sid_append_rid(sid, pwdb_uid_to_user_rid(id)); - return True; - } - case SID_NAME_ALIAS: - { - sid_append_rid(sid, pwdb_gid_to_alias_rid(id)); - return True; - } - case SID_NAME_DOM_GRP: - case SID_NAME_WKN_GRP: - { - sid_append_rid(sid, pwdb_gid_to_group_rid(id)); - return True; - } - } - return False; -} - -/******************************************************************* - Decides if a RID is a well known RID. - ********************************************************************/ -static BOOL pwdb_rid_is_well_known(uint32 rid) -{ - return (rid < 1000); -} - -/******************************************************************* - determines a rid's type. NOTE: THIS IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -static uint32 pwdb_rid_type(uint32 rid) -{ - /* lkcl i understand that NT attaches an enumeration to a RID - * such that it can be identified as either a user, group etc - * type: SID_ENUM_TYPE. - */ - if (pwdb_rid_is_well_known(rid)) - { - /* - * The only well known user RIDs are DOMAIN_USER_RID_ADMIN - * and DOMAIN_USER_RID_GUEST. - */ - if (rid == DOMAIN_USER_RID_ADMIN || rid == DOMAIN_USER_RID_GUEST) - { - return RID_TYPE_USER; - } - if (DOMAIN_GROUP_RID_ADMINS <= rid && rid <= DOMAIN_GROUP_RID_GUESTS) - { - return RID_TYPE_GROUP; - } - if (BUILTIN_ALIAS_RID_ADMINS <= rid && rid <= BUILTIN_ALIAS_RID_REPLICATOR) - { - return RID_TYPE_ALIAS; - } - } - return (rid & RID_TYPE_MASK); -} - -/******************************************************************* - checks whether rid is a user rid. NOTE: THIS IS SOMETHING SPECIFIC TO SAMBA - ********************************************************************/ -BOOL pwdb_rid_is_user(uint32 rid) -{ - return pwdb_rid_type(rid) == RID_TYPE_USER; -} - -/************************************************************************** - Groupname map functionality. The code loads a groupname map file and - (currently) loads it into a linked list. This is slow and memory - hungry, but can be changed into a more efficient storage format - if the demands on it become excessive. -***************************************************************************/ - -typedef struct name_map -{ - ubi_slNode next; - DOM_NAME_MAP grp; - -} name_map_entry; - -static ubi_slList groupname_map_list; -static ubi_slList aliasname_map_list; -static ubi_slList ntusrname_map_list; - -static void delete_name_entry(name_map_entry *gmep) -{ - if (gmep->grp.nt_name) - { - free(gmep->grp.nt_name); - } - if (gmep->grp.nt_domain) - { - free(gmep->grp.nt_domain); - } - if (gmep->grp.unix_name) - { - free(gmep->grp.unix_name); - } - free((char*)gmep); -} - -/************************************************************************** - Delete all the entries in the name map list. -***************************************************************************/ - -static void delete_map_list(ubi_slList *map_list) -{ - name_map_entry *gmep; - - while ((gmep = (name_map_entry *)ubi_slRemHead(map_list )) != NULL) - { - delete_name_entry(gmep); - } -} - - -/************************************************************************** - makes a group sid out of a domain sid and a _unix_ gid. -***************************************************************************/ -static BOOL make_mydomain_sid(DOM_NAME_MAP *grp, DOM_MAP_TYPE type) -{ - int ret = False; - fstring sid_str; - - if (!map_domain_name_to_sid(&grp->sid, &(grp->nt_domain))) - { - DEBUG(0,("make_mydomain_sid: unknown domain %s\n", - grp->nt_domain)); - return False; - } - - if (sid_equal(&grp->sid, &global_sid_S_1_5_20)) - { - /* - * only builtin aliases are recognised in S-1-5-20 - */ - DEBUG(10,("make_mydomain_sid: group %s in builtin domain\n", - grp->nt_name)); - - if (lookup_builtin_alias_name(grp->nt_name, "BUILTIN", &grp->sid, &grp->type) != 0x0) - { - DEBUG(0,("unix group %s mapped to an unrecognised BUILTIN domain name %s\n", - grp->unix_name, grp->nt_name)); - return False; - } - ret = True; - } - else if (lookup_wk_user_name(grp->nt_name, grp->nt_domain, &grp->sid, &grp->type) == 0x0) - { - if (type != DOM_MAP_USER) - { - DEBUG(0,("well-known NT user %s\\%s listed in wrong map file\n", - grp->nt_domain, grp->nt_name)); - return False; - } - ret = True; - } - else if (lookup_wk_group_name(grp->nt_name, grp->nt_domain, &grp->sid, &grp->type) == 0x0) - { - if (type != DOM_MAP_DOMAIN) - { - DEBUG(0,("well-known NT group %s\\%s listed in wrong map file\n", - grp->nt_domain, grp->nt_name)); - return False; - } - ret = True; - } - else - { - switch (type) - { - case DOM_MAP_USER: - { - grp->type = SID_NAME_USER; - break; - } - case DOM_MAP_DOMAIN: - { - grp->type = SID_NAME_DOM_GRP; - break; - } - case DOM_MAP_LOCAL: - { - grp->type = SID_NAME_ALIAS; - break; - } - } - - ret = pwdb_unixid_to_sam_sid(grp->unix_id, grp->type, &grp->sid); - } - - sid_to_string(sid_str, &grp->sid); - DEBUG(10,("nt name %s\\%s gid %d mapped to %s\n", - grp->nt_domain, grp->nt_name, grp->unix_id, sid_str)); - return ret; -} - -/************************************************************************** - makes a group sid out of an nt domain, nt group name or a unix group name. -***************************************************************************/ -static BOOL unix_name_to_nt_name_info(DOM_NAME_MAP *map, DOM_MAP_TYPE type) -{ - /* - * Attempt to get the unix gid_t for this name. - */ - - DEBUG(5,("unix_name_to_nt_name_info: unix_name:%s\n", map->unix_name)); - - if (type == DOM_MAP_USER) - { - const struct passwd *pwptr = Get_Pwnam(map->unix_name, False); - if (pwptr == NULL) - { - DEBUG(0,("unix_name_to_nt_name_info: Get_Pwnam for user %s\ -failed. Error was %s.\n", map->unix_name, strerror(errno) )); - return False; - } - - map->unix_id = (uint32)pwptr->pw_uid; - } - else - { - struct group *gptr = getgrnam(map->unix_name); - if (gptr == NULL) - { - DEBUG(0,("unix_name_to_nt_name_info: getgrnam for group %s\ -failed. Error was %s.\n", map->unix_name, strerror(errno) )); - return False; - } - - map->unix_id = (uint32)gptr->gr_gid; - } - - DEBUG(5,("unix_name_to_nt_name_info: unix gid:%d\n", map->unix_id)); - - /* - * Now map the name to an NT SID+RID. - */ - - if (map->nt_domain != NULL && !strequal(map->nt_domain, global_sam_name)) - { - /* Must add client-call lookup code here, to - * resolve remote domain's sid and the group's rid, - * in that domain. - * - * NOTE: it is _incorrect_ to put code here that assumes - * we are responsible for lookups for foriegn domains' RIDs. - * - * for foriegn domains for which we are *NOT* the PDC, all - * we can be responsible for is the unix gid_t to which - * the foriegn SID+rid maps to, on this _local_ machine. - * we *CANNOT* make any short-cuts or assumptions about - * RIDs in a foriegn domain. - */ - - if (!map_domain_name_to_sid(&map->sid, &(map->nt_domain))) - { - DEBUG(0,("unix_name_to_nt_name_info: no known sid for %s\n", - map->nt_domain)); - return False; - } - } - - return make_mydomain_sid(map, type); -} - -static BOOL make_name_entry(name_map_entry **new_ep, - char *nt_domain, char *nt_group, char *unix_group, - DOM_MAP_TYPE type) -{ - /* - * Create the list entry and add it onto the list. - */ - - DEBUG(5,("make_name_entry:%s,%s,%s\n", nt_domain, nt_group, unix_group)); - - (*new_ep) = (name_map_entry *)malloc(sizeof(name_map_entry)); - if ((*new_ep) == NULL) - { - DEBUG(0,("make_name_entry: malloc fail for name_map_entry.\n")); - return False; - } - - ZERO_STRUCTP(*new_ep); - - (*new_ep)->grp.nt_name = strdup(nt_group ); - (*new_ep)->grp.nt_domain = strdup(nt_domain ); - (*new_ep)->grp.unix_name = strdup(unix_group); - - if ((*new_ep)->grp.nt_name == NULL || - (*new_ep)->grp.unix_name == NULL) - { - DEBUG(0,("make_name_entry: malloc fail for names in name_map_entry.\n")); - delete_name_entry((*new_ep)); - return False; - } - - /* - * look up the group names, make the Group-SID and unix gid - */ - - if (!unix_name_to_nt_name_info(&(*new_ep)->grp, type)) - { - delete_name_entry((*new_ep)); - return False; - } - - return True; -} - -/************************************************************************** - Load a name map file. Sets last accessed timestamp. -***************************************************************************/ -static ubi_slList *load_name_map(DOM_MAP_TYPE type) -{ - static time_t groupmap_file_last_modified = (time_t)0; - static time_t aliasmap_file_last_modified = (time_t)0; - static time_t ntusrmap_file_last_modified = (time_t)0; - static BOOL initialised_group = False; - static BOOL initialised_alias = False; - static BOOL initialised_ntusr = False; - char *groupname_map_file = lp_groupname_map(); - char *aliasname_map_file = lp_aliasname_map(); - char *ntusrname_map_file = lp_ntusrname_map(); - - FILE *fp; - char *s; - pstring buf; - name_map_entry *new_ep; - - time_t *file_last_modified = NULL; - int *initialised = NULL; - char *map_file = NULL; - ubi_slList *map_list = NULL; - - switch (type) - { - case DOM_MAP_DOMAIN: - { - file_last_modified = &groupmap_file_last_modified; - initialised = &initialised_group; - map_file = groupname_map_file; - map_list = &groupname_map_list; - - break; - } - case DOM_MAP_LOCAL: - { - file_last_modified = &aliasmap_file_last_modified; - initialised = &initialised_alias; - map_file = aliasname_map_file; - map_list = &aliasname_map_list; - - break; - } - case DOM_MAP_USER: - { - file_last_modified = &ntusrmap_file_last_modified; - initialised = &initialised_ntusr; - map_file = ntusrname_map_file; - map_list = &ntusrname_map_list; - - break; - } - } - - if (!(*initialised)) - { - DEBUG(10,("initialising map %s\n", map_file)); - ubi_slInitList(map_list); - (*initialised) = True; - } - - if (!*map_file) - { - return map_list; - } - - /* - * Load the file. - */ - - fp = open_file_if_modified(map_file, "r", file_last_modified); - if (!fp) - { - return map_list; - } - - /* - * Throw away any previous list. - */ - delete_map_list(map_list); - - DEBUG(4,("load_name_map: Scanning name map %s\n",map_file)); - - while ((s = fgets_slash(buf, sizeof(buf), fp)) != NULL) - { - pstring unixname; - pstring nt_name; - fstring nt_domain; - fstring ntname; - char *p; - - DEBUG(10,("Read line |%s|\n", s)); - - memset(nt_name, 0, sizeof(nt_name)); - - if (!*s || strchr("#;",*s)) - continue; - - if (!next_token(&s,unixname, "\t\n\r=", sizeof(unixname))) - continue; - - if (!next_token(&s,nt_name, "\t\n\r=", sizeof(nt_name))) - continue; - - trim_string(unixname, " ", " "); - trim_string(nt_name, " ", " "); - - if (!*nt_name) - continue; - - if (!*unixname) - continue; - - p = strchr(nt_name, '\\'); - - if (p == NULL) - { - memset(nt_domain, 0, sizeof(nt_domain)); - fstrcpy(ntname, nt_name); - } - else - { - *p = 0; - p++; - fstrcpy(nt_domain, nt_name); - fstrcpy(ntname , p); - } - - if (make_name_entry(&new_ep, nt_domain, ntname, unixname, type)) - { - ubi_slAddTail(map_list, (ubi_slNode *)new_ep); - DEBUG(5,("unixname = %s, ntname = %s\\%s type = %d\n", - new_ep->grp.unix_name, - new_ep->grp.nt_domain, - new_ep->grp.nt_name, - new_ep->grp.type)); - } - } - - DEBUG(10,("load_name_map: Added %ld entries to name map.\n", - ubi_slCount(map_list))); - - fclose(fp); - - return map_list; -} - -static void copy_grp_map_entry(DOM_NAME_MAP *grp, const DOM_NAME_MAP *from) -{ - sid_copy(&grp->sid, &from->sid); - grp->unix_id = from->unix_id; - grp->nt_name = from->nt_name; - grp->nt_domain = from->nt_domain; - grp->unix_name = from->unix_name; - grp->type = from->type; -} - -#if 0 -/*********************************************************** - Lookup unix name. -************************************************************/ -static BOOL map_unixname(DOM_MAP_TYPE type, - char *unixname, DOM_NAME_MAP *grp_info) -{ - name_map_entry *gmep; - ubi_slList *map_list; - - /* - * Initialise and load if not already loaded. - */ - map_list = load_name_map(type); - - for (gmep = (name_map_entry *)ubi_slFirst(map_list); - gmep != NULL; - gmep = (name_map_entry *)ubi_slNext(gmep )) - { - if (strequal(gmep->grp.unix_name, unixname)) - { - copy_grp_map_entry(grp_info, &gmep->grp); - DEBUG(7,("map_unixname: Mapping unix name %s to nt group %s.\n", - gmep->grp.unix_name, gmep->grp.nt_name )); - return True; - } - } - - return False; -} - -#endif - -/*********************************************************** - Lookup nt name. -************************************************************/ -static BOOL map_ntname(DOM_MAP_TYPE type, char *ntname, char *ntdomain, - DOM_NAME_MAP *grp_info) -{ - name_map_entry *gmep; - ubi_slList *map_list; - - /* - * Initialise and load if not already loaded. - */ - map_list = load_name_map(type); - - for (gmep = (name_map_entry *)ubi_slFirst(map_list); - gmep != NULL; - gmep = (name_map_entry *)ubi_slNext(gmep )) - { - if (strequal(gmep->grp.nt_name , ntname) && - strequal(gmep->grp.nt_domain, ntdomain)) - { - copy_grp_map_entry(grp_info, &gmep->grp); - DEBUG(7,("map_ntname: Mapping unix name %s to nt name %s.\n", - gmep->grp.unix_name, gmep->grp.nt_name )); - return True; - } - } - - return False; -} - - -/*********************************************************** - Lookup by SID -************************************************************/ -static BOOL map_sid(DOM_MAP_TYPE type, - DOM_SID *psid, DOM_NAME_MAP *grp_info) -{ - name_map_entry *gmep; - ubi_slList *map_list; - - /* - * Initialise and load if not already loaded. - */ - map_list = load_name_map(type); - - for (gmep = (name_map_entry *)ubi_slFirst(map_list); - gmep != NULL; - gmep = (name_map_entry *)ubi_slNext(gmep )) - { - if (sid_equal(&gmep->grp.sid, psid)) - { - copy_grp_map_entry(grp_info, &gmep->grp); - DEBUG(7,("map_sid: Mapping unix name %s to nt name %s.\n", - gmep->grp.unix_name, gmep->grp.nt_name )); - return True; - } - } - - return False; -} - -/*********************************************************** - Lookup by gid_t. -************************************************************/ -static BOOL map_unixid(DOM_MAP_TYPE type, uint32 unix_id, DOM_NAME_MAP *grp_info) -{ - name_map_entry *gmep; - ubi_slList *map_list; - - /* - * Initialise and load if not already loaded. - */ - map_list = load_name_map(type); - - for (gmep = (name_map_entry *)ubi_slFirst(map_list); - gmep != NULL; - gmep = (name_map_entry *)ubi_slNext(gmep )) - { - fstring sid_str; - sid_to_string(sid_str, &gmep->grp.sid); - DEBUG(10,("map_unixid: enum entry unix group %s %d nt %s %s\n", - gmep->grp.unix_name, gmep->grp.unix_id, gmep->grp.nt_name, sid_str)); - if (gmep->grp.unix_id == unix_id) - { - copy_grp_map_entry(grp_info, &gmep->grp); - DEBUG(7,("map_unixid: Mapping unix name %s to nt name %s type %d\n", - gmep->grp.unix_name, gmep->grp.nt_name, gmep->grp.type)); - return True; - } - } - - return False; -} - -/*********************************************************** - * - * Call four functions to resolve unix group ids and either - * local group SIDs or domain group SIDs listed in the local group - * or domain group map files. - * - * Note that it is *NOT* the responsibility of these functions to - * resolve entries that are not in the map files. - * - * Any SID can be in the map files (i.e from any Domain). - * - ***********************************************************/ - -#if 0 - -/*********************************************************** - Lookup a UNIX Group entry by name. -************************************************************/ -BOOL map_unix_group_name(char *group_name, DOM_NAME_MAP *grp_info) -{ - return map_unixname(DOM_MAP_DOMAIN, group_name, grp_info); -} - -/*********************************************************** - Lookup a UNIX Alias entry by name. -************************************************************/ -BOOL map_unix_alias_name(char *alias_name, DOM_NAME_MAP *grp_info) -{ - return map_unixname(DOM_MAP_LOCAL, alias_name, grp_info); -} - -/*********************************************************** - Lookup an Alias name entry -************************************************************/ -BOOL map_nt_alias_name(char *ntalias_name, char *nt_domain, DOM_NAME_MAP *grp_info) -{ - return map_ntname(DOM_MAP_LOCAL, ntalias_name, nt_domain, grp_info); -} - -/*********************************************************** - Lookup a Group entry -************************************************************/ -BOOL map_nt_group_name(char *ntgroup_name, char *nt_domain, DOM_NAME_MAP *grp_info) -{ - return map_ntname(DOM_MAP_DOMAIN, ntgroup_name, nt_domain, grp_info); -} - -#endif - -/*********************************************************** - Lookup a Username entry by name. -************************************************************/ -static BOOL map_nt_username(char *nt_name, char *nt_domain, DOM_NAME_MAP *grp_info) -{ - return map_ntname(DOM_MAP_USER, nt_name, nt_domain, grp_info); -} - -/*********************************************************** - Lookup a Username entry by SID. -************************************************************/ -static BOOL map_username_sid(DOM_SID *sid, DOM_NAME_MAP *grp_info) -{ - return map_sid(DOM_MAP_USER, sid, grp_info); -} - -/*********************************************************** - Lookup a Username SID entry by uid. -************************************************************/ -static BOOL map_username_uid(uid_t gid, DOM_NAME_MAP *grp_info) -{ - return map_unixid(DOM_MAP_USER, (uint32)gid, grp_info); -} - -/*********************************************************** - Lookup an Alias SID entry by name. -************************************************************/ -BOOL map_alias_sid(DOM_SID *psid, DOM_NAME_MAP *grp_info) -{ - return map_sid(DOM_MAP_LOCAL, psid, grp_info); -} - -/*********************************************************** - Lookup a Group entry by sid. -************************************************************/ -BOOL map_group_sid(DOM_SID *psid, DOM_NAME_MAP *grp_info) -{ - return map_sid(DOM_MAP_DOMAIN, psid, grp_info); -} - -/*********************************************************** - Lookup an Alias SID entry by gid_t. -************************************************************/ -static BOOL map_alias_gid(gid_t gid, DOM_NAME_MAP *grp_info) -{ - return map_unixid(DOM_MAP_LOCAL, (uint32)gid, grp_info); -} - -/*********************************************************** - Lookup a Group SID entry by gid_t. -************************************************************/ -static BOOL map_group_gid( gid_t gid, DOM_NAME_MAP *grp_info) -{ - return map_unixid(DOM_MAP_DOMAIN, (uint32)gid, grp_info); -} - - -/************************************************************************ - Routine to look up User details by UNIX name -*************************************************************************/ -BOOL lookupsmbpwnam(const char *unix_usr_name, DOM_NAME_MAP *grp) -{ - uid_t uid; - DEBUG(10,("lookupsmbpwnam: unix user name %s\n", unix_usr_name)); - if (nametouid(unix_usr_name, &uid)) - { - return lookupsmbpwuid(uid, grp); - } - else - { - return False; - } -} - -/************************************************************************ - Routine to look up a remote nt name -*************************************************************************/ -static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type) -{ - struct cli_state cli; - POLICY_HND lsa_pol; - fstring srv_name; - extern struct ntuser_creds *usr_creds; - struct ntuser_creds usr; - - BOOL res3 = True; - BOOL res4 = True; - uint32 num_sids; - DOM_SID *sids; - uint8 *types; - char *names[1]; - - usr_creds = &usr; - - ZERO_STRUCT(usr); - pwd_set_nullpwd(&usr.pwd); - - DEBUG(5,("lookup_remote_ntname: %s\n", ntname)); - - if (!cli_connect_serverlist(&cli, lp_passwordserver())) - { - return False; - } - - names[0] = ntname; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, cli.desthost); - strupper(srv_name); - - /* lookup domain controller; receive a policy handle */ - res3 = res3 ? lsa_open_policy( srv_name, - &lsa_pol, True) : False; - - /* send lsa lookup sids call */ - res4 = res3 ? lsa_lookup_names( &lsa_pol, - 1, names, - &sids, &types, &num_sids) : False; - - res3 = res3 ? lsa_close(&lsa_pol) : False; - - if (res4 && res3 && sids != NULL && types != NULL) - { - sid_copy(sid, &sids[0]); - *type = types[0]; - } - else - { - res3 = False; - } - if (types != NULL) - { - free(types); - } - - if (sids != NULL) - { - free(sids); - } - - return res3 && res4; -} - -/************************************************************************ - Routine to look up a remote nt name -*************************************************************************/ -static BOOL get_sid_and_type(const char *fullntname, uint8 expected_type, - DOM_NAME_MAP *gmep) -{ - /* - * check with the PDC to see if it owns the name. if so, - * the SID is resolved with the PDC database. - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { - if (lookup_remote_ntname(fullntname, &gmep->sid, &gmep->type)) - { - if (sid_front_equal(&gmep->sid, &global_member_sid) && - strequal(gmep->nt_domain, global_myworkgroup) && - gmep->type == expected_type) - { - return True; - } - return False; - } - } - - /* - * ... otherwise, it's one of ours. map the sid ourselves, - * which can only happen in our own SAM database. - */ - - if (!strequal(gmep->nt_domain, global_sam_name)) - { - return False; - } - if (!pwdb_unixid_to_sam_sid(gmep->unix_id, gmep->type, &gmep->sid)) - { - return False; - } - - return True; -} - -/* - * used by lookup functions below - */ - -static fstring nt_name; -static fstring unix_name; -static fstring nt_domain; - -/************************************************************************* - looks up a uid, returns User Information. -*************************************************************************/ -BOOL lookupsmbpwuid(uid_t uid, DOM_NAME_MAP *gmep) -{ - DEBUG(10,("lookupsmbpwuid: unix uid %d\n", uid)); - if (map_username_uid(uid, gmep)) - { - return True; - } - if (lp_server_role() != ROLE_DOMAIN_NONE) - { - gmep->nt_name = nt_name; - gmep->unix_name = unix_name; - gmep->nt_domain = nt_domain; - - gmep->unix_id = (uint32)uid; - - /* - * ok, assume it's one of ours. then double-check it - * if we are a member of a domain - */ - - gmep->type = SID_NAME_USER; - fstrcpy(gmep->nt_name, uidtoname(uid)); - fstrcpy(gmep->unix_name, gmep->nt_name); - - /* - * here we should do a LsaLookupNames() call - * to check the status of the name with the PDC. - * if the PDC know nothing of the name, it's ours. - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { -#if 0 - lsa_lookup_names(global_myworkgroup, gmep->nt_name, &gmep->sid...); -#endif - } - - /* - * ok, it's one of ours. - */ - - gmep->nt_domain = global_sam_name; - pwdb_unixid_to_sam_sid(gmep->unix_id, gmep->type, &gmep->sid); - - return True; - } - - /* oops. */ - - return False; -} - -/************************************************************************* - looks up by NT name, returns User Information. -*************************************************************************/ -BOOL lookupsmbpwntnam(const char *fullntname, DOM_NAME_MAP *gmep) -{ - DEBUG(10,("lookupsmbpwntnam: nt user name %s\n", fullntname)); - - if (!split_domain_name(fullntname, nt_domain, nt_name)) - { - return False; - } - - if (map_nt_username(nt_name, nt_domain, gmep)) - { - return True; - } - if (lp_server_role() != ROLE_DOMAIN_NONE) - { - uid_t uid; - gmep->nt_name = nt_name; - gmep->unix_name = unix_name; - gmep->nt_domain = nt_domain; - - /* - * ok, it's one of ours. we therefore "create" an nt user named - * after the unix user. this is the point where "appliance mode" - * should get its teeth in, as unix users won't really exist, - * they will only be numbers... - */ - - gmep->type = SID_NAME_USER; - fstrcpy(gmep->unix_name, gmep->nt_name); - if (!nametouid(gmep->unix_name, &uid)) - { - return False; - } - gmep->unix_id = (uint32)uid; - - return get_sid_and_type(fullntname, gmep->type, gmep); - } - - /* oops. */ - - return False; -} - -/************************************************************************* - looks up by RID, returns User Information. -*************************************************************************/ -BOOL lookupsmbpwsid(DOM_SID *sid, DOM_NAME_MAP *gmep) -{ - fstring sid_str; - sid_to_string(sid_str, sid); - DEBUG(10,("lookupsmbpwsid: nt sid %s\n", sid_str)); - - if (map_username_sid(sid, gmep)) - { - return True; - } - if (lp_server_role() != ROLE_DOMAIN_NONE) - { - gmep->nt_name = nt_name; - gmep->unix_name = unix_name; - gmep->nt_domain = nt_domain; - - /* - * here we should do a LsaLookupNames() call - * to check the status of the name with the PDC. - * if the PDC know nothing of the name, it's ours. - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { -#if 0 - if (lookup_remote_sid(global_myworkgroup, gmep->sid, gmep->nt_name, gmep->nt_domain...); -#endif - } - - /* - * ok, it's one of ours. we therefore "create" an nt user named - * after the unix user. this is the point where "appliance mode" - * should get its teeth in, as unix users won't really exist, - * they will only be numbers... - */ - - gmep->type = SID_NAME_USER; - sid_copy(&gmep->sid, sid); - if (!pwdb_sam_sid_to_unixid(&gmep->sid, gmep->type, &gmep->unix_id)) - { - return False; - } - fstrcpy(gmep->nt_name, uidtoname((uid_t)gmep->unix_id)); - fstrcpy(gmep->unix_name, gmep->nt_name); - gmep->nt_domain = global_sam_name; - - return True; - } - - /* oops. */ - - return False; -} - -/************************************************************************ - Routine to look up group / alias / well-known group RID by UNIX name -*************************************************************************/ -BOOL lookupsmbgrpnam(const char *unix_grp_name, DOM_NAME_MAP *grp) -{ - gid_t gid; - DEBUG(10,("lookupsmbgrpnam: unix user group %s\n", unix_grp_name)); - if (nametogid(unix_grp_name, &gid)) - { - return lookupsmbgrpgid(gid, grp); - } - else - { - return False; - } -} - -/************************************************************************* - looks up a SID, returns name map entry -*************************************************************************/ -BOOL lookupsmbgrpsid(DOM_SID *sid, DOM_NAME_MAP *gmep) -{ - fstring sid_str; - sid_to_string(sid_str, sid); - DEBUG(10,("lookupsmbgrpsid: nt sid %s\n", sid_str)); - - if (map_alias_sid(sid, gmep)) - { - return True; - } - if (map_group_sid(sid, gmep)) - { - return True; - } - if (lp_server_role() != ROLE_DOMAIN_NONE) - { - gmep->nt_name = nt_name; - gmep->unix_name = unix_name; - gmep->nt_domain = nt_domain; - - /* - * here we should do a LsaLookupNames() call - * to check the status of the name with the PDC. - * if the PDC know nothing of the name, it's ours. - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { -#if 0 - lsa_lookup_sids(global_myworkgroup, gmep->sid, gmep->nt_name, gmep->nt_domain...); -#endif - } - - /* - * ok, it's one of ours. we therefore "create" an nt group or - * alias name named after the unix group. this is the point - * where "appliance mode" should get its teeth in, as unix - * groups won't really exist, they will only be numbers... - */ - - /* name is not explicitly mapped - * with map files or the PDC - * so we are responsible for it... - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { - /* ... as a LOCAL group. */ - gmep->type = SID_NAME_ALIAS; - } - else - { - /* ... as a DOMAIN group. */ - gmep->type = SID_NAME_DOM_GRP; - } - - sid_copy(&gmep->sid, sid); - if (!pwdb_sam_sid_to_unixid(&gmep->sid, gmep->type, &gmep->unix_id)) - { - return False; - } - fstrcpy(gmep->nt_name, gidtoname((gid_t)gmep->unix_id)); - fstrcpy(gmep->unix_name, gmep->nt_name); - gmep->nt_domain = global_sam_name; - - return True; - } - - /* oops */ - return False; -} - -/************************************************************************* - looks up a gid, returns RID and type local, domain or well-known domain group -*************************************************************************/ -BOOL lookupsmbgrpgid(gid_t gid, DOM_NAME_MAP *gmep) -{ - DEBUG(10,("lookupsmbgrpgid: unix gid %d\n", (int)gid)); - if (map_alias_gid(gid, gmep)) - { - return True; - } - if (map_group_gid(gid, gmep)) - { - return True; - } - if (lp_server_role() != ROLE_DOMAIN_NONE) - { - gmep->nt_name = nt_name; - gmep->unix_name = unix_name; - gmep->nt_domain = nt_domain; - - gmep->unix_id = (uint32)gid; - - /* - * here we should do a LsaLookupNames() call - * to check the status of the name with the PDC. - * if the PDC know nothing of the name, it's ours. - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { -#if 0 - if (lsa_lookup_names(global_myworkgroup, gmep->nt_name, &gmep->sid...); - { - return True; - } -#endif - } - - /* - * ok, it's one of ours. we therefore "create" an nt group or - * alias name named after the unix group. this is the point - * where "appliance mode" should get its teeth in, as unix - * groups won't really exist, they will only be numbers... - */ - - /* name is not explicitly mapped - * with map files or the PDC - * so we are responsible for it... - */ - - if (lp_server_role() == ROLE_DOMAIN_MEMBER) - { - /* ... as a LOCAL group. */ - gmep->type = SID_NAME_ALIAS; - } - else - { - /* ... as a DOMAIN group. */ - gmep->type = SID_NAME_DOM_GRP; - } - fstrcpy(gmep->nt_name, gidtoname(gid)); - fstrcpy(gmep->unix_name, gmep->nt_name); - - return get_sid_and_type(gmep->nt_name, gmep->type, gmep); - } - - /* oops */ - return False; -} - diff --git a/source/lib/hmacmd5.c b/source/lib/hmacmd5.c deleted file mode 100644 index d017bba77d8..00000000000 --- a/source/lib/hmacmd5.c +++ /dev/null @@ -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); -} diff --git a/source/lib/md5.c b/source/lib/md5.c deleted file mode 100644 index cff7bef034b..00000000000 --- a/source/lib/md5.c +++ /dev/null @@ -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 diff --git a/source/lib/membuffer.c b/source/lib/membuffer.c deleted file mode 100644 index e228503643f..00000000000 --- a/source/lib/membuffer.c +++ /dev/null @@ -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; -} - - diff --git a/source/lib/msrpc-agent.c b/source/lib/msrpc-agent.c deleted file mode 100644 index 9fc592d3777..00000000000 --- a/source/lib/msrpc-agent.c +++ /dev/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); - } -} - diff --git a/source/lib/msrpc-client.c b/source/lib/msrpc-client.c deleted file mode 100644 index e13850a9e24..00000000000 --- a/source/lib/msrpc-client.c +++ /dev/null @@ -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; -} - diff --git a/source/lib/msrpc_use.c b/source/lib/msrpc_use.c deleted file mode 100644 index 193867e6100..00000000000 --- a/source/lib/msrpc_use.c +++ /dev/null @@ -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); - } -} - diff --git a/source/lib/netmask.c b/source/lib/netmask.c deleted file mode 100644 index 6d710583758..00000000000 --- a/source/lib/netmask.c +++ /dev/null @@ -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 diff --git a/source/lib/passcheck.c b/source/lib/passcheck.c deleted file mode 100644 index bec64550595..00000000000 --- a/source/lib/passcheck.c +++ /dev/null @@ -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; -} - diff --git a/source/lib/sids.c b/source/lib/sids.c deleted file mode 100644 index 712eef8a0df..00000000000 --- a/source/lib/sids.c +++ /dev/null @@ -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; -} - diff --git a/source/lib/streams.c b/source/lib/streams.c deleted file mode 100644 index 8e6ad9f53aa..00000000000 --- a/source/lib/streams.c +++ /dev/null @@ -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); -} diff --git a/source/lib/unix_sec_ctxt.c b/source/lib/unix_sec_ctxt.c deleted file mode 100644 index ead1f3c6d32..00000000000 --- a/source/lib/unix_sec_ctxt.c +++ /dev/null @@ -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; -} - diff --git a/source/lib/util_array.c b/source/lib/util_array.c deleted file mode 100644 index c3945ff9f83..00000000000 --- a/source/lib/util_array.c +++ /dev/null @@ -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); -} - diff --git a/source/lib/util_hnd.c b/source/lib/util_hnd.c deleted file mode 100644 index b895fb31c0f..00000000000 --- a/source/lib/util_hnd.c +++ /dev/null @@ -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; -} - diff --git a/source/lib/util_pwdb.c b/source/lib/util_pwdb.c deleted file mode 100644 index 3de1829da3e..00000000000 --- a/source/lib/util_pwdb.c +++ /dev/null @@ -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); -} - diff --git a/source/lib/util_status.c b/source/lib/util_status.c deleted file mode 100644 index 836388a1bd5..00000000000 --- a/source/lib/util_status.c +++ /dev/null @@ -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; -} - diff --git a/source/lib/vagent.c b/source/lib/vagent.c deleted file mode 100644 index 96df03e2f3e..00000000000 --- a/source/lib/vagent.c +++ /dev/null @@ -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; - } - } - } - } -} - diff --git a/source/lib/vuser.c b/source/lib/vuser.c deleted file mode 100644 index 09a553e4e63..00000000000 --- a/source/lib/vuser.c +++ /dev/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); -} - diff --git a/source/libsmb/clienttrust.c b/source/libsmb/clienttrust.c deleted file mode 100644 index b223750529f..00000000000 --- a/source/libsmb/clienttrust.c +++ /dev/null @@ -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; -} - diff --git a/source/lsarpcd/lsarpcd.c b/source/lsarpcd/lsarpcd.c deleted file mode 100644 index 050a593eb0f..00000000000 --- a/source/lsarpcd/lsarpcd.c +++ /dev/null @@ -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); -} diff --git a/source/msrpc/msrpcd.c b/source/msrpc/msrpcd.c deleted file mode 100644 index d6ae3ca642d..00000000000 --- a/source/msrpc/msrpcd.c +++ /dev/null @@ -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); -} diff --git a/source/msrpc/msrpcd_process.c b/source/msrpc/msrpcd_process.c deleted file mode 100644 index 35a28d105a2..00000000000 --- a/source/msrpc/msrpcd_process.c +++ /dev/null @@ -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); - } -} diff --git a/source/netlogond/netlogond.c b/source/netlogond/netlogond.c deleted file mode 100644 index fb0ace784db..00000000000 --- a/source/netlogond/netlogond.c +++ /dev/null @@ -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); -} diff --git a/source/passdb/mysqlpass.c b/source/passdb/mysqlpass.c deleted file mode 100644 index 75be8b638b9..00000000000 --- a/source/passdb/mysqlpass.c +++ /dev/null @@ -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 diff --git a/source/passdb/mysqlsampass.c b/source/passdb/mysqlsampass.c deleted file mode 100644 index 4615591bfbe..00000000000 --- a/source/passdb/mysqlsampass.c +++ /dev/null @@ -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 diff --git a/source/passdb/passgrpldap.c b/source/passdb/passgrpldap.c deleted file mode 100644 index 1092a3c5b16..00000000000 --- a/source/passdb/passgrpldap.c +++ /dev/null @@ -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 - diff --git a/source/passdb/sampass.c b/source/passdb/sampass.c deleted file mode 100644 index b9be8a7bae2..00000000000 --- a/source/passdb/sampass.c +++ /dev/null @@ -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 */ diff --git a/source/passdb/sampassdb.c b/source/passdb/sampassdb.c deleted file mode 100644 index bca5bfa45f3..00000000000 --- a/source/passdb/sampassdb.c +++ /dev/null @@ -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; -} diff --git a/source/passdb/sampassldap.c b/source/passdb/sampassldap.c deleted file mode 100644 index fd503c3d27c..00000000000 --- a/source/passdb/sampassldap.c +++ /dev/null @@ -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 diff --git a/source/passdb/smbpassgroupunix.c b/source/passdb/smbpassgroupunix.c deleted file mode 100644 index 66c094d9621..00000000000 --- a/source/passdb/smbpassgroupunix.c +++ /dev/null @@ -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 */ diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c deleted file mode 100644 index d58ead0f932..00000000000 --- a/source/printing/nt_printing.c +++ /dev/null @@ -1,1412 +0,0 @@ -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - -/**************************************************************************** -parse a form line. -****************************************************************************/ -static BOOL parse_form_entry(char *line, nt_forms_struct *buf) -{ -#define NAMETOK 0 -#define FLAGTOK 1 -#define WIDTHTOK 2 -#define LENGTHTOK 3 -#define LEFTTOK 4 -#define TOPTOK 5 -#define RIGHTTOK 6 -#define BOTTOMTOK 7 -#define MAXTOK 8 - char *tok[MAXTOK]; - int count = 0; - - tok[count] = strtok(line,":"); - - /* strip the comment lines */ - if (tok[0][0]=='#') return (False); - count++; - - while ( ((tok[count] = strtok(NULL,":")) != NULL ) && count<MAXTOK-1) - { - count++; - } - - DEBUG(6,("Found [%d] tokens\n", count)); - - StrnCpy(buf->name,tok[NAMETOK],sizeof(buf->name)-1); - buf->flag=atoi(tok[FLAGTOK]); - buf->width=atoi(tok[WIDTHTOK]); - buf->length=atoi(tok[LENGTHTOK]); - buf->left=atoi(tok[LEFTTOK]); - buf->top=atoi(tok[TOPTOK]); - buf->right=atoi(tok[RIGHTTOK]); - buf->bottom=atoi(tok[BOTTOMTOK]); - - return(True); -} - -/**************************************************************************** -get a form struct list -****************************************************************************/ -int get_ntforms(nt_forms_struct **list) -{ - FILE *f; - pstring line; - char *lp_forms = lp_nt_forms(); - int total=0; - int grandtotal=0; - *line=0; - - f = sys_fopen(lp_forms,"r"); - if (!f) - { - return(0); - } - - while ( fgets(line, sizeof(pstring), f) ) - { - DEBUG(5,("%s\n",line)); - - *list = Realloc(*list, sizeof(nt_forms_struct)*(total+1)); - if (! *list) - { - total = 0; - break; - } - bzero( (char *)&(*list)[total], sizeof(nt_forms_struct) ); - if ( parse_form_entry(line, &(*list)[total] ) ) - { - total++; - } - grandtotal++; - } - fclose(f); - - DEBUG(4,("%d info lines on %d\n",total, grandtotal)); - - return(total); -} - -/**************************************************************************** -write a form struct list -****************************************************************************/ -int write_ntforms(nt_forms_struct **list, int number) -{ - FILE *f; - pstring line; - char *file = lp_nt_forms(); - int total=0; - int i; - - *line=0; - - DEBUG(6,("write_ntforms\n")); - - if((f = sys_fopen(file, "w")) == NULL) - { - DEBUG(1, ("cannot create forms file [%s]\n", file)); - return(0); - } - - for (i=0; i<number;i++) - { - - fprintf(f,"%s:%d:%d:%d:%d:%d:%d:%d\n", (*list)[i].name, - (*list)[i].flag, (*list)[i].width, (*list)[i].length, - (*list)[i].left, (*list)[i].top, (*list)[i].right, (*list)[i].bottom); - - DEBUGADD(7,("adding entry [%s]\n", (*list)[i].name)); - } - - fclose(f); - DEBUGADD(6,("closing file\n")); - return(total); -} - -/**************************************************************************** -add a form struct at the end of the list -****************************************************************************/ -void add_a_form(nt_forms_struct **list, FORM form, int *count) -{ - int n=0; - BOOL update; - fstring form_name; - - /* - * NT tries to add forms even when - * they are already in the base - * only update the values if already present - */ - - update=False; - - unistr2_to_ascii(form_name, &(form.name), sizeof(form_name)-1); - for (n=0; n<*count && update==False; n++) - { - if (!strncmp((*list)[n].name, form_name, strlen(form_name))) - { - DEBUG(3, ("NT workaround, [%s] already exists\n", form_name)); - update=True; - } - } - - if (update==False) - { - *list=Realloc(*list, (n+1)*sizeof(nt_forms_struct)); - unistr2_to_ascii((*list)[n].name, &(form.name), sizeof((*list)[n].name)-1); - (*count)++; - } - - (*list)[n].flag=form.flags; - (*list)[n].width=form.size_x; - (*list)[n].length=form.size_y; - (*list)[n].left=form.left; - (*list)[n].top=form.top; - (*list)[n].right=form.right; - (*list)[n].bottom=form.bottom; -} - -/**************************************************************************** -update a form struct -****************************************************************************/ -void update_a_form(nt_forms_struct **list, FORM form, int count) -{ - int n=0; - fstring form_name; - unistr2_to_ascii(form_name, &(form.name), sizeof(form_name)-1); - - DEBUG(6, ("[%s]\n", form_name)); - for (n=0; n<count; n++) - { - DEBUGADD(6, ("n [%d]:[%s]\n", n, (*list)[n].name)); - if (!strncmp((*list)[n].name, form_name, strlen(form_name))) - break; - } - - if (n==count) return; - - (*list)[n].flag=form.flags; - (*list)[n].width=form.size_x; - (*list)[n].length=form.size_y; - (*list)[n].left=form.left; - (*list)[n].top=form.top; - (*list)[n].right=form.right; - (*list)[n].bottom=form.bottom; -} - -/**************************************************************************** -get the nt drivers list - -open the directory and look-up the matching names -****************************************************************************/ -int get_ntdrivers(fstring **list, char *architecture) -{ - DIR *dirp; - char *dpname; - fstring name_match; - fstring short_archi; - fstring driver_name; - int match_len; - int total=0; - - DEBUG(5,("Getting the driver list from directory: [%s]\n", lp_nt_drivers_file())); - - *list=NULL; - dirp = opendir(lp_nt_drivers_file()); - - if (dirp == NULL) - { - DEBUG(0,("Error opening driver directory [%s]\n",lp_nt_drivers_file())); - return(-1); - } - - get_short_archi(short_archi, architecture); - slprintf(name_match, sizeof(name_match)-1, "NTdriver_%s_", short_archi); - match_len=strlen(name_match); - - while ((dpname = readdirname(dirp)) != NULL) - { - if (strncmp(dpname, name_match, match_len)==0) - { - DEBUGADD(7,("Found: [%s]\n", dpname)); - - StrCpy(driver_name, dpname+match_len); - all_string_sub(driver_name, "#", "/"); - *list = Realloc(*list, sizeof(fstring)*(total+1)); - StrnCpy((*list)[total], driver_name, strlen(driver_name)); - DEBUGADD(6,("Added: [%s]\n", driver_name)); - total++; - } - } - - closedir(dirp); - return(total); -} - -/**************************************************************************** -function to do the mapping between the long architecture name and -the short one. -****************************************************************************/ -void get_short_archi(char *short_archi, char *long_archi) -{ - struct table { - char *long_archi; - char *short_archi; - }; - - struct table archi_table[]= - { - {"Windows 4.0", "" }, - {"Windows NT x86", "W32X86" }, - {"Windows NT R4000", "" }, - {"Windows NT Alpha_AXP", "" }, - {"Windows NT PowerPC", "" }, - {NULL, "" } - }; - - int i=-1; - - DEBUG(7,("Getting architecture dependant directory\n")); - do { - i++; - } while ( (archi_table[i].long_archi!=NULL ) && strncmp(long_archi, archi_table[i].long_archi, strlen(long_archi)) ); - - if (archi_table[i].long_archi==NULL) - { - DEBUGADD(7,("Unknown architecture [%s] !\n", long_archi)); - } - StrnCpy (short_archi, archi_table[i].short_archi, strlen(archi_table[i].short_archi)); - - DEBUGADD(8,("index: [%d]\n", i)); - DEBUGADD(8,("long architecture: [%s]\n", long_archi)); - DEBUGADD(8,("short architecture: [%s]\n", short_archi)); -} - -/**************************************************************************** -****************************************************************************/ -static uint32 add_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver) -{ - FILE *f; - pstring file; - fstring architecture; - fstring driver_name; - char **dependentfiles; - - /* create a file in the dir lp_nt_driver_file */ - /* with the full printer DRIVER name */ - /* eg: "/usr/local/samba/lib/NTdriver_HP LaserJet 6MP" */ - /* each name is really defining an *unique* printer model */ - /* I don't want to mangle the name to find it back when enumerating */ - - /* il faut substituer les / par 1 autre caractere d'abord */ - /* dans le nom de l'imprimante par un # ???*/ - - StrnCpy(driver_name, driver->name, sizeof(driver_name)-1); - - all_string_sub(driver_name, "/", "#"); - - get_short_archi(architecture, driver->environment); - - slprintf(file, sizeof(file)-1, "%s/NTdriver_%s_%s", - lp_nt_drivers_file(), architecture, driver_name); - - if((f = sys_fopen(file, "w")) == NULL) - { - DEBUG(1, ("cannot create driver file [%s]\n", file)); - return(2); - } - - /* - * cversion must be 2. - * when adding a printer ON the SERVER - * rpcAddPrinterDriver defines it to zero - * which is wrong !!! - * - * JFM, 4/14/99 - */ - driver->cversion=2; - - fprintf(f, "version: %d\n", driver->cversion); - fprintf(f, "name: %s\n", driver->name); - fprintf(f, "environment: %s\n", driver->environment); - fprintf(f, "driverpath: %s\n", driver->driverpath); - fprintf(f, "datafile: %s\n", driver->datafile); - fprintf(f, "configfile: %s\n", driver->configfile); - fprintf(f, "helpfile: %s\n", driver->helpfile); - fprintf(f, "monitorname: %s\n", driver->monitorname); - fprintf(f, "defaultdatatype: %s\n", driver->defaultdatatype); - - /* and the dependants files */ - - dependentfiles=driver->dependentfiles; - - while ( **dependentfiles != '\0' ) - { - fprintf(f, "dependentfile: %s\n", *dependentfiles); - dependentfiles++; - } - - fclose(f); - return(0); -} - -/**************************************************************************** -****************************************************************************/ -static uint32 get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, fstring in_prt, fstring in_arch) -{ - FILE *f; - pstring file; - fstring driver_name; - fstring architecture; - NT_PRINTER_DRIVER_INFO_LEVEL_3 *info; - char *line; - fstring p; - char *v; - int i=0; - char **dependentfiles=NULL; - - /* - * replace all the / by # in the driver name - * get the short architecture name - * construct the driver file name - */ - StrnCpy(driver_name, in_prt, sizeof(driver_name)-1); - all_string_sub(driver_name, "/", "#"); - - get_short_archi(architecture, in_arch); - - slprintf(file, sizeof(file)-1, "%s/NTdriver_%s_%s", - lp_nt_drivers_file(), architecture, driver_name); - - if((f = sys_fopen(file, "r")) == NULL) - { - DEBUG(2, ("cannot open printer driver file [%s]\n", file)); - return(2); - } - - /* the file exists, allocate some memory */ - info=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3)); - ZERO_STRUCTP(info); - - /* allocate a 4Kbytes buffer for parsing lines */ - line=(char *)malloc(4096*sizeof(char)); - - while ( fgets(line, 4095, f) ) - { - - v=strncpyn(p, line, sizeof(p), ':'); - if (v==NULL) - { - DEBUG(1, ("malformed printer entry (no :)\n")); - continue; - } - - v++; - - trim_string(v, " ", NULL); - trim_string(v, NULL, " "); - trim_string(v, NULL, "\n"); - /* don't check if v==NULL as an empty arg is valid */ - - if (!strncmp(p, "version", strlen("version"))) - info->cversion=atoi(v); - - if (!strncmp(p, "name", strlen("name"))) - StrnCpy(info->name, v, strlen(v)); - - if (!strncmp(p, "environment", strlen("environment"))) - StrnCpy(info->environment, v, strlen(v)); - - if (!strncmp(p, "driverpath", strlen("driverpath"))) - StrnCpy(info->driverpath, v, strlen(v)); - - if (!strncmp(p, "datafile", strlen("datafile"))) - StrnCpy(info->datafile, v, strlen(v)); - - if (!strncmp(p, "configfile", strlen("configfile"))) - StrnCpy(info->configfile, v, strlen(v)); - - if (!strncmp(p, "helpfile", strlen("helpfile"))) - StrnCpy(info->helpfile, v, strlen(v)); - - if (!strncmp(p, "monitorname", strlen("monitorname"))) - StrnCpy(info->monitorname, v, strlen(v)); - - if (!strncmp(p, "defaultdatatype", strlen("defaultdatatype"))) - StrnCpy(info->defaultdatatype, v, strlen(v)); - - if (!strncmp(p, "dependentfile", strlen("dependentfile"))) - { - dependentfiles=(char **)Realloc(dependentfiles, sizeof(char *)*(i+1)); - - dependentfiles[i]=(char *)malloc( sizeof(char)* (strlen(v)+1) ); - - StrnCpy(dependentfiles[i], v, strlen(v) ); - i++; - } - - } - - free(line); - - fclose(f); - - dependentfiles=(char **)Realloc(dependentfiles, sizeof(char *)*(i+1)); - dependentfiles[i]=(char *)malloc( sizeof(char) ); - *dependentfiles[i]='\0'; - - info->dependentfiles=dependentfiles; - - *info_ptr=info; - - return (0); -} - -/**************************************************************************** -debugging function, dump at level 6 the struct in the logs -****************************************************************************/ -static uint32 dump_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level) -{ - uint32 success; - NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3; - char **dependentfiles; - - DEBUG(6,("Dumping printer driver at level [%d]\n", level)); - - switch (level) - { - case 3: - { - if (driver.info_3 == NULL) - { - DEBUGADD(3,("NULL pointer, memory not alloced ?\n")); - success=5; - } - else - { - info3=driver.info_3; - - DEBUGADD(6,("version:[%d]\n", info3->cversion)); - DEBUGADD(6,("name:[%s]\n", info3->name)); - DEBUGADD(6,("environment:[%s]\n", info3->environment)); - DEBUGADD(6,("driverpath:[%s]\n", info3->driverpath)); - DEBUGADD(6,("datafile:[%s]\n", info3->datafile)); - DEBUGADD(6,("configfile:[%s]\n", info3->configfile)); - DEBUGADD(6,("helpfile:[%s]\n", info3->helpfile)); - DEBUGADD(6,("monitorname:[%s]\n", info3->monitorname)); - DEBUGADD(6,("defaultdatatype:[%s]\n", info3->defaultdatatype)); - - dependentfiles=info3->dependentfiles; - - while ( **dependentfiles != '\0' ) - { - DEBUGADD(6,("dependentfile:[%s]\n", *dependentfiles)); - dependentfiles++; - } - success=0; - } - break; - } - default: - DEBUGADD(1,("Level not implemented\n")); - success=1; - break; - } - - return (success); -} - -/**************************************************************************** -****************************************************************************/ -static void add_a_devicemode(NT_DEVICEMODE *nt_devmode, FILE *f) -{ - int i; - - fprintf(f, "formname: %s\n", nt_devmode->formname); - fprintf(f, "specversion: %d\n", nt_devmode->specversion); - fprintf(f, "driverversion: %d\n", nt_devmode->driverversion); - fprintf(f, "size: %d\n", nt_devmode->size); - fprintf(f, "driverextra: %d\n", nt_devmode->driverextra); - fprintf(f, "fields: %d\n", nt_devmode->fields); - fprintf(f, "orientation: %d\n", nt_devmode->orientation); - fprintf(f, "papersize: %d\n", nt_devmode->papersize); - fprintf(f, "paperlength: %d\n", nt_devmode->paperlength); - fprintf(f, "paperwidth: %d\n", nt_devmode->paperwidth); - fprintf(f, "scale: %d\n", nt_devmode->scale); - fprintf(f, "copies: %d\n", nt_devmode->copies); - fprintf(f, "defaultsource: %d\n", nt_devmode->defaultsource); - fprintf(f, "printquality: %d\n", nt_devmode->printquality); - fprintf(f, "color: %d\n", nt_devmode->color); - fprintf(f, "duplex: %d\n", nt_devmode->duplex); - fprintf(f, "yresolution: %d\n", nt_devmode->yresolution); - fprintf(f, "ttoption: %d\n", nt_devmode->ttoption); - fprintf(f, "collate: %d\n", nt_devmode->collate); - fprintf(f, "icmmethod: %d\n", nt_devmode->icmmethod); - fprintf(f, "icmintent: %d\n", nt_devmode->icmintent); - fprintf(f, "mediatype: %d\n", nt_devmode->mediatype); - fprintf(f, "dithertype: %d\n", nt_devmode->dithertype); - - if (nt_devmode->private != NULL) - { - fprintf(f, "private: "); - for (i=0; i<nt_devmode->driverextra; i++) - fprintf(f, "%02X", nt_devmode->private[i]); - fprintf(f, "\n"); - } -} - -/**************************************************************************** -****************************************************************************/ -static void save_specifics(NT_PRINTER_PARAM *param, FILE *f) -{ - int i; - - while (param != NULL) - { - fprintf(f, "specific: %s#%d#%d#", param->value, param->type, param->data_len); - - for (i=0; i<param->data_len; i++) - fprintf(f, "%02X", param->data[i]); - - fprintf(f, "\n"); - - param=param->next; - } -} - -/**************************************************************************** -****************************************************************************/ -static uint32 add_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info) -{ - FILE *f; - pstring file; - fstring printer_name; - NT_DEVICEMODE *nt_devmode; - - /* - * JFM: one day I'll forget. - * below that's info->portname because that's the SAMBA sharename - * and I made NT 'thinks' it's the portname - * the info->sharename is the thing you can name when you add a printer - * that's the short-name when you create shared printer for 95/98 - * So I've made a limitation in SAMBA: you can only have 1 printer model - * behind a SAMBA share. - */ - - - StrnCpy(printer_name, info->portname, sizeof(printer_name)-1); - - slprintf(file, sizeof(file)-1, "%s/NTprinter_%s", - lp_nt_drivers_file(), printer_name); - - /* create a file in the dir lp_nt_driver_file */ - /* with the full printer name */ - /* eg: "/usr/local/samba/lib/NTprinter_HP LaserJet 6MP" */ - /* each name is really defining an *unique* printer model */ - /* I don't want to mangle the name to find it back when enumerating */ - - if((f = sys_fopen(file, "w")) == NULL) - { - DEBUG(1, ("cannot create printer file [%s]\n", file)); - return(2); - } - - fprintf(f, "attributes: %d\n", info->attributes); - fprintf(f, "priority: %d\n", info->priority); - fprintf(f, "default_priority: %d\n", info->default_priority); - fprintf(f, "starttime: %d\n", info->starttime); - fprintf(f, "untiltime: %d\n", info->untiltime); - fprintf(f, "status: %d\n", info->status); - fprintf(f, "cjobs: %d\n", info->cjobs); - fprintf(f, "averageppm: %d\n", info->averageppm); - - /* - * in addprinter: no servername and the printer is the name - * in setprinter: servername is \\server - * and printer is \\server\\printer - * - * Samba manages only local printers. - * we currently don't support things like path=\\other_server\printer - */ - - if (info->servername[0]!='\0') - { - trim_string(info->printername, info->servername, NULL); - trim_string(info->printername, "\\", NULL); - info->servername[0]='\0'; - } - - fprintf(f, "servername: %s\n", info->servername); - fprintf(f, "printername: %s\n", info->printername); - fprintf(f, "sharename: %s\n", info->sharename); - fprintf(f, "portname: %s\n", info->portname); - fprintf(f, "drivername: %s\n", info->drivername); - fprintf(f, "comment: %s\n", info->comment); - fprintf(f, "location: %s\n", info->location); - fprintf(f, "sepfile: %s\n", info->sepfile); - fprintf(f, "printprocessor: %s\n", info->printprocessor); - fprintf(f, "datatype: %s\n", info->datatype); - fprintf(f, "parameters: %s\n", info->parameters); - - /* store the devmode and the private part if it exist */ - nt_devmode=info->devmode; - if (nt_devmode!=NULL) - { - add_a_devicemode(nt_devmode, f); - } - - /* and store the specific parameters */ - if (info->specific != NULL) - { - save_specifics(info->specific, f); - } - - fclose(f); - - return (0); -} - -/**************************************************************************** -fill a NT_PRINTER_PARAM from a text file - -used when reading from disk. -****************************************************************************/ -static void dissect_and_fill_a_param(NT_PRINTER_PARAM *param, char *v) -{ - char *tok[5]; - int count = 0; - - DEBUG(5,("dissect_and_fill_a_param\n")); - - tok[count] = strtok(v,"#"); - count++; - - while ( ((tok[count] = strtok(NULL,"#")) != NULL ) && count<4) - { - count++; - } - - StrnCpy(param->value, tok[0], sizeof(param->value)-1); - param->type=atoi(tok[1]); - param->data_len=atoi(tok[2]); - param->data=(uint8 *)malloc(param->data_len * sizeof(uint8)); - strhex_to_str(param->data, 2*(param->data_len), tok[3]); - param->next=NULL; - - DEBUGADD(5,("value:[%s], len:[%d]\n", param->value, param->data_len)); -} - -/**************************************************************************** -fill a NT_PRINTER_PARAM from a text file - -used when reading from disk. -****************************************************************************/ -void dump_a_param(NT_PRINTER_PARAM *param) -{ - DEBUG(5,("dump_a_param\n")); - DEBUGADD(6,("value [%s]\n", param->value)); - DEBUGADD(6,("type [%d]\n", param->type)); - DEBUGADD(6,("data len [%d]\n", param->data_len)); -} - -/**************************************************************************** -****************************************************************************/ -BOOL add_a_specific_param(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param) -{ - NT_PRINTER_PARAM *current; - - DEBUG(8,("add_a_specific_param\n")); - - param->next=NULL; - - if (info_2->specific == NULL) - { - info_2->specific=param; - } - else - { - current=info_2->specific; - while (current->next != NULL) { - current=current->next; - } - current->next=param; - } - return (True); -} - -/**************************************************************************** -****************************************************************************/ -BOOL unlink_specific_param_if_exist(NT_PRINTER_INFO_LEVEL_2 *info_2, NT_PRINTER_PARAM *param) -{ - NT_PRINTER_PARAM *current; - NT_PRINTER_PARAM *previous; - - current=info_2->specific; - previous=current; - - if (current==NULL) return (False); - - if ( !strcmp(current->value, param->value) && - (strlen(current->value)==strlen(param->value)) ) - { - DEBUG(9,("deleting first value\n")); - info_2->specific=current->next; - free(current); - DEBUG(9,("deleted first value\n")); - return (True); - } - - current=previous->next; - - while ( current!=NULL ) - { - if (!strcmp(current->value, param->value) && - strlen(current->value)==strlen(param->value) ) - { - DEBUG(9,("deleting current value\n")); - previous->next=current->next; - free(current); - DEBUG(9,("deleted current value\n")); - return(True); - } - - previous=previous->next; - current=current->next; - } - return (False); -} - -/**************************************************************************** -****************************************************************************/ -static uint32 get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharename) -{ - FILE *f; - pstring file; - fstring printer_name; - NT_PRINTER_INFO_LEVEL_2 *info; - NT_DEVICEMODE *nt_devmode; - NT_PRINTER_PARAM *param; - char *line; - fstring p; - char *v; - - /* - * the sharename argument is the SAMBA sharename - */ - StrnCpy(printer_name, sharename, sizeof(printer_name)-1); - - slprintf(file, sizeof(file)-1, "%s/NTprinter_%s", - lp_nt_drivers_file(), printer_name); - - if((f = sys_fopen(file, "r")) == NULL) - { - DEBUG(2, ("cannot open printer file [%s]\n", file)); - return(2); - } - - /* the file exists, allocate some memory */ - info=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2)); - ZERO_STRUCTP(info); - - nt_devmode=(NT_DEVICEMODE *)malloc(sizeof(NT_DEVICEMODE)); - ZERO_STRUCTP(nt_devmode); - init_devicemode(nt_devmode); - - info->devmode=nt_devmode; - - line=(char *)malloc(4096*sizeof(char)); - - while ( fgets(line, 4095, f) ) - { - - v=strncpyn(p, line, sizeof(p), ':'); - if (v==NULL) - { - DEBUG(1, ("malformed printer entry (no `:')\n")); - DEBUGADD(2, ("line [%s]\n", line)); - continue; - } - - v++; - - trim_string(v, " ", NULL); - trim_string(v, NULL, " "); - trim_string(v, NULL, "\n"); - - /* don't check if v==NULL as an empty arg is valid */ - - DEBUGADD(15, ("[%s]:[%s]\n", p, v)); - - /* - * The PRINTER_INFO_2 fields - */ - - if (!strncmp(p, "attributes", strlen("attributes"))) - info->attributes=atoi(v); - - if (!strncmp(p, "priority", strlen("priority"))) - info->priority=atoi(v); - - if (!strncmp(p, "default_priority", strlen("default_priority"))) - info->default_priority=atoi(v); - - if (!strncmp(p, "starttime", strlen("starttime"))) - info->starttime=atoi(v); - - if (!strncmp(p, "untiltime", strlen("untiltime"))) - info->untiltime=atoi(v); - - if (!strncmp(p, "status", strlen("status"))) - info->status=atoi(v); - - if (!strncmp(p, "cjobs", strlen("cjobs"))) - info->cjobs=atoi(v); - - if (!strncmp(p, "averageppm", strlen("averageppm"))) - info->averageppm=atoi(v); - - if (!strncmp(p, "servername", strlen("servername"))) - StrnCpy(info->servername, v, strlen(v)); - - if (!strncmp(p, "printername", strlen("printername"))) - StrnCpy(info->printername, v, strlen(v)); - - if (!strncmp(p, "sharename", strlen("sharename"))) - StrnCpy(info->sharename, v, strlen(v)); - - if (!strncmp(p, "portname", strlen("portname"))) - StrnCpy(info->portname, v, strlen(v)); - - if (!strncmp(p, "drivername", strlen("drivername"))) - StrnCpy(info->drivername, v, strlen(v)); - - if (!strncmp(p, "comment", strlen("comment"))) - StrnCpy(info->comment, v, strlen(v)); - - if (!strncmp(p, "location", strlen("location"))) - StrnCpy(info->location, v, strlen(v)); - - if (!strncmp(p, "sepfile", strlen("sepfile"))) - StrnCpy(info->sepfile, v, strlen(v)); - - if (!strncmp(p, "printprocessor", strlen("printprocessor"))) - StrnCpy(info->printprocessor, v, strlen(v)); - - if (!strncmp(p, "datatype", strlen("datatype"))) - StrnCpy(info->datatype, v, strlen(v)); - - if (!strncmp(p, "parameters", strlen("parameters"))) - StrnCpy(info->parameters, v, strlen(v)); - - /* - * The DEVICEMODE fields - */ - - if (!strncmp(p, "formname", strlen("formname"))) - StrnCpy(nt_devmode->formname, v, strlen(v)); - - if (!strncmp(p, "specversion", strlen("specversion"))) - nt_devmode->specversion=atoi(v); - - if (!strncmp(p, "driverversion", strlen("driverversion"))) - nt_devmode->driverversion=atoi(v); - - if (!strncmp(p, "size", strlen("size"))) - nt_devmode->size=atoi(v); - - if (!strncmp(p, "driverextra", strlen("driverextra"))) - nt_devmode->driverextra=atoi(v); - - if (!strncmp(p, "fields", strlen("fields"))) - nt_devmode->fields=atoi(v); - - if (!strncmp(p, "orientation", strlen("orientation"))) - nt_devmode->orientation=atoi(v); - - if (!strncmp(p, "papersize", strlen("papersize"))) - nt_devmode->papersize=atoi(v); - - if (!strncmp(p, "paperlength", strlen("paperlength"))) - nt_devmode->paperlength=atoi(v); - - if (!strncmp(p, "paperwidth", strlen("paperwidth"))) - nt_devmode->paperwidth=atoi(v); - - if (!strncmp(p, "scale", strlen("scale"))) - nt_devmode->scale=atoi(v); - - if (!strncmp(p, "copies", strlen("copies"))) - nt_devmode->copies=atoi(v); - - if (!strncmp(p, "defaultsource", strlen("defaultsource"))) - nt_devmode->defaultsource=atoi(v); - - if (!strncmp(p, "printquality", strlen("printquality"))) - nt_devmode->printquality=atoi(v); - - if (!strncmp(p, "color", strlen("color"))) - nt_devmode->color=atoi(v); - - if (!strncmp(p, "duplex", strlen("duplex"))) - nt_devmode->duplex=atoi(v); - - if (!strncmp(p, "yresolution", strlen("yresolution"))) - nt_devmode->yresolution=atoi(v); - - if (!strncmp(p, "ttoption", strlen("ttoption"))) - nt_devmode->ttoption=atoi(v); - - if (!strncmp(p, "collate", strlen("collate"))) - nt_devmode->collate=atoi(v); - - if (!strncmp(p, "icmmethod", strlen("icmmethod"))) - nt_devmode->icmmethod=atoi(v); - - if (!strncmp(p, "icmintent", strlen("icmintent"))) - nt_devmode->icmintent=atoi(v); - - if (!strncmp(p, "mediatype", strlen("mediatype"))) - nt_devmode->mediatype=atoi(v); - - if (!strncmp(p, "dithertype", strlen("dithertype"))) - nt_devmode->dithertype=atoi(v); - - if (!strncmp(p, "private", strlen("private"))) - { - nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra*sizeof(uint8)); - strhex_to_str(nt_devmode->private, 2*nt_devmode->driverextra, v); - } - - /* the specific */ - - if (!strncmp(p, "specific", strlen("specific"))) - { - param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM)); - ZERO_STRUCTP(param); - - dissect_and_fill_a_param(param, v); - - dump_a_param(param); - - add_a_specific_param(info, param); - } - - } - fclose(f); - free(line); - - *info_ptr=info; - - return (0); -} - -/**************************************************************************** -debugging function, dump at level 6 the struct in the logs -****************************************************************************/ -static uint32 dump_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level) -{ - uint32 success; - NT_PRINTER_INFO_LEVEL_2 *info2; - - DEBUG(6,("Dumping printer at level [%d]\n", level)); - - switch (level) - { - case 2: - { - if (printer.info_2 == NULL) - { - DEBUGADD(3,("NULL pointer, memory not alloced ?\n")); - success=5; - } - else - { - info2=printer.info_2; - - DEBUGADD(6,("attributes:[%d]\n", info2->attributes)); - DEBUGADD(6,("priority:[%d]\n", info2->priority)); - DEBUGADD(6,("default_priority:[%d]\n", info2->default_priority)); - DEBUGADD(6,("starttime:[%d]\n", info2->starttime)); - DEBUGADD(6,("untiltime:[%d]\n", info2->untiltime)); - DEBUGADD(6,("status:[%d]\n", info2->status)); - DEBUGADD(6,("cjobs:[%d]\n", info2->cjobs)); - DEBUGADD(6,("averageppm:[%d]\n", info2->averageppm)); - - DEBUGADD(6,("servername:[%s]\n", info2->servername)); - DEBUGADD(6,("printername:[%s]\n", info2->printername)); - DEBUGADD(6,("sharename:[%s]\n", info2->sharename)); - DEBUGADD(6,("portname:[%s]\n", info2->portname)); - DEBUGADD(6,("drivername:[%s]\n", info2->drivername)); - DEBUGADD(6,("comment:[%s]\n", info2->comment)); - DEBUGADD(6,("location:[%s]\n", info2->location)); - DEBUGADD(6,("sepfile:[%s]\n", info2->sepfile)); - DEBUGADD(6,("printprocessor:[%s]\n", info2->printprocessor)); - DEBUGADD(6,("datatype:[%s]\n", info2->datatype)); - DEBUGADD(6,("parameters:[%s]\n", info2->parameters)); - success=0; - } - break; - } - default: - DEBUGADD(1,("Level not implemented\n")); - success=1; - break; - } - - return (success); -} - -/* - * The function below are the high level ones. - * only those ones must be called from the spoolss code. - * JFM. - */ - - -/**************************************************************************** -****************************************************************************/ -uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level) -{ - uint32 success; - - dump_a_printer(printer, level); - - switch (level) - { - case 2: - { - success=add_a_printer_2(printer.info_2); - break; - } - default: - success=1; - break; - } - - return (success); -} - -/**************************************************************************** -****************************************************************************/ -uint32 get_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level, fstring sharename) -{ - uint32 success; - - switch (level) - { - case 2: - { - printer->info_2=NULL; - success=get_a_printer_2(&(printer->info_2), sharename); - break; - } - default: - success=1; - break; - } - - dump_a_printer(*printer, level); - return (success); -} - -/**************************************************************************** -****************************************************************************/ -uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level) -{ - uint32 success; - DEBUG(4,("freeing a printer at level [%d]\n", level)); - - switch (level) - { - case 2: - { - if (printer.info_2 != NULL) - { - if ((printer.info_2)->devmode != NULL) - { - DEBUG(6,("deleting DEVMODE\n")); - if ((printer.info_2)->devmode->private !=NULL ) - free((printer.info_2)->devmode->private); - free((printer.info_2)->devmode); - } - - if ((printer.info_2)->specific != NULL) - { - NT_PRINTER_PARAM *param; - NT_PRINTER_PARAM *next_param; - - param=(printer.info_2)->specific; - - while ( param != NULL) - { - next_param=param->next; - DEBUG(6,("deleting param [%s]\n", param->value)); - free(param->data); - free(param); - param=next_param; - } - } - - free(printer.info_2); - success=0; - } - else - { - success=4; - } - break; - } - default: - success=1; - break; - } - return (success); -} - -/**************************************************************************** -****************************************************************************/ -uint32 add_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level) -{ - uint32 success; - DEBUG(4,("adding a printer at level [%d]\n", level)); - dump_a_printer_driver(driver, level); - - switch (level) - { - case 3: - { - success=add_a_printer_driver_3(driver.info_3); - break; - } - default: - success=1; - break; - } - - return (success); -} -/**************************************************************************** -****************************************************************************/ -uint32 get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level, - fstring printername, fstring architecture) -{ - uint32 success; - - switch (level) - { - case 3: - { - success=get_a_printer_driver_3(&(driver->info_3), - printername, - architecture); - break; - } - default: - success=1; - break; - } - - dump_a_printer_driver(*driver, level); - return (success); -} - -/**************************************************************************** -****************************************************************************/ -uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level) -{ - uint32 success; - NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3; - char **dependentfiles; - - switch (level) - { - case 3: - { - if (driver.info_3 != NULL) - { - info3=driver.info_3; - dependentfiles=info3->dependentfiles; - - while ( **dependentfiles != '\0' ) - { - free (*dependentfiles); - dependentfiles++; - } - - /* the last one (1 char !) */ - free (*dependentfiles); - - dependentfiles=info3->dependentfiles; - free (dependentfiles); - - free(info3); - success=0; - } - else - { - success=4; - } - break; - } - default: - success=1; - break; - } - return (success); -} - -/**************************************************************************** -****************************************************************************/ -BOOL get_specific_param_by_index(NT_PRINTER_INFO_LEVEL printer, uint32 level, uint32 param_index, - fstring value, uint8 **data, uint32 *type, uint32 *len) -{ - /* right now that's enough ! */ - NT_PRINTER_PARAM *param; - int i=0; - - param=printer.info_2->specific; - - while (param != NULL && i < param_index) - { - param=param->next; - i++; - } - - if (param != NULL) - { - /* exited because it exist */ - *type=param->type; - StrnCpy(value, param->value, sizeof(value)-1); - *data=(uint8 *)malloc(param->data_len*sizeof(uint8)); - memcpy(*data, param->data, param->data_len); - *len=param->data_len; - return (True); - } - return (False); -} - -/**************************************************************************** -****************************************************************************/ -BOOL get_specific_param(NT_PRINTER_INFO_LEVEL printer, uint32 level, - fstring value, uint8 **data, uint32 *type, uint32 *len) -{ - /* right now that's enough ! */ - NT_PRINTER_PARAM *param; - - DEBUG(5, ("get_specific_param\n")); - - param=printer.info_2->specific; - - while (param != NULL) - { - if ( !strcmp(value, param->value) - && strlen(value)==strlen(param->value)) - break; - - param=param->next; - } - - DEBUG(6, ("found one param\n")); - if (param != NULL) - { - /* exited because it exist */ - *type=param->type; - - *data=(uint8 *)malloc(param->data_len*sizeof(uint8)); - memcpy(*data, param->data, param->data_len); - *len=param->data_len; - - DEBUG(6, ("exit of get_specific_param:true\n")); - return (True); - } - DEBUG(6, ("exit of get_specific_param:false\n")); - return (False); -} - -/**************************************************************************** -****************************************************************************/ -void init_devicemode(NT_DEVICEMODE *nt_devmode) -{ -/* - * should I init this ones ??? - nt_devmode->devicename -*/ - StrCpy(nt_devmode->formname, "A4"); - - nt_devmode->specversion = 0x0401; - nt_devmode->driverversion = 0x0400; - nt_devmode->size = 0x00DC; - nt_devmode->driverextra = 0x0000; - nt_devmode->fields = FORMNAME | TTOPTION | PRINTQUALITY | - DEFAULTSOURCE | COPIES | SCALE | - PAPERSIZE | ORIENTATION; - nt_devmode->orientation = 1; - nt_devmode->papersize = PAPER_A4; - nt_devmode->paperlength = 0; - nt_devmode->paperwidth = 0; - nt_devmode->scale = 0x64; - nt_devmode->copies = 01; - nt_devmode->defaultsource = BIN_FORMSOURCE; - nt_devmode->printquality = 0x0258; - nt_devmode->color = COLOR_MONOCHROME; - nt_devmode->duplex = DUP_SIMPLEX; - nt_devmode->yresolution = 0; - nt_devmode->ttoption = TT_SUBDEV; - nt_devmode->collate = COLLATE_FALSE; - nt_devmode->icmmethod = 0; - nt_devmode->icmintent = 0; - nt_devmode->mediatype = 0; - nt_devmode->dithertype = 0; - - /* non utilisés par un driver d'imprimante */ - nt_devmode->logpixels = 0; - nt_devmode->bitsperpel = 0; - nt_devmode->pelswidth = 0; - nt_devmode->pelsheight = 0; - nt_devmode->displayflags = 0; - nt_devmode->displayfrequency = 0; - nt_devmode->reserved1 = 0; - nt_devmode->reserved2 = 0; - nt_devmode->panningwidth = 0; - nt_devmode->panningheight = 0; - - nt_devmode->private=NULL; -} - -/* error code: - 0: everything OK - 1: level not implemented - 2: file doesn't exist - 3: can't allocate memory - 4: can't free memory - 5: non existant struct -*/ - -/* - A printer and a printer driver are 2 different things. - NT manages them separatelly, Samba does the same. - Why ? Simply because it's easier and it makes sense ! - - Now explanation: You have 3 printers behind your samba server, - 2 of them are the same make and model (laser A and B). But laser B - has an 3000 sheet feeder and laser A doesn't such an option. - Your third printer is an old dot-matrix model for the accounting :-). - - If the /usr/local/samba/lib directory (default dir), you will have - 5 files to describe all of this. - - 3 files for the printers (1 by printer): - NTprinter_laser A - NTprinter_laser B - NTprinter_accounting - 2 files for the drivers (1 for the laser and 1 for the dot matrix) - NTdriver_printer model X - NTdriver_printer model Y - -jfm: I should use this comment for the text file to explain - same thing for the forms BTW. - Je devrais mettre mes commentaires en francais, ca serait mieux :-) - -*/ - - diff --git a/source/rpc_client/cli_atsvc.c b/source/rpc_client/cli_atsvc.c deleted file mode 100644 index 9ba87e6e4a2..00000000000 --- a/source/rpc_client/cli_atsvc.c +++ /dev/null @@ -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; -} diff --git a/source/rpc_client/cli_brs.c b/source/rpc_client/cli_brs.c deleted file mode 100644 index f4e055f3944..00000000000 --- a/source/rpc_client/cli_brs.c +++ /dev/null @@ -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; -} - diff --git a/source/rpc_client/cli_connect.c b/source/rpc_client/cli_connect.c deleted file mode 100644 index f935b530444..00000000000 --- a/source/rpc_client/cli_connect.c +++ /dev/null @@ -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); -} diff --git a/source/rpc_client/cli_eventlog.c b/source/rpc_client/cli_eventlog.c deleted file mode 100644 index 85ba3022945..00000000000 --- a/source/rpc_client/cli_eventlog.c +++ /dev/null @@ -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; -} - diff --git a/source/rpc_client/cli_netlogon_sync.c b/source/rpc_client/cli_netlogon_sync.c deleted file mode 100644 index a56e37a8ed0..00000000000 --- a/source/rpc_client/cli_netlogon_sync.c +++ /dev/null @@ -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; -} diff --git a/source/rpc_client/cli_spoolss.c b/source/rpc_client/cli_spoolss.c deleted file mode 100644 index 7ddbb9dbe40..00000000000 --- a/source/rpc_client/cli_spoolss.c +++ /dev/null @@ -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; -} - diff --git a/source/rpc_client/cli_svcctl.c b/source/rpc_client/cli_svcctl.c deleted file mode 100644 index b284b2661e1..00000000000 --- a/source/rpc_client/cli_svcctl.c +++ /dev/null @@ -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; -} diff --git a/source/rpc_client/cli_use.c b/source/rpc_client/cli_use.c deleted file mode 100644 index 96122c307dd..00000000000 --- a/source/rpc_client/cli_use.c +++ /dev/null @@ -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); - } - } -} diff --git a/source/rpc_client/msrpc_lsarpc.c b/source/rpc_client/msrpc_lsarpc.c deleted file mode 100644 index 83ecc94197e..00000000000 --- a/source/rpc_client/msrpc_lsarpc.c +++ /dev/null @@ -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; -} diff --git a/source/rpc_client/msrpc_samr.c b/source/rpc_client/msrpc_samr.c deleted file mode 100644 index 621b218ad6d..00000000000 --- a/source/rpc_client/msrpc_samr.c +++ /dev/null @@ -1,1593 +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 - -BOOL req_user_info( const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid, - uint32 user_rid, - USER_INFO_FN(usr_inf)) -{ - SAM_USER_INFO_21 usr; - /* send user info query, level 0x15 */ - if (get_samr_query_userinfo( - pol_dom, - 0x15, user_rid, &usr)) - { - if (usr_inf != NULL) - { - usr_inf(domain, sid, user_rid, &usr); - } - return True; - } - return False; -} - -/**************************************************************************** -SAM Query User Groups. -****************************************************************************/ -uint32 sam_query_usergroups( - const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid, - uint32 user_rid, - const char *user_name, - uint32 *num_groups, - DOM_GID **gid, - char ***name, - uint32 **type, - USER_MEM_FN(usr_mem)) -{ - uint32 num_names = 0; - (*gid) = NULL; - /* send user group query */ - if (get_samr_query_usergroups( - pol_dom, - user_rid, num_groups, gid) && - gid != NULL) - { - uint32 i; - uint32 *rid_mem; - - rid_mem = (uint32*)malloc((*num_groups) * sizeof(rid_mem[0])); - - if (rid_mem == NULL) - { - free(*gid); - (*gid) = NULL; - return 0; - } - - for (i = 0; i < (*num_groups); i++) - { - rid_mem[i] = (*gid)[i].g_rid; - } - - if (samr_query_lookup_rids( - pol_dom, 0x3e8, - (*num_groups), rid_mem, - &num_names, name, type)) - { - usr_mem(domain, sid, - user_rid, user_name, - num_names, rid_mem, *name, *type); - } - } - - return num_names; -} - -static uint32 req_group_info( - const POLICY_HND *pol_dom, - const char *domain, const DOM_SID *sid, - uint32 user_rid, const char *user_name, - USER_MEM_FN(usr_mem)) -{ - uint32 num_groups; - uint32 num_names; - DOM_GID *gid = NULL; - char **name = NULL; - uint32 *type = NULL; - - num_names = sam_query_usergroups( pol_dom, - domain, sid, - user_rid, user_name, - &num_groups, &gid, - &name, &type, usr_mem); - - free_char_array(num_names, name); - if (type != NULL) - { - free(type); - } - - if (gid != NULL) - { - free(gid); - } - - return num_names; -} - -static void req_alias_info( - const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid1, uint32 user_rid, - const char *user_name, - USER_MEM_FN(usr_mem)) -{ - uint32 num_aliases; - uint32 *rid_mem = NULL; - uint32 *ptr_sid; - DOM_SID2 *als_sid; - - if (pol_dom == NULL) - { - return; - } - - ptr_sid = (uint32*) malloc(sizeof(ptr_sid[0]) * 1); - als_sid = (DOM_SID2*)malloc(sizeof(als_sid[0]) * 1); - - sid_copy(&als_sid[0].sid, sid1); - sid_append_rid(&als_sid[0].sid, user_rid); - als_sid[0].num_auths = als_sid[0].sid.num_auths; - - ptr_sid[0] = 1; - - /* send user alias query */ - if (samr_query_useraliases( - pol_dom, - ptr_sid, als_sid, &num_aliases, &rid_mem)) - { - uint32 num_names; - char **name = NULL; - uint32 *type = NULL; - - uint32 *rid_copy = (uint32*)malloc(num_aliases * sizeof(*rid_copy)); - - if (rid_copy != NULL) - { - uint32 i; - for (i = 0; i < num_aliases; i++) - { - rid_copy[i] = rid_mem[i]; - } - if (samr_query_lookup_rids( - pol_dom, 0x3e8, - num_aliases, rid_copy, - &num_names, &name, &type)) - { - usr_mem(domain, sid1, - user_rid, user_name, - num_names, rid_mem, name, type); - } - } - - free_char_array(num_names, name); - if (type != NULL) - { - free(type); - } - } - - if (rid_mem != NULL) - { - free(rid_mem); - rid_mem = NULL; - } - - if (ptr_sid != NULL) - { - free(ptr_sid); - ptr_sid = NULL; - } - if (als_sid != NULL) - { - free(als_sid); - als_sid = NULL; - } -} - -/**************************************************************************** -experimental SAM user display info. -****************************************************************************/ -void msrpc_sam_user( const POLICY_HND *pol_dom, const POLICY_HND *pol_blt, - const char* domain, - const DOM_SID *sid1, - const DOM_SID *blt_sid1, - uint32 user_rid, - char *user_name, - USER_FN(usr_fn), - USER_INFO_FN(usr_inf_fn), - USER_MEM_FN(usr_grp_fn), - USER_MEM_FN(usr_als_fn)) -{ - if (usr_fn != NULL) - { - usr_fn(domain, sid1, user_rid, user_name); - } - - if (usr_inf_fn != NULL) - { - req_user_info(pol_dom, - domain, sid1, - user_rid, - usr_inf_fn); - } - - if (usr_grp_fn != NULL) - { - req_group_info(pol_dom, - domain, sid1, - user_rid, user_name, - usr_grp_fn); - } - - if (usr_als_fn != NULL) - { - req_alias_info(pol_dom, - domain, sid1, - user_rid, user_name, - usr_als_fn); - req_alias_info(pol_blt, - domain, blt_sid1, - user_rid, user_name, - usr_als_fn); - } -} - -/**************************************************************************** -experimental SAM user query. -****************************************************************************/ -BOOL msrpc_sam_query_user( const char* srv_name, - const char* domain, - const DOM_SID *sid, - char *user_name, - USER_FN(usr_fn), - USER_INFO_FN(usr_inf_fn), - USER_MEM_FN(usr_grp_fn), - USER_MEM_FN(usr_als_fn)) -{ - BOOL res = True; - BOOL res1 = True; - - char *names[1]; - uint32 num_rids; - uint32 rid[MAX_LOOKUP_SIDS]; - uint32 type[MAX_LOOKUP_SIDS]; - POLICY_HND sam_pol; - POLICY_HND pol_dom; - - /* establish a connection. */ - res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; - - /* connect to the domain */ - res = res ? samr_open_domain( &sam_pol, 0x304, sid, &pol_dom) : False; - - /* look up user rid */ - names[0] = user_name; - res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8, - 1, names, - &num_rids, rid, type) : False; - - /* send user info query */ - if (res1 && num_rids == 1) - { - msrpc_sam_user( &pol_dom, NULL, - domain, - sid, NULL, - rid[0], - names[0], - usr_fn, usr_inf_fn, - usr_grp_fn, usr_als_fn); - } - else - { - res1 = False; - } - - res = res ? samr_close( &sam_pol) : False; - res = res ? samr_close( &pol_dom) : False; - - return res1; -} - -/**************************************************************************** -experimental SAM users enum. -****************************************************************************/ -int msrpc_sam_enum_users( const char* srv_name, - const char* domain, - const DOM_SID *sid1, - struct acct_info **sam, - uint32 *num_sam_entries, - USER_FN(usr_fn), - USER_INFO_FN(usr_inf_fn), - USER_MEM_FN(usr_grp_fn), - USER_MEM_FN(usr_als_fn)) -{ - DOM_SID sid_1_5_20; - uint32 user_idx; - BOOL res = True; - BOOL res1 = True; - BOOL res2 = True; - uint32 start_idx = 0x0; - uint16 unk_0 = 0x0; - uint16 acb_mask = 0; - uint16 unk_1 = 0x0; - uint32 ace_perms = 0x304; /* access control permissions */ - uint32 status; - POLICY_HND sam_pol; - POLICY_HND pol_dom; - POLICY_HND pol_blt; - - (*sam) = NULL; - (*num_sam_entries) = 0; - - string_to_sid(&sid_1_5_20, "S-1-5-32"); - - DEBUG(5,("Number of entries:%d unk_0:%04x acb_mask:%04x unk_1:%04x\n", - start_idx, unk_0, acb_mask, unk_1)); - - /* establish a connection. */ - res = res ? samr_connect( srv_name, 0x02000000, - &sam_pol) : False; - - /* connect to the domain */ - res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1, - &pol_dom) : False; - - /* connect to the S-1-5-20 domain */ - res2 = res ? samr_open_domain( &sam_pol, ace_perms, &sid_1_5_20, - &pol_blt) : False; - - if (res1) - { - /* read some users */ - do - { - status = samr_enum_dom_users( - &pol_dom, - &start_idx, acb_mask, unk_1, 0x100000, - sam, num_sam_entries); - - } while (status == STATUS_MORE_ENTRIES); - -#if 0 - if ((*num_sam_entries) == 0) - { - report(out_hnd, "No users\n"); - } -#endif - - /* query all the users */ - for (user_idx = 0; res && user_idx < - (*num_sam_entries); user_idx++) - { - uint32 user_rid = (*sam)[user_idx].rid; - char *user_name = (*sam)[user_idx].acct_name; - - msrpc_sam_user( &pol_dom, &pol_blt, - domain, - sid1, &sid_1_5_20, - user_rid, user_name, - usr_fn, usr_inf_fn, - usr_grp_fn, usr_als_fn); - } - } - - res2 = res2 ? samr_close( &pol_blt) : False; - res1 = res1 ? samr_close( &pol_dom) : False; - res = res ? samr_close( &sam_pol) : False; - - if (res) - { - DEBUG(5,("msrpc_sam_enum_users: succeeded\n")); - } - else - { - DEBUG(5,("msrpc_sam_enum_users: failed\n")); - } - - return (*num_sam_entries); -} - - -/**************************************************************************** -experimental SAM domain info query. -****************************************************************************/ -BOOL sam_query_dominfo(const char* srv_name, - const DOM_SID *sid1, - uint32 switch_value, SAM_UNK_CTR *ctr) -{ - BOOL res = True; - BOOL res1 = True; - BOOL res2 = True; - uint32 ace_perms = 0x02000000; /* absolutely no idea. */ - POLICY_HND sam_pol; - POLICY_HND pol_dom; - - /* establish a connection. */ - res = res ? samr_connect( - srv_name, 0x02000000, - &sam_pol) : False; - - /* connect to the domain */ - res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1, - &pol_dom) : False; - - /* send a samr 0x8 command */ - res2 = res ? samr_query_dom_info( - &pol_dom, switch_value, ctr) : False; - - res1 = res1 ? samr_close( &sam_pol) : False; - - res = res ? samr_close( &pol_dom) : False; - - if (res2) - { - DEBUG(5,("sam_query_dominfo: succeeded\n")); - } - else - { - DEBUG(5,("sam_query_dominfo: failed\n")); - } - - return res2; -} - - -BOOL query_aliasinfo( - const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid, - uint32 alias_rid, - ALIAS_INFO_FN(grp_inf)) -{ - ALIAS_INFO_CTR ctr; - - /* send alias info query */ - if (get_samr_query_aliasinfo( - pol_dom, - 3, /* info level */ - alias_rid, &ctr)) - { - if (grp_inf != NULL) - { - grp_inf(domain, sid, alias_rid, &ctr); - } - return True; - } - return False; -} - -BOOL sam_query_aliasmem(const char *srv_name, - const POLICY_HND *pol_dom, - uint32 alias_rid, - uint32 *num_names, - DOM_SID ***sids, - char ***name, - uint8 **type) -{ - BOOL res3 = True; - BOOL res4 = True; - DOM_SID2 sid_mem[MAX_LOOKUP_SIDS]; - uint32 num_aliases = 0; - - *sids = NULL; - *num_names = 0; - *name = NULL; - *type = NULL; - - /* get alias members */ - res3 = get_samr_query_aliasmem( - pol_dom, - alias_rid, &num_aliases, sid_mem); - - if (res3 && num_aliases != 0) - { - POLICY_HND lsa_pol; - - uint32 i; - uint32 numsids = 0; - - for (i = 0; i < num_aliases; i++) - { - add_sid_to_array(&numsids, sids, &sid_mem[i].sid); - } - - /* lookup domain controller; receive a policy handle */ - res3 = res3 ? lsa_open_policy( srv_name, - &lsa_pol, True) : False; - - /* send lsa lookup sids call */ - res4 = res3 ? lsa_lookup_sids( &lsa_pol, - num_aliases, *sids, - name, type, num_names) : False; - - res3 = res3 ? lsa_close(&lsa_pol) : False; - } - - if (!res4) - { - free_char_array(*num_names, *name); - if ((*type) != NULL) - { - free(*type); - } - if ((*sids) != NULL) - { - free_sid_array(num_aliases, *sids); - } - *num_names = 0; - *name = NULL; - *type = NULL; - *sids = NULL; - } - - return res4; -} - -BOOL req_aliasmem_info(const char* srv_name, - const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid, - uint32 alias_rid, - const char *alias_name, - ALIAS_MEM_FN(als_mem)) -{ - uint32 num_names = 0; - char **name = NULL; - uint8 *type = NULL; - DOM_SID **sids = NULL; - - if (sam_query_aliasmem( srv_name, pol_dom, alias_rid, - &num_names, &sids, - &name, &type)) - { - als_mem(domain, sid, - alias_rid, alias_name, - num_names, sids, name, type); - - free_char_array(num_names, name); - if (type != NULL) - { - free(type); - } - if (sids != NULL) - { - free_sid_array(num_names, sids); - } - return True; - } - return False; -} - -BOOL sam_query_groupmem( - const POLICY_HND *pol_dom, - uint32 group_rid, - uint32 *num_names, - uint32 **rid_mem, - char ***name, - uint32 **type) -{ - uint32 num_mem; - uint32 *attr_mem = NULL; - BOOL res3; - - *rid_mem = NULL; - *num_names = 0; - *name = NULL; - *type = NULL; - - /* get group members */ - res3 = get_samr_query_groupmem( - pol_dom, - group_rid, &num_mem, rid_mem, &attr_mem); - - if (res3 && num_mem != 0) - { - uint32 *rid_copy = (uint32*)malloc(num_mem * - sizeof(rid_copy[0])); - - if (rid_copy != NULL) - { - uint32 i; - for (i = 0; i < num_mem; i++) - { - rid_copy[i] = (*rid_mem)[i]; - } - /* resolve names */ - res3 = samr_query_lookup_rids( - pol_dom, 1000, - num_mem, rid_copy, num_names, name, type); - } - } - else - { - if (attr_mem != NULL) - { - free(attr_mem); - } - if ((*rid_mem) != NULL) - { - free(*rid_mem); - } - attr_mem = NULL; - *rid_mem = NULL; - } - - if (!res3) - { - free_char_array(*num_names, *name); - if ((*type) != NULL) - { - free(*type); - } - *num_names = 0; - *name = NULL; - *type = NULL; - } - - if (attr_mem != NULL) - { - free(attr_mem); - } - - return res3; -} - -BOOL query_groupinfo( const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid, - uint32 group_rid, - GROUP_INFO_FN(grp_inf)) -{ - GROUP_INFO_CTR ctr; - - /* send group info query */ - if (get_samr_query_groupinfo( - pol_dom, - 1, /* info level */ - group_rid, &ctr)) - { - if (grp_inf != NULL) - { - grp_inf(domain, sid, group_rid, &ctr); - } - return True; - } - return False; -} - -BOOL req_groupmem_info( const POLICY_HND *pol_dom, - const char *domain, - const DOM_SID *sid, - uint32 group_rid, - const char *group_name, - GROUP_MEM_FN(grp_mem)) -{ - uint32 num_names = 0; - char **name = NULL; - uint32 *type = NULL; - uint32 *rid_mem = NULL; - - if (sam_query_groupmem(pol_dom, group_rid, - &num_names, &rid_mem, &name, &type)) - { - grp_mem(domain, sid, - group_rid, group_name, - num_names, rid_mem, name, type); - - free_char_array(num_names, name); - if (type != NULL) - { - free(type); - } - if (rid_mem != NULL) - { - free(rid_mem); - } - return True; - } - return False; -} - -/**************************************************************************** -SAM Domains query. - DOMAIN_INFO_FN(dom_inf_fn), - DOMAIN_MEM_FN(dom_mem_fn)) -****************************************************************************/ -uint32 msrpc_sam_enum_domains( const char* srv_name, - struct acct_info **sam, - uint32 *num_sam_entries, - DOMAIN_FN(dom_fn), - DOMAIN_INFO_FN(dom_inf_fn)) -{ - BOOL res = True; - uint32 ace_perms = 0x02000000; /* access control permissions. */ - POLICY_HND sam_pol; - uint32 status; - - /* establish a connection. */ - res = res ? samr_connect( srv_name, ace_perms, - &sam_pol) : False; - - (*sam) = NULL; - (*num_sam_entries) = 0; - - if (res) - { - uint32 domain_idx; - uint32 start_idx = 0; - /* read some domains */ - do - { - status = samr_enum_domains( &sam_pol, - &start_idx, 0x10000, - sam, num_sam_entries); - - } while (status == STATUS_MORE_ENTRIES); - -#if 0 - if ((*num_sam_entries) == 0) - { - report(out_hnd, "No domains\n"); - } -#endif - - for (domain_idx = 0; domain_idx < (*num_sam_entries); domain_idx++) - { - char *domain_name = (*sam)[domain_idx].acct_name; - - if (dom_fn != NULL) - { - dom_fn(domain_name); - } - - if (dom_inf_fn != NULL) - { - uint32 switch_value = 2; - SAM_UNK_CTR ctr; - DOM_SID dom_sid; - /* connect to the domain */ - if (samr_query_lookup_domain( &sam_pol, - domain_name, - &dom_sid) && - sam_query_dominfo(srv_name, &dom_sid, - switch_value, &ctr)) - { - dom_inf_fn(domain_name, &dom_sid, - switch_value, &ctr); - } - } - } - } - - res = res ? samr_close(&sam_pol) : False; - - if (res) - { - DEBUG(5,("msrpc_sam_enum_domains: succeeded\n")); - } - else - { - DEBUG(5,("msrpc_sam_enum_domains: failed\n")); - } - return (*num_sam_entries); -} - -/**************************************************************************** -SAM groups query. -****************************************************************************/ -uint32 msrpc_sam_enum_groups( const char* srv_name, - const char* domain, - const DOM_SID *sid1, - struct acct_info **sam, - uint32 *num_sam_entries, - GROUP_FN(grp_fn), - GROUP_INFO_FN(grp_inf_fn), - GROUP_MEM_FN(grp_mem_fn)) -{ - BOOL res = True; - uint32 ace_perms = 0x02000000; /* access control permissions. */ - POLICY_HND sam_pol; - POLICY_HND pol_dom; - uint32 status; - - /* establish a connection. */ - res = res ? samr_connect( srv_name, 0x02000000, - &sam_pol) : False; - - /* connect to the domain */ - res = res ? samr_open_domain( &sam_pol, ace_perms, sid1, - &pol_dom) : False; - - (*sam) = NULL; - (*num_sam_entries) = 0; - - if (res) - { - uint32 group_idx; - uint32 start_idx = 0; - /* read some groups */ - do - { - status = samr_enum_dom_groups( - &pol_dom, - &start_idx, 0x100000, - sam, num_sam_entries); - - } while (status == STATUS_MORE_ENTRIES); - -#if 0 - if ((*num_sam_entries) == 0) - { - report(out_hnd, "No groups\n"); - } -#endif - - for (group_idx = 0; group_idx < (*num_sam_entries); group_idx++) - { - uint32 group_rid = (*sam)[group_idx].rid; - char *group_name = (*sam)[group_idx].acct_name; - - if (grp_fn != NULL) - { - grp_fn(domain, sid1, group_rid, group_name); - } - - if (grp_inf_fn != NULL) - { - query_groupinfo(&pol_dom, - domain, sid1, - group_rid, - grp_inf_fn); - } - if (grp_mem_fn != NULL) - { - req_groupmem_info(&pol_dom, - domain, sid1, - group_rid, group_name, - grp_mem_fn); - } - } - } - - res = res ? samr_close(&pol_dom) : False; - res = res ? samr_close(&sam_pol) : False; - - if (res) - { - DEBUG(5,("msrpc_sam_enum_groups: succeeded\n")); - } - else - { - DEBUG(5,("msrpc_sam_enum_groups: failed\n")); - } - return (*num_sam_entries); -} - -/**************************************************************************** -SAM aliases query. -****************************************************************************/ -uint32 msrpc_sam_enum_aliases( const char* srv_name, - const char* domain, - const DOM_SID *sid1, - struct acct_info **sam, - uint32 *num_sam_entries, - ALIAS_FN(als_fn), - ALIAS_INFO_FN(als_inf_fn), - ALIAS_MEM_FN(als_mem_fn)) -{ - BOOL res = True; - uint32 ace_perms = 0x02000000; /* access control permissions */ - POLICY_HND sam_pol; - POLICY_HND pol_dom; - uint32 status = 0x0; - - /* establish a connection. */ - res = res ? samr_connect( srv_name, 0x02000000, - &sam_pol) : False; - - /* connect to the domain */ - res = res ? samr_open_domain( - &sam_pol, ace_perms, sid1, - &pol_dom) : False; - - (*sam) = NULL; - (*num_sam_entries) = 0; - - if (res) - { - uint32 alias_idx; - uint32 start_idx = 0; - /* read some groups */ - do - { - status = samr_enum_dom_aliases( - &pol_dom, - &start_idx, 0x100000, - sam, num_sam_entries); - - } while (status == STATUS_MORE_ENTRIES); - -#if 0 - if ((*num_sam_entries) == 0) - { - report(out_hnd, "No aliases\n"); - } -#endif - - for (alias_idx = 0; alias_idx < (*num_sam_entries); alias_idx++) - { - uint32 alias_rid = (*sam)[alias_idx].rid; - char *alias_name = (*sam)[alias_idx].acct_name; - - if (als_fn != NULL) - { - als_fn(domain, sid1, alias_rid, alias_name); - } - - if (als_inf_fn != NULL) - { - query_aliasinfo(&pol_dom, - domain, sid1, - alias_rid, - als_inf_fn); - } - if (als_mem_fn != NULL) - { - req_aliasmem_info(srv_name, &pol_dom, - domain, sid1, - alias_rid, alias_name, - als_mem_fn); - } - } - } - - res = res ? samr_close(&sam_pol) : False; - res = res ? samr_close(&pol_dom) : False; - - if (res) - { - DEBUG(5,("msrpc_sam_enum_aliases: succeeded\n")); - } - else - { - DEBUG(5,("msrpc_sam_enum_aliases: failed\n")); - } - - return (*num_sam_entries); -} - -/**************************************************************************** -do a SAMR create domain user -****************************************************************************/ -BOOL create_samr_domain_user( POLICY_HND *pol_dom, - char *acct_name, uint16 acb_info, - const char* password, int plen, - uint32 *rid) -{ - POLICY_HND pol_open_user; - BOOL ret = True; - BOOL res1 = True; - char pwbuf[516]; - SAM_USER_INFO_24 *p24; - SAM_USER_INFO_16 *p16; - SAM_USER_INFO_16 usr16; - - if (pol_dom == NULL || acct_name == NULL) return False; - - /* send create user */ - ret = samr_create_dom_user( pol_dom, - acct_name, acb_info, 0xe005000b, - &pol_open_user, rid); - - if (ret == 0x0) - { - samr_close(&pol_open_user); - } - - if (ret != 0 && ret != (NT_STATUS_USER_EXISTS | 0xC0000000)) - { - return False; - } - - if (ret == (NT_STATUS_USER_EXISTS | 0xC0000000)) - { - uint32 num_rids; - char *names[1]; - uint32 type[1]; - - names[0] = acct_name; - res1 = samr_query_lookup_names( pol_dom, 0x3e8, - 1, names, - &num_rids, rid, type); - if (res1 == False || type[0] != SID_NAME_USER) - { - return False; - } - } - - DEBUG(5,("create_samr_domain_user: name: %s rid 0x%x\n", - acct_name, *rid)); - - if (IS_BITS_SET_SOME(acb_info, ACB_NORMAL | ACB_DOMTRUST) && - password == NULL) - { - return True; - } - - encode_pw_buffer(pwbuf, password, plen, False); - - p24 = (SAM_USER_INFO_24*)malloc(sizeof(SAM_USER_INFO_24)); - if (p24 == NULL) - { - return False; - } - - make_sam_user_info24(p24, pwbuf, plen); - - res1 = set_samr_set_userinfo( pol_dom, 0x18, *rid, (void*)p24); - - if (res1 == False) - { - return False; - } - - /* send set user info */ - res1 = get_samr_query_userinfo( pol_dom, 0x10, *rid, (void*)&usr16); - - if (res1 == False) - { - return False; - } - - if (usr16.acb_info != acb_info) - { - p16 = (SAM_USER_INFO_16 *) malloc(sizeof(SAM_USER_INFO_16)); - if (p16 == NULL) - { - return False; - } - p16->acb_info = usr16.acb_info; - - res1 = set_samr_set_userinfo2( pol_dom, 0x10, *rid, (void*)p16); - } - - return res1; -} - -/**************************************************************************** -do a SAMR create domain alias -****************************************************************************/ -BOOL create_samr_domain_alias( POLICY_HND *pol_open_domain, - const char *acct_name, const char *acct_desc, - uint32 *rid) -{ - POLICY_HND pol_open_alias; - ALIAS_INFO_CTR ctr; - BOOL ret = True; - - if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False; - - /* send create alias */ - if (!samr_create_dom_alias( - pol_open_domain, - acct_name, - &pol_open_alias, rid)) - { - return False; - } - - DEBUG(5,("create_samr_domain_alias: name: %s rid 0x%x\n", - acct_name, *rid)); - - ctr.switch_value1 = 3; - make_samr_alias_info3(&ctr.alias.info3, acct_desc); - - /* send set alias info */ - if (!samr_set_aliasinfo( - &pol_open_alias, - &ctr)) - { - DEBUG(5,("create_samr_domain_alias: error in samr_set_aliasinfo\n")); - ret = False; - } - - return samr_close(&pol_open_alias) && ret; -} - -/**************************************************************************** -do a SAMR create domain group -****************************************************************************/ -BOOL create_samr_domain_group( - POLICY_HND *pol_open_domain, - const char *acct_name, const char *acct_desc, - uint32 *rid) -{ - POLICY_HND pol_open_group; - GROUP_INFO_CTR ctr; - BOOL ret = True; - - if (pol_open_domain == NULL || acct_name == NULL || acct_desc == NULL) return False; - - /* send create group*/ - if (!samr_create_dom_group( - pol_open_domain, - acct_name, - &pol_open_group, rid)) - { - return False; - } - - DEBUG(5,("create_samr_domain_group: name: %s rid 0x%x\n", - acct_name, *rid)); - - ctr.switch_value1 = 4; - ctr.switch_value2 = 4; - make_samr_group_info4(&ctr.group.info4, acct_desc); - - /* send user groups query */ - if (!samr_set_groupinfo( - &pol_open_group, - &ctr)) - { - DEBUG(5,("create_samr_domain_group: error in samr_set_groupinfo\n")); - ret = False; - } - - return samr_close(&pol_open_group) && ret; -} - -/**************************************************************************** -do a SAMR query user groups -****************************************************************************/ -BOOL get_samr_query_usergroups( const POLICY_HND *pol_open_domain, - uint32 user_rid, - uint32 *num_groups, DOM_GID **gid) -{ - POLICY_HND pol_open_user; - BOOL ret = True; - - if (pol_open_domain == NULL || num_groups == NULL || gid == NULL) return False; - - /* send open domain (on user sid) */ - if (!samr_open_user( - pol_open_domain, - 0x02011b, user_rid, - &pol_open_user)) - { - return False; - } - - /* send user groups query */ - if (!samr_query_usergroups( - &pol_open_user, - num_groups, gid)) - { - DEBUG(5,("samr_query_usergroups: error in query user groups\n")); - ret = False; - } - - return samr_close(&pol_open_user) && ret; -} - -/**************************************************************************** -do a SAMR delete group -****************************************************************************/ -BOOL delete_samr_dom_group( - POLICY_HND *pol_open_domain, - uint32 group_rid) -{ - POLICY_HND pol_open_group; - - if (pol_open_domain == NULL) return False; - - /* send open domain (on group rid) */ - if (!samr_open_group(pol_open_domain, - 0x00000010, group_rid, - &pol_open_group)) - { - return False; - } - - /* send group delete */ - if (!samr_delete_dom_group(&pol_open_group)) - - { - DEBUG(5,("delete_samr_dom_group: error in delete domain group\n")); - samr_close(&pol_open_group); - return False; - } - - return True; -} - - -/**************************************************************************** -do a SAMR query group members -****************************************************************************/ -BOOL get_samr_query_groupmem( - const POLICY_HND *pol_open_domain, - uint32 group_rid, uint32 *num_mem, - uint32 **rid, uint32 **attr) -{ - POLICY_HND pol_open_group; - BOOL ret = True; - - if (pol_open_domain == NULL || num_mem == NULL || rid == NULL || attr == NULL) return False; - - /* send open domain (on group sid) */ - if (!samr_open_group( pol_open_domain, - 0x00000010, group_rid, - &pol_open_group)) - { - return False; - } - - /* send group info query */ - if (!samr_query_groupmem(&pol_open_group, num_mem, rid, attr)) - - { - DEBUG(5,("samr_query_group: error in query group members\n")); - ret = False; - } - - return samr_close(&pol_open_group) && ret; -} - -/**************************************************************************** -do a SAMR delete alias -****************************************************************************/ -BOOL delete_samr_dom_alias( - POLICY_HND *pol_open_domain, - uint32 alias_rid) -{ - POLICY_HND pol_open_alias; - - if (pol_open_domain == NULL) return False; - - /* send open domain (on alias rid) */ - if (!samr_open_alias(pol_open_domain, - 0x000f001f, alias_rid, &pol_open_alias)) - { - return False; - } - - /* send alias delete */ - if (!samr_delete_dom_alias(&pol_open_alias)) - - { - DEBUG(5,("delete_samr_dom_alias: error in delete domain alias\n")); - samr_close(&pol_open_alias); - return False; - } - - return True; -} - - -/**************************************************************************** -do a SAMR query alias members -****************************************************************************/ -BOOL get_samr_query_aliasmem( - const POLICY_HND *pol_open_domain, - uint32 alias_rid, uint32 *num_mem, DOM_SID2 *sid) -{ - POLICY_HND pol_open_alias; - BOOL ret = True; - - if (pol_open_domain == NULL || num_mem == NULL || sid == NULL) return False; - - /* send open domain (on alias sid) */ - if (!samr_open_alias( pol_open_domain, - 0x000f001f, alias_rid, - &pol_open_alias)) - { - return False; - } - - /* send alias info query */ - if (!samr_query_aliasmem( &pol_open_alias, num_mem, sid)) - - { - DEBUG(5,("samr_query_alias: error in query alias members\n")); - ret = False; - } - - return samr_close(&pol_open_alias) && ret; -} - -/**************************************************************************** -do a SAMR set user info -****************************************************************************/ -BOOL set_samr_set_userinfo2( - POLICY_HND *pol_open_domain, - uint32 info_level, - uint32 user_rid, void *usr) -{ - POLICY_HND pol_open_user; - BOOL ret = True; - - if (pol_open_domain == NULL || usr == NULL) return False; - - /* send open domain (on user sid) */ - if (!samr_open_user( - pol_open_domain, - 0x000601b4, user_rid, - &pol_open_user)) - { - return False; - } - - /* send user info query */ - if (!samr_set_userinfo2( - &pol_open_user, - info_level, usr)) - { - DEBUG(5,("samr_set_userinfo: error in query user info, level 0x%x\n", - info_level)); - ret = False; - } - - return samr_close(&pol_open_user) && ret; -} - -/**************************************************************************** -do a SAMR set user info -****************************************************************************/ -BOOL set_samr_set_userinfo( - POLICY_HND *pol_open_domain, - uint32 info_level, - uint32 user_rid, void *usr) -{ - POLICY_HND pol_open_user; - BOOL ret = True; - - if (pol_open_domain == NULL || usr == NULL) return False; - - /* send open domain (on user sid) */ - if (!samr_open_user( - pol_open_domain, - 0x000601b4, user_rid, - &pol_open_user)) - { - return False; - } - - /* send user info query */ - if (!samr_set_userinfo( - &pol_open_user, - info_level, usr)) - { - DEBUG(5,("samr_set_userinfo: error in query user info, level 0x%x\n", - info_level)); - ret = False; - } - - return samr_close(&pol_open_user) && ret; -} - -/**************************************************************************** -do a SAMR query user info -****************************************************************************/ -BOOL get_samr_query_userinfo( - const POLICY_HND *pol_open_domain, - uint32 info_level, - uint32 user_rid, void *usr) -{ - POLICY_HND pol_open_user; - BOOL ret = True; - - if (pol_open_domain == NULL || usr == NULL) return False; - - /* send open domain (on user sid) */ - if (!samr_open_user( - pol_open_domain, - 0x02011b, user_rid, - &pol_open_user)) - { - return False; - } - - /* send user info query */ - if (!samr_query_userinfo( - &pol_open_user, - info_level, usr)) - { - DEBUG(5,("samr_query_userinfo: error in query user info, level 0x%x\n", - info_level)); - ret = False; - } - - return samr_close(&pol_open_user) && ret; -} - -/**************************************************************************** -do a SAMR query group info -****************************************************************************/ -BOOL get_samr_query_groupinfo( - const POLICY_HND *pol_open_domain, - uint32 info_level, - uint32 group_rid, GROUP_INFO_CTR *ctr) -{ - POLICY_HND pol_open_group; - BOOL ret = True; - - if (pol_open_domain == NULL || ctr == NULL) return False; - - bzero(ctr, sizeof(*ctr)); - - /* send open domain (on group sid) */ - if (!samr_open_group( - pol_open_domain, - 0x02000000, group_rid, &pol_open_group)) - { - return False; - } - - /* send group info query */ - if (!samr_query_groupinfo( - &pol_open_group, - info_level, ctr)) - { - DEBUG(5,("samr_query_groupinfo: error in query group info, level 0x%x\n", - info_level)); - ret = False; - } - - return samr_close(&pol_open_group) && ret; -} - -/**************************************************************************** -do a SAMR query alias info -****************************************************************************/ -BOOL get_samr_query_aliasinfo( - const POLICY_HND *pol_open_domain, - uint32 info_level, - uint32 alias_rid, ALIAS_INFO_CTR *ctr) -{ - POLICY_HND pol_open_alias; - BOOL ret = True; - - if (pol_open_domain == NULL || ctr == NULL) return False; - - bzero(ctr, sizeof(*ctr)); - - /* send open domain (on alias sid) */ - if (!samr_open_alias( - pol_open_domain, - 0x02000000, alias_rid, &pol_open_alias)) - { - return False; - } - - /* send alias info query */ - if (!samr_query_aliasinfo( - &pol_open_alias, - info_level, ctr)) - { - DEBUG(5,("samr_query_aliasinfo: error in query alias info, level 0x%x\n", - info_level)); - ret = False; - } - - return samr_close(&pol_open_alias) && ret; -} - -/**************************************************************************** -SAM create domain user. -****************************************************************************/ -BOOL msrpc_sam_create_dom_user(const char* srv_name, DOM_SID *sid1, - char *acct_name, uint16 acb_info, - const char *password, int plen, - uint32 *rid) -{ - BOOL res = True; - BOOL res1 = True; - BOOL res2 = True; - uint32 ace_perms = 0x02000000; /* absolutely no idea. */ - uint32 user_rid; - POLICY_HND sam_pol; - POLICY_HND pol_dom; - - /* establish a connection. */ - res = res ? samr_connect( - srv_name, 0x02000000, - &sam_pol) : False; - - /* connect to the domain */ - res1 = res ? samr_open_domain( - &sam_pol, ace_perms, sid1, - &pol_dom) : False; - - /* create a domain user */ - res2 = res1 ? create_samr_domain_user( &pol_dom, - acct_name, - acb_info, password, plen, &user_rid) : False; - - res1 = res1 ? samr_close( &pol_dom) : False; - res = res ? samr_close( &sam_pol) : False; - - if (res2) - { - DEBUG(5,("msrpc_sam_create_dom_user: succeeded\n")); - } - else - { - DEBUG(5,("msrpc_sam_create_dom_user: failed\n")); - } - - return res2; -} - -/**************************************************************************** -experimental SAM query display info. -****************************************************************************/ -BOOL msrpc_sam_query_dispinfo(const char* srv_name, const char* domain, - DOM_SID *sid1, - uint16 switch_value, - uint32 *num_entries, SAM_DISPINFO_CTR *ctr, - DISP_FN(disp_fn)) -{ - BOOL res = True; - BOOL res1 = True; - uint32 ace_perms = 0x304; /* absolutely no idea. */ - POLICY_HND sam_pol; - POLICY_HND pol_dom; - - /* establish a connection. */ - res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False; - - /* connect to the domain */ - res = res ? samr_open_domain( &sam_pol, ace_perms, sid1, - &pol_dom) : False; - - /* send a samr query_disp_info command */ - res1 = res ? samr_query_dispinfo( &pol_dom, switch_value, - num_entries, ctr) : False; - - res = res ? samr_close(&sam_pol) : False; - res = res ? samr_close(&pol_dom) : False; - - if (res1 && disp_fn != NULL) - { - disp_fn(domain, sid1, switch_value, *num_entries, ctr); - } - - return res1; -} - diff --git a/source/rpc_parse/parse_at.c b/source/rpc_parse/parse_at.c deleted file mode 100644 index a03a8cfad97..00000000000 --- a/source/rpc_parse/parse_at.c +++ /dev/null @@ -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; -} diff --git a/source/rpc_parse/parse_brs.c b/source/rpc_parse/parse_brs.c deleted file mode 100644 index 723866e9f9a..00000000000 --- a/source/rpc_parse/parse_brs.c +++ /dev/null @@ -1,180 +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) Paul Ashton 1997-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_brs_q_query_info - ********************************************************************/ -BOOL make_brs_q_query_info(BRS_Q_QUERY_INFO *q_u, - const char *server, uint16 switch_value) -{ - DEBUG(5,("make_brs_q_query_info\n")); - - make_buf_unistr2(&(q_u->uni_srv_name), &(q_u->ptr_srv_name), server); - q_u->switch_value1 = switch_value; - q_u->switch_value2 = switch_value; - - q_u->ptr = 1; - q_u->pad1 = 0x0; - q_u->pad2 = 0x0; - - return True; -} - -/******************************************************************* -reads or writes a BRS_Q_QUERY_INFO structure. -********************************************************************/ -BOOL brs_io_q_query_info(char *desc, BRS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "brs_io_q_query_info"); - depth++; - - prs_align(ps); - - prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name)); - smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth); - prs_align(ps); - - prs_uint16("switch_value1", ps, depth, &(q_u->switch_value1)); - prs_align(ps); - - prs_uint16("switch_value2", ps, depth, &(q_u->switch_value2)); - prs_align(ps); - - prs_uint32("ptr", ps, depth, &(q_u->ptr)); - if (q_u->ptr) - { - prs_uint32("pad1", ps, depth, &(q_u->pad1)); - } - - prs_uint32("pad2", ps, depth, &(q_u->pad2)); - - return True; -} - -/******************************************************************* - brs_info_100 - ********************************************************************/ -BOOL make_brs_info_100(BRS_INFO_100 *inf) -{ - DEBUG(5,("BRS_INFO_100: %d\n", __LINE__)); - - inf->pad1 = 0x0; - inf->ptr2 = 0x1; - inf->pad2 = 0x0; - inf->pad3 = 0x0; - - return True; -} - -/******************************************************************* -reads or writes a BRS_INFO_100 structure. -********************************************************************/ -static BOOL brs_io_brs_info_100(char *desc, BRS_INFO_100 *inf, prs_struct *ps, int depth) -{ - if (inf == NULL) return False; - - prs_debug(ps, depth, desc, "brs_io_brs_info_100"); - depth++; - - prs_align(ps); - - prs_uint32("pad1", ps, depth, &(inf->pad1)); - prs_uint32("ptr2", ps, depth, &(inf->ptr2)); - prs_uint32("pad2", ps, depth, &(inf->pad2)); - prs_uint32("pad3", ps, depth, &(inf->pad3)); - - return True; -} - -/******************************************************************* - make_brs_r_query_info - - only supports info level 100 at the moment. - - ********************************************************************/ -BOOL make_brs_r_query_info(BRS_R_QUERY_INFO *r_u, - uint32 switch_value, void *inf, - int status) -{ - DEBUG(5,("make_brs_r_unknown_0: %d\n", __LINE__)); - - r_u->switch_value1 = switch_value; /* same as in request */ - r_u->switch_value2 = switch_value; /* same as in request */ - - r_u->ptr_1 = inf != NULL ? 1 : 0; /* pointer 1 */ - r_u->info.id = inf; - - r_u->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL brs_io_r_query_info(char *desc, BRS_R_QUERY_INFO *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "brs_io_r_query_info"); - depth++; - - prs_align(ps); - - prs_uint16("switch_value1", ps, depth, &(r_u->switch_value1)); - prs_align(ps); - - prs_uint16("switch_value2", ps, depth, &(r_u->switch_value2)); - prs_align(ps); - - prs_uint32("ptr_1 ", ps, depth, &(r_u->ptr_1)); - if (r_u->ptr_1 != 0x0) - { - switch (r_u->switch_value1) - { - case 100: - { - brs_io_brs_info_100("inf", r_u->info.brs100, ps, depth); - break; - } - default: - { - break; - } - } - } - - prs_uint32("status ", ps, depth, &(r_u->status)); - - return True; -} - diff --git a/source/rpc_parse/parse_creds.c b/source/rpc_parse/parse_creds.c deleted file mode 100644 index c661d5a3c66..00000000000 --- a/source/rpc_parse/parse_creds.c +++ /dev/null @@ -1,563 +0,0 @@ -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tgrpsgell 1992-1999, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1999, - * Copyright (C) Paul Ashton 1997-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, Cambgrpsge, MA 02139, USA. - */ - - -#include "includes.h" - -extern int DEBUGLEVEL; - - -/******************************************************************* -makes a CREDS_UNIX structure. -********************************************************************/ -BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name, - const char* requested_name, - const char* real_name, - BOOL guest) -{ - if (r_u == NULL) return False; - - DEBUG(5,("make_creds_unix\n")); - - fstrcpy(r_u->user_name , user_name); - fstrcpy(r_u->requested_name, requested_name); - fstrcpy(r_u->real_name , real_name); - r_u->guest = guest; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_unix(char *desc, CREDS_UNIX *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_unix"); - depth++; - - prs_align(ps); - prs_string("user_name", ps, depth, r_u->user_name, strlen(r_u->user_name), sizeof(r_u->user_name)); - prs_align(ps); - prs_string("requested_name", ps, depth, r_u->requested_name, strlen(r_u->requested_name), sizeof(r_u->requested_name)); - prs_align(ps); - prs_string("real_name", ps, depth, r_u->real_name, strlen(r_u->real_name), sizeof(r_u->real_name)); - prs_align(ps); - prs_uint32("guest", ps, depth, &(r_u->guest)); - return True; -} - - -/******************************************************************* -frees a structure. -********************************************************************/ -void creds_free_unix(CREDS_UNIX *r_u) -{ -} - -/******************************************************************* -makes a CREDS_UNIX_SEC structure. -********************************************************************/ -BOOL make_creds_unix_sec(CREDS_UNIX_SEC *r_u, - uint32 uid, uint32 gid, uint32 num_grps, gid_t *grps) -{ - int i; - if (r_u == NULL) return False; - - DEBUG(5,("make_creds_unix_sec\n")); - - r_u->uid = uid; - r_u->gid = gid; - r_u->num_grps = num_grps; - r_u->grps = (uint32*)Realloc(NULL, sizeof(r_u->grps[0]) * - r_u->num_grps); - if (r_u->grps == NULL && num_grps != 0) - { - return False; - } - for (i = 0; i < num_grps; i++) - { - r_u->grps[i] = (gid_t)grps[i]; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_unix_sec(char *desc, CREDS_UNIX_SEC *r_u, prs_struct *ps, int depth) -{ - uint32 i; - - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_unix_sec"); - depth++; - - prs_align(ps); - - prs_uint32("uid", ps, depth, &(r_u->uid)); - prs_uint32("gid", ps, depth, &(r_u->gid)); - prs_uint32("num_grps", ps, depth, &(r_u->num_grps)); - if (r_u->num_grps != 0) - { - r_u->grps = (uint32*)Realloc(r_u->grps, - sizeof(r_u->grps[0]) * - r_u->num_grps); - if (r_u->grps == NULL) - { - creds_free_unix_sec(r_u); - return False; - } - } - for (i = 0; i < r_u->num_grps; i++) - { - prs_uint32("", ps, depth, &(r_u->grps[i])); - } - return True; -} - - -/******************************************************************* -frees a structure. -********************************************************************/ -void creds_free_unix_sec(CREDS_UNIX_SEC *r_u) -{ - if (r_u->grps != NULL) - { - free(r_u->grps); - r_u->grps = NULL; - } -} - -/******************************************************************* -makes a CREDS_NT_SEC structure. -********************************************************************/ -BOOL make_creds_nt_sec(CREDS_NT_SEC *r_u, - DOM_SID *sid, uint32 num_grps, uint32 *grps) -{ - int i; - if (r_u == NULL) return False; - - DEBUG(5,("make_creds_unix_sec\n")); - - sid_copy(&r_u->sid, sid); - r_u->num_grps = num_grps; - r_u->grp_rids = (uint32*)Realloc(NULL, sizeof(r_u->grp_rids[0]) * - r_u->num_grps); - - if (r_u->grp_rids == NULL && num_grps != 0) - { - return False; - } - for (i = 0; i < num_grps; i++) - { - r_u->grp_rids[i] = grps[i]; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_nt_sec(char *desc, CREDS_NT_SEC *r_u, prs_struct *ps, int depth) -{ - int i; - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_nt"); - depth++; - - prs_align(ps); - - smb_io_dom_sid ("sid", &r_u->sid, ps, depth); - prs_align(ps); - - prs_uint32("num_grps", ps, depth, &(r_u->num_grps)); - if (r_u->num_grps != 0) - { - r_u->grp_rids = (uint32*)Realloc(r_u->grp_rids, - sizeof(r_u->grp_rids[0]) * - r_u->num_grps); - if (r_u->grp_rids == NULL) - { - creds_free_nt_sec(r_u); - return False; - } - } - for (i = 0; i < r_u->num_grps; i++) - { - prs_uint32("", ps, depth, &(r_u->grp_rids[i])); - } - - return True; -} - -/******************************************************************* -frees a structure. -********************************************************************/ -void creds_free_nt_sec(CREDS_NT_SEC *r_u) -{ - if (r_u->grp_rids != NULL) - { - free(r_u->grp_rids); - r_u->grp_rids = NULL; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_pwd_info(char *desc, struct pwd_info *pwd, prs_struct *ps, int depth) -{ - if (pwd == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_pwd_info"); - depth++; - - prs_align(ps); - - prs_uint32("nullpwd", ps, depth, &(pwd->null_pwd)); - if (pwd->null_pwd) - { - return True; - } - - prs_uint32("cleartext", ps, depth, &(pwd->cleartext)); - if (pwd->cleartext) - { - prs_string("password", ps, depth, pwd->password, strlen(pwd->password), sizeof(pwd->password)); - prs_align(ps); - return True; - } - prs_uint32("crypted", ps, depth, &(pwd->crypted)); - - prs_uint8s(False, "smb_lm_pwd", ps, depth, (char*)&pwd->smb_lm_pwd, sizeof(pwd->smb_lm_pwd)); - prs_align(ps); - prs_uint8s(False, "smb_nt_pwd", ps, depth, (char*)&pwd->smb_nt_pwd, sizeof(pwd->smb_nt_pwd)); - prs_align(ps); - - prs_uint8s(False, "smb_lm_owf", ps, depth, (char*)&pwd->smb_lm_owf, sizeof(pwd->smb_lm_owf)); - prs_align(ps); - prs_uint32("nt_owf_len", ps, depth, &(pwd->nt_owf_len)); - if (pwd->nt_owf_len > sizeof(pwd->smb_nt_owf)) - { - return False; - } - prs_uint8s(False, "smb_nt_owf", ps, depth, (char*)&pwd->smb_nt_owf, pwd->nt_owf_len); - prs_align(ps); - - prs_uint8s(False, "lm_cli_chal", ps, depth, (char*)&pwd->lm_cli_chal, sizeof(pwd->lm_cli_chal)); - prs_align(ps); - prs_uint32("nt_cli_chal_len", ps, depth, &(pwd->nt_cli_chal_len)); - - if (pwd->nt_cli_chal_len > sizeof(pwd->nt_cli_chal)) - { - return False; - } - prs_uint8s(False, "nt_cli_chal", ps, depth, (char*)&pwd->nt_cli_chal, pwd->nt_cli_chal_len); - prs_align(ps); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_nt(char *desc, CREDS_NT *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_nt"); - depth++; - - prs_align(ps); - - /* lkclXXXX CHEAT!!!!!!!! */ - prs_string("user_name", ps, depth, r_u->user_name, strlen(r_u->user_name), sizeof(r_u->user_name)); - prs_align(ps); - prs_string("domain", ps, depth, r_u->domain, strlen(r_u->domain), sizeof(r_u->domain)); - prs_align(ps); - - creds_io_pwd_info("pwd", &r_u->pwd, ps, depth); - prs_align(ps); - - prs_uint32("ntlmssp", ps, depth, &(r_u->ntlmssp_flags)); - - return True; -} - -/******************************************************************* -frees a structure. -********************************************************************/ -void creds_free_nt(CREDS_NT *r_u) -{ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_hybrid(char *desc, CREDS_HYBRID *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_hybrid"); - depth++; - - prs_align(ps); - - prs_uint32("reuse", ps, depth, &(r_u->reuse)); - prs_uint32("ptr_ntc", ps, depth, &(r_u->ptr_ntc)); - prs_uint32("ptr_uxc", ps, depth, &(r_u->ptr_uxc)); - prs_uint32("ptr_nts", ps, depth, &(r_u->ptr_nts)); - prs_uint32("ptr_uxs", ps, depth, &(r_u->ptr_uxs)); - if (r_u->ptr_ntc != 0) - { - if (!creds_io_nt ("ntc", &r_u->ntc, ps, depth)) return False; - } - if (r_u->ptr_uxc != 0) - { - if (!creds_io_unix("uxc", &r_u->uxc, ps, depth)) return False; - } - if (r_u->ptr_nts != 0) - { - if (!creds_io_nt_sec ("nts", &r_u->nts, ps, depth)) return False; - } - if (r_u->ptr_uxs != 0) - { - if (!creds_io_unix_sec("uxs", &r_u->uxs, ps, depth)) return False; - } - return True; -} - -void copy_unix_creds(CREDS_UNIX *to, const CREDS_UNIX *from) -{ - if (from == NULL) - { - to->user_name[0] = 0; - return; - } - fstrcpy(to->user_name, from->user_name); -}; - -void copy_nt_sec_creds(CREDS_NT_SEC *to, const CREDS_NT_SEC *from) -{ - if (from == NULL) - { - ZERO_STRUCTP(to); - return; - } - memcpy(&to, &from, sizeof(*from)); -}; - -void copy_unix_sec_creds(CREDS_UNIX_SEC *to, const CREDS_UNIX_SEC *from) -{ - if (from == NULL) - { - to->uid = -1; - to->gid = -1; - to->num_grps = 0; - to->grps = NULL; - return; - } - to->uid = from->uid; - to->gid = from->gid; - to->num_grps = 0; - to->grps = NULL; - - if (from->num_grps != 0) - { - size_t size = from->num_grps * sizeof(from->grps[0]); - to->grps = (uint32*)malloc(size); - if (to->grps == NULL) - { - return; - } - to->num_grps = from->num_grps; - memcpy(to->grps, from->grps, size); - } -}; - -void copy_nt_creds(struct ntuser_creds *to, - const struct ntuser_creds *from) -{ - if (from == NULL) - { - to->domain[0] = 0; - to->user_name[0] = 0; - pwd_set_nullpwd(&to->pwd); - to->ntlmssp_flags = 0; - - return; - } - safe_strcpy(to->domain , from->domain , sizeof(from->domain )-1); - safe_strcpy(to->user_name, from->user_name, sizeof(from->user_name)-1); - memcpy(&to->pwd, &from->pwd, sizeof(from->pwd)); - to->ntlmssp_flags = from->ntlmssp_flags; -}; - -void copy_user_creds(struct user_creds *to, - const struct user_creds *from) -{ - ZERO_STRUCTP(to); - if (from == NULL) - { - to->ptr_ntc = 0; - to->ptr_uxc = 0; - to->ptr_nts = 0; - to->ptr_uxs = 0; - copy_nt_creds(&to->ntc, NULL); - copy_unix_creds(&to->uxc, NULL); - copy_nt_sec_creds(&to->nts, NULL); - copy_unix_sec_creds(&to->uxs, NULL); - to->reuse = False; - return; - } - to->ptr_nts = from->ptr_nts; - to->ptr_uxs = from->ptr_uxs; - to->ptr_ntc = from->ptr_ntc; - to->ptr_uxc = from->ptr_uxc; - if (to->ptr_ntc != 0) - { - copy_nt_creds(&to->ntc, &from->ntc); - } - if (to->ptr_uxc != 0) - { - copy_unix_creds(&to->uxc, &from->uxc); - } - if (to->ptr_ntc != 0) - { - copy_nt_sec_creds(&to->nts, &from->nts); - } - if (to->ptr_uxc != 0) - { - copy_unix_sec_creds(&to->uxs, &from->uxs); - } - to->reuse = from->reuse; -}; - -void free_user_creds(struct user_creds *creds) -{ - creds_free_unix(&creds->uxc); - creds_free_nt (&creds->ntc); - creds_free_unix_sec(&creds->uxs); - creds_free_nt_sec (&creds->nts); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL creds_io_cmd(char *desc, CREDS_CMD *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "creds_io_cmd"); - depth++; - - prs_align(ps); - - prs_uint16("version", ps, depth, &(r_u->version)); - prs_uint16("command", ps, depth, &(r_u->command)); - - prs_string("name ", ps, depth, r_u->name, strlen(r_u->name), sizeof(r_u->name)); - prs_align(ps); - - prs_uint32("ptr_creds", ps, depth, &(r_u->ptr_creds)); - if (r_u->ptr_creds != 0) - { - if (!creds_io_hybrid("creds", r_u->cred, ps, depth)) - { - return False; - } - } - - - return True; -} - - -BOOL create_ntuser_creds( prs_struct *ps, - const char* name, - uint16 version, uint16 command, - const struct ntuser_creds *ntu, - BOOL reuse) -{ - CREDS_CMD cmd; - struct user_creds usr; - - ZERO_STRUCT(cmd); - ZERO_STRUCT(usr); - - DEBUG(10,("create_user_creds: %s %d %d\n", - name, version, command)); - - usr.reuse = reuse; - - fstrcpy(cmd.name, name); - cmd.version = version; - cmd.command = command; - cmd.ptr_creds = ntu != NULL ? 1 : 0; - cmd.cred = &usr; - - if (ntu != NULL) - { - copy_nt_creds(&usr.ntc, ntu); - usr.ptr_ntc = 1; - } - else - { - usr.ptr_ntc = 0; - } - - prs_init(ps, 1024, 4, 0, False); - - ps->offset = 4; - return creds_io_cmd("creds", &cmd, ps, 0); -} - -BOOL create_user_creds( prs_struct *ps, - const char* name, - uint16 version, uint16 command, - const struct user_creds *usr) -{ - CREDS_CMD cmd; - - ZERO_STRUCT(cmd); - - DEBUG(10,("create_user_creds: %s %d %d\n", - name, version, command)); - - fstrcpy(cmd.name, name); - cmd.version = version; - cmd.command = command; - cmd.ptr_creds = usr != NULL ? 1 : 0; - cmd.cred = usr; - - prs_init(ps, 1024, 4, 0, False); - - ps->offset = 4; - return creds_io_cmd("creds", &cmd, ps, 0); -} diff --git a/source/rpc_parse/parse_eventlog.c b/source/rpc_parse/parse_eventlog.c deleted file mode 100644 index 0b49ed5da79..00000000000 --- a/source/rpc_parse/parse_eventlog.c +++ /dev/null @@ -1,261 +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) Jean François Micouleau 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. - */ - -#include "includes.h" - -extern int DEBUGLEVEL; - -/******************************************************************* -********************************************************************/ -BOOL make_eventlog_q_open(EVENTLOG_Q_OPEN *q_u, const char *journal, char *unk) -{ - int len_journal = journal != NULL ? strlen(journal) : 0; - int len_unk = unk != NULL ? strlen(unk) : 0; - - q_u->ptr0=0x1; - q_u->unk0=0x5c; - q_u->unk1=0x01; - - make_uni_hdr(&(q_u->hdr_source), len_journal); - make_unistr2(&(q_u->uni_source), journal, len_journal); - - make_uni_hdr(&(q_u->hdr_unk), len_unk); - make_unistr2(&(q_u->uni_unk), unk, len_unk); - - q_u->unk6=0x01; - q_u->unk7=0x01; - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_q_open(char *desc, EVENTLOG_Q_OPEN *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_q_open"); - depth++; - - prs_align(ps); - - prs_uint32("ptr0", ps, depth, &(q_u->ptr0)); - - prs_uint16("unk0", ps, depth, &(q_u->unk0)); - prs_uint16("unk1", ps, depth, &(q_u->unk1)); - - smb_io_unihdr("hdr_source", &(q_u->hdr_source), ps, depth); - smb_io_unistr2("uni_source", &(q_u->uni_source), - q_u->hdr_source.buffer, ps, depth); - prs_align(ps); - - smb_io_unihdr("hdr_unk", &(q_u->hdr_unk), ps, depth); - smb_io_unistr2("uni_unk", &(q_u->uni_unk), - q_u->hdr_unk.buffer, ps, depth); - prs_align(ps); - - prs_uint32("unk6", ps, depth, &(q_u->unk6)); - prs_uint32("unk7", ps, depth, &(q_u->unk7)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_r_open(char *desc, EVENTLOG_R_OPEN *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_r_open"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(r_u->pol), ps, depth); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_eventlog_q_close(EVENTLOG_Q_CLOSE *q_u, POLICY_HND *pol) -{ - memcpy(&(q_u->pol.data), pol->data, sizeof(q_u->pol.data)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_q_close(char *desc, EVENTLOG_Q_CLOSE *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_q_close"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_r_close(char *desc, EVENTLOG_R_CLOSE *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_r_close"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(r_u->pol), ps, depth); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_eventlog_q_numofeventlogrec(EVENTLOG_Q_NUMOFEVENTLOGREC *q_u, POLICY_HND *pol) -{ - memcpy(&(q_u->pol.data), pol->data, sizeof(q_u->pol.data)); - - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_q_numofeventlogrec(char *desc,EVENTLOG_Q_NUMOFEVENTLOGREC *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_q_numofeventlogrec"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_r_numofeventlogrec(char *desc, EVENTLOG_R_NUMOFEVENTLOGREC *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_r_numofeventlogrec"); - depth++; - - prs_align(ps); - prs_uint32("number", ps, depth, &(r_u->number)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_eventlog_q_readeventlog(EVENTLOG_Q_READEVENTLOG *q_u, POLICY_HND *pol, - uint32 flags, uint32 offset, uint32 number_of_bytes) -{ - memcpy(&(q_u->pol.data), pol->data, sizeof(q_u->pol.data)); - q_u->flags=flags; - q_u->offset=offset; - q_u->number_of_bytes=number_of_bytes; - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_q_readeventlog(char *desc, EVENTLOG_Q_READEVENTLOG *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_q_readeventlog"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - prs_uint32("flags", ps, depth, &(q_u->flags)); - prs_uint32("offset", ps, depth, &(q_u->offset)); - prs_uint32("number_of_bytes", ps, depth, &(q_u->number_of_bytes)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL eventlog_io_eventlog(char *desc, EVENTLOGRECORD *ev, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_eventlog"); - depth++; - - prs_align(ps); - prs_uint32("size", ps, depth, &(ev->size)); - prs_uint32("reserved", ps, depth, &(ev->reserved)); - prs_uint32("recordnumber", ps, depth, &(ev->recordnumber)); - prs_uint32("creationtime", ps, depth, &(ev->creationtime)); - prs_uint32("writetime", ps, depth, &(ev->writetime)); - prs_uint32("eventnumber", ps, depth, &(ev->eventnumber)); - - prs_uint16("eventtype", ps, depth, &(ev->eventtype)); - prs_uint16("num_of_strings", ps, depth, &(ev->num_of_strings)); - prs_uint16("category", ps, depth, &(ev->category)); - prs_uint16("reserved_flag", ps, depth, &(ev->reserved_flag)); - - prs_uint32("closingrecord", ps, depth, &(ev->closingrecord)); - prs_uint32("stringoffset", ps, depth, &(ev->stringoffset)); - prs_uint32("sid_length", ps, depth, &(ev->sid_length)); - prs_uint32("sid_offset", ps, depth, &(ev->sid_offset)); - prs_uint32("data_length", ps, depth, &(ev->data_length)); - prs_uint32("data_offset", ps, depth, &(ev->data_offset)); - - smb_io_unistr("", &(ev->sourcename), ps, depth); - smb_io_unistr("", &(ev->computername), ps, depth); - - if (ev->sid_length!=0) - smb_io_unistr("", &(ev->sid), ps, depth); - - if (ev->num_of_strings!=0) - smb_io_unistr("", &(ev->strings),ps, depth); - - if (ev->data_length) - smb_io_unistr("", &(ev->data), ps, depth); - - prs_uint32("size2", ps, depth, &(ev->size2)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL eventlog_io_r_readeventlog(char *desc, EVENTLOG_R_READEVENTLOG *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "eventlog_io_r_readeventlog"); - depth++; - - prs_align(ps); - prs_uint32("number_of_bytes", ps, depth, &(r_u->number_of_bytes)); - - if (r_u->number_of_bytes!= 0) - eventlog_io_eventlog("", r_u->event, ps, depth); - - prs_uint32("sent_size", ps, depth, &(r_u->sent_size)); - prs_uint32("real_size", ps, depth, &(r_u->real_size)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c deleted file mode 100644 index 5cb6179936f..00000000000 --- a/source/rpc_parse/parse_spoolss.c +++ /dev/null @@ -1,4408 +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) Jean François Micouleau 1998. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - - -/******************************************************************* -return the length of a UNISTR string. -********************************************************************/ -static uint32 str_len_uni(UNISTR *source) -{ - uint32 i=0; - - while (source->buffer[i]!=0x0000) - { - i++; - } - return i; -} - -/******************************************************************* -This should be moved in a more generic lib. -********************************************************************/ -static BOOL spoolss_io_system_time(char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime) -{ - prs_uint16("year", ps, depth, &(systime->year)); - prs_uint16("month", ps, depth, &(systime->month)); - prs_uint16("dayofweek", ps, depth, &(systime->dayofweek)); - prs_uint16("day", ps, depth, &(systime->day)); - prs_uint16("hour", ps, depth, &(systime->hour)); - prs_uint16("minute", ps, depth, &(systime->minute)); - prs_uint16("second", ps, depth, &(systime->second)); - prs_uint16("milliseconds", ps, depth, &(systime->milliseconds)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime) -{ - systime->year=unixtime->tm_year+1900; - systime->month=unixtime->tm_mon+1; - systime->dayofweek=unixtime->tm_wday; - systime->day=unixtime->tm_mday; - systime->hour=unixtime->tm_hour; - systime->minute=unixtime->tm_min; - systime->second=unixtime->tm_sec; - systime->milliseconds=0; - - return True; -} - -/******************************************************************* -reads or writes an POLICY_HND structure. -********************************************************************/ -static BOOL smb_io_prt_hnd(char *desc, POLICY_HND *hnd, prs_struct *ps, int depth) -{ - if (hnd == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_prt_hnd"); - depth++; - - prs_align(ps); - - prs_uint8s (False, "data", ps, depth, hnd->data, POLICY_HND_SIZE); - - return True; -} - -/******************************************************************* -reads or writes an DOC_INFO structure. -********************************************************************/ -static BOOL smb_io_doc_info_1(char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth) -{ - if (info_1 == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_doc_info_1"); - depth++; - - prs_align(ps); - - prs_uint32("p_docname", ps, depth, &(info_1->p_docname)); - prs_uint32("p_outputfile", ps, depth, &(info_1->p_outputfile)); - prs_uint32("p_datatype", ps, depth, &(info_1->p_datatype)); - - smb_io_unistr2("", &(info_1->docname), info_1->p_docname, ps, depth); - smb_io_unistr2("", &(info_1->outputfile), info_1->p_outputfile, ps, depth); - smb_io_unistr2("", &(info_1->datatype), info_1->p_datatype, ps, depth); - - return True; -} - -/******************************************************************* -reads or writes an DOC_INFO structure. -********************************************************************/ -static BOOL smb_io_doc_info(char *desc, DOC_INFO *info, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0; - - if (info == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_doc_info"); - depth++; - - prs_align(ps); - - prs_uint32("switch_value", ps, depth, &(info->switch_value)); - - prs_uint32("doc_info_X ptr", ps, depth, &(useless_ptr)); - - switch (info->switch_value) - { - case 1: - smb_io_doc_info_1("",&(info->doc_info_1), ps, depth); - break; - case 2: - /* - this is just a placeholder - - MSDN July 1998 says doc_info_2 is only on - Windows 95, and as Win95 doesn't do RPC to print - this case is nearly impossible - - Maybe one day with Windows for dishwasher 2037 ... - - */ - /* smb_io_doc_info_2("",&(info->doc_info_2), ps, depth); */ - break; - default: - DEBUG(0,("Something is obviously wrong somewhere !\n")); - break; - } - - return True; -} - -/******************************************************************* -reads or writes an DOC_INFO_CONTAINER structure. -********************************************************************/ -static BOOL smb_io_doc_info_container(char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth) -{ - if (cont == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_doc_info_container"); - depth++; - - prs_align(ps); - - prs_uint32("level", ps, depth, &(cont->level)); - - smb_io_doc_info("",&(cont->docinfo), ps, depth); - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION TYPE structure. -********************************************************************/ -static BOOL smb_io_notify_option_type(char *desc, - SPOOL_NOTIFY_OPTION_TYPE *type, - prs_struct *ps, int depth) -{ - uint32 useless_ptr; - - prs_debug(ps, depth, desc, "smb_io_notify_option_type"); - depth++; - - prs_align(ps); - - prs_uint16("type", ps, depth, &(type->type)); - prs_uint16("reserved0", ps, depth, &(type->reserved0)); - prs_uint32("reserved1", ps, depth, &(type->reserved1)); - prs_uint32("reserved2", ps, depth, &(type->reserved2)); - prs_uint32("count", ps, depth, &(type->count)); - prs_uint32("useless ptr", ps, depth, &useless_ptr); - - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION TYPE DATA. -********************************************************************/ -static BOOL smb_io_notify_option_type_data(char *desc, - SPOOL_NOTIFY_OPTION_TYPE *type, - prs_struct *ps, int depth) -{ - uint32 count; - int i; - - prs_debug(ps, depth, desc, "smb_io_notify_option_type_data"); - depth++; - - prs_align(ps); - - prs_uint32("count", ps, depth, &count); - - if (count != type->count) - { - DEBUG(4,("What a mess, count was %x now is %x !\n",type->count,count)); - type->count=count; - } - for(i=0;i<count;i++) - { - /* read the option type struct */ - prs_uint16("fields",ps,depth,&(type->fields[i])); - } - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION structure. -********************************************************************/ -static BOOL smb_io_notify_option(char *desc, SPOOL_NOTIFY_OPTION *option, - prs_struct *ps, int depth) -{ - uint32 useless_ptr; - int i; - - prs_debug(ps, depth, desc, "smb_io_notify_option"); - depth++; - - prs_align(ps); - - /* memory pointer to the struct */ - prs_uint32("useless ptr", ps, depth, &useless_ptr); - - prs_uint32("version", ps, depth, &(option->version)); - prs_uint32("reserved", ps, depth, &(option->reserved)); - prs_uint32("count", ps, depth, &(option->count)); - prs_uint32("useless ptr", ps, depth, &useless_ptr); - prs_uint32("count", ps, depth, &(option->count)); - - /* read the option type struct */ - for(i=0;i<option->count;i++) - { - smb_io_notify_option_type("",&(option->type[i]) ,ps, depth); - } - - /* now read the type associated with the option type struct */ - for(i=0;i<option->count;i++) - { - smb_io_notify_option_type_data("",&(option->type[i]) ,ps, depth); - } - - - return True; -} - - -/******************************************************************* -reads or writes an NOTIFY INFO DATA structure. -********************************************************************/ -static BOOL smb_io_notify_info_data(char *desc,SPOOL_NOTIFY_INFO_DATA *data, - prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - - uint32 how_many_words; - BOOL isvalue; - uint32 x; - - prs_debug(ps, depth, desc, "smb_io_notify_info_data"); - depth++; - - how_many_words=data->size; - if (how_many_words==POINTER) - { - how_many_words=TWO_VALUE; - } - - isvalue=data->enc_type; - - prs_align(ps); - prs_uint16("type", ps, depth, &(data->type)); - prs_uint16("field", ps, depth, &(data->field)); - /*prs_align(ps);*/ - - prs_uint32("how many words", ps, depth, &how_many_words); - prs_uint32("id", ps, depth, &(data->id)); - prs_uint32("how many words", ps, depth, &how_many_words); - /*prs_align(ps);*/ - - if (isvalue==True) - { - prs_uint32("value[0]", ps, depth, &(data->notify_data.value[0])); - prs_uint32("value[1]", ps, depth, &(data->notify_data.value[1])); - /*prs_align(ps);*/ - } - else - { - /* it's a string */ - /* length in ascii including \0 */ - x=2*(data->notify_data.data.length+1); - prs_uint32("string length", ps, depth, &x ); - prs_uint32("pointer", ps, depth, &useless_ptr); - /*prs_align(ps);*/ - } - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY INFO DATA structure. -********************************************************************/ -BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data, - prs_struct *ps, int depth) -{ - uint32 x; - BOOL isvalue; - - prs_debug(ps, depth, desc, "smb_io_notify_info_data"); - depth++; - - prs_align(ps); - isvalue=data->enc_type; - - if (isvalue==False) - { - /* length of string in unicode include \0 */ - x=data->notify_data.data.length+1; - prs_uint32("string length", ps, depth, &x ); - prs_uint16s(True,"string",ps,depth,data->notify_data.data.string,x); - } - prs_align(ps); - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY INFO structure. -********************************************************************/ -static BOOL smb_io_notify_info(char *desc, SPOOL_NOTIFY_INFO *info, - prs_struct *ps, int depth) -{ - uint32 useless_ptr=0x0001; - int i; - - info->version=0x02; - prs_debug(ps, depth, desc, "smb_io_notify_info"); - depth++; - - prs_align(ps); - - prs_uint32("pointer", ps, depth, &useless_ptr); - prs_uint32("count", ps, depth, &(info->count)); - prs_uint32("version", ps, depth, &(info->version)); - prs_uint32("flags", ps, depth, &(info->flags)); - prs_uint32("count", ps, depth, &(info->count)); - - for (i=0;i<info->count;i++) - { - smb_io_notify_info_data(desc, &(info->data[i]), ps, depth); - } - - /* now do the strings at the end of the stream */ - for (i=0;i<info->count;i++) - { - smb_io_notify_info_data_strings(desc, &(info->data[i]), - ps, depth); - } - - return True; -} - -/******************************************************************* - * write a structure. - * called from static spoolss_r_open_printer_ex (srv_spoolss.c) - * called from spoolss_open_printer_ex (cli_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_open_printer_ex(char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex"); - depth++; - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(r_u->handle),ps,depth); - -/* prs_align(ps);*/ - - prs_uint32("status code", ps, depth, &(r_u->status)); - - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ -BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, - const char *printername, - uint32 cbbuf, uint32 devmod, uint32 des_access, - const char *station, - const char *username) -{ - int len_name = printername != NULL ? strlen(printername) : 0; - int len_sta = station != NULL ? strlen(station ) : 0; - int len_user = username != NULL ? strlen(username ) : 0; - - if (q_u == NULL) return False; - - DEBUG(5,("make_spoolss_io_q_open_printer_ex\n")); - - q_u->ptr = 1; - make_unistr2(&(q_u->printername), printername, len_name); - - q_u->unknown0 = 0x0; /* 0x0000 0000 */ - q_u->cbbuf = cbbuf; /* 0x0000 0000 */ - q_u->devmod = devmod; /* 0x0000 0000 */ - q_u->access_required = des_access; - - q_u->unknown1 = 0x1; - q_u->unknown2 = 0x1; - q_u->unknown3 = 0x149f7d8; /* looks like a pointer */ - q_u->unknown4 = 0x1c; - q_u->unknown5 = 0x00b94dd0; - q_u->unknown6 = 0x0149f5cc; /* looks like _another_ pointer */ - q_u->unknown7 = 0x00000565; - q_u->unknown8 = 0x2; - q_u->unknown9 = 0x0; - q_u->unknown10 = 0x0; - - make_unistr2(&(q_u->station), station, len_sta); - make_unistr2(&(q_u->username), username, len_user); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_open_printer_ex (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex"); - depth++; - - prs_align(ps); - - prs_uint32("ptr", ps, depth, &(q_u->ptr)); - smb_io_unistr2("", &(q_u->printername),True,ps,depth); - - prs_align(ps); - - prs_uint32("unknown0", ps, depth, &(q_u->unknown0)); - prs_uint32("cbbuf", ps, depth, &(q_u->cbbuf)); - prs_uint32("devmod", ps, depth, &(q_u->devmod)); - prs_uint32("access required", ps, depth, &(q_u->access_required)); - - /* don't care to decode end of packet by now */ - /* but when acl will be implemented, it will be useful */ - - prs_uint32("unknown1", ps, depth, &(q_u->unknown1)); - prs_uint32("unknown2", ps, depth, &(q_u->unknown2)); - prs_uint32("unknown3", ps, depth, &(q_u->unknown3)); - prs_uint32("unknown4", ps, depth, &(q_u->unknown4)); - prs_uint32("unknown5", ps, depth, &(q_u->unknown5)); - prs_uint32("unknown6", ps, depth, &(q_u->unknown6)); - prs_uint32("unknown7", ps, depth, &(q_u->unknown7)); - prs_uint32("unknown8", ps, depth, &(q_u->unknown8)); - prs_uint32("unknown9", ps, depth, &(q_u->unknown9)); - prs_uint32("unknown10", ps, depth, &(q_u->unknown10)); - - smb_io_unistr2("", &(q_u->station),True,ps,depth); - prs_align(ps); - smb_io_unistr2("", &(q_u->username),True,ps,depth); - prs_align(ps); - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ -BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, - POLICY_HND *handle, - char *valuename, - uint32 size) -{ - int len_name = valuename != NULL ? strlen(valuename) : 0; - - if (q_u == NULL) return False; - - DEBUG(5,("make_spoolss_q_getprinterdata\n")); - - memcpy(&(q_u->handle), handle, sizeof(q_u->handle)); - make_unistr2(&(q_u->valuename), valuename, len_name); - q_u->size = size; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_getprinterdata (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata"); - depth++; - - prs_align(ps); - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_align(ps); - smb_io_unistr2("", &(q_u->valuename),True,ps,depth); - prs_align(ps); - prs_uint32("size", ps, depth, &(q_u->size)); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_getprinterdata (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata"); - depth++; - - /* grow buffer mem enough */ - mem_grow_data(&(ps->data), ps->io, r_u->size+100, 0); - - prs_align(ps); - prs_uint32("type", ps, depth, &(r_u->type)); - prs_uint32("size", ps, depth, &(r_u->size)); - - prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size); - prs_align(ps); - - prs_uint32("needed", ps, depth, &(r_u->needed)); - prs_uint32("status", ps, depth, &(r_u->status)); - prs_align(ps); - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ -BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd) -{ - if (q_u == NULL) return False; - - DEBUG(5,("make_spoolss_q_closeprinter\n")); - - memcpy(&(q_u->handle), hnd, sizeof(q_u->handle)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from static spoolss_q_closeprinter (srv_spoolss.c) - * called from spoolss_closeprinter (cli_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - return True; -} - -/******************************************************************* - * write a structure. - * called from static spoolss_r_closeprinter (srv_spoolss.c) - * called from spoolss_closeprinter (cli_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter"); - depth++; - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(r_u->handle),ps,depth); - prs_uint32("status", ps, depth, &(r_u->status)); - - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_startdocprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - smb_io_doc_info_container("",&(q_u->doc_info_container), ps, depth); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_startdocprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_startdocprinter(char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter"); - depth++; - prs_uint32("jobid", ps, depth, &(r_u->jobid)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_enddocprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_enddocprinter(char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_enddocprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_enddocprinter(char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter"); - depth++; - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_startpageprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_startpageprinter(char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_startpageprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_startpageprinter(char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter"); - depth++; - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_endpageprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_endpageprinter(char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_endpageprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_endpageprinter(char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter"); - depth++; - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_writeprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_writeprinter(char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("buffer_size", ps, depth, &(q_u->buffer_size)); - - if (q_u->buffer_size!=0) - { - q_u->buffer=(uint8 *)malloc(q_u->buffer_size*sizeof(uint8)); - prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size); - } - prs_align(ps); - prs_uint32("buffer_size2", ps, depth, &(q_u->buffer_size2)); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_writeprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_writeprinter(char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter"); - depth++; - prs_uint32("buffer_written", ps, depth, &(r_u->buffer_written)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_rffpcnex (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_rffpcnex(char *desc, SPOOL_Q_RFFPCNEX *q_u, - prs_struct *ps, int depth) -{ - uint32 useless_ptr; - - prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex"); - depth++; - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("flags", ps, depth, &(q_u->flags)); - prs_uint32("options", ps, depth, &(q_u->options)); - prs_uint32("useless ptr", ps, depth, &useless_ptr); - /*prs_align(ps);*/ - - smb_io_unistr2("", &(q_u->localmachine), True, ps, depth); - - prs_align(ps); - prs_uint32("printerlocal", ps, depth, &(q_u->printerlocal)); - - smb_io_notify_option("notify option", &(q_u->option), ps, depth); - - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_rffpcnex (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_rffpcnex(char *desc, SPOOL_R_RFFPCNEX *r_u, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex"); - depth++; - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_rfnpcnex (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u, - prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - prs_uint32("change", ps, depth, &(q_u->change)); - - smb_io_notify_option("notify option",&(q_u->option),ps,depth); - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_rfnpcnex (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_rfnpcnex(char *desc, - SPOOL_R_RFNPCNEX *r_u, - prs_struct *ps, int depth) -{ - uint32 x=0x0; - - prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex"); - depth++; - - prs_align(ps); - - smb_io_notify_info("notify info",&(r_u->info),ps,depth); - prs_align(ps); - prs_uint32("status", ps, depth, &(x)); - - return True; -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ -static uint32 size_of_uint32(uint32 *value) -{ - return (sizeof(*value)); - - return True; -} - -/******************************************************************* - * return the length of a UNICODE string in number of char, includes: - * - the leading zero - * - the relative pointer size - ********************************************************************/ -static uint32 size_of_relative_string(UNISTR *string) -{ - uint32 size=0; - - size=str_len_uni(string); /* the string length */ - size=size+1; /* add the leading zero */ - size=size*2; /* convert in char */ - size=size+4; /* add the size of the ptr */ - return (size); - - return True; -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ -static uint32 size_of_device_mode(DEVICEMODE *devmode) -{ - if (devmode==NULL) - return (4); - else - return (0xDC+4); - - return True; -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ -static uint32 size_of_systemtime(SYSTEMTIME *systime) -{ - if (systime==NULL) - return (4); - else - return (sizeof(SYSTEMTIME) +4); - - return True; -} - -/******************************************************************* - * write a UNICODE string. - * used by all the RPC structs passing a buffer - ********************************************************************/ -static BOOL spoolss_smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int depth) -{ - if (uni == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_smb_io_unistr"); - depth++; - prs_unistr("unistr", ps, depth, uni); - - return True; -} - - -/******************************************************************* - * write a UNICODE string and its relative pointer. - * used by all the RPC structs passing a buffer - ********************************************************************/ -static BOOL smb_io_relstr(char *desc, prs_struct *ps, int depth, UNISTR *buffer, - uint32 *start_offset, uint32 *end_offset) -{ - if (!ps->io) - { - uint32 struct_offset = ps->offset; - uint32 relative_offset; - - /* writing */ - *end_offset -= 2*(str_len_uni(buffer)+1); - ps->offset=*end_offset; - spoolss_smb_io_unistr(desc, buffer, ps, depth); - - ps->offset=struct_offset; - relative_offset=*end_offset-*start_offset; - - prs_uint32("offset", ps, depth, &(relative_offset)); - } - else - { - uint32 old_offset; - uint32 relative_offset; - - prs_uint32("offset", ps, depth, &(relative_offset)); - - old_offset = ps->offset; - ps->offset = (*start_offset) + relative_offset; - - spoolss_smb_io_unistr(desc, buffer, ps, depth); - - *end_offset = ps->offset; - ps->offset = old_offset; - } - return True; -} - - -/******************************************************************* - * write a array UNICODE strings and its relative pointer. - * used by 2 RPC structs - ********************************************************************/ -static BOOL smb_io_relarraystr(char *desc, prs_struct *ps, int depth, UNISTR ***buffer, - uint32 *start_offset, uint32 *end_offset) -{ - int i=0; - uint32 struct_offset; - uint32 relative_offset; - struct_offset=ps->offset; - - while ( (*buffer)[i]!=0x0000 ) - { - i++; - } - - i--; - - /* that's for the ending NULL */ - *end_offset-=2; - - do - { - *end_offset-= 2*(str_len_uni((*buffer)[i])+1); - ps->offset=*end_offset; - spoolss_smb_io_unistr(desc, (*buffer)[i], ps, depth); - - i--; - } - while (i>=0); - - ps->offset=struct_offset; - relative_offset=*end_offset-*start_offset; - - prs_uint32("offset", ps, depth, &(relative_offset)); - - return True; -} - -/******************************************************************* - * write a DEVICEMODE struct. - * on reading allocate memory for the private member - ********************************************************************/ -static BOOL smb_io_devmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode) -{ - prs_debug(ps, depth, desc, "smb_io_devmode"); - depth++; - - prs_uint16s(True,"devicename", ps, depth, devmode->devicename.buffer, 32); - prs_uint16("specversion", ps, depth, &(devmode->specversion)); - prs_uint16("driverversion", ps, depth, &(devmode->driverversion)); - prs_uint16("size", ps, depth, &(devmode->size)); - prs_uint16("driverextra", ps, depth, &(devmode->driverextra)); - prs_uint32("fields", ps, depth, &(devmode->fields)); - prs_uint16("orientation", ps, depth, &(devmode->orientation)); - prs_uint16("papersize", ps, depth, &(devmode->papersize)); - prs_uint16("paperlength", ps, depth, &(devmode->paperlength)); - prs_uint16("paperwidth", ps, depth, &(devmode->paperwidth)); - prs_uint16("scale", ps, depth, &(devmode->scale)); - prs_uint16("copies", ps, depth, &(devmode->copies)); - prs_uint16("defaultsource", ps, depth, &(devmode->defaultsource)); - prs_uint16("printquality", ps, depth, &(devmode->printquality)); - prs_uint16("color", ps, depth, &(devmode->color)); - prs_uint16("duplex", ps, depth, &(devmode->duplex)); - prs_uint16("yresolution", ps, depth, &(devmode->yresolution)); - prs_uint16("ttoption", ps, depth, &(devmode->ttoption)); - prs_uint16("collate", ps, depth, &(devmode->collate)); - prs_uint16s(True, "formname", ps, depth, devmode->formname.buffer, 32); - prs_uint16("logpixels", ps, depth, &(devmode->logpixels)); - prs_uint32("bitsperpel", ps, depth, &(devmode->bitsperpel)); - prs_uint32("pelswidth", ps, depth, &(devmode->pelswidth)); - prs_uint32("pelsheight", ps, depth, &(devmode->pelsheight)); - prs_uint32("displayflags", ps, depth, &(devmode->displayflags)); - prs_uint32("displayfrequency", ps, depth, &(devmode->displayfrequency)); - prs_uint32("icmmethod", ps, depth, &(devmode->icmmethod)); - prs_uint32("icmintent", ps, depth, &(devmode->icmintent)); - prs_uint32("mediatype", ps, depth, &(devmode->mediatype)); - prs_uint32("dithertype", ps, depth, &(devmode->dithertype)); - prs_uint32("reserved1", ps, depth, &(devmode->reserved1)); - prs_uint32("reserved2", ps, depth, &(devmode->reserved2)); - prs_uint32("panningwidth", ps, depth, &(devmode->panningwidth)); - prs_uint32("panningheight", ps, depth, &(devmode->panningheight)); - - if (devmode->driverextra!=0) - { - if (ps->io) - { - devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8)); - DEBUG(7,("smb_io_devmode: allocated memory [%d] for private\n",devmode->driverextra)); - } - DEBUG(7,("smb_io_devmode: parsing [%d] bytes of private\n",devmode->driverextra)); - - prs_uint8s(True, "private", ps, depth, devmode->private, devmode->driverextra); - DEBUG(8,("smb_io_devmode: parsed\n")); - } - - return True; -} - -/******************************************************************* - * write a DEVMODE struct and its relative pointer. - * used by all the RPC structs passing a buffer - ********************************************************************/ -static BOOL smb_io_reldevmode(char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode, - uint32 *start_offset, uint32 *end_offset) -{ - uint32 struct_offset; - uint32 relative_offset; - - prs_debug(ps, depth, desc, "smb_io_reldevmode"); - depth++; - - struct_offset=ps->offset; - *end_offset-= (devmode->size+devmode->driverextra); - ps->offset=*end_offset; - - smb_io_devmode(desc, ps, depth, devmode); - - ps->offset=struct_offset; - relative_offset=*end_offset-*start_offset; - - prs_uint32("offset", ps, depth, &(relative_offset)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_printer_info_0(char *desc, PRINTER_INFO_0 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_printer_info_0"); - depth++; - *start_offset=ps->offset; - - smb_io_relstr("printername",ps, depth, &(info->printername), start_offset, end_offset); - smb_io_relstr("servername",ps, depth, &(info->servername), start_offset, end_offset); - prs_uint32("cjobs", ps, depth, &(info->cjobs)); - prs_uint32("attributes", ps, depth, &(info->attributes)); - - prs_uint32("unknown0", ps, depth, &(info->unknown0)); - prs_uint32("unknown1", ps, depth, &(info->unknown1)); - prs_uint32("unknown2", ps, depth, &(info->unknown2)); - prs_uint32("unknown3", ps, depth, &(info->unknown3)); - prs_uint32("unknown4", ps, depth, &(info->unknown4)); - prs_uint32("unknown5", ps, depth, &(info->unknown5)); - prs_uint32("unknown6", ps, depth, &(info->unknown6)); - prs_uint16("majorversion", ps, depth, &(info->majorversion)); - prs_uint16("buildversion", ps, depth, &(info->buildversion)); - prs_uint32("unknown7", ps, depth, &(info->unknown7)); - prs_uint32("unknown8", ps, depth, &(info->unknown8)); - prs_uint32("unknown9", ps, depth, &(info->unknown9)); - prs_uint32("unknown10", ps, depth, &(info->unknown10)); - prs_uint32("unknown11", ps, depth, &(info->unknown11)); - prs_uint32("unknown12", ps, depth, &(info->unknown12)); - prs_uint32("unknown13", ps, depth, &(info->unknown13)); - prs_uint32("unknown14", ps, depth, &(info->unknown14)); - prs_uint32("unknown15", ps, depth, &(info->unknown15)); - prs_uint32("unknown16", ps, depth, &(info->unknown16)); - prs_uint32("unknown17", ps, depth, &(info->unknown17)); - prs_uint32("unknown18", ps, depth, &(info->unknown18)); - prs_uint32("status" , ps, depth, &(info->status)); - prs_uint32("unknown20", ps, depth, &(info->unknown20)); - prs_uint32("unknown21", ps, depth, &(info->unknown21)); - prs_uint16("unknown22", ps, depth, &(info->unknown22)); - prs_uint32("unknown23", ps, depth, &(info->unknown23)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_printer_info_1(char *desc, PRINTER_INFO_1 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_printer_info_1"); - depth++; - *start_offset=ps->offset; - - prs_uint32("flags", ps, depth, &(info->flags)); - smb_io_relstr("description",ps, depth, &(info->description), start_offset, end_offset); - smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset); - smb_io_relstr("comment",ps, depth, &(info->comment), start_offset, end_offset); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_printer_info_2(char *desc, PRINTER_INFO_2 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - uint32 pipo=0; - uint32 devmode_offset; - uint32 backup_offset; - - prs_debug(ps, depth, desc, "smb_io_printer_info_2"); - depth++; - *start_offset=ps->offset; - - smb_io_relstr("servername", ps, depth, &(info->servername), start_offset, end_offset); - smb_io_relstr("printername", ps, depth, &(info->printername), start_offset, end_offset); - smb_io_relstr("sharename", ps, depth, &(info->sharename), start_offset, end_offset); - smb_io_relstr("portname", ps, depth, &(info->portname), start_offset, end_offset); - smb_io_relstr("drivername", ps, depth, &(info->drivername), start_offset, end_offset); - smb_io_relstr("comment", ps, depth, &(info->comment), start_offset, end_offset); - smb_io_relstr("location", ps, depth, &(info->location), start_offset, end_offset); - - devmode_offset=ps->offset; - ps->offset=ps->offset+4; - - smb_io_relstr("sepfile", ps, depth, &(info->sepfile), start_offset, end_offset); - smb_io_relstr("printprocessor",ps, depth, &(info->printprocessor), start_offset, end_offset); - smb_io_relstr("datatype", ps, depth, &(info->datatype), start_offset, end_offset); - smb_io_relstr("parameters", ps, depth, &(info->parameters), start_offset, end_offset); - - prs_uint32("security descriptor", ps, depth, &(pipo)); - - prs_uint32("attributes", ps, depth, &(info->attributes)); - prs_uint32("priority", ps, depth, &(info->priority)); - prs_uint32("defpriority", ps, depth, &(info->defaultpriority)); - prs_uint32("starttime", ps, depth, &(info->starttime)); - prs_uint32("untiltime", ps, depth, &(info->untiltime)); - prs_uint32("status", ps, depth, &(info->status)); - prs_uint32("jobs", ps, depth, &(info->cjobs)); - prs_uint32("averageppm", ps, depth, &(info->averageppm)); - - /* - I'm not sure if putting the devmode at the end the struct is worth it - but NT does it - */ - backup_offset=ps->offset; - ps->offset=devmode_offset; - smb_io_reldevmode("devmode", ps, depth, info->devmode, start_offset, end_offset); - ps->offset=backup_offset; - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_printer_driver_info_1(char *desc, DRIVER_INFO_1 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1"); - depth++; - *start_offset=ps->offset; - - smb_io_relstr("name", ps, depth, &(info->name), start_offset, end_offset); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_printer_driver_info_2(char *desc, DRIVER_INFO_2 *info,prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_printer_xxx"); - depth++; - *start_offset=ps->offset; - - prs_uint32("version", ps, depth, &(info->version)); - smb_io_relstr("name", ps, depth, &(info->name), start_offset, end_offset); - smb_io_relstr("architecture", ps, depth, &(info->architecture), start_offset, end_offset); - smb_io_relstr("driverpath", ps, depth, &(info->driverpath), start_offset, end_offset); - smb_io_relstr("datafile", ps, depth, &(info->datafile), start_offset, end_offset); - smb_io_relstr("configfile", ps, depth, &(info->configfile), start_offset, end_offset); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_printer_driver_info_3(char *desc, DRIVER_INFO_3 *info,prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3"); - depth++; - *start_offset=ps->offset; - - prs_uint32("version", ps, depth, &(info->version)); - smb_io_relstr("name", ps, depth, &(info->name), start_offset, end_offset); - smb_io_relstr("architecture", ps, depth, &(info->architecture), start_offset, end_offset); - smb_io_relstr("driverpath", ps, depth, &(info->driverpath), start_offset, end_offset); - smb_io_relstr("datafile", ps, depth, &(info->datafile), start_offset, end_offset); - smb_io_relstr("configfile", ps, depth, &(info->configfile), start_offset, end_offset); - smb_io_relstr("helpfile", ps, depth, &(info->helpfile), start_offset, end_offset); - - smb_io_relarraystr("dependentfiles", ps, depth, &(info->dependentfiles), start_offset, end_offset); - - smb_io_relstr("monitorname", ps, depth, &(info->monitorname), start_offset, end_offset); - smb_io_relstr("defaultdatatype", ps, depth, &(info->defaultdatatype), start_offset, end_offset); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_job_info_1(char *desc, JOB_INFO_1 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_job_info_1"); - depth++; - *start_offset=ps->offset; - - prs_uint32("jobid", ps, depth, &(info->jobid)); - smb_io_relstr("printername", ps, depth, &(info->printername), start_offset, end_offset); - smb_io_relstr("machinename", ps, depth, &(info->machinename), start_offset, end_offset); - smb_io_relstr("username", ps, depth, &(info->username), start_offset, end_offset); - smb_io_relstr("document", ps, depth, &(info->document), start_offset, end_offset); - smb_io_relstr("datatype", ps, depth, &(info->datatype), start_offset, end_offset); - smb_io_relstr("text_status", ps, depth, &(info->text_status), start_offset, end_offset); - prs_uint32("status", ps, depth, &(info->status)); - prs_uint32("priority", ps, depth, &(info->priority)); - prs_uint32("position", ps, depth, &(info->position)); - prs_uint32("totalpages", ps, depth, &(info->totalpages)); - prs_uint32("pagesprinted", ps, depth, &(info->pagesprinted)); - spoolss_io_system_time("submitted", ps, depth, &(info->submitted) ); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_job_info_2(char *desc, JOB_INFO_2 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - int pipo=0; - prs_debug(ps, depth, desc, "smb_io_job_info_2"); - depth++; - *start_offset=ps->offset; - - prs_uint32("jobid", ps, depth, &(info->jobid)); - smb_io_relstr("printername", ps, depth, &(info->printername), start_offset, end_offset); - smb_io_relstr("machinename", ps, depth, &(info->machinename), start_offset, end_offset); - smb_io_relstr("username", ps, depth, &(info->username), start_offset, end_offset); - smb_io_relstr("document", ps, depth, &(info->document), start_offset, end_offset); - smb_io_relstr("notifyname", ps, depth, &(info->notifyname), start_offset, end_offset); - smb_io_relstr("datatype", ps, depth, &(info->datatype), start_offset, end_offset); - - smb_io_relstr("printprocessor", ps, depth, &(info->printprocessor), start_offset, end_offset); - smb_io_relstr("parameters", ps, depth, &(info->parameters), start_offset, end_offset); - smb_io_relstr("drivername", ps, depth, &(info->drivername), start_offset, end_offset); - smb_io_reldevmode("devmode", ps, depth, info->devmode, start_offset, end_offset); - smb_io_relstr("text_status", ps, depth, &(info->text_status), start_offset, end_offset); - -/* SEC_DESC sec_desc;*/ - prs_uint32("Hack! sec desc", ps, depth, &pipo); - - prs_uint32("status", ps, depth, &(info->status)); - prs_uint32("priority", ps, depth, &(info->priority)); - prs_uint32("position", ps, depth, &(info->position)); - prs_uint32("starttime", ps, depth, &(info->starttime)); - prs_uint32("untiltime", ps, depth, &(info->untiltime)); - prs_uint32("totalpages", ps, depth, &(info->totalpages)); - prs_uint32("size", ps, depth, &(info->size)); - spoolss_io_system_time("submitted", ps, depth, &(info->submitted) ); - prs_uint32("timeelapsed", ps, depth, &(info->timeelapsed)); - prs_uint32("pagesprinted", ps, depth, &(info->pagesprinted)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_form_1(char *desc, FORM_1 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_form_1"); - depth++; - *start_offset=ps->offset; - - prs_uint32("flag", ps, depth, &(info->flag)); - smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset); - prs_uint32("width", ps, depth, &(info->width)); - prs_uint32("length", ps, depth, &(info->length)); - prs_uint32("left", ps, depth, &(info->left)); - prs_uint32("top", ps, depth, &(info->top)); - prs_uint32("right", ps, depth, &(info->right)); - prs_uint32("bottom", ps, depth, &(info->bottom)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_port_2(char *desc, PORT_INFO_2 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_form_1"); - depth++; - *start_offset=ps->offset; - - smb_io_relstr("port_name",ps, depth, &(info->port_name), start_offset, end_offset); - smb_io_relstr("monitor_name",ps, depth, &(info->monitor_name), start_offset, end_offset); - smb_io_relstr("description",ps, depth, &(info->description), start_offset, end_offset); - prs_uint32("port_type", ps, depth, &(info->port_type)); - prs_uint32("reserved", ps, depth, &(info->reserved)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_processor_info_1(char *desc, PRINTPROCESSOR_1 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_processor_info_1"); - depth++; - *start_offset=ps->offset; - - smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL smb_io_monitor_info_1(char *desc, PRINTMONITOR_1 *info, prs_struct *ps, int depth, - uint32 *start_offset, uint32 *end_offset) -{ - prs_debug(ps, depth, desc, "smb_io_monitor_info_1"); - depth++; - *start_offset=ps->offset; - - smb_io_relstr("name",ps, depth, &(info->name), start_offset, end_offset); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info) -{ - int size=0; - - size+=size_of_uint32( &(info->attributes) ); - size+=size_of_relative_string( &(info->printername) ); - size+=size_of_relative_string( &(info->servername) ); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info) -{ - int size=0; - - size+=size_of_uint32( &(info->flags) ); - size+=size_of_relative_string( &(info->description) ); - size+=size_of_relative_string( &(info->name) ); - size+=size_of_relative_string( &(info->comment) ); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info) -{ - int size=0; - - size+=4; /* the security descriptor */ - size+=info->devmode->size+4; /* size of the devmode and the ptr */ - size+=info->devmode->driverextra; /* if a devmode->private section exists, add its size */ - - size+=size_of_relative_string( &(info->servername) ); - size+=size_of_relative_string( &(info->printername) ); - size+=size_of_relative_string( &(info->sharename) ); - size+=size_of_relative_string( &(info->portname) ); - size+=size_of_relative_string( &(info->drivername) ); - size+=size_of_relative_string( &(info->comment) ); - size+=size_of_relative_string( &(info->location) ); - - size+=size_of_relative_string( &(info->sepfile) ); - size+=size_of_relative_string( &(info->printprocessor) ); - size+=size_of_relative_string( &(info->datatype) ); - size+=size_of_relative_string( &(info->parameters) ); - - size+=size_of_uint32( &(info->attributes) ); - size+=size_of_uint32( &(info->priority) ); - size+=size_of_uint32( &(info->defaultpriority) ); - size+=size_of_uint32( &(info->starttime) ); - size+=size_of_uint32( &(info->untiltime) ); - size+=size_of_uint32( &(info->status) ); - size+=size_of_uint32( &(info->cjobs) ); - size+=size_of_uint32( &(info->averageppm) ); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info) -{ - int size=0; - DEBUG(9,("Sizing driver info_1\n")); - size+=size_of_relative_string( &(info->name) ); - - DEBUGADD(9,("size: [%d]\n", size)); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info) -{ - int size=0; - DEBUG(9,("Sizing driver info_2\n")); - size+=size_of_uint32( &(info->version) ); - size+=size_of_relative_string( &(info->name) ); - size+=size_of_relative_string( &(info->architecture) ); - size+=size_of_relative_string( &(info->driverpath) ); - size+=size_of_relative_string( &(info->datafile) ); - size+=size_of_relative_string( &(info->configfile) ); - - DEBUGADD(9,("size: [%d]\n", size)); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info) -{ - int size=0; - UNISTR **string; - int i=0; - - DEBUG(9,("Sizing driver info_3\n")); - size+=size_of_uint32( &(info->version) ); - size+=size_of_relative_string( &(info->name) ); - size+=size_of_relative_string( &(info->architecture) ); - size+=size_of_relative_string( &(info->driverpath) ); - size+=size_of_relative_string( &(info->datafile) ); - size+=size_of_relative_string( &(info->configfile) ); - size+=size_of_relative_string( &(info->helpfile) ); - size+=size_of_relative_string( &(info->monitorname) ); - size+=size_of_relative_string( &(info->defaultdatatype) ); - - string=info->dependentfiles; - - while ( (string)[i]!=0x0000 ) - { - size+=2*(1+ str_len_uni( string[i] ) ); - i++; - } - size+=6; - - DEBUGADD(9,("size: [%d]\n", size)); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_job_info_1(JOB_INFO_1 *info) -{ - int size=0; - size+=size_of_uint32( &(info->jobid) ); - size+=size_of_relative_string( &(info->printername) ); - size+=size_of_relative_string( &(info->machinename) ); - size+=size_of_relative_string( &(info->username) ); - size+=size_of_relative_string( &(info->document) ); - size+=size_of_relative_string( &(info->datatype) ); - size+=size_of_relative_string( &(info->text_status) ); - size+=size_of_uint32( &(info->status) ); - size+=size_of_uint32( &(info->priority) ); - size+=size_of_uint32( &(info->position) ); - size+=size_of_uint32( &(info->totalpages) ); - size+=size_of_uint32( &(info->pagesprinted) ); - size+=size_of_systemtime( &(info->submitted) ); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_job_info_2(JOB_INFO_2 *info) -{ - int size=0; - - size+=4; /* size of sec desc ptr */ - - size+=size_of_uint32( &(info->jobid) ); - size+=size_of_relative_string( &(info->printername) ); - size+=size_of_relative_string( &(info->machinename) ); - size+=size_of_relative_string( &(info->username) ); - size+=size_of_relative_string( &(info->document) ); - size+=size_of_relative_string( &(info->notifyname) ); - size+=size_of_relative_string( &(info->datatype) ); - size+=size_of_relative_string( &(info->printprocessor) ); - size+=size_of_relative_string( &(info->parameters) ); - size+=size_of_relative_string( &(info->drivername) ); - size+=size_of_device_mode( info->devmode ); - size+=size_of_relative_string( &(info->text_status) ); -/* SEC_DESC sec_desc;*/ - size+=size_of_uint32( &(info->status) ); - size+=size_of_uint32( &(info->priority) ); - size+=size_of_uint32( &(info->position) ); - size+=size_of_uint32( &(info->starttime) ); - size+=size_of_uint32( &(info->untiltime) ); - size+=size_of_uint32( &(info->totalpages) ); - size+=size_of_uint32( &(info->size) ); - size+=size_of_systemtime( &(info->submitted) ); - size+=size_of_uint32( &(info->timeelapsed) ); - size+=size_of_uint32( &(info->pagesprinted) ); - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_form_1(FORM_1 *info) -{ - int size=0; - - size+=size_of_uint32( &(info->flag) ); - size+=size_of_relative_string( &(info->name) ); - size+=size_of_uint32( &(info->width) ); - size+=size_of_uint32( &(info->length) ); - size+=size_of_uint32( &(info->left) ); - size+=size_of_uint32( &(info->top) ); - size+=size_of_uint32( &(info->right) ); - size+=size_of_uint32( &(info->bottom) ); - - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_port_info_2(PORT_INFO_2 *info) -{ - int size=0; - - size+=size_of_relative_string( &(info->port_name) ); - size+=size_of_relative_string( &(info->monitor_name) ); - size+=size_of_relative_string( &(info->description) ); - - size+=size_of_uint32( &(info->port_type) ); - size+=size_of_uint32( &(info->reserved) ); - - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_processor_info_1(PRINTPROCESSOR_1 *info) -{ - int size=0; - size+=size_of_relative_string( &(info->name) ); - - return (size); - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -static uint32 spoolss_size_monitor_info_1(PRINTMONITOR_1 *info) -{ - int size=0; - size+=size_of_relative_string( &(info->name) ); - - return (size); - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ -static BOOL make_spoolss_buffer(BUFFER* buffer, uint32 size) -{ - buffer->ptr = (size != 0) ? 1 : 0; - buffer->size = size; - buffer->data = (uint8 *)Realloc( NULL, (buffer->size) * sizeof(uint8) ); - - return (buffer->data != NULL || size == 0); -} - -/******************************************************************* - * read a uint8 buffer of size *size. - * allocate memory for it - * return a pointer to the allocated memory and the size - * return NULL and a size of 0 if the buffer is empty - * - * jfmxxxx: fix it to also write a buffer - ********************************************************************/ -static BOOL spoolss_io_read_buffer(char *desc, prs_struct *ps, int depth, BUFFER *buffer) -{ - prs_debug(ps, depth, desc, "spoolss_io_read_buffer"); - depth++; - - prs_align(ps); - - prs_uint32("pointer", ps, depth, &(buffer->ptr)); - - if (buffer->ptr != 0x0000) - { - prs_uint32("size", ps, depth, &(buffer->size)); - if (ps->io) - { - /* reading */ - buffer->data=(uint8 *)Realloc(NULL, buffer->size * sizeof(uint8) ); - } - if (buffer->data == NULL) - { - return False; - } - mem_grow_data(&(ps->data), ps->io, - ps->data->data_size + buffer->size, 0); - prs_uint8s(True, "buffer", ps, depth, buffer->data, buffer->size); - prs_align(ps); - - } - else - { - if (ps->io) - { - /* reading */ - buffer->data=0x0000; - buffer->size=0x0000; - } - } - - if (!ps->io) - { - /* writing */ - if (buffer->data != NULL) - { - free(buffer->data); - } - buffer->data = NULL; - } - return True; -} - -/******************************************************************* - * read a uint8 buffer of size *size. - * allocate memory for it - * return a pointer to the allocated memory and the size - * return NULL and a size of 0 if the buffer is empty - * - * jfmxxxx: fix it to also write a buffer - ********************************************************************/ -BOOL spoolss_io_free_buffer(BUFFER *buffer) -{ - DEBUG(8,("spoolss_io_free_buffer\n")); - - if (buffer->ptr != 0x0000) - { - free(buffer->data); - } - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_getprinterdriver2 (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_getprinterdriver2(char *desc, - SPOOL_Q_GETPRINTERDRIVER2 *q_u, - prs_struct *ps, int depth) -{ - uint32 useless_ptr; - prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("pointer", ps, depth, &useless_ptr); - smb_io_unistr2("architecture", &(q_u->architecture),True,ps,depth); - - prs_align(ps); - - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - - prs_align(ps); - - prs_uint32("buffer size", ps, depth, &(q_u->buf_size)); - prs_uint32("status", ps, depth, &(q_u->status)); - - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_getprinterdriver2 (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_r_getprinterdriver2(char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, - prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - uint32 pipo=0; - DRIVER_INFO_1 *info1; - DRIVER_INFO_2 *info2; - DRIVER_INFO_3 *info3; - - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2"); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - - info1 = r_u->printer.info1; - info2 = r_u->printer.info2; - info3 = r_u->printer.info3; - - switch (r_u->level) - { - case 1: - { - bufsize_required += spoolss_size_printer_driver_info_1(info1); - break; - } - case 2: - { - bufsize_required += spoolss_size_printer_driver_info_2(info2); - break; - } - case 3: - { - bufsize_required += spoolss_size_printer_driver_info_3(info3); - break; - } - } - - if (ps->io) - { - /* reading */ - r_u->offered = bufsize_required; - } - - DEBUG(4,("spoolss_io_r_getprinterdriver2, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_getprinterdriver2, size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered < bufsize_required) - { - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - - DEBUG(4,("spoolss_io_r_getprinterdriver2, buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("spoolss_io_r_getprinterdriver2, buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - smb_io_printer_driver_info_1(desc, - info1, - ps, - depth, - &start_offset, - &end_offset); - break; - } - case 2: - { - smb_io_printer_driver_info_2(desc, - info2, - ps, - depth, - &start_offset, - &end_offset); - break; - } - case 3: - { - smb_io_printer_driver_info_3(desc, - info3, - ps, - depth, - &start_offset, - &end_offset); - break; - } - - } - - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("pipo", ps, depth, &pipo); - prs_uint32("pipo", ps, depth, &pipo); - prs_uint32("status", ps, depth, &(r_u->status)); - - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ -BOOL make_spoolss_q_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, - uint32 flags, - const char* servername, - uint32 level, - uint32 size) -{ - size_t len_name = servername != NULL ? strlen(servername) : 0; - - DEBUG(5,("make_spoolss_q_enumprinters. size: %d\n", size)); - - q_u->flags = flags; - - make_unistr2(&(q_u->servername), servername, len_name); - - q_u->level = level; - make_spoolss_buffer(&q_u->buffer, size); - q_u->buf_size = size; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_enumprinters (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_enumprinters(char *desc, SPOOL_Q_ENUMPRINTERS *q_u, - prs_struct *ps, int depth) -{ - uint32 useless_ptr = 0x01; - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters"); - depth++; - - prs_align(ps); - - prs_uint32("flags", ps, depth, &(q_u->flags)); - prs_uint32("useless ptr", ps, depth, &useless_ptr); - - smb_io_unistr2("", &(q_u->servername),True,ps,depth); - prs_align(ps); - - prs_uint32("level", ps, depth, &(q_u->level)); - - spoolss_io_read_buffer("buffer", ps, depth, &(q_u->buffer)); - - prs_uint32("buf_size", ps, depth, &q_u->buf_size); - - return True; -} - -/**************************************************************************** -****************************************************************************/ -void free_r_enumprinters(SPOOL_R_ENUMPRINTERS *r_u) -{ - DEBUG(4,("free_enum_printers_info: [%d] structs to free at level [%d]\n", r_u->returned, r_u->level)); - switch (r_u->level) - { - case 1: - { - free_print1_array(r_u->returned, r_u->printer.printers_1); - break; - } - case 2: - { - free_print2_array(r_u->returned, r_u->printer.printers_2); - break; - } - } -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_enum_printers (srv_spoolss.c) - * - ********************************************************************/ -BOOL spoolss_io_r_enumprinters(char *desc, - SPOOL_R_ENUMPRINTERS *r_u, - prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - int i; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - uint32 tmp_ct = 0; - - PRINTER_INFO_1 *info1; - PRINTER_INFO_2 *info2; - fstring tmp; - - slprintf(tmp, sizeof(tmp)-1, "spoolss_io_r_enumprinters %d", r_u->level); - - prs_debug(ps, depth, desc, tmp); - depth++; - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - - if (!ps->io) - { - /* writing */ - for(i=0;i<r_u->returned;i++) - { - switch (r_u->level) - { - case 1: - info1 = r_u->printer.printers_1[i]; - bufsize_required += spoolss_size_printer_info_1(info1); - break; - case 2: - info2 = r_u->printer.printers_2[i]; - bufsize_required += spoolss_size_printer_info_2(info2); - break; - } - } - - DEBUG(4,("spoolss_io_r_enumprinters, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_enumprinters, size offered: %d\n",r_u->offered)); - - if (r_u->offered<bufsize_required) - { - /* - * so the buffer is too small to handle datas - * reply the minimum size required in the status - * make the buffer equal 0 - * and reply no printers in buffer - */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; - r_u->offered=0; - /*r_u->returned=0;*/ - - DEBUG(4,("spoolss_io_r_enumprinters, buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("count", ps, depth, &(r_u->returned)); - prs_uint32("status", ps, depth, &(r_u->status)); - return False; - } - - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("spoolss_io_r_enumprinters, buffer large enough\n")); - } - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - - /* have to skip to end of buffer when reading, and have to record - * size of buffer when writing. *shudder*. - */ - - beginning = ps->offset; - start_offset = ps->offset; - end_offset = start_offset + r_u->offered; - - if (ps->io) - { - /* reading */ - ps->offset = beginning + r_u->offered; - - prs_align(ps); - prs_uint32("buffer size", ps, depth, &(bufsize_required)); - prs_uint32("count", ps, depth, &(r_u->returned)); - - ps->offset = beginning; - } - - for(i=0;i<r_u->returned;i++) - { - - switch (r_u->level) - { - case 1: - { - if (ps->io) - { - /* reading */ - r_u->printer.printers_1[i] = add_print1_to_array(&tmp_ct, &r_u->printer.printers_1, NULL); - } - info1 = r_u->printer.printers_1[i]; - if (info1 == NULL) - { - return False; - } - smb_io_printer_info_1(desc, info1, ps, depth, - &start_offset, &end_offset); - break; - } - case 2: - { - if (ps->io) - { - /* reading */ - r_u->printer.printers_2[i] = add_print2_to_array(&tmp_ct, &r_u->printer.printers_2, NULL); - } - info2 = r_u->printer.printers_2[i]; - if (info2 == NULL) - { - return False; - } - smb_io_printer_info_2(desc, info2, ps, depth, - &start_offset, &end_offset); - break; - } - } - } - - ps->offset = beginning + r_u->offered; - prs_align(ps); - - prs_uint32("buffer size", ps, depth, &(bufsize_required)); - prs_uint32("count", ps, depth, &(r_u->returned)); - prs_uint32("status", ps, depth, &(r_u->status)); - - if (!ps->io) - { - /* writing */ - free_r_enumprinters(r_u); - } - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_enum_printers (srv_spoolss.c) - * - ********************************************************************/ -BOOL spoolss_io_r_getprinter(char *desc, - SPOOL_R_GETPRINTER *r_u, - prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - - prs_debug(ps, depth, desc, "spoolss_io_r_getprinter"); - depth++; - - prs_align(ps); - - prs_uint32("pointer", ps, depth, &useless_ptr); - - switch (r_u->level) - { - case 0: - { - PRINTER_INFO_0 *info; - info = r_u->printer.info0; - bufsize_required += spoolss_size_printer_info_0(info); - break; - } - case 1: - { - PRINTER_INFO_1 *info; - info = r_u->printer.info1; - bufsize_required += spoolss_size_printer_info_1(info); - break; - } - case 2: - { - PRINTER_INFO_2 *info; - info = r_u->printer.info2; - bufsize_required += spoolss_size_printer_info_2(info); - break; - } - } - - DEBUG(4,("spoolss_io_r_getprinter, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_getprinter, size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered < bufsize_required) - { - /* it's too small */ - r_u->status = ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered = 0; /* don't send back the buffer */ - - DEBUG(4,("spoolss_io_r_getprinter, buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("spoolss_io_r_getprinter, buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - - if (ps->io) - { - /* reading */ - r_u->printer.info = Realloc(NULL, r_u->offered); - } - - if (bufsize_required <= r_u->offered) - { - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 0: - { - PRINTER_INFO_0 *info; - info = r_u->printer.info0; - smb_io_printer_info_0(desc, - info, - ps, - depth, - &start_offset, - &end_offset); - break; - } - case 1: - { - PRINTER_INFO_1 *info; - info = r_u->printer.info1; - smb_io_printer_info_1(desc, - info, - ps, - depth, - &start_offset, - &end_offset); - break; - } - case 2: - { - PRINTER_INFO_2 *info; - info = r_u->printer.info2; - smb_io_printer_info_2(desc, - info, - ps, - depth, - &start_offset, - &end_offset); - break; - } - - } - - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - * read a uint8 buffer of size *size. - * allocate memory for it - * return a pointer to the allocated memory and the size - * return NULL and a size of 0 if the buffer is empty - * - * jfmxxxx: fix it to also write a buffer - ********************************************************************/ -static BOOL spoolss_io_read_buffer8(char *desc, prs_struct *ps, uint8 **buffer, uint32 *size,int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_read_buffer8"); - depth++; - - prs_align(ps); - - prs_uint32("buffer size", ps, depth, size); - *buffer = (uint8 *)Realloc(NULL, (*size) * sizeof(uint8) ); - prs_uint8s(True,"buffer",ps,depth,*buffer,*size); - prs_align(ps); - - return True; -} - -/******************************************************************* - * make a structure. - * called from spoolss_getprinter (srv_spoolss.c) - ********************************************************************/ -BOOL make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER *q_u, - POLICY_HND *hnd, - uint32 level, - uint32 buf_size) -{ - if (q_u == NULL) return False; - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - q_u->level = level; - q_u->buffer = (uint8 *)Realloc(NULL, (buf_size) * sizeof(uint8) ); - q_u->offered = buf_size; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_getprinter (srv_spoolss.c) - ********************************************************************/ -BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u, - prs_struct *ps, int depth) -{ - uint32 count = 0; - uint32 buf_ptr = q_u->buffer != NULL ? 1 : 0; - prs_debug(ps, depth, desc, "spoolss_io_q_getprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - prs_uint32("level", ps, depth, &(q_u->level)); - - if (!ps->io) - { - /* writing */ - buf_ptr = q_u->buffer != NULL ? 1 : 0; - } - prs_uint32("buffer pointer", ps, depth, &buf_ptr); - - if (buf_ptr != 0) - { - spoolss_io_read_buffer8("",ps, &q_u->buffer, &count,depth); - } - if (q_u->buffer != NULL) - { - free(q_u->buffer); - } - prs_uint32("buffer size", ps, depth, &(q_u->offered)); - - return count == q_u->offered; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setprinter"); - depth++; - - prs_align(ps); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL spoolss_io_devmode(char *desc, prs_struct *ps, int depth, DEVICEMODE **devmode) -{ - uint32 devmode_size=0x0; - uint32 useless_ptr=0x0; - - prs_debug(ps, depth, desc, "spoolss_io_devmode"); - depth++; - - prs_uint32("devmode_size", ps, depth, &(devmode_size)); - prs_uint32("useless_ptr", ps, depth, &(useless_ptr)); - - if (devmode_size!=0 && useless_ptr!=0) - { - /* so we have a DEVICEMODE to follow */ - if (ps->io) - { - DEBUG(9,("Allocating memory for spoolss_io_devmode\n")); - *devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); - ZERO_STRUCTP(*devmode); - } - - /* this is bad code, shouldn't be there */ - prs_uint32("devmode_size", ps, depth, &(devmode_size)); - - smb_io_devmode(desc, ps, depth, *devmode); - } - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_setprinter(char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_setprinter"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle", &(q_u->handle),ps,depth); - prs_uint32("level", ps, depth, &(q_u->level)); - - /* again a designed mess */ - /* sometimes I'm wondering how all of this work ! */ - - /* To be correct it need to be split in 3 functions */ - - spool_io_printer_info_level("", &(q_u->info), ps, depth); - - spoolss_io_devmode(desc, ps, depth, &(q_u->devmode)); - - prs_uint32("security.size_of_buffer", ps, depth, &(q_u->security.size_of_buffer)); - prs_uint32("security.data", ps, depth, &(q_u->security.data)); - - prs_uint32("command", ps, depth, &(q_u->command)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_fcpn(char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_fcpn"); - depth++; - - prs_align(ps); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_fcpn(char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_fcpn"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - - return True; -} - - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("level", ps, depth, &(q_u->level)); - - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - - prs_align(ps); - - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/**************************************************************************** -****************************************************************************/ -void free_r_enumjobs(SPOOL_R_ENUMJOBS *r_u) -{ - DEBUG(4,("free_enum_jobs_info: [%d] structs to free at level [%d]\n", r_u->numofjobs, r_u->level)); - switch (r_u->level) - { - case 1: - { - free_job1_array(r_u->numofjobs, r_u->job.job_info_1); - break; - } - case 2: - { - free_job2_array(r_u->numofjobs, r_u->job.job_info_2); - break; - } - } -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr = 0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - uint32 tmp_ct = 0; - int i; - - prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs"); - depth++; - - prs_align(ps); - - if (!ps->io) - { - /* writing */ - switch (r_u->level) - { - case 1: - { - for (i=0; i<r_u->numofjobs; i++) - { - JOB_INFO_1 *info; - info=r_u->job.job_info_1[i]; - bufsize_required += spoolss_size_job_info_1(&(info[i])); - } - break; - } - case 2: - { - for (i=0; i<r_u->numofjobs; i++) - { - JOB_INFO_2 *info; - info=r_u->job.job_info_2[i]; - - bufsize_required += spoolss_size_job_info_2(&(info[i])); - } - break; - } - } - - DEBUG(4,("spoolss_io_r_enumjobs, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_enumjobs, size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered<bufsize_required) - { - /* it's too small */ - r_u->status = ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered = bufsize_required; - useless_ptr = 0; - - DEBUG(4,("spoolss_io_r_enumjobs, buffer too small\n")); - - } - else - { - useless_ptr = 1; - } - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - } - - prs_uint32("pointer", ps, depth, &useless_ptr); - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - - if (useless_ptr != 0) - { - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - tmp_ct = 0; - - if (ps->io) - { - /* reading */ - ps->offset = beginning + r_u->offered; - - prs_align(ps); - prs_uint32("buffer size", ps, depth, &(bufsize_required)); - prs_uint32("numofjobs", ps, depth, &(r_u->numofjobs)); - - ps->offset = beginning; - } - - switch (r_u->level) - { - case 1: - { - JOB_INFO_1 *info; - for (i=0; i<r_u->numofjobs; i++) - { - if (ps->io) - { - /* reading */ - r_u->job.job_info_1[i] = add_job1_to_array(&tmp_ct, &r_u->job.job_info_1, NULL); - } - info = r_u->job.job_info_1[i]; - smb_io_job_info_1(desc, - info, - ps, - depth, - &start_offset, - &end_offset); - } - break; - } - case 2: - { - JOB_INFO_2 *info; - for (i=0; i<r_u->numofjobs; i++) - { - if (ps->io) - { - /* reading */ - r_u->job.job_info_2[i] = add_job2_to_array(&tmp_ct, &r_u->job.job_info_2, NULL); - } - info = r_u->job.job_info_2[i]; - smb_io_job_info_2(desc, - info, - ps, - depth, - &start_offset, - &end_offset); - } - break; - } - - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("buffer size", ps, depth, &(bufsize_required)); - } - - prs_uint32("numofjobs", ps, depth, &(r_u->numofjobs)); - prs_uint32("status", ps, depth, &(r_u->status)); - - if (!ps->io) - { - /* writing */ - free_r_enumjobs(r_u); - } - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd, - uint32 firstjob, - uint32 numofjobs, - uint32 level, - uint32 buf_size) -{ - if (q_u == NULL) - { - return False; - } - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - q_u->firstjob = firstjob; - q_u->numofjobs = numofjobs; - q_u->level = level; - - if (!make_spoolss_buffer(&q_u->buffer, buf_size)) - { - return False; - } - q_u->buf_size = buf_size; - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumjobs(char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("firstjob", ps, depth, &(q_u->firstjob)); - prs_uint32("numofjobs", ps, depth, &(q_u->numofjobs)); - prs_uint32("level", ps, depth, &(q_u->level)); - - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_schedulejob(char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob"); - depth++; - - prs_align(ps); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_schedulejob(char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("jobid", ps, depth, &(q_u->jobid)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_setjob(char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setjob"); - depth++; - - prs_align(ps); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_setjob(char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_setjob"); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("jobid", ps, depth, &(q_u->jobid)); - /* - * level is usually 0. If (level!=0) then I'm in trouble ! - * I will try to generate setjob command with level!=0, one day. - */ - prs_uint32("level", ps, depth, &(q_u->level)); - prs_uint32("command", ps, depth, &(q_u->command)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumdrivers(char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - int i; - - prs_debug(ps, depth, desc, "spoolss_io_r_enumdrivers"); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - - DEBUG(7,("Level [%d], number [%d]\n", r_u->level, r_u->numofdrivers)); - switch (r_u->level) - { - case 1: - { - DRIVER_INFO_1 *driver_info_1; - driver_info_1=r_u->driver.driver_info_1; - - for (i=0; i<r_u->numofdrivers; i++) - { - bufsize_required += spoolss_size_printer_driver_info_1(&(driver_info_1[i])); - } - break; - } - case 2: - { - DRIVER_INFO_2 *driver_info_2; - driver_info_2=r_u->driver.driver_info_2; - - for (i=0; i<r_u->numofdrivers; i++) - { - bufsize_required += spoolss_size_printer_driver_info_2(&(driver_info_2[i])); - } - break; - } - case 3: - { - DRIVER_INFO_3 *driver_info_3; - driver_info_3=r_u->driver.driver_info_3; - - for (i=0; i<r_u->numofdrivers; i++) - { - bufsize_required += spoolss_size_printer_driver_info_3(&(driver_info_3[i])); - } - break; - } - } - - DEBUGADD(7,("size needed: %d\n",bufsize_required)); - DEBUGADD(7,("size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - - if (r_u->offered<bufsize_required) - { - - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - DEBUGADD(8,("buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUGADD(8,("buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - DRIVER_INFO_1 *info; - for (i=0; i<r_u->numofdrivers; i++) - { - info = &(r_u->driver.driver_info_1[i]); - smb_io_printer_driver_info_1(desc, info, ps, depth, &start_offset, &end_offset); - } - break; - } - case 2: - { - DRIVER_INFO_2 *info; - for (i=0; i<r_u->numofdrivers; i++) - { - info = &(r_u->driver.driver_info_2[i]); - smb_io_printer_driver_info_2(desc, info, ps, depth, &start_offset, &end_offset); - } - break; - } - case 3: - { - DRIVER_INFO_3 *info; - for (i=0; i<r_u->numofdrivers; i++) - { - info = &(r_u->driver.driver_info_3[i]); - smb_io_printer_driver_info_3(desc, info, ps, depth, &start_offset, &end_offset); - } - break; - } - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("numofdrivers", ps, depth, &(r_u->numofdrivers)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumprinterdrivers(char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth) -{ - - uint32 useless_ptr=0xADDE0FF0; - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - smb_io_unistr2("", &(q_u->name),True,ps,depth); - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - smb_io_unistr2("", &(q_u->environment),True,ps,depth); - prs_align(ps); - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumforms(char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - int i; - - prs_debug(ps, depth, desc, "spoolss_io_r_enumforms"); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - switch (r_u->level) - { - case 1: - { - FORM_1 *forms_1; - forms_1=r_u->forms_1; - - for (i=0; i<r_u->numofforms; i++) - { - bufsize_required += spoolss_size_form_1(&(forms_1[i])); - } - break; - } - } - - DEBUG(4,("spoolss_io_r_enumforms, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_enumforms, size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - - if (r_u->offered<bufsize_required) - { - - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - - DEBUG(4,("spoolss_io_r_enumforms, buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("spoolss_io_r_enumforms, buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - - if (r_u->offered!=0) - { - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - FORM_1 *info; - for (i=0; i<r_u->numofforms; i++) - { - info = &(r_u->forms_1[i]); - smb_io_form_1(desc, info, ps, depth, &start_offset, &end_offset); - } - break; - } - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("numofforms", ps, depth, &(r_u->numofforms)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumforms(char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumports(char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - int i; - - prs_debug(ps, depth, desc, "spoolss_io_r_enumports"); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - switch (r_u->level) - { - case 2: - { - PORT_INFO_2 *port_2; - port_2=r_u->port.port_info_2; - - for (i=0; i<r_u->numofports; i++) - { - bufsize_required += spoolss_size_port_info_2(&(port_2[i])); - } - break; - } - } - - DEBUG(4,("size needed: %d\n",bufsize_required)); - DEBUG(4,("size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered<bufsize_required) - { - - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - - DEBUG(4,("buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 2: - { - PORT_INFO_2 *info; - for (i=0; i<r_u->numofports; i++) - { - info = &(r_u->port.port_info_2[i]); - smb_io_port_2(desc, info, ps, depth, &start_offset, &end_offset); - } - break; - } - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("numofports", ps, depth, &(r_u->numofports)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumports(char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth) -{ - uint32 useless; - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - prs_uint32("useless", ps, depth, &useless); - smb_io_unistr2("", &(q_u->name),True,ps,depth); - prs_align(ps); - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - - -/******************************************************************* -********************************************************************/ -BOOL spool_io_printer_info_level_2(char *desc, SPOOL_PRINTER_INFO_LEVEL_2 **q_u, prs_struct *ps, int depth) -{ - SPOOL_PRINTER_INFO_LEVEL_2 *il; - - prs_debug(ps, depth, desc, ""); - depth++; - - /* reading */ - if (ps->io) - { - il=(SPOOL_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(SPOOL_PRINTER_INFO_LEVEL_2)); - ZERO_STRUCTP(il); - *q_u=il; - DEBUG(7,("lecture: memoire ok\n")); - } - else - { - il=*q_u; - } - - prs_align(ps); - - prs_uint32("servername_ptr", ps, depth, &(il->servername_ptr)); - prs_uint32("printername_ptr", ps, depth, &(il->printername_ptr)); - prs_uint32("sharename_ptr", ps, depth, &(il->sharename_ptr)); - prs_uint32("portname_ptr", ps, depth, &(il->portname_ptr)); - prs_uint32("drivername_ptr", ps, depth, &(il->drivername_ptr)); - prs_uint32("comment_ptr", ps, depth, &(il->comment_ptr)); - prs_uint32("location_ptr", ps, depth, &(il->location_ptr)); - prs_uint32("devmode_ptr", ps, depth, &(il->devmode_ptr)); - prs_uint32("sepfile_ptr", ps, depth, &(il->sepfile_ptr)); - prs_uint32("printprocessor_ptr", ps, depth, &(il->printprocessor_ptr)); - prs_uint32("datatype_ptr", ps, depth, &(il->datatype_ptr)); - prs_uint32("parameters_ptr", ps, depth, &(il->parameters_ptr)); - prs_uint32("secdesc_ptr", ps, depth, &(il->secdesc_ptr)); - - prs_uint32("attributes", ps, depth, &(il->attributes)); - prs_uint32("priority", ps, depth, &(il->priority)); - prs_uint32("default_priority", ps, depth, &(il->default_priority)); - prs_uint32("starttime", ps, depth, &(il->starttime)); - prs_uint32("untiltime", ps, depth, &(il->untiltime)); - prs_uint32("status", ps, depth, &(il->status)); - prs_uint32("cjobs", ps, depth, &(il->cjobs)); - prs_uint32("averageppm", ps, depth, &(il->averageppm)); - - smb_io_unistr2("", &(il->servername), il->servername_ptr, ps, depth); - smb_io_unistr2("", &(il->printername), il->printername_ptr, ps, depth); - smb_io_unistr2("", &(il->sharename), il->sharename_ptr, ps, depth); - smb_io_unistr2("", &(il->portname), il->portname_ptr, ps, depth); - smb_io_unistr2("", &(il->drivername), il->drivername_ptr, ps, depth); - smb_io_unistr2("", &(il->comment), il->comment_ptr, ps, depth); - smb_io_unistr2("", &(il->location), il->location_ptr, ps, depth); - smb_io_unistr2("", &(il->sepfile), il->sepfile_ptr, ps, depth); - smb_io_unistr2("", &(il->printprocessor), il->printprocessor_ptr, ps, depth); - smb_io_unistr2("", &(il->datatype), il->datatype_ptr, ps, depth); - smb_io_unistr2("", &(il->parameters), il->parameters_ptr, ps, depth); - - prs_align(ps); - - /* this code as nothing to do here !!! - - if (il->secdesc_ptr) - { - il->secdesc=NULL; - sec_io_desc_buf("", &(il->secdesc), ps, depth); - } - - */ - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spool_io_printer_info_level(char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth) -{ - uint32 useless; - uint32 level; - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - prs_uint32("info level", ps, depth, &level); - prs_uint32("useless", ps, depth, &useless); - - switch (level) - { - /* - * level 0 is used by setprinter when managing the queue - * (hold, stop, start a queue) - */ - case 0: - break; - /* - * level 2 is used by addprinter - * and by setprinter when updating printer's info - */ - case 2: - spool_io_printer_info_level_2("", &(il->info_2), ps, depth); - break; - } - - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spool_io_user_level_1(char *desc, SPOOL_USER_LEVEL_1 **q_u, prs_struct *ps, int depth) -{ - SPOOL_USER_LEVEL_1 *il; - prs_debug(ps, depth, desc, ""); - depth++; - - /* reading */ - if (ps->io) - { - il=(SPOOL_USER_LEVEL_1 *)malloc(sizeof(SPOOL_USER_LEVEL_1)); - ZERO_STRUCTP(il); - *q_u=il; - } - else - { - il=*q_u; - } - - prs_align(ps); - prs_uint32("size", ps, depth, &(il->size)); - prs_uint32("client_name_ptr", ps, depth, &(il->client_name_ptr)); - prs_uint32("user_name_ptr", ps, depth, &(il->user_name_ptr)); - prs_uint32("build", ps, depth, &(il->build)); - prs_uint32("major", ps, depth, &(il->major)); - prs_uint32("minor", ps, depth, &(il->minor)); - prs_uint32("processor", ps, depth, &(il->processor)); - - smb_io_unistr2("", &(il->client_name), il->client_name_ptr, ps, depth); - prs_align(ps); - smb_io_unistr2("", &(il->user_name), il->user_name_ptr, ps, depth); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spool_io_user_level(char *desc, SPOOL_USER_LEVEL *q_u, prs_struct *ps, int depth) -{ - uint32 useless; - uint32 level; - prs_debug(ps, depth, desc, "spool_io_user_level"); - depth++; - - prs_align(ps); - prs_uint32("info_level", ps, depth, &level); - prs_uint32("useless", ps, depth, &useless); - - switch (level) - { - case 1: - spool_io_user_level_1("", &(q_u->user_level_1), ps, depth); - break; - - } - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_addprinterex(char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth) -{ - uint32 useless; - prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex"); - depth++; - - /* - * I think that's one of the few well written functions. - * the sub-structures are correctly parsed and analysed - * the info level are handled in a nice way. - */ - - prs_align(ps); - prs_uint32("useless", ps, depth, &useless); - smb_io_unistr2("", &(q_u->server_name),True,ps,depth); - prs_align(ps); - - prs_uint32("info_level", ps, depth, &(q_u->level)); - - spool_io_printer_info_level("", &(q_u->info), ps, depth); - - /* the 4 unknown are all 0 */ - - /* - * en fait ils sont pas inconnu - * par recoupement avec rpcSetPrinter - * c'est le devicemode - * et le security descriptor. - */ - - prs_uint32("unk0", ps, depth, &(q_u->unk0)); - prs_uint32("unk1", ps, depth, &(q_u->unk1)); - prs_uint32("unk2", ps, depth, &(q_u->unk2)); - prs_uint32("unk3", ps, depth, &(q_u->unk3)); - - prs_uint32("info_level", ps, depth, &(q_u->user_level)); - - spool_io_user_level("", &(q_u->user), ps, depth); - - return True; -} - - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_addprinterex(char *desc, SPOOL_R_ADDPRINTEREX *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex"); - depth++; - - smb_io_prt_hnd("printer handle",&(r_u->handle),ps,depth); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spool_io_printer_driver_info_level_3(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u, - prs_struct *ps, int depth) -{ - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il; - - prs_debug(ps, depth, desc, ""); - depth++; - - /* reading */ - if (ps->io) - { - il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)); - ZERO_STRUCTP(il); - *q_u=il; - DEBUG(1,("lecture: memoire ok\n")); - } - else - { - il=*q_u; - } - - prs_align(ps); - - prs_uint32("cversion", ps, depth, &(il->cversion)); - prs_uint32("name", ps, depth, &(il->name_ptr)); - prs_uint32("environment", ps, depth, &(il->environment_ptr)); - prs_uint32("driverpath", ps, depth, &(il->driverpath_ptr)); - prs_uint32("datafile", ps, depth, &(il->datafile_ptr)); - prs_uint32("configfile", ps, depth, &(il->configfile_ptr)); - prs_uint32("helpfile", ps, depth, &(il->helpfile_ptr)); - prs_uint32("monitorname", ps, depth, &(il->monitorname_ptr)); - prs_uint32("defaultdatatype", ps, depth, &(il->defaultdatatype_ptr)); - prs_uint32("dependentfilessize", ps, depth, &(il->dependentfilessize)); - prs_uint32("dependentfiles", ps, depth, &(il->dependentfiles_ptr)); - - prs_align(ps); - - smb_io_unistr2("", &(il->name), il->name_ptr, ps, depth); - smb_io_unistr2("", &(il->environment), il->environment_ptr, ps, depth); - smb_io_unistr2("", &(il->driverpath), il->driverpath_ptr, ps, depth); - smb_io_unistr2("", &(il->datafile), il->datafile_ptr, ps, depth); - smb_io_unistr2("", &(il->configfile), il->configfile_ptr, ps, depth); - smb_io_unistr2("", &(il->helpfile), il->helpfile_ptr, ps, depth); - smb_io_unistr2("", &(il->monitorname), il->monitorname_ptr, ps, depth); - smb_io_unistr2("", &(il->defaultdatatype), il->defaultdatatype_ptr, ps, depth); - - prs_align(ps); - if (il->dependentfiles_ptr) - smb_io_buffer5("", &(il->dependentfiles), ps, depth); - - - return True; -} - - -/******************************************************************* - convert a buffer of UNICODE strings null terminated - the buffer is terminated by a NULL - - convert to an ascii array (null terminated) - - dynamically allocate memory - -********************************************************************/ -BOOL uniarray_2_ascarray(BUFFER5 *buf5, char ***ar) -{ - char **array; - char *string; - char *destend; - char *dest; - uint32 n; - uint32 i; - - uint16 *src; - - if (buf5==NULL) return False; - - array=NULL; - n=0; - i=0; - src=buf5->buffer; - - string=(char *)malloc(sizeof(char)*buf5->buf_len); - - destend = string + buf5->buf_len; - dest=string; - - while (dest < destend) - { - *(dest++) = (char)*(src++); - } - - /* that ugly for the first one but that's working */ - array=(char **)Realloc(array, sizeof(char *)*(i+1)); - array[i++]=string; - - while ( n < buf5->buf_len ) - { - if ( *(string++) == '\0' ) - { - array=(char **)Realloc(array, sizeof(char *)*(i+1)); - array[i++]=string; - } - n++; - } - *ar=array; - - DEBUG(10,("Number of dependent files: [%d]\n", i-1)); - - return True; -} - -/******************************************************************* - read a UNICODE array with null terminated strings - and null terminated array - and size of array at beginning -********************************************************************/ -BOOL smb_io_unibuffer(char *desc, UNISTR2 *buffer, prs_struct *ps, int depth) -{ - if (buffer==NULL) return False; - - buffer->undoc=0; - buffer->uni_str_len=buffer->uni_max_len; - - prs_uint32("buffer_size", ps, depth, &(buffer->uni_max_len)); - - prs_unistr2(True, "buffer ", ps, depth, buffer); - - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spool_io_printer_driver_info_level(char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth) -{ - uint32 useless; - uint32 level; - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - prs_uint32("info level", ps, depth, &level); - prs_uint32("useless", ps, depth, &useless); - - switch (level) - { - case 3: - spool_io_printer_driver_info_level_3("", &(il->info_3), ps, depth); - break; - } - - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_addprinterdriver(char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth) -{ - uint32 useless; - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - prs_uint32("useless", ps, depth, &useless); - smb_io_unistr2("", &(q_u->server_name),True,ps,depth); - prs_align(ps); - prs_uint32("info_level", ps, depth, &(q_u->level)); - - spool_io_printer_driver_info_level("", &(q_u->info), ps, depth); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_addprinterdriver(char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - prs_uint32("status", ps, depth, &(q_u->status)); - - return True; -} - - -/******************************************************************* -********************************************************************/ -BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni, - NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc) -{ - NT_PRINTER_DRIVER_INFO_LEVEL_3 *d; - - DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n")); - - if (*asc==NULL) - { - *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3)); - ZERO_STRUCTP(*asc); - } - - d=*asc; - - d->cversion=uni->cversion; - - unistr2_to_ascii(d->name, &(uni->name), sizeof(d->name)-1); - unistr2_to_ascii(d->environment, &(uni->environment), sizeof(d->environment)-1); - unistr2_to_ascii(d->driverpath, &(uni->driverpath), sizeof(d->driverpath)-1); - unistr2_to_ascii(d->datafile, &(uni->datafile), sizeof(d->datafile)-1); - unistr2_to_ascii(d->configfile, &(uni->configfile), sizeof(d->configfile)-1); - unistr2_to_ascii(d->helpfile, &(uni->helpfile), sizeof(d->helpfile)-1); - unistr2_to_ascii(d->monitorname, &(uni->monitorname), sizeof(d->monitorname)-1); - unistr2_to_ascii(d->defaultdatatype, &(uni->defaultdatatype), sizeof(d->defaultdatatype)-1); - - DEBUGADD(8,( "version: %d\n", d->cversion)); - DEBUGADD(8,( "name: %s\n", d->name)); - DEBUGADD(8,( "environment: %s\n", d->environment)); - DEBUGADD(8,( "driverpath: %s\n", d->driverpath)); - DEBUGADD(8,( "datafile: %s\n", d->datafile)); - DEBUGADD(8,( "configfile: %s\n", d->configfile)); - DEBUGADD(8,( "helpfile: %s\n", d->helpfile)); - DEBUGADD(8,( "monitorname: %s\n", d->monitorname)); - DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype)); - - uniarray_2_ascarray(&(uni->dependentfiles), &(d->dependentfiles) ); - - return True; -} - -BOOL uni_2_asc_printer_info_2(SPOOL_PRINTER_INFO_LEVEL_2 *uni, - NT_PRINTER_INFO_LEVEL_2 **asc) -{ - NT_PRINTER_INFO_LEVEL_2 *d; - - DEBUG(7,("Converting from UNICODE to ASCII\n")); - - if (*asc==NULL) - { - DEBUGADD(8,("allocating memory\n")); - - *asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2)); - ZERO_STRUCTP(*asc); - } - DEBUGADD(8,("start converting\n")); - - d=*asc; - - d->attributes=uni->attributes; - d->priority=uni->priority; - d->default_priority=uni->default_priority; - d->starttime=uni->starttime; - d->untiltime=uni->untiltime; - d->status=uni->status; - d->cjobs=uni->cjobs; - - unistr2_to_ascii(d->servername, &(uni->servername), sizeof(d->servername)-1); - unistr2_to_ascii(d->printername, &(uni->printername), sizeof(d->printername)-1); - unistr2_to_ascii(d->sharename, &(uni->sharename), sizeof(d->sharename)-1); - unistr2_to_ascii(d->portname, &(uni->portname), sizeof(d->portname)-1); - unistr2_to_ascii(d->drivername, &(uni->drivername), sizeof(d->drivername)-1); - unistr2_to_ascii(d->comment, &(uni->comment), sizeof(d->comment)-1); - unistr2_to_ascii(d->location, &(uni->location), sizeof(d->location)-1); - unistr2_to_ascii(d->sepfile, &(uni->sepfile), sizeof(d->sepfile)-1); - unistr2_to_ascii(d->printprocessor, &(uni->printprocessor), sizeof(d->printprocessor)-1); - unistr2_to_ascii(d->datatype, &(uni->datatype), sizeof(d->datatype)-1); - unistr2_to_ascii(d->parameters, &(uni->parameters), sizeof(d->parameters)-1); - - return True; -} - -BOOL convert_printer_info(SPOOL_PRINTER_INFO_LEVEL uni, - NT_PRINTER_INFO_LEVEL *printer, - uint32 level) -{ - switch (level) - { - case 2: - { - uni_2_asc_printer_info_2(uni.info_2, &(printer->info_2)); - break; - } - default: - break; - } - - - - return True; -} - -BOOL convert_printer_driver_info(SPOOL_PRINTER_DRIVER_INFO_LEVEL uni, - NT_PRINTER_DRIVER_INFO_LEVEL *printer, - uint32 level) -{ - switch (level) - { - case 3: - { - printer->info_3=NULL; - uni_2_asc_printer_driver_3(uni.info_3, &(printer->info_3)); - break; - } - default: - break; - } - - - - return True; -} - -BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) -{ - unistr_to_ascii(nt_devmode->devicename, - devmode.devicename.buffer, - 31); - - unistr_to_ascii(nt_devmode->formname, - devmode.formname.buffer, - 31); - - nt_devmode->specversion=devmode.specversion; - nt_devmode->driverversion=devmode.driverversion; - nt_devmode->size=devmode.size; - nt_devmode->driverextra=devmode.driverextra; - nt_devmode->fields=devmode.fields; - nt_devmode->orientation=devmode.orientation; - nt_devmode->papersize=devmode.papersize; - nt_devmode->paperlength=devmode.paperlength; - nt_devmode->paperwidth=devmode.paperwidth; - nt_devmode->scale=devmode.scale; - nt_devmode->copies=devmode.copies; - nt_devmode->defaultsource=devmode.defaultsource; - nt_devmode->printquality=devmode.printquality; - nt_devmode->color=devmode.color; - nt_devmode->duplex=devmode.duplex; - nt_devmode->yresolution=devmode.yresolution; - nt_devmode->ttoption=devmode.ttoption; - nt_devmode->collate=devmode.collate; - - nt_devmode->logpixels=devmode.logpixels; - nt_devmode->bitsperpel=devmode.bitsperpel; - nt_devmode->pelswidth=devmode.pelswidth; - nt_devmode->pelsheight=devmode.pelsheight; - nt_devmode->displayflags=devmode.displayflags; - nt_devmode->displayfrequency=devmode.displayfrequency; - nt_devmode->icmmethod=devmode.icmmethod; - nt_devmode->icmintent=devmode.icmintent; - nt_devmode->mediatype=devmode.mediatype; - nt_devmode->dithertype=devmode.dithertype; - nt_devmode->reserved1=devmode.reserved1; - nt_devmode->reserved2=devmode.reserved2; - nt_devmode->panningwidth=devmode.panningwidth; - nt_devmode->panningheight=devmode.panningheight; - - if (nt_devmode->driverextra != 0) - { - /* if we had a previous private delete it and make a new one */ - if (nt_devmode->private != NULL) - free(nt_devmode->private); - nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8)); - memcpy(nt_devmode->private, devmode.private, nt_devmode->driverextra); - } - - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_getprinterdriverdir(char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir"); - depth++; - - prs_align(ps); - - prs_uint32("pointer", ps, depth, &useless_ptr); - - switch (r_u->level) - { - case 1: - { - DRIVER_DIRECTORY_1 *driver_info_1; - driver_info_1=&(r_u->driver.driver_info_1); - - bufsize_required = size_of_relative_string(&(driver_info_1->name)); - break; - } - } - - DEBUG(4,("spoolss_io_r_getprinterdriverdir, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_getprinterdriverdir, size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - - if (r_u->offered<bufsize_required) - { - - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - DEBUG(4,("spoolss_io_r_getprinterdriverdir, buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("spoolss_io_r_getprinterdriverdir, buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - DRIVER_DIRECTORY_1 *info; - info = &(r_u->driver.driver_info_1); - prs_unistr("name", ps, depth, &(info->name)); - /*smb_io_printer_driver_dir_1(desc, info, ps, depth, &start_offset, &end_offset);*/ - break; - } - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_getprinterdriverdir(char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth) -{ - - uint32 useless_ptr=0xADDE0FF0; - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - smb_io_unistr2("", &(q_u->name),True,ps,depth); - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - smb_io_unistr2("", &(q_u->environment),True,ps,depth); - prs_align(ps); - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumprintprocessors(char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - int i; - - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors"); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - switch (r_u->level) - { - case 1: - { - PRINTPROCESSOR_1 *info_1; - info_1=r_u->info_1; - - for (i=0; i<r_u->numofprintprocessors; i++) - { - bufsize_required += spoolss_size_processor_info_1(&(info_1[i])); - } - break; - } - } - - DEBUG(4,("size needed: %d\n",bufsize_required)); - DEBUG(4,("size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered<bufsize_required) - { - - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - - DEBUG(4,("buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - PRINTPROCESSOR_1 *info_1; - for (i=0; i<r_u->numofprintprocessors; i++) - { - info_1 = &(r_u->info_1[i]); - smb_io_processor_info_1(desc, info_1, ps, depth, &start_offset, &end_offset); - } - break; - } - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("numofprintprocessors", ps, depth, &(r_u->numofprintprocessors)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumprintprocessors(char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth) -{ - uint32 useless; - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors"); - depth++; - - prs_align(ps); - prs_uint32("useless", ps, depth, &useless); - smb_io_unistr2("", &(q_u->name),True,ps,depth); - prs_align(ps); - prs_uint32("useless", ps, depth, &useless); - smb_io_unistr2("", &(q_u->environment),True,ps,depth); - prs_align(ps); - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumprintmonitors(char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - int i; - - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors"); - depth++; - - prs_align(ps); - prs_uint32("pointer", ps, depth, &useless_ptr); - switch (r_u->level) - { - case 1: - { - PRINTMONITOR_1 *info_1; - info_1=r_u->info_1; - - for (i=0; i<r_u->numofprintmonitors; i++) - { - bufsize_required += spoolss_size_monitor_info_1(&(info_1[i])); - } - break; - } - } - - DEBUG(4,("size needed: %d\n",bufsize_required)); - DEBUG(4,("size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered<bufsize_required) - { - - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - - DEBUG(4,("buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - PRINTMONITOR_1 *info_1; - for (i=0; i<r_u->numofprintmonitors; i++) - { - info_1 = &(r_u->info_1[i]); - smb_io_monitor_info_1(desc, info_1, ps, depth, &start_offset, &end_offset); - } - break; - } - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("numofprintmonitors", ps, depth, &(r_u->numofprintmonitors)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumprintmonitors(char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth) -{ - uint32 useless; - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors"); - depth++; - - prs_align(ps); - prs_uint32("useless", ps, depth, &useless); - smb_io_unistr2("", &(q_u->name),True,ps,depth); - prs_align(ps); - prs_uint32("level", ps, depth, &(q_u->level)); - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_enumprinterdata(char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata"); - depth++; - - prs_align(ps); - prs_uint32("valuesize", ps, depth, &(r_u->valuesize)); - prs_unistr("value", ps, depth, &(r_u->value)); - prs_uint32("realvaluesize", ps, depth, &(r_u->realvaluesize)); - - prs_uint32("type", ps, depth, &(r_u->type)); - - prs_uint32("datasize", ps, depth, &(r_u->datasize)); - prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize); - prs_uint32("realdatasize", ps, depth, &(r_u->realdatasize)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_enumprinterdata(char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata"); - depth++; - - prs_align(ps); - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("index", ps, depth, &(q_u->index)); - prs_uint32("valuesize", ps, depth, &(q_u->valuesize)); - prs_uint32("datasize", ps, depth, &(q_u->datasize)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_setprinterdata(char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata"); - depth++; - - prs_align(ps); - smb_io_prt_hnd("printer handle", &(q_u->handle), ps, depth); - smb_io_unistr2("", &(q_u->value), True, ps, depth); - - prs_align(ps); - - prs_uint32("type", ps, depth, &(q_u->type)); - - prs_uint32("max_len", ps, depth, &(q_u->max_len)); - - switch (q_u->type) - { - case 0x1: - case 0x3: - case 0x4: - case 0x7: - q_u->data=(uint8 *)malloc(q_u->max_len * sizeof(uint8)); - prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len); - prs_align(ps); - break; - } - - prs_uint32("real_len", ps, depth, &(q_u->real_len)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_setprinterdata(char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata"); - depth++; - - prs_align(ps); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL convert_specific_param(NT_PRINTER_PARAM **param, UNISTR2 value , uint32 type, uint8 *data, uint32 len) -{ - DEBUG(5,("converting a specific param struct\n")); - - if (*param == NULL) - { - *param=(NT_PRINTER_PARAM *)malloc(sizeof(NT_PRINTER_PARAM)); - ZERO_STRUCTP(*param); - DEBUGADD(6,("Allocated a new PARAM struct\n")); - } - unistr2_to_ascii((*param)->value, &value, sizeof((*param)->value)-1); - (*param)->type = type; - - /* le champ data n'est pas NULL termine */ - /* on stocke donc la longueur */ - - (*param)->data_len=len; - - (*param)->data=(uint8 *)malloc(len * sizeof(uint8)); - - memcpy((*param)->data, data, len); - - DEBUGADD(6,("\tvalue:[%s], len:[%d]\n",(*param)->value, (*param)->data_len)); - - return True; -} - -/******************************************************************* -********************************************************************/ -static BOOL spoolss_io_addform(char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_addform"); - depth++; - prs_align(ps); - - if (ptr!=0) - { - prs_uint32("flags", ps, depth, &(f->flags)); - prs_uint32("name_ptr", ps, depth, &(f->name_ptr)); - prs_uint32("size_x", ps, depth, &(f->size_x)); - prs_uint32("size_y", ps, depth, &(f->size_y)); - prs_uint32("left", ps, depth, &(f->left)); - prs_uint32("top", ps, depth, &(f->top)); - prs_uint32("right", ps, depth, &(f->right)); - prs_uint32("bottom", ps, depth, &(f->bottom)); - - smb_io_unistr2("", &(f->name), f->name_ptr, ps, depth); - } - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_addform(char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0; - prs_debug(ps, depth, desc, "spoolss_io_q_addform"); - depth++; - - prs_align(ps); - smb_io_prt_hnd("printer handle", &(q_u->handle), ps, depth); - prs_uint32("level", ps, depth, &(q_u->level)); - prs_uint32("level2", ps, depth, &(q_u->level2)); - - if (q_u->level==1) - { - prs_uint32("useless_ptr", ps, depth, &(useless_ptr)); - spoolss_io_addform("", &(q_u->form), useless_ptr, ps, depth); - } - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_addform(char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addform"); - depth++; - - prs_align(ps); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_setform(char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0; - prs_debug(ps, depth, desc, "spoolss_io_q_setform"); - depth++; - - prs_align(ps); - smb_io_prt_hnd("printer handle", &(q_u->handle), ps, depth); - smb_io_unistr2("", &(q_u->name), True, ps, depth); - - prs_align(ps); - - prs_uint32("level", ps, depth, &(q_u->level)); - prs_uint32("level2", ps, depth, &(q_u->level2)); - - if (q_u->level==1) - { - prs_uint32("useless_ptr", ps, depth, &(useless_ptr)); - spoolss_io_addform("", &(q_u->form), useless_ptr, ps, depth); - } - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_setform(char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setform"); - depth++; - - prs_align(ps); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_getjob(char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0xADDE0FF0; - uint32 start_offset, end_offset, beginning; - uint32 bufsize_required=0; - - prs_debug(ps, depth, desc, "spoolss_io_r_getjob"); - depth++; - - prs_align(ps); - - prs_uint32("pointer", ps, depth, &useless_ptr); - - switch (r_u->level) - { - case 1: - { - JOB_INFO_1 *info; - info=r_u->job.job_info_1; - - bufsize_required += spoolss_size_job_info_1(info); - break; - } - case 2: - { - JOB_INFO_2 *info; - info=r_u->job.job_info_2; - - bufsize_required += spoolss_size_job_info_2(info); - break; - } - } - - DEBUG(4,("spoolss_io_r_getjob, size needed: %d\n",bufsize_required)); - DEBUG(4,("spoolss_io_r_getjob, size offered: %d\n",r_u->offered)); - - /* check if the buffer is big enough for the datas */ - if (r_u->offered<bufsize_required) - { - /* it's too small */ - r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */ - r_u->offered=0; /* don't send back the buffer */ - - DEBUG(4,("spoolss_io_r_getjob, buffer too small\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - } - else - { - mem_grow_data(&(ps->data), ps->io, r_u->offered, 0); - - DEBUG(4,("spoolss_io_r_enumjobs, buffer large enough\n")); - - prs_uint32("size of buffer", ps, depth, &(r_u->offered)); - beginning=ps->offset; - start_offset=ps->offset; - end_offset=start_offset+r_u->offered; - - switch (r_u->level) - { - case 1: - { - JOB_INFO_1 *info; - info = r_u->job.job_info_1; - smb_io_job_info_1(desc, info, ps, depth, &start_offset, &end_offset); - break; - } - case 2: - { - JOB_INFO_2 *info; - info = r_u->job.job_info_2; - smb_io_job_info_2(desc, info, ps, depth, &start_offset, &end_offset); - break; - } - - } - ps->offset=beginning+r_u->offered; - prs_align(ps); - } - - /* - * if the buffer was too small, send the minimum required size - * if it was too large, send the real needed size - */ - - prs_uint32("size of buffer needed", ps, depth, &(bufsize_required)); - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_getjob(char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, ""); - depth++; - - prs_align(ps); - - smb_io_prt_hnd("printer handle",&(q_u->handle),ps,depth); - prs_uint32("jobid", ps, depth, &(q_u->jobid)); - prs_uint32("level", ps, depth, &(q_u->level)); - - spoolss_io_read_buffer("", ps, depth, &(q_u->buffer)); - - prs_align(ps); - - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} diff --git a/source/rpc_parse/parse_svc.c b/source/rpc_parse/parse_svc.c deleted file mode 100644 index 08fed7d47c7..00000000000 --- a/source/rpc_parse/parse_svc.c +++ /dev/null @@ -1,936 +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) Paul Ashton 1997-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_svc_q_open_sc_man - ********************************************************************/ -BOOL make_svc_q_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, - const char *server, const char *database, - uint32 des_access) -{ - DEBUG(5,("make_svc_q_open_sc_man\n")); - - make_buf_unistr2(&(q_u->uni_srv_name), &(q_u->ptr_srv_name), server); - make_buf_unistr2(&(q_u->uni_db_name ), &(q_u->ptr_db_name), database); - q_u->des_access = des_access; - - - return True; -} - -/******************************************************************* -reads or writes a SVC_Q_OPEN_SC_MAN structure. -********************************************************************/ -BOOL svc_io_q_open_sc_man(char *desc, SVC_Q_OPEN_SC_MAN *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_open_sc_man"); - depth++; - - prs_align(ps); - - prs_uint32("ptr_srv_name", ps, depth, &(q_u->ptr_srv_name)); - smb_io_unistr2("", &(q_u->uni_srv_name), q_u->ptr_srv_name, ps, depth); - prs_align(ps); - - prs_uint32("ptr_db_name", ps, depth, &(q_u->ptr_db_name)); - smb_io_unistr2("", &(q_u->uni_db_name), q_u->ptr_db_name, ps, depth); - prs_align(ps); - - prs_uint32("des_access", ps, depth, &(q_u->des_access)); - prs_align(ps); - - return True; -} - -/******************************************************************* - make_svc_r_open_sc_man - ********************************************************************/ -BOOL make_svc_r_open_sc_man(SVC_R_OPEN_SC_MAN *r_u, POLICY_HND *hnd, - uint32 status) -{ - DEBUG(5,("make_svc_r_unknown_0: %d\n", __LINE__)); - - memcpy(&(r_u->pol), hnd, sizeof(r_u->pol)); - r_u->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_open_sc_man(char *desc, SVC_R_OPEN_SC_MAN *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_open_sc_man"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(r_u->pol), ps, depth); - - prs_uint32("status ", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* - make_svc_q_open_service - ********************************************************************/ -BOOL make_svc_q_open_service(SVC_Q_OPEN_SERVICE *q_u, - POLICY_HND *hnd, - const char *server, - uint32 des_access) -{ - DEBUG(5,("make_svc_q_open_service\n")); - - memcpy(&(q_u->scman_pol), hnd, sizeof(q_u->scman_pol)); - make_unistr2(&(q_u->uni_svc_name), server, strlen(server)+1); - q_u->des_access = des_access; - - - return True; -} - -/******************************************************************* -reads or writes a SVC_Q_OPEN_SERVICE structure. -********************************************************************/ -BOOL svc_io_q_open_service(char *desc, SVC_Q_OPEN_SERVICE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_open_service"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(q_u->scman_pol), ps, depth); - prs_align(ps); - - smb_io_unistr2("", &(q_u->uni_svc_name), 1, ps, depth); - prs_align(ps); - - prs_uint32("des_access", ps, depth, &(q_u->des_access)); - prs_align(ps); - - return True; -} - -/******************************************************************* - make_svc_r_open_service - ********************************************************************/ -BOOL make_svc_r_open_service(SVC_R_OPEN_SERVICE *r_u, POLICY_HND *hnd, - uint32 status) -{ - DEBUG(5,("make_svc_r_unknown_0: %d\n", __LINE__)); - - memcpy(&(r_u->pol), hnd, sizeof(r_u->pol)); - r_u->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_open_service(char *desc, SVC_R_OPEN_SERVICE *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_open_service"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(r_u->pol), ps, depth); - - prs_uint32("status ", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -makes an SVC_Q_STOP_SERVICE structure. -********************************************************************/ -BOOL make_svc_q_stop_service(SVC_Q_STOP_SERVICE *q_c, POLICY_HND *hnd, - uint32 unk) -{ - if (q_c == NULL || hnd == NULL) return False; - - DEBUG(5,("make_svc_q_stop_service\n")); - - memcpy(&(q_c->pol), hnd, sizeof(q_c->pol)); - q_c->unknown = unk; - - return True; -} - -/******************************************************************* -reads or writes a SVC_Q_STOP_SERVICE structure. -********************************************************************/ -BOOL svc_io_q_stop_service(char *desc, SVC_Q_STOP_SERVICE *q_s, prs_struct *ps, int depth) -{ - if (q_s == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_stop_service"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(q_s->pol), ps, depth); - - prs_align(ps); - - prs_uint32("unknown", ps, depth, &(q_s->unknown)); - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_stop_service(char *desc, SVC_R_STOP_SERVICE *r_s, prs_struct *ps, int depth) -{ - if (r_s == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_stop_service"); - depth++; - - prs_uint32("unknown0", ps, depth, &(r_s->unknown0)); - prs_uint32("unknown1", ps, depth, &(r_s->unknown1)); - prs_uint32("unknown2", ps, depth, &(r_s->unknown2)); - prs_uint32("unknown3", ps, depth, &(r_s->unknown3)); - prs_uint32("unknown4", ps, depth, &(r_s->unknown4)); - prs_uint32("unknown5", ps, depth, &(r_s->unknown5)); - prs_uint32("unknown6", ps, depth, &(r_s->unknown6)); - prs_uint32("status", ps, depth, &(r_s->status)); - - return True; -} - -/******************************************************************* -makes an SVC_Q_START_SERVICE structure. -********************************************************************/ -BOOL make_svc_q_start_service(SVC_Q_START_SERVICE *q_c, POLICY_HND *hnd, - uint32 argc, - char **argv) -{ - uint32 i; - - if (q_c == NULL || hnd == NULL) return False; - - DEBUG(5,("make_svc_q_start_service\n")); - - memcpy(&(q_c->pol), hnd, sizeof(q_c->pol)); - q_c->argc = argc; - q_c->ptr_args = 1; - q_c->argc2 = argc; - - for (i = 0; i < argc; i++) - { - size_t len_argv = argv[i] != NULL ? strlen(argv[i])+1 : 0; - q_c->ptr_argv[i] = argv[i] != NULL ? 1 : 0; - make_unistr2(&(q_c->argv[i]), argv[i], len_argv); - } - - return True; -} - -/******************************************************************* -reads or writes a SVC_Q_START_SERVICE structure. -********************************************************************/ -BOOL svc_io_q_start_service(char *desc, SVC_Q_START_SERVICE *q_s, prs_struct *ps, int depth) -{ - if (q_s == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_start_service"); - depth++; - - prs_align(ps); - smb_io_pol_hnd("", &(q_s->pol), ps, depth); - - prs_align(ps); - prs_uint32("argc ", ps, depth, &(q_s->argc )); - prs_uint32("ptr_args", ps, depth, &(q_s->ptr_args)); - - if (q_s->ptr_args != 0) - { - uint32 i; - - prs_uint32("argc2 ", ps, depth, &(q_s->argc2)); - - if (q_s->argc2 > MAX_SVC_ARGS) - { - return False; - } - - for (i = 0; i < q_s->argc2; i++) - { - prs_uint32("", ps, depth, &(q_s->ptr_argv[i])); - } - for (i = 0; i < q_s->argc2; i++) - { - smb_io_unistr2("", &(q_s->argv[i]), q_s->ptr_argv[i], ps, depth); - prs_align(ps); - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_start_service(char *desc, SVC_R_START_SERVICE *r_s, prs_struct *ps, int depth) -{ - if (r_s == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_start_service"); - depth++; - - prs_uint32("status", ps, depth, &(r_s->status)); - - return True; -} - -/******************************************************************* - make_svc_query_svc_cfg - ********************************************************************/ -BOOL make_svc_query_svc_cfg(QUERY_SERVICE_CONFIG *q_u, - uint32 service_type, uint32 start_type, - uint32 error_control, - char* bin_path_name, char* load_order_grp, - uint32 tag_id, - char* dependencies, char* service_start_name, - char* disp_name) -{ - DEBUG(5,("make_svc_query_svc_cfg\n")); - - q_u->service_type = service_type; - q_u->start_type = start_type; - q_u->error_control = error_control; - make_buf_unistr2(&(q_u->uni_bin_path_name ), &(q_u->ptr_bin_path_name ), bin_path_name ); - make_buf_unistr2(&(q_u->uni_load_order_grp ), &(q_u->ptr_load_order_grp ), load_order_grp ); - q_u->tag_id = tag_id; - make_buf_unistr2(&(q_u->uni_dependencies ), &(q_u->ptr_dependencies ), dependencies ); - make_buf_unistr2(&(q_u->uni_service_start_name), &(q_u->ptr_service_start_name), service_start_name); - make_buf_unistr2(&(q_u->uni_display_name ), &(q_u->ptr_display_name ), disp_name ); - - return True; -} - -/******************************************************************* -reads or writes a QUERY_SERVICE_CONFIG structure. -********************************************************************/ -BOOL svc_io_query_svc_cfg(char *desc, QUERY_SERVICE_CONFIG *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_query_svc_cfg"); - depth++; - - prs_align(ps); - - prs_uint32("service_type ", ps, depth, &(q_u->service_type )); - prs_uint32("start_type ", ps, depth, &(q_u->start_type )); - prs_uint32("error_control ", ps, depth, &(q_u->error_control )); - prs_uint32("ptr_bin_path_name ", ps, depth, &(q_u->ptr_bin_path_name )); - prs_uint32("ptr_load_order_grp ", ps, depth, &(q_u->ptr_load_order_grp )); - prs_uint32("tag_id ", ps, depth, &(q_u->tag_id )); - prs_uint32("ptr_dependencies ", ps, depth, &(q_u->ptr_dependencies )); - prs_uint32("ptr_service_start_name", ps, depth, &(q_u->ptr_service_start_name)); - prs_uint32("ptr_display_name ", ps, depth, &(q_u->ptr_display_name )); - - smb_io_unistr2("uni_bin_path_name ", &(q_u->uni_bin_path_name ), q_u->ptr_bin_path_name , ps, depth); - prs_align(ps); - smb_io_unistr2("uni_load_order_grp ", &(q_u->uni_load_order_grp ), q_u->ptr_load_order_grp , ps, depth); - prs_align(ps); - smb_io_unistr2("uni_dependencies ", &(q_u->uni_dependencies ), q_u->ptr_dependencies , ps, depth); - prs_align(ps); - smb_io_unistr2("uni_service_start_name", &(q_u->uni_service_start_name), q_u->ptr_service_start_name, ps, depth); - prs_align(ps); - smb_io_unistr2("uni_display_name ", &(q_u->uni_display_name ), q_u->ptr_display_name , ps, depth); - prs_align(ps); - - return True; -} - -/******************************************************************* -makes an SVC_Q_ENUM_SVCS_STATUS structure. -********************************************************************/ -BOOL make_svc_q_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_c, POLICY_HND *hnd, - uint32 service_type, uint32 service_state, - uint32 buf_size, uint32 resume_hnd ) -{ - if (q_c == NULL || hnd == NULL) return False; - - DEBUG(5,("make_svc_q_enum_svcs_status\n")); - - memcpy(&(q_c->pol), hnd, sizeof(q_c->pol)); - q_c->service_type = service_type; - q_c->service_state = service_state; - q_c->buf_size = buf_size; - make_enum_hnd(&q_c->resume_hnd, resume_hnd); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_q_enum_svcs_status(char *desc, SVC_Q_ENUM_SVCS_STATUS *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_enum_svcs_status"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - prs_align(ps); - - prs_uint32("service_type ", ps, depth, &(q_u->service_type )); - prs_uint32("service_state", ps, depth, &(q_u->service_state)); - prs_uint32("buf_size ", ps, depth, &(q_u->buf_size )); - smb_io_enum_hnd("resume_hnd", &(q_u->resume_hnd), ps, depth); - - return True; -} - -/******************************************************************* -makes an SVC_R_ENUM_SVCS_STATUS structure. -********************************************************************/ -BOOL make_svc_r_enum_svcs_status(SVC_R_ENUM_SVCS_STATUS *r_c, - ENUM_SRVC_STATUS *svcs, uint32 more_buf_size, - uint32 num_svcs, uint32 resume_hnd, - uint32 dos_status) -{ - if (r_c == NULL) return False; - - DEBUG(5,("make_svc_r_enum_svcs_status\n")); - - r_c->svcs = svcs; - r_c->more_buf_size = more_buf_size; - r_c->num_svcs = num_svcs; - make_enum_hnd(&r_c->resume_hnd, resume_hnd); - r_c->dos_status = dos_status; - - return True; -} - -/******************************************************************* -reads or writes a SVC_R_ENUM_SVCS_STATUS structure. - -this is another wierd structure. WHY oh WHY can the microsoft teams -not COMMUNICATE and get some CONSISTENCY TO THEIR DATA STRUCTURES! -ARGH! - -********************************************************************/ -BOOL svc_io_r_enum_svcs_status(char *desc, SVC_R_ENUM_SVCS_STATUS *svc, prs_struct *ps, int depth) -{ - uint32 i; - if (svc == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_enum_svcs_status"); - depth++; - - prs_align(ps); - - /* - * format is actually as laid out in SVC_R_ENUM_SVCS_STATUS. - * the reason for all the jumping about, which is horrible - * and can be avoided, is due to the use of offsets instead - * of pointers. - * - * if i ever find out that these offsets are in fact non-zero - * tokens just like pointer-tokens, i am going to go MAD. - */ - - if (ps->io) - { - /* reading */ - - uint32 buf_offset; - uint32 new_offset; - - prs_uint32("buf_size", ps, depth, &(svc->buf_size)); - - buf_offset = ps->offset; - ps->offset = buf_offset + svc->buf_size; - - prs_align(ps); - - prs_uint32("more_buf_size", ps, depth, &(svc->more_buf_size)); - prs_uint32("num_svcs", ps, depth, &(svc->num_svcs)); - smb_io_enum_hnd("resume_hnd", &(svc->resume_hnd), ps, depth); - prs_uint32("dos_status", ps, depth, &(svc->dos_status)); - - new_offset = ps->offset; - ps->offset = buf_offset; - - svc->svcs = (ENUM_SRVC_STATUS*)Realloc(NULL, - svc->num_svcs * sizeof(ENUM_SRVC_STATUS)); - - if (svc->svcs == NULL) - { - DEBUG(0,("svc_io_r_enum_svcs_status: Realloc failed\n")); - ps->offset = 0x7fffffff; - return False; - } - - bzero(svc->svcs, svc->num_svcs * sizeof(ENUM_SRVC_STATUS)); - - for (i = 0; i < svc->num_svcs; i++) - { - fstring name; - uint32 old_offset; - uint32 srvc_offset; - uint32 disp_offset; - - prs_uint32("srvc_offset", ps, depth, &srvc_offset); - prs_uint32("disp_offset", ps, depth, &disp_offset); - svc_io_svc_status("status", &svc->svcs[i].status, ps, depth); - - old_offset = ps->offset; - - ps->offset = buf_offset + srvc_offset; - slprintf(name, sizeof(name)-1, "srvc[%02d]", i); - smb_io_unistr(name, &svc->svcs[i].uni_srvc_name, ps, depth); - - ps->offset = buf_offset + disp_offset; - slprintf(name, sizeof(name)-1, "disp[%02d]", i); - smb_io_unistr(name, &svc->svcs[i].uni_disp_name, ps, depth); - - ps->offset = old_offset; - } - - ps->offset = new_offset; - } - else - { - /* writing */ - - uint32 buf_offset; - uint32 old_buf_offset; - uint32 srvc_offset = 9 * sizeof(uint32) * svc->num_svcs; - - prs_uint32_pre("buf_size", ps, depth, &svc->buf_size, &buf_offset); - old_buf_offset = ps->offset; - - srvc_offset += old_buf_offset; - - if (svc->svcs == NULL) - { - return False; - } - - for (i = 0; i < svc->num_svcs; i++) - { - fstring name; - uint32 old_offset; - - /* - * store unicode string offset and unicode string - */ - - srvc_offset -= old_buf_offset; - prs_uint32("srvc_offset", ps, depth, &srvc_offset); - srvc_offset += old_buf_offset; - - slprintf(name, sizeof(name)-1, "srvc[%02d]", i); - - old_offset = ps->offset; - ps->offset = srvc_offset; - smb_io_unistr(name, &svc->svcs[i].uni_srvc_name, ps, depth); - srvc_offset = ps->offset; - ps->offset = old_offset; - - /* - * store unicode string offset and unicode string - */ - - srvc_offset -= old_buf_offset; - prs_uint32("disp_offset", ps, depth, &srvc_offset); - srvc_offset += old_buf_offset; - - slprintf(name, sizeof(name)-1, "disp[%02d]", i); - - old_offset = ps->offset; - ps->offset = srvc_offset; - smb_io_unistr(name, &svc->svcs[i].uni_disp_name, ps, depth); - srvc_offset = ps->offset; - ps->offset = old_offset; - - /* - * store status info - */ - - svc_io_svc_status("status", &svc->svcs[i].status, ps, depth); - } - - prs_uint32_post("buf_size", ps, depth, &svc->buf_size, buf_offset, srvc_offset - buf_offset - sizeof(uint32)); - - ps->offset = srvc_offset; - - prs_align(ps); - - prs_uint32("more_buf_size", ps, depth, &(svc->more_buf_size)); - prs_uint32("num_svcs", ps, depth, &(svc->num_svcs)); - smb_io_enum_hnd("resume_hnd", &(svc->resume_hnd), ps, depth); - prs_uint32("dos_status", ps, depth, &(svc->dos_status)); - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_svc_status(char *desc, SVC_STATUS *svc, prs_struct *ps, int depth) -{ - if (svc == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_svc_status"); - depth++; - - prs_align(ps); - - prs_uint32("svc_type", ps, depth, &(svc->svc_type)); - prs_uint32("current_state", ps, depth, &(svc->current_state)); - prs_uint32("controls_accepted", ps, depth, &(svc->controls_accepted)); - prs_uint32("win32_exit_code", ps, depth, &(svc->win32_exit_code)); - prs_uint32("svc_specific_exit_code", ps, depth, &(svc->svc_specific_exit_code)); - prs_uint32("check_point", ps, depth, &(svc->check_point)); - prs_uint32("wait_hint", ps, depth, &(svc->wait_hint)); - - return True; -} - -/******************************************************************* -makes an SVC_Q_QUERY_SVC_CONFIG structure. -********************************************************************/ -BOOL make_svc_q_query_svc_config(SVC_Q_QUERY_SVC_CONFIG *q_c, POLICY_HND *hnd, - uint32 buf_size) -{ - if (q_c == NULL || hnd == NULL) return False; - - DEBUG(5,("make_svc_q_query_svc_config\n")); - - memcpy(&(q_c->pol), hnd, sizeof(q_c->pol)); - q_c->buf_size = buf_size; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_q_query_svc_config(char *desc, SVC_Q_QUERY_SVC_CONFIG *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_query_svc_config"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - prs_align(ps); - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -makes an SVC_R_QUERY_SVC_CONFIG structure. -********************************************************************/ -BOOL make_svc_r_query_svc_config(SVC_R_QUERY_SVC_CONFIG *r_c, - QUERY_SERVICE_CONFIG *cfg, - uint32 buf_size) -{ - if (r_c == NULL) return False; - - DEBUG(5,("make_svc_r_query_svc_config\n")); - - r_c->cfg = cfg; - r_c->buf_size = buf_size; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_query_svc_config(char *desc, SVC_R_QUERY_SVC_CONFIG *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_query_svc_config"); - depth++; - - prs_align(ps); - - svc_io_query_svc_cfg("cfg", r_u->cfg, ps, depth); - prs_uint32("buf_size", ps, depth, &(r_u->buf_size)); - prs_uint32("status ", ps, depth, &(r_u->status )); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_q_query_disp_name(char *desc, SVC_Q_QUERY_DISP_NAME *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_query_disp_name"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(q_u->scman_pol), ps, depth); - prs_align(ps); - - smb_io_unistr2("uni_svc_name", &(q_u->uni_svc_name), 1, ps, depth); - prs_align(ps); - - prs_uint32("buf_size", ps, depth, &(q_u->buf_size)); - - return True; -} - -/******************************************************************* -makes an SVC_R_QUERY_DISP_NAME structure. -********************************************************************/ -BOOL make_svc_r_query_disp_name(SVC_R_QUERY_DISP_NAME *r_d, - char *disp_name, uint32 status) -{ - uint32 len = strlen(disp_name); - - if (r_d == NULL) return False; - - DEBUG(5,("make_svc_r_query_disp_name\n")); - - make_unistr2(&(r_d->uni_disp_name), disp_name, len+1); - r_d->buf_size = len; - - r_d->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_query_disp_name(char *desc, SVC_R_QUERY_DISP_NAME *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_query_disp_name"); - depth++; - - prs_align(ps); - - smb_io_unistr2("uni_disp_name", &(r_u->uni_disp_name), 1, ps, depth); - prs_align(ps); - - prs_uint32("buf_size", ps, depth, &(r_u->buf_size)); - prs_uint32("status ", ps, depth, &(r_u->status )); - - return True; -} - -/******************************************************************* -makes an SVC_Q_CLOSE structure. -********************************************************************/ -BOOL make_svc_q_close(SVC_Q_CLOSE *q_c, POLICY_HND *hnd) -{ - if (q_c == NULL || hnd == NULL) return False; - - DEBUG(5,("make_svc_q_close\n")); - - memcpy(&(q_c->pol), hnd, sizeof(q_c->pol)); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_q_close(char *desc, SVC_Q_CLOSE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_close"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - prs_align(ps); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_close(char *desc, SVC_R_CLOSE *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_close"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(r_u->pol), ps, depth); - prs_align(ps); - - prs_uint32("status", ps, depth, &(r_u->status)); - - return True; -} - -/******************************************************************* -makes an SVC_Q_CHANGE_SVC_CONFIG structure. -********************************************************************/ -BOOL make_svc_q_change_svc_config(SVC_Q_CHANGE_SVC_CONFIG *q_u, 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) -{ - if (q_u == NULL || hnd == NULL) return False; - - DEBUG(5,("make_svc_q_change_svc_config\n")); - - memcpy(&(q_u->pol), hnd, sizeof(q_u->pol)); - - q_u->service_type = service_type; - q_u->start_type = start_type; - q_u->unknown_0 = unknown_0; - q_u->error_control = error_control; - make_buf_unistr2(&(q_u->uni_bin_path_name ), &(q_u->ptr_bin_path_name ), bin_path_name ); - make_buf_unistr2(&(q_u->uni_load_order_grp ), &(q_u->ptr_load_order_grp ), load_order_grp ); - q_u->tag_id = tag_id; - make_buf_unistr2(&(q_u->uni_dependencies ), &(q_u->ptr_dependencies ), dependencies ); - make_buf_unistr2(&(q_u->uni_service_start_name), &(q_u->ptr_service_start_name), service_start_name); - make_buf_string2(&(q_u->str_password ), &(q_u->ptr_password ), password ); - make_buf_unistr2(&(q_u->uni_display_name ), &(q_u->ptr_display_name ), disp_name ); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_q_change_svc_config(char *desc, SVC_Q_CHANGE_SVC_CONFIG *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_q_change_svc_config"); - depth++; - - prs_align(ps); - - smb_io_pol_hnd("", &(q_u->pol), ps, depth); - prs_align(ps); - - prs_uint32("service_type ", ps, depth, &(q_u->service_type )); - prs_uint32("start_type ", ps, depth, &(q_u->start_type )); - prs_uint32("unknown_0 ", ps, depth, &(q_u->unknown_0 )); - prs_uint32("error_control ", ps, depth, &(q_u->error_control )); - prs_uint32("ptr_bin_path_name ", ps, depth, &(q_u->ptr_bin_path_name )); - smb_io_unistr2("uni_bin_path_name ", &(q_u->uni_bin_path_name ), q_u->ptr_bin_path_name , ps, depth); - prs_align(ps); - - prs_uint32("ptr_load_order_grp ", ps, depth, &(q_u->ptr_load_order_grp )); - smb_io_unistr2("uni_load_order_grp ", &(q_u->uni_load_order_grp ), q_u->ptr_load_order_grp , ps, depth); - prs_align(ps); - prs_uint32("tag_id ", ps, depth, &(q_u->tag_id )); - prs_uint32("ptr_dependencies ", ps, depth, &(q_u->ptr_dependencies )); - smb_io_unistr2("uni_dependencies ", &(q_u->uni_dependencies ), q_u->ptr_dependencies , ps, depth); - prs_align(ps); - prs_uint32("ptr_service_start_name", ps, depth, &(q_u->ptr_service_start_name)); - smb_io_unistr2("uni_service_start_name", &(q_u->uni_service_start_name), q_u->ptr_service_start_name, ps, depth); - prs_align(ps); - prs_uint32("ptr_password ", ps, depth, &(q_u->ptr_password )); - - smb_io_string2("str_password ", &(q_u->str_password ), q_u->ptr_display_name , ps, depth); - prs_align(ps); - - prs_uint32("ptr_display_name ", ps, depth, &(q_u->ptr_display_name )); - smb_io_unistr2("uni_display_name ", &(q_u->uni_display_name ), q_u->ptr_display_name , ps, depth); - prs_align(ps); - - return True; -} - -/******************************************************************* -makes an SVC_R_CHANGE_SVC_CONFIG structure. -********************************************************************/ -BOOL make_svc_r_change_svc_config(SVC_R_CHANGE_SVC_CONFIG *r_c, - uint32 unknown_0, uint32 status) -{ - if (r_c == NULL) return False; - - DEBUG(5,("make_svc_r_change_svc_config\n")); - - r_c->unknown_0 = unknown_0; - r_c->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL svc_io_r_change_svc_config(char *desc, SVC_R_CHANGE_SVC_CONFIG *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "svc_io_r_change_svc_config"); - depth++; - - prs_align(ps); - - prs_uint32("unknown_0", ps, depth, &(r_u->unknown_0)); - prs_uint32("status ", ps, depth, &(r_u->status )); - - return True; -} - diff --git a/source/rpc_server/srv_brs.c b/source/rpc_server/srv_brs.c deleted file mode 100644 index c9abab20be5..00000000000 --- a/source/rpc_server/srv_brs.c +++ /dev/null @@ -1,98 +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. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; -extern pstring global_myname; - - -/******************************************************************* - create_brs_info_100 - ********************************************************************/ -static void create_brs_info_100(BRS_INFO_100 *inf) -{ - DEBUG(5,("create_brs_info_100: %d\n", __LINE__)); - - make_brs_info_100(inf); -} - -/******************************************************************* - brs_reply_query_info - - only supports info level 100 at the moment. - - ********************************************************************/ -static void brs_reply_query_info(BRS_Q_QUERY_INFO *q_u, - prs_struct *rdata, - int status) -{ - BRS_R_QUERY_INFO r_u; - BRS_INFO_100 brs100; - - DEBUG(5,("brs_query_info: %d\n", __LINE__)); - - create_brs_info_100(&brs100); - make_brs_r_query_info(&r_u, q_u->switch_value1, &brs100, status); - - /* store the response in the SMB stream */ - brs_io_r_query_info("", &r_u, rdata, 0); - - DEBUG(5,("brs_query_info: %d\n", __LINE__)); -} - -/******************************************************************* - api_brs_query_info - ********************************************************************/ -static void api_brs_query_info( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - BRS_Q_QUERY_INFO q_u; - - /* grab the net share enum */ - brs_io_q_query_info("", &q_u, data, 0); - - /* construct reply. always indicate success */ - brs_reply_query_info(&q_u, rdata, 0x0); -} - - -/******************************************************************* - \PIPE\brssvc commands - ********************************************************************/ -struct api_struct api_brs_cmds[] = -{ - { "BRS_Q_QUERY_INFO", BRS_QUERY_INFO, api_brs_query_info }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a browser pipe and responds. - ********************************************************************/ -BOOL api_brs_rpc(rpcsrv_struct *p, prs_struct *data) -{ - return api_rpcTNP(p, "api_brs_rpc", api_brs_cmds, data); -} - diff --git a/source/rpc_server/srv_sid.c b/source/rpc_server/srv_sid.c deleted file mode 100644 index 6552e0963bf..00000000000 --- a/source/rpc_server/srv_sid.c +++ /dev/null @@ -1,22 +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. -*/ - -/* this module is retired, is is called lib/sids.c */ diff --git a/source/rpc_server/srv_spoolss.c b/source/rpc_server/srv_spoolss.c deleted file mode 100755 index aff896edfd6..00000000000 --- a/source/rpc_server/srv_spoolss.c +++ /dev/null @@ -1,3781 +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) Jean François Micouleau 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. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; -extern pstring global_myname; - -#ifndef MAX_OPEN_PRINTER_EXS -#define MAX_OPEN_PRINTER_EXS 50 -#endif - -#define PRINTER_HANDLE_IS_PRINTER 0 -#define PRINTER_HANDLE_IS_PRINTSERVER 1 - - -/* structure to store the printer handles */ -/* and a reference to what it's pointing to */ -/* and the notify info asked about */ -/* that's the central struct */ -static struct -{ - BOOL open; - BOOL document_started; - BOOL page_started; - uint32 current_jobid; - uint32 document_fd; - uint32 document_lastwritten; - pstring document_name; - pstring job_name; - POLICY_HND printer_hnd; - BOOL printer_type; - union - { - fstring printername; - fstring printerservername; - } dev; - uint32 type; - uint32 access; - uint32 number_of_notify; - SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY]; -} Printer[MAX_OPEN_PRINTER_EXS]; - -#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS)) -#define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open) - -/**************************************************************************** - initialise printer handle states... -****************************************************************************/ -void init_printer_hnd(void) -{ - int i; - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - Printer[i].open = False; - } -} - - -/**************************************************************************** - create a unique printer handle -****************************************************************************/ -static void create_printer_hnd(POLICY_HND *hnd) -{ - static uint32 prt_hnd_low = 0; - static uint32 prt_hnd_high = 0; - - if (hnd == NULL) return; - - /* i severely doubt that prt_hnd_high will ever be non-zero... */ - prt_hnd_low++; - if (prt_hnd_low == 0) prt_hnd_high++; - - SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ - SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */ - SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */ - SIVAL(hnd->data, 12, time(NULL)); /* something random */ - SIVAL(hnd->data, 16, getpid()); /* something more random */ -} - -/**************************************************************************** - clear an handle -****************************************************************************/ -static void clear_handle(POLICY_HND *hnd) -{ - bzero(hnd->data, POLICY_HND_SIZE); -} - -/**************************************************************************** - find first available printer slot. creates a printer handle for you. - ****************************************************************************/ -static BOOL open_printer_hnd(POLICY_HND *hnd) -{ - int i; - - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - if (!Printer[i].open) - { - Printer[i].open = True; - create_printer_hnd(hnd); - memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)); - - DEBUG(4,("Opened printer handle[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); - return True; - } - } - DEBUG(1,("ERROR - open_printer_hnd: out of Printers Handles!\n")); - return False; -} - -/**************************************************************************** - find printer index by handle -****************************************************************************/ -static int find_printer_index_by_hnd(POLICY_HND *hnd) -{ - int i; - - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) - { - DEBUG(4,("Found printer handle[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); - return i; - } - } - DEBUG(3,("Whoops, Printer handle not found: ")); - dump_data(4, hnd->data, sizeof(hnd->data)); - return -1; -} - -/**************************************************************************** - set printer handle type. -****************************************************************************/ -static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) -{ - int pnum = find_printer_index_by_hnd(hnd); - - if (OPEN_HANDLE(pnum)) - { - DEBUG(4,("Setting printer access=%x (pnum=%x)\n", - access_required, pnum)); - - - - Printer[pnum].access = access_required; - return True; - } - else - { - DEBUG(4,("Error setting printer type=%x (pnum=%x)", - access_required, pnum)); - return False; - } - return False; -} - -/**************************************************************************** - set printer handle type. -****************************************************************************/ -static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) -{ - int pnum = find_printer_index_by_hnd(hnd); - - if (OPEN_HANDLE(pnum)) - { - DEBUG(3,("Setting printer type=%s (pnum=%x)\n", printername, pnum)); - - if ( strlen(printername) < 3 ) - { - DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); - return False; - } - - /* check if it's \\server or \\server\printer */ - /* +2 is to skip the leading \\ */ - if (!strchr(printername+2, '\\')) - { - /* it's a print server */ - DEBUGADD(4,("Printer is a print server\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; - return True; - } - else - { - /* it's a printer */ - DEBUGADD(4,("Printer is a printer\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER; - return True; - } - } - else - { - DEBUGADD(4,("Error setting printer name %s (pnum=%x)", - printername, pnum)); - return False; - } - return False; -} - -/**************************************************************************** - set printer handle printername. -****************************************************************************/ -static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) -{ - int pnum = find_printer_index_by_hnd(hnd); - char *back; - NT_PRINTER_INFO_LEVEL printer; - int snum; - int n_services=lp_numservices(); - uint32 marche; - - if (OPEN_HANDLE(pnum)) - { - DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", - printername,strlen(printername), pnum)); - - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTER: - back=strchr(printername+2, '\\'); - back=back+1; - DEBUGADD(5,("searching for %s (len=%d)\n", back,strlen(back))); - /* - * store the Samba share name in it - * in back we have the long printer name - * need to iterate all the snum and do a - * get_a_printer each time to find the printer - * faster to do it here than later. - */ - for (snum=0;snum<n_services; snum++) - { - if (lp_browseable(snum) && - lp_snum_ok(snum) && - lp_print_ok(snum) ) - { - DEBUGADD(5,("share:%s\n",lp_servicename(snum))); - - marche=get_a_printer(&printer, 2, lp_servicename(snum)); - DEBUGADD(6,("marche:%d\n",marche)); - - if ( marche==0 && ( strlen(printer.info_2->printername) == strlen(back) ) - && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) - ) - { - DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); - ZERO_STRUCT(Printer[pnum].dev.printername); - strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); - free_a_printer(printer, 2); - return True; - break; - } - free_a_printer(printer, 2); - } - } - - return False; - break; - case PRINTER_HANDLE_IS_PRINTSERVER: - ZERO_STRUCT(Printer[pnum].dev.printerservername); - strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); - return True; - break; - default: - return False; - break; - } - } - else - { - DEBUG(0,("Error setting printer name=%s (pnum=%x)\n", - printername , pnum)); - return False; - } -} - -/**************************************************************************** - return the snum of a printer corresponding to an handle -****************************************************************************/ -static BOOL get_printer_snum(POLICY_HND *hnd, int *number) -{ - int snum; - int pnum = find_printer_index_by_hnd(hnd); - int n_services=lp_numservices(); - - if (OPEN_HANDLE(pnum)) - { - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("short name:%s\n", Printer[pnum].dev.printername)); - for (snum=0;snum<n_services; snum++) - { - if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) - { - DEBUG(4,("share:%s\n",lp_servicename(snum))); - if ( ( strlen(lp_servicename(snum)) == strlen( Printer[pnum].dev.printername ) ) - && ( !strncasecmp(lp_servicename(snum), - Printer[pnum].dev.printername, - strlen( lp_servicename(snum) ))) - ) - { - DEBUG(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); - *number=snum; - return True; - break; - } - } - } - return False; - break; - case PRINTER_HANDLE_IS_PRINTSERVER: - return False; - break; - default: - return False; - break; - } - } - else - { - DEBUG(3,("Error getting printer - take a nap quickly !\n")); - return False; - } -} - -/******************************************************************** - ********************************************************************/ -static BOOL handle_is_printserver(POLICY_HND *handle) -{ - int pnum=find_printer_index_by_hnd(handle); - - if (OPEN_HANDLE(pnum)) - { - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTSERVER: - return True; - break; - case PRINTER_HANDLE_IS_PRINTER: - return False; - break; - } - } - return False; -} - -/******************************************************************** - ********************************************************************/ -/* -static BOOL handle_is_printer(POLICY_HND *handle) -{ - return (!handle_is_printserver(handle)); -} -*/ - -/******************************************************************** - * api_spoolss_open_printer - * - * called from the spoolss dispatcher - ********************************************************************/ -static void spoolss_reply_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *rdata) -{ - SPOOL_R_OPEN_PRINTER_EX r_u; - BOOL printer_open = False; - fstring name; - - /* some sanity check because you can open a printer or a print server */ - /* aka: \\server\printer or \\server */ - unistr2_to_ascii(name, &(q_u->printername), sizeof(name)-1); - - DEBUGADD(3,("checking name: %s\n",name)); - - /* now the response */ - r_u.status=0x00000000; - - printer_open = open_printer_hnd(&(r_u.handle)); - set_printer_hnd_printertype(&(r_u.handle), name); - - if ( !set_printer_hnd_printername(&(r_u.handle), name) ) - { - r_u.status=0xC0000000|NT_STATUS_ACCESS_DENIED; - } - - set_printer_hnd_accesstype(&(r_u.handle), q_u->access_required); - - - /* if there is a error free the printer entry */ - - if (r_u.status != 0x00000000) - { - int pnum; - - pnum = find_printer_index_by_hnd(&(r_u.handle)); - Printer[pnum].open=False; - clear_handle(&(r_u.handle)); - } - - spoolss_io_r_open_printer_ex("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_open_printer - * - * called from the spoolss dispatcher - ********************************************************************/ -static void api_spoolss_open_printer_ex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SPOOL_Q_OPEN_PRINTER_EX q_u; - - /* grab the spoolss open policy */ - spoolss_io_q_open_printer_ex("", &q_u, data, 0); - - /* construct reply. always indicate success */ - spoolss_reply_open_printer_ex(&q_u, rdata); -} - -/******************************************************************** - ********************************************************************/ -static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *type, - uint32 *numeric_data, uint8 **data, uint32 *needed) -{ - int i; - - if (!strcmp(value, "BeepEnabled")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - ZERO_STRUCTP(*data); - (*data)[0]=0x01; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x1; /* beep enabled */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "EventLog")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - ZERO_STRUCTP(*data); - (*data)[0]=0x1B; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x1B; /* Don't know ??? */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "NetPopup")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - ZERO_STRUCTP(*data); - (*data)[0]=0x01; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x1; /* popup enabled */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "MajorVersion")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - (*data)[0]=0x02; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x2; /* it's 2, period. */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "DefaultSpoolDirectory")) - { - pstring directory="You are using a Samba server"; - *type = 0x1; - *data = (uint8 *)malloc( size*sizeof(uint8) ); - ZERO_STRUCTP(*data); - - /* it's done by hand ready to go on the wire */ - for (i=0; i<strlen(directory); i++) - { - (*data)[2*i]=directory[i]; - (*data)[2*i+1]='\0'; - } - *needed = 2*(strlen(directory)+1); - return True; - } - - if (!strcmp(value, "Architecture")) - { - pstring directory="Windows NT x86"; - *type = 0x1; - *data = (uint8 *)malloc( size*sizeof(uint8) ); - ZERO_STRUCTP(*data); - for (i=0; i<strlen(directory); i++) - { - (*data)[2*i]=directory[i]; - (*data)[2*i+1]='\0'; - } - *needed = 2*(strlen(directory)+1); - return True; - } - - return False; -} - -/******************************************************************** - ********************************************************************/ -static BOOL getprinterdata_printer(POLICY_HND *handle, fstring value, uint32 size, uint32 *type, - uint32 *numeric_data, uint8 **data, uint32 *needed ) -{ - NT_PRINTER_INFO_LEVEL printer; - int pnum=0; - int snum=0; - uint8 *idata=NULL; - uint32 len; - - DEBUG(5,("getprinterdata_printer\n")); - - pnum = find_printer_index_by_hnd(handle); - if (OPEN_HANDLE(pnum)) - { - get_printer_snum(handle, &snum); - get_a_printer(&printer, 2, lp_servicename(snum)); - - if (get_specific_param(printer, 2, value, &idata, type, &len)) - { - /*switch (*type) - { - case 1: - case 3: - case 4:*/ - *data = (uint8 *)malloc( size*sizeof(uint8) ); - bzero(*data, sizeof(uint8)*size); - memcpy(*data, idata, len>size?size:len); - *needed = len; - if (idata) free(idata); - /*break;*/ - /*case 4: - *numeric_data=atoi(idata); - break;*/ - /*}*/ - return (True); - } - free_a_printer(printer, 2); - } - - return (False); -} - -/******************************************************************** - * api_spoolss_reply_getprinterdata - * - * called from api_spoolss_getprinterdata - ********************************************************************/ -static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTERDATA r_u; - fstring value; - BOOL found; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - /* - * Reminder: when it's a string, the length is in BYTES - * even if UNICODE is negociated. - * - * r_u.type is the kind of data - * 1 is a string - * 4 is a uint32 - * - * I think it's documented in MSDN somewhere in - * the registry data type (yep it's linked ...) - * - * JFM, 4/19/1999 - */ - - if (OPEN_HANDLE(pnum)) - { - r_u.size = q_u->size; - r_u.status = 0x0; - r_u.type = 0x4; - r_u.needed = 0x0; - r_u.data = NULL; - r_u.numeric_data=0x0; - - unistr2_to_ascii(value, &(q_u->valuename), sizeof(value)-1); - - if (handle_is_printserver(&(q_u->handle))) - { - found=getprinterdata_printer_server(value, r_u.size, - &(r_u.type), &(r_u.numeric_data), - &(r_u.data), &(r_u.needed)); - } - else - { - found=getprinterdata_printer(&(q_u->handle), value, r_u.size, - &(r_u.type), &(r_u.numeric_data), - &(r_u.data), &(r_u.needed)); - } - - if (found==False) - { - /* reply this param doesn't exist */ - r_u.type = 0x4; - r_u.size = 0x0; - r_u.data = NULL; - r_u.numeric_data=0x0; - r_u.needed = 0x0; - r_u.status = ERROR_INVALID_PARAMETER; - } - - spoolss_io_r_getprinterdata("", &r_u, rdata, 0); - DEBUG(3,("freeing memory\n")); - if (r_u.data) free(r_u.data); - DEBUG(3,("freeing memory:ok\n")); - } -} - -/******************************************************************** - * api_spoolss_getprinterdata - * - * called from the spoolss dispatcher - ********************************************************************/ -static void api_spoolss_getprinterdata(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTERDATA q_u; - - /* read the stream and fill the struct */ - spoolss_io_q_getprinterdata("", &q_u, data, 0); - - spoolss_reply_getprinterdata(&q_u,rdata); -} - -/******************************************************************** - * api_spoolss_reply_closeprinter - * - * called from api_spoolss_closeprinter - ********************************************************************/ -static void spoolss_reply_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_CLOSEPRINTER r_u; - - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - clear_handle(&(r_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].open=False; - r_u.status=0x0; - } - else - { - r_u.status= 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(3,("Error closing printer handle (pnum=%x)\n", pnum)); - } - - spoolss_io_r_closeprinter("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_closeprinter - * - * called from the spoolss dispatcher - ********************************************************************/ -static void api_spoolss_closeprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_CLOSEPRINTER q_u; - - spoolss_io_q_closeprinter("", &q_u, data, 0); - - spoolss_reply_closeprinter(&q_u,rdata); -} - -/******************************************************************** - * api_spoolss_reply_rffpcnex - * - * called from api_spoolss_rffpcnex (see this to understand) - ********************************************************************/ -static void spoolss_reply_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, prs_struct *rdata) -{ - SPOOL_R_RFFPCNEX r_u; - - r_u.status = 0x0000; - - spoolss_io_r_rffpcnex("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_rffpcnex - * ReplyFindFirstPrinterChangeNotifyEx - * called from the spoolss dispatcher - * - * jfmxxxx: before replying OK: status=0 - * should do a rpc call to the workstation asking ReplyOpenPrinter - * have to code it, later. - * - * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe - ********************************************************************/ -static void api_spoolss_rffpcnex(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_RFFPCNEX q_u; - - int i,j,k; - - spoolss_io_q_rffpcnex("", &q_u, data, 0); - - /* store the notify value in the printer struct */ - - i=find_printer_index_by_hnd(&(q_u.handle)); - - Printer[i].number_of_notify=q_u.option.count; - - DEBUG(3,("Copying %x notify option info\n",Printer[i].number_of_notify)); - - for (j=0;j<Printer[i].number_of_notify;j++) - { - Printer[i].notify_info[j].count=q_u.option.type[j].count; - Printer[i].notify_info[j].type=q_u.option.type[j].type ; - - DEBUG(4,("Copying %x info fields of type %x\n", - Printer[i].notify_info[j].count, - Printer[i].notify_info[j].type)); - for(k=0;k<Printer[i].notify_info[j].count;k++) - { - Printer[i].notify_info[j].fields[k]=q_u.option.type[j].fields[k]; - } - } - spoolss_reply_rffpcnex(&q_u,rdata); -} - -/******************************************************************* - * fill a notify_info_data with the servername - ********************************************************************/ -static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - pstring temp_name; - - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); - - data->notify_data.data.length=strlen(temp_name); - ascii_to_unistr(data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the servicename - * jfmxxxx: it's incorrect should be long_printername - ********************************************************************/ -static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ -/* - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); -*/ - data->notify_data.data.length=strlen(printer->info_2->printername); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->printername, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the servicename - ********************************************************************/ -static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, - lp_servicename(snum), - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the port name - ********************************************************************/ -static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - /* even if it's strange, that's consistant in all the code */ - - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, - lp_servicename(snum), - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the printername - * jfmxxxx: it's incorrect, should be lp_printerdrivername() - * but it doesn't exist, have to see what to do - ********************************************************************/ -static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->drivername); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->drivername, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the comment - ********************************************************************/ -static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(lp_comment(snum)); - ascii_to_unistr(data->notify_data.data.string, - lp_comment(snum), - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the comment - * jfm:xxxx incorrect, have to create a new smb.conf option - * location = "Room 1, floor 2, building 3" - ********************************************************************/ -static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->location); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->location, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the device mode - * jfm:xxxx don't to it for know but that's a real problem !!! - ********************************************************************/ -static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ -} - -/******************************************************************* - * fill a notify_info_data with the separator file name - * jfm:xxxx just return no file could add an option to smb.conf - * separator file = "separator.txt" - ********************************************************************/ -static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->sepfile); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->sepfile, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the print processor - * jfm:xxxx return always winprint to indicate we don't do anything to it - ********************************************************************/ -static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->printprocessor); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->printprocessor, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the print processor options - * jfm:xxxx send an empty string - ********************************************************************/ -static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->parameters); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->parameters, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the data type - * jfm:xxxx always send RAW as data type - ********************************************************************/ -static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->datatype); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->datatype, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the security descriptor - * jfm:xxxx send an null pointer to say no security desc - * have to implement security before ! - ********************************************************************/ -static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=0; - data->notify_data.data.string[0]=0x00; -} - -/******************************************************************* - * fill a notify_info_data with the attributes - * jfm:xxxx a samba printer is always shared - ********************************************************************/ -static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; -} - -/******************************************************************* - * fill a notify_info_data with the priority - ********************************************************************/ -static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->priority; -} - -/******************************************************************* - * fill a notify_info_data with the default priority - ********************************************************************/ -static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->default_priority; -} - -/******************************************************************* - * fill a notify_info_data with the start time - ********************************************************************/ -static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->starttime; -} - -/******************************************************************* - * fill a notify_info_data with the until time - ********************************************************************/ -static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->untiltime; -} - -/******************************************************************* - * fill a notify_info_data with the status - ********************************************************************/ -static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - int count; - print_queue_struct *q=NULL; - print_status_struct status; - - bzero(&status,sizeof(status)); - - count=get_printqueue(snum, NULL, &q, &status); - - data->notify_data.value[0]=(uint32) status.status; - if (q) free(q); -} - -/******************************************************************* - * fill a notify_info_data with the number of jobs queued - ********************************************************************/ -static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - print_queue_struct *q=NULL; - print_status_struct status; - - bzero(&status,sizeof(status)); - - data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); - if (q) free(q); -} - -/******************************************************************* - * fill a notify_info_data with the average ppm - ********************************************************************/ -static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - /* always respond 8 pages per minutes */ - /* a little hard ! */ - data->notify_data.value[0] = printer->info_2->averageppm; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(queue->user); - ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=queue->status; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(queue->file); - ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen("En attente"); - ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=0x0; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=queue->size; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=queue->job; -} - -#define END 65535 - -struct s_notify_info_data_table notify_info_data_table[] = -{ -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", POINTER, spoolss_notify_share_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", POINTER, spoolss_notify_comment }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", POINTER, spoolss_notify_location }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", POINTER, spoolss_notify_sepfile }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", ONE_VALUE, spoolss_notify_default_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_status }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", ONE_VALUE, spoolss_notify_cjobs }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", ONE_VALUE, spoolss_notify_average_ppm }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", POINTER, spoolss_notify_server_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", POINTER, spoolss_notify_job_status_string }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, -{ END, END, "", END, NULL } -}; - -/******************************************************************* -return the size of info_data structure -********************************************************************/ -uint32 size_of_notify_info_data(uint16 type, uint16 field) -{ - int i=0; - - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - return (notify_info_data_table[i].size); - continue; - } - i++; - } - return (65535); -} - -/******************************************************************* -return the type of notify_info_data -********************************************************************/ -BOOL type_of_notify_info_data(uint16 type, uint16 field) -{ - int i=0; - - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - if (notify_info_data_table[i].size == POINTER) - { - return (False); - } - else - { - return (True); - } - continue; - } - i++; - } - return (False); -} - -/**************************************************************************** -****************************************************************************/ -static int search_notify(uint16 type, uint16 field, int *value) -{ - int j; - BOOL found; - - DEBUG(4,("\tsearch_notify: in\n")); - for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) - { - if ( (notify_info_data_table[j].type == type ) && - (notify_info_data_table[j].field == field ) ) - { - found=True; - } - } - *value=--j; - - if ( found && (notify_info_data_table[j].fn != NULL) ) - { - DEBUG(4,("\tsearch_notify: out TRUE\n")); - return (True); - } - else - { - DEBUG(4,("\tsearch_notify: out FALSE\n")); - return (False); - } -} - -/**************************************************************************** -****************************************************************************/ -static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) -{ - DEBUG(4,("\tconstruct_info_data: in\n")); - info_data->type = type; - info_data->field = field; - info_data->id = id; - info_data->size = size_of_notify_info_data(type, field); - info_data->enc_type = type_of_notify_info_data(type, field); - DEBUG(4,("\tconstruct_info_data: out\n")); -} - - -/******************************************************************* - * - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, - int snum, int i, uint32 id) -{ - - int k,j; - uint16 type; - uint16 field; - - SPOOL_NOTIFY_INFO_DATA *info_data; - print_queue_struct *queue=NULL; - NT_PRINTER_INFO_LEVEL printer; - - DEBUG(4,("construct_notify_printer_info\n")); - - info_data=&(info->data[info->count]); - - type = Printer[pnum].notify_info[i].type; - - DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); - - if (!get_a_printer(&printer, 2, lp_servicename(snum))) - { - - for(k=0; k<Printer[pnum].notify_info[i].count; k++) - { - field = Printer[pnum].notify_info[i].fields[k]; - DEBUGADD(4,("notify [%d]: type [%x], field [%x]\n", k, type, field)); - - if (search_notify(type, field, &j) ) - { - DEBUGADD(4,("j=[%d]:%s\n", j, notify_info_data_table[j].name)); - construct_info_data(info_data, type, field, id); - - DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(snum, info_data, queue, &printer); - DEBUGADD(4,("notify_info_data_table: out\n")); - info->count++; - info_data=&(info->data[info->count]); - } - } - - free_a_printer(printer, 2); - } -} - -/******************************************************************* - * - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, - int pnum, int snum, int i, uint32 id) -{ - - int k,j; - uint16 type; - uint16 field; - - SPOOL_NOTIFY_INFO_DATA *info_data; - NT_PRINTER_INFO_LEVEL printer; - - DEBUG(4,("construct_notify_jobs_info\n")); - info_data=&(info->data[info->count]); - - type = Printer[pnum].notify_info[i].type; - - DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); - - if (!get_a_printer(&printer, 2, lp_servicename(snum))) - { - for(k=0; k<Printer[pnum].notify_info[i].count; k++) - { - field = Printer[pnum].notify_info[i].fields[k]; - DEBUGADD(4,("notify [%d]: type [%x], field [%x]\n",k, type, field)); - - if (search_notify(type, field, &j) ) - { - DEBUGADD(4,("j=[%d]:%s\n", j, notify_info_data_table[j].name)); - construct_info_data(info_data, type, field, id); - DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(snum, info_data, queue, &printer); - DEBUGADD(4,("notify_info_data_table: out\n")); - info->count++; - info_data=&(info->data[info->count]); - } - } - free_a_printer(printer, 2); - } -} - - -/******************************************************************* - * - * enumerate all printers on the printserver - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) -{ - int snum; - int pnum=find_printer_index_by_hnd(hnd); - int n_services=lp_numservices(); - int i=0; - uint32 id=1; - info->count=0; - - DEBUG(4,("Enumerating printers\n")); - - for (i=0; i<Printer[pnum].number_of_notify; i++) - { - if ( Printer[pnum].notify_info[i].type == PRINTER_NOTIFY_TYPE ) - { - for (snum=0; snum<n_services; snum++) - { - if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) - { - construct_notify_printer_info(info, pnum, snum, i, id); - id++; - } - } - } - } - DEBUG(4,("All printers enumerated\n")); -} - -/******************************************************************* - * - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) -{ - int snum; - int pnum=find_printer_index_by_hnd(hnd); - int i=0, j; - uint32 id=0xFFFF; - - info->count=0; - - if (get_printer_snum(hnd, &snum) ) - { - for (i=0; i<Printer[pnum].number_of_notify; i++) - { - switch ( Printer[pnum].notify_info[i].type ) - { - case PRINTER_NOTIFY_TYPE: - { - construct_notify_printer_info(info, pnum, snum, i, id); - id--; - break; - } - case JOB_NOTIFY_TYPE: - { - int count; - print_queue_struct *queue=NULL; - print_status_struct status; - bzero(&status, sizeof(status)); - count=get_printqueue(snum, NULL, &queue, &status); - for (j=0; j<count; j++) - { - construct_notify_jobs_info(&(queue[j]), info, pnum, snum, i, queue[j].job); - } - if (queue) free(queue); - break; - } - } - } - } -} - -/******************************************************************** - * api_spoolss_reply_rfnpcnex - * - * called from api_spoolss_rfnpcnex (see this to understand) - ********************************************************************/ -static void spoolss_reply_rfnpcnex(SPOOL_Q_RFNPCNEX *q_u, prs_struct *rdata) -{ - SPOOL_R_RFNPCNEX r_u; - int pnum=find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - DEBUG(4,("Printer %x of type %x\n",pnum,Printer[pnum].printer_type)); - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTSERVER: - printserver_notify_info(&(q_u->handle), &(r_u.info)); - break; - case PRINTER_HANDLE_IS_PRINTER: - printer_notify_info(&(q_u->handle), &(r_u.info)); - break; - } - - spoolss_io_r_rfnpcnex("", &r_u, rdata, 0); - } -} - -/******************************************************************** - * api_spoolss_rfnpcnex - * ReplyFindNextPrinterChangeNotifyEx - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_rfnpcnex(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_RFNPCNEX q_u; - - spoolss_io_q_rfnpcnex("", &q_u, data, 0); - - spoolss_reply_rfnpcnex(&q_u, rdata); -} - -/******************************************************************** - * construct_printer_info_0 - * fill a printer_info_1 struct - ********************************************************************/ -static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername) -{ - pstring chaine; - int count; - NT_PRINTER_INFO_LEVEL ntprinter; - - print_queue_struct *queue=NULL; - print_status_struct status; - bzero(&status,sizeof(status)); - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) - { - return (False); - } - - count=get_printqueue(snum, NULL, &queue, &status); - - /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter.info_2->printername); - - make_unistr(&(printer->printername), chaine); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername); - make_unistr(&(printer->servername), chaine); - - printer->cjobs = count; - printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; - printer->unknown0 = 0x1; /* pointer */ - printer->unknown1 = 0x000A07CE; /* don't known */ - printer->unknown2 = 0x00020005; - printer->unknown3 = 0x0006000D; - printer->unknown4 = 0x02180026; - printer->unknown5 = 0x09; - printer->unknown6 = 0x36; - printer->majorversion = 0x0004; /* NT 4 */ - printer->buildversion = 0x0565; /* build 1381 */ - printer->unknown7 = 0x1; - printer->unknown8 = 0x0; - printer->unknown9 = 0x2; - printer->unknown10 = 0x3; - printer->unknown11 = 0x0; - printer->unknown12 = 0x0; - printer->unknown13 = 0x0; - printer->unknown14 = 0x1; - printer->unknown15 = 0x024a; /*586 Pentium ? */ - printer->unknown16 = 0x0; - printer->unknown17 = 0x423ed444; - printer->unknown18 = 0x0; - printer->status = status.status; - printer->unknown20 = 0x0; - printer->unknown21 = 0x0648; - printer->unknown22 = 0x0; - printer->unknown23 = 0x5; - - if (queue) free(queue); - - free_a_printer(ntprinter, 2); - return (True); -} - -/******************************************************************** - * construct_printer_info_1 - * fill a printer_info_1 struct - ********************************************************************/ -static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername) -{ - pstring chaine; - NT_PRINTER_INFO_LEVEL ntprinter; - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) - { - return (False); - } - - printer->flags=PRINTER_ENUM_NAME; - - /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, - ntprinter.info_2->printername, - ntprinter.info_2->drivername, - lp_comment(snum)); - make_unistr(&(printer->description), chaine); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); - make_unistr(&(printer->name), chaine); - - make_unistr(&(printer->comment), lp_comment(snum)); - - free_a_printer(ntprinter, 2); - return (True); -} - -/**************************************************************************** -****************************************************************************/ -static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) -{ - char adevice[32]; - char aform[32]; - NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE *ntdevmode; - - DEBUG(7,("construct_dev_mode\n")); - - bzero(&(devmode->devicename), 2*sizeof(adevice)); - bzero(&(devmode->formname), 2*sizeof(aform)); - - DEBUGADD(8,("getting printer characteristics\n")); - - get_a_printer(&printer, 2, lp_servicename(snum)); - ntdevmode=(printer.info_2)->devmode; - - DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, - printer.info_2->printername); - make_unistr(&(devmode->devicename), adevice); - - snprintf(aform, sizeof(aform), ntdevmode->formname); - make_unistr(&(devmode->formname), aform); - - devmode->specversion = ntdevmode->specversion; - devmode->driverversion = ntdevmode->driverversion; - devmode->size = ntdevmode->size; - devmode->driverextra = ntdevmode->driverextra; - devmode->fields = ntdevmode->fields; - - devmode->orientation = ntdevmode->orientation; - devmode->papersize = ntdevmode->papersize; - devmode->paperlength = ntdevmode->paperlength; - devmode->paperwidth = ntdevmode->paperwidth; - devmode->scale = ntdevmode->scale; - devmode->copies = ntdevmode->copies; - devmode->defaultsource = ntdevmode->defaultsource; - devmode->printquality = ntdevmode->printquality; - devmode->color = ntdevmode->color; - devmode->duplex = ntdevmode->duplex; - devmode->yresolution = ntdevmode->yresolution; - devmode->ttoption = ntdevmode->ttoption; - devmode->collate = ntdevmode->collate; - devmode->icmmethod = ntdevmode->icmmethod; - devmode->icmintent = ntdevmode->icmintent; - devmode->mediatype = ntdevmode->mediatype; - devmode->dithertype = ntdevmode->dithertype; - - if (ntdevmode->private != NULL) - { - devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8)); - memcpy(devmode->private, ntdevmode->private, devmode->driverextra); - } - - free_a_printer(printer, 2); -} - -/******************************************************************** - * construct_printer_info_2 - * fill a printer_info_2 struct - ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) -{ - pstring chaine; - int count; - DEVICEMODE *devmode; - NT_PRINTER_INFO_LEVEL ntprinter; - - print_queue_struct *queue=NULL; - print_status_struct status; - bzero(&status, sizeof(status)); - count=get_printqueue(snum, NULL, &queue, &status); - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - { - return (False); - } - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s", servername); - make_unistr(&(printer->servername), chaine); /* servername*/ - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", servername, ntprinter.info_2->printername); - make_unistr(&(printer->printername), chaine); /* printername*/ - - make_unistr(&(printer->sharename), lp_servicename(snum)); /* sharename */ - - make_unistr(&(printer->portname), lp_servicename(snum)); /* port */ - make_unistr(&(printer->drivername), ntprinter.info_2->drivername); /* drivername */ - - make_unistr(&(printer->comment), ntprinter.info_2->comment); /* comment */ - make_unistr(&(printer->location), ntprinter.info_2->location); /* location */ - make_unistr(&(printer->sepfile), ntprinter.info_2->sepfile); /* separator file */ - make_unistr(&(printer->printprocessor), ntprinter.info_2->printprocessor);/* print processor */ - make_unistr(&(printer->datatype), ntprinter.info_2->datatype); /* datatype */ - make_unistr(&(printer->parameters), ntprinter.info_2->parameters); /* parameters (of print processor) */ - - printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ - - printer->priority = ntprinter.info_2->priority; /* priority */ - printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ - printer->starttime = ntprinter.info_2->starttime; /* starttime */ - printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ - printer->status = status.status; /* status */ - printer->cjobs = count; /* jobs */ - printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ - - devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); - ZERO_STRUCTP(devmode); - construct_dev_mode(devmode, snum, servername); - printer->devmode=devmode; - - if (queue) free(queue); - free_a_printer(ntprinter, 2); - return (True); -} - -/******************************************************************** - * enum_printer_info_1 - * glue between spoolss_reply_enumprinters and construct_printer_info_1 - ********************************************************************/ -static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) -{ - pstring servername; - - *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); - pstrcpy(servername, global_myname); - if (!construct_printer_info_1(*printer, snum, servername)) - { - free(*printer); - return (False); - } - else - { - return (True); - } -} - -/******************************************************************** - * enum_printer_info_2 - * glue between spoolss_reply_enumprinters and construct_printer_info_2 - ********************************************************************/ -static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) -{ - pstring servername; - - *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); - pstrcpy(servername, global_myname); - if (!construct_printer_info_2(*printer, snum, servername)) - { - free(*printer); - return (False); - } - else - { - return (True); - } -} - -/******************************************************************** - * api_spoolss_reply_enumprinters - * - * called from api_spoolss_enumprinters (see this to understand) - ********************************************************************/ -static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) -{ - int snum; - int n_services=lp_numservices(); - *printers=NULL; - *number=0; - - for (snum=0;snum<n_services; snum++) - { - if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) - { - DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); - *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_1 *)); - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers)); - if (enum_printer_info_1( &((*printers)[*number]), snum, *number) ) - { - (*number)++; - } - } - } -} - -/******************************************************************** - * api_spoolss_reply_enumprinters - * - * called from api_spoolss_enumprinters (see this to understand) - ********************************************************************/ -static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number) -{ - int snum; - int n_services=lp_numservices(); - *printers=NULL; - *number=0; - - for (snum=0;snum<n_services; snum++) - { - if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) - { - DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); - *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_2 *)); - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers at [%p]\n", *number+1, *printers)); - if (enum_printer_info_2( &((*printers)[*number]), snum, *number) ) - { - (*number)++; - } - } - } -} - -/******************************************************************** - * api_spoolss_reply_enumprinters - * - * called from api_spoolss_enumprinters (see this to understand) - ********************************************************************/ -static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTERS r_u; - - DEBUG(4,("Enumerating printers\n")); - - memcpy(r_u.servername.buffer,q_u->servername.buffer,2*q_u->servername.uni_str_len); - r_u.servername.buffer[q_u->servername.uni_str_len]=0x0000; - r_u.returned=0; - - switch (q_u->level) - { - case 1: - if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) - /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned) ); - /*else - enum_one_printer_info_1(&r_u);*/ - break; - case 2: - if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) - /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned) ); - /*else - enum_one_printer_info_2(&r_u);*/ - break; - case 3: /* doesn't exist */ - break; - case 4: /* can't, always on local machine */ - break; - case 5: - break; - - } - DEBUG(4,("%d printers enumerated\n", r_u.returned)); - r_u.offered=q_u->buffer.size; - r_u.level=q_u->level; - r_u.status=0x0000; - - spoolss_io_r_enumprinters("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_enumprinters - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_enumprinters(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTERS q_u; - - spoolss_io_q_enumprinters("", &q_u, data, 0); - - spoolss_reply_enumprinters(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTER r_u; - int snum; - pstring servername; - - pstrcpy(servername, global_myname); - - get_printer_snum(&(q_u->handle),&snum); - - switch (q_u->level) - { - case 0: - { - PRINTER_INFO_0 *printer; - - printer=(PRINTER_INFO_0 *)malloc(sizeof(PRINTER_INFO_0)); - - construct_printer_info_0(printer, snum, servername); - r_u.printer.info0=printer; - r_u.status=0x0000; - r_u.offered=q_u->offered; - r_u.level=q_u->level; - - spoolss_io_r_getprinter("",&r_u,rdata,0); - - free(printer); - - break; - } - case 1: - { - PRINTER_INFO_1 *printer; - - printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - - construct_printer_info_1(printer, snum, servername); - - r_u.printer.info1=printer; - r_u.status=0x0000; - r_u.offered=q_u->offered; - r_u.level=q_u->level; - spoolss_io_r_getprinter("",&r_u,rdata,0); - - free(printer); - - break; - } - case 2: - { - PRINTER_INFO_2 *printer; - - printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - construct_printer_info_2(printer, snum, servername); - - r_u.printer.info2=printer; - r_u.status=0x0000; - r_u.offered=q_u->offered; - r_u.level=q_u->level; - spoolss_io_r_getprinter("",&r_u,rdata,0); - - free_printer_info_2(printer); - - break; - } - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_getprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTER q_u; - - spoolss_io_q_getprinter("", &q_u, data, 0); - - spoolss_reply_getprinter(&q_u, rdata); -} - -/******************************************************************** - * construct_printer_driver_info_1 - * fill a construct_printer_driver_info_1 struct - ********************************************************************/ -static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) -{ - make_unistr( &(info->name), driver.info_3->name); -} - -static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, - pstring servername, fstring architecture) -{ - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); - - fill_printer_driver_info_1(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); -} - -/******************************************************************** - * construct_printer_driver_info_2 - * fill a printer_info_2 struct - ********************************************************************/ -static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) -{ - pstring where; - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; - fstring short_archi; - - get_short_archi(short_archi,architecture); - - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); - - info->version=driver.info_3->cversion; - - make_unistr( &(info->name), driver.info_3->name ); - make_unistr( &(info->architecture), architecture ); - - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, - driver.info_3->driverpath); - make_unistr( &(info->driverpath), temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, - driver.info_3->datafile); - make_unistr( &(info->datafile), temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, - driver.info_3->configfile); - make_unistr( &(info->configfile), temp_configfile ); -} - -/******************************************************************** - * construct_printer_driver_info_2 - * fill a printer_info_2 struct - ********************************************************************/ -static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, - pstring servername, fstring architecture) -{ - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); - - fill_printer_driver_info_2(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); -} - -/******************************************************************** - * copy a strings array and convert to UNICODE - ********************************************************************/ -static void make_unistr_array(UNISTR ***uni_array, char **char_array, char *where) -{ - int i=0; - char *v; - pstring line; - - DEBUG(6,("make_unistr_array\n")); - - for (v=char_array[i]; *v!='\0'; v=char_array[i]) - { - DEBUGADD(6,("i:%d:", i)); - DEBUGADD(6,("%s:%d:", v, strlen(v))); - - *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - DEBUGADD(7,("realloc:[%p],", *uni_array)); - - (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR) ); - DEBUGADD(7,("alloc:[%p],", (*uni_array)[i])); - - snprintf(line, sizeof(line)-1, "%s%s", where, v); - make_unistr( (*uni_array)[i], line ); - DEBUGADD(7,("copy\n")); - - i++; - } - DEBUGADD(7,("last one\n")); - - *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - (*uni_array)[i]=0x0000; - DEBUGADD(6,("last one:done\n")); -} - -/******************************************************************** - * construct_printer_info_3 - * fill a printer_info_3 struct - ********************************************************************/ -static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) -{ - pstring where; - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; - pstring temp_helpfile; - fstring short_archi; - - get_short_archi(short_archi, architecture); - - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); - - info->version=driver.info_3->cversion; - - make_unistr( &(info->name), driver.info_3->name ); - make_unistr( &(info->architecture), architecture ); - - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); - make_unistr( &(info->driverpath), temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); - make_unistr( &(info->datafile), temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); - make_unistr( &(info->configfile), temp_configfile ); - - snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); - make_unistr( &(info->helpfile), temp_helpfile ); - - make_unistr( &(info->monitorname), driver.info_3->monitorname ); - make_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); - - info->dependentfiles=NULL; - make_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles, where); -} - -/******************************************************************** - * construct_printer_info_3 - * fill a printer_info_3 struct - ********************************************************************/ -static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, - pstring servername, fstring architecture) -{ - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); - - fill_printer_driver_info_3(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTERDRIVER2 r_u; - pstring servername; - fstring architecture; - int snum; - DRIVER_INFO_1 *info1=NULL; - DRIVER_INFO_2 *info2=NULL; - DRIVER_INFO_3 *info3=NULL; - - pstrcpy(servername, global_myname); - get_printer_snum(&(q_u->handle),&snum); - - r_u.offered=q_u->buf_size; - r_u.level=q_u->level; - r_u.status=0x0000; - - unistr2_to_ascii(architecture, &(q_u->architecture), sizeof(architecture) ); - - DEBUG(1,("spoolss_reply_getprinterdriver2:[%d]\n", q_u->level)); - - switch (q_u->level) - { - case 1: - { - info1=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); - construct_printer_driver_info_1(info1, snum, servername, architecture); - r_u.printer.info1=info1; - break; - } - case 2: - { - info2=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); - construct_printer_driver_info_2(info2, snum, servername, architecture); - r_u.printer.info2=info2; - break; - } - case 3: - { - info3=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); - construct_printer_driver_info_3(info3, snum, servername, architecture); - r_u.printer.info3=info3; - break; - } - } - - spoolss_io_r_getprinterdriver2("",&r_u,rdata,0); - - if (info1!=NULL) free(info1); - if (info2!=NULL) free(info2); - if (info3!=NULL) - { - UNISTR **dependentfiles; - int j=0; - dependentfiles=info3->dependentfiles; - while ( dependentfiles[j] != NULL ) - { - free(dependentfiles[j]); - j++; - } - free(dependentfiles); - - free(info3); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_getprinterdriver2(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTERDRIVER2 q_u; - - spoolss_io_q_getprinterdriver2("", &q_u, data, 0); - - spoolss_reply_getprinterdriver2(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_STARTPAGEPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].page_started=True; - r_u.status=0x0; - - spoolss_io_r_startpageprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in startpageprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_startpageprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_STARTPAGEPRINTER q_u; - - spoolss_io_q_startpageprinter("", &q_u, data, 0); - - spoolss_reply_startpageprinter(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_ENDPAGEPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].page_started=False; - r_u.status=0x0; - - spoolss_io_r_endpageprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in endpageprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_endpageprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENDPAGEPRINTER q_u; - - spoolss_io_q_endpageprinter("", &q_u, data, 0); - - spoolss_reply_endpageprinter(&q_u, rdata); -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_startdocprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_STARTDOCPRINTER q_u; - SPOOL_R_STARTDOCPRINTER r_u; - DOC_INFO_1 *info_1; - - pstring fname; - pstring tempname; - pstring datatype; - int fd = -1; - int snum; - int pnum; - - /* decode the stream and fill the struct */ - spoolss_io_q_startdocprinter("", &q_u, data, 0); - - info_1=&(q_u.doc_info_container.docinfo.doc_info_1); - r_u.status=0x0; - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - /* - * a nice thing with NT is it doesn't listen to what you tell it. - * when asked to send _only_ RAW datas, it tries to send datas - * in EMF format. - * - * So I add checks like in NT Server ... - */ - - if (info_1->p_datatype != 0) - { - unistr2_to_ascii(datatype, &(info_1->docname), sizeof(datatype)); - if (strcmp(datatype, "RAW") != 0) - { - r_u.jobid=0; - r_u.status=1804; - } - } - - if (r_u.status==0 && OPEN_HANDLE(pnum)) - { - /* get the share number of the printer */ - get_printer_snum(&(q_u.handle),&snum); - - /* Create a temporary file in the printer spool directory - * and open it - */ - - slprintf(tempname,sizeof(tempname)-1, "%s/smb_print.XXXXXX",lp_pathname(snum)); - pstrcpy(fname, (char *)mktemp(tempname)); - - fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); - DEBUG(4,("Temp spool file created: [%s]\n", fname)); - - Printer[pnum].current_jobid=fd; - pstrcpy(Printer[pnum].document_name,fname); - - unistr2_to_ascii(Printer[pnum].job_name, - &(q_u.doc_info_container.docinfo.doc_info_1.docname), - sizeof(Printer[pnum].job_name)); - - Printer[pnum].document_fd=fd; - Printer[pnum].document_started=True; - r_u.jobid=Printer[pnum].current_jobid; - r_u.status=0x0; - - } - - spoolss_io_r_startdocprinter("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_ENDDOCPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - r_u.status=0x0; - - spoolss_io_r_enddocprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in enddocprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_enddocprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENDDOCPRINTER q_u; - int pnum; - int snum; - pstring filename; - pstring filename1; - pstring job_name; - pstring syscmd; - char *tstr; - - spoolss_io_q_enddocprinter("", &q_u, data, 0); - - *syscmd=0; - - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].document_started=False; - close(Printer[pnum].document_fd); - DEBUG(4,("Temp spool file closed, printing now ...\n")); - - pstrcpy(filename1, Printer[pnum].document_name); - pstrcpy(job_name, Printer[pnum].job_name); - - get_printer_snum(&(q_u.handle),&snum); - - /* copy the command into the buffer for extensive meddling. */ - StrnCpy(syscmd, lp_printcommand(snum), sizeof(pstring) - 1); - - /* look for "%s" in the string. If there is no %s, we cannot print. */ - if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) - { - DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum))); - } - - if (strstr(syscmd,"%s")) - { - pstrcpy(filename,filename1); - string_sub(syscmd, "%s", filename); - } - - string_sub(syscmd, "%f", filename1); - - /* Does the service have a printername? If not, make a fake and empty */ - /* printer name. That way a %p is treated sanely if no printer */ - /* name was specified to replace it. This eventuality is logged. */ - tstr = lp_printername(snum); - if (tstr == NULL || tstr[0] == '\0') - { - DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); - tstr = SERVICE(snum); - } - - string_sub(syscmd, "%p", tstr); - - /* If the lpr command support the 'Job' option replace here */ - string_sub(syscmd, "%j", job_name); - - if ( *syscmd != '\0') - { - int ret = smbrun(syscmd, NULL, False); - DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); - } - else - DEBUG(0,("Null print command?\n")); - - lpq_reset(snum); - } - - spoolss_reply_enddocprinter(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_writeprinter(SPOOL_Q_WRITEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_WRITEPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - r_u.buffer_written=Printer[pnum].document_lastwritten; - r_u.status=0x0; - - spoolss_io_r_writeprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in writeprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_writeprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_WRITEPRINTER q_u; - int pnum; - int fd; - int size; - spoolss_io_q_writeprinter("", &q_u, data, 0); - - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - fd=Printer[pnum].document_fd; - size=write(fd, q_u.buffer, q_u.buffer_size); - if (q_u.buffer) free(q_u.buffer); - Printer[pnum].document_lastwritten=size; - } - - spoolss_reply_writeprinter(&q_u, rdata); -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void control_printer(POLICY_HND handle, uint32 command) -{ - int pnum; - int snum; - pnum = find_printer_index_by_hnd(&(handle)); - - if ( get_printer_snum(&handle, &snum) ) - { - switch (command) - { - case PRINTER_CONTROL_PAUSE: - /* pause the printer here */ - status_printqueue(NULL, snum, LPSTAT_STOPPED); - break; - - case PRINTER_CONTROL_RESUME: - case PRINTER_CONTROL_UNPAUSE: - /* UN-pause the printer here */ - status_printqueue(NULL, snum, LPSTAT_OK); - break; - case PRINTER_CONTROL_PURGE: - /* Envoi des dragées FUCA dans l'imprimante */ - break; - } - } -} - -/******************************************************************** - * called by spoolss_api_setprinter - * when updating a printer description - ********************************************************************/ -static void update_printer(POLICY_HND handle, uint32 level, - SPOOL_PRINTER_INFO_LEVEL info, DEVICEMODE *devmode) -{ - int pnum; - int snum; - NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE *nt_devmode; - - nt_devmode=NULL; - - DEBUG(8,("update_printer\n")); - - if (level!=2) - { - DEBUG(0,("Send a mail to samba-bugs@samba.org\n")); - DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - return; - } - - pnum = find_printer_index_by_hnd(&handle); - - if ( get_printer_snum(&handle, &snum) ) - { - get_a_printer(&printer, level, lp_servicename(snum)); - - DEBUGADD(8,("Converting info_2 struct\n")); - convert_printer_info(info, &printer, level); - - if ((info.info_2)->devmode_ptr != 0) - { - /* we have a valid devmode - convert it and link it*/ - - /* the nt_devmode memory is already alloced - * while doing the get_a_printer call - * but the devmode private part is not - * it's done by convert_devicemode - */ - DEBUGADD(8,("Converting the devicemode struct\n")); - nt_devmode=printer.info_2->devmode; - - init_devicemode(nt_devmode); - - convert_devicemode(*devmode, nt_devmode); - - /* now clear the memory used in - * the RPC parsing routine - */ - if (devmode->private != NULL) - free(devmode->private); - free(devmode); - } - else - { - if (printer.info_2->devmode != NULL) - { - free(printer.info_2->devmode); - } - printer.info_2->devmode=NULL; - } - - add_a_printer(printer, level); - free_a_printer(printer, level); - } -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setprinter(SPOOL_Q_SETPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_SETPRINTER r_u; - - /* - Let's the sun shine !!! - Always respond everything is alright - */ - - r_u.status=0x0; - - spoolss_io_r_setprinter("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETPRINTER q_u; - int pnum; - spoolss_io_q_setprinter("", &q_u, data, 0); - - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - /* check the level */ - switch (q_u.level) - { - case 0: - control_printer(q_u.handle, q_u.command); - break; - case 2: - update_printer(q_u.handle, q_u.level, q_u.info, q_u.devmode); - break; - } - } - spoolss_reply_setprinter(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_fcpn(SPOOL_Q_FCPN *q_u, prs_struct *rdata) -{ - SPOOL_R_FCPN r_u; - - r_u.status=0x0; - - spoolss_io_r_fcpn("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_fcpn(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_FCPN q_u; - - spoolss_io_q_fcpn("", &q_u, data, 0); - - spoolss_reply_fcpn(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addjob(SPOOL_Q_ADDJOB *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDJOB r_u; - - r_u.status=0x0; - - spoolss_io_r_addjob("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addjob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ADDJOB q_u; - - spoolss_io_q_addjob("", &q_u, data, 0); - - spoolss_reply_addjob(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, - int position, int snum) -{ - pstring temp_name; - - struct tm *t; - time_t unixdate = time(NULL); - - t=gmtime(&unixdate); - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); - - job_info->jobid=queue->job; - make_unistr(&(job_info->printername), lp_servicename(snum)); - make_unistr(&(job_info->machinename), temp_name); - make_unistr(&(job_info->username), queue->user); - make_unistr(&(job_info->document), queue->file); - make_unistr(&(job_info->datatype), "RAW"); - make_unistr(&(job_info->text_status), ""); - job_info->status=queue->status; - job_info->priority=queue->priority; - job_info->position=position; - job_info->totalpages=0; - job_info->pagesprinted=0; - - make_systemtime(&(job_info->submitted), t); -} - -/**************************************************************************** -****************************************************************************/ -static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, - int position, int snum) -{ - pstring temp_name; - DEVICEMODE *devmode; - NT_PRINTER_INFO_LEVEL ntprinter; - pstring chaine; - - struct tm *t; - time_t unixdate = time(NULL); - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - { - return (False); - } - - t=gmtime(&unixdate); - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); - - job_info->jobid=queue->job; - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter.info_2->printername); - make_unistr(&(job_info->printername), chaine); - - make_unistr(&(job_info->machinename), temp_name); - make_unistr(&(job_info->username), queue->user); - make_unistr(&(job_info->document), queue->file); - make_unistr(&(job_info->notifyname), queue->user); - make_unistr(&(job_info->datatype), "RAW"); - make_unistr(&(job_info->printprocessor), "winprint"); - make_unistr(&(job_info->parameters), ""); - make_unistr(&(job_info->text_status), ""); - -/* and here the security descriptor */ - - job_info->status=queue->status; - job_info->priority=queue->priority; - job_info->position=position; - job_info->starttime=0; - job_info->untiltime=0; - job_info->totalpages=0; - job_info->size=queue->size; - make_systemtime(&(job_info->submitted), t); - job_info->timeelapsed=0; - job_info->pagesprinted=0; - - devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); - ZERO_STRUCTP(devmode); - construct_dev_mode(devmode, snum, global_myname); - job_info->devmode=devmode; - - free_a_printer(ntprinter, 2); - return (True); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMJOBS r_u; - int snum; - int count; - int i; - print_queue_struct *queue=NULL; - print_status_struct status; - JOB_INFO_1 *job_info_1=NULL; - JOB_INFO_2 *job_info_2=NULL; - - DEBUG(4,("spoolss_reply_enumjobs\n")); - - bzero(&status,sizeof(status)); - - r_u.offered=q_u->buf_size; - - - if (get_printer_snum(&(q_u->handle), &snum)) - { - count=get_printqueue(snum, NULL, &queue, &status); - r_u.numofjobs=0; - - r_u.level=q_u->level; - - DEBUG(4,("count:[%d], status:[%d], [%s]\n", count, status.status, status.message)); - - switch (r_u.level) - { - case 1: - { - for (i=0; i<count; i++) - { - job_info_1=(JOB_INFO_1 *)malloc(count*sizeof(JOB_INFO_1)); - add_job1_to_array(&r_u.numofjobs, - &r_u.job.job_info_1, - job_info_1); - - fill_job_info_1(r_u.job.job_info_1[i], &(queue[i]), i, snum); - } - break; - } - case 2: - { - for (i=0; i<count; i++) - { - job_info_2=(JOB_INFO_2 *)malloc(count*sizeof(JOB_INFO_2)); - add_job2_to_array(&r_u.numofjobs, - &r_u.job.job_info_2, - job_info_2); - - fill_job_info_2(r_u.job.job_info_2[i], &(queue[i]), i, snum); - } - break; - } - } - } - - r_u.status = 0x0; - - spoolss_io_r_enumjobs("",&r_u,rdata,0); - - if (queue) free(queue); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumjobs(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMJOBS q_u; - - spoolss_io_q_enumjobs("", &q_u, data, 0); - - spoolss_reply_enumjobs(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_schedulejob(SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *rdata) -{ - SPOOL_R_SCHEDULEJOB r_u; - - r_u.status=0x0; - - spoolss_io_r_schedulejob("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_schedulejob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SCHEDULEJOB q_u; - - spoolss_io_q_schedulejob("", &q_u, data, 0); - - spoolss_reply_schedulejob(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata) -{ - SPOOL_R_SETJOB r_u; - int snum; - print_queue_struct *queue=NULL; - print_status_struct status; - int i=0; - BOOL found=False; - int count; - - bzero(&status,sizeof(status)); - - if (get_printer_snum(&(q_u->handle), &snum)) - { - count=get_printqueue(snum, NULL, &queue, &status); - while ( (i<count) && found==False ) - { - if ( q_u->jobid == queue[i].job ) - { - found=True; - } - i++; - } - - if (found==True) - { - switch (q_u->command) - { - case JOB_CONTROL_CANCEL: - case JOB_CONTROL_DELETE: - { - del_printqueue(NULL, snum, q_u->jobid); - break; - } - case JOB_CONTROL_PAUSE: - { - status_printjob(NULL, snum, q_u->jobid, LPQ_PAUSED); - break; - } - case JOB_CONTROL_RESUME: - { - status_printjob(NULL, snum, q_u->jobid, LPQ_QUEUED); - break; - } - } - } - } - r_u.status=0x0; - spoolss_io_r_setjob("",&r_u,rdata,0); - if (queue) free(queue); - -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setjob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETJOB q_u; - - spoolss_io_q_setjob("", &q_u, data, 0); - - spoolss_reply_setjob(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTERDRIVERS r_u; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - int count; - int i; - fstring *list; - DRIVER_INFO_1 *driver_info_1=NULL; - DRIVER_INFO_2 *driver_info_2=NULL; - DRIVER_INFO_3 *driver_info_3=NULL; - fstring servername; - fstring architecture; - - DEBUG(4,("spoolss_reply_enumdrivers\n")); - fstrcpy(servername, global_myname); - - unistr2_to_ascii(architecture, &(q_u->environment), sizeof(architecture)); - count=get_ntdrivers(&list, architecture); - - DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture)); - for (i=0; i<count; i++) - { - DEBUGADD(5,("driver [%s]\n",list[i])); - } - - r_u.offered=q_u->buf_size; - r_u.numofdrivers=count; - r_u.level=q_u->level; - - switch (r_u.level) - { - case 1: - { - driver_info_1=(DRIVER_INFO_1 *)malloc(count*sizeof(DRIVER_INFO_1)); - - for (i=0; i<count; i++) - { - get_a_printer_driver(&driver, 3, list[i], architecture); - fill_printer_driver_info_1(&(driver_info_1[i]), driver, servername, architecture ); - free_a_printer_driver(driver, 3); - } - r_u.driver.driver_info_1=driver_info_1; - break; - } - case 2: - { - driver_info_2=(DRIVER_INFO_2 *)malloc(count*sizeof(DRIVER_INFO_2)); - - for (i=0; i<count; i++) - { - get_a_printer_driver(&driver, 3, list[i], architecture); - fill_printer_driver_info_2(&(driver_info_2[i]), driver, servername, architecture ); - free_a_printer_driver(driver, 3); - } - r_u.driver.driver_info_2=driver_info_2; - break; - } - case 3: - { - driver_info_3=(DRIVER_INFO_3 *)malloc(count*sizeof(DRIVER_INFO_3)); - - for (i=0; i<count; i++) - { - get_a_printer_driver(&driver, 3, list[i], architecture); - fill_printer_driver_info_3(&(driver_info_3[i]), driver, servername, architecture ); - free_a_printer_driver(driver, 3); - } - r_u.driver.driver_info_3=driver_info_3; - break; - } - } - - r_u.status=0x0; - - spoolss_io_r_enumdrivers("",&r_u,rdata,0); - - switch (r_u.level) - { - case 1: - { - free(driver_info_1); - break; - } - case 2: - { - free(driver_info_2); - break; - } - case 3: - { - UNISTR **dependentfiles; - - for (i=0; i<count; i++) - { - int j=0; - dependentfiles=(driver_info_3[i]).dependentfiles; - while ( dependentfiles[j] != NULL ) - { - free(dependentfiles[j]); - j++; - } - - free(dependentfiles); - } - free(driver_info_3); - break; - } - } -} - -/**************************************************************************** -****************************************************************************/ - -static void api_spoolss_enumprinterdrivers(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTERDRIVERS q_u; - - spoolss_io_q_enumprinterdrivers("", &q_u, data, 0); - - spoolss_reply_enumprinterdrivers(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - - -/**************************************************************************** -****************************************************************************/ -static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position) -{ - form->flag=list->flag; - make_unistr(&(form->name), list->name); - form->width=list->width; - form->length=list->length; - form->left=list->left; - form->top=list->top; - form->right=list->right; - form->bottom=list->bottom; -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumforms(SPOOL_Q_ENUMFORMS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMFORMS r_u; - int count; - int i; - nt_forms_struct *list=NULL; - FORM_1 *forms_1=NULL; - - DEBUG(4,("spoolss_reply_enumforms\n")); - - count=get_ntforms(&list); - r_u.offered=q_u->buf_size; - r_u.numofforms=count; - r_u.level=q_u->level; - r_u.status=0x0; - - DEBUGADD(5,("Offered buffer size [%d]\n", r_u.offered)); - DEBUGADD(5,("Number of forms [%d]\n", r_u.numofforms)); - DEBUGADD(5,("Info level [%d]\n", r_u.level)); - - switch (r_u.level) - { - case 1: - { - forms_1=(FORM_1 *)malloc(count*sizeof(FORM_1)); - for (i=0; i<count; i++) - { - DEBUGADD(6,("Filling form number [%d]\n",i)); - fill_form_1(&(forms_1[i]), &(list[i]), i); - } - r_u.forms_1=forms_1; - break; - } - } - spoolss_io_r_enumforms("",&r_u,rdata,0); - switch (r_u.level) - { - case 1: - { - free(forms_1); - break; - } - } - free(list); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumforms(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMFORMS q_u; - - spoolss_io_q_enumforms("", &q_u, data, 0); - - spoolss_reply_enumforms(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void fill_port_2(PORT_INFO_2 *port, char *name) -{ - make_unistr(&(port->port_name), name); - make_unistr(&(port->monitor_name), "Moniteur Local"); - make_unistr(&(port->description), "Local Port"); -#define PORT_TYPE_WRITE 1 - port->port_type=PORT_TYPE_WRITE; - port->reserved=0x0; -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumports(SPOOL_Q_ENUMPORTS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPORTS r_u; - int i=0; - PORT_INFO_2 *ports_2=NULL; - int n_services=lp_numservices(); - int snum; - - DEBUG(4,("spoolss_reply_enumports\n")); - - r_u.offered=q_u->buf_size; - r_u.level=q_u->level; - r_u.status=0x0; - - switch (r_u.level) - { - case 2: - { - ports_2=(PORT_INFO_2 *)malloc(n_services*sizeof(PORT_INFO_2)); - for (snum=0; snum<n_services; snum++) - { - if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) - { - DEBUGADD(6,("Filling port number [%d]\n",i)); - fill_port_2(&(ports_2[i]), lp_servicename(snum)); - i++; - } - } - r_u.port.port_info_2=ports_2; - break; - } - } - r_u.numofports=i; - spoolss_io_r_enumports("",&r_u,rdata,0); - switch (r_u.level) - { - case 2: - { - free(ports_2); - break; - } - } -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumports(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPORTS q_u; - - spoolss_io_q_enumports("", &q_u, data, 0); - - spoolss_reply_enumports(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addprinterex(SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDPRINTEREX r_u; - BOOL printer_open = False; - fstring ascii_name; - fstring server_name; - fstring share_name; - UNISTR2 *portname; - SPOOL_PRINTER_INFO_LEVEL_2 *info2; - SPOOL_PRINTER_INFO_LEVEL *info; - - info=&(q_u->info); - info2=info->info_2; - portname=&(info2->portname); - - r_u.status=0x0; /* everything is always nice in this world */ - - StrnCpy(server_name, global_myname, strlen(global_myname) ); - unistr2_to_ascii(share_name, portname, sizeof(share_name)-1); - - slprintf(ascii_name, sizeof(ascii_name)-1, "\\\\%s\\%s", - server_name, share_name); - - printer_open = open_printer_hnd(&(r_u.handle)); - set_printer_hnd_printertype(&(r_u.handle), ascii_name); - set_printer_hnd_printername(&(r_u.handle), ascii_name); - - spoolss_io_r_addprinterex("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addprinterex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SPOOL_Q_ADDPRINTEREX q_u; - NT_PRINTER_INFO_LEVEL printer; - - /* read the stream and decode */ - spoolss_io_q_addprinterex("", &q_u, data, 0); - - /* NULLify info_2 here */ - /* don't put it in convert_printer_info as it's used also with non-NULL values */ - printer.info_2=NULL; - - /* convert from UNICODE to ASCII */ - convert_printer_info(q_u.info, &printer, q_u.level); - - /* write the ASCII on disk */ - add_a_printer(printer, q_u.level); - - spoolss_reply_addprinterex(&q_u, rdata); - /* free mem used in q_u and r_u */ - - /* free_add_printer(q_u, r_u); */ -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDPRINTERDRIVER r_u; - - r_u.status=0x0; /* everything is always nice in this world */ - - spoolss_io_r_addprinterdriver("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addprinterdriver(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ADDPRINTERDRIVER q_u; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - spoolss_io_q_addprinterdriver("", &q_u, data, 0); - - convert_printer_driver_info(q_u.info, &driver, q_u.level); - - add_a_printer_driver(driver, q_u.level); - - spoolss_reply_addprinterdriver(&q_u, rdata); - /* free mem used in q_u and r_u */ -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getprinterdriverdirectory(SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTERDRIVERDIR r_u; - pstring chaine; - pstring long_archi; - pstring archi; - - r_u.offered=q_u->buf_size; - r_u.level=q_u->level; - r_u.status=0x0; - - unistr2_to_ascii(long_archi, &(q_u->environment), sizeof(long_archi)-1); - get_short_archi(archi, long_archi); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\print$\\%s", global_myname, archi); - - DEBUG(4,("printer driver directory: [%s]\n", chaine)); - - make_unistr(&(r_u.driver.driver_info_1.name), chaine); - - spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_getprinterdriverdirectory(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTERDRIVERDIR q_u; - - spoolss_io_q_getprinterdriverdir("", &q_u, data, 0); - - spoolss_reply_getprinterdriverdirectory(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTERDATA r_u; - NT_PRINTER_INFO_LEVEL printer; - - uint32 type; - fstring value; - uint8 *data=NULL; - - uint32 param_index; - uint32 biggest_valuesize; - uint32 biggest_datasize; - uint32 data_len; - - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - int snum; - - DEBUG(5,("spoolss_reply_enumprinterdata\n")); - - if (OPEN_HANDLE(pnum)) - { - get_printer_snum(&(q_u->handle), &snum); - get_a_printer(&printer, 2, lp_servicename(snum)); - - /* The NT machine wants to know the biggest size of value and data */ - if ( (q_u->valuesize==0) && (q_u->datasize==0) ) - { - DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - - r_u.valuesize=0; - r_u.realvaluesize=0; - r_u.type=0; - r_u.datasize=0; - r_u.realdatasize=0; - r_u.status=0; - - param_index=0; - biggest_valuesize=0; - biggest_datasize=0; - - while (get_specific_param_by_index(printer, 2, param_index, value, &data, &type, &data_len)) - { - if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); - if (data_len > biggest_datasize) biggest_datasize=data_len; - - param_index++; - } - - /* I wrote it, I didn't designed the protocol */ - if (biggest_valuesize!=0) - { - SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); - } - r_u.data=(uint8 *)malloc(4*sizeof(uint8)); - SIVAL(r_u.data, 0, biggest_datasize ); - } - else - { - /* - * the value len is wrong in NT sp3 - * that's the number of bytes not the number of unicode chars - */ - - r_u.valuesize=q_u->valuesize; - r_u.datasize=q_u->datasize; - - if (get_specific_param_by_index(printer, 2, q_u->index, value, &data, &type, &data_len)) - { - make_unistr(&(r_u.value), value); - r_u.data=data; - - r_u.type=type; - - /* the length are in bytes including leading NULL */ - r_u.realvaluesize=2*(strlen(value)+1); - r_u.realdatasize=data_len; - - r_u.status=0; - } - else - { - r_u.valuesize=0; - r_u.realvaluesize=0; - r_u.datasize=0; - r_u.realdatasize=0; - r_u.type=0; - r_u.status=0x0103; /* ERROR_NO_MORE_ITEMS */ - } - } - - free_a_printer(printer, 2); - } - spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); - if (r_u.data!=NULL) free(r_u.data); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumprinterdata(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTERDATA q_u; - - spoolss_io_q_enumprinterdata("", &q_u, data, 0); - - spoolss_reply_enumprinterdata(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *rdata) -{ - SPOOL_R_SETPRINTERDATA r_u; - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_PARAM *param = NULL; - - int pnum=0; - int snum=0; - - DEBUG(5,("spoolss_reply_setprinterdata\n")); - - pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - get_printer_snum(&(q_u->handle), &snum); - get_a_printer(&printer, 2, lp_servicename(snum)); - convert_specific_param(¶m, q_u->value , q_u->type, q_u->data, q_u->real_len); - - unlink_specific_param_if_exist(printer.info_2, param); - - add_a_specific_param(printer.info_2, param); - - add_a_printer(printer, 2); - - free_a_printer(printer, 2); - } - - r_u.status = 0x0; - spoolss_io_r_setprinterdata("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setprinterdata(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETPRINTERDATA q_u; - - spoolss_io_q_setprinterdata("", &q_u, data, 0); - - spoolss_reply_setprinterdata(&q_u, rdata); - - free(q_u.data); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addform(SPOOL_Q_ADDFORM *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDFORM r_u; - int pnum=0; - int count=0; - nt_forms_struct *list=NULL; - - DEBUG(5,("spoolss_reply_addform\n")); - - pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - count=get_ntforms(&list); - - add_a_form(&list, q_u->form, &count); - - write_ntforms(&list, count); - - free(list); - } - - r_u.status = 0x0; - spoolss_io_r_addform("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addform(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ADDFORM q_u; - - spoolss_io_q_addform("", &q_u, data, 0); - - spoolss_reply_addform(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setform(SPOOL_Q_SETFORM *q_u, prs_struct *rdata) -{ - SPOOL_R_SETFORM r_u; - int pnum=0; - int count=0; - nt_forms_struct *list=NULL; - - DEBUG(5,("spoolss_reply_setform\n")); - - pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - count=get_ntforms(&list); - - update_a_form(&list, q_u->form, count); - - write_ntforms(&list, count); - - free(list); - } - r_u.status = 0x0; - spoolss_io_r_setform("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setform(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETFORM q_u; - - spoolss_io_q_setform("", &q_u, data, 0); - - spoolss_reply_setform(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprintprocessors(SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTPROCESSORS r_u; - PRINTPROCESSOR_1 *info_1; - - DEBUG(5,("spoolss_reply_enumprintprocessors\n")); - - /* - * Enumerate the print processors ... - * - * Just reply with "winprint", to keep NT happy - * and I can use my nice printer checker. - */ - - r_u.status = 0x0; - r_u.offered = q_u->buf_size; - r_u.level = q_u->level; - - r_u.numofprintprocessors = 0x1; - - info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1)); - - make_unistr(&(info_1->name), "winprint"); - - r_u.info_1=info_1; - - spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0); - - free(info_1); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumprintprocessors(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTPROCESSORS q_u; - - spoolss_io_q_enumprintprocessors("", &q_u, data, 0); - - spoolss_reply_enumprintprocessors(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprintmonitors(SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTMONITORS r_u; - PRINTMONITOR_1 *info_1; - - DEBUG(5,("spoolss_reply_enumprintmonitors\n")); - - /* - * Enumerate the print monitors ... - * - * Just reply with "Local Port", to keep NT happy - * and I can use my nice printer checker. - */ - - r_u.status = 0x0; - r_u.offered = q_u->buf_size; - r_u.level = q_u->level; - - r_u.numofprintmonitors = 0x1; - - info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); - - make_unistr(&(info_1->name), "Local Port"); - - r_u.info_1=info_1; - - spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0); - - free(info_1); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumprintmonitors(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTMONITORS q_u; - - spoolss_io_q_enumprintmonitors("", &q_u, data, 0); - - spoolss_reply_enumprintmonitors(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata) -{ - SPOOL_R_GETJOB r_u; - int snum; - int count; - int i; - print_queue_struct *queue=NULL; - print_status_struct status; - JOB_INFO_1 *job_info_1=NULL; - JOB_INFO_2 *job_info_2=NULL; - - DEBUG(4,("spoolss_reply_getjob\n")); - - bzero(&status,sizeof(status)); - - r_u.offered=q_u->buf_size; - - if (get_printer_snum(&(q_u->handle), &snum)) - { - count=get_printqueue(snum, NULL, &queue, &status); - - r_u.level=q_u->level; - - DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", count, status.status, status.message)); - - switch (r_u.level) - { - case 1: - { - job_info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); - - for (i=0; i<count; i++) - { - if (queue[i].job==(int)q_u->jobid) - { - fill_job_info_1(job_info_1, &(queue[i]), i, snum); - } - } - r_u.job.job_info_1=job_info_1; - break; - } - case 2: - { - job_info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); - - for (i=0; i<count; i++) - { - if (queue[i].job==(int)q_u->jobid) - { - fill_job_info_2(job_info_2, &(queue[i]), i, snum); - } - } - r_u.job.job_info_2=job_info_2; - break; - } - } - } - - r_u.status=0x0; - - spoolss_io_r_getjob("",&r_u,rdata,0); - switch (r_u.level) - { - case 1: - { - free(job_info_1); - break; - } - case 2: - { - free_devmode(job_info_2->devmode); - free(job_info_2); - break; - } - } - if (queue) free(queue); - -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_getjob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETJOB q_u; - - spoolss_io_q_getjob("", &q_u, data, 0); - - spoolss_reply_getjob(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/******************************************************************* -\pipe\spoolss commands -********************************************************************/ -struct api_struct api_spoolss_cmds[] = -{ - {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, - {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, - {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, - {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, - {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex }, - {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters }, - {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter }, - {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 }, - {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter }, - {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter }, - {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter }, - {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter }, - {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter }, - {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter }, - {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn }, - {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob }, - {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs }, - {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob }, - {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob }, - {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms }, - {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports }, - {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers }, - {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex }, - {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver }, - {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, - {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, - {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, - {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, - {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, - {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, - {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, - {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, - { NULL, 0, NULL } -}; - -/******************************************************************* -receives a spoolss pipe and responds. -********************************************************************/ -BOOL api_spoolss_rpc(rpcsrv_struct *p, prs_struct *data) -{ - return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); -} - diff --git a/source/rpc_server/srv_svcctl.c b/source/rpc_server/srv_svcctl.c deleted file mode 100644 index 12f0bdf3b35..00000000000 --- a/source/rpc_server/srv_svcctl.c +++ /dev/null @@ -1,388 +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. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - - -/******************************************************************* - svc_reply_unknown_1 - ********************************************************************/ -static void svc_reply_close(SVC_Q_CLOSE *q_r, - prs_struct *rdata) -{ - SVC_R_CLOSE r_u; - - /* set up the REG unknown_1 response */ - bzero(r_u.pol.data, POL_HND_SIZE); - - /* close the policy handle */ - if (close_policy_hnd(&(q_r->pol))) - { - r_u.status = 0; - } - else - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; - } - - DEBUG(5,("svc_unknown_1: %d\n", __LINE__)); - - /* store the response in the SMB stream */ - svc_io_r_close("", &r_u, rdata, 0); - - DEBUG(5,("svc_unknown_1: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_close - ********************************************************************/ -static void api_svc_close( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_CLOSE q_r; - svc_io_q_close("", &q_r, data, 0); - svc_reply_close(&q_r, rdata); -} - - -/******************************************************************* - svc_reply_open_service - ********************************************************************/ -static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - POLICY_HND pol; - SVC_R_OPEN_SERVICE r_u; - fstring name; - - DEBUG(5,("svc_open_service: %d\n", __LINE__)); - - if (status == 0x0 && find_policy_by_hnd(&q_u->scman_pol) == -1) - { - status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - if (status == 0x0 && !open_policy_hnd(&pol)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - unistr2_to_ascii(name, &q_u->uni_svc_name, sizeof(name)-1); - - if (status == 0x0) - { - DEBUG(5,("svc_open_service: %s\n", name)); - /* lkcl XXXX do a check on the name, here */ - } - - if (status == 0x0 && !set_policy_reg_name(&pol, name)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - make_svc_r_open_service(&r_u, &pol, status); - - /* store the response in the SMB stream */ - svc_io_r_open_service("", &r_u, rdata, 0); - - DEBUG(5,("svc_open_service: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_open_service - ********************************************************************/ -static void api_svc_open_service( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_OPEN_SERVICE q_u; - svc_io_q_open_service("", &q_u, data, 0); - svc_reply_open_service(&q_u, rdata); -} - -/******************************************************************* - svc_reply_start_service - ********************************************************************/ -static void svc_reply_start_service(SVC_Q_START_SERVICE *q_s, - prs_struct *rdata) -{ - SVC_R_START_SERVICE r_s; - - DEBUG(5,("svc_start_service: %d\n", __LINE__)); - - r_s.status = 0x0; - - if (find_policy_by_hnd(&q_s->pol) == -1) - { - r_s.status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - /* start the service here */ - - /* store the response in the SMB stream */ - svc_io_r_start_service("", &r_s, rdata, 0); - - DEBUG(5,("svc_start_service: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_start_service - ********************************************************************/ -static void api_svc_start_service( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_START_SERVICE q_u; - svc_io_q_start_service("", &q_u, data, 0); - svc_reply_start_service(&q_u, rdata); -} - -/******************************************************************* - svc_reply_open_sc_man - ********************************************************************/ -static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - POLICY_HND pol; - SVC_R_OPEN_SC_MAN r_u; - fstring name; - - DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); - - if (status == 0x0 && !open_policy_hnd(&pol)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - unistr2_to_ascii(name, &q_u->uni_srv_name, sizeof(name)-1); - - if (status == 0x0) - { - DEBUG(5,("svc_open_sc_man: %s\n", name)); - /* lkcl XXXX do a check on the name, here */ - } - - if (status == 0x0 && !set_policy_reg_name(&pol, name)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - make_svc_r_open_sc_man(&r_u, &pol, status); - - /* store the response in the SMB stream */ - svc_io_r_open_sc_man("", &r_u, rdata, 0); - - DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_open_sc_man - ********************************************************************/ -static void api_svc_open_sc_man( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_OPEN_SC_MAN q_u; - svc_io_q_open_sc_man("", &q_u, data, 0); - svc_reply_open_sc_man(&q_u, rdata); -} - -static char *dummy_services[] = -{ - "imapd", - "popd", - "smbd", - "nmbd", - "httpd", - "inetd", - "syslogd", - NULL -}; - -/******************************************************************* - svc_reply_enum_svcs_status - ********************************************************************/ -static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, - prs_struct *rdata) -{ - uint32 dos_status = 0; - SVC_R_ENUM_SVCS_STATUS r_u; - ENUM_SRVC_STATUS *svcs = NULL; - int num_svcs = 0; - int buf_size = 0; - int i = get_enum_hnd(&q_u->resume_hnd); - uint32 resume_hnd = 0; - int max_buf_size = 0x10000; - - ZERO_STRUCT(r_u); - - DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); - - if (dos_status == 0x0 && find_policy_by_hnd(&q_u->pol) == -1) - { - dos_status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - if (dos_status == 0x0) - { - DEBUG(5,("svc_enum_svcs_status:\n")); - while (dummy_services[i] != NULL) - { - ENUM_SRVC_STATUS *svc = NULL; - - buf_size += strlen(dummy_services[i] + 1) * 2; - buf_size += 9 * sizeof(uint32); - - DEBUG(10,("buf_size: %d q_u->buf_size: %d\n", - buf_size, q_u->buf_size)); - - if (buf_size >= max_buf_size) - { - resume_hnd = i; - break; - } - - if (buf_size > q_u->buf_size) - { - dos_status = ERRmoredata; - break; - } - - num_svcs++; - svcs = Realloc(svcs, num_svcs * sizeof(ENUM_SRVC_STATUS)); - if (svcs == NULL) - { - dos_status = ERRnomem; - num_svcs = 0; - break; - } - - svc = &svcs[num_svcs-1]; - ZERO_STRUCTP(svc); - - make_unistr(&svc->uni_srvc_name, dummy_services[i]); - make_unistr(&svc->uni_disp_name, dummy_services[i]); - - DEBUG(10,("show service: %s\n", dummy_services[i])); - i++; - } - } - - /* - * check for finished condition: no resume handle and last buffer fits - */ - - if (resume_hnd == 0 && buf_size <= q_u->buf_size) - { - /* this indicates, along with resume_hnd of 0, an end. */ - max_buf_size = 0; - } - - make_svc_r_enum_svcs_status(&r_u, svcs, max_buf_size, num_svcs, resume_hnd, dos_status); - - /* store the response in the SMB stream */ - svc_io_r_enum_svcs_status("", &r_u, rdata, 0); - - if (svcs != NULL) - { - free(svcs); - } - - DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_enum_svcs_status - ********************************************************************/ -static void api_svc_enum_svcs_status( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_ENUM_SVCS_STATUS q_u; - svc_io_q_enum_svcs_status("", &q_u, data, 0); - svc_reply_enum_svcs_status(&q_u, rdata); -} - -/******************************************************************* - svc_reply_query_disp_name - ********************************************************************/ -static void svc_reply_query_disp_name(SVC_Q_QUERY_DISP_NAME *q_u, - prs_struct *rdata) -{ - SVC_R_QUERY_DISP_NAME r_u; - fstring svc_name; - uint32 status = 0; - - DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); - - if (find_policy_by_hnd(&q_u->scman_pol) == -1) - { - status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - /* for now display name = service name */ - unistr2_to_ascii(svc_name, &q_u->uni_svc_name, sizeof(svc_name)-1); - make_svc_r_query_disp_name(&r_u, svc_name, status); - - /* store the response in the SMB stream */ - svc_io_r_query_disp_name("", &r_u, rdata, 0); - - DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_query_disp_name - ********************************************************************/ -static void api_svc_query_disp_name( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_QUERY_DISP_NAME q_u; - svc_io_q_query_disp_name("", &q_u, data, 0); - svc_reply_query_disp_name(&q_u, rdata); -} - -/******************************************************************* - array of \PIPE\svcctl operations - ********************************************************************/ -static struct api_struct api_svc_cmds[] = -{ - { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, - { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, - { "SVC_OPEN_SERVICE" , SVC_OPEN_SERVICE , api_svc_open_service }, - { "SVC_ENUM_SVCS_STATUS", SVC_ENUM_SVCS_STATUS, api_svc_enum_svcs_status }, - { "SVC_QUERY_DISP_NAME" , SVC_QUERY_DISP_NAME , api_svc_query_disp_name }, - { "SVC_START_SERVICE" , SVC_START_SERVICE , api_svc_start_service }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a svcctl pipe and responds. - ********************************************************************/ -BOOL api_svcctl_rpc(rpcsrv_struct *p, prs_struct *data) -{ - return api_rpcTNP(p, "api_svc_rpc", api_svc_cmds, data); -} - diff --git a/source/rpcclient/cmd_atsvc.c b/source/rpcclient/cmd_atsvc.c deleted file mode 100644 index 547ca960536..00000000000 --- a/source/rpcclient/cmd_atsvc.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 2.1. - MSRPC client: scheduler service - Copyright (C) Matthew Chapman 1999 - Copyright (C) Luke Kenneth Casson Leighton 1996-1999 - Copyright (C) Andrew Tridgell 1994-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 - -extern FILE* out_hnd; - - -/**************************************************************************** -checks for a /OPTION:param style option -****************************************************************************/ -static BOOL checkopt(char *input, char *optname, char **params) -{ - char *inend; - - if (*input++ != '/') - return False; - - for (inend = input; *inend != 0 && *inend != ':'; inend++); - - if (params != NULL) - { - *inend = 0; - *params = inend; - } - - while(input < inend) - { - if (toupper(*input++) != *optname++) - return False; - } - - return True; -} - -extern char *daynames_short[]; -extern char *daynames[]; - -/**************************************************************************** -parses a list of days of the week and month -****************************************************************************/ -static BOOL at_parse_days(char *str, uint32 *monthdays, uint8 *weekdays) -{ - char *tok; - char *nexttok = str; - int day; - - do { - tok = nexttok; - - if ((nexttok = strchr(tok, ',')) != NULL) - { - *nexttok++ = 0; - } - - if (isdigit((int)*tok)) - { - day = strtol(tok, NULL, 10); - if (day == 0 || day > 31) - { - printf("\tInvalid day of month.\n\n"); - return False; - } - - *monthdays |= (1 << (day-1)); - } - else - { - if (strlen(tok) < 3) - { - for (day = 0; day < 7; day++) - { - if (!strcasecmp(tok, daynames_short[day])) - break; - } - } - else - { - for (day = 0; day < 7; day++) - { - if (!strncasecmp(tok, daynames[day], 3)) - break; - } - } - - if (day < 7) - { - *weekdays |= (1 << day); - } - else - { - printf("\tInvalid day of week\n\n"); - return False; - } - } - - } while (nexttok != NULL); - - return True; -} - -#define SOON_OFFSET 2 /* seconds */ - -/**************************************************************************** -schedule the job 'soon' -****************************************************************************/ -static BOOL at_soon(char *dest_srv, uint32 *hours, uint32 *minutes, uint32 *seconds) -{ - TIME_OF_DAY_INFO tod; - BOOL res = True; - - /* enumerate files on server */ - res = res ? srv_net_remote_tod(dest_srv, &tod) : False; - - if (res) - { - *hours = (tod.hours - ((int)tod.zone/60)) % 24; - *minutes = tod.mins; - *seconds = (tod.secs + SOON_OFFSET) % 60; - return True; - } - - return False; -} - - -/**************************************************************************** -scheduler add job -****************************************************************************/ -void cmd_at(struct client_info *info, int argc, char *argv[]) -{ - fstring dest_wks; - BOOL add = False; - BOOL del = False; - char *p; - - uint32 jobid = -1; - unsigned int hours, minutes, seconds = 0; - uint32 monthdays = 0; - uint8 weekdays = 0; - uint8 flags = JOB_NONINTERACTIVE; - pstring command; - - safe_strcpy(dest_wks, "\\\\", sizeof(dest_wks)); - safe_strcat(dest_wks, info->dest_host, sizeof(dest_wks)); - strupper(dest_wks); - - while (argc > 1) - { - argc--; - argv++; - - if (checkopt(argv[0], "DELETE", NULL)) - { - del = True; - continue; - } - else if (checkopt(argv[0], "YES", NULL)) - { - /* Compatibility */ - continue; - } - - jobid = strtol(argv[0], &p, 10); - if (*p == 0) /* Entirely numeric field */ - continue; - - if (!strcasecmp(argv[0], "NOW")) - { - if (!at_soon(dest_wks, &hours, &minutes, &seconds)) - { - return; - } - } - else if (sscanf(argv[0], "%d:%d:%d", &hours, &minutes, &seconds) >= 2) - { - p = strchr(argv[0], 0); - - if (!strcasecmp(p-2, "AM")) - { - hours = (hours == 12) ? 0 : hours; - } - - if (!strcasecmp(p-2, "PM")) - { - hours = (hours == 12) ? 12 : hours + 12; - } - - if (hours > 23 || minutes > 59 || seconds > 59) - { - printf("\tInvalid time.\n\n"); - return; - } - } - else - { - printf("at { {time | NOW} [/INTERACTIVE] [{/EVERY|/NEXT}:5,Sun,...] command\n\t| [/DEL] [jobid] }\n\n"); - return; - } - - add = True; - command[0] = 0; - p = NULL; - - if (argc <= 1) break; - argc--; - argv++; - - if (checkopt(argv[0], "INTERACTIVE", NULL)) - { - flags &= ~JOB_NONINTERACTIVE; - - if (argc <= 1) break; - argc--; - argv++; - } - - if (checkopt(argv[0], "EVERY", &p)) - { - flags |= JOB_PERIODIC; - } - else - { - checkopt(argv[0], "NEXT", &p); - } - - if (p != NULL) - { - if (*p == ':') - { - if (!at_parse_days(p, &monthdays, &weekdays)) - return; - } - else - { - weekdays = 0x7F; - } - - if (argc <= 1) break; - argc--; - argv++; - } - - while (True) - { - safe_strcat(command, argv[0], sizeof(command)); - - if (argc <= 1) break; - argc--; - argv++; - - safe_strcat(command, " ", sizeof(command)); - } - - break; - } - - if (add && !command[0]) - { - printf("\tNo command specified.\n\n"); - return; - } - - if (add) /* add job */ - { - AT_JOB_INFO job; - - job.time = ((((hours * 60) + minutes) * 60) + seconds) * 1000; - job.monthdays = monthdays; - job.weekdays = weekdays; - job.flags = flags; - job.ptr_command = 1; - - display_at_job_info(out_hnd, ACTION_HEADER , &job, command); - display_at_job_info(out_hnd, ACTION_ENUMERATE, &job, command); - display_at_job_info(out_hnd, ACTION_FOOTER , &job, command); - - if (at_add_job(dest_wks, &job, command, &jobid)) - { - fprintf(out_hnd, "\tJob ID: %d\n\n", jobid); - } - } - else if (del) /* delete */ - { - if (jobid == -1) - { - fprintf(out_hnd, "\tDeleting all jobs.\n\n"); - at_del_job(dest_wks, 0, 0xffffffff); - } - else - { - fprintf(out_hnd, "\tDeleting job %d.\n\n", jobid); - at_del_job(dest_wks, jobid, jobid); - } - - } - else if (jobid == -1) /* enumerate */ - { - AT_ENUM_INFO jobs[AT_MAX_JOBS]; - char **commands; - uint32 num_jobs; - - if (at_enum_jobs(dest_wks, &num_jobs, jobs, &commands)) - { - display_at_enum_info(out_hnd, ACTION_HEADER , num_jobs, jobs, commands); - display_at_enum_info(out_hnd, ACTION_ENUMERATE, num_jobs, jobs, commands); - display_at_enum_info(out_hnd, ACTION_FOOTER , num_jobs, jobs, commands); - } - - free_char_array(num_jobs, commands); - } - else /* job info */ - { - AT_JOB_INFO job; - - if (at_query_job(dest_wks, jobid, &job, command)) - { - display_at_job_info(out_hnd, ACTION_HEADER , &job, command); - display_at_job_info(out_hnd, ACTION_ENUMERATE, &job, command); - display_at_job_info(out_hnd, ACTION_FOOTER , &job, command); - } - } -} diff --git a/source/rpcclient/cmd_brs.c b/source/rpcclient/cmd_brs.c deleted file mode 100644 index ca1dbe036ca..00000000000 --- a/source/rpcclient/cmd_brs.c +++ /dev/null @@ -1,83 +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 - -extern FILE* out_hnd; - - -/**************************************************************************** -Browser get info query -****************************************************************************/ -void cmd_brs_query_info(struct client_info *info, int argc, char *argv[]) -{ - fstring dest_brs; - BRS_INFO_100 ctr; - uint32 info_level = 100; - - BOOL res = True; - - bzero(&ctr, sizeof(ctr)); - - fstrcpy(dest_brs, "\\\\"); - fstrcat(dest_brs, info->dest_host); - strupper(dest_brs); - - if (argc > 1) - { - info_level = (uint32)strtol(argv[1], (char**)NULL, 10); - } - - DEBUG(4,("cmd_brs_query_info: server:%s info level: %d\n", - dest_brs, info_level)); - - /* send info level: receive requested info. hopefully. */ - res = res ? brs_query_info( dest_brs, info_level, &ctr) : False; - - if (res) - { - DEBUG(5,("cmd_brs_query_info: query succeeded\n")); - -#if 0 - display_brs_info_100(out_hnd, ACTION_HEADER , &ctr); - display_brs_info_100(out_hnd, ACTION_ENUMERATE, &ctr); - display_brs_info_100(out_hnd, ACTION_FOOTER , &ctr); -#endif - - } - else - { - DEBUG(5,("cmd_brs_query_info: query failed\n")); - } -} - diff --git a/source/rpcclient/cmd_eventlog.c b/source/rpcclient/cmd_eventlog.c deleted file mode 100644 index 3e86f5bb28b..00000000000 --- a/source/rpcclient/cmd_eventlog.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 2.1. - Copyright (C) Luke Kenneth Casson Leighton 1996-1999, - Copyright (C) Andrew Tridgell 1994-1999, - Copyright (C) Jean Francois Micouleau 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. -*/ - - -#ifdef SYSLOG -#undef SYSLOG -#endif - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - -#define DEBUG_TESTING - -extern FILE* out_hnd; - - -/**************************************************************************** -****************************************************************************/ -void cmd_eventlog(struct client_info *info, int argc, char *argv[]) -{ - BOOL res1 = True; - BOOL res = True; - POLICY_HND hnd; - uint32 number = 0; - uint32 flags; - uint32 offset; - uint32 num_of_bytes; - EVENTLOGRECORD ev; - - char *journal = NULL; - - fstring srv_name; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - flags = EVENTLOG_READ_SEQUENTIAL|EVENTLOG_READ_BACKWARD; - - if (argc > 1) - { - journal = argv[1]; - } - - res = res ? event_open(srv_name, journal, &hnd) : False; - res1 = res ? event_numofeventlogrec(&hnd, &number) : False; - - fprintf(out_hnd, "Number of events: %d\n", number); - - display_eventlog_eventrecord(out_hnd, ACTION_HEADER, &ev); - - for (offset = 0; offset < number && res1; offset++) - { - num_of_bytes=0; - - /* try once with a empty buffer */ - res1 = res1 ? event_readeventlog(&hnd, number, - flags, offset, - &num_of_bytes, &ev) : False; - - /* and try again with the correct size */ - res1 = res1 ? event_readeventlog(&hnd, number, - flags, offset, - &num_of_bytes, &ev) : False; - - display_eventlog_eventrecord(out_hnd, ACTION_ENUMERATE, &ev); - } - - display_eventlog_eventrecord(out_hnd, ACTION_FOOTER, &ev); - - res = res ? event_close(&hnd): False; -} diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c deleted file mode 100644 index 43fa9900d40..00000000000 --- a/source/rpcclient/cmd_spoolss.c +++ /dev/null @@ -1,264 +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 - -extern FILE* out_hnd; - -extern struct ntuser_creds *usr_creds; - -/**************************************************************************** -nt spoolss query -****************************************************************************/ -BOOL msrpc_spoolss_enum_printers( const char* srv_name, - uint32 level, - uint32 *num, - void ***ctr, - PRINT_INFO_FN(fn)) -{ - BOOL res = True; - - if (spoolss_enum_printers( 0x40, srv_name, level, num, ctr) && - fn != NULL) - { - fn(srv_name, level, *num, *ctr); - } - - return res; -} - -static void spool_print_info_ctr(const char* srv_name, uint32 level, - uint32 num, void *const *const ctr) -{ - display_printer_info_ctr(out_hnd, ACTION_HEADER , level, num, ctr); - display_printer_info_ctr(out_hnd, ACTION_ENUMERATE, level, num, ctr); - display_printer_info_ctr(out_hnd, ACTION_FOOTER , level, num, ctr); -} - -/**************************************************************************** -nt spoolss query -****************************************************************************/ -void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]) -{ - void **ctr = NULL; - uint32 num = 0; - uint32 level = 1; - - fstring srv_name; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - if (msrpc_spoolss_enum_printers(srv_name, level, &num, &ctr, - spool_print_info_ctr)) - { - DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); - } - else - { - report(out_hnd, "FAILED\n"); - } - - free_void_array(num, ctr, free); -} - -/**************************************************************************** -nt spoolss query -****************************************************************************/ -void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]) -{ - fstring srv_name; - fstring station; - char *printer_name; - POLICY_HND hnd; - - BOOL res = True; - - if (argc < 2) - { - report(out_hnd, "spoolopen <printer name>\n"); - return; - } - - printer_name = argv[1]; - - fstrcpy(station, "\\\\"); - fstrcat(station, info->myhostname); - strupper(station); - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - if (!strnequal("\\\\", printer_name, 2)) - { - fstrcat(srv_name, "\\"); - fstrcat(srv_name, printer_name); - printer_name = srv_name; - } - - DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n", - printer_name, station, usr_creds->user_name)); - - res = res ? spoolss_open_printer_ex( printer_name, - 0, 0, 0, - station, usr_creds->user_name, - &hnd) : False; - - res = res ? spoolss_closeprinter(&hnd) : False; - - if (res) - { - DEBUG(5,("cmd_spoolss_open_printer_ex: query succeeded\n")); - report(out_hnd, "OK\n"); - } - else - { - DEBUG(5,("cmd_spoolss_open_printer_ex: query failed\n")); - } -} - -/**************************************************************************** -nt spoolss query -****************************************************************************/ -BOOL msrpc_spoolss_enum_jobs( const char* printer_name, - const char* station, const char* user_name, - uint32 level, - uint32 *num, - void ***ctr, - JOB_INFO_FN(fn)) -{ - POLICY_HND hnd; - uint32 buf_size = 0x0; - uint32 status = 0x0; - - BOOL res = True; - BOOL res1 = True; - - DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n", - printer_name, station, user_name)); - - res = res ? spoolss_open_printer_ex( printer_name, - 0, 0, 0, - station, user_name, - &hnd) : False; - - if (status == 0x0) - { - status = spoolss_enum_jobs( &hnd, - 0, 1000, level, &buf_size, - num, ctr); - } - - if (status == ERROR_INSUFFICIENT_BUFFER) - { - status = spoolss_enum_jobs( &hnd, - 0, 1000, level, &buf_size, - num, ctr); - } - - res1 = (status == 0x0); - - res = res ? spoolss_closeprinter(&hnd) : False; - - if (res1 && fn != NULL) - { - fn(printer_name, station, level, *num, *ctr); - } - - return res1; -} - -static void spool_job_info_ctr( const char* printer_name, - const char* station, - uint32 level, - uint32 num, void *const *const ctr) -{ - display_job_info_ctr(out_hnd, ACTION_HEADER , level, num, ctr); - display_job_info_ctr(out_hnd, ACTION_ENUMERATE, level, num, ctr); - display_job_info_ctr(out_hnd, ACTION_FOOTER , level, num, ctr); -} - -/**************************************************************************** -nt spoolss query -****************************************************************************/ -void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[]) -{ - fstring srv_name; - fstring station; - char *printer_name; - - void **ctr = NULL; - uint32 num = 0; - uint32 level = 1; - - if (argc < 2) - { - report(out_hnd, "spoolenum <printer name>\n"); - return; - } - - printer_name = argv[1]; - - fstrcpy(station, "\\\\"); - fstrcat(station, info->myhostname); - strupper(station); - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - if (!strnequal("\\\\", printer_name, 2)) - { - fstrcat(srv_name, "\\"); - fstrcat(srv_name, printer_name); - printer_name = srv_name; - } - - DEBUG(4,("spoolopen - printer: %s station: %s user: %s\n", - printer_name, station, usr_creds->user_name)); - - if (msrpc_spoolss_enum_jobs( printer_name, station, - usr_creds->user_name, - level, &num, &ctr, - spool_job_info_ctr)) - { - DEBUG(5,("cmd_spoolss_enum_jobs: query succeeded\n")); - } - else - { - report(out_hnd, "FAILED\n"); - } - - free_void_array(num, ctr, free); -} - diff --git a/source/rpcclient/cmd_svcctl.c b/source/rpcclient/cmd_svcctl.c deleted file mode 100644 index d118a7d15db..00000000000 --- a/source/rpcclient/cmd_svcctl.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - NT Domain Authentication SMB / MSRPC client - Copyright (C) Andrew Tridgell 1994-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. -*/ - - - -#ifdef SYSLOG -#undef SYSLOG -#endif - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - -extern FILE* out_hnd; - -void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg) -{ - display_query_svc_cfg(out_hnd, ACTION_HEADER , cfg); - display_query_svc_cfg(out_hnd, ACTION_ENUMERATE, cfg); - display_query_svc_cfg(out_hnd, ACTION_FOOTER , cfg); -} - -BOOL svc_query_service( POLICY_HND *pol_scm, - const char *svc_name, - SVC_QUERY_FN(svc_query_fn)) -{ - BOOL res2 = True; - BOOL res3; - POLICY_HND pol_svc; - QUERY_SERVICE_CONFIG cfg; - uint32 svc_buf_size = 0x8000; - - res2 = res2 ? svc_open_service( pol_scm, - svc_name, 0x80000001, - &pol_svc) : False; - res3 = res2 ? svc_query_svc_cfg( &pol_svc, &cfg, - &svc_buf_size) : False; - - if (res3 && svc_query_fn != NULL) - { - svc_query_fn(&cfg); - } - - res2 = res2 ? svc_close(&pol_svc) : False; - - return res3; -} - -/**************************************************************************** -nt service info -****************************************************************************/ -void cmd_svc_info(struct client_info *info, int argc, char *argv[]) -{ - BOOL res = True; - BOOL res1 = True; - char *svc_name; - - POLICY_HND pol_scm; - - fstring srv_name; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - DEBUG(4,("cmd_svc_info: server:%s\n", srv_name)); - - if (argc < 2) - { - report(out_hnd,"svcinfo <service name>\n"); - return; - } - - svc_name = argv[1]; - - /* open service control manager receive a policy handle */ - res = res ? svc_open_sc_man( srv_name, NULL, 0x80000004, - &pol_scm) : False; - - res1 = svc_query_service(&pol_scm, svc_name, - svc_display_query_svc_cfg); - - res = res ? svc_close(&pol_scm) : False; - - if (res && res1) - { - DEBUG(5,("cmd_svc_info: query succeeded\n")); - } - else - { - DEBUG(5,("cmd_svc_info: query failed\n")); - } -} - -static void svc_display_svc_info(const ENUM_SRVC_STATUS *svc) -{ - display_svc_info(out_hnd, ACTION_HEADER , svc); - display_svc_info(out_hnd, ACTION_ENUMERATE, svc); - display_svc_info(out_hnd, ACTION_FOOTER , svc); -} - -/**************************************************************************** -nt service enum -****************************************************************************/ -BOOL msrpc_svc_enum(const char* srv_name, - ENUM_SRVC_STATUS **svcs, - uint32 *num_svcs, - SVC_INFO_FN(info_fn), - SVC_QUERY_FN(query_fn)) -{ - BOOL res = True; - BOOL res1 = False; - int i; - uint32 resume_hnd = 0; - uint32 buf_size = 0; - uint32 dos_error = 0; - - POLICY_HND pol_scm; - - (*svcs) = NULL; - (*num_svcs) = 0; - - /* open service control manager receive a policy handle */ - res = res ? svc_open_sc_man( srv_name, NULL, 0x80000004, - &pol_scm) : False; - - do - { - if ((*svcs) != NULL) - { - free(*svcs); - (*svcs) = NULL; - (*num_svcs) = 0; - } - - buf_size += 0x800; - - /* enumerate services */ - res1 = res ? svc_enum_svcs( &pol_scm, - 0x00000030, 0x00000003, - &buf_size, &resume_hnd, &dos_error, - svcs, num_svcs) : False; - - } while (res1 && dos_error == ERRmoredata); - - for (i = 0; i < (*num_svcs) && (*svcs) != NULL && res1; i++) - { - fstring svc_name; - - unistr_to_ascii(svc_name, (*svcs)[i].uni_srvc_name.buffer, - sizeof(svc_name)-1); - - if (query_fn != NULL) - { - res1 = svc_query_service(&pol_scm, - svc_name, query_fn); - } - else if (info_fn != NULL) - { - info_fn(&(*svcs)[i]); - } - } - - res = res ? svc_close(&pol_scm) : False; - - return res1; -} - -/**************************************************************************** -nt service enum -****************************************************************************/ -void cmd_svc_enum(struct client_info *info, int argc, char *argv[]) -{ - ENUM_SRVC_STATUS *svcs = NULL; - uint32 num_svcs = 0; - BOOL request_info = False; - int opt; - fstring srv_name; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - while ((opt = getopt(argc, argv,"i")) != EOF) - { - switch (opt) - { - case 'i': - { - request_info = True; - break; - } - } - } - - report(out_hnd,"Services\n"); - report(out_hnd,"--------\n"); - - msrpc_svc_enum(srv_name, &svcs, &num_svcs, - request_info ? NULL : svc_display_svc_info, - request_info ? svc_display_query_svc_cfg : NULL); - - if (svcs != NULL) - { - free(svcs); - } -} - -/**************************************************************************** -nt stop service -****************************************************************************/ -void cmd_svc_stop(struct client_info *info, int argc, char *argv[]) -{ - BOOL res = True; - BOOL res1 = True; - char *svc_name; - BOOL res2 = True; - POLICY_HND pol_svc; - POLICY_HND pol_scm; - - fstring srv_name; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - DEBUG(4,("cmd_svc_stop: server:%s\n", srv_name)); - - if (argc < 2) - { - report(out_hnd,"svcstop <service name>\n"); - return; - } - - svc_name = argv[1]; - - /* open service control manager receive a policy handle */ - res = res ? svc_open_sc_man( srv_name, NULL, 0x80000000, - &pol_scm) : False; - - res1 = res ? svc_open_service( &pol_scm, - svc_name, 0x00000020, - &pol_svc) : False; - res2 = res1 ? svc_stop_service(&pol_svc, 0x1) : False; - - res1 = res1 ? svc_close(&pol_svc) : False; - res = res ? svc_close(&pol_scm) : False; - - if (res2) - { - report(out_hnd,"Stopped Service %s\n", svc_name); - DEBUG(5,("cmd_svc_stop: succeeded\n")); - } - else - report(out_hnd,"Failed Service Stopped (%s)\n", svc_name); - { - DEBUG(5,("cmd_svc_stop: failed\n")); - } -} - -/**************************************************************************** -nt start service -****************************************************************************/ -void cmd_svc_start(struct client_info *info, int argc, char *argv[]) -{ - BOOL res = True; - BOOL res1 = True; - char *svc_name; - BOOL res2 = True; - POLICY_HND pol_svc; - POLICY_HND pol_scm; - - fstring srv_name; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - DEBUG(4,("cmd_svc_start: server:%s\n", srv_name)); - - if (argc < 2) - { - report(out_hnd,"svcstart <service name> [arg 0] [arg 1]...]\n"); - return; - } - - argv++; - argc--; - - svc_name = argv[0]; - - argv++; - argc--; - - /* open service control manager receive a policy handle */ - res = res ? svc_open_sc_man( srv_name, NULL, 0x80000000, - &pol_scm) : False; - - res1 = res ? svc_open_service( &pol_scm, - svc_name, 0x80000010, - &pol_svc) : False; - res2 = res1 ? svc_start_service( &pol_svc, argc, argv) : False; - - res1 = res1 ? svc_close(&pol_svc) : False; - res = res ? svc_close(&pol_scm) : False; - - if (res2) - { - report(out_hnd,"Started Service %s\n", svc_name); - DEBUG(5,("cmd_svc_start: succeeded\n")); - } - else - report(out_hnd,"Failed Service Startup (%s)\n", svc_name); - { - DEBUG(5,("cmd_svc_start: failed\n")); - } -} - -/**************************************************************************** -nt service set -****************************************************************************/ -void cmd_svc_set(struct client_info *info, int argc, char *argv[]) -{ - BOOL res = True; - BOOL res2 = True; - BOOL res3; - POLICY_HND pol_svc; - QUERY_SERVICE_CONFIG cfg; - uint32 svc_buf_size = 0x8000; - - char *svc_name; - - POLICY_HND pol_scm; - - fstring srv_name; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - DEBUG(4,("cmd_svc_set: server:%s\n", srv_name)); - - if (argc < 2) - { - report(out_hnd,"svcset <service name>\n"); - return; - } - - svc_name = argv[1]; - - /* open service control manager receive a policy handle */ - res = res ? svc_open_sc_man( srv_name, NULL, 0x80000004, - &pol_scm) : False; - - res2 = res ? svc_open_service( &pol_scm, - svc_name, 0x80000001, - &pol_svc) : False; - res3 = res2 ? svc_query_svc_cfg( &pol_svc, &cfg, - &svc_buf_size) : False; - - if (res3) - { - res3 = svc_change_svc_cfg(&pol_svc, - cfg.service_type, - cfg.start_type, - 0xffffffff, - 0, - NULL, NULL, - cfg.tag_id, - NULL, "administrator", NULL, NULL); - - } - - res2 = res2 ? svc_close(&pol_svc) : False; - - res = res ? svc_close(&pol_scm) : False; - - if (res3) - { - DEBUG(5,("cmd_svc_set: change succeeded\n")); - } - else - { - DEBUG(5,("cmd_svc_set: change failed\n")); - } -} - diff --git a/source/rpcclient/display_at.c b/source/rpcclient/display_at.c deleted file mode 100644 index 29daf9f3336..00000000000 --- a/source/rpcclient/display_at.c +++ /dev/null @@ -1,190 +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" - -static char *get_at_time_str(uint32 t) -{ - static fstring timestr; - unsigned int hours, minutes, seconds; - - hours = t / 1000; - seconds = hours % 60; - hours /= 60; - minutes = hours % 60; - hours /= 60; - - slprintf(timestr, sizeof(timestr)-1, "%2d:%02d:%02d", - hours, minutes, seconds); - - return timestr; -} - -extern char *daynames_short[]; - -static char *get_at_days_str(uint32 monthdays, uint8 weekdays, uint8 flags) -{ - static fstring days; - fstring numstr; - int day, bit; - BOOL first = True; - - if (monthdays == 0 && weekdays == 0) - return "Once"; - - if (flags & JOB_PERIODIC) - { - if (IS_BITS_SET_ALL(weekdays, 0x7F)) - return "Every Day"; - - fstrcpy(days, "Every "); - } - else - { - fstrcpy(days, "Next "); - } - - for (day = 1, bit = 1; day < 32; day++, bit <<= 1) - { - if (monthdays & bit) - { - if (first) - first = False; - else - fstrcat(days, ", "); - - slprintf(numstr, sizeof(numstr)-1, "%d", day); - fstrcat(days, numstr); - } - } - - for (day = 0, bit = 1; day < 7; day++, bit <<= 1) - { - if (weekdays & bit) - { - if (first) - first = False; - else - fstrcat(days, ", "); - - fstrcat(days, daynames_short[day]); - } - } - - return days; -} - -/**************************************************************************** - display scheduled jobs - ****************************************************************************/ -void display_at_enum_info(FILE *out_hnd, enum action_type action, - uint32 num_jobs, const AT_ENUM_INFO *const jobs, - char *const *const commands) -{ - switch (action) - { - case ACTION_HEADER: - { - if (num_jobs == 0) - { - report(out_hnd, "\tNo Jobs.\n"); - } - else - { - report(out_hnd, "\tJobs:\n"); - report(out_hnd, "\t-----\n"); - } - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < num_jobs; i++) - { - const AT_JOB_INFO *const job = &jobs[i].info; - - report(out_hnd, "\t%d\t%s\t%s\t%s\n", - jobs[i].jobid, - get_at_time_str(job->time), - get_at_days_str(job->monthdays, - job->weekdays, - job->flags), - commands[i]); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display information about a scheduled job - ****************************************************************************/ -void display_at_job_info(FILE *out_hnd, enum action_type action, - AT_JOB_INFO *const job, fstring command) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tJob Information:\n"); - report(out_hnd, "\t----------------\n"); - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\tTime: %s\n", - get_at_time_str(job->time)); - - report(out_hnd, "\tSchedule: %s\n", - get_at_days_str(job->monthdays, job->weekdays, - job->flags)); - - report(out_hnd, "\tStatus: %s", - (job->flags & JOB_EXEC_ERR) ? "Failed" : "OK"); - - if (job->flags & JOB_RUNS_TODAY) - { - report(out_hnd, ", Runs Today"); - } - - report(out_hnd, "\n\tInteractive: %s\n", - (job->flags & JOB_NONINTERACTIVE) ? "No" - : "Yes"); - - report(out_hnd, "\tCommand: %s\n", command); - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - diff --git a/source/rpcclient/display_event.c b/source/rpcclient/display_event.c deleted file mode 100644 index cd941851ac5..00000000000 --- a/source/rpcclient/display_event.c +++ /dev/null @@ -1,101 +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" - - -/**************************************************************************** - display structure - ****************************************************************************/ -void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tevent log records\n"); - report(out_hnd, "\t-----------------\n"); - break; - } - case ACTION_ENUMERATE: - { - fstring temp; - report(out_hnd, "\t\trecord n.:\t%d\n", ev->recordnumber); - - report(out_hnd, "\t\tsource\teventnumber\teventtype\tcategory\n"); - unistr_to_ascii(temp, ev->sourcename.buffer, sizeof(temp)-1); - - report(out_hnd, "\t\t%s", temp); - - report(out_hnd, "\t%d\t\t", ev->eventnumber&0x0000FFFF); - - switch (ev->eventtype) - { - case EVENTLOG_OK: - report(out_hnd, "Normal"); - break; - - case EVENTLOG_ERROR: - report(out_hnd, "Error"); - break; - - case EVENTLOG_WARNING: - report(out_hnd, "Warning"); - break; - - case EVENTLOG_INFORMATION: - report(out_hnd, "Information"); - break; - - case EVENTLOG_AUDIT_OK: - report(out_hnd, "Audit Normal"); - break; - - case EVENTLOG_AUDIT_ERROR: - report(out_hnd, "Audit Error\n"); - break; - } - - report(out_hnd, "\t%d\n", ev->category); - report(out_hnd, "\t\tcreationtime:\t%s\n", http_timestring(ev->creationtime)); - report(out_hnd, "\t\twritetime:\t%s\n", http_timestring(ev->writetime)); - - unistr_to_ascii(temp, ev->computername.buffer, sizeof(temp)-1); - report(out_hnd, "\t\tcomputer:\t%s\n", temp); - - if (ev->num_of_strings!=0) - { - unistr_to_ascii(temp, ev->strings.buffer, sizeof(temp)-1); - report(out_hnd, "\t\tdescription:\t%s\n", temp); - } - - report(out_hnd, "\n"); - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - diff --git a/source/rpcclient/display_reg.c b/source/rpcclient/display_reg.c deleted file mode 100644 index d832d1bffb2..00000000000 --- a/source/rpcclient/display_reg.c +++ /dev/null @@ -1,168 +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" - - -/**************************************************************************** -convert a security permissions into a string -****************************************************************************/ -char *get_reg_val_type_str(uint32 type) -{ - static fstring typestr; - - switch (type) - { - case 0x01: - { - fstrcpy(typestr, "string"); - return typestr; - } - - case 0x03: - { - fstrcpy(typestr, "bytes"); - return typestr; - } - - case 0x04: - { - fstrcpy(typestr, "uint32"); - return typestr; - } - - case 0x07: - { - fstrcpy(typestr, "multi"); - return typestr; - } - default: - { - break; - } - } - slprintf(typestr, sizeof(typestr)-1, "[%d]", type); - return typestr; -} - - -static void print_reg_value(FILE *out_hnd, const char *val_name, - uint32 val_type, const BUFFER2 *value) -{ - fstring type; - fstring valstr; - - fstrcpy(type, get_reg_val_type_str(val_type)); - - switch (val_type) - { - case 0x01: /* unistr */ - { - unibuf_to_ascii(valstr, value->buffer, - MIN(value->buf_len, sizeof(valstr)-1)); - report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr); - break; - } - - default: /* unknown */ - case 0x03: /* bytes */ - { - if (value->buf_len <= 8) - { - report(out_hnd, "\t%s:\t%s:\t", val_name, type); - out_data(out_hnd, (const char*)value->buffer, - value->buf_len, 8); - } - else - { - report(out_hnd, "\t%s:\t%s:\n", val_name, type); - out_data(out_hnd, (const char*)value->buffer, - value->buf_len, 16); - } - break; - } - - case 0x04: /* uint32 */ - { - report(out_hnd, "\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value)); - break; - } - - case 0x07: /* multiunistr */ - { - buffer2_to_multistr(valstr, value, sizeof(valstr)-1); - report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr); - break; - } - } -} - -/**************************************************************************** - display structure - ****************************************************************************/ -void display_reg_value_info(FILE *out_hnd, enum action_type action, - const char *val_name, - uint32 val_type, const BUFFER2 *value) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - print_reg_value(out_hnd, val_name, val_type, value); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display structure - ****************************************************************************/ -void display_reg_key_info(FILE *out_hnd, enum action_type action, - const char *key_name, time_t key_mod_time) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\t%s\t(%s)\n", - key_name, http_timestring(key_mod_time)); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - diff --git a/source/rpcclient/display_sam.c b/source/rpcclient/display_sam.c deleted file mode 100644 index 59bb2bfa54d..00000000000 --- a/source/rpcclient/display_sam.c +++ /dev/null @@ -1,685 +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" - -/**************************************************************************** - display alias members - ****************************************************************************/ -void display_alias_members(FILE *out_hnd, enum action_type action, - uint32 num_mem, char *const *const sid_mem, - uint8 *const type) -{ - switch (action) - { - case ACTION_HEADER: - { - if (num_mem == 0) - { - report(out_hnd, "\tNo Alias Members\n"); - } - else - { - report(out_hnd, "\tAlias Members:\n"); - report(out_hnd, "\t-------------\n"); - } - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < num_mem; i++) - { - if (sid_mem[i] != NULL) - { - report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n", - sid_mem[i], - get_sid_name_use_str(type[i])); - } - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - - -/**************************************************************************** - display alias rid info - ****************************************************************************/ -void display_alias_rid_info(FILE *out_hnd, enum action_type action, - DOM_SID *const sid, - uint32 num_rids, uint32 *const rid) -{ - switch (action) - { - case ACTION_HEADER: - { - fstring sid_str; - sid_to_string(sid_str, sid); - if (num_rids == 0) - { - report(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str); - } - else - { - report(out_hnd, "\tAlias Info:\tSid %s\n", sid_str); - report(out_hnd, "\t----------\n"); - } - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < num_rids; i++) - { - report(out_hnd, "\tAlias RID:\t%8x\n", rid[i]); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display group members - ****************************************************************************/ -void display_group_members(FILE *out_hnd, enum action_type action, - uint32 num_mem, char *const *const name, uint32 *const type) -{ - switch (action) - { - case ACTION_HEADER: - { - if (num_mem == 0) - { - report(out_hnd, "\tNo Members\n"); - } - else - { - report(out_hnd, "\tMembers:\n"); - report(out_hnd, "\t-------\n"); - } - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < num_mem; i++) - { - report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n", - name[i], get_sid_name_use_str(type[i])); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - - -/**************************************************************************** - display group info - ****************************************************************************/ -void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *const info1) - -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - fstring temp; - - unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp)-1); - report(out_hnd, "\tGroup Name:\t%s\n", temp); - unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp)-1); - report(out_hnd, "\tDescription:\t%s\n", temp); - report(out_hnd, "\tunk1:%d\n", info1->unknown_1); - report(out_hnd, "\tNum Members:%d\n", info1->num_members); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display group info - ****************************************************************************/ -void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *const info4) - -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - fstring desc; - - unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc)-1); - report(out_hnd, "\tGroup Description:%s\n", - desc); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display sam sync structure - ****************************************************************************/ -void display_group_info_ctr(FILE *out_hnd, enum action_type action, - GROUP_INFO_CTR *const ctr) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tSAM Group Info\n"); - report(out_hnd, "\t--------------\n"); - - break; - } - case ACTION_ENUMERATE: - { - switch (ctr->switch_value1) - { - case 1: - { - display_group_info1(out_hnd, ACTION_HEADER , &ctr->group.info1); - display_group_info1(out_hnd, ACTION_ENUMERATE, &ctr->group.info1); - display_group_info1(out_hnd, ACTION_FOOTER , &ctr->group.info1); - break; - } - case 4: - { - display_group_info4(out_hnd, ACTION_HEADER , &ctr->group.info4); - display_group_info4(out_hnd, ACTION_ENUMERATE, &ctr->group.info4); - display_group_info4(out_hnd, ACTION_FOOTER , &ctr->group.info4); - break; - } - } - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display group rid info - ****************************************************************************/ -void display_group_rid_info(FILE *out_hnd, enum action_type action, - uint32 num_gids, DOM_GID *const gid) -{ - switch (action) - { - case ACTION_HEADER: - { - if (num_gids == 0) - { - report(out_hnd, "\tNo Groups\n"); - } - else - { - report(out_hnd, "\tGroup Info\n"); - report(out_hnd, "\t----------\n"); - } - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < num_gids; i++) - { - report(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n", - gid[i].g_rid, gid[i].attr); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - - -/**************************************************************************** - display alias name info - ****************************************************************************/ -void display_alias_name_info(FILE *out_hnd, enum action_type action, - uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs) -{ - switch (action) - { - case ACTION_HEADER: - { - if (num_aliases == 0) - { - report(out_hnd, "\tNo Aliases\n"); - } - else - { - report(out_hnd, "\tAlias Names\n"); - report(out_hnd, "\t----------- \n"); - } - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < num_aliases; i++) - { - report(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n", - alias_name[i], num_als_usrs[i]); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display alias info - ****************************************************************************/ -void display_alias_info3(FILE *out_hnd, enum action_type action, ALIAS_INFO3 *const info3) - -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - fstring temp; - - unistr2_to_ascii(temp, &info3->uni_acct_desc, sizeof(temp)-1); - report(out_hnd, "\tDescription:\t%s\n", temp); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display sam sync structure - ****************************************************************************/ -void display_alias_info_ctr(FILE *out_hnd, enum action_type action, - ALIAS_INFO_CTR *const ctr) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tSAM Group Info\n"); - report(out_hnd, "\t--------------\n"); - - break; - } - case ACTION_ENUMERATE: - { - switch (ctr->switch_value1) - { - case 3: - { - display_alias_info3(out_hnd, ACTION_HEADER , &ctr->alias.info3); - display_alias_info3(out_hnd, ACTION_ENUMERATE, &ctr->alias.info3); - display_alias_info3(out_hnd, ACTION_FOOTER , &ctr->alias.info3); - break; - } - } - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - - -/**************************************************************************** - display sam_user_info_21 structure - ****************************************************************************/ -void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tUser Info, Level 0x15\n"); - report(out_hnd, "\t---------------------\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring temp; - - unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp)-1); - report(out_hnd, "\t\tUser Name :\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp)-1); - report(out_hnd, "\t\tFull Name :\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp)-1); - report(out_hnd, "\t\tHome Drive :\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp)-1); - report(out_hnd, "\t\tDir Drive :\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp)-1); - report(out_hnd, "\t\tProfile Path:\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp)-1); - report(out_hnd, "\t\tLogon Script:\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp)-1); - report(out_hnd, "\t\tDescription :\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp)-1); - report(out_hnd, "\t\tWorkstations:\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_unknown_str, sizeof(temp)-1); - report(out_hnd, "\t\tUnknown Str :\t%s\n", temp); - - unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp)-1); - report(out_hnd, "\t\tRemote Dial :\t%s\n", temp); - - report(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time )))); - report(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time )))); - report(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time )))); - report(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time )))); - report(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time )))); - report(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time)))); - - report(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */ - - report(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */ - report(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */ - report(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */ - - report(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */ - report(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */ - report(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */ - - report(out_hnd, "\t\tpadding1[0..7]...\n"); - - if (usr->ptr_logon_hrs) - { - report(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - - -/**************************************************************************** - display sam sync structure - ****************************************************************************/ -void display_sam_unk_info_2(FILE *out_hnd, enum action_type action, - SAM_UNK_INFO_2 *const info2) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - fstring name; - unistr2_to_ascii(name, &(info2->uni_domain), sizeof(name)-1); - report(out_hnd, "Domain:\t%s\n", name); - - unistr2_to_ascii(name, &(info2->uni_server), sizeof(name)-1); - report(out_hnd, "Server:\t%s\n", name); - - report(out_hnd, "Total Users:\t%d\n", info2->num_domain_usrs); - report(out_hnd, "Total Groups:\t%d\n", info2->num_domain_grps); - report(out_hnd, "Total Aliases:\t%d\n", info2->num_local_grps); - - report(out_hnd, "Sequence No:\t%d\n", info2->seq_num); - - report(out_hnd, "Unknown 0:\t0x%x\n", info2->unknown_0); - report(out_hnd, "Unknown 1:\t0x%x\n", info2->unknown_1); - report(out_hnd, "Unknown 2:\t0x%x\n", info2->unknown_2); - report(out_hnd, "Unknown 3:\t0x%x\n", info2->unknown_3); - report(out_hnd, "Unknown 4:\t0x%x\n", info2->unknown_4); - report(out_hnd, "Unknown 5:\t0x%x\n", info2->unknown_5); - report(out_hnd, "Unknown 6:\t0x%x\n", info2->unknown_6); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display sam sync structure - ****************************************************************************/ -void display_sam_unk_ctr(FILE *out_hnd, enum action_type action, - uint32 switch_value, SAM_UNK_CTR *const ctr) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tSAM Domain Info\n"); - report(out_hnd, "\t---------------\n"); - - break; - } - case ACTION_ENUMERATE: - { - switch (switch_value) - { - case 2: - { - display_sam_unk_info_2(out_hnd, ACTION_HEADER , &ctr->info.inf2); - display_sam_unk_info_2(out_hnd, ACTION_ENUMERATE, &ctr->info.inf2); - display_sam_unk_info_2(out_hnd, ACTION_FOOTER , &ctr->info.inf2); - break; - } - } - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** -sam info level 1 display function -****************************************************************************/ -void display_sam_info_1(FILE *out_hnd, enum action_type action, - SAM_ENTRY1 *const e1, SAM_STR1 *const s1) -{ - if (e1 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Sam Level 1:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring tmp; - - report(out_hnd, "\tIndex:\t%d\n", e1->user_idx); - report(out_hnd, "\tRID:\t0x%x\n", e1->rid_user); - report(out_hnd, "\tACB:\t%s\n", - pwdb_encode_acct_ctrl(e1->acb_info, - NEW_PW_FORMAT_SPACE_PADDED_LEN)); - - unistr_to_ascii(tmp, s1->uni_acct_name.buffer, sizeof(tmp)-1); - report(out_hnd, "\tAccount Name:\t%s\n", tmp); - unistr_to_ascii(tmp, s1->uni_full_name.buffer, sizeof(tmp)-1); - report(out_hnd, "\tFull Name:\t%s\n", tmp); - unistr_to_ascii(tmp, s1->uni_acct_desc.buffer, sizeof(tmp)-1); - report(out_hnd, "\tUser Description:\t%s\n", tmp); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -connection info level 1 container display function -****************************************************************************/ -void display_sam_info_1_ctr(FILE *out_hnd, enum action_type action, - uint32 count, SAM_DISPINFO_1 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_sam_info_1_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < count; i++) - { - display_sam_info_1(out_hnd, ACTION_HEADER , &ctr->sam[i], &ctr->str[i]); - display_sam_info_1(out_hnd, ACTION_ENUMERATE, &ctr->sam[i], &ctr->str[i]); - display_sam_info_1(out_hnd, ACTION_FOOTER , &ctr->sam[i], &ctr->str[i]); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info container display function -****************************************************************************/ -void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action, - uint16 level, uint32 count, - SAM_DISPINFO_CTR *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_sam_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (level) - { - case 1: - { - display_sam_info_1_ctr(out_hnd, action, - count, ctr->sam.info1); - break; - } - default: - { - report(out_hnd, "display_sam_info_ctr: Unknown Info Level\n"); - break; - } - } -} - diff --git a/source/rpcclient/display_sec.c b/source/rpcclient/display_sec.c deleted file mode 100644 index b29a27fefaa..00000000000 --- a/source/rpcclient/display_sec.c +++ /dev/null @@ -1,232 +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" - - -/**************************************************************************** -convert a security permissions into a string -****************************************************************************/ -char *get_sec_mask_str(uint32 type) -{ - static fstring typestr; - int i; - - switch (type) - { - case SEC_RIGHTS_FULL_CONTROL: - { - fstrcpy(typestr, "Full Control"); - return typestr; - } - - case SEC_RIGHTS_READ: - { - fstrcpy(typestr, "Read"); - return typestr; - } - default: - { - break; - } - } - - typestr[0] = 0; - for (i = 0; i < 32; i++) - { - if (IS_BITS_SET_ALL(type, 1 << i)) - { - switch (1 << i) - { - case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break; - case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break; - case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break; - case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break; - case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break; - case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break; - case SEC_RIGHTS_DELETE : fstrcat(typestr, "Delete "); break; - case SEC_RIGHTS_READ_CONTROL : fstrcat(typestr, "ReadControl "); break; - case SEC_RIGHTS_WRITE_DAC : fstrcat(typestr, "WriteDAC "); break; - case SEC_RIGHTS_WRITE_OWNER : fstrcat(typestr, "WriteOwner "); break; - } - type &= ~(1 << i); - } - } - - /* remaining bits get added on as-is */ - if (type != 0) - { - fstring tmp; - slprintf(tmp, sizeof(tmp)-1, "[%08x]", type); - fstrcat(typestr, tmp); - } - - /* remove last space */ - i = strlen(typestr)-1; - if (typestr[i] == ' ') typestr[i] = 0; - - return typestr; -} - -/**************************************************************************** - display sec_access structure - ****************************************************************************/ -void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *const info) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\t\tPermissions:\t%s\n", - get_sec_mask_str(info->mask)); - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display sec_ace structure - ****************************************************************************/ -void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *const ace) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tACE\n"); - break; - } - case ACTION_ENUMERATE: - { - fstring sid_str; - - display_sec_access(out_hnd, ACTION_HEADER , &ace->info); - display_sec_access(out_hnd, ACTION_ENUMERATE, &ace->info); - display_sec_access(out_hnd, ACTION_FOOTER , &ace->info); - - sid_to_string(sid_str, &ace->sid); - report(out_hnd, "\t\tSID:\t%s\n", sid_str); - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display sec_acl structure - ****************************************************************************/ -void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_acl) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n", - sec_acl->num_aces, sec_acl->revision); - report(out_hnd, "\t---\n"); - - break; - } - case ACTION_ENUMERATE: - { - if (sec_acl->size != 0 && sec_acl->num_aces != 0) - { - int i; - for (i = 0; i < sec_acl->num_aces; i++) - { - display_sec_ace(out_hnd, ACTION_HEADER , &sec_acl->ace[i]); - display_sec_ace(out_hnd, ACTION_ENUMERATE, &sec_acl->ace[i]); - display_sec_ace(out_hnd, ACTION_FOOTER , &sec_acl->ace[i]); - } - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display sec_desc structure - ****************************************************************************/ -void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n", - sec->revision, sec->type); - report(out_hnd, "\t-------------------\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring sid_str; - - if (sec->off_sacl != 0) - { - display_sec_acl(out_hnd, ACTION_HEADER , sec->sacl); - display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->sacl); - display_sec_acl(out_hnd, ACTION_FOOTER , sec->sacl); - } - if (sec->off_dacl != 0) - { - display_sec_acl(out_hnd, ACTION_HEADER , sec->dacl); - display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->dacl); - display_sec_acl(out_hnd, ACTION_FOOTER , sec->dacl); - } - if (sec->off_owner_sid != 0) - { - sid_to_string(sid_str, sec->owner_sid); - report(out_hnd, "\tOwner SID:\t%s\n", sid_str); - } - if (sec->off_grp_sid != 0) - { - sid_to_string(sid_str, sec->grp_sid); - report(out_hnd, "\tParent SID:\t%s\n", sid_str); - } - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - diff --git a/source/rpcclient/display_spool.c b/source/rpcclient/display_spool.c deleted file mode 100644 index 252fc881568..00000000000 --- a/source/rpcclient/display_spool.c +++ /dev/null @@ -1,457 +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" - -/**************************************************************************** -printer info level 0 display function -****************************************************************************/ -void display_print_info_0(FILE *out_hnd, enum action_type action, - PRINTER_INFO_0 *const i0) -{ - if (i0 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Printer Info Level 0:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring name; - fstring serv; - - unistr_to_ascii(name, i0->printername.buffer, sizeof(name)-1); - unistr_to_ascii(serv, i0->servername .buffer, sizeof(serv)-1); - - report(out_hnd, "\tprinter name:\t%s\n", name); - report(out_hnd, "\tserver name:\t%s\n", serv); - report(out_hnd, "\t[Other info not displayed]\n"); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -printer info level 1 display function -****************************************************************************/ -void display_print_info_1(FILE *out_hnd, enum action_type action, - PRINTER_INFO_1 *const i1) -{ - if (i1 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Printer Info Level 1:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring desc; - fstring name; - fstring comm; - - unistr_to_ascii(desc, i1->description.buffer, sizeof(desc)-1); - unistr_to_ascii(name, i1->name .buffer, sizeof(name)-1); - unistr_to_ascii(comm, i1->comment .buffer, sizeof(comm)-1); - - report(out_hnd, "\tflags:\t%d\n", i1->flags); - report(out_hnd, "\tname:\t%s\n", name); - report(out_hnd, "\tdescription:\t%s\n", desc); - report(out_hnd, "\tcomment:\t%s\n", comm); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -connection info level 0 container display function -****************************************************************************/ -void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action, - uint32 count, PRINTER_INFO_0 *const *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_printer_info_0_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < count; i++) - { - display_print_info_0(out_hnd, ACTION_HEADER , ctr[i]); - display_print_info_0(out_hnd, ACTION_ENUMERATE, ctr[i]); - display_print_info_0(out_hnd, ACTION_FOOTER , ctr[i]); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info level 1 container display function -****************************************************************************/ -void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action, - uint32 count, PRINTER_INFO_1 *const *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_printer_info_1_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < count; i++) - { - display_print_info_1(out_hnd, ACTION_HEADER , ctr[i]); - display_print_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]); - display_print_info_1(out_hnd, ACTION_FOOTER , ctr[i]); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info container display function -****************************************************************************/ -void display_printer_info_ctr(FILE *out_hnd, enum action_type action, - uint32 level, uint32 count, - void *const *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (level) - { - case 0: - { - display_printer_info_0_ctr(out_hnd, action, - count, (PRINTER_INFO_0*const*const)ctr); - break; - } - case 1: - { - display_printer_info_1_ctr(out_hnd, action, - count, (PRINTER_INFO_1*const*const)ctr); - break; - } - default: - { - report(out_hnd, "display_printer_info_ctr: Unknown Info Level\n"); - break; - } - } -} - -/**************************************************************************** -job info level 2 display function -****************************************************************************/ -void display_job_info_2(FILE *out_hnd, enum action_type action, - JOB_INFO_2 *const i2) -{ - if (i2 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Job Info Level 2:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring tmp; - - report(out_hnd, "\tjob id:\t%d\n", i2->jobid); - unistr_to_ascii(tmp, i2->printername.buffer, sizeof(tmp)-1); - report(out_hnd, "\tprinter name:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->machinename.buffer, sizeof(tmp)-1); - report(out_hnd, "\tmachine name:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->username.buffer, sizeof(tmp)-1); - report(out_hnd, "\tusername:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->document.buffer, sizeof(tmp)-1); - report(out_hnd, "\tdocument:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->notifyname.buffer, sizeof(tmp)-1); - report(out_hnd, "\tnotify name:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->datatype.buffer, sizeof(tmp)-1); - report(out_hnd, "\tdata type:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->printprocessor.buffer, sizeof(tmp)-1); - report(out_hnd, "\tprint processor:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->parameters.buffer, sizeof(tmp)-1); - report(out_hnd, "\tparameters:\t%s\n", tmp); - unistr_to_ascii(tmp, i2->drivername.buffer, sizeof(tmp)-1); - report(out_hnd, "\tdriver name:\t%s\n", tmp); - report(out_hnd, "\tDevice Mode:\tNOT DISPLAYED YET\n"); -/* - DEVICEMODE *devmode; -*/ - unistr_to_ascii(tmp, i2->text_status.buffer, sizeof(tmp)-1); - report(out_hnd, "\ttext status:\t%s\n", tmp); - /* SEC_DESC sec_desc;*/ - report(out_hnd, "\tstatus:\t%d\n", i2->status); - report(out_hnd, "\tpriority:\t%d\n", i2->priority); - report(out_hnd, "\tposition:\t%d\n", i2->position); - report(out_hnd, "\tstarttime:\t%d\n", i2->starttime); - report(out_hnd, "\tuntiltime:\t%d\n", i2->untiltime); - report(out_hnd, "\ttotalpages:\t%d\n", i2->totalpages); - report(out_hnd, "\tsize:\t%d\n", i2->size); -/* - SYSTEMTIME submitted; -*/ - report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n"); - report(out_hnd, "\ttimeelapsed:\t%d\n", i2->timeelapsed); - report(out_hnd, "\tpagesprinted:\t%d\n", i2->pagesprinted); - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -job info level 1 display function -****************************************************************************/ -void display_job_info_1(FILE *out_hnd, enum action_type action, - JOB_INFO_1 *const i1) -{ - if (i1 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Job Info Level 1:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring tmp; - - report(out_hnd, "\tjob id:\t%d\n", i1->jobid); - unistr_to_ascii(tmp, i1->printername.buffer, sizeof(tmp)-1); - report(out_hnd, "\tprinter name:\t%s\n", tmp); - unistr_to_ascii(tmp, i1->machinename.buffer, sizeof(tmp)-1); - report(out_hnd, "\tmachine name:\t%s\n", tmp); - unistr_to_ascii(tmp, i1->username.buffer, sizeof(tmp)-1); - report(out_hnd, "\tusername:\t%s\n", tmp); - unistr_to_ascii(tmp, i1->document.buffer, sizeof(tmp)-1); - report(out_hnd, "\tdocument:\t%s\n", tmp); - unistr_to_ascii(tmp, i1->datatype.buffer, sizeof(tmp)-1); - report(out_hnd, "\tdata type:\t%s\n", tmp); - unistr_to_ascii(tmp, i1->text_status.buffer, sizeof(tmp)-1); - report(out_hnd, "\ttext status:\t%s\n", tmp); - report(out_hnd, "\tstatus:\t%d\n", i1->status); - report(out_hnd, "\tpriority:\t%d\n", i1->priority); - report(out_hnd, "\tposition:\t%d\n", i1->position); - report(out_hnd, "\ttotalpages:\t%d\n", i1->totalpages); -/* - SYSTEMTIME submitted; -*/ - report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n"); - report(out_hnd, "\tpagesprinted:\t%d\n", i1->pagesprinted); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -connection info level 2 container display function -****************************************************************************/ -void display_job_info_2_ctr(FILE *out_hnd, enum action_type action, - uint32 count, JOB_INFO_2 *const *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_job_info_2_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < count; i++) - { - display_job_info_2(out_hnd, ACTION_HEADER , ctr[i]); - display_job_info_2(out_hnd, ACTION_ENUMERATE, ctr[i]); - display_job_info_2(out_hnd, ACTION_FOOTER , ctr[i]); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info level 1 container display function -****************************************************************************/ -void display_job_info_1_ctr(FILE *out_hnd, enum action_type action, - uint32 count, JOB_INFO_1 *const *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_job_info_1_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < count; i++) - { - display_job_info_1(out_hnd, ACTION_HEADER , ctr[i]); - display_job_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]); - display_job_info_1(out_hnd, ACTION_FOOTER , ctr[i]); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info container display function -****************************************************************************/ -void display_job_info_ctr(FILE *out_hnd, enum action_type action, - uint32 level, uint32 count, - void *const *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_job_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (level) - { - case 1: - { - display_job_info_1_ctr(out_hnd, action, - count, (JOB_INFO_1*const*const)ctr); - break; - } - case 2: - { - display_job_info_2_ctr(out_hnd, action, - count, (JOB_INFO_2*const*const)ctr); - break; - } - default: - { - report(out_hnd, "display_job_info_ctr: Unknown Info Level\n"); - break; - } - } -} diff --git a/source/rpcclient/display_srv.c b/source/rpcclient/display_srv.c deleted file mode 100644 index f0069c0d532..00000000000 --- a/source/rpcclient/display_srv.c +++ /dev/null @@ -1,1198 +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" - - -struct field_info sid_name_info[] = -{ - { SID_NAME_UNKNOWN, "UNKNOWN" }, /* default */ - { SID_NAME_USER , "User" }, - { SID_NAME_DOM_GRP, "Domain Group" }, - { SID_NAME_DOMAIN , "Domain" }, - { SID_NAME_ALIAS , "Local Group" }, - { SID_NAME_WKN_GRP, "Well-known Group"}, - { SID_NAME_DELETED, "Deleted" }, - { SID_NAME_INVALID, "Invalid" }, - { 0 , NULL } -}; - -/**************************************************************************** -convert a SID_NAME_USE to a string -****************************************************************************/ -char *get_sid_name_use_str(uint8 sid_name_use) -{ - return enum_field_to_str((uint32)sid_name_use, sid_name_info, True); -} - -/**************************************************************************** -convert a share mode to a string -****************************************************************************/ -char *get_file_mode_str(uint32 share_mode) -{ - static fstring mode; - - switch ((share_mode>>4)&0xF) - { - case DENY_NONE : fstrcpy(mode, "DENY_NONE "); break; - case DENY_ALL : fstrcpy(mode, "DENY_ALL "); break; - case DENY_DOS : fstrcpy(mode, "DENY_DOS "); break; - case DENY_READ : fstrcpy(mode, "DENY_READ "); break; - case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break; - default : fstrcpy(mode, "DENY_???? "); break; - } - - switch (share_mode & 0xF) - { - case 0 : fstrcat(mode, "RDONLY"); break; - case 1 : fstrcat(mode, "WRONLY"); break; - case 2 : fstrcat(mode, "RDWR "); break; - default: fstrcat(mode, "R??W??"); break; - } - - return mode; -} - -/**************************************************************************** -convert an oplock mode to a string -****************************************************************************/ -char *get_file_oplock_str(uint32 op_type) -{ - static fstring oplock; - BOOL excl = IS_BITS_SET_ALL(op_type, EXCLUSIVE_OPLOCK); - BOOL batch = IS_BITS_SET_ALL(op_type, BATCH_OPLOCK ); - - oplock[0] = 0; - - if (excl ) fstrcat(oplock, "EXCLUSIVE"); - if (excl && batch) fstrcat(oplock, "+"); - if ( batch) fstrcat(oplock, "BATCH"); - if (!excl && !batch) fstrcat(oplock, "NONE"); - - return oplock; -} - -/**************************************************************************** -convert a share type enum to a string -****************************************************************************/ -char *get_share_type_str(uint32 type) -{ - static fstring typestr; - - switch (type) - { - case STYPE_DISKTREE: fstrcpy(typestr, "Disk" ); break; - case STYPE_PRINTQ : fstrcpy(typestr, "Printer"); break; - case STYPE_DEVICE : fstrcpy(typestr, "Device" ); break; - case STYPE_IPC : fstrcpy(typestr, "IPC" ); break; - default : fstrcpy(typestr, "????" ); break; - } - return typestr; -} - -/**************************************************************************** -convert a server type enum to a string -****************************************************************************/ -char *get_server_type_str(uint32 type) -{ - static fstring typestr; - - if (type == SV_TYPE_ALL) - { - fstrcpy(typestr, "All"); - } - else - { - int i; - typestr[0] = 0; - for (i = 0; i < 32; i++) - { - if (IS_BITS_SET_ALL(type, 1 << i)) - { - switch (1 << i) - { - case SV_TYPE_WORKSTATION : fstrcat(typestr, "Wk " ); break; - case SV_TYPE_SERVER : fstrcat(typestr, "Sv " ); break; - case SV_TYPE_SQLSERVER : fstrcat(typestr, "Sql "); break; - case SV_TYPE_DOMAIN_CTRL : fstrcat(typestr, "PDC "); break; - case SV_TYPE_DOMAIN_BAKCTRL : fstrcat(typestr, "BDC "); break; - case SV_TYPE_TIME_SOURCE : fstrcat(typestr, "Tim "); break; - case SV_TYPE_AFP : fstrcat(typestr, "AFP "); break; - case SV_TYPE_NOVELL : fstrcat(typestr, "Nov "); break; - case SV_TYPE_DOMAIN_MEMBER : fstrcat(typestr, "Dom "); break; - case SV_TYPE_PRINTQ_SERVER : fstrcat(typestr, "PrQ "); break; - case SV_TYPE_DIALIN_SERVER : fstrcat(typestr, "Din "); break; - case SV_TYPE_SERVER_UNIX : fstrcat(typestr, "Unx "); break; - case SV_TYPE_NT : fstrcat(typestr, "NT " ); break; - case SV_TYPE_WFW : fstrcat(typestr, "Wfw "); break; - case SV_TYPE_SERVER_MFPN : fstrcat(typestr, "Mfp "); break; - case SV_TYPE_SERVER_NT : fstrcat(typestr, "SNT "); break; - case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break; - case SV_TYPE_BACKUP_BROWSER : fstrcat(typestr, "BMB "); break; - case SV_TYPE_MASTER_BROWSER : fstrcat(typestr, "LMB "); break; - case SV_TYPE_DOMAIN_MASTER : fstrcat(typestr, "DMB "); break; - case SV_TYPE_SERVER_OSF : fstrcat(typestr, "OSF "); break; - case SV_TYPE_SERVER_VMS : fstrcat(typestr, "VMS "); break; - case SV_TYPE_WIN95_PLUS : fstrcat(typestr, "W95 "); break; - case SV_TYPE_ALTERNATE_XPORT : fstrcat(typestr, "Xpt "); break; - case SV_TYPE_LOCAL_LIST_ONLY : fstrcat(typestr, "Dom "); break; - case SV_TYPE_DOMAIN_ENUM : fstrcat(typestr, "Loc "); break; - } - } - } - i = strlen(typestr)-1; - if (typestr[i] == ' ') typestr[i] = 0; - - } - return typestr; -} - -/**************************************************************************** -server info level 101 display function -****************************************************************************/ -void display_srv_info_101(FILE *out_hnd, enum action_type action, - SRV_INFO_101 *const sv101) -{ - if (sv101 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Server Info Level 101:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring name; - fstring comment; - - unistr2_to_ascii(name, &sv101->uni_name, sizeof(name)-1); - unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment)-1); - - display_server(out_hnd, action, name, sv101->srv_type, comment); - - report(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id); - report(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor); - - break; - } - case ACTION_FOOTER: - { - break; - } - } - -} - -/**************************************************************************** -server info level 102 display function -****************************************************************************/ -void display_srv_info_102(FILE *out_hnd, enum action_type action, SRV_INFO_102 *const sv102) -{ - if (sv102 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Server Info Level 102:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring name; - fstring comment; - fstring usr_path; - - unistr2_to_ascii(name, &sv102->uni_name, sizeof(name)-1); - unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment)-1); - unistr2_to_ascii(usr_path, &sv102->uni_usr_path, - sizeof(usr_path)-1); - - display_server(out_hnd, action, name, sv102->srv_type, comment); - - report(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id); - report(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor); - - report(out_hnd, "\tusers :\t%x\n" , sv102->users ); - report(out_hnd, "\tdisc, hidden :\t%x, %x\n" , sv102->disc , sv102->hidden ); - report(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta); - report(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses ); - report(out_hnd, "\tuser path :\t%s\n" , usr_path); - - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -server info container display function -****************************************************************************/ -void display_srv_info_ctr(FILE *out_hnd, enum action_type action, SRV_INFO_CTR *const ctr) -{ - if (ctr == NULL || ctr->ptr_srv_ctr == 0) - { - report(out_hnd, "Server Information: unavailable due to an error\n"); - return; - } - - switch (ctr->switch_value) - { - case 101: - { - display_srv_info_101(out_hnd, action, &(ctr->srv.sv101)); - break; - } - case 102: - { - display_srv_info_102(out_hnd, action, &(ctr->srv.sv102)); - break; - } - default: - { - report(out_hnd, "Server Information: Unknown Info Level\n"); - break; - } - } -} - -/**************************************************************************** -connection info level 0 display function -****************************************************************************/ -void display_conn_info_0(FILE *out_hnd, enum action_type action, - CONN_INFO_0 *const info0) -{ - if (info0 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Connection Info Level 0:\n"); - - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\tid:\t%d\n", info0->id); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -connection info level 1 display function -****************************************************************************/ -void display_conn_info_1(FILE *out_hnd, enum action_type action, - CONN_INFO_1 *const info1, CONN_INFO_1_STR *const str1) -{ - if (info1 == NULL || str1 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Connection Info Level 1:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring usr_name; - fstring net_name; - - unistr2_to_ascii(usr_name, &str1->uni_usr_name, sizeof(usr_name)-1); - unistr2_to_ascii(net_name, &str1->uni_net_name, sizeof(net_name)-1); - - report(out_hnd, "\tid :\t%d\n", info1->id); - report(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type)); - report(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens); - report(out_hnd, "\tnum_users:\t%d\n", info1->num_users); - report(out_hnd, "\topen_time:\t%d\n", info1->open_time); - - report(out_hnd, "\tuser name:\t%s\n", usr_name); - report(out_hnd, "\tnet name:\t%s\n", net_name); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -connection info level 0 container display function -****************************************************************************/ -void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action, - SRV_CONN_INFO_0 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_conn_info_0_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_conn_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i])); - display_conn_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i])); - display_conn_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info level 1 container display function -****************************************************************************/ -void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action, - SRV_CONN_INFO_1 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_conn_info_1_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_conn_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); - display_conn_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i])); - display_conn_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -connection info container display function -****************************************************************************/ -void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action, - SRV_CONN_INFO_CTR *const ctr) -{ - if (ctr == NULL || ctr->ptr_conn_ctr == 0) - { - report(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (ctr->switch_value) - { - case 0: - { - display_srv_conn_info_0_ctr(out_hnd, action, - &(ctr->conn.info0)); - break; - } - case 1: - { - display_srv_conn_info_1_ctr(out_hnd, action, - &(ctr->conn.info1)); - break; - } - default: - { - report(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n"); - break; - } - } -} - - -/**************************************************************************** -transport info level 0 display function -****************************************************************************/ -void display_tprt_info_0(FILE *out_hnd, enum action_type action, - TPRT_INFO_0 *const info0, TPRT_INFO_0_STR *const str0) -{ - if (info0 == NULL || str0 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Transport Info Level 0:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring trans_name; - fstring trans_addr; - fstring addr_name; - - unistr2_to_ascii(trans_name, &str0->uni_trans_name, sizeof(trans_name)-1); - buffer4_to_str(trans_addr, &str0->buf_trans_addr, sizeof(trans_addr)-1); - unistr2_to_ascii(addr_name, &str0->uni_addr_name, sizeof(addr_name)-1); - - report(out_hnd, "\tnum_vcs :\t%d\n", info0->num_vcs); - report(out_hnd, "\ttransport name:\t%s\n", trans_name); - report(out_hnd, "\ttransport addr:\t%s\n", trans_addr); - report(out_hnd, "\taddress name:\t%s\n", addr_name); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -transport info level 0 container display function -****************************************************************************/ -void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action, - const SRV_TPRT_INFO_0 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_tprt_info_0_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_tprt_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]), &(ctr->info_0_str[i])); - display_tprt_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]), &(ctr->info_0_str[i])); - display_tprt_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]), &(ctr->info_0_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -transport info container display function -****************************************************************************/ -void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action, - const SRV_TPRT_INFO_CTR *const ctr) -{ - if (ctr == NULL || ctr->ptr_tprt_ctr == 0) - { - report(out_hnd, "display_srv_tprt_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (ctr->switch_value) - { - case 0: - { - display_srv_tprt_info_0_ctr(out_hnd, action, - &(ctr->tprt.info0)); - break; - } - default: - { - report(out_hnd, "display_srv_tprt_info_ctr: Unknown Info Level\n"); - break; - } - } -} - - -/**************************************************************************** -share info level 1 display function -****************************************************************************/ -void display_share_info_1(FILE *out_hnd, enum action_type action, - SH_INFO_1 *const info1, SH_INFO_1_STR *const str1) -{ - if (info1 == NULL || str1 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Share Info Level 1:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring remark ; - fstring net_name; - - unistr2_to_ascii(net_name, &str1->uni_netname, sizeof(net_name)-1); - unistr2_to_ascii(remark, &str1->uni_remark, sizeof(remark)-1); - - display_share(out_hnd, action, net_name, info1->type, remark); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -share info level 2 display function -****************************************************************************/ -void display_share_info_2(FILE *out_hnd, enum action_type action, - SH_INFO_2 *const info2, SH_INFO_2_STR *const str2) -{ - if (info2 == NULL || str2 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Share Info Level 2:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring remark ; - fstring net_name; - fstring path ; - fstring password; - - unistr2_to_ascii(net_name, &str2->uni_netname, sizeof(net_name)-1); - unistr2_to_ascii(remark, &str2->uni_remark, sizeof(remark)-1); - unistr2_to_ascii(path, &str2->uni_path, sizeof(path)-1); - unistr2_to_ascii(password, &str2->uni_passwd, sizeof(password)-1); - - display_share2(out_hnd, action, net_name, info2->type, remark, - info2->perms, info2->max_uses, info2->num_uses, - path, password); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -share info level 1 container display function -****************************************************************************/ -void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action, - SRV_SHARE_INFO_1 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_share_info_1_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_share_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); - display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i])); - display_share_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -share info level 2 container display function -****************************************************************************/ -void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action, - SRV_SHARE_INFO_2 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_share_info_2_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_share_info_2(out_hnd, ACTION_HEADER , &(ctr->info_2[i]), &(ctr->info_2_str[i])); - display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->info_2[i]), &(ctr->info_2_str[i])); - display_share_info_2(out_hnd, ACTION_FOOTER , &(ctr->info_2[i]), &(ctr->info_2_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -share info container display function -****************************************************************************/ -void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action, - SRV_SHARE_INFO_CTR *const ctr) -{ - if (ctr == NULL || ctr->ptr_share_ctr == 0) - { - report(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (ctr->switch_value) - { - case 1: - { - display_srv_share_info_1_ctr(out_hnd, action, - &(ctr->share.info1)); - break; - } - case 2: - { - display_srv_share_info_2_ctr(out_hnd, action, - &(ctr->share.info2)); - break; - } - default: - { - report(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n"); - break; - } - } -} - - -/**************************************************************************** -file info level 3 display function -****************************************************************************/ -void display_file_info_3(FILE *out_hnd, enum action_type action, - FILE_INFO_3 *const info3, FILE_INFO_3_STR *const str3) -{ - if (info3 == NULL || str3 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "File Info Level 3:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring path_name; - fstring user_name; - - unistr2_to_ascii(path_name, &str3->uni_path_name, - sizeof(path_name)-1); - unistr2_to_ascii(user_name, &str3->uni_user_name, - sizeof(user_name)-1); - - report(out_hnd, "\tid :\t%d\n", info3->id); - report(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms)); - report(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks); - - report(out_hnd, "\tpath name:\t%s\n", path_name); - report(out_hnd, "\tuser name:\t%s\n", user_name); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -file info level 3 container display function -****************************************************************************/ -void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action, - SRV_FILE_INFO_3 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_file_info_3_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_file_info_3(out_hnd, ACTION_HEADER , &(ctr->info_3[i]), &(ctr->info_3_str[i])); - display_file_info_3(out_hnd, ACTION_ENUMERATE, &(ctr->info_3[i]), &(ctr->info_3_str[i])); - display_file_info_3(out_hnd, ACTION_FOOTER , &(ctr->info_3[i]), &(ctr->info_3_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -file info container display function -****************************************************************************/ -void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action, - SRV_FILE_INFO_CTR *const ctr) -{ - if (ctr == NULL || ctr->ptr_file_ctr == 0) - { - report(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (ctr->switch_value) - { - case 3: - { - display_srv_file_info_3_ctr(out_hnd, action, - &(ctr->file.info3)); - break; - } - default: - { - report(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n"); - break; - } - } -} - -/**************************************************************************** -sess info level 0 display function -****************************************************************************/ -void display_sess_info_0(FILE *out_hnd, enum action_type action, - SESS_INFO_0 *const info0, SESS_INFO_0_STR *const str0) -{ - if (info0 == NULL || str0 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Session Info Level 0:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring name; - - unistr2_to_ascii(name, &str0->uni_name, - sizeof(name)-1); - - report(out_hnd, "\tname:\t%s\n", name); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -sess info level 1 display function -****************************************************************************/ -void display_sess_info_1(FILE *out_hnd, enum action_type action, - SESS_INFO_1 *const info1, SESS_INFO_1_STR *const str1) -{ - if (info1 == NULL || str1 == NULL) - { - return; - } - - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "Session Info Level 1:\n"); - - break; - } - case ACTION_ENUMERATE: - { - fstring name; - fstring user_name; - - unistr2_to_ascii(user_name, &str1->uni_user, - sizeof(user_name)-1); - unistr2_to_ascii(name, &str1->uni_name, - sizeof(name)-1); - - report(out_hnd, "\tname:\t%s\n", name); - - report(out_hnd, "\topen :\t%d\n", info1->num_opens); - report(out_hnd, "\ttime :\t%d\n", info1->open_time); - report(out_hnd, "\tidle :\t%d\n", info1->idle_time); - report(out_hnd, "\tflags:\t%d\n", info1->user_flags); - - report(out_hnd, "\tuser :\t%s\n", user_name); - - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } - -} - -/**************************************************************************** -sess info level 0 container display function -****************************************************************************/ -void display_srv_sess_info_0_ctr(FILE *out_hnd, enum action_type action, - SRV_SESS_INFO_0 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_sess_info_0_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_sess_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]), &(ctr->info_0_str[i])); - display_sess_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]), &(ctr->info_0_str[i])); - display_sess_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]), &(ctr->info_0_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -sess info level 1 container display function -****************************************************************************/ -void display_srv_sess_info_1_ctr(FILE *out_hnd, enum action_type action, - SRV_SESS_INFO_1 *const ctr) -{ - if (ctr == NULL) - { - report(out_hnd, "display_srv_sess_info_1_ctr: unavailable due to an internal error\n"); - return; - } - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - int i; - - for (i = 0; i < ctr->num_entries_read; i++) - { - display_sess_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); - display_sess_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i])); - display_sess_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -sess info container display function -****************************************************************************/ -void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action, - SRV_SESS_INFO_CTR *const ctr) -{ - if (ctr == NULL || ctr->ptr_sess_ctr == 0) - { - report(out_hnd, "display_srv_sess_info_ctr: unavailable due to an internal error\n"); - return; - } - - switch (ctr->switch_value) - { - case 0: - { - display_srv_sess_info_0_ctr(out_hnd, action, - &(ctr->sess.info0)); - break; - } - case 1: - { - display_srv_sess_info_1_ctr(out_hnd, action, - &(ctr->sess.info1)); - break; - } - default: - { - report(out_hnd, "display_srv_sess_info_ctr: Unknown Info Level\n"); - break; - } - } -} - -/**************************************************************************** - print browse connection on a host - ****************************************************************************/ -void display_server(FILE *out_hnd, enum action_type action, - char *const sname, uint32 type, char *const comment) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\t%-15.15s%-20s %s\n", - sname, get_server_type_str(type), comment); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** -print shares on a host -****************************************************************************/ -void display_share(FILE *out_hnd, enum action_type action, - char *const sname, uint32 type, char *const comment) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\t%-15.15s%-10.10s%s\n", - sname, get_share_type_str(type), comment); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - - -/**************************************************************************** -print shares on a host, level 2 -****************************************************************************/ -void display_share2(FILE *out_hnd, enum action_type action, - char *const sname, uint32 type, char *const comment, - uint32 perms, uint32 max_uses, uint32 num_uses, - char *const path, char *const password) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n", - sname, get_share_type_str(type), comment, - perms, max_uses, num_uses, path, password); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - - -/**************************************************************************** -print name info -****************************************************************************/ -void display_name(FILE *out_hnd, enum action_type action, - char *const sname) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - report(out_hnd, "\t%-21.21s\n", sname); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - diff --git a/source/rpcclient/display_svc.c b/source/rpcclient/display_svc.c deleted file mode 100644 index 04b366a216d..00000000000 --- a/source/rpcclient/display_svc.c +++ /dev/null @@ -1,126 +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" - - -/**************************************************************************** -convert a security permissions into a string -****************************************************************************/ -char *get_svc_start_type_str(uint32 type) -{ - static fstring typestr; - - switch (type) - { - case 0x00: fstrcpy(typestr, "Boot" ); return typestr; - case 0x01: fstrcpy(typestr, "System" ); return typestr; - case 0x02: fstrcpy(typestr, "Auto" ); return typestr; - case 0x03: fstrcpy(typestr, "Manual" ); return typestr; - case 0x04: fstrcpy(typestr, "Disabled"); return typestr; - default : break; - } - slprintf(typestr, sizeof(typestr)-1, "[%d]", type); - return typestr; -} - - -/**************************************************************************** - display structure - ****************************************************************************/ -void display_query_svc_cfg(FILE *out_hnd, enum action_type action, - const QUERY_SERVICE_CONFIG *const cfg) -{ - switch (action) - { - case ACTION_HEADER: - { - fstring service; - - unistr2_to_ascii(service, &cfg->uni_display_name, sizeof(service)-1); - report(out_hnd, "\tService:\t%s\n", service); - report(out_hnd, "\t-------\n"); - break; - } - case ACTION_ENUMERATE: - { - fstring temp; - - unistr2_to_ascii(temp, &cfg->uni_bin_path_name, sizeof(temp)-1); - report(out_hnd, "\tPath:\t%s\n", temp); - - unistr2_to_ascii(temp, &cfg->uni_load_order_grp, sizeof(temp)-1); - report(out_hnd, "\tLoad Order:\t%s\n", temp); - - unistr2_to_ascii(temp, &cfg->uni_dependencies, sizeof(temp)-1); - report(out_hnd, "\tDependencies:\t%s\n", temp); - - unistr2_to_ascii(temp, &cfg->uni_service_start_name, sizeof(temp)-1); - report(out_hnd, "\tService Start:\t%s\n", temp); - - report(out_hnd, "\tService Type:\t%d\n", cfg->service_type); - report(out_hnd, "\tStart Type:\t%s\n" , get_svc_start_type_str(cfg->start_type)); - report(out_hnd, "\tError Control:\t%d\n" , cfg->error_control); - report(out_hnd, "\tTag Id:\t%d\n" , cfg->tag_id); - break; - - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - -/**************************************************************************** - display structure - ****************************************************************************/ -void display_svc_info(FILE *out_hnd, enum action_type action, - const ENUM_SRVC_STATUS *const svc) -{ - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - fstring name; - - unistr_to_ascii(name, svc->uni_srvc_name.buffer, - sizeof(name)-1); /* service name */ - report(out_hnd, "\t%s:", name); - - unistr_to_ascii(name, svc->uni_disp_name.buffer, - sizeof(name)-1); /* display name */ - report(out_hnd, "\t%s\n", name); - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - diff --git a/source/rpcclient/display_sync.c b/source/rpcclient/display_sync.c deleted file mode 100644 index 8250a96f021..00000000000 --- a/source/rpcclient/display_sync.c +++ /dev/null @@ -1,116 +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" - - -/**************************************************************************** - display sam sync structure - ****************************************************************************/ -void display_sam_sync_ctr(FILE *out_hnd, enum action_type action, - SAM_DELTA_HDR *const delta, - SAM_DELTA_CTR *const ctr) -{ - fstring name; - - switch (action) - { - case ACTION_HEADER: - { - break; - } - case ACTION_ENUMERATE: - { - switch (delta->type) - { - case 1: - { - unistr2_to_ascii(name, &(ctr->domain_info.uni_dom_name), sizeof(name)-1); - report(out_hnd, "Domain: %s\n", name); - break; - } - case 2: - { - unistr2_to_ascii(name, &(ctr->group_info.uni_grp_name), sizeof(name)-1); - report(out_hnd, "Group: %s\n", name); - break; - } - case 5: - { - unsigned char lm_pwd[16]; - unsigned char nt_pwd[16]; - - unistr2_to_ascii(name, &(ctr->account_info.uni_acct_name), sizeof(name)-1); - report(out_hnd, "Account: %s\n", name); - - sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_lm_pwd, lm_pwd, 0); - out_struct(out_hnd, lm_pwd, 16, 8); - - sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_nt_pwd, nt_pwd, 0); - out_struct(out_hnd, nt_pwd, 16, 8); - } - } - break; - } - case ACTION_FOOTER: - { - break; - } - } -} - -/**************************************************************************** - display sam sync structure - ****************************************************************************/ -void display_sam_sync(FILE *out_hnd, enum action_type action, - SAM_DELTA_HDR *const deltas, - SAM_DELTA_CTR *const ctr, - uint32 num) -{ - switch (action) - { - case ACTION_HEADER: - { - report(out_hnd, "\tSAM Database Sync\n"); - report(out_hnd, "\t-----------------\n"); - - break; - } - case ACTION_ENUMERATE: - { - int i; - for (i = 0; i < num; i++) - { - display_sam_sync_ctr(out_hnd, ACTION_HEADER , &deltas[i], &ctr[i]); - display_sam_sync_ctr(out_hnd, ACTION_ENUMERATE, &deltas[i], &ctr[i]); - display_sam_sync_ctr(out_hnd, ACTION_FOOTER , &deltas[i], &ctr[i]); - } - break; - } - case ACTION_FOOTER: - { - report(out_hnd, "\n"); - break; - } - } -} - diff --git a/source/samrd/samrd.c b/source/samrd/samrd.c deleted file mode 100644 index 40ebf45b518..00000000000 --- a/source/samrd/samrd.c +++ /dev/null @@ -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, "samr"); - slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name); - add_msrpc_command_processor( pipe_name, argv[0], api_samr_rpc ); - - return msrpc_main(argc, argv); -} diff --git a/source/script/mysql_convert.pl b/source/script/mysql_convert.pl deleted file mode 100644 index 1479ce62b78..00000000000 --- a/source/script/mysql_convert.pl +++ /dev/null @@ -1,433 +0,0 @@ -#!/bin/env perl -# -# MYSQL Convert - Creates and initialises mysql tables for use by samba -# -# 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. -# -# -# Converts smbpasswd files into MySQL tables. -# Can understand Samba 1.19 and Samba 2.0 file formats. -# Assumes table structure: -# unix_name char(20) not null, -# unix_uid int(10) unsigned not null, -# nt_name char(20) not null, -# user_rid int(10) unsigned not null, -# smb_passwd char(32), -# smb_nt_passwd char(32), -# acct_ctrl int(10) unsigned not null, -# pass_last_set_time int(10) unsigned not null, -# unique (unix_name), -# unique (unix_uid) -# When given the --create option, mysql_convert will generate this -# statement. -# -# To move from flat file smbpasswd directly into a mysql table: -# -# mysql_convert.pl --db=samba --table=smbpasswd --user=samba --create --infile=smbpasswd -# -# Assumes mysql server on localhost, use --host if otherwise. -# To convert back to flat file: -# -# mysql_convert.pl --db=samba --table=smbpasswd --user=samba --outfile=smbpasswd -# -# If smbpasswd file already exists, use --file=append or --file=trash -# to determine whether to append or over-right the file. -# -# In converting from NT Server PDC to Samba PDC: -# Run pwdump on NT Server to generate an smbpasswd file (Samba 1.19 format), -# called say NTpasslist. -# then: -# -# mysql_convert.pl --db=samba --table=smbpasswd --user=samba --infile=NTpasslist --create --check -# -# The --check option will change the unix_uid field to the real uid -# value of respective users, also filter out users that dont exist on -# the system. -# -# If dont have mysql perl module: -# -# mysql_convert.pl --table=smbpasswd --infile=NTpasslist --outfile=mysql.txt -# -# Then use the mysql client: -# -# mysql -u samba < mysql.txt -# - -$ACB_DISABLED=0x0001; -$ACB_HOMDIRREQ=0x0002; -$ACB_PWNOTREQ=0x0004; -$ACB_TEMPDUP=0x0008; -$ACB_NORMAL=0x0010; -$ACB_MNS=0x0020; -$ACB_DOMTRUST=0x0040; -$ACB_WSTRUST=0x0080; -$ACB_SVRTRUST=0x0100; -$ACB_PWNOEXP=0x0200; -$ACB_AUTOLOCK=0x0400; - -sub getoptionval { - my ($option) = @_; - - my ($value) = ($option =~ /^[^=]+=\s*(\S.*\S)\s*$/ ); - - return $value; -} - -sub usage { - -print <<EOUSAGE; -$0 [options] -options: - --infile=<filename> # smbpasswd style file to read entries from - --outfile=<filename> # file to dump results to, format depending - # on --infile: - # With --infile: Dump mysql script queries - # Without --infile: Dump smbpasswd format - # from reading mysql database - --host=<hostname> # Mysql Server name (default: localhost) - --db=<database> # Mysql Database name - --user=<user> # Mysql User - --password[=<password>] # Mysql password for --user - --table=<table> # Mysql table - --create # Generate 'create table' query - --file=[trash|append] # Action to take if --outfile file exists - --check # Do not alter or skip bad uids - -EOUSAGE -exit 0; -} - -sub getpass { - my($prompt)=@_; - my($ret); - - print $prompt; - system "stty -echo"; - chomp($ret=<STDIN>); - system "stty echo"; - print "\n"; - $ret; -} - -sub next_entry { - my ($name,$uid,$lm,$nt,$f,$lct) = (); - - $name=""; - if ( not $infile ) { - ($name,$uid,$lm,$nt,$f,$lct) = $mysqlquery->fetchrow(); - } - else { - my $line=<INFILE>; - - return () if ( not $line ); - - chomp($line); - - next if ( $line !~ /^[^: ]+:\d+:/ ); - - ($name,$uid,$lm,$nt,$f,$lct) = split(/:/,$line); - - if ( $lct =~ /^LCT-/ ) { - # New Format smbpasswd file - my $flags=0; - - $flags |= $ACB_PWNOTREQ if ( $f =~ /N/ ); - $flags |= $ACB_DISABLED if ( $f =~ /D/ ); - $flags |= $ACB_HOMDIRREQ if ( $f =~ /H/ ); - $flags |= $ACB_TEMPDUP if ( $f =~ /T/ ); - $flags |= $ACB_NORMAL if ( $f =~ /U/ ); - $flags |= $ACB_MNS if ( $f =~ /M/ ); - $flags |= $ACB_WSTRUST if ( $f =~ /W/ ); - $flags |= $ACB_SVRTRUST if ( $f =~ /S/ ); - $flags |= $ACB_AUTOLOCK if ( $f =~ /L/ ); - $flags |= $ACB_PWNOEXP if ( $f =~ /X/ ); - $flags |= $ACB_DOMTRUST if ( $f =~ /I/ ); - - $f = $flags; - - $f = $ACB_NORMAL if ( not $f ); - - $lct =~ s/LCT-//; - $lct = (unpack("L",pack("H8",$lct)))[0]; - } - else { - # Old Format smbpasswd file - $f = 0; - $lct = time(); - if ( $lm =~ /^NO PASS/ ) { - $f |= $ACB_PWNOTREQ; - $lm = ""; - $nt = ""; - } - elsif ( $lm =~ /^XX/ ) { - $f |= $ACB_DISABLED; - - $lm = ""; - $nt = ""; - } - - if ( $name =~ /\$$/ ) { - $f |= $ACB_WSTRUST; - } - - $f = $ACB_NORMAL if ( not $f ); - } - } - return () if ( not $name ); - ($name,$uid,$lm,$nt,$f,$lct); -} - -sub do_query { - my ( $query ) = @_; - - chomp($query); - if ( $outfile ) { - print OUTFILE "$query;\n"; - } - else { - if ( not $mysqldb->query($query) ) { - print "$query: $Mysql::db_errstr\n"; - } - } -} - -sub do_file { - my ($file,$name,$uid,$lm,$nt,$f,$lct)=@_; - - my $strings = ""; - - $strings .= "N" if ( $f & $ACB_PWNOTREQ ); - $strings .= "D" if ( $f & $ACB_DISABLED ); - $strings .= "H" if ( $f & $ACB_HOMDIRREQ ); - $strings .= "T" if ( $f & $ACB_TEMPDUP ); - $strings .= "U" if ( $f & $ACB_NORMAL ); - $strings .= "M" if ( $f & $ACB_MNS ); - $strings .= "W" if ( $f & $ACB_WSTRUST ); - $strings .= "S" if ( $f & $ACB_SVRTRUST ); - $strings .= "L" if ( $f & $ACB_AUTOLOCK ); - $strings .= "X" if ( $f & $ACB_PWNOEXP ); - $strings .= "I" if ( $f & $ACB_DOMTRUST ); - - $f = sprintf( "[%-11s]", $strings ); - - $lct=uc("LCT-".(unpack("H8",pack("L","$lct")))[0]); - - $lm = "X"x32 if ( not $lm ); - $nt = "X"x32 if ( not $nt ); - - print $file "$name:$uid:$lm:$nt:$f:$lct\n"; -} - -$dbhost = "localhost"; - -for $option ( @ARGV ) { - if ( $option =~ /--outfile=/ ) { - $outfile = getoptionval($option); - } - elsif ( $option =~ /--infile=/ ) { - $infile = getoptionval($option); - } - elsif ( $option =~ /--db=/ ) { - $dbname = getoptionval($option); - } - elsif ( $option =~ /--user=/ ) { - $dbuser = getoptionval($option); - } - elsif ( $option =~ /--host=/ ) { - $dbhost = getoptionval($option); - } - elsif ( $option =~ /--password/ ) { - $dbpasswd = getoptionval($option); - $need_password = "yes" - } - elsif ( $option =~ /--table=/ ) { - $dbtable = getoptionval($option); - } - elsif ( $option =~ /--create/ ) { - $create_table = "yes"; - } - elsif ( $option =~ /--file=/ ) { - $file_action = getoptionval($option); - } - elsif ( $option =~ /--check/ ) { - $check = "yes"; - } - else { - print "Unknown option: $option\n"; - $unknown = "yes"; - } -} - -&usage if ( $unknown eq "yes" ); - -if ( ( not $infile ) && ( not $outfile ) && ( $create_table ne "yes" ) ) { - print "Need file to read from or write to\n"; - &usage; -} -elsif ( $infile && $outfile ) { - if ( not $dbtable ) { - print "Need --table to create queries\n"; - exit 1; - } - - # Reading a smbpasswd file, dumping queries into an file which - # can be used for a mysql script - # --db* options are ignored. - - $ignored = ""; - $ignored .= " --db" if ( $dbname ); - $ignored .= " --user" if ( $dbuser ); - $ignored .= " --password" if ( $dbuser ); - - if ( $ignored ) { - print "Ignoring options: $ignored\n"; - } -} -elsif ( (not $dbname) || (not $dbtable) || (not $dbuser) ) { - print "Missing database particulars:\n"; - print " --db=??\n" if ( not $dbname ); - print " --user=??\n" if ( not $dbuser ); - print " --table=??\n" if ( not $dbtable ); - &usage; -} -else { - use Mysql; - - if ( ($need_password eq "yes") && ( not $dbpasswd )) { - $dbpasswd = getpass("Enter MySQL password for $dbuser: "); - } - $mysqldb = Connect Mysql($dbhost,$dbname,$dbuser,$dbpasswd); - - if ( not $mysqldb ) { - print "Cannot connect to database: $Mysql::db_errstr\n"; - exit 1; - } - - if ( $outfile ) { - $mysqlquery = $mysqldb->query("select unix_name,unix_uid,smb_passwd,smb_nt_passwd,acct_ctrl,pass_last_set_time from $dbtable"); - - if ( not $mysqlquery ) { - print "MySQL Query failed: $Mysql::db_errstr\n"; - exit 1; - } - } -} - -if ( $create_table eq "yes" ) { - $create_table_query=<<EOSQL; -create table $dbtable ( -unix_name char(20) not null, -unix_uid int(10) unsigned not null, -nt_name char(20) not null, -user_rid int(10) unsigned not null, -smb_passwd char(32), -smb_nt_passwd char(32), -acct_ctrl int(10) unsigned not null, -pass_last_set_time int(10) unsigned not null, -unique (unix_name), -unique (unix_uid) -) -EOSQL - print "$create_table_query\n"; -} -if ( $infile ) { - if ( not open(INFILE,$infile) ) { - print "$infile: $!\n"; - exit 1; - } -} - -if ( $outfile ) { - if ( ! -f $outfile ) { - $open_string=">$outfile"; - } - elsif ( not $file_action ) { - print "File $outfile exists:\n"; - print "Please use --file=[trash|append] option to determine destiny of file\n"; - exit 1; - } - elsif ( $file_action eq "append" ) { - $open_string = ">>$outfile"; - } - else { - $open_string = ">$outfile"; - } - - if ( not open(OUTFILE,$open_string) ) { - print "$outfile: $!\n"; - exit 1; - } -} - -do_query($create_table_query) if ( $create_table_query ); - -$linenum=1; -while (($name,$uid,$lm,$nt,$f,$lct)=next_entry()) { - - $| = 1; - print "\r$linenum "; - $linenum++; - - $nuid = ""; - - $nuid = (getpwnam(lc($name)))[2]; - - if ( $check ) { - if ( not $nuid ) { - # print "Removing $name: Does not exist\n"; - push(@removed,[$name,$uid,$lm,$nt,$f,$lct]); - next; - } - else { - # print "Changing uid of $name\n"; - $uid = $nuid; - } - } - - if ( $infile ) { - if ( $lm ) { - $lm = "'$lm'"; - } - else { - $lm = "NULL"; - } - if ( $nt ) { - $nt = "'$nt'"; - } - else { - $nt = "NULL"; - } - $rid=(4*$uid)+1000; - do_query("insert into $dbtable (unix_name,unix_uid,smb_passwd,smb_nt_passwd,acct_ctrl,pass_last_set_time,nt_name,user_rid) values ('$name',$uid,$lm,$nt,$f,$lct,'$name',$rid)"); - } - else { - do_file(OUTFILE,$name,$uid,$lm,$nt,$f,$lct); - } -} - -if ( @removed ) { - print "\n\nIgnored entries because usernames do not exist\n"; - foreach $line ( @removed ) { - do_file(STDOUT,@{ $line }); - } -} - -close (OUTFILE) if ( $outfile ); -close (INFILE) if ( $infile ); -print "\n"; diff --git a/source/smbd/challenge.c b/source/smbd/challenge.c deleted file mode 100644 index cbb34e63954..00000000000 --- a/source/smbd/challenge.c +++ /dev/null @@ -1,61 +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; - -/* Data to do lanman1/2 password challenge. */ -static unsigned char saved_challenge[8]; -static BOOL challenge_sent=False; - -/******************************************************************* -Get the next challenge value - no repeats. -********************************************************************/ -void generate_next_challenge(char *challenge) -{ - unsigned char buf[8]; - generate_random_buffer(buf,8,False); - memcpy(saved_challenge, buf, 8); - memcpy(challenge,buf,8); - challenge_sent = True; -} - -/******************************************************************* -set the last challenge sent, usually from a password server -********************************************************************/ -BOOL set_challenge(unsigned char *challenge) -{ - memcpy(saved_challenge,challenge,8); - challenge_sent = True; - return(True); -} - -/******************************************************************* -get the last challenge sent -********************************************************************/ -BOOL last_challenge(unsigned char *challenge) -{ - if (!challenge_sent) return False; - memcpy(challenge,saved_challenge,8); - return(True); -} - diff --git a/source/smbd/dfs.c b/source/smbd/dfs.c deleted file mode 100644 index 55433f2c479..00000000000 --- a/source/smbd/dfs.c +++ /dev/null @@ -1,255 +0,0 @@ - -#include "includes.h" - -extern int DEBUGLEVEL; - -dfs_internal dfs_struct; -extern pstring global_myname; - -/**************************************************************************** -read a line and split it -****************************************************************************/ -static BOOL parse_dfs_text_entry(char *line, dfs_internal_table *buf) -{ -#define MAXTOK 4 - char *tok[MAXTOK+1]; - int count = 0; - - tok[count] = strtok(line,":"); - - /* strip the comment lines */ - if (tok[0][0] == '#') return (False); - count++; - - while ( ((tok[count] = strtok(NULL,":")) != NULL ) && count < MAXTOK) - { - count++; - } - - DEBUG(7,("Found [%d] tokens\n", count)); - - if (count > 1) { - StrnCpy(buf->localpath, tok[0], sizeof(buf->localpath)-1); - StrnCpy(buf->sharename, tok[1], sizeof(buf->sharename)-1); -/* - strupper(buf->localpath); - strupper(buf->sharename); -*/ - buf->localpath_length = strlen(buf->localpath); - buf->sharename_length = strlen(buf->sharename); - } - else - return (False); - - if (count > 2) - buf->proximity = atoi(tok[2]); - else - buf->proximity = 0; - - if (count > 3) - buf->type = atoi(tok[3]); - else - buf->type = 2; - - DEBUGADD(7,("localpath: [%s]\n", buf->localpath)); - DEBUGADD(7,("sharename: [%s]\n", buf->sharename)); - return True; -} - -/**************************************************************************** -mangle the localpath and store it. -****************************************************************************/ -static void mangle_dfs_path(dfs_internal_table *buf) -{ - char *p; - char *mp; - char *q; - int mlen; - - fstring temp; - - p = buf->localpath; - mp = buf->mangledpath; - mlen = sizeof(buf->mangledpath); - - ZERO_STRUCTP(mp); - DEBUG(2, ("DFS name is: [%s]\n", buf->localpath)); - - /* copy the head: \server-name\ */ - q = strchr(p + 1, '\\'); - safe_strcpy(mp, p, mlen); - p = q + 1; - - while (q != NULL) - { - q = strchr(p, '\\'); - - safe_strcpy(temp, p, sizeof(temp)); - - if (!is_8_3(temp, True)) - { - mangle_name_83(temp); - } - - safe_strcat(mp, temp, mlen); - - if (q != NULL) - { - safe_strcat(mp, "\\", mlen); - } - p = q + 1; - } - -/* - strupper(mp); -*/ - buf->mangledpath_length = strlen(mp); - DEBUGADD(2, ("DFS mangled name is: [%s]\n", mp)); -} - -/**************************************************************************** -initialisation de la table dfs en memoire au demarrage de samba -****************************************************************************/ -BOOL init_dfs_table(void) -{ - char *file = lp_dfs_map(); - int num_lines = 0; - int total = 0; - FILE *f; - pstring line; - int i; - - dfs_internal_table *entry; - - entry = NULL; - dfs_struct.ready = False; - - if (*file == '\0') { - DEBUG(0,("No DFS map, Samba is running in NON DFS mode\n")); - return False; - } - - f = sys_fopen(file, "r"); - if (!f) { - DEBUG(0,("No DFS map file, Samba is running in NON DFS mode\n")); - return False; - } - - while ( fgets(line, sizeof(pstring), f) ) - { - entry = Realloc(entry,sizeof(dfs_internal_table)*(total+1)); - if (! entry) - { - total = 0; - break; - } - - if ( parse_dfs_text_entry(line, &(entry[total]) ) ) - { - total++; - } - num_lines++; - } - dfs_struct.size = total; - dfs_struct.table = entry; - fclose(f); - - /* we have the file in memory */ - /* now initialise the mangled names */ - for (i = 0; i < total; i++) - { - mangle_dfs_path(&(entry[i])); - } - - dfs_struct.ready = True; - DEBUG(0,("Samba is DFS aware now!\n")); - return True; -} - -static BOOL check_dfs_path(int search_len, const char *search_path, - int path_len, const char* fullpath, - const char* sharename, - const char* share_path, size_t share_len, - char *localpath, size_t local_plen) -{ - if (StrnCaseCmp(search_path, fullpath, search_len) != 0) - { - return False; - } - - DEBUG(2,("found one linked to [%s]. share_path: %s\n", - sharename, share_path)); - - if (StrnCaseCmp(fullpath, share_path, share_len) == 0) - { - safe_strcpy(localpath, fullpath + share_len, local_plen); - } - else - { - localpath[0] = 0; - } - - return True; -} - -/**************************************************************************** - check if a path name is a DFS branch -****************************************************************************/ -int under_dfs(connection_struct *conn, const char *path, - char *local_path, size_t local_plen) -{ - fstring fullpath; - pstring share_path; - int i; - int snum; - - int path_len; - int share_len; - - dfs_internal_table *list = dfs_struct.table; - - snum = SNUM(conn); - snprintf(share_path, sizeof(share_path), "\\%s\\%s", - global_myname, lp_servicename(snum)); - share_len = strlen(share_path); - - if (path[0] != '\\') - { - snprintf(fullpath, sizeof(fullpath), "%s\\%s", - share_path, path); - } - else - { - safe_strcpy(fullpath, path, sizeof(fullpath)); - } - - path_len = strlen(fullpath); - - DEBUG(2,("DFS looking for: [%s]\n", fullpath)); - - for (i = 0; i < dfs_struct.size; i++) - { - DEBUG(6,("checking against [%s][%d]\n", list[i].localpath,i)); - - if (check_dfs_path(list[i].localpath_length, - list[i].localpath, - path_len, fullpath, - list[i].sharename, - share_path, share_len, - local_path, local_plen)) - { - return True; - } - - if (check_dfs_path(list[i].mangledpath_length, - list[i].mangledpath, - path_len, fullpath, - list[i].sharename, - share_path, share_len, - local_path, local_plen)) - { - return True; - } - } - return False; -} diff --git a/source/smbd/vfs-wrap.c b/source/smbd/vfs-wrap.c deleted file mode 100644 index 3493c231789..00000000000 --- a/source/smbd/vfs-wrap.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - Wrap disk only vfs functions to sidestep dodgy compilers. - Copyright (C) Tim Potter 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" - -/* Check for NULL pointer parameters in vfswrap_* functions */ - -#define VFS_CHECK_NULL - -/* We don't want to have NULL function pointers lying around. Someone - is sure to try and execute them. These stubs are used to prevent - this possibility. */ - -int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service, - char *user) -{ - return 0; /* Return >= 0 for success */ -} - -void vfswrap_dummy_disconnect(void) -{ -} - -/* Disk operations */ - -SMB_BIG_UINT vfswrap_disk_free(char *path, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) -{ - SMB_BIG_UINT result; - -#ifdef VFS_CHECK_NULL - if ((path == NULL) || (bsize == NULL) || (dfree == NULL) || - (dsize == NULL)) { - - smb_panic("NULL pointer passed to vfswrap_disk_free() function\n"); - } -#endif - - result = sys_disk_free(path, bsize, dfree, dsize); - return result; -} - -/* Directory operations */ - -DIR *vfswrap_opendir(char *fname) -{ - DIR *result; - -#ifdef VFS_CHECK_NULL - if (fname == NULL) { - smb_panic("NULL pointer passed to vfswrap_opendir()\n"); - } -#endif - - result = opendir(fname); - return result; -} - -struct dirent *vfswrap_readdir(DIR *dirp) -{ - struct dirent *result; - -#ifdef VFS_CHECK_NULL - if (dirp == NULL) { - smb_panic("NULL pointer passed to vfswrap_readdir()\n"); - } -#endif - - result = readdir(dirp); - return result; -} - -int vfswrap_mkdir(char *path, mode_t mode) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (path == NULL) { - smb_panic("NULL pointer passed to vfswrap_mkdir()\n"); - } -#endif - - result = mkdir(path, mode); - return result; -} - -int vfswrap_rmdir(char *path) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (path == NULL) { - smb_panic("NULL pointer passed to vfswrap_rmdir()\n"); - } -#endif - - result = rmdir(path); - return result; -} - -int vfswrap_closedir(DIR *dirp) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (dirp == NULL) { - smb_panic("NULL pointer passed to vfswrap_closedir()\n"); - } -#endif - - result = closedir(dirp); - return result; -} - -/* File operations */ - -int vfswrap_open(char *fname, int flags, mode_t mode) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (fname == NULL) { - smb_panic("NULL pointer passed to vfswrap_open()\n"); - } -#endif - - result = sys_open(fname, flags, mode); - return result; -} - -int vfswrap_close(int fd) -{ - int result; - - result = close(fd); - return result; -} - -ssize_t vfswrap_read(int fd, char *data, size_t n) -{ - ssize_t result; - -#ifdef VFS_CHECK_NULL - if (data == NULL) { - smb_panic("NULL pointer passed to vfswrap_read()\n"); - } -#endif - - result = read(fd, data, n); - return result; -} - -ssize_t vfswrap_write(int fd, char *data, size_t n) -{ - ssize_t result; - -#ifdef VFS_CHECK_NULL - if (data == NULL) { - smb_panic("NULL pointer passed to vfswrap_write()\n"); - } -#endif - - result = write(fd, data, n); - return result; -} - -SMB_OFF_T vfswrap_lseek(int filedes, SMB_OFF_T offset, int whence) -{ - SMB_OFF_T result; - - result = sys_lseek(filedes, offset, whence); - return result; -} - -int vfswrap_rename(char *old, char *new) -{ - int result; - -#ifdef VFS_CHECK_NULL - if ((old == NULL) || (new == NULL)) { - smb_panic("NULL pointer passed to vfswrap_rename()\n"); - } -#endif - - result = rename(old, new); - return result; -} - -void vfswrap_sync_file(int fd) -{ - sys_sync_file(fd); -} - -int vfswrap_stat(char *fname, SMB_STRUCT_STAT *sbuf) -{ - int result; - -#ifdef VFS_CHECK_NULL - if ((fname == NULL) || (sbuf == NULL)) { - smb_panic("NULL pointer passed to vfswrap_stat()\n"); - } -#endif - - result = sys_stat(fname, sbuf); - return result; -} - -int vfswrap_fstat(int fd, SMB_STRUCT_STAT *sbuf) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (sbuf == NULL) { - smb_panic("NULL pointer passed to vfswrap_fstat()\n"); - } -#endif - - result = sys_fstat(fd, sbuf); - return result; -} - -int vfswrap_lstat(char *path, - SMB_STRUCT_STAT *sbuf) -{ - int result; - -#ifdef VFS_CHECK_NULL - if ((path == NULL) || (sbuf == NULL)) { - smb_panic("NULL pointer passed to vfswrap_lstat()\n"); - } -#endif - - result = sys_lstat(path, sbuf); - return result; -} - -BOOL vfswrap_fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, - int type) -{ - BOOL result; - - result = fcntl_lock(fd, op, offset, count, type); - return result; -} - -int vfswrap_unlink(char *path) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (path == NULL) { - smb_panic("NULL pointer passed to vfswrap_unlink()\n"); - } -#endif - - result = unlink(path); - return result; -} - -int vfswrap_chmod(char *path, mode_t mode) -{ - int result; - -#ifdef VFS_CHECK_NULL - if (path == NULL) { - smb_panic("NULL pointer passed to vfswrap_chmod()\n"); - } -#endif - - result = chmod(path, mode); - return result; -} - -int vfswrap_utime(char *path, struct utimbuf *times) -{ - int result; - -#ifdef VFS_CHECK_NULL - if ((path == NULL) || (times == NULL)) { - smb_panic("NULL pointer passed to vfswrap_utime()\n"); - } -#endif - - result = utime(path, times); - return result; -} diff --git a/source/smbd/vfs.c b/source/smbd/vfs.c deleted file mode 100644 index 95bb4c94143..00000000000 --- a/source/smbd/vfs.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - VFS initialisation and support functions - 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. -*/ - -#include "includes.h" -#ifdef HAVE_LIBDL -#include <dlfcn.h> -#endif - -extern int DEBUGLEVEL; - -/* Some structures to help us initialise the vfs operations table */ - -struct vfs_syminfo { - char *name; - void *fptr; -}; - -/* Default vfs hooks. WARNING: The order of these initialisers is - very important. They must be in the same order as defined in - vfs.h. Change at your own peril. */ - -struct vfs_ops default_vfs_ops = { - - /* Disk operations */ - - vfswrap_dummy_connect, - vfswrap_dummy_disconnect, - vfswrap_disk_free, - - /* Directory operations */ - - vfswrap_opendir, - vfswrap_readdir, - vfswrap_mkdir, - vfswrap_rmdir, - vfswrap_closedir, - - /* File operations */ - - vfswrap_open, - vfswrap_close, - vfswrap_read, - vfswrap_write, - vfswrap_lseek, - vfswrap_rename, - vfswrap_sync_file, - vfswrap_stat, - vfswrap_fstat, - vfswrap_lstat, - vfswrap_fcntl_lock, - vfswrap_unlink, - vfswrap_chmod, - vfswrap_utime -}; - -/**************************************************************************** - initialise default vfs hooks -****************************************************************************/ -int vfs_init_default(connection_struct *conn) -{ - DEBUG(3, ("Initialising default vfs hooks\n")); - - memcpy(&conn->vfs_ops, &default_vfs_ops, sizeof(conn->vfs_ops)); - return True; -} - -/**************************************************************************** - initialise custom vfs hooks -****************************************************************************/ -#ifdef HAVE_LIBDL -BOOL vfs_init_custom(connection_struct *conn) -{ - void *handle; - struct vfs_ops *ops, *(*fptr)(struct vfs_options *options); - - DEBUG(3, ("Initialising custom vfs hooks from %s\n", - lp_vfsobj(SNUM(conn)))); - - /* Open object file */ - - handle = dlopen(lp_vfsobj(SNUM(conn)), RTLD_NOW); - if (!handle) { - DEBUG(0, ("Error opening %s: %s\n", lp_vfsobj(SNUM(conn)), - dlerror())); - return False; - } - - /* Get handle on vfs_init() symbol */ - - fptr = dlsym(handle, "vfs_init"); - if (fptr == NULL) { - DEBUG(0, ("No vfs_init() symbol found in %s\n", - lp_vfsobj(SNUM(conn)))); - return False; - } - - dlclose(handle); - - /* Initialise vfs_ops structure */ - - if ((ops = fptr(lp_vfsoptions(SNUM(conn)))) == NULL) { - return False; - } - - /* Fill in unused operations with default (disk based) ones. - There's probably a neater way to do this then a whole bunch of - if statements. */ - - memcpy(&conn->vfs_ops, ops, sizeof(conn->vfs_ops)); - - if (conn->vfs_ops.connect == NULL) { - conn->vfs_ops.connect = default_vfs_ops.connect; - } - - if (conn->vfs_ops.disconnect == NULL) { - conn->vfs_ops.disconnect = default_vfs_ops.disconnect; - } - - if (conn->vfs_ops.disk_free == NULL) { - conn->vfs_ops.disk_free = default_vfs_ops.disk_free; - } - - if (conn->vfs_ops.opendir == NULL) { - conn->vfs_ops.opendir = default_vfs_ops.opendir; - } - - if (conn->vfs_ops.readdir == NULL) { - conn->vfs_ops.readdir = default_vfs_ops.readdir; - } - - if (conn->vfs_ops.mkdir == NULL) { - conn->vfs_ops.mkdir = default_vfs_ops.mkdir; - } - - if (conn->vfs_ops.rmdir == NULL) { - conn->vfs_ops.rmdir = default_vfs_ops.rmdir; - } - - if (conn->vfs_ops.closedir == NULL) { - conn->vfs_ops.closedir = default_vfs_ops.closedir; - } - - if (conn->vfs_ops.open == NULL) { - conn->vfs_ops.open = default_vfs_ops.open; - } - - if (conn->vfs_ops.close == NULL) { - conn->vfs_ops.close = default_vfs_ops.close; - } - - if (conn->vfs_ops.read == NULL) { - conn->vfs_ops.read = default_vfs_ops.read; - } - - if (conn->vfs_ops.write == NULL) { - conn->vfs_ops.write = default_vfs_ops.write; - } - - if (conn->vfs_ops.lseek == NULL) { - conn->vfs_ops.lseek = default_vfs_ops.lseek; - } - - if (conn->vfs_ops.rename == NULL) { - conn->vfs_ops.rename = default_vfs_ops.rename; - } - - if (conn->vfs_ops.sync == NULL) { - conn->vfs_ops.sync = default_vfs_ops.sync; - } - - if (conn->vfs_ops.stat == NULL) { - conn->vfs_ops.stat = default_vfs_ops.stat; - } - - if (conn->vfs_ops.fstat == NULL) { - conn->vfs_ops.fstat = default_vfs_ops.fstat; - } - - if (conn->vfs_ops.lstat == NULL) { - conn->vfs_ops.lstat = default_vfs_ops.lstat; - } - - if (conn->vfs_ops.lock == NULL) { - conn->vfs_ops.lock = default_vfs_ops.lock; - } - - if (conn->vfs_ops.unlink == NULL) { - conn->vfs_ops.unlink = default_vfs_ops.unlink; - } - - if (conn->vfs_ops.chmod == NULL) { - conn->vfs_ops.chmod = default_vfs_ops.chmod; - } - - if (conn->vfs_ops.utime == NULL) { - conn->vfs_ops.utime = default_vfs_ops.utime; - } - - return True; -} -#endif - -/******************************************************************* - check if a vfs file exists -********************************************************************/ -BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf) -{ - SMB_STRUCT_STAT st; - if (!sbuf) sbuf = &st; - - if (conn->vfs_ops.stat(fname,sbuf) != 0) - return(False); - - return(S_ISREG(sbuf->st_mode)); -} - -/**************************************************************************** - write data to a fd on the vfs -****************************************************************************/ -ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N) -{ - size_t total=0; - ssize_t ret; - int fd = fsp->fd_ptr->fd; - - while (total < N) - { - ret = fsp->conn->vfs_ops.write(fd,buffer + total,N - total); - - if (ret == -1) return -1; - if (ret == 0) return total; - - total += ret; - } - return (ssize_t)total; -} - -/**************************************************************************** -transfer some data between two file_struct's -****************************************************************************/ -SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp, - int out_fd, files_struct *out_fsp, - SMB_OFF_T n, char *header, int headlen, int align) -{ - static char *buf=NULL; - static int size=0; - char *buf1,*abuf; - SMB_OFF_T total = 0; - - DEBUG(4,("vfs_transfer_file n=%.0f (head=%d) called\n",(double)n,headlen)); - - /* Check we have at least somewhere to read from */ - - SMB_ASSERT((in_fd != -1) || (in_fsp != NULL)); - - if (size == 0) { - size = lp_readsize(); - size = MAX(size,1024); - } - - while (!buf && size>0) { - buf = (char *)Realloc(buf,size+8); - if (!buf) size /= 2; - } - - if (!buf) { - DEBUG(0,("Can't allocate transfer buffer!\n")); - exit(1); - } - - abuf = buf + (align%8); - - if (header) - n += headlen; - - while (n > 0) - { - int s = (int)MIN(n,(SMB_OFF_T)size); - int ret,ret2=0; - - ret = 0; - - if (header && (headlen >= MIN(s,1024))) { - buf1 = header; - s = headlen; - ret = headlen; - headlen = 0; - header = NULL; - } else { - buf1 = abuf; - } - - if (header && headlen > 0) - { - ret = MIN(headlen,size); - memcpy(buf1,header,ret); - headlen -= ret; - header += ret; - if (headlen <= 0) header = NULL; - } - - if (s > ret) { - ret += in_fsp ? - in_fsp->conn->vfs_ops.read(in_fsp->fd_ptr->fd,buf1+ret,s-ret) : read(in_fd,buf1+ret,s-ret); - } - - if (ret > 0) - { - if (out_fsp) { - ret2 = out_fsp->conn->vfs_ops.write(out_fsp->fd_ptr->fd,buf1,ret); - } else { - ret2= (out_fd != -1) ? write_data(out_fd,buf1,ret) : ret; - } - } - - if (ret2 > 0) total += ret2; - /* if we can't write then dump excess data */ - if (ret2 != ret) - vfs_transfer_file(in_fd, in_fsp, -1,NULL,n-(ret+headlen),NULL,0,0); - - if (ret <= 0 || ret2 != ret) - return(total); - n -= ret; - } - return(total); -} - -/******************************************************************* -a vfs_readdir wrapper which just returns the file name -********************************************************************/ -char *vfs_readdirname(connection_struct *conn, void *p) -{ - struct dirent *ptr; - char *dname; - - if (!p) return(NULL); - - ptr = (struct dirent *)conn->vfs_ops.readdir(p); - if (!ptr) return(NULL); - - dname = ptr->d_name; - -#ifdef NEXT2 - if (telldir(p) < 0) return(NULL); -#endif - -#ifdef HAVE_BROKEN_READDIR - /* using /usr/ucb/cc is BAD */ - dname = dname - 2; -#endif - - { - static pstring buf; - memcpy(buf, dname, NAMLEN(ptr)+1); - unix_to_dos(buf, True); - dname = buf; - } - - unix_to_dos(dname, True); - return(dname); -} diff --git a/source/spoolssd/spoolssd.c b/source/spoolssd/spoolssd.c deleted file mode 100644 index 7ea5195009b..00000000000 --- a/source/spoolssd/spoolssd.c +++ /dev/null @@ -1,100 +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) -{ - init_printer_hnd(); /* for SPOOLSS handles */ -} - -/**************************************************************************** - 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); - - load_printers(); - - /* 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, "spoolss"); - slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name); - add_msrpc_command_processor( pipe_name, argv[0], api_spoolss_rpc ); - - return msrpc_main(argc, argv); -} diff --git a/source/srvsvcd/srvsvcd.c b/source/srvsvcd/srvsvcd.c deleted file mode 100644 index 78c64a200b3..00000000000 --- a/source/srvsvcd/srvsvcd.c +++ /dev/null @@ -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, "srvsvc"); - slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name); - add_msrpc_command_processor( pipe_name, argv[0], api_srvsvc_rpc ); - - return msrpc_main(argc, argv); -} diff --git a/source/svcctld/svcctld.c b/source/svcctld/svcctld.c deleted file mode 100644 index 95470ad4a49..00000000000 --- a/source/svcctld/svcctld.c +++ /dev/null @@ -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, "svcctl"); - slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name); - add_msrpc_command_processor( pipe_name, argv[0], api_svcctl_rpc ); - - return msrpc_main(argc, argv); -} diff --git a/source/tests/trapdoor.c b/source/tests/trapdoor.c deleted file mode 100644 index 83e10d06130..00000000000 --- a/source/tests/trapdoor.c +++ /dev/null @@ -1,25 +0,0 @@ -/* test for a trapdoor uid system */ - -#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> - -main() -{ - if (getuid() != 0) { - fprintf(stderr,"ERROR: This test must be run as root - assuming non-trapdoor system\n"); - exit(0); - } - - if (seteuid(1) != 0) exit(1); - if (geteuid() != 1) exit(1); - if (seteuid(0) != 0) exit(1); - if (geteuid() != 0) exit(1); - - if (setegid(1) != 0) exit(1); - if (getegid() != 1) exit(1); - if (setegid(0) != 0) exit(1); - if (getegid() != 0) exit(1); - - exit(0); -} diff --git a/source/utils/nmb-agent.c b/source/utils/nmb-agent.c deleted file mode 100644 index f49983db79c..00000000000 --- a/source/utils/nmb-agent.c +++ /dev/null @@ -1,295 +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" - -#define SECURITY_MASK 0 -#define SECURITY_SET 0 - -/* this forces non-unicode */ -#define CAPABILITY_MASK CAP_UNICODE -#define CAPABILITY_SET 0 - -/* and non-unicode for the client too */ -#define CLI_CAPABILITY_MASK CAP_UNICODE -#define CLI_CAPABILITY_SET 0 - -extern int DEBUGLEVEL; - -static int ClientNMB = -1; - -/**************************************************************************** -terminate sockent connection -****************************************************************************/ -static void free_sock(void *sock) -{ - if (sock != NULL) - { - free(sock); - } -} - -static void filter_reply(struct packet_struct *p, int tr_id) -{ - p->packet.nmb.header.name_trn_id = tr_id; -} - -static BOOL process_cli_sock(struct sock_redir **socks, - uint32 num_socks, - struct sock_redir *sock) -{ - struct packet_struct *p; - struct nmb_state *nmb; - static uint16 trn_id = 0x0; - - p = receive_packet(sock->c, NMB_SOCK_PACKET, 0); - if (p == NULL) - { - DEBUG(0,("client closed connection\n")); - return False; - } - - nmb = (struct nmb_state*)malloc(sizeof(struct nmb_state)); - if (nmb == NULL) - { - free_packet(p); - return False; - } - - sock->s = ClientNMB; - sock->n = nmb; - sock->c_id = p->packet.nmb.header.name_trn_id; - sock->s_id = trn_id; - - trn_id++; - if (trn_id > 0xffff) - { - trn_id = 0x0; - } - - DEBUG(10,("new trn_id: %d\n", trn_id)); - - filter_reply(p, sock->s_id); - - nmb->ip = p->ip; - nmb->port = p->port; - - p->fd = ClientNMB; - p->packet_type = NMB_PACKET; - - if (!send_packet(p)) - { - DEBUG(0,("server is dead\n")); - free_packet(p); - return False; - } - free_packet(p); - return True; -} - -static BOOL process_srv_sock(struct sock_redir **socks, - uint32 num_socks, - int fd) -{ - int nmb_id; - int tr_id; - int i; - - struct packet_struct *p; - - p = receive_packet(fd, NMB_PACKET, 0); - if (p == NULL) - { - return True; - } - -#if 0 - if (!p->packet.nmb.header.response) - { - DEBUG(10,("skipping response packet\n")); - free_packet(p); - return True; - } -#endif - - nmb_id = p->packet.nmb.header.name_trn_id; - DEBUG(10,("process_srv_sock:\tnmb_id:\t%d\n", nmb_id)); - - for (i = 0; i < num_socks; i++) - { - if (socks[i] == NULL) - { - continue; - } - - tr_id = socks[i]->s_id; - - DEBUG(10,("list:\tfd:\t%d\tc_id:\t%d\ttr_id:\t%d\n", - socks[i]->c, - socks[i]->c_id, - tr_id)); - - if (nmb_id != tr_id) - { - continue; - } - - filter_reply(p, socks[i]->c_id); - p->fd = socks[i]->c; - p->packet_type = NMB_SOCK_PACKET; - - if (!send_packet(p)) - { - DEBUG(0,("client is dead\n")); - return False; - } - return True; - } - return True; -} - -static int get_agent_sock(char *id) -{ - fstring dir; - fstring path; - - slprintf(dir, sizeof(dir)-1, "/tmp/.nmb"); - slprintf(path, sizeof(path)-1, "%s/agent", dir); - - return create_pipe_socket(dir, 0777, path, 0777); -} - -static void start_nmb_agent(void) -{ - struct vagent_ops va = - { - free_sock, - get_agent_sock, - process_cli_sock, - process_srv_sock, - NULL, - NULL, - 0 - }; - - CatchChild(); - - start_agent(&va); -} - -/****************************************************************************** - open the socket communication - *****************************************************************************/ -static BOOL open_sockets(BOOL isdaemon, int port) -{ - /* The sockets opened here will be used to receive broadcast - packets *only*. Interface specific sockets are opened in - make_subnet() in namedbsubnet.c. Thus we bind to the - address "0.0.0.0". The parameter 'socket address' is - now deprecated. - */ - - if ( isdaemon ) - ClientNMB = open_socket_in(SOCK_DGRAM, port,0,0); - else - ClientNMB = 0; - - if ( ClientNMB == -1 ) - return( False ); - - /* we are never interested in SIGPIPE */ - BlockSignals(True,SIGPIPE); - - set_socket_options( ClientNMB, "SO_BROADCAST" ); - - DEBUG( 3, ( "open_sockets: Broadcast sockets opened.\n" ) ); - return( True ); -} /* open_sockets */ - -/**************************************************************************** -usage on the program -****************************************************************************/ -static void usage(char *pname) -{ - printf("Usage: %s [-D]", pname); - - printf("\nVersion %s\n",VERSION); - printf("\t-D run as a daemon\n"); - printf("\t-h usage\n"); - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - pstring configfile; - BOOL is_daemon = False; - int opt; - extern pstring debugf; - int global_nmb_port = NMB_PORT; - - TimeInit(); - - pstrcpy(configfile,CONFIGFILE); - - while ((opt = getopt(argc, argv, "Dh")) != EOF) - { - switch (opt) - { - case 'D': - { - is_daemon = True; - break; - } - case 'h': - default: - { - usage(argv[0]); - break; - } - } - } - - slprintf(debugf, sizeof(debugf)-1, "log.%s", argv[0]); - setup_logging(argv[0], !is_daemon); - - charset_initialise(); - - if (!lp_load(configfile,True,False,False)) - { - DEBUG(0,("Unable to load config file\n")); - } - - if (is_daemon) - { - DEBUG(0,("%s: becoming daemon\n", argv[0])); - become_daemon(); - } - - if (!open_sockets(True, global_nmb_port)) - { - return 1; - } - - start_nmb_agent(); - - return 0; -} diff --git a/source/utils/smb-agent.c b/source/utils/smb-agent.c deleted file mode 100644 index 2ecfdba7e24..00000000000 --- a/source/utils/smb-agent.c +++ /dev/null @@ -1,385 +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" - -#define SECURITY_MASK 0 -#define SECURITY_SET 0 - -/* this forces non-unicode */ -#define CAPABILITY_MASK CAP_UNICODE -#define CAPABILITY_SET 0 - -/* and non-unicode for the client too */ -#define CLI_CAPABILITY_MASK CAP_UNICODE -#define CLI_CAPABILITY_SET 0 - -static char packet[BUFFER_SIZE]; - -extern int DEBUGLEVEL; - - -static uint16 mid_offset = 0x0; - -/**************************************************************************** -terminate sockent connection -****************************************************************************/ -static void free_sock(void *sock) -{ - if (sock != NULL) - { - struct cli_state *n = (struct cli_state*)sock; - cli_net_use_del(n->desthost, &n->usr, - False, NULL); - } -} - - -static struct cli_state *init_client_connection(int c) -{ - pstring buf; - struct user_creds usr; - int rl; - uint32 len; - BOOL new_con = False; - CREDS_CMD cmd; - prs_struct ps; - BOOL reuse = False; - - ZERO_STRUCT(usr); - ZERO_STRUCT(cmd); - cmd.cred = &usr; - - ZERO_STRUCT(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: - { - new_con = True; - break; - } - case AGENT_CMD_CON_REUSE: - { - new_con = True; - reuse = True; - break; - } - default: - { - DEBUG(0,("unknown command %d\n", cmd.command)); - return NULL; - } - } - - if (new_con) - { - struct cli_state *n; - n = cli_net_use_add(cmd.name, &usr.ntc, False, reuse); - - if (n == NULL) - { - DEBUG(0,("Unable to connect to %s\n", cmd.name)); - return NULL; - } - - mid_offset += MIN(MAX(n->max_mux, 1), MAX_MAX_MUX_LIMIT); - - if (mid_offset > 0xffff) - { - mid_offset = 0x0; - } - DEBUG(10,("new mid offset: %d\n", mid_offset)); - - if (write(c, n, sizeof(*n)) < 0) - { - DEBUG(0,("Could not write connection down pipe.\n")); - cli_net_use_del(cmd.name, &usr.ntc, False, NULL); - return NULL; - } - return n; - } - return NULL; -} - -static void filter_reply(char *buf, int moff) -{ - int msg_type = CVAL(buf,0); - int x; - - if (msg_type != 0x0) return; - - /* alter the mid */ - x = SVAL(buf, smb_mid); - x += moff; - - if (x < 0) - { - x += 0x10000; - } - if (x > 0xffff) - { - x -= 0x10000; - } - - SCVAL(buf, smb_mid, x); - -} - -static BOOL process_cli_sock(struct sock_redir **socks, uint32 num_socks, - struct sock_redir *sock) -{ - struct cli_state *n = (struct cli_state*)sock->n; - if (n == NULL) - { - n = init_client_connection(sock->c); - if (n == NULL) - { - return False; - } - sock->n = (void*)n; - sock->s_id = mid_offset; - sock->s = n->fd; - } - else - { - if (!receive_smb(sock->c, packet, 0)) - { - DEBUG(0,("client closed connection\n")); - return False; - } - - filter_reply(packet, sock->s_id); - /* ignore keep-alives */ - if (CVAL(packet, 0) != 0x85) - { - if (!send_smb(sock->s, packet)) - { - DEBUG(0,("server is dead\n")); - return False; - } - } - } - return True; -} - -static int get_smbmid(char *buf) -{ - int msg_type = CVAL(buf,0); - - if (msg_type != 0x0) - { - return -1; - } - - return SVAL(buf,smb_mid); -} - -static BOOL process_srv_sock(struct sock_redir **socks, uint32 num_socks, - int fd) -{ - int smbmid; - int i; - if (!receive_smb(fd, packet, 0)) - { - DEBUG(0,("server closed connection\n")); - return False; - } - - smbmid = get_smbmid(packet); - - DEBUG(10,("process_srv_sock:\tfd:\t%d\tmid:\t%d\n", fd, smbmid)); - - if (smbmid == -1) - { - return True; - } - - for (i = 0; i < num_socks; i++) - { - int moff; - struct cli_state *n; - if (socks[i] == NULL || socks[i]->n == NULL) - { - continue; - } - moff = socks[i]->s_id; - n = (struct cli_state*)socks[i]->n; - DEBUG(10,("list:\tfd:\t%d\tmid:\t%d\tmoff:\t%d\n", - socks[i]->s, - n->mid, - moff)); - if (smbmid != n->mid + moff) - { - continue; - } - filter_reply(packet, -moff); - 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 *id) -{ - fstring path; - fstring dir; - - slprintf(dir, sizeof(dir)-1, "/tmp/.smb.%d", getuid()); - slprintf(path, sizeof(path)-1, "%s/agent", dir); - - return create_pipe_socket(dir, S_IRUSR|S_IWUSR|S_IXUSR, path, 0); -} - -static void start_smb_agent(void) -{ - struct vagent_ops va = - { - free_sock, - get_agent_sock, - process_cli_sock, - process_srv_sock, - NULL, - NULL, - 0 - }; - - CatchChild(); - - start_agent(&va); -} - -/**************************************************************************** -usage on the program -****************************************************************************/ -static void usage(char *pname) -{ - printf("Usage: %s [-D]", pname); - - printf("\nVersion %s\n",VERSION); - printf("\t-D run as a daemon\n"); - printf("\t-h usage\n"); - printf("\n"); -} - -int main(int argc, char *argv[]) -{ - pstring configfile; - BOOL is_daemon = False; - int opt; - extern pstring debugf; - - TimeInit(); - - pstrcpy(configfile,CONFIGFILE); - - while ((opt = getopt(argc, argv, "Dh")) != EOF) - { - switch (opt) - { - case 'D': - { - is_daemon = True; - break; - } - case 'h': - default: - { - usage(argv[0]); - break; - } - } - } - - slprintf(debugf, sizeof(debugf)-1, "log.%s", argv[0]); - setup_logging(argv[0], !is_daemon); - - charset_initialise(); - - if (!lp_load(configfile,True,False,False)) - { - DEBUG(0,("Unable to load config file\n")); - } - - if (is_daemon) - { - DEBUG(0,("%s: becoming daemon\n", argv[0])); - become_daemon(); - } - - start_smb_agent(); - - return 0; -} diff --git a/source/winregd/winregd.c b/source/winregd/winregd.c deleted file mode 100644 index c317ddd6f44..00000000000 --- a/source/winregd/winregd.c +++ /dev/null @@ -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, "winreg"); - slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name); - add_msrpc_command_processor( pipe_name, argv[0], api_reg_rpc ); - - return msrpc_main(argc, argv); -} diff --git a/source/wkssvcd/wkssvcd.c b/source/wkssvcd/wkssvcd.c deleted file mode 100644 index dcb5bb98eef..00000000000 --- a/source/wkssvcd/wkssvcd.c +++ /dev/null @@ -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, "wkssvc"); - slprintf(debugf, sizeof(debugf), "%s/log.%s", LOGFILEBASE, pipe_name); - add_msrpc_command_processor( pipe_name, argv[0], api_wkssvc_rpc ); - - return msrpc_main(argc, argv); -} |