You can subscribe to this list here.
| 2006 |
Jan
|
Feb
(12) |
Mar
(41) |
Apr
|
May
|
Jun
(3) |
Jul
(2) |
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2008 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(33) |
Jul
(18) |
Aug
(20) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(12) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <co...@us...> - 2008-07-30 11:49:10
|
Revision: 136
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=136&view=rev
Author: collen
Date: 2008-07-30 11:49:18 +0000 (Wed, 30 Jul 2008)
Log Message:
-----------
Test Branch for implementations
Added Paths:
-----------
branches/pdbsql_32-test/pdbsql_3_2/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-07-30 11:45:42
|
Revision: 135
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=135&view=rev
Author: collen
Date: 2008-07-30 11:45:50 +0000 (Wed, 30 Jul 2008)
Log Message:
-----------
Test Branch for implementations
Added Paths:
-----------
branches/pdbsql_32-test/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Jelmer V. <je...@sa...> - 2008-07-19 09:30:52
|
Am Freitag, den 18.07.2008, 19:32 +0000 schrieb he...@us...: > Modified: branches/pdbsql_3_2/debian/rules > =================================================================== > --- branches/pdbsql_3_2/debian/rules 2008-07-12 12:49:32 UTC (rev 131) > +++ branches/pdbsql_3_2/debian/rules 2008-07-18 19:32:05 UTC (rev 132) > @@ -25,7 +25,7 @@ > $(MAKE) install DESTDIR=`pwd`/debian/tmp LIBDIR=/usr/lib/samba > dh_install --sourcedir=`pwd`/debian/tmp > dh_installdocs -p samba-pdb-pgsql AUTHORS docs/README > - dh_installdocs -p samba-pdb-mysql docs/pdb_mysql.html AUTHORS docs/README > + dh_installdocs -p samba-pdb-mysql docs/pdb_mysql.xml AUTHORS docs/README > dh_installdocs -p samba-pdb-multi AUTHORS docs/README > dh_installchangelogs -a > dh_installexamples -p samba-pdb-mysql docs/smb.conf.mysql docs/mysql.dump The xml file is not directly usable. It really is the HTML file that should be installed. Cheers, Jelmer -- Jelmer Vernooij <je...@sa...> - http://samba.org/~jelmer/ Jabber: je...@ja... |
|
From: <he...@us...> - 2008-07-18 20:19:11
|
Revision: 134
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=134&view=rev
Author: herwinw
Date: 2008-07-18 20:19:20 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Fix the filter of r133 (only allow results that match the whole filter, not just a single bit of the filter)
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-07-18 20:06:37 UTC (rev 133)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-18 20:19:20 UTC (rev 134)
@@ -481,7 +481,7 @@
return false;
}
- if (!(entry->acct_flags & state->acct_flags)) {
+ if ((entry->acct_flags & state->acct_flags) != state->acct_flags) {
return mysqlsam_search_next_entry(search, entry);
}
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-07-18 20:06:37 UTC (rev 133)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-07-18 20:19:20 UTC (rev 134)
@@ -526,7 +526,7 @@
return False;
}
- if (!(entry->acct_flags & search_state->acct_flags)) {
+ if ((entry->acct_flags & search_state->acct_flags) != search_state->acct_flags) {
return pgsqlsam_search_next_entry(search, entry);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-07-18 20:06:28
|
Revision: 133
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=133&view=rev
Author: herwinw
Date: 2008-07-18 20:06:37 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Added acct_ctrl flags check to filter results
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-07-18 19:32:05 UTC (rev 132)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-18 20:06:37 UTC (rev 133)
@@ -480,6 +480,12 @@
DEBUG(0, ("talloc_strdup failed\n"));
return false;
}
+
+ if (!(entry->acct_flags & state->acct_flags)) {
+ return mysqlsam_search_next_entry(search, entry);
+
+ }
+
return true;
}
/****************************/
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-07-18 19:32:05 UTC (rev 132)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-07-18 20:06:37 UTC (rev 133)
@@ -526,6 +526,11 @@
return False;
}
+ if (!(entry->acct_flags & search_state->acct_flags)) {
+ return pgsqlsam_search_next_entry(search, entry);
+
+ }
+
return True;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-07-18 19:31:55
|
Revision: 132
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=132&view=rev
Author: herwinw
Date: 2008-07-18 19:32:05 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
* Fixed typo in mysql dump
* Added groups to pgsql dump
* Fixed html/xml confusion in debian/rules
Modified Paths:
--------------
branches/pdbsql_3_2/debian/rules
branches/pdbsql_3_2/sql-dumps/mysql.dump
branches/pdbsql_3_2/sql-dumps/pgsql.dump
Modified: branches/pdbsql_3_2/debian/rules
===================================================================
--- branches/pdbsql_3_2/debian/rules 2008-07-12 12:49:32 UTC (rev 131)
+++ branches/pdbsql_3_2/debian/rules 2008-07-18 19:32:05 UTC (rev 132)
@@ -25,7 +25,7 @@
$(MAKE) install DESTDIR=`pwd`/debian/tmp LIBDIR=/usr/lib/samba
dh_install --sourcedir=`pwd`/debian/tmp
dh_installdocs -p samba-pdb-pgsql AUTHORS docs/README
- dh_installdocs -p samba-pdb-mysql docs/pdb_mysql.html AUTHORS docs/README
+ dh_installdocs -p samba-pdb-mysql docs/pdb_mysql.xml AUTHORS docs/README
dh_installdocs -p samba-pdb-multi AUTHORS docs/README
dh_installchangelogs -a
dh_installexamples -p samba-pdb-mysql docs/smb.conf.mysql docs/mysql.dump
Modified: branches/pdbsql_3_2/sql-dumps/mysql.dump
===================================================================
--- branches/pdbsql_3_2/sql-dumps/mysql.dump 2008-07-12 12:49:32 UTC (rev 131)
+++ branches/pdbsql_3_2/sql-dumps/mysql.dump 2008-07-18 19:32:05 UTC (rev 132)
@@ -37,6 +37,6 @@
KEY username(username)
);
-CREATE TABLE group (
- group varchar(255) default NULL,
+CREATE TABLE groups (
+ groupname varchar(255) default NULL
);
Modified: branches/pdbsql_3_2/sql-dumps/pgsql.dump
===================================================================
--- branches/pdbsql_3_2/sql-dumps/pgsql.dump 2008-07-12 12:49:32 UTC (rev 131)
+++ branches/pdbsql_3_2/sql-dumps/pgsql.dump 2008-07-18 19:32:05 UTC (rev 132)
@@ -37,3 +37,7 @@
UNIQUE (username),
UNIQUE (nt_username)
);
+
+CREATE TABLE groups (
+ groupname varchar(255) default NULL
+);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-07-12 12:50:09
|
Revision: 131
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=131&view=rev
Author: herwinw
Date: 2008-07-12 05:49:32 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
* Ported r130 to postgresql
* Removed compilation warning from mysql (acct_flags was an int, not a string)
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-07-11 14:02:52 UTC (rev 130)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-12 12:49:32 UTC (rev 131)
@@ -456,7 +456,6 @@
search->private_data, struct mysqlsam_search_state);
MYSQL_ROW row;
DOM_SID sid;
- struct samu *user = NULL;
if (state->current >= state->num_entries) {
return false;
@@ -470,13 +469,12 @@
entry->rid = sid.sub_auths[4];
}
- entry->acct_flags = talloc_strdup(search->mem_ctx,row[23]);
- entry->account_name = talloc_strdup(search->mem_ctx,row[6]);
- entry->fullname = talloc_strdup(search->mem_ctx,row[9]);
- entry->description = talloc_strdup(search->mem_ctx,row[14]);
+ entry->acct_flags = atoi(row[23]);
+ entry->account_name = talloc_strdup(search->mem_ctx,row[6]);
+ entry->fullname = talloc_strdup(search->mem_ctx,row[9]);
+ entry->description = talloc_strdup(search->mem_ctx,row[14]);
state->current += 1;
- TALLOC_FREE(user);
if ((entry->account_name == NULL)) {
DEBUG(0, ("talloc_strdup failed\n"));
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-07-11 14:02:52 UTC (rev 130)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-07-12 12:49:32 UTC (rev 131)
@@ -514,8 +514,18 @@
entry->rid = sid.sub_auths[4];
}
+ entry->acct_flags = atoi(PQgetvalue(r, row, 23));
+ entry->account_name = talloc_strdup(search->mem_ctx, PQgetvalue(r, row, 6));
+ entry->fullname = talloc_strdup(search->mem_ctx, PQgetvalue(r, row, 9));
+ entry->description = talloc_strdup(search->mem_ctx, PQgetvalue(r, row, 14));
+
search_state->currow++;
+ if ((entry->account_name == NULL)) {
+ DEBUG(0, ("talloc_strdup failed\n"));
+ return False;
+ }
+
return True;
}
@@ -533,6 +543,8 @@
search_state->pwent = NULL;
search_state->currow = 0;
+ talloc_free(search);
+
DEBUG(5, ("pgsqlsam_search_end called\n"));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-07-11 14:02:44
|
Revision: 130
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=130&view=rev
Author: collen
Date: 2008-07-11 07:02:52 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
fix for net sam user (mysql only,sorry)
fix for net sam workstation (mysql only, sorry)
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_mysql.c
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-07-07 08:50:28 UTC (rev 129)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-11 14:02:52 UTC (rev 130)
@@ -444,21 +444,11 @@
uint32_t acct_flags;
MYSQL_RES *pwent;
+// struct samr_displayentry *entries;
uint32_t num_entries;
uint32_t current;
};
-
/****************************/
-static void mysqlsam_search_end(struct pdb_search *search)
-{
- struct mysqlsam_search_state *state = talloc_get_type_abort(
- search->private_data, struct mysqlsam_search_state);
- if (state->pwent != NULL) {
- mysql_free_result(state->pwent);
- }
- DEBUG(5, ("End of entries reached\n"));
-}
-/****************************/
static bool mysqlsam_search_next_entry(struct pdb_search *search,
struct samr_displayentry *entry)
{
@@ -466,20 +456,45 @@
search->private_data, struct mysqlsam_search_state);
MYSQL_ROW row;
DOM_SID sid;
+ struct samu *user = NULL;
if (state->current >= state->num_entries) {
return false;
}
+
+
row = mysql_fetch_row(state->pwent);
if (row[18]) {
string_to_sid(&sid, row[18]);
entry->rid = sid.sub_auths[4];
}
+ entry->acct_flags = talloc_strdup(search->mem_ctx,row[23]);
+ entry->account_name = talloc_strdup(search->mem_ctx,row[6]);
+ entry->fullname = talloc_strdup(search->mem_ctx,row[9]);
+ entry->description = talloc_strdup(search->mem_ctx,row[14]);
+
state->current += 1;
+ TALLOC_FREE(user);
+
+ if ((entry->account_name == NULL)) {
+ DEBUG(0, ("talloc_strdup failed\n"));
+ return false;
+ }
return true;
}
+/****************************/
+static void mysqlsam_search_end(struct pdb_search *search)
+{
+ struct mysqlsam_search_state *state = talloc_get_type_abort(
+ search->private_data, struct mysqlsam_search_state);
+ if (state->pwent != NULL) {
+ mysql_free_result(state->pwent);
+ }
+ DEBUG(5, ("End of entries reached\n"));
+}
+/****************************/
/* Enum user list*/
static bool mysqlsam_search_users(struct pdb_methods *methods,
struct pdb_search *search,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-07-07 08:50:19
|
Revision: 129
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=129&view=rev
Author: collen
Date: 2008-07-07 01:50:28 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
Clean up
Modified Paths:
--------------
branches/pdbsql_3_2/AUTHORS
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
branches/pdbsql_3_2/pdb_sql.c
Modified: branches/pdbsql_3_2/AUTHORS
===================================================================
--- branches/pdbsql_3_2/AUTHORS 2008-07-06 15:26:26 UTC (rev 128)
+++ branches/pdbsql_3_2/AUTHORS 2008-07-07 08:50:28 UTC (rev 129)
@@ -1,5 +1,6 @@
Current maintainer:
Collen Blijenberg
+Herwin Weststrate
original authors:
Jelmer Vernooij <je...@sa...> (pdbsql core / pdb_mysql / pdb_multi)
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-07-06 15:26:26 UTC (rev 128)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-07 08:50:28 UTC (rev 129)
@@ -166,99 +166,6 @@
return NT_STATUS_OK;
}
-//static NTSTATUS mysqlsam_setsampwent(struct pdb_methods *methods, bool update, uint32 acb_mask)
-//{
-// struct pdb_mysql_data *data =
-// (struct pdb_mysql_data *) methods->private_data;
-// char *query;
-// int mysql_ret;
-//
-// if (!data || !(data->handle)) {
-// DEBUG(0, ("invalid handle!\n"));
-// return NT_STATUS_INVALID_HANDLE;
-// }
-//
-// query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
-//
-// mysql_ret = mysql_query(data->handle, query);
-//
-// /* [SYN] If the server has gone away, reconnect and retry */
-// if (mysql_ret && mysql_errno(data->handle) == CR_SERVER_GONE_ERROR) {
-// DEBUG(5, ("MySQL server has gone away, reconnecting and retrying.\n"));
-//
-// /* [SYN] Reconnect */
-// if (!NT_STATUS_IS_OK(pdb_mysql_connect(data))) {
-// DEBUG(0, ("Error: Lost connection to MySQL server\n"));
-// talloc_free(query);
-// return NT_STATUS_UNSUCCESSFUL;
-// }
-// /* [SYN] Retry */
-// mysql_ret = mysql_query(data->handle, query);
-// }
-//
-// talloc_free(query);
-//
-// if (mysql_ret) {
-// DEBUG(0,
-// ("Error executing MySQL query %s\n", mysql_error(data->handle)));
-// return NT_STATUS_UNSUCCESSFUL;
-// }
-//
-// data->pwent = mysql_store_result(data->handle);
-//
-// if (data->pwent == NULL) {
-// DEBUG(0,
-// ("Error storing results: %s\n", mysql_error(data->handle)));
-// return NT_STATUS_UNSUCCESSFUL;
-// }
-//
-// DEBUG(5,
-// ("mysqlsam_setsampwent succeeded(%llu results)!\n",
-// mysql_num_rows(data->pwent)));
-//
-// return NT_STATUS_OK;
-//}
-
-/***************************************************************
- End enumeration of the passwd list.
- ****************************************************************/
-
-//static void mysqlsam_endsampwent(struct pdb_methods *methods)
-//{
-// struct pdb_mysql_data *data =
-// (struct pdb_mysql_data *) methods->private_data;
-//
-// if (data == NULL) {
-// DEBUG(0, ("invalid handle!\n"));
-// return;
-// }
-//
-// if (data->pwent != NULL)
-// mysql_free_result(data->pwent);
-//
-// data->pwent = NULL;
-//
-// DEBUG(5, ("mysql_endsampwent called\n"));
-//}
-
-/*****************************************************************
- Get one struct samu from the list (next in line)
- *****************************************************************/
-
-//static NTSTATUS mysqlsam_getsampwent(struct pdb_methods *methods, struct samu * user)
-//{
-// struct pdb_mysql_data *data;
-//
-// SET_DATA(data, methods);
-//
-// if (data->pwent == NULL) {
-// DEBUG(0, ("invalid pwent\n"));
-// return NT_STATUS_INVALID_PARAMETER;
-// }
-//
-// return row_to_sam_account(data->pwent, user);
-//}
-
static NTSTATUS mysqlsam_select_by_field(struct pdb_methods * methods, struct samu * user,
enum sql_search_field field, const char *sname)
{
@@ -533,7 +440,6 @@
return False;
}
-/****************************/
struct mysqlsam_search_state {
uint32_t acct_flags;
@@ -541,6 +447,7 @@
uint32_t num_entries;
uint32_t current;
};
+
/****************************/
static void mysqlsam_search_end(struct pdb_search *search)
{
@@ -573,7 +480,7 @@
state->current += 1;
return true;
}
-/****************************/
+/* Enum user list*/
static bool mysqlsam_search_users(struct pdb_methods *methods,
struct pdb_search *search,
uint32 acct_flags)
@@ -625,8 +532,6 @@
("Error storing results: %s\n", mysql_error(data->handle)));
return false;
}
-// state->methods = methods;
-// db_sam->traverse_read(db_sam, tdbsam_collect_rids, state);
state->num_entries = mysql_num_rows(state->pwent);
DEBUG(5, ("Found %d results\n", state->num_entries));
@@ -663,18 +568,6 @@
(*pdb_method)->rid_algorithm = mysqlsam_rid_algorithm;
(*pdb_method)->new_rid = mysqlsam_new_rid;
-/* (*pdb_method)->rename_sam_account = mysqlsam_rename_sam_account; */
-/* (*pdb_method)->getgrsid = mysqlsam_getgrsid; */
-/* (*pdb_method)->getgrgid = mysqlsam_getgrgid; */
-/* (*pdb_method)->getgrnam = mysqlsam_getgrnam; */
-/* (*pdb_method)->add_group_mapping_entry = mysqlsam_add_group_mapping_entry; */
-/* (*pdb_method)->update_group_mapping_entry = mysqlsam_update_group_mapping_entry; */
-/* (*pdb_method)->delete_group_mapping_entry = mysqlsam_delete_group_mapping_entry; */
-/* (*pdb_method)->enum_group_mapping = mysqlsam_enum_group_mapping; */
-/* (*pdb_method)->get_account_policy = mysqlsam_get_account_policy; */
-/* (*pdb_method)->set_account_policy = mysqlsam_set_account_policy; */
-/* (*pdb_method)->get_seq_num = mysqlsam_get_seq_num; */
-
data = talloc(*pdb_method, struct pdb_mysql_data);
(*pdb_method)->private_data = data;
data->handle = NULL;
@@ -721,4 +614,3 @@
{
return init_samba_module();
}
-
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-07-06 15:26:26 UTC (rev 128)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-07-07 08:50:28 UTC (rev 129)
@@ -236,87 +236,6 @@
return NT_STATUS_OK;
}
-//static NTSTATUS pgsqlsam_setsampwent(struct pdb_methods *methods, bool update, uint32 acb_mask)
-//{
-// struct pdb_pgsql_data *data;
-// PGconn *handle;
-// char *query;
-// NTSTATUS retval;
-//
-// SET_DATA(data, methods);
-//
-// /* Connect to the DB. */
-// handle = choose_connection(data);
-// if (handle == NULL) {
-// return NT_STATUS_UNSUCCESSFUL;
-// }
-// DEBUG(5, ("CONNECTING pgsqlsam_setsampwent\n"));
-//
-// query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
-//
-// /* Execute query */
-// DEBUG(5, ("Executing query %s\n", query));
-// data->pwent = PQexec(handle, query);
-// data->currow = 0;
-//
-// /* Result? */
-// if (data->pwent == NULL) {
-// DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
-// retval = NT_STATUS_UNSUCCESSFUL;
-// } else if (PQresultStatus(data->pwent) != PGRES_TUPLES_OK) {
-// DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(data->pwent)));
-// retval = NT_STATUS_UNSUCCESSFUL;
-// } else {
-// DEBUG(5, ("pgsqlsam_setsampwent succeeded(%d results)!\n", PQntuples(data->pwent)));
-// retval = NT_STATUS_OK;
-// }
-//
-// talloc_free(query);
-// return retval;
-//}
-
-/***************************************************************
- End enumeration of the passwd list.
- ****************************************************************/
-
-//static void pgsqlsam_endsampwent(struct pdb_methods *methods)
-//{
-// struct pdb_pgsql_data *data;
-//
-// SET_DATA_QUIET(data, methods);
-//
-// if (data->pwent != NULL) {
-// PQclear(data->pwent);
-// }
-//
-// data->pwent = NULL;
-// data->currow = 0;
-//
-// DEBUG(5, ("pgsql_endsampwent called\n"));
-//}
-
-/*****************************************************************
- Get one struct samu from the list (next in line)
- *****************************************************************/
-
-//static NTSTATUS pgsqlsam_getsampwent(struct pdb_methods *methods, struct samu *user)
-//{
-// struct pdb_pgsql_data *data;
-// NTSTATUS retval;
-//
-// SET_DATA(data, methods);
-//
-// if (data->pwent == NULL) {
-// DEBUG(0, ("invalid pwent\n"));
-// return NT_STATUS_INVALID_PARAMETER;
-// }
-//
-// retval = row_to_sam_account(data->pwent, data->currow, user);
-// data->currow++;
-//
-// return retval;
-//}
-
static NTSTATUS pgsqlsam_select_by_field(struct pdb_methods *methods, struct samu *user, enum sql_search_field field, const char *sname)
{
struct pdb_pgsql_data *data;
@@ -700,18 +619,6 @@
(*pdb_method)->rid_algorithm = pgsqlsam_rid_algorithm;
(*pdb_method)->new_rid = pgsqlsam_new_rid;
-/* (*pdb_method)->rename_sam_account = pgsqlsam_rename_sam_account; */
-/* (*pdb_method)->getgrsid = pgsqlsam_getgrsid; */
-/* (*pdb_method)->getgrgid = pgsqlsam_getgrgid; */
-/* (*pdb_method)->getgrnam = pgsqlsam_getgrnam; */
-/* (*pdb_method)->add_group_mapping_entry = pgsqlsam_add_group_mapping_entry; */
-/* (*pdb_method)->update_group_mapping_entry = pgsqlsam_update_group_mapping_entry; */
-/* (*pdb_method)->delete_group_mapping_entry = pgsqlsam_delete_group_mapping_entry; */
-/* (*pdb_method)->enum_group_mapping = pgsqlsam_enum_group_mapping; */
-/* (*pdb_method)->get_account_policy = pgsqlsam_get_account_policy; */
-/* (*pdb_method)->set_account_policy = pgsqlsam_set_account_policy; */
-/* (*pdb_method)->get_seq_num = pgsqlsam_get_seq_num; */
-
data = talloc(*pdb_method, struct pdb_pgsql_data);
(*pdb_method)->private_data = data;
Modified: branches/pdbsql_3_2/pdb_sql.c
===================================================================
--- branches/pdbsql_3_2/pdb_sql.c 2008-07-06 15:26:26 UTC (rev 128)
+++ branches/pdbsql_3_2/pdb_sql.c 2008-07-07 08:50:28 UTC (rev 129)
@@ -422,7 +422,6 @@
config_value_write(location, "group sid column",
CONFIG_GROUP_SID_DEFAULT),
sid_to_fstring(sid_str,
-// sid_string_dbg(sid,
pdb_get_group_sid(newpwd)));
}
@@ -582,7 +581,6 @@
"user sid column",
CONFIG_USER_SID_DEFAULT),
sid_to_fstring(sid_str, pdb_get_user_sid (newpwd)));
-// sid_string_dbg(pdb_get_user_sid (newpwd)));
} else {
query->part2[strlen(query->part2) - 1] = ')';
query->part1[strlen(query->part1) - 1] = ')';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-07-06 15:27:04
|
Revision: 128
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=128&view=rev
Author: herwinw
Date: 2008-07-06 08:26:26 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
Fixed _search_users function
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_mysql.c
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-07-05 21:02:00 UTC (rev 127)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-06 15:26:26 UTC (rev 128)
@@ -373,8 +373,8 @@
SET_DATA(data, methods);
-// sid_to_string(sid_str, sid);
- sid_string_dbg(sid);
+ sid_to_fstring(sid_str, sid);
+ // sid_string_dbg(sid);
return mysqlsam_select_by_field(methods, user, SQL_SEARCH_USER_SID, sid_str);
}
@@ -537,9 +537,8 @@
struct mysqlsam_search_state {
uint32_t acct_flags;
- struct samr_displayentry *entries;
+ MYSQL_RES *pwent;
uint32_t num_entries;
- ssize_t array_size;
uint32_t current;
};
/****************************/
@@ -547,7 +546,10 @@
{
struct mysqlsam_search_state *state = talloc_get_type_abort(
search->private_data, struct mysqlsam_search_state);
- TALLOC_FREE(state);
+ if (state->pwent != NULL) {
+ mysql_free_result(state->pwent);
+ }
+ DEBUG(5, ("End of entries reached\n"));
}
/****************************/
static bool mysqlsam_search_next_entry(struct pdb_search *search,
@@ -555,26 +557,17 @@
{
struct mysqlsam_search_state *state = talloc_get_type_abort(
search->private_data, struct mysqlsam_search_state);
+ MYSQL_ROW row;
+ DOM_SID sid;
- if (state->current == state->num_entries) {
+ if (state->current >= state->num_entries) {
return false;
}
- entry->idx = state->entries[state->current].idx;
- entry->rid = state->entries[state->current].rid;
- entry->acct_flags = state->entries[state->current].acct_flags;
-
- entry->account_name = talloc_strdup(
- search->mem_ctx, state->entries[state->current].account_name);
- entry->fullname = talloc_strdup(
- search->mem_ctx, state->entries[state->current].fullname);
- entry->description = talloc_strdup(
- search->mem_ctx, state->entries[state->current].description);
-
- if ((entry->account_name == NULL) || (entry->fullname == NULL)
- || (entry->description == NULL)) {
- DEBUG(0, ("talloc_strdup failed\n"));
- return false;
+ row = mysql_fetch_row(state->pwent);
+ if (row[18]) {
+ string_to_sid(&sid, row[18]);
+ entry->rid = sid.sub_auths[4];
}
state->current += 1;
@@ -583,13 +576,12 @@
/****************************/
static bool mysqlsam_search_users(struct pdb_methods *methods,
struct pdb_search *search,
- uint32 acct_flags,
- bool update)
+ uint32 acct_flags)
{
struct pdb_mysql_data *data =
(struct pdb_mysql_data *) methods->private_data;
- char *query;
- int mysql_ret;
+ char *query;
+ int mysql_ret;
struct mysqlsam_search_state *state;
state = TALLOC_ZERO_P(search->mem_ctx, struct mysqlsam_search_state);
@@ -600,7 +592,7 @@
state->acct_flags = acct_flags;
//
- query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
+ query = sql_account_query_select(NULL, data->location, False, SQL_SEARCH_NONE, NULL);
mysql_ret = mysql_query(data->handle, query);
@@ -625,17 +617,19 @@
("Error executing MySQL query %s\n", mysql_error(data->handle)));
return false;
}
-// klopt nie !
- data->pwent = mysql_store_result(data->handle);
- if (data->pwent == NULL) {
+ state->pwent = mysql_store_result(data->handle);
+
+ if (state->pwent == NULL) {
DEBUG(0,
("Error storing results: %s\n", mysql_error(data->handle)));
return false;
}
// state->methods = methods;
// db_sam->traverse_read(db_sam, tdbsam_collect_rids, state);
-//
+ state->num_entries = mysql_num_rows(state->pwent);
+ DEBUG(5, ("Found %d results\n", state->num_entries));
+
search->private_data = state;
search->next_entry = mysqlsam_search_next_entry;
search->search_end = mysqlsam_search_end;
@@ -722,3 +716,9 @@
{
return smb_register_passdb(PASSDB_INTERFACE_VERSION, "mysql", mysqlsam_init);
}
+
+NTSTATUS init_module(void)
+{
+ return init_samba_module();
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2008-07-05 21:02:37
|
Revision: 127
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=127&view=rev
Author: herwinw
Date: 2008-07-05 14:02:00 -0700 (Sat, 05 Jul 2008)
Log Message:
-----------
Fixed the _search_users function
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_pgsql.c
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-07-03 11:04:54 UTC (rev 126)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-07-05 21:02:00 UTC (rev 127)
@@ -65,6 +65,14 @@
const char *location;
} pdb_pgsql_data;
+/* Store the data needed for the _search_next_entry iterator */
+typedef struct pdb_pgsql_search_state {
+ uint32_t acct_flags;
+
+ PGresult *pwent;
+ long currow;
+} pdb_pgsql_search_state;
+
#define SET_DATA(data,methods) { \
if(!methods){ \
DEBUG(0, ("invalid methods!\n")); \
@@ -553,6 +561,116 @@
return False;
}
+/* Iterate through search results, if a new entry is available: store in
+ * entry and return True. Otherwise: return False
+ */
+static bool pgsqlsam_search_next_entry(struct pdb_search *search,
+ struct samr_displayentry *entry)
+{
+ struct pdb_pgsql_search_state *search_state;
+ DOM_SID sid;
+ PGresult *r;
+ long row;
+
+ search_state = (struct pdb_pgsql_search_state *)search->private_data;
+ r = search_state->pwent;
+ row = search_state->currow;
+
+ if (r == NULL) {
+ DEBUG(0, ("invalid query result pointer\n"));
+ return False;
+ }
+
+ if (row >= PQntuples(r)) {
+ /* We've reached the end */
+ return False;
+ }
+
+ /* Now why do we need to fill entry as rid is enough? Okay, it is a bit
+ * of a hack, but I don't see the point in filling everything when we
+ * never read it.
+ */
+ if (!PQgetisnull(r, row, 18)) {
+ string_to_sid(&sid, PQgetvalue(r, row, 18));
+ entry->rid = sid.sub_auths[4];
+ }
+
+ search_state->currow++;
+
+ return True;
+}
+
+/* Free the memory after a search, reset some default values */
+static void pgsqlsam_search_end(struct pdb_search *search)
+{
+ struct pdb_pgsql_search_state *search_state;
+
+ search_state = (struct pdb_pgsql_search_state *)search->private_data;
+
+ if (search_state->pwent != NULL) {
+ PQclear(search_state->pwent);
+ }
+
+ search_state->pwent = NULL;
+ search_state->currow = 0;
+
+ DEBUG(5, ("pgsqlsam_search_end called\n"));
+}
+
+/* Prepare a search object for iterating through the users */
+static bool pgsqlsam_search_users(struct pdb_methods *pdb_methods,
+ struct pdb_search *search, uint32_t acct_flags)
+{
+ struct pdb_pgsql_data *data;
+ struct pdb_pgsql_search_state *search_state;
+ PGconn *handle;
+ char *query;
+
+ data = (struct pdb_pgsql_data *) pdb_methods->private_data;
+
+ search_state = TALLOC_ZERO_P(search->mem_ctx, struct pdb_pgsql_search_state);
+ if (search_state == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ return False;
+ }
+ search_state->acct_flags = acct_flags;
+
+ if (!pdb_methods) {
+ DEBUG(0, ("invalid methods!\n"));
+ return False;
+ }
+
+ handle = choose_connection(data);
+ if (handle == NULL) {
+ DEBUG(0, ("Unable to obtain handle\n"));
+ return False;
+ }
+
+ /* The query to select all the users */
+ query = sql_account_query_select(NULL, data->location, False, SQL_SEARCH_NONE, NULL);
+
+ DEBUG(5, ("Executing query: %s\n", query));
+ search_state->pwent = PQexec(handle, query);
+ search_state->currow = 0;
+ talloc_free(query);
+
+ /* Check results */
+ if (search_state->pwent == NULL) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
+ return False;
+ } else if (PQresultStatus(search_state->pwent) != PGRES_TUPLES_OK) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(search_state->pwent)));
+ return False;
+ } else {
+ DEBUG(5, ("pgsqlsam_search_users succeeded(%d results)!\n", PQntuples(search_state->pwent)));
+ }
+ search->private_data = search_state;
+ search->next_entry = pgsqlsam_search_next_entry;
+ search->search_end = pgsqlsam_search_end;
+
+ return True;
+}
+
static NTSTATUS pgsqlsam_init (struct pdb_methods **pdb_method, const char *location)
{
NTSTATUS nt_status;
@@ -573,7 +691,7 @@
(*pdb_method)->name = "pgsqlsam";
-// (*pdb_method)->search_users = pgsqlsam_search_users;
+ (*pdb_method)->search_users = pgsqlsam_search_users;
(*pdb_method)->getsampwnam = pgsqlsam_getsampwnam;
(*pdb_method)->getsampwsid = pgsqlsam_getsampwsid;
(*pdb_method)->add_sam_account = pgsqlsam_add_sam_account;
@@ -633,3 +751,10 @@
{
return smb_register_passdb(PASSDB_INTERFACE_VERSION, "pgsql", pgsqlsam_init);
}
+
+/* For backwards compatibility with either 3.2.0~r2 or Debian */
+NTSTATUS init_module(void)
+{
+ return init_samba_module();
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-07-03 11:04:47
|
Revision: 126
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=126&view=rev
Author: collen
Date: 2008-07-03 04:04:54 -0700 (Thu, 03 Jul 2008)
Log Message:
-----------
New compat fixes for 3.2.0 samba
insert search_users
insert search_next
insert search_end
insert search_state
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_multi.c
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
Modified: branches/pdbsql_3_2/pdb_multi.c
===================================================================
--- branches/pdbsql_3_2/pdb_multi.c 2008-06-27 11:48:33 UTC (rev 125)
+++ branches/pdbsql_3_2/pdb_multi.c 2008-07-03 11:04:54 UTC (rev 126)
@@ -702,6 +702,7 @@
// (*pdb_method)->setsampwent = multisam_setsampwent;
// (*pdb_method)->endsampwent = multisam_endsampwent;
// (*pdb_method)->getsampwent = multisam_getsampwent;
+// (*pdb_method)->search_users = multisam_search_users;
(*pdb_method)->getsampwnam = multisam_getsampwnam;
(*pdb_method)->getsampwsid = multisam_getsampwsid;
(*pdb_method)->add_sam_account = multisam_add_sam_account;
@@ -744,7 +745,7 @@
(*pdb_method)->get_account_policy = multisam_get_account_policy;
(*pdb_method)->set_account_policy = multisam_set_account_policy;
(*pdb_method)->get_seq_num = multisam_get_seq_num;
- (*pdb_method)->search_users = multisam_search_users;
+// (*pdb_method)->search_users = multisam_search_users;
(*pdb_method)->search_groups = multisam_search_groups;
(*pdb_method)->search_aliases = multisam_search_aliases;
#endif
@@ -799,7 +800,7 @@
return NT_STATUS_OK;
}
-NTSTATUS init_module(void)
+NTSTATUS init_samba_module(void)
{
return smb_register_passdb(PASSDB_INTERFACE_VERSION, "multi", multisam_init);
}
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-06-27 11:48:33 UTC (rev 125)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-07-03 11:04:54 UTC (rev 126)
@@ -533,6 +533,116 @@
return False;
}
+/****************************/
+struct mysqlsam_search_state {
+ uint32_t acct_flags;
+
+ struct samr_displayentry *entries;
+ uint32_t num_entries;
+ ssize_t array_size;
+ uint32_t current;
+};
+/****************************/
+static void mysqlsam_search_end(struct pdb_search *search)
+{
+ struct mysqlsam_search_state *state = talloc_get_type_abort(
+ search->private_data, struct mysqlsam_search_state);
+ TALLOC_FREE(state);
+}
+/****************************/
+static bool mysqlsam_search_next_entry(struct pdb_search *search,
+ struct samr_displayentry *entry)
+{
+ struct mysqlsam_search_state *state = talloc_get_type_abort(
+ search->private_data, struct mysqlsam_search_state);
+
+ if (state->current == state->num_entries) {
+ return false;
+ }
+
+ entry->idx = state->entries[state->current].idx;
+ entry->rid = state->entries[state->current].rid;
+ entry->acct_flags = state->entries[state->current].acct_flags;
+
+ entry->account_name = talloc_strdup(
+ search->mem_ctx, state->entries[state->current].account_name);
+ entry->fullname = talloc_strdup(
+ search->mem_ctx, state->entries[state->current].fullname);
+ entry->description = talloc_strdup(
+ search->mem_ctx, state->entries[state->current].description);
+
+ if ((entry->account_name == NULL) || (entry->fullname == NULL)
+ || (entry->description == NULL)) {
+ DEBUG(0, ("talloc_strdup failed\n"));
+ return false;
+ }
+
+ state->current += 1;
+ return true;
+}
+/****************************/
+static bool mysqlsam_search_users(struct pdb_methods *methods,
+ struct pdb_search *search,
+ uint32 acct_flags,
+ bool update)
+{
+ struct pdb_mysql_data *data =
+ (struct pdb_mysql_data *) methods->private_data;
+ char *query;
+ int mysql_ret;
+ struct mysqlsam_search_state *state;
+
+ state = TALLOC_ZERO_P(search->mem_ctx, struct mysqlsam_search_state);
+ if (state == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ return false;
+ }
+
+ state->acct_flags = acct_flags;
+//
+ query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
+
+ mysql_ret = mysql_query(data->handle, query);
+
+// /* [SYN] If the server has gone away, reconnect and retry */
+ if (mysql_ret && mysql_errno(data->handle) == CR_SERVER_GONE_ERROR) {
+ DEBUG(5, ("MySQL server has gone away, reconnecting and retrying.\n"));
+
+// /* [SYN] Reconnect */
+ if (!NT_STATUS_IS_OK(pdb_mysql_connect(data))) {
+ DEBUG(0, ("Error: Lost connection to MySQL server\n"));
+ talloc_free(query);
+ return false;
+ }
+// /* [SYN] Retry */
+ mysql_ret = mysql_query(data->handle, query);
+ }
+
+ talloc_free(query);
+
+ if (mysql_ret) {
+ DEBUG(0,
+ ("Error executing MySQL query %s\n", mysql_error(data->handle)));
+ return false;
+ }
+// klopt nie !
+ data->pwent = mysql_store_result(data->handle);
+
+ if (data->pwent == NULL) {
+ DEBUG(0,
+ ("Error storing results: %s\n", mysql_error(data->handle)));
+ return false;
+ }
+// state->methods = methods;
+// db_sam->traverse_read(db_sam, tdbsam_collect_rids, state);
+//
+ search->private_data = state;
+ search->next_entry = mysqlsam_search_next_entry;
+ search->search_end = mysqlsam_search_end;
+
+ return true;
+}
+
static NTSTATUS mysqlsam_init(struct pdb_methods **pdb_method, const char *location)
{
NTSTATUS nt_status;
@@ -541,19 +651,16 @@
mysqlsam_debug_level = debug_add_class("mysqlsam");
if (mysqlsam_debug_level == -1) {
mysqlsam_debug_level = DBGC_ALL;
- DEBUG(0,
- ("mysqlsam: Couldn't register custom debugging class!\n"));
+ DEBUG(0,("mysqlsam: Couldn't register custom debugging class!\n"));
}
- if ( !NT_STATUS_IS_OK(nt_status = make_pdb_method( pdb_method )) ) {
+ if (!NT_STATUS_IS_OK(nt_status = make_pdb_method( pdb_method ))) {
return nt_status;
}
(*pdb_method)->name = "mysqlsam";
-// (*pdb_method)->setsampwent = mysqlsam_setsampwent;
-// (*pdb_method)->endsampwent = mysqlsam_endsampwent;
-// (*pdb_method)->getsampwent = mysqlsam_getsampwent;
+ (*pdb_method)->search_users = mysqlsam_search_users;
(*pdb_method)->getsampwnam = mysqlsam_getsampwnam;
(*pdb_method)->getsampwsid = mysqlsam_getsampwsid;
(*pdb_method)->add_sam_account = mysqlsam_add_sam_account;
@@ -611,8 +718,7 @@
return NT_STATUS_OK;
}
-NTSTATUS init_module(void)
+NTSTATUS init_samba_module(void)
{
return smb_register_passdb(PASSDB_INTERFACE_VERSION, "mysql", mysqlsam_init);
}
-
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-06-27 11:48:33 UTC (rev 125)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-07-03 11:04:54 UTC (rev 126)
@@ -573,9 +573,7 @@
(*pdb_method)->name = "pgsqlsam";
-// (*pdb_method)->setsampwent = pgsqlsam_setsampwent;
-// (*pdb_method)->endsampwent = pgsqlsam_endsampwent;
-// (*pdb_method)->getsampwent = pgsqlsam_getsampwent;
+// (*pdb_method)->search_users = pgsqlsam_search_users;
(*pdb_method)->getsampwnam = pgsqlsam_getsampwnam;
(*pdb_method)->getsampwsid = pgsqlsam_getsampwsid;
(*pdb_method)->add_sam_account = pgsqlsam_add_sam_account;
@@ -631,7 +629,7 @@
return NT_STATUS_OK;
}
-NTSTATUS init_module(void)
+NTSTATUS init_samba_module(void)
{
return smb_register_passdb(PASSDB_INTERFACE_VERSION, "pgsql", pgsqlsam_init);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-27 11:48:25
|
Revision: 125
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=125&view=rev
Author: collen
Date: 2008-06-27 04:48:33 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Ok, compiles again...
sid_to_string
pstring->fstring
compile clean ups..
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_multi.c
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
branches/pdbsql_3_2/pdb_sql.c
Modified: branches/pdbsql_3_2/pdb_multi.c
===================================================================
--- branches/pdbsql_3_2/pdb_multi.c 2008-06-26 12:58:35 UTC (rev 124)
+++ branches/pdbsql_3_2/pdb_multi.c 2008-06-27 11:48:33 UTC (rev 125)
@@ -171,7 +171,7 @@
/* Tries sid_to_id on every backend until one succeeds, returns true on success */
static bool multisam_sid_to_id(struct pdb_methods *methods,
const DOM_SID *sid,
- union unid_t *id, enum SID_NAME_USE *type)
+ union unid_t *id, enum lsa_SidType *type)
{
short i;
struct multisam_data *data;
@@ -755,7 +755,7 @@
}
data->location = talloc_strdup(data, location);
- data->names = str_list_make_talloc(data, data->location, NULL);
+// data->names = str_list_make_talloc(data, data->location, NULL);
data->num_backends = str_list_count((const char **)data->names);
data->locations = talloc_array(data, char *, data->num_backends);
data->methods = talloc_array(data, struct pdb_methods *, data->num_backends);
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-06-26 12:58:35 UTC (rev 124)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-06-27 11:48:33 UTC (rev 125)
@@ -559,6 +559,8 @@
(*pdb_method)->add_sam_account = mysqlsam_add_sam_account;
(*pdb_method)->update_sam_account = mysqlsam_update_sam_account;
(*pdb_method)->delete_sam_account = mysqlsam_delete_sam_account;
+ (*pdb_method)->rid_algorithm = mysqlsam_rid_algorithm;
+ (*pdb_method)->new_rid = mysqlsam_new_rid;
/* (*pdb_method)->rename_sam_account = mysqlsam_rename_sam_account; */
/* (*pdb_method)->getgrsid = mysqlsam_getgrsid; */
@@ -572,9 +574,6 @@
/* (*pdb_method)->set_account_policy = mysqlsam_set_account_policy; */
/* (*pdb_method)->get_seq_num = mysqlsam_get_seq_num; */
- (*pdb_method)->rid_algorithm = mysqlsam_rid_algorithm;
- (*pdb_method)->new_rid = mysqlsam_new_rid;
-
data = talloc(*pdb_method, struct pdb_mysql_data);
(*pdb_method)->private_data = data;
data->handle = NULL;
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-06-26 12:58:35 UTC (rev 124)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-06-27 11:48:33 UTC (rev 125)
@@ -415,7 +415,7 @@
SET_DATA(data, methods);
- sid_to_string(sid_str, sid);
+ sid_to_fstring(sid_str, sid);
return pgsqlsam_select_by_field(methods, user, SQL_SEARCH_USER_SID, sid_str);
}
@@ -596,6 +596,7 @@
/* (*pdb_method)->set_account_policy = pgsqlsam_set_account_policy; */
/* (*pdb_method)->get_seq_num = pgsqlsam_get_seq_num; */
+ data = talloc(*pdb_method, struct pdb_pgsql_data);
(*pdb_method)->private_data = data;
data->master_handle = NULL;
Modified: branches/pdbsql_3_2/pdb_sql.c
===================================================================
--- branches/pdbsql_3_2/pdb_sql.c 2008-06-26 12:58:35 UTC (rev 124)
+++ branches/pdbsql_3_2/pdb_sql.c 2008-06-27 11:48:33 UTC (rev 125)
@@ -20,6 +20,9 @@
#include "pdb_sql.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_PASSDB
+
#define CONFIG_TABLE_DEFAULT "user"
#define CONFIG_LOGON_TIME_DEFAULT "logon_time"
#define CONFIG_LOGOFF_TIME_DEFAULT "logoff_time"
@@ -298,7 +301,7 @@
char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, struct samu *newpwd, char isupdate)
{
char *ret;
- pstring temp;
+ fstring temp;
fstring sid_str;
pdb_sql_query *query;
int some_field_affected = 0;
@@ -408,8 +411,9 @@
pdb_sql_string_field(query,
config_value_write(location, "user sid column",
CONFIG_USER_SID_DEFAULT),
- sid_to_string(sid_str,
- pdb_get_user_sid(newpwd)));
+ sid_to_fstring(sid_str,
+// sid_string_dbg(sid,
+ pdb_get_user_sid(newpwd)));
}
if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_GROUPSID)) {
@@ -417,7 +421,8 @@
pdb_sql_string_field(query,
config_value_write(location, "group sid column",
CONFIG_GROUP_SID_DEFAULT),
- sid_to_string(sid_str,
+ sid_to_fstring(sid_str,
+// sid_string_dbg(sid,
pdb_get_group_sid(newpwd)));
}
@@ -576,7 +581,8 @@
config_value_read(location,
"user sid column",
CONFIG_USER_SID_DEFAULT),
- sid_to_string(sid_str, pdb_get_user_sid (newpwd)));
+ sid_to_fstring(sid_str, pdb_get_user_sid (newpwd)));
+// sid_string_dbg(pdb_get_user_sid (newpwd)));
} else {
query->part2[strlen(query->part2) - 1] = ')';
query->part1[strlen(query->part1) - 1] = ')';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-26 12:58:26
|
Revision: 124
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=124&view=rev
Author: collen
Date: 2008-06-26 05:58:35 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
fixed bool and others.
still broke, but working on it..
Modified Paths:
--------------
branches/pdbsql_3_2/pdb_multi.c
branches/pdbsql_3_2/pdb_mysql.c
branches/pdbsql_3_2/pdb_pgsql.c
branches/pdbsql_3_2/pdb_sql.c
branches/pdbsql_3_2/pdb_sql.h
Modified: branches/pdbsql_3_2/pdb_multi.c
===================================================================
--- branches/pdbsql_3_2/pdb_multi.c 2008-06-26 10:45:37 UTC (rev 123)
+++ branches/pdbsql_3_2/pdb_multi.c 2008-06-26 12:58:35 UTC (rev 124)
@@ -20,9 +20,9 @@
* TODO
* * Volker commited Trust domain passwords to be included in the pdb.
* These need to be added here:
- * BOOL get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
- * BOOL set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
- * BOOL del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
+ * bool get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
+ * bool set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
+ * bool del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
* NTSTATUS enum_trusteddoms(struct pdb_methods *methods, TALLOC_CTX *mem_ctx, uint32 *num_domains, struct trustdom_info ***domains)
*/
@@ -54,7 +54,7 @@
}
#define IS_DEFAULT(methods, function) ((*(data->default_methods)->function) == (*(methods)->function))
-static BOOL multisam_new_rid(struct pdb_methods *methods,
+static bool multisam_new_rid(struct pdb_methods *methods,
uint32 *rid,
short backend)
{
@@ -85,20 +85,20 @@
}
#if 0
-static BOOL multisam_search_groups(struct pdb_methods *methods,
+static bool multisam_search_groups(struct pdb_methods *methods,
struct pdb_search *search)
{
return False;
}
-static BOOL multisam_search_aliases(struct pdb_methods *methods,
+static bool multisam_search_aliases(struct pdb_methods *methods,
struct pdb_search *search,
const DOM_SID *sid)
{
return False;
}
-static BOOL multisam_search_users(struct pdb_methods *methods,
+static bool multisam_search_users(struct pdb_methods *methods,
struct pdb_search *search,
uint32 acct_flags)
{
@@ -125,12 +125,12 @@
#endif
/* Tries uid_to_rid on every backend until one succeeds, returns true on success */
-static BOOL multisam_uid_to_rid(struct pdb_methods *methods, uid_t uid,
+static bool multisam_uid_to_rid(struct pdb_methods *methods, uid_t uid,
uint32 *rid)
{
short i;
struct multisam_data *data;
- BOOL rv;
+ bool rv;
if (!methods) return False;
data = (struct multisam_data *)methods->private_data;
@@ -147,12 +147,12 @@
}
/* Tries gid_to_sid on every backend until one succeeds, returns true on success */
-static BOOL multisam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
+static bool multisam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
DOM_SID *sid)
{
short i;
struct multisam_data *data;
- BOOL rv;
+ bool rv;
if (!methods) return False;
data = (struct multisam_data *)methods->private_data;
@@ -169,13 +169,13 @@
}
/* Tries sid_to_id on every backend until one succeeds, returns true on success */
-static BOOL multisam_sid_to_id(struct pdb_methods *methods,
+static bool multisam_sid_to_id(struct pdb_methods *methods,
const DOM_SID *sid,
union unid_t *id, enum SID_NAME_USE *type)
{
short i;
struct multisam_data *data;
- BOOL rv;
+ bool rv;
if (!methods) return False;
data = (struct multisam_data *)methods->private_data;
@@ -273,7 +273,7 @@
}
-static NTSTATUS multisam_update_login_attempts (struct pdb_methods *methods, struct samu *newpwd, BOOL success)
+static NTSTATUS multisam_update_login_attempts (struct pdb_methods *methods, struct samu *newpwd, bool success)
{
DEBUG(1, ("This function is not implemented yet\n"));
return NT_STATUS_NOT_IMPLEMENTED;
@@ -363,7 +363,7 @@
static NTSTATUS multisam_enum_group_mapping(struct pdb_methods *methods,
const DOM_SID *sid, enum SID_NAME_USE sid_name_use,
GROUP_MAP **pp_rmap, size_t *p_num_entries,
- BOOL unix_only)
+ bool unix_only)
{
DEBUG(1, ("This function is not implemented yet\n"));
return NT_STATUS_NOT_IMPLEMENTED;
@@ -442,67 +442,67 @@
#endif
/* Creates user list in every backend */
-static NTSTATUS multisam_setsampwent(struct pdb_methods *methods, BOOL update, uint32 acb_mask)
-{
- short i;
- struct multisam_data *data;
- NTSTATUS ret;
+//static NTSTATUS multisam_setsampwent(struct pdb_methods *methods, bool update, uint32 acb_mask)
+//{
+// short i;
+// struct multisam_data *data;
+// NTSTATUS ret;
+//
+// SET_DATA(data, methods);
+//
+// DEBUG(1, ("Setsampwent executing..\n"));
+//
+// for (i = 0; i < data->num_backends; i++) {
+// ret = data->methods[i]->setsampwent(data->methods[i], update, acb_mask);
+// if (!NT_STATUS_IS_OK(ret)) {
+// return ret;
+// }
+// }
+//
+// return NT_STATUS_OK;
+//}
- SET_DATA(data, methods);
-
- DEBUG(1, ("Setsampwent executing..\n"));
-
- for (i = 0; i < data->num_backends; i++) {
- ret = data->methods[i]->setsampwent(data->methods[i], update, acb_mask);
- if (!NT_STATUS_IS_OK(ret)) {
- return ret;
- }
- }
-
- return NT_STATUS_OK;
-}
-
/***************************************************************
End enumeration of the passwd list.
****************************************************************/
/* Runs endsampwent on every backend */
-static void multisam_endsampwent(struct pdb_methods *methods)
-{
- short i;
- struct multisam_data *data;
+//static void multisam_endsampwent(struct pdb_methods *methods)
+//{
+// short i;
+// struct multisam_data *data;
+//
+// if (!methods) return;
+// data = (struct multisam_data *)methods->private_data;
+// if (!data) return;
+//
+// DEBUG(1, ("Freeing pwent results on multisam backends\n"));
+//
+// for (i = 0; i < data->num_backends; i++) {
+// data->methods[i]->endsampwent(data->methods[i]);
+// }
+//}
- if (!methods) return;
- data = (struct multisam_data *)methods->private_data;
- if (!data) return;
-
- DEBUG(1, ("Freeing pwent results on multisam backends\n"));
-
- for (i = 0; i < data->num_backends; i++) {
- data->methods[i]->endsampwent(data->methods[i]);
- }
-}
-
/*****************************************************************
Get one struct samu from the list (next in line)
*****************************************************************/
/* Reads every user from backend 0, then 1.. etc (returns one) */
-static NTSTATUS multisam_getsampwent(struct pdb_methods *methods, struct samu * user)
-{
- short i;
- struct multisam_data *data;
- NTSTATUS ret;
-
- SET_DATA(data, methods);
-
- for (i = 0; i < data->num_backends; i++) {
- ret = data->methods[i]->getsampwent(data->methods[i], user);
- if (NT_STATUS_IS_OK(ret)) {
- return ret;
- }
- }
-
- return NT_STATUS_INVALID_PARAMETER;
-}
+//static NTSTATUS multisam_getsampwent(struct pdb_methods *methods, struct samu * user)
+//{
+// short i;
+// struct multisam_data *data;
+// NTSTATUS ret;
+//
+// SET_DATA(data, methods);
+//
+// for (i = 0; i < data->num_backends; i++) {
+// ret = data->methods[i]->getsampwent(data->methods[i], user);
+// if (NT_STATUS_IS_OK(ret)) {
+// return ret;
+// }
+// }
+//
+// return NT_STATUS_INVALID_PARAMETER;
+//}
/******************************************************************
Lookup a name in the SAM database
@@ -659,12 +659,12 @@
#endif
/* The rid algorithm of the first backend is used. */
-static BOOL multisam_rid_algorithm (struct pdb_methods *methods)
+static bool multisam_rid_algorithm (struct pdb_methods *methods)
{
return True;
}
/* This function is a fallback for errors */
-static BOOL multisam_dummy_new_rid (struct pdb_methods *methods, uint32 *rid)
+static bool multisam_dummy_new_rid (struct pdb_methods *methods, uint32 *rid)
{
DEBUG(0, ("This function should not be used!\n"));
return False;
@@ -699,9 +699,9 @@
(*pdb_method)->name = "multisam";
/* Mandatory implementation */
- (*pdb_method)->setsampwent = multisam_setsampwent;
- (*pdb_method)->endsampwent = multisam_endsampwent;
- (*pdb_method)->getsampwent = multisam_getsampwent;
+// (*pdb_method)->setsampwent = multisam_setsampwent;
+// (*pdb_method)->endsampwent = multisam_endsampwent;
+// (*pdb_method)->getsampwent = multisam_getsampwent;
(*pdb_method)->getsampwnam = multisam_getsampwnam;
(*pdb_method)->getsampwsid = multisam_getsampwsid;
(*pdb_method)->add_sam_account = multisam_add_sam_account;
Modified: branches/pdbsql_3_2/pdb_mysql.c
===================================================================
--- branches/pdbsql_3_2/pdb_mysql.c 2008-06-26 10:45:37 UTC (rev 123)
+++ branches/pdbsql_3_2/pdb_mysql.c 2008-06-26 12:58:35 UTC (rev 124)
@@ -20,9 +20,9 @@
* TODO
* * Volker commited Trust domain passwords to be included in the pdb.
* These need to be added here:
- * BOOL get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
- * BOOL set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
- * BOOL del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
+ * bool get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
+ * bool set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
+ * bool del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
* NTSTATUS enum_trusteddoms(struct pdb_methods *methods, TALLOC_CTX *mem_ctx, uint32 *num_domains, struct trustdom_info ***domains)
*/
@@ -166,99 +166,99 @@
return NT_STATUS_OK;
}
-static NTSTATUS mysqlsam_setsampwent(struct pdb_methods *methods, BOOL update, uint32 acb_mask)
-{
- struct pdb_mysql_data *data =
- (struct pdb_mysql_data *) methods->private_data;
- char *query;
- int mysql_ret;
+//static NTSTATUS mysqlsam_setsampwent(struct pdb_methods *methods, bool update, uint32 acb_mask)
+//{
+// struct pdb_mysql_data *data =
+// (struct pdb_mysql_data *) methods->private_data;
+// char *query;
+// int mysql_ret;
+//
+// if (!data || !(data->handle)) {
+// DEBUG(0, ("invalid handle!\n"));
+// return NT_STATUS_INVALID_HANDLE;
+// }
+//
+// query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
+//
+// mysql_ret = mysql_query(data->handle, query);
+//
+// /* [SYN] If the server has gone away, reconnect and retry */
+// if (mysql_ret && mysql_errno(data->handle) == CR_SERVER_GONE_ERROR) {
+// DEBUG(5, ("MySQL server has gone away, reconnecting and retrying.\n"));
+//
+// /* [SYN] Reconnect */
+// if (!NT_STATUS_IS_OK(pdb_mysql_connect(data))) {
+// DEBUG(0, ("Error: Lost connection to MySQL server\n"));
+// talloc_free(query);
+// return NT_STATUS_UNSUCCESSFUL;
+// }
+// /* [SYN] Retry */
+// mysql_ret = mysql_query(data->handle, query);
+// }
+//
+// talloc_free(query);
+//
+// if (mysql_ret) {
+// DEBUG(0,
+// ("Error executing MySQL query %s\n", mysql_error(data->handle)));
+// return NT_STATUS_UNSUCCESSFUL;
+// }
+//
+// data->pwent = mysql_store_result(data->handle);
+//
+// if (data->pwent == NULL) {
+// DEBUG(0,
+// ("Error storing results: %s\n", mysql_error(data->handle)));
+// return NT_STATUS_UNSUCCESSFUL;
+// }
+//
+// DEBUG(5,
+// ("mysqlsam_setsampwent succeeded(%llu results)!\n",
+// mysql_num_rows(data->pwent)));
+//
+// return NT_STATUS_OK;
+//}
- if (!data || !(data->handle)) {
- DEBUG(0, ("invalid handle!\n"));
- return NT_STATUS_INVALID_HANDLE;
- }
-
- query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
-
- mysql_ret = mysql_query(data->handle, query);
-
- /* [SYN] If the server has gone away, reconnect and retry */
- if (mysql_ret && mysql_errno(data->handle) == CR_SERVER_GONE_ERROR) {
- DEBUG(5, ("MySQL server has gone away, reconnecting and retrying.\n"));
-
- /* [SYN] Reconnect */
- if (!NT_STATUS_IS_OK(pdb_mysql_connect(data))) {
- DEBUG(0, ("Error: Lost connection to MySQL server\n"));
- talloc_free(query);
- return NT_STATUS_UNSUCCESSFUL;
- }
- /* [SYN] Retry */
- mysql_ret = mysql_query(data->handle, query);
- }
-
- talloc_free(query);
-
- if (mysql_ret) {
- DEBUG(0,
- ("Error executing MySQL query %s\n", mysql_error(data->handle)));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- data->pwent = mysql_store_result(data->handle);
-
- if (data->pwent == NULL) {
- DEBUG(0,
- ("Error storing results: %s\n", mysql_error(data->handle)));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- DEBUG(5,
- ("mysqlsam_setsampwent succeeded(%llu results)!\n",
- mysql_num_rows(data->pwent)));
-
- return NT_STATUS_OK;
-}
-
/***************************************************************
End enumeration of the passwd list.
****************************************************************/
-static void mysqlsam_endsampwent(struct pdb_methods *methods)
-{
- struct pdb_mysql_data *data =
- (struct pdb_mysql_data *) methods->private_data;
+//static void mysqlsam_endsampwent(struct pdb_methods *methods)
+//{
+// struct pdb_mysql_data *data =
+// (struct pdb_mysql_data *) methods->private_data;
+//
+// if (data == NULL) {
+// DEBUG(0, ("invalid handle!\n"));
+// return;
+// }
+//
+// if (data->pwent != NULL)
+// mysql_free_result(data->pwent);
+//
+// data->pwent = NULL;
+//
+// DEBUG(5, ("mysql_endsampwent called\n"));
+//}
- if (data == NULL) {
- DEBUG(0, ("invalid handle!\n"));
- return;
- }
-
- if (data->pwent != NULL)
- mysql_free_result(data->pwent);
-
- data->pwent = NULL;
-
- DEBUG(5, ("mysql_endsampwent called\n"));
-}
-
/*****************************************************************
Get one struct samu from the list (next in line)
*****************************************************************/
-static NTSTATUS mysqlsam_getsampwent(struct pdb_methods *methods, struct samu * user)
-{
- struct pdb_mysql_data *data;
+//static NTSTATUS mysqlsam_getsampwent(struct pdb_methods *methods, struct samu * user)
+//{
+// struct pdb_mysql_data *data;
+//
+// SET_DATA(data, methods);
+//
+// if (data->pwent == NULL) {
+// DEBUG(0, ("invalid pwent\n"));
+// return NT_STATUS_INVALID_PARAMETER;
+// }
+//
+// return row_to_sam_account(data->pwent, user);
+//}
- SET_DATA(data, methods);
-
- if (data->pwent == NULL) {
- DEBUG(0, ("invalid pwent\n"));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- return row_to_sam_account(data->pwent, user);
-}
-
static NTSTATUS mysqlsam_select_by_field(struct pdb_methods * methods, struct samu * user,
enum sql_search_field field, const char *sname)
{
@@ -373,8 +373,9 @@
SET_DATA(data, methods);
- sid_to_string(sid_str, sid);
-
+// sid_to_string(sid_str, sid);
+ sid_string_dbg(sid);
+
return mysqlsam_select_by_field(methods, user, SQL_SEARCH_USER_SID, sid_str);
}
@@ -525,10 +526,10 @@
return mysqlsam_replace_sam_account(methods, newpwd, 1);
}
-static BOOL mysqlsam_rid_algorithm (struct pdb_methods *pdb_methods) {
+static bool mysqlsam_rid_algorithm (struct pdb_methods *pdb_methods) {
return True;
}
-static BOOL mysqlsam_new_rid (struct pdb_methods *pdb_methods, uint32 *rid) {
+static bool mysqlsam_new_rid (struct pdb_methods *pdb_methods, uint32 *rid) {
return False;
}
@@ -550,9 +551,9 @@
(*pdb_method)->name = "mysqlsam";
- (*pdb_method)->setsampwent = mysqlsam_setsampwent;
- (*pdb_method)->endsampwent = mysqlsam_endsampwent;
- (*pdb_method)->getsampwent = mysqlsam_getsampwent;
+// (*pdb_method)->setsampwent = mysqlsam_setsampwent;
+// (*pdb_method)->endsampwent = mysqlsam_endsampwent;
+// (*pdb_method)->getsampwent = mysqlsam_getsampwent;
(*pdb_method)->getsampwnam = mysqlsam_getsampwnam;
(*pdb_method)->getsampwsid = mysqlsam_getsampwsid;
(*pdb_method)->add_sam_account = mysqlsam_add_sam_account;
Modified: branches/pdbsql_3_2/pdb_pgsql.c
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c 2008-06-26 10:45:37 UTC (rev 123)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-06-26 12:58:35 UTC (rev 124)
@@ -21,9 +21,9 @@
* TODO
* * Volker commited Trust domain passwords to be included in the pdb.
* These need to be added here:
- * BOOL get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
- * BOOL set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
- * BOOL del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
+ * bool get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
+ * bool set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
+ * bool del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
* NTSTATUS enum_trusteddoms(struct pdb_methods *methods, TALLOC_CTX *mem_ctx, uint32 *num_domains, struct trustdom_info ***domains)
*/
@@ -228,86 +228,86 @@
return NT_STATUS_OK;
}
-static NTSTATUS pgsqlsam_setsampwent(struct pdb_methods *methods, BOOL update, uint32 acb_mask)
-{
- struct pdb_pgsql_data *data;
- PGconn *handle;
- char *query;
- NTSTATUS retval;
-
- SET_DATA(data, methods);
+//static NTSTATUS pgsqlsam_setsampwent(struct pdb_methods *methods, bool update, uint32 acb_mask)
+//{
+// struct pdb_pgsql_data *data;
+// PGconn *handle;
+// char *query;
+// NTSTATUS retval;
+//
+// SET_DATA(data, methods);
+//
+// /* Connect to the DB. */
+// handle = choose_connection(data);
+// if (handle == NULL) {
+// return NT_STATUS_UNSUCCESSFUL;
+// }
+// DEBUG(5, ("CONNECTING pgsqlsam_setsampwent\n"));
+//
+// query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
+//
+// /* Execute query */
+// DEBUG(5, ("Executing query %s\n", query));
+// data->pwent = PQexec(handle, query);
+// data->currow = 0;
+//
+// /* Result? */
+// if (data->pwent == NULL) {
+// DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
+// retval = NT_STATUS_UNSUCCESSFUL;
+// } else if (PQresultStatus(data->pwent) != PGRES_TUPLES_OK) {
+// DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(data->pwent)));
+// retval = NT_STATUS_UNSUCCESSFUL;
+// } else {
+// DEBUG(5, ("pgsqlsam_setsampwent succeeded(%d results)!\n", PQntuples(data->pwent)));
+// retval = NT_STATUS_OK;
+// }
+//
+// talloc_free(query);
+// return retval;
+//}
- /* Connect to the DB. */
- handle = choose_connection(data);
- if (handle == NULL) {
- return NT_STATUS_UNSUCCESSFUL;
- }
- DEBUG(5, ("CONNECTING pgsqlsam_setsampwent\n"));
-
- query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
-
- /* Execute query */
- DEBUG(5, ("Executing query %s\n", query));
- data->pwent = PQexec(handle, query);
- data->currow = 0;
-
- /* Result? */
- if (data->pwent == NULL) {
- DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
- retval = NT_STATUS_UNSUCCESSFUL;
- } else if (PQresultStatus(data->pwent) != PGRES_TUPLES_OK) {
- DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(data->pwent)));
- retval = NT_STATUS_UNSUCCESSFUL;
- } else {
- DEBUG(5, ("pgsqlsam_setsampwent succeeded(%d results)!\n", PQntuples(data->pwent)));
- retval = NT_STATUS_OK;
- }
-
- talloc_free(query);
- return retval;
-}
-
/***************************************************************
End enumeration of the passwd list.
****************************************************************/
-static void pgsqlsam_endsampwent(struct pdb_methods *methods)
-{
- struct pdb_pgsql_data *data;
-
- SET_DATA_QUIET(data, methods);
-
- if (data->pwent != NULL) {
- PQclear(data->pwent);
- }
-
- data->pwent = NULL;
- data->currow = 0;
-
- DEBUG(5, ("pgsql_endsampwent called\n"));
-}
+//static void pgsqlsam_endsampwent(struct pdb_methods *methods)
+//{
+// struct pdb_pgsql_data *data;
+//
+// SET_DATA_QUIET(data, methods);
+//
+// if (data->pwent != NULL) {
+// PQclear(data->pwent);
+// }
+//
+// data->pwent = NULL;
+// data->currow = 0;
+//
+// DEBUG(5, ("pgsql_endsampwent called\n"));
+//}
/*****************************************************************
Get one struct samu from the list (next in line)
*****************************************************************/
-static NTSTATUS pgsqlsam_getsampwent(struct pdb_methods *methods, struct samu *user)
-{
- struct pdb_pgsql_data *data;
- NTSTATUS retval;
-
- SET_DATA(data, methods);
-
- if (data->pwent == NULL) {
- DEBUG(0, ("invalid pwent\n"));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- retval = row_to_sam_account(data->pwent, data->currow, user);
- data->currow++;
-
- return retval;
-}
+//static NTSTATUS pgsqlsam_getsampwent(struct pdb_methods *methods, struct samu *user)
+//{
+// struct pdb_pgsql_data *data;
+// NTSTATUS retval;
+//
+// SET_DATA(data, methods);
+//
+// if (data->pwent == NULL) {
+// DEBUG(0, ("invalid pwent\n"));
+// return NT_STATUS_INVALID_PARAMETER;
+// }
+//
+// retval = row_to_sam_account(data->pwent, data->currow, user);
+// data->currow++;
+//
+// return retval;
+//}
static NTSTATUS pgsqlsam_select_by_field(struct pdb_methods *methods, struct samu *user, enum sql_search_field field, const char *sname)
{
@@ -544,11 +544,11 @@
return pgsqlsam_replace_sam_account(methods, newpwd, 1);
}
-static BOOL pgsqlsam_rid_algorithm(struct pdb_methods *pdb_methods)
+static bool pgsqlsam_rid_algorithm(struct pdb_methods *pdb_methods)
{
return True;
}
-static BOOL pgsqlsam_new_rid(struct pdb_methods *pdb_methods, uint32 *rid)
+static bool pgsqlsam_new_rid(struct pdb_methods *pdb_methods, uint32 *rid)
{
return False;
}
@@ -573,9 +573,9 @@
(*pdb_method)->name = "pgsqlsam";
- (*pdb_method)->setsampwent = pgsqlsam_setsampwent;
- (*pdb_method)->endsampwent = pgsqlsam_endsampwent;
- (*pdb_method)->getsampwent = pgsqlsam_getsampwent;
+// (*pdb_method)->setsampwent = pgsqlsam_setsampwent;
+// (*pdb_method)->endsampwent = pgsqlsam_endsampwent;
+// (*pdb_method)->getsampwent = pgsqlsam_getsampwent;
(*pdb_method)->getsampwnam = pgsqlsam_getsampwnam;
(*pdb_method)->getsampwsid = pgsqlsam_getsampwsid;
(*pdb_method)->add_sam_account = pgsqlsam_add_sam_account;
Modified: branches/pdbsql_3_2/pdb_sql.c
===================================================================
--- branches/pdbsql_3_2/pdb_sql.c 2008-06-26 10:45:37 UTC (rev 123)
+++ branches/pdbsql_3_2/pdb_sql.c 2008-06-26 12:58:35 UTC (rev 124)
@@ -189,7 +189,7 @@
return (const char *)v;
}
-char *sql_account_query_select(TALLOC_CTX *mem_ctx, const char *data, BOOL update, enum sql_search_field field, const char *value)
+char *sql_account_query_select(TALLOC_CTX *mem_ctx, const char *data, bool update, enum sql_search_field field, const char *value)
{
const char *field_string;
char *query;
@@ -590,7 +590,7 @@
return ret;
}
-BOOL sql_account_config_valid(const char *data)
+bool sql_account_config_valid(const char *data)
{
const char *sid_column, *username_column;
Modified: branches/pdbsql_3_2/pdb_sql.h
===================================================================
--- branches/pdbsql_3_2/pdb_sql.h 2008-06-26 10:45:37 UTC (rev 123)
+++ branches/pdbsql_3_2/pdb_sql.h 2008-06-26 12:58:35 UTC (rev 124)
@@ -32,7 +32,7 @@
char *sql_escape_string(TALLOC_CTX *mem_ctx, const char *unesc);
char *sql_account_query_select(TALLOC_CTX *mem_ctx, const char *data,
- BOOL update, enum sql_search_field field,
+ bool update, enum sql_search_field field,
const char *value);
char *sql_account_query_delete(TALLOC_CTX *mem_ctx, const char *data,
@@ -41,7 +41,7 @@
char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location,
struct samu *newpwd, char isupdate);
-BOOL sql_account_config_valid(const char *data);
+bool sql_account_config_valid(const char *data);
#endif /* _PDB_SQL_H */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-26 10:45:29
|
Revision: 123
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=123&view=rev
Author: collen
Date: 2008-06-26 03:45:37 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
New more comple sql scheme
Added Paths:
-----------
branches/pdbsql_3_2/sql-dumps/samba3.dump
Added: branches/pdbsql_3_2/sql-dumps/samba3.dump
===================================================================
--- branches/pdbsql_3_2/sql-dumps/samba3.dump (rev 0)
+++ branches/pdbsql_3_2/sql-dumps/samba3.dump 2008-06-26 10:45:37 UTC (rev 123)
@@ -0,0 +1,98 @@
+-- MySQL dump 10.11
+--
+-- Host: localhost Database: samba
+-- ------------------------------------------------------
+-- Server version 5.0.51a
+
+--
+-- Table structure for table `domains`
+--
+
+CREATE TABLE `domains` (
+ `domainname` varchar(128) NOT NULL COMMENT 'domain name',
+ `sid` varchar(64) NOT NULL COMMENT 'Security ID',
+ `minpwdlength` int(15) NOT NULL default '5' COMMENT 'minimal password lenght',
+ `pwdhistorylength` int(15) NOT NULL default '0' COMMENT 'password history length',
+ `logontochgpwd` int(2) NOT NULL default '0' COMMENT 'logon for password change',
+ `forcelogoff` int(2) NOT NULL default '-1' COMMENT 'Disconnect users outside logon hours',
+ `refusemachinepwdchange` int(2) unsigned NOT NULL default '0' COMMENT 'Allow machine password change',
+ `lockoutthreshold` int(2) NOT NULL default '0' COMMENT 'lockout users after bad logon attempts',
+ `minpwdage` int(2) NOT NULL default '0' COMMENT 'minimum password age (seconds)',
+ `maxpwdage` int(2) NOT NULL default '-1' COMMENT 'Maximum password age (seconds, -1 never)',
+ `lockoutduration` int(2) NOT NULL default '30' COMMENT 'Lockout duration minutes (-1 forever)',
+ `lockoutobservationwindow` int(2) NOT NULL default '30' COMMENT 'Reset time after lockout (minutes)',
+ `nextrid` int(2) NOT NULL COMMENT 'Next NT RID',
+ `nextuserrid` int(50) NOT NULL COMMENT 'Next NT RID to give our users',
+ `nextgrouprid` int(50) NOT NULL COMMENT 'Next NT group RID',
+ `algorithmicridbase` int(50) NOT NULL COMMENT 'RID base'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `groups`
+--
+
+CREATE TABLE `groups` (
+ `gidnumber` int(11) NOT NULL COMMENT 'Group identifyer in an domain',
+ `description` varchar(1024) default NULL COMMENT 'Descriptive Information',
+ `displayname` varchar(50) default NULL COMMENT 'Preferrence name to be used when displaying entries',
+ `grouptype` int(11) default NULL COMMENT 'NT Group type',
+ `sid` varchar(64) NOT NULL COMMENT 'Security ID'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `hosts`
+--
+
+CREATE TABLE `hosts` (
+ `id` int(10) unsigned default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `user`
+--
+
+CREATE TABLE `user` (
+ `logon_time` int(9) default NULL,
+ `logoff_time` int(9) default NULL,
+ `kickoff_time` int(9) default NULL,
+ `pass_last_set_time` int(9) default NULL,
+ `pass_can_change_time` int(9) default '0',
+ `pass_must_change_time` int(9) default '2147483647',
+ `username` varchar(255) default NULL,
+ `domain` varchar(255) default NULL,
+ `nt_username` varchar(255) default NULL,
+ `nt_fullname` varchar(255) default NULL,
+ `home_dir` varchar(255) default NULL,
+ `dir_drive` varchar(4) default NULL,
+ `logon_script` varchar(255) default NULL,
+ `profile_path` varchar(255) default NULL,
+ `acct_desc` varchar(255) default NULL,
+ `workstations` varchar(255) default NULL,
+ `unknown_str` varchar(255) default NULL,
+ `munged_dial` varchar(255) default NULL,
+ `uid` int(9) NOT NULL auto_increment,
+ `gid` int(9) default NULL,
+ `user_sid` varchar(255) default NULL,
+ `group_sid` varchar(255) default NULL,
+ `lm_pw` varchar(255) default NULL,
+ `nt_pw` varchar(255) default NULL,
+ `acct_ctrl` int(9) default '528',
+ `logon_divs` int(9) default '168',
+ `hours_len` int(9) default '21',
+ `unknown_6` int(9) default '1260',
+ `bad_password_count` int(9) default NULL,
+ `logon_count` int(9) default '0',
+ `logon_hours` varchar(42) default NULL,
+ `password_history` text,
+ PRIMARY KEY (`uid`),
+ KEY `username` (`username`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `users`
+--
+
+CREATE TABLE `users` (
+ `sid` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-26 10:43:50
|
Revision: 122
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=122&view=rev
Author: collen
Date: 2008-06-26 03:43:57 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
New more comple sql scheme
Modified Paths:
--------------
branches/pdbsql_3_2/sql-dumps/mysql.dump
Modified: branches/pdbsql_3_2/sql-dumps/mysql.dump
===================================================================
--- branches/pdbsql_3_2/sql-dumps/mysql.dump 2008-06-23 10:51:52 UTC (rev 121)
+++ branches/pdbsql_3_2/sql-dumps/mysql.dump 2008-06-26 10:43:57 UTC (rev 122)
@@ -36,3 +36,7 @@
password_history text default NULL,
KEY username(username)
);
+
+CREATE TABLE group (
+ group varchar(255) default NULL,
+);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:51:43
|
Revision: 121
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=121&view=rev
Author: collen
Date: 2008-06-23 03:51:52 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/docs/pgsql.dump
Copied: branches/pdbsql_3_2/docs/pgsql.dump (from rev 120, branches/pdbsql_3_2/sql-dumps/pgsql.dump)
===================================================================
--- branches/pdbsql_3_2/docs/pgsql.dump (rev 0)
+++ branches/pdbsql_3_2/docs/pgsql.dump 2008-06-23 10:51:52 UTC (rev 121)
@@ -0,0 +1,39 @@
+/*
+ * Import this file with psql < pgsql.dump
+ */
+CREATE TABLE users (
+ logon_time integer default NULL,
+ logoff_time integer default NULL,
+ kickoff_time integer default NULL,
+ pass_last_set_time integer default NULL,
+ pass_can_change_time integer default '0',
+ pass_must_change_time integer default '2147483647',
+ username varchar(255) default NULL,
+ domain varchar(255) default NULL,
+ nt_username varchar(255) default NULL,
+ nt_fullname varchar(255) default NULL,
+ home_dir varchar(255) default NULL,
+ dir_drive varchar(4) default NULL,
+ logon_script varchar(255) default NULL,
+ profile_path varchar(255) default NULL,
+ acct_desc varchar(255) default NULL,
+ workstations varchar(255) default NULL,
+ unknown_str varchar(255) default NULL,
+ munged_dial varchar(255) default NULL,
+ uid SERIAL NOT NULL PRIMARY KEY,
+ gid integer default NULL,
+ user_sid varchar(255) default NULL,
+ group_sid varchar(255) default NULL,
+ lm_pw varchar(255) default NULL,
+ nt_pw varchar(255) default NULL,
+ acct_ctrl integer default '528',
+ logon_divs integer default '168',
+ hours_len integer default '21',
+ unknown_6 integer default '1260',
+ bad_password_count integer default NULL,
+ logon_count integer default '0',
+ logon_hours varchar(42) default NULL,
+ password_history text default NULL,
+ UNIQUE (username),
+ UNIQUE (nt_username)
+);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:51:30
|
Revision: 120
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=120&view=rev
Author: collen
Date: 2008-06-23 03:51:39 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/docs/mysql.dump
Copied: branches/pdbsql_3_2/docs/mysql.dump (from rev 119, branches/pdbsql_3_2/sql-dumps/mysql.dump)
===================================================================
--- branches/pdbsql_3_2/docs/mysql.dump (rev 0)
+++ branches/pdbsql_3_2/docs/mysql.dump 2008-06-23 10:51:39 UTC (rev 120)
@@ -0,0 +1,38 @@
+# Put this in your MySQL database by running
+# mysql -u<user> -p<password> -h<host> <database> < mysql.dump
+
+CREATE TABLE user (
+ logon_time int(9) default NULL,
+ logoff_time int(9) default NULL,
+ kickoff_time int(9) default NULL,
+ pass_last_set_time int(9) default NULL,
+ pass_can_change_time int(9) default '0',
+ pass_must_change_time int(9) default '2147483647',
+ username varchar(255) default NULL,
+ domain varchar(255) default NULL,
+ nt_username varchar(255) default NULL,
+ nt_fullname varchar(255) default NULL,
+ home_dir varchar(255) default NULL,
+ dir_drive varchar(4) default NULL,
+ logon_script varchar(255) default NULL,
+ profile_path varchar(255) default NULL,
+ acct_desc varchar(255) default NULL,
+ workstations varchar(255) default NULL,
+ unknown_str varchar(255) default NULL,
+ munged_dial varchar(255) default NULL,
+ uid int(9) NOT NULL PRIMARY KEY auto_increment,
+ gid int(9) default NULL,
+ user_sid varchar(255) default NULL,
+ group_sid varchar(255) default NULL,
+ lm_pw varchar(255) default NULL,
+ nt_pw varchar(255) default NULL,
+ acct_ctrl int(9) default '528',
+ logon_divs int(9) default '168',
+ hours_len int(9) default '21',
+ unknown_6 int(9) default "1260",
+ bad_password_count int(9) default NULL,
+ logon_count int(9) default '0',
+ logon_hours varchar(42) default NULL,
+ password_history text default NULL,
+ KEY username(username)
+);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:50:28
|
Revision: 119
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=119&view=rev
Author: collen
Date: 2008-06-23 03:50:37 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/sql-dumps/pgsql.dump
Removed Paths:
-------------
branches/pdbsql_3_2/docs/pgsql.dump
Deleted: branches/pdbsql_3_2/docs/pgsql.dump
===================================================================
--- branches/pdbsql_3_2/docs/pgsql.dump 2008-06-23 10:50:26 UTC (rev 118)
+++ branches/pdbsql_3_2/docs/pgsql.dump 2008-06-23 10:50:37 UTC (rev 119)
@@ -1,39 +0,0 @@
-/*
- * Import this file with psql < pgsql.dump
- */
-CREATE TABLE users (
- logon_time integer default NULL,
- logoff_time integer default NULL,
- kickoff_time integer default NULL,
- pass_last_set_time integer default NULL,
- pass_can_change_time integer default '0',
- pass_must_change_time integer default '2147483647',
- username varchar(255) default NULL,
- domain varchar(255) default NULL,
- nt_username varchar(255) default NULL,
- nt_fullname varchar(255) default NULL,
- home_dir varchar(255) default NULL,
- dir_drive varchar(4) default NULL,
- logon_script varchar(255) default NULL,
- profile_path varchar(255) default NULL,
- acct_desc varchar(255) default NULL,
- workstations varchar(255) default NULL,
- unknown_str varchar(255) default NULL,
- munged_dial varchar(255) default NULL,
- uid SERIAL NOT NULL PRIMARY KEY,
- gid integer default NULL,
- user_sid varchar(255) default NULL,
- group_sid varchar(255) default NULL,
- lm_pw varchar(255) default NULL,
- nt_pw varchar(255) default NULL,
- acct_ctrl integer default '528',
- logon_divs integer default '168',
- hours_len integer default '21',
- unknown_6 integer default '1260',
- bad_password_count integer default NULL,
- logon_count integer default '0',
- logon_hours varchar(42) default NULL,
- password_history text default NULL,
- UNIQUE (username),
- UNIQUE (nt_username)
-);
Copied: branches/pdbsql_3_2/sql-dumps/pgsql.dump (from rev 118, branches/pdbsql_3_2/docs/pgsql.dump)
===================================================================
--- branches/pdbsql_3_2/sql-dumps/pgsql.dump (rev 0)
+++ branches/pdbsql_3_2/sql-dumps/pgsql.dump 2008-06-23 10:50:37 UTC (rev 119)
@@ -0,0 +1,39 @@
+/*
+ * Import this file with psql < pgsql.dump
+ */
+CREATE TABLE users (
+ logon_time integer default NULL,
+ logoff_time integer default NULL,
+ kickoff_time integer default NULL,
+ pass_last_set_time integer default NULL,
+ pass_can_change_time integer default '0',
+ pass_must_change_time integer default '2147483647',
+ username varchar(255) default NULL,
+ domain varchar(255) default NULL,
+ nt_username varchar(255) default NULL,
+ nt_fullname varchar(255) default NULL,
+ home_dir varchar(255) default NULL,
+ dir_drive varchar(4) default NULL,
+ logon_script varchar(255) default NULL,
+ profile_path varchar(255) default NULL,
+ acct_desc varchar(255) default NULL,
+ workstations varchar(255) default NULL,
+ unknown_str varchar(255) default NULL,
+ munged_dial varchar(255) default NULL,
+ uid SERIAL NOT NULL PRIMARY KEY,
+ gid integer default NULL,
+ user_sid varchar(255) default NULL,
+ group_sid varchar(255) default NULL,
+ lm_pw varchar(255) default NULL,
+ nt_pw varchar(255) default NULL,
+ acct_ctrl integer default '528',
+ logon_divs integer default '168',
+ hours_len integer default '21',
+ unknown_6 integer default '1260',
+ bad_password_count integer default NULL,
+ logon_count integer default '0',
+ logon_hours varchar(42) default NULL,
+ password_history text default NULL,
+ UNIQUE (username),
+ UNIQUE (nt_username)
+);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:50:19
|
Revision: 118
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=118&view=rev
Author: collen
Date: 2008-06-23 03:50:26 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/sql-dumps/mysql.dump
Removed Paths:
-------------
branches/pdbsql_3_2/docs/mysql.dump
Deleted: branches/pdbsql_3_2/docs/mysql.dump
===================================================================
--- branches/pdbsql_3_2/docs/mysql.dump 2008-06-23 10:47:58 UTC (rev 117)
+++ branches/pdbsql_3_2/docs/mysql.dump 2008-06-23 10:50:26 UTC (rev 118)
@@ -1,38 +0,0 @@
-# Put this in your MySQL database by running
-# mysql -u<user> -p<password> -h<host> <database> < mysql.dump
-
-CREATE TABLE user (
- logon_time int(9) default NULL,
- logoff_time int(9) default NULL,
- kickoff_time int(9) default NULL,
- pass_last_set_time int(9) default NULL,
- pass_can_change_time int(9) default '0',
- pass_must_change_time int(9) default '2147483647',
- username varchar(255) default NULL,
- domain varchar(255) default NULL,
- nt_username varchar(255) default NULL,
- nt_fullname varchar(255) default NULL,
- home_dir varchar(255) default NULL,
- dir_drive varchar(4) default NULL,
- logon_script varchar(255) default NULL,
- profile_path varchar(255) default NULL,
- acct_desc varchar(255) default NULL,
- workstations varchar(255) default NULL,
- unknown_str varchar(255) default NULL,
- munged_dial varchar(255) default NULL,
- uid int(9) NOT NULL PRIMARY KEY auto_increment,
- gid int(9) default NULL,
- user_sid varchar(255) default NULL,
- group_sid varchar(255) default NULL,
- lm_pw varchar(255) default NULL,
- nt_pw varchar(255) default NULL,
- acct_ctrl int(9) default '528',
- logon_divs int(9) default '168',
- hours_len int(9) default '21',
- unknown_6 int(9) default "1260",
- bad_password_count int(9) default NULL,
- logon_count int(9) default '0',
- logon_hours varchar(42) default NULL,
- password_history text default NULL,
- KEY username(username)
-);
Copied: branches/pdbsql_3_2/sql-dumps/mysql.dump (from rev 117, branches/pdbsql_3_2/docs/mysql.dump)
===================================================================
--- branches/pdbsql_3_2/sql-dumps/mysql.dump (rev 0)
+++ branches/pdbsql_3_2/sql-dumps/mysql.dump 2008-06-23 10:50:26 UTC (rev 118)
@@ -0,0 +1,38 @@
+# Put this in your MySQL database by running
+# mysql -u<user> -p<password> -h<host> <database> < mysql.dump
+
+CREATE TABLE user (
+ logon_time int(9) default NULL,
+ logoff_time int(9) default NULL,
+ kickoff_time int(9) default NULL,
+ pass_last_set_time int(9) default NULL,
+ pass_can_change_time int(9) default '0',
+ pass_must_change_time int(9) default '2147483647',
+ username varchar(255) default NULL,
+ domain varchar(255) default NULL,
+ nt_username varchar(255) default NULL,
+ nt_fullname varchar(255) default NULL,
+ home_dir varchar(255) default NULL,
+ dir_drive varchar(4) default NULL,
+ logon_script varchar(255) default NULL,
+ profile_path varchar(255) default NULL,
+ acct_desc varchar(255) default NULL,
+ workstations varchar(255) default NULL,
+ unknown_str varchar(255) default NULL,
+ munged_dial varchar(255) default NULL,
+ uid int(9) NOT NULL PRIMARY KEY auto_increment,
+ gid int(9) default NULL,
+ user_sid varchar(255) default NULL,
+ group_sid varchar(255) default NULL,
+ lm_pw varchar(255) default NULL,
+ nt_pw varchar(255) default NULL,
+ acct_ctrl int(9) default '528',
+ logon_divs int(9) default '168',
+ hours_len int(9) default '21',
+ unknown_6 int(9) default "1260",
+ bad_password_count int(9) default NULL,
+ logon_count int(9) default '0',
+ logon_hours varchar(42) default NULL,
+ password_history text default NULL,
+ KEY username(username)
+);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:47:48
|
Revision: 117
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=117&view=rev
Author: collen
Date: 2008-06-23 03:47:58 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
New sql databases
Added Paths:
-----------
branches/pdbsql_3_2/sql-dumps/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:46:06
|
Revision: 116
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=116&view=rev
Author: collen
Date: 2008-06-23 03:46:15 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Removed Paths:
-------------
branches/pdbsql_3_2/trunk/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:45:19
|
Revision: 115
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=115&view=rev
Author: collen
Date: 2008-06-23 03:45:28 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/pdb_sql.h
Copied: branches/pdbsql_3_2/pdb_sql.h (from rev 114, branches/pdbsql_3_2/trunk/pdb_sql.h)
===================================================================
--- branches/pdbsql_3_2/pdb_sql.h (rev 0)
+++ branches/pdbsql_3_2/pdb_sql.h 2008-06-23 10:45:28 UTC (rev 115)
@@ -0,0 +1,47 @@
+/*
+ * Common PDB SQL backend functions
+ * Copyright (C) Jelmer Vernooij 2003-2004
+ *
+ * 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"
+
+#ifndef _PDB_SQL_H
+#define _PDB_SQL_H
+
+enum sql_search_field {
+ SQL_SEARCH_NONE = 0,
+ SQL_SEARCH_USER_SID = 1,
+ SQL_SEARCH_USER_NAME = 2
+};
+
+
+char *sql_escape_string(TALLOC_CTX *mem_ctx, const char *unesc);
+
+char *sql_account_query_select(TALLOC_CTX *mem_ctx, const char *data,
+ BOOL update, enum sql_search_field field,
+ const char *value);
+
+char *sql_account_query_delete(TALLOC_CTX *mem_ctx, const char *data,
+ const char *esc);
+
+char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location,
+ struct samu *newpwd, char isupdate);
+
+BOOL sql_account_config_valid(const char *data);
+
+#endif /* _PDB_SQL_H */
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:45:05
|
Revision: 114
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=114&view=rev
Author: collen
Date: 2008-06-23 03:45:14 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/pdb_sql.c
Copied: branches/pdbsql_3_2/pdb_sql.c (from rev 113, branches/pdbsql_3_2/trunk/pdb_sql.c)
===================================================================
--- branches/pdbsql_3_2/pdb_sql.c (rev 0)
+++ branches/pdbsql_3_2/pdb_sql.c 2008-06-23 10:45:14 UTC (rev 114)
@@ -0,0 +1,606 @@
+/*
+ * Common PDB SQL backend functions
+ * Copyright (C) Jelmer Vernooij 2003-2004
+ * Copyright (C) Collen Blijenberg 2007-2008
+ *
+ * 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 "pdb_sql.h"
+
+#define CONFIG_TABLE_DEFAULT "user"
+#define CONFIG_LOGON_TIME_DEFAULT "logon_time"
+#define CONFIG_LOGOFF_TIME_DEFAULT "logoff_time"
+#define CONFIG_KICKOFF_TIME_DEFAULT "kickoff_time"
+#define CONFIG_PASS_LAST_SET_TIME_DEFAULT "pass_last_set_time"
+#define CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT "pass_can_change_time"
+#define CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT "pass_must_change_time"
+#define CONFIG_USERNAME_DEFAULT "username"
+#define CONFIG_DOMAIN_DEFAULT "domain"
+#define CONFIG_NT_USERNAME_DEFAULT "nt_username"
+#define CONFIG_FULLNAME_DEFAULT "nt_fullname"
+#define CONFIG_HOME_DIR_DEFAULT "home_dir"
+#define CONFIG_DIR_DRIVE_DEFAULT "dir_drive"
+#define CONFIG_LOGON_SCRIPT_DEFAULT "logon_script"
+#define CONFIG_PROFILE_PATH_DEFAULT "profile_path"
+#define CONFIG_ACCT_DESC_DEFAULT "acct_desc"
+#define CONFIG_WORKSTATIONS_DEFAULT "workstations"
+#define CONFIG_UNKNOWN_STR_DEFAULT "unknown_str"
+#define CONFIG_MUNGED_DIAL_DEFAULT "munged_dial"
+#define CONFIG_USER_SID_DEFAULT "user_sid"
+#define CONFIG_GROUP_SID_DEFAULT "group_sid"
+#define CONFIG_LM_PW_DEFAULT "lm_pw"
+#define CONFIG_NT_PW_DEFAULT "nt_pw"
+#define CONFIG_PLAIN_PW_DEFAULT "NULL"
+#define CONFIG_ACCT_CTRL_DEFAULT "acct_ctrl"
+#define CONFIG_LOGON_DIVS_DEFAULT "logon_divs"
+#define CONFIG_HOURS_LEN_DEFAULT "hours_len"
+#define CONFIG_BAD_PASSWORD_COUNT_DEFAULT "bad_password_count"
+#define CONFIG_LOGON_COUNT_DEFAULT "logon_count"
+#define CONFIG_UNKNOWN_6_DEFAULT "unknown_6"
+#define CONFIG_LOGON_HOURS_DEFAULT "logon_hours"
+#define CONFIG_PASSWORD_HISTORY_DEFAULT "password_history"
+
+/* Used to construct insert and update queries */
+
+typedef struct pdb_sql_query {
+ char update;
+ char *part1;
+ char *part2;
+} pdb_sql_query;
+
+static void pdb_sql_int_field(struct pdb_sql_query *q, const char *name, long value)
+{
+ if (!name || strchr(name, '\''))
+ return; /* This field shouldn't be set by us */
+
+ if (q->update) {
+ q->part1 =
+ talloc_asprintf_append(q->part1,
+ "%s = %ld,", name, value);
+ } else {
+ q->part1 =
+ talloc_asprintf_append(q->part1, "%s,", name);
+ q->part2 =
+ talloc_asprintf_append(q->part2, "%ld,", value);
+ }
+}
+
+char *sql_escape_string(TALLOC_CTX *mem_ctx, const char *unesc)
+{
+ char *esc = talloc_array(mem_ctx, char, strlen(unesc) * 2 + 3);
+ size_t pos_unesc = 0, pos_esc = 0;
+
+ for(pos_unesc = 0; unesc[pos_unesc]; pos_unesc++) {
+ switch(unesc[pos_unesc]) {
+ case '\\':
+ case '\'':
+ case '"':
+ esc[pos_esc] = '\\'; pos_esc++;
+ default:
+ esc[pos_esc] = unesc[pos_unesc]; pos_esc++;
+ break;
+ }
+ }
+
+ esc[pos_esc] = '\0';
+
+ return esc;
+}
+
+static NTSTATUS pdb_sql_string_field(struct pdb_sql_query *q,
+ const char *name, const char *value)
+{
+ char *esc_value;
+
+ if (!name || !value || !strcmp(value, "") || strchr(name, '\''))
+ return NT_STATUS_INVALID_PARAMETER; /* This field shouldn't be set by module */
+
+ esc_value = sql_escape_string(q, value);
+
+ if (q->update) {
+ q->part1 =
+ talloc_asprintf_append(q->part1,
+ "%s = '%s',", name, esc_value);
+ } else {
+ q->part1 =
+ talloc_asprintf_append(q->part1, "%s,", name);
+ q->part2 =
+ talloc_asprintf_append(q->part2, "'%s',",
+ esc_value);
+ }
+
+ talloc_free(esc_value);
+
+ return NT_STATUS_OK;
+}
+
+#define config_value(data,name,default_value) \
+ lp_parm_const_string(GLOBAL_SECTION_SNUM, data, name, default_value)
+
+static const char * config_value_write(const char *location, const char *name, const char *default_value)
+{
+ char const *v = NULL;
+ char const *swrite = NULL;
+
+ v = lp_parm_const_string(GLOBAL_SECTION_SNUM, location, name, default_value);
+
+ if (!v)
+ return NULL;
+
+ swrite = strrchr(v, ':');
+
+ /* Default to the same field as read field */
+ if (!swrite) {
+
+ /* Updating NULL does not make much sense */
+ if (!strcmp(v, "NULL"))
+ return NULL;
+
+ return v;
+ }
+
+ swrite++;
+
+ /* If the field is 0 chars long, we shouldn't write to it */
+ if (!strlen(swrite) || !strcmp(swrite, "NULL"))
+ return NULL;
+
+ /* Otherwise, use the additionally specified */
+ return swrite;
+}
+
+static const char * config_value_read(const char *location, const char *name, const char *default_value)
+{
+ char *v = NULL;
+ char *swrite;
+
+ v = lp_parm_talloc_string(GLOBAL_SECTION_SNUM, location, name, default_value);
+
+ if (!v)
+ return "NULL";
+
+ swrite = strrchr(v, ':');
+
+ /* If no write is specified, there are no problems */
+ if (!swrite) {
+ if (strlen(v) == 0)
+ return "NULL";
+ return (const char *)v;
+ }
+
+ /* Otherwise, we have to cut the ':write_part' */
+ *swrite = '\0';
+ if (strlen(v) == 0)
+ return "NULL";
+
+ return (const char *)v;
+}
+
+char *sql_account_query_select(TALLOC_CTX *mem_ctx, const char *data, BOOL update, enum sql_search_field field, const char *value)
+{
+ const char *field_string;
+ char *query;
+
+ switch(field) {
+ case SQL_SEARCH_NONE:
+ field_string = "'1'";
+ value = "1";
+ break;
+
+ case SQL_SEARCH_USER_SID:
+ field_string = config_value_read(data, "user sid column",
+ CONFIG_USER_SID_DEFAULT);
+ break;
+
+ case SQL_SEARCH_USER_NAME:
+ field_string = config_value_read(data, "username column",
+ CONFIG_USERNAME_DEFAULT);
+ break;
+ default:
+ field_string = "unknown";
+ break;
+ }
+
+ query = talloc_asprintf(mem_ctx,
+ "SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s WHERE %s = '%s'",
+ config_value_read(data, "logon time column",
+ CONFIG_LOGON_TIME_DEFAULT),
+ config_value_read(data, "logoff time column",
+ CONFIG_LOGOFF_TIME_DEFAULT),
+ config_value_read(data, "kickoff time column",
+ CONFIG_KICKOFF_TIME_DEFAULT),
+ config_value_read(data, "pass last set time column",
+ CONFIG_PASS_LAST_SET_TIME_DEFAULT),
+ config_value_read(data, "pass can change time column",
+ CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT),
+ config_value_read(data, "pass must change time column",
+ CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT),
+ config_value_read(data, "username column",
+ CONFIG_USERNAME_DEFAULT),
+ config_value_read(data, "domain column",
+ CONFIG_DOMAIN_DEFAULT),
+ config_value_read(data, "nt username column",
+ CONFIG_NT_USERNAME_DEFAULT),
+ config_value_read(data, "fullname column",
+ CONFIG_FULLNAME_DEFAULT),
+ config_value_read(data, "home dir column",
+ CONFIG_HOME_DIR_DEFAULT),
+ config_value_read(data, "dir drive column",
+ CONFIG_DIR_DRIVE_DEFAULT),
+ config_value_read(data, "logon script column",
+ CONFIG_LOGON_SCRIPT_DEFAULT),
+ config_value_read(data, "profile path column",
+ CONFIG_PROFILE_PATH_DEFAULT),
+ config_value_read(data, "acct desc column",
+ CONFIG_ACCT_DESC_DEFAULT),
+ config_value_read(data, "workstations column",
+ CONFIG_WORKSTATIONS_DEFAULT),
+ config_value_read(data, "unknown string column",
+ CONFIG_UNKNOWN_STR_DEFAULT),
+ config_value_read(data, "munged dial column",
+ CONFIG_MUNGED_DIAL_DEFAULT),
+ config_value_read(data, "user sid column",
+ CONFIG_USER_SID_DEFAULT),
+ config_value_read(data, "group sid column",
+ CONFIG_GROUP_SID_DEFAULT),
+ config_value_read(data, "lanman pass column",
+ CONFIG_LM_PW_DEFAULT),
+ config_value_read(data, "nt pass column",
+ CONFIG_NT_PW_DEFAULT),
+ config_value_read(data, "plain pass column",
+ CONFIG_PLAIN_PW_DEFAULT),
+ config_value_read(data, "acct ctrl column",
+ CONFIG_ACCT_CTRL_DEFAULT),
+ config_value_read(data, "logon divs column",
+ CONFIG_LOGON_DIVS_DEFAULT),
+ config_value_read(data, "hours len column",
+ CONFIG_HOURS_LEN_DEFAULT),
+ config_value_read(data, "bad password count column",
+ CONFIG_BAD_PASSWORD_COUNT_DEFAULT),
+ config_value_read(data, "logon count column",
+ CONFIG_LOGON_COUNT_DEFAULT),
+ config_value_read(data, "unknown 6 column",
+ CONFIG_UNKNOWN_6_DEFAULT),
+ config_value_read(data, "logon hours column",
+ CONFIG_LOGON_HOURS_DEFAULT),
+ config_value_read(data, "password history column",
+ CONFIG_PASSWORD_HISTORY_DEFAULT),
+ config_value(data, "table", CONFIG_TABLE_DEFAULT),
+ field_string, value
+ );
+ return (char *)query;
+}
+
+char *sql_account_query_delete(TALLOC_CTX *mem_ctx, const char *data, const char *esc)
+{
+ char *query;
+
+ query = talloc_asprintf(mem_ctx, "DELETE FROM %s WHERE %s = '%s'",
+ config_value(data, "table", CONFIG_TABLE_DEFAULT),
+ config_value_read(data, "username column",
+ CONFIG_USERNAME_DEFAULT), esc);
+ return query;
+}
+
+char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, struct samu *newpwd, char isupdate)
+{
+ char *ret;
+ pstring temp;
+ fstring sid_str;
+ pdb_sql_query *query;
+ int some_field_affected = 0;
+
+ query = talloc(mem_ctx, pdb_sql_query);
+ query->update = isupdate;
+
+ /* I know this is somewhat overkill but only the talloc
+ * functions have asprint_append and the 'normal' asprintf
+ * is a GNU extension */
+ query->part2 = talloc_asprintf(query, "%s", "");
+ if (query->update) {
+ query->part1 =
+ talloc_asprintf(query, "UPDATE %s SET ",
+ config_value(location, "table",
+ CONFIG_TABLE_DEFAULT));
+ } else {
+ query->part1 =
+ talloc_asprintf(query, "INSERT INTO %s (",
+ config_value(location, "table",
+ CONFIG_TABLE_DEFAULT));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_ACCTCTRL)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location, "acct ctrl column",
+ CONFIG_ACCT_CTRL_DEFAULT),
+ pdb_get_acct_ctrl(newpwd));
+ }
+
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGONTIME)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "logon time column",
+ CONFIG_LOGON_TIME_DEFAULT),
+ pdb_get_logon_time(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGOFFTIME)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "logoff time column",
+ CONFIG_LOGOFF_TIME_DEFAULT),
+ pdb_get_logoff_time(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_KICKOFFTIME)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "kickoff time column",
+ CONFIG_KICKOFF_TIME_DEFAULT),
+ pdb_get_kickoff_time(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_CANCHANGETIME)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "pass can change time column",
+ CONFIG_PASS_CAN_CHANGE_TIME_DEFAULT),
+ pdb_get_pass_can_change_time(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_MUSTCHANGETIME)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "pass must change time column",
+ CONFIG_PASS_MUST_CHANGE_TIME_DEFAULT),
+ pdb_get_pass_must_change_time(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_PASSLASTSET)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "pass last set time column",
+ CONFIG_PASS_LAST_SET_TIME_DEFAULT),
+ pdb_get_pass_last_set_time(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_HOURSLEN)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "hours len column",
+ CONFIG_HOURS_LEN_DEFAULT),
+ pdb_get_hours_len(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGONDIVS)) {
+ some_field_affected = 1;
+ pdb_sql_int_field(query,
+ config_value_write(location,
+ "logon divs column",
+ CONFIG_LOGON_DIVS_DEFAULT),
+ pdb_get_logon_divs(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_USERSID)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "user sid column",
+ CONFIG_USER_SID_DEFAULT),
+ sid_to_string(sid_str,
+ pdb_get_user_sid(newpwd)));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_GROUPSID)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "group sid column",
+ CONFIG_GROUP_SID_DEFAULT),
+ sid_to_string(sid_str,
+ pdb_get_group_sid(newpwd)));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_USERNAME)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "username column",
+ CONFIG_USERNAME_DEFAULT),
+ pdb_get_username(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_DOMAIN)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "domain column",
+ CONFIG_DOMAIN_DEFAULT),
+ pdb_get_domain(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_USERNAME)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "nt username column",
+ CONFIG_NT_USERNAME_DEFAULT),
+ pdb_get_nt_username(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_FULLNAME)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "fullname column",
+ CONFIG_FULLNAME_DEFAULT),
+ pdb_get_fullname(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGONSCRIPT)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "logon script column",
+ CONFIG_LOGON_SCRIPT_DEFAULT),
+ pdb_get_logon_script(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_PROFILE)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "profile path column",
+ CONFIG_PROFILE_PATH_DEFAULT),
+ pdb_get_profile_path(newpwd));
+ }
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_ACCTDESC)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "acct desc column",
+ CONFIG_ACCT_DESC_DEFAULT),
+ pdb_get_acct_desc(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_DRIVE)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "dir drive column",
+ CONFIG_DIR_DRIVE_DEFAULT),
+ pdb_get_dir_drive(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_SMBHOME)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location, "home dir column",
+ CONFIG_HOME_DIR_DEFAULT),
+ pdb_get_homedir(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_WORKSTATIONS)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "workstations column",
+ CONFIG_WORKSTATIONS_DEFAULT),
+ pdb_get_workstations(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_COMMENT)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "unknown string column",
+ CONFIG_UNKNOWN_STR_DEFAULT),
+ pdb_get_comment(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LMPASSWD)) {
+ some_field_affected = 1;
+ pdb_sethexpwd(temp, pdb_get_lanman_passwd(newpwd),
+ pdb_get_acct_ctrl(newpwd));
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "lanman pass column",
+ CONFIG_LM_PW_DEFAULT), temp);
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_NTPASSWD)) {
+ some_field_affected = 1;
+ pdb_sethexpwd(temp, pdb_get_nt_passwd(newpwd),
+ pdb_get_acct_ctrl(newpwd));
+ pdb_sql_string_field(query,
+ config_value_write(location, "nt pass column",
+ CONFIG_NT_PW_DEFAULT), temp);
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_HOURS)) {
+ some_field_affected = 1;
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "logon hours column",
+ CONFIG_LOGON_HOURS_DEFAULT),
+ (const char *)pdb_get_hours(newpwd));
+ }
+
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_PWHISTORY)) {
+ uint32 pw_history_len = 0;
+ uint32 max_history_len = 0;
+ int i;
+ const uint8 *pwhist;
+
+ pwhist = pdb_get_pw_history(newpwd, &pw_history_len);
+
+ pdb_get_account_policy(AP_PASSWORD_HISTORY, &max_history_len);
+
+ some_field_affected = 1;
+ for (i = 0; i < max_history_len && i < pw_history_len; i++) {
+ pdb_sethexpwd(&temp[i*64], &pwhist[i*PW_HISTORY_ENTRY_LEN], 0);
+ pdb_sethexpwd(&temp[i*64+32],
+ &pwhist[(i*PW_HISTORY_ENTRY_LEN)+PW_HISTORY_SALT_LEN], 0);
+ }
+ pdb_sql_string_field(query,
+ config_value_write(location,
+ "password history column",
+ CONFIG_PASSWORD_HISTORY_DEFAULT),
+ temp);
+ }
+
+ if (!some_field_affected) {
+ talloc_free(query);
+ return NULL;
+ }
+
+ if (query->update) {
+ query->part1[strlen(query->part1) - 1] = '\0';
+ query->part1 = talloc_asprintf(
+ mem_ctx, "%s WHERE %s = '%s'", query->part1,
+ config_value_read(location,
+ "user sid column",
+ CONFIG_USER_SID_DEFAULT),
+ sid_to_string(sid_str, pdb_get_user_sid (newpwd)));
+ } else {
+ query->part2[strlen(query->part2) - 1] = ')';
+ query->part1[strlen(query->part1) - 1] = ')';
+ query->part1 =
+ talloc_asprintf_append(query->part1,
+ " VALUES (%s", query->part2);
+ }
+
+ ret = talloc_strdup(mem_ctx, query->part1);
+ talloc_free(query);
+ return ret;
+}
+
+BOOL sql_account_config_valid(const char *data)
+{
+ const char *sid_column, *username_column;
+
+ sid_column = config_value_read(data, "user sid column", CONFIG_USER_SID_DEFAULT);
+ username_column = config_value_read(data, "username column", CONFIG_USERNAME_DEFAULT);
+
+ if(!strcmp(sid_column,"NULL") || !strcmp(username_column, "NULL")) {
+ DEBUG(0,("Please specify both a valid 'user sid column' and a valid 'username column' in smb.conf\n"));
+ return False;
+ }
+
+ return True;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <co...@us...> - 2008-06-23 10:44:52
|
Revision: 113
http://pdbsql.svn.sourceforge.net/pdbsql/?rev=113&view=rev
Author: collen
Date: 2008-06-23 03:45:01 -0700 (Mon, 23 Jun 2008)
Log Message:
-----------
Added Paths:
-----------
branches/pdbsql_3_2/pdb_pgsql.c
Copied: branches/pdbsql_3_2/pdb_pgsql.c (from rev 112, branches/pdbsql_3_2/trunk/pdb_pgsql.c)
===================================================================
--- branches/pdbsql_3_2/pdb_pgsql.c (rev 0)
+++ branches/pdbsql_3_2/pdb_pgsql.c 2008-06-23 10:45:01 UTC (rev 113)
@@ -0,0 +1,636 @@
+/*
+ * PostgresSQL password backend for samba
+ * Copyright (C) Hamish Friedlander 2003
+ * Copyright (C) Jelmer Vernooij 2004-2006
+ * Copyright (C) Wilco Baan Hofman 2006
+ *
+ * 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.
+ *
+ * TODO
+ * * Volker commited Trust domain passwords to be included in the pdb.
+ * These need to be added here:
+ * BOOL get_trusteddom_pw(struct pdb_methods *methods, const char *domain, char **pwd, DOM_SID *sid, time_t *pass_last_set_time)
+ * BOOL set_trusteddom_pw(struct pdb_methods *methods, const char *domain, const char *pwd, const DOM_SID *sid)
+ * BOOL del_trusteddom_pw(struct pdb_methods *methods, const char *domain)
+ * NTSTATUS enum_trusteddoms(struct pdb_methods *methods, TALLOC_CTX *mem_ctx, uint32 *num_domains, struct trustdom_info ***domains)
+ */
+
+#include "pdb_sql.h"
+#include <libpq-fe.h>
+
+/* To prevent duplicate defines */
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_VERSION
+#undef PACKAGE_TARNAME
+#include <pg_config.h>
+
+#define CONFIG_HOST_DEFAULT "localhost"
+#define CONFIG_USER_DEFAULT "samba"
+#define CONFIG_PASS_DEFAULT ""
+#define CONFIG_PORT_DEFAULT DEF_PGPORT_STR
+#define CONFIG_DB_DEFAULT "samba"
+
+static int pgsqlsam_debug_level = DBGC_ALL;
+
+#undef DBGC_CLASS
+#define DBGC_CLASS pgsqlsam_debug_level
+
+/* handles for doing db transactions */
+typedef struct pdb_pgsql_data {
+ PGconn *master_handle;
+ PGconn *handle;
+
+ PGresult *pwent;
+ long currow;
+ const char *db;
+ const char *host;
+ const char *port;
+ const char *user;
+ const char *pass;
+
+ const char *location;
+} pdb_pgsql_data;
+
+#define SET_DATA(data,methods) { \
+ if(!methods){ \
+ DEBUG(0, ("invalid methods!\n")); \
+ return NT_STATUS_INVALID_PARAMETER; \
+ } \
+ data = (struct pdb_pgsql_data *)methods->private_data; \
+}
+
+
+#define SET_DATA_QUIET(data,methods) { \
+ if(!methods){ \
+ DEBUG(0, ("invalid methods!\n")); \
+ return; \
+ } \
+ data = (struct pdb_pgsql_data *)methods->private_data; \
+}
+
+
+#define config_value(data, name, default_value) \
+ lp_parm_const_string(GLOBAL_SECTION_SNUM, (data)->location, name, default_value)
+
+static PGconn *pgsqlsam_connect(struct pdb_pgsql_data *data)
+{
+ PGconn *handle;
+
+ DEBUG(1, ("Connecting to database server, host: %s, user: %s, password: XXXXXX, database: %s, port: %s\n",
+ data->host, data->user, data->db, data->port));
+
+ /* Do the pgsql initialization */
+ handle = PQsetdbLogin(
+ data->host,
+ data->port,
+ NULL,
+ NULL,
+ data->db,
+ data->user,
+ data->pass);
+
+ if (handle != NULL && PQstatus(handle) != CONNECTION_OK) {
+ DEBUG(0, ("Failed to connect to pgsql database: error: %s\n",
+ (handle != NULL ? PQerrorMessage(handle) : "")));
+ return NULL;
+ }
+
+ DEBUG(5, ("Connected to pgsql database\n"));
+ return handle;
+}
+
+/* The assumption here is that the master process will get connection 0,
+ * and all the renaining ones just one connection for their etire life span.
+ */
+static PGconn *choose_connection(struct pdb_pgsql_data *data)
+{
+ if (data->master_handle == NULL) {
+ data->master_handle = pgsqlsam_connect(data);
+ return data->master_handle;
+ }
+
+ /* Master connection != NULL, so we are just another process. */
+
+ /* If we didn't connect yet, do it now. */
+ if (data->handle == NULL) {
+ data->handle = pgsqlsam_connect(data);
+ }
+
+ return data->handle;
+}
+
+static long PQgetlong(PGresult *r, long row, long col)
+{
+ if (PQgetisnull(r, row, col)) {
+ return 0;
+ }
+
+ return atol(PQgetvalue(r, row, col));
+}
+
+static NTSTATUS row_to_sam_account (PGresult *r, long row, struct samu *u)
+{
+ unsigned char temp[16];
+ DOM_SID sid;
+ unsigned char *hours;
+ size_t hours_len = 0;
+
+ if (row >= PQntuples(r)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ pdb_set_logon_time (u, PQgetlong (r, row, 0), PDB_SET);
+ pdb_set_logoff_time (u, PQgetlong (r, row, 1), PDB_SET);
+ pdb_set_kickoff_time (u, PQgetlong (r, row, 2), PDB_SET);
+ pdb_set_pass_last_set_time (u, PQgetlong (r, row, 3), PDB_SET);
+ pdb_set_pass_can_change_time (u, PQgetlong (r, row, 4), PDB_SET);
+ pdb_set_pass_must_change_time(u, PQgetlong (r, row, 5), PDB_SET);
+ pdb_set_username (u, PQgetvalue(r, row, 6), PDB_SET);
+ pdb_set_domain (u, PQgetvalue(r, row, 7), PDB_SET);
+ pdb_set_nt_username (u, PQgetvalue(r, row, 8), PDB_SET);
+ pdb_set_fullname (u, PQgetvalue(r, row, 9), PDB_SET);
+ pdb_set_homedir (u, PQgetvalue(r, row, 10), PDB_SET);
+ pdb_set_dir_drive (u, PQgetvalue(r, row, 11), PDB_SET);
+ pdb_set_logon_script (u, PQgetvalue(r, row, 12), PDB_SET);
+ pdb_set_profile_path (u, PQgetvalue(r, row, 13), PDB_SET);
+ pdb_set_acct_desc (u, PQgetvalue(r, row, 14), PDB_SET);
+ pdb_set_workstations (u, PQgetvalue(r, row, 15), PDB_SET);
+ pdb_set_comment (u, PQgetvalue(r, row, 16), PDB_SET);
+ pdb_set_munged_dial (u, PQgetvalue(r, row, 17), PDB_SET);
+
+ pdb_set_acct_ctrl (u, PQgetlong (r, row, 23), PDB_SET);
+ pdb_set_logon_divs (u, PQgetlong (r, row, 24), PDB_SET);
+ pdb_set_hours_len (u, PQgetlong (r, row, 25), PDB_SET);
+ pdb_set_bad_password_count (u, PQgetlong (r, row, 26), PDB_SET);
+ pdb_set_logon_count (u, PQgetlong (r, row, 27), PDB_SET);
+ pdb_set_unknown_6 (u, PQgetlong (r, row, 28), PDB_SET);
+
+ hours = (unsigned char *) PQgetvalue (r, row, 29);
+ if (hours != NULL) {
+ hours = PQunescapeBytea(hours, &hours_len);
+ if (hours_len > 0) {
+ pdb_set_hours(u, hours, PDB_SET);
+ }
+ }
+
+
+ if (!PQgetisnull(r, row, 18)) {
+ string_to_sid(&sid, PQgetvalue(r, row, 18));
+ pdb_set_user_sid(u, &sid, PDB_SET);
+ }
+
+ if (!PQgetisnull(r, row, 19)) {
+ string_to_sid(&sid, PQgetvalue(r, row, 19));
+ pdb_set_group_sid(u, &sid, PDB_SET);
+ }
+
+ if (pdb_gethexpwd(PQgetvalue(r, row, 20), temp)) {
+ pdb_set_lanman_passwd(u, temp, PDB_SET);
+ }
+ if (pdb_gethexpwd(PQgetvalue(r, row, 21), temp)) {
+ pdb_set_nt_passwd(u, temp, PDB_SET);
+ }
+ /* Set password history field */
+ if (!PQgetisnull(r, row, 30)) {
+ uint8 pwhist[MAX_PW_HISTORY_LEN * PW_HISTORY_ENTRY_LEN];
+ int i;
+ char *history_string = PQgetvalue(r, row, 30);
+
+ memset(&pwhist, 0, MAX_PW_HISTORY_LEN * PW_HISTORY_ENTRY_LEN);
+ for (i = 0; i < MAX_PW_HISTORY_LEN && i < strlen(history_string)/64; i++) {
+ pdb_gethexpwd(&(history_string)[i*64], &pwhist[i*PW_HISTORY_ENTRY_LEN]);
+ pdb_gethexpwd(&(history_string)[i*64+32],
+ &pwhist[i*PW_HISTORY_ENTRY_LEN+PW_HISTORY_SALT_LEN]);
+ }
+ pdb_set_pw_history(u, pwhist, strlen(history_string)/64, PDB_SET);
+ }
+
+
+ /* Only use plaintext password storage when lanman and nt are NOT used */
+ if (PQgetisnull(r, row, 20) || PQgetisnull(r, row, 21)) {
+ pdb_set_plaintext_passwd(u, PQgetvalue(r, row, 22));
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS pgsqlsam_setsampwent(struct pdb_methods *methods, BOOL update, uint32 acb_mask)
+{
+ struct pdb_pgsql_data *data;
+ PGconn *handle;
+ char *query;
+ NTSTATUS retval;
+
+ SET_DATA(data, methods);
+
+ /* Connect to the DB. */
+ handle = choose_connection(data);
+ if (handle == NULL) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ DEBUG(5, ("CONNECTING pgsqlsam_setsampwent\n"));
+
+ query = sql_account_query_select(NULL, data->location, update, SQL_SEARCH_NONE, NULL);
+
+ /* Execute query */
+ DEBUG(5, ("Executing query %s\n", query));
+ data->pwent = PQexec(handle, query);
+ data->currow = 0;
+
+ /* Result? */
+ if (data->pwent == NULL) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
+ retval = NT_STATUS_UNSUCCESSFUL;
+ } else if (PQresultStatus(data->pwent) != PGRES_TUPLES_OK) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(data->pwent)));
+ retval = NT_STATUS_UNSUCCESSFUL;
+ } else {
+ DEBUG(5, ("pgsqlsam_setsampwent succeeded(%d results)!\n", PQntuples(data->pwent)));
+ retval = NT_STATUS_OK;
+ }
+
+ talloc_free(query);
+ return retval;
+}
+
+/***************************************************************
+ End enumeration of the passwd list.
+ ****************************************************************/
+
+static void pgsqlsam_endsampwent(struct pdb_methods *methods)
+{
+ struct pdb_pgsql_data *data;
+
+ SET_DATA_QUIET(data, methods);
+
+ if (data->pwent != NULL) {
+ PQclear(data->pwent);
+ }
+
+ data->pwent = NULL;
+ data->currow = 0;
+
+ DEBUG(5, ("pgsql_endsampwent called\n"));
+}
+
+/*****************************************************************
+ Get one struct samu from the list (next in line)
+ *****************************************************************/
+
+static NTSTATUS pgsqlsam_getsampwent(struct pdb_methods *methods, struct samu *user)
+{
+ struct pdb_pgsql_data *data;
+ NTSTATUS retval;
+
+ SET_DATA(data, methods);
+
+ if (data->pwent == NULL) {
+ DEBUG(0, ("invalid pwent\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ retval = row_to_sam_account(data->pwent, data->currow, user);
+ data->currow++;
+
+ return retval;
+}
+
+static NTSTATUS pgsqlsam_select_by_field(struct pdb_methods *methods, struct samu *user, enum sql_search_field field, const char *sname)
+{
+ struct pdb_pgsql_data *data;
+ PGconn *handle;
+
+ char *esc;
+ char *query;
+
+ PGresult *result;
+ NTSTATUS retval;
+
+ SET_DATA(data, methods);
+
+ if (user == NULL) {
+ DEBUG(0, ("pdb_getsampwnam: struct samu is NULL.\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ DEBUG(5, ("pgsqlsam_select_by_field: getting data where %d = %s(nonescaped)\n", field, sname));
+
+ /* Escape sname */
+ esc = talloc_array(NULL, char, strlen(sname) * 2 + 1);
+ if (!esc) {
+ DEBUG(0, ("Can't allocate memory to store escaped name\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* tmp_sname = smb_xstrdup(sname); */
+ PQescapeString(esc, sname, strlen(sname));
+
+ /* Connect to the DB. */
+ handle = choose_connection(data);
+ if (handle == NULL) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ query = sql_account_query_select(NULL, data->location, True, field, esc);
+
+ /* Execute query */
+ DEBUG(5, ("Executing query %s\n", query));
+ result = PQexec(handle, query);
+
+ /* Result? */
+ if (result == NULL) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
+ retval = NT_STATUS_UNSUCCESSFUL;
+ } else if (PQresultStatus(result) != PGRES_TUPLES_OK) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(result)));
+ retval = NT_STATUS_UNSUCCESSFUL;
+ } else {
+ retval = row_to_sam_account(result, 0, user);
+ }
+
+ talloc_free(esc);
+ talloc_free(query);
+
+ if (result != NULL) {
+ PQclear(result);
+ }
+
+ return retval;
+}
+
+/******************************************************************
+ Lookup a name in the SAM database
+ ******************************************************************/
+
+static NTSTATUS pgsqlsam_getsampwnam(struct pdb_methods *methods, struct samu *user, const char *sname)
+{
+ struct pdb_pgsql_data *data;
+ size_t i, l;
+ char *lowercasename;
+ NTSTATUS result;
+
+ SET_DATA(data, methods);
+
+ if (!sname) {
+ DEBUG(0, ("invalid name specified"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ lowercasename = smb_xstrdup(sname);
+ l = strlen(lowercasename);
+ for(i = 0; i < l; i++) {
+ lowercasename[i] = tolower_ascii(lowercasename[i]);
+ }
+
+ result = pgsqlsam_select_by_field(methods, user, SQL_SEARCH_USER_NAME, lowercasename);
+
+ SAFE_FREE(lowercasename);
+
+ return result;
+}
+
+
+/***************************************************************************
+ Search by sid
+ **************************************************************************/
+
+static NTSTATUS pgsqlsam_getsampwsid(struct pdb_methods *methods, struct samu *user, const DOM_SID *sid)
+{
+ struct pdb_pgsql_data *data;
+ fstring sid_str;
+
+ SET_DATA(data, methods);
+
+ sid_to_string(sid_str, sid);
+
+ return pgsqlsam_select_by_field(methods, user, SQL_SEARCH_USER_SID, sid_str);
+}
+
+/***************************************************************************
+ Delete a struct samu
+ ****************************************************************************/
+
+static NTSTATUS pgsqlsam_delete_sam_account(struct pdb_methods *methods, struct samu *sam_pass)
+{
+ struct pdb_pgsql_data *data;
+ PGconn *handle;
+
+ const char *sname = pdb_get_username(sam_pass);
+ char *esc;
+ char *query;
+
+ PGresult *result;
+ NTSTATUS retval;
+
+ SET_DATA(data, methods);
+
+ if (!sname) {
+ DEBUG(0, ("invalid name specified\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ /* Escape sname */
+ esc = talloc_array(NULL, char, strlen(sname) * 2 + 1);
+ if (!esc) {
+ DEBUG(0, ("Can't allocate memory to store escaped name\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ PQescapeString(esc, sname, strlen(sname));
+
+ /* Connect to the DB. */
+ handle = choose_connection(data);
+ if (handle == NULL) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ query = sql_account_query_delete(NULL, data->location, esc);
+
+ /* Execute query */
+ result = PQexec(handle, query);
+
+ if (result == NULL) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
+ retval = NT_STATUS_UNSUCCESSFUL;
+ } else if (PQresultStatus(result) != PGRES_COMMAND_OK) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(result)));
+ retval = NT_STATUS_UNSUCCESSFUL;
+ } else {
+ DEBUG(5, ("User '%s' deleted\n", sname));
+ retval = NT_STATUS_OK;
+ }
+
+ if (result != NULL) {
+ PQclear(result);
+ }
+ talloc_free(esc);
+ talloc_free(query);
+
+ return retval;
+}
+
+static NTSTATUS pgsqlsam_replace_sam_account(struct pdb_methods *methods, struct samu *newpwd, char isupdate)
+{
+ struct pdb_pgsql_data *data;
+ PGconn *handle;
+ char *query;
+ PGresult *result;
+ NTSTATUS retval;
+
+ if (!methods) {
+ DEBUG(0, ("invalid methods!\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ data = (struct pdb_pgsql_data *) methods->private_data;
+
+ if (data == NULL) {
+ DEBUG(0, ("invalid handle!\n"));
+ return NT_STATUS_INVALID_HANDLE;
+ }
+
+ query = sql_account_query_update(NULL, data->location, newpwd, isupdate);
+ if (query == NULL) {
+ /* Nothing to update. */
+ return NT_STATUS_OK;
+ }
+ /* Connect to the DB. */
+ handle = choose_connection(data);
+ if (handle == NULL) {
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* Execute the query */
+ result = PQexec(handle, query);
+
+ if (result == NULL) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQerrorMessage(handle)));
+ retval = NT_STATUS_INVALID_PARAMETER;
+ } else if (PQresultStatus(result) != PGRES_COMMAND_OK) {
+ DEBUG(0, ("Error executing %s, %s\n", query, PQresultErrorMessage(result)));
+ retval = NT_STATUS_INVALID_PARAMETER;
+ } else {
+ retval = NT_STATUS_OK;
+ }
+
+ if (result != NULL) {
+ PQclear(result);
+ }
+ talloc_free(query);
+
+ return retval;
+}
+
+static NTSTATUS pgsqlsam_add_sam_account(struct pdb_methods *methods, struct samu *newpwd)
+{
+ return pgsqlsam_replace_sam_account(methods, newpwd, 0);
+}
+
+static NTSTATUS pgsqlsam_update_sam_account(struct pdb_methods *methods, struct samu *newpwd)
+{
+ return pgsqlsam_replace_sam_account(methods, newpwd, 1);
+}
+
+static BOOL pgsqlsam_rid_algorithm(struct pdb_methods *pdb_methods)
+{
+ return True;
+}
+static BOOL pgsqlsam_new_rid(struct pdb_methods *pdb_methods, uint32 *rid)
+{
+ return False;
+}
+
+static NTSTATUS pgsqlsam_init (struct pdb_methods **pdb_method, const char *location)
+{
+ NTSTATUS nt_status;
+
+ struct pdb_pgsql_data *data;
+
+ pgsqlsam_debug_level = debug_add_class("pgsqlsam");
+ if (pgsqlsam_debug_level == -1) {
+ pgsqlsam_debug_level = DBGC_ALL;
+ DEBUG(0,
+ ("pgsqlsam: Couldn't register custom debugging class!\n"));
+ }
+
+ if ( !NT_STATUS_IS_OK(nt_status = make_pdb_method( pdb_method )) ) {
+ return nt_status;
+ }
+
+
+ (*pdb_method)->name = "pgsqlsam";
+
+ (*pdb_method)->setsampwent = pgsqlsam_setsampwent;
+ (*pdb_method)->endsampwent = pgsqlsam_endsampwent;
+ (*pdb_method)->getsampwent = pgsqlsam_getsampwent;
+ (*pdb_method)->getsampwnam = pgsqlsam_getsampwnam;
+ (*pdb_method)->getsampwsid = pgsqlsam_getsampwsid;
+ (*pdb_method)->add_sam_account = pgsqlsam_add_sam_account;
+ (*pdb_method)->update_sam_account = pgsqlsam_update_sam_account;
+ (*pdb_method)->delete_sam_account = pgsqlsam_delete_sam_account;
+ (*pdb_method)->rid_algorithm = pgsqlsam_rid_algorithm;
+ (*pdb_method)->new_rid = pgsqlsam_new_rid;
+
+/* (*pdb_method)->rename_sam_account = pgsqlsam_rename_sam_account; */
+/* (*pdb_method)->getgrsid = pgsqlsam_getgrsid; */
+/* (*pdb_method)->getgrgid = pgsqlsam_getgrgid; */
+/* (*pdb_method)->getgrnam = pgsqlsam_getgrnam; */
+/* (*pdb_method)->add_group_mapping_entry = pgsqlsam_add_group_mapping_entry; */
+/* (*pdb_method)->update_group_mapping_entry = pgsqlsam_update_group_mapping_entry; */
+/* (*pdb_method)->delete_group_mapping_entry = pgsqlsam_delete_group_mapping_entry; */
+/* (*pdb_method)->enum_group_mapping = pgsqlsam_enum_group_mapping; */
+/* (*pdb_method)->get_account_policy = pgsqlsam_get_account_policy; */
+/* (*pdb_method)->set_account_policy = pgsqlsam_set_account_policy; */
+/* (*pdb_method)->get_seq_num = pgsqlsam_get_seq_num; */
+
+ (*pdb_method)->private_data = data;
+
+ data->master_handle = NULL;
+ data->handle = NULL;
+ data->pwent = NULL;
+
+ if (!location) {
+ DEBUG(0, ("No identifier specified. Check the Samba HOWTO Collection for details\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ data->location = smb_xstrdup(location);
+
+ if(!sql_account_config_valid(data->location)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ DEBUG(1, ("Database server parameters: host: %s, user: %s, password: XXXX, database: %s, port: %s\n",
+ config_value(data, "pgsql host" , CONFIG_HOST_DEFAULT),
+ config_value(data, "pgsql user" , CONFIG_USER_DEFAULT),
+ config_value(data, "pgsql database", CONFIG_DB_DEFAULT ),
+ config_value(data, "pgsql port" , CONFIG_PORT_DEFAULT)));
+
+ /* Save the parameters. */
+ data->db = config_value(data, "pgsql database", CONFIG_DB_DEFAULT );
+ data->host = config_value(data, "pgsql host" , CONFIG_HOST_DEFAULT);
+ data->port = config_value(data, "pgsql port" , CONFIG_PORT_DEFAULT);
+ data->user = config_value(data, "pgsql user" , CONFIG_USER_DEFAULT);
+ data->pass = config_value(data, "pgsql password", CONFIG_PASS_DEFAULT);
+
+ DEBUG(5, ("Pgsql module initialized\n"));
+ return NT_STATUS_OK;
+}
+
+NTSTATUS init_module(void)
+{
+ return smb_register_passdb(PASSDB_INTERFACE_VERSION, "pgsql", pgsqlsam_init);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|