Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorJelmer Vernooij <jelmer@samba.org>
Thu, 22 Jan 2009 21:49:30 +0000 (22:49 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 22 Jan 2009 21:49:30 +0000 (22:49 +0100)
26 files changed:
source3/configure.in
source3/tests/trivial.c [deleted file]
source4/build/m4/check_cc.m4
source4/build/m4/check_ld.m4
source4/build/m4/public.m4
source4/build/tests/README [deleted file]
source4/build/tests/crypttest.c [deleted file]
source4/build/tests/fcntl_lock.c [deleted file]
source4/build/tests/fcntl_lock64.c [deleted file]
source4/build/tests/shlib.c [deleted file]
source4/build/tests/summary.c [deleted file]
source4/configure.ac
source4/libcli/security/tests/bindings.py
source4/librpc/ndr/py_security.c
source4/scripting/python/samba/samr.py [deleted file]
tests/README [moved from source3/tests/README with 100% similarity]
tests/crypttest.c [moved from source3/tests/crypttest.c with 100% similarity]
tests/fcntl_lock.c [moved from source3/tests/fcntl_lock.c with 100% similarity]
tests/fcntl_lock64.c [moved from source3/tests/fcntl_lock64.c with 100% similarity]
tests/fcntl_lock_thread.c [moved from source4/build/tests/fcntl_lock_thread.c with 100% similarity]
tests/ftruncate.c [moved from source3/tests/ftruncate.c with 100% similarity]
tests/getgroups.c [moved from source3/tests/getgroups.c with 100% similarity]
tests/shared_mmap.c [moved from source4/build/tests/shared_mmap.c with 100% similarity]
tests/shlib.c [moved from source3/tests/shlib.c with 100% similarity]
tests/summary.c [moved from source3/tests/summary.c with 98% similarity]
tests/trivial.c [moved from source4/build/tests/trivial.c with 100% similarity]

index 87b4c33417c47000cac71e16a6b8d16bd9b8d5f1..44a932c6f581b4dd897093c3d4d7eb6ffd6c7db8 100644 (file)
@@ -1916,7 +1916,7 @@ AC_CACHE_CHECK([whether building shared libraries actually works],
    # The $SHLD and $LDSHFLAGS variables may contain references to other
    # variables so they need to be eval'ed.
    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o \
-       shlib.o ${srcdir-.}/tests/shlib.c && \
+       shlib.o ${srcdir-.}/../tests/shlib.c && \
    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
         shlib.o && ac_cv_shlib_works=yes
    rm -f "shlib.$SHLIBEXT" shlib.o
@@ -2749,20 +2749,20 @@ if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
 fi
 
 AC_MSG_CHECKING([for test routines])
-AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
            AC_MSG_RESULT(yes),
           AC_MSG_ERROR([cant find test code. Aborting config]),
           AC_MSG_WARN([cannot run when cross-compiling]))
 
 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/ftruncate.c"],
            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
 fi
 
 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/getgroups.c"],
            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
@@ -2849,14 +2849,14 @@ if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
 fi
 
 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock.c"],
            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
 if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
 fi
 
 AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock64.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock64.c"],
            samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
 if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
     AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
@@ -4375,7 +4375,7 @@ if test $with_pam_for_crypt = no; then
 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
 crypt_LIBS="$LIBS"
 LIBS="$AUTH_LIBS $LIBS"
-AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/crypttest.c"],
        samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
 LIBS="$crypt_LIBS"])
 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
@@ -4603,7 +4603,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4A 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
     samba_cv_SYSQUOTA_FOUND=yes;
@@ -4618,7 +4618,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4B 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
@@ -4634,7 +4634,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_3 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
@@ -6348,7 +6348,7 @@ AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
 # final configure stuff
 
 AC_MSG_CHECKING([configure summary])
-AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
            AC_MSG_RESULT(yes),
           AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
           AC_MSG_WARN([cannot run when cross-compiling]))
diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c
deleted file mode 100644 (file)
index 2723637..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-main()
-{
-       exit(0);
-}
index 51531ca7765d65ecc6425de9fe394edec812ac89..1683cb028ae64e86fb56f2f6f7fddedebf199062 100644 (file)
@@ -51,7 +51,7 @@ if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
 fi
 
 AC_MSG_CHECKING([for test routines])
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
            AC_MSG_RESULT(yes),
            AC_MSG_ERROR([cant find test code. Aborting config]),
            AC_MSG_WARN([cannot run when cross-compiling]))
index 3a74ffc239505b6a080f08d3dab3920f14b3eb0b..48d6b333efbbc7b39e94b9ac8a362eef8b802431 100644 (file)
@@ -137,7 +137,7 @@ if test $BLDSHARED = true; then
                        ac_cv_shlib_works=no
                        # try building a trivial shared library
                        # TODO: also test SONAMEFLAG
-                       ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
+                       ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/../tests/shlib.c -o shlib.o &&
                                ${SHLD} ${SHLD_FLAGS} -o shlib.${SHLIBEXT} shlib.o && 
                                ac_cv_shlib_works=yes
                        rm -f shlib.${SHLIBEXT} shlib.o
@@ -146,7 +146,7 @@ if test $BLDSHARED = true; then
                       [ac_cv_shmod_works],[
                        ac_cv_shmod_works=no
                        # try building a trivial shared library
-                       ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
+                       ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/../tests/shlib.c -o shlib.o &&
                                ${MDLD} ${MDLD_FLAGS} -o shlib.${SHLIBEXT} shlib.o && 
                                ac_cv_shmod_works=yes
                        rm -f shlib.${SHLIBEXT} shlib.o
@@ -162,7 +162,7 @@ fi
 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
 
 AC_MSG_CHECKING([if we can link using the selected flags])
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
            AC_MSG_RESULT(yes),
            AC_MSG_ERROR([we cannot link with the selected cc and ld flags. Aborting configure]),
            AC_MSG_WARN([cannot run when cross-compiling]))
index a2b46a5287bd0e3bbdc1374f8316af16ca49b2b9..ffd112f5f173448e842ffbc6a59ce19158ac9b34 100644 (file)
@@ -90,7 +90,7 @@ AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
                                OLD_CFLAGS="$CFLAGS"
                                CFLAGS="$CFLAGS $$1_CFLAGS"
                                AC_MSG_CHECKING([that the C compiler can use the $1_CFLAGS])
-                               AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
+                               AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
                                        SMB_ENABLE($1, YES)
                                        AC_MSG_RESULT(yes),
                                        AC_MSG_RESULT(no),
diff --git a/source4/build/tests/README b/source4/build/tests/README
deleted file mode 100644 (file)
index cf1be8b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-This directory contains autoconf test programs that are too large to
-comfortably fit in configure.in.
-
-These programs should test one feature of the OS and exit(0) if it
-works or exit(1) if it doesn't work (do _not_ use return)
-
-The programs should be kept simple and to the point. Beautiful/fast
-code is not necessary
-
-
diff --git a/source4/build/tests/crypttest.c b/source4/build/tests/crypttest.c
deleted file mode 100644 (file)
index 0e500d5..0000000
+++ /dev/null
@@ -1,851 +0,0 @@
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
-#include <sys/types.h>
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#if !defined(HAVE_CRYPT)
-
-/*
-   This bit of code was derived from the UFC-crypt package which
-   carries the following copyright
-
-   Modified for use by Samba by Andrew Tridgell, October 1994
-
-   Note that this routine is only faster on some machines. Under Linux 1.1.51 
-   libc 4.5.26 I actually found this routine to be slightly slower.
-
-   Under SunOS I found a huge speedup by using these routines 
-   (a factor of 20 or so)
-
-   Warning: I've had a report from Steve Kennedy <steve@gbnet.org>
-   that this crypt routine may sometimes get the wrong answer. Only
-   use UFC_CRYT if you really need it.
-
-*/
-
-/*
- * UFC-crypt: ultra fast crypt(3) implementation
- *
- * Copyright (C) 1991-1998, Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- *
- * @(#)crypt_util.c    2.31 02/08/92
- *
- * Support routines
- *
- */
-
-
-#ifndef long32
-#if (SIZEOF_INT == 4)
-#define long32 int
-#elif (SIZEOF_LONG == 4)
-#define long32 long
-#elif (SIZEOF_SHORT == 4)
-#define long32 short
-#else
-/* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */
-#define long32 int
-#endif
-#endif
-
-#ifndef long64
-#ifdef HAVE_LONGLONG
-#define long64 long long long
-#endif
-#endif
-
-#ifndef ufc_long
-#define ufc_long unsigned
-#endif
-
-#ifndef _UFC_64_
-#define _UFC_32_
-#endif
-
-/* 
- * Permutation done once on the 56 bit 
- *  key derived from the original 8 byte ASCII key.
- */
-static int pc1[56] = { 
-  57, 49, 41, 33, 25, 17,  9,  1, 58, 50, 42, 34, 26, 18,
-  10,  2, 59, 51, 43, 35, 27, 19, 11,  3, 60, 52, 44, 36,
-  63, 55, 47, 39, 31, 23, 15,  7, 62, 54, 46, 38, 30, 22,
-  14,  6, 61, 53, 45, 37, 29, 21, 13,  5, 28, 20, 12,  4
-};
-
-/*
- * How much to rotate each 28 bit half of the pc1 permutated
- *  56 bit key before using pc2 to give the i' key
- */
-static int rots[16] = { 
-  1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 
-};
-
-/* 
- * Permutation giving the key 
- * of the i' DES round 
- */
-static int pc2[48] = { 
-  14, 17, 11, 24,  1,  5,  3, 28, 15,  6, 21, 10,
-  23, 19, 12,  4, 26,  8, 16,  7, 27, 20, 13,  2,
-  41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
-  44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
-};
-
-/*
- * The E expansion table which selects
- * bits from the 32 bit intermediate result.
- */
-static int esel[48] = { 
-  32,  1,  2,  3,  4,  5,  4,  5,  6,  7,  8,  9,
-   8,  9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17,
-  16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25,
-  24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32,  1
-};
-static int e_inverse[64];
-
-/* 
- * Permutation done on the 
- * result of sbox lookups 
- */
-static int perm32[32] = {
-  16,  7, 20, 21, 29, 12, 28, 17,  1, 15, 23, 26,  5, 18, 31, 10,
-  2,   8, 24, 14, 32, 27,  3,  9, 19, 13, 30,  6, 22, 11,  4, 25
-};
-
-/* 
- * The sboxes
- */
-static int sbox[8][4][16]= {
-        { { 14,  4, 13,  1,  2, 15, 11,  8,  3, 10,  6, 12,  5,  9,  0,  7 },
-          {  0, 15,  7,  4, 14,  2, 13,  1, 10,  6, 12, 11,  9,  5,  3,  8 },
-          {  4,  1, 14,  8, 13,  6,  2, 11, 15, 12,  9,  7,  3, 10,  5,  0 },
-          { 15, 12,  8,  2,  4,  9,  1,  7,  5, 11,  3, 14, 10,  0,  6, 13 }
-        },
-
-        { { 15,  1,  8, 14,  6, 11,  3,  4,  9,  7,  2, 13, 12,  0,  5, 10 },
-          {  3, 13,  4,  7, 15,  2,  8, 14, 12,  0,  1, 10,  6,  9, 11,  5 },
-          {  0, 14,  7, 11, 10,  4, 13,  1,  5,  8, 12,  6,  9,  3,  2, 15 },
-          { 13,  8, 10,  1,  3, 15,  4,  2, 11,  6,  7, 12,  0,  5, 14,  9 }
-        },
-
-        { { 10,  0,  9, 14,  6,  3, 15,  5,  1, 13, 12,  7, 11,  4,  2,  8 },
-          { 13,  7,  0,  9,  3,  4,  6, 10,  2,  8,  5, 14, 12, 11, 15,  1 },
-          { 13,  6,  4,  9,  8, 15,  3,  0, 11,  1,  2, 12,  5, 10, 14,  7 },
-          {  1, 10, 13,  0,  6,  9,  8,  7,  4, 15, 14,  3, 11,  5,  2, 12 }
-        },
-
-        { {  7, 13, 14,  3,  0,  6,  9, 10,  1,  2,  8,  5, 11, 12,  4, 15 },
-          { 13,  8, 11,  5,  6, 15,  0,  3,  4,  7,  2, 12,  1, 10, 14,  9 },
-          { 10,  6,  9,  0, 12, 11,  7, 13, 15,  1,  3, 14,  5,  2,  8,  4 },
-          {  3, 15,  0,  6, 10,  1, 13,  8,  9,  4,  5, 11, 12,  7,  2, 14 }
-        },
-
-        { {  2, 12,  4,  1,  7, 10, 11,  6,  8,  5,  3, 15, 13,  0, 14,  9 },
-          { 14, 11,  2, 12,  4,  7, 13,  1,  5,  0, 15, 10,  3,  9,  8,  6 },
-          {  4,  2,  1, 11, 10, 13,  7,  8, 15,  9, 12,  5,  6,  3,  0, 14 },
-          { 11,  8, 12,  7,  1, 14,  2, 13,  6, 15,  0,  9, 10,  4,  5,  3 }
-        },
-
-        { { 12,  1, 10, 15,  9,  2,  6,  8,  0, 13,  3,  4, 14,  7,  5, 11 },
-          { 10, 15,  4,  2,  7, 12,  9,  5,  6,  1, 13, 14,  0, 11,  3,  8 },
-          {  9, 14, 15,  5,  2,  8, 12,  3,  7,  0,  4, 10,  1, 13, 11,  6 },
-          {  4,  3,  2, 12,  9,  5, 15, 10, 11, 14,  1,  7,  6,  0,  8, 13 }
-        },
-
-        { {  4, 11,  2, 14, 15,  0,  8, 13,  3, 12,  9,  7,  5, 10,  6,  1 },
-          { 13,  0, 11,  7,  4,  9,  1, 10, 14,  3,  5, 12,  2, 15,  8,  6 },
-          {  1,  4, 11, 13, 12,  3,  7, 14, 10, 15,  6,  8,  0,  5,  9,  2 },
-          {  6, 11, 13,  8,  1,  4, 10,  7,  9,  5,  0, 15, 14,  2,  3, 12 }
-        },
-
-        { { 13,  2,  8,  4,  6, 15, 11,  1, 10,  9,  3, 14,  5,  0, 12,  7 },
-          {  1, 15, 13,  8, 10,  3,  7,  4, 12,  5,  6, 11,  0, 14,  9,  2 },
-          {  7, 11,  4,  1,  9, 12, 14,  2,  0,  6, 10, 13, 15,  3,  5,  8 },
-          {  2,  1, 14,  7,  4, 10,  8, 13, 15, 12,  9,  0,  3,  5,  6, 11 }
-        }
-};
-
-/* 
- * This is the final 
- * permutation matrix
- */
-static int final_perm[64] = {
-  40,  8, 48, 16, 56, 24, 64, 32, 39,  7, 47, 15, 55, 23, 63, 31,
-  38,  6, 46, 14, 54, 22, 62, 30, 37,  5, 45, 13, 53, 21, 61, 29,
-  36,  4, 44, 12, 52, 20, 60, 28, 35,  3, 43, 11, 51, 19, 59, 27,
-  34,  2, 42, 10, 50, 18, 58, 26, 33,  1, 41,  9, 49, 17, 57, 25
-};
-
-/* 
- * The 16 DES keys in BITMASK format 
- */
-#ifdef _UFC_32_
-long32 _ufc_keytab[16][2];
-#endif
-
-#ifdef _UFC_64_
-long64 _ufc_keytab[16];
-#endif
-
-
-#define ascii_to_bin(c) ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.')
-#define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.')
-
-/* Macro to set a bit (0..23) */
-#define BITMASK(i) ( (1<<(11-(i)%12+3)) << ((i)<12?16:0) )
-
-/*
- * sb arrays:
- *
- * Workhorses of the inner loop of the DES implementation.
- * They do sbox lookup, shifting of this  value, 32 bit
- * permutation and E permutation for the next round.
- *
- * Kept in 'BITMASK' format.
- */
-
-#ifdef _UFC_32_
-long32 _ufc_sb0[8192], _ufc_sb1[8192], _ufc_sb2[8192], _ufc_sb3[8192];
-static long32 *sb[4] = {_ufc_sb0, _ufc_sb1, _ufc_sb2, _ufc_sb3}; 
-#endif
-
-#ifdef _UFC_64_
-long64 _ufc_sb0[4096], _ufc_sb1[4096], _ufc_sb2[4096], _ufc_sb3[4096];
-static long64 *sb[4] = {_ufc_sb0, _ufc_sb1, _ufc_sb2, _ufc_sb3}; 
-#endif
-
-/* 
- * eperm32tab: do 32 bit permutation and E selection
- *
- * The first index is the byte number in the 32 bit value to be permuted
- *  -  second  -   is the value of this byte
- *  -  third   -   selects the two 32 bit values
- *
- * The table is used and generated internally in init_des to speed it up
- */
-static ufc_long eperm32tab[4][256][2];
-
-/* 
- * do_pc1: permform pc1 permutation in the key schedule generation.
- *
- * The first   index is the byte number in the 8 byte ASCII key
- *  -  second    -      -    the two 28 bits halfs of the result
- *  -  third     -   selects the 7 bits actually used of each byte
- *
- * The result is kept with 28 bit per 32 bit with the 4 most significant
- * bits zero.
- */
-static ufc_long do_pc1[8][2][128];
-
-/*
- * do_pc2: permform pc2 permutation in the key schedule generation.
- *
- * The first   index is the septet number in the two 28 bit intermediate values
- *  -  second    -    -  -  septet values
- *
- * Knowledge of the structure of the pc2 permutation is used.
- *
- * The result is kept with 28 bit per 32 bit with the 4 most significant
- * bits zero.
- */
-static ufc_long do_pc2[8][128];
-
-/*
- * efp: undo an extra e selection and do final
- *      permutation giving the DES result.
- * 
- *      Invoked 6 bit a time on two 48 bit values
- *      giving two 32 bit longs.
- */
-static ufc_long efp[16][64][2];
-
-static unsigned char bytemask[8]  = {
-  0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
-};
-
-static ufc_long longmask[32] = {
-  0x80000000, 0x40000000, 0x20000000, 0x10000000,
-  0x08000000, 0x04000000, 0x02000000, 0x01000000,
-  0x00800000, 0x00400000, 0x00200000, 0x00100000,
-  0x00080000, 0x00040000, 0x00020000, 0x00010000,
-  0x00008000, 0x00004000, 0x00002000, 0x00001000,
-  0x00000800, 0x00000400, 0x00000200, 0x00000100,
-  0x00000080, 0x00000040, 0x00000020, 0x00000010,
-  0x00000008, 0x00000004, 0x00000002, 0x00000001
-};
-
-
-/*
- * Silly rewrite of 'bzero'. I do so
- * because some machines don't have
- * bzero and some don't have memset.
- */
-
-static void clearmem(char *start, int cnt)
-  { while(cnt--)
-      *start++ = '\0';
-  }
-
-static int initialized = 0;
-
-/* lookup a 6 bit value in sbox */
-
-#define s_lookup(i,s) sbox[(i)][(((s)>>4) & 0x2)|((s) & 0x1)][((s)>>1) & 0xf];
-
-/*
- * Initialize unit - may be invoked directly
- * by fcrypt users.
- */
-
-static void ufc_init_des(void)
-  { int comes_from_bit;
-    int bit, sg;
-    ufc_long j;
-    ufc_long mask1, mask2;
-
-    /*
-     * Create the do_pc1 table used
-     * to affect pc1 permutation
-     * when generating keys
-     */
-    for(bit = 0; bit < 56; bit++) {
-      comes_from_bit  = pc1[bit] - 1;
-      mask1 = bytemask[comes_from_bit % 8 + 1];
-      mask2 = longmask[bit % 28 + 4];
-      for(j = 0; j < 128; j++) {
-       if(j & mask1) 
-         do_pc1[comes_from_bit / 8][bit / 28][j] |= mask2;
-      }
-    }
-
-    /*
-     * Create the do_pc2 table used
-     * to affect pc2 permutation when
-     * generating keys
-     */
-    for(bit = 0; bit < 48; bit++) {
-      comes_from_bit  = pc2[bit] - 1;
-      mask1 = bytemask[comes_from_bit % 7 + 1];
-      mask2 = BITMASK(bit % 24);
-      for(j = 0; j < 128; j++) {
-       if(j & mask1)
-         do_pc2[comes_from_bit / 7][j] |= mask2;
-      }
-    }
-
-    /* 
-     * Now generate the table used to do combined
-     * 32 bit permutation and e expansion
-     *
-     * We use it because we have to permute 16384 32 bit
-     * longs into 48 bit in order to initialize sb.
-     *
-     * Looping 48 rounds per permutation becomes 
-     * just too slow...
-     *
-     */
-
-    clearmem((char*)eperm32tab, sizeof(eperm32tab));
-
-    for(bit = 0; bit < 48; bit++) {
-      ufc_long inner_mask1,comes_from;
-       
-      comes_from = perm32[esel[bit]-1]-1;
-      inner_mask1      = bytemask[comes_from % 8];
-       
-      for(j = 256; j--;) {
-       if(j & inner_mask1)
-         eperm32tab[comes_from / 8][j][bit / 24] |= BITMASK(bit % 24);
-      }
-    }
-    
-    /* 
-     * Create the sb tables:
-     *
-     * For each 12 bit segment of an 48 bit intermediate
-     * result, the sb table precomputes the two 4 bit
-     * values of the sbox lookups done with the two 6
-     * bit halves, shifts them to their proper place,
-     * sends them through perm32 and finally E expands
-     * them so that they are ready for the next
-     * DES round.
-     *
-     */
-    for(sg = 0; sg < 4; sg++) {
-      int j1, j2;
-      int s1, s2;
-    
-      for(j1 = 0; j1 < 64; j1++) {
-       s1 = s_lookup(2 * sg, j1);
-       for(j2 = 0; j2 < 64; j2++) {
-         ufc_long to_permute, inx;
-    
-         s2         = s_lookup(2 * sg + 1, j2);
-         to_permute = ((s1 << 4)  | s2) << (24 - 8 * sg);
-
-#ifdef _UFC_32_
-         inx = ((j1 << 6)  | j2) << 1;
-         sb[sg][inx  ]  = eperm32tab[0][(to_permute >> 24) & 0xff][0];
-         sb[sg][inx+1]  = eperm32tab[0][(to_permute >> 24) & 0xff][1];
-         sb[sg][inx  ] |= eperm32tab[1][(to_permute >> 16) & 0xff][0];
-         sb[sg][inx+1] |= eperm32tab[1][(to_permute >> 16) & 0xff][1];
-         sb[sg][inx  ] |= eperm32tab[2][(to_permute >>  8) & 0xff][0];
-         sb[sg][inx+1] |= eperm32tab[2][(to_permute >>  8) & 0xff][1];
-         sb[sg][inx  ] |= eperm32tab[3][(to_permute)       & 0xff][0];
-         sb[sg][inx+1] |= eperm32tab[3][(to_permute)       & 0xff][1];
-#endif
-#ifdef _UFC_64_
-         inx = ((j1 << 6)  | j2);
-         sb[sg][inx]  = 
-           ((long64)eperm32tab[0][(to_permute >> 24) & 0xff][0] << 32) |
-            (long64)eperm32tab[0][(to_permute >> 24) & 0xff][1];
-         sb[sg][inx] |=
-           ((long64)eperm32tab[1][(to_permute >> 16) & 0xff][0] << 32) |
-            (long64)eperm32tab[1][(to_permute >> 16) & 0xff][1];
-         sb[sg][inx] |= 
-           ((long64)eperm32tab[2][(to_permute >>  8) & 0xff][0] << 32) |
-            (long64)eperm32tab[2][(to_permute >>  8) & 0xff][1];
-         sb[sg][inx] |=
-           ((long64)eperm32tab[3][(to_permute)       & 0xff][0] << 32) |
-            (long64)eperm32tab[3][(to_permute)       & 0xff][1];
-#endif
-       }
-      }
-    }  
-
-    /* 
-     * Create an inverse matrix for esel telling
-     * where to plug out bits if undoing it
-     */
-    for(bit=48; bit--;) {
-      e_inverse[esel[bit] - 1     ] = bit;
-      e_inverse[esel[bit] - 1 + 32] = bit + 48;
-    }
-
-    /* 
-     * create efp: the matrix used to
-     * undo the E expansion and effect final permutation
-     */
-    clearmem((char*)efp, sizeof efp);
-    for(bit = 0; bit < 64; bit++) {
-      int o_bit, o_long;
-      ufc_long word_value, inner_mask1, inner_mask2;
-      int comes_from_f_bit, comes_from_e_bit;
-      int comes_from_word, bit_within_word;
-
-      /* See where bit i belongs in the two 32 bit long's */
-      o_long = bit / 32; /* 0..1  */
-      o_bit  = bit % 32; /* 0..31 */
-
-      /* 
-       * And find a bit in the e permutated value setting this bit.
-       *
-       * Note: the e selection may have selected the same bit several
-       * times. By the initialization of e_inverse, we only look
-       * for one specific instance.
-       */
-      comes_from_f_bit = final_perm[bit] - 1;         /* 0..63 */
-      comes_from_e_bit = e_inverse[comes_from_f_bit]; /* 0..95 */
-      comes_from_word  = comes_from_e_bit / 6;        /* 0..15 */
-      bit_within_word  = comes_from_e_bit % 6;        /* 0..5  */
-
-      inner_mask1 = longmask[bit_within_word + 26];
-      inner_mask2 = longmask[o_bit];
-
-      for(word_value = 64; word_value--;) {
-       if(word_value & inner_mask1)
-         efp[comes_from_word][word_value][o_long] |= inner_mask2;
-      }
-    }
-    initialized++;
-  }
-
-/* 
- * Process the elements of the sb table permuting the
- * bits swapped in the expansion by the current salt.
- */
-
-#ifdef _UFC_32_
-static void shuffle_sb(long32 *k, ufc_long saltbits)
-  { ufc_long j;
-    long32 x;
-    for(j=4096; j--;) {
-      x = (k[0] ^ k[1]) & (long32)saltbits;
-      *k++ ^= x;
-      *k++ ^= x;
-    }
-  }
-#endif
-
-#ifdef _UFC_64_
-static void shuffle_sb(long64 *k, ufc_long saltbits)
-  { ufc_long j;
-    long64 x;
-    for(j=4096; j--;) {
-      x = ((*k >> 32) ^ *k) & (long64)saltbits;
-      *k++ ^= (x << 32) | x;
-    }
-  }
-#endif
-
-/* 
- * Setup the unit for a new salt
- * Hopefully we'll not see a new salt in each crypt call.
- */
-
-static unsigned char current_salt[3] = "&&"; /* invalid value */
-static ufc_long current_saltbits = 0;
-static int direction = 0;
-
-static void setup_salt(const char *s1)
-  { ufc_long i, j, saltbits;
-    const unsigned char *s2 = (const unsigned char *)s1;
-
-    if(!initialized)
-      ufc_init_des();
-
-    if(s2[0] == current_salt[0] && s2[1] == current_salt[1])
-      return;
-    current_salt[0] = s2[0]; current_salt[1] = s2[1];
-
-    /* 
-     * This is the only crypt change to DES:
-     * entries are swapped in the expansion table
-     * according to the bits set in the salt.
-     */
-    saltbits = 0;
-    for(i = 0; i < 2; i++) {
-      long c=ascii_to_bin(s2[i]);
-      if(c < 0 || c > 63)
-       c = 0;
-      for(j = 0; j < 6; j++) {
-       if((c >> j) & 0x1)
-         saltbits |= BITMASK(6 * i + j);
-      }
-    }
-
-    /*
-     * Permute the sb table values
-     * to reflect the changed e
-     * selection table
-     */
-    shuffle_sb(_ufc_sb0, current_saltbits ^ saltbits); 
-    shuffle_sb(_ufc_sb1, current_saltbits ^ saltbits);
-    shuffle_sb(_ufc_sb2, current_saltbits ^ saltbits);
-    shuffle_sb(_ufc_sb3, current_saltbits ^ saltbits);
-
-    current_saltbits = saltbits;
-  }
-
-static void ufc_mk_keytab(char *key)
-  { ufc_long v1, v2, *k1;
-    int i;
-#ifdef _UFC_32_
-    long32 v, *k2 = &_ufc_keytab[0][0];
-#endif
-#ifdef _UFC_64_
-    long64 v, *k2 = &_ufc_keytab[0];
-#endif
-
-    v1 = v2 = 0; k1 = &do_pc1[0][0][0];
-    for(i = 8; i--;) {
-      v1 |= k1[*key   & 0x7f]; k1 += 128;
-      v2 |= k1[*key++ & 0x7f]; k1 += 128;
-    }
-
-    for(i = 0; i < 16; i++) {
-      k1 = &do_pc2[0][0];
-
-      v1 = (v1 << rots[i]) | (v1 >> (28 - rots[i]));
-      v  = k1[(v1 >> 21) & 0x7f]; k1 += 128;
-      v |= k1[(v1 >> 14) & 0x7f]; k1 += 128;
-      v |= k1[(v1 >>  7) & 0x7f]; k1 += 128;
-      v |= k1[(v1      ) & 0x7f]; k1 += 128;
-
-#ifdef _UFC_32_
-      *k2++ = v;
-      v = 0;
-#endif
-#ifdef _UFC_64_
-      v <<= 32;
-#endif
-
-      v2 = (v2 << rots[i]) | (v2 >> (28 - rots[i]));
-      v |= k1[(v2 >> 21) & 0x7f]; k1 += 128;
-      v |= k1[(v2 >> 14) & 0x7f]; k1 += 128;
-      v |= k1[(v2 >>  7) & 0x7f]; k1 += 128;
-      v |= k1[(v2      ) & 0x7f];
-
-      *k2++ = v;
-    }
-
-    direction = 0;
-  }
-
-/* 
- * Undo an extra E selection and do final permutations
- */
-
-ufc_long *_ufc_dofinalperm(ufc_long l1, ufc_long l2, ufc_long r1, ufc_long r2)
-  { ufc_long v1, v2, x;
-    static ufc_long ary[2];
-
-    x = (l1 ^ l2) & current_saltbits; l1 ^= x; l2 ^= x;
-    x = (r1 ^ r2) & current_saltbits; r1 ^= x; r2 ^= x;
-
-    v1=v2=0; l1 >>= 3; l2 >>= 3; r1 >>= 3; r2 >>= 3;
-
-    v1 |= efp[15][ r2         & 0x3f][0]; v2 |= efp[15][ r2 & 0x3f][1];
-    v1 |= efp[14][(r2 >>= 6)  & 0x3f][0]; v2 |= efp[14][ r2 & 0x3f][1];
-    v1 |= efp[13][(r2 >>= 10) & 0x3f][0]; v2 |= efp[13][ r2 & 0x3f][1];
-    v1 |= efp[12][(r2 >>= 6)  & 0x3f][0]; v2 |= efp[12][ r2 & 0x3f][1];
-
-    v1 |= efp[11][ r1         & 0x3f][0]; v2 |= efp[11][ r1 & 0x3f][1];
-    v1 |= efp[10][(r1 >>= 6)  & 0x3f][0]; v2 |= efp[10][ r1 & 0x3f][1];
-    v1 |= efp[ 9][(r1 >>= 10) & 0x3f][0]; v2 |= efp[ 9][ r1 & 0x3f][1];
-    v1 |= efp[ 8][(r1 >>= 6)  & 0x3f][0]; v2 |= efp[ 8][ r1 & 0x3f][1];
-
-    v1 |= efp[ 7][ l2         & 0x3f][0]; v2 |= efp[ 7][ l2 & 0x3f][1];
-    v1 |= efp[ 6][(l2 >>= 6)  & 0x3f][0]; v2 |= efp[ 6][ l2 & 0x3f][1];
-    v1 |= efp[ 5][(l2 >>= 10) & 0x3f][0]; v2 |= efp[ 5][ l2 & 0x3f][1];
-    v1 |= efp[ 4][(l2 >>= 6)  & 0x3f][0]; v2 |= efp[ 4][ l2 & 0x3f][1];
-
-    v1 |= efp[ 3][ l1         & 0x3f][0]; v2 |= efp[ 3][ l1 & 0x3f][1];
-    v1 |= efp[ 2][(l1 >>= 6)  & 0x3f][0]; v2 |= efp[ 2][ l1 & 0x3f][1];
-    v1 |= efp[ 1][(l1 >>= 10) & 0x3f][0]; v2 |= efp[ 1][ l1 & 0x3f][1];
-    v1 |= efp[ 0][(l1 >>= 6)  & 0x3f][0]; v2 |= efp[ 0][ l1 & 0x3f][1];
-
-    ary[0] = v1; ary[1] = v2;
-    return ary;
-  }
-
-/* 
- * crypt only: convert from 64 bit to 11 bit ASCII 
- * prefixing with the salt
- */
-
-static char *output_conversion(ufc_long v1, ufc_long v2, const char *salt)
-  { static char outbuf[14];
-    int i, s;
-
-    outbuf[0] = salt[0];
-    outbuf[1] = salt[1] ? salt[1] : salt[0];
-
-    for(i = 0; i < 5; i++)
-      outbuf[i + 2] = bin_to_ascii((v1 >> (26 - 6 * i)) & 0x3f);
-
-    s  = (v2 & 0xf) << 2;
-    v2 = (v2 >> 2) | ((v1 & 0x3) << 30);
-
-    for(i = 5; i < 10; i++)
-      outbuf[i + 2] = bin_to_ascii((v2 >> (56 - 6 * i)) & 0x3f);
-
-    outbuf[12] = bin_to_ascii(s);
-    outbuf[13] = 0;
-
-    return outbuf;
-  }
-
-/* 
- * UNIX crypt function
- */
-
-static ufc_long *_ufc_doit(ufc_long , ufc_long, ufc_long, ufc_long, ufc_long);
-   
-char *ufc_crypt(const char *key,const char *salt)
-  { ufc_long *s;
-    char ktab[9];
-
-    /*
-     * Hack DES tables according to salt
-     */
-    setup_salt(salt);
-
-    /*
-     * Setup key schedule
-     */
-    clearmem(ktab, sizeof ktab);
-    strncpy(ktab, key, 8);
-    ufc_mk_keytab(ktab);
-
-    /*
-     * Go for the 25 DES encryptions
-     */
-    s = _ufc_doit((ufc_long)0, (ufc_long)0, 
-                 (ufc_long)0, (ufc_long)0, (ufc_long)25);
-
-    /*
-     * And convert back to 6 bit ASCII
-     */
-    return output_conversion(s[0], s[1], salt);
-  }
-
-
-#ifdef _UFC_32_
-
-/*
- * 32 bit version
- */
-
-extern long32 _ufc_keytab[16][2];
-extern long32 _ufc_sb0[], _ufc_sb1[], _ufc_sb2[], _ufc_sb3[];
-
-#define SBA(sb, v) (*(long32*)((char*)(sb)+(v)))
-
-static ufc_long *_ufc_doit(ufc_long l1, ufc_long l2, ufc_long r1, ufc_long r2, ufc_long itr)
-  { int i;
-    long32 s, *k;
-
-    while(itr--) {
-      k = &_ufc_keytab[0][0];
-      for(i=8; i--; ) {
-       s = *k++ ^ r1;
-       l1 ^= SBA(_ufc_sb1, s & 0xffff); l2 ^= SBA(_ufc_sb1, (s & 0xffff)+4);  
-        l1 ^= SBA(_ufc_sb0, s >>= 16);   l2 ^= SBA(_ufc_sb0, (s)         +4); 
-        s = *k++ ^ r2; 
-        l1 ^= SBA(_ufc_sb3, s & 0xffff); l2 ^= SBA(_ufc_sb3, (s & 0xffff)+4);
-        l1 ^= SBA(_ufc_sb2, s >>= 16);   l2 ^= SBA(_ufc_sb2, (s)         +4);
-
-        s = *k++ ^ l1; 
-        r1 ^= SBA(_ufc_sb1, s & 0xffff); r2 ^= SBA(_ufc_sb1, (s & 0xffff)+4);  
-        r1 ^= SBA(_ufc_sb0, s >>= 16);   r2 ^= SBA(_ufc_sb0, (s)         +4); 
-        s = *k++ ^ l2; 
-        r1 ^= SBA(_ufc_sb3, s & 0xffff); r2 ^= SBA(_ufc_sb3, (s & 0xffff)+4);  
-        r1 ^= SBA(_ufc_sb2, s >>= 16);   r2 ^= SBA(_ufc_sb2, (s)         +4);
-      } 
-      s=l1; l1=r1; r1=s; s=l2; l2=r2; r2=s;
-    }
-    return _ufc_dofinalperm(l1, l2, r1, r2);
-  }
-
-#endif
-
-#ifdef _UFC_64_
-
-/*
- * 64 bit version
- */
-
-extern long64 _ufc_keytab[16];
-extern long64 _ufc_sb0[], _ufc_sb1[], _ufc_sb2[], _ufc_sb3[];
-
-#define SBA(sb, v) (*(long64*)((char*)(sb)+(v)))
-
-static ufc_long *_ufc_doit(ufc_long l1, ufc_long l2, ufc_long r1, ufc_long r2, ufc_long itr)
-  { int i;
-    long64 l, r, s, *k;
-
-    l = (((long64)l1) << 32) | ((long64)l2);
-    r = (((long64)r1) << 32) | ((long64)r2);
-
-    while(itr--) {
-      k = &_ufc_keytab[0];
-      for(i=8; i--; ) {
-       s = *k++ ^ r;
-       l ^= SBA(_ufc_sb3, (s >>  0) & 0xffff);
-        l ^= SBA(_ufc_sb2, (s >> 16) & 0xffff);
-        l ^= SBA(_ufc_sb1, (s >> 32) & 0xffff);
-        l ^= SBA(_ufc_sb0, (s >> 48) & 0xffff);
-
-       s = *k++ ^ l;
-       r ^= SBA(_ufc_sb3, (s >>  0) & 0xffff);
-        r ^= SBA(_ufc_sb2, (s >> 16) & 0xffff);
-        r ^= SBA(_ufc_sb1, (s >> 32) & 0xffff);
-        r ^= SBA(_ufc_sb0, (s >> 48) & 0xffff);
-      } 
-      s=l; l=r; r=s;
-    }
-
-    l1 = l >> 32; l2 = l & 0xffffffff;
-    r1 = r >> 32; r2 = r & 0xffffffff;
-    return _ufc_dofinalperm(l1, l2, r1, r2);
-  }
-
-#endif
-
-#define crypt ufc_crypt
-#endif
-
-main()
-{
-       char passwd[9];
-       char salt[9];
-       char c_out1[256];
-       char c_out2[256];
-
-       char expected_out[14];
-
-       strcpy(expected_out, "12yJ.Of/NQ.Pk");
-       strcpy(passwd, "12345678");
-       strcpy(salt, "12345678");
-       
-       strcpy(c_out1, crypt(passwd, salt));
-       salt[2] = '\0';
-       strcpy(c_out2, crypt(passwd, salt));
-
-       /*
-        * If the non-trucated salt fails but the
-        * truncated salt succeeds then exit 1.
-        */
-
-       if((strcmp(c_out1, expected_out) != 0) && 
-               (strcmp(c_out2, expected_out) == 0))
-               exit(1);
-
-#ifdef HAVE_BIGCRYPT
-       /*
-        * Try the same with bigcrypt...
-        */
-
-       {
-               char big_passwd[17];
-               char big_salt[17];
-               char big_c_out1[256];
-               char big_c_out2[256];
-               char big_expected_out[27];
-
-               strcpy(big_passwd, "1234567812345678");
-               strcpy(big_salt, "1234567812345678");
-               strcpy(big_expected_out, "12yJ.Of/NQ.PklfyCuHi/rwM");
-
-               strcpy(big_c_out1, bigcrypt(big_passwd, big_salt));
-               big_salt[2] = '\0';
-               strcpy(big_c_out2, bigcrypt(big_passwd, big_salt));
-
-               /*
-                * If the non-trucated salt fails but the
-                * truncated salt succeeds then exit 1.
-                */
-
-               if((strcmp(big_c_out1, big_expected_out) != 0) && 
-                       (strcmp(big_c_out2, big_expected_out) == 0))
-                       exit(1);
-
-       }
-#endif
-
-       exit(0);
-}
diff --git a/source4/build/tests/fcntl_lock.c b/source4/build/tests/fcntl_lock.c
deleted file mode 100644 (file)
index ffd1ee6..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* test whether fcntl locking works on this system */
-
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#include <errno.h>
-
-#define DATA "conftest.fcntl"
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-/* lock a byte range in a open file */
-int main(int argc, char *argv[])
-{
-       struct flock lock;
-       int fd, ret, status=1;
-       pid_t pid;
-       char *testdir = NULL;
-
-       testdir = getenv("TESTDIR");
-       if (testdir) chdir(testdir);
-
-       alarm(10);
-
-       if (!(pid=fork())) {
-               sleep(2);
-               fd = open(DATA, O_RDONLY);
-
-               if (fd == -1) {
-                       fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", 
-                               DATA, (int)errno);
-                       exit(1);
-               }
-
-               lock.l_type = F_WRLCK;
-               lock.l_whence = SEEK_SET;
-               lock.l_start = 0;
-               lock.l_len = 4;
-               lock.l_pid = getpid();
-               
-               lock.l_type = F_WRLCK;
-               
-               /* check if a lock applies */
-               ret = fcntl(fd,F_GETLK,&lock);
-
-               if ((ret == -1) ||
-                   (lock.l_type == F_UNLCK)) {
-                       fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno);
-                       exit(1);
-               } else {
-                       exit(0);
-               }
-       }
-
-       unlink(DATA);
-       fd = open(DATA, O_RDWR|O_CREAT|O_EXCL, 0600);
-
-       if (fd == -1) {
-               fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", 
-                       DATA, (int)errno);
-               exit(1);
-       }
-
-       lock.l_type = F_WRLCK;
-       lock.l_whence = SEEK_SET;
-       lock.l_start = 0;
-       lock.l_len = 4;
-       lock.l_pid = getpid();
-
-       /* set a 4 byte write lock */
-       fcntl(fd,F_SETLK,&lock);
-
-       waitpid(pid, &status, 0);
-
-       unlink(DATA);
-
-#if defined(WIFEXITED) && defined(WEXITSTATUS)
-    if(WIFEXITED(status)) {
-        status = WEXITSTATUS(status);
-    } else {
-        status = 1;
-    }
-#else /* defined(WIFEXITED) && defined(WEXITSTATUS) */
-       status = (status == 0) ? 0 : 1;
-#endif /* defined(WIFEXITED) && defined(WEXITSTATUS) */
-
-       if (status) {
-               fprintf(stderr,"ERROR: lock test failed with status=%d\n", 
-                       status);
-       }
-
-       exit(status);
-}
diff --git a/source4/build/tests/fcntl_lock64.c b/source4/build/tests/fcntl_lock64.c
deleted file mode 100644 (file)
index 913580c..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* test whether 64 bit fcntl locking really works on this system */
-
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-
-#include <errno.h>
-
-#define DATA "conftest.fcntl64"
-
-/* lock a byte range in a open file */
-int main(int argc, char *argv[])
-{
-       struct flock64 lock;
-       int fd, ret, status=1;
-       pid_t pid;
-
-       if (!(pid=fork())) {
-               sleep(2);
-               fd = open64(DATA, O_RDONLY);
-
-               if (fd == -1) exit(1);
-
-               lock.l_type = F_WRLCK;
-               lock.l_whence = SEEK_SET;
-               lock.l_start = 0;
-               lock.l_len = 4;
-               lock.l_pid = getpid();
-               
-               lock.l_type = F_WRLCK;
-               
-               /* check if a lock applies */
-               ret = fcntl(fd,F_GETLK64,&lock);
-
-               if ((ret == -1) ||
-                   (lock.l_type == F_UNLCK)) {
-/*            printf("No lock conflict\n"); */
-                       exit(1);
-               } else {
-/*            printf("lock conflict\n"); */
-                       exit(0);
-               }
-       }
-
-       fd = open64(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
-
-       lock.l_type = F_WRLCK;
-       lock.l_whence = SEEK_SET;
-#if defined(COMPILER_SUPPORTS_LL)
-       lock.l_start = 0x100000000LL;
-#else
-       lock.l_start = 0x100000000;
-#endif
-       lock.l_len = 4;
-       lock.l_pid = getpid();
-
-       /* set a 4 byte write lock */
-       fcntl(fd,F_SETLK64,&lock);
-
-       sys_waitpid(pid, &status, 0);
-
-#if defined(WIFEXITED) && defined(WEXITSTATUS)
-       if(WIFEXITED(status)) {
-               status = WEXITSTATUS(status);
-       } else {
-               status = 1;
-       }
-#else /* defined(WIFEXITED) && defined(WEXITSTATUS) */
-       status = (status == 0) ? 0 : 1;
-#endif /* defined(WIFEXITED) && defined(WEXITSTATUS) */
-
-       unlink(DATA);
-
-       exit(status);
-}
diff --git a/source4/build/tests/shlib.c b/source4/build/tests/shlib.c
deleted file mode 100644 (file)
index 761d9fd..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-/* a trivial function used to test building shared libraries */
-
-int foo(void)
-{
-       return 1;
-}
diff --git a/source4/build/tests/summary.c b/source4/build/tests/summary.c
deleted file mode 100644 (file)
index 95fa1cb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <stdio.h>
-
-void exit(int);
-
-main()
-{
-#if !(defined(HAVE_IFACE_GETIFADDRS) || defined(HAVE_IFACE_IFCONF) || defined(HAVE_IFACE_IFREQ) || defined(HAVE_IFACE_AIX))
-       printf("WARNING: No automated network interface determination\n");
-#endif
-
-#if !(defined(STAT_STATVFS) || defined(STAT_STATVFS64) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA))
-       printf("ERROR: No disk free routine!\n");
-       exit(1);
-#endif
-
-#if !((defined(HAVE_RANDOM) || defined(HAVE_RAND)) && (defined(HAVE_SRANDOM) || defined(HAVE_SRAND)))
-    printf("ERROR: No random or srandom routine!\n");
-    exit(1);
-#endif
-
-       exit(0);
-}
index 6c8fb0efc28c991fcf77afa75b2757244df2f6a5..ef3bfd73f6df544724f9075dad6ddcacd6cff737 100644 (file)
@@ -122,7 +122,7 @@ CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
 # final configure stuff
 
 AC_MSG_CHECKING([configure summary])
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/summary.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
            AC_MSG_RESULT(yes),
           AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
           AC_MSG_WARN([cannot run when cross-compiling]))
index 2b23ecf05f7d81b4c9e99006ec1dd9627f4e2493..24ee01c37fb244d8d360fb0ea3258121d4fab3ee 100644 (file)
@@ -49,6 +49,24 @@ class SecurityDescriptorTests(unittest.TestCase):
     def setUp(self):
         self.descriptor = security.descriptor()
 
+    def test_from_sddl(self):
+        desc = security.descriptor.from_sddl("O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)", security.dom_sid("S-2-0-0"))
+        self.assertEquals(desc.group_sid, security.dom_sid('S-2-0-0-512'))
+        self.assertEquals(desc.owner_sid, security.dom_sid('S-1-5-32-548'))
+        self.assertEquals(desc.revision, 1)
+        self.assertEquals(desc.sacl, None)
+        self.assertEquals(desc.type, 0x8004)
+
+    def test_as_sddl(self):
+        text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
+        dom = security.dom_sid("S-2-0-0")
+        desc1 = security.descriptor.from_sddl(text, dom)
+        desc2 = security.descriptor.from_sddl(desc1.as_sddl(dom), dom)
+        self.assertEquals(desc1.group_sid, desc2.group_sid)
+        self.assertEquals(desc1.owner_sid, desc2.owner_sid)
+        self.assertEquals(desc1.sacl, desc2.sacl)
+        self.assertEquals(desc1.type, desc2.type)
+
 
 class DomSidTests(unittest.TestCase):
     def test_parse_sid(self):
index 08542640b99dbd861962f224943d3a862a180007..93e4a093f3d02ceb8b67720b764123bb69b132e2 100644 (file)
@@ -31,7 +31,11 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
                type->tp_dict = PyDict_New();
        dict = type->tp_dict;
        for (i = 0; methods[i].ml_name; i++) {
-               PyObject *descr = PyDescr_NewMethod(type, &methods[i]);
+               PyObject *descr;
+               if (methods[i].ml_flags & METH_CLASS) 
+                       descr = PyCFunction_New(&methods[i], (PyObject *)type);
+               else 
+                       descr = PyDescr_NewMethod(type, &methods[i]);
                PyDict_SetItemString(dict, methods[i].ml_name, 
                                     descr);
        }
@@ -160,7 +164,44 @@ static PyObject *py_descriptor_sacl_del(PyObject *self, PyObject *args)
 static PyObject *py_descriptor_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)
 {
        return py_talloc_import(self, security_descriptor_initialise(NULL));
-}      
+}
+
+static PyObject *py_descriptor_from_sddl(PyObject *self, PyObject *args)
+{
+       struct security_descriptor *secdesc;
+       char *sddl;
+       PyObject *py_sid;
+       struct dom_sid *sid;
+
+       if (!PyArg_ParseTuple(args, "sO", &sddl, &py_sid))
+               return NULL;
+
+       sid = py_talloc_get_ptr(py_sid);
+
+       secdesc = sddl_decode(NULL, sddl, sid);
+       if (secdesc == NULL) {
+               PyErr_SetString(PyExc_TypeError, "Unable to parse SDDL");
+               return NULL;
+       }
+
+       return py_talloc_import((PyTypeObject *)self, secdesc);
+}
+
+static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *py_sid)
+{
+       struct dom_sid *sid = py_talloc_get_ptr(py_sid);
+       struct security_descriptor *desc = py_talloc_get_ptr(self);
+       char *text;
+       PyObject *ret;
+
+       text = sddl_encode(NULL, desc, sid);
+
+       ret = PyString_FromString(text);
+
+       talloc_free(text);
+
+       return ret;
+}
 
 static PyMethodDef py_descriptor_extra_methods[] = {
        { "sacl_add", (PyCFunction)py_descriptor_sacl_add, METH_VARARGS,
@@ -172,6 +213,10 @@ static PyMethodDef py_descriptor_extra_methods[] = {
                NULL },
        { "sacl_del", (PyCFunction)py_descriptor_sacl_del, METH_VARARGS,
                NULL },
+       { "from_sddl", (PyCFunction)py_descriptor_from_sddl, METH_VARARGS|METH_CLASS, 
+               NULL },
+       { "as_sddl", (PyCFunction)py_descriptor_as_sddl, METH_O,
+               NULL },
        { NULL }
 };
 
diff --git a/source4/scripting/python/samba/samr.py b/source4/scripting/python/samba/samr.py
deleted file mode 100644 (file)
index 62a7c6e..0000000
+++ /dev/null
@@ -1,759 +0,0 @@
-import dcerpc
-
-def sid_to_string(sid):
-    """Convert a Python dictionary SID to a string SID."""
-
-    result = 'S-%d' % sid.sid_rev_num
-
-    result = result + '-%u' % \
-             (dcerpc.uint8_array_getitem(sid.id_auth, 5) +
-              (dcerpc.uint8_array_getitem(sid.id_auth, 4) << 8) + 
-              (dcerpc.uint8_array_getitem(sid.id_auth, 3) << 16) +
-              (dcerpc.uint8_array_getitem(sid.id_auth, 2) << 24))
-    
-    for i in range(0, sid.num_auths):
-        result = result + '-%u' % \
-                 dcerpc.uint32_array_getitem(sid.sub_auths, i)
-
-    return result
-
-def string_to_sid(string):
-    """Convert a string SID to a Python dictionary SID.  Throws a
-    ValueError if the SID string was badly formed."""
-
-    if string[0] != 'S':
-        raise ValueError('Bad SID format')
-
-    string = string[1:]
-
-    import re
-
-    match = re.match('-\d+', string)
-
-    if not match:
-        raise ValueError('Bad SID format')
-
-    try:
-        sid_rev_num = int(string[match.start()+1:match.end()])
-    except ValueError:
-        raise ValueError('Bad SID format')
-
-    string = string[match.end():]
-
-    match = re.match('-\d+', string)
-
-    if not match:
-        raise ValueError('Bad SID format')
-
-    try:
-        ia = int(string[match.start()+1:match.end()])
-    except ValueError:
-        raise ValueError('Bad SID format')
-
-    string = string[match.end():]
-
-    id_auth = [0, 0, (ia >> 24) & 0xff, (ia >> 16) & 0xff,
-               (ia >> 8) & 0xff, ia & 0xff]
-
-    num_auths = 0
-    sub_auths = []
-    
-    while len(string):
-
-        match = re.match('-\d+', string)
-
-        if not match:
-            raise ValueError('Bad SID format')
-
-        try:
-            sa = int(string[match.start() + 1 : match.end()])
-        except ValueError:
-            raise ValueError('Bad SID format')
-
-        num_auths = num_auths + 1
-        sub_auths.append(int(sa))
-
-        string = string[match.end():]
-
-    sid = dcerpc.dom_sid()
-    sid.sid_rev_num = sid_rev_num
-    sid.id_auth = dcerpc.new_uint8_array(6)
-    for i in range(6):
-        dcerpc.uint8_array_setitem(sid.id_auth, i, id_auth[i])
-    sid.num_auths = num_auths
-    sid.sub_auths = dcerpc.new_uint32_array(num_auths)
-    for i in range(num_auths):
-        dcerpc.uint32_array_setitem(sid.sub_auths, i, sub_auths[i])
-
-    return sid
-
-def call_fn(fn, pipe, args):
-    """Wrap up a RPC call and throw an exception is an error was returned."""
-    
-    result = fn(pipe, args);
-
-    if result & 0xc0000000L:
-        raise dcerpc.NTSTATUS(result, dcerpc.nt_errstr(result));
-
-    return result;
-   
-
-class SamrHandle(object):
-
-    def __init__(self, pipe, handle):
-
-        self.pipe = pipe
-        self.handle = handle
-
-    def __del__(self):
-
-        if self.handle is not None:
-            self.Close()
-
-    def Close(self):
-                    
-        r = dcerpc.samr_Close()
-        r.data_in.handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_Close, self.pipe, r)
-
-        self.handle = None
-
-    def QuerySecurity(self, sec_info = 7):
-
-        r = dcerpc.samr_QuerySecurity()
-        r.data_in.handle = self.handle
-        r.data_in.sec_info = sec_info
-
-        call_fn(dcerpc.dcerpc_samr_QuerySecurity, self.pipe, r)
-
-        return r.data_out.sdbuf
-
-    def SetSecurity(self, sdbuf, sec_info = 7):
-
-        r = dcerpc.samr_SetSecurity()
-        r.data_in.handle = self.handle
-        r.data_in.sec_info = sec_info
-        r.data_in.sdbuf = sdbuf
-
-        call_fn(dcerpc.dcerpc_samr_SetSecurity, self.pipe, r)
-        
-
-class ConnectHandle(SamrHandle):
-
-    def EnumDomains(self):
-
-        r = dcerpc.samr_EnumDomains()
-        r.data_in.connect_handle = self.handle
-        r.data_in.resume_handle = 0
-        r.data_in.buf_size = -1
-
-        domains = []
-
-        while 1:
-
-            call_fn(dcerpc.dcerpc_samr_EnumDomains, self.pipe, r)
-
-            for i in range(r.data_out.sam.count):
-                domains.append(dcerpc.samr_SamEntry_array_getitem(
-                    r.data_out.sam.entries, i).name.string)
-
-            # TODO: Handle more entries here
-
-            break
-
-        return domains
-
-    def LookupDomain(self, domain_name):
-
-        r = dcerpc.samr_LookupDomain()
-        r.data_in.connect_handle = self.handle
-        r.data_in.domain_name = dcerpc.samr_String()
-        r.data_in.domain_name.string = domain_name
-
-        call_fn(dcerpc.dcerpc_samr_LookupDomain, self.pipe, r)
-
-        return sid_to_string(r.data_out.sid);
-
-    def OpenDomain(self, domain_sid, access_mask = 0x02000000):
-
-        r = dcerpc.samr_OpenDomain()
-        r.data_in.connect_handle = self.handle
-        r.data_in.access_mask = access_mask
-        r.data_in.sid = string_to_sid(domain_sid)
-
-        call_fn(dcerpc.dcerpc_samr_OpenDomain, self.pipe, r)
-
-        return DomainHandle(self.pipe, r.data_out.domain_handle)
-
-    def Shutdown(self):
-
-        r = dcerpc.samr_Shutdown()
-        r.data_in.connect_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_Shutdown, self.pipe, r)
-
-    def GetDomPwInfo(self, domain_name):
-
-        r = dcerpc.samr_GetDomPwInfo()
-        r.data_in.domain_name = dcerpc.samr_String()
-        r.data_in.domain_name.string = domain_name
-
-        call_fn(dcerpc.dcerpc_samr_GetDomPwInfo, self.pipe, r)
-
-        return r.data_out.info
-
-
-    def SetBootKeyInformation(self, unknown1, unknown2, unknown3):
-        
-        r = dcerpc.samr_GetBootKeyInformation()
-        r.data_in.connect_handle = self.handle
-        r.data_in.unknown1 = unknown1
-        r.data_in.unknown2 = unknown2
-        r.data_in.unknown3 = unknown3
-
-        call_fn(dcerpc.dcerpc_samr_SetBootKeyInformation, self.pipe, r)
-
-
-class DomainHandle(SamrHandle):
-
-    def QueryDomainInfo(self, level = 2):
-
-        r = dcerpc.samr_QueryDomainInfo()
-        r.data_in.domain_handle = self.handle
-        r.data_in.level = level
-
-        call_fn(dcerpc.dcerpc_samr_QueryDomainInfo, self.pipe, r)
-
-        return getattr(r.data_out.info, 'info%d' % level)
-
-    def QueryDomainInfo2(self, level = 2):
-
-        r = dcerpc.samr_QueryDomainInfo2()
-        r.data_in.domain_handle = self.handle
-        r.data_in.level = level
-
-        call_fn(dcerpc.dcerpc_samr_QueryDomainInfo2, self.pipe, r)
-
-        return getattr(r.data_out.info, 'info%d' % level)       
-
-    def SetDomainInfo(self, level, info):
-
-        r = dcerpc.samr_SetDomainInfo()
-        r.data_in.domain_handle = self.handle
-        r.data_in.level = level
-        r.data_in.info = dcerpc.samr_DomainInfo()
-        setattr(r.data_in.info, 'info%d' % level, info)
-
-        call_fn(dcerpc.dcerpc_samr_SetDomainInfo, self.pipe, r)
-
-    def EnumDomainGroups(self):
-
-        r = dcerpc.samr_EnumDomainGroups()
-        r.data_in.domain_handle = self.handle
-        r.data_in.resume_handle = 0
-        r.data_in.max_size = 1000
-
-        call_fn(dcerpc.dcerpc_samr_EnumDomainGroups, self.pipe, r)
-
-        groups = []
-
-        if r.data_out.sam.entries:
-            for i in range(r.data_out.sam.count):
-                groups.append(dcerpc.samr_SamEntry_array_getitem(
-                    r.data_out.sam.entries, i).name.string)
-
-        return groups
-
-    def EnumDomainAliases(self):
-
-        r = dcerpc.samr_EnumDomainAliases()
-        r.data_in.domain_handle = self.handle
-        r.data_in.resume_handle = 0
-        # acct_flags in SamrEnumerateAliasesInDomain has probably
-        # no meaning so use 0xffffffff like W2K
-        r.data_in.acct_flags = 0xffffffffL
-
-        call_fn(dcerpc.dcerpc_samr_EnumDomainAliases, self.pipe, r)
-
-        aliases = []
-
-        if r.data_out.sam.entries:
-            for i in range(r.data_out.sam.count):
-                aliases.append(dcerpc.samr_SamEntry_array_getitem(
-                    r.data_out.sam.entries, i).name.string)
-
-        return aliases
-
-    def EnumDomainUsers(self, user_account_flags = 16):
-
-        r = dcerpc.samr_EnumDomainUsers()
-        r.data_in.domain_handle = self.handle
-        r.data_in.resume_handle = 0
-        r.data_in.acct_flags = user_account_flags
-        r.data_in.max_size = 1000
-
-        call_fn(dcerpc.dcerpc_samr_EnumDomainUsers, self.pipe, r)
-
-        users = []
-
-        if r.data_out.sam.entries:
-            for i in range(r.data_out.sam.count):
-                users.append(dcerpc.samr_SamEntry_array_getitem(
-                    r.data_out.sam.entries, i).name.string)
-
-        return users
-
-    def CreateUser(self, account_name, access_mask = 0x02000000):
-
-        r = dcerpc.samr_CreateUser()
-        r.data_in.domain_handle = self.handle
-        r.data_in.account_name = dcerpc.samr_String()
-        r.data_in.account_name.string = account_name
-        r.data_in.access_mask = access_mask
-
-        call_fn(dcerpc.dcerpc_samr_CreateUser, self.pipe, r)
-
-        return (r.data_out.user_handle,
-                dcerpc.uint32_array_getitem(r.data_out.rid, 0))
-
-    def CreateUser2(self, account_name, acct_flags = 0x00000010,
-                    access_mask = 0x02000000):
-
-        r = dcerpc.samr_CreateUser2()
-        r.data_in.domain_handle = self.handle
-        r.data_in.account_name = dcerpc.samr_String()
-        r.data_in.account_name.string = account_name
-        r.data_in.acct_flags = acct_flags
-        r.data_in.access_mask = access_mask
-
-        call_fn(dcerpc.dcerpc_samr_CreateUser2, self.pipe, r)
-
-        return (r.data_out.user_handle,
-                dcerpc.uint32_array_getitem(r.data_out.access_granted, 0),
-                dcerpc.uint32_array_getitem(r.data_out.rid, 0))
-
-    def OpenUser(self, rid, access_mask = 0x02000000):
-
-        r = dcerpc.samr_OpenUser()
-        r.data_in.domain_handle = self.handle
-        r.data_in.access_mask = access_mask
-        r.data_in.rid = rid
-
-        call_fn(dcerpc.dcerpc_samr_OpenUser, self.pipe, r)
-
-        return UserHandle(self.pipe, r.data_out.user_handle)
-
-    def OpenGroup(self, rid, access_mask = 0x02000000):
-
-        r = dcerpc.samr_OpenGroup()
-        r.data_in.domain_handle = self.handle
-        r.data_in.access_mask = access_mask
-        r.data_in.rid = rid
-
-        call_fn(dcerpc.dcerpc_samr_OpenGroup, self.pipe, r)
-
-        return GroupHandle(self.pipe, r.data_out.group_handle)
-
-    def OpenAlias(self, rid, access_mask = 0x02000000):
-
-        r = dcerpc.samr_OpenAlias()
-        r.data_in.domain_handle = self.handle
-        r.data_in.access_mask = access_mask
-        r.data_in.rid = rid
-
-        call_fn(dcerpc.dcerpc_samr_OpenAlias, self.pipe, r)
-
-        return AliasHandle(self.pipe, r.data_out.alias_handle)
-
-    def CreateDomAlias(self, alias_name, access_mask = 0x02000000):
-
-        r = dcerpc.samr_CreateDomAlias()
-        r.data_in.domain_handle = self.handle
-        r.data_in.alias_name = dcerpc.samr_String()
-        r.data_in.alias_name.string = alias_name
-        r.data_in.access_mask = access_mask
-
-        call_fn(dcerpc.dcerpc_samr_CreateDomAlias, self.pipe, r)
-
-        return (AliasHandle(self.pipe, r.data_out.alias_handle),
-                r.data_out.rid)    
-
-    def RidToSid(self, rid):
-
-        r = dcerpc.samr_RidToSid()
-        r.data_in.domain_handle = self.handle
-        r.data_in.rid = rid
-
-        call_fn(dcerpc.dcerpc_samr_RidToSid, self.pipe, r)
-
-        return sid_to_string(r.data_out.sid)
-
-    def RemoveMemberFromForeignDomain(self, sid):
-
-        r = dcerpc.samr_RemoveMemberFromForeignDomain()
-        r.data_in.domain_handle = self.handle
-        r.data_in.sid = sid
-
-        call_fn(dcerpc.dcerpc_samr_RemoveMemberFromForeignDomain, self.pipe, r)
-
-    def LookupNames(self, names):
-
-        r = dcerpc.samr_LookupNames()
-        r.data_in.domain_handle = self.handle
-        r.data_in.num_names = len(names)
-        r.data_in.names = dcerpc.new_samr_String_array(len(names))
-
-        for i in range(len(names)):
-            s = dcerpc.samr_String()
-            s.string = names[i]
-            dcerpc.samr_String_array_setitem(r.data_in.names, i, s)
-
-        call_fn(dcerpc.dcerpc_samr_LookupNames, self.pipe, r)
-
-        return ([dcerpc.uint32_array_getitem(r.data_out.rids.ids, i)
-                 for i in range(r.data_out.rids.count)],
-                [dcerpc.uint32_array_getitem(r.data_out.types.ids, i)
-                 for i in range(r.data_out.types.count)])
-
-    def CreateDomainGroup(self, domain_name, access_mask = 0x02000000):
-
-        r = dcerpc.samr_CreateDomainGroup()
-        r.data_in.domain_handle = self.handle
-        r.data_in.name = dcerpc.samr_String()
-        r.data_in.name.string = domain_name
-        r.data_in.access_mask = access_mask
-
-        call_fn(dcerpc.dcerpc_samr_CreateDomainGroup, self.pipe, r)
-
-    def GetAliasMembership(self, sids):
-
-        r = dcerpc.samr_GetAliasMembership()
-        r.data_in.domain_handle = self.handle
-        r.data_in.sids = dcerpc.lsa_SidArray()
-        r.data_in.sids.num_sids = len(sids)
-        r.data_in.sids.sids = dcerpc.new_lsa_SidPtr_array(len(sids))
-
-        for i in range(len(sids)):
-            s = dcerpc.lsa_SidPtr()
-            s.sid = string_to_sid(sids[i])
-            dcerpc.lsa_SidPtr_array_setitem(r.data_in.sids.sids, i, s)
-
-        call_fn(dcerpc.dcerpc_samr_GetAliasMembership, self.pipe, r)
-
-        return [r.ids[x] for x in range(r.count)]
-
-    def QueryDisplayInfo(self, level):
-
-        # TODO: Handle more data returns
-
-        r = dcerpc.samr_QueryDisplayInfo()
-        r.data_in.domain_handle = self.handle
-        r.data_in.level = level
-        r.data_in.start_idx = 0
-        r.data_in.max_entries = 1000
-        r.data_in.buf_size = -1
-
-        call_fn(dcerpc.dcerpc_samr_QueryDisplayInfo, self.pipe, r)
-
-        # TODO: Return a mapping of the various samr_DispInfo
-        # structures here.
-
-        return getattr(r.data_out.info, 'info%d' % level)
-    
-    def QueryDisplayInfo2(self, level):
-
-        # TODO: Handle more data returns
-
-        r = dcerpc.samr_QueryDisplayInfo2()
-        r.data_in.domain_handle = self.handle
-        r.data_in.level = level
-        r.data_in.start_idx = 0
-        r.data_in.max_entries = 1000
-        r.data_in.buf_size = -1
-
-        call_fn(dcerpc.dcerpc_samr_QueryDisplayInfo2, self.pipe, r)
-
-        # TODO: Return a mapping of the various samr_DispInfo
-        # structures here.
-
-        return getattr(r.data_out.info, 'info%d' % level)
-
-    def QueryDisplayInfo3(self, level):
-
-        # TODO: Handle more data returns
-
-        r = dcerpc.samr_QueryDisplayInfo3()
-        r.data_in.domain_handle = self.handle
-        r.data_in.level = level
-        r.data_in.start_idx = 0
-        r.data_in.max_entries = 1000
-        r.data_in.buf_size = -1
-
-        call_fn(dcerpc.dcerpc_samr_QueryDisplayInfo3, self.pipe, r)
-
-        # TODO: Return a mapping of the various samr_DispInfo
-        # structures here.
-
-        return getattr(r.data_out.info, 'info%d' % level)
-
-    def GetBootKeyInformation(self):
-
-        r = dcerpc.samr_GetBootKeyInformation()
-        r.data_in.domain_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_GetBootKeyInformation, self.pipe, r)
-
-        return r.data_out.unknown
-
-    def SetBootKeyInformation(self):
-
-        r = dcerpc.samr_GetBootKeyInformation()
-        r.data_in.domain_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_GetBootKeyInformation, self.pipe, r)
-
-    def TestPrivateFunctionsDomain(self):
-
-        r = dcerpc.samr_TestPrivateFunctionsDomain()
-        r.data_in.domain_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsDomain, self.pipe, r)
-
-
-class UserHandle(SamrHandle):
-
-    def DeleteUser(self):
-
-        r = dcerpc.samr_DeleteUser()
-        r.data_in.user_handle = self.handle
-        
-        call_fn(dcerpc.dcerpc_samr_DeleteUser, self.pipe, r)
-
-        self.handle = None
-
-    def GetUserPwInfo(self):
-
-        r = dcerpc.samr_GetUserPwInfo()
-        r.data_in.user_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_GetUserPwInfo, self.pipe, r)
-
-        return r.data_out.info
-
-    def QueryUserInfo(self, level):
-
-        r = dcerpc.samr_QueryUserInfo()
-        r.data_in.user_handle = self.handle
-        r.data_in.level = level
-
-        call_fn(dcerpc.dcerpc_samr_QueryUserInfo, self.pipe, r)
-
-        return r.data_out.info
-
-    def QueryUserInfo2(self, level):
-
-        r = dcerpc.samr_QueryUserInfo2()
-        r.data_in.user_handle = self.handle
-        r.data_in.level = level
-
-        call_fn(dcerpc.dcerpc_samr_QueryUserInfo2, self.pipe, r)
-
-        return r.data_out.info
-
-    def GetGroupsForUser(self):
-
-        r = dcerpc.samr_GetGroupsForUser()
-        r.data_in.user_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_GetGroupsForUser, self.pipe, r)
-
-        rid_types = [dcerpc.samr_RidType_array_getitem(r.data_out.rids.rid, x)
-                     for x in range(r.data_out.rids.count)]
-
-        return [(x.rid, x.type) for x in rid_types]
-
-    def TestPrivateFunctionsUser(self):
-
-        r = dcerpc.samr_TestPrivateFunctionsUser()
-        r.data_in.user_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_TestPrivateFunctionsUser, self.pipe, r)
-            
-
-class GroupHandle(SamrHandle):
-
-    def QueryGroupInfo(self, level):
-
-        r = dcerpc.samr_QueryGroupInfo()
-        r.data_in.group_handle = self.handle
-        r.data_in.level = level
-
-        call_fn(dcerpc.dcerpc_samr_QueryGroupInfo, self.pipe, r)
-
-        return r.data_out.info
-
-    def SetGroupInfo(self, level, info):
-
-        r = dcerpc.samr_SetGroupInfo()
-        r.data_in.group_handle = self.handle
-        r.data_in.level = level
-        r.data_in.info = info
-
-        call_fn(dcerpc.dcerpc_samr_SetGroupInfo, self.pipe, r)
-
-    def QueryGroupMember(self):
-
-        r = dcerpc.samr_QueryGroupMember()
-        r.data_in.group_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_QueryGroupMember, self.pipe, r)
-
-        return [(dcerpc.uint32_array_getitem(r.data_out.rids.rids, x),
-                 dcerpc.uint32_array_getitem(r.data_out.rids.unknown, x))
-                for x in range(r.data_out.rids.count)]
-    
-
-class AliasHandle(SamrHandle):
-
-    def DeleteDomAlias(self):
-
-        r = dcerpc.samr_DeleteDomAlias()
-        r.data_in.alias_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_DeleteDomAlias, self.pipe, r)
-
-        self.handle = None
-
-    def QueryAliasInfo(self, level = 1):
-
-        r = dcerpc.samr_QueryAliasInfo()
-        r.data_in.alias_handle = self.handle
-        r.data_in.level = level
-
-        call_fn(dcerpc.dcerpc_samr_QueryAliasInfo, self.pipe, r)
-
-        return r.data_out.info
-
-    def SetAliasInfo(self, level, info):
-
-        r = dcerpc.samr_SetAliasInfo()
-        r.data_in.alias_handle = self.handle
-        r.data_in.level = level
-        r.data_in.info = info
-
-        call_fn(dcerpc.dcerpc_samr_SetAliasInfo, self.pipe, r)
-
-    def AddAliasMember(self, sid):
-
-        r = dcerpc.samr_AddAliasMember()
-        r.data_in.alias_handle = self.handle
-        r.data_in.sid = string_to_sid(sid)
-
-        call_fn(dcerpc.dcerpc_samr_AddAliasMember, self.pipe, r)
-
-    def AddMultipleMembersToAlias(self, sids):
-
-        r = dcerpc.samr_AddMultipleMembersToAlias()
-        r.data_in.alias_handle = self.handle
-        r.data_in.sids = dcerpc.lsa_SidArray()
-        r.data_in.sids.num_sids = len(sids)
-        r.data_in.sids.sids = dcerpc.new_lsa_SidPtr_array(len(sids))
-
-        for i in range(len(sids)):
-            s = dcerpc.lsa_SidPtr()
-            s.sid = string_to_sid(sids[i])
-            dcerpc.lsa_SidPtr_array_setitem(r.data_in.sids.sids, i, s)
-
-        call_fn(dcerpc.dcerpc_samr_AddMultipleMembersToAlias, self.pipe, r)
-
-    def GetMembersInAlias(self):
-
-        r = dcerpc.samr_GetMembersInAlias()
-        r.data_in.alias_handle = self.handle
-
-        call_fn(dcerpc.dcerpc_samr_GetMembersInAlias, self.pipe, r)
-
-        return [
-            sid_to_string(
-                dcerpc.lsa_SidPtr_array_getitem(r.data_out.sids.sids, x).sid)
-            for x in range(r.data_out.sids.num_sids)]
-
-def Connect(pipe, access_mask = 0x02000000):
-
-    r = dcerpc.samr_Connect()
-    r.data_in.system_name = dcerpc.new_uint16_array(1)
-    dcerpc.uint16_array_setitem(r.data_in.system_name, 0, ord('\\'))
-    r.data_in.access_mask = access_mask
-
-    call_fn(dcerpc.dcerpc_samr_Connect, pipe, r)
-
-    return ConnectHandle(pipe, r.data_out.connect_handle)
-
-def Connect2(pipe, system_name = '', access_mask = 0x02000000):
-    """Connect to the SAMR pipe."""
-
-    r = dcerpc.samr_Connect2()
-    r.data_in.system_name = system_name
-    r.data_in.access_mask = access_mask
-
-    call_fn(dcerpc.dcerpc_samr_Connect2, pipe, r)
-
-    return ConnectHandle(pipe, r.data_out.connect_handle)
-
-def Connect3(pipe, system_name = '', access_mask = 0x02000000):
-
-    r = dcerpc.samr_Connect3()
-    r.data_in.system_name = system_name
-    r.data_in.unknown = 0
-    r.data_in.access_mask = access_mask
-
-    call_fn(dcerpc.dcerpc_samr_Connect3, pipe, r)
-
-    return ConnectHandle(pipe, r.data_out.connect_handle)
-
-
-def Connect4(pipe, system_name = '', access_mask = 0x02000000):
-
-    r = dcerpc.samr_Connect4()
-    r.data_in.system_name = system_name
-    r.data_in.unknown = 0
-    r.data_in.access_mask = access_mask
-
-    call_fn(dcerpc.dcerpc_samr_Connect4, pipe, r)
-
-    return ConnectHandle(pipe, r.data_out.connect_handle)
-
-def Connect5(pipe, system_name = '', access_mask = 0x02000000):
-
-    r = dcerpc.samr_Connect5()
-    r.data_in.system_name = system_name
-    r.data_in.access_mask = access_mask
-    r.data_in.level = 1
-    r.data_in.info = dcerpc.new_samr_ConnectInfo_array(1)
-    r.data_in.info.unknown1 = 0
-    r.data_in.info.unknown2 = 0
-
-    call_fn(dcerpc.dcerpc_samr_Connect5, pipe, r)
-
-    return ConnectHandle(pipe, r.data_out.connect_handle)
-    
-# AddGroupMember
-# DeleteDomainGroup
-# DeleteGroupMember
-# SetMemberAttributesofGroup
-# AddAliasMember
-# DeleteAliasMember
-# GetMembersinAlias
-# SetUserInfo
-# ChangePasswordUser
-# GetDisplayEnumerationIndex
-# RemoveMemberFromForeignDomain
-# GetDisplayEnumerationIndex2
-# RemoveMultipleMembersFromAlias
-# OemChangePasswordUser2
-# ChangePasswordUser2
-# SetUserInfo2
-# ChangePasswordUser3
-# SetDsrmPassword
-# ValidatePassword
similarity index 100%
rename from source3/tests/README
rename to tests/README
similarity index 100%
rename from source3/tests/crypttest.c
rename to tests/crypttest.c
similarity index 100%
rename from source3/tests/ftruncate.c
rename to tests/ftruncate.c
similarity index 100%
rename from source3/tests/getgroups.c
rename to tests/getgroups.c
similarity index 100%
rename from source3/tests/shlib.c
rename to tests/shlib.c
similarity index 98%
rename from source3/tests/summary.c
rename to tests/summary.c
index 8fcde7bd998e91456823fbc472886cab4047be29..886fc8da88012f8f32962cf8df5f3c5d586f65fd 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 
+void exit(int);
+
 main()
 {
     exit (0);