From 64578c0589a3a741f81fb55c16eeb882128da00b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:08:05 +0000 Subject: merge from the autoconf2 branch to the main branch (This used to be commit 3bda7ac417107a7b01d91805ca71c4330657ed21) --- source3/tests/README | 10 ++++++ source3/tests/fcntl_lock.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ source3/tests/ftruncate.c | 24 ++++++++++++++ source3/tests/shared_mmap.c | 66 ++++++++++++++++++++++++++++++++++++++ source3/tests/sysv_ipc.c | 66 ++++++++++++++++++++++++++++++++++++++ source3/tests/trapdoor.c | 25 +++++++++++++++ 6 files changed, 269 insertions(+) create mode 100644 source3/tests/README create mode 100644 source3/tests/fcntl_lock.c create mode 100644 source3/tests/ftruncate.c create mode 100644 source3/tests/shared_mmap.c create mode 100644 source3/tests/sysv_ipc.c create mode 100644 source3/tests/trapdoor.c (limited to 'source3/tests') diff --git a/source3/tests/README b/source3/tests/README new file mode 100644 index 0000000000..cf1be8b00a --- /dev/null +++ b/source3/tests/README @@ -0,0 +1,10 @@ +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/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c new file mode 100644 index 0000000000..c54479434e --- /dev/null +++ b/source3/tests/fcntl_lock.c @@ -0,0 +1,78 @@ +/* test whether fcntl locking works on this system */ + +#include +#include + +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_SYS_FCNTL_H +#include +#endif + +#include + +static int sys_waitpid(pid_t pid,int *status,int options) +{ +#ifdef HAVE_WAITPID + return waitpid(pid,status,options); +#else /* USE_WAITPID */ + return wait4(pid, status, options, NULL); +#endif /* USE_WAITPID */ +} + +#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, pid, ret, status=1; + + if (!(pid=fork())) { + sleep(2); + fd = open(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_GETLK,&lock); + + if ((ret == -1) || + (lock.l_type == F_UNLCK)) { + exit(1); + } else { + exit(0); + } + } + + fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600); + + 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); + + sys_waitpid(pid, &status, 0); + + unlink(DATA); + + exit(status); +} diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c new file mode 100644 index 0000000000..8d5e8942e3 --- /dev/null +++ b/source3/tests/ftruncate.c @@ -0,0 +1,24 @@ +/* test whether ftruncte() can extend a file */ + +#include +#include +#include +#include + +#define DATA "conftest.trunc" +#define LEN 7663 + +main() +{ + int *buf; + int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); + + ftruncate(fd, LEN); + + unlink(DATA); + + if (lseek(fd, 0, SEEK_END) == LEN) { + exit(0); + } + exit(1); +} diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c new file mode 100644 index 0000000000..fb8a2a32d5 --- /dev/null +++ b/source3/tests/shared_mmap.c @@ -0,0 +1,66 @@ +/* this tests whether we can use a shared writeable mmap on a file - + as needed for the mmap varient of FAST_SHARE_MODES */ + +#include +#include +#include +#include +#include + +#define DATA "conftest.mmap" + +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif + +main() +{ + int *buf; + int i, pid; + int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); + int count=7; + + if (fd == -1) exit(1); + + for (i=0;i<10000;i++) { + write(fd,&i,sizeof(i)); + } + + close(fd); + + if (fork() == 0) { + fd = open(DATA,O_RDWR); + if (fd == -1) exit(1); + + buf = (int *)mmap(NULL, 10000*sizeof(int), + (PROT_READ | PROT_WRITE), + MAP_FILE | MAP_SHARED, + fd, 0); + + while (count-- && buf[9124] != 55732) sleep(1); + + if (count <= 0) exit(1); + + buf[1763] = 7268; + exit(0); + } + + fd = open(DATA,O_RDWR); + if (fd == -1) exit(1); + + buf = (int *)mmap(NULL, 10000*sizeof(int), + (PROT_READ | PROT_WRITE), + MAP_FILE | MAP_SHARED, + fd, 0); + + if (buf == (int *)-1) exit(1); + + buf[9124] = 55732; + + while (count-- && buf[1763] != 7268) sleep(1); + + unlink(DATA); + + if (count > 0) exit(0); + exit(1); +} diff --git a/source3/tests/sysv_ipc.c b/source3/tests/sysv_ipc.c new file mode 100644 index 0000000000..2374174e8f --- /dev/null +++ b/source3/tests/sysv_ipc.c @@ -0,0 +1,66 @@ +/* this tests whether we can use a sysv shared memory segment + as needed for the sysv varient of FAST_SHARE_MODES */ + +#include +#include +#include +#include +#include + +#define KEY 0x963796 +#define SIZE (32*1024) + +main() +{ + int id; + int *buf; + int count=7; + +#ifdef LINUX + if (sizeof(struct shmid_ds) == 52) { + printf("WARNING: You probably have a broken set of glibc2 include files - disabling sysv shared memory\n"); + exit(1); + } +#endif + + id = shmget(KEY, 0, 0); + if (id != -1) { + if (shmctl(id, IPC_RMID, 0) != 0) exit(1); + } + + if (fork() == 0) { + /* uggh - need locking */ + sleep(2); + + /* get an existing area */ + id = shmget(KEY, 0, 0); + if (id == -1) exit(1); + + buf = (int *)shmat(id, 0, 0); + if (buf == (int *)-1) exit(1); + + + while (count-- && buf[6124] != 55732) sleep(1); + + if (count <= 0) exit(1); + + buf[1763] = 7268; + exit(0); + } + + id = shmget(KEY, SIZE, IPC_CREAT | IPC_EXCL | 0600); + if (id == -1) exit(1); + + buf = (int *)shmat(id, 0, 0); + + if (buf == (int *)-1) exit(1); + + buf[6124] = 55732; + + while (count-- && buf[1763] != 7268) sleep(1); + + shmctl(id, IPC_RMID, 0); + + if (count <= 0) exit(1); + exit(0); +} diff --git a/source3/tests/trapdoor.c b/source3/tests/trapdoor.c new file mode 100644 index 0000000000..83e10d0613 --- /dev/null +++ b/source3/tests/trapdoor.c @@ -0,0 +1,25 @@ +/* test for a trapdoor uid system */ + +#include +#include +#include + +main() +{ + if (getuid() != 0) { + fprintf(stderr,"ERROR: This test must be run as root - assuming non-trapdoor system\n"); + exit(0); + } + + if (seteuid(1) != 0) exit(1); + if (geteuid() != 1) exit(1); + if (seteuid(0) != 0) exit(1); + if (geteuid() != 0) exit(1); + + if (setegid(1) != 0) exit(1); + if (getegid() != 1) exit(1); + if (setegid(0) != 0) exit(1); + if (getegid() != 0) exit(1); + + exit(0); +} -- cgit From 8d42ee0f2c8cdd8d9f41e5e245999a9a6d44523f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:15:02 +0000 Subject: some merge cleanups (This used to be commit 1d655b7c64231b0aec0548bb90fc3dcc3f37791c) --- source3/tests/dummy.in | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 source3/tests/dummy.in (limited to 'source3/tests') diff --git a/source3/tests/dummy.in b/source3/tests/dummy.in new file mode 100644 index 0000000000..e69de29bb2 -- cgit From fb08c34cf3950f994701a9c98c89670f6346f7ab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 05:05:36 +0000 Subject: get rid of the runtime test for broken getgroups() and add a compile time test instead. This also allows us to get rid of the igroups element of a couple of structures. (This used to be commit 8b25fe734166b76ceebf8d9543c706ebe0fddc96) --- source3/tests/getgroups.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 source3/tests/getgroups.c (limited to 'source3/tests') diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c new file mode 100644 index 0000000000..37990e010b --- /dev/null +++ b/source3/tests/getgroups.c @@ -0,0 +1,62 @@ +/* this tests whether getgroups actually returns lists of integers + rather than gid_t. The test only works if the user running + the test is in at least 1 group + + The test is designed to check for those broken OSes that define + getgroups() as returning an array of gid_t but actually return a + array of ints! Ultrix is one culprit + */ + +#include +#include +#include +#include + +main() +{ + int i; + int *igroups; + char *cgroups; + int grp = 0; + int ngroups = getgroups(0,&grp); + + if (sizeof(gid_t) == sizeof(int)) { + fprintf(stderr,"gid_t and int are the same size\n"); + exit(1); + } + + if (ngroups <= 0) + ngroups = 32; + + igroups = (int *)malloc(sizeof(int)*ngroups); + + for (i=0;i Date: Wed, 29 Jul 1998 05:09:10 +0000 Subject: ignore the auto-generated dummy file (This used to be commit f4c629bde2bbcb0cfa4d6f5cb1aa7edddf569fac) --- source3/tests/.cvsignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 source3/tests/.cvsignore (limited to 'source3/tests') diff --git a/source3/tests/.cvsignore b/source3/tests/.cvsignore new file mode 100644 index 0000000000..421376db9e --- /dev/null +++ b/source3/tests/.cvsignore @@ -0,0 +1 @@ +dummy -- cgit From 0cb85e04a974daf4442a7561931ff1be566a8410 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Sep 1998 13:21:57 +0000 Subject: some people are foolishly running ./configure from other than the source directory! This adds a new "trivial" test that makes sure that the autoconf tests are working. It aborts the configure run if not. (This used to be commit ead0338ad27f29f1abbbe9f6302d6bf633bf98b2) --- source3/tests/trivial.c | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 source3/tests/trivial.c (limited to 'source3/tests') diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c new file mode 100644 index 0000000000..2723637a0f --- /dev/null +++ b/source3/tests/trivial.c @@ -0,0 +1,4 @@ +main() +{ + exit(0); +} -- cgit From f5e6f03389e53c6575c68f7bde5f9fa7dc496240 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Sep 1998 13:35:54 +0000 Subject: expand the sysv shmem test to look for semaphores as well as shared memory. Some FreeBSD systems have sysv shared memory but no semaphores! (This used to be commit 3f4959a065ed987a8254903a5aaf6234bb88ad5c) --- source3/tests/sysv_ipc.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'source3/tests') diff --git a/source3/tests/sysv_ipc.c b/source3/tests/sysv_ipc.c index 2374174e8f..13956ec6f0 100644 --- a/source3/tests/sysv_ipc.c +++ b/source3/tests/sysv_ipc.c @@ -6,15 +6,27 @@ #include #include #include +#include #define KEY 0x963796 +#define SEMKEY 0x963797 #define SIZE (32*1024) +#ifndef HAVE_UNION_SEMUN +union semun { + int val; + struct semid_ds *buf; + unsigned short *array; +}; +#endif + + main() { - int id; + int id, sem_id; int *buf; int count=7; + union semun su; #ifdef LINUX if (sizeof(struct shmid_ds) == 52) { @@ -23,6 +35,14 @@ main() } #endif + + sem_id = semget(SEMKEY, 1, IPC_CREAT|IPC_EXCL|0600); + + if (sem_id == -1) exit(1); + + su.val = 1; + semctl(sem_id, 0, IPC_RMID, su); + id = shmget(KEY, 0, 0); if (id != -1) { if (shmctl(id, IPC_RMID, 0) != 0) exit(1); -- cgit From b28284007838c5802930691f1bd0aa77627ae7a2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Sep 1998 13:53:13 +0000 Subject: added a configuration summary at the end of ./configure. It also aborts if essential functions are not available. (This used to be commit 5c7717f033f670f587b4a250d0a663cad30824e5) --- source3/tests/summary.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 source3/tests/summary.c (limited to 'source3/tests') diff --git a/source3/tests/summary.c b/source3/tests/summary.c new file mode 100644 index 0000000000..8c0d3005af --- /dev/null +++ b/source3/tests/summary.c @@ -0,0 +1,28 @@ +#include + +main() +{ +#ifndef HAVE_FCNTL_LOCK + printf("ERROR: No locking available. Running Samba would be unsafe\n"); + exit(1); +#endif + +#if !(defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP)) + printf("WARNING: no shared memory. Running with slow locking code\n"); +#endif + +#ifdef HAVE_TRAPDOOR_UID + printf("WARNING: trapdoor uid system - Samba may not operate correctly\n"); +#endif + +#if !(defined(HAVE_NETMASK_IFCONF) || defined(HAVE_NETMASK_IFREQ) || defined(HAVE_NETMASK_AIX)) + printf("WARNING: No automated netmask determination - use an interfaces line\n"); +#endif + +#if !(defined(STAT_STATVFS) || 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 + + exit(0); +} -- cgit From b8b67f4fab4a6fd686c5796c2701882197a7bd9d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Sep 1998 23:06:57 +0000 Subject: configure configure.in: Added checks for statvfs64. Last bit of 64 bit widening (I hope :-). include/config.h.in: Added #undef STAT_STATVFS64. include/includes.h: Added SMB_STRUCT_STATVFS type, Changed SMB_BIG_INTEGER to SMB_BIG_UINT and SMB_BIG_INT types. include/smb.h: Added flag defines from CIFS spec. lib/debug.c: Fixed one more mode_t issue. lib/system.c: Added sys_statvfs wrapper. lib/util.c: Changed trim_string to use size_t. param/loadparm.c: Moved "blocking locks" into locking section. Alphabetised locking options. Question - shuld we do this for all options ? passdb/ldap.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/nispass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/smbpass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. smbd/dfree.c: Changed to use 64 bit types if available. Moved to use unsigned types. smbd/dosmode.c: Fixed one more mode_t issue. smbd/negprot.c: Changed literals to be FLAG_ #defines. smbd/nttrans.c: Removed dead code. smbd/open.c: Changed disk_free call. smbd/process.c: Changed literals to be FLAG_ #defines. smbd/reply.c: Changed disk_free call. smbd/trans2.c: Fixed but in SMB_QUERY_FS_VOLUME_INFO call. Was using UNICODE - should use ascii. tests/summary.c: Added STAT_STATVFS64 check. Jeremy. (This used to be commit c512b1b91fb7f2a7a93b9033a33e06d966daadb4) --- source3/tests/summary.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/tests') diff --git a/source3/tests/summary.c b/source3/tests/summary.c index 8c0d3005af..b89bac86ac 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -19,7 +19,7 @@ main() printf("WARNING: No automated netmask determination - use an interfaces line\n"); #endif -#if !(defined(STAT_STATVFS) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA)) +#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 -- cgit From e649750cb4d2d2577f0577b1d7a87ae4daf8fb6f Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Mon, 21 Sep 1998 09:07:08 +0000 Subject: major autoconf clean-up fix problems in builds with srcdir!=builddir (This used to be commit 1ffc3b807a3f80644c974b454ff5e6f68e89b546) --- source3/tests/dummy.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/tests') diff --git a/source3/tests/dummy.in b/source3/tests/dummy.in index e69de29bb2..8b13789179 100644 --- a/source3/tests/dummy.in +++ b/source3/tests/dummy.in @@ -0,0 +1 @@ + -- cgit From 5f7ee360567a6b4e1a6f43ff01da057d2998fef8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 25 Sep 1998 23:40:49 +0000 Subject: Makefile.in: Fixed bug with continuation line causing proto to fail. Added $(PROGS) $(SPROGS) as targets for make clean. acconfig.h: Added HAVE_IRIX_SPECIFIC_CAPABILITIES. configure.in: Added sys/capability.h header check. Added function checks for srandom random srand rand. Added HAVE_IRIX_SPECIFIC_CAPABILITIES test. includes.h: Added #include . ntdomain.h: Moved struct acct_info into here from smb.h smb.h: Added KERNEL_OPLOCK_CAPABILITY define. Moved enum action_type into rpcclient.h Moved struct cli_state into client.h Moved struct nt_client_info, struct tar_client_info, struct client_info into rpcclient.h lib/genrand.c: Changed to use sys_random() & friends. lib/smbrun.c: Lose capabilities after fork. lib/system.c: Added set_process_capability(), set_inherited_process_capability() sys_random(), sys_srandom(). lib/util.c: Added Ander's EFBIG lock check to fcntl_lock for 64 bit access to an 32 bit mounted NFS filesystem. nmbd/nmbd.c: Changed to use sys_random() & friends. nmbd/nmbd_browsesync.c: Changed to use sys_random() & friends. passdb/ldap.c: Missed one pdb_encode_acct_ctrl call. passdb/passdb.c: Changed to Ander's code for ' ' characters. passdb/smbpass.c: Added Ander's code to reset ACB_PWNOTREQ. script/mkproto.awk: Added 'long' to prototypes. smbd/chgpasswd.c: Lose capabilities after fork. smbd/open.c: Do the mmap *after* the kernel oplock. smbd/oplock.c: Removed stub code from kernel oplock path. Added set_process_capability(), set_inherited_process_capability() calls. smbd/reply.c: Initialize count = 0, offset = 0. smbd/server.c: Added set_process_capability(), set_inherited_process_capability() calls. tests/summary.c: Ensure we have RANDOM or RAND. utils/smbpasswd.c: Added Ander's code to reset ACB_PWNOTREQ. utils/torture.c: Changed to use sys_random() & friends. Jeremy. (This used to be commit e8be306f23963ac00b1a383ebe0cc1421529fb02) --- source3/tests/summary.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/summary.c b/source3/tests/summary.c index b89bac86ac..3db510495a 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -24,5 +24,10 @@ main() 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); } -- cgit From cf971f88ac188eec353a7fb021744b8076cc4eb7 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Mon, 28 Sep 1998 00:14:36 +0000 Subject: automated generation of .dummy files for each subdirectory; dummy.in files are no longer needed, and new directories will be taken care of automatically, at configure (or config.status --recheck) time (This used to be commit 237a8e5fe62d757c04b8207cbbee4df1470cfe4e) --- source3/tests/dummy.in | 1 - 1 file changed, 1 deletion(-) delete mode 100644 source3/tests/dummy.in (limited to 'source3/tests') diff --git a/source3/tests/dummy.in b/source3/tests/dummy.in deleted file mode 100644 index 8b13789179..0000000000 --- a/source3/tests/dummy.in +++ /dev/null @@ -1 +0,0 @@ - -- cgit From a2d7f765e8500f23c126c7b7cb6bb346adc11641 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Tue, 29 Sep 1998 04:52:17 +0000 Subject: get away with dummy and .dummy files (This used to be commit 90a8a02484a0897b053fd6531b7fec5d23098b6f) --- source3/tests/.cvsignore | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/tests') diff --git a/source3/tests/.cvsignore b/source3/tests/.cvsignore index 421376db9e..e69de29bb2 100644 --- a/source3/tests/.cvsignore +++ b/source3/tests/.cvsignore @@ -1 +0,0 @@ -dummy -- cgit From 80f920181f8d2d58bd3b341aac57de0c71e21374 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Oct 1998 18:51:16 +0000 Subject: server/srv_samr.c smbd/ipc.c: Changed global_myworkgroup back to fstring (as it is everywhere else). smbwrapper/smbsh.c: For IRIX n32 binaries, set _RLDN32_LIST not _RLD32_LIST. Exec users preferred shell is SHELL environment variable is set. tests/fcntl_lock.c: Added sys/types.h for systems that need this. Jeremy. (This used to be commit 50413d0d819d4f13e760ca8439c5bdde0898d63e) --- source3/tests/fcntl_lock.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index c54479434e..a90e00aa00 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -2,6 +2,7 @@ #include #include +#include #ifdef HAVE_FCNTL_H #include -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/tests/fcntl_lock.c | 17 ++++++++++++++++- source3/tests/ftruncate.c | 3 +++ source3/tests/getgroups.c | 4 ++++ source3/tests/shared_mmap.c | 4 +++- source3/tests/summary.c | 11 ++++++----- source3/tests/sysv_ipc.c | 2 ++ 6 files changed, 34 insertions(+), 7 deletions(-) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index a90e00aa00..32aecb8743 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -1,5 +1,9 @@ /* test whether fcntl locking works on this system */ +#if defined(HAVE_UNISTD_H) +#include +#endif + #include #include #include @@ -33,7 +37,8 @@ static int sys_waitpid(pid_t pid,int *status,int options) int main(int argc, char *argv[]) { struct flock lock; - int fd, pid, ret, status=1; + int fd, ret, status=1; + pid_t pid; if (!(pid=fork())) { sleep(2); @@ -75,5 +80,15 @@ int main(int argc, char *argv[]) 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) */ + exit(status); } diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c index 8d5e8942e3..93282782ee 100644 --- a/source3/tests/ftruncate.c +++ b/source3/tests/ftruncate.c @@ -1,6 +1,9 @@ /* test whether ftruncte() can extend a file */ +#if defined(HAVE_UNISTD_H) #include +#endif + #include #include #include diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c index 37990e010b..343fd5a184 100644 --- a/source3/tests/getgroups.c +++ b/source3/tests/getgroups.c @@ -7,6 +7,10 @@ array of ints! Ultrix is one culprit */ +#if defined(HAVE_UNISTD_H) +#include +#endif + #include #include #include diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c index fb8a2a32d5..fcef75d0d6 100644 --- a/source3/tests/shared_mmap.c +++ b/source3/tests/shared_mmap.c @@ -1,7 +1,9 @@ /* this tests whether we can use a shared writeable mmap on a file - as needed for the mmap varient of FAST_SHARE_MODES */ +#if defined(HAVE_UNISTD_H) #include +#endif #include #include #include @@ -16,7 +18,7 @@ main() { int *buf; - int i, pid; + int i; int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); int count=7; diff --git a/source3/tests/summary.c b/source3/tests/summary.c index 3db510495a..7ff9ea61c9 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -2,7 +2,7 @@ main() { -#ifndef HAVE_FCNTL_LOCK +#if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64)) printf("ERROR: No locking available. Running Samba would be unsafe\n"); exit(1); #endif @@ -11,12 +11,13 @@ main() printf("WARNING: no shared memory. Running with slow locking code\n"); #endif -#ifdef HAVE_TRAPDOOR_UID - printf("WARNING: trapdoor uid system - Samba may not operate correctly\n"); +#if !(defined(HAVE_IFACE_IFCONF) || defined(HAVE_IFACE_IFREQ) || defined(HAVE_IFACE_AIX)) + printf("WARNING: No automated network interface determination\n"); #endif -#if !(defined(HAVE_NETMASK_IFCONF) || defined(HAVE_NETMASK_IFREQ) || defined(HAVE_NETMASK_AIX)) - printf("WARNING: No automated netmask determination - use an interfaces line\n"); +#if !(defined(USE_SETEUID) || defined(USE_SETREUID) || defined(USE_SETRESUID) || defined(USE_SETUIDX)) + printf("ERROR: no seteuid method available\n"); + exit(1); #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)) diff --git a/source3/tests/sysv_ipc.c b/source3/tests/sysv_ipc.c index 13956ec6f0..9f0e20957a 100644 --- a/source3/tests/sysv_ipc.c +++ b/source3/tests/sysv_ipc.c @@ -1,7 +1,9 @@ /* this tests whether we can use a sysv shared memory segment as needed for the sysv varient of FAST_SHARE_MODES */ +#if defined(HAVE_UNISTD_H) #include +#endif #include #include #include -- cgit From 32a965e09ce4befe971855e11e1fb5ceb51a9ed1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:35:20 +0000 Subject: 2nd phase of head branch sync with SAMBA_2_0 - this delets all the files that were in the head branch but weren't in SAMBA_2_0 (This used to be commit d7b208786590b5a28618590172b8d523627dda09) --- source3/tests/trapdoor.c | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 source3/tests/trapdoor.c (limited to 'source3/tests') diff --git a/source3/tests/trapdoor.c b/source3/tests/trapdoor.c deleted file mode 100644 index 83e10d0613..0000000000 --- a/source3/tests/trapdoor.c +++ /dev/null @@ -1,25 +0,0 @@ -/* test for a trapdoor uid system */ - -#include -#include -#include - -main() -{ - if (getuid() != 0) { - fprintf(stderr,"ERROR: This test must be run as root - assuming non-trapdoor system\n"); - exit(0); - } - - if (seteuid(1) != 0) exit(1); - if (geteuid() != 1) exit(1); - if (seteuid(0) != 0) exit(1); - if (geteuid() != 0) exit(1); - - if (setegid(1) != 0) exit(1); - if (getegid() != 1) exit(1); - if (setegid(0) != 0) exit(1); - if (getegid() != 0) exit(1); - - exit(0); -} -- cgit From 868c81eefa72b31023eeac32788eaa439013c0f8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 7 Feb 2000 14:27:04 +0000 Subject: Added check for SGI IRIX brokenness with semaphores when using gcc. Code from Don Badrak Jeremy. (This used to be commit 773d6e504b1ac97f0d8136002ace2c0c0771a163) --- source3/tests/sgi_sysv_hack.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 source3/tests/sgi_sysv_hack.c (limited to 'source3/tests') diff --git a/source3/tests/sgi_sysv_hack.c b/source3/tests/sgi_sysv_hack.c new file mode 100644 index 0000000000..0fb16f11f8 --- /dev/null +++ b/source3/tests/sgi_sysv_hack.c @@ -0,0 +1,46 @@ +/* this tests if we need to define SGI_SEMUN_HACK + if we're using gcc on IRIX 6.5.x. */ + +#if defined(HAVE_UNISTD_H) +#include +#endif +#include +#include +#include +#include +#include + +#ifndef HAVE_UNION_SEMUN +union semun { + int val; + struct semid_ds *buf; + unsigned short *array; +}; +#endif + +union semun_hack { + int val; + struct semid_ds *buf; + unsigned short *array; + char __dummy[5]; +}; + +main() { + struct semid_ds sem_ds; + union semun_hack suh; + union semun su; + int sem_id, ret; + + ret = 1; + sem_id = semget(0xdead6666,1,IPC_CREAT|IPC_EXCL|0777); + su.buf = &sem_ds; + suh.buf = &sem_ds; + if (sem_id != -1) { + if ((semctl(sem_id, 0, IPC_STAT, su) == -1) && + (semctl(sem_id, 0, IPC_STAT, suh) != -1)) { + ret = 0; + } + } + semctl(sem_id, 0, IPC_RMID, 0); + return ret; +} -- cgit From 332013e09efadabcf31c01852690960bf614abd7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Mar 2000 23:03:48 +0000 Subject: Added check for LL suffix to long long ints needed by AIX 4.3.x compiler to allow successful build. Jeremy. (This used to be commit 567713a07c089ab3ebb4c9b96087777de154b601) --- source3/tests/fcntl_lock64.c | 96 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 source3/tests/fcntl_lock64.c (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c new file mode 100644 index 0000000000..e5ecd88fd0 --- /dev/null +++ b/source3/tests/fcntl_lock64.c @@ -0,0 +1,96 @@ +/* test whether 64 bit fcntl locking really works on this system */ + +#if defined(HAVE_UNISTD_H) +#include +#endif + +#include +#include +#include + +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_SYS_FCNTL_H +#include +#endif + +#include + +static int sys_waitpid(pid_t pid,int *status,int options) +{ +#ifdef HAVE_WAITPID + return waitpid(pid,status,options); +#else /* USE_WAITPID */ + return wait4(pid, status, options, NULL); +#endif /* USE_WAITPID */ +} + +#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); +} -- cgit From 98825661ddb4dd5cfa603291a69b5c4d3d98e791 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Apr 2000 05:56:49 +0000 Subject: removed some obsolete configure tests (sysv ipc etc) (This used to be commit e8905a557a342ba3604a61663c6ff24887a9fd46) --- source3/tests/sgi_sysv_hack.c | 46 ---------------------- source3/tests/summary.c | 4 -- source3/tests/sysv_ipc.c | 88 ------------------------------------------- 3 files changed, 138 deletions(-) delete mode 100644 source3/tests/sgi_sysv_hack.c delete mode 100644 source3/tests/sysv_ipc.c (limited to 'source3/tests') diff --git a/source3/tests/sgi_sysv_hack.c b/source3/tests/sgi_sysv_hack.c deleted file mode 100644 index 0fb16f11f8..0000000000 --- a/source3/tests/sgi_sysv_hack.c +++ /dev/null @@ -1,46 +0,0 @@ -/* this tests if we need to define SGI_SEMUN_HACK - if we're using gcc on IRIX 6.5.x. */ - -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include -#include -#include -#include - -#ifndef HAVE_UNION_SEMUN -union semun { - int val; - struct semid_ds *buf; - unsigned short *array; -}; -#endif - -union semun_hack { - int val; - struct semid_ds *buf; - unsigned short *array; - char __dummy[5]; -}; - -main() { - struct semid_ds sem_ds; - union semun_hack suh; - union semun su; - int sem_id, ret; - - ret = 1; - sem_id = semget(0xdead6666,1,IPC_CREAT|IPC_EXCL|0777); - su.buf = &sem_ds; - suh.buf = &sem_ds; - if (sem_id != -1) { - if ((semctl(sem_id, 0, IPC_STAT, su) == -1) && - (semctl(sem_id, 0, IPC_STAT, suh) != -1)) { - ret = 0; - } - } - semctl(sem_id, 0, IPC_RMID, 0); - return ret; -} diff --git a/source3/tests/summary.c b/source3/tests/summary.c index 7ff9ea61c9..79a530b013 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -7,10 +7,6 @@ main() exit(1); #endif -#if !(defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP)) - printf("WARNING: no shared memory. Running with slow locking code\n"); -#endif - #if !(defined(HAVE_IFACE_IFCONF) || defined(HAVE_IFACE_IFREQ) || defined(HAVE_IFACE_AIX)) printf("WARNING: No automated network interface determination\n"); #endif diff --git a/source3/tests/sysv_ipc.c b/source3/tests/sysv_ipc.c deleted file mode 100644 index 9f0e20957a..0000000000 --- a/source3/tests/sysv_ipc.c +++ /dev/null @@ -1,88 +0,0 @@ -/* this tests whether we can use a sysv shared memory segment - as needed for the sysv varient of FAST_SHARE_MODES */ - -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include -#include -#include -#include - -#define KEY 0x963796 -#define SEMKEY 0x963797 -#define SIZE (32*1024) - -#ifndef HAVE_UNION_SEMUN -union semun { - int val; - struct semid_ds *buf; - unsigned short *array; -}; -#endif - - -main() -{ - int id, sem_id; - int *buf; - int count=7; - union semun su; - -#ifdef LINUX - if (sizeof(struct shmid_ds) == 52) { - printf("WARNING: You probably have a broken set of glibc2 include files - disabling sysv shared memory\n"); - exit(1); - } -#endif - - - sem_id = semget(SEMKEY, 1, IPC_CREAT|IPC_EXCL|0600); - - if (sem_id == -1) exit(1); - - su.val = 1; - semctl(sem_id, 0, IPC_RMID, su); - - id = shmget(KEY, 0, 0); - if (id != -1) { - if (shmctl(id, IPC_RMID, 0) != 0) exit(1); - } - - if (fork() == 0) { - /* uggh - need locking */ - sleep(2); - - /* get an existing area */ - id = shmget(KEY, 0, 0); - if (id == -1) exit(1); - - buf = (int *)shmat(id, 0, 0); - if (buf == (int *)-1) exit(1); - - - while (count-- && buf[6124] != 55732) sleep(1); - - if (count <= 0) exit(1); - - buf[1763] = 7268; - exit(0); - } - - id = shmget(KEY, SIZE, IPC_CREAT | IPC_EXCL | 0600); - if (id == -1) exit(1); - - buf = (int *)shmat(id, 0, 0); - - if (buf == (int *)-1) exit(1); - - buf[6124] = 55732; - - while (count-- && buf[1763] != 7268) sleep(1); - - shmctl(id, IPC_RMID, 0); - - if (count <= 0) exit(1); - exit(0); -} -- cgit From da08b5374eaeeec6269fff0e22cec16c1b774b61 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Fri, 12 Jan 2001 00:10:24 +0000 Subject: Changes from APPLIANCE_HEAD: source/tests/crypttest.c - another one missed from a while ago: Add back tests/crypttest.c so that we can check for truncated crypt on those systems that it is relevant for and we avoid setting if for those systems that it is not true for. (Originally from SAMBA_2_2, Nov 13th 2000) (This used to be commit 5358f8abc1e1dea591446e926c00821fadfe0d84) --- source3/tests/crypttest.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 source3/tests/crypttest.c (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c new file mode 100644 index 0000000000..c9133f40be --- /dev/null +++ b/source3/tests/crypttest.c @@ -0,0 +1,74 @@ +#if defined(HAVE_UNISTD_H) +#include +#endif + +#include + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#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); +} -- cgit From 9019718582850e20d3e1506b020116e8b2cb2016 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 2 May 2001 06:52:25 +0000 Subject: added error msgs to fcntl_lock test (This used to be commit db5d38736d0d91acb55f4e4a67f33a2c0b5fdca3) --- source3/tests/fcntl_lock.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 32aecb8743..1f67679c8c 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -44,7 +44,11 @@ int main(int argc, char *argv[]) sleep(2); fd = open(DATA, O_RDONLY); - if (fd == -1) exit(1); + 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; @@ -59,6 +63,7 @@ int main(int argc, char *argv[]) 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); @@ -67,6 +72,12 @@ int main(int argc, char *argv[]) fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 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; @@ -90,5 +101,10 @@ int main(int argc, char *argv[]) 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); } -- cgit From 1107dc4c4f99936129f1459625857976e1b1ddd4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 2 May 2001 06:54:52 +0000 Subject: added sys/wait.h to fcntl_lock test (This used to be commit ed151605e57b7db3457cdf0c87f71c86e84c8f5b) --- source3/tests/fcntl_lock.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 1f67679c8c..3cd0e5ff5e 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -16,6 +16,10 @@ #include #endif +#ifdef HAVE_SYS_WAIT_H +#include +#endif + #include static int sys_waitpid(pid_t pid,int *status,int options) -- cgit From 71ac074517a528c2f08ff5adc842403ca8d3c1cb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 2 May 2001 07:58:40 +0000 Subject: use O_EXCL for fcntl_lock.c test in case some fool runs on /tmp (This used to be commit 4d3d7a0d673b80f1de411a5fb5a23ae06cf80f43) --- source3/tests/fcntl_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 3cd0e5ff5e..1b790b0a97 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -74,7 +74,8 @@ int main(int argc, char *argv[]) } } - fd = open(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600); + 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", -- cgit From a808ca914f74b997d222d47159dc0185511d1862 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 May 2001 12:47:32 +0000 Subject: add an alarm to fcntl test to stop tru64 from freezing on the test (This used to be commit 6b1ced1674217343ab4e5f966608a21c66bf650c) --- source3/tests/fcntl_lock.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 1b790b0a97..d03efb35b3 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -44,6 +44,8 @@ int main(int argc, char *argv[]) int fd, ret, status=1; pid_t pid; + alarm(10); + if (!(pid=fork())) { sleep(2); fd = open(DATA, O_RDONLY); -- cgit From 289b92de513aa1edce6246a1ceac23e72e81d979 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 May 2001 14:09:10 +0000 Subject: allow env variable TESTDIR for directory for fcntl_lock test (This used to be commit b6645402b12cf8eaa7d9edf7dba3fae1f5ec0356) --- source3/tests/fcntl_lock.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index d03efb35b3..3dc12a3897 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -43,6 +43,10 @@ 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); -- cgit From 21fd0a0f6261fb511488e391349ecdb0bf93e12d Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Tue, 26 Jun 2001 07:44:02 +0000 Subject: Add check for working AF_LOCAL sockets, which are borken on RH7.0 with _LARGEFILE64_SOURCE, and probably not present on non-Unix systems like VMS. (This used to be commit 8b0a5bc436fb44f5123d037b102f2d2c4d3287e8) --- source3/tests/.cvsignore | 1 + source3/tests/unixsock.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 source3/tests/unixsock.c (limited to 'source3/tests') diff --git a/source3/tests/.cvsignore b/source3/tests/.cvsignore index e69de29bb2..b6c1f01120 100644 --- a/source3/tests/.cvsignore +++ b/source3/tests/.cvsignore @@ -0,0 +1 @@ +unixsock diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c new file mode 100644 index 0000000000..f2765d68f6 --- /dev/null +++ b/source3/tests/unixsock.c @@ -0,0 +1,93 @@ +/* -*- 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 , June 2000. */ + +/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ + +#include + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +#ifdef HAVE_SYS_UN_H +# include +#endif + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + +#if HAVE_SYS_WAIT_H +# include +#endif + +#if HAVE_ERRNO_DECL +# include +#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); +} -- cgit From 9d96f7321e92c3b1d9f13c9f582f45d940d8cf80 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Aug 2001 19:48:54 +0000 Subject: Update to work with no crypt available, just like it will in Samba. Jermey. (This used to be commit 84e15b81992977fd546f2118d1f9847cf0713fa0) --- source3/tests/crypttest.c | 778 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 778 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index c9133f40be..efee2e593d 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -12,6 +12,784 @@ #include #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 + 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 Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * @(#)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]; -- cgit From 927e86047786cbdda2bded6d983d952202b08006 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 31 Dec 2001 22:10:24 +0000 Subject: added a simple test to see whether building shared libraries actually works (This used to be commit 3aeefbca4f272f57e83e753177ee6e8157b2dbd5) --- source3/tests/shlib.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 source3/tests/shlib.c (limited to 'source3/tests') diff --git a/source3/tests/shlib.c b/source3/tests/shlib.c new file mode 100644 index 0000000000..761d9fd5c5 --- /dev/null +++ b/source3/tests/shlib.c @@ -0,0 +1,6 @@ +/* a trivial function used to test building shared libraries */ + +int foo(void) +{ + return 1; +} -- cgit From 9759adc4ffd2bc56cd09ca9c4c696502c327dce1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 9 Oct 2003 20:58:11 +0000 Subject: Move sysquotas autoconf tests to a seperate file. Patch by Stefan Metzmacher (This used to be commit 9f6cd8177db9a88f681f28a8dca044595ddaae88) --- source3/tests/sysquotas.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 source3/tests/sysquotas.c (limited to 'source3/tests') diff --git a/source3/tests/sysquotas.c b/source3/tests/sysquotas.c new file mode 100644 index 0000000000..2aa643326c --- /dev/null +++ b/source3/tests/sysquotas.c @@ -0,0 +1,94 @@ +/* this test should find out what quota api is available on the os */ + +#if defined(HAVE_QUOTACTL_4A) +/* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_ASM_TYPES_H +#include +#endif + +#if defined(HAVE_LINUX_QUOTA_H) +# include +# if defined(HAVE_STRUCT_IF_DQBLK) +# define SYS_DQBLK if_dqblk +# elif defined(HAVE_STRUCT_MEM_DQBLK) +# define SYS_DQBLK mem_dqblk +# endif +#elif defined(HAVE_SYS_QUOTA_H) +# include +#endif + +#ifndef SYS_DQBLK +#define SYS_DQBLK dqblk +#endif + + int autoconf_quota(void) +{ + int ret = -1; + struct SYS_DQBLK D; + + ret = quotactl(Q_GETQUOTA,"/dev/hda1",0,(void *)&D); + + return ret; +} + +#elif defined(HAVE_QUOTACTL_4B) +/* int quotactl(const char *path, int cmd, int id, char *addr); */ + +#ifdef HAVE_SYS_QUOTA_H +#include +#else /* *BSD */ +#include +#include +#include +#endif + + int autoconf_quota(void) +{ + int ret = -1; + struct dqblk D; + + ret = quotactl("/",Q_GETQUOTA,0,(char *) &D); + + return ret; +} + +#elif defined(HAVE_QUOTACTL_3) +/* int quotactl (char *spec, int request, char *arg); */ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_QUOTA_H +#include +#endif + + int autoconf_quota(void) +{ + int ret = -1; + struct q_request request; + + ret = quotactl("/", Q_GETQUOTA, &request); + + return ret; +} + +#elif defined(HAVE_QUOTACTL_2) + +#error HAVE_QUOTACTL_2 not implemented + +#else + +#error Unknow QUOTACTL prototype + +#endif + + int main(void) +{ + autoconf_quota(); + return 0; +} -- cgit From b75b755a2ba78ad323d6a87fdbee78b1829f864f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 12 Jan 2004 12:18:11 +0000 Subject: First stab at cracklib support (password quality checking) in Samba 3.0 This adds a configure test, that tries to find out if we have a working cracklib installation, and tries to pick up the debian hints on where the dictionary might be found. Default is per my Fedora Core 1 system - I'm not sure how much it changes. Andrew Bartlett (This used to be commit bc770edb788f0b6f719011cda683f045b76b7ba5) --- source3/tests/crack.c | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 source3/tests/crack.c (limited to 'source3/tests') diff --git a/source3/tests/crack.c b/source3/tests/crack.c new file mode 100644 index 0000000000..1342887852 --- /dev/null +++ b/source3/tests/crack.c @@ -0,0 +1,5 @@ + +int main(int argc, char **argv) { + FascistCheck("Foo", CRACKLIB_DICTPATH); + return 0; +} -- cgit From 0c0dfe4da56f52164da6e6633d2f8815d9d170fd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 14 Jan 2004 01:14:22 +0000 Subject: Finish adding cracklib support - this adds the configure test to enable it, on machines that actually have a working cracklib, for which we have the correct path to the dictionary. Andrew Bartlett (This used to be commit 17518018c0264d2a8e4afbc712a22ef4a1a00003) --- source3/tests/crack.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/crack.c b/source3/tests/crack.c index 1342887852..36119b3bbc 100644 --- a/source3/tests/crack.c +++ b/source3/tests/crack.c @@ -1,3 +1,10 @@ +#include + +#ifndef HAVE_CRACKLIB_DICTPATH +#ifndef CRACKLIB_DICTPATH +#define CRACKLIB_DICTPATH SAMBA_CRACKLIB_DICTPATH +#endif +#endif int main(int argc, char **argv) { FascistCheck("Foo", CRACKLIB_DICTPATH); -- cgit From 931df5850e326ad0639fe317e0ca82e6d820a68e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 5 Apr 2004 12:19:50 +0000 Subject: r39: * importing .cvsignore files * updateing WHATSNEW with vl's change (This used to be commit a7e2730ec4389e0c249886a8bfe1ee14c5abac41) --- source3/tests/.cvsignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 source3/tests/.cvsignore (limited to 'source3/tests') diff --git a/source3/tests/.cvsignore b/source3/tests/.cvsignore deleted file mode 100644 index b6c1f01120..0000000000 --- a/source3/tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -unixsock -- cgit From 335b10ef10f9825ad52501c77bc6b77cdad39067 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 19 Apr 2004 17:05:31 +0000 Subject: r283: removing --with-cracklib after discussion with abartklet @ sambaXP (This used to be commit df94b0471eb0628aa27f534134d60b62ed123688) --- source3/tests/crack.c | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 source3/tests/crack.c (limited to 'source3/tests') diff --git a/source3/tests/crack.c b/source3/tests/crack.c deleted file mode 100644 index 36119b3bbc..0000000000 --- a/source3/tests/crack.c +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#ifndef HAVE_CRACKLIB_DICTPATH -#ifndef CRACKLIB_DICTPATH -#define CRACKLIB_DICTPATH SAMBA_CRACKLIB_DICTPATH -#endif -#endif - -int main(int argc, char **argv) { - FascistCheck("Foo", CRACKLIB_DICTPATH); - return 0; -} -- cgit From 7a7f9ab847435bbd17012a9a04211c130f4ccb37 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 12 Apr 2005 21:56:34 +0000 Subject: r6319: add prototype so -Wstrict-prototypes will not fail (This used to be commit b92e8b1c82ff3aa497b614a01ebbca4fbc9d00c4) --- source3/tests/sysquotas.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/sysquotas.c b/source3/tests/sysquotas.c index 2aa643326c..48a34feb13 100644 --- a/source3/tests/sysquotas.c +++ b/source3/tests/sysquotas.c @@ -1,5 +1,7 @@ /* this test should find out what quota api is available on the os */ + int autoconf_quota(void); + #if defined(HAVE_QUOTACTL_4A) /* long quotactl(int cmd, char *special, qid_t id, caddr_t addr) */ -- cgit From 1c4bbe06549d86614318718a45b9bc48e3bfc81f Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Mon, 2 May 2005 17:49:43 +0000 Subject: r6586: get rid of a few more compiler warnings (This used to be commit 173375f8d88bf8e8db8d60e5d5f0e5dcc28767d9) --- source3/tests/shlib.c | 2 ++ source3/tests/sysquotas.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/shlib.c b/source3/tests/shlib.c index 761d9fd5c5..eddb76ff2a 100644 --- a/source3/tests/shlib.c +++ b/source3/tests/shlib.c @@ -1,5 +1,7 @@ /* a trivial function used to test building shared libraries */ +int foo(void); + int foo(void) { return 1; diff --git a/source3/tests/sysquotas.c b/source3/tests/sysquotas.c index 48a34feb13..bf16c8ba6e 100644 --- a/source3/tests/sysquotas.c +++ b/source3/tests/sysquotas.c @@ -28,6 +28,8 @@ #define SYS_DQBLK dqblk #endif + int autoconf_quota(void); + int autoconf_quota(void) { int ret = -1; -- cgit From 1d3fd5201c98417ba40bb367d92c3a924f947799 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 27 Mar 2006 19:50:45 +0000 Subject: r14746: Add the Samba4 replacements for opendir/readdir etc. to Samba3 - with some 64-bit macro madness. Attempt to fix the broken directory handling in the *BSD-of-the-month club. Jeremy. (This used to be commit fd98427f64f4206c01f16f82fadf24f5863878db) --- source3/tests/os2_delete.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 source3/tests/os2_delete.c (limited to 'source3/tests') diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c new file mode 100644 index 0000000000..831fa367eb --- /dev/null +++ b/source3/tests/os2_delete.c @@ -0,0 +1,107 @@ +/* + test readdir/unlink pattern that OS/2 uses + tridge@samba.org July 2005 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_FILES 700 +#define READDIR_SIZE 100 +#define DELETE_SIZE 4 + +#define TESTDIR "test.dir" + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files() +{ + int i; + for (i=0;id_name); + } + + if (i == 0) { + return 0; + } + + /* delete the first few */ + for (j=0; jd_name, ".") == 0 || FAILED("match ."); + de = readdir(d); + strcmp(de->d_name, "..") == 0 || FAILED("match .."); + + while (1) { + int n = os2_delete(d); + if (n == 0) break; + total_deleted += n; + } + closedir(d); + + printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return 0; +} -- cgit From 22dbd67708f1651a2341d70ce576fac360affccf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Apr 2006 15:33:04 +0000 Subject: r15018: Merge Volker's ipc/trans2/nttrans changes over into 3.0. Also merge the new POSIX lock code - this is not enabled unless -DDEVELOPER is defined. This doesn't yet map onto underlying system POSIX locks. Updates vfs to allow lock queries. Jeremy. (This used to be commit 08e52ead03304ff04229e1bfe544ff40e2564fc7) --- source3/tests/os2_delete.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'source3/tests') diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c index 831fa367eb..b3aaf67f41 100644 --- a/source3/tests/os2_delete.c +++ b/source3/tests/os2_delete.c @@ -105,3 +105,110 @@ int main(void) return 0; } +/* + test readdir/unlink pattern that OS/2 uses + tridge@samba.org July 2005 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_FILES 700 +#define READDIR_SIZE 100 +#define DELETE_SIZE 4 + +#define TESTDIR "test.dir" + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files() +{ + int i; + for (i=0;id_name); + } + + if (i == 0) { + return 0; + } + + /* delete the first few */ + for (j=0; jd_name, ".") == 0 || FAILED("match ."); + de = readdir(d); + strcmp(de->d_name, "..") == 0 || FAILED("match .."); + + while (1) { + int n = os2_delete(d); + if (n == 0) break; + total_deleted += n; + } + closedir(d); + + printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return 0; +} -- cgit From 760c7a6534c2c7cf8d35eddf7971940379f683c3 Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 28 Nov 2006 22:55:32 +0000 Subject: r19941: One copy of this code should be sufficient. (This used to be commit 493ba681e541292f1c2c6b6670bb2c48f63a0aa3) --- source3/tests/os2_delete.c | 107 --------------------------------------------- 1 file changed, 107 deletions(-) (limited to 'source3/tests') diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c index b3aaf67f41..831fa367eb 100644 --- a/source3/tests/os2_delete.c +++ b/source3/tests/os2_delete.c @@ -105,110 +105,3 @@ int main(void) return 0; } -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files() -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return 0; -} -- cgit From 82979331427c4004c15f4a247b17bf4271b3bca8 Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 20 Apr 2007 21:31:04 +0000 Subject: r22419: Update configure so that we only need one copy of os2_delete.c (This used to be commit e5dd3bbf29f206090d64134eb808e5f627317804) --- source3/tests/os2_delete.c | 107 --------------------------------------------- 1 file changed, 107 deletions(-) delete mode 100644 source3/tests/os2_delete.c (limited to 'source3/tests') diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c deleted file mode 100644 index 831fa367eb..0000000000 --- a/source3/tests/os2_delete.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files() -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return 0; -} -- cgit From 3a9a3ad8f9ead7ec963103f8ee0fe905f3982913 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 7 May 2007 03:02:24 +0000 Subject: r22731: - Fix bug #4594. configure.in determines if -Werror-implicit-function-declaration is available, and if so it enables that flag if --enable-developer is specified. Since the configure tests themselves did not use that flag, it was possible for a configure test to succeed, followed by a failed compilation due to a facility being available but not having a proper declaration in a header file. (This bit me with readahead().) This patch ensures that if implicit function declarations will kill the build, the feature being tested is deselected so the build will succeed. The autoconf manual suggests using return instead of exit in configure tests because the declaration for exit is often missing. We require this now, since we error if prototypes are missing. See section 5.5.1 of http://www.gnu.org/software/autoconf/manual/autoconf.html. This patch makes these changes, because in fact, an external declaration for exit is missing here (and likely elsewhere). I've verified that the features selected (here) with the original configure.in and the new one are the same except for, in my case, readahead. I've also confirmed that the generated Makefile is identical. These changes are not being applied to the 3.0.26 branch because it does not exhibit the initial problem this patch is supposed to solve since it doesn't attempt to use -Werror-implicit-function-declaration. (This used to be commit 4d42720915b8f65842147171f689127e94d1b973) --- source3/tests/crypttest.c | 6 +++--- source3/tests/fcntl_lock.c | 10 +++++----- source3/tests/fcntl_lock64.c | 12 ++++++++---- source3/tests/ftruncate.c | 4 ++-- source3/tests/getgroups.c | 14 +++++++++----- source3/tests/shared_mmap.c | 16 ++++++++-------- source3/tests/summary.c | 1 + source3/tests/trivial.c | 1 + source3/tests/unixsock.c | 21 ++++++++++++--------- 9 files changed, 49 insertions(+), 36 deletions(-) (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index efee2e593d..8bed1c74d1 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -814,7 +814,7 @@ main() if((strcmp(c_out1, expected_out) != 0) && (strcmp(c_out2, expected_out) == 0)) - exit(1); + return 1; #ifdef HAVE_BIGCRYPT /* @@ -843,10 +843,10 @@ main() if((strcmp(big_c_out1, big_expected_out) != 0) && (strcmp(big_c_out2, big_expected_out) == 0)) - exit(1); + return 1; } #endif - exit(0); + return 0; } diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 3dc12a3897..728f94b612 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - exit(1); + return 1; } lock.l_type = F_WRLCK; @@ -74,9 +74,9 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno); - exit(1); + return 1; } else { - exit(0); + return 0; } } @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - exit(1); + return 1; } lock.l_type = F_WRLCK; @@ -117,5 +117,5 @@ int main(int argc, char *argv[]) status); } - exit(status); + return status; } diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c index e5ecd88fd0..b218fa9282 100644 --- a/source3/tests/fcntl_lock64.c +++ b/source3/tests/fcntl_lock64.c @@ -16,6 +16,10 @@ #include #endif +#ifdef HAVE_SYS_WAIT_H +#include +#endif + #include static int sys_waitpid(pid_t pid,int *status,int options) @@ -40,7 +44,7 @@ int main(int argc, char *argv[]) sleep(2); fd = open64(DATA, O_RDONLY); - if (fd == -1) exit(1); + if (fd == -1) return 1; lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; @@ -56,10 +60,10 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { /* printf("No lock conflict\n"); */ - exit(1); + return 1; } else { /* printf("lock conflict\n"); */ - exit(0); + return 0; } } @@ -92,5 +96,5 @@ int main(int argc, char *argv[]) unlink(DATA); - exit(status); + return status; } diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c index 93282782ee..700d5c8ce5 100644 --- a/source3/tests/ftruncate.c +++ b/source3/tests/ftruncate.c @@ -21,7 +21,7 @@ main() unlink(DATA); if (lseek(fd, 0, SEEK_END) == LEN) { - exit(0); + return 0; } - exit(1); + return 1; } diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c index 343fd5a184..c73cd21650 100644 --- a/source3/tests/getgroups.c +++ b/source3/tests/getgroups.c @@ -11,6 +11,10 @@ #include #endif +#if defined(HAVE_STDLIB_H) +#include +#endif + #include #include #include @@ -26,7 +30,7 @@ main() if (sizeof(gid_t) == sizeof(int)) { fprintf(stderr,"gid_t and int are the same size\n"); - exit(1); + return 1; } if (ngroups <= 0) @@ -44,7 +48,7 @@ main() if (ngroups == 0) { printf("WARNING: can't determine getgroups return type\n"); - exit(1); + return 1; } cgroups = (char *)igroups; @@ -52,15 +56,15 @@ main() if (ngroups == 1 && cgroups[2] == 0x42 && cgroups[3] == 0x42) { fprintf(stderr,"getgroups returns gid_t\n"); - exit(1); + return 1; } for (i=0;i 0) exit(0); - exit(1); + if (count > 0) return 0; + return 1; } diff --git a/source3/tests/summary.c b/source3/tests/summary.c index 79a530b013..735f93e116 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -1,3 +1,4 @@ +#include #include main() diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c index 2723637a0f..ae368a1398 100644 --- a/source3/tests/trivial.c +++ b/source3/tests/trivial.c @@ -1,3 +1,4 @@ +#include main() { exit(0); diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c index f2765d68f6..ba384ae362 100644 --- a/source3/tests/unixsock.c +++ b/source3/tests/unixsock.c @@ -1,4 +1,5 @@ -/* -*- c-file-style: "linux" -*- +/* + * -*- 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. @@ -8,15 +9,17 @@ * 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 , June 2000. */ + * Martin Pool , June 2000. + */ /* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ #include +#if defined(HAVE_UNISTD_H) +#include +#endif + #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -48,7 +51,7 @@ static int bind_socket(char const *filename) /* Create the socket. */ if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { perror ("socket(PF_LOCAL, SOCK_STREAM)"); - exit(1); + return 1; } /* Bind a name to the socket. */ @@ -67,7 +70,7 @@ static int bind_socket(char const *filename) if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) { perror ("bind"); - exit(1); + return 1; } return sock_fd; @@ -84,10 +87,10 @@ int main(void) alarm(15); /* secs */ if ((sock_fd = bind_socket(filename)) < 0) - exit(1); + return 1; /* the socket will be deleted when autoconf cleans up these files. */ - exit(0); + return 0; } -- cgit From b1ce226af8b61ad7e3c37860a59c6715012e738b Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 15 Jun 2007 21:58:49 +0000 Subject: r23510: Tidy calls to smb_panic by removing trailing newlines. Print the failed expression in SMB_ASSERT. (This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713) --- source3/tests/summary.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/tests') diff --git a/source3/tests/summary.c b/source3/tests/summary.c index 735f93e116..c3da22f170 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -3,6 +3,7 @@ main() { + exit (0); #if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64)) printf("ERROR: No locking available. Running Samba would be unsafe\n"); exit(1); -- cgit From fbfaaa99937f97b3f1fd2e4fb4ce8ee6b4335f7f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit c14aba93c06348a1f84fc1dd9791ff1159d22c4b) --- source3/tests/crypttest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index 8bed1c74d1..3f9a649027 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -40,7 +40,7 @@ * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * 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 -- cgit From 28b9d61076912adbc0c6571c71688aa6831506bf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 04:04:46 +0000 Subject: r23800: LGPL is now called GNU Lesser General Public License not GNU Library General Public License (This used to be commit 727a6cf2cba8da6b40610409b264e86e6908eb0c) --- source3/tests/crypttest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index 3f9a649027..52d8155092 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -38,7 +38,7 @@ * 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 Library General Public + * 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. * @@ -47,7 +47,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * - * You should have received a copy of the GNU Library General Public + * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/tests/crypttest.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index 52d8155092..ee5a23235e 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -48,8 +48,7 @@ * 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, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . * * @(#)crypt_util.c 2.31 02/08/92 * -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/tests/crypttest.c | 6 +- source3/tests/fcntl_lock.c | 10 +- source3/tests/fcntl_lock64.c | 12 +-- source3/tests/ftruncate.c | 4 +- source3/tests/getgroups.c | 14 +-- source3/tests/os2_delete.c | 214 +++++++++++++++++++++++++++++++++++++++++++ source3/tests/shared_mmap.c | 16 ++-- source3/tests/summary.c | 1 - source3/tests/trivial.c | 1 - source3/tests/unixsock.c | 21 ++--- 10 files changed, 250 insertions(+), 49 deletions(-) create mode 100644 source3/tests/os2_delete.c (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index ee5a23235e..0e500d5481 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -813,7 +813,7 @@ main() if((strcmp(c_out1, expected_out) != 0) && (strcmp(c_out2, expected_out) == 0)) - return 1; + exit(1); #ifdef HAVE_BIGCRYPT /* @@ -842,10 +842,10 @@ main() if((strcmp(big_c_out1, big_expected_out) != 0) && (strcmp(big_c_out2, big_expected_out) == 0)) - return 1; + exit(1); } #endif - return 0; + exit(0); } diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 728f94b612..3dc12a3897 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - return 1; + exit(1); } lock.l_type = F_WRLCK; @@ -74,9 +74,9 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno); - return 1; + exit(1); } else { - return 0; + exit(0); } } @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - return 1; + exit(1); } lock.l_type = F_WRLCK; @@ -117,5 +117,5 @@ int main(int argc, char *argv[]) status); } - return status; + exit(status); } diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c index b218fa9282..e5ecd88fd0 100644 --- a/source3/tests/fcntl_lock64.c +++ b/source3/tests/fcntl_lock64.c @@ -16,10 +16,6 @@ #include #endif -#ifdef HAVE_SYS_WAIT_H -#include -#endif - #include static int sys_waitpid(pid_t pid,int *status,int options) @@ -44,7 +40,7 @@ int main(int argc, char *argv[]) sleep(2); fd = open64(DATA, O_RDONLY); - if (fd == -1) return 1; + if (fd == -1) exit(1); lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; @@ -60,10 +56,10 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { /* printf("No lock conflict\n"); */ - return 1; + exit(1); } else { /* printf("lock conflict\n"); */ - return 0; + exit(0); } } @@ -96,5 +92,5 @@ int main(int argc, char *argv[]) unlink(DATA); - return status; + exit(status); } diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c index 700d5c8ce5..93282782ee 100644 --- a/source3/tests/ftruncate.c +++ b/source3/tests/ftruncate.c @@ -21,7 +21,7 @@ main() unlink(DATA); if (lseek(fd, 0, SEEK_END) == LEN) { - return 0; + exit(0); } - return 1; + exit(1); } diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c index c73cd21650..343fd5a184 100644 --- a/source3/tests/getgroups.c +++ b/source3/tests/getgroups.c @@ -11,10 +11,6 @@ #include #endif -#if defined(HAVE_STDLIB_H) -#include -#endif - #include #include #include @@ -30,7 +26,7 @@ main() if (sizeof(gid_t) == sizeof(int)) { fprintf(stderr,"gid_t and int are the same size\n"); - return 1; + exit(1); } if (ngroups <= 0) @@ -48,7 +44,7 @@ main() if (ngroups == 0) { printf("WARNING: can't determine getgroups return type\n"); - return 1; + exit(1); } cgroups = (char *)igroups; @@ -56,15 +52,15 @@ main() if (ngroups == 1 && cgroups[2] == 0x42 && cgroups[3] == 0x42) { fprintf(stderr,"getgroups returns gid_t\n"); - return 1; + exit(1); } for (i=0;i +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_FILES 700 +#define READDIR_SIZE 100 +#define DELETE_SIZE 4 + +#define TESTDIR "test.dir" + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files() +{ + int i; + for (i=0;id_name); + } + + if (i == 0) { + return 0; + } + + /* delete the first few */ + for (j=0; jd_name, ".") == 0 || FAILED("match ."); + de = readdir(d); + strcmp(de->d_name, "..") == 0 || FAILED("match .."); + + while (1) { + int n = os2_delete(d); + if (n == 0) break; + total_deleted += n; + } + closedir(d); + + printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return 0; +} +/* + test readdir/unlink pattern that OS/2 uses + tridge@samba.org July 2005 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NUM_FILES 700 +#define READDIR_SIZE 100 +#define DELETE_SIZE 4 + +#define TESTDIR "test.dir" + +#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) + +#ifndef MIN +#define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +static void cleanup(void) +{ + /* I'm a lazy bastard */ + system("rm -rf " TESTDIR); + mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); +} + +static void create_files() +{ + int i; + for (i=0;id_name); + } + + if (i == 0) { + return 0; + } + + /* delete the first few */ + for (j=0; jd_name, ".") == 0 || FAILED("match ."); + de = readdir(d); + strcmp(de->d_name, "..") == 0 || FAILED("match .."); + + while (1) { + int n = os2_delete(d); + if (n == 0) break; + total_deleted += n; + } + closedir(d); + + printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); + + rmdir(TESTDIR) == 0 || FAILED("rmdir"); + + return 0; +} diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c index 6af9ba0b39..fcef75d0d6 100644 --- a/source3/tests/shared_mmap.c +++ b/source3/tests/shared_mmap.c @@ -22,7 +22,7 @@ main() int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); int count=7; - if (fd == -1) return 1; + if (fd == -1) exit(1); for (i=0;i<10000;i++) { write(fd,&i,sizeof(i)); @@ -32,7 +32,7 @@ main() if (fork() == 0) { fd = open(DATA,O_RDWR); - if (fd == -1) return 1; + if (fd == -1) exit(1); buf = (int *)mmap(NULL, 10000*sizeof(int), (PROT_READ | PROT_WRITE), @@ -41,21 +41,21 @@ main() while (count-- && buf[9124] != 55732) sleep(1); - if (count <= 0) return 1; + if (count <= 0) exit(1); buf[1763] = 7268; - return 0; + exit(0); } fd = open(DATA,O_RDWR); - if (fd == -1) return 1; + if (fd == -1) exit(1); buf = (int *)mmap(NULL, 10000*sizeof(int), (PROT_READ | PROT_WRITE), MAP_FILE | MAP_SHARED, fd, 0); - if (buf == (int *)-1) return 1; + if (buf == (int *)-1) exit(1); buf[9124] = 55732; @@ -63,6 +63,6 @@ main() unlink(DATA); - if (count > 0) return 0; - return 1; + if (count > 0) exit(0); + exit(1); } diff --git a/source3/tests/summary.c b/source3/tests/summary.c index c3da22f170..8fcde7bd99 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -1,4 +1,3 @@ -#include #include main() diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c index ae368a1398..2723637a0f 100644 --- a/source3/tests/trivial.c +++ b/source3/tests/trivial.c @@ -1,4 +1,3 @@ -#include main() { exit(0); diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c index ba384ae362..f2765d68f6 100644 --- a/source3/tests/unixsock.c +++ b/source3/tests/unixsock.c @@ -1,5 +1,4 @@ -/* - * -*- c-file-style: "linux" -*- +/* -*- 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. @@ -9,17 +8,15 @@ * on which they are broken under some conditions, such as RedHat 7.0 * (unpatched). We can't build WinBind there at the moment. * - * Martin Pool , June 2000. - */ + * Coding standard says to always use exit() for this, not return, so + * we do. + * + * Martin Pool , June 2000. */ /* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ #include -#if defined(HAVE_UNISTD_H) -#include -#endif - #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -51,7 +48,7 @@ static int bind_socket(char const *filename) /* Create the socket. */ if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { perror ("socket(PF_LOCAL, SOCK_STREAM)"); - return 1; + exit(1); } /* Bind a name to the socket. */ @@ -70,7 +67,7 @@ static int bind_socket(char const *filename) if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) { perror ("bind"); - return 1; + exit(1); } return sock_fd; @@ -87,10 +84,10 @@ int main(void) alarm(15); /* secs */ if ((sock_fd = bind_socket(filename)) < 0) - return 1; + exit(1); /* the socket will be deleted when autoconf cleans up these files. */ - return 0; + exit(0); } -- cgit From 48302a28a90190572c5e9a6a54a539d883e89f6b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 21 Feb 2008 00:11:03 +0100 Subject: Remove mmap check from configure.in It is available in libreplace. Michael (This used to be commit 310c121faf5effeca9ab0df3591c486dd4982749) --- source3/tests/shared_mmap.c | 68 --------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 source3/tests/shared_mmap.c (limited to 'source3/tests') diff --git a/source3/tests/shared_mmap.c b/source3/tests/shared_mmap.c deleted file mode 100644 index fcef75d0d6..0000000000 --- a/source3/tests/shared_mmap.c +++ /dev/null @@ -1,68 +0,0 @@ -/* this tests whether we can use a shared writeable mmap on a file - - as needed for the mmap varient of FAST_SHARE_MODES */ - -#if defined(HAVE_UNISTD_H) -#include -#endif -#include -#include -#include -#include - -#define DATA "conftest.mmap" - -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif - -main() -{ - int *buf; - int i; - int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666); - int count=7; - - if (fd == -1) exit(1); - - for (i=0;i<10000;i++) { - write(fd,&i,sizeof(i)); - } - - close(fd); - - if (fork() == 0) { - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - while (count-- && buf[9124] != 55732) sleep(1); - - if (count <= 0) exit(1); - - buf[1763] = 7268; - exit(0); - } - - fd = open(DATA,O_RDWR); - if (fd == -1) exit(1); - - buf = (int *)mmap(NULL, 10000*sizeof(int), - (PROT_READ | PROT_WRITE), - MAP_FILE | MAP_SHARED, - fd, 0); - - if (buf == (int *)-1) exit(1); - - buf[9124] = 55732; - - while (count-- && buf[1763] != 7268) sleep(1); - - unlink(DATA); - - if (count > 0) exit(0); - exit(1); -} -- cgit From 8657066f3ad942f5596ef14e0f071b8dbfcd5554 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Feb 2008 09:25:18 +0100 Subject: configure: Remove lib/repdir.c and related stuff It was only used in configure, but lib/replace already has a much better version of it. metze (This used to be commit c9b60b75b4763c37cfa63741b4f055e4ea488e92) --- source3/tests/os2_delete.c | 214 --------------------------------------------- 1 file changed, 214 deletions(-) delete mode 100644 source3/tests/os2_delete.c (limited to 'source3/tests') diff --git a/source3/tests/os2_delete.c b/source3/tests/os2_delete.c deleted file mode 100644 index b3aaf67f41..0000000000 --- a/source3/tests/os2_delete.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files() -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return 0; -} -/* - test readdir/unlink pattern that OS/2 uses - tridge@samba.org July 2005 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_FILES 700 -#define READDIR_SIZE 100 -#define DELETE_SIZE 4 - -#define TESTDIR "test.dir" - -#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), exit(1), 1) - -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - -static void cleanup(void) -{ - /* I'm a lazy bastard */ - system("rm -rf " TESTDIR); - mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir"); -} - -static void create_files() -{ - int i; - for (i=0;id_name); - } - - if (i == 0) { - return 0; - } - - /* delete the first few */ - for (j=0; jd_name, ".") == 0 || FAILED("match ."); - de = readdir(d); - strcmp(de->d_name, "..") == 0 || FAILED("match .."); - - while (1) { - int n = os2_delete(d); - if (n == 0) break; - total_deleted += n; - } - closedir(d); - - printf("Deleted %d files of %d\n", total_deleted, NUM_FILES); - - rmdir(TESTDIR) == 0 || FAILED("rmdir"); - - return 0; -} -- cgit From ab90fc9a5636b166652cd5b653c58ffe576e00e2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 May 2008 12:16:05 +0200 Subject: configure: remove unused configure check for HAVE_WORKING_AF_LOCAL metze (This used to be commit dddc4f0cef8ea71783fa7f7b68ec9ad3f29f7add) --- source3/tests/unixsock.c | 93 ------------------------------------------------ 1 file changed, 93 deletions(-) delete mode 100644 source3/tests/unixsock.c (limited to 'source3/tests') diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c deleted file mode 100644 index f2765d68f6..0000000000 --- a/source3/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 , June 2000. */ - -/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ - -#include - -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - -#ifdef HAVE_SYS_UN_H -# include -#endif - -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#if HAVE_SYS_WAIT_H -# include -#endif - -#if HAVE_ERRNO_DECL -# include -#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); -} -- cgit