summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorCVS Import User <samba-bugs@samba.org>2004-04-04 09:21:52 +0000
committerCVS Import User <samba-bugs@samba.org>2004-04-04 09:21:52 +0000
commit9f765b7406282904ce56f2535dcd929a9aefc5ca (patch)
treedbdff78b624ac7c1afcb8851f395df3d99eb1f84 /testsuite
parent111b4e05ab96eafc4212f38dc5977538907187c7 (diff)
downloadsamba-9f765b7406282904ce56f2535dcd929a9aefc5ca.tar.gz
samba-9f765b7406282904ce56f2535dcd929a9aefc5ca.tar.xz
samba-9f765b7406282904ce56f2535dcd929a9aefc5ca.zip
r2: import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
metze
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/README19
-rwxr-xr-xtestsuite/build_farm/backtrace15
-rw-r--r--testsuite/build_farm/basicsmb-domainsec-nt4.test28
-rw-r--r--testsuite/build_farm/basicsmb-domainsec.test27
-rw-r--r--testsuite/build_farm/basicsmb-hostsdeny.test18
-rw-r--r--testsuite/build_farm/basicsmb-hostsequiv.test26
-rw-r--r--testsuite/build_farm/basicsmb-invalidusers.test10
-rw-r--r--testsuite/build_farm/basicsmb-local-pass-change.test10
-rw-r--r--testsuite/build_farm/basicsmb-preexec.test28
-rw-r--r--testsuite/build_farm/basicsmb-remote-pass-change.test10
-rw-r--r--testsuite/build_farm/basicsmb-serversec.test9
-rw-r--r--testsuite/build_farm/basicsmb-shareguest.test20
-rw-r--r--testsuite/build_farm/basicsmb-sharelist.test22
-rw-r--r--testsuite/build_farm/basicsmb-sharesec.test9
-rw-r--r--testsuite/build_farm/basicsmb-usersec.test9
-rw-r--r--testsuite/build_farm/basicsmb.fns204
-rw-r--r--testsuite/build_farm/runlist18
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf49
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.domain2
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.hostsdeny1
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.hostsequiv3
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.invalidusers1
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.preexec1
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.preexec_cl_fl2
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.preexec_close2
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.server3
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.share1
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.user1
-rw-r--r--testsuite/build_farm/template/basicsmb.smb.conf.validusers1
-rw-r--r--testsuite/build_farm/template/preexec3
-rw-r--r--testsuite/build_farm/torture-ATTR.test2
-rw-r--r--testsuite/build_farm/torture-BROWSE.test2
-rw-r--r--testsuite/build_farm/torture-DELETE.test2
-rw-r--r--testsuite/build_farm/torture-DENY1.test2
-rw-r--r--testsuite/build_farm/torture-DENY2.test2
-rw-r--r--testsuite/build_farm/torture-DIR.test2
-rw-r--r--testsuite/build_farm/torture-DIR1.test2
-rw-r--r--testsuite/build_farm/torture-FDPASS.test2
-rw-r--r--testsuite/build_farm/torture-FDSESS.test2
-rw-r--r--testsuite/build_farm/torture-LOCK1.test2
-rw-r--r--testsuite/build_farm/torture-LOCK2.test2
-rw-r--r--testsuite/build_farm/torture-LOCK3.test2
-rw-r--r--testsuite/build_farm/torture-LOCK4.test2
-rw-r--r--testsuite/build_farm/torture-LOCK5.test2
-rw-r--r--testsuite/build_farm/torture-LOCK6.test2
-rw-r--r--testsuite/build_farm/torture-LOCK7.test2
-rw-r--r--testsuite/build_farm/torture-MANGLE.test2
-rw-r--r--testsuite/build_farm/torture-OPEN.test2
-rw-r--r--testsuite/build_farm/torture-OPLOCK1.test2
-rw-r--r--testsuite/build_farm/torture-OPLOCK3.test2
-rw-r--r--testsuite/build_farm/torture-PROPERTIES.test2
-rw-r--r--testsuite/build_farm/torture-RANDOMIPC.test2
-rw-r--r--testsuite/build_farm/torture-RENAME.test2
-rw-r--r--testsuite/build_farm/torture-RW1.test2
-rw-r--r--testsuite/build_farm/torture-RW2.test2
-rw-r--r--testsuite/build_farm/torture-TCON.test2
-rw-r--r--testsuite/build_farm/torture-TCON1.test2
-rw-r--r--testsuite/build_farm/torture-TCON2.test2
-rw-r--r--testsuite/build_farm/torture-TCONDEV.test2
-rw-r--r--testsuite/build_farm/torture-TORTURE.test2
-rw-r--r--testsuite/build_farm/torture-TRANS2.test2
-rw-r--r--testsuite/build_farm/torture-UNLINK.test2
-rw-r--r--testsuite/build_farm/torture-XCOPY.test2
-rw-r--r--testsuite/build_farm/torture_setup.fns19
-rw-r--r--testsuite/config/unix.exp27
-rw-r--r--testsuite/lib/compile.exp79
-rw-r--r--testsuite/lib/default-nt-names.exp20
-rw-r--r--testsuite/lib/env-single.exp36
-rw-r--r--testsuite/lib/nsswitch-config.exp21
-rw-r--r--testsuite/lib/smbclient.exp54
-rw-r--r--testsuite/libsmbclient/src/.cvsignore1
-rw-r--r--testsuite/libsmbclient/src/Makefile817
-rw-r--r--testsuite/libsmbclient/src/chmod/chmod_1.c59
-rw-r--r--testsuite/libsmbclient/src/chown/chown_1.c59
-rw-r--r--testsuite/libsmbclient/src/close/close_1.c59
-rw-r--r--testsuite/libsmbclient/src/close/close_2.c57
-rw-r--r--testsuite/libsmbclient/src/closedir/closedir_1.c65
-rw-r--r--testsuite/libsmbclient/src/closedir/closedir_2.c61
-rw-r--r--testsuite/libsmbclient/src/closedir/closedir_3.c63
-rw-r--r--testsuite/libsmbclient/src/closedir/closedir_4.c59
-rw-r--r--testsuite/libsmbclient/src/creat/creat_1.c60
-rw-r--r--testsuite/libsmbclient/src/creat/creat_2.c63
-rw-r--r--testsuite/libsmbclient/src/creat/creat_3.c56
-rw-r--r--testsuite/libsmbclient/src/fstat/fstat_1.c62
-rw-r--r--testsuite/libsmbclient/src/fstat/fstat_2.c58
-rw-r--r--testsuite/libsmbclient/src/fstat/fstat_3.c69
-rw-r--r--testsuite/libsmbclient/src/fstat/fstat_4.c69
-rw-r--r--testsuite/libsmbclient/src/fstat/fstat_5.c77
-rw-r--r--testsuite/libsmbclient/src/fstat/fstat_6.c80
-rw-r--r--testsuite/libsmbclient/src/getdents/getdents_1.c72
-rw-r--r--testsuite/libsmbclient/src/getdents/getdents_2.c67
-rw-r--r--testsuite/libsmbclient/src/getdents/getdents_3.c155
-rw-r--r--testsuite/libsmbclient/src/getdents/getdents_4.c101
-rw-r--r--testsuite/libsmbclient/src/getdents/getdents_5.c106
-rw-r--r--testsuite/libsmbclient/src/init/init_1.c18
-rw-r--r--testsuite/libsmbclient/src/init/init_2.c23
-rw-r--r--testsuite/libsmbclient/src/init/init_3.c58
-rw-r--r--testsuite/libsmbclient/src/init/init_4.c18
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_1.c109
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_2.c105
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_3.c103
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_4.c99
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_5.c101
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_6.c110
-rw-r--r--testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_7.c106
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_1.c61
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_2.c57
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_3.c80
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_4.c80
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_5.c80
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_6.c75
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_7.c80
-rw-r--r--testsuite/libsmbclient/src/lseek/lseek_8.c75
-rw-r--r--testsuite/libsmbclient/src/lseekdir/lseekdir_1.c102
-rw-r--r--testsuite/libsmbclient/src/lseekdir/lseekdir_2.c95
-rw-r--r--testsuite/libsmbclient/src/lseekdir/lseekdir_3.c67
-rw-r--r--testsuite/libsmbclient/src/lseekdir/lseekdir_4.c61
-rw-r--r--testsuite/libsmbclient/src/lseekdir/lseekdir_5.c119
-rw-r--r--testsuite/libsmbclient/src/lseekdir/lseekdir_6.c124
-rw-r--r--testsuite/libsmbclient/src/mkdir/mkdir_1.c60
-rw-r--r--testsuite/libsmbclient/src/mkdir/mkdir_2.c56
-rw-r--r--testsuite/libsmbclient/src/mkdir/mkdir_3.c58
-rw-r--r--testsuite/libsmbclient/src/mkdir/mkdir_4.c62
-rw-r--r--testsuite/libsmbclient/src/open/open_1.c60
-rw-r--r--testsuite/libsmbclient/src/open/open_2.c56
-rw-r--r--testsuite/libsmbclient/src/open/open_3.c60
-rw-r--r--testsuite/libsmbclient/src/open/open_4.c63
-rw-r--r--testsuite/libsmbclient/src/open/open_5.c58
-rw-r--r--testsuite/libsmbclient/src/open_print_job/open_print_job_1.c60
-rw-r--r--testsuite/libsmbclient/src/open_print_job/open_print_job_2.c56
-rw-r--r--testsuite/libsmbclient/src/opendir/opendir_1.c62
-rw-r--r--testsuite/libsmbclient/src/opendir/opendir_2.c55
-rw-r--r--testsuite/libsmbclient/src/opendir/opendir_3.c65
-rw-r--r--testsuite/libsmbclient/src/opendir/opendir_4.c61
-rw-r--r--testsuite/libsmbclient/src/print_file/print_file_1.c76
-rw-r--r--testsuite/libsmbclient/src/print_file/print_file_2.c72
-rw-r--r--testsuite/libsmbclient/src/print_file/print_file_3.c59
-rw-r--r--testsuite/libsmbclient/src/print_file/print_file_4.c55
-rw-r--r--testsuite/libsmbclient/src/read/read_1.c83
-rw-r--r--testsuite/libsmbclient/src/read/read_10.c68
-rw-r--r--testsuite/libsmbclient/src/read/read_11.c83
-rw-r--r--testsuite/libsmbclient/src/read/read_12.c87
-rw-r--r--testsuite/libsmbclient/src/read/read_13.c91
-rw-r--r--testsuite/libsmbclient/src/read/read_2.c76
-rw-r--r--testsuite/libsmbclient/src/read/read_3.c83
-rw-r--r--testsuite/libsmbclient/src/read/read_4.c77
-rw-r--r--testsuite/libsmbclient/src/read/read_5.c83
-rw-r--r--testsuite/libsmbclient/src/read/read_6.c77
-rw-r--r--testsuite/libsmbclient/src/read/read_7.c60
-rw-r--r--testsuite/libsmbclient/src/read/read_8.c56
-rw-r--r--testsuite/libsmbclient/src/read/read_9.c70
-rw-r--r--testsuite/libsmbclient/src/readdir/readdir_1.c107
-rw-r--r--testsuite/libsmbclient/src/readdir/readdir_2.c102
-rw-r--r--testsuite/libsmbclient/src/readdir/readdir_3.c71
-rw-r--r--testsuite/libsmbclient/src/readdir/readdir_4.c67
-rw-r--r--testsuite/libsmbclient/src/readdir/readdir_5.c155
-rw-r--r--testsuite/libsmbclient/src/rename/rename_1.c57
-rw-r--r--testsuite/libsmbclient/src/rename/rename_10.c64
-rw-r--r--testsuite/libsmbclient/src/rename/rename_11.c63
-rw-r--r--testsuite/libsmbclient/src/rename/rename_12.c58
-rw-r--r--testsuite/libsmbclient/src/rename/rename_13.c63
-rw-r--r--testsuite/libsmbclient/src/rename/rename_14.c58
-rw-r--r--testsuite/libsmbclient/src/rename/rename_2.c54
-rw-r--r--testsuite/libsmbclient/src/rename/rename_3.c56
-rw-r--r--testsuite/libsmbclient/src/rename/rename_4.c55
-rw-r--r--testsuite/libsmbclient/src/rename/rename_5.c59
-rw-r--r--testsuite/libsmbclient/src/rename/rename_6.c57
-rw-r--r--testsuite/libsmbclient/src/rename/rename_7.c66
-rw-r--r--testsuite/libsmbclient/src/rename/rename_8.c68
-rw-r--r--testsuite/libsmbclient/src/rename/rename_9.c68
-rw-r--r--testsuite/libsmbclient/src/rmdir/rmdir_1.c59
-rw-r--r--testsuite/libsmbclient/src/rmdir/rmdir_2.c55
-rw-r--r--testsuite/libsmbclient/src/rmdir/rmdir_3.c61
-rw-r--r--testsuite/libsmbclient/src/rmdir/rmdir_4.c57
-rw-r--r--testsuite/libsmbclient/src/rmdir/rmdir_5.c63
-rw-r--r--testsuite/libsmbclient/src/rmdir/rmdir_6.c59
-rw-r--r--testsuite/libsmbclient/src/stat/stat_1.c62
-rw-r--r--testsuite/libsmbclient/src/stat/stat_2.c58
-rw-r--r--testsuite/libsmbclient/src/stat/stat_3.c66
-rw-r--r--testsuite/libsmbclient/src/stat/stat_4.c62
-rw-r--r--testsuite/libsmbclient/src/stat/stat_5.c77
-rw-r--r--testsuite/libsmbclient/src/stat/stat_6.c80
-rw-r--r--testsuite/libsmbclient/src/telldir/telldir_1.c102
-rw-r--r--testsuite/libsmbclient/src/telldir/telldir_2.c95
-rw-r--r--testsuite/libsmbclient/src/telldir/telldir_3.c67
-rw-r--r--testsuite/libsmbclient/src/telldir/telldir_4.c61
-rw-r--r--testsuite/libsmbclient/src/telldir/telldir_5.c122
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_1.c61
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_10.c62
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_11.c66
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_12.c65
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_2.c61
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_3.c57
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_4.c64
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_5.c62
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_6.c58
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_7.c62
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_8.c55
-rw-r--r--testsuite/libsmbclient/src/unlink/unlink_9.c57
-rw-r--r--testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_1.c107
-rw-r--r--testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_2.c102
-rw-r--r--testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_3.c106
-rw-r--r--testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_4.c101
-rw-r--r--testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_5.c141
-rw-r--r--testsuite/libsmbclient/src/write/write_1.c77
-rw-r--r--testsuite/libsmbclient/src/write/write_10.c70
-rw-r--r--testsuite/libsmbclient/src/write/write_11.c83
-rw-r--r--testsuite/libsmbclient/src/write/write_12.c83
-rw-r--r--testsuite/libsmbclient/src/write/write_13.c87
-rw-r--r--testsuite/libsmbclient/src/write/write_2.c71
-rw-r--r--testsuite/libsmbclient/src/write/write_3.c79
-rw-r--r--testsuite/libsmbclient/src/write/write_4.c74
-rw-r--r--testsuite/libsmbclient/src/write/write_5.c79
-rw-r--r--testsuite/libsmbclient/src/write/write_6.c74
-rw-r--r--testsuite/libsmbclient/src/write/write_7.c60
-rw-r--r--testsuite/libsmbclient/src/write/write_8.c56
-rw-r--r--testsuite/libsmbclient/src/write/write_9.c72
-rw-r--r--testsuite/nsswitch/.cvsignore12
-rw-r--r--testsuite/nsswitch/Makefile.longarg5
-rw-r--r--testsuite/nsswitch/bigfd.c38
-rw-r--r--testsuite/nsswitch/bigfd.exp28
-rw-r--r--testsuite/nsswitch/domusers.exp38
-rw-r--r--testsuite/nsswitch/envvar.exp282
-rw-r--r--testsuite/nsswitch/finger.exp39
-rw-r--r--testsuite/nsswitch/getent.c151
-rw-r--r--testsuite/nsswitch/getent.exp148
-rw-r--r--testsuite/nsswitch/getent_grent.c101
-rw-r--r--testsuite/nsswitch/getent_pwent.c113
-rwxr-xr-xtestsuite/nsswitch/getent_r.sh35
-rw-r--r--testsuite/nsswitch/getgrent_r.c84
-rw-r--r--testsuite/nsswitch/getgrent_r.exp41
-rw-r--r--testsuite/nsswitch/getgrgid.c57
-rw-r--r--testsuite/nsswitch/getgrgid.exp50
-rw-r--r--testsuite/nsswitch/getgrnam.c51
-rw-r--r--testsuite/nsswitch/getgrnam.exp28
-rw-r--r--testsuite/nsswitch/getpwent_r.c85
-rw-r--r--testsuite/nsswitch/getpwent_r.exp41
-rw-r--r--testsuite/nsswitch/getpwnam.c37
-rw-r--r--testsuite/nsswitch/getpwnam.exp28
-rw-r--r--testsuite/nsswitch/getpwuid.c43
-rw-r--r--testsuite/nsswitch/getpwuid.exp59
-rw-r--r--testsuite/nsswitch/groupmem_dom.exp33
-rw-r--r--testsuite/nsswitch/initgroups.c42
-rw-r--r--testsuite/nsswitch/initgroups.exp37
-rw-r--r--testsuite/nsswitch/login.exp102
-rw-r--r--testsuite/nsswitch/longarg.exp29
-rw-r--r--testsuite/nsswitch/longarg_getgrnam.c42
-rw-r--r--testsuite/nsswitch/longarg_getpwnam.c42
-rw-r--r--testsuite/nsswitch/longarg_utils.h27
-rw-r--r--testsuite/nsswitch/nss_winbind_syms.c63
-rw-r--r--testsuite/nsswitch/nss_winbind_syms.exp42
-rw-r--r--testsuite/nsswitch/pam_winbind_syms.c55
-rw-r--r--testsuite/nsswitch/pam_winbind_syms.exp44
-rw-r--r--testsuite/nsswitch/wbinfo.exp360
-rw-r--r--testsuite/printing/.cvsignore2
-rw-r--r--testsuite/printing/Makefile.psec22
-rw-r--r--testsuite/printing/Makefile.vlp14
-rw-r--r--testsuite/printing/README.vlp35
-rw-r--r--testsuite/printing/psec.c436
-rw-r--r--testsuite/printing/vlp.c426
-rw-r--r--testsuite/server/ipc.exp44
-rw-r--r--testsuite/server/masktest.exp57
-rw-r--r--testsuite/server/rename.exp59
-rw-r--r--testsuite/server/xfer.exp48
-rw-r--r--testsuite/smbd/Makefile.se_access_check24
-rw-r--r--testsuite/smbd/Makefile.sec_ctx57
-rw-r--r--testsuite/smbd/se_access_check.exp54
-rw-r--r--testsuite/smbd/se_access_check_allowall.c87
-rw-r--r--testsuite/smbd/se_access_check_allowsome.c104
-rw-r--r--testsuite/smbd/se_access_check_denyall.c86
-rw-r--r--testsuite/smbd/se_access_check_denysome.c106
-rw-r--r--testsuite/smbd/se_access_check_empty.c109
-rw-r--r--testsuite/smbd/se_access_check_nullsd.c74
-rw-r--r--testsuite/smbd/se_access_check_printer.c212
-rw-r--r--testsuite/smbd/se_access_check_utils.c158
-rw-r--r--testsuite/smbd/se_access_check_utils.h46
-rw-r--r--testsuite/smbd/sec_ctx.exp67
-rw-r--r--testsuite/smbd/sec_ctx1.c40
-rw-r--r--testsuite/smbd/sec_ctx_current_user.c114
-rw-r--r--testsuite/smbd/sec_ctx_flow.c73
-rw-r--r--testsuite/smbd/sec_ctx_groups.c131
-rw-r--r--testsuite/smbd/sec_ctx_nonroot.c42
-rw-r--r--testsuite/smbd/sec_ctx_root.c61
-rw-r--r--testsuite/smbd/sec_ctx_stack.c86
-rw-r--r--testsuite/smbd/sec_ctx_torture.c103
-rw-r--r--testsuite/smbd/sec_ctx_utils.c65
-rw-r--r--testsuite/smbd/sec_ctx_utils.h30
-rw-r--r--testsuite/smbd/sighup.exp107
288 files changed, 17920 insertions, 0 deletions
diff --git a/testsuite/README b/testsuite/README
new file mode 100644
index 00000000000..0d5157325a9
--- /dev/null
+++ b/testsuite/README
@@ -0,0 +1,19 @@
+README for testsuite directory
+------------------------------
+
+The Samba testsuite is divided up into the following subdirectories.
+
+ - config Configuration for DejaGnu program
+ - lib Various library files used by tool directories
+
+ - nsswitch Tests for nsswitch extensions
+ - server Miscellaneous server tests
+ - rpc_client Tests for the RPC client library code
+ - rpcclient Tests for the rpcclient program
+
+ - build_farm Tests designed to run automatically on the build farm
+
+All the scripts except those in build_farm require an unreleased
+version of DejaGNU, and although they contain some useful tests they
+are not so useful at the moment. All scripts are migrating to a
+single test framework, Satyr. <cvs://cvs.samba.org/data/cvs/satyr>
diff --git a/testsuite/build_farm/backtrace b/testsuite/build_farm/backtrace
new file mode 100755
index 00000000000..efaa9f2dcde
--- /dev/null
+++ b/testsuite/build_farm/backtrace
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Modified version of tridge's backtrace script.
+# we want everything on stderr, so the program is not disturbed
+exec 1>&2
+
+PID=$1
+TMPFILE=$prefix/backtrace.$$
+cat << EOF > $TMPFILE
+set height 0
+up 8
+bt full
+quit
+EOF
+gdb -x $TMPFILE $prefix/sbin/smbd $PID
+/bin/rm -f $TMPFILE
diff --git a/testsuite/build_farm/basicsmb-domainsec-nt4.test b/testsuite/build_farm/basicsmb-domainsec-nt4.test
new file mode 100644
index 00000000000..4e68acabec5
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-domainsec-nt4.test
@@ -0,0 +1,28 @@
+. basicsmb.fns
+
+test_joindomain_nt4() {
+
+ echo $prefix/bin/smbpasswd -L -a -m buildfarm$
+ $prefix/bin/smbpasswd -L -a -m buildfarm$
+
+ echo $prefix/bin/net rpc oldjoin -S localhost
+ $prefix/bin/net rpc oldjoin -S localhost
+ status=$?
+ if [ $status = 0 ]; then
+ echo "'net rpc oldjoin' correctly joined the domain"
+ else
+ echo "'net rpc oldjoin' failed to join the domain! (status $status)"
+ return 1
+ fi
+ return 0
+}
+
+password=samba
+security=DOMAIN
+(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
+
+test_joindomain_nt4 $password || exit 1
+
+test_listfilesauth $security || exit 1
+test_listfilesnpw $security || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-domainsec.test b/testsuite/build_farm/basicsmb-domainsec.test
new file mode 100644
index 00000000000..eb0a5c81aa1
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-domainsec.test
@@ -0,0 +1,27 @@
+
+. basicsmb.fns
+
+test_joindomain() {
+ test_join_domain_password="$1"
+
+ echo "$prefix/bin/net rpc join -S localhost -U $whoami%$test_join_domain_password"
+ $prefix/bin/net rpc join -S localhost -U $whoami%$test_join_domain_password
+ status=$?
+ if [ $status = 0 ]; then
+ echo "'net rpc join' correctly joined the domain"
+ else
+ echo "'net rpc join' failed to join the domain! (status $status)"
+ return 1
+ fi
+ return 0
+}
+
+password=samba
+(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
+
+test_joindomain $password || exit 1
+
+security=DOMAIN
+test_listfilesauth $security || exit 1
+test_listfilesnpw $security || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-hostsdeny.test b/testsuite/build_farm/basicsmb-hostsdeny.test
new file mode 100644
index 00000000000..c7f6bec62f7
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-hostsdeny.test
@@ -0,0 +1,18 @@
+. basicsmb.fns
+
+password="samba"
+security="hostsdeny"
+(test_smb_conf_setup && test_smbpasswd $password) || exit 1
+
+(test_listfilesauth_should_deny $security) || exit 1
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testsuite/build_farm/basicsmb-hostsequiv.test b/testsuite/build_farm/basicsmb-hostsequiv.test
new file mode 100644
index 00000000000..d424743d116
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-hostsequiv.test
@@ -0,0 +1,26 @@
+if [ $whoami = "root" ]; then
+ exit 0;
+fi
+
+. basicsmb.fns
+
+test_listfilesrootnpw() {
+ remote_name="$1"
+ echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -Uroot% -c 'ls'
+ $prefix/bin/smbclient //$remote_name/samba -n buildclient -Uroot% -c 'ls'
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbd listed files AS ROOT with NO PASSWORD (hosts equiv test)!"
+ return 1
+ else
+ echo "listing files with smbd failed with status $status (correct)"
+ fi
+ return 0
+}
+
+password="not-a-valid-password"
+security="hostsequiv"
+(test_smb_conf_setup ) || exit 1
+
+(test_listfilesauth $security) || exit 1
+(test_listfilesrootnpw $security) || exit 1
diff --git a/testsuite/build_farm/basicsmb-invalidusers.test b/testsuite/build_farm/basicsmb-invalidusers.test
new file mode 100644
index 00000000000..7d67cc2fc71
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-invalidusers.test
@@ -0,0 +1,10 @@
+. basicsmb.fns
+
+password="samba"
+security="invalidusers"
+(test_smb_conf_setup && test_smbpasswd $password) || exit 1
+
+(test_listfilesauth_should_deny $security) || exit 1
+
+security="validusers"
+(test_listfilesauth $security) || exit 1
diff --git a/testsuite/build_farm/basicsmb-local-pass-change.test b/testsuite/build_farm/basicsmb-local-pass-change.test
new file mode 100644
index 00000000000..432376c6662
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-local-pass-change.test
@@ -0,0 +1,10 @@
+. basicsmb.fns
+
+passwordold=samba
+password=samba2
+security=USER
+(test_smb_conf_setup && test_smbpasswd $passwordold && test_smbpasswd_local $passwordold $password) || exit 1
+
+test_listfilesauth $security || exit 1
+test_listfilesnpw $security || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-preexec.test b/testsuite/build_farm/basicsmb-preexec.test
new file mode 100644
index 00000000000..fc072e5fdb6
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-preexec.test
@@ -0,0 +1,28 @@
+. basicsmb.fns
+
+password=samba
+(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
+
+rm -f $prefix/testdir/preexec_touch
+
+mode=PREEXEC
+(test_listfilesauth $mode) || exit 1
+
+if [ -f $prefix/testdir/preexec_touch ]; then
+ rm -f $prefix/testdir/preexec_touch
+else
+ exit 1;
+fi
+
+mode=PREEXEC_close
+(test_listfilesauth $mode) || exit 1
+
+if [ -f $prefix/testdir/preexec_touch ]; then
+ rm -f $prefix/testdir/preexec_touch
+else
+ exit 1;
+fi
+
+mode=PREEXEC_cl_fl
+(test_listfilesauth_should_deny $mode) || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-remote-pass-change.test b/testsuite/build_farm/basicsmb-remote-pass-change.test
new file mode 100644
index 00000000000..adfe0dc3ebc
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-remote-pass-change.test
@@ -0,0 +1,10 @@
+. basicsmb.fns
+
+passwordold=samba
+password=samba2
+security=USER
+(test_smb_conf_setup && test_smbpasswd $passwordold && test_smbpasswd_remote $passwordold $password) || exit 1
+
+test_listfilesauth $security || exit 1
+test_listfilesnpw $security || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-serversec.test b/testsuite/build_farm/basicsmb-serversec.test
new file mode 100644
index 00000000000..b45899ab774
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-serversec.test
@@ -0,0 +1,9 @@
+. basicsmb.fns
+
+password=samba
+security=SERVER
+(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
+
+test_listfilesauth $security || exit 1
+test_listfilesnpw $security || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-shareguest.test b/testsuite/build_farm/basicsmb-shareguest.test
new file mode 100644
index 00000000000..4ba445a17e3
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-shareguest.test
@@ -0,0 +1,20 @@
+. basicsmb.fns
+
+test_listfilesguestshare() {
+ remote_name=$1
+ echo $prefix/bin/smbclient //$remote_name/guest_share -n buildclient -U$whoami% -c 'ls'
+ $prefix/bin/smbclient //$remote_name/guest_share -n buildclient -U$whoami% -c 'ls'
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbd listed files correctly (guest share)"
+ else
+ echo "listing files on a guest share failed with status $status"
+ return 1
+ fi
+ return 0
+}
+
+security=SHARE
+( test_smb_conf_setup ) || exit 1
+
+( test_listfilesguestshare $security ) || exit 1 \ No newline at end of file
diff --git a/testsuite/build_farm/basicsmb-sharelist.test b/testsuite/build_farm/basicsmb-sharelist.test
new file mode 100644
index 00000000000..188e985658d
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-sharelist.test
@@ -0,0 +1,22 @@
+. basicsmb.fns
+test_sharelist() {
+ echo $prefix/bin/smbclient -U$whoami% -L localhost
+ $prefix/bin/smbclient -U$whoami% -L localhost
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbd listed shares OK"
+ else
+ echo "listing shares with smbd failed with status $status"
+ return 1
+ fi
+ return 0
+}
+
+# Need guest account
+password=samba
+security=USER
+(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
+
+test_sharelist || exit 1
+
+
diff --git a/testsuite/build_farm/basicsmb-sharesec.test b/testsuite/build_farm/basicsmb-sharesec.test
new file mode 100644
index 00000000000..edef6a91230
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-sharesec.test
@@ -0,0 +1,9 @@
+. basicsmb.fns
+
+password="samba"
+security="SHARE"
+(test_smb_conf_setup && ( test_smbpasswd $password ) ) || exit 1
+
+(test_listfilesauth $security) || exit 1
+(test_listfilesnpw $security) || exit 1
+
diff --git a/testsuite/build_farm/basicsmb-usersec.test b/testsuite/build_farm/basicsmb-usersec.test
new file mode 100644
index 00000000000..06f2a1c4040
--- /dev/null
+++ b/testsuite/build_farm/basicsmb-usersec.test
@@ -0,0 +1,9 @@
+. basicsmb.fns
+
+password=samba
+security=USER
+(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
+
+test_listfilesauth $security || exit 1
+test_listfilesnpw $security || exit 1
+
diff --git a/testsuite/build_farm/basicsmb.fns b/testsuite/build_farm/basicsmb.fns
new file mode 100644
index 00000000000..3a9080f473b
--- /dev/null
+++ b/testsuite/build_farm/basicsmb.fns
@@ -0,0 +1,204 @@
+#! /bin/sh
+
+# Common functions for Samba build scripts.
+
+# Copyright (C) 2001 by Martin Pool <mbp@samba.org> and others
+
+# The following variables are passed in by the calling script. They
+# originate in either the buildfarm scripts or the configured
+# Makefile.
+
+# PREFIX = Installed prefix of samba test installation. Used to
+# locate binaries, configuration files, etc.
+
+# XXX: It's pretty bad to clobber the installed configuration file and
+# other data in $prefix, because somebody might unwittingly run this
+# with prefix=/usr.
+
+# Really what we want is a consistent way to pass the location of the
+# configuration and all other files into *all* Samba programs
+# (smbclient, smd, ...) and be able to set them to a temporary
+# directory when testing. Some of them take a -c parameter, but tpot
+# says it's not done consistently.
+
+template_setup() {
+ cat template/$1 | \
+ sed "s|PREFIX|$prefix|g" | \
+ sed "s|BUILD_FARM|$test_root|g" | \
+ sed "s|WHOAMI|$whoami|g" | \
+ sed "s|LOGLEVEL|$loglevel|g" \
+ > $prefix/$2
+ echo "template_setup: Created $prefix/$2"
+}
+
+template_smb_conf_setup() {
+ template_setup "basicsmb.smb.conf$1" "lib/smb.conf$1"
+}
+
+test_smb_conf_setup() {
+ echo "test_smb_conf_setup: Configuring: "
+ echo " PREFIX=$prefix"
+ echo " BUILD_FARM=$test_root"
+ echo " WHOAMI=$whoami"
+ echo " LOGLEVEL=$loglevel"
+ echo " TREE=$tree"
+
+ case "$prefix" in
+ /usr*|/|//)
+ echo "** I don't want to clobber your installation in "
+ echo "** $prefix"
+ echo "** by running tests there. Please reconfigure this source tree to"
+ echo "** use a different prefix."
+ exit 1
+ esac
+
+# Please keep these names under 15 characters,
+# so that the final name is 31 characters or fewer.
+
+ template_smb_conf_setup
+ template_smb_conf_setup .hostsequiv
+ template_smb_conf_setup .validusers
+ template_smb_conf_setup .invalidusers
+ template_smb_conf_setup .preexec
+ template_smb_conf_setup .preexec_close
+ template_smb_conf_setup .preexec_cl_fl
+
+ template_smb_conf_setup .share
+ template_smb_conf_setup .user
+ template_smb_conf_setup .server
+ template_smb_conf_setup .domain
+
+ template_setup preexec lib/preexec
+
+ touch $prefix/lib/smb.conf.
+ touch $prefix/lib/smb.conf.localhost
+
+ echo "127.0.0.1 localhost">$prefix/lib/lmhosts
+ echo "127.0.0.2 BUILDFARM">>$prefix/lib/lmhosts
+ echo "127.0.0.3 SHARE">>$prefix/lib/lmhosts
+ echo "127.0.0.4 USER">>$prefix/lib/lmhosts
+ echo "127.0.0.5 SERVER">>$prefix/lib/lmhosts
+ echo "127.0.0.6 DOMAIN">>$prefix/lib/lmhosts
+ echo "127.0.0.7 HOSTSEQUIV">>$prefix/lib/lmhosts
+ echo "127.0.0.7 VALIDUSERS">>$prefix/lib/lmhosts
+ echo "127.0.0.7 INVALIDUSERS">>$prefix/lib/lmhosts
+ echo "127.0.0.7 PREEXEC">>$prefix/lib/lmhosts
+ echo "127.0.0.7 PREEXEC_CLOSE">>$prefix/lib/lmhosts
+ echo "127.0.0.7 PREEXEC_CL_FL">>$prefix/lib/lmhosts
+
+
+ echo "127.0.0.1" > $prefix/lib/hosts.equiv
+
+}
+
+test_smbpasswd() {
+ test_smbpasswd_password="$1"
+ rm -f $prefix/private/smbpasswd
+ echo "( echo $test_smbpasswd_password ; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -D $loglevel -s -a $whoami"
+ ( echo $test_smbpasswd_password; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -D $loglevel -s -a $whoami
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbpasswd correctly set initial password ($test_smbpasswd_password)"
+ else
+ echo "smbpasswd failed to set initial password ($test_smbpasswd_password)! (status $status)"
+ return 1
+ fi
+ return 0
+}
+
+test_smbpasswd_remote() {
+ test_smbpasswd_rem_password="$1"
+ test_smbpasswd_rem_newpassword="$2"
+ echo "( echo $test_smbpasswd_rem_password; echo $test_smbpasswd_rem_newpassword; echo $test_smbpasswd_rem_newpassword; ) | $prefix/bin/smbpasswd -r localhost -s -U $whoami"
+ ( echo $test_smbpasswd_rem_password; echo $test_smbpasswd_rem_newpassword; echo $test_smbpasswd_rem_newpassword; ) | $prefix/bin/smbpasswd -r localhost -s -U $whoami
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbpasswd correctly remotely changed password ($test_smbpasswd_rem_password -> $test_smbpasswd_rem_newpassword)"
+ else
+ echo "smbpasswd failed to remotely changed password ($test_smbpasswd_rem_password -> $test_smbpasswd_rem_newpassword)! (status $status)"
+ return 1
+ fi
+ return 0
+}
+
+test_smbpasswd_local() {
+ test_smbpasswd_newpassword="$2"
+ echo "( echo $test_smbpasswd_newpassword ; echo $test_smbpasswd_newpassword; ) | $prefix/bin/smbpasswd -L -s $whoami"
+ ( echo $test_smbpasswd_newpassword ; echo $test_smbpasswd_newpassword; ) | $prefix/bin/smbpasswd -L -s $whoami
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbpasswd correctly locally changed password ($test_smbpasswd_password -> $test_smbpasswd_newpassword)"
+ else
+ echo "smbpasswd failed to locallly changed password ($test_smbpasswd_password -> $test_smbpasswd_newpassword)! (status $status)"
+ return 1
+ fi
+ return 0
+}
+
+test_listfilesauth() {
+ remote_name="$1"
+ echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
+ $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
+ status=$?
+ if [ $status = 0 ]; then
+ echo "listed files OK"
+ else
+ echo "listing files with smbd failed with status $status"
+ return 1
+ fi
+ return 0
+}
+
+test_listfilesnpw() {
+ remote_name="$1"
+ echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
+ $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbd listed files with NO PASSWORD on an authenticated share!"
+ return 1
+ else
+ echo "listing files with smbd failed with status $status (correct)"
+ fi
+ return 0
+}
+
+test_listfilesauth_should_deny() {
+ remote_name="$1"
+ echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
+ $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbd LISTED FILES despite smb.conf entires to the contary!"
+ return 1
+ else
+ echo "listing files with smbd failed with status $status (correct)"
+ fi
+ return 0
+}
+
+echo "LIBSMB_PROG=$LIBSMB_PROG" >&2
+
+
+
+# Give sensible defaults to some variables.
+
+# "What's my age again?"
+
+if [ ! $USER = "" ]; then
+ whoami=$USER
+else
+ if [ ! $LOGNAME = "" ]; then
+ whoami=$LOGNAME
+ else
+ whoami=build
+ fi
+fi
+
+
+
+if test -z "$loglevel"
+then
+ loglevel=1
+fi
+
diff --git a/testsuite/build_farm/runlist b/testsuite/build_farm/runlist
new file mode 100644
index 00000000000..594c172b6ff
--- /dev/null
+++ b/testsuite/build_farm/runlist
@@ -0,0 +1,18 @@
+TEST_ALL="basicsmb-sharelist basicsmb-local-pass-change \
+basicsmb-sharesec basicsmb-usersec \
+basicsmb-serversec \
+basicsmb-shareguest basicsmb-hostsequiv basicsmb-invalidusers \
+basicsmb-hostsdeny basicsmb-remote-pass-change \
+basicsmb-preexec \
+torture-FDPASS torture-LOCK1 torture-LOCK2 \
+torture-LOCK3 torture-LOCK4 torture-LOCK5 \
+torture-LOCK6 torture-LOCK7 \
+torture-UNLINK torture-BROWSE torture-ATTR \
+torture-TRANS2 torture-TORTURE torture-OPLOCK1 \
+torture-OPLOCK3 torture-DIR torture-DIR1 torture-DENY1 \
+torture-DENY2 torture-TCON torture-TCON2 torture-TCONDEV \
+torture-RW1 torture-RW2 torture-OPEN torture-XCOPY \
+torture-RENAME torture-DELETE torture-PROPERTIES \
+torture-MANGLE torture-FDSESS"
+
+#basicsmb-domainsec basicsmb-domainsec-nt4 \ No newline at end of file
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf b/testsuite/build_farm/template/basicsmb.smb.conf
new file mode 100644
index 00000000000..234419b6885
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf
@@ -0,0 +1,49 @@
+[global]
+ netbios name = BUILDFARM
+ workgroup = TESTWG
+ log level = LOGLEVEL
+ debug timestamp = no
+ encrypt passwords = yes
+ server string = Samba %v Build Farm Tests
+ name resolve order = lmhosts
+ guest account = WHOAMI
+ domain logons = yes
+
+ strict locking = yes
+
+ include = PREFIX/lib/smb.conf.%L
+
+ add machine script = useradd %u -d /dev/null -s /bin/false
+
+ panic action = /bin/sh BUILD_FARM/samba/testsuite/build_farm/backtrace %d
+
+ passdb backend = smbpasswd
+
+ idmap uid = 10000-200000
+ map hidden = yes
+ create mask = 0777
+
+[test]
+ path = PREFIX/testdir
+ read only = no
+
+[samba]
+ path = BUILD_FARM/samba
+ read only = yes
+ comment = Samba HEAD Sources
+
+[samba_2_2]
+ path = BUILD_FARM/samba_2_2
+ read only = yes
+ comment = Samba 2.2. Sources
+
+[rsync]
+ path = BUILD_FARM/rsync
+ read only = yes
+ comment = Rsync Sources
+
+[guest_share]
+ path = PREFIX
+ guest ok = yes
+ read only = yes
+ comment = Unauthenticated share for use in share level test
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.domain b/testsuite/build_farm/template/basicsmb.smb.conf.domain
new file mode 100644
index 00000000000..8b9728838e1
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.domain
@@ -0,0 +1,2 @@
+security=domain
+password server=user
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.hostsdeny b/testsuite/build_farm/template/basicsmb.smb.conf.hostsdeny
new file mode 100644
index 00000000000..3fce0bdbf4e
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.hostsdeny
@@ -0,0 +1 @@
+ hosts deny = 127. \ No newline at end of file
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.hostsequiv b/testsuite/build_farm/template/basicsmb.smb.conf.hostsequiv
new file mode 100644
index 00000000000..750af74f59c
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.hostsequiv
@@ -0,0 +1,3 @@
+ hostname lookups = no
+ hosts equiv=PREFIX/lib/hosts.equiv
+ auth methods = hostsequiv
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.invalidusers b/testsuite/build_farm/template/basicsmb.smb.conf.invalidusers
new file mode 100644
index 00000000000..a96a316db9f
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.invalidusers
@@ -0,0 +1 @@
+ invalid users = WHOAMI
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.preexec b/testsuite/build_farm/template/basicsmb.smb.conf.preexec
new file mode 100644
index 00000000000..cc34872c5df
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.preexec
@@ -0,0 +1 @@
+preexec = /bin/sh PREFIX/lib/preexec
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.preexec_cl_fl b/testsuite/build_farm/template/basicsmb.smb.conf.preexec_cl_fl
new file mode 100644
index 00000000000..4a6fae57bc0
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.preexec_cl_fl
@@ -0,0 +1,2 @@
+preexec close = yes
+preexec = PREFIX/lib/preexec_does_not_exist
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.preexec_close b/testsuite/build_farm/template/basicsmb.smb.conf.preexec_close
new file mode 100644
index 00000000000..3aac6998bfc
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.preexec_close
@@ -0,0 +1,2 @@
+preexec close = yes
+preexec = /bin/sh PREFIX/lib/preexec
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.server b/testsuite/build_farm/template/basicsmb.smb.conf.server
new file mode 100644
index 00000000000..016f84cd353
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.server
@@ -0,0 +1,3 @@
+security=server
+password server=user
+smb passwd file=NON_EXISTANT_FILE
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.share b/testsuite/build_farm/template/basicsmb.smb.conf.share
new file mode 100644
index 00000000000..8e69cc199a5
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.share
@@ -0,0 +1 @@
+ security = share
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.user b/testsuite/build_farm/template/basicsmb.smb.conf.user
new file mode 100644
index 00000000000..9d294b9c396
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.user
@@ -0,0 +1 @@
+ security = user
diff --git a/testsuite/build_farm/template/basicsmb.smb.conf.validusers b/testsuite/build_farm/template/basicsmb.smb.conf.validusers
new file mode 100644
index 00000000000..d4a85e0a028
--- /dev/null
+++ b/testsuite/build_farm/template/basicsmb.smb.conf.validusers
@@ -0,0 +1 @@
+ valid users = WHOAMI
diff --git a/testsuite/build_farm/template/preexec b/testsuite/build_farm/template/preexec
new file mode 100644
index 00000000000..23809aaf893
--- /dev/null
+++ b/testsuite/build_farm/template/preexec
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo "Test worked" > PREFIX/testdir/preexec_touch
diff --git a/testsuite/build_farm/torture-ATTR.test b/testsuite/build_farm/torture-ATTR.test
new file mode 100644
index 00000000000..db6d5e87824
--- /dev/null
+++ b/testsuite/build_farm/torture-ATTR.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "ATTR"
diff --git a/testsuite/build_farm/torture-BROWSE.test b/testsuite/build_farm/torture-BROWSE.test
new file mode 100644
index 00000000000..da758977da5
--- /dev/null
+++ b/testsuite/build_farm/torture-BROWSE.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "BROWSE"
diff --git a/testsuite/build_farm/torture-DELETE.test b/testsuite/build_farm/torture-DELETE.test
new file mode 100644
index 00000000000..395f449d1e1
--- /dev/null
+++ b/testsuite/build_farm/torture-DELETE.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "DELETE"
diff --git a/testsuite/build_farm/torture-DENY1.test b/testsuite/build_farm/torture-DENY1.test
new file mode 100644
index 00000000000..99ce7ea8869
--- /dev/null
+++ b/testsuite/build_farm/torture-DENY1.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "DENY1"
diff --git a/testsuite/build_farm/torture-DENY2.test b/testsuite/build_farm/torture-DENY2.test
new file mode 100644
index 00000000000..17c8f707d87
--- /dev/null
+++ b/testsuite/build_farm/torture-DENY2.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "DENY2"
diff --git a/testsuite/build_farm/torture-DIR.test b/testsuite/build_farm/torture-DIR.test
new file mode 100644
index 00000000000..085ce59c3b0
--- /dev/null
+++ b/testsuite/build_farm/torture-DIR.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "DIR"
diff --git a/testsuite/build_farm/torture-DIR1.test b/testsuite/build_farm/torture-DIR1.test
new file mode 100644
index 00000000000..6cc075e9ba9
--- /dev/null
+++ b/testsuite/build_farm/torture-DIR1.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "DIR1"
diff --git a/testsuite/build_farm/torture-FDPASS.test b/testsuite/build_farm/torture-FDPASS.test
new file mode 100644
index 00000000000..40ffdb666d7
--- /dev/null
+++ b/testsuite/build_farm/torture-FDPASS.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "FDSESS"
diff --git a/testsuite/build_farm/torture-FDSESS.test b/testsuite/build_farm/torture-FDSESS.test
new file mode 100644
index 00000000000..e8af277d430
--- /dev/null
+++ b/testsuite/build_farm/torture-FDSESS.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "FDPASS"
diff --git a/testsuite/build_farm/torture-LOCK1.test b/testsuite/build_farm/torture-LOCK1.test
new file mode 100644
index 00000000000..fd01c492f16
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK1.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK1"
diff --git a/testsuite/build_farm/torture-LOCK2.test b/testsuite/build_farm/torture-LOCK2.test
new file mode 100644
index 00000000000..66b671d8010
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK2.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK2"
diff --git a/testsuite/build_farm/torture-LOCK3.test b/testsuite/build_farm/torture-LOCK3.test
new file mode 100644
index 00000000000..dcf14019d8e
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK3.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK3"
diff --git a/testsuite/build_farm/torture-LOCK4.test b/testsuite/build_farm/torture-LOCK4.test
new file mode 100644
index 00000000000..8fdc9b66615
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK4.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK4"
diff --git a/testsuite/build_farm/torture-LOCK5.test b/testsuite/build_farm/torture-LOCK5.test
new file mode 100644
index 00000000000..a04f83c8491
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK5.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK5"
diff --git a/testsuite/build_farm/torture-LOCK6.test b/testsuite/build_farm/torture-LOCK6.test
new file mode 100644
index 00000000000..78e139e3103
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK6.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK6"
diff --git a/testsuite/build_farm/torture-LOCK7.test b/testsuite/build_farm/torture-LOCK7.test
new file mode 100644
index 00000000000..fc967fca57d
--- /dev/null
+++ b/testsuite/build_farm/torture-LOCK7.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "LOCK7"
diff --git a/testsuite/build_farm/torture-MANGLE.test b/testsuite/build_farm/torture-MANGLE.test
new file mode 100644
index 00000000000..5a3d478a456
--- /dev/null
+++ b/testsuite/build_farm/torture-MANGLE.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "MANGLE"
diff --git a/testsuite/build_farm/torture-OPEN.test b/testsuite/build_farm/torture-OPEN.test
new file mode 100644
index 00000000000..ee3e55f0890
--- /dev/null
+++ b/testsuite/build_farm/torture-OPEN.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "OPEN"
diff --git a/testsuite/build_farm/torture-OPLOCK1.test b/testsuite/build_farm/torture-OPLOCK1.test
new file mode 100644
index 00000000000..bb606ad3bc9
--- /dev/null
+++ b/testsuite/build_farm/torture-OPLOCK1.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "OPLOCK1"
diff --git a/testsuite/build_farm/torture-OPLOCK3.test b/testsuite/build_farm/torture-OPLOCK3.test
new file mode 100644
index 00000000000..f8dfb3f8e9b
--- /dev/null
+++ b/testsuite/build_farm/torture-OPLOCK3.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "OPLOCK3"
diff --git a/testsuite/build_farm/torture-PROPERTIES.test b/testsuite/build_farm/torture-PROPERTIES.test
new file mode 100644
index 00000000000..91fde27f8af
--- /dev/null
+++ b/testsuite/build_farm/torture-PROPERTIES.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "PROPERTIES"
diff --git a/testsuite/build_farm/torture-RANDOMIPC.test b/testsuite/build_farm/torture-RANDOMIPC.test
new file mode 100644
index 00000000000..e510b6b6672
--- /dev/null
+++ b/testsuite/build_farm/torture-RANDOMIPC.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "RANDOMIPC"
diff --git a/testsuite/build_farm/torture-RENAME.test b/testsuite/build_farm/torture-RENAME.test
new file mode 100644
index 00000000000..58cb8eb466f
--- /dev/null
+++ b/testsuite/build_farm/torture-RENAME.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "RENAME"
diff --git a/testsuite/build_farm/torture-RW1.test b/testsuite/build_farm/torture-RW1.test
new file mode 100644
index 00000000000..6be4a897d91
--- /dev/null
+++ b/testsuite/build_farm/torture-RW1.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "RW1"
diff --git a/testsuite/build_farm/torture-RW2.test b/testsuite/build_farm/torture-RW2.test
new file mode 100644
index 00000000000..dc457decab1
--- /dev/null
+++ b/testsuite/build_farm/torture-RW2.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "RW2"
diff --git a/testsuite/build_farm/torture-TCON.test b/testsuite/build_farm/torture-TCON.test
new file mode 100644
index 00000000000..7d1aba0f29f
--- /dev/null
+++ b/testsuite/build_farm/torture-TCON.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "TCON"
diff --git a/testsuite/build_farm/torture-TCON1.test b/testsuite/build_farm/torture-TCON1.test
new file mode 100644
index 00000000000..3c9267640de
--- /dev/null
+++ b/testsuite/build_farm/torture-TCON1.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "TCON1"
diff --git a/testsuite/build_farm/torture-TCON2.test b/testsuite/build_farm/torture-TCON2.test
new file mode 100644
index 00000000000..1f30a975daa
--- /dev/null
+++ b/testsuite/build_farm/torture-TCON2.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "TCON2"
diff --git a/testsuite/build_farm/torture-TCONDEV.test b/testsuite/build_farm/torture-TCONDEV.test
new file mode 100644
index 00000000000..18bd5345fb7
--- /dev/null
+++ b/testsuite/build_farm/torture-TCONDEV.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "TCONDEV"
diff --git a/testsuite/build_farm/torture-TORTURE.test b/testsuite/build_farm/torture-TORTURE.test
new file mode 100644
index 00000000000..bc97e94e850
--- /dev/null
+++ b/testsuite/build_farm/torture-TORTURE.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "TORTURE"
diff --git a/testsuite/build_farm/torture-TRANS2.test b/testsuite/build_farm/torture-TRANS2.test
new file mode 100644
index 00000000000..d2a387f1afc
--- /dev/null
+++ b/testsuite/build_farm/torture-TRANS2.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "TRANS2"
diff --git a/testsuite/build_farm/torture-UNLINK.test b/testsuite/build_farm/torture-UNLINK.test
new file mode 100644
index 00000000000..b7086bbc838
--- /dev/null
+++ b/testsuite/build_farm/torture-UNLINK.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "UNLINK"
diff --git a/testsuite/build_farm/torture-XCOPY.test b/testsuite/build_farm/torture-XCOPY.test
new file mode 100644
index 00000000000..94cc7979769
--- /dev/null
+++ b/testsuite/build_farm/torture-XCOPY.test
@@ -0,0 +1,2 @@
+. torture_setup.fns
+test_torture "XCOPY"
diff --git a/testsuite/build_farm/torture_setup.fns b/testsuite/build_farm/torture_setup.fns
new file mode 100644
index 00000000000..a42be94129b
--- /dev/null
+++ b/testsuite/build_farm/torture_setup.fns
@@ -0,0 +1,19 @@
+. basicsmb.fns
+
+test_torture() {
+ torture_test=$1
+ password=samba
+ security=USER
+ (test_smb_conf_setup && test_smbpasswd $password ) || return 1
+
+ echo $srcdir/bin/smbtorture //localhost/test -U$whoami%$password $torture_test
+ $srcdir/bin/smbtorture //localhost/test -U$whoami%$password $torture_test
+ status=$?
+ if [ $status = 0 ]; then
+ echo "smbtorture test $torture_test worked"
+ else
+ echo "smbtorture test $torture_test FAILED (status $status)!"
+ return 1
+ fi
+ return 0
+}
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
new file mode 100644
index 00000000000..c8b3b28779d
--- /dev/null
+++ b/testsuite/config/unix.exp
@@ -0,0 +1,27 @@
+# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@prep.ai.mit.edu
+
+# This file was written by Rob Savoye. (rob@cygnus.com)
+
+# Set a default timeout to be used for the tests under UNIX, rather than
+# accepting whatever default dejagnu gives us (apparently 10 seconds).
+# When running the tests over NFS, under somewhat heavy load, 10 seconds
+# does not seem to be enough. Try starting with 60.
+set timeout 60
+verbose "Timeout is now $timeout seconds" 2
diff --git a/testsuite/lib/compile.exp b/testsuite/lib/compile.exp
new file mode 100644
index 00000000000..070498d9589
--- /dev/null
+++ b/testsuite/lib/compile.exp
@@ -0,0 +1,79 @@
+#
+# Compilation utility functions
+#
+
+#
+# Unix SMB/Netbios implementation.
+# Copyright (C) Tim Potter 2000
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+# Compile a program consisting of one .c file. For example
+# simple_compile "foo" will compile foo.c to the executable foo.exe
+# Use a second argument to specify link libraries.
+
+proc simple_compile { args } {
+ global srcdir
+ global subdir
+
+ # Compile up program
+
+ set program [lindex $args 0]
+ set libs [lindex $args 1]
+
+ if { $libs == "" } {
+
+ set output [target_compile "$srcdir/$subdir/$program.c" \
+ "$srcdir/$subdir/$program" executable \
+ {additional_flags="-g"}]
+ } else {
+
+ set output [target_compile "$srcdir/$subdir/$program.c" \
+ "$srcdir/$subdir/$program" executable \
+ [list libs=$libs additional_flags="-g"]]
+ }
+
+ # Check for errors
+
+ if {$output != ""} {
+ perror "compile $program"
+ puts $output
+ return -1
+ }
+}
+
+# Compile a program from a Makefile.suffix
+
+proc simple_make { args } {
+ global srcdir
+ global subdir
+
+ # Compile up program with make
+
+ set suffix [lindex $args 0]
+ set program [lindex $args 1]
+
+ set output [util_start "make" \
+ "-C $srcdir/$subdir -f Makefile.$suffix $program"]
+
+ # Check for errors
+
+ if { [regexp "Error" $output] } {
+ perror "make $program"
+ puts $output
+ return -1
+ }
+}
diff --git a/testsuite/lib/default-nt-names.exp b/testsuite/lib/default-nt-names.exp
new file mode 100644
index 00000000000..5d01d2a5bb3
--- /dev/null
+++ b/testsuite/lib/default-nt-names.exp
@@ -0,0 +1,20 @@
+#
+# A list of default domain/local users/groups. Unfortunately this is tied
+# to the English language version of Windows NT.
+#
+
+global domain
+
+# Domain users and groups
+
+set domain_users [list "$domain/Administrator" "$domain/Guest"]
+
+set domain_groups [list "$domain/Domain Admins" "$domain/Domain Guests" \
+ "$domain/Domain Users"]
+
+# Local groups
+
+set local_groups [list "BUILTIN/Replicator" "BUILTIN/Server Operators" \
+ "BUILTIN/Account Operators" "BUILTIN/Backup Operators" \
+ "BUILTIN/Print Operators" "BUILTIN/Guests" "BUILTIN/Users" \
+ "BUILTIN/Administrators"]
diff --git a/testsuite/lib/env-single.exp b/testsuite/lib/env-single.exp
new file mode 100644
index 00000000000..6cd7f94a869
--- /dev/null
+++ b/testsuite/lib/env-single.exp
@@ -0,0 +1,36 @@
+#
+# Environment variables for a single machine test. We look for the
+# following environment variables:
+#
+# $TEST_SERVER The SMB server to contact for the test
+# $TEST_SHARE Share name on $TEST_SERVER to contact
+# $TEST_USER The username to connect to $TEST_SHARE as
+#
+# These are stored in the Tcl variables $server, $share and $user
+# respectively.
+#
+# An error will be produced and the test will exit if any of these
+# variables are not present.
+#
+
+verbose "Loading single machine environment variables"
+
+catch {set server "$env(TEST_SERVER)"} tmp
+
+if {[regexp "^can't read" $tmp]} {
+ error "Environment variable TEST_SERVER not set"
+}
+
+catch {set share "$env(TEST_SHARE)"} tmp
+
+if {[regexp "^can't read" $tmp]} {
+ error "Environment variable TEST_SHARE not set"
+}
+
+catch {set user "$env(TEST_USER)"} tmp
+
+if {[regexp "^can't read" $tmp]} {
+ error "Environment variable TEST_USER not set"
+}
+
+verbose "Single machine is //$server/$share -U $user"
diff --git a/testsuite/lib/nsswitch-config.exp b/testsuite/lib/nsswitch-config.exp
new file mode 100644
index 00000000000..38342685dfa
--- /dev/null
+++ b/testsuite/lib/nsswitch-config.exp
@@ -0,0 +1,21 @@
+#
+# Load environment variables
+#
+
+global tool
+
+if { [file exists "deja-$tool.tcl"] } {
+ source "deja-$tool.tcl"
+}
+
+# Required options
+
+if { ![info exists WORKGROUP] } {
+ error "\$WORKGROUP not set in config file"
+}
+
+if { ![info exists PDC] } {
+ error "\$PDC not set in config file"
+}
+
+set domain $WORKGROUP
diff --git a/testsuite/lib/smbclient.exp b/testsuite/lib/smbclient.exp
new file mode 100644
index 00000000000..dc55d72139c
--- /dev/null
+++ b/testsuite/lib/smbclient.exp
@@ -0,0 +1,54 @@
+#
+# Utilities for driving smbclient
+#
+
+# Variables
+
+set smb_prompt "smb: \\\\>"
+
+# Spawn smbclient and wait for a prompt
+
+proc spawn_smbclient { args } {
+ set result 0
+ global smb_prompt
+ global spawn_id
+
+ # Spawn smbclient
+
+ spawn smbclient [lindex $args 0] [lindex $args 1] [lindex $args 2] \
+ [lindex $args 3] [lindex $args 4] [lindex $args 5] \
+ [lindex $args 6]
+
+ # Wait for prompt
+
+ expect {
+ $smb_prompt { set result 1 }
+ timeout { perror "timed out spawning smbclient" }
+ eof { perror "end of file spawning smbclient" }
+ }
+
+ return $result
+}
+
+# Run a command and wait for a prompt
+
+proc do_smbclient { args } {
+ set action [lindex $args 0]
+ set description [lindex $args 1]
+ global smb_prompt
+
+ # Send command
+
+ verbose $action
+
+ send $action
+
+ expect {
+ $smb_prompt {}
+ timeout { perror "timed out $description"; return -1}
+ eof { perror "end of file $description"; return -1 }
+ }
+
+ verbose $expect_out(buffer)
+ return $expect_out(buffer)
+}
diff --git a/testsuite/libsmbclient/src/.cvsignore b/testsuite/libsmbclient/src/.cvsignore
new file mode 100644
index 00000000000..ba077a4031a
--- /dev/null
+++ b/testsuite/libsmbclient/src/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/testsuite/libsmbclient/src/Makefile b/testsuite/libsmbclient/src/Makefile
new file mode 100644
index 00000000000..a59f1342801
--- /dev/null
+++ b/testsuite/libsmbclient/src/Makefile
@@ -0,0 +1,817 @@
+CC = gcc
+CFLAGS = -Wall -W -O2 -g
+LFLAGS = -L/root/samba-head-old/source/bin
+
+LIBS= -L/usr/lib -lsmbclient
+INCPATH= -I. -I/usr/include -I./include
+BIN_DIR=bin
+
+SUB_DIRS=init fstat open unlink chown close opendir closedir rename lseek lseekdir stat \
+ getdents creat read readdir mkdir rmdir write chmod open_print_job list_print_jobs \
+ print_file telldir unlink_print_job
+
+
+G_INIT = $(BIN_DIR)/init_1 \
+ $(BIN_DIR)/init_2 \
+ $(BIN_DIR)/init_3 \
+ $(BIN_DIR)/init_4
+
+G_FSTAT = $(BIN_DIR)/fstat_1 \
+ $(BIN_DIR)/fstat_2 \
+ $(BIN_DIR)/fstat_3 \
+ $(BIN_DIR)/fstat_4 \
+ $(BIN_DIR)/fstat_5 \
+ $(BIN_DIR)/fstat_6
+
+G_OPEN = $(BIN_DIR)/open_1 \
+ $(BIN_DIR)/open_2 \
+ $(BIN_DIR)/open_3 \
+ $(BIN_DIR)/open_4 \
+ $(BIN_DIR)/open_5
+
+G_UNLINK = $(BIN_DIR)/unlink_1 \
+ $(BIN_DIR)/unlink_2 \
+ $(BIN_DIR)/unlink_3 \
+ $(BIN_DIR)/unlink_4 \
+ $(BIN_DIR)/unlink_5 \
+ $(BIN_DIR)/unlink_6 \
+ $(BIN_DIR)/unlink_7 \
+ $(BIN_DIR)/unlink_8 \
+ $(BIN_DIR)/unlink_9 \
+ $(BIN_DIR)/unlink_10 \
+ $(BIN_DIR)/unlink_11 \
+ $(BIN_DIR)/unlink_12
+
+
+G_CLOSE = $(BIN_DIR)/close_1 \
+ $(BIN_DIR)/close_2
+
+G_OPENDIR = $(BIN_DIR)/opendir_1 \
+ $(BIN_DIR)/opendir_2 \
+ $(BIN_DIR)/opendir_3 \
+ $(BIN_DIR)/opendir_4
+
+G_CLOSEDIR = $(BIN_DIR)/closedir_1 \
+ $(BIN_DIR)/closedir_2 \
+ $(BIN_DIR)/closedir_3 \
+ $(BIN_DIR)/closedir_4
+
+G_RENAME = $(BIN_DIR)/rename_1 \
+ $(BIN_DIR)/rename_2 \
+ $(BIN_DIR)/rename_3 \
+ $(BIN_DIR)/rename_4 \
+ $(BIN_DIR)/rename_5 \
+ $(BIN_DIR)/rename_6 \
+ $(BIN_DIR)/rename_7 \
+ $(BIN_DIR)/rename_8 \
+ $(BIN_DIR)/rename_9 \
+ $(BIN_DIR)/rename_10 \
+ $(BIN_DIR)/rename_11 \
+ $(BIN_DIR)/rename_12 \
+ $(BIN_DIR)/rename_13 \
+ $(BIN_DIR)/rename_14
+
+G_LSEEK = $(BIN_DIR)/lseek_1 \
+ $(BIN_DIR)/lseek_2 \
+ $(BIN_DIR)/lseek_3 \
+ $(BIN_DIR)/lseek_4 \
+ $(BIN_DIR)/lseek_5 \
+ $(BIN_DIR)/lseek_6 \
+ $(BIN_DIR)/lseek_7 \
+ $(BIN_DIR)/lseek_8
+
+G_LSEEKDIR = $(BIN_DIR)/lseekdir_1 \
+ $(BIN_DIR)/lseekdir_2 \
+ $(BIN_DIR)/lseekdir_3 \
+ $(BIN_DIR)/lseekdir_4 \
+ $(BIN_DIR)/lseekdir_5 \
+ $(BIN_DIR)/lseekdir_6
+
+G_STAT = $(BIN_DIR)/stat_1 \
+ $(BIN_DIR)/stat_2 \
+ $(BIN_DIR)/stat_3 \
+ $(BIN_DIR)/stat_4 \
+ $(BIN_DIR)/stat_5 \
+ $(BIN_DIR)/stat_6
+
+G_GETDENTS = $(BIN_DIR)/getdents_1 \
+ $(BIN_DIR)/getdents_2 \
+ $(BIN_DIR)/getdents_3 \
+ $(BIN_DIR)/getdents_4 \
+ $(BIN_DIR)/getdents_5
+
+G_CREAT = $(BIN_DIR)/creat_1 \
+ $(BIN_DIR)/creat_2 \
+ $(BIN_DIR)/creat_3
+
+G_READ = $(BIN_DIR)/read_1 \
+ $(BIN_DIR)/read_2 \
+ $(BIN_DIR)/read_3 \
+ $(BIN_DIR)/read_4 \
+ $(BIN_DIR)/read_5 \
+ $(BIN_DIR)/read_6 \
+ $(BIN_DIR)/read_7 \
+ $(BIN_DIR)/read_8 \
+ $(BIN_DIR)/read_9 \
+ $(BIN_DIR)/read_10 \
+ $(BIN_DIR)/read_11 \
+ $(BIN_DIR)/read_12 \
+ $(BIN_DIR)/read_13
+
+G_MKDIR = $(BIN_DIR)/mkdir_1 \
+ $(BIN_DIR)/mkdir_2 \
+ $(BIN_DIR)/mkdir_3 \
+ $(BIN_DIR)/mkdir_4
+
+G_RMDIR = $(BIN_DIR)/rmdir_1 \
+ $(BIN_DIR)/rmdir_2 \
+ $(BIN_DIR)/rmdir_3 \
+ $(BIN_DIR)/rmdir_4 \
+ $(BIN_DIR)/rmdir_5 \
+ $(BIN_DIR)/rmdir_6
+
+G_READDIR = $(BIN_DIR)/readdir_1 \
+ $(BIN_DIR)/readdir_2 \
+ $(BIN_DIR)/readdir_3 \
+ $(BIN_DIR)/readdir_4 \
+ $(BIN_DIR)/readdir_5
+
+G_WRITE = $(BIN_DIR)/write_1 \
+ $(BIN_DIR)/write_2 \
+ $(BIN_DIR)/write_3 \
+ $(BIN_DIR)/write_4 \
+ $(BIN_DIR)/write_5 \
+ $(BIN_DIR)/write_6 \
+ $(BIN_DIR)/write_7 \
+ $(BIN_DIR)/write_8 \
+ $(BIN_DIR)/write_9 \
+ $(BIN_DIR)/write_10 \
+ $(BIN_DIR)/write_11 \
+ $(BIN_DIR)/write_12 \
+ $(BIN_DIR)/write_13
+
+G_TELLDIR = $(BIN_DIR)/telldir_1 \
+ $(BIN_DIR)/telldir_2 \
+ $(BIN_DIR)/telldir_3 \
+ $(BIN_DIR)/telldir_4 \
+ $(BIN_DIR)/telldir_5
+
+G_CHMOD = $(BIN_DIR)/chmod_1
+
+G_CHOWN = $(BIN_DIR)/chown_1
+
+G_PRINT_FILE = $(BIN_DIR)/print_file_1 \
+ $(BIN_DIR)/print_file_2 \
+ $(BIN_DIR)/print_file_3 \
+ $(BIN_DIR)/print_file_4
+
+G_OPEN_PRINT_JOB = $(BIN_DIR)/open_print_job_1 \
+ $(BIN_DIR)/open_print_job_2
+
+G_LIST_PRINT_JOBS = $(BIN_DIR)/list_print_jobs_1 \
+ $(BIN_DIR)/list_print_jobs_2 \
+ $(BIN_DIR)/list_print_jobs_3 \
+ $(BIN_DIR)/list_print_jobs_4 \
+ $(BIN_DIR)/list_print_jobs_5 \
+ $(BIN_DIR)/list_print_jobs_6 \
+ $(BIN_DIR)/list_print_jobs_7
+
+G_UNLINK_PRINT_JOB = $(BIN_DIR)/unlink_print_job_1 \
+ $(BIN_DIR)/unlink_print_job_2 \
+ $(BIN_DIR)/unlink_print_job_3 \
+ $(BIN_DIR)/unlink_print_job_4 \
+ $(BIN_DIR)/unlink_print_job_5
+
+GROUPS= $(G_CHMOD) $(G_CHOWN) $(G_CLOSE) $(G_CLOSEDIR) $(G_CREAT) $(G_FSTAT)\
+ $(G_GETDENTS) $(G_INIT) $(G_LIST_PRINT_JOBS) $(G_LSEEK) $(G_LSEEKDIR) \
+ $(G_MKDIR) $(G_OPEN) $(G_OPENDIR) $(G_OPEN_PRINT_JOB) $(G_PRINT_FILE)\
+ $(G_READ) $(G_READDIR) $(G_RENAME) $(G_RMDIR) $(G_STAT) $(G_TELLDIR) $(G_UNLINK) \
+ $(G_UNLINK_PRINT_JOB) $(G_WRITE)
+
+.c.o:
+ @echo Compiling $*.c
+ @$(CC) -c $(CFLAGS) -o $@ $(INCPATH) $<
+
+
+all: $(GROUPS)
+
+init: $(G_INIT)
+fstat: $(G_FSTAT)
+open: $(G_OPEN)
+unlink: $(G_UNLINK)
+chown: $(G_CHOWN)
+close: $(G_CLOSE)
+opendir: $(G_OPENDIR)
+closedir: $(G_CLOSEDIR)
+rename: $(G_RENAME)
+readdir: $(G_READDIR)
+lseek: $(G_LSEEK)
+lseekdir: $(G_LSEEKDIR)
+stat: $(G_STAT)
+getdents: $(G_GETDENTS)
+creat: $(G_CREAT)
+read: $(G_READ)
+mkdir: $(G_MKDIR)
+rmdir: $(G_RMDIR)
+write: $(G_WRITE)
+chmod: $(G_CHMOD)
+telldir: $(G_TELLDIR)
+print_file: $(G_PRINT_FILE)
+open_print_job: $(G_OPEN_PRINT_JOB)
+list_print_jobs: $(G_LIST_PRINT_JOBS)
+unlink_print_job: $(G_UNLINK_PRINT_JOB)
+
+
+$(BIN_DIR)/testsmbc: testsmbc.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ testsmbc.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/init_1: init/init_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ init/init_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/init_2: init/init_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ init/init_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/init_3: init/init_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ init/init_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/init_4: init/init_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ init/init_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/fstat_1: fstat/fstat_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ fstat/fstat_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/fstat_2: fstat/fstat_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ fstat/fstat_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/fstat_3: fstat/fstat_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ fstat/fstat_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/fstat_4: fstat/fstat_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ fstat/fstat_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/fstat_5: fstat/fstat_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ fstat/fstat_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/fstat_6: fstat/fstat_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ fstat/fstat_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_1: open/open_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open/open_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_2: open/open_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open/open_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_3: open/open_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open/open_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_4: open/open_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open/open_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_5: open/open_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open/open_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_1: unlink/unlink_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_2: unlink/unlink_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_3: unlink/unlink_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_4: unlink/unlink_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_5: unlink/unlink_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_6: unlink/unlink_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_7: unlink/unlink_7.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_7.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_8: unlink/unlink_8.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_8.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_9: unlink/unlink_9.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_9.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_10: unlink/unlink_10.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_10.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_11: unlink/unlink_11.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_11.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_12: unlink/unlink_12.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink/unlink_12.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/chown_1: chown/chown_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ chown/chown_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/close_1: close/close_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ close/close_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/close_2: close/close_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ close/close_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/opendir_1: opendir/opendir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ opendir/opendir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/opendir_2: opendir/opendir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ opendir/opendir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/opendir_3: opendir/opendir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ opendir/opendir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/opendir_4: opendir/opendir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ opendir/opendir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/closedir_1: closedir/closedir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ closedir/closedir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/closedir_2: closedir/closedir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ closedir/closedir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/closedir_3: closedir/closedir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ closedir/closedir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/closedir_4: closedir/closedir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ closedir/closedir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_1: rename/rename_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_2: rename/rename_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_3: rename/rename_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_4: rename/rename_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_5: rename/rename_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_6: rename/rename_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_7: rename/rename_7.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_7.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_8: rename/rename_8.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_8.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_9: rename/rename_9.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_9.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_10: rename/rename_10.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_10.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_11: rename/rename_11.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_11.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_12: rename/rename_12.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_12.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_13: rename/rename_13.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_13.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rename_14: rename/rename_14.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rename/rename_14.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_1: lseek/lseek_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_2: lseek/lseek_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_3: lseek/lseek_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_4: lseek/lseek_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_5: lseek/lseek_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_6: lseek/lseek_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_7: lseek/lseek_7.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_7.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseek_8: lseek/lseek_8.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseek/lseek_8.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseekdir_1: lseekdir/lseekdir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseekdir/lseekdir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseekdir_2: lseekdir/lseekdir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseekdir/lseekdir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseekdir_3: lseekdir/lseekdir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseekdir/lseekdir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseekdir_4: lseekdir/lseekdir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseekdir/lseekdir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseekdir_5: lseekdir/lseekdir_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseekdir/lseekdir_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/lseekdir_6: lseekdir/lseekdir_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ lseekdir/lseekdir_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/stat_1: stat/stat_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ stat/stat_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/stat_2: stat/stat_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ stat/stat_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/stat_3: stat/stat_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ stat/stat_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/stat_4: stat/stat_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ stat/stat_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/stat_5: stat/stat_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ stat/stat_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/stat_6: stat/stat_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ stat/stat_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/getdents_1: getdents/getdents_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ getdents/getdents_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/getdents_2: getdents/getdents_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ getdents/getdents_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/getdents_3: getdents/getdents_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ getdents/getdents_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/getdents_4: getdents/getdents_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ getdents/getdents_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/getdents_5: getdents/getdents_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ getdents/getdents_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/creat_1: creat/creat_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ creat/creat_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/creat_2: creat/creat_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ creat/creat_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/creat_3: creat/creat_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ creat/creat_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/mkdir_1: mkdir/mkdir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ mkdir/mkdir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/mkdir_2: mkdir/mkdir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ mkdir/mkdir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/mkdir_3: mkdir/mkdir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ mkdir/mkdir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/mkdir_4: mkdir/mkdir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ mkdir/mkdir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/readdir_1: readdir/readdir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ readdir/readdir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/readdir_2: readdir/readdir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ readdir/readdir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/readdir_3: readdir/readdir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ readdir/readdir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/readdir_4: readdir/readdir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ readdir/readdir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/readdir_5: readdir/readdir_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ readdir/readdir_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rmdir_1: rmdir/rmdir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rmdir/rmdir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rmdir_2: rmdir/rmdir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rmdir/rmdir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rmdir_3: rmdir/rmdir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rmdir/rmdir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rmdir_4: rmdir/rmdir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rmdir/rmdir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rmdir_5: rmdir/rmdir_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rmdir/rmdir_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/rmdir_6: rmdir/rmdir_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ rmdir/rmdir_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_1: write/write_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_2: write/write_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_3: write/write_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_4: write/write_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_5: write/write_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_6: write/write_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_7: write/write_7.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_7.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_8: write/write_8.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_8.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_9: write/write_9.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_9.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_10: write/write_10.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_10.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_11: write/write_11.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_11.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_12: write/write_12.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_12.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/write_13: write/write_13.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ write/write_13.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_1: read/read_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_2: read/read_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_3: read/read_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_4: read/read_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_5: read/read_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_6: read/read_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_7: read/read_7.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_7.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_8: read/read_8.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_8.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_9: read/read_9.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_9.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_10: read/read_10.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_10.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_11: read/read_11.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_11.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_12: read/read_12.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_12.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/read_13: read/read_13.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ read/read_13.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/chmod_1: chmod/chmod_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ chmod/chmod_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/telldir_1: telldir/telldir_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ telldir/telldir_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/telldir_2: telldir/telldir_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ telldir/telldir_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/telldir_3: telldir/telldir_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ telldir/telldir_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/telldir_4: telldir/telldir_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ telldir/telldir_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/telldir_5: telldir/telldir_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ telldir/telldir_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/print_file_1: print_file/print_file_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ print_file/print_file_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/print_file_2: print_file/print_file_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ print_file/print_file_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/print_file_3: print_file/print_file_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ print_file/print_file_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/print_file_4: print_file/print_file_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ print_file/print_file_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_print_job_1: open_print_job/open_print_job_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open_print_job/open_print_job_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/open_print_job_2: open_print_job/open_print_job_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ open_print_job/open_print_job_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_1: list_print_jobs/list_print_jobs_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_2: list_print_jobs/list_print_jobs_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_3: list_print_jobs/list_print_jobs_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_4: list_print_jobs/list_print_jobs_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_5: list_print_jobs/list_print_jobs_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_5.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_6: list_print_jobs/list_print_jobs_6.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_6.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/list_print_jobs_7: list_print_jobs/list_print_jobs_7.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ list_print_jobs/list_print_jobs_7.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_print_job_1: unlink_print_job/unlink_print_job_1.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink_print_job/unlink_print_job_1.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_print_job_2: unlink_print_job/unlink_print_job_2.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink_print_job/unlink_print_job_2.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_print_job_3: unlink_print_job/unlink_print_job_3.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink_print_job/unlink_print_job_3.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_print_job_4: unlink_print_job/unlink_print_job_4.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink_print_job/unlink_print_job_4.o $(INCPATH) $(LIBS)
+
+$(BIN_DIR)/unlink_print_job_5: unlink_print_job/unlink_print_job_5.o
+ @echo Linking $@
+ @$(CC) $(LFLAGS) -o $@ unlink_print_job/unlink_print_job_5.o $(INCPATH) $(LIBS)
+
+
+clean:
+ @for i in $(SUB_DIRS); do \
+ rm -f $$i/*.o; \
+ done
+
+ @rm -f $(GROUPS)
+ @echo "Done"
+
diff --git a/testsuite/libsmbclient/src/chmod/chmod_1.c b/testsuite/libsmbclient/src/chmod/chmod_1.c
new file mode 100644
index 00000000000..47c86b1f809
--- /dev/null
+++ b/testsuite/libsmbclient/src/chmod/chmod_1.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ fd = smbc_init(auth_fn, 0);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/chown/chown_1.c b/testsuite/libsmbclient/src/chown/chown_1.c
new file mode 100644
index 00000000000..47c86b1f809
--- /dev/null
+++ b/testsuite/libsmbclient/src/chown/chown_1.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ fd = smbc_init(auth_fn, 0);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/close/close_1.c b/testsuite/libsmbclient/src/close/close_1.c
new file mode 100644
index 00000000000..983e627d897
--- /dev/null
+++ b/testsuite/libsmbclient/src/close/close_1.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ err = smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/close/close_2.c b/testsuite/libsmbclient/src/close/close_2.c
new file mode 100644
index 00000000000..b0319e41d9d
--- /dev/null
+++ b/testsuite/libsmbclient/src/close/close_2.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/closedir/closedir_1.c b/testsuite/libsmbclient/src/closedir/closedir_1.c
new file mode 100644
index 00000000000..702b92c24ab
--- /dev/null
+++ b/testsuite/libsmbclient/src/closedir/closedir_1.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ err = smbc_closedir(dh);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/closedir/closedir_2.c b/testsuite/libsmbclient/src/closedir/closedir_2.c
new file mode 100644
index 00000000000..88b6e2ce7e8
--- /dev/null
+++ b/testsuite/libsmbclient/src/closedir/closedir_2.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ smbc_closedir(dh);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/closedir/closedir_3.c b/testsuite/libsmbclient/src/closedir/closedir_3.c
new file mode 100644
index 00000000000..4fdc9c849c5
--- /dev/null
+++ b/testsuite/libsmbclient/src/closedir/closedir_3.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ err = smbc_closedir(dh);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/closedir/closedir_4.c b/testsuite/libsmbclient/src/closedir/closedir_4.c
new file mode 100644
index 00000000000..ee1d72bae39
--- /dev/null
+++ b/testsuite/libsmbclient/src/closedir/closedir_4.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ smbc_closedir(dh);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/creat/creat_1.c b/testsuite/libsmbclient/src/creat/creat_1.c
new file mode 100644
index 00000000000..9ccab002c13
--- /dev/null
+++ b/testsuite/libsmbclient/src/creat/creat_1.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_creat(url, 0666);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/creat/creat_2.c b/testsuite/libsmbclient/src/creat/creat_2.c
new file mode 100644
index 00000000000..599a1845d34
--- /dev/null
+++ b/testsuite/libsmbclient/src/creat/creat_2.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+ fd = 0;
+ fd = smbc_creat(url, 0666);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/creat/creat_3.c b/testsuite/libsmbclient/src/creat/creat_3.c
new file mode 100644
index 00000000000..ae27a2a1c90
--- /dev/null
+++ b/testsuite/libsmbclient/src/creat/creat_3.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_creat(url, 0666);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/fstat/fstat_1.c b/testsuite/libsmbclient/src/fstat/fstat_1.c
new file mode 100644
index 00000000000..fd63400869d
--- /dev/null
+++ b/testsuite/libsmbclient/src/fstat/fstat_1.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ smbc_init(auth_fn, 0);
+
+ fd = 11234;
+ err = smbc_fstat(fd,&st);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/fstat/fstat_2.c b/testsuite/libsmbclient/src/fstat/fstat_2.c
new file mode 100644
index 00000000000..ea2e7e3145f
--- /dev/null
+++ b/testsuite/libsmbclient/src/fstat/fstat_2.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ smbc_init(auth_fn, 0);
+
+ fd = 11234;
+ smbc_fstat(fd,&st);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/fstat/fstat_3.c b/testsuite/libsmbclient/src/fstat/fstat_3.c
new file mode 100644
index 00000000000..57bb3b7557d
--- /dev/null
+++ b/testsuite/libsmbclient/src/fstat/fstat_3.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ err = smbc_fstat(fd, &st);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/fstat/fstat_4.c b/testsuite/libsmbclient/src/fstat/fstat_4.c
new file mode 100644
index 00000000000..57bb3b7557d
--- /dev/null
+++ b/testsuite/libsmbclient/src/fstat/fstat_4.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ err = smbc_fstat(fd, &st);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/fstat/fstat_5.c b/testsuite/libsmbclient/src/fstat/fstat_5.c
new file mode 100644
index 00000000000..9ebdd602646
--- /dev/null
+++ b/testsuite/libsmbclient/src/fstat/fstat_5.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+
+ smbc_fstat(fd,&st);
+
+ smbc_close(fd);
+ free(message);
+
+ if ( st.st_size != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/fstat/fstat_6.c b/testsuite/libsmbclient/src/fstat/fstat_6.c
new file mode 100644
index 00000000000..8a38e5be346
--- /dev/null
+++ b/testsuite/libsmbclient/src/fstat/fstat_6.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ unsigned int mode_mask = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+
+ smbc_fstat(fd,&st);
+
+ smbc_close(fd);
+ free(message);
+
+ mode_mask = mode_mask | S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; /* 0666 or 33206 */
+
+ if ( st.st_mode != mode_mask )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/getdents/getdents_1.c b/testsuite/libsmbclient/src/getdents/getdents_1.c
new file mode 100644
index 00000000000..6e253f78c5c
--- /dev/null
+++ b/testsuite/libsmbclient/src/getdents/getdents_1.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ /* int dirsize = 0; */
+ /* int dircount = 0; */
+
+ struct smbc_dirent *dirptr;
+
+ char url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ err = smbc_getdents( dh, dirptr, sizeof(dirbuff));
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/getdents/getdents_2.c b/testsuite/libsmbclient/src/getdents/getdents_2.c
new file mode 100644
index 00000000000..e7eb959a8f5
--- /dev/null
+++ b/testsuite/libsmbclient/src/getdents/getdents_2.c
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ /* int dirsize = 0; */
+ /* int dircount = 0; */
+
+ struct smbc_dirent *dirptr;
+
+ char url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ err = smbc_getdents( dh, dirptr, sizeof(dirbuff));
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/getdents/getdents_3.c b/testsuite/libsmbclient/src/getdents/getdents_3.c
new file mode 100644
index 00000000000..58c8f709a96
--- /dev/null
+++ b/testsuite/libsmbclient/src/getdents/getdents_3.c
@@ -0,0 +1,155 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ int j = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+ int direntsize = 0;
+ int diramount = 0;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ diramount = smbc_getdents( dh, dirptr, sizeof(dirbuff));
+
+ err = 0;
+ i = 0;
+ bzero(buff,MAX_BUFF_SIZE);
+ bzero(tmp_file_ptr,MAX_BUFF_SIZE-9);
+
+ while ( diramount > 0 )
+ {
+ direntsize = dirptr->dirlen;
+ /* printf("Name: %s\n",dirptr->name); */
+ if ( j == 0 )
+ {
+ if ( !(( strncmp(dirptr->name,".",1) == 0 )) )
+ {
+ break;
+ err = 1;
+ }
+
+ } else if ( j == 1 ) {
+
+ if ( !(( strncmp(dirptr->name,"..",2) == 0 )) )
+ {
+ break;
+ err = 1;
+ }
+
+ } else if ( j > 1 ) {
+
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+
+ if ( !((strcmp(dirptr->name,file_url) == 0 )) ) /* make sure entries match */
+ {
+ err = 1;
+ break;
+ }
+
+ i++;
+
+ }
+
+ (char *)dirptr += direntsize;
+ (char *)diramount -= direntsize;
+ j++;
+
+ }
+
+ if ( ! err )
+ {
+ if ( (j - 2) != entry_num ) /* Make sure that all entries created are counted and returned - minus . and .. */
+ err = 1;
+ }
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/getdents/getdents_4.c b/testsuite/libsmbclient/src/getdents/getdents_4.c
new file mode 100644
index 00000000000..4afd3539b8e
--- /dev/null
+++ b/testsuite/libsmbclient/src/getdents/getdents_4.c
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+ int diramount = 0;
+
+ struct smbc_dirent *dirptr;
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ diramount = smbc_getdents( dh, dirptr, 20 /*sizeof(dirbuff)*/ );
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/getdents/getdents_5.c b/testsuite/libsmbclient/src/getdents/getdents_5.c
new file mode 100644
index 00000000000..5cf7c1b9282
--- /dev/null
+++ b/testsuite/libsmbclient/src/getdents/getdents_5.c
@@ -0,0 +1,106 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+ int diramount = 0;
+
+ struct smbc_dirent *dirptr;
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ diramount = smbc_getdents( dh, dirptr, 20 /* sizeof(dirbuff)*/);
+
+ if ( diramount < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/init/init_1.c b/testsuite/libsmbclient/src/init/init_1.c
new file mode 100644
index 00000000000..bc928ac3d5c
--- /dev/null
+++ b/testsuite/libsmbclient/src/init/init_1.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+
+int main()
+{
+ int err = -1;
+
+ err = smbc_init(NULL, 0);
+
+ if ( err < 0 )
+ err = 1;
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/init/init_2.c b/testsuite/libsmbclient/src/init/init_2.c
new file mode 100644
index 00000000000..120160297b6
--- /dev/null
+++ b/testsuite/libsmbclient/src/init/init_2.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+
+int main(int argc, char **argv )
+{
+ int err = -1;
+
+ if ( argc > 1 )
+ {
+ err = smbc_init(NULL, atoi(argv[1]));
+
+ if ( err < 0 )
+ err = 1;
+
+ }
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/init/init_3.c b/testsuite/libsmbclient/src/init/init_3.c
new file mode 100644
index 00000000000..f49ed982e18
--- /dev/null
+++ b/testsuite/libsmbclient/src/init/init_3.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ err = smbc_init(auth_fn, atoi(argv[4]));
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/init/init_4.c b/testsuite/libsmbclient/src/init/init_4.c
new file mode 100644
index 00000000000..d8e44b50eed
--- /dev/null
+++ b/testsuite/libsmbclient/src/init/init_4.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+
+int main( )
+{
+ int err = -1;
+
+ err = smbc_init(NULL, 0);
+
+ err = errno;
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_1.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_1.c
new file mode 100644
index 00000000000..714f08fd723
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_1.c
@@ -0,0 +1,109 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+int call_back_flag;
+int print_queue_empty;
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn_2(struct print_job_info *pji)
+{
+ print_queue_empty = 0;
+ g_print_id = pji->id;
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ call_back_flag = 1;
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+ call_back_flag = 0;
+ print_queue_empty = 0;
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ while ( ! print_queue_empty ) /* Wait until the queue is empty */
+ {
+ sleep(1);
+ print_queue_empty = 1;
+ smbc_list_print_jobs(url,print_list_fn_2);
+ }
+
+ smbc_list_print_jobs(url,print_list_fn);
+
+ if ( call_back_flag )
+
+ err = 0;
+
+ else
+ err = 1;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_2.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_2.c
new file mode 100644
index 00000000000..6d6874716cc
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_2.c
@@ -0,0 +1,105 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+int print_queue_empty;
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn_2(struct print_job_info *pji)
+{
+ print_queue_empty = 0;
+ g_print_id = pji->id;
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ print_queue_empty = 0;
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ while ( ! print_queue_empty ) /* Wait until the queue is empty */
+ {
+ sleep(1);
+ print_queue_empty = 1;
+ smbc_list_print_jobs(url,print_list_fn_2);
+ }
+
+ err = smbc_list_print_jobs(url,print_list_fn);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_3.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_3.c
new file mode 100644
index 00000000000..1cb52d08941
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_3.c
@@ -0,0 +1,103 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ err = smbc_list_print_jobs(argv[6],print_list_fn);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_4.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_4.c
new file mode 100644
index 00000000000..ad207724b46
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_4.c
@@ -0,0 +1,99 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ err = smbc_list_print_jobs(argv[6],print_list_fn);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_5.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_5.c
new file mode 100644
index 00000000000..874bc896d06
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_5.c
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+int print_queue_empty;
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn_2(struct print_job_info *pji)
+{
+ print_queue_empty = 0;
+ g_print_id = pji->id;
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ print_queue_empty = 0;
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ while ( ! print_queue_empty ) /* Wait until the queue is empty */
+ {
+ sleep(1);
+ print_queue_empty = 1;
+ smbc_list_print_jobs(url,print_list_fn_2);
+ }
+
+ smbc_list_print_jobs(url,print_list_fn);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_6.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_6.c
new file mode 100644
index 00000000000..7b691ae75ac
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_6.c
@@ -0,0 +1,110 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+int print_fn_call_flag;
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+
+ print_fn_call_flag = 1;
+
+}
+
+int main(int argc, char** argv)
+{
+
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char * message;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ print_fn_call_flag = 0;
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ smbc_list_print_jobs(url,print_list_fn);
+
+ if ( print_fn_call_flag == 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_7.c b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_7.c
new file mode 100644
index 00000000000..d25d20721b1
--- /dev/null
+++ b/testsuite/libsmbclient/src/list_print_jobs/list_print_jobs_7.c
@@ -0,0 +1,106 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ smbc_print_file(url,argv[6]);
+ smbc_list_print_jobs(argv[6],print_list_fn);
+
+
+ if (( (g_print_size > 0) && (g_print_size > 0) && (strcasecmp(g_username,g_print_user)==0) ))
+ /* && (strlen(g_print_name) > 0) )) */
+ err = 0;
+
+ else
+ err = 1;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_1.c b/testsuite/libsmbclient/src/lseek/lseek_1.c
new file mode 100644
index 00000000000..c358565d31c
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_1.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ smbc_init(auth_fn, 0);
+
+ fd = -1;
+ err = smbc_lseek(fd, 0, SEEK_SET);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_2.c b/testsuite/libsmbclient/src/lseek/lseek_2.c
new file mode 100644
index 00000000000..8b58ade0836
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_2.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ smbc_init(auth_fn, 0);
+
+ fd = -1;
+ smbc_lseek(fd, 0, SEEK_SET);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_3.c b/testsuite/libsmbclient/src/lseek/lseek_3.c
new file mode 100644
index 00000000000..c8a62e682b2
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_3.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_lseek(fd,msg_len,SEEK_SET);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ free(message);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_4.c b/testsuite/libsmbclient/src/lseek/lseek_4.c
new file mode 100644
index 00000000000..c8a62e682b2
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_4.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_lseek(fd,msg_len,SEEK_SET);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ free(message);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_5.c b/testsuite/libsmbclient/src/lseek/lseek_5.c
new file mode 100644
index 00000000000..2e40c96410c
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_5.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_lseek(fd,msg_len,SEEK_SET);
+ smbc_close(fd);
+
+ if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ free(message);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_6.c b/testsuite/libsmbclient/src/lseek/lseek_6.c
new file mode 100644
index 00000000000..b5236b8537e
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_6.c
@@ -0,0 +1,75 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_lseek(fd,msg_len,SEEK_SET);
+ err = errno;
+ smbc_close(fd);
+
+ free(message);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_7.c b/testsuite/libsmbclient/src/lseek/lseek_7.c
new file mode 100644
index 00000000000..e3ef6cdd544
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_7.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_lseek(fd,0,SEEK_END);
+ smbc_close(fd);
+
+ if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ free(message);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseek/lseek_8.c b/testsuite/libsmbclient/src/lseek/lseek_8.c
new file mode 100644
index 00000000000..e70f3ca6b55
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseek/lseek_8.c
@@ -0,0 +1,75 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_lseek(fd,0,SEEK_END);
+ err = errno;
+ smbc_close(fd);
+
+ free(message);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseekdir/lseekdir_1.c b/testsuite/libsmbclient/src/lseekdir/lseekdir_1.c
new file mode 100644
index 00000000000..010ca382a59
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseekdir/lseekdir_1.c
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ err = smbc_lseekdir(dh,0);
+ /* printf("err: %i\n",err); */
+
+ if ( err < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseekdir/lseekdir_2.c b/testsuite/libsmbclient/src/lseekdir/lseekdir_2.c
new file mode 100644
index 00000000000..cb729d8642e
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseekdir/lseekdir_2.c
@@ -0,0 +1,95 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ smbc_lseekdir(dh,0);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseekdir/lseekdir_3.c b/testsuite/libsmbclient/src/lseekdir/lseekdir_3.c
new file mode 100644
index 00000000000..ede9cef0815
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseekdir/lseekdir_3.c
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ err = smbc_lseekdir(dh,0);
+ /* printf("err: %i\n",err); */
+
+ if ( err < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseekdir/lseekdir_4.c b/testsuite/libsmbclient/src/lseekdir/lseekdir_4.c
new file mode 100644
index 00000000000..1bc9a7e45d0
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseekdir/lseekdir_4.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ smbc_lseekdir(dh,0);
+ err = errno;
+ /* printf("err: %i\n",err); */
+
+
+ }
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/lseekdir/lseekdir_5.c b/testsuite/libsmbclient/src/lseekdir/lseekdir_5.c
new file mode 100644
index 00000000000..08af806f5fe
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseekdir/lseekdir_5.c
@@ -0,0 +1,119 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ int dirsize = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ err = 0;
+
+ while ( 1 )
+ {
+ dirptr = smbc_readdir(dh);
+
+ if ( dirptr == NULL )
+ {
+ break;
+ }
+
+ (char*)dirsize += dirptr->dirlen;
+
+ }
+
+ smbc_lseekdir(dh,0);
+ err = smbc_telldir(dh);
+
+ if ( err != 0 )
+ err = 1;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/lseekdir/lseekdir_6.c b/testsuite/libsmbclient/src/lseekdir/lseekdir_6.c
new file mode 100644
index 00000000000..543cbafe140
--- /dev/null
+++ b/testsuite/libsmbclient/src/lseekdir/lseekdir_6.c
@@ -0,0 +1,124 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ int offset = 0;
+ int dirsize = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ err = 0;
+
+ while ( 1 )
+ {
+ dirptr = smbc_readdir(dh);
+
+ if ( dirptr == NULL )
+ {
+ break;
+ }
+
+ (char*)dirsize += dirptr->dirlen;
+
+ }
+
+ smbc_lseekdir(dh,0); /* move to front */
+ smbc_lseekdir(dh,dirsize); /* move to end */
+ offset = smbc_telldir(dh);
+
+ if ( offset != dirsize )
+ {
+ /* printf("offset: %i dirsize: %i\n",offset,dirsize); */
+ err = 1;
+ }
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/mkdir/mkdir_1.c b/testsuite/libsmbclient/src/mkdir/mkdir_1.c
new file mode 100644
index 00000000000..20389bcb9b6
--- /dev/null
+++ b/testsuite/libsmbclient/src/mkdir/mkdir_1.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_rmdir( url );
+ err = smbc_mkdir( url, 0666 );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/mkdir/mkdir_2.c b/testsuite/libsmbclient/src/mkdir/mkdir_2.c
new file mode 100644
index 00000000000..ebbc94a18bb
--- /dev/null
+++ b/testsuite/libsmbclient/src/mkdir/mkdir_2.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_rmdir( url );
+ smbc_mkdir( url, 0666 );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/mkdir/mkdir_3.c b/testsuite/libsmbclient/src/mkdir/mkdir_3.c
new file mode 100644
index 00000000000..e5a0ce2561f
--- /dev/null
+++ b/testsuite/libsmbclient/src/mkdir/mkdir_3.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_rmdir( url );
+
+ smbc_mkdir( url, 0666 );
+ smbc_mkdir( url, 0666 );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/mkdir/mkdir_4.c b/testsuite/libsmbclient/src/mkdir/mkdir_4.c
new file mode 100644
index 00000000000..ed1aa70f33f
--- /dev/null
+++ b/testsuite/libsmbclient/src/mkdir/mkdir_4.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_rmdir( url );
+
+ smbc_mkdir( url, 0666 );
+ err = smbc_mkdir( url, 0666 );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open/open_1.c b/testsuite/libsmbclient/src/open/open_1.c
new file mode 100644
index 00000000000..9f72985cec7
--- /dev/null
+++ b/testsuite/libsmbclient/src/open/open_1.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open/open_2.c b/testsuite/libsmbclient/src/open/open_2.c
new file mode 100644
index 00000000000..8903ee912b0
--- /dev/null
+++ b/testsuite/libsmbclient/src/open/open_2.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open/open_3.c b/testsuite/libsmbclient/src/open/open_3.c
new file mode 100644
index 00000000000..25a663d6ab7
--- /dev/null
+++ b/testsuite/libsmbclient/src/open/open_3.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open/open_4.c b/testsuite/libsmbclient/src/open/open_4.c
new file mode 100644
index 00000000000..2bfe30f1af1
--- /dev/null
+++ b/testsuite/libsmbclient/src/open/open_4.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+ fd = 0;
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open/open_5.c b/testsuite/libsmbclient/src/open/open_5.c
new file mode 100644
index 00000000000..93ffb4891ed
--- /dev/null
+++ b/testsuite/libsmbclient/src/open/open_5.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open_print_job/open_print_job_1.c b/testsuite/libsmbclient/src/open_print_job/open_print_job_1.c
new file mode 100644
index 00000000000..585fdee377f
--- /dev/null
+++ b/testsuite/libsmbclient/src/open_print_job/open_print_job_1.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open_print_job(url);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/open_print_job/open_print_job_2.c b/testsuite/libsmbclient/src/open_print_job/open_print_job_2.c
new file mode 100644
index 00000000000..f737f19bfec
--- /dev/null
+++ b/testsuite/libsmbclient/src/open_print_job/open_print_job_2.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open_print_job(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/opendir/opendir_1.c b/testsuite/libsmbclient/src/opendir/opendir_1.c
new file mode 100644
index 00000000000..1bd01b5feeb
--- /dev/null
+++ b/testsuite/libsmbclient/src/opendir/opendir_1.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+
+ if ( dh < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/opendir/opendir_2.c b/testsuite/libsmbclient/src/opendir/opendir_2.c
new file mode 100644
index 00000000000..60658d2cd56
--- /dev/null
+++ b/testsuite/libsmbclient/src/opendir/opendir_2.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_opendir(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/opendir/opendir_3.c b/testsuite/libsmbclient/src/opendir/opendir_3.c
new file mode 100644
index 00000000000..3b6f28eaf34
--- /dev/null
+++ b/testsuite/libsmbclient/src/opendir/opendir_3.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR|O_CREAT,0666);
+ smbc_close(fd);
+
+ err = smbc_opendir(url);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/opendir/opendir_4.c b/testsuite/libsmbclient/src/opendir/opendir_4.c
new file mode 100644
index 00000000000..23b25e55063
--- /dev/null
+++ b/testsuite/libsmbclient/src/opendir/opendir_4.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR|O_CREAT,0666);
+ smbc_close(fd);
+
+ smbc_opendir(url);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/print_file/print_file_1.c b/testsuite/libsmbclient/src/print_file/print_file_1.c
new file mode 100644
index 00000000000..19932aa3192
--- /dev/null
+++ b/testsuite/libsmbclient/src/print_file/print_file_1.c
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ err = smbc_print_file(url,argv[6]);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/print_file/print_file_2.c b/testsuite/libsmbclient/src/print_file/print_file_2.c
new file mode 100644
index 00000000000..a569cd8fe97
--- /dev/null
+++ b/testsuite/libsmbclient/src/print_file/print_file_2.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ smbc_print_file(url,argv[6]);
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/print_file/print_file_3.c b/testsuite/libsmbclient/src/print_file/print_file_3.c
new file mode 100644
index 00000000000..4b2a6af84f2
--- /dev/null
+++ b/testsuite/libsmbclient/src/print_file/print_file_3.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+
+ char url[MAX_BUFF_SIZE];
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ err = smbc_print_file(url,argv[6]);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/print_file/print_file_4.c b/testsuite/libsmbclient/src/print_file/print_file_4.c
new file mode 100644
index 00000000000..1650f7340df
--- /dev/null
+++ b/testsuite/libsmbclient/src/print_file/print_file_4.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+
+ char url[MAX_BUFF_SIZE];
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_print_file(url,argv[6]);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/read/read_1.c b/testsuite/libsmbclient/src/read/read_1.c
new file mode 100644
index 00000000000..accf0bf8721
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_1.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url,O_RDWR, 0666);
+ err = smbc_read(fd,response,msg_len);
+
+ free(message);
+ free(response);
+
+ if ( err < 0 )
+ err = 1;
+
+ else if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_10.c b/testsuite/libsmbclient/src/read/read_10.c
new file mode 100644
index 00000000000..d5b66dfe635
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_10.c
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message = NULL;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ msg_len = 10;
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+
+ err = errno;
+
+ smbc_close(fd);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_11.c b/testsuite/libsmbclient/src/read/read_11.c
new file mode 100644
index 00000000000..3f9ae3f97da
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_11.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDONLY, 0666);
+ smbc_read(fd,response,msg_len);
+ smbc_close(fd);
+
+ if ( memcmp ( message, response, msg_len) == 0 )
+ err = 0;
+
+ else
+ err = 1;
+
+ free(message);
+ free(response);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_12.c b/testsuite/libsmbclient/src/read/read_12.c
new file mode 100644
index 00000000000..2747f62e1c8
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_12.c
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ strncpy(g_username,"xxxxxxxx",8);
+ strncpy(g_password,"xxxxxxxx",8);
+
+ fd = smbc_open(url, O_RDONLY, 0666);
+
+ err = smbc_read(fd,response,msg_len);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ free(message);
+ free(response);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_13.c b/testsuite/libsmbclient/src/read/read_13.c
new file mode 100644
index 00000000000..89bc68f915b
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_13.c
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ strncpy(g_username,"xxxxxxxx",8);
+ strncpy(g_password,"xxxxxxxx",8);
+
+ fd = smbc_open(url, O_RDONLY, 0666);
+
+ if (fd < 0)
+
+ err = errno;
+
+ else {
+
+ err = smbc_read(fd,response,msg_len);
+ err = errno;
+
+ smbc_close(fd);
+
+ }
+
+ free(message);
+ free(response);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_2.c b/testsuite/libsmbclient/src/read/read_2.c
new file mode 100644
index 00000000000..4b3dc9439c1
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_2.c
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url,O_RDWR, 0666);
+ smbc_read(fd,response,msg_len);
+ err = errno;
+
+ free(message);
+ free(response);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_3.c b/testsuite/libsmbclient/src/read/read_3.c
new file mode 100644
index 00000000000..3f4493487e7
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_3.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url,O_WRONLY, 0666);
+ err = smbc_read(fd,response,msg_len);
+
+ free(message);
+ free(response);
+
+ if ( err < 0 )
+ err = 1;
+
+ else if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_4.c b/testsuite/libsmbclient/src/read/read_4.c
new file mode 100644
index 00000000000..dbacfa392e8
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_4.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ bzero(response,msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url,O_WRONLY, 0666);
+ smbc_read(fd,response,msg_len);
+ err = errno;
+
+ free(message);
+ free(response);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_5.c b/testsuite/libsmbclient/src/read/read_5.c
new file mode 100644
index 00000000000..96891ef8da6
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_5.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url,O_RDONLY, 0666);
+ err = smbc_read(fd,response,msg_len);
+
+ free(message);
+ free(response);
+
+ if ( err < 0 )
+ err = 1;
+
+ else if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_6.c b/testsuite/libsmbclient/src/read/read_6.c
new file mode 100644
index 00000000000..7839a964ee4
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_6.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ bzero(response,msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url,O_RDONLY, 0666);
+ smbc_read(fd,response,msg_len);
+ err = errno;
+
+ free(message);
+ free(response);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_7.c b/testsuite/libsmbclient/src/read/read_7.c
new file mode 100644
index 00000000000..fa8a783d7fa
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_7.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char* message = "Testing";
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ fd = 10345; /* Random value for File Descriptor */
+ smbc_init(auth_fn, 0);
+ err = smbc_read(fd, message, sizeof(message));
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_8.c b/testsuite/libsmbclient/src/read/read_8.c
new file mode 100644
index 00000000000..e3f7055d3f4
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_8.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char* message = "Testing";
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ fd = 10345; /* Random value for File Descriptor */
+ smbc_init(auth_fn, 0);
+ err = smbc_read(fd, message, sizeof(message));
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/read/read_9.c b/testsuite/libsmbclient/src/read/read_9.c
new file mode 100644
index 00000000000..77468317d92
--- /dev/null
+++ b/testsuite/libsmbclient/src/read/read_9.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message = NULL;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ msg_len = 10;
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_read(fd, message, msg_len);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/readdir/readdir_1.c b/testsuite/libsmbclient/src/readdir/readdir_1.c
new file mode 100644
index 00000000000..5ca7e38bf8d
--- /dev/null
+++ b/testsuite/libsmbclient/src/readdir/readdir_1.c
@@ -0,0 +1,107 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ dirptr = smbc_readdir( dh );
+
+ if ( dirptr == NULL )
+
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/readdir/readdir_2.c b/testsuite/libsmbclient/src/readdir/readdir_2.c
new file mode 100644
index 00000000000..bc4f53dd859
--- /dev/null
+++ b/testsuite/libsmbclient/src/readdir/readdir_2.c
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ dirptr = smbc_readdir( dh );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/readdir/readdir_3.c b/testsuite/libsmbclient/src/readdir/readdir_3.c
new file mode 100644
index 00000000000..06a4c9eded1
--- /dev/null
+++ b/testsuite/libsmbclient/src/readdir/readdir_3.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+
+ struct smbc_dirent *dirptr;
+
+
+ char url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ dirptr = smbc_readdir( dh );
+
+ if ( dirptr == NULL )
+
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/readdir/readdir_4.c b/testsuite/libsmbclient/src/readdir/readdir_4.c
new file mode 100644
index 00000000000..42b18aaa48b
--- /dev/null
+++ b/testsuite/libsmbclient/src/readdir/readdir_4.c
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+
+ struct smbc_dirent *dirptr;
+
+
+ char url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+
+ dh = smbc_opendir(url);
+ dirptr = smbc_readdir( dh );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/readdir/readdir_5.c b/testsuite/libsmbclient/src/readdir/readdir_5.c
new file mode 100644
index 00000000000..de94c4698e3
--- /dev/null
+++ b/testsuite/libsmbclient/src/readdir/readdir_5.c
@@ -0,0 +1,155 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ int j = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+
+ err = 0;
+ i = 0;
+ bzero(buff,MAX_BUFF_SIZE);
+ bzero(tmp_file_ptr,MAX_BUFF_SIZE-9);
+
+ while ( 1 )
+ {
+ dirptr = smbc_readdir( dh );
+ if ( dirptr == NULL )
+ {
+ break;
+ }
+
+ /* printf("Name: %s\n",dirptr->name); */
+ if ( j == 0 )
+ {
+ if ( !(( strncmp(dirptr->name,".",1) == 0 )) )
+ {
+ break;
+ err = 1;
+ }
+
+ } else if ( j == 1 ) {
+
+ if ( !(( strncmp(dirptr->name,"..",2) == 0 )) )
+ {
+ break;
+ err = 1;
+ }
+
+ } else if ( j > 1 ) {
+
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+
+ if ( !(( strcmp(dirptr->name,file_url) == 0 )) ) /* make sure entries match */
+ {
+ err = 1;
+ break;
+ }
+
+ i++;
+
+ }
+
+ j++;
+
+ }
+
+ if ( ! err )
+ {
+ if ( (j - 2) != entry_num ) /* Make sure that all entries created are counted and returned - minus . and .. */
+ err = 1;
+ }
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_1.c b/testsuite/libsmbclient/src/rename/rename_1.c
new file mode 100644
index 00000000000..c3e1377c293
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_1.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ err = smbc_rename( url, argv[5] );
+
+ if ( err < 0 )
+ err = 1;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_10.c b/testsuite/libsmbclient/src/rename/rename_10.c
new file mode 100644
index 00000000000..01fb144c593
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_10.c
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 9 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[6], strlen(argv[6]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_mkdir( argv[7], 0700 );
+
+ strncpy( g_username, argv[4], strlen(argv[4]) );
+ strncpy( g_password, argv[5], strlen(argv[5]) );
+
+ smbc_rename( url, argv[8] );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_11.c b/testsuite/libsmbclient/src/rename/rename_11.c
new file mode 100644
index 00000000000..0c341088026
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_11.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ err = smbc_rename( NULL, url );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_12.c b/testsuite/libsmbclient/src/rename/rename_12.c
new file mode 100644
index 00000000000..cc34e079e18
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_12.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_rename( NULL, url );
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_13.c b/testsuite/libsmbclient/src/rename/rename_13.c
new file mode 100644
index 00000000000..30b33499d60
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_13.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ err = smbc_rename( url, NULL );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_14.c b/testsuite/libsmbclient/src/rename/rename_14.c
new file mode 100644
index 00000000000..61aad34e722
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_14.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_rename( url, NULL );
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_2.c b/testsuite/libsmbclient/src/rename/rename_2.c
new file mode 100644
index 00000000000..b3d340348c8
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_2.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_rename( url, argv[5] );
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_3.c b/testsuite/libsmbclient/src/rename/rename_3.c
new file mode 100644
index 00000000000..a7508e969c8
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_3.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_open(url,O_RDWR | O_CREAT,0666);
+ err = smbc_rename( url, argv[5] );
+
+ if ( err < 0 )
+ err = 1;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_4.c b/testsuite/libsmbclient/src/rename/rename_4.c
new file mode 100644
index 00000000000..a4c26470017
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_4.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_open(url,O_RDWR | O_CREAT,0666);
+ smbc_rename( url, argv[5] );
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_5.c b/testsuite/libsmbclient/src/rename/rename_5.c
new file mode 100644
index 00000000000..97fb8fe6830
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_5.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd );
+ err = smbc_rename( url, argv[5] );
+
+ if ( err < 0 )
+ err = 1;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_6.c b/testsuite/libsmbclient/src/rename/rename_6.c
new file mode 100644
index 00000000000..c9c349427e4
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_6.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url,O_RDWR | O_CREAT,0666);
+ smbc_close( fd );
+ smbc_rename( url, argv[5] );
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_7.c b/testsuite/libsmbclient/src/rename/rename_7.c
new file mode 100644
index 00000000000..67188abea96
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_7.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ int fd2 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_rename( url, argv[5] );
+ fd1 = smbc_open( url, O_RDWR, 0666 );
+ fd2 = smbc_open( argv[5], O_RDWR, 0666 );
+
+ if ( fd1 == -1 && fd2 != -1 )
+ err = 0;
+
+ else
+ err = 1;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_8.c b/testsuite/libsmbclient/src/rename/rename_8.c
new file mode 100644
index 00000000000..efbef5c30cd
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_8.c
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ int fd2 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 7 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_mkdir( argv[5], 0666 );
+ smbc_rename( url, argv[6] );
+
+ fd1 = smbc_open( url, O_RDWR, 0666 );
+ fd2 = smbc_open( argv[6], O_RDWR, 0666 );
+
+ if ( fd1 == -1 && fd2 != -1 )
+ err = 0;
+
+ else
+ err = 1;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rename/rename_9.c b/testsuite/libsmbclient/src/rename/rename_9.c
new file mode 100644
index 00000000000..1c1876dbb00
--- /dev/null
+++ b/testsuite/libsmbclient/src/rename/rename_9.c
@@ -0,0 +1,68 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 9 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[6], strlen(argv[6]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_mkdir( argv[7], 0700 );
+
+ strncpy( g_username, argv[4], strlen(argv[4]) );
+ strncpy( g_password, argv[5], strlen(argv[5]) );
+
+ err = smbc_rename( url, argv[8] );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rmdir/rmdir_1.c b/testsuite/libsmbclient/src/rmdir/rmdir_1.c
new file mode 100644
index 00000000000..2c64052d8be
--- /dev/null
+++ b/testsuite/libsmbclient/src/rmdir/rmdir_1.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ err = smbc_rmdir( url );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rmdir/rmdir_2.c b/testsuite/libsmbclient/src/rmdir/rmdir_2.c
new file mode 100644
index 00000000000..700b1d7a97f
--- /dev/null
+++ b/testsuite/libsmbclient/src/rmdir/rmdir_2.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_rmdir( url );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rmdir/rmdir_3.c b/testsuite/libsmbclient/src/rmdir/rmdir_3.c
new file mode 100644
index 00000000000..c1b881d4d4d
--- /dev/null
+++ b/testsuite/libsmbclient/src/rmdir/rmdir_3.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_mkdir( url, 700 );
+
+ err = smbc_rmdir( url );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rmdir/rmdir_4.c b/testsuite/libsmbclient/src/rmdir/rmdir_4.c
new file mode 100644
index 00000000000..a7723037256
--- /dev/null
+++ b/testsuite/libsmbclient/src/rmdir/rmdir_4.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ smbc_mkdir( url, 700 );
+
+ smbc_rmdir( url );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rmdir/rmdir_5.c b/testsuite/libsmbclient/src/rmdir/rmdir_5.c
new file mode 100644
index 00000000000..c4f787f63bc
--- /dev/null
+++ b/testsuite/libsmbclient/src/rmdir/rmdir_5.c
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ err = smbc_rmdir( url );
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/rmdir/rmdir_6.c b/testsuite/libsmbclient/src/rmdir/rmdir_6.c
new file mode 100644
index 00000000000..a44e6778322
--- /dev/null
+++ b/testsuite/libsmbclient/src/rmdir/rmdir_6.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd1 = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+ strncpy( g_workgroup, argv[1], strlen(argv[1]) );
+ strncpy( g_username, argv[2], strlen(argv[2]) );
+ strncpy( g_password, argv[3], strlen(argv[3]) );
+ strncpy( url, argv[4], strlen(argv[4]) );
+
+ smbc_init( auth_fn, 0 );
+ fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
+ smbc_close( fd1 );
+
+ smbc_rmdir( url );
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/stat/stat_1.c b/testsuite/libsmbclient/src/stat/stat_1.c
new file mode 100644
index 00000000000..08382acd74a
--- /dev/null
+++ b/testsuite/libsmbclient/src/stat/stat_1.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ err = smbc_stat(url, &st);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/stat/stat_2.c b/testsuite/libsmbclient/src/stat/stat_2.c
new file mode 100644
index 00000000000..80ee5dd8713
--- /dev/null
+++ b/testsuite/libsmbclient/src/stat/stat_2.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_stat(url, &st);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/stat/stat_3.c b/testsuite/libsmbclient/src/stat/stat_3.c
new file mode 100644
index 00000000000..1220577a3c7
--- /dev/null
+++ b/testsuite/libsmbclient/src/stat/stat_3.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ err = smbc_stat(url, &st);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/stat/stat_4.c b/testsuite/libsmbclient/src/stat/stat_4.c
new file mode 100644
index 00000000000..8bc544833e7
--- /dev/null
+++ b/testsuite/libsmbclient/src/stat/stat_4.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ smbc_stat(url, &st);
+
+ err = errno;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/stat/stat_5.c b/testsuite/libsmbclient/src/stat/stat_5.c
new file mode 100644
index 00000000000..86028f0598a
--- /dev/null
+++ b/testsuite/libsmbclient/src/stat/stat_5.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ smbc_stat(url,&st);
+
+ free(message);
+
+ if ( st.st_size != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/stat/stat_6.c b/testsuite/libsmbclient/src/stat/stat_6.c
new file mode 100644
index 00000000000..071bdd0f2f0
--- /dev/null
+++ b/testsuite/libsmbclient/src/stat/stat_6.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ unsigned int mode_mask = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ struct stat st;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ smbc_stat(url,&st);
+
+ free(message);
+
+ mode_mask = mode_mask | S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; /* 0666 or 33206 */
+
+ if ( st.st_mode != mode_mask )
+ err = 1;
+
+ else
+ err = 0;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/telldir/telldir_1.c b/testsuite/libsmbclient/src/telldir/telldir_1.c
new file mode 100644
index 00000000000..725033f453c
--- /dev/null
+++ b/testsuite/libsmbclient/src/telldir/telldir_1.c
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ err = smbc_telldir(dh);
+ /* printf("err: %i\n",err); */
+
+ if ( err < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/telldir/telldir_2.c b/testsuite/libsmbclient/src/telldir/telldir_2.c
new file mode 100644
index 00000000000..6971b79b0f9
--- /dev/null
+++ b/testsuite/libsmbclient/src/telldir/telldir_2.c
@@ -0,0 +1,95 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ smbc_telldir(dh);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/telldir/telldir_3.c b/testsuite/libsmbclient/src/telldir/telldir_3.c
new file mode 100644
index 00000000000..06ba59538ae
--- /dev/null
+++ b/testsuite/libsmbclient/src/telldir/telldir_3.c
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ err = smbc_telldir(dh);
+ /* printf("err: %i\n",err); */
+
+ if ( err < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/telldir/telldir_4.c b/testsuite/libsmbclient/src/telldir/telldir_4.c
new file mode 100644
index 00000000000..14184237d76
--- /dev/null
+++ b/testsuite/libsmbclient/src/telldir/telldir_4.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int dh = 0;
+
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+
+ dh = smbc_opendir(url);
+ /* printf("directory handle: %i\n",dh); */
+ smbc_telldir(dh);
+ err = errno;
+ /* printf("err: %i\n",err); */
+
+
+ }
+
+ return err;
+
+}
diff --git a/testsuite/libsmbclient/src/telldir/telldir_5.c b/testsuite/libsmbclient/src/telldir/telldir_5.c
new file mode 100644
index 00000000000..9172b2d1aba
--- /dev/null
+++ b/testsuite/libsmbclient/src/telldir/telldir_5.c
@@ -0,0 +1,122 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int dh = 0;
+ int entry_num = 0;
+ int i = 0;
+ int offset = 0;
+ int dirsize = 0;
+ char *file_name;
+ char *tmp_file_ptr;
+
+ struct smbc_dirent *dirptr;
+
+
+ char buff[MAX_BUFF_SIZE];
+ char url[MAX_BUFF_SIZE];
+ char file_url[MAX_BUFF_SIZE];
+ char dir_url[MAX_BUFF_SIZE];
+ char dirbuff[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(file_url,MAX_BUFF_SIZE);
+ bzero(dir_url,MAX_BUFF_SIZE);
+ bzero(buff,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ dirptr = (struct smbc_dirent *) dirbuff;
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+ smbc_init(auth_fn, 0);
+
+ strncpy(file_url,"tempfile-",9);
+ tmp_file_ptr = file_url;
+ tmp_file_ptr += 9;
+
+ smbc_rmdir(url);
+ smbc_mkdir(url,0666);
+
+ entry_num = atoi(argv[5]);
+ strcat(dir_url,url);
+ strcat(dir_url,"/");
+
+ file_name = dir_url;
+ file_name += strlen(dir_url);
+
+ for ( i = 0; i < entry_num; i++ )
+ {
+ sprintf(buff,"%d",i);
+ memcpy(tmp_file_ptr,buff,strlen(buff)+4);
+ strncat(tmp_file_ptr,".txt",4);
+ strcpy(file_name,file_url);
+ fd = smbc_open(dir_url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ }
+
+ dh = smbc_opendir(url);
+ err = 0;
+
+ while ( 1 )
+ {
+ dirptr = smbc_readdir(dh);
+
+ if ( dirptr == NULL )
+ {
+ break;
+ }
+
+ (char*)dirsize += dirptr->dirlen;
+
+ }
+
+ offset = smbc_telldir(dh);
+
+ if ( offset != dirsize )
+ {
+ /* printf("offset: %i dirsize: %i\n",offset,dirsize); */
+ err = 1;
+ }
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_1.c b/testsuite/libsmbclient/src/unlink/unlink_1.c
new file mode 100644
index 00000000000..12e9d1d0aa8
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_1.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ err = smbc_unlink(url);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_10.c b/testsuite/libsmbclient/src/unlink/unlink_10.c
new file mode 100644
index 00000000000..58f541c69a1
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_10.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0000);
+ smbc_close(fd);
+
+ strncpy(g_username, "xxxxxx", 6);
+ strncpy(g_password, "xxxxxx", 6);
+
+ smbc_unlink(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_11.c b/testsuite/libsmbclient/src/unlink/unlink_11.c
new file mode 100644
index 00000000000..f94b93d0482
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_11.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0000);
+ smbc_close(fd);
+
+ strncpy(g_username, "xxxxxx", 6);
+ strncpy(g_password, "xxxxxx", 6);
+
+ err = smbc_unlink(url);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_12.c b/testsuite/libsmbclient/src/unlink/unlink_12.c
new file mode 100644
index 00000000000..f6082595a35
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_12.c
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ smbc_unlink(url);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ if ( fd < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_2.c b/testsuite/libsmbclient/src/unlink/unlink_2.c
new file mode 100644
index 00000000000..3980704847f
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_2.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_mkdir(url, 0666);
+ err = smbc_unlink(url);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_3.c b/testsuite/libsmbclient/src/unlink/unlink_3.c
new file mode 100644
index 00000000000..551a651ae45
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_3.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_mkdir(url, 0666);
+ smbc_unlink(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_4.c b/testsuite/libsmbclient/src/unlink/unlink_4.c
new file mode 100644
index 00000000000..309dc39639d
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_4.c
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[6],strlen(argv[6]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ strncpy(g_username,argv[4],strlen(argv[4]));
+ strncpy(g_password,argv[5],strlen(argv[5]));
+
+ err = smbc_unlink(url);
+
+ if ( err < 0 )
+ err = 1;
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_5.c b/testsuite/libsmbclient/src/unlink/unlink_5.c
new file mode 100644
index 00000000000..73a8e057a6b
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_5.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+ err = smbc_unlink(url);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_6.c b/testsuite/libsmbclient/src/unlink/unlink_6.c
new file mode 100644
index 00000000000..334c3653d1f
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_6.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+ smbc_unlink(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_7.c b/testsuite/libsmbclient/src/unlink/unlink_7.c
new file mode 100644
index 00000000000..cda3c9d7b07
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_7.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[6],strlen(argv[6]));
+
+ smbc_init(auth_fn, 0);
+ fd = smbc_open(url, O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ strncpy(g_username,argv[4],strlen(argv[4]));
+ strncpy(g_password,argv[5],strlen(argv[5]));
+
+ smbc_unlink(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_8.c b/testsuite/libsmbclient/src/unlink/unlink_8.c
new file mode 100644
index 00000000000..2053be3c961
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_8.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink/unlink_9.c b/testsuite/libsmbclient/src/unlink/unlink_9.c
new file mode 100644
index 00000000000..78f9c297481
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink/unlink_9.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ char url[MAX_BUFF_SIZE];
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ err = smbc_unlink(url);
+
+ if ( err < 0 )
+ err = 1;
+
+
+ }
+
+ return 1;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_1.c b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_1.c
new file mode 100644
index 00000000000..b19bf228de1
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_1.c
@@ -0,0 +1,107 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ smbc_list_print_jobs(argv[6],print_list_fn);
+
+ g_print_id = -1;
+ err = smbc_unlink_print_job(argv[6],g_print_id);
+
+ if ( err < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_2.c b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_2.c
new file mode 100644
index 00000000000..52f127c3629
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_2.c
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ smbc_list_print_jobs(argv[6],print_list_fn);
+
+ g_print_id = -1;
+ smbc_unlink_print_job(argv[6],g_print_id);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_3.c b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_3.c
new file mode 100644
index 00000000000..5686b3f53ed
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_3.c
@@ -0,0 +1,106 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ smbc_list_print_jobs(argv[6],print_list_fn);
+
+ err = smbc_unlink_print_job(argv[6],g_print_id);
+
+ if ( err < 0 )
+
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_4.c b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_4.c
new file mode 100644
index 00000000000..28966f8af4d
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_4.c
@@ -0,0 +1,101 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+ smbc_print_file(url,argv[6]);
+ smbc_list_print_jobs(argv[6],print_list_fn);
+
+ smbc_unlink_print_job(argv[6],g_print_id);
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_5.c b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_5.c
new file mode 100644
index 00000000000..4fb3e30017b
--- /dev/null
+++ b/testsuite/libsmbclient/src/unlink_print_job/unlink_print_job_5.c
@@ -0,0 +1,141 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+char g_print_user[MAX_BUFF_SIZE];
+char g_print_name[MAX_BUFF_SIZE];
+unsigned int g_print_id;
+unsigned int g_print_priority;
+unsigned int g_print_size;
+
+unsigned int print_ids[MAX_BUFF_SIZE];
+unsigned int print_id_count;
+int call_flag;
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+void print_list_fn_2(struct print_job_info *pji)
+{
+
+ print_ids[print_id_count] = pji->id;
+ print_id_count++;
+
+ /* fprintf(stdout, "Call to Second Print Function - Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+void print_list_fn(struct print_job_info *pji)
+{
+
+ g_print_id = pji->id;
+ g_print_priority = pji->priority;
+ g_print_size = pji->size;
+ strcpy(g_print_user,pji->user);
+ strcpy(g_print_name,pji->name);
+
+ /* fprintf(stdout, "Call to First Print Function - Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
+ pji->id, pji->priority, pji->size, pji->user, pji->name); */
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ unsigned int i = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+ bzero(g_print_user,MAX_BUFF_SIZE);
+ bzero(g_print_name,MAX_BUFF_SIZE);
+
+ g_print_id = 0;
+ g_print_priority = 0;
+ g_print_size = 0;
+
+ print_id_count = 0;
+
+ if ( argc == 7 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+ /* printf("Message: %s\n",message); */
+ /* printf("Message len: %i\n",msg_len); */
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ smbc_print_file(url,argv[6]);
+ smbc_print_file(url,argv[6]);
+ smbc_print_file(url,argv[6]);
+
+ smbc_list_print_jobs(argv[6],print_list_fn);
+
+ if ( smbc_unlink_print_job(argv[6],g_print_id) == 0 )
+ {
+ if ( smbc_list_print_jobs(argv[6],print_list_fn_2) == 0 )
+ {
+ err = 0;
+
+ for ( i=0; i<print_id_count; i++ )
+ {
+ if ( g_print_id == print_ids[i] )
+ {
+ err = 1;
+ break;
+ }
+
+ }
+ }
+
+ } else
+ err = 1;
+
+
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_1.c b/testsuite/libsmbclient/src/write/write_1.c
new file mode 100644
index 00000000000..fa147f8f503
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_1.c
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ err = smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ if ( err < 0 )
+ err = 1;
+
+ else if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_10.c b/testsuite/libsmbclient/src/write/write_10.c
new file mode 100644
index 00000000000..1f43c60bb75
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_10.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message = NULL;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ msg_len = 10;
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+
+ err = errno;
+
+ smbc_close(fd);
+
+ free(message);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_11.c b/testsuite/libsmbclient/src/write/write_11.c
new file mode 100644
index 00000000000..3f9ae3f97da
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_11.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+ smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDONLY, 0666);
+ smbc_read(fd,response,msg_len);
+ smbc_close(fd);
+
+ if ( memcmp ( message, response, msg_len) == 0 )
+ err = 0;
+
+ else
+ err = 1;
+
+ free(message);
+ free(response);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_12.c b/testsuite/libsmbclient/src/write/write_12.c
new file mode 100644
index 00000000000..3528dbb36e2
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_12.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ strncpy(g_username,"xxxxxxxx",8);
+ strncpy(g_password,"xxxxxxxx",8);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ err = smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ free(message);
+ free(response);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_13.c b/testsuite/libsmbclient/src/write/write_13.c
new file mode 100644
index 00000000000..f3c2ad5bc3f
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_13.c
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+ char* response;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ response = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ strncpy(g_username,"xxxxxxxx",8);
+ strncpy(g_password,"xxxxxxxx",8);
+
+ fd = smbc_open(url, O_RDWR, 0666);
+
+ if (fd < 0)
+
+ err = errno;
+
+ else {
+
+ smbc_write(fd, message, msg_len);
+ err = errno;
+
+ smbc_close(fd);
+
+ }
+
+ free(message);
+ free(response);
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_2.c b/testsuite/libsmbclient/src/write/write_2.c
new file mode 100644
index 00000000000..49763ebe0cd
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_2.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+
+ smbc_write(fd, message, msg_len);
+ err = errno;
+
+ smbc_close(fd);
+
+ free(message);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_3.c b/testsuite/libsmbclient/src/write/write_3.c
new file mode 100644
index 00000000000..254782946d7
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_3.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDONLY, 0666);
+ err = smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ if ( err < 0 )
+ err = 1;
+
+ else if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_4.c b/testsuite/libsmbclient/src/write/write_4.c
new file mode 100644
index 00000000000..6ee585f0210
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_4.c
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_RDONLY, 0666);
+
+ smbc_write(fd, message, msg_len);
+ err = errno;
+
+ smbc_close(fd);
+
+ free(message);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_5.c b/testsuite/libsmbclient/src/write/write_5.c
new file mode 100644
index 00000000000..84cb50123cc
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_5.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_WRONLY, 0666);
+ err = smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ if ( err < 0 )
+ err = 1;
+
+ else if ( err != msg_len )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_6.c b/testsuite/libsmbclient/src/write/write_6.c
new file mode 100644
index 00000000000..c139ff81379
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_6.c
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 6 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ msg_len = strlen(argv[5])+1;
+ message = malloc(msg_len);
+ message[msg_len - 1] = 0;
+ strncpy(message,argv[5],msg_len);
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ fd = smbc_open(url, O_WRONLY, 0666);
+
+ smbc_write(fd, message, msg_len);
+ err = errno;
+
+ smbc_close(fd);
+
+ free(message);
+
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_7.c b/testsuite/libsmbclient/src/write/write_7.c
new file mode 100644
index 00000000000..bc509f1efd3
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_7.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char* message = "Testing";
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ fd = 10345; /* Random value for File Descriptor */
+ smbc_init(auth_fn, 0);
+ err = smbc_write(fd, message, sizeof(message));
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_8.c b/testsuite/libsmbclient/src/write/write_8.c
new file mode 100644
index 00000000000..acc20f19586
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_8.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ char* message = "Testing";
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+
+ if ( argc == 4 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+
+ fd = 10345; /* Random value for File Descriptor */
+ smbc_init(auth_fn, 0);
+ err = smbc_write(fd, message, sizeof(message));
+
+ err = errno;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/libsmbclient/src/write/write_9.c b/testsuite/libsmbclient/src/write/write_9.c
new file mode 100644
index 00000000000..b707d5c688e
--- /dev/null
+++ b/testsuite/libsmbclient/src/write/write_9.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <libsmbclient.h>
+
+#define MAX_BUFF_SIZE 255
+char g_workgroup[MAX_BUFF_SIZE];
+char g_username[MAX_BUFF_SIZE];
+char g_password[MAX_BUFF_SIZE];
+char g_server[MAX_BUFF_SIZE];
+char g_share[MAX_BUFF_SIZE];
+
+
+void auth_fn(const char *server, const char *share, char *workgroup, int wgmaxlen,
+ char *username, int unmaxlen, char *password, int pwmaxlen)
+{
+
+ strncpy(workgroup, g_workgroup, wgmaxlen - 1);
+
+ strncpy(username, g_username, unmaxlen - 1);
+
+ strncpy(password, g_password, pwmaxlen - 1);
+
+ strcpy(g_server, server);
+ strcpy(g_share, share);
+
+}
+
+int main(int argc, char** argv)
+{
+ int err = -1;
+ int fd = 0;
+ int msg_len = 0;
+ char url[MAX_BUFF_SIZE];
+ char* message = NULL;
+
+ bzero(g_workgroup,MAX_BUFF_SIZE);
+ bzero(url,MAX_BUFF_SIZE);
+
+ if ( argc == 5 )
+ {
+
+ strncpy(g_workgroup,argv[1],strlen(argv[1]));
+ strncpy(g_username,argv[2],strlen(argv[2]));
+ strncpy(g_password,argv[3],strlen(argv[3]));
+ strncpy(url,argv[4],strlen(argv[4]));
+
+ smbc_init(auth_fn, 0);
+ smbc_unlink(url);
+ fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
+ smbc_close(fd);
+
+ msg_len = 10;
+ fd = smbc_open(url, O_RDWR, 0666);
+ err = smbc_write(fd, message, msg_len);
+ smbc_close(fd);
+
+ free(message);
+
+ if ( err < 0 )
+ err = 1;
+
+ else
+ err = 0;
+
+ }
+
+ return err;
+
+}
+
diff --git a/testsuite/nsswitch/.cvsignore b/testsuite/nsswitch/.cvsignore
new file mode 100644
index 00000000000..1c30875a884
--- /dev/null
+++ b/testsuite/nsswitch/.cvsignore
@@ -0,0 +1,12 @@
+initgroups
+nss_winbind_syms
+getgrent_r
+getgrgid
+getgrnam
+getpwent_r
+getpwnam
+wbtorture
+leaktest?
+getpwuid
+getent_pwent
+getent_grent
diff --git a/testsuite/nsswitch/Makefile.longarg b/testsuite/nsswitch/Makefile.longarg
new file mode 100644
index 00000000000..6cc7ef8306d
--- /dev/null
+++ b/testsuite/nsswitch/Makefile.longarg
@@ -0,0 +1,5 @@
+#
+# Makefile for null tests
+#
+
+longarg_getpwnam: longarg_getpwnam.o \ No newline at end of file
diff --git a/testsuite/nsswitch/bigfd.c b/testsuite/nsswitch/bigfd.c
new file mode 100644
index 00000000000..99e402e0f33
--- /dev/null
+++ b/testsuite/nsswitch/bigfd.c
@@ -0,0 +1,38 @@
+/*
+ * Test maximum number of file descriptors winbind daemon can handle
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+ struct passwd *pw;
+ int i;
+
+ while(1) {
+
+ /* Start getpwent until we get an NT user. This way we know we
+ have at least opened a connection to the winbind daemon */
+
+ setpwent();
+
+ while((pw = getpwent()) != NULL) {
+ if (strchr(pw->pw_name, '/') != NULL) {
+ break;
+ }
+ }
+
+ if (pw != NULL) {
+ i++;
+ printf("got pwent handle %d\n", i);
+ } else {
+ printf("winbind daemon not running?\n");
+ exit(1);
+ }
+
+ sleep(1);
+ }
+}
diff --git a/testsuite/nsswitch/bigfd.exp b/testsuite/nsswitch/bigfd.exp
new file mode 100644
index 00000000000..62fc9ea7f35
--- /dev/null
+++ b/testsuite/nsswitch/bigfd.exp
@@ -0,0 +1,28 @@
+#
+# @(#) Test maximum number of clients (file descriptors) for winbindd
+#
+
+load_lib util-defs.exp
+
+# Unimplemented - eek!
+
+untested "bigfd"
+return
+
+# Compile bigfd.c
+
+set output [target_compile "$srcdir/$subdir/bigfd.c" \
+ "$srcdir/$subdir/bigfd" executable {additional_flags="-g"}]
+
+if {$output != ""} {
+ perror "compile bigfd"
+ puts $output
+ return
+}
+
+# Run bigfd
+
+set output [util_start "$srcdir/$subdir/bigfd" "" ""]
+puts $output
+
+pass "bigfd"
diff --git a/testsuite/nsswitch/domusers.exp b/testsuite/nsswitch/domusers.exp
new file mode 100644
index 00000000000..3b291ab398b
--- /dev/null
+++ b/testsuite/nsswitch/domusers.exp
@@ -0,0 +1,38 @@
+#
+# @(#) Test that all users are members of the Domain Users group.
+#
+# Note that this isn't necessarily true all the time but you have to
+# explicitly move people out of that group so it should be OK for te
+#
+
+load_lib util-defs.exp
+load_lib $srcdir/lib/nsswitch-config.exp
+
+# Get list of users and stick usernames in a hash
+
+set user_list [util_start "getent" "passwd" ""]
+
+foreach { user } [split $user_list "\n"] {
+ set user_elts [split $user ":"]
+ set users([lindex $user_elts 0]) 1
+}
+
+# Get list of groups
+
+set group_list [util_start "getent" "group" ""]
+
+foreach { group } [split $group_list "\n"] {
+ set group_elts [split $group ":"]
+
+ # Look for domain users group
+
+ if { ![regexp "Domain Users" [lindex $group_elts 0]] } {
+ continue
+ }
+
+ # Check each member of group was found in getent passwd
+
+ foreach { mem } [split [lindex $group_elts 3] ","] {
+ set mems($mem) 1
+ }
+}
diff --git a/testsuite/nsswitch/envvar.exp b/testsuite/nsswitch/envvar.exp
new file mode 100644
index 00000000000..134a8b37a85
--- /dev/null
+++ b/testsuite/nsswitch/envvar.exp
@@ -0,0 +1,282 @@
+#
+# @(#) Test operation of WINBINDD_DOMAIN environment variable
+#
+
+load_lib "util-defs.exp"
+load_lib "$srcdir/lib/nsswitch-config.exp"
+
+#
+# @(#) Test that there is at least one domain user and domain group
+# @(#) in the output of getent passwd and getent group.
+#
+
+# Get list of users and groups
+
+set user_list [util_start "getent passwd"]
+set group_list [util_start "getent group"]
+
+verbose "user list is:\n$user_list"
+verbose "group list is:\n$group_list"
+
+# Check for domain users
+
+set no_dom 0
+
+if { ![regexp "$domain/" $user_list] } {
+ fail "no domain users in getent"
+ set no_dom 1
+}
+
+# Check for domain groups
+
+if { ![regexp "$domain/" $group_list] } {
+ fail "no domain groups in getent group"
+ set no_dom 1
+}
+
+if { $no_dom } {
+ return
+}
+
+#
+# @(#) Check for "leakage" between different domains using the
+# @(#) WINBINDD_DOMAIN environment variable.
+#
+
+verbose "Domain is $domain"
+
+set output [util_start "bin/wbinfo" "-m"]
+verbose "Trusted domains are $output"
+set trusted_domain_list [split $output "\n"]
+
+# Test simple inclusion by setting $WINBINDD_DOMAIN to each trusted domain
+# in turn and checking there are no users/groups from other domains in the
+# output of getent.
+
+set domain_list $trusted_domain_list
+lappend domain_list $domain
+
+foreach { the_domain } $domain_list {
+
+ set env(WINBINDD_DOMAIN) $the_domain
+
+ set user_out [util_start "getent passwd"]
+ set group_out [util_start "getent group"]
+
+ verbose "users in $the_domain:\n$user_out\n"
+ verbose "groups in $the_domain:\n$group_out\n"
+
+ # Users
+
+ set test_desc "users in WINBINDD_DOMAIN $the_domain"
+ set failed 0
+
+ foreach { user } [split $user_out "\n"] {
+ set user_name [lindex [split $user ":"] 0]
+ if { [regexp "/" $user_name] && ![regexp $the_domain $user_name]} {
+ set failed 1
+ }
+ }
+
+ if { $failed } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ # Groups
+
+ set test_desc "groups in WINBINDD_DOMAIN $the_domain"
+ set failed 0
+
+ foreach { group } [split $group_out "\n"] {
+ set group_name [lindex [split $group ":"] 0]
+ if { [regexp "/" $group_name] && ![regexp $the_domain $group_name]} {
+ set failed 1
+ }
+ }
+
+ if { $failed } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+#
+# @(#) Test inclusion of a dummy domain doesn't generate users/groups
+# @(#) from that domain.
+#
+
+set env(WINBINDD_DOMAIN) "asmithee"
+set user_out [util_start "getent passwd"]
+set group_out [util_start "getent group"]
+
+# Users
+
+set test_desc "users in different WINBINDD_DOMAIN"
+if { [regexp $domain $user_out] } {
+ fail $test_desc
+} else {
+ pass $test_desc
+}
+
+# Groups
+
+set test_desc "groups in different WINBINDD_DOMAIN"
+if { [regexp $domain $group_out] } {
+ fail $test_desc
+} else {
+ pass $test_desc
+}
+
+#
+# @(#) Test comma separated inclusion of dummy domain doesn't generate
+# @(#) users/groups in the dummy domain.
+#
+
+foreach { the_domain } $domain_list {
+ set env(WINBINDD_DOMAIN) "$the_domain,asmithee"
+ set user_out [util_start "getent passwd"]
+ set group_out [util_start "getent group"]
+
+ verbose "users in $the_domain:\n$user_out\n"
+ verbose "groups in $the_domain:\n$group_out\n"
+
+ # Users
+
+ set test_desc "users in comma separated WINBINDD_DOMAIN $the_domain"
+ set failed 0
+
+ foreach { user } [split $user_out "\n"] {
+ set user_name [lindex [split $user ":"] 0]
+ if { [regexp "/" $user_name] && ![regexp $the_domain $user_name]} {
+ set failed 1
+ }
+ }
+
+ if { $failed } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ # Groups
+
+ set test_desc "groups in comma separated WINBINDD_DOMAIN $the_domain"
+ set failed 0
+
+ foreach { group } [split $group_out "\n"] {
+ set group_name [lindex [split $group ":"] 0]
+ if { [regexp "/" $group_name] && ![regexp $the_domain $group_name]} {
+ set failed 1
+ }
+ }
+
+ if { $failed } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+#
+# @(#) Test two comma separated dummy domains do not generate any domain
+# @(#) users or groups.
+#
+
+foreach { the_domain } $domain_list {
+
+ set env(WINBINDD_DOMAIN) "moose,asmithee"
+ set user_out [util_start "getent passwd"]
+ set group_out [util_start "getent group"]
+
+ verbose "users in $the_domain:\n$user_out\n"
+ verbose "groups in $the_domain:\n$group_out\n"
+
+ # Users
+
+ set test_desc "users in comma separated invalid WINBINDD_DOMAIN"
+ if { [regexp $the_domain $user_out] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ # Groups
+
+ set test_desc "groups in comma separated invalid WINBINDD_DOMAIN"
+ if { [regexp $the_domain $group_out] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+set env(WINBINDD_DOMAIN) ""
+
+#
+# @(#) Test _NO_WINBINDD doesn't return any domain users or groups
+#
+
+set env(_NO_WINBINDD) "1"
+set user_out [util_start "getent passwd"]
+set group_out [util_start "getent group"]
+
+verbose "users with _NO_WINBINDD:\n$user_out\n"
+verbose "groups with _NO_WINBINDD:\n$group_out\n"
+
+foreach { the_domain } $domain_list {
+
+ # Users
+
+ set test_desc "users found with _NO_WINBINDD environment variable set"
+ if { [regexp $the_domain $user_out] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ # Groups
+
+ set test_desc "groups found with _NO_WINBINDD environment variable set"
+ if { [regexp $the_domain $group_out] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+# Unset _NO_WINBINDD and make sure everything still works
+
+unset env(_NO_WINBINDD)
+
+set user_out [util_start "getent passwd"]
+set group_out [util_start "getent group"]
+
+verbose "users with _NO_WINBINDD unset:\n$user_out\n"
+verbose "groups with _NO_WINBINDD unset:\n$group_out\n"
+
+# Users
+
+set test_desc "no users found with _NO_WINBINDD environment variable set"
+if { $user_out != $user_list } {
+ fail $test_desc
+} else {
+ pass $test_desc
+}
+
+# Groups
+
+set test_desc "no groups found with _NO_WINBINDD environment variable set"
+if { $group_out != $group_list } {
+ fail $test_desc
+} else {
+ pass $test_desc
+}
+
+# Make sure we unset the environment vars so we don't cause subsequent tests
+# any grief.
+
+catch { unset env(WINBINDD_DOMAIN) } tmp
+catch { unset env(_NO_WINBINDD) } tmp
diff --git a/testsuite/nsswitch/finger.exp b/testsuite/nsswitch/finger.exp
new file mode 100644
index 00000000000..36bab8e1990
--- /dev/null
+++ b/testsuite/nsswitch/finger.exp
@@ -0,0 +1,39 @@
+#
+# @(#) Test default domain users resolve using the finger command
+#
+
+load_lib util-defs.exp
+
+set output [util_start "bin/wbinfo" "-u"]
+if { [regexp "Error" $output] } {
+ fail "error running wbinfo"
+ return
+}
+
+set user_list [split $output "\n"]
+
+# Look up all users using finger -m. This should test getpwnam()
+
+foreach { user } $user_list {
+ set output [util_start "finger" "-m \"$user\"" "" "no such user"]
+ verbose $output
+
+ if { [regexp "no such user" $output] } {
+ fail "finger -m $user"
+ } else {
+ pass "finger -m $user"
+ }
+}
+
+# Run finger without the -m to also test set/get/endpwent()
+
+foreach { user } $user_list {
+ set output [util_start "finger" "\"$user\""]
+ verbose $output
+
+ if { [regexp "no such user" $output] } {
+ fail "finger $user"
+ } else {
+ pass "finger $user"
+ }
+}
diff --git a/testsuite/nsswitch/getent.c b/testsuite/nsswitch/getent.c
new file mode 100644
index 00000000000..b4c4e50c6fe
--- /dev/null
+++ b/testsuite/nsswitch/getent.c
@@ -0,0 +1,151 @@
+/* Cut down version of getent which only returns passwd and group database
+ entries and seems to compile on most systems without too much fuss.
+ Original copyright notice below. */
+
+/* Copyright (c) 1998, 1999, 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
+
+ The GNU C 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.
+
+ The GNU C 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 the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include <pwd.h>
+#include <grp.h>
+
+group_keys (int number, char *key[])
+{
+ int result = 0;
+ int i;
+
+ for (i = 0; i < number; ++i)
+ {
+ struct group *grp;
+
+ if (isdigit (key[i][0]))
+ grp = getgrgid (atol (key[i]));
+ else
+ grp = getgrnam (key[i]);
+
+ if (grp == NULL)
+ result = 2;
+ else
+ print_group (grp);
+ }
+
+ return result;
+}
+
+passwd_keys (int number, char *key[])
+{
+ int result = 0;
+ int i;
+
+ for (i = 0; i < number; ++i)
+ {
+ struct passwd *pwd;
+
+ if (isdigit (key[i][0]))
+ pwd = getpwuid (atol (key[i]));
+ else
+ pwd = getpwnam (key[i]);
+
+ if (pwd == NULL)
+ result = 2;
+ else
+ print_passwd (pwd);
+ }
+
+ return result;
+}
+
+print_group (struct group *grp)
+{
+ unsigned int i = 0;
+
+ printf ("%s:%s:%ld:", grp->gr_name ? grp->gr_name : "",
+ grp->gr_passwd ? grp->gr_passwd : "",
+ (unsigned long)grp->gr_gid);
+
+ while (grp->gr_mem[i] != NULL)
+ {
+ fputs (grp->gr_mem[i], stdout);
+ ++i;
+ if (grp->gr_mem[i] != NULL)
+ fputs (",", stdout);
+ }
+ fputs ("\n", stdout);
+}
+
+print_passwd (struct passwd *pwd)
+{
+ printf ("%s:%s:%ld:%ld:%s:%s:%s\n",
+ pwd->pw_name ? pwd->pw_name : "",
+ pwd->pw_passwd ? pwd->pw_passwd : "",
+ (unsigned long)pwd->pw_uid,
+ (unsigned long)pwd->pw_gid,
+ pwd->pw_gecos ? pwd->pw_gecos : "",
+ pwd->pw_dir ? pwd->pw_dir : "",
+ pwd->pw_shell ? pwd->pw_shell : "");
+}
+
+int main(int argc, char **argv)
+{
+ switch(argv[1][0])
+ {
+ case 'g': /* group */
+ if (strcmp (argv[1], "group") == 0)
+ {
+ if (argc == 2)
+ {
+ struct group *grp;
+
+ setgrent ();
+ while ((grp = getgrent()) != NULL)
+ print_group (grp);
+ endgrent ();
+ }
+ else
+ return group_keys (argc - 2, &argv[2]);
+ }
+ else
+ goto error;
+ break;
+
+ case 'p': /* passwd, protocols */
+ if (strcmp (argv[1], "passwd") == 0)
+ {
+ if (argc == 2)
+ {
+ struct passwd *pwd;
+
+ setpwent ();
+ while ((pwd = getpwent()) != NULL)
+ print_passwd (pwd);
+ endpwent ();
+ }
+ else
+ return passwd_keys (argc - 2, &argv[2]);
+ }
+ else
+ goto error;
+ break;
+ default:
+ error:
+ fprintf (stderr, "Unknown database: %s\n", argv[1]);
+ return 1;
+ }
+ return 0;
+}
diff --git a/testsuite/nsswitch/getent.exp b/testsuite/nsswitch/getent.exp
new file mode 100644
index 00000000000..72bf2ea1ebe
--- /dev/null
+++ b/testsuite/nsswitch/getent.exp
@@ -0,0 +1,148 @@
+#
+# @(#) Test the getent command returns domain/local users and groups
+#
+
+load_lib util-defs.exp
+load_lib compile.exp
+load_lib $srcdir/lib/nsswitch-config.exp
+
+#
+# @(#) Test getent passwd returns domain users
+#
+
+set wbinfo_output [util_start "bin/wbinfo" "-u"]
+set getent_output [util_start "getent" "passwd" ""]
+
+if { ![regexp "$domain/" $getent_output] } {
+ fail "no domain users in getent passwd"
+ return
+}
+
+if { [regexp "Error" $wbinfo_output] } {
+ fail "wbinfo -u failed"
+ return
+}
+
+#
+# @(#) Test each user in the output of wbinfo is also in the output of
+# @(#) getent.
+#
+
+# Test wbinfo user names are in getent user names
+
+foreach { user } [split $wbinfo_output "\n"] {
+
+ verbose "looking for $user"
+
+ set test_desc "getent passwd does not contain $user"
+
+ if { ![regexp "$user" $getent_output] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+# Test getent user names are in wbinfo user names
+
+foreach { user } [split $getent_output "\n"] {
+
+ set user_info [split $user ":"]
+ set username [lindex $user_info 0]
+
+ if { [regexp {^[^/]+/} $username] } {
+
+ set test_desc "wbinfo -u does not contain $username"
+
+ if { ![regexp "$username" $wbinfo_output] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+ } else {
+ verbose "ignoring non-domain user $username"
+ }
+}
+
+#
+# @(#) Test each group in the output of wbinfo is also in the output of
+# @(#) getent.
+#
+
+set wbinfo_output [util_start "bin/wbinfo" "-g"]
+set getent_output [util_start "getent" "group" ""]
+
+if { ![regexp "$domain/" $getent_output] } {
+ fail "no domain groups in getent passwd"
+ return
+}
+
+if { [regexp "Error" $wbinfo_output] } {
+ fail "wbinfo -g failed"
+ return
+}
+
+# Test wbinfo group names are in getent group names
+
+foreach { group } [split $wbinfo_output "\n"] {
+
+ verbose "looking for $group"
+
+ set test_desc "getent group does not contain $group"
+
+ if { ![regexp "$group" $getent_output] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+# Test getent group names are in wbinfo group names
+
+foreach { group } [split $getent_output "\n"] {
+
+ set group_info [split $group ":"]
+ set groupname [lindex $group_info 0]
+
+ if { [regexp {^[^/]+/} $groupname] } {
+
+ set test_desc "wbinfo -g does not contain $groupname"
+
+ if { ![regexp "$groupname" $wbinfo_output] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+ } else {
+ verbose "ignoring non-domain group $groupname"
+ }
+}
+
+#
+# @(#) Test out of order and repeat calls of pwent functions
+# @(#) Test out of order and repeat calls of grent functions
+#
+
+set getent_tests [list \
+ { "out of order pwent operations" "getent_pwent" } \
+ { "out of order grent operations" "getent_grent" } \
+ ]
+
+# Compile and run each test
+
+foreach { test } $getent_tests {
+ set test_desc [lindex $test 0]
+ set test_file [lindex $test 1]
+
+ simple_compile $test_file
+ set output [util_start "$srcdir/$subdir/$test_file" ]
+
+ if { [regexp "PASS" $output] } {
+ pass $test_desc
+ file delete "$srcdir/$subdir/$test_file" "$srcdir/$subdir/$test_file.o"
+ } else {
+ fail $test_desc
+ puts $output
+ }
+
+}
diff --git a/testsuite/nsswitch/getent_grent.c b/testsuite/nsswitch/getent_grent.c
new file mode 100644
index 00000000000..782cc0c86b7
--- /dev/null
+++ b/testsuite/nsswitch/getent_grent.c
@@ -0,0 +1,101 @@
+/* Test out of order operations with {set,get,end}grent */
+
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <grp.h>
+
+int main (int argc, char **argv)
+{
+ struct group *gr;
+ int found = 0;
+ int num_users, i;
+
+ /* Test getgrent() without setgrent() */
+
+ for (i = 0; i < 100; i++) {
+ gr = getgrent();
+
+ /* This is supposed to work */
+
+#if 0
+ if (gr != NULL) {
+ printf("FAIL: getgrent() with no setgrent()\n");
+ return 1;
+ }
+#endif
+ }
+
+ /* Work out how many user till first domain group */
+
+ num_users = 0;
+ setgrent();
+
+ while (1) {
+ gr = getgrent();
+ num_users++;
+
+ if (gr == NULL) break;
+
+ if (strchr(gr->gr_name, '/')) {
+ found = 1;
+ break;
+ }
+
+ }
+
+ if (!found) {
+ printf("FAIL: could not find any domain groups\n");
+ return 1;
+ }
+
+ /* Test stopping getgrent in the middle of a set of users */
+
+ endgrent();
+
+ /* Test setgrent() without any getgrent() calls */
+
+ setgrent();
+
+ for (i = 0; i < (num_users - 1); i++) {
+ getgrent();
+ }
+
+ endgrent();
+
+ /* Test lots of setgrent() calls */
+
+ for (i = 0; i < 100; i++) {
+ setgrent();
+ }
+
+ /* Test lots of endgrent() calls */
+
+ for (i = 0; i < 100; i++) {
+ endgrent();
+ }
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/nsswitch/getent_pwent.c b/testsuite/nsswitch/getent_pwent.c
new file mode 100644
index 00000000000..96c804433a4
--- /dev/null
+++ b/testsuite/nsswitch/getent_pwent.c
@@ -0,0 +1,113 @@
+/* Test out of order operations with {set,get,end}pwent */
+
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <pwd.h>
+
+int main (int argc, char **argv)
+{
+ struct passwd *pw;
+ int found = 0;
+ int num_users, i;
+
+ /* Test getpwent() without setpwent() */
+
+ for (i = 0; i < 100; i++) {
+ pw = getpwent();
+
+ /* This is supposed to work */
+
+#if 0
+ if (pw != NULL) {
+ printf("FAIL: getpwent() with no setpwent()\n");
+ return 1;
+ }
+#endif
+ }
+
+ /* Work out how many user till first domain user */
+
+ num_users = 0;
+ setpwent();
+
+ while (1) {
+ pw = getpwent();
+ num_users++;
+
+ if (pw == NULL) break;
+
+ if (strchr(pw->pw_name, '/')) {
+ found = 1;
+ break;
+ }
+
+ }
+
+ if (!found) {
+ printf("FAIL: could not find any domain users\n");
+ return 1;
+ }
+
+ /* Test stopping getpwent in the middle of a set of users */
+
+ endpwent();
+
+ /* Test setpwent() without any getpwent() calls */
+
+ setpwent();
+
+ for (i = 0; i < (num_users - 1); i++) {
+ getpwent();
+ }
+
+ endpwent();
+
+ /* Test lots of setpwent() calls */
+
+ setpwent();
+
+ for (i = 0; i < (num_users - 1); i++) {
+ getpwent();
+ }
+
+ for (i = 0; i < 100; i++) {
+ setpwent();
+ }
+
+ /* Test lots of endpwent() calls */
+
+ setpwent();
+
+ for (i = 0; i < (num_users - 1); i++) {
+ getpwent();
+ }
+
+ for (i = 0; i < 100; i++) {
+ endpwent();
+ }
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/nsswitch/getent_r.sh b/testsuite/nsswitch/getent_r.sh
new file mode 100755
index 00000000000..75dc603f829
--- /dev/null
+++ b/testsuite/nsswitch/getent_r.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Verify test output. Basically we check to see if all the files generated
+# in /tmp by the get{pw,gr}ent_r.c and program are identical. If there is
+# some problem with the re-entrancy of the code then the information in the
+# two files will be different.
+#
+
+TYPE=$1
+ID=$2
+FILES="/tmp/${TYPE}_r-${ID}.out-*"
+
+# Sort files
+
+for file in $FILES; do
+ cat $file | sort > $file.sorted
+done
+
+# Diff files
+
+SORTED="/tmp/${TYPE}_r-${ID}.out-*.sorted"
+failed=0
+
+for file1 in $SORTED; do
+ for file2 in $SORTED; do
+ if [ $file1 != $file2 ]; then
+ diff $file1 $file2
+ fi
+ done
+done
+
+# Clean up
+
+rm -f $SORTED
+
diff --git a/testsuite/nsswitch/getgrent_r.c b/testsuite/nsswitch/getgrent_r.c
new file mode 100644
index 00000000000..3eac8aa218d
--- /dev/null
+++ b/testsuite/nsswitch/getgrent_r.c
@@ -0,0 +1,84 @@
+/*
+ * Use set/get/endgrent calls from two processes to iterate over the
+ * password database. This checks the multithreaded stuff works.
+ */
+
+#include <stdio.h>
+#include <grp.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <wait.h>
+
+void dump_grent(char *id)
+{
+ struct group *gr;
+ char fname[255];
+ FILE *fptr;
+
+ /* Open results file */
+
+ sprintf(fname, "/tmp/getgrent_r-%s.out-%d", id, getpid());
+
+ if ((fptr = fopen(fname, "w")) < 0) {
+ fprintf(stderr, "ERROR: could not open file %s: %s\n", fname,
+ sys_errlist[errno]);
+ return;
+ }
+
+ /* Dump group database */
+
+ setgrent();
+
+ while((gr = getgrent()) != NULL) {
+ fprintf(fptr,"%s:%s:%d:%d\n", gr->gr_name, gr->gr_passwd,
+ gr->gr_gid);
+ }
+
+ endgrent();
+
+ /* Close results file */
+
+ fclose(fptr);
+}
+
+int main(int argc, char **argv)
+{
+ pid_t pid;
+
+ /* Check args */
+
+ if (argc != 2) {
+ printf("ERROR: must specify output file identifier\n");
+ return 1;
+ }
+
+ /* Fork child process */
+
+ if ((pid = fork()) == -1) {
+ printf("ERROR: unable to fork\n");
+ return 1;
+ }
+
+ /* Handle test case */
+
+ if (pid > 0) {
+ int status;
+
+ /* Parent */
+
+ dump_grent(argv[1]);
+ wait(&status);
+
+ } else {
+
+ /* Child */
+
+ dump_grent(argv[1]);
+ return 0;
+ }
+
+ printf("PASS: run getgrent_r.c\n");
+ return 0;
+}
diff --git a/testsuite/nsswitch/getgrent_r.exp b/testsuite/nsswitch/getgrent_r.exp
new file mode 100644
index 00000000000..c03237c2ad1
--- /dev/null
+++ b/testsuite/nsswitch/getgrent_r.exp
@@ -0,0 +1,41 @@
+#
+# @(#) Test multiple threads can enumerate groups correctly
+#
+
+load_lib util-defs.exp
+load_lib "$srcdir/lib/nsswitch-config.exp"
+
+# Compile getgrent_r.c
+
+set output [target_compile "$srcdir/$subdir/getgrent_r.c" \
+ "$srcdir/$subdir/getgrent_r" executable {additional_flags="-g"}]
+
+if {$output != ""} {
+ perror "compile getgrent_r"
+ puts $output
+ return
+}
+
+# Clean up output from previous tests
+
+set pid [pid]
+file delete [glob -nocomplain "/tmp/getgrent_r-$pid.out-*"]
+
+# Run test proggy
+
+set output [util_start "$srcdir/$subdir/getgrent_r" "$pid" ""]
+if {![regexp "^PASS:" $output]} {
+ perror "run getgrent_r"
+ puts $output
+ return -1
+}
+
+# Sort and compare output
+
+set output [util_start "$srcdir/$subdir/getent_r.sh" "getgrent $pid" ""]
+if {$output == ""} {
+ pass "getgrent_r"
+} else {
+ fail "getgrent_r"
+ puts $output
+}
diff --git a/testsuite/nsswitch/getgrgid.c b/testsuite/nsswitch/getgrgid.c
new file mode 100644
index 00000000000..947dd0ac4c7
--- /dev/null
+++ b/testsuite/nsswitch/getgrgid.c
@@ -0,0 +1,57 @@
+/*
+ * Lookup a group by gid.
+ */
+
+#include <stdio.h>
+#include <grp.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+ struct group *gr;
+ gid_t gid;
+
+ /* Check args */
+
+ if (argc != 2) {
+ printf("ERROR: no arg specified\n");
+ exit(1);
+ }
+
+ if ((gid = atoi(argv[1])) == 0) {
+ printf("ERROR: invalid gid specified\n");
+ exit(1);
+ }
+
+ /* Do getgrgid() */
+
+ if ((gr = getgrgid(gid)) == NULL) {
+ printf("FAIL: gid %d does not exist\n", gid);
+ exit(1);
+ }
+
+ /* Print group info */
+
+ printf("PASS: gid %d exists\n", gid);
+ printf("gr_name = %s\n", gr->gr_name);
+ printf("gr_passwd = %s\n", gr->gr_passwd);
+ printf("gr_gid = %d\n", gr->gr_gid);
+
+ /* Group membership */
+
+ if (gr->gr_mem != NULL) {
+ int i = 0;
+
+ printf("gr_mem = ");
+ while(gr->gr_mem[i] != NULL) {
+ printf("%s", gr->gr_mem[i]);
+ i++;
+ if (gr->gr_mem != NULL) {
+ printf(",");
+ }
+ }
+ printf("\n");
+ }
+
+ exit(0);
+}
diff --git a/testsuite/nsswitch/getgrgid.exp b/testsuite/nsswitch/getgrgid.exp
new file mode 100644
index 00000000000..c53749f2629
--- /dev/null
+++ b/testsuite/nsswitch/getgrgid.exp
@@ -0,0 +1,50 @@
+#
+# @(#) Test reverse lookup of group ids from getent match getgrgid() output
+#
+
+load_lib util-defs.exp
+load_lib compile.exp
+
+# Compile getgruid.c
+
+simple_compile "getgrgid"
+
+# Get list of gids using getent
+
+set output [util_start "getent" "group" ""]
+set got_entries 0
+
+verbose $output
+
+foreach {line} [split $output "\n"] {
+
+ # Process user
+
+ set grp_entry [split $line ":"]
+ set group [lindex $grp_entry 0]
+
+ if {[regexp {^[^/]+/} $group]} {
+
+ set got_entries 1
+
+ # Only lookup winbindd users
+
+ set gid [lindex $grp_entry 2]
+
+ # Test lookup of gid succeeds
+
+ set output [util_start "$srcdir/$subdir/getgrgid" "$gid" ""]
+ verbose $output
+
+ if {[regexp "PASS:" $output]} {
+ pass "getgrgid $gid ($group)"
+ } else {
+ fail "getgrgid $gid ($group)"
+ }
+ }
+
+}
+
+if {!$got_entries} {
+ perror "No domain groups returned from getent"
+}
diff --git a/testsuite/nsswitch/getgrnam.c b/testsuite/nsswitch/getgrnam.c
new file mode 100644
index 00000000000..8ab4046bd9e
--- /dev/null
+++ b/testsuite/nsswitch/getgrnam.c
@@ -0,0 +1,51 @@
+/*
+ * Lookup a group by name
+ */
+
+#include <stdio.h>
+#include <grp.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+ struct group *gr;
+
+ /* Check args */
+
+ if (argc != 2) {
+ printf("ERROR: no arg specified\n");
+ exit(1);
+ }
+
+ /* Do getgrnam() */
+
+ if ((gr = getgrnam(argv[1])) == NULL) {
+ printf("FAIL: group %s does not exist\n", argv[1]);
+ exit(1);
+ }
+
+ /* Print group info */
+
+ printf("PASS: group %s exists\n", argv[1]);
+ printf("gr_name = %s\n", gr->gr_name);
+ printf("gr_passwd = %s\n", gr->gr_passwd);
+ printf("gr_gid = %d\n", gr->gr_gid);
+
+ /* Group membership */
+
+ if (gr->gr_mem != NULL) {
+ int i = 0;
+
+ printf("gr_mem = ");
+ while(gr->gr_mem[i] != NULL) {
+ printf("%s", gr->gr_mem[i]);
+ i++;
+ if (gr->gr_mem != NULL) {
+ printf(",");
+ }
+ }
+ printf("\n");
+ }
+
+ exit(0);
+}
diff --git a/testsuite/nsswitch/getgrnam.exp b/testsuite/nsswitch/getgrnam.exp
new file mode 100644
index 00000000000..92c5b76742e
--- /dev/null
+++ b/testsuite/nsswitch/getgrnam.exp
@@ -0,0 +1,28 @@
+#
+# @(#) Test domain groups resolve using getgrnam()
+#
+
+load_lib "util-defs.exp"
+load_lib "compile.exp"
+
+# Compile getgrnam.c
+
+simple_compile "getgrnam"
+
+# Test domain groups
+
+set group_list [split [util_start "bin/wbinfo" "-g"] "\n"]
+
+verbose $group_list
+
+foreach {group} $group_list {
+ set output [util_start "$srcdir/$subdir/getgrnam" "\"$group\"" ""]
+
+ verbose $output
+
+ if {[regexp "PASS:" $output]} {
+ pass "getgrnam $group"
+ } else {
+ fail "getgrnam $group"
+ }
+}
diff --git a/testsuite/nsswitch/getpwent_r.c b/testsuite/nsswitch/getpwent_r.c
new file mode 100644
index 00000000000..2ba7ea96f1e
--- /dev/null
+++ b/testsuite/nsswitch/getpwent_r.c
@@ -0,0 +1,85 @@
+/*
+ * Use set/get/endpwent calls from two processes to iterate over the
+ * password database. This checks the multithreaded stuff works.
+ */
+
+#include <stdio.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <wait.h>
+
+void dump_pwent(char *id)
+{
+ struct passwd *pw;
+ char fname[255];
+ FILE *fptr;
+
+ /* Open results file */
+
+ sprintf(fname, "/tmp/getpwent_r-%s.out-%d", id, getpid());
+
+ if ((fptr = fopen(fname, "w")) < 0) {
+ fprintf(stderr, "ERROR: could not open file %s: %s\n", fname,
+ sys_errlist[errno]);
+ return;
+ }
+
+ /* Dump passwd database */
+
+ setpwent();
+
+ while((pw = getpwent()) != NULL) {
+ fprintf(fptr,"%s:%s:%s:%d:%d\n", pw->pw_name, pw->pw_passwd,
+ pw->pw_gecos, pw->pw_uid, pw->pw_gid);
+ }
+
+ endpwent();
+
+ /* Close results file */
+
+ fclose(fptr);
+}
+
+#define NUM_FORKS 2
+
+int main(int argc, char **argv)
+{
+ pid_t pids[NUM_FORKS];
+ int i, status;
+
+ /* Check args */
+
+ if (argc != 2) {
+ printf("ERROR: must specify output file identifier\n");
+ return 1;
+ }
+
+ for(i = 0; i < NUM_FORKS; i++) {
+
+ /* Fork off lots */
+
+ if ((pids[i] = fork()) == -1) {
+ perror("fork");
+ return 1;
+ }
+
+ /* Child does tests */
+
+ if (pids[i] == 0) {
+ dump_pwent(argv[1]);
+ return 0;
+ }
+ }
+
+ /* Wait for everyone to finish */
+
+ for (i = 0; i < NUM_FORKS; i++) {
+ waitpid(pids[i], &status, 0);
+ }
+
+ printf("PASS: getpwent_r.c\n");
+ return 0;
+}
diff --git a/testsuite/nsswitch/getpwent_r.exp b/testsuite/nsswitch/getpwent_r.exp
new file mode 100644
index 00000000000..95c155d78cc
--- /dev/null
+++ b/testsuite/nsswitch/getpwent_r.exp
@@ -0,0 +1,41 @@
+#
+# @(#) Test multiple threads can enumerate users correctly
+#
+
+load_lib util-defs.exp
+load_lib "$srcdir/lib/nsswitch-config.exp"
+
+# Compile getpwent_r.c
+
+set output [target_compile "$srcdir/$subdir/getpwent_r.c" \
+ "$srcdir/$subdir/getpwent_r" executable {additional_flags="-g"}]
+
+if {$output != ""} {
+ perror "compile getpwent_r"
+ puts $output
+ fail ""
+}
+
+# Clean up output from previous tests
+
+set pid [pid]
+file delete [glob -nocomplain "/tmp/getpwent_r-$pid.out-*"]
+
+# Run test proggy
+
+set output [util_start "$srcdir/$subdir/getpwent_r" "$pid" ""]
+if {![regexp "^PASS:" $output]} {
+ perror "run getpwent_r"
+ puts $output
+ return -1
+}
+
+# Sort and compare output
+
+set output [util_start "$srcdir/$subdir/getent_r.sh" "getpwent $pid" ""]
+if {$output == ""} {
+ pass "getpwent_r"
+} else {
+ fail "getpwent_r"
+ puts $output
+}
diff --git a/testsuite/nsswitch/getpwnam.c b/testsuite/nsswitch/getpwnam.c
new file mode 100644
index 00000000000..e7dd2910b66
--- /dev/null
+++ b/testsuite/nsswitch/getpwnam.c
@@ -0,0 +1,37 @@
+/*
+ * Lookup a user by name
+ */
+
+#include <stdio.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+ struct passwd *pw;
+
+ /* Check args */
+
+ if (argc != 2) {
+ printf("ERROR: no arg specified\n");
+ exit(1);
+ }
+
+ /* Do getpwnam() */
+
+ if ((pw = getpwnam(argv[1])) == NULL) {
+ printf("FAIL: user %s does not exist\n", argv[1]);
+ exit(1);
+ }
+
+ printf("PASS: user %s exists\n", argv[1]);
+ printf("pw_name = %s\n", pw->pw_name);
+ printf("pw_passwd = %s\n", pw->pw_passwd);
+ printf("pw_uid = %d\n", pw->pw_uid);
+ printf("pw_gid = %d\n", pw->pw_gid);
+ printf("pw_gecos = %s\n", pw->pw_gecos);
+ printf("pw_dir = %s\n", pw->pw_dir);
+ printf("pw_shell = %s\n", pw->pw_shell);
+
+ exit(0);
+}
diff --git a/testsuite/nsswitch/getpwnam.exp b/testsuite/nsswitch/getpwnam.exp
new file mode 100644
index 00000000000..5f6b2343392
--- /dev/null
+++ b/testsuite/nsswitch/getpwnam.exp
@@ -0,0 +1,28 @@
+#
+# @(#) Test domain users resolve using getpwnam()
+#
+
+load_lib util-defs.exp
+load_lib "compile.exp"
+
+# Compile getpwnam.c
+
+simple_compile "getpwnam"
+
+# Test domain users
+
+set user_list [split [util_start "bin/wbinfo" "-u"] "\n"]
+
+verbose $user_list
+
+foreach { user } $user_list {
+ set output [util_start "$srcdir/$subdir/getpwnam" "\"$user\"" ""]
+
+ verbose $output
+
+ if {[regexp "PASS:" $output]} {
+ pass "getpwnam $user"
+ } else {
+ fail "getpwnam $user"
+ }
+}
diff --git a/testsuite/nsswitch/getpwuid.c b/testsuite/nsswitch/getpwuid.c
new file mode 100644
index 00000000000..3f364df29d5
--- /dev/null
+++ b/testsuite/nsswitch/getpwuid.c
@@ -0,0 +1,43 @@
+/*
+ * Lookup a user by uid.
+ */
+
+#include <stdio.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+ struct passwd *pw;
+ uid_t uid;
+
+ /* Check args */
+
+ if (argc != 2) {
+ printf("ERROR: no arg specified\n");
+ exit(1);
+ }
+
+ if ((uid = atoi(argv[1])) == 0) {
+ printf("ERROR: invalid uid specified\n");
+ exit(1);
+ }
+
+ /* Do getpwuid() */
+
+ if ((pw = getpwuid(uid)) == NULL) {
+ printf("FAIL: uid %d does not exist\n", uid);
+ exit(1);
+ }
+
+ printf("PASS: uid %d exists\n", uid);
+ printf("pw_name = %s\n", pw->pw_name);
+ printf("pw_passwd = %s\n", pw->pw_passwd);
+ printf("pw_uid = %d\n", pw->pw_uid);
+ printf("pw_gid = %d\n", pw->pw_gid);
+ printf("pw_gecos = %s\n", pw->pw_gecos);
+ printf("pw_dir = %s\n", pw->pw_dir);
+ printf("pw_shell = %s\n", pw->pw_shell);
+
+ exit(0);
+}
diff --git a/testsuite/nsswitch/getpwuid.exp b/testsuite/nsswitch/getpwuid.exp
new file mode 100644
index 00000000000..be6a01cb9e1
--- /dev/null
+++ b/testsuite/nsswitch/getpwuid.exp
@@ -0,0 +1,59 @@
+#
+# @(#) Test reverse lookup of user ids from getent match getpwuid() output
+#
+
+load_lib util-defs.exp
+
+# Compile getpwuid.c
+
+set output [target_compile "$srcdir/$subdir/getpwuid.c" \
+ "$srcdir/$subdir/getpwuid" executable {additional_flags="-g"}]
+
+if {$output != ""} {
+ perror "compile getpwuid"
+ puts $output
+ return
+}
+
+# Get list of uids using getent
+
+set output [util_start "getent" "passwd" ""]
+set got_entries 0
+
+verbose $output
+
+foreach {line} [split $output "\n"] {
+
+ # Process user
+
+ set pwd_entry [split $line ":"]
+ set user [lindex $pwd_entry 0]
+
+ if {[regexp {^[^/]+/} $user]} {
+
+ set got_entries 1
+
+ # Only lookup winbindd users
+
+ set uid [lindex $pwd_entry 2]
+ set gid [lindex $pwd_entry 3]
+
+ # Test lookup of uid succeeds
+
+ set output [util_start "$srcdir/$subdir/getpwuid" "$uid" ""]
+
+ verbose $output
+
+ set test_desc "getpwuid $uid ($user)"
+
+ if {[regexp "PASS:" $output]} {
+ pass $test_desc
+ } else {
+ fail $test_desc
+ }
+ }
+}
+
+if {!$got_entries} {
+ perror "No domain users returned from getent"
+}
diff --git a/testsuite/nsswitch/groupmem_dom.exp b/testsuite/nsswitch/groupmem_dom.exp
new file mode 100644
index 00000000000..3ba34bb810e
--- /dev/null
+++ b/testsuite/nsswitch/groupmem_dom.exp
@@ -0,0 +1,33 @@
+#
+# @(#) Test whether members of domain groups all have domain names
+#
+
+load_lib util-defs.exp
+
+set group_list [split [util_start "getent group" ""] "\n"]
+set failed 0
+
+foreach { group } $group_list {
+ set group_entry [split $group ":"]
+
+ set group_name [lindex $group_entry 0]
+ set group_members [split [lindex $group_entry 3] ","]
+
+ if { [regexp {^[^/]+/} $group_name] } {
+
+ verbose "group $group_name has members $group_members"
+
+ foreach { user } $group_members {
+ if { ![regexp {^[^/]+/} $user] } {
+ fail "group $group has non-domain user $user"
+ set failed 1
+ }
+ }
+ } else {
+ verbose "ignoring non-domain group $group_name"
+ }
+}
+
+if { !$failed } {
+ pass "domain groups contain only domain members"
+}
diff --git a/testsuite/nsswitch/initgroups.c b/testsuite/nsswitch/initgroups.c
new file mode 100644
index 00000000000..b7d9c50eaa3
--- /dev/null
+++ b/testsuite/nsswitch/initgroups.c
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <grp.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+int main(int argc, char **argv)
+{
+ int result, ngroups, i;
+ gid_t *groups;
+ struct passwd *pw;
+
+ if (!(pw = getpwnam(argv[1]))) {
+ printf("FAIL: no passwd entry for %s\n", argv[1]);
+ return 1;
+ }
+
+ result = initgroups(argv[1], pw->pw_gid);
+
+ if (result == -1) {
+ printf("FAIL");
+ return 1;
+ }
+
+ ngroups = getgroups(0, NULL);
+
+ groups = (gid_t *)malloc(sizeof(gid_t) * ngroups);
+ ngroups = getgroups(ngroups, groups);
+
+ printf("%s is a member of groups:\n", argv[1]);
+
+ for (i = 0; i < ngroups; i++) {
+ struct group *grp;
+
+ grp = getgrgid(groups[i]);
+
+ printf("%d (%s)\n", groups[i], grp ? grp->gr_name : "?");
+ }
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/nsswitch/initgroups.exp b/testsuite/nsswitch/initgroups.exp
new file mode 100644
index 00000000000..ab21bcc9e7b
--- /dev/null
+++ b/testsuite/nsswitch/initgroups.exp
@@ -0,0 +1,37 @@
+#
+# @(#) Test initgroups function
+#
+
+load_lib util-defs.exp
+load_lib compile.exp
+
+if { [util_start "id -u"] != 0 } {
+ set test_desc "must be userid 0 to run"
+ note $test_desc
+ untested $test_desc
+ return
+}
+
+# Compile test program
+
+simple_compile "initgroups"
+
+# Test domain users
+
+set user_list [split [util_start "bin/wbinfo" "-u"] "\n"]
+
+verbose $user_list
+
+foreach { user } $user_list {
+ set output [util_start "$srcdir/$subdir/initgroups" "\"$user\"" ""]
+
+ verbose $output
+
+ set test_desc "initgroups $user"
+
+ if { [regexp "PASS" $output] } {
+ pass $test_desc
+ } else {
+ fail $test_desc
+ }
+}
diff --git a/testsuite/nsswitch/login.exp b/testsuite/nsswitch/login.exp
new file mode 100644
index 00000000000..c2bb0e5a40a
--- /dev/null
+++ b/testsuite/nsswitch/login.exp
@@ -0,0 +1,102 @@
+#
+# @(#) Test logins using pam_winbind.so module using telnet
+#
+
+load_lib util-defs.exp
+load_lib nsswitch-config.exp
+
+#
+# @(#) Test user can login
+#
+
+spawn telnet localhost
+
+set test_desc "telnet localhost (login)"
+
+expect {
+ "login:" { }
+ timeout { fail "timed out in $test_desc"; return }
+ eof { fail "end of file in $test_desc"; return }
+}
+
+send "$domain/$USER\r"
+
+set test_desc "telnet localhost (password)"
+
+expect {
+ "Password:" { }
+ timeout { fail "timed out in $test_desc"; return }
+ eof { fail "end of file in $test_desc"; return }
+}
+
+send "$PASSWORD\r"
+
+expect {
+ "$ " { }
+ "Login incorrect" { fail "login incorrect"; return }
+ timeout { fail "timed out in $test_desc"; return }
+ eof { fail "end of file in $test_desc"; return }
+}
+
+pass "login $domain/$USER"
+
+#
+# @(#) Check supplementary group membership
+#
+
+set test_desc "supplementary groups"
+
+# Get list of groups
+
+send "id -G\r"
+
+expect {
+ -re "((\[0-9]+ )*\[0-9]+\r)" { exp_continue; }
+ "$ " { }
+ timeout { fail "timed out in $test_desc"; return }
+ eof { fail "end of file in $test_desc"; return }
+}
+
+set groups $expect_out(1,string)
+set wb_groups [util_start "bin/wbinfo" "-r $domain/$USER"]
+
+verbose "id groups are $groups"
+verbose "wbinfo groups are $wb_groups"
+
+# Check all groups from id are in wbinfo and vice-versa
+
+set failed 0
+
+foreach { group } $groups {
+ set got_group 0
+ foreach { wb_group } $wb_groups {
+ if { $wb_group == $group } {
+ set got_group 1
+ break
+ }
+ }
+
+ if { !$got_group } {
+ fail "group $group not in output of wbinfo -r"
+ set failed 1
+ }
+}
+
+foreach { wb_group } $wb_groups {
+ set got_group 0
+ foreach { group } $groups {
+ if { $group == $wb_group } {
+ set got_group 1
+ break
+ }
+ }
+
+ if { !$got_group } {
+ fail "group $group not in output of id -G"
+ set failed 1
+ }
+}
+
+if { !$failed } {
+ pass "id/wbinfo groups match"
+}
diff --git a/testsuite/nsswitch/longarg.exp b/testsuite/nsswitch/longarg.exp
new file mode 100644
index 00000000000..e1d0eda9ccb
--- /dev/null
+++ b/testsuite/nsswitch/longarg.exp
@@ -0,0 +1,29 @@
+#
+# @(#) Test handling of long arguments passed to various nss functions
+#
+
+load_lib compile.exp
+load_lib util-defs.exp
+
+# Run tests from C source files
+
+set longarg_tests [list \
+ { "long arg to getpwnam()" "longarg_getpwnam" } \
+ { "long arg to getgrnam()" "longarg_getgrnam" } \
+ ]
+
+foreach { test } $longarg_tests {
+ set test_desc [lindex $test 0]
+ set test_file [lindex $test 1]
+
+ simple_make "longarg" $test_file
+ set output [util_start "$srcdir/$subdir/$test_file" ]
+
+ if { [regexp "PASS" $output] } {
+ pass $test_desc
+ file delete "$srcdir/$subdir/$test_file" "$srcdir/$subdir/$test_file.o"
+ } else {
+ fail $test_desc
+ puts $output
+ }
+}
diff --git a/testsuite/nsswitch/longarg_getgrnam.c b/testsuite/nsswitch/longarg_getgrnam.c
new file mode 100644
index 00000000000..84083d2620e
--- /dev/null
+++ b/testsuite/nsswitch/longarg_getgrnam.c
@@ -0,0 +1,42 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <grp.h>
+#include <sys/types.h>
+
+#include "longarg_utils.h"
+
+int main(void)
+{
+ struct group *grp;
+ char *domain = getenv("TEST_WORKGROUP");
+ char long_name[65535];
+ int failed = 0;
+
+ sprintf(long_name, "%s/%s", domain, LONG_STRING);
+
+ grp = getgrnam(long_name);
+ printf("%s\n", !grp ? "PASS" : "FAIL");
+
+ return grp == NULL;
+}
diff --git a/testsuite/nsswitch/longarg_getpwnam.c b/testsuite/nsswitch/longarg_getpwnam.c
new file mode 100644
index 00000000000..f2a0a73ddca
--- /dev/null
+++ b/testsuite/nsswitch/longarg_getpwnam.c
@@ -0,0 +1,42 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <pwd.h>
+#include <sys/types.h>
+
+#include "longarg_utils.h"
+
+int main(void)
+{
+ struct passwd *pwd;
+ char *domain = getenv("TEST_WORKGROUP");
+ char long_name[65535];
+ int failed = 0;
+
+ sprintf(long_name, "%s/%s", domain, LONG_STRING);
+
+ pwd = getpwnam(long_name);
+ printf("%s\n", !pwd ? "PASS" : "FAIL");
+
+ return pwd == NULL;
+}
diff --git a/testsuite/nsswitch/longarg_utils.h b/testsuite/nsswitch/longarg_utils.h
new file mode 100644
index 00000000000..1f2f2a7065d
--- /dev/null
+++ b/testsuite/nsswitch/longarg_utils.h
@@ -0,0 +1,27 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _LONGARG_UTILS_H
+#define _LONGARG_UTILS_H
+
+#define LONG_STRING "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+
+#endif
diff --git a/testsuite/nsswitch/nss_winbind_syms.c b/testsuite/nsswitch/nss_winbind_syms.c
new file mode 100644
index 00000000000..29d1da9d499
--- /dev/null
+++ b/testsuite/nsswitch/nss_winbind_syms.c
@@ -0,0 +1,63 @@
+/*
+ * Test required functions are exported from the libnss_winbind.so library
+ */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+/* Symbol list to check */
+
+static char *symlist[] = {
+ "_nss_winbind_getgrent_r",
+ "_nss_winbind_endgrent",
+ "_nss_winbind_endpwent",
+ "_nss_winbind_getgrgid_r",
+ "_nss_winbind_getgrnam_r",
+ "_nss_winbind_getpwent_r",
+ "_nss_winbind_getpwnam_r",
+ "_nss_winbind_getpwuid_r",
+ "_nss_winbind_setgrent",
+ "_nss_winbind_setpwent",
+ "_nss_winbind_initgroups",
+ NULL
+};
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ void *handle, *sym;
+ int i, y;
+
+ /* Open library */
+
+ if (argc != 2) {
+ printf("FAIL: usage '%s sharedlibname'\n", argv[0]);
+ return 1;
+ }
+
+ handle = dlopen(argv[1], RTLD_NOW);
+
+ if (handle == NULL) {
+ printf("FAIL: could not dlopen library: %s\n", dlerror());
+ return 1;
+ }
+
+ /* Read symbols */
+
+ for (i = 0; symlist[i] != NULL; i++) {
+ sym = dlsym(handle, symlist[i]);
+ if (sym == NULL) {
+ printf("FAIL: could not resolve symbol '%s': %s\n",
+ symlist[i], dlerror());
+ return 1;
+ } else {
+ printf("loaded symbol '%s' ok\n", symlist[i]);
+ }
+ }
+
+ /* Clean up */
+
+ dlclose(handle);
+ return 0;
+}
diff --git a/testsuite/nsswitch/nss_winbind_syms.exp b/testsuite/nsswitch/nss_winbind_syms.exp
new file mode 100644
index 00000000000..ab84cc5c757
--- /dev/null
+++ b/testsuite/nsswitch/nss_winbind_syms.exp
@@ -0,0 +1,42 @@
+#
+# @(#) Test nss functions are exported from the libnss_winbind.so library
+# @(#) Test there are no external dependencies in the libnss_winbind.so library
+#
+# We expect the following symbols to be exported:
+#
+# _nss_winbind_getgrent_r
+# _nss_winbind_endgrent
+# _nss_winbind_endpwent
+# _nss_winbind_getgrgid_r
+# _nss_winbind_getgrnam_r
+# _nss_winbind_getpwent_r
+# _nss_winbind_getpwnam_r
+# _nss_winbind_getpwuid_r
+# _nss_winbind_setgrent
+# _nss_winbind_setpwent
+# _nss_winbind_initgroups
+#
+# This test also has the nice side-effect of showing any unresolved symbols
+# in the library.
+#
+
+load_lib util-defs.exp
+load_lib compile.exp
+
+simple_compile "nss_winbind_syms" "-ldl"
+
+set output [util_start "$srcdir/$subdir/nss_winbind_syms" \
+ "nsswitch/libnss_winbind.so"]
+
+verbose $output
+
+if { [regexp "FAIL:" $output] } {
+ fail "run nss_winbind_syms"
+ return
+}
+
+pass "nss_winbind_syms"
+
+# Clean up
+
+file delete "$srcdir/$subdir/nss_winbind_syms"
diff --git a/testsuite/nsswitch/pam_winbind_syms.c b/testsuite/nsswitch/pam_winbind_syms.c
new file mode 100644
index 00000000000..1264bdb23e2
--- /dev/null
+++ b/testsuite/nsswitch/pam_winbind_syms.c
@@ -0,0 +1,55 @@
+/*
+ * Test required functions are exported from the pam_winbind.so library
+ */
+
+#include <stdio.h>
+#include <dlfcn.h>
+
+/* Symbol list to check */
+
+static char *symlist[] = {
+ "pam_sm_acct_mgmt",
+ "pam_sm_authenticate",
+ "pam_sm_setcred",
+ NULL
+};
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ void *handle, *sym;
+ int i, y;
+
+ /* Open library */
+
+ if (argc != 2) {
+ printf("FAIL: usage '%s sharedlibname'\n", argv[0]);
+ return 1;
+ }
+
+ handle = dlopen(argv[1], RTLD_NOW);
+
+ if (handle == NULL) {
+ printf("FAIL: could not dlopen library: %s\n", dlerror());
+ return 1;
+ }
+
+ /* Read symbols */
+
+ for (i = 0; symlist[i] != NULL; i++) {
+ sym = dlsym(handle, symlist[i]);
+ if (sym == NULL) {
+ printf("FAIL: could not resolve symbol '%s': %s\n",
+ symlist[i], dlerror());
+ return 1;
+ } else {
+ printf("loaded symbol '%s' ok\n", symlist[i]);
+ }
+ }
+
+ /* Clean up */
+
+ dlclose(handle);
+ return 0;
+}
diff --git a/testsuite/nsswitch/pam_winbind_syms.exp b/testsuite/nsswitch/pam_winbind_syms.exp
new file mode 100644
index 00000000000..f95274cdd9d
--- /dev/null
+++ b/testsuite/nsswitch/pam_winbind_syms.exp
@@ -0,0 +1,44 @@
+#
+# @(#) Test nss functions are exported from the pam_winbind.so library
+# @(#) Test there are no external dependencies in the pam_winbind.so library
+#
+# We expect the following symbols to be exported:
+#
+# pam_sm_acct_mgmt
+# pam_sm_authenticate
+# pam_sm_setcred
+#
+# This test also has the nice side-effect of showing any unresolved symbols
+# in the library.
+#
+
+load_lib util-defs.exp
+
+# Compile pam_winbind_syms.c
+
+set output [target_compile "$srcdir/$subdir/pam_winbind_syms.c" \
+ "$srcdir/$subdir/pam_winbind_syms" executable \
+ {"libs=-ldl -lpam" "additional_flags=-g"}]
+
+if {$output != ""} {
+ perror "compile pam_winbind_syms.c"
+ puts $output
+ return
+}
+
+# Run load-dl.c
+
+set output [util_start "$srcdir/$subdir/pam_winbind_syms" \
+ "nsswitch/pam_winbind.so"]
+
+if {[regexp "FAIL:" $output]} {
+ fail "run pam_winbind_syms"
+ puts $output
+ return
+}
+
+pass "pam_winbind_syms"
+
+# Clean up
+
+file delete "$srcdir/$subdir/pam_winbind_syms"
diff --git a/testsuite/nsswitch/wbinfo.exp b/testsuite/nsswitch/wbinfo.exp
new file mode 100644
index 00000000000..8be25b2a0f1
--- /dev/null
+++ b/testsuite/nsswitch/wbinfo.exp
@@ -0,0 +1,360 @@
+#
+# @(#) Test wbinfo client access to winbind daemon
+#
+
+load_lib "util-defs.exp"
+load_lib "$srcdir/lib/nsswitch-config.exp"
+load_lib "$srcdir/lib/default-nt-names.exp"
+
+# Name types
+
+set SID_NAME_USER 1
+set SID_NAME_DOM_GRP 2
+set SID_NAME_DOMAIN 3
+set SID_NAME_ALIAS 4
+set SID_NAME_UNKNOWN 8
+
+# Get list of users and groups
+
+set user_list [util_start "bin/wbinfo" "-u"]
+set group_list [util_start "bin/wbinfo" "-g"]
+
+verbose "user list is:\n$user_list"
+verbose "group list is:\n$group_list"
+
+set user_list [split $user_list "\n"]
+set group_list [split $group_list "\n"]
+
+#
+# @(#) Check list of users and groups contain default NT user and group
+# @(#) names
+#
+
+# Users
+
+foreach { user } $domain_users {
+ set test_desc "user $user in wbinfo domain users"
+ if {![regexp $user $user_list]} {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+# Groups
+
+foreach { group } $domain_groups {
+ set test_desc "group $group in wbinfo domain groups"
+ if {![regexp $group $group_list]} {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+#
+# @(#) Lookup sids for all user and group names returned by wbinfo
+#
+
+# Users
+
+foreach { user } $user_list {
+ set test_desc "get sid for user $user"
+ set output [util_start "bin/wbinfo" "-n \"$user\""]
+
+ verbose $output
+
+ # Split output into name and name_type
+
+ set list [split $output " "]
+ set sid_type [lindex $list [expr [llength $list] - 1]]
+ set sid [join [lrange $list 0 [expr [llength $list] - 2]] " "]
+
+ if { ![regexp "S-" $sid] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ set test_desc "sid type for user $user"
+ if { $sid_type != $SID_NAME_USER } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ lappend user_sid_list $sid
+}
+
+# Groups
+
+foreach { group } $group_list {
+ set test_desc "get sid for group $group"
+ set output [util_start "bin/wbinfo" "-n \"$group\""]
+
+ verbose $output
+
+ # Split output into sid and sid type
+
+ set list [split $output " "]
+ set sid_type [lindex $list [expr [llength $list] - 1]]
+ set sid [join [lrange $list 0 [expr [llength $list] - 2]] " "]
+
+ if { ![regexp "S-" $sid] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ set test_desc "sid type for group group"
+ if { $sid_type != $SID_NAME_DOM_GRP } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ lappend group_sid_list $sid
+}
+
+#
+# @(#) Check reverse lookup of sids to names
+#
+
+# Users
+
+set count 0
+
+foreach { sid } $user_sid_list {
+ set test_desc "reverse user name lookup for sid $sid"
+ set output [util_start "bin/wbinfo" "-s $sid"]
+
+ verbose $output
+
+ # Split output into name and name_type
+
+ set list [split $output " "]
+ set name_type [lindex $list [expr [llength $list] - 1]]
+ set name [join [lrange $list 0 [expr [llength $list] - 2]] " "]
+
+ if { $name != [lindex $user_list $count] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ set test_desc "reverse user name type lookup for sid $sid"
+
+ if { $name_type != 1 } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ incr count
+}
+
+# Groups
+
+set count 0
+
+foreach { sid } $group_sid_list {
+ set test_desc "reverse group name lookup for sid $sid"
+ set output [util_start "bin/wbinfo" "-s $sid"]
+
+ verbose $output
+
+ # Split output into name and name_type
+
+ set list [split $output " "]
+ set name_type [lindex $list [expr [llength $list] - 1]]
+ set name [join [lrange $list 0 [expr [llength $list] - 2]] " "]
+
+ if { $name != [lindex $group_list $count] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ set test_desc "reverse group name type lookup for sid $sid"
+
+ if { $name_type != 2 } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ incr count
+}
+
+#
+# @(#) Cross-check the output of wbinfo -n, getent passwd/group and
+# @(#) wbinfo -S
+#
+
+# Get mapped list of uids from winbindd
+
+set output [util_start "getent" "passwd"]
+set user_list [split $output "\n"]
+
+foreach { user_entry } $user_list {
+ if { [regexp $domain $user_entry] } {
+ set field_list [split $user_entry ":"]
+ set name_output [util_start "bin/wbinfo" \
+ "-n \"[lindex $field_list 0]\""]
+ set list [split $name_output " "]
+ set name_type [lindex $list [expr [llength $list] - 1]]
+ set name [join [lrange $list 0 [expr [llength $list] - 2]] " "]
+ set username_uid_sid [lappend username_uid_sid [list \
+ [lindex $field_list 0] \
+ [lindex $field_list 2] \
+ $name]]
+ }
+}
+
+# Get mapped list of gids from winbindd
+
+set output [util_start "getent" "group"]
+set group_list [split $output "\n"]
+
+foreach { group_entry } $group_list {
+ if { [regexp $domain $group_entry] } {
+ set field_list [split $group_entry ":"]
+ set groupname_gid_sid [lappend groupname_gid_sid [list \
+ [lindex $field_list 0] \
+ [lindex $field_list 2] \
+ [util_start "bin/wbinfo" "-n \"[lindex $field_list 0]\""]]]
+ }
+}
+
+# OK, now we have enough info to cross-check the uid/gid -> sid and
+# sid -> uid/gid functions
+
+foreach { user } $username_uid_sid {
+ set sid [util_start "bin/wbinfo" "-U [lindex $user 1]"]
+ set uid [util_start "bin/wbinfo" "-S [lindex $user 2]"]
+
+ set test_desc "lookup sid by uid [lindex $user 1]"
+
+ if { $sid != [lindex $user 2] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ set test_desc "lookup uid by sid [lindex $user 2]"
+
+ if { $uid != [lindex $user 1] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+foreach { group } $groupname_gid_sid {
+ set sid [util_start "bin/wbinfo" "-G [lindex $group 1]"]
+ set gid [util_start "bin/wbinfo" "-Y [lindex $group 2]"]
+
+ set test_desc "lookup sid by gid [lindex $group 1]"
+
+ if { $sid != [lindex [split [lindex $group 2] " "] 0] ||
+ [lindex [split [lindex $group 2] " " ] 1] != 2 } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+
+ set test_desc "lookup gid by sid [lindex $group 2]"
+
+ if { $gid != [lindex $group 1] } {
+ fail $test_desc
+ } else {
+ pass $test_desc
+ }
+}
+
+# Check exit codes
+
+proc check_errcode { args } {
+ global errorCode
+ set test_desc [lindex $args 0]
+ set cmd [lindex $args 1]
+ set result [lindex $args 2]
+
+ set errorCode ""
+ verbose "Spawning $cmd"
+ catch "exec $cmd" output
+ set exit_code [lindex $errorCode 2]
+ if { $exit_code == "" } { set exit_code 0 }
+
+ if { $exit_code == $result } {
+ verbose "process returned correct exit code $exit_code"
+ pass $test_desc
+ } else {
+ verbose "process returned bad exit code $exit_code instead of $result"
+ fail $test_desc
+ }
+}
+
+set gooduser_name [lindex [split [lindex $user_list 0] ":"] 0]
+set gooduser_sid [util_start "bin/wbinfo" "-n $gooduser_name"]
+
+set goodgroup_name [lindex [split [lindex $group_list 0] ":"] 0]
+set goodgroup_sid [util_start "bin/wbinfo" "-n $goodgroup_name"]
+
+# Some conditions not tested:
+# - bad list users/groups
+# - good uid/gid to sid
+
+set errcode_tests [list \
+ { "exit code, no arg" "bin/wbinfo" 1 } \
+ { "exit code, invalid arg" "bin/wbinfo -@" 1 } \
+ { "exit code, list users" "bin/wbinfo -u" 0 } \
+ { "exit code, list groups" "bin/wbinfo -g" 0 } \
+ { "exit code, good name to sid" "bin/wbinfo -n $gooduser_name" 0 } \
+ { "exit code, bad name to sid" "bin/wbinfo -n asmithee" 1 } \
+ { "exit code, good sid to name" "bin/wbinfo -s $gooduser_sid" 0 } \
+ { "exit code, bad sid to name" "bin/wbinfo -s S-1234" 1 } \
+ { "exit code, bad uid to sid" "bin/wbinfo -U 0" 1 } \
+ { "exit code, bad gid to sid" "bin/wbinfo -G 0" 1} \
+ { "exit code, good sid to uid" "bin/wbinfo -S $gooduser_sid" 0 } \
+ { "exit code, bad sid to uid" "bin/wbinfo -S S-1234" 1 } \
+ { "exit code, good sid to gid" "bin/wbinfo -Y $goodgroup_sid" 0 } \
+ { "exit code, bad sid to gid" "bin/wbinfo -Y S-1234" 1 } \
+ ]
+
+foreach { test } $errcode_tests {
+ check_errcode [lindex $test 0] [lindex $test 1] [lindex $test 2]
+}
+
+# Test enumerate trusted domains
+
+set test_desc "enumerate trusted domains"
+set output [util_start "bin/wbinfo" "-m"]
+
+verbose $output
+
+foreach { the_domain } $output {
+ if { $the_domain == $domain} {
+ fail "own domain appears in trusted list"
+ }
+}
+
+if {[regexp "Usage" $output] || [regexp "Could not" $output]} {
+ fail $test_desc
+} else {
+ pass $test_desc
+}
+
+# Test check machine account
+
+set test_desc "check machine account"
+set output [util_start "bin/wbinfo" "-t"]
+
+verbose $output
+
+if {[regexp "Usage" $output] || [regexp "Could not" $output] || \
+ ![regexp "(good|bad)" $output]} {
+ fail $test_desc
+} else {
+ pass $test_desc
+}
diff --git a/testsuite/printing/.cvsignore b/testsuite/printing/.cvsignore
new file mode 100644
index 00000000000..392f2777686
--- /dev/null
+++ b/testsuite/printing/.cvsignore
@@ -0,0 +1,2 @@
+vlp
+psec
diff --git a/testsuite/printing/Makefile.psec b/testsuite/printing/Makefile.psec
new file mode 100644
index 00000000000..1410c9e0099
--- /dev/null
+++ b/testsuite/printing/Makefile.psec
@@ -0,0 +1,22 @@
+#
+# Makefile for psec utility
+#
+
+#
+# NOTE: Samba must be configured with the --srcdir option before this Makefile
+# will work: ./configure --srcdir=`pwd`
+#
+# Compile with: make -f Makefile.psec psec
+#
+
+psec_default: psec
+
+include ../../source/Makefile
+
+PSEC_OBJ1 = $(LIB_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) $(RPC_PARSE_OBJ) \
+ $(LIBSMB_OBJ) $(PASSDB_OBJ) $(RPC_CLIENT_OBJ)
+
+PSEC_OBJS = $(PSEC_OBJ1:%=$(srcdir)/%)
+
+psec: $(PSEC_OBJS) psec.o
+ $(CC) -o $@ psec.o $(PSEC_OBJS) $(LIBS)
diff --git a/testsuite/printing/Makefile.vlp b/testsuite/printing/Makefile.vlp
new file mode 100644
index 00000000000..142082ebfe6
--- /dev/null
+++ b/testsuite/printing/Makefile.vlp
@@ -0,0 +1,14 @@
+#
+# Makefile for vlp utility
+#
+
+vlp_default: vlp
+
+include ../../source/Makefile
+
+VLP_OBJ1 = $(LIB_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ)
+
+VLP_OBJS = $(VLP_OBJ1:%=$(srcdir)/%)
+
+vlp: $(VLP_OBJS) vlp.o
+ $(CC) -o $@ vlp.o $(VLP_OBJS) $(LIBS)
diff --git a/testsuite/printing/README.vlp b/testsuite/printing/README.vlp
new file mode 100644
index 00000000000..48d2c8c0a2b
--- /dev/null
+++ b/testsuite/printing/README.vlp
@@ -0,0 +1,35 @@
+Virtual line printer test program (vlp)
+=======================================
+
+This can be useful for testing/debugging Samba print code. It gives you a
+virtual full-function printer.
+
+Setup
+
+1) Configure and build Samba.
+ For this to work, you need to add:
+ -DDEVELOPER
+ to your CFLAGS, and add:
+ --srcdir=<wherever your source is>
+ when running configure. Generally
+ ./configure --srcdir=`pwd` <other configure options>
+ should work.
+
+2) Build and install vlp.
+ # cd testsuite/printing
+ # make -f Makefile.vlp vlp
+ # su
+ # cp vlp /usr/local/samba/bin
+
+3) Set up Samba to use vlp.
+ In your smb.conf file under [global], add the following option:
+ printing = vlp
+ and then add any number of print shares, without needing to make them
+ really exist.
+
+ [testprinter]
+ printable = yes
+
+ is all you need for the most basic virtual printer.
+
+
diff --git a/testsuite/printing/psec.c b/testsuite/printing/psec.c
new file mode 100644
index 00000000000..7ba40b18a31
--- /dev/null
+++ b/testsuite/printing/psec.c
@@ -0,0 +1,436 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.0
+
+ Printer security permission manipulation.
+
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/* This program can get or set NT printer security permissions from the
+ command line. Usage: psec getsec|setsec printername. You must have
+ write access to the ntdrivers.tdb file to set permissions and read
+ access to get permissions.
+
+ For this program to compile using the supplied Makefile.psec, Samba
+ must be configured with the --srcdir option
+
+ For getsec, output like the following is sent to standard output:
+
+ S-1-5-21-1067277791-1719175008-3000797951-500
+
+ 1 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-501
+ 1 2 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-501
+ 0 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-500
+ 0 2 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-500
+ 0 9 0x10000000 S-1-5-21-1067277791-1719175008-3000797951-513
+ 0 2 0x00020000 S-1-5-21-1067277791-1719175008-3000797951-513
+ 0 2 0xe0000000 S-1-1-0
+
+ The first two lines describe the owner user and owner group of the printer.
+ If either of these lines are blank then the respective owner property is
+ not set. The remaining lines list the printer permissions or ACE entries,
+ one per line. Each column describes a different property of the ACE:
+
+ Column Description
+ -------------------------------------------------------------------
+ 1 ACE type (allow/deny etc) defined in rpc_secdes.h
+ 2 ACE flags defined in rpc_secdes.h
+ 3 ACE mask - printer ACE masks are defined in rpc_spoolss.h
+ 4 SID the ACE applies to
+
+ The above example describes the following permissions in order:
+
+ - The guest user has No Access to the printer
+ - The domain administrator has Full Access
+ - Domain Users can Manage Documents
+ - Everyone has Print access
+
+ The setsec command takes the output format but sets the security descriptor
+ appropriately. */
+
+#include "includes.h"
+
+TDB_CONTEXT *tdb;
+
+/* ACE type conversions */
+
+char *ace_type_to_str(uint ace_type)
+{
+ static fstring temp;
+
+ switch(ace_type) {
+ case SEC_ACE_TYPE_ACCESS_DENIED:
+ return "DENY";
+ case SEC_ACE_TYPE_ACCESS_ALLOWED:
+ return "ALLOW";
+ }
+
+ slprintf(temp, sizeof(temp) - 1, "0x%02x", ace_type);
+ return temp;
+}
+
+uint str_to_ace_type(char *ace_type)
+{
+ if (strcmp(ace_type, "ALLOWED") == 0)
+ return SEC_ACE_TYPE_ACCESS_ALLOWED;
+
+ if (strcmp(ace_type, "DENIED") == 0)
+ return SEC_ACE_TYPE_ACCESS_DENIED;
+
+ return -1;
+}
+
+/* ACE mask (permission) conversions */
+
+char *ace_mask_to_str(uint32 ace_mask)
+{
+ static fstring temp;
+
+ switch (ace_mask) {
+ case PRINTER_ACE_FULL_CONTROL:
+ return "Full Control";
+ case PRINTER_ACE_MANAGE_DOCUMENTS:
+ return "Manage Documents";
+ case PRINTER_ACE_PRINT:
+ return "Print";
+ }
+
+ slprintf(temp, sizeof(temp) - 1, "0x%08x", ace_mask);
+ return temp;
+}
+
+uint32 str_to_ace_mask(char *ace_mask)
+{
+ if (strcmp(ace_mask, "Full Control") == 0)
+ return PRINTER_ACE_FULL_CONTROL;
+
+ if (strcmp(ace_mask, "Manage Documents") == 0)
+ return PRINTER_ACE_MANAGE_DOCUMENTS;
+
+ if (strcmp(ace_mask, "Print") == 0)
+ return PRINTER_ACE_PRINT;
+
+ return -1;
+}
+
+/* ACE conversions */
+
+char *ace_to_str(SEC_ACE *ace)
+{
+ static pstring temp;
+ fstring sidstr;
+
+ sid_to_string(sidstr, &ace->sid);
+
+ slprintf(temp, sizeof(temp) - 1, "%s %d %s %s",
+ ace_type_to_str(ace->type), ace->flags,
+ ace_mask_to_str(ace->info.mask), sidstr);
+
+ return temp;
+}
+
+void str_to_ace(SEC_ACE *ace, char *ace_str)
+{
+ SEC_ACCESS sa;
+ DOM_SID sid;
+ uint32 mask;
+ uint8 type, flags;
+
+ init_sec_access(&sa, mask);
+ init_sec_ace(ace, &sid, type, sa, flags);
+}
+
+/* Get a printer security descriptor */
+
+int psec_getsec(char *printer)
+{
+ SEC_DESC_BUF *secdesc_ctr = NULL;
+ TALLOC_CTX *mem_ctx = NULL;
+ fstring keystr, sidstr, tdb_path;
+ prs_struct ps;
+ int result = 0, i;
+
+ ZERO_STRUCT(ps);
+
+ /* Open tdb for reading */
+
+ slprintf(tdb_path, sizeof(tdb_path) - 1, "%s/ntdrivers.tdb",
+ lp_lockdir());
+
+ tdb = tdb_open(tdb_path, 0, 0, O_RDONLY, 0600);
+
+ if (!tdb) {
+ printf("psec: failed to open nt drivers database: %s\n",
+ sys_errlist[errno]);
+ return 1;
+ }
+
+ /* Get security blob from tdb */
+
+ slprintf(keystr, sizeof(keystr) - 1, "SECDESC/%s", printer);
+
+ mem_ctx = talloc_init();
+
+ if (!mem_ctx) {
+ printf("memory allocation error\n");
+ result = 1;
+ goto done;
+ }
+
+ if (tdb_prs_fetch(tdb, keystr, &ps, mem_ctx) != 0) {
+ printf("error fetching descriptor for printer %s\n",
+ printer);
+ /* cannot do a prs_mem_free() when tdb_prs_fetch fails */
+ /* as the prs structure has not been initialized */
+ tdb_close(tdb);
+ talloc_destroy(mem_ctx);
+ return 1;
+ }
+
+ /* Unpack into security descriptor buffer */
+
+ if (!sec_io_desc_buf("nt_printing_getsec", &secdesc_ctr, &ps, 1)) {
+ printf("error unpacking sec_desc_buf\n");
+ result = 1;
+ goto done;
+ }
+
+ /* Print owner and group sid */
+
+ if (secdesc_ctr->sec->owner_sid) {
+ sid_to_string(sidstr, secdesc_ctr->sec->owner_sid);
+ } else {
+ fstrcpy(sidstr, "");
+ }
+
+ printf("%s\n", sidstr);
+
+ if (secdesc_ctr->sec->grp_sid) {
+ sid_to_string(sidstr, secdesc_ctr->sec->grp_sid);
+ } else {
+ fstrcpy(sidstr, "");
+ }
+
+ printf("%s\n", sidstr);
+
+ /* Print aces */
+
+ if (!secdesc_ctr->sec->dacl) {
+ result = 0;
+ goto done;
+ }
+
+ for (i = 0; i < secdesc_ctr->sec->dacl->num_aces; i++) {
+ SEC_ACE *ace = &secdesc_ctr->sec->dacl->ace[i];
+
+ sid_to_string(sidstr, &ace->sid);
+
+ printf("%d %d 0x%08x %s\n", ace->type, ace->flags,
+ ace->info.mask, sidstr);
+ }
+
+ done:
+ if (tdb) tdb_close(tdb);
+ if (mem_ctx) talloc_destroy(mem_ctx);
+ if (secdesc_ctr) free_sec_desc_buf(&secdesc_ctr);
+ prs_mem_free(&ps);
+
+ return result;
+}
+
+/* Set a printer security descriptor */
+
+int psec_setsec(char *printer)
+{
+ DOM_SID user_sid, group_sid;
+ SEC_ACE *ace_list = NULL;
+ SEC_ACL *dacl = NULL;
+ SEC_DESC *sd;
+ SEC_DESC_BUF *sdb = NULL;
+ int result = 0, num_aces = 0;
+ fstring line, keystr, tdb_path;
+ size_t size;
+ prs_struct ps;
+ TALLOC_CTX *mem_ctx = NULL;
+ BOOL has_user_sid = False, has_group_sid = False;
+
+ ZERO_STRUCT(ps);
+
+ /* Open tdb for reading */
+
+ slprintf(tdb_path, sizeof(tdb_path) - 1, "%s/ntdrivers.tdb",
+ lp_lockdir());
+
+ tdb = tdb_open(tdb_path, 0, 0, O_RDWR, 0600);
+
+ if (!tdb) {
+ printf("psec: failed to open nt drivers database: %s\n",
+ sys_errlist[errno]);
+ result = 1;
+ goto done;
+ }
+
+ /* Read owner and group sid */
+
+ fgets(line, sizeof(fstring), stdin);
+ if (line[0] != '\n') {
+ string_to_sid(&user_sid, line);
+ has_user_sid = True;
+ }
+
+ fgets(line, sizeof(fstring), stdin);
+ if (line[0] != '\n') {
+ string_to_sid(&group_sid, line);
+ has_group_sid = True;
+ }
+
+ /* Read ACEs from standard input for discretionary ACL */
+
+ while(fgets(line, sizeof(fstring), stdin)) {
+ int ace_type, ace_flags;
+ uint32 ace_mask;
+ fstring sidstr;
+ DOM_SID sid;
+ SEC_ACCESS sa;
+
+ if (sscanf(line, "%d %d 0x%x %s", &ace_type, &ace_flags,
+ &ace_mask, sidstr) != 4) {
+ continue;
+ }
+
+ string_to_sid(&sid, sidstr);
+
+ ace_list = Realloc(ace_list, sizeof(SEC_ACE) *
+ (num_aces + 1));
+
+ init_sec_access(&sa, ace_mask);
+ init_sec_ace(&ace_list[num_aces], &sid, ace_type, sa,
+ ace_flags);
+
+ num_aces++;
+ }
+
+ dacl = make_sec_acl(ACL_REVISION, num_aces, ace_list);
+ free(ace_list);
+
+ /* Create security descriptor */
+
+ sd = make_sec_desc(SEC_DESC_REVISION,
+ has_user_sid ? &user_sid : NULL,
+ has_group_sid ? &group_sid : NULL,
+ NULL, /* System ACL */
+ dacl, /* Discretionary ACL */
+ &size);
+
+ free_sec_acl(&dacl);
+
+ sdb = make_sec_desc_buf(size, sd);
+
+ free_sec_desc(&sd);
+
+ /* Write security descriptor to tdb */
+
+ mem_ctx = talloc_init();
+
+ if (!mem_ctx) {
+ printf("memory allocation error\n");
+ result = 1;
+ goto done;
+ }
+
+ prs_init(&ps, (uint32)sec_desc_size(sdb->sec) +
+ sizeof(SEC_DESC_BUF), 4, mem_ctx, MARSHALL);
+
+ if (!sec_io_desc_buf("nt_printing_setsec", &sdb, &ps, 1)) {
+ printf("sec_io_desc_buf failed\n");
+ goto done;
+ }
+
+ slprintf(keystr, sizeof(keystr) - 1, "SECDESC/%s", printer);
+
+ if (!tdb_prs_store(tdb, keystr, &ps)==0) {
+ printf("Failed to store secdesc for %s\n", printer);
+ goto done;
+ }
+
+ done:
+ if (tdb) tdb_close(tdb);
+ if (sdb) free_sec_desc_buf(&sdb);
+ if (mem_ctx) talloc_destroy(mem_ctx);
+ prs_mem_free(&ps);
+
+ return result;
+}
+
+/* Help */
+
+void usage(void)
+{
+ printf("Usage: psec getsec|setsec printername\n");
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ pstring servicesf = CONFIGFILE;
+
+ /* Argument check */
+
+ if (argc == 1) {
+ usage();
+ return 1;
+ }
+
+ /* Load smb.conf file */
+
+ charset_initialise();
+
+ if (!lp_load(servicesf,False,False,True)) {
+ fprintf(stderr, "Couldn't load confiuration file %s\n",
+ servicesf);
+ return 1;
+ }
+
+ /* Do commands */
+
+ if (strcmp(argv[1], "setsec") == 0) {
+
+ if (argc != 3) {
+ usage();
+ return 1;
+ }
+
+ return psec_setsec(argv[2]);
+ }
+
+ if (strcmp(argv[1], "getsec") == 0) {
+
+ if (argc != 3) {
+ usage();
+ return 1;
+ }
+
+ return psec_getsec(argv[2]);
+ }
+
+ /* An unknown command */
+
+ printf("psec: unknown command %s\n", argv[1]);
+ return 1;
+}
diff --git a/testsuite/printing/vlp.c b/testsuite/printing/vlp.c
new file mode 100644
index 00000000000..2dd028fcd38
--- /dev/null
+++ b/testsuite/printing/vlp.c
@@ -0,0 +1,426 @@
+/*
+ Unix SMB/Netbios implementation.
+
+ Virtual lp system for printer testing
+
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+#define PRINT_TDB "/tmp/vlp.tdb"
+#define PRINT_FIRSTJOB "100"
+
+static TDB_CONTEXT *tdb;
+
+struct vlp_job {
+ fstring owner;
+ int jobid;
+ fstring jobname;
+ int size;
+ int status;
+ time_t submit_time;
+ int deleted;
+};
+
+/* Print usage */
+
+static void usage(void)
+{
+ printf("Usage: print-test lpq|lprm|print|queuepause|queueresume|"
+ "lppause|lpresume [args]\n");
+}
+
+/* Return an array of vlp jobs that is the printer queue */
+
+static void get_job_list(char *printer, struct vlp_job **job_list,
+ int *num_jobs)
+{
+ fstring keystr;
+ TDB_DATA data;
+
+ slprintf(keystr, sizeof(keystr) - 1, "LPQ/%s", printer);
+ data = tdb_fetch_by_string(tdb, keystr);
+
+ *job_list = (struct vlp_job *)data.dptr;
+ *num_jobs = data.dsize / sizeof(struct vlp_job);
+}
+
+/* Store an array of vl jobs for the queue */
+
+static void set_job_list(char *printer, struct vlp_job *job_list,
+ int num_jobs)
+{
+ fstring keystr;
+
+ slprintf(keystr, sizeof(keystr) - 1, "LPQ/%s", printer);
+
+ tdb_store_by_string(tdb, keystr, job_list,
+ num_jobs * sizeof(struct vlp_job));
+}
+
+/* Return the next job number for a printer */
+
+static int next_jobnum(char *printer)
+{
+ fstring keystr;
+ int jobnum;
+
+ slprintf(keystr, sizeof(keystr) - 1, "JOBNUM/%s", printer);
+
+ tdb_lock_bystring(tdb, keystr);
+
+ jobnum = tdb_fetch_int(tdb, keystr);
+
+ /* Create next job index if none exists */
+
+ if (jobnum == -1) {
+ jobnum = atoi(PRINT_FIRSTJOB);
+ }
+
+ jobnum++;
+ tdb_store_int(tdb, keystr, jobnum);
+
+ tdb_unlock_bystring(tdb, keystr);
+
+ return jobnum;
+}
+
+static void set_printer_status(char *printer, int status)
+{
+ fstring keystr;
+ int result;
+
+ slprintf(keystr, sizeof(keystr) - 1, "STATUS/%s", printer);
+ result = tdb_store_int(tdb, keystr, status);
+}
+
+static int get_printer_status(char *printer)
+{
+ fstring keystr;
+ TDB_DATA data;
+
+ slprintf(keystr, sizeof(keystr) - 1, "STATUS/%s", printer);
+
+ data.dptr = keystr;
+ data.dsize = strlen(keystr) + 1;
+
+ if (!tdb_exists(tdb, data)) {
+ set_printer_status(printer, LPSTAT_OK);
+ return LPSTAT_OK;
+ }
+
+ return tdb_fetch_int(tdb, keystr);
+}
+
+/* Display printer queue */
+
+static int lpq_command(int argc, char **argv)
+{
+ char *printer;
+ struct vlp_job *job_list = NULL;
+ int i, num_jobs, job_count = 0;
+
+ if (argc != 2) {
+ printf("Usage: lpq <printername>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+
+ /* Display printer status */
+
+ switch (get_printer_status(printer)) {
+ case LPSTAT_OK:
+ printf("enabled\n");
+ break;
+ case LPSTAT_STOPPED:
+ printf("disabled\n");
+ break;
+ case LPSTAT_ERROR:
+ default:
+ printf("error\n");
+ break;
+ }
+
+ /* Print queued documents */
+
+ get_job_list(printer, &job_list, &num_jobs);
+
+ for (i = 0; i < num_jobs; i++) {
+ if (job_list[i].deleted) continue;
+ printf("%d\t%d\t%d\t%ld\t%s\t%s\n", job_list[i].jobid,
+ job_list[i].size,
+ (i == 0 && job_list[i].status == LPQ_QUEUED) ?
+ LPQ_SPOOLING : job_list[i].status,
+ job_list[i].submit_time, job_list[i].owner,
+ job_list[i].jobname);
+ job_count++;
+ }
+
+ free(job_list);
+
+ return 0;
+}
+
+/* Remove a job */
+
+static int lprm_command(int argc, char **argv)
+{
+ char *printer;
+ int jobid, num_jobs, i;
+ struct vlp_job *job_list;
+
+ if (argc < 3) {
+ printf("Usage: lprm <printername> <jobid>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+ jobid = atoi(argv[2]);
+
+ get_job_list(printer, &job_list, &num_jobs);
+
+ for (i = 0; i < num_jobs; i++) {
+ if (job_list[i].jobid == jobid) {
+ job_list[i].deleted = 1;
+ set_job_list(printer, job_list, num_jobs);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/* print command = print-test %p %s */
+
+static int print_command(int argc, char **argv)
+{
+ char *printer;
+ fstring keystr;
+ struct passwd *pw;
+ TDB_DATA value;
+ struct vlp_job job;
+ int i;
+
+ if (argc < 3) {
+ printf("Usage: print <printername> <jobname>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+
+ ZERO_STRUCT(job);
+
+ /* Create a job record */
+
+ for (i = 2; i < argc; i++) {
+ fstrcat(job.jobname, argv[i]);
+ if (i < argc - 1) {
+ fstrcat(job.jobname, " ");
+ }
+ }
+
+ if (!(pw = getpwuid(getuid()))) {
+ return 1;
+ }
+
+ fstrcpy(job.owner, pw->pw_name);
+
+ job.jobid = next_jobnum(printer);
+ job.size = 666;
+ job.submit_time = time(NULL);
+
+ /* Store job entry in queue */
+
+ slprintf(keystr, sizeof(keystr) - 1, "LPQ/%s", printer);
+
+ value = tdb_fetch_by_string(tdb, keystr);
+
+ if (value.dptr) {
+
+ /* Add job to end of queue */
+
+ value.dptr = realloc(value.dptr, value.dsize +
+ sizeof(struct vlp_job));
+ if (!value.dptr) return 1;
+
+ memcpy(value.dptr + value.dsize, &job, sizeof(struct vlp_job));
+
+ tdb_store_by_string(tdb, keystr, value.dptr, value.dsize +
+ sizeof(struct vlp_job));
+
+ free(value.dptr);
+
+ } else {
+
+ /* Create new queue */
+
+ tdb_store_by_string(tdb, keystr, &job, sizeof(struct vlp_job));
+ }
+
+ return 0;
+}
+
+/* Pause the queue */
+
+static int queuepause_command(int argc, char **argv)
+{
+ char *printer;
+
+ if (argc != 2) {
+ printf("Usage: queuepause <printername>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+ set_printer_status(printer, LPSTAT_STOPPED);
+
+ return 0;
+}
+
+/* Resume the queue */
+
+static int queueresume_command(int argc, char **argv)
+{
+ char *printer;
+
+ if (argc != 2) {
+ printf("Usage: queueresume <printername>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+ set_printer_status(printer, LPSTAT_OK);
+
+ return 0;
+}
+
+/* Pause a job */
+
+static int lppause_command(int argc, char **argv)
+{
+ struct vlp_job *job_list;
+ char *printer;
+ int jobid, num_jobs, i;
+
+ if (argc != 3) {
+ printf("Usage: lppause <printername> <jobid>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+ jobid = atoi(argv[2]);
+
+ get_job_list(printer, &job_list, &num_jobs);
+
+ for (i = 0; i < num_jobs; i++) {
+ if (job_list[i].jobid == jobid) {
+ job_list[i].status = LPQ_PAUSED;
+ set_job_list(printer, job_list, num_jobs);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/* Resume a job */
+
+static int lpresume_command(int argc, char **argv)
+{
+ struct vlp_job *job_list;
+ char *printer;
+ int jobid, num_jobs, i;
+
+ if (argc != 3) {
+ printf("Usage: lpresume <printername> <jobid>\n");
+ return 1;
+ }
+
+ printer = argv[1];
+ jobid = atoi(argv[2]);
+
+ get_job_list(printer, &job_list, &num_jobs);
+
+ for (i = 0; i < num_jobs; i++) {
+ if (job_list[i].jobid == jobid) {
+ job_list[i].status = LPQ_QUEUED;
+ set_job_list(printer, job_list, num_jobs);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ /* Parameter check */
+
+ if (argc == 1) {
+ usage();
+ return 1;
+ }
+
+ /* Initialise */
+
+ if (!(tdb = tdb_open(PRINT_TDB, 0, 0, O_RDWR | O_CREAT,
+ 0666))) {
+ printf("%s: unable to open %s\n", argv[0], PRINT_TDB);
+ return 1;
+ }
+
+ /* Ensure we are modes 666 */
+
+ chmod(PRINT_TDB, 0666);
+
+ /* Do commands */
+
+ if (strcmp(argv[1], "lpq") == 0) {
+ return lpq_command(argc - 1, &argv[1]);
+ }
+
+ if (strcmp(argv[1], "lprm") == 0) {
+ return lprm_command(argc - 1, &argv[1]);
+ }
+
+ if (strcmp(argv[1], "print") == 0) {
+ return print_command(argc - 1, &argv[1]);
+ }
+
+ if (strcmp(argv[1], "queuepause") == 0) {
+ return queuepause_command(argc - 1, &argv[1]);
+ }
+
+ if (strcmp(argv[1], "queueresume") == 0) {
+ return queueresume_command(argc - 1, &argv[1]);
+ }
+
+ if (strcmp(argv[1], "lppause") == 0) {
+ return lppause_command(argc - 1, &argv[1]);
+ }
+
+ if (strcmp(argv[1], "lpresume") == 0) {
+ return lpresume_command(argc - 1, &argv[1]);
+ }
+
+ /* Unknown command */
+
+ printf("%s: invalid command %s\n", argv[0], argv[1]);
+ return 1;
+}
diff --git a/testsuite/server/ipc.exp b/testsuite/server/ipc.exp
new file mode 100644
index 00000000000..ae0688872a8
--- /dev/null
+++ b/testsuite/server/ipc.exp
@@ -0,0 +1,44 @@
+#
+# Test operations on IPC$ share
+#
+
+# Initialisation
+
+load_lib env-single.exp
+load_lib smbclient.exp
+
+set timeout 10
+
+# Spawn a smbclient
+
+if {![spawn_smbclient //$server/ipc\$ -U $user]} {
+ perror "error spawning smbclient"
+ return -1
+}
+
+#
+# Start performing tests
+#
+
+global smb_prompt
+
+do_smbclient "lcd /tmp\r" "lcd /tmp"
+do_smbclient "!touch test.out\r" "touch test.out"
+
+foreach { op } { "dir\r" "put test.out\r" "get test.out\r" \
+ "get /etc/passwd\r" "mkdir foo\r" "print test.out\r" } {
+
+ set action "doing $op"
+ set output [do_smbclient $op $action]
+
+ if {![regexp "ERR" $output]} {
+ fail $action
+ puts $output
+ } else {
+ pass $action
+ }
+}
+
+# Clean up
+
+file delete test.out
diff --git a/testsuite/server/masktest.exp b/testsuite/server/masktest.exp
new file mode 100644
index 00000000000..532291bffb8
--- /dev/null
+++ b/testsuite/server/masktest.exp
@@ -0,0 +1,57 @@
+#
+# Test various things using the masktest program
+#
+
+# Initialisation
+
+load_lib env-single.exp
+
+set timeout 10
+
+# Test each wildcard individually, then all together at once
+
+set testlist {{"abc" "<"} {"abc" ">"} {"abc" "\""} {"abc" "?"} {"abc" "*"} \
+ {"abc" "."} {"abc" "<>\"?*."}}
+
+foreach { test } $testlist {
+
+ set got_output 0
+ set fail 0
+
+ # Spawn masktest
+
+ spawn bin/masktest //$server/$share -U $user -n 1000 -a \
+ -f [lindex $test 0] -m [concat [lindex $test 0] [lindex $test 1]]
+
+ # Check output
+
+ while 1 {
+ expect {
+ -re "(...) (...) \[0-9\]+ mask=" {
+ if { $expect_out(1,string) != $expect_out(2,string) } {
+ fail "masktest [lindex $test 1]"
+ puts $expect_out(0,string);
+ set fail 1
+ break;
+ } else {
+ set got_output 1
+ }
+ }
+ eof { break }
+ }
+ }
+
+ # Produce result
+
+ set testname "[lindex $test 0] [lindex $test 1]"
+
+ if {$got_output} {
+ if {$fail} {
+ fail "masktest $testname"
+ } else {
+ pass "masktest $testname"
+ }
+ } else {
+ perror "no output seen for test $testname"
+ }
+}
diff --git a/testsuite/server/rename.exp b/testsuite/server/rename.exp
new file mode 100644
index 00000000000..77e7297776b
--- /dev/null
+++ b/testsuite/server/rename.exp
@@ -0,0 +1,59 @@
+#
+# Test misc file operations
+#
+
+# Initialisation
+
+load_lib env-single.exp
+load_lib smbclient.exp
+
+set timeout 10
+
+# Spawn a connection
+
+if {![spawn_smbclient //$server/$share -U $user]} {
+ perror "error spawning smbclient"
+ return -1
+}
+
+# Do wildcard rename test
+
+foreach { op } {"!touch /tmp/test.out\r" "lcd /tmp\r" "rm test.out\r" \
+ "put test.out\r"} {
+
+ set action "doing $op"
+ set output [do_smbclient $op $action]
+
+ if {[regexp "ERR" $output]} {
+ perror $action
+ puts $output
+ return -1;
+ }
+}
+
+file delete "/tmp/test.out"
+
+# Perform rename
+
+set output [do_smbclient "rename *.out *.dat\r" "wildcard rename"]
+
+if {[regexp "ERR" $output]} {
+ perror "wildcard rename didn't work"
+ return -1
+}
+
+# Check it worked
+
+set testname "wildcard match"
+set output [do_smbclient "dir\r" "wildcard rename check"]
+
+if {[regexp "test.dat" $output]} {
+ pass $testname
+} else {
+ fail $testname
+}
+
+# Clean up
+
+set op "rm test.dat\r"
+do_smbclient $op "doing $op"
diff --git a/testsuite/server/xfer.exp b/testsuite/server/xfer.exp
new file mode 100644
index 00000000000..6d00b29885c
--- /dev/null
+++ b/testsuite/server/xfer.exp
@@ -0,0 +1,48 @@
+#
+# Test file transfer
+#
+
+# Initialisation
+
+load_lib util-defs.exp
+load_lib smbclient.exp
+load_lib env-single.exp
+
+set timeout 60
+
+# Spawn a connection
+
+if {![spawn_smbclient //$server/$share -U $user]} {
+ perror "error spawning smbclient"
+ return -1
+}
+
+# Create a big file, store it and fetch it again
+
+foreach { op } { "!dd if=/dev/urandom of=/tmp/file bs=1048576 count=1\r" \
+ "lcd /tmp\r" "put file\r" "get file /tmp/file2\r" } {
+
+ set action "doing $op"
+ set output [do_smbclient $op $action]
+
+ if {[regexp "ERR" $output]} {
+ error $action
+ puts $output
+ return -1
+ }
+}
+
+# Compare the two files
+
+set output [util_start "diff" "/tmp/file /tmp/file2" ""]
+
+if {[regexp "differ" $output]} {
+ fail "xfertest"
+ puts $output
+} else {
+ pass "xfertest"
+}
+
+# Clean up temporary files
+
+file delete /tmp/file /tmp/file2
diff --git a/testsuite/smbd/Makefile.se_access_check b/testsuite/smbd/Makefile.se_access_check
new file mode 100644
index 00000000000..5637fa2f2fc
--- /dev/null
+++ b/testsuite/smbd/Makefile.se_access_check
@@ -0,0 +1,24 @@
+#
+# Makefile for se_access_check tests
+#
+
+include ../../source/Makefile
+
+# Objects common to all tests
+
+SE_ACCESS_CHECK_OBJ1 = $(LIB_OBJ) $(UBIQX_OBJ) $(PARAM_OBJ) $(RPC_PARSE_OBJ) \
+ $(LIBSMB_OBJ) lib/util_seaccess.o nsswitch/common.o
+
+SE_ACCESS_CHECK_OBJS = $(SE_ACCESS_CHECK_OBJ1:%=$(srcdir)/%) \
+ se_access_check_utils.o
+
+# Targets for individual tests
+
+se_access_check_nullsd: $(SE_ACCESS_CHECK_OBJS) se_access_check_nullsd.o
+se_access_check_everyone: $(SE_ACCESS_CHECK_OBJS) se_access_check_everyone.o
+se_access_check_allowall: $(SE_ACCESS_CHECK_OBJS) se_access_check_allowall.o
+se_access_check_denyall: $(SE_ACCESS_CHECK_OBJS) se_access_check_denyall.o
+se_access_check_allowsome: $(SE_ACCESS_CHECK_OBJS) se_access_check_allowsome.o
+se_access_check_denysome: $(SE_ACCESS_CHECK_OBJS) se_access_check_denysome.o
+se_access_check_empty: $(SE_ACCESS_CHECK_OBJS) se_access_check_empty.o
+se_access_check_printer: $(SE_ACCESS_CHECK_OBJS) se_access_check_printer.o
diff --git a/testsuite/smbd/Makefile.sec_ctx b/testsuite/smbd/Makefile.sec_ctx
new file mode 100644
index 00000000000..c45ab5bb5e8
--- /dev/null
+++ b/testsuite/smbd/Makefile.sec_ctx
@@ -0,0 +1,57 @@
+#
+# Makefile for sec_ctx tests
+#
+
+include ../../source/Makefile
+
+# Objects common to all tests
+
+SEC_CTX_OBJ1 = $(RPC_CLIENT_OBJ) $(LIB_OBJ) $(RPC_PARSE_OBJ) $(PARAM_OBJ) \
+ $(LIBSMB_OBJ) $(PASSDB_OBJ) $(UBIQX_OBJ) smbd/password.o smbd/uid.o \
+ smbd/chgpasswd.o smbd/sec_ctx.o
+
+SEC_CTX_OBJS = $(SEC_CTX_OBJ1:%=$(srcdir)/%) sec_ctx_utils.o
+
+# Targets for tests
+
+SEC_CTX_NONROOT_OBJS = $(SEC_CTX_OBJS) sec_ctx_nonroot.o
+
+sec_ctx_nonroot: $(SEC_CTX_NONROOT_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_NONROOT_OBJS) $(LIBS)
+
+SEC_CTX_STACK_OBJS = $(SEC_CTX_OBJS) sec_ctx_stack.o
+
+sec_ctx_stack: $(SEC_CTX_STACK_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_STACK_OBJS) $(LIBS)
+
+SEC_CTX_FLOW_OBJS = $(SEC_CTX_OBJS) sec_ctx_flow.o
+
+sec_ctx_flow: $(SEC_CTX_FLOW_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_FLOW_OBJS) $(LIBS)
+
+SEC_CTX_TORTURE_OBJS = $(SEC_CTX_OBJS) sec_ctx_torture.o
+
+sec_ctx_torture: $(SEC_CTX_TORTURE_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_TORTURE_OBJS) $(LIBS)
+
+SEC_CTX_CURRENT_USER_OBJS = $(SEC_CTX_OBJS) sec_ctx_current_user.o
+
+sec_ctx_current_user: $(SEC_CTX_CURRENT_USER_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_CURRENT_USER_OBJS) $(LIBS)
+
+SEC_CTX_GROUPS_OBJS = $(SEC_CTX_OBJS) sec_ctx_groups.o
+
+sec_ctx_groups: $(SEC_CTX_GROUPS_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_GROUPS_OBJS) $(LIBS)
+
+SEC_CTX_ROOT_OBJS = $(SEC_CTX_OBJS) sec_ctx_root.o
+
+sec_ctx_root: $(SEC_CTX_ROOT_OBJS)
+ @echo Linking $@
+ @$(CC) $(FLAGS) -o $@ $(SEC_CTX_ROOT_OBJS) $(LIBS)
diff --git a/testsuite/smbd/se_access_check.exp b/testsuite/smbd/se_access_check.exp
new file mode 100644
index 00000000000..cd84ab8ee08
--- /dev/null
+++ b/testsuite/smbd/se_access_check.exp
@@ -0,0 +1,54 @@
+#
+# @(#) Test se_access_check() function
+#
+
+#
+# Unix SMB/Netbios implementation.
+# Copyright (C) Tim Potter 2000
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+load_lib "compile.exp"
+load_lib "util-defs.exp"
+
+# Run tests from C source files
+
+set se_access_check_tests [list \
+ { "null security descriptor" "se_access_check_nullsd" } \
+ { "security descriptor allow everyone" "se_access_check_allowall" } \
+ { "security descriptor allow everyone" "se_access_check_allowall" } \
+ { "security descriptor deny everyone" "se_access_check_denyall" } \
+ { "empty security descriptor" "se_access_check_empty" } \
+ { "allow some users access" "se_access_check_allowsome" } \
+ { "deny some users access" "se_access_check_denysome" } \
+ { "printer access permissions" "se_access_check_printer" } \
+ ]
+
+foreach { test } $se_access_check_tests {
+ set test_desc [lindex $test 0]
+ set test_file [lindex $test 1]
+
+ simple_make "se_access_check" $test_file
+ set output [util_start "$srcdir/$subdir/$test_file" ]
+
+ if { [regexp "PASS" $output] } {
+ pass $test_desc
+ file delete "$srcdir/$subdir/$test_file" "$srcdir/$subdir/$test_file.o"
+ } else {
+ fail $test_desc
+ puts $output
+ }
+}
diff --git a/testsuite/smbd/se_access_check_allowall.c b/testsuite/smbd/se_access_check_allowall.c
new file mode 100644
index 00000000000..b49e8e52e7f
--- /dev/null
+++ b/testsuite/smbd/se_access_check_allowall.c
@@ -0,0 +1,87 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+SEC_DESC *sd;
+
+struct ace_entry acl_allowall[] = {
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "S-1-1-0" },
+ { 0, 0, 0, NULL}
+};
+
+/* Check that access is always allowed for a NULL security descriptor */
+
+BOOL allowall_check(struct passwd *pw, int ngroups, gid_t *groups)
+{
+ uint32 acc_granted, status;
+ BOOL result;
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &acc_granted, &status);
+
+ if (!result || status != NT_STATUS_NO_PROBLEMO ||
+ acc_granted != GENERIC_ALL_ACCESS) {
+ printf("FAIL: allowall se_access_check %d/%d\n",
+ pw->pw_uid, pw->pw_gid);
+ failed = True;
+ }
+
+ return True;
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Create security descriptor */
+
+ sd = build_sec_desc(acl_allowall, NULL, NULL_SID, NULL_SID);
+
+ if (!sd) {
+ printf("FAIL: could not build security descriptor\n");
+ return 1;
+ }
+
+ /* Run test */
+
+ visit_pwdb(allowall_check);
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_allowsome.c b/testsuite/smbd/se_access_check_allowsome.c
new file mode 100644
index 00000000000..529b2007622
--- /dev/null
+++ b/testsuite/smbd/se_access_check_allowsome.c
@@ -0,0 +1,104 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+SEC_DESC *sd;
+
+struct ace_entry acl_allowsome[] = {
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "user0" },
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "user2" },
+ { 0, 0, 0, NULL}
+};
+
+BOOL allowsome_check(struct passwd *pw, int ngroups, gid_t *groups)
+{
+ uint32 acc_granted, status;
+ fstring name;
+ BOOL result;
+ int len1, len2;
+
+ /* Check only user0 and user2 allowed access */
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &acc_granted, &status);
+
+ len1 = (int)strlen(pw->pw_name) - strlen("user0");
+ len2 = (int)strlen(pw->pw_name) - strlen("user2");
+
+ if ((strncmp("user0", &pw->pw_name[MAX(len1, 0)],
+ strlen("user0")) == 0) ||
+ (strncmp("user2", &pw->pw_name[MAX(len2, 0)],
+ strlen("user2")) == 0)) {
+ if (!result || acc_granted != GENERIC_ALL_ACCESS) {
+ printf("FAIL: access not granted for %s\n",
+ pw->pw_name);
+ }
+ } else {
+ if (result || acc_granted != 0) {
+ printf("FAIL: access granted for %s\n", pw->pw_name);
+ }
+ }
+
+ printf("result %s for user %s\n", result ? "allowed" : "denied",
+ pw->pw_name);
+
+ return True;
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Create security descriptor */
+
+ sd = build_sec_desc(acl_allowsome, NULL, NULL_SID, NULL_SID);
+
+ if (!sd) {
+ printf("FAIL: could not build security descriptor\n");
+ return 1;
+ }
+
+ /* Run test */
+
+ visit_pwdb(allowsome_check);
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_denyall.c b/testsuite/smbd/se_access_check_denyall.c
new file mode 100644
index 00000000000..016e6f6d549
--- /dev/null
+++ b/testsuite/smbd/se_access_check_denyall.c
@@ -0,0 +1,86 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+SEC_DESC *sd;
+
+struct ace_entry acl_denyall[] = {
+ { SEC_ACE_TYPE_ACCESS_DENIED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "S-1-1-0" },
+ { 0, 0, 0, NULL}
+};
+
+/* Check that access is always allowed for a NULL security descriptor */
+
+BOOL denyall_check(struct passwd *pw, int ngroups, gid_t *groups)
+{
+ uint32 acc_granted, status;
+ BOOL result;
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &acc_granted, &status);
+
+ if (result || acc_granted != 0) {
+ printf("FAIL: denyall se_access_check %d/%d\n",
+ pw->pw_uid, pw->pw_gid);
+ failed = True;
+ }
+
+ return True;
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Create security descriptor */
+
+ sd = build_sec_desc(acl_denyall, NULL, NULL_SID, NULL_SID);
+
+ if (!sd) {
+ printf("FAIL: could not build security descriptor\n");
+ return 1;
+ }
+
+ /* Run test */
+
+ visit_pwdb(denyall_check);
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_denysome.c b/testsuite/smbd/se_access_check_denysome.c
new file mode 100644
index 00000000000..1f0aaaf1392
--- /dev/null
+++ b/testsuite/smbd/se_access_check_denysome.c
@@ -0,0 +1,106 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+SEC_DESC *sd;
+
+struct ace_entry acl_denysome[] = {
+ { SEC_ACE_TYPE_ACCESS_DENIED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "user1" },
+ { SEC_ACE_TYPE_ACCESS_DENIED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "user3" },
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ GENERIC_ALL_ACCESS, "S-1-1-0" },
+ { 0, 0, 0, NULL}
+};
+
+BOOL denysome_check(struct passwd *pw, int ngroups, gid_t *groups)
+{
+ uint32 acc_granted, status;
+ fstring name;
+ BOOL result;
+ int len1, len2;
+
+ /* Check only user1 and user3 denied access */
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &acc_granted, &status);
+
+ len1 = (int)strlen(pw->pw_name) - strlen("user1");
+ len2 = (int)strlen(pw->pw_name) - strlen("user3");
+
+ if ((strncmp("user1", &pw->pw_name[MAX(len1, 0)],
+ strlen("user1")) == 0) ||
+ (strncmp("user3", &pw->pw_name[MAX(len2, 0)],
+ strlen("user3")) == 0)) {
+ if (result || acc_granted != 0) {
+ printf("FAIL: access not denied for %s\n",
+ pw->pw_name);
+ }
+ } else {
+ if (!result || acc_granted != GENERIC_ALL_ACCESS) {
+ printf("FAIL: access denied for %s\n", pw->pw_name);
+ }
+ }
+
+ printf("result %s for user %s\n", result ? "allowed" : "denied",
+ pw->pw_name);
+
+ return True;
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Create security descriptor */
+
+ sd = build_sec_desc(acl_denysome, NULL, NULL_SID, NULL_SID);
+
+ if (!sd) {
+ printf("FAIL: could not build security descriptor\n");
+ return 1;
+ }
+
+ /* Run test */
+
+ visit_pwdb(denysome_check);
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_empty.c b/testsuite/smbd/se_access_check_empty.c
new file mode 100644
index 00000000000..6602b1147ee
--- /dev/null
+++ b/testsuite/smbd/se_access_check_empty.c
@@ -0,0 +1,109 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+SEC_DESC *sd;
+
+struct ace_entry acl_empty[] = {
+ { 0, 0, 0, NULL}
+};
+
+/* Check that access is always allowed for a NULL security descriptor */
+
+BOOL emptysd_check(struct passwd *pw, int ngroups, gid_t *groups)
+{
+ uint32 acc_granted, status;
+ BOOL result;
+
+ /* For no DACL, access is allowed and the desired access mask is
+ returned */
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &acc_granted, &status);
+
+ if (!result || !(acc_granted == SEC_RIGHTS_MAXIMUM_ALLOWED)) {
+ printf("FAIL: no dacl for %s (%d/%d)\n", pw->pw_name,
+ pw->pw_uid, pw->pw_gid);
+ failed = True;
+ }
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups, 0x1234,
+ &acc_granted, &status);
+
+ if (!result || !(acc_granted == 0x1234)) {
+ printf("FAIL: no dacl2 for %s (%d/%d)\n", pw->pw_name,
+ pw->pw_uid, pw->pw_gid);
+ failed = True;
+ }
+
+ /* If desired access mask is empty then no access is allowed */
+
+ result = se_access_check(sd, pw->pw_uid, pw->pw_gid,
+ ngroups, groups, 0,
+ &acc_granted, &status);
+
+ if (result) {
+ printf("FAIL: zero desired access for %s (%d/%d)\n",
+ pw->pw_name, pw->pw_uid, pw->pw_gid);
+ failed = True;
+ }
+
+ return True;
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Create security descriptor */
+
+ sd = build_sec_desc(acl_empty, NULL, NULL_SID, NULL_SID);
+
+ if (!sd) {
+ printf("FAIL: could not build security descriptor\n");
+ return 1;
+ }
+
+ /* Run test */
+
+ visit_pwdb(emptysd_check);
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_nullsd.c b/testsuite/smbd/se_access_check_nullsd.c
new file mode 100644
index 00000000000..c042c2b1485
--- /dev/null
+++ b/testsuite/smbd/se_access_check_nullsd.c
@@ -0,0 +1,74 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+
+/* Check that access is always allowed for a NULL security descriptor */
+
+BOOL nullsd_check(struct passwd *pw, int ngroups, gid_t *groups)
+{
+ uint32 acc_granted, status;
+ BOOL result;
+
+ result = se_access_check(NULL, pw->pw_uid, pw->pw_gid,
+ ngroups, groups,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &acc_granted, &status);
+
+ if (!result || status != NT_STATUS_NO_PROBLEMO ||
+ acc_granted != SEC_RIGHTS_MAXIMUM_ALLOWED) {
+ printf("FAIL: null se_access_check %d/%d\n",
+ pw->pw_uid, pw->pw_gid);
+ failed = True;
+ }
+
+ printf("access check passed for user %s (%d/%d)\n",
+ pw->pw_name, pw->pw_uid, pw->pw_gid);
+
+ return True;
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Run test */
+
+ visit_pwdb(nullsd_check);
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_printer.c b/testsuite/smbd/se_access_check_printer.c
new file mode 100644
index 00000000000..e73a23ce21b
--- /dev/null
+++ b/testsuite/smbd/se_access_check_printer.c
@@ -0,0 +1,212 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+/* Globals */
+
+BOOL failed;
+SEC_DESC *sd;
+
+struct ace_entry acl_printer[] = {
+
+ /* Everyone is allowed to print */
+
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ PRINTER_ACE_PRINT, "S-1-1-0" },
+
+ /* Except for user0 who uses too much paper */
+
+ { SEC_ACE_TYPE_ACCESS_DENIED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ PRINTER_ACE_FULL_CONTROL, "user0" },
+
+ /* Users 1 and 2 can manage documents */
+
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ PRINTER_ACE_MANAGE_DOCUMENTS, "user1" },
+
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ PRINTER_ACE_MANAGE_DOCUMENTS, "user2" },
+
+ /* Domain Admins can also manage documents */
+
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ PRINTER_ACE_MANAGE_DOCUMENTS, "Domain Admins" },
+
+ /* User 3 is da man */
+
+ { SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_ACE_FLAG_CONTAINER_INHERIT,
+ PRINTER_ACE_FULL_CONTROL, "user3" },
+
+ { 0, 0, 0, NULL}
+};
+
+BOOL test_user(char *username, uint32 acc_desired, uint32 *acc_granted)
+{
+ struct passwd *pw;
+ uint32 status;
+
+ if (!(pw = getpwnam(username))) {
+ printf("FAIL: could not lookup user info for %s\n",
+ username);
+ exit(1);
+ }
+
+ return se_access_check(sd, pw->pw_uid, pw->pw_gid, 0, NULL,
+ acc_desired, acc_granted, &status);
+}
+
+static char *pace_str(uint32 ace_flags)
+{
+ if ((ace_flags & PRINTER_ACE_FULL_CONTROL) ==
+ PRINTER_ACE_FULL_CONTROL) return "full control";
+
+ if ((ace_flags & PRINTER_ACE_MANAGE_DOCUMENTS) ==
+ PRINTER_ACE_MANAGE_DOCUMENTS) return "manage documents";
+
+ if ((ace_flags & PRINTER_ACE_PRINT) == PRINTER_ACE_PRINT)
+ return "print";
+
+ return "UNKNOWN";
+}
+
+uint32 perms[] = {
+ PRINTER_ACE_PRINT,
+ PRINTER_ACE_FULL_CONTROL,
+ PRINTER_ACE_MANAGE_DOCUMENTS,
+ 0
+};
+
+void runtest(void)
+{
+ uint32 acc_granted;
+ BOOL result;
+ int i, j;
+
+ for (i = 0; perms[i]; i++) {
+
+ /* Test 10 users */
+
+ for (j = 0; j < 10; j++) {
+ fstring name;
+
+ /* Test user against ACL */
+
+ snprintf(name, sizeof(fstring), "%s/user%d",
+ getenv("TEST_WORKGROUP"), j);
+
+ result = test_user(name, perms[i], &acc_granted);
+
+ printf("%s: %s %s 0x%08x\n", name,
+ pace_str(perms[i]),
+ result ? "TRUE " : "FALSE", acc_granted);
+
+ /* Check results */
+
+ switch (perms[i]) {
+
+ case PRINTER_ACE_PRINT: {
+ if (!result || acc_granted !=
+ PRINTER_ACE_PRINT) {
+ printf("FAIL: user %s can't print\n",
+ name);
+ failed = True;
+ }
+ break;
+ }
+
+ case PRINTER_ACE_FULL_CONTROL: {
+ if (j == 3) {
+ if (!result || acc_granted !=
+ PRINTER_ACE_FULL_CONTROL) {
+ printf("FAIL: user %s doesn't "
+ "have full control\n",
+ name);
+ failed = True;
+ }
+ } else {
+ if (result || acc_granted != 0) {
+ printf("FAIL: user %s has full "
+ "control\n", name);
+ failed = True;
+ }
+ }
+ break;
+ }
+ case PRINTER_ACE_MANAGE_DOCUMENTS: {
+ if (j == 1 || j == 2) {
+ if (!result || acc_granted !=
+ PRINTER_ACE_MANAGE_DOCUMENTS) {
+ printf("FAIL: user %s can't "
+ "manage documents\n",
+ name);
+ failed = True;
+ }
+ } else {
+ if (result || acc_granted != 0) {
+ printf("FAIL: user %s can "
+ "manage documents\n",
+ name);
+ failed = True;
+ }
+ }
+ break;
+ }
+
+ default:
+ printf("FAIL: internal error\n");
+ exit(1);
+ }
+ }
+ }
+}
+
+/* Main function */
+
+int main(int argc, char **argv)
+{
+ /* Initialisation */
+
+ generate_wellknown_sids();
+
+ /* Create security descriptor */
+
+ sd = build_sec_desc(acl_printer, NULL, NULL_SID, NULL_SID);
+
+ if (!sd) {
+ printf("FAIL: could not build security descriptor\n");
+ return 1;
+ }
+
+ /* Run test */
+
+ runtest();
+
+ /* Return */
+
+ if (!failed) {
+ printf("PASS\n");
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/testsuite/smbd/se_access_check_utils.c b/testsuite/smbd/se_access_check_utils.c
new file mode 100644
index 00000000000..316bb5d905a
--- /dev/null
+++ b/testsuite/smbd/se_access_check_utils.c
@@ -0,0 +1,158 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "se_access_check_utils.h"
+
+void char_to_sid(DOM_SID *sid, char *sid_str)
+{
+ /* If it looks like a SID, call string_to_sid() else look it up
+ using wbinfo. */
+
+ if (strncmp(sid_str, "S-", 2) == 0) {
+ string_to_sid(sid, sid_str);
+ } else {
+ struct winbindd_request request;
+ struct winbindd_response response;
+
+ /* Send off request */
+
+ ZERO_STRUCT(request);
+ ZERO_STRUCT(response);
+
+ fstrcpy(request.data.name, sid_str);
+ if (winbindd_request(WINBINDD_LOOKUPNAME, &request,
+ &response) != NSS_STATUS_SUCCESS) {
+ printf("FAIL: unable to look up sid for name %s\n",
+ sid_str);
+ exit(1);
+ }
+
+ string_to_sid(sid, response.data.sid.sid);
+ printf("converted char %s to sid %s\n", sid_str,
+ response.data.sid.sid);
+ }
+}
+
+/* Construct an ACL from a list of ace_entry structures */
+
+SEC_ACL *build_acl(struct ace_entry *ace_list)
+{
+ SEC_ACE *aces = NULL;
+ SEC_ACL *result;
+ int num_aces = 0;
+
+ if (ace_list == NULL) return NULL;
+
+ /* Create aces */
+
+ while(ace_list->sid) {
+ SEC_ACCESS sa;
+ DOM_SID sid;
+
+ /* Create memory for new ACE */
+
+ if (!(aces = Realloc(aces,
+ sizeof(SEC_ACE) * (num_aces + 1)))) {
+ return NULL;
+ }
+
+ /* Create ace */
+
+ init_sec_access(&sa, ace_list->mask);
+
+ char_to_sid(&sid, ace_list->sid);
+ init_sec_ace(&aces[num_aces], &sid, ace_list->type,
+ sa, ace_list->flags);
+
+ num_aces++;
+ ace_list++;
+ }
+
+ /* Create ACL from list of ACEs */
+
+ result = make_sec_acl(ACL_REVISION, num_aces, aces);
+ free(aces);
+
+ return result;
+}
+
+/* Make a security descriptor */
+
+SEC_DESC *build_sec_desc(struct ace_entry *dacl, struct ace_entry *sacl,
+ char *owner_sid, char *group_sid)
+{
+ DOM_SID the_owner_sid, the_group_sid;
+ SEC_ACL *the_dacl, *the_sacl;
+ SEC_DESC *result;
+ size_t size;
+
+ /* Build up bits of security descriptor */
+
+ char_to_sid(&the_owner_sid, owner_sid);
+ char_to_sid(&the_group_sid, group_sid);
+
+ the_dacl = build_acl(dacl);
+ the_sacl = build_acl(sacl);
+
+ result = make_sec_desc(SEC_DESC_REVISION,
+ SEC_DESC_SELF_RELATIVE | SEC_DESC_DACL_PRESENT,
+ &the_owner_sid, &the_group_sid,
+ the_sacl, the_dacl, &size);
+
+ free_sec_acl(&the_dacl);
+ free_sec_acl(&the_sacl);
+
+ return result;
+}
+
+/* Iterate over password database and call a user-specified function */
+
+void visit_pwdb(BOOL (*fn)(struct passwd *pw, int ngroups, gid_t *groups))
+{
+ struct passwd *pw;
+ int ngroups;
+ gid_t *groups;
+
+ setpwent();
+
+ while ((pw = getpwent())) {
+ BOOL result;
+
+ /* Get grouplist */
+
+ ngroups = getgroups(0, NULL);
+
+ groups = malloc(sizeof(gid_t) * ngroups);
+ getgroups(ngroups, groups);
+
+ /* Call function */
+
+ result = fn(pw, ngroups, groups);
+ if (!result) break;
+
+ /* Clean up */
+
+ free(groups);
+ }
+
+ endpwent();
+}
diff --git a/testsuite/smbd/se_access_check_utils.h b/testsuite/smbd/se_access_check_utils.h
new file mode 100644
index 00000000000..bae0d171abf
--- /dev/null
+++ b/testsuite/smbd/se_access_check_utils.h
@@ -0,0 +1,46 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _SE_ACCESS_CHECK_UTILS_H
+#define _SE_ACCESS_CHECK_UTILS_H
+
+#include "includes.h"
+
+/* Structure to build ACE lists from */
+
+struct ace_entry {
+ uint8 type, flags;
+ uint32 mask;
+ char *sid;
+};
+
+#define NULL_SID "S-1-0-0"
+#define WORLD_SID "S-1-1-0"
+
+/* Function prototypes */
+
+SEC_ACL *build_acl(struct ace_entry *ace_list);
+SEC_DESC *build_sec_desc(struct ace_entry *dacl, struct ace_entry *sacl,
+ char *owner_sid, char *group_sid);
+
+void visit_pwdb(BOOL (*fn)(struct passwd *pw, int ngroups, gid_t *groups));
+
+#endif
diff --git a/testsuite/smbd/sec_ctx.exp b/testsuite/smbd/sec_ctx.exp
new file mode 100644
index 00000000000..0831400e702
--- /dev/null
+++ b/testsuite/smbd/sec_ctx.exp
@@ -0,0 +1,67 @@
+#
+# @(#) Test the push_sec_ctx() and pop_sec_ctx() functions
+#
+
+#
+# Unix SMB/Netbios implementation.
+# Copyright (C) Tim Potter 2000
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+load_lib "compile.exp"
+load_lib "util-defs.exp"
+
+# Non-root test
+
+set test_desc "change sec_ctx as non-root"
+set test_prog "sec_ctx_nonroot"
+simple_make "sec_ctx" $test_prog
+set output [util_start "$srcdir/$subdir/$test_prog"]
+
+if { [regexp "child killed" $output] } {
+ pass $test_desc
+ file delete "$srcdir/$subdir/$test_prog" "$srcdir/$subdir/$test_prog.o"
+} else {
+ fail $test_desc
+}
+
+# Run tests from C files as root
+
+set sec_ctx_tests [list \
+ { "security contexts are stackable" "sec_ctx_stack" } \
+ { "over/underflow tests" "sec_ctx_flow" } \
+ { "torture test" "sec_ctx_torture" } \
+ { "current_user global" "sec_ctx_current_user" } \
+ { "group membership" "sec_ctx_groups" } \
+ { "become root" "sec_ctx_root" } \
+ ]
+
+foreach { test } $sec_ctx_tests {
+ set test_desc [lindex $test 0]
+ set test_file [lindex $test 1]
+
+ simple_make "sec_ctx" $test_file
+ set output [util_start "sudo $srcdir/$subdir/$test_file" ]
+
+ if { [regexp "PASS" $output] } {
+ pass $test_desc
+ file delete "$srcdir/$subdir/$test_file" "$srcdir/$subdir/$test_file.o"
+ } else {
+ fail $test_desc
+ puts $output
+ }
+
+}
diff --git a/testsuite/smbd/sec_ctx1.c b/testsuite/smbd/sec_ctx1.c
new file mode 100644
index 00000000000..b74b6ed9009
--- /dev/null
+++ b/testsuite/smbd/sec_ctx1.c
@@ -0,0 +1,40 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+void exit_server(char *reason) {}
+
+int main (int argc, char **argv)
+{
+ /* Become a non-root user */
+
+ setuid(1);
+ setgid(1);
+
+ /* Try to push a security context. This should fail with a
+ smb_assert() error. */
+
+ push_sec_ctx(2, 2);
+ printf("FAIL\n");
+
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_current_user.c b/testsuite/smbd/sec_ctx_current_user.c
new file mode 100644
index 00000000000..5b7da0ef464
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_current_user.c
@@ -0,0 +1,114 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+int main(int argc, char **argv)
+{
+ extern struct current_user current_user;
+ uid_t initial_uid = current_user.uid;
+ gid_t initial_gid = current_user.gid;
+ int ngroups;
+ gid_t *groups;
+
+ init_sec_ctx();
+
+ /* Check initial id */
+
+ if (initial_uid != 0 || initial_gid != 0) {
+ printf("FAIL: current_user not initialised to root\n");
+ return 1;
+ }
+
+ /* Push a context and check current user is updated */
+
+ if (!push_sec_ctx()) {
+ printf("FAIL: push_sec_ctx\n");
+ return 1;
+ }
+
+ set_sec_ctx(1, 2, 0, NULL);
+
+ if (current_user.uid != 1 || current_user.gid != 2) {
+ printf("FAIL: current_user id not updated after push\n");
+ return 1;
+ }
+
+ if (current_user.ngroups != 0 || current_user.groups) {
+ printf("FAIL: current_user groups not updated after push\n");
+ return 1;
+ }
+
+ /* Push another */
+
+ get_random_grouplist(&ngroups, &groups);
+
+ if (!push_sec_ctx()) {
+ printf("FAIL: push_sec_ctx\n");
+ return 1;
+ }
+
+ set_sec_ctx(2, 3, ngroups, groups);
+
+ if (current_user.uid != 2 || current_user.gid != 3) {
+ printf("FAIL: current_user id not updated after second "
+ "push\n");
+ return 1;
+ }
+
+ if (current_user.ngroups != ngroups ||
+ (memcmp(current_user.groups, groups,
+ sizeof(gid_t) * ngroups) != 0)) {
+ printf("FAIL: current_user groups not updated\n");
+ return 1;
+ }
+
+ /* Pop them both off */
+
+ if (!pop_sec_ctx()) {
+ printf("FAIL: pop_sec_ctx\n");
+ return 1;
+ }
+
+ if (current_user.uid != 1 || current_user.gid != 2) {
+ printf("FAIL: current_user not updaded pop\n");
+ return 1;
+ }
+
+ if (!pop_sec_ctx()) {
+ printf("FAIL: pop_sec_ctx\n");
+ return 1;
+ }
+
+ /* Check initial state was returned */
+
+ if (current_user.uid != initial_uid ||
+ current_user.gid != initial_gid) {
+ printf("FAIL: current_user not updaded pop\n");
+ return 1;
+ }
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_flow.c b/testsuite/smbd/sec_ctx_flow.c
new file mode 100644
index 00000000000..7b251784671
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_flow.c
@@ -0,0 +1,73 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+int main (int argc, char **argv)
+{
+ int i;
+
+ init_sec_ctx();
+
+ /* Check for underflow */
+
+ if (!push_sec_ctx()) {
+ printf("FAIL: push_sec_ctx\n");
+ return 1;
+ }
+
+ set_sec_ctx(1, 1, 0, NULL);
+
+ if (!pop_sec_ctx()) {
+ printf("FAIL: pop_sec_ctx\n");
+ return 1;
+ }
+
+ if (pop_sec_ctx()) {
+ printf("FAIL: underflow push_sec_ctx\n");
+ return 1;
+ }
+
+ /* Check for overflow */
+
+ for (i = 0; i < MAX_SEC_CTX_DEPTH + 1; i++) {
+ BOOL result;
+
+ result = push_sec_ctx();
+ set_sec_ctx(i, i, 0, NULL);
+
+ if ((i < MAX_SEC_CTX_DEPTH) && !result) {
+ printf("FAIL: push_sec_ctx(%d)\n", i);
+ return 1;
+ }
+
+ if ((i == MAX_SEC_CTX_DEPTH + 1) && result) {
+ printf("FAIL: overflow push_sec_ctx(%d)\n", i);
+ return 1;
+ }
+ }
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_groups.c b/testsuite/smbd/sec_ctx_groups.c
new file mode 100644
index 00000000000..61d77f6f4f0
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_groups.c
@@ -0,0 +1,131 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+int main (int argc, char **argv)
+{
+ int ngroups, initial_ngroups, check_ngroups, final_ngroups;
+ gid_t *groups, *initial_groups, *check_groups, *final_groups;
+ int i;
+
+ init_sec_ctx();
+
+ /* Save current groups */
+
+ initial_ngroups = sys_getgroups(0, NULL);
+ initial_groups = malloc(sizeof(gid_t) * initial_ngroups);
+ sys_getgroups(initial_ngroups, initial_groups);
+
+ printf("Initial groups are: ");
+ for (i = 0; i < initial_ngroups; i++) {
+ printf("%d, ", initial_groups[i]);
+ }
+ printf("\n");
+
+ /* Push a context plus groups */
+
+ get_random_grouplist(&ngroups, &groups);
+
+ printf("Random groups are: ");
+ for (i = 0; i < ngroups; i++) {
+ printf("%d, ", groups[i]);
+ }
+ printf("\n");
+
+ if (!push_sec_ctx()) {
+ printf("FAIL: push_sec_ctx\n");
+ return 1;
+ }
+
+ set_sec_ctx(1, 2, ngroups, groups);
+
+ /* Check grouplist stuck */
+
+ check_ngroups = sys_getgroups(0, NULL);
+ check_groups = malloc(sizeof(gid_t) * check_ngroups);
+ sys_getgroups(check_ngroups, check_groups);
+
+ printf("Actual groups are: ");
+ for (i = 0; i < check_ngroups; i++) {
+ printf("%d, ", check_groups[i]);
+ }
+ printf("\n");
+
+ if (ngroups != check_ngroups) {
+ printf("FAIL: number of groups differs\n");
+ return 1;
+ }
+
+ for (i = 0; i < ngroups; i++) {
+ if (groups[i] != check_groups[i]) {
+ printf("FAIL: group %d differs\n", i);
+ return 1;
+ }
+ }
+
+ safe_free(groups);
+ safe_free(check_groups);
+
+ /* Pop and check initial groups are back */
+
+ if (!pop_sec_ctx()) {
+ printf("FAIL: pop_sec_ctx\n");
+ return 1;
+ }
+
+ final_ngroups = sys_getgroups(0, NULL);
+ final_groups = malloc(sizeof(gid_t) * final_ngroups);
+ sys_getgroups(final_ngroups, final_groups);
+
+ printf("Final groups are: ");
+ for (i = 0; i < final_ngroups; i++) {
+ printf("%d, ", final_groups[i]);
+ }
+ printf("\n");
+
+ if (initial_ngroups != final_ngroups) {
+ printf("FAIL: final number of groups differ\n");
+ return 1;
+ }
+
+ for (i = 0; i < initial_ngroups; i++) {
+ if (initial_groups[i] != final_groups[i]) {
+ printf("FAIL: final group %d differs\n", i);
+ return 1;
+ }
+ }
+
+ printf("Final groups are: ");
+ for (i = 0; i < final_ngroups; i++) {
+ printf("%d, ", final_groups[i]);
+ }
+ printf("\n");
+
+ safe_free(initial_groups);
+ safe_free(final_groups);
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_nonroot.c b/testsuite/smbd/sec_ctx_nonroot.c
new file mode 100644
index 00000000000..18bba7e2806
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_nonroot.c
@@ -0,0 +1,42 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+int main (int argc, char **argv)
+{
+ init_sec_ctx();
+
+ /* Become a non-root user */
+
+ setuid(1);
+ setgid(1);
+
+ /* Try to push a security context. This should fail with a
+ smb_assert() error. */
+
+ push_sec_ctx();
+ set_sec_ctx(2, 2, 0, NULL);
+ printf("FAIL\n");
+
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_root.c b/testsuite/smbd/sec_ctx_root.c
new file mode 100644
index 00000000000..f2e46f0a5cd
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_root.c
@@ -0,0 +1,61 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+int main (int argc, char **argv)
+{
+ int ngroups, actual_ngroups;
+ gid_t *groups, *actual_groups;
+ extern struct current_user current_user;
+
+ init_sec_ctx();
+
+ /* Initialise a security context */
+
+ get_random_grouplist(&ngroups, &groups);
+ set_sec_ctx(1, 1, ngroups, groups);
+
+ /* Become root and check */
+
+ set_root_sec_ctx();
+
+ actual_ngroups = getgroups(0, NULL);
+ actual_groups = (gid_t *)malloc(actual_ngroups * sizeof(gid_t));
+
+ getgroups(actual_ngroups, actual_groups);
+
+ if (geteuid() != 0 || getegid() != 0 || actual_ngroups != 0) {
+ printf("FAIL: root id not set\n");
+ return 1;
+ }
+
+ if (current_user.uid != 0 || current_user.gid != 0 ||
+ current_user.ngroups != 0 || current_user.groups) {
+ printf("FAIL: current_user not set correctly\n");
+ return 1;
+ }
+
+ printf("PASS\n");
+
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_stack.c b/testsuite/smbd/sec_ctx_stack.c
new file mode 100644
index 00000000000..f6952fabb4e
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_stack.c
@@ -0,0 +1,86 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+int main (int argc, char **argv)
+{
+ BOOL result;
+ int i;
+
+ init_sec_ctx();
+
+ /* Push a whole bunch of security contexts */
+
+ for (i = 0; i < MAX_SEC_CTX_DEPTH; i++) {
+
+ result = push_sec_ctx();
+ set_sec_ctx(i + 1, i + 2, 0, NULL);
+
+ if (!result) {
+ printf("FAIL: push_sec_ctx(%d)\n", i);
+ return 1;
+ }
+
+ printf("pushed context (%d, %d) eff=(%d, %d)\n",
+ getuid(), getgid(), geteuid(), getegid());
+
+ if ((geteuid() != i + 1) || (getegid() != i + 2)) {
+ printf("FAIL: incorrect context pushed\n");
+ return 1;
+ }
+ }
+
+ /* Pop them all off */
+
+ for (i = MAX_SEC_CTX_DEPTH; i > 0; i--) {
+
+ result = pop_sec_ctx();
+
+ if (!result) {
+ printf("FAIL: pop_sec_ctx(%d)\n", i);
+ return 1;
+ }
+
+ printf("popped context (%d, %d) eff=(%d, %d)\n",
+ getuid(), getgid(), geteuid(), getegid());
+
+ printf("i = %d\n",i);
+
+ if (i > 1) {
+ if ((geteuid() != i - 1) || (getegid() != i)) {
+ printf("FAIL: incorrect context popped\n");
+ return 1;
+ }
+ } else {
+ if ((geteuid() != 0) || (getegid() != 0)) {
+ printf("FAIL: incorrect context popped\n");
+ return 1;
+ }
+ }
+ }
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_torture.c b/testsuite/smbd/sec_ctx_torture.c
new file mode 100644
index 00000000000..effee069ef9
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_torture.c
@@ -0,0 +1,103 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "sec_ctx_utils.h"
+
+#define NUM_TESTS 10000
+
+int main (int argc, char **argv)
+{
+ int seed, level = 0, num_tests = 0;
+
+ init_sec_ctx();
+
+ if (argc == 1) {
+ seed = time(NULL);
+ } else {
+ seed = atoi(argv[1]);
+ }
+
+ printf("seed = %d\n", seed);
+
+ while(num_tests < NUM_TESTS) {
+ switch (random() % 2) {
+
+ /* Push a random context */
+
+ case 0:
+ if (level < MAX_SEC_CTX_DEPTH) {
+ int ngroups;
+ gid_t *groups;
+
+ if (!push_sec_ctx()) {
+ printf("FAIL: push random ctx\n");
+ return 1;
+ }
+
+ get_random_grouplist(&ngroups, &groups);
+
+ set_sec_ctx(random() % 32767,
+ random() % 32767,
+ ngroups, groups);
+
+ if (!verify_current_groups(ngroups,
+ groups)) {
+ printf("FAIL: groups did not stick\n");
+ return 1;
+ }
+
+ printf("pushed (%d, %d) eff=(%d, %d)\n",
+ getuid(), getgid(), geteuid(),
+ getegid());
+
+ level++;
+ num_tests++;
+
+ free(groups);
+ }
+ break;
+
+ /* Pop a random context */
+
+ case 1:
+ if (level > 0) {
+ if (!pop_sec_ctx()) {
+ printf("FAIL: pop random ctx\n");
+ return 1;
+ }
+
+ printf("popped (%d, %d) eff=(%d, %d)\n",
+ getuid(), getgid(), geteuid(),
+ getegid());
+
+ level--;
+ num_tests++;
+ }
+ break;
+ }
+ }
+
+ /* Everything's cool */
+
+ printf("PASS\n");
+ return 0;
+}
diff --git a/testsuite/smbd/sec_ctx_utils.c b/testsuite/smbd/sec_ctx_utils.c
new file mode 100644
index 00000000000..fbda6352c46
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_utils.c
@@ -0,0 +1,65 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/* Keep linker happy */
+
+void exit_server(char *reason) {}
+
+/* Generate random list of groups */
+
+void get_random_grouplist(int *ngroups, gid_t **groups)
+{
+ int i;
+
+ *ngroups = random() % groups_max();
+ *groups = malloc(*ngroups * sizeof(gid_t));
+
+ if (!groups) {
+ printf("FAIL: malloc random grouplist\n");
+ return;
+ }
+
+ for (i = 0; i < *ngroups; i++) {
+ (*groups)[i] = random() % 32767;
+ }
+}
+
+/* Check a list of groups with current groups */
+
+BOOL verify_current_groups(int ngroups, gid_t *groups)
+{
+ int actual_ngroups;
+ gid_t *actual_groups;
+
+ actual_ngroups = getgroups(0, NULL);
+ actual_groups = (gid_t *)malloc(actual_ngroups * sizeof(gid_t));
+
+ getgroups(actual_ngroups, actual_groups);
+
+ if (actual_ngroups != ngroups) {
+ return False;
+ }
+
+ return memcmp(actual_groups, groups, actual_ngroups *
+ sizeof(gid_t)) == 0;
+}
diff --git a/testsuite/smbd/sec_ctx_utils.h b/testsuite/smbd/sec_ctx_utils.h
new file mode 100644
index 00000000000..1f4bde841ed
--- /dev/null
+++ b/testsuite/smbd/sec_ctx_utils.h
@@ -0,0 +1,30 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Security context tests
+ Copyright (C) Tim Potter 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _SEC_CTX_UTILS_H
+#define _SEC_CTX_UTILS_H
+
+/* Function prototypes */
+
+void get_random_grouplist(int *ngroups, gid_t **groups);
+BOOL verify_current_groups(int ngroups, gid_t *groups);
+
+#endif /* _SEC_CTX_UTILS_H */
diff --git a/testsuite/smbd/sighup.exp b/testsuite/smbd/sighup.exp
new file mode 100644
index 00000000000..a9e1bffe11d
--- /dev/null
+++ b/testsuite/smbd/sighup.exp
@@ -0,0 +1,107 @@
+#
+# @(#) Check services file reloaded after SIGHUP
+#
+
+load_lib "util-defs.exp"
+
+# Create a smb.conf file from a list of sections. Each section consists of
+# a name and a list of lines which are the contents of that section.
+# Returns a temporary filename which must be deleted after use.
+
+proc write_smb_conf { args } {
+
+ # Set up temporary file
+
+ set name "/tmp/smb.conf-test-[pid]"
+ set f [open $name "w"]
+
+ # Parse sections
+
+ foreach section [lindex $args 0] {
+ set secname [lindex $section 0]
+ set contents [lindex $section 1]
+
+ puts $f "\[$secname]"
+
+ foreach { line } $contents {
+ puts $f "\t$line"
+ }
+
+ puts $f ""
+ }
+
+ close $f
+
+ # Return filename of smb.conf file
+
+ return $name
+}
+
+proc append_smb_conf { args } {
+
+ set name [lindex $args 0]
+ set f [open $name "a"]
+
+ foreach section [lindex $args 1] {
+ set secname [lindex $section 0]
+ set contents [lindex $section 1]
+
+ puts $f "\[$secname]"
+
+ foreach { line } $contents {
+ puts $f "\t$line"
+ }
+
+ puts $f ""
+ }
+
+ close $f
+}
+
+# Create a smb.conf file
+
+set smb_conf [list \
+ [list "global" \
+ [list "netbios name = testing" \
+ "guest ok = true"]]]
+
+set name [write_smb_conf $smb_conf]
+
+# Run smbd and smbclient output
+
+set smbd_output [util_start "bin/smbd" "-s $name"]
+set nmbd_output [util_start "bin/nmbd" "-s $name"]
+
+sleep 5
+
+set smbclient_output [util_start "bin/smbclient -L //testing -N"]
+verbose $smbclient_output
+
+if { ![regexp "Anonymous login successful" $smbclient_output] } {
+ untested "smbd could not be started"
+ util_start "killall" "smbd nmbd"
+ file delete $name
+ return
+}
+
+# Append another share and sighup
+
+append_smb_conf $name [list [list "tmp" [list "browseable = true"]]]
+set output [util_start "killall" "-HUP smbd"]
+verbose $output
+
+sleep 2
+
+set smbclient_output2 [util_start "bin/smbclient -L //testing -N"]
+verbose $smbclient_output2
+
+if { [regexp "tmp.*Disk" $smbclient_output2] } {
+ pass "sighup reload"
+} else {
+ fail "sighup reload"
+}
+
+# Clean up
+
+util_start "killall" "smbd nmbd"
+file delete $name