The Samba-Bugzilla – Attachment 5292 Details for
Bug 5198
Samba Fails to Split GECOS on Comma
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Alternative patch
5198.patch (text/plain), 2.10 KB, created by
Volker Lendecke
on 2010-02-06 06:28:53 UTC
(
hide
)
Description:
Alternative patch
Filename:
MIME Type:
Creator:
Volker Lendecke
Created:
2010-02-06 06:28:53 UTC
Size:
2.10 KB
patch
obsolete
>From 93a703f6d1970397cd563aeba633be7145a4831d Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Sat, 6 Feb 2010 13:26:06 +0100 >Subject: [PATCH] s3: Fix bug 5198 -- parse chfn(1)-change gecos field > >--- > source3/passdb/passdb.c | 35 ++++++++++++++++++++++++++++++++++- > 1 files changed, 34 insertions(+), 1 deletions(-) > >diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c >index 3ced150..566a1ea 100644 >--- a/source3/passdb/passdb.c >+++ b/source3/passdb/passdb.c >@@ -122,6 +122,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(str, ',')) != 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 >@@ -132,6 +144,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 ) { >@@ -141,7 +154,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 >-- >1.6.5.7 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 5198
: 5292 |
5311