summaryrefslogtreecommitdiff
path: root/source3/lib/smbconf
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-10-23 11:16:50 +0200
committerMichael Adam <obnox@samba.org>2008-10-27 13:02:40 +0100
commit3a06201086e77b1c6bd8cf9374f02e5f667aa86c (patch)
treedbbf64c4948a51bba221e03f0ea5972a3bc8684c /source3/lib/smbconf
parent9c09d545bfae9e4abde317364b1586b691ba4d89 (diff)
downloadsamba-3a06201086e77b1c6bd8cf9374f02e5f667aa86c.tar.gz
samba-3a06201086e77b1c6bd8cf9374f02e5f667aa86c.tar.bz2
samba-3a06201086e77b1c6bd8cf9374f02e5f667aa86c.zip
[s3]libsmbconf: add method is_writeable() and wrapper smbconf_is_writeable()
This allows for per-config-source checking of write support. Michael
Diffstat (limited to 'source3/lib/smbconf')
-rw-r--r--source3/lib/smbconf/smbconf.c8
-rw-r--r--source3/lib/smbconf/smbconf.h1
-rw-r--r--source3/lib/smbconf/smbconf_private.h1
-rw-r--r--source3/lib/smbconf/smbconf_reg.c12
-rw-r--r--source3/lib/smbconf/smbconf_txt.c7
5 files changed, 29 insertions, 0 deletions
diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c
index f0188380a0..e5a865a62b 100644
--- a/source3/lib/smbconf/smbconf.c
+++ b/source3/lib/smbconf/smbconf.c
@@ -52,6 +52,14 @@ bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx)
}
/**
+ * Tell whether the source is writeable.
+ */
+bool smbconf_is_writeable(struct smbconf_ctx *ctx)
+{
+ return ctx->ops->is_writeable(ctx);
+}
+
+/**
* Close the configuration.
*/
void smbconf_shutdown(struct smbconf_ctx *ctx)
diff --git a/source3/lib/smbconf/smbconf.h b/source3/lib/smbconf/smbconf.h
index 3f3435ea00..9ff9a83fad 100644
--- a/source3/lib/smbconf/smbconf.h
+++ b/source3/lib/smbconf/smbconf.h
@@ -57,6 +57,7 @@ WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
* the smbconf API functions
*/
bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
+bool smbconf_is_writeable(struct smbconf_ctx *ctx);
void smbconf_shutdown(struct smbconf_ctx *ctx);
bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
const char *service, const char *param);
diff --git a/source3/lib/smbconf/smbconf_private.h b/source3/lib/smbconf/smbconf_private.h
index a47d81fa25..b0333e981a 100644
--- a/source3/lib/smbconf/smbconf_private.h
+++ b/source3/lib/smbconf/smbconf_private.h
@@ -24,6 +24,7 @@ struct smbconf_ops {
WERROR (*init)(struct smbconf_ctx *ctx, const char *path);
int (*shutdown)(struct smbconf_ctx *ctx);
bool (*requires_messaging)(struct smbconf_ctx *ctx);
+ bool (*is_writeable)(struct smbconf_ctx *ctx);
WERROR (*open_conf)(struct smbconf_ctx *ctx);
int (*close_conf)(struct smbconf_ctx *ctx);
void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index 6edb9ed22e..c5092895bb 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -652,6 +652,17 @@ static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx)
return false;
}
+static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx)
+{
+ /*
+ * The backend has write support.
+ *
+ * TODO: add access checks whether the concrete
+ * config source is really writeable by the calling user.
+ */
+ return true;
+}
+
static WERROR smbconf_reg_open(struct smbconf_ctx *ctx)
{
WERROR werr;
@@ -1130,6 +1141,7 @@ struct smbconf_ops smbconf_ops_reg = {
.init = smbconf_reg_init,
.shutdown = smbconf_reg_shutdown,
.requires_messaging = smbconf_reg_requires_messaging,
+ .is_writeable = smbconf_reg_is_writeable,
.open_conf = smbconf_reg_open,
.close_conf = smbconf_reg_close,
.get_csn = smbconf_reg_get_csn,
diff --git a/source3/lib/smbconf/smbconf_txt.c b/source3/lib/smbconf/smbconf_txt.c
index d932705e7d..70d5f82bf0 100644
--- a/source3/lib/smbconf/smbconf_txt.c
+++ b/source3/lib/smbconf/smbconf_txt.c
@@ -248,6 +248,12 @@ static bool smbconf_txt_requires_messaging(struct smbconf_ctx *ctx)
return false;
}
+static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx)
+{
+ /* no write support in this backend yet... */
+ return false;
+}
+
static WERROR smbconf_txt_open(struct smbconf_ctx *ctx)
{
return smbconf_txt_load_file(ctx);
@@ -610,6 +616,7 @@ static struct smbconf_ops smbconf_ops_txt = {
.init = smbconf_txt_init,
.shutdown = smbconf_txt_shutdown,
.requires_messaging = smbconf_txt_requires_messaging,
+ .is_writeable = smbconf_txt_is_writeable,
.open_conf = smbconf_txt_open,
.close_conf = smbconf_txt_close,
.get_csn = smbconf_txt_get_csn,