diff options
author | cvs2svn Import User <samba-bugs@samba.org> | 2003-06-20 12:58:10 +0000 |
---|---|---|
committer | cvs2svn Import User <samba-bugs@samba.org> | 2003-06-20 12:58:10 +0000 |
commit | cdcac240f95b1d5f21d8fa171c97729b94250a5c (patch) | |
tree | 356ce667b1e67113f86863714112612cf866a5fe | |
parent | 751367cd1d71f50751086c776f02583efd929e02 (diff) | |
download | samba-misc-tags/APPLIANCE_HEAD_PRE_3_0_0_RC2_MERGE.tar.gz samba-misc-tags/APPLIANCE_HEAD_PRE_3_0_0_RC2_MERGE.tar.xz samba-misc-tags/APPLIANCE_HEAD_PRE_3_0_0_RC2_MERGE.zip |
This commit was manufactured by cvs2svn to create tagsamba-misc-tags/APPLIANCE_HEAD_PRE_3_0_0_RC2_MERGE
'APPLIANCE_HEAD_PRE_3_0_0_RC2_MERGE'.
54 files changed, 0 insertions, 5048 deletions
diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 30433041802..00000000000 --- a/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -ID -testtmp diff --git a/source/auth/auth_compat.c b/source/auth/auth_compat.c deleted file mode 100644 index a70f1e98b72..00000000000 --- a/source/auth/auth_compat.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Password and authentication handling - Copyright (C) Andrew Bartlett 2001-2002 - - 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" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_AUTH - -/**************************************************************************** - COMPATIBILITY INTERFACES: - ***************************************************************************/ - -/**************************************************************************** -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 -****************************************************************************/ - -NTSTATUS check_plaintext_password(const char *smb_name, DATA_BLOB plaintext_password, auth_serversupplied_info **server_info) -{ - struct auth_context *plaintext_auth_context = NULL; - auth_usersupplied_info *user_info = NULL; - const uint8 *chal; - NTSTATUS nt_status; - if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&plaintext_auth_context))) { - return nt_status; - } - - chal = plaintext_auth_context->get_ntlm_challenge(plaintext_auth_context); - - if (!make_user_info_for_reply(&user_info, - smb_name, lp_workgroup(), chal, - plaintext_password)) { - return NT_STATUS_NO_MEMORY; - } - - nt_status = plaintext_auth_context->check_ntlm_password(plaintext_auth_context, - user_info, server_info); - - (plaintext_auth_context->free)(&plaintext_auth_context); - free_user_info(&user_info); - return nt_status; -} - -static NTSTATUS pass_check_smb(const char *smb_name, - const char *domain, - DATA_BLOB lm_pwd, - DATA_BLOB nt_pwd, - DATA_BLOB plaintext_password, - BOOL encrypted) - -{ - NTSTATUS nt_status; - extern struct auth_context *negprot_global_auth_context; - auth_serversupplied_info *server_info = NULL; - if (encrypted) { - auth_usersupplied_info *user_info = NULL; - make_user_info_for_reply_enc(&user_info, smb_name, - domain, - lm_pwd, - nt_pwd); - nt_status = negprot_global_auth_context->check_ntlm_password(negprot_global_auth_context, - user_info, &server_info); - free_user_info(&user_info); - } else { - nt_status = check_plaintext_password(smb_name, plaintext_password, &server_info); - } - free_server_info(&server_info); - return nt_status; -} - -/**************************************************************************** -check if a username/password pair is ok via the auth subsystem. -return True if the password is correct, False otherwise -****************************************************************************/ -BOOL password_ok(char *smb_name, DATA_BLOB password_blob) -{ - - DATA_BLOB null_password = data_blob(NULL, 0); - extern BOOL global_encrypted_passwords_negotiated; - BOOL encrypted = (global_encrypted_passwords_negotiated && password_blob.length == 24); - - if (encrypted) { - /* - * The password could be either NTLM or plain LM. Try NTLM first, - * but fall-through as required. - * NTLMv2 makes no sense here. - */ - if (NT_STATUS_IS_OK(pass_check_smb(smb_name, lp_workgroup(), null_password, password_blob, null_password, encrypted))) { - return True; - } - - if (NT_STATUS_IS_OK(pass_check_smb(smb_name, lp_workgroup(), password_blob, null_password, null_password, encrypted))) { - return True; - } - } else { - if (NT_STATUS_IS_OK(pass_check_smb(smb_name, lp_workgroup(), null_password, null_password, password_blob, encrypted))) { - return True; - } - } - - return False; -} - - diff --git a/source/codepages/lowcase.dat b/source/codepages/lowcase.dat Binary files differdeleted file mode 100644 index 62b6e2e952b..00000000000 --- a/source/codepages/lowcase.dat +++ /dev/null diff --git a/source/codepages/upcase.dat b/source/codepages/upcase.dat Binary files differdeleted file mode 100644 index bb6f9beb4e3..00000000000 --- a/source/codepages/upcase.dat +++ /dev/null diff --git a/source/codepages/valid.dat b/source/codepages/valid.dat Binary files differdeleted file mode 100644 index 78c14b33f0f..00000000000 --- a/source/codepages/valid.dat +++ /dev/null diff --git a/source/include/hmacmd5.h b/source/include/hmacmd5.h deleted file mode 100644 index 6b53a6fd074..00000000000 --- a/source/include/hmacmd5.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - Unix SMB/CIFS implementation. - 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/intl.h b/source/include/intl.h deleted file mode 100644 index 5b56d9aa2c9..00000000000 --- a/source/include/intl.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - Unix SMB/CIFS implementation. - internationalisation headers - Copyright (C) Andrew Tridgell 2001 - - 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. -*/ - - -/* ideally we would have a static mapping, but that precludes - dynamic loading. This is a reasonable compromise */ -#define _(x) lang_msg_rotate(x) diff --git a/source/include/libsmb_internal.h b/source/include/libsmb_internal.h deleted file mode 100644 index 21fe47d4b29..00000000000 --- a/source/include/libsmb_internal.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _LIBSMB_INTERNAL_H_ -#define _LIBSMB_INTERNAL_H_ - -#define SMBC_MAX_NAME 1023 -#define SMBC_FILE_MODE (S_IFREG | 0444) -#define SMBC_DIR_MODE (S_IFDIR | 0555) - - -#include "../include/libsmbclient.h" - - -struct _SMBCSRV { - struct cli_state cli; - dev_t dev; - BOOL no_pathinfo2; - int server_fd; - - SMBCSRV *next, *prev; - -}; - -/* - * Keep directory entries in a list - */ -struct smbc_dir_list { - struct smbc_dir_list *next; - struct smbc_dirent *dirent; -}; - - -/* - * Structure for open file management - */ -struct _SMBCFILE { - int cli_fd; - char *fname; - off_t offset; - struct _SMBCSRV *srv; - BOOL file; - struct smbc_dir_list *dir_list, *dir_end, *dir_next; - int dir_type, dir_error; - - SMBCFILE *next, *prev; -}; - - -struct smbc_internal_data { - - /** INTERNAL: is this handle initialized ? - */ - int _initialized; - - /** INTERNAL: dirent pointer location - */ - char _dirent[512]; - - /** INTERNAL: server connection list - */ - SMBCSRV * _servers; - - /** INTERNAL: open file/dir list - */ - SMBCFILE * _files; -}; - - -#endif diff --git a/source/include/md5.h b/source/include/md5.h deleted file mode 100644 index 6665171e7c5..00000000000 --- a/source/include/md5.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MD5_H -#define MD5_H -#ifndef HEADER_MD5_H -/* Try to avoid clashes with OpenSSL */ -#define HEADER_MD5_H -#endif - -struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - unsigned char in[64]; -}; - -void MD5Init(struct MD5Context *context); -void MD5Update(struct MD5Context *context, unsigned char const *buf, - unsigned len); -void MD5Final(unsigned char digest[16], struct MD5Context *context); - -/* - * This is needed to make RSAREF happy on some MS-DOS compilers. - */ -typedef struct MD5Context MD5_CTX; - -#endif /* !MD5_H */ diff --git a/source/include/nt_status.h b/source/include/nt_status.h deleted file mode 100644 index 9747f73eb18..00000000000 --- a/source/include/nt_status.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB parameters and setup, plus a whole lot more. - - Copyright (C) Andrew Tridgell 2001 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef _NT_STATUS_H -#define _NT_STATUS_H - -/* The Splint code analysis tool doesn't like immediate structures. */ - -#ifdef _SPLINT_ /* http://www.splint.org */ -#undef HAVE_IMMEDIATE_STRUCTURES -#endif - -/* the following rather strange looking definitions of NTSTATUS and WERROR - and there in order to catch common coding errors where different error types - are mixed up. This is especially important as we slowly convert Samba - from using BOOL for internal functions -*/ - -#if defined(HAVE_IMMEDIATE_STRUCTURES) -typedef struct {uint32 v;} NTSTATUS; -#define NT_STATUS(x) ((NTSTATUS) { x }) -#define NT_STATUS_V(x) ((x).v) -#else -typedef uint32 NTSTATUS; -#define NT_STATUS(x) (x) -#define NT_STATUS_V(x) (x) -#endif - -#if defined(HAVE_IMMEDIATE_STRUCTURES) -typedef struct {uint32 v;} WERROR; -#define W_ERROR(x) ((WERROR) { x }) -#define W_ERROR_V(x) ((x).v) -#else -typedef uint32 WERROR; -#define W_ERROR(x) (x) -#define W_ERROR_V(x) (x) -#endif - -#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0) -#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) -#define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y)) -#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) -#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) - -#endif diff --git a/source/include/pstring.h b/source/include/pstring.h deleted file mode 100644 index 92870e4cae5..00000000000 --- a/source/include/pstring.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - samba -- Unix SMB/CIFS implementation. - Safe standardized string types - - Copyright (C) Andrew Tridgell 1992-2000 - Copyright (C) John H Terpstra 1996-2000 - Copyright (C) Luke Kenneth Casson Leighton 1996-2000 - Copyright (C) Paul Ashton 1998-2000 - Copyright (C) Martin Pool 2002 - - 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 _PSTRING - -#define PSTRING_LEN 1024 -#define FSTRING_LEN 256 - -typedef char pstring[PSTRING_LEN]; -typedef char fstring[FSTRING_LEN]; - -#define _PSTRING - -#endif /* ndef _PSTRING */ diff --git a/source/include/session.h b/source/include/session.h deleted file mode 100644 index f613afee09a..00000000000 --- a/source/include/session.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Unix SMB/CIFS implementation. - session handling for recording currently vailid vuids - Copyright (C) tridge@samba.org 2001 - Copyright (C) Andew Bartlett <abartlet@samba.org> 2001 - - 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. -*/ - -/* a "session" is claimed when we do a SessionSetupX operation - and is yielded when the corresponding vuid is destroyed. - - sessions are used to populate utmp and PAM session structures -*/ - -struct sessionid { - uid_t uid; - gid_t gid; - fstring username; - fstring hostname; - fstring netbios_name; - fstring remote_machine; - fstring id_str; - uint32 id_num; - uint32 pid; - fstring ip_addr; -}; - diff --git a/source/intl/.cvsignore b/source/intl/.cvsignore deleted file mode 100644 index 5f2a5c4cf75..00000000000 --- a/source/intl/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.po -*.po32 diff --git a/source/intl/linux-msg.sed b/source/intl/linux-msg.sed deleted file mode 100644 index 5918e720a9a..00000000000 --- a/source/intl/linux-msg.sed +++ /dev/null @@ -1,100 +0,0 @@ -# po2msg.sed - Convert Uniforum style .po file to Linux style .msg file -# Copyright (C) 1995 Free Software Foundation, Inc. -# Ulrich Drepper <drepper@gnu.ai.mit.edu>, 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# The first directive in the .msg should be the definition of the -# message set number. We use always set number 1. -# -1 { - i\ -$set 1 # Automatically created by po2msg.sed - h - s/.*/0/ - x -} -# -# Mitch's old catalog format does not allow comments. -# -# We copy the original message as a comment into the .msg file. -# -/^msgid/ { - s/msgid[ ]*"// -# -# This does not work now with the new format. -# /"$/! { -# s/\\$// -# s/$/ ... (more lines following)"/ -# } - x -# The following nice solution is by -# Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de> - td -# Increment a decimal number in pattern space. -# First hide trailing `9' digits. - :d - s/9\(_*\)$/_\1/ - td -# Assure at least one digit is available. - s/^\(_*\)$/0\1/ -# Increment the last digit. - s/8\(_*\)$/9\1/ - s/7\(_*\)$/8\1/ - s/6\(_*\)$/7\1/ - s/5\(_*\)$/6\1/ - s/4\(_*\)$/5\1/ - s/3\(_*\)$/4\1/ - s/2\(_*\)$/3\1/ - s/1\(_*\)$/2\1/ - s/0\(_*\)$/1\1/ -# Convert the hidden `9' digits to `0's. - s/_/0/g - x - G - s/\(.*\)"\n\([0-9]*\)/$ #\2 Original Message:(\1)/p -} -# -# The .msg file contains, other then the .po file, only the translations -# but each given a unique ID. Starting from 1 and incrementing by 1 for -# each message we assign them to the messages. -# It is important that the .po file used to generate the cat-id-tbl.c file -# (with po-to-tbl) is the same as the one used here. (At least the order -# of declarations must not be changed.) -# -/^msgstr/ { - s/msgstr[ ]*"\(.*\)"/# \1/ -# Clear substitution flag. - tb -# Append the next line. - :b - N -# Look whether second part is continuation line. - s/\(.*\n\)"\(.*\)"/\1\2/ -# Yes, then branch. - ta - P - D -# Note that D includes a jump to the start!! -# We found a continuation line. But before printing insert '\'. - :a - s/\(.*\)\(\n.*\)/\1\\\2/ - P -# We cannot use D here. - s/.*\n\(.*\)/\1/ - tb -} -d diff --git a/source/lib/hmacmd5.c b/source/lib/hmacmd5.c deleted file mode 100644 index f436fd30c0e..00000000000 --- a/source/lib/hmacmd5.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - Unix SMB/CIFS implementation. - HMAC MD5 code for use in NTLMv2 - Copyright (C) Luke Kenneth Casson Leighton 1996-2000 - Copyright (C) Andrew Tridgell 1992-2000 - - 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 */ - ZERO_STRUCT(ctx->k_ipad); - ZERO_STRUCT(ctx->k_opad); - memcpy( ctx->k_ipad, key, key_len); - memcpy( ctx->k_opad, key, 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 */ - ZERO_STRUCT(ctx->k_ipad); - ZERO_STRUCT(ctx->k_opad); - memcpy( ctx->k_ipad, key, key_len); - memcpy( ctx->k_opad, key, 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); -} - -/*********************************************************** - single function to calculate an HMAC MD5 digest from data. - use the microsoft hmacmd5 init method because the key is 16 bytes. -************************************************************/ -void hmac_md5( uchar key[16], uchar* data, int data_len, uchar* digest) -{ - HMACMD5Context ctx; - hmac_md5_init_limK_to_64(key, 16, &ctx); - if (data_len != 0) - { - hmac_md5_update(data, data_len, &ctx); - } - hmac_md5_final(digest, &ctx); -} - diff --git a/source/lib/md5.c b/source/lib/md5.c deleted file mode 100644 index 2121b170479..00000000000 --- a/source/lib/md5.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * 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. - */ - -/* This code slightly modified to fit into Samba by - abartlet@samba.org Jun 2001 */ - -#include "includes.h" - -#include "md5.h" - -static void MD5Transform(uint32 buf[4], uint32 const in[16]); - -/* - * Note: this code is harmless on little-endian machines. - */ -static void byteReverse(unsigned char *buf, unsigned longs) -{ - uint32 t; - do { - t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32 *) buf = t; - buf += 4; - } while (--longs); -} - -/* - * 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, unsigned char const *buf, unsigned len) -{ - register uint32 t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32) len << 3)) < 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) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memmove(p, buf, len); - return; - } - memmove(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memmove(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memmove(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(unsigned char digest[16], struct MD5Context *ctx) -{ - unsigned int count; - unsigned char *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); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32 *) 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); - } - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((uint32 *) ctx->in)[14] = ctx->bits[0]; - ((uint32 *) ctx->in)[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, (uint32 *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memmove(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - -/* 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. - */ -static void MD5Transform(uint32 buf[4], uint32 const in[16]) -{ - register uint32 a, b, c, d; - - 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; -} diff --git a/source/lib/util_pw.c b/source/lib/util_pw.c deleted file mode 100644 index 9d075a05e88..00000000000 --- a/source/lib/util_pw.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Safe versions of getpw* calls - - Copyright (C) Andrew Bartlett 2002 - - 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 struct passwd *alloc_copy_passwd(const struct passwd *from) -{ - struct passwd *ret = smb_xmalloc(sizeof(struct passwd)); - ZERO_STRUCTP(ret); - ret->pw_name = smb_xstrdup(from->pw_name); - ret->pw_passwd = smb_xstrdup(from->pw_passwd); - ret->pw_uid = from->pw_uid; - ret->pw_gid = from->pw_gid; - ret->pw_gecos = smb_xstrdup(from->pw_gecos); - ret->pw_dir = smb_xstrdup(from->pw_dir); - ret->pw_shell = smb_xstrdup(from->pw_shell); - return ret; -} - -void passwd_free (struct passwd **buf) -{ - if (!*buf) { - DEBUG(0, ("attempted double-free of allocated passwd\n")); - return; - } - - SAFE_FREE((*buf)->pw_name); - SAFE_FREE((*buf)->pw_passwd); - SAFE_FREE((*buf)->pw_gecos); - SAFE_FREE((*buf)->pw_dir); - SAFE_FREE((*buf)->pw_shell); - - SAFE_FREE(*buf); -} - -struct passwd *getpwnam_alloc(const char *name) -{ - struct passwd *temp; - - temp = sys_getpwnam(name); - - if (!temp) { -#if 0 - if (errno == ENOMEM) { - /* what now? */ - } -#endif - return NULL; - } - - return alloc_copy_passwd(temp); -} - -struct passwd *getpwuid_alloc(uid_t uid) -{ - struct passwd *temp; - - temp = sys_getpwuid(uid); - - if (!temp) { -#if 0 - if (errno == ENOMEM) { - /* what now? */ - } -#endif - return NULL; - } - - return alloc_copy_passwd(temp); -} diff --git a/source/lib/util_smbd.c b/source/lib/util_smbd.c deleted file mode 100644 index 071f20b4162..00000000000 --- a/source/lib/util_smbd.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions, used in smbd only - Copyright (C) Andrew Tridgell 2002 - - 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" - -/* - This function requires sys_getgrouplist - which is only - available in smbd due to it's use of become_root() in a - legacy systems hack. -*/ - -/* - return a full list of groups for a user - - returns the number of groups the user is a member of. The return will include the - users primary group. - - remember to free the resulting gid_t array - - NOTE! uses become_root() to gain correct priviages on systems - that lack a native getgroups() call (uses initgroups and getgroups) -*/ -int getgroups_user(const char *user, gid_t **groups) -{ - struct passwd *pwd; - int ngrp, max_grp; - - pwd = getpwnam_alloc(user); - if (!pwd) return -1; - - max_grp = groups_max(); - (*groups) = (gid_t *)malloc(sizeof(gid_t) * max_grp); - if (! *groups) { - passwd_free(&pwd); - errno = ENOMEM; - return -1; - } - - ngrp = sys_getgrouplist(user, pwd->pw_gid, *groups, &max_grp); - if (ngrp <= 0) { - passwd_free(&pwd); - free(*groups); - return ngrp; - } - - passwd_free(&pwd); - return ngrp; -} diff --git a/source/libads/.cvsignore b/source/libads/.cvsignore deleted file mode 100644 index 5f2a5c4cf75..00000000000 --- a/source/libads/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.po -*.po32 diff --git a/source/libads/ads_status.c b/source/libads/ads_status.c deleted file mode 100644 index 80fdb99eac0..00000000000 --- a/source/libads/ads_status.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - Unix SMB/CIFS implementation. - ads (active directory) utility library - Copyright (C) Andrew Tridgell 2001 - Copyright (C) Remus Koos 2001 - Copyright (C) Andrew Bartlett 2001 - - - 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" - -/* - build a ADS_STATUS structure -*/ -ADS_STATUS ads_build_error(enum ads_error_type etype, - int rc, int minor_status) -{ - ADS_STATUS ret; - - if (etype == ADS_ERROR_NT) { - DEBUG(0,("don't use ads_build_error with ADS_ERROR_NT!\n")); - ret.err.rc = -1; - ret.error_type = ADS_ERROR_SYSTEM; - ret.minor_status = 0; - return ret; - } - - ret.err.rc = rc; - ret.error_type = etype; - ret.minor_status = minor_status; - return ret; -} - -ADS_STATUS ads_build_nt_error(enum ads_error_type etype, - NTSTATUS nt_status) -{ - ADS_STATUS ret; - - if (etype != ADS_ERROR_NT) { - DEBUG(0,("don't use ads_build_nt_error without ADS_ERROR_NT!\n")); - ret.err.rc = -1; - ret.error_type = ADS_ERROR_SYSTEM; - ret.minor_status = 0; - return ret; - } - ret.err.nt_status = nt_status; - ret.error_type = etype; - ret.minor_status = 0; - return ret; -} - -/* - do a rough conversion between ads error codes and NT status codes - we'll need to fill this in more -*/ -NTSTATUS ads_ntstatus(ADS_STATUS status) -{ - if (status.error_type == ADS_ERROR_NT){ - return status.err.nt_status; - } -#ifdef HAVE_LDAP - if ((status.error_type == ADS_ERROR_LDAP) - && (status.err.rc == LDAP_NO_MEMORY)) { - return NT_STATUS_NO_MEMORY; - } -#endif - if (ADS_ERR_OK(status)) return NT_STATUS_OK; - return NT_STATUS_UNSUCCESSFUL; -} - -/* - return a string for an error from a ads routine -*/ -const char *ads_errstr(ADS_STATUS status) -{ - int msg_ctx; - static char *ret; - - SAFE_FREE(ret); - msg_ctx = 0; - - switch (status.error_type) { - case ADS_ERROR_SYSTEM: - return strerror(status.err.rc); -#ifdef HAVE_LDAP - case ADS_ERROR_LDAP: - return ldap_err2string(status.err.rc); -#endif -#ifdef HAVE_KRB5 - case ADS_ERROR_KRB5: - return error_message(status.err.rc); -#endif -#ifdef HAVE_GSSAPI - case ADS_ERROR_GSS: - { - uint32 minor; - - gss_buffer_desc msg1, msg2; - msg1.value = NULL; - msg2.value = NULL; - gss_display_status(&minor, status.err.rc, GSS_C_GSS_CODE, - GSS_C_NULL_OID, &msg_ctx, &msg1); - gss_display_status(&minor, status.minor_status, GSS_C_MECH_CODE, - GSS_C_NULL_OID, &msg_ctx, &msg2); - asprintf(&ret, "%s : %s", (char *)msg1.value, (char *)msg2.value); - gss_release_buffer(&minor, &msg1); - gss_release_buffer(&minor, &msg2); - return ret; - } -#endif - case ADS_ERROR_NT: - return nt_errstr(ads_ntstatus(status)); - default: - return "Unknown ADS error type!? (not compiled in?)"; - } - -} - - diff --git a/source/libads/kerberos.c b/source/libads/kerberos.c deleted file mode 100644 index bef2febaefd..00000000000 --- a/source/libads/kerberos.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - Unix SMB/CIFS implementation. - kerberos utility library - Copyright (C) Andrew Tridgell 2001 - Copyright (C) Remus Koos 2001 - - - 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_KRB5 - -/* - we use a prompter to avoid a crash bug in the kerberos libs when - dealing with empty passwords - this prompter is just a string copy ... -*/ -static krb5_error_code -kerb_prompter(krb5_context ctx, void *data, - const char *name, - const char *banner, - int num_prompts, - krb5_prompt prompts[]) -{ - if (num_prompts == 0) return 0; - - memset(prompts[0].reply->data, 0, prompts[0].reply->length); - if (prompts[0].reply->length > 0) { - if (data) { - strncpy(prompts[0].reply->data, data, prompts[0].reply->length-1); - prompts[0].reply->length = strlen(prompts[0].reply->data); - } else { - prompts[0].reply->length = 0; - } - } - return 0; -} - -/* - simulate a kinit, putting the tgt in the default cache location - remus@snapserver.com -*/ -int kerberos_kinit_password(const char *principal, const char *password, int time_offset) -{ - krb5_context ctx; - krb5_error_code code = 0; - krb5_ccache cc; - krb5_principal me; - krb5_creds my_creds; - - if ((code = krb5_init_context(&ctx))) - return code; - - if (time_offset != 0) { - krb5_set_real_time(ctx, time(NULL) + time_offset, 0); - } - - if ((code = krb5_cc_default(ctx, &cc))) { - krb5_free_context(ctx); - return code; - } - - if ((code = krb5_parse_name(ctx, principal, &me))) { - krb5_free_context(ctx); - return code; - } - - if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, NULL, - kerb_prompter, - password, 0, NULL, NULL))) { - krb5_free_principal(ctx, me); - krb5_free_context(ctx); - return code; - } - - if ((code = krb5_cc_initialize(ctx, cc, me))) { - krb5_free_cred_contents(ctx, &my_creds); - krb5_free_principal(ctx, me); - krb5_free_context(ctx); - return code; - } - - if ((code = krb5_cc_store_cred(ctx, cc, &my_creds))) { - krb5_cc_close(ctx, cc); - krb5_free_cred_contents(ctx, &my_creds); - krb5_free_principal(ctx, me); - krb5_free_context(ctx); - return code; - } - - krb5_cc_close(ctx, cc); - krb5_free_cred_contents(ctx, &my_creds); - krb5_free_principal(ctx, me); - krb5_free_context(ctx); - - return 0; -} - - - -/* run kinit to setup our ccache */ -int ads_kinit_password(ADS_STRUCT *ads) -{ - char *s; - int ret; - - if (asprintf(&s, "%s@%s", ads->auth.user_name, ads->auth.realm) == -1) { - return KRB5_CC_NOMEM; - } - - if (!ads->auth.password) { - return KRB5_LIBOS_CANTREADPWD; - } - - ret = kerberos_kinit_password(s, ads->auth.password, ads->auth.time_offset); - - if (ret) { - DEBUG(0,("kerberos_kinit_password %s failed: %s\n", - s, error_message(ret))); - } - free(s); - return ret; -} - - -#endif diff --git a/source/libsmb/libsmb_compat.c b/source/libsmb/libsmb_compat.c deleted file mode 100644 index 27b274953ab..00000000000 --- a/source/libsmb/libsmb_compat.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB client library implementation (Old interface compatibility) - Copyright (C) Andrew Tridgell 1998 - Copyright (C) Richard Sharpe 2000 - Copyright (C) John Terpstra 2000 - Copyright (C) Tom Jansen (Ninja ISD) 2002 - - 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 "../include/libsmb_internal.h" - -struct smbc_compat_fdlist { - SMBCFILE * file; - int fd; - struct smbc_compat_fdlist *next, *prev; -}; - -static SMBCCTX * statcont = NULL; -static int smbc_compat_initialized = 0; -static int smbc_currentfd = 10000; -static struct smbc_compat_fdlist * smbc_compat_fdlist = NULL; - - -/* Find an fd and return the SMBCFILE * or NULL on failure */ -static SMBCFILE * find_fd(int fd) -{ - struct smbc_compat_fdlist * f = smbc_compat_fdlist; - while (f) { - if (f->fd == fd) - return f->file; - f = f->next; - } - return NULL; -} - -/* Add an fd, returns 0 on success, -1 on error with errno set */ -static int add_fd(SMBCFILE * file) -{ - struct smbc_compat_fdlist * f = malloc(sizeof(struct smbc_compat_fdlist)); - if (!f) { - errno = ENOMEM; - return -1; - } - - f->fd = smbc_currentfd++; - f->file = file; - - DLIST_ADD(smbc_compat_fdlist, f); - - return f->fd; -} - - - -/* Delete an fd, returns 0 on success */ -static int del_fd(int fd) -{ - struct smbc_compat_fdlist * f = smbc_compat_fdlist; - while (f) { - if (f->fd == fd) - break; - f = f->next; - } - if (f) { - /* found */ - DLIST_REMOVE(smbc_compat_fdlist, f); - SAFE_FREE(f); - return 0; - } - return 1; -} - - - -int smbc_init(smbc_get_auth_data_fn fn, int debug) -{ - if (!smbc_compat_initialized) { - statcont = smbc_new_context(); - if (!statcont) - return -1; - - statcont->debug = debug; - statcont->callbacks.auth_fn = fn; - - if (!smbc_init_context(statcont)) { - smbc_free_context(statcont, False); - return -1; - } - - smbc_compat_initialized = 1; - - return 0; - } - return 0; -} - - -int smbc_open(const char *furl, int flags, mode_t mode) -{ - SMBCFILE * file; - int fd; - - file = statcont->open(statcont, furl, flags, mode); - if (!file) - return -1; - - fd = add_fd(file); - if (fd == -1) - statcont->close(statcont, file); - return fd; -} - - -int smbc_creat(const char *furl, mode_t mode) -{ - SMBCFILE * file; - int fd; - - file = statcont->creat(statcont, furl, mode); - if (!file) - return -1; - - fd = add_fd(file); - if (fd == -1) { - /* Hmm... should we delete the file too ? I guess we could try */ - statcont->close(statcont, file); - statcont->unlink(statcont, furl); - } - return fd; -} - - -ssize_t smbc_read(int fd, void *buf, size_t bufsize) -{ - SMBCFILE * file = find_fd(fd); - return statcont->read(statcont, file, buf, bufsize); -} - -ssize_t smbc_write(int fd, void *buf, size_t bufsize) -{ - SMBCFILE * file = find_fd(fd); - return statcont->write(statcont, file, buf, bufsize); -} - -off_t smbc_lseek(int fd, off_t offset, int whence) -{ - SMBCFILE * file = find_fd(fd); - return statcont->lseek(statcont, file, offset, whence); -} - -int smbc_close(int fd) -{ - SMBCFILE * file = find_fd(fd); - del_fd(fd); - return statcont->close(statcont, file); -} - -int smbc_unlink(const char *fname) -{ - return statcont->unlink(statcont, fname); -} - -int smbc_rename(const char *ourl, const char *nurl) -{ - return statcont->rename(statcont, ourl, statcont, nurl); -} - -int smbc_opendir(const char *durl) -{ - SMBCFILE * file; - int fd; - - file = statcont->opendir(statcont, durl); - if (!file) - return -1; - - fd = add_fd(file); - if (fd == -1) - statcont->closedir(statcont, file); - - return fd; -} - -int smbc_closedir(int dh) -{ - SMBCFILE * file = find_fd(dh); - del_fd(dh); - return statcont->closedir(statcont, file); -} - -int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count) -{ - SMBCFILE * file = find_fd(dh); - return statcont->getdents(statcont, file,dirp, count); -} - -struct smbc_dirent* smbc_readdir(unsigned int dh) -{ - SMBCFILE * file = find_fd(dh); - return statcont->readdir(statcont, file); -} - -off_t smbc_telldir(int dh) -{ - SMBCFILE * file = find_fd(dh); - return statcont->telldir(statcont, file); -} - -int smbc_lseekdir(int fd, off_t offset) -{ - SMBCFILE * file = find_fd(fd); - return statcont->lseekdir(statcont, file, offset); -} - -int smbc_mkdir(const char *durl, mode_t mode) -{ - return statcont->mkdir(statcont, durl, mode); -} - -int smbc_rmdir(const char *durl) -{ - return statcont->rmdir(statcont, durl); -} - -int smbc_stat(const char *url, struct stat *st) -{ - return statcont->stat(statcont, url, st); -} - -int smbc_fstat(int fd, struct stat *st) -{ - SMBCFILE * file = find_fd(fd); - return statcont->fstat(statcont, file, st); -} - -int smbc_chmod(const char *url, mode_t mode) -{ - /* NOT IMPLEMENTED IN LIBSMBCLIENT YET */ - return -1; -} - -int smbc_print_file(const char *fname, const char *printq) -{ - return statcont->print_file(statcont, fname, statcont, printq); -} - -int smbc_open_print_job(const char *fname) -{ - SMBCFILE * file = statcont->open_print_job(statcont, fname); - if (!file) return -1; - return (int) file; -} - -int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) -{ - return statcont->list_print_jobs(statcont, purl, fn); -} - -int smbc_unlink_print_job(const char *purl, int id) -{ - return statcont->unlink_print_job(statcont, purl, id); -} - - diff --git a/source/nsswitch/winbind_client.h b/source/nsswitch/winbind_client.h deleted file mode 100644 index 4de2d57cc7d..00000000000 --- a/source/nsswitch/winbind_client.h +++ /dev/null @@ -1,16 +0,0 @@ -#include "winbind_nss_config.h" -#include "winbindd_nss.h" - -void init_request(struct winbindd_request *req,int rq_type); -NSS_STATUS winbindd_send_request(int req_type, - struct winbindd_request *request); -NSS_STATUS winbindd_get_response(struct winbindd_response *response); -NSS_STATUS winbindd_request(int req_type, - struct winbindd_request *request, - struct winbindd_response *response); -int winbind_open_pipe_sock(void); -int write_sock(void *buffer, int count); -int read_reply(struct winbindd_response *response); -void close_sock(void); -void free_response(struct winbindd_response *response); - diff --git a/source/passdb/.cvsignore b/source/passdb/.cvsignore deleted file mode 100644 index 5f2a5c4cf75..00000000000 --- a/source/passdb/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.po -*.po32 diff --git a/source/passdb/pdb_compat.c b/source/passdb/pdb_compat.c deleted file mode 100644 index abd572a7c14..00000000000 --- a/source/passdb/pdb_compat.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SAM_ACCOUNT access routines - Copyright (C) Jeremy Allison 1996-2001 - Copyright (C) Luke Kenneth Casson Leighton 1996-1998 - Copyright (C) Gerald (Jerry) Carter 2000-2001 - Copyright (C) Andrew Bartlett 2001-2002 - Copyright (C) Stefan (metze) Metzmacher 2002 - - 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" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_PASSDB - -uint32 pdb_get_user_rid (const SAM_ACCOUNT *sampass) -{ - uint32 u_rid; - - if (sampass) - if (sid_peek_check_rid(get_global_sam_sid(), pdb_get_user_sid(sampass),&u_rid)) - return u_rid; - - return (0); -} - -uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass) -{ - uint32 g_rid; - - if (sampass) - if (sid_peek_check_rid(get_global_sam_sid(), pdb_get_group_sid(sampass),&g_rid)) - return g_rid; - return (0); -} - -BOOL pdb_set_user_sid_from_rid (SAM_ACCOUNT *sampass, uint32 rid, enum pdb_value_state flag) -{ - DOM_SID u_sid; - const DOM_SID *global_sam_sid; - - if (!sampass) - return False; - - if (!(global_sam_sid = get_global_sam_sid())) { - DEBUG(1, ("pdb_set_user_sid_from_rid: Could not read global sam sid!\n")); - return False; - } - - sid_copy(&u_sid, global_sam_sid); - - if (!sid_append_rid(&u_sid, rid)) - return False; - - if (!pdb_set_user_sid(sampass, &u_sid, flag)) - return False; - - DEBUG(10, ("pdb_set_user_sid_from_rid:\n\tsetting user sid %s from rid %d\n", - sid_string_static(&u_sid),rid)); - - return True; -} - -BOOL pdb_set_group_sid_from_rid (SAM_ACCOUNT *sampass, uint32 grid, enum pdb_value_state flag) -{ - DOM_SID g_sid; - const DOM_SID *global_sam_sid; - - if (!sampass) - return False; - - if (!(global_sam_sid = get_global_sam_sid())) { - DEBUG(1, ("pdb_set_user_sid_from_rid: Could not read global sam sid!\n")); - return False; - } - - sid_copy(&g_sid, global_sam_sid); - - if (!sid_append_rid(&g_sid, grid)) - return False; - - if (!pdb_set_group_sid(sampass, &g_sid, flag)) - return False; - - DEBUG(10, ("pdb_set_group_sid_from_rid:\n\tsetting group sid %s from rid %d\n", - sid_string_static(&g_sid), grid)); - - return True; -} - diff --git a/source/python/.cvsignore b/source/python/.cvsignore deleted file mode 100644 index 7e99e367f84..00000000000 --- a/source/python/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc
\ No newline at end of file diff --git a/source/python/README b/source/python/README deleted file mode 100644 index 04f794215ab..00000000000 --- a/source/python/README +++ /dev/null @@ -1,28 +0,0 @@ -This directory contains Python bindings to allow you to access various -aspects of Samba. At the moment their status is "experimental" and -they are not built by default. - -In order to be able to compile samba-python you need to have python -and the python-dev packages installed. - -Python libraries are always built for a particular version of Python -(2.2, 2.1, etc), and libraries built for one version will not be seen -by another. By default Samba's libraries are built for whatever is -installed as "python" on your $PATH, but you can override this using -the --with-python option. For example - - $ ./configure --with-python=python2.2 - -To build: - -$ autoconf -$ ./configure -$ make python_ext - -Now, you can install the modules: - -$ cp build/lib.*/*.so /usr/lib/python2.1/lib-dynload/ - -(the directory /usr/lib/python2.1 may vary, depending on your installation) - -Samba-python should work now! diff --git a/source/python/gprinterdata b/source/python/gprinterdata deleted file mode 100755 index cd062076c0b..00000000000 --- a/source/python/gprinterdata +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python - -import sys -from gtkdictbrowser import GtkDictBrowser, hex_string -import gtk -from samba import spoolss -import string -import printerdata - -# Initialise printerdata dictionary - -if len(sys.argv) < 2 or len(sys.argv) > 3: - print "Usage: gprinterdata [--ex] <printer>" - print "where <printer> is a UNC printer name." - sys.exit(1) - -try: - host = string.replace(sys.argv[len(sys.argv) - 1], "/", "\\") - if sys.argv[1] == "--ex": - t = printerdata.printerdata_ex(host) - else: - t = printerdata.printerdata(host) -except: - print "gprinterdata: error opening %s" % sys.argv[len(sys.argv) - 1] - sys.exit(1) - -# Create interface - -db = GtkDictBrowser(t) -db.register_get_value_text_fn("", hex_string) -db.build_ui('gprinterdata') - -# Override Python's handling of ctrl-c so we can break out of the -# gui from the command line. - -import signal -signal.signal(signal.SIGINT, signal.SIG_DFL) - -gtk.mainloop() diff --git a/source/python/gtdbtool b/source/python/gtdbtool deleted file mode 100755 index 129f4fe0e2e..00000000000 --- a/source/python/gtdbtool +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python - -import sys -from gtkdictbrowser import GtkDictBrowser -import gtk -from samba import tdb -import string - -# Open handle on tdb - -if len(sys.argv) != 2: - print "Usage: gdbtool <tdbfile>" - sys.exit(1) - -try: - t = tdb.open(sys.argv[1]) -except tdb.error, t: - print "gtdbtool: error opening %s: %s" % (sys.argv[1], t) - sys.exit(1) - -# Create interface - -db = GtkDictBrowser(t) - -def display_key_x00(key): - """Remove \x00 from all keys as they mucks up GTK.""" - return string.replace(key, "\x00", "") - -db.register_get_key_text_fn(display_key_x00) - -db.build_ui('gtdbtool') - -# Override Python's handling of ctrl-c so we can break out of the -# gui from the command line. - -import signal -signal.signal(signal.SIGINT, signal.SIG_DFL) - -gtk.mainloop() diff --git a/source/python/gtkdictbrowser.py b/source/python/gtkdictbrowser.py deleted file mode 100755 index dd8bed8f478..00000000000 --- a/source/python/gtkdictbrowser.py +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/python -# -# Browse a Python dictionary in a two pane graphical interface written -# in GTK. -# -# The GtkDictBrowser class is supposed to be generic enough to allow -# applications to override enough methods and produce a -# domain-specific browser provided the information is presented as a -# Python dictionary. -# -# Possible applications: -# -# - Windows registry browser -# - SPOOLSS printerdata browser -# - tdb file browser -# - -from gtk import * -import string, re - -class GtkDictBrowser: - - def __init__(self, dict): - self.dict = dict - - # This variable stores a list of (regexp, function) used to - # convert the raw value data to a displayable string. - - self.get_value_text_fns = [] - self.get_key_text = lambda x: x - - # We can filter the list of keys displayed using a regex - - self.filter_regex = "" - - # Create and configure user interface widgets. A string argument is - # used to set the window title. - - def build_ui(self, title): - win = GtkWindow() - win.set_title(title) - - win.connect("destroy", mainquit) - - hpaned = GtkHPaned() - win.add(hpaned) - hpaned.set_border_width(5) - hpaned.show() - - vbox = GtkVBox() - hpaned.add1(vbox) - vbox.show() - - scrolled_win = GtkScrolledWindow() - scrolled_win.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) - vbox.pack_start(scrolled_win) - scrolled_win.show() - - hbox = GtkHBox() - vbox.pack_end(hbox, expand = 0, padding = 5) - hbox.show() - - label = GtkLabel("Filter:") - hbox.pack_start(label, expand = 0, padding = 5) - label.show() - - self.entry = GtkEntry() - hbox.pack_end(self.entry, padding = 5) - self.entry.show() - - self.entry.connect("activate", self.filter_activated) - - self.list = GtkList() - self.list.set_selection_mode(SELECTION_MULTIPLE) - self.list.set_selection_mode(SELECTION_BROWSE) - scrolled_win.add_with_viewport(self.list) - self.list.show() - - self.list.connect("select_child", self.key_selected) - - scrolled_win = GtkScrolledWindow() - scrolled_win.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) - hpaned.add2(scrolled_win) - scrolled_win.set_usize(500,400) - scrolled_win.show() - - self.text = GtkText() - self.text.set_editable(FALSE) - scrolled_win.add_with_viewport(self.text) - self.text.show() - - self.text.connect("event", self.event_handler) - - self.menu = GtkMenu() - self.menu.show() - - self.font = load_font("fixed") - - self.update_keylist() - - win.show() - - # Add a key to the left hand side of the user interface - - def add_key(self, key): - display_key = self.get_key_text(key) - list_item = GtkListItem(display_key) - list_item.set_data("raw_key", key) # Store raw key in item data - self.list.add(list_item) - list_item.show() - - # Event handler registered by build_ui() - - def event_handler(self, event, menu): - return FALSE - - # Set the text to appear in the right hand side of the user interface - - def set_value_text(self, item): - - # Clear old old value in text window - - self.text.delete_text(0, self.text.get_length()) - - if type(item) == str: - - # The text widget has trouble inserting text containing NULL - # characters. - - item = string.replace(item, "\x00", ".") - - self.text.insert(self.font, None, None, item) - - else: - - # A non-text item - - self.text.insert(self.font, None, None, repr(item)) - - # This function is called when a key is selected in the left hand side - # of the user interface. - - def key_selected(self, list, list_item): - key = list_item.children()[0].get() - - # Look for a match in the value display function list - - text = self.dict[list_item.get_data("raw_key")] - - for entry in self.get_value_text_fns: - if re.match(entry[0], key): - text = entry[1](text) - break - - self.set_value_text(text) - - # Refresh the key list by removing all items and re-inserting them. - # Items are only inserted if they pass through the filter regexp. - - def update_keylist(self): - self.list.remove_items(self.list.children()) - self.set_value_text("") - for k in self.dict.keys(): - if re.match(self.filter_regex, k): - self.add_key(k) - - # Invoked when the user hits return in the filter text entry widget. - - def filter_activated(self, entry): - self.filter_regex = entry.get_text() - self.update_keylist() - - # Register a key display function - - def register_get_key_text_fn(self, fn): - self.get_key_text = fn - - # Register a value display function - - def register_get_value_text_fn(self, regexp, fn): - self.get_value_text_fns.append((regexp, fn)) - -# -# A utility function to convert a string to the standard hex + ascii format. -# To display all values in hex do: -# register_get_value_text_fn("", gtkdictbrowser.hex_string) -# - -def hex_string(data): - """Return a hex dump of a string as a string. - - The output produced is in the standard 16 characters per line hex + - ascii format: - - 00000000: 40 00 00 00 00 00 00 00 40 00 00 00 01 00 04 80 @....... @....... - 00000010: 01 01 00 00 00 00 00 01 00 00 00 00 ........ .... - """ - - pos = 0 # Position in data - line = 0 # Line of data - - hex = "" # Hex display - ascii = "" # ASCII display - - result = "" - - while pos < len(data): - - # Start with header - - if pos % 16 == 0: - hex = "%08x: " % (line * 16) - ascii = "" - - # Add character - - hex = hex + "%02x " % (ord(data[pos])) - - if ord(data[pos]) < 32 or ord(data[pos]) > 176: - ascii = ascii + '.' - else: - ascii = ascii + data[pos] - - pos = pos + 1 - - # Add separator if half way - - if pos % 16 == 8: - hex = hex + " " - ascii = ascii + " " - - # End of line - - if pos % 16 == 0: - result = result + "%s %s\n" % (hex, ascii) - line = line + 1 - - # Leftover bits - - if pos % 16 != 0: - - # Pad hex string - - for i in range(0, (16 - (pos % 16))): - hex = hex + " " - - # Half way separator - - if (pos % 16) < 8: - hex = hex + " " - - result = result + "%s %s\n" % (hex, ascii) - - return result - -# For testing purposes, create a fixed dictionary to browse with - -if __name__ == "__main__": - - dict = {"chicken": "ham", "spam": "fun", "subdict": {"a": "b", "c": "d"}} - - db = GtkDictBrowser(dict) - - db.build_ui("GtkDictBrowser") - - # Override Python's handling of ctrl-c so we can break out of the - # gui from the command line. - - import signal - signal.signal(signal.SIGINT, signal.SIG_DFL) - - mainloop() diff --git a/source/python/py_spoolss_drivers_conv.c b/source/python/py_spoolss_drivers_conv.c deleted file mode 100644 index 9bc84080529..00000000000 --- a/source/python/py_spoolss_drivers_conv.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - Python wrappers for DCERPC/SMB client routines. - - Copyright (C) Tim Potter, 2002 - - 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 "python/py_spoolss.h" -#include "python/py_conv.h" - -/* Structure/hash conversions */ - -struct pyconv py_DRIVER_INFO_1[] = { - { "name", PY_UNISTR, offsetof(DRIVER_INFO_1, name) }, - { NULL } -}; - -struct pyconv py_DRIVER_INFO_2[] = { - { "version", PY_UINT32, offsetof(DRIVER_INFO_2, version) }, - { "name", PY_UNISTR, offsetof(DRIVER_INFO_2, name) }, - { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_2, architecture) }, - { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_2, driverpath) }, - { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_2, datafile) }, - { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_2, configfile) }, - { NULL } -}; - -struct pyconv py_DRIVER_INFO_3[] = { - { "version", PY_UINT32, offsetof(DRIVER_INFO_3, version) }, - { "name", PY_UNISTR, offsetof(DRIVER_INFO_3, name) }, - { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_3, architecture) }, - { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_3, driverpath) }, - { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) }, - { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) }, - { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) }, - { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) }, - { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) }, - { NULL } -}; - -struct pyconv py_DRIVER_INFO_6[] = { - { "version", PY_UINT32, offsetof(DRIVER_INFO_6, version) }, - { "name", PY_UNISTR, offsetof(DRIVER_INFO_6, name) }, - { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_6, architecture) }, - { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_6, driverpath) }, - { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_6, datafile) }, - { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_6, configfile) }, - { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_6, helpfile) }, - { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_6, monitorname) }, - { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_6, defaultdatatype) }, - /* driver_date */ - { "padding", PY_UINT32, offsetof(DRIVER_INFO_6, padding) }, - { "driver_version_low", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_low) }, - { "driver_version_high", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_high) }, - { "mfg_name", PY_UNISTR, offsetof(DRIVER_INFO_6, mfgname) }, - { "oem_url", PY_UNISTR, offsetof(DRIVER_INFO_6, oem_url) }, - { "hardware_id", PY_UNISTR, offsetof(DRIVER_INFO_6, hardware_id) }, - { "provider", PY_UNISTR, offsetof(DRIVER_INFO_6, provider) }, - - { NULL } -}; - -struct pyconv py_DRIVER_DIRECTORY_1[] = { - { "name", PY_UNISTR, offsetof(DRIVER_DIRECTORY_1, name) }, - { NULL } -}; - -static uint16 *to_dependentfiles(PyObject *dict) -{ - return (uint16 *)"abcd\0"; -} - -BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info) -{ - *dict = from_struct(info, py_DRIVER_INFO_1); - PyDict_SetItemString(*dict, "level", PyInt_FromLong(1)); - - return True; -} - -BOOL py_to_DRIVER_INFO_1(DRIVER_INFO_1 *info, PyObject *dict) -{ - return False; -} - -BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info) -{ - *dict = from_struct(info, py_DRIVER_INFO_2); - PyDict_SetItemString(*dict, "level", PyInt_FromLong(2)); - - return True; -} - -BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict) -{ - return False; -} - -BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info) -{ - *dict = from_struct(info, py_DRIVER_INFO_3); - - PyDict_SetItemString(*dict, "level", PyInt_FromLong(3)); - - PyDict_SetItemString( - *dict, "dependent_files", - from_unistr_list(info->dependentfiles)); - - return True; -} - -BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict) -{ - PyObject *obj, *dict_copy = PyDict_Copy(dict); - BOOL result = False; - - if (!(obj = PyDict_GetItemString(dict_copy, "dependent_files")) || - !PyList_Check(obj)) - goto done; - - info->dependentfiles = to_dependentfiles(obj); - - PyDict_DelItemString(dict_copy, "dependent_files"); - - if (!(obj = PyDict_GetItemString(dict_copy, "level")) || - !PyInt_Check(obj)) - goto done; - - PyDict_DelItemString(dict_copy, "level"); - - if (!to_struct(info, dict_copy, py_DRIVER_INFO_3)) - goto done; - - result = True; - -done: - Py_DECREF(dict_copy); - return result; -} - -BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info) -{ - *dict = from_struct(info, py_DRIVER_INFO_6); - PyDict_SetItemString(*dict, "level", PyInt_FromLong(6)); - PyDict_SetItemString( - *dict, "dependent_files", - from_unistr_list(info->dependentfiles)); - return True; -} - -BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict) -{ - return False; -} - -BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info) -{ - *dict = from_struct(info, py_DRIVER_DIRECTORY_1); - PyDict_SetItemString(*dict, "level", PyInt_FromLong(1)); - return True; -} - -BOOL py_to_DRIVER_DIRECTORY_1(DRIVER_DIRECTORY_1 *info, PyObject *dict) -{ - return False; -} diff --git a/source/python/py_spoolss_jobs.c b/source/python/py_spoolss_jobs.c deleted file mode 100644 index 59754bd36dd..00000000000 --- a/source/python/py_spoolss_jobs.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - Python wrappers for DCERPC/SMB client routines. - - Copyright (C) Tim Potter, 2002 - - 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 "python/py_spoolss.h" - -/* Enumerate jobs */ - -PyObject *spoolss_hnd_enumjobs(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - PyObject *result; - int level = 1; - uint32 i, needed, num_jobs; - static char *kwlist[] = {"level", NULL}; - JOB_INFO_CTR ctr; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords(args, kw, "|i", kwlist, &level)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_enumjobs( - hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, level, 0, - 1000, &num_jobs, &ctr); - - if (W_ERROR_V(werror) == ERRinsufficientbuffer) - werror = cli_spoolss_enumjobs( - hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, - level, 0, 1000, &num_jobs, &ctr); - - /* Return value */ - - result = Py_None; - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - goto done; - } - - result = PyList_New(num_jobs); - - switch (level) { - case 1: - for (i = 0; i < num_jobs; i++) { - PyObject *value; - - py_from_JOB_INFO_1(&value, &ctr.job.job_info_1[i]); - - PyList_SetItem(result, i, value); - } - - break; - case 2: - for(i = 0; i < num_jobs; i++) { - PyObject *value; - - py_from_JOB_INFO_2(&value, &ctr.job.job_info_2[i]); - - PyList_SetItem(result, i, value); - } - - break; - } - - done: - Py_INCREF(result); - return result; -} - -/* Set job command */ - -PyObject *spoolss_hnd_setjob(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - uint32 level = 0, command, jobid; - static char *kwlist[] = {"jobid", "command", "level", NULL}; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords( - args, kw, "ii|i", kwlist, &jobid, &command, &level)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_setjob(hnd->cli, hnd->mem_ctx, &hnd->pol, - jobid, level, command); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* Get job */ - -PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - PyObject *result; - uint32 level = 1, jobid, needed; - static char *kwlist[] = {"jobid", "level", NULL}; - JOB_INFO_CTR ctr; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords( - args, kw, "i|i", kwlist, &jobid, &level)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_getjob(hnd->cli, hnd->mem_ctx, 0, &needed, - &hnd->pol, jobid, level, &ctr); - - if (W_ERROR_V(werror) == ERRinsufficientbuffer) - werror = cli_spoolss_getjob( - hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, - jobid, level, &ctr); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - switch(level) { - case 1: - py_from_JOB_INFO_1(&result, &ctr.job.job_info_1[0]); - break; - case 2: - py_from_JOB_INFO_2(&result, &ctr.job.job_info_2[0]); - break; - } - - return result; -} - -/* Start page printer. This notifies the spooler that a page is about to be - printed on the specified printer. */ - -PyObject *spoolss_hnd_startpageprinter(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - static char *kwlist[] = { NULL }; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_startpageprinter( - hnd->cli, hnd->mem_ctx, &hnd->pol); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* End page printer. This notifies the spooler that a page has finished - being printed on the specified printer. */ - -PyObject *spoolss_hnd_endpageprinter(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - static char *kwlist[] = { NULL }; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_endpageprinter( - hnd->cli, hnd->mem_ctx, &hnd->pol); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* Start doc printer. This notifies the spooler that a document is about to be - printed on the specified printer. */ - -PyObject *spoolss_hnd_startdocprinter(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - static char *kwlist[] = { "document_info", NULL }; - PyObject *info, *obj; - uint32 level, jobid; - char *document_name = NULL, *output_file = NULL, *data_type = NULL; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords( - args, kw, "O!", kwlist, &PyDict_Type, &info)) - return NULL; - - /* Check document_info parameter */ - - if (!get_level_value(info, &level)) { - PyErr_SetString(spoolss_error, "invalid info level"); - return NULL; - } - - if (level != 1) { - PyErr_SetString(spoolss_error, "unsupported info level"); - return NULL; - } - - if ((obj = PyDict_GetItemString(info, "document_name"))) { - - if (!PyString_Check(obj) && obj != Py_None) { - PyErr_SetString(spoolss_error, - "document_name not a string"); - return NULL; - } - - if (PyString_Check(obj)) - document_name = PyString_AsString(obj); - - } else { - PyErr_SetString(spoolss_error, "no document_name present"); - return NULL; - } - - if ((obj = PyDict_GetItemString(info, "output_file"))) { - - if (!PyString_Check(obj) && obj != Py_None) { - PyErr_SetString(spoolss_error, - "output_file not a string"); - return NULL; - } - - if (PyString_Check(obj)) - output_file = PyString_AsString(obj); - - } else { - PyErr_SetString(spoolss_error, "no output_file present"); - return NULL; - } - - if ((obj = PyDict_GetItemString(info, "data_type"))) { - - if (!PyString_Check(obj) && obj != Py_None) { - PyErr_SetString(spoolss_error, - "data_type not a string"); - return NULL; - } - - if (PyString_Check(obj)) - data_type = PyString_AsString(obj); - - } else { - PyErr_SetString(spoolss_error, "no data_type present"); - return NULL; - } - - /* Call rpc function */ - - werror = cli_spoolss_startdocprinter( - hnd->cli, hnd->mem_ctx, &hnd->pol, document_name, - output_file, data_type, &jobid); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - /* The return value is zero for an error (where does the status - code come from now??) and the return value is the jobid - allocated for the new job. */ - - return Py_BuildValue("i", jobid); -} - -/* End doc printer. This notifies the spooler that a document has finished - being printed on the specified printer. */ - -PyObject *spoolss_hnd_enddocprinter(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - static char *kwlist[] = { NULL }; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_enddocprinter(hnd->cli, hnd->mem_ctx, &hnd->pol); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -/* Write data to a printer */ - -PyObject *spoolss_hnd_writeprinter(PyObject *self, PyObject *args, PyObject *kw) -{ - spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; - WERROR werror; - static char *kwlist[] = { "data", NULL }; - PyObject *data; - uint32 num_written; - - /* Parse parameters */ - - if (!PyArg_ParseTupleAndKeywords( - args, kw, "O!", kwlist, &PyString_Type, &data)) - return NULL; - - /* Call rpc function */ - - werror = cli_spoolss_writeprinter( - hnd->cli, hnd->mem_ctx, &hnd->pol, PyString_Size(data), - PyString_AsString(data), &num_written); - - if (!W_ERROR_IS_OK(werror)) { - PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); - return NULL; - } - - Py_INCREF(Py_None); - return Py_None; -} - -PyObject *spoolss_hnd_addjob(PyObject *self, PyObject *args, PyObject *kw) -{ - PyErr_SetString(spoolss_error, "Not implemented"); - return NULL; -} diff --git a/source/python/py_spoolss_jobs_conv.c b/source/python/py_spoolss_jobs_conv.c deleted file mode 100644 index cb04ec6713c..00000000000 --- a/source/python/py_spoolss_jobs_conv.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - Python wrappers for DCERPC/SMB client routines. - - Copyright (C) Tim Potter, 2002 - - 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 "python/py_spoolss.h" -#include "python/py_conv.h" - -struct pyconv py_JOB_INFO_1[] = { - { "jobid", PY_UINT32, offsetof(JOB_INFO_1, jobid) }, - { "printer_name", PY_UNISTR, offsetof(JOB_INFO_1, printername) }, - { "server_name", PY_UNISTR, offsetof(JOB_INFO_1, machinename) }, - { "user_name", PY_UNISTR, offsetof(JOB_INFO_1, username) }, - { "document_name", PY_UNISTR, offsetof(JOB_INFO_1, document) }, - { "data_type", PY_UNISTR, offsetof(JOB_INFO_1, datatype) }, - { "text_status", PY_UNISTR, offsetof(JOB_INFO_1, text_status) }, - { "status", PY_UINT32, offsetof(JOB_INFO_1, status) }, - { "priority", PY_UINT32, offsetof(JOB_INFO_1, priority) }, - { "position", PY_UINT32, offsetof(JOB_INFO_1, position) }, - { "total_pages", PY_UINT32, offsetof(JOB_INFO_1, totalpages) }, - { "pages_printed", PY_UINT32, offsetof(JOB_INFO_1, pagesprinted) }, - { NULL } -}; - -struct pyconv py_JOB_INFO_2[] = { - { "jobid", PY_UINT32, offsetof(JOB_INFO_2, jobid) }, - { "printer_name", PY_UNISTR, offsetof(JOB_INFO_2, printername) }, - { "server_name", PY_UNISTR, offsetof(JOB_INFO_2, machinename) }, - { "user_name", PY_UNISTR, offsetof(JOB_INFO_2, username) }, - { "document_name", PY_UNISTR, offsetof(JOB_INFO_2, document) }, - { "notify_name", PY_UNISTR, offsetof(JOB_INFO_2, notifyname) }, - { "data_type", PY_UNISTR, offsetof(JOB_INFO_2, datatype) }, - { "print_processor", PY_UNISTR, offsetof(JOB_INFO_2, printprocessor) }, - { "parameters", PY_UNISTR, offsetof(JOB_INFO_2, parameters) }, - { "driver_name", PY_UNISTR, offsetof(JOB_INFO_2, drivername) }, - { "text_status", PY_UNISTR, offsetof(JOB_INFO_2, text_status) }, - { "status", PY_UINT32, offsetof(JOB_INFO_2, status) }, - { "priority", PY_UINT32, offsetof(JOB_INFO_2, priority) }, - { "position", PY_UINT32, offsetof(JOB_INFO_2, position) }, - { "start_time", PY_UINT32, offsetof(JOB_INFO_2, starttime) }, - { "until_time", PY_UINT32, offsetof(JOB_INFO_2, untiltime) }, - { "total_pages", PY_UINT32, offsetof(JOB_INFO_2, totalpages) }, - { "size", PY_UINT32, offsetof(JOB_INFO_2, size) }, - { "time_elapsed", PY_UINT32, offsetof(JOB_INFO_2, timeelapsed) }, - { "pages_printed", PY_UINT32, offsetof(JOB_INFO_2, pagesprinted) }, - { NULL } -}; - -struct pyconv py_DOC_INFO_1[] = { - { "document_name", PY_UNISTR, offsetof(DOC_INFO_1, docname) }, - { "output_file", PY_UNISTR, offsetof(DOC_INFO_1, outputfile) }, - { "data_type", PY_UNISTR, offsetof(DOC_INFO_1, datatype) }, - { NULL } -}; - -BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info) -{ - *dict = from_struct(info, py_JOB_INFO_1); - return True; -} - -BOOL py_to_JOB_INFO_1(JOB_INFO_1 *info, PyObject *dict) -{ - return False; -} - -BOOL py_from_JOB_INFO_2(PyObject **dict, JOB_INFO_2 *info) -{ - *dict = from_struct(info, py_JOB_INFO_2); - return True; -} - -BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict) -{ - return False; -} - -BOOL py_from_DOC_INFO_1(PyObject **dict, DOC_INFO_1 *info) -{ - *dict = from_struct(info, py_DOC_INFO_1); - return True; -} - -BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict) -{ - return to_struct(info, dict, py_DOC_INFO_1); -} diff --git a/source/python/py_spoolss_ports_conv.c b/source/python/py_spoolss_ports_conv.c deleted file mode 100644 index 3f6d94bf7e7..00000000000 --- a/source/python/py_spoolss_ports_conv.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - Python wrappers for DCERPC/SMB client routines. - - Copyright (C) Tim Potter, 2002 - - 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 "python/py_spoolss.h" -#include "python/py_conv.h" - -struct pyconv py_PORT_INFO_1[] = { - { "name", PY_UNISTR, offsetof(PORT_INFO_1, port_name) }, - { NULL } -}; - -struct pyconv py_PORT_INFO_2[] = { - { "name", PY_UNISTR, offsetof(PORT_INFO_2, port_name) }, - { "monitor_name", PY_UNISTR, offsetof(PORT_INFO_2, monitor_name) }, - { "description", PY_UNISTR, offsetof(PORT_INFO_2, description) }, - { "reserved", PY_UINT32, offsetof(PORT_INFO_2, reserved) }, - { "type", PY_UINT32, offsetof(PORT_INFO_2, port_type) }, - { NULL } -}; - -BOOL py_from_PORT_INFO_1(PyObject **dict, PORT_INFO_1 *info) -{ - *dict = from_struct(info, py_PORT_INFO_1); - return True; -} - -BOOL py_to_PORT_INFO_1(PORT_INFO_1 *info, PyObject *dict) -{ - return False; -} - -BOOL py_from_PORT_INFO_2(PyObject **dict, PORT_INFO_2 *info) -{ - *dict = from_struct(info, py_PORT_INFO_2); - return True; -} - -BOOL py_to_PORT_INFO_2(PORT_INFO_2 *info, PyObject *dict) -{ - return False; -} diff --git a/source/python/py_spoolss_printers_conv.c b/source/python/py_spoolss_printers_conv.c deleted file mode 100644 index f7b2f516df5..00000000000 --- a/source/python/py_spoolss_printers_conv.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - Python wrappers for DCERPC/SMB client routines. - - Copyright (C) Tim Potter, 2002 - - 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 "python/py_spoolss.h" -#include "python/py_conv.h" - -struct pyconv py_PRINTER_INFO_0[] = { - { "name", PY_UNISTR, offsetof(PRINTER_INFO_0, printername) }, - { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_0, servername) }, - - { "cjobs", PY_UINT32, offsetof(PRINTER_INFO_0, cjobs) }, - { "total_jobs", PY_UINT32, offsetof(PRINTER_INFO_0, total_jobs) }, - { "total_bytes", PY_UINT32, offsetof(PRINTER_INFO_0, total_bytes) }, - - { "year", PY_UINT16, offsetof(PRINTER_INFO_0, year) }, - { "month", PY_UINT16, offsetof(PRINTER_INFO_0, month) }, - { "day_of_week", PY_UINT16, offsetof(PRINTER_INFO_0, dayofweek) }, - { "day", PY_UINT16, offsetof(PRINTER_INFO_0, day) }, - { "hour", PY_UINT16, offsetof(PRINTER_INFO_0, hour) }, - { "minute", PY_UINT16, offsetof(PRINTER_INFO_0, minute) }, - { "second", PY_UINT16, offsetof(PRINTER_INFO_0, second) }, - { "milliseconds", PY_UINT16, offsetof(PRINTER_INFO_0, milliseconds) }, - - { "global_counter", PY_UINT32, offsetof(PRINTER_INFO_0, global_counter) }, - { "total_pages", PY_UINT32, offsetof(PRINTER_INFO_0, total_pages) }, - - { "major_version", PY_UINT16, offsetof(PRINTER_INFO_0, major_version) }, - { "build_version", PY_UINT16, offsetof(PRINTER_INFO_0, build_version) }, - - { "unknown7", PY_UINT32, offsetof(PRINTER_INFO_0, unknown7) }, - { "unknown8", PY_UINT32, offsetof(PRINTER_INFO_0, unknown8) }, - { "unknown9", PY_UINT32, offsetof(PRINTER_INFO_0, unknown9) }, - { "session_counter", PY_UINT32, offsetof(PRINTER_INFO_0, session_counter)}, - { "unknown11", PY_UINT32, offsetof(PRINTER_INFO_0, unknown11) }, - { "printer_errors", PY_UINT32, offsetof(PRINTER_INFO_0, printer_errors) }, - { "unknown13", PY_UINT32, offsetof(PRINTER_INFO_0, unknown13) }, - { "unknown14", PY_UINT32, offsetof(PRINTER_INFO_0, unknown14) }, - { "unknown15", PY_UINT32, offsetof(PRINTER_INFO_0, unknown15) }, - { "unknown16", PY_UINT32, offsetof(PRINTER_INFO_0, unknown16) }, - { "change_id", PY_UINT32, offsetof(PRINTER_INFO_0, change_id) }, - { "unknown18", PY_UINT32, offsetof(PRINTER_INFO_0, unknown18) }, - { "status", PY_UINT32, offsetof(PRINTER_INFO_0, status) }, - { "unknown20", PY_UINT32, offsetof(PRINTER_INFO_0, unknown20) }, - { "c_setprinter", PY_UINT32, offsetof(PRINTER_INFO_0, c_setprinter) }, - { "unknown22", PY_UINT32, offsetof(PRINTER_INFO_0, unknown22) }, - { "unknown23", PY_UINT32, offsetof(PRINTER_INFO_0, unknown23) }, - { "unknown24", PY_UINT32, offsetof(PRINTER_INFO_0, unknown24) }, - { "unknown25", PY_UINT32, offsetof(PRINTER_INFO_0, unknown25) }, - { "unknown26", PY_UINT32, offsetof(PRINTER_INFO_0, unknown26) }, - { "unknown27", PY_UINT32, offsetof(PRINTER_INFO_0, unknown27) }, - { "unknown28", PY_UINT32, offsetof(PRINTER_INFO_0, unknown28) }, - { "unknown29", PY_UINT32, offsetof(PRINTER_INFO_0, unknown29) }, - - { NULL } -}; - -struct pyconv py_PRINTER_INFO_1[] = { - { "name", PY_UNISTR, offsetof(PRINTER_INFO_1, name) }, - { "description", PY_UNISTR, offsetof(PRINTER_INFO_1, description) }, - { "comment", PY_UNISTR, offsetof(PRINTER_INFO_1, comment) }, - { "flags", PY_UINT32, offsetof(PRINTER_INFO_1, flags) }, - { NULL } -}; - -struct pyconv py_PRINTER_INFO_2[] = { - { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_2, servername) }, - { "name", PY_UNISTR, offsetof(PRINTER_INFO_2, printername) }, - { "share_name", PY_UNISTR, offsetof(PRINTER_INFO_2, sharename) }, - { "port_name", PY_UNISTR, offsetof(PRINTER_INFO_2, portname) }, - { "driver_name", PY_UNISTR, offsetof(PRINTER_INFO_2, drivername) }, - { "comment", PY_UNISTR, offsetof(PRINTER_INFO_2, comment) }, - { "location", PY_UNISTR, offsetof(PRINTER_INFO_2, location) }, - { "datatype", PY_UNISTR, offsetof(PRINTER_INFO_2, datatype) }, - { "sepfile", PY_UNISTR, offsetof(PRINTER_INFO_2, sepfile) }, - { "print_processor", PY_UNISTR, offsetof(PRINTER_INFO_2, printprocessor) }, - { "parameters", PY_UNISTR, offsetof(PRINTER_INFO_2, parameters) }, - { "attributes", PY_UINT32, offsetof(PRINTER_INFO_2, attributes) }, - { "default_priority", PY_UINT32, offsetof(PRINTER_INFO_2, defaultpriority) }, - { "priority", PY_UINT32, offsetof(PRINTER_INFO_2, priority) }, - { "start_time", PY_UINT32, offsetof(PRINTER_INFO_2, starttime) }, - { "until_time", PY_UINT32, offsetof(PRINTER_INFO_2, untiltime) }, - { "status", PY_UINT32, offsetof(PRINTER_INFO_2, status) }, - { "cjobs", PY_UINT32, offsetof(PRINTER_INFO_2, cjobs) }, - { "average_ppm", PY_UINT32, offsetof(PRINTER_INFO_2, averageppm) }, - { NULL } -}; - -struct pyconv py_PRINTER_INFO_3[] = { - { "flags", PY_UINT32, offsetof(PRINTER_INFO_3, flags) }, - { NULL } -}; - -struct pyconv py_DEVICEMODE[] = { - { "device_name", PY_UNISTR, offsetof(DEVICEMODE, devicename) }, - { "spec_version", PY_UINT16, offsetof(DEVICEMODE, specversion) }, - { "driver_version", PY_UINT16, offsetof(DEVICEMODE, driverversion) }, - { "size", PY_UINT16, offsetof(DEVICEMODE, size) }, - { "fields", PY_UINT16, offsetof(DEVICEMODE, fields) }, - { "orientation", PY_UINT16, offsetof(DEVICEMODE, orientation) }, - { "paper_size", PY_UINT16, offsetof(DEVICEMODE, papersize) }, - { "paper_width", PY_UINT16, offsetof(DEVICEMODE, paperwidth) }, - { "paper_length", PY_UINT16, offsetof(DEVICEMODE, paperlength) }, - { "scale", PY_UINT16, offsetof(DEVICEMODE, scale) }, - { "copies", PY_UINT16, offsetof(DEVICEMODE, copies) }, - { "default_source", PY_UINT16, offsetof(DEVICEMODE, defaultsource) }, - { "print_quality", PY_UINT16, offsetof(DEVICEMODE, printquality) }, - { "color", PY_UINT16, offsetof(DEVICEMODE, color) }, - { "duplex", PY_UINT16, offsetof(DEVICEMODE, duplex) }, - { "y_resolution", PY_UINT16, offsetof(DEVICEMODE, yresolution) }, - { "tt_option", PY_UINT16, offsetof(DEVICEMODE, ttoption) }, - { "collate", PY_UINT16, offsetof(DEVICEMODE, collate) }, - { "form_name", PY_UNISTR, offsetof(DEVICEMODE, formname) }, - { "log_pixels", PY_UINT16, offsetof(DEVICEMODE, logpixels) }, - { "bits_per_pel", PY_UINT32, offsetof(DEVICEMODE, bitsperpel) }, - { "pels_width", PY_UINT32, offsetof(DEVICEMODE, pelswidth) }, - { "pels_height", PY_UINT32, offsetof(DEVICEMODE, pelsheight) }, - { "display_flags", PY_UINT32, offsetof(DEVICEMODE, displayflags) }, - { "display_frequency", PY_UINT32, offsetof(DEVICEMODE, displayfrequency) }, - { "icm_method", PY_UINT32, offsetof(DEVICEMODE, icmmethod) }, - { "icm_intent", PY_UINT32, offsetof(DEVICEMODE, icmintent) }, - { "media_type", PY_UINT32, offsetof(DEVICEMODE, mediatype) }, - { "dither_type", PY_UINT32, offsetof(DEVICEMODE, dithertype) }, - { "reserved1", PY_UINT32, offsetof(DEVICEMODE, reserved1) }, - { "reserved2", PY_UINT32, offsetof(DEVICEMODE, reserved2) }, - { "panning_width", PY_UINT32, offsetof(DEVICEMODE, panningwidth) }, - { "panning_height", PY_UINT32, offsetof(DEVICEMODE, panningheight) }, - { NULL } -}; - -/* - * Convert between DEVICEMODE and Python - */ - -BOOL py_from_DEVICEMODE(PyObject **dict, DEVICEMODE *devmode) -{ - *dict = from_struct(devmode, py_DEVICEMODE); - - PyDict_SetItemString(*dict, "private", - PyString_FromStringAndSize( - devmode->private, devmode->driverextra)); - - return True; -} - -BOOL py_to_DEVICEMODE(DEVICEMODE *devmode, PyObject *dict) -{ - PyObject *obj, *dict_copy = PyDict_Copy(dict); - BOOL result = False; - - if (!(obj = PyDict_GetItemString(dict_copy, "private"))) - goto done; - - if (!PyString_Check(obj)) - goto done; - - devmode->private = PyString_AsString(obj); - devmode->driverextra = PyString_Size(obj); - - PyDict_DelItemString(dict_copy, "private"); - - if (!to_struct(devmode, dict_copy, py_DEVICEMODE)) - goto done; - - result = True; - -done: - Py_DECREF(dict_copy); - return result; -} - -/* - * Convert between PRINTER_INFO_0 and Python - */ - -BOOL py_from_PRINTER_INFO_0(PyObject **dict, PRINTER_INFO_0 *info) -{ - *dict = from_struct(info, py_PRINTER_INFO_0); - PyDict_SetItemString(*dict, "level", PyInt_FromLong(0)); - return True; -} - -BOOL py_to_PRINTER_INFO_0(PRINTER_INFO_0 *info, PyObject *dict) -{ - return False; -} - -/* - * Convert between PRINTER_INFO_1 and Python - */ - -BOOL py_from_PRINTER_INFO_1(PyObject **dict, PRINTER_INFO_1 *info) -{ - *dict = from_struct(info, py_PRINTER_INFO_1); - PyDict_SetItemString(*dict, "level", PyInt_FromLong(1)); - return True; -} - -BOOL py_to_PRINTER_INFO_1(PRINTER_INFO_1 *info, PyObject *dict) -{ - PyObject *obj, *dict_copy = PyDict_Copy(dict); - BOOL result = False; - - if (!(obj = PyDict_GetItemString(dict_copy, "level")) || - !PyInt_Check(obj)) - goto done; - - PyDict_DelItemString(dict_copy, "level"); - - if (!to_struct(info, dict_copy, py_PRINTER_INFO_1)) - goto done; - - result = True; - -done: - Py_DECREF(dict_copy); - return result; -} - -/* - * Convert between PRINTER_INFO_2 and Python - */ - -BOOL py_from_PRINTER_INFO_2(PyObject **dict, PRINTER_INFO_2 *info) -{ - PyObject *obj; - - *dict = from_struct(info, py_PRINTER_INFO_2); - - /* The security descriptor could be NULL */ - - if (info->secdesc) { - if (py_from_SECDESC(&obj, info->secdesc)) - PyDict_SetItemString(*dict, "security_descriptor", obj); - } - - /* Bong! The devmode could be NULL */ - - if (info->devmode) - py_from_DEVICEMODE(&obj, info->devmode); - else - obj = PyDict_New(); - - PyDict_SetItemString(*dict, "device_mode", obj); - - PyDict_SetItemString(*dict, "level", PyInt_FromLong(2)); - - return True; -} - -BOOL py_to_PRINTER_INFO_2(PRINTER_INFO_2 *info, PyObject *dict, - TALLOC_CTX *mem_ctx) -{ - PyObject *obj, *dict_copy = PyDict_Copy(dict); - BOOL result = False; - - /* Convert security descriptor - may be NULL */ - - info->secdesc = NULL; - - if ((obj = PyDict_GetItemString(dict_copy, "security_descriptor"))) { - - if (!PyDict_Check(obj)) - goto done; - - if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx)) - goto done; - - PyDict_DelItemString(dict_copy, "security_descriptor"); - } - - /* Convert device mode */ - - if (!(obj = PyDict_GetItemString(dict_copy, "device_mode")) - || !PyDict_Check(obj)) - goto done; - - info->devmode = talloc(mem_ctx, sizeof(DEVICEMODE)); - - if (!py_to_DEVICEMODE(info->devmode, obj)) - goto done; - - PyDict_DelItemString(dict_copy, "device_mode"); - - /* Check info level */ - - if (!(obj = PyDict_GetItemString(dict_copy, "level")) || - !PyInt_Check(obj)) - goto done; - - PyDict_DelItemString(dict_copy, "level"); - - /* Convert remaining elements of dictionary */ - - if (!to_struct(info, dict_copy, py_PRINTER_INFO_2)) - goto done; - - result = True; - -done: - Py_DECREF(dict_copy); - return result; -} - -/* - * Convert between PRINTER_INFO_1 and Python - */ - -BOOL py_from_PRINTER_INFO_3(PyObject **dict, PRINTER_INFO_3 *info) -{ - PyObject *obj; - - *dict = from_struct(info, py_PRINTER_INFO_3); - - if (py_from_SECDESC(&obj, info->secdesc)) - PyDict_SetItemString(*dict, "security_descriptor", obj); - - PyDict_SetItemString(*dict, "level", PyInt_FromLong(3)); - - return True; -} - -BOOL py_to_PRINTER_INFO_3(PRINTER_INFO_3 *info, PyObject *dict, - TALLOC_CTX *mem_ctx) -{ - PyObject *obj; - - if (!to_struct(info, dict, py_PRINTER_INFO_3)) - return False; - - if (!(obj = PyDict_GetItemString(dict, "security_descriptor"))) - return False; - - if (!py_to_SECDESC(&info->secdesc, obj, mem_ctx)) - return False; - - return True; -} diff --git a/source/python/py_winreg.c b/source/python/py_winreg.c deleted file mode 100644 index ce27f5c533b..00000000000 --- a/source/python/py_winreg.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - Python wrappers for DCERPC/SMB client routines. - - Copyright (C) Tim Potter, 2002 - - 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 "python/py_winreg.h" - -static struct const_vals { - char *name; - uint32 value; -} module_const_vals[] = { - - /* Registry value types */ - - { "REG_NONE", REG_NONE }, - { "REG_SZ", REG_SZ }, - { "REG_EXPAND_SZ", REG_EXPAND_SZ }, - { "REG_BINARY", REG_BINARY }, - { "REG_DWORD", REG_DWORD }, - { "REG_DWORD_LE", REG_DWORD_LE }, - { "REG_DWORD_BE", REG_DWORD_BE }, - { "REG_LINK", REG_LINK }, - { "REG_MULTI_SZ", REG_MULTI_SZ }, - { "REG_RESOURCE_LIST", REG_RESOURCE_LIST }, - { "REG_FULL_RESOURCE_DESCRIPTOR", REG_FULL_RESOURCE_DESCRIPTOR }, - { "REG_RESOURCE_REQUIREMENTS_LIST", REG_RESOURCE_REQUIREMENTS_LIST }, - - { NULL }, -}; - -static void const_init(PyObject *dict) -{ - struct const_vals *tmp; - PyObject *obj; - - for (tmp = module_const_vals; tmp->name; tmp++) { - obj = PyInt_FromLong(tmp->value); - PyDict_SetItemString(dict, tmp->name, obj); - Py_DECREF(obj); - } -} - -/* - * Module initialisation - */ - -static PyMethodDef winreg_methods[] = { - { NULL } -}; - -void initwinreg(void) -{ - PyObject *module, *dict; - - /* Initialise module */ - - module = Py_InitModule("winreg", winreg_methods); - dict = PyModule_GetDict(module); - - /* Initialise constants */ - - const_init(dict); - - /* Do samba initialisation */ - - py_samba_init(); -} diff --git a/source/python/samba/.cvsignore b/source/python/samba/.cvsignore deleted file mode 100644 index 0d20b6487c6..00000000000 --- a/source/python/samba/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/source/python/samba/printerdata.py b/source/python/samba/printerdata.py deleted file mode 100644 index 33251f6a00f..00000000000 --- a/source/python/samba/printerdata.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python - -# -# A python module that maps printerdata to a dictionary. We define -# two classes. The printerdata class maps to Get/Set/Enum/DeletePrinterData -# and the printerdata_ex class maps to Get/Set/Enum/DeletePrinterDataEx -# - -# -# TODO: -# -# - Implement __delitem__ -# - -from samba import spoolss - -class printerdata: - def __init__(self, host, creds = {}): - self.hnd = spoolss.openprinter(host, creds = creds) - - def keys(self): - return self.hnd.enumprinterdata().keys() - - def __getitem__(self, key): - return self.hnd.getprinterdata(key)['data'] - - def __setitem__(self, key, value): - # Store as REG_BINARY for now - self.hnd.setprinterdata({"key": "", "value": key, "type": 3, - "data": value}) - -class printerdata_ex: - def __init__(self, host): - self.host = host - self.top_level_keys = ["PrinterDriverData", "DsSpooler", "DsDriver", - "DsUser"] - - def keys(self): - return self.top_level_keys - - def has_key(self, key): - for k in self.top_level_keys: - if k == key: - return 1 - return 0 - - class printerdata_ex_subkey: - def __init__(self, host, key): - self.hnd = spoolss.openprinter(host) - self.key = key - - def keys(self): - return self.hnd.enumprinterdataex(self.key).keys() - - def __getitem__(self, key): - return self.hnd.getprinterdataex(self.key, key)['data'] - - def __getitem__(self, key): - return self.printerdata_ex_subkey(self.host, key) diff --git a/source/script/creategroup b/source/script/creategroup deleted file mode 100755 index 01fb0659444..00000000000 --- a/source/script/creategroup +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# Example script for 'add group command'. Handle weird NT group -# names. First attempt to create the group directly, if that fails -# then create a random group and print the numeric group id. -# -# Note that this is only an example and assumes /dev/urandom. -# -# Volker - -GROUPNAME="$1" -ITERS=0 - -while ! /usr/sbin/groupadd "$GROUPNAME" > /dev/null 2>&1 -do - # we had difficulties creating that group. Maybe the name was - # too weird, or it already existed. Create a random name. - GROUPNAME=nt-$(dd if=/dev/urandom bs=16 count=1 2>/dev/null | md5sum | cut -b 1-5) - ITERS=$(expr "$ITERS" + 1) - if [ "$ITERS" -gt 10 ] - then - # Too many attempts - exit 1 - fi -done - -getent group | grep ^"$GROUPNAME": | cut -d : -f 3 diff --git a/source/script/findstatic.pl b/source/script/findstatic.pl deleted file mode 100755 index 43a4916435d..00000000000 --- a/source/script/findstatic.pl +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/perl -w -# find a list of fns and variables in the code that could be static -# usually called with something like this: -# findstatic.pl `find . -name "*.o"` -# Andrew Tridgell <tridge@samba.org> - -use strict; - -# use nm to find the symbols -my($saved_delim) = $/; -undef $/; -my($syms) = `nm -o @ARGV`; -$/ = $saved_delim; - -my(@lines) = split(/\n/s, $syms); - -my(%def); -my(%undef); -my(%stype); - -my(%typemap) = ( - "T" => "function", - "C" => "uninitialised variable", - "D" => "initialised variable" - ); - - -# parse the symbols into defined and undefined -for (my($i)=0; $i <= $#{@lines}; $i++) { - my($line) = $lines[$i]; - if ($line =~ /(.*):[a-f0-9]* ([TCD]) (.*)/) { - my($fname) = $1; - my($symbol) = $3; - push(@{$def{$fname}}, $symbol); - $stype{$symbol} = $2; - } - if ($line =~ /(.*):\s* U (.*)/) { - my($fname) = $1; - my($symbol) = $2; - push(@{$undef{$fname}}, $symbol); - } -} - -# look for defined symbols that are never referenced outside the place they -# are defined -foreach my $f (keys %def) { - print "Checking $f\n"; - my($found_one) = 0; - foreach my $s (@{$def{$f}}) { - my($found) = 0; - foreach my $f2 (keys %undef) { - if ($f2 ne $f) { - foreach my $s2 (@{$undef{$f2}}) { - if ($s2 eq $s) { - $found = 1; - $found_one = 1; - } - } - } - } - if ($found == 0) { - my($t) = $typemap{$stype{$s}}; - print " '$s' is unique to $f ($t)\n"; - } - } - if ($found_one == 0) { - print " all symbols in '$f' are unused (main program?)\n"; - } -} - diff --git a/source/script/installdat.sh b/source/script/installdat.sh deleted file mode 100755 index 7ff88ac788e..00000000000 --- a/source/script/installdat.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -#fist version March 2002, Herb Lewis - -DATDIR=$1 -SRCDIR=$2/ - -echo Installing dat files in $DATDIR - -for f in $SRCDIR/codepages/*.dat; do - FNAME=$DATDIR/`basename $f` - echo $FNAME - cp $f $FNAME || echo Cannot install $FNAME. Does $USER have privileges? - chmod 0644 $FNAME -done - -cat << EOF -====================================================================== -The dat files have been installed. -====================================================================== -EOF - -exit 0 - diff --git a/source/script/mkinstalldirs b/source/script/mkinstalldirs deleted file mode 100755 index f945dbf2bce..00000000000 --- a/source/script/mkinstalldirs +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman <friedman@prep.ai.mit.edu> -# Created: 1993-05-16 -# Public domain - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" 1>&2 - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here diff --git a/source/script/uninstallmodules.sh b/source/script/uninstallmodules.sh deleted file mode 100755 index 30582a39fac..00000000000 --- a/source/script/uninstallmodules.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -#4 July 96 Dan.Shearer@UniSA.edu.au - -INSTALLPERMS=$1 -BASEDIR=$2 -LIBDIR=$3 -shift -shift -shift - -if [ ! -d $LIBDIR ]; then - echo Directory $LIBDIR does not exist! - echo Do a "make installmodules" or "make install" first. - exit 1 -fi - -for p in $*; do - p2=`basename $p` - if [ -f $LIBDIR/$p2 ]; then - echo Removing $LIBDIR/$p2 - rm -f $LIBDIR/$p2 - if [ -f $LIBDIR/$p2 ]; then - echo Cannot remove $LIBDIR/$p2 ... does $USER have privileges? - fi - fi -done - - -cat << EOF -====================================================================== -The modules have been uninstalled. You may restore the modules using -the command "make installmodules" or "make install" to install -binaries, modules, man pages and shell scripts. -====================================================================== -EOF - -exit 0 diff --git a/source/smbwrapper/smbw_cache.c b/source/smbwrapper/smbw_cache.c deleted file mode 100644 index fcb0eda8050..00000000000 --- a/source/smbwrapper/smbw_cache.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB wrapper directory functions - Copyright (C) Tim Potter 2000 - - 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" - -/* We cache lists of workgroups, lists of servers in workgroups, and lists - of shares exported by servers. */ - -#define CACHE_TIMEOUT 30 - -struct name_list { - struct name_list *prev, *next; - char *name; - uint32 stype; - char *comment; -}; - -struct cached_names { - struct cached_names *prev, *next; - char *key; - struct name_list *name_list; - time_t cache_timeout; - int result; -}; - -static struct cached_names *cached_names = NULL; - -/* Find a list of cached name for a workgroup, server or share list */ - -static struct cached_names *find_cached_names(char *key) -{ - struct cached_names *tmp; - - for (tmp = cached_names; tmp; tmp = tmp->next) { - if (strequal(tmp->key, key)) { - return tmp; - } - } - - return NULL; -} - -/* Add a name to a list stored in the state variable */ - -static void add_cached_names(const char *name, uint32 stype, - const char *comment, void *state) -{ - struct name_list **name_list = (struct name_list **)state; - struct name_list *new_name; - - new_name = (struct name_list *)malloc(sizeof(struct name_list)); - if (!new_name) return; - - ZERO_STRUCTP(new_name); - - new_name->name = strdup(name); - new_name->stype = stype; - new_name->comment = strdup(comment); - - DLIST_ADD(*name_list, new_name); -} - -static void free_name_list(struct name_list *name_list) -{ - struct name_list *tmp = name_list; - - while(tmp) { - struct name_list *next; - - next = tmp->next; - - SAFE_FREE(tmp->name); - SAFE_FREE(tmp->comment); - SAFE_FREE(tmp); - - tmp = next; - } -} - -/* Wrapper for NetServerEnum function */ - -BOOL smbw_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *, void *), - void *state) -{ - struct cached_names *names; - struct name_list *tmp; - time_t now = time(NULL); - char key[PATH_MAX]; - BOOL result = True; - - slprintf(key, PATH_MAX - 1, "%s/%s#%s", cli->desthost, - workgroup, (stype == SV_TYPE_DOMAIN_ENUM ? "DOM" : "SRV")); - - names = find_cached_names(key); - - if (names == NULL || (now - names->cache_timeout) > CACHE_TIMEOUT) { - struct cached_names *new_names = NULL; - - /* No names cached for this workgroup */ - - if (names == NULL) { - new_names = (struct cached_names *) - malloc(sizeof(struct cached_names)); - - ZERO_STRUCTP(new_names); - DLIST_ADD(cached_names, new_names); - - } else { - - /* Dispose of out of date name list */ - - free_name_list(names->name_list); - names->name_list = NULL; - - new_names = names; - } - - result = cli_NetServerEnum(cli, workgroup, stype, - add_cached_names, - &new_names->name_list); - - new_names->cache_timeout = now; - new_names->result = result; - new_names->key = strdup(key); - - names = new_names; - } - - /* Return names by running callback function. */ - - for (tmp = names->name_list; tmp; tmp = tmp->next) - fn(tmp->name, stype, tmp->comment, state); - - return names->result; -} - -/* Wrapper for RNetShareEnum function */ - -int smbw_RNetShareEnum(struct cli_state *cli, - void (*fn)(const char *, uint32, const char *, void *), - void *state) -{ - struct cached_names *names; - struct name_list *tmp; - time_t now = time(NULL); - char key[PATH_MAX]; - - slprintf(key, PATH_MAX - 1, "SHARE/%s", cli->desthost); - - names = find_cached_names(key); - - if (names == NULL || (now - names->cache_timeout) > CACHE_TIMEOUT) { - struct cached_names *new_names = NULL; - - /* No names cached for this server */ - - if (names == NULL) { - new_names = (struct cached_names *) - malloc(sizeof(struct cached_names)); - - ZERO_STRUCTP(new_names); - DLIST_ADD(cached_names, new_names); - - } else { - - /* Dispose of out of date name list */ - - free_name_list(names->name_list); - names->name_list = NULL; - - new_names = names; - } - - new_names->result = cli_RNetShareEnum(cli, add_cached_names, - &new_names->name_list); - - new_names->cache_timeout = now; - new_names->key = strdup(key); - - names = new_names; - } - - /* Return names by running callback function. */ - - for (tmp = names->name_list; tmp; tmp = tmp->next) - fn(tmp->name, tmp->stype, tmp->comment, state); - - return names->result; -} diff --git a/source/tdb/tdb.magic b/source/tdb/tdb.magic deleted file mode 100644 index f5619e7327e..00000000000 --- a/source/tdb/tdb.magic +++ /dev/null @@ -1,10 +0,0 @@ -# Magic file(1) information about tdb files. -# -# Install this into /etc/magic or the corresponding location for your -# system, or pass as a -m argument to file(1). - -# You may use and redistribute this file without restriction. - -0 string TDB\ file TDB database ->32 lelong =0x2601196D version 6, little-endian ->>36 lelong x hash size %d bytes diff --git a/source/tdb/tdbutil.h b/source/tdb/tdbutil.h deleted file mode 100644 index 01473446a1c..00000000000 --- a/source/tdb/tdbutil.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Unix SMB/CIFS implementation. - tdb utility functions - 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. -*/ - -#ifndef __TDBUTIL_H__ -#define __TDBUTIL_H__ - - -/* single node of a list returned by tdb_search_keys */ -typedef struct keys_node -{ - struct keys_node *prev, *next; - TDB_DATA node_key; -} TDB_LIST_NODE; - - -TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT*, const char*); -void tdb_search_list_free(TDB_LIST_NODE*); - - -#endif /* __TDBUTIL_H__ */ diff --git a/source/tests/shlib.c b/source/tests/shlib.c deleted file mode 100644 index 761d9fd5c57..00000000000 --- a/source/tests/shlib.c +++ /dev/null @@ -1,6 +0,0 @@ -/* a trivial function used to test building shared libraries */ - -int foo(void) -{ - return 1; -} diff --git a/source/tests/unixsock.c b/source/tests/unixsock.c deleted file mode 100644 index f2765d68f67..00000000000 --- a/source/tests/unixsock.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c-file-style: "linux" -*- - * - * Try creating a Unix-domain socket, opening it, and reading from it. - * The POSIX name for these is AF_LOCAL/PF_LOCAL. - * - * This is used by the Samba autoconf scripts to detect systems which - * don't have Unix-domain sockets, such as (probably) VMS, or systems - * on which they are broken under some conditions, such as RedHat 7.0 - * (unpatched). We can't build WinBind there at the moment. - * - * Coding standard says to always use exit() for this, not return, so - * we do. - * - * Martin Pool <mbp@samba.org>, June 2000. */ - -/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ - -#include <stdio.h> - -#ifdef HAVE_SYS_SOCKET_H -# include <sys/socket.h> -#endif - -#ifdef HAVE_SYS_UN_H -# include <sys/un.h> -#endif - -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif - -#if HAVE_SYS_WAIT_H -# include <sys/wait.h> -#endif - -#if HAVE_ERRNO_DECL -# include <errno.h> -#else -extern int errno; -#endif - -static int bind_socket(char const *filename) -{ - int sock_fd; - struct sockaddr_un name; - size_t size; - - /* Create the socket. */ - if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { - perror ("socket(PF_LOCAL, SOCK_STREAM)"); - exit(1); - } - - /* Bind a name to the socket. */ - name.sun_family = AF_LOCAL; - strncpy(name.sun_path, filename, sizeof (name.sun_path)); - - /* The size of the address is - the offset of the start of the filename, - plus its length, - plus one for the terminating null byte. - Alternatively you can just do: - size = SUN_LEN (&name); - */ - size = SUN_LEN(&name); - /* XXX: This probably won't work on unfriendly libcs */ - - if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) { - perror ("bind"); - exit(1); - } - - return sock_fd; -} - - -int main(void) -{ - int sock_fd; - int kid; - char const *filename = "conftest.unixsock.sock"; - - /* abolish hanging */ - alarm(15); /* secs */ - - if ((sock_fd = bind_socket(filename)) < 0) - exit(1); - - /* the socket will be deleted when autoconf cleans up these - files. */ - - exit(0); -} diff --git a/source/torture/samtest.h b/source/torture/samtest.h deleted file mode 100644 index a136ab191e4..00000000000 --- a/source/torture/samtest.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SAM module tester - - Copyright (C) Jelmer Vernooij 2002 - - Most of this code was ripped off of rpcclient. - Copyright (C) Tim Potter 2000-2001 - - 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. -*/ - -struct samtest_state { - SAM_CONTEXT *context; - NT_USER_TOKEN *token; -}; - -struct cmd_set { - char *name; - NTSTATUS (*fn)(struct samtest_state *sam, TALLOC_CTX *mem_ctx, int argc, - char **argv); - char *description; - char *usage; -}; - - diff --git a/source/utils/.cvsignore b/source/utils/.cvsignore deleted file mode 100644 index 6b8749f64eb..00000000000 --- a/source/utils/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -net_proto.h
\ No newline at end of file diff --git a/source/web/neg_lang.c b/source/web/neg_lang.c deleted file mode 100644 index da974f78a4a..00000000000 --- a/source/web/neg_lang.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SWAT language handling - - 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. - - Created by Ryo Kawahara <rkawa@lbe.co.jp> -*/ - -#include "includes.h" -#include "../web/swat_proto.h" - -/* - during a file download we first check to see if there is a language - specific file available. If there is then use that, otherwise - just open the specified file -*/ -int web_open(const char *fname, int flags, mode_t mode) -{ - char *p = NULL; - char *lang = lang_tdb_current(); - int fd; - if (lang) { - asprintf(&p, "lang/%s/%s", lang, fname); - if (p) { - fd = sys_open(p, flags, mode); - free(p); - if (fd != -1) { - return fd; - } - } - } - - /* fall through to default name */ - return sys_open(fname, flags, mode); -} - - -struct pri_list { - float pri; - char *string; -}; - -static int qsort_cmp_list(const void *x, const void *y) { - struct pri_list *a = (struct pri_list *)x; - struct pri_list *b = (struct pri_list *)y; - if (a->pri > b->pri) return -1; - if (a->pri == b->pri) return 0; - return 1; -} - -/* - choose from a list of languages. The list can be comma or space - separated - Keep choosing until we get a hit - Changed to habdle priority -- Simo -*/ - -void web_set_lang(const char *lang_string) -{ - char **lang_list, **count; - struct pri_list *pl; - int lang_num, i; - - /* build the lang list */ - lang_list = str_list_make(lang_string, ", \t\r\n"); - if (!lang_list) return; - - /* sort the list by priority */ - lang_num = 0; - count = lang_list; - while (*count && **count) { - count++; - lang_num++; - } - pl = (struct pri_list *)malloc(sizeof(struct pri_list) * lang_num); - for (i = 0; i < lang_num; i++) { - char *pri_code; - if ((pri_code=strstr(lang_list[i], ";q="))) { - *pri_code = '\0'; - pri_code += 3; - sscanf(pri_code, "%f", &(pl[i].pri)); - } else { - pl[i].pri = 1; - } - pl[i].string = strdup(lang_list[i]); - } - str_list_free(&lang_list); - - qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list); - - /* it's not an error to not initialise - we just fall back to - the default */ - - for (i = 0; i < lang_num; i++) { - if (lang_tdb_init(pl[i].string)) break; - } - - for (i = 0; i < lang_num; i++) { - SAFE_FREE(pl[i].string); - } - SAFE_FREE(pl); - - return; -} diff --git a/source/wrepld/parser.c b/source/wrepld/parser.c deleted file mode 100644 index b619cb0cef5..00000000000 --- a/source/wrepld/parser.c +++ /dev/null @@ -1,759 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Jean François Micouleau 1998-2002. - * - * 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 "wins_repl.h" - -extern TALLOC_CTX *mem_ctx; - -/**************************************************************************** -grow the send buffer if necessary -****************************************************************************/ -BOOL grow_buffer(struct BUFFER *buffer, int more) -{ - char *temp; - - DEBUG(10,("grow_buffer: size is: %d offet is:%d growing by %d\n", buffer->length, buffer->offset, more)); - - /* grow by at least 256 bytes */ - if (more<256) - more=256; - - if (buffer->offset+more >= buffer->length) { - temp=(char *)talloc_realloc(mem_ctx, buffer->buffer, sizeof(char)* (buffer->length+more) ); - if (temp==NULL) { - DEBUG(0,("grow_buffer: can't grow buffer\n")); - return False; - } - buffer->length+=more; - buffer->buffer=temp; - } - - return True; -} - -/**************************************************************************** -check if the buffer has that much data -****************************************************************************/ -static BOOL check_buffer(struct BUFFER *buffer, int more) -{ - DEBUG(10,("check_buffer: size is: %d offet is:%d growing by %d\n", buffer->length, buffer->offset, more)); - - if (buffer->offset+more > buffer->length) { - DEBUG(10,("check_buffer: buffer smaller than requested, size is: %d needed: %d\n", buffer->length, buffer->offset+more)); - return False; - } - - return True; -} - -/**************************************************************************** -decode a WINS_OWNER struct -****************************************************************************/ -static void decode_wins_owner(struct BUFFER *inbuf, WINS_OWNER *wins_owner) -{ - if(!check_buffer(inbuf, 24)) - return; - - wins_owner->address.s_addr=IVAL(inbuf->buffer, inbuf->offset); - wins_owner->max_version=((SMB_BIG_UINT)RIVAL(inbuf->buffer, inbuf->offset+4))<<32; - wins_owner->max_version|=RIVAL(inbuf->buffer, inbuf->offset+8); - wins_owner->min_version=((SMB_BIG_UINT)RIVAL(inbuf->buffer, inbuf->offset+12))<<32; - wins_owner->min_version|=RIVAL(inbuf->buffer, inbuf->offset+16); - wins_owner->type=RIVAL(inbuf->buffer, inbuf->offset+20); - inbuf->offset+=24; - -} - -/**************************************************************************** -decode a WINS_NAME struct -****************************************************************************/ -static void decode_wins_name(struct BUFFER *outbuf, WINS_NAME *wins_name) -{ - char *p; - int i; - - if(!check_buffer(outbuf, 40)) - return; - - wins_name->name_len=RIVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - memcpy(wins_name->name,outbuf->buffer+outbuf->offset, 15); - wins_name->name[15]='\0'; - if((p = strchr(wins_name->name,' ')) != NULL) - *p = 0; - - outbuf->offset+=15; - - wins_name->type=(int)outbuf->buffer[outbuf->offset++]; - - /* - * fix to bug in WINS replication, - * present in all versions including W2K SP2 ! - */ - if (wins_name->name[0]==0x1B) { - wins_name->name[0]=(char)wins_name->type; - wins_name->type=0x1B; - } - - wins_name->empty=RIVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - - wins_name->name_flag=RIVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - wins_name->group_flag=RIVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - wins_name->id=((SMB_BIG_UINT)RIVAL(outbuf->buffer, outbuf->offset))<<32; - outbuf->offset+=4; - wins_name->id|=RIVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - - /* special groups have multiple address */ - if (wins_name->name_flag & 2) { - if(!check_buffer(outbuf, 4)) - return; - wins_name->num_ip=IVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - } - else - wins_name->num_ip=1; - - if(!check_buffer(outbuf, 4)) - return; - wins_name->owner.s_addr=IVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - - if (wins_name->name_flag & 2) { - wins_name->others=(struct in_addr *)talloc(mem_ctx, sizeof(struct in_addr)*wins_name->num_ip); - if (wins_name->others==NULL) - return; - - if(!check_buffer(outbuf, 4*wins_name->num_ip)) - return; - for (i=0; i<wins_name->num_ip; i++) { - wins_name->others[i].s_addr=IVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - } - } - - if(!check_buffer(outbuf, 4)) - return; - wins_name->foo=RIVAL(outbuf->buffer, outbuf->offset); - outbuf->offset+=4; - -} - -/**************************************************************************** -decode a update notification request -****************************************************************************/ -static void decode_update_notify_request(struct BUFFER *inbuf, UPDATE_NOTIFY_REQUEST *un_rq) -{ - int i; - - if(!check_buffer(inbuf, 4)) - return; - un_rq->partner_count=RIVAL(inbuf->buffer, inbuf->offset); - inbuf->offset+=4; - - un_rq->wins_owner=(WINS_OWNER *)talloc(mem_ctx, un_rq->partner_count*sizeof(WINS_OWNER)); - if (un_rq->wins_owner==NULL) - return; - - for (i=0; i<un_rq->partner_count; i++) - decode_wins_owner(inbuf, &un_rq->wins_owner[i]); - - if(!check_buffer(inbuf, 4)) - return; - un_rq->initiating_wins_server.s_addr=IVAL(inbuf->buffer, inbuf->offset); - inbuf->offset+=4; -} - -/**************************************************************************** -decode a send entries request -****************************************************************************/ -static void decode_send_entries_request(struct BUFFER *inbuf, SEND_ENTRIES_REQUEST *se_rq) -{ - decode_wins_owner(inbuf, &se_rq->wins_owner); -} - -/**************************************************************************** -decode a send entries reply -****************************************************************************/ -static void decode_send_entries_reply(struct BUFFER *inbuf, SEND_ENTRIES_REPLY *se_rp) -{ - int i; - - if(!check_buffer(inbuf, 4)) - return; - se_rp->max_names = RIVAL(inbuf->buffer, inbuf->offset); - inbuf->offset+=4; - - se_rp->wins_name=(WINS_NAME *)talloc(mem_ctx, se_rp->max_names*sizeof(WINS_NAME)); - if (se_rp->wins_name==NULL) - return; - - for (i=0; i<se_rp->max_names; i++) - decode_wins_name(inbuf, &se_rp->wins_name[i]); -} - -/**************************************************************************** -decode a add version number map table reply -****************************************************************************/ -static void decode_add_version_number_map_table_reply(struct BUFFER *inbuf, AVMT_REP *avmt_rep) -{ - int i; - - if(!check_buffer(inbuf, 4)) - return; - - avmt_rep->partner_count=RIVAL(inbuf->buffer, inbuf->offset); - inbuf->offset+=4; - - avmt_rep->wins_owner=(WINS_OWNER *)talloc(mem_ctx, avmt_rep->partner_count*sizeof(WINS_OWNER)); - if (avmt_rep->wins_owner==NULL) - return; - - for (i=0; i<avmt_rep->partner_count; i++) - decode_wins_owner(inbuf, &avmt_rep->wins_owner[i]); - - if(!check_buffer(inbuf, 4)) - return; - avmt_rep->initiating_wins_server.s_addr=IVAL(inbuf->buffer, inbuf->offset); - inbuf->offset+=4; -} - -/**************************************************************************** -decode a replicate packet and fill a structure -****************************************************************************/ -static void decode_replicate(struct BUFFER *inbuf, REPLICATE *rep) -{ - if(!check_buffer(inbuf, 4)) - return; - - rep->msg_type = RIVAL(inbuf->buffer, inbuf->offset); - - inbuf->offset+=4; - - switch (rep->msg_type) { - case 0: - break; - case 1: - /* add version number map table reply */ - decode_add_version_number_map_table_reply(inbuf, &rep->avmt_rep); - break; - case 2: - /* send entry request */ - decode_send_entries_request(inbuf, &rep->se_rq); - break; - case 3: - /* send entry request */ - decode_send_entries_reply(inbuf, &rep->se_rp); - break; - case 4: - /* update notification request */ - decode_update_notify_request(inbuf, &rep->un_rq); - break; - default: - DEBUG(0,("decode_replicate: unknown message type:%d\n", rep->msg_type)); - break; - } -} - -/**************************************************************************** -read the generic header and fill the struct. -****************************************************************************/ -static void read_generic_header(struct BUFFER *inbuf, generic_header *q) -{ - if(!check_buffer(inbuf, 16)) - return; - - q->data_size = RIVAL(inbuf->buffer, inbuf->offset+0); - q->opcode = RIVAL(inbuf->buffer, inbuf->offset+4); - q->assoc_ctx = RIVAL(inbuf->buffer, inbuf->offset+8); - q->mess_type = RIVAL(inbuf->buffer, inbuf->offset+12); -} - -/******************************************************************* -decode a start association request -********************************************************************/ -static void decode_start_assoc_request(struct BUFFER *inbuf, START_ASSOC_REQUEST *q) -{ - if(!check_buffer(inbuf, 8)) - return; - - q->assoc_ctx = RIVAL(inbuf->buffer, inbuf->offset+0); - q->min_ver = RSVAL(inbuf->buffer, inbuf->offset+4); - q->maj_ver = RSVAL(inbuf->buffer, inbuf->offset+6); -} - -/******************************************************************* -decode a start association reply -********************************************************************/ -static void decode_start_assoc_reply(struct BUFFER *inbuf, START_ASSOC_REPLY *r) -{ - if(!check_buffer(inbuf, 8)) - return; - - r->assoc_ctx=RIVAL(inbuf->buffer, inbuf->offset+0); - r->min_ver = RSVAL(inbuf->buffer, inbuf->offset+4); - r->maj_ver = RSVAL(inbuf->buffer, inbuf->offset+6); -} - -/******************************************************************* -decode a start association reply -********************************************************************/ -static void decode_stop_assoc(struct BUFFER *inbuf, STOP_ASSOC *r) -{ - if(!check_buffer(inbuf, 4)) - return; - - r->reason=RIVAL(inbuf->buffer, inbuf->offset); -} - -/**************************************************************************** -decode a packet and fill a generic structure -****************************************************************************/ -void decode_generic_packet(struct BUFFER *inbuf, GENERIC_PACKET *q) -{ - read_generic_header(inbuf, &q->header); - - inbuf->offset+=16; - - switch (q->header.mess_type) { - case 0: - decode_start_assoc_request(inbuf, &q->sa_rq); - break; - case 1: - decode_start_assoc_reply(inbuf, &q->sa_rp); - break; - case 2: - decode_stop_assoc(inbuf, &q->so); - break; - case 3: - decode_replicate(inbuf, &q->rep); - break; - default: - DEBUG(0,("decode_generic_packet: unknown message type:%d\n", q->header.mess_type)); - break; - } -} - -/**************************************************************************** -encode a WINS_OWNER struct -****************************************************************************/ -static void encode_wins_owner(struct BUFFER *outbuf, WINS_OWNER *wins_owner) -{ - if (!grow_buffer(outbuf, 24)) - return; - - SIVAL(outbuf->buffer, outbuf->offset, wins_owner->address.s_addr); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, (int)(wins_owner->max_version>>32)); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, (int)(wins_owner->max_version&0xffffffff)); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, wins_owner->min_version>>32); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, wins_owner->min_version&0xffffffff); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, wins_owner->type); - outbuf->offset+=4; - -} - -/**************************************************************************** -encode a WINS_NAME struct -****************************************************************************/ -static void encode_wins_name(struct BUFFER *outbuf, WINS_NAME *wins_name) -{ - int i; - - if (!grow_buffer(outbuf, 48+(4*wins_name->num_ip))) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->name_len); - outbuf->offset+=4; - - memset(outbuf->buffer+outbuf->offset, ' ', 15); - - /* to prevent copying the leading \0 */ - memcpy(outbuf->buffer+outbuf->offset, wins_name->name, strlen(wins_name->name)); - outbuf->offset+=15; - - outbuf->buffer[outbuf->offset++]=(char)wins_name->type; - - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->empty); - outbuf->offset+=4; - - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->name_flag); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->group_flag); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->id>>32); - outbuf->offset+=4; - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->id); - outbuf->offset+=4; - - if (wins_name->name_flag & 2) { - SIVAL(outbuf->buffer, outbuf->offset, wins_name->num_ip); - outbuf->offset+=4; - } - - SIVAL(outbuf->buffer, outbuf->offset, wins_name->owner.s_addr); - outbuf->offset+=4; - - if (wins_name->name_flag & 2) { - for (i=0;i<wins_name->num_ip;i++) { - SIVAL(outbuf->buffer, outbuf->offset, wins_name->others[i].s_addr); - outbuf->offset+=4; - } - } - - RSIVAL(outbuf->buffer, outbuf->offset, wins_name->foo); - outbuf->offset+=4; -} - -/**************************************************************************** -encode a update notification request -****************************************************************************/ -static void encode_update_notify_request(struct BUFFER *outbuf, UPDATE_NOTIFY_REQUEST *un_rq) -{ - int i; - - if (!grow_buffer(outbuf, 8)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, un_rq->partner_count); - outbuf->offset+=4; - - for (i=0; i<un_rq->partner_count; i++) - encode_wins_owner(outbuf, &un_rq->wins_owner[i]); - - SIVAL(outbuf->buffer, outbuf->offset, un_rq->initiating_wins_server.s_addr); - outbuf->offset+=4; - -} - -/**************************************************************************** -decode a send entries request -****************************************************************************/ -static void encode_send_entries_request(struct BUFFER *outbuf, SEND_ENTRIES_REQUEST *se_rq) -{ - encode_wins_owner(outbuf, &se_rq->wins_owner); -} - -/**************************************************************************** -decode a send entries reply -****************************************************************************/ -static void encode_send_entries_reply(struct BUFFER *outbuf, SEND_ENTRIES_REPLY *se_rp) -{ - int i; - - if (!grow_buffer(outbuf, 4)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, se_rp->max_names); - outbuf->offset+=4; - - for (i=0; i<se_rp->max_names; i++) - encode_wins_name(outbuf, &se_rp->wins_name[i]); - -} - -/**************************************************************************** -encode a add version number map table reply -****************************************************************************/ -static void encode_add_version_number_map_table_reply(struct BUFFER *outbuf, AVMT_REP *avmt_rep) -{ - int i; - - if (!grow_buffer(outbuf, 8)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, avmt_rep->partner_count); - outbuf->offset+=4; - - for (i=0; i<avmt_rep->partner_count; i++) - encode_wins_owner(outbuf, &avmt_rep->wins_owner[i]); - - SIVAL(outbuf->buffer, outbuf->offset, avmt_rep->initiating_wins_server.s_addr); - outbuf->offset+=4; - -} - -/**************************************************************************** -decode a replicate packet and fill a structure -****************************************************************************/ -static void encode_replicate(struct BUFFER *outbuf, REPLICATE *rep) -{ - if (!grow_buffer(outbuf, 4)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, rep->msg_type); - outbuf->offset+=4; - - switch (rep->msg_type) { - case 0: - break; - case 1: - /* add version number map table reply */ - encode_add_version_number_map_table_reply(outbuf, &rep->avmt_rep); - break; - case 2: - /* send entry request */ - encode_send_entries_request(outbuf, &rep->se_rq); - break; - case 3: - /* send entry request */ - encode_send_entries_reply(outbuf, &rep->se_rp); - break; - case 4: - /* update notification request */ - encode_update_notify_request(outbuf, &rep->un_rq); - break; - default: - DEBUG(0,("encode_replicate: unknown message type:%d\n", rep->msg_type)); - break; - } -} - -/**************************************************************************** -write the generic header. -****************************************************************************/ -static void write_generic_header(struct BUFFER *outbuf, generic_header *r) -{ - RSIVAL(outbuf->buffer, 0, r->data_size); - RSIVAL(outbuf->buffer, 4, r->opcode); - RSIVAL(outbuf->buffer, 8, r->assoc_ctx); - RSIVAL(outbuf->buffer,12, r->mess_type); -} - -/******************************************************************* -decode a start association request -********************************************************************/ -static void encode_start_assoc_request(struct BUFFER *outbuf, START_ASSOC_REQUEST *q) -{ - if (!grow_buffer(outbuf, 45)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, q->assoc_ctx); - RSSVAL(outbuf->buffer, outbuf->offset+4, q->min_ver); - RSSVAL(outbuf->buffer, outbuf->offset+6, q->maj_ver); - - outbuf->offset=45; -} - -/******************************************************************* -decode a start association reply -********************************************************************/ -static void encode_start_assoc_reply(struct BUFFER *outbuf, START_ASSOC_REPLY *r) -{ - if (!grow_buffer(outbuf, 45)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, r->assoc_ctx); - RSSVAL(outbuf->buffer, outbuf->offset+4, r->min_ver); - RSSVAL(outbuf->buffer, outbuf->offset+6, r->maj_ver); - - outbuf->offset=45; -} - -/******************************************************************* -decode a start association reply -********************************************************************/ -static void encode_stop_assoc(struct BUFFER *outbuf, STOP_ASSOC *r) -{ - if (!grow_buffer(outbuf, 44)) - return; - - RSIVAL(outbuf->buffer, outbuf->offset, r->reason); - - outbuf->offset=44; -} - -/**************************************************************************** -write the generic header size. -****************************************************************************/ -static void write_generic_header_size(generic_header *r, int size) -{ - /* the buffer size is the total size minus the size field */ - r->data_size=size-4; -} - -/**************************************************************************** -encode a packet and read a generic structure -****************************************************************************/ -void encode_generic_packet(struct BUFFER *outbuf, GENERIC_PACKET *q) -{ - if (!grow_buffer(outbuf, 16)) - return; - - outbuf->offset=16; - - switch (q->header.mess_type) { - case 0: - encode_start_assoc_request(outbuf, &q->sa_rq); - break; - case 1: - encode_start_assoc_reply(outbuf, &q->sa_rp); - break; - case 2: - encode_stop_assoc(outbuf, &q->so); - break; - case 3: - encode_replicate(outbuf, &q->rep); - break; - default: - DEBUG(0,("encode_generic_packet: unknown message type:%d\n", q->header.mess_type)); - break; - } - - write_generic_header_size(&q->header, outbuf->offset); - write_generic_header(outbuf, &q->header); -} - - -/**************************************************************************** -dump a WINS_OWNER structure -****************************************************************************/ -static void dump_wins_owner(WINS_OWNER *wins_owner) -{ - DEBUGADD(10,("\t\t\t\taddress : %s\n", inet_ntoa(wins_owner->address))); - DEBUGADD(10,("\t\t\t\tmax version: %d\n", (int)wins_owner->max_version)); - DEBUGADD(10,("\t\t\t\tmin version: %d\n", (int)wins_owner->min_version)); - DEBUGADD(10,("\t\t\t\ttype : %d\n", wins_owner->type)); -} - -/**************************************************************************** -dump a WINS_NAME structure -****************************************************************************/ -static void dump_wins_name(WINS_NAME *wins_name) -{ - fstring name; - int i; - - strncpy(name, wins_name->name, 15); - - DEBUGADD(10,("name: %d, %s<%02x> %x,%x, %d %s %d ", wins_name->name_len, name, wins_name->type, - wins_name->name_flag, wins_name->group_flag, (int)wins_name->id, - inet_ntoa(wins_name->owner), wins_name->num_ip)); - - if (wins_name->num_ip!=1) - for (i=0; i<wins_name->num_ip; i++) - DEBUGADD(10,("%s ", inet_ntoa(wins_name->others[i]))); - - DEBUGADD(10,("\n")); -} - -/**************************************************************************** -dump a replicate structure -****************************************************************************/ -static void dump_replicate(REPLICATE *rep) -{ - int i; - - DEBUGADD(5,("\t\tmsg_type: %d ", rep->msg_type)); - - switch (rep->msg_type) { - case 0: - DEBUGADD(5,("(Add Version Map Table Request)\n")); - break; - case 1: - DEBUGADD(5,("(Add Version Map Table Reply)\n")); - DEBUGADD(5,("\t\t\tpartner_count : %d\n", rep->avmt_rep.partner_count)); - for (i=0; i<rep->avmt_rep.partner_count; i++) - dump_wins_owner(&rep->avmt_rep.wins_owner[i]); - DEBUGADD(5,("\t\t\tinitiating_wins_server: %s\n", inet_ntoa(rep->avmt_rep.initiating_wins_server))); - break; - case 2: - DEBUGADD(5,("(Send Entries Request)\n")); - dump_wins_owner(&rep->se_rq.wins_owner); - break; - case 3: - DEBUGADD(5,("(Send Entries Reply)\n")); - DEBUGADD(5,("\t\t\tmax_names : %d\n", rep->se_rp.max_names)); - for (i=0; i<rep->se_rp.max_names; i++) - dump_wins_name(&rep->se_rp.wins_name[i]); - break; - case 4: - DEBUGADD(5,("(Update Notify Request)\n")); - DEBUGADD(5,("\t\t\tpartner_count : %d\n", rep->un_rq.partner_count)); - for (i=0; i<rep->un_rq.partner_count; i++) - dump_wins_owner(&rep->un_rq.wins_owner[i]); - DEBUGADD(5,("\t\t\tinitiating_wins_server: %s\n", inet_ntoa(rep->un_rq.initiating_wins_server))); - break; - default: - DEBUG(5,("\n")); - break; - } -} - -/**************************************************************************** -dump a generic structure -****************************************************************************/ -void dump_generic_packet(GENERIC_PACKET *q) -{ - DEBUG(5,("dump_generic_packet:\n")); - DEBUGADD(5,("\tdata_size: %08x\n", q->header.data_size)); - DEBUGADD(5,("\topcode : %08x\n", q->header.opcode)); - DEBUGADD(5,("\tassoc_ctx: %08x\n", q->header.assoc_ctx)); - DEBUGADD(5,("\tmess_type: %08x ", q->header.mess_type)); - - switch (q->header.mess_type) { - case 0: - DEBUGADD(5,("(Start Association Request)\n")); - DEBUGADD(5,("\t\tassoc_ctx: %08x\n", q->sa_rq.assoc_ctx)); - DEBUGADD(5,("\t\tmin_ver : %04x\n", q->sa_rq.min_ver)); - DEBUGADD(5,("\t\tmaj_ver : %04x\n", q->sa_rq.maj_ver)); - break; - case 1: - DEBUGADD(5,("(Start Association Reply)\n")); - DEBUGADD(5,("\t\tassoc_ctx: %08x\n", q->sa_rp.assoc_ctx)); - DEBUGADD(5,("\t\tmin_ver : %04x\n", q->sa_rp.min_ver)); - DEBUGADD(5,("\t\tmaj_ver : %04x\n", q->sa_rp.maj_ver)); - break; - case 2: - DEBUGADD(5,("(Stop Association)\n")); - DEBUGADD(5,("\t\treason: %08x\n", q->so.reason)); - break; - case 3: - DEBUGADD(5,("(Replication Message)\n")); - dump_replicate(&q->rep); - break; - default: - DEBUG(5,("\n")); - break; - } - -} - -/**************************************************************************** -generate a stop packet -****************************************************************************/ -void stop_packet(GENERIC_PACKET *q, GENERIC_PACKET *r, int reason) -{ - r->header.opcode=OPCODE_NON_NBT; - r->header.assoc_ctx=get_server_assoc(q->header.assoc_ctx); - r->header.mess_type=MESSAGE_TYPE_STOP_ASSOC; - r->so.reason=reason; - -} - - diff --git a/source/wrepld/partners.c b/source/wrepld/partners.c deleted file mode 100644 index 2387f5b45f6..00000000000 --- a/source/wrepld/partners.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - Unix SMB/CIFS implementation. - process incoming packets - main loop - Copyright (C) Jean François Micouleau 1998-2002. - - 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 "wins_repl.h" - -/* we can exchange info with 64 partners at any given time */ -WINS_PARTNER current_partners[64]; -int total_current_partners; - -/******************************************************************* -verify if we know this partner -********************************************************************/ -BOOL check_partner(int assoc) -{ - int i; - - DEBUG(5,("check_partner: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==assoc) - return True; - - return False; -} - -/******************************************************************* -add a new entry to the list -********************************************************************/ -BOOL add_partner(int client_assoc, int server_assoc, BOOL pull, BOOL push) -{ - DEBUG(5,("add_partner: total_current_partners: %d\n", total_current_partners)); - - if (total_current_partners==64) - return False; - - current_partners[total_current_partners].client_assoc=client_assoc; - current_partners[total_current_partners].server_assoc=server_assoc; - current_partners[total_current_partners].pull_partner=pull; - current_partners[total_current_partners].push_partner=push; - - total_current_partners++; - - return True; -} - -/******************************************************************* -remove an entry to the list -********************************************************************/ -BOOL remove_partner(int client_assoc) -{ - int i,j; - - DEBUG(5,("remove_partner: total_current_partners: %d\n", total_current_partners)); - - for (i=0; current_partners[i].client_assoc!=client_assoc && i<total_current_partners; i++) - ; - - if (i==total_current_partners) - return False; - - for (j=i+1; j<total_current_partners; j++) { - current_partners[j-1].client_assoc=current_partners[j].client_assoc; - current_partners[j-1].server_assoc=current_partners[j].server_assoc; - current_partners[j-1].pull_partner=current_partners[j].pull_partner; - current_partners[j-1].push_partner=current_partners[j].push_partner; - current_partners[j-1].partner_server.s_addr=current_partners[j].partner_server.s_addr; - current_partners[j-1].other_server.s_addr=current_partners[j].other_server.s_addr; - } - - total_current_partners--; - - return True; -} - -/******************************************************************* -link the client and server context -********************************************************************/ -BOOL update_server_partner(int client_assoc, int server_assoc) -{ - int i; - - DEBUG(5,("update_server_partner: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==client_assoc) { - current_partners[i].server_assoc=server_assoc; - return True; - } - - return False; -} - -/******************************************************************* -verify if it's a pull partner -********************************************************************/ -BOOL check_pull_partner(int assoc) -{ - int i; - - DEBUG(5,("check_pull_partner: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==assoc && - current_partners[i].pull_partner==True) - return True; - - return False; -} - -/******************************************************************* -verify if it's a push partner -********************************************************************/ -BOOL check_push_partner(int assoc) -{ - int i; - - DEBUG(5,("check_push_partner: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==assoc && - current_partners[i].push_partner==True) - return True; - - return False; -} - -/******************************************************************* -return the server ctx linked to the client ctx -********************************************************************/ -int get_server_assoc(int assoc) -{ - int i; - - DEBUG(5,("get_server_assoc: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==assoc) - return current_partners[i].server_assoc; - - return 0; -} - - -/******************************************************************* -link the client and server context -********************************************************************/ -BOOL write_server_assoc_table(int client_assoc, struct in_addr partner, struct in_addr server) -{ - int i; - - DEBUG(5,("write_server_assoc_table: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==client_assoc) { - current_partners[i].partner_server=partner; - current_partners[i].other_server=server; - return True; - } - - return False; -} - -/******************************************************************* -link the client and server context -********************************************************************/ -BOOL get_server_assoc_table(int client_assoc, struct in_addr *partner, struct in_addr *server) -{ - int i; - - DEBUG(5,("get_server_assoc_table: total_current_partners: %d\n", total_current_partners)); - - for (i=0; i<total_current_partners; i++) - if (current_partners[i].client_assoc==client_assoc) { - partner->s_addr=current_partners[i].partner_server.s_addr; - server->s_addr=current_partners[i].other_server.s_addr; - return True; - } - - return False; -} - - diff --git a/source/wrepld/socket.c b/source/wrepld/socket.c deleted file mode 100644 index 3d759f0ab89..00000000000 --- a/source/wrepld/socket.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - Unix SMB/CIFS implementation. - process incoming packets - main loop - Copyright (C) Jean François Micouleau 1998-2002. - - 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 "wins_repl.h" - -fd_set *listen_set = NULL; -int listen_number = 0; -int *sock_array = NULL; - -/******************************************************************* - Add an fd from the sock_array -******************************************************************/ -void add_fd_to_sock_array(int fd) -{ - int *temp_sock=NULL; - - temp_sock=(int *)Realloc(sock_array, (listen_number+1)*sizeof(int)); - if (temp_sock==NULL) - return; - - sock_array=temp_sock; - sock_array[listen_number]=fd; - listen_number++; -} - - -/******************************************************************* - Remove an fd from the sock_array -******************************************************************/ -void remove_fd_from_sock_array(int fd) -{ - int i,j; - - for (i=0; sock_array[i]!=fd && i<listen_number; i++) - ; - - if (i==listen_number) { - DEBUG(0,("remove_fd_from_sock_array: unknown fd: %d\n", fd)); - return; - } - - if (i==listen_number-1) { - sock_array=(int *)Realloc(sock_array, --listen_number*sizeof(int)); - return; - } - - for (j=i; j<listen_number-1; j++) - sock_array[j]=sock_array[j+1]; - - sock_array=(int *)Realloc(sock_array, --listen_number*sizeof(int)); -} |