summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-02-01 14:24:31 -0500
committerSimo Sorce <idra@samba.org>2008-02-01 14:24:31 -0500
commit2fffc9a1b1fe2a1490e867bb38462e50c282d2b3 (patch)
tree428e09c9b35138db8b7ca7161c659a71aa129d29 /examples
parent93a3c5b3f9927973b4ad1496f593ea147052d1e1 (diff)
parentb708005a7106db26d7df689b887b419c9f2ea41c (diff)
downloadsamba-2fffc9a1b1fe2a1490e867bb38462e50c282d2b3.tar.gz
samba-2fffc9a1b1fe2a1490e867bb38462e50c282d2b3.tar.bz2
samba-2fffc9a1b1fe2a1490e867bb38462e50c282d2b3.zip
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit 7dbfc7bdc65314466a83e8121b35c9bcb24b2631)
Diffstat (limited to 'examples')
-rw-r--r--examples/VFS/skel_opaque.c108
-rw-r--r--examples/VFS/skel_transparent.c129
-rw-r--r--examples/libsmbclient/Makefile21
-rw-r--r--examples/libsmbclient/get_auth_data_fn.h22
-rw-r--r--examples/libsmbclient/smbwrapper/Makefile2
-rw-r--r--examples/libsmbclient/smbwrapper/select.c5
-rw-r--r--examples/libsmbclient/smbwrapper/wrapper.c1
-rw-r--r--examples/libsmbclient/testacl.c27
-rw-r--r--examples/libsmbclient/testacl3.c62
-rw-r--r--examples/libsmbclient/testread.c76
-rw-r--r--examples/libsmbclient/teststat3.c78
-rw-r--r--examples/libsmbclient/testwrite.c69
-rw-r--r--examples/libsmbclient/tree.c2
-rw-r--r--examples/logon/genlogon/genlogon.pl2
-rwxr-xr-xexamples/misc/adssearch.pl16
15 files changed, 471 insertions, 149 deletions
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index fd4b206185..4a6e6be42f 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -92,7 +92,7 @@ static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, SMB_STRUCT_DI
static void skel_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset)
{
- return vfswrap_seekdir(NULL, dirp, offset);
+ vfswrap_seekdir(NULL, dirp, offset);
}
static long skel_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
@@ -102,7 +102,7 @@ static long skel_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
static void skel_rewinddir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
{
- return vfswrap_rewinddir(NULL, dirp);
+ vfswrap_rewinddir(NULL, dirp);
}
static int skel_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode)
@@ -130,40 +130,40 @@ static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
return vfswrap_close(NULL, fsp, fd);
}
-static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
+static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
{
- return vfswrap_read(NULL, fsp, fd, data, n);
+ return vfswrap_read(NULL, fsp, data, n);
}
-static ssize_t skel_pread(vfs_handle_struct *handle, struct files_struct *fsp, int fd, void *data, size_t n, SMB_OFF_T offset)
+static ssize_t skel_pread(vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset)
{
- return vfswrap_pread(NULL, fsp, fd, data, n, offset);
+ return vfswrap_pread(NULL, fsp, data, n, offset);
}
-static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
+static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
{
- return vfswrap_write(NULL, fsp, fd, data, n);
+ return vfswrap_write(NULL, fsp, data, n);
}
-ssize_t skel_pwrite(vfs_handle_struct *handle, struct files_struct *fsp, int fd, const void *data, size_t n, SMB_OFF_T offset)
+ssize_t skel_pwrite(vfs_handle_struct *handle, struct files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset)
{
- return vfswrap_pwrite(NULL, fsp, fd, data, n, offset);
+ return vfswrap_pwrite(NULL, fsp, data, n, offset);
}
-static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
+static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence)
{
- return vfswrap_lseek(NULL, fsp, filedes, offset, whence);
+ return vfswrap_lseek(NULL, fsp, offset, whence);
}
-static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
+static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr,
SMB_OFF_T offset, size_t n)
{
- return vfswrap_sendfile(NULL, tofd, fsp, fromfd, hdr, offset, n);
+ return vfswrap_sendfile(NULL, tofd, fromfsp, hdr, offset, n);
}
-static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *fsp, int tofd, SMB_OFF_T offset, size_t n)
+static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t n)
{
- return vfswrap_recvfile(NULL, fromfd, fsp, tofd, offset, n);
+ return vfswrap_recvfile(NULL, fromfd, tofsp, offset, n);
}
static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
@@ -171,9 +171,9 @@ static int skel_rename(vfs_handle_struct *handle, const char *oldname, const ch
return vfswrap_rename(NULL, oldname, newname);
}
-static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
{
- return vfswrap_fsync(NULL, fsp, fd);
+ return vfswrap_fsync(NULL, fsp);
}
static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf)
@@ -181,9 +181,9 @@ static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_S
return vfswrap_stat(NULL, fname, sbuf);
}
-static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
+static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
{
- return vfswrap_fstat(NULL, fsp, fd, sbuf);
+ return vfswrap_fstat(NULL, fsp, sbuf);
}
static int skel_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
@@ -201,9 +201,9 @@ static int skel_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
return vfswrap_chmod(NULL, path, mode);
}
-static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
+static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
{
- return vfswrap_fchmod(NULL, fsp, fd, mode);
+ return vfswrap_fchmod(NULL, fsp, mode);
}
static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
@@ -211,9 +211,9 @@ static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, g
return vfswrap_chown(NULL, path, uid, gid);
}
-static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid)
+static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)
{
- return vfswrap_fchown(NULL, fsp, fd, uid, gid);
+ return vfswrap_fchown(NULL, fsp, uid, gid);
}
static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
@@ -236,19 +236,19 @@ static int skel_ntimes(vfs_handle_struct *handle, const char *path, const struc
return vfswrap_ntimes(NULL, path, ts);
}
-static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T offset)
+static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset)
{
- return vfswrap_ftruncate(NULL, fsp, fd, offset);
+ return vfswrap_ftruncate(NULL, fsp, offset);
}
-static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
+static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
- return vfswrap_lock(NULL, fsp, fd, op, offset, count, type);
+ return vfswrap_lock(NULL, fsp, op, offset, count, type);
}
-static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
+static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
{
- return vfswrap_getlock(NULL, fsp, fd, poffset, pcount, ptype, ppid);
+ return vfswrap_getlock(NULL, fsp, poffset, pcount, ptype, ppid);
}
static int skel_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
@@ -301,7 +301,7 @@ static struct file_id skel_file_id_create(vfs_handle_struct *handle,
}
static size_t skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info, SEC_DESC **ppdesc)
+ uint32 security_info, SEC_DESC **ppdesc)
{
errno = ENOSYS;
return 0;
@@ -314,8 +314,8 @@ static size_t skel_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
return 0;
}
-static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int
- fd, uint32 security_info_sent, SEC_DESC *psd)
+static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+ uint32 security_info_sent, SEC_DESC *psd)
{
errno = ENOSYS;
return NT_STATUS_NOT_IMPLEMENTED;
@@ -334,7 +334,7 @@ static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t m
return -1;
}
-static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
+static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
{
errno = ENOSYS;
return -1;
@@ -370,7 +370,7 @@ static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle, const char *p
return NULL;
}
-static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
errno = ENOSYS;
return NULL;
@@ -436,7 +436,7 @@ static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name, S
return -1;
}
-static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl)
+static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl)
{
errno = ENOSYS;
return -1;
@@ -485,7 +485,7 @@ size)
return -1;
}
-static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size)
+static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
{
errno = ENOSYS;
return -1;
@@ -503,7 +503,7 @@ static ssize_t skel_llistxattr(vfs_handle_struct *handle, const char *path, char
return -1;
}
-static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size)
+static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
{
errno = ENOSYS;
return -1;
@@ -521,7 +521,7 @@ static int skel_lremovexattr(vfs_handle_struct *handle, const char *path, const
return -1;
}
-static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name)
+static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
{
errno = ENOSYS;
return -1;
@@ -539,7 +539,7 @@ static int skel_lsetxattr(vfs_handle_struct *handle, const char *path, const cha
return -1;
}
-static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags)
+static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
{
errno = ENOSYS;
return -1;
@@ -560,9 +560,9 @@ static ssize_t skel_aio_return(struct vfs_handle_struct *handle, struct files_st
return vfswrap_aio_return(NULL, fsp, aiocb);
}
-static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
+static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
{
- return vfswrap_aio_cancel(NULL, fsp, fd, aiocb);
+ return vfswrap_aio_cancel(NULL, fsp, aiocb);
}
static int skel_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
@@ -580,6 +580,21 @@ static int skel_aio_suspend(struct vfs_handle_struct *handle, struct files_struc
return vfswrap_aio_suspend(NULL, fsp, aiocb, n, ts);
}
+static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
+{
+ return vfswrap_aio_force(NULL, fsp);
+}
+
+static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
+{
+ return vfswrap_is_offline(NULL, path, sbuf);
+}
+
+static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
+{
+ return vfswrap_set_offline(NULL, path);
+}
+
/* VFS operations structure */
static vfs_op_tuple skel_op_tuples[] = {
@@ -615,7 +630,7 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_pwrite), SMB_VFS_OP_PWRITE, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_lseek), SMB_VFS_OP_LSEEK, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_sendfile), SMB_VFS_OP_SENDFILE, SMB_VFS_LAYER_OPAQUE},
- {SMB_VFS_OP(skel_recvfile), SMB_VFS_OP_RECVFLE, SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(skel_recvfile), SMB_VFS_OP_RECVFILE, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_fsync), SMB_VFS_OP_FSYNC, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_OPAQUE},
@@ -676,7 +691,7 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, SMB_VFS_LAYER_OPAQUE},
-
+
/* EA operations. */
{SMB_VFS_OP(skel_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_OPAQUE},
@@ -699,6 +714,11 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_aio_error), SMB_VFS_OP_AIO_ERROR, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_aio_fsync), SMB_VFS_OP_AIO_FSYNC, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_aio_suspend), SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(skel_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_OPAQUE},
+
+ /* offline operations */
+ {SMB_VFS_OP(skel_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(skel_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_OPAQUE},
{NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
};
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 2512f4d6db..f4cb9b15ba 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -124,39 +124,39 @@ static int skel_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
return SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
}
-static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n)
+static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
{
- return SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
+ return SMB_VFS_NEXT_READ(handle, fsp, data, n);
}
-static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n, SMB_OFF_T offset)
+static ssize_t skel_pread(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, SMB_OFF_T offset)
{
- return SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset);
+ return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
}
-static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n)
+static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
{
- return SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
+ return SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
}
-static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n, SMB_OFF_T offset)
+static ssize_t skel_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, SMB_OFF_T offset)
{
- return SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset);
+ return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
}
-static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
+static SMB_OFF_T skel_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence)
{
- return SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence);
+ return SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
}
-static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n)
+static ssize_t skel_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n)
{
- return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr, offset, n);
+ return SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
}
-static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *fsp, int tofd, SMB_OFF_T offset, size_t n)
+static ssize_t skel_recvfile(vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t n)
{
- return SMB_VFS_NEXT_RECVFILE(handle, fromfd, fsp, tofd, offset, n);
+ return SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
}
static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
@@ -164,9 +164,9 @@ static int skel_rename(vfs_handle_struct *handle, const char *oldname, const ch
return SMB_VFS_NEXT_RENAME(handle, oldname, newname);
}
-static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int skel_fsync(vfs_handle_struct *handle, files_struct *fsp)
{
- return SMB_VFS_NEXT_FSYNC(handle, fsp, fd);
+ return SMB_VFS_NEXT_FSYNC(handle, fsp);
}
static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf)
@@ -174,9 +174,9 @@ static int skel_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_S
return SMB_VFS_NEXT_STAT(handle, fname, sbuf);
}
-static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
+static int skel_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
{
- return SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf);
+ return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
}
static int skel_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
@@ -194,9 +194,9 @@ static int skel_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
return SMB_VFS_NEXT_CHMOD(handle, path, mode);
}
-static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
+static int skel_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
{
- return SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode);
+ return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
}
static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
@@ -204,9 +204,9 @@ static int skel_chown(vfs_handle_struct *handle, const char *path, uid_t uid, g
return SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
}
-static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid_t uid, gid_t gid)
+static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)
{
- return SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid);
+ return SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
}
static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
@@ -229,19 +229,19 @@ static int skel_ntimes(vfs_handle_struct *handle, const char *path, const struc
return SMB_VFS_NEXT_NTIMES(handle, path, ts);
}
-static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T offset)
+static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset)
{
- return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset);
+ return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
}
-static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
+static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
- return SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type);
+ return SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
}
-static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
+static bool skel_getlock(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
{
- return SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid);
+ return SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
}
static int skel_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
@@ -289,22 +289,22 @@ static struct file_id skel_file_id_create(vfs_handle_struct *handle,
return SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode);
}
-static size_t skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info, SEC_DESC **ppdesc)
+static NTSTATUS skel_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+ uint32 security_info, SEC_DESC **ppdesc)
{
- return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info, ppdesc);
+ return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
}
-static size_t skel_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+static NTSTATUS skel_get_nt_acl(vfs_handle_struct *handle,
const char *name, uint32 security_info, SEC_DESC **ppdesc)
{
- return SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info, ppdesc);
+ return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
}
static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info_sent, SEC_DESC *psd)
+ uint32 security_info_sent, SEC_DESC *psd)
{
- return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent, psd);
+ return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
}
static NTSTATUS skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
@@ -323,14 +323,14 @@ static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t m
return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode);
}
-static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode)
+static int skel_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
{
/* If the underlying VFS doesn't have ACL support... */
if (!handle->vfs_next.ops.fchmod_acl) {
errno = ENOSYS;
return -1;
}
- return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode);
+ return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
}
static int skel_sys_acl_get_entry(vfs_handle_struct *handle, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
@@ -358,9 +358,9 @@ static SMB_ACL_T skel_sys_acl_get_file(vfs_handle_struct *handle, const char *p
return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
}
-static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static SMB_ACL_T skel_sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
{
- return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd);
+ return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
}
static int skel_sys_acl_clear_perms(vfs_handle_struct *handle, SMB_ACL_PERMSET_T permset)
@@ -413,9 +413,9 @@ static int skel_sys_acl_set_file(vfs_handle_struct *handle, const char *name, S
return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype, theacl);
}
-static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl)
+static int skel_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, SMB_ACL_T theacl)
{
- return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl);
+ return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
}
static int skel_sys_acl_delete_def_file(vfs_handle_struct *handle, const char *path)
@@ -454,9 +454,9 @@ size)
return SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
}
-static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size)
+static ssize_t skel_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
{
- return SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size);
+ return SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
}
static ssize_t skel_listxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size)
@@ -469,9 +469,9 @@ static ssize_t skel_llistxattr(vfs_handle_struct *handle, const char *path, char
return SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
}
-static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, char *list, size_t size)
+static ssize_t skel_flistxattr(vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
{
- return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size);
+ return SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
}
static int skel_removexattr(vfs_handle_struct *handle, const char *path, const char *name)
@@ -484,9 +484,9 @@ static int skel_lremovexattr(vfs_handle_struct *handle, const char *path, const
return SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
}
-static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name)
+static int skel_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
{
- return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name);
+ return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
}
static int skel_setxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
@@ -499,9 +499,9 @@ static int skel_lsetxattr(vfs_handle_struct *handle, const char *path, const cha
return SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size, flags);
}
-static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags)
+static int skel_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
{
- return SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size, flags);
+ return SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
}
static int skel_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
@@ -519,9 +519,9 @@ static ssize_t skel_aio_return(struct vfs_handle_struct *handle, struct files_st
return SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
}
-static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
+static int skel_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
{
- return SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb);
+ return SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
}
static int skel_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
@@ -539,6 +539,26 @@ static int skel_aio_suspend(struct vfs_handle_struct *handle, struct files_struc
return SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
}
+static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
+{
+ return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
+}
+
+static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
+{
+ return SMB_VFS_NEXT_IS_OFFLINE(handle, path, sbuf);
+}
+
+static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
+{
+ return SMB_VFS_NEXT_SET_OFFLINE(handle, path);
+}
+
+static bool skel_is_remotestorage(struct vfs_handle_struct *handle, const char *path)
+{
+ return SMB_VFS_NEXT_IS_REMOTESTORAGE(handle, path);
+}
+
/* VFS operations structure */
static vfs_op_tuple skel_op_tuples[] = {
@@ -633,7 +653,7 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, SMB_VFS_LAYER_TRANSPARENT},
-
+
/* EA operations. */
{SMB_VFS_OP(skel_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT},
@@ -656,6 +676,11 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_aio_error), SMB_VFS_OP_AIO_ERROR, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_aio_fsync), SMB_VFS_OP_AIO_FSYNC, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_aio_suspend), SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(skel_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_TRANSPARENT},
+
+ /* offline operations */
+ {SMB_VFS_OP(skel_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(skel_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_TRANSPARENT},
{NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
};
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index be383aea67..6c70659661 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -5,7 +5,7 @@ SAMBA_INCL = ../../source/include
EXTLIB_INCL = -I/usr/include/gtk-1.2 \
-I/usr/include/glib-1.2 \
-I/usr/lib/glib/include
-
+EXTLIB_INCL = `gtk-config --cflags`
DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
CFLAGS = -O0 -g -I$(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS)
@@ -13,18 +13,21 @@ CFLAGS = -O0 -g -I$(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS)
LDFLAGS = -L/usr/local/samba/lib \
-lldap -lkrb5 -lgssapi_krb5
#LIBSMBCLIENT = /usr/local/samba/lib/libsmbclient.so
-LIBSMBCLIENT = ../../source/bin/libsmbclient.a -ldl -lresolv
+LIBSMBCLIENT = -lwbclient -lsmbclient -ldl -lresolv
TESTS= testsmbc \
testacl \
testacl2 \
+ testacl3 \
testbrowse \
testbrowse2 \
teststat \
teststat2 \
+ teststat3 \
testchmod \
testutime \
- testread
+ testread \
+ testwrite
# tree \
@@ -46,6 +49,10 @@ testacl2: testacl2.o
@echo Linking testacl2
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+testacl3: testacl3.o
+ @echo Linking testacl3
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
testbrowse: testbrowse.o
@echo Linking testbrowse
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
@@ -62,6 +69,10 @@ teststat2: teststat2.o
@echo Linking teststat2
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+teststat3: teststat3.o
+ @echo Linking teststat3
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
testchmod: testchmod.o
@echo Linking testchmod
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
@@ -74,6 +85,10 @@ testread: testread.o
@echo Linking testread
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+testwrite: testwrite.o
+ @echo Linking testwrite
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
smbsh:
make -C smbwrapper
diff --git a/examples/libsmbclient/get_auth_data_fn.h b/examples/libsmbclient/get_auth_data_fn.h
index eb493885af..b1d36c8bea 100644
--- a/examples/libsmbclient/get_auth_data_fn.h
+++ b/examples/libsmbclient/get_auth_data_fn.h
@@ -8,7 +8,23 @@ get_auth_data_fn(const char * pServer,
char * pPassword,
int maxLenPassword)
{
- char temp[128];
+ char temp[128];
+ char server[256] = { '\0' };
+ char share[256] = { '\0' };
+ char workgroup[256] = { '\0' };
+ char username[256] = { '\0' };
+ char password[256] = { '\0' };
+
+ if (strcmp(server, pServer) == 0 &&
+ strcmp(share, pShare) == 0 &&
+ *workgroup != '\0' &&
+ *username != '\0')
+ {
+ strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
+ strncpy(pUsername, username, maxLenUsername - 1);
+ strncpy(pPassword, password, maxLenPassword - 1);
+ return;
+ }
fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
fgets(temp, sizeof(temp), stdin);
@@ -48,4 +64,8 @@ get_auth_data_fn(const char * pServer,
{
strncpy(pPassword, temp, maxLenPassword - 1);
}
+
+ strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
+ strncpy(username, pUsername, sizeof(username) - 1);
+ strncpy(password, pPassword, sizeof(password) - 1);
}
diff --git a/examples/libsmbclient/smbwrapper/Makefile b/examples/libsmbclient/smbwrapper/Makefile
index c94ef8fa6a..726435319f 100644
--- a/examples/libsmbclient/smbwrapper/Makefile
+++ b/examples/libsmbclient/smbwrapper/Makefile
@@ -1,4 +1,4 @@
-LIBS = -lsmbclient -ldl
+LIBS = -lwbclient -lsmbclient -ldl
DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
CFLAGS = -I$(SAMBA_INCL) $(EXTLIB_INCL)
diff --git a/examples/libsmbclient/smbwrapper/select.c b/examples/libsmbclient/smbwrapper/select.c
index 4e87a2e2e8..bb7a25f13e 100644
--- a/examples/libsmbclient/smbwrapper/select.c
+++ b/examples/libsmbclient/smbwrapper/select.c
@@ -72,13 +72,12 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf
int ret;
fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf;
struct timeval tval2, *ptval, end_time, now_time;
- extern void GetTimeOfDay(struct timeval *tval);
readfds2 = (readfds ? &readfds_buf : NULL);
writefds2 = (writefds ? &writefds_buf : NULL);
errorfds2 = (errorfds ? &errorfds_buf : NULL);
if (tval) {
- GetTimeOfDay(&end_time);
+ gettimeofday(&end_time, NULL);
end_time.tv_sec += tval->tv_sec;
end_time.tv_usec += tval->tv_usec;
end_time.tv_sec += end_time.tv_usec / 1000000;
@@ -96,7 +95,7 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf
if (errorfds)
errorfds_buf = *errorfds;
if (tval) {
- GetTimeOfDay(&now_time);
+ gettimeofday(&now_time, NULL);
tval2.tv_sec = end_time.tv_sec - now_time.tv_sec;
tval2.tv_usec = end_time.tv_usec - now_time.tv_usec;
if ((signed long) tval2.tv_usec < 0) {
diff --git a/examples/libsmbclient/smbwrapper/wrapper.c b/examples/libsmbclient/smbwrapper/wrapper.c
index 30f9037d53..958e00636e 100644
--- a/examples/libsmbclient/smbwrapper/wrapper.c
+++ b/examples/libsmbclient/smbwrapper/wrapper.c
@@ -61,6 +61,7 @@
#include <dirent.h>
#include <signal.h>
#include <stdarg.h>
+#include <string.h>
#ifdef __USE_GNU
# define SMBW_USE_GNU
#endif
diff --git a/examples/libsmbclient/testacl.c b/examples/libsmbclient/testacl.c
index 4d327b39a7..51cc90f101 100644
--- a/examples/libsmbclient/testacl.c
+++ b/examples/libsmbclient/testacl.c
@@ -7,6 +7,7 @@
enum acl_mode
{
+ SMB_ACL_LIST,
SMB_ACL_GET,
SMB_ACL_SET,
SMB_ACL_DELETE,
@@ -24,7 +25,7 @@ int main(int argc, const char *argv[])
int debug = 0;
int numeric = 0;
int full_time_names = 0;
- enum acl_mode mode = SMB_ACL_GET;
+ enum acl_mode mode = SMB_ACL_LIST;
static char *the_acl = NULL;
int ret;
char *p;
@@ -149,6 +150,30 @@ int main(int argc, const char *argv[])
switch(mode)
{
+ case SMB_ACL_LIST:
+ ret = smbc_listxattr(path, value, sizeof(value)-2);
+ if (ret < 0)
+ {
+ printf("Could not get attribute list for [%s] %d: %s\n",
+ path, errno, strerror(errno));
+ return 1;
+ }
+
+ /*
+ * The list of attributes has a series of null-terminated strings.
+ * The list of strings terminates with an extra null byte, thus two in
+ * a row. Ensure that our buffer, which is conceivably shorter than
+ * the list of attributes, actually ends with two null bytes in a row.
+ */
+ value[sizeof(value) - 2] = '\0';
+ value[sizeof(value) - 1] = '\0';
+ printf("Supported attributes:\n");
+ for (p = value; *p; p += strlen(p) + 1)
+ {
+ printf("\t%s\n", p);
+ }
+ break;
+
case SMB_ACL_GET:
if (the_acl == NULL)
{
diff --git a/examples/libsmbclient/testacl3.c b/examples/libsmbclient/testacl3.c
new file mode 100644
index 0000000000..9102405659
--- /dev/null
+++ b/examples/libsmbclient/testacl3.c
@@ -0,0 +1,62 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <libsmbclient.h>
+#include "get_auth_data_fn.h"
+
+
+int main(int argc, char * argv[])
+{
+ int i;
+ int fd;
+ int ret;
+ int debug = 0;
+ int mode = 0666;
+ int savedErrno;
+ char value[2048];
+ char path[2048];
+ char * the_acl;
+ char * p;
+ time_t t0;
+ time_t t1;
+ struct stat st;
+ SMBCCTX * context;
+
+ smbc_init(get_auth_data_fn, debug);
+
+ context = smbc_set_context(NULL);
+ smbc_option_set(context, "full_time_names", 1);
+
+ for (;;)
+ {
+ fprintf(stdout, "Path: ");
+ *path = '\0';
+ fgets(path, sizeof(path) - 1, stdin);
+ if (strlen(path) == 0)
+ {
+ return 0;
+ }
+
+ p = path + strlen(path) - 1;
+ if (*p == '\n')
+ {
+ *p = '\0';
+ }
+
+ the_acl = strdup("system.nt_sec_desc.*+");
+ ret = smbc_getxattr(path, the_acl, value, sizeof(value));
+ if (ret < 0)
+ {
+ printf("Could not get attributes for [%s] %d: %s\n",
+ path, errno, strerror(errno));
+ return 1;
+ }
+
+ printf("Attributes for [%s] are:\n%s\n", path, value);
+ }
+
+ return 0;
+}
diff --git a/examples/libsmbclient/testread.c b/examples/libsmbclient/testread.c
index d59fc70ec1..3f94884895 100644
--- a/examples/libsmbclient/testread.c
+++ b/examples/libsmbclient/testread.c
@@ -10,66 +10,58 @@
int main(int argc, char * argv[])
{
+ int i;
int fd;
int ret;
int debug = 0;
int mode = 0666;
int savedErrno;
char buffer[2048];
- char * pSmbPath = NULL;
+ char path[2048];
+ char * p;
time_t t0;
time_t t1;
struct stat st;
- if (argc == 1)
- {
- pSmbPath = "smb://RANDOM/Public/bigfile";
- }
- else if (argc == 2)
- {
- pSmbPath = argv[1];
- }
- else
- {
- printf("usage: "
- "%s [ smb://path/to/file ]\n",
- argv[0]);
- return 1;
- }
-
smbc_init(get_auth_data_fn, debug);
- printf("Open file %s\n", pSmbPath);
-
- t0 = time(NULL);
-
- if ((fd = smbc_open(pSmbPath, O_RDONLY, 0)) < 0)
+ for (;;)
{
- perror("smbc_open");
- return 1;
- }
+ fprintf(stdout, "Path: ");
+ *path = '\0';
+ fgets(path, sizeof(path) - 1, stdin);
+ if (strlen(path) == 0)
+ {
+ return 0;
+ }
- printf("Beginning read loop.\n");
+ p = path + strlen(path) - 1;
+ if (*p == '\n')
+ {
+ *p = '\0';
+ }
+
+ if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
+ {
+ perror("smbc_open");
+ continue;
+ }
- do
- {
- ret = smbc_read(fd, buffer, sizeof(buffer));
- savedErrno = errno;
- if (ret > 0) fwrite(buffer, 1, ret, stdout);
- } while (ret > 0);
+ do
+ {
+ ret = smbc_read(fd, buffer, sizeof(buffer));
+ savedErrno = errno;
+ if (ret > 0) fwrite(buffer, 1, ret, stdout);
+ } while (ret > 0);
- smbc_close(fd);
+ smbc_close(fd);
- if (ret < 0)
- {
- errno = savedErrno;
- perror("read");
- return 1;
+ if (ret < 0)
+ {
+ errno = savedErrno;
+ perror("read");
+ }
}
- t1 = time(NULL);
-
- printf("Elapsed time: %d seconds\n", t1 - t0);
-
return 0;
}
diff --git a/examples/libsmbclient/teststat3.c b/examples/libsmbclient/teststat3.c
new file mode 100644
index 0000000000..26348b335c
--- /dev/null
+++ b/examples/libsmbclient/teststat3.c
@@ -0,0 +1,78 @@
+#include <libsmbclient.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+#include "get_auth_data_fn.h"
+
+/*
+ * This test is intended to ensure that the timestamps returned by
+ * libsmbclient using smbc_stat() are the same as those returned by
+ * smbc_fstat().
+ */
+
+
+int main(int argc, char* argv[])
+{
+ int fd;
+ struct stat st1;
+ struct stat st2;
+ char mtime[32];
+ char ctime[32];
+ char atime[32];
+ char * pUrl = argv[1];
+
+ if(argc != 2)
+ {
+ printf("usage: %s <file_url>\n", argv[0]);
+ return 1;
+ }
+
+
+ smbc_init(get_auth_data_fn, 0);
+
+ if (smbc_stat(pUrl, &st1) < 0)
+ {
+ perror("smbc_stat");
+ return 1;
+ }
+
+ if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
+ {
+ perror("smbc_open");
+ return 1;
+ }
+
+ if (smbc_fstat(fd, &st2) < 0)
+ {
+ perror("smbc_fstat");
+ return 1;
+ }
+
+ smbc_close(fd);
+
+#define COMPARE(name, field) \
+ if (st1.field != st2.field) \
+ { \
+ printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \
+ (unsigned long) st1.field, \
+ (unsigned long) st2.field); \
+ }
+
+ COMPARE("st_dev", st_dev);
+ COMPARE("st_ino", st_ino);
+ COMPARE("st_mode", st_mode);
+ COMPARE("st_nlink", st_nlink);
+ COMPARE("st_uid", st_uid);
+ COMPARE("st_gid", st_gid);
+ COMPARE("st_rdev", st_rdev);
+ COMPARE("st_size", st_size);
+ COMPARE("st_blksize", st_blksize);
+ COMPARE("st_blocks", st_blocks);
+ COMPARE("st_atime", st_atime);
+ COMPARE("st_mtime", st_mtime);
+ COMPARE("st_ctime", st_ctime);
+
+ return 0;
+}
+
diff --git a/examples/libsmbclient/testwrite.c b/examples/libsmbclient/testwrite.c
new file mode 100644
index 0000000000..780f0e95da
--- /dev/null
+++ b/examples/libsmbclient/testwrite.c
@@ -0,0 +1,69 @@
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+#include <libsmbclient.h>
+#include "get_auth_data_fn.h"
+
+
+int main(int argc, char * argv[])
+{
+ int i;
+ int fd;
+ int ret;
+ int debug = 0;
+ int mode = 0666;
+ int savedErrno;
+ char buffer[2048];
+ char path[2048];
+ char * p;
+ time_t t0;
+ time_t t1;
+ struct stat st;
+
+ smbc_init(get_auth_data_fn, debug);
+
+ printf("CAUTION: This program will overwrite a file. "
+ "Press ENTER to continue.");
+ fgets(buffer, sizeof(buffer), stdin);
+
+
+ for (;;)
+ {
+ fprintf(stdout, "\nPath: ");
+ *path = '\0';
+ fgets(path, sizeof(path) - 1, stdin);
+ if (strlen(path) == 0)
+ {
+ return 0;
+ }
+
+ p = path + strlen(path) - 1;
+ if (*p == '\n')
+ {
+ *p = '\0';
+ }
+
+ if ((fd = smbc_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
+ {
+ perror("smbc_open");
+ continue;
+ }
+
+ strcpy(buffer, "Hello world\n");
+
+ ret = smbc_write(fd, buffer, strlen(buffer));
+ savedErrno = errno;
+ smbc_close(fd);
+
+ if (ret < 0)
+ {
+ errno = savedErrno;
+ perror("write");
+ }
+ }
+
+ return 0;
+}
diff --git a/examples/libsmbclient/tree.c b/examples/libsmbclient/tree.c
index d5a71e2868..6e34cd0562 100644
--- a/examples/libsmbclient/tree.c
+++ b/examples/libsmbclient/tree.c
@@ -24,6 +24,8 @@
#include <stdio.h>
#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
#include <gtk/gtk.h>
#include "libsmbclient.h"
diff --git a/examples/logon/genlogon/genlogon.pl b/examples/logon/genlogon/genlogon.pl
index 8ebf392141..4799ac8452 100644
--- a/examples/logon/genlogon/genlogon.pl
+++ b/examples/logon/genlogon/genlogon.pl
@@ -45,7 +45,7 @@ if ($ARGV[1] eq "SUPPORT" || $ARGV[0] eq "support")
}
# Connect shares just used by Administration staff
-If ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin")
+if ($ARGV[1] eq "ADMIN" || $ARGV[0] eq "admin")
{
print LOGON "NET USE L: \\\\$ARGV[2]\\ADMIN\r\n";
print LOGON "NET USE K: \\\\$ARGV[2]\\MKTING\r\n";
diff --git a/examples/misc/adssearch.pl b/examples/misc/adssearch.pl
index a63ae311eb..d17e680ec8 100755
--- a/examples/misc/adssearch.pl
+++ b/examples/misc/adssearch.pl
@@ -3,7 +3,7 @@
# adssearch.pl - query an Active Directory server and
# display objects in a human readable format
#
-# Copyright (C) Guenther Deschner <gd@samba.org> 2003-2007
+# Copyright (C) Guenther Deschner <gd@samba.org> 2003-2008
#
# TODO: add range retrieval
# write sddl-converter, decode userParameters
@@ -230,6 +230,7 @@ my %ads_mixed_domain = (
my %ads_ds_func = (
"DS_BEHAVIOR_WIN2000" => 0, # untested
"DS_BEHAVIOR_WIN2003" => 2,
+"DS_BEHAVIOR_WIN2008" => 3,
);
my %ads_instance_type = (
@@ -244,6 +245,14 @@ my %ads_uacc = (
"ACCOUNT_LOCKED_OUT" => 0x800010, # 8388624
);
+my %ads_enctypes = (
+ "DES-CBC-CRC" => 0x01,
+ "DES-CBC-MD5" => 0x02,
+ "RC4_HMAC_MD5" => 0x04,
+ "AES128_CTS_HMAC_SHA1_96" => 0x08,
+ "AES128_CTS_HMAC_SHA1_128" => 0x10,
+);
+
my %ads_gpoptions = (
"GPOPTIONS_INHERIT" => 0,
"GPOPTIONS_BLOCK_INHERITANCE" => 1,
@@ -518,6 +527,7 @@ my %attr_handler = (
"modifyTimeStamp" => \&dump_timestr,
"msDS-Behavior-Version" => \&dump_ds_func, #unsure
"msDS-User-Account-Control-Computed" => \&dump_uacc,
+ "msDS-SupportedEncryptionTypes" => \&dump_enctypes,
"mS-DS-CreatorSID" => \&dump_sid,
# "msRADIUSFramedIPAddress" => \&dump_ipaddr,
# "msRASSavedFramedIPAddress" => \&dump_ipaddr,
@@ -1209,6 +1219,10 @@ sub dump_uacc {
return dump_bitmask_equal(@_,%ads_uacc);
}
+sub dump_enctypes {
+ return dump_bitmask_and(@_,%ads_enctypes);
+}
+
sub dump_uf {
return dump_bitmask_and(@_,%ads_uf);
}