summaryrefslogtreecommitdiff
path: root/source4/lib/samba3
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/samba3')
-rw-r--r--source4/lib/samba3/config.mk3
-rw-r--r--source4/lib/samba3/ldb_samba3.c60
-rw-r--r--source4/lib/samba3/samba3.c69
-rw-r--r--source4/lib/samba3/samba3.h16
-rw-r--r--source4/lib/samba3/share_info.c85
5 files changed, 231 insertions, 2 deletions
diff --git a/source4/lib/samba3/config.mk b/source4/lib/samba3/config.mk
index b5bf3fadb9..79142e4f67 100644
--- a/source4/lib/samba3/config.mk
+++ b/source4/lib/samba3/config.mk
@@ -11,7 +11,8 @@ ADD_OBJ_FILES = \
lib/samba3/group.o \
lib/samba3/registry.o \
lib/samba3/secrets.o \
- lib/samba3/ldb_samba3.o
+ lib/samba3/ldb_samba3.o \
+ lib/samba3/share_info.o
# End SUBSYSTEM LIBSAMBA3
################################################
diff --git a/source4/lib/samba3/ldb_samba3.c b/source4/lib/samba3/ldb_samba3.c
index fa13daa611..030b051938 100644
--- a/source4/lib/samba3/ldb_samba3.c
+++ b/source4/lib/samba3/ldb_samba3.c
@@ -34,9 +34,67 @@
* sambaGroupType -> groupType
* displayName -> name
* description -> description
- * sambaSIDList -> member
+ * sambaSIDList -> member (special!)
*/
+/*
+ * sambaTrustPassword
+ */
+
+/* sambaDomain
+ * sambaDomainName
+ * sambaSID
+ * sambaNextRid
+ * sambaNextGroupRid
+ * sambaNextUserRid
+ * sambaAlgorithmicRidBase
+ */
+
+/* sambaUnixIdPool
+ */
+
+/* sambaIdmapEntry */
+
+/* sambaAccountPolicy */
+
+/* sambaSidEntry: FIXME */
+
+/* sambaSamAccount -> user:
+ * uid -> unixName (magic!)
+ * sambaSID -> objectSid
+ * cn -> cn
+ * sambaLMPassword -> lmPwdHash
+ * sambaNTPassword -> ntPwdHash
+ * sambaPwdLastSet -> pwdLastSet
+ * sambaLogonTime -> lastLogon
+ * sambaLogoffTime -> lastLogoff
+ * sambaKickoffTime -> ???
+ * sambaPwdCanChange -> ???
+ * sambaPwdMustChange -> ???
+ * sambaAcctFlags -> systemFlags ?
+ * displayName -> name
+ * sambaHomePath -> ???
+ * sambaHomeDrive -> ???
+ * sambaLogonScript -> ???
+ * sambaProfilePath -> ???
+ * description -> description
+ * sambaUserWorkstations -> ???
+ * sambaPrimaryGroupSID -> primaryGroupID
+ * sambaDomainName -> ???
+ * sambaMungedDial -> ???
+ * sambaBadPasswordCount -> badPwdcount
+ * sambaBadPasswordTime -> badPasswordtime
+ * sambaPasswordHistory -> ntPwdHistory
+ * sambaLogonHours -> ???
+ */
+
+/* Not necessary:
+ * sambaConfig
+ * sambaShare
+ * sambaConfigOption
+ */
+
+
struct ldb_map_mappings samba3_mappings;
/* the init function */
diff --git a/source4/lib/samba3/samba3.c b/source4/lib/samba3/samba3.c
index bfd41d6554..4eda3bd154 100644
--- a/source4/lib/samba3/samba3.c
+++ b/source4/lib/samba3/samba3.c
@@ -20,6 +20,71 @@
#include "includes.h"
#include "lib/samba3/samba3.h"
+struct smbconf_data {
+ TALLOC_CTX *ctx;
+ struct samba3 *db;
+ struct samba3_share_info *current_share;
+};
+
+struct samba3_share_info *samba3_find_share(struct samba3 *db, TALLOC_CTX* ctx, const char *name)
+{
+ int i;
+ for (i = 0; i < db->share_count; i++) {
+ if (!StrCaseCmp(db->shares[i].name, name))
+ return &db->shares[i];
+ }
+
+ db->shares = talloc_realloc(ctx, db->shares, struct samba3_share_info, db->share_count+1);
+ ZERO_STRUCT(db->shares[i]);
+ db->shares[i].name = talloc_strdup(ctx, name);
+ db->share_count++;
+
+ return &db->shares[i];
+}
+
+static BOOL samba3_sfunc (const char *name, void *_db)
+{
+ struct smbconf_data *privdat = _db;
+
+ privdat->current_share = samba3_find_share(privdat->db, privdat->ctx, name);
+
+ return True;
+}
+
+static BOOL samba3_pfunc (const char *name, const char *value, void *_db)
+{
+ struct smbconf_data *privdat = _db;
+ struct samba3_parameter *p;
+
+ privdat->current_share->parameters =
+ talloc_realloc(privdat->ctx, privdat->current_share->parameters,
+ struct samba3_parameter,
+ privdat->current_share->parameter_count+1);
+
+ p = &privdat->current_share->parameters[privdat->current_share->parameter_count];
+ p->name = talloc_strdup(privdat->ctx, name);
+ p->value = talloc_strdup(privdat->ctx, value);
+
+ privdat->current_share->parameter_count++;
+
+ return True;
+}
+
+NTSTATUS samba3_read_smbconf(const char *fn, TALLOC_CTX *ctx, struct samba3 *db)
+{
+ struct smbconf_data privdat;
+
+ privdat.ctx = ctx;
+ privdat.db = db;
+ privdat.current_share = samba3_find_share(db, ctx, "global");
+
+ if (!pm_process( fn, samba3_sfunc, samba3_pfunc, &privdat )) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ return NT_STATUS_OK;
+}
+
struct samba3 *samba3_read(const char *libdir, TALLOC_CTX *ctx)
{
struct samba3 *ret;
@@ -55,5 +120,9 @@ struct samba3 *samba3_read(const char *libdir, TALLOC_CTX *ctx)
samba3_read_secrets(dbfile, ctx, &ret->secrets);
SAFE_FREE(dbfile);
+ asprintf(&dbfile, "%s/share_info.tdb", libdir);
+ samba3_read_share_info(dbfile, ctx, ret);
+ SAFE_FREE(dbfile);
+
return ret;
}
diff --git a/source4/lib/samba3/samba3.h b/source4/lib/samba3/samba3.h
index 575ee83825..fe4db560a8 100644
--- a/source4/lib/samba3/samba3.h
+++ b/source4/lib/samba3/samba3.h
@@ -184,6 +184,19 @@ struct samba3_secrets
} *afs_keyfiles;
};
+struct samba3_parameter {
+ char *name;
+ char *value;
+};
+
+struct samba3_share_info {
+ char *name;
+ struct security_descriptor secdesc;
+
+ uint32_t parameter_count;
+ struct samba3_parameter *parameters;
+};
+
struct samba3
{
uint32_t winsdb_count;
@@ -192,6 +205,9 @@ struct samba3
uint32_t samaccount_count;
struct samba3_samaccount *samaccounts;
+ uint32_t share_count;
+ struct samba3_share_info *shares;
+
struct samba3_secrets secrets;
struct samba3_groupdb group;
struct samba3_idmapdb idmap;
diff --git a/source4/lib/samba3/share_info.c b/source4/lib/samba3/share_info.c
new file mode 100644
index 0000000000..098d6c552e
--- /dev/null
+++ b/source4/lib/samba3/share_info.c
@@ -0,0 +1,85 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Share Info parsing
+ * Copyright (C) Andrew Tridgell 1992-1997,
+ * Copyright (C) Jeremy Allison 2001.
+ * Copyright (C) Nigel Williams 2001.
+ * Copyright (C) Jelmer Vernooij 2005.
+ *
+ * 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 "librpc/gen_ndr/ndr_security.h"
+#include "lib/tdb/include/tdbutil.h"
+#include "lib/samba3/samba3.h"
+#include "system/filesys.h"
+
+#define SHARE_DATABASE_VERSION_V1 1
+#define SHARE_DATABASE_VERSION_V2 2 /* version id in little endian. */
+
+NTSTATUS samba3_read_share_info(const char *fn, TALLOC_CTX *ctx, struct samba3 *db)
+{
+ int32_t vers_id;
+ TDB_CONTEXT *tdb;
+ TDB_DATA kbuf, vbuf;
+ DATA_BLOB blob;
+
+ tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600);
+ if (!tdb) {
+ DEBUG(0,("Failed to open share info database %s (%s)\n",
+ fn, strerror(errno) ));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* Cope with byte-reversed older versions of the db. */
+ vers_id = tdb_fetch_int32(tdb, "INFO/version");
+ if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) {
+ /* Written on a bigendian machine with old fetch_int code. Save as le. */
+ vers_id = SHARE_DATABASE_VERSION_V2;
+ }
+
+ if (vers_id != SHARE_DATABASE_VERSION_V2) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ for (kbuf = tdb_firstkey(tdb); kbuf.dptr; kbuf = tdb_nextkey(tdb, kbuf))
+ {
+ struct ndr_pull *pull;
+ struct samba3_share_info *share;
+ char *name;
+
+ if (strncmp(kbuf.dptr, "SECDESC/", strlen("SECDESC/")) != 0)
+ continue;
+
+ name = talloc_strndup(ctx, kbuf.dptr+strlen("SECDESC/"), kbuf.dsize-strlen("SECDESC/"));
+
+ share = samba3_find_share(db, ctx, name);
+
+ vbuf = tdb_fetch(tdb, kbuf);
+ blob.data = (uint8_t *)vbuf.dptr;
+ blob.length = vbuf.dsize;
+
+ pull = ndr_pull_init_blob(&blob, ctx);
+
+ ndr_pull_security_descriptor(pull, NDR_SCALARS|NDR_BUFFERS, &share->secdesc);
+
+ talloc_free(pull);
+ }
+
+ tdb_close(tdb);
+
+ return NT_STATUS_OK;
+}