[SCM] Samba Shared Repository - branch v3-4-test updated
Karolin Seeger
kseeger at samba.org
Tue Mar 2 05:23:09 MST 2010
The branch, v3-4-test has been updated
via 4178dc4... s3: Fix bug 5198 -- parse chfn(1)-change gecos field (cherry picked from commit 2ea2d2a81e0666f478c5daf1469c8447a3096e8e) (cherry picked from commit 52a3ebc3a4ec54a427e54fa331251fd495c3c6aa)
from 19623b2... s3-spoolss: fix fstrings in convert_devicemode() function.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test
- Log -----------------------------------------------------------------
commit 4178dc4ed4b160a8f9ec08b1c729deae47b8368a
Author: Volker Lendecke <vl at samba.org>
Date: Sat Feb 6 13:26:06 2010 +0100
s3: Fix bug 5198 -- parse chfn(1)-change gecos field
(cherry picked from commit 2ea2d2a81e0666f478c5daf1469c8447a3096e8e)
(cherry picked from commit 52a3ebc3a4ec54a427e54fa331251fd495c3c6aa)
-----------------------------------------------------------------------
Summary of changes:
source3/passdb/passdb.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 6ba67ef..a364e26 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -121,6 +121,18 @@ struct samu *samu_new( TALLOC_CTX *ctx )
return user;
}
+static int count_commas(const char *str)
+{
+ int num_commas = 0;
+ const char *comma = str;
+
+ while ((comma = strchr(comma, ',')) != NULL) {
+ comma += 1;
+ num_commas += 1;
+ }
+ return num_commas;
+}
+
/*********************************************************************
Initialize a struct samu from a struct passwd including the user
and group SIDs. The *user structure is filled out with the Unix
@@ -131,6 +143,7 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p
{
const char *guest_account = lp_guestaccount();
const char *domain = global_myname();
+ char *fullname;
uint32 urid;
if ( !pwd ) {
@@ -140,7 +153,27 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p
/* Basic properties based upon the Unix account information */
pdb_set_username(user, pwd->pw_name, PDB_SET);
- pdb_set_fullname(user, pwd->pw_gecos, PDB_SET);
+
+ fullname = NULL;
+
+ if (count_commas(pwd->pw_gecos) == 3) {
+ /*
+ * Heuristic: This seems to be a gecos field that has been
+ * edited by chfn(1). Only use the part before the first
+ * comma. Fixes bug 5198.
+ */
+ fullname = talloc_strndup(
+ talloc_tos(), pwd->pw_gecos,
+ strchr(pwd->pw_gecos, ',') - pwd->pw_gecos);
+ }
+
+ if (fullname != NULL) {
+ pdb_set_fullname(user, fullname, PDB_SET);
+ } else {
+ pdb_set_fullname(user, pwd->pw_gecos, PDB_SET);
+ }
+ TALLOC_FREE(fullname);
+
pdb_set_domain (user, get_global_sam_name(), PDB_DEFAULT);
#if 0
/* This can lead to a primary group of S-1-22-2-XX which
--
Samba Shared Repository
More information about the samba-cvs
mailing list