summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-04-30 13:28:41 +0000
committerJeremy Allison <jra@samba.org>2002-04-30 13:28:41 +0000
commitd04b55f2186fb8af998cf61c576771a5f72f4892 (patch)
tree9ff8c3a7cf34cefc0ee9a550a3bb1236a9e77595 /examples
parent73267ca42d9eddabb71b31b4c5068ebbe7bc9f7c (diff)
downloadsamba-d04b55f2186fb8af998cf61c576771a5f72f4892.tar.gz
samba-d04b55f2186fb8af998cf61c576771a5f72f4892.tar.xz
samba-d04b55f2186fb8af998cf61c576771a5f72f4892.zip
Start of merge to 2_2_RELEASE branch for release.
Jeremy.
Diffstat (limited to 'examples')
-rw-r--r--examples/LDAP/samba.schema12
-rw-r--r--examples/VFS/Makefile2
-rw-r--r--examples/VFS/README4
-rw-r--r--examples/VFS/audit.c130
-rw-r--r--examples/VFS/block/Makefile4
-rw-r--r--examples/VFS/block/block.c208
-rw-r--r--examples/VFS/skel.c344
-rwxr-xr-xexamples/printing/smbprint104
8 files changed, 569 insertions, 239 deletions
diff --git a/examples/LDAP/samba.schema b/examples/LDAP/samba.schema
index 28828f4f940..be088c74033 100644
--- a/examples/LDAP/samba.schema
+++ b/examples/LDAP/samba.schema
@@ -6,8 +6,8 @@
## Prerequisite schemas - uid (cosine.schema)
## - displayName (inetorgperson.schema)
##
-## 1.3.1.5.1.4.1.7165.2.1.x - attributetypes
-## 1.3.1.5.1.4.1.7165.2.2.x - objectclasses
+## 1.3.6.1.4.1.7165.2.1.x - attributetypes
+## 1.3.6.1.4.1.7165.2.2.x - objectclasses
##
##
@@ -114,12 +114,12 @@ attributetype ( 1.3.6.1.4.1.7165.2.1.15 NAME 'primaryGroupID'
## The smbPasswordEntry objectclass has been depreciated in favor of the
## sambaAccount objectclass
##
-#objectclass ( 1.3.1.5.1.4.1.7165.2.2.1 NAME 'smbPasswordEntry' SUP top AUXILIARY
+#objectclass ( 1.3.6.1.4.1.7165.2.2.1 NAME 'smbPasswordEntry' SUP top AUXILIARY
# DESC 'Samba smbpasswd entry'
# MUST ( uid $ uidNumber )
# MAY ( lmPassword $ ntPassword $ pwdLastSet $ acctFlags ))
-objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top STRUCTURAL
+objectclass ( 1.3.6.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top STRUCTURAL
DESC 'Samba Account'
MUST ( uid $ rid )
MAY ( cn $ lmPassword $ ntPassword $ pwdLastSet $ logonTime $
@@ -130,11 +130,11 @@ objectclass ( 1.3.1.5.1.4.1.7165.2.2.2 NAME 'sambaAccount' SUP top STRUCTURAL
##
## Used for Winbind experimentation
##
-objectclass ( 1.3.1.5.1.4.1.7165.1.2.2.3 NAME 'uidPool' SUP top AUXILIARY
+objectclass ( 1.3.6.1.4.1.7165.1.2.2.3 NAME 'uidPool' SUP top AUXILIARY
DESC 'Pool for allocating UNIX uids'
MUST ( uidNumber $ cn ) )
-objectclass ( 1.3.1.5.1.4.1.7165.1.2.2.4 NAME 'gidPool' SUP top AUXILIARY
+objectclass ( 1.3.6.1.4.1.7165.1.2.2.4 NAME 'gidPool' SUP top AUXILIARY
DESC 'Pool for allocating UNIX gids'
MUST ( gidNumber $ cn ) )
diff --git a/examples/VFS/Makefile b/examples/VFS/Makefile
index 9c216cd29b8..eaa1ffbb54e 100644
--- a/examples/VFS/Makefile
+++ b/examples/VFS/Makefile
@@ -13,7 +13,7 @@ SAMBA_INCL = ../../source/include
UBIQX_SRC = ../../source/ubiqx
SMBWR_SRC = ../../source/smbwrapper
CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g
-VFS_OBJS = audit.so skel.so
+VFS_OBJS = audit.so skel.so recycle.so
# Default target
diff --git a/examples/VFS/README b/examples/VFS/README
index 825f8a961ff..91ef37a2ac3 100644
--- a/examples/VFS/README
+++ b/examples/VFS/README
@@ -17,10 +17,14 @@ construction. The following VFS modules are given:
connect/disconnect, directory opens/create/remove,
file open/close/rename/unlink/chmod.
+ recycle
+ Add a recycle bin facility to a samba share
+
block/
A directory containing a sample module by Ronald Kuetemeier
<ronald@kuetemeier.com> to block named symbolic link following.
+ Note: Config file is in /etc/samba/samba-block.conf
The libtool program, available from your favourite GNU software
archive, is required to compile these programs.
diff --git a/examples/VFS/audit.c b/examples/VFS/audit.c
index ce2aa52250e..aad483c295a 100644
--- a/examples/VFS/audit.c
+++ b/examples/VFS/audit.c
@@ -47,16 +47,19 @@
/* Function prototypes */
-int audit_connect(struct connection_struct *conn, char *svc, char *user);
+int audit_connect(struct connection_struct *conn, const char *svc, const char *user);
void audit_disconnect(struct connection_struct *conn);
-DIR *audit_opendir(struct connection_struct *conn, char *fname);
-int audit_mkdir(struct connection_struct *conn, char *path, mode_t mode);
-int audit_rmdir(struct connection_struct *conn, char *path);
-int audit_open(struct connection_struct *conn, char *fname, int flags, mode_t mode);
+DIR *audit_opendir(struct connection_struct *conn, const char *fname);
+int audit_mkdir(struct connection_struct *conn, const char *path, mode_t mode);
+int audit_rmdir(struct connection_struct *conn, const char *path);
+int audit_open(struct connection_struct *conn, const char *fname, int flags, mode_t mode);
int audit_close(struct files_struct *fsp, int fd);
-int audit_rename(struct connection_struct *conn, char *old, char *new);
-int audit_unlink(struct connection_struct *conn, char *path);
-int audit_chmod(struct connection_struct *conn, char *path, mode_t mode);
+int audit_rename(struct connection_struct *conn, const char *old, const char *new);
+int audit_unlink(struct connection_struct *conn, const char *path);
+int audit_chmod(struct connection_struct *conn, const char *path, mode_t mode);
+int audit_chmod_acl(struct connection_struct *conn, const char *name, mode_t mode);
+int audit_fchmod(struct files_struct *fsp, int fd, mode_t mode);
+int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode);
/* VFS operations */
@@ -92,32 +95,86 @@ struct vfs_ops audit_ops = {
NULL, /* lstat */
audit_unlink,
audit_chmod,
+ audit_fchmod,
NULL, /* chown */
+ NULL, /* fchown */
NULL, /* chdir */
NULL, /* getwd */
NULL, /* utime */
NULL, /* ftruncate */
NULL, /* lock */
+ NULL, /* symlink */
+ NULL, /* readlink */
+ NULL, /* link */
+ NULL, /* mknod */
+ NULL, /* realpath */
NULL, /* fget_nt_acl */
NULL, /* get_nt_acl */
NULL, /* fset_nt_acl */
- NULL /* set_nt_acl */
+ NULL, /* set_nt_acl */
+
+ audit_chmod_acl, /* chmod_acl */
+ audit_fchmod_acl, /* fchmod_acl */
+
+ NULL, /* sys_acl_get_entry */
+ NULL, /* sys_acl_get_tag_type */
+ NULL, /* sys_acl_get_permset */
+ NULL, /*sys_acl_get_qualifier */
+ NULL, /* sys_acl_get_file */
+ NULL, /* sys_acl_get_fd */
+ NULL, /* sys_acl_clear_perms */
+ NULL, /* sys_acl_add_perm */
+ NULL, /* sys_acl_to_text */
+ NULL, /* sys_acl_init */
+ NULL, /* sys_acl_create_entry */
+ NULL, /* sys_acl_set_tag_type */
+ NULL, /* sys_acl_set_qualifier */
+ NULL, /* sys_acl_set_permset */
+ NULL, /* sys_acl_valid */
+ NULL, /* sys_acl_set_file */
+ NULL, /* sys_acl_set_fd */
+ NULL, /* sys_acl_delete_def_file */
+ NULL, /* sys_acl_get_perm */
+ NULL, /* sys_acl_free_text */
+ NULL, /* sys_acl_free_acl */
+ NULL /* sys_acl_free_qualifier */
};
/* VFS initialisation function. Return initialised vfs_ops structure
back to SAMBA. */
-BOOL vfs_init(connection_struct *conn)
+struct vfs_ops *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops)
{
+ struct vfs_ops tmp_ops;
+
+ *vfs_version = SMB_VFS_INTERFACE_VERSION;
+ memcpy(&tmp_ops, def_vfs_ops, sizeof(struct vfs_ops));
+
+ tmp_ops.connect = audit_connect;
+ tmp_ops.disconnect = audit_disconnect;
+ tmp_ops.opendir = audit_opendir;
+ tmp_ops.mkdir = audit_mkdir;
+ tmp_ops.rmdir = audit_rmdir;
+ tmp_ops.open = audit_open;
+ tmp_ops.close = audit_close;
+ tmp_ops.rename = audit_rename;
+ tmp_ops.unlink = audit_unlink;
+ tmp_ops.chmod = audit_chmod;
+ tmp_ops.chmod_acl = audit_chmod_acl;
+ tmp_ops.fchmod = audit_fchmod;
+ tmp_ops.fchmod_acl = audit_fchmod_acl;
+
+ memcpy(&audit_ops, &tmp_ops, sizeof(struct vfs_ops));
+
openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY);
syslog(SYSLOG_PRIORITY, "VFS_INIT: vfs_ops loaded\n");
- return True;
+ return &audit_ops;
}
/* Implementation of vfs_ops. Pass everything on to the default
operation but log event first. */
-int audit_connect(struct connection_struct *conn, char *svc, char *user)
+int audit_connect(struct connection_struct *conn, const char *svc, const char *user)
{
syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n",
svc, user);
@@ -131,7 +188,7 @@ void audit_disconnect(struct connection_struct *conn)
default_vfs_ops.disconnect(conn);
}
-DIR *audit_opendir(struct connection_struct *conn, char *fname)
+DIR *audit_opendir(struct connection_struct *conn, const char *fname)
{
DIR *result = default_vfs_ops.opendir(conn, fname);
@@ -143,7 +200,7 @@ DIR *audit_opendir(struct connection_struct *conn, char *fname)
return result;
}
-int audit_mkdir(struct connection_struct *conn, char *path, mode_t mode)
+int audit_mkdir(struct connection_struct *conn, const char *path, mode_t mode)
{
int result = default_vfs_ops.mkdir(conn, path, mode);
@@ -155,7 +212,7 @@ int audit_mkdir(struct connection_struct *conn, char *path, mode_t mode)
return result;
}
-int audit_rmdir(struct connection_struct *conn, char *path)
+int audit_rmdir(struct connection_struct *conn, const char *path)
{
int result = default_vfs_ops.rmdir(conn, path);
@@ -167,7 +224,7 @@ int audit_rmdir(struct connection_struct *conn, char *path)
return result;
}
-int audit_open(struct connection_struct *conn, char *fname, int flags, mode_t mode)
+int audit_open(struct connection_struct *conn, const char *fname, int flags, mode_t mode)
{
int result = default_vfs_ops.open(conn, fname, flags, mode);
@@ -192,7 +249,7 @@ int audit_close(struct files_struct *fsp, int fd)
return result;
}
-int audit_rename(struct connection_struct *conn, char *old, char *new)
+int audit_rename(struct connection_struct *conn, const char *old, const char *new)
{
int result = default_vfs_ops.rename(conn, old, new);
@@ -204,7 +261,7 @@ int audit_rename(struct connection_struct *conn, char *old, char *new)
return result;
}
-int audit_unlink(struct connection_struct *conn, char *path)
+int audit_unlink(struct connection_struct *conn, const char *path)
{
int result = default_vfs_ops.unlink(conn, path);
@@ -216,7 +273,7 @@ int audit_unlink(struct connection_struct *conn, char *path)
return result;
}
-int audit_chmod(struct connection_struct *conn, char *path, mode_t mode)
+int audit_chmod(struct connection_struct *conn, const char *path, mode_t mode)
{
int result = default_vfs_ops.chmod(conn, path, mode);
@@ -228,3 +285,38 @@ int audit_chmod(struct connection_struct *conn, char *path, mode_t mode)
return result;
}
+int audit_chmod_acl(struct connection_struct *conn, const char *path, mode_t mode)
+{
+ int result = default_vfs_ops.chmod_acl(conn, path, mode);
+
+ syslog(SYSLOG_PRIORITY, "chmod_acl %s mode 0x%x %s%s\n",
+ path, mode,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
+
+ return result;
+}
+
+int audit_fchmod(struct files_struct *fsp, int fd, mode_t mode)
+{
+ int result = default_vfs_ops.fchmod(fsp, fd, mode);
+
+ syslog(SYSLOG_PRIORITY, "fchmod %s mode 0x%x %s%s\n",
+ fsp->fsp_name, mode,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
+
+ return result;
+}
+
+int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode)
+{
+ int result = default_vfs_ops.fchmod_acl(fsp, fd, mode);
+
+ syslog(SYSLOG_PRIORITY, "fchmod_acl %s mode 0x%x %s%s\n",
+ fsp->fsp_name, mode,
+ (result < 0) ? "failed: " : "",
+ (result < 0) ? strerror(errno) : "");
+
+ return result;
+}
diff --git a/examples/VFS/block/Makefile b/examples/VFS/block/Makefile
index dcc7c077936..4887915fb4f 100644
--- a/examples/VFS/block/Makefile
+++ b/examples/VFS/block/Makefile
@@ -8,11 +8,11 @@
CC = gcc
LIBTOOL = libtool
-SAMBA_SRC = /usr/local/src/samba/samba-2.2.0-ron/source
+SAMBA_SRC = ../../../source
SAMBA_INCL = ${SAMBA_SRC}/include
UBIQX_SRC = ${SAMBA_SRC}/ubiqx
SMBWR_SRC = ${SAMBA_SRC}/smbwrapper
-CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g -D_LARGEFILE63_SOURCE -D_GNU_SOURCE -fno-builtin
+CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g
VFS_OBJS = block.so
diff --git a/examples/VFS/block/block.c b/examples/VFS/block/block.c
index 3c4f736e849..8c0fa61d506 100644
--- a/examples/VFS/block/block.c
+++ b/examples/VFS/block/block.c
@@ -47,8 +47,8 @@
-DIR *block_opendir(struct connection_struct *conn, char *fname);
-int block_connect(struct connection_struct *conn, char *service, char *user);
+DIR *block_opendir(struct connection_struct *conn, const char *fname);
+int block_connect(struct connection_struct *conn, const char *service, const char *user);
void block_disconnect(struct connection_struct *conn);
@@ -63,49 +63,82 @@ struct vfs_ops execute_vfs_ops = {
block_connect,
block_disconnect,
- NULL, /* disk free */
+ NULL, /* disk free */
/* Directory operations */
block_opendir,
- NULL, /* readdir */
- NULL,
- NULL,
- NULL, /* closedir */
+ NULL, /* readdir */
+ NULL, /* mkdir */
+ NULL, /* rmdir */
+ NULL, /* closedir */
/* File operations */
- NULL,
- NULL,
- NULL, /* read */
- NULL, /* write */
- NULL, /* lseek */
- NULL,
- NULL, /* fsync */
- NULL, /* stat */
- NULL, /* fstat */
- NULL, /* lstat */
- NULL,
- NULL,
- NULL,
- NULL, /* chown */
- NULL,
- NULL, /* chdir */
- NULL, /* getwd */
- NULL, /* utime */
- NULL, /* ftruncate */
- NULL, /* lock */
- NULL, /* fget_nt_acl */
- NULL, /* get_nt_acl */
- NULL, /* fset_nt_acl */
- NULL, /* set_nt_acl */
- NULL,
- NULL
+ NULL, /* open */
+ NULL, /* close */
+ NULL, /* read */
+ NULL, /* write */
+ NULL, /* lseek */
+ NULL, /* rename */
+ NULL, /* fsync */
+ NULL, /* stat */
+ NULL, /* fstat */
+ NULL, /* lstat */
+ NULL, /* unlink */
+ NULL, /* chmod */
+ NULL, /* fchmod */
+ NULL, /* chown */
+ NULL, /* fchown */
+ NULL, /* chdir */
+ NULL, /* getwd */
+ NULL, /* utime */
+ NULL, /* ftruncate */
+ NULL, /* lock */
+ NULL, /* symlink */
+ NULL, /* readlink */
+ NULL, /* link */
+ NULL, /* mknod */
+ NULL, /* realpath */
+
+ /* NT ACL operations */
+
+ NULL, /* fget_nt_acl */
+ NULL, /* get_nt_acl */
+ NULL, /* fset_nt_acl */
+ NULL, /* set_nt_acl */
+
+ /* POSIX ACL operations. */
+
+ NULL, /* chmod_acl */
+ NULL, /* fchmod_acl */
+ NULL, /* sys_acl_get_entry */
+ NULL, /* sys_acl_get_tag_type */
+ NULL, /* sys_acl_get_permset */
+ NULL, /* sys_acl_get_qualifier */
+ NULL, /* sys_acl_get_file */
+ NULL, /* sys_acl_get_fd */
+ NULL, /* sys_acl_clear_perms */
+ NULL, /* sys_acl_add_perm */
+ NULL, /* sys_acl_to_text */
+ NULL, /* sys_acl_init */
+ NULL, /* sys_acl_create_entry */
+ NULL, /* sys_acl_set_tag_type */
+ NULL, /* sys_acl_set_qualifier */
+ NULL, /* sys_acl_set_permset */
+ NULL, /* sys_acl_valid */
+ NULL, /* sys_acl_set_file */
+ NULL, /* sys_acl_set_fd */
+ NULL, /* sys_acl_delete_def_file */
+ NULL, /* sys_acl_get_perm */
+ NULL, /* sys_acl_free_text */
+ NULL, /* sys_acl_free_acl */
+ NULL /* sys_acl_free_qualifier */
};
#ifndef PARAMCONF
-#define PARAMCONF "/etc/samba-block.conf"
+#define PARAMCONF "/etc/samba/samba-block.conf"
#endif
extern BOOL pm_process(char *FileName, BOOL (*sfunc)(char *), BOOL(*pfunc)(char * , char *));
@@ -117,7 +150,7 @@ BOOL get_section(char *sect);
BOOL get_parameter_value(char *param, char *value);
BOOL load_param(void);
BOOL search(struct stat *stat_buf);
-BOOL dir_search(char *link, char *dir);
+BOOL dir_search(char *link, const char *dir);
BOOL enter_pblock_dir(char *dir);
@@ -297,10 +330,20 @@ BOOL get_parameter_value(char *param, char *value)
/* VFS initialisation function. Return initialised vfs_ops structure
back to SAMBA. */
-struct vfs_ops *vfs_init(int *vfs_version)
+struct vfs_ops *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops)
{
+ struct vfs_ops tmp_ops;
+
*vfs_version = SMB_VFS_INTERFACE_VERSION;
+ memcpy(&tmp_ops, def_vfs_ops, sizeof(struct vfs_ops));
+
+ /* Override the ones we want. */
+ tmp_ops.connect = block_connect;
+ tmp_ops.disconnect = block_disconnect;
+ tmp_ops.opendir = block_opendir;
+
+ memcpy(&execute_vfs_ops, &tmp_ops, sizeof(struct vfs_ops));
return(&execute_vfs_ops);
}
@@ -309,7 +352,7 @@ struct vfs_ops *vfs_init(int *vfs_version)
* VFS connect and param file loading
*/
-int block_connect(struct connection_struct *conn, char *service, char *user)
+int block_connect(struct connection_struct *conn, const char *service, const char *user)
{
if((load_param()) == FALSE)
{
@@ -360,7 +403,7 @@ void block_disconnect(struct connection_struct *conn)
* VFS opendir
*/
-DIR *block_opendir(struct connection_struct *conn, char *fname)
+DIR *block_opendir(struct connection_struct *conn, const char *fname)
{
char *dir_name = NULL;
@@ -416,7 +459,7 @@ BOOL search(struct stat *stat_buf)
* Find dir in list to block id the starting point is link from a share
*/
-BOOL dir_search(char *link, char *dir)
+BOOL dir_search(char *link, const char *dir)
{
char buf[PATH_MAX +1], *ext_path;
int len = 0;
@@ -457,90 +500,3 @@ BOOL dir_search(char *link, char *dir)
return FALSE;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/VFS/skel.c b/examples/VFS/skel.c
index 65cb4bfe0d5..bb5486e690b 100644
--- a/examples/VFS/skel.c
+++ b/examples/VFS/skel.c
@@ -39,31 +39,19 @@
#include <vfs.h>
extern struct vfs_ops default_vfs_ops; /* For passthrough operation */
-struct vfs_ops skel_ops;
+extern struct vfs_ops skel_ops;
-
-
-/* VFS initialisation - return vfs_ops function pointer structure */
-
-BOOL vfs_init(connection_struct *conn)
-{
- DEBUG(3, ("Initialising default vfs hooks\n"));
-
- memcpy(&conn->vfs_ops, &skel_ops, sizeof(struct vfs_ops));
- return True;
-}
-
-int skel_connect(struct connection_struct *conn, char *service, char *user)
+static int skel_connect(struct connection_struct *conn, const char *service, const char *user)
{
return default_vfs_ops.connect(conn, service, user);
}
-void skel_disconnect(struct connection_struct *conn)
+static void skel_disconnect(struct connection_struct *conn)
{
default_vfs_ops.disconnect(conn);
}
-SMB_BIG_UINT skel_disk_free(struct connection_struct *conn, char *path,
+static SMB_BIG_UINT skel_disk_free(struct connection_struct *conn, const char *path,
BOOL small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
@@ -71,171 +59,383 @@ SMB_BIG_UINT skel_disk_free(struct connection_struct *conn, char *path,
dfree, dsize);
}
-DIR *skel_opendir(struct connection_struct *conn, char *fname)
+static DIR *skel_opendir(struct connection_struct *conn, const char *fname)
{
return default_vfs_ops.opendir(conn, fname);
}
-struct dirent *skel_readdir(struct connection_struct *conn, DIR *dirp)
+static struct dirent *skel_readdir(struct connection_struct *conn, DIR *dirp)
{
return default_vfs_ops.readdir(conn, dirp);
}
-int skel_mkdir(struct connection_struct *conn, char *path, mode_t mode)
+static int skel_mkdir(struct connection_struct *conn, const char *path, mode_t mode)
{
return default_vfs_ops.mkdir(conn, path, mode);
}
-int skel_rmdir(struct connection_struct *conn, char *path)
+static int skel_rmdir(struct connection_struct *conn, const char *path)
{
return default_vfs_ops.rmdir(conn, path);
}
-int skel_closedir(struct connection_struct *conn, DIR *dir)
+static int skel_closedir(struct connection_struct *conn, DIR *dir)
{
return default_vfs_ops.closedir(conn, dir);
}
-int skel_open(struct connection_struct *conn, char *fname, int flags, mode_t mode)
+static int skel_open(struct connection_struct *conn, const char *fname, int flags, mode_t mode)
{
return default_vfs_ops.open(conn, fname, flags, mode);
}
-int skel_close(struct files_struct *fsp, int fd)
+static int skel_close(struct files_struct *fsp, int fd)
{
return default_vfs_ops.close(fsp, fd);
}
-ssize_t skel_read(struct files_struct *fsp, int fd, char *data, size_t n)
+static ssize_t skel_read(struct files_struct *fsp, int fd, void *data, size_t n)
{
return default_vfs_ops.read(fsp, fd, data, n);
}
-ssize_t skel_write(struct files_struct *fsp, int fd, char *data, size_t n)
+static ssize_t skel_write(struct files_struct *fsp, int fd, const void *data, size_t n)
{
return default_vfs_ops.write(fsp, fd, data, n);
}
-SMB_OFF_T skel_lseek(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
+static SMB_OFF_T skel_lseek(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
{
return default_vfs_ops.lseek(fsp, filedes, offset, whence);
}
-int skel_rename(struct connection_struct *conn, char *old, char *new)
+static int skel_rename(struct connection_struct *conn, const char *old, const char *new)
{
return default_vfs_ops.rename(conn, old, new);
}
-int skel_fsync(struct files_struct *fsp, int fd)
+static int skel_fsync(struct files_struct *fsp, int fd)
{
return default_vfs_ops.fsync(fsp, fd);
}
-int skel_stat(struct connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf)
+static int skel_stat(struct connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf)
{
return default_vfs_ops.stat(conn, fname, sbuf);
}
-int skel_fstat(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
+static int skel_fstat(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
{
return default_vfs_ops.fstat(fsp, fd, sbuf);
}
-int skel_lstat(struct connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf)
+static int skel_lstat(struct connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf)
{
return default_vfs_ops.lstat(conn, path, sbuf);
}
-int skel_unlink(struct connection_struct *conn, char *path)
+static int skel_unlink(struct connection_struct *conn, const char *path)
{
return default_vfs_ops.unlink(conn, path);
}
-int skel_chmod(struct connection_struct *conn, char *path, mode_t mode)
+static int skel_chmod(struct connection_struct *conn, const char *path, mode_t mode)
{
return default_vfs_ops.chmod(conn, path, mode);
}
-int skel_fchmod(struct files_struct *fsp, int fd, mode_t mode)
+static int skel_fchmod(struct files_struct *fsp, int fd, mode_t mode)
{
return default_vfs_ops.fchmod(fsp, fd, mode);
}
-int skel_chown(struct connection_struct *conn, char *path, uid_t uid, gid_t gid)
+static int skel_chown(struct connection_struct *conn, const char *path, uid_t uid, gid_t gid)
{
return default_vfs_ops.chown(conn, path, uid, gid);
}
-int skel_fchown(struct files_struct *fsp, int fd, uid_t uid, gid_t gid)
+static int skel_fchown(struct files_struct *fsp, int fd, uid_t uid, gid_t gid)
{
return default_vfs_ops.fchown(fsp, fd, uid, gid);
}
-int skel_chdir(struct connection_struct *conn, char *path)
+static int skel_chdir(struct connection_struct *conn, const char *path)
{
return default_vfs_ops.chdir(conn, path);
}
-char *skel_getwd(struct connection_struct *conn, char *buf)
+static char *skel_getwd(struct connection_struct *conn, char *buf)
{
return default_vfs_ops.getwd(conn, buf);
}
-int skel_utime(struct connection_struct *conn, char *path, struct utimbuf *times)
+static int skel_utime(struct connection_struct *conn, const char *path, struct utimbuf *times)
{
return default_vfs_ops.utime(conn, path, times);
}
-int skel_ftruncate(struct files_struct *fsp, int fd, SMB_OFF_T offset)
+static int skel_ftruncate(struct files_struct *fsp, int fd, SMB_OFF_T offset)
{
return default_vfs_ops.ftruncate(fsp, fd, offset);
}
-BOOL skel_lock(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
+static BOOL skel_lock(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
return default_vfs_ops.lock(fsp, fd, op, offset, count, type);
}
-BOOL skel_symlink(struct connection_struct *conn, const char *oldpath, const char *newpath)
+static BOOL skel_symlink(struct connection_struct *conn, const char *oldpath, const char *newpath)
{
return default_vfs_ops.symlink(conn, oldpath, newpath);
}
-BOOL skel_readlink(struct connection_struct *conn, const char *path, char *buf, size_t bufsiz)
+static BOOL skel_readlink(struct connection_struct *conn, const char *path, char *buf, size_t bufsiz)
{
return default_vfs_ops.readlink(conn, path, buf, bufsiz);
}
-size_t skel_fget_nt_acl(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc)
+static int skel_link(struct connection_struct *conn, const char *oldpath, const char *newpath)
+{
+ return default_vfs_ops.link(conn, oldpath, newpath);
+}
+
+static int skel_mknod(struct connection_struct *conn, const char *path, mode_t mode, SMB_DEV_T dev)
+{
+ return default_vfs_ops.mknod(conn, path, mode, dev);
+}
+
+static char *skel_realpath(struct connection_struct *conn, const char *path, char *resolved_path)
+{
+ return default_vfs_ops.realpath(conn, path, resolved_path);
+}
+
+static size_t skel_fget_nt_acl(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc)
{
return default_vfs_ops.fget_nt_acl(fsp, fd, ppdesc);
}
-size_t skel_get_nt_acl(struct files_struct *fsp, char *name, struct security_descriptor_info **ppdesc)
+static size_t skel_get_nt_acl(struct files_struct *fsp, const char *name, struct security_descriptor_info **ppdesc)
{
return default_vfs_ops.get_nt_acl(fsp, name, ppdesc);
}
-BOOL skel_fset_nt_acl(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd)
+static BOOL skel_fset_nt_acl(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd)
{
return default_vfs_ops.fset_nt_acl(fsp, fd, security_info_sent, psd);
}
-BOOL skel_set_nt_acl(struct files_struct *fsp, char *name, uint32 security_info_sent, struct security_descriptor_info *psd)
+static BOOL skel_set_nt_acl(struct files_struct *fsp, const char *name, uint32 security_info_sent, struct security_descriptor_info *psd)
{
return default_vfs_ops.set_nt_acl(fsp, name, security_info_sent, psd);
}
-BOOL skel_chmod_acl(struct connection_struct *conn, char *name, mode_t mode)
+static BOOL skel_chmod_acl(struct connection_struct *conn, const char *name, mode_t mode)
{
return default_vfs_ops.chmod_acl(conn, name, mode);
}
-BOOL skel_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode)
+static BOOL skel_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode)
{
return default_vfs_ops.fchmod_acl(fsp, fd, mode);
}
+static int skel_sys_acl_get_entry(struct connection_struct *conn, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
+{
+ return default_vfs_ops.sys_acl_get_entry(conn, theacl, entry_id, entry_p);
+}
+
+static int skel_sys_acl_get_tag_type(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p)
+{
+ return default_vfs_ops.sys_acl_get_tag_type(conn, entry_d, tag_type_p);
+}
+
+static int skel_sys_acl_get_permset(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p)
+{
+ return default_vfs_ops.sys_acl_get_permset(conn, entry_d, permset_p);
+}
+
+static void *skel_sys_acl_get_qualifier(struct connection_struct *conn, SMB_ACL_ENTRY_T entry_d)
+{
+ return default_vfs_ops.sys_acl_get_qualifier(conn, entry_d);
+}
+
+static SMB_ACL_T skel_sys_acl_get_file(struct connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type)
+{
+ return default_vfs_ops.sys_acl_get_file(conn, path_p, type);
+}
+
+static SMB_ACL_T skel_sys_acl_get_fd(struct files_struct *fsp, int fd)
+{
+ return default_vfs_ops.sys_acl_get_fd(fsp, fd);
+}
+
+static int skel_sys_acl_clear_perms(struct connection_struct *conn, SMB_ACL_PERMSET_T permset)
+{
+ return default_vfs_ops.sys_acl_clear_perms(conn, permset);
+}
+
+static int skel_sys_acl_add_perm(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
+{
+ return default_vfs_ops.sys_acl_add_perm(conn, permset, perm);
+}
+
+static char *skel_sys_acl_to_text(struct connection_struct *conn, SMB_ACL_T theacl, ssize_t *plen)
+{
+ return default_vfs_ops.sys_acl_to_text(conn, theacl, plen);
+}
+
+static SMB_ACL_T skel_sys_acl_init(struct connection_struct *conn, int count)
+{
+ return default_vfs_ops.sys_acl_init(conn, count);
+}
+
+static int skel_sys_acl_create_entry(struct connection_struct *conn, SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry)
+{
+ return default_vfs_ops.sys_acl_create_entry(conn, pacl, pentry);
+}
+
+static int skel_sys_acl_set_tag_type(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype)
+{
+ return default_vfs_ops.sys_acl_set_tag_type(conn, entry, tagtype);
+}
+
+static int skel_sys_acl_set_qualifier(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, void *qual)
+{
+ return default_vfs_ops.sys_acl_set_qualifier(conn, entry, qual);
+}
+
+static int skel_sys_acl_set_permset(struct connection_struct *conn, SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset)
+{
+ return default_vfs_ops.sys_acl_set_permset(conn, entry, permset);
+}
+
+static int skel_sys_acl_valid(struct connection_struct *conn, SMB_ACL_T theacl )
+{
+ return default_vfs_ops.sys_acl_valid(conn, theacl );
+}
+
+static int skel_sys_acl_set_file(struct connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
+{
+ return default_vfs_ops.sys_acl_set_file(conn, name, acltype, theacl);
+}
+
+static int skel_sys_acl_set_fd(struct files_struct *fsp, int fd, SMB_ACL_T theacl)
+{
+ return default_vfs_ops.sys_acl_set_fd(fsp, fd, theacl);
+}
+
+static int skel_sys_acl_delete_def_file(struct connection_struct *conn, const char *path)
+{
+ return default_vfs_ops.sys_acl_delete_def_file(conn, path);
+}
+
+static int skel_sys_acl_get_perm(struct connection_struct *conn, SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm)
+{
+ return default_vfs_ops.sys_acl_get_perm(conn, permset, perm);
+}
+
+static int skel_sys_acl_free_text(struct connection_struct *conn, char *text)
+{
+ return default_vfs_ops.sys_acl_free_text(conn, text);
+}
+
+static int skel_sys_acl_free_acl(struct connection_struct *conn, SMB_ACL_T posix_acl)
+{
+ return default_vfs_ops.sys_acl_free_acl(conn, posix_acl);
+}
+
+static int skel_sys_acl_free_qualifier(struct connection_struct *conn, void *qualifier, SMB_ACL_TAG_T tagtype)
+{
+ return default_vfs_ops.sys_acl_free_qualifier(conn, qualifier, tagtype);
+}
+
+/* VFS initialisation - return vfs_ops function pointer structure */
+
+struct vfs_ops *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops)
+{
+ struct vfs_ops tmp_ops;
+
+ DEBUG(3, ("Initialising default vfs hooks\n"));
+
+ *vfs_version = SMB_VFS_INTERFACE_VERSION;
+ memcpy(&tmp_ops, def_vfs_ops, sizeof(struct vfs_ops));
+
+ tmp_ops.connect = skel_connect;
+ tmp_ops.disconnect = skel_disconnect;
+ tmp_ops.disk_free = skel_disk_free;
+
+ /* Directory operations */
+
+ tmp_ops.opendir = skel_opendir;
+ tmp_ops.readdir = skel_readdir;
+ tmp_ops.mkdir = skel_mkdir;
+ tmp_ops.rmdir = skel_rmdir;
+ tmp_ops.closedir = skel_closedir;
+
+ /* File operations */
+
+ tmp_ops.open = skel_open;
+ tmp_ops.close = skel_close;
+ tmp_ops.read = skel_read;
+ tmp_ops.write = skel_write;
+ tmp_ops.lseek = skel_lseek;
+ tmp_ops.rename = skel_rename;
+ tmp_ops.fsync = skel_fsync;
+ tmp_ops.stat = skel_stat;
+ tmp_ops.fstat = skel_fstat;
+ tmp_ops.lstat = skel_lstat;
+ tmp_ops.unlink = skel_unlink;
+ tmp_ops.chmod = skel_chmod;
+ tmp_ops.fchmod = skel_fchmod;
+ tmp_ops.chown = skel_chown;
+ tmp_ops.fchown = skel_fchown;
+ tmp_ops.chdir = skel_chdir;
+ tmp_ops.getwd = skel_getwd;
+ tmp_ops.utime = skel_utime;
+ tmp_ops.ftruncate = skel_ftruncate;
+ tmp_ops.lock = skel_lock;
+ tmp_ops.symlink = skel_symlink;
+ tmp_ops.readlink = skel_readlink;
+ tmp_ops.link = skel_link;
+ tmp_ops.mknod = skel_mknod;
+ tmp_ops.realpath = skel_realpath;
+
+ tmp_ops.fget_nt_acl = skel_fget_nt_acl;
+ tmp_ops.get_nt_acl = skel_get_nt_acl;
+ tmp_ops.fset_nt_acl = skel_fset_nt_acl;
+ tmp_ops.set_nt_acl = skel_set_nt_acl;
+
+ /* POSIX ACL operations. */
+
+ tmp_ops.chmod_acl = skel_chmod_acl;
+ tmp_ops.fchmod_acl = skel_fchmod_acl;
+ tmp_ops.sys_acl_get_entry = skel_sys_acl_get_entry;
+ tmp_ops.sys_acl_get_tag_type = skel_sys_acl_get_tag_type;
+ tmp_ops.sys_acl_get_permset = skel_sys_acl_get_permset;
+ tmp_ops.sys_acl_get_qualifier = skel_sys_acl_get_qualifier;
+ tmp_ops.sys_acl_get_file = skel_sys_acl_get_file;
+ tmp_ops.sys_acl_get_fd = skel_sys_acl_get_fd;
+ tmp_ops.sys_acl_clear_perms = skel_sys_acl_clear_perms;
+ tmp_ops.sys_acl_add_perm = skel_sys_acl_add_perm;
+ tmp_ops.sys_acl_to_text = skel_sys_acl_to_text;
+ tmp_ops.sys_acl_init = skel_sys_acl_init;
+ tmp_ops.sys_acl_create_entry = skel_sys_acl_create_entry;
+ tmp_ops.sys_acl_set_tag_type = skel_sys_acl_set_tag_type;
+ tmp_ops.sys_acl_set_qualifier = skel_sys_acl_set_qualifier;
+ tmp_ops.sys_acl_set_permset = skel_sys_acl_set_permset;
+ tmp_ops.sys_acl_valid = skel_sys_acl_valid;
+ tmp_ops.sys_acl_set_file = skel_sys_acl_set_file;
+ tmp_ops.sys_acl_set_fd = skel_sys_acl_set_fd;
+ tmp_ops.sys_acl_delete_def_file = skel_sys_acl_delete_def_file;
+ tmp_ops.sys_acl_get_perm = skel_sys_acl_get_perm;
+ tmp_ops.sys_acl_free_text = skel_sys_acl_free_text;
+ tmp_ops.sys_acl_free_acl = skel_sys_acl_free_acl;
+ tmp_ops.sys_acl_free_qualifier = skel_sys_acl_free_qualifier;
+
+ memcpy(&skel_ops, &tmp_ops, sizeof(struct vfs_ops));
+
+ return &skel_ops;
+}
/* VFS operations structure */
@@ -270,23 +470,51 @@ struct vfs_ops skel_ops = {
skel_unlink,
skel_chmod,
skel_fchmod,
- skel_chown,
- skel_fchown,
- skel_chdir,
- skel_getwd,
+ skel_chown,
+ skel_fchown,
+ skel_chdir,
+ skel_getwd,
skel_utime,
skel_ftruncate,
skel_lock,
skel_symlink,
skel_readlink,
+ skel_link,
+ skel_mknod,
+ skel_realpath,
/* NT File ACL operations */
- skel_fget_nt_acl,
- skel_get_nt_acl,
- skel_fset_nt_acl,
- skel_set_nt_acl,
+ skel_fget_nt_acl,
+ skel_get_nt_acl,
+ skel_fset_nt_acl,
+ skel_set_nt_acl,
+
+ /* POSIX ACL operations */
skel_chmod_acl,
- skel_fchmod_acl
+ skel_fchmod_acl,
+
+ skel_sys_acl_get_entry,
+ skel_sys_acl_get_tag_type,
+ skel_sys_acl_get_permset,
+ skel_sys_acl_get_qualifier,
+ skel_sys_acl_get_file,
+ skel_sys_acl_get_fd,
+ skel_sys_acl_clear_perms,
+ skel_sys_acl_add_perm,
+ skel_sys_acl_to_text,
+ skel_sys_acl_init,
+ skel_sys_acl_create_entry,
+ skel_sys_acl_set_tag_type,
+ skel_sys_acl_set_qualifier,
+ skel_sys_acl_set_permset,
+ skel_sys_acl_valid,
+ skel_sys_acl_set_file,
+ skel_sys_acl_set_fd,
+ skel_sys_acl_delete_def_file,
+ skel_sys_acl_get_perm,
+ skel_sys_acl_free_text,
+ skel_sys_acl_free_acl,
+ skel_sys_acl_free_qualifier
};
diff --git a/examples/printing/smbprint b/examples/printing/smbprint
index 5a00a2a8aa8..68bd66a13fe 100755
--- a/examples/printing/smbprint
+++ b/examples/printing/smbprint
@@ -25,6 +25,11 @@
#
# -t now causes translate to be used when sending files
#
+# Further modifications by Alfred Perlstein to fix some problems and
+# improve the quality of the code (3-Dec-2001).
+#
+# More hacking by Richard Sharpe to improve portability. 9-Dec-2001.
+#
# In order for this to work the /etc/printcap entry must include an
# accounting file (af=...):
#
@@ -46,12 +51,10 @@
# service=CJET_371
# password=""
-#
-# Debugging log file, change to /dev/null if you like.
-#
-logfile=/tmp/smb-print.log
-# logfile=/dev/null
+#smbclient=/usr/pkg/bin/smbclient
+# Assume that smbclient will be in the same place as smbprint
+smbclient="`dirname $0`/smbclient"
#
# The last parameter to the filter is the accounting file name.
@@ -67,29 +70,76 @@ config_file=$spool_dir/.config
# server
# service
# password
-eval `cat $config_file`
+# username (optional)
+# IP (optional)
+# debug (optional)
+# debugsmb (optional)
+# debugfile (optional)
+. $config_file
+
+if [ "x$password" = "x" ] ; then
+ password="-N"
+fi
-while getopts t c; do
- case $c in
- t)
- TRANS=1
- ;;
+if [ "x$username" == "x" ] ; then
+ username="$server";
+fi
- '?') # Bad parameters, ignore it ...
- ;;
- esac
+while test $# -gt 0; do
+ case "$1" in
+ -t)
+ TRANS=1
+ ;;
+
+ *) # Bad Parameters, ignore them ...
+ ;;
+ esac
+ shift
done
+
+command="print - ;"
+if [ $TRANS -eq 1 ]; then
+ command="translate;$command";
+fi
+
+debugfile="/tmp/smb-print.log"
+if [ "x$debug" = "x" ] ; then
+ debugfile=/dev/null debugargs=
+else
+ if [ $debug -eq 0 ] ; then
+ debugfile=/dev/null debugargs=
+ else
+ set -x; exec >>$debugfile 2>&1
+ debugargs="$debugfile."
+ #[ "x$debugsmb" == "x" ] || debugargs="$debugargs -d $debugsmb"
+ fi
+fi
+
+if [ "x$smbconf" != "x" ]; then
+
+ smbconf="-s $smbconf"
+
+fi
+
+if [ "x$IP" != "x" ]; then
+
+ IP="-I $IP"
+
+fi
+
+if [ "x$debugargs" != "x" ]; then
+
+ debugargs="-l $debugargs"
+
+fi
+
+$smbclient \
+ "\\\\$server\\$service" \
+ $password \
+ $smbconf \
+ $IP \
+ $debugargs \
+ -U $username \
+ -P \
+ -c "$command"
#
-# Some debugging help, change the >> to > if you want to same space.
-#
-echo "server $server, service $service" >> $logfile
-
-(
-# NOTE You may wish to add the line `echo translate' if you want automatic
-# CR/LF translation when printing.
- if [ $TRANS -eq 1 ]; then
- echo translate
- fi
- echo "print -"
- cat
-) | /usr/local/samba/bin/smbclient "\\\\$server\\$service" $password -U $server -N -P >> $logfile