summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-09-29 12:27:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:04:48 -0500
commitdbbaccc2c05ca2220dbbb74a7368304a89d31c9c (patch)
treefe7b9485951134f4600450628e353f43bc17b8a7
parent4850bc63104f5f2945d9e91cfbd99773a5bc570f (diff)
downloadsamba-dbbaccc2c05ca2220dbbb74a7368304a89d31c9c.tar.gz
samba-dbbaccc2c05ca2220dbbb74a7368304a89d31c9c.tar.bz2
samba-dbbaccc2c05ca2220dbbb74a7368304a89d31c9c.zip
r10606: pdb_*sql patches from
Uli Meis <a.sporto@gmail.com> Peter Rindfuss <rindfuss@wz-berlin.de> (This used to be commit 8bf124adaf4d6cacc18ebca82d96eabe47088151)
-rw-r--r--source3/lib/talloc.c5
-rw-r--r--source3/passdb/pdb_pgsql.c2
-rw-r--r--source3/passdb/pdb_sql.c48
3 files changed, 25 insertions, 30 deletions
diff --git a/source3/lib/talloc.c b/source3/lib/talloc.c
index 15b0f4ea7d..98cba8597e 100644
--- a/source3/lib/talloc.c
+++ b/source3/lib/talloc.c
@@ -989,7 +989,6 @@ static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINT
static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
{
- struct talloc_chunk *tc;
int len, s_len;
va_list ap2;
@@ -997,11 +996,9 @@ static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
return talloc_vasprintf(NULL, fmt, ap);
}
- tc = talloc_chunk_from_ptr(s);
-
VA_COPY(ap2, ap);
- s_len = tc->size - 1;
+ s_len = strlen(s);
len = vsnprintf(NULL, 0, fmt, ap2);
s = talloc_realloc(NULL, s, char, s_len + len+1);
diff --git a/source3/passdb/pdb_pgsql.c b/source3/passdb/pdb_pgsql.c
index fbafd70cb6..632903c1ac 100644
--- a/source3/passdb/pdb_pgsql.c
+++ b/source3/passdb/pdb_pgsql.c
@@ -231,8 +231,6 @@ static NTSTATUS pgsqlsam_setsampwent(struct pdb_methods *methods, BOOL update, u
}
talloc_free(query);
- if ( data->pwent != NULL )
- PQclear( data->pwent ) ;
return retval ;
}
diff --git a/source3/passdb/pdb_sql.c b/source3/passdb/pdb_sql.c
index cc84828008..3cf34df812 100644
--- a/source3/passdb/pdb_sql.c
+++ b/source3/passdb/pdb_sql.c
@@ -318,7 +318,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
CONFIG_TABLE_DEFAULT));
}
- if (IS_SAM_CHANGED(newpwd, PDB_ACCTCTRL)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_ACCTCTRL)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location, "acct ctrl column",
@@ -326,7 +326,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_acct_ctrl(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_LOGONTIME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGONTIME)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -335,7 +335,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_logon_time(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_LOGOFFTIME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGOFFTIME)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -344,7 +344,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_logoff_time(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_KICKOFFTIME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_KICKOFFTIME)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -353,7 +353,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_kickoff_time(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_CANCHANGETIME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_CANCHANGETIME)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -362,7 +362,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_pass_can_change_time(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_MUSTCHANGETIME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_MUSTCHANGETIME)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -371,7 +371,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_pass_must_change_time(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_PASSLASTSET)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_PASSLASTSET)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -380,7 +380,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_pass_last_set_time(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_HOURSLEN)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_HOURSLEN)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -389,7 +389,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_hours_len(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_LOGONDIVS)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGONDIVS)) {
some_field_affected = 1;
pdb_sql_int_field(query,
config_value_write(location,
@@ -398,7 +398,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_logon_divs(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_USERSID)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_USERSID)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "user sid column",
@@ -407,7 +407,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_user_sid(newpwd)));
}
- if (IS_SAM_CHANGED(newpwd, PDB_GROUPSID)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_GROUPSID)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "group sid column",
@@ -416,7 +416,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_group_sid(newpwd)));
}
- if (IS_SAM_CHANGED(newpwd, PDB_USERNAME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_USERNAME)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "username column",
@@ -424,7 +424,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_username(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_DOMAIN)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_DOMAIN)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "domain column",
@@ -432,7 +432,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_domain(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_USERNAME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_USERNAME)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location,
@@ -441,7 +441,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_nt_username(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_FULLNAME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_FULLNAME)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "fullname column",
@@ -449,7 +449,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_fullname(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_LOGONSCRIPT)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_LOGONSCRIPT)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location,
@@ -458,7 +458,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_logon_script(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_PROFILE)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_PROFILE)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location,
@@ -467,7 +467,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_profile_path(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_DRIVE)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_DRIVE)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "dir drive column",
@@ -475,7 +475,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_dir_drive(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_SMBHOME)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_SMBHOME)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location, "home dir column",
@@ -483,7 +483,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_homedir(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_WORKSTATIONS)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_WORKSTATIONS)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location,
@@ -492,7 +492,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_workstations(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_UNKNOWNSTR)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_UNKNOWNSTR)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location,
@@ -501,7 +501,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
pdb_get_workstations(newpwd));
}
- if (IS_SAM_CHANGED(newpwd, PDB_LMPASSWD)) {
+ 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));
@@ -511,7 +511,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
CONFIG_LM_PW_DEFAULT), temp);
}
- if (IS_SAM_CHANGED(newpwd, PDB_NTPASSWD)) {
+ 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));
@@ -520,7 +520,7 @@ char *sql_account_query_update(TALLOC_CTX *mem_ctx, const char *location, const
CONFIG_NT_PW_DEFAULT), temp);
}
- if (IS_SAM_CHANGED(newpwd, PDB_HOURS)) {
+ if (!isupdate || IS_SAM_CHANGED(newpwd, PDB_HOURS)) {
some_field_affected = 1;
pdb_sql_string_field(query,
config_value_write(location,