summaryrefslogtreecommitdiff
path: root/nsswitch
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-04-06 22:16:07 +0200
committerVolker Lendecke <vl@samba.org>2010-04-19 14:27:16 +0200
commit041be88bd04a8a054b8fcb254225889b6069de55 (patch)
tree96b4bd7bb4d23c55835d53794f48812a94cb2622 /nsswitch
parent20011f4681754160c59725c066357d902e00102c (diff)
downloadsamba-041be88bd04a8a054b8fcb254225889b6069de55.tar.gz
samba-041be88bd04a8a054b8fcb254225889b6069de55.tar.bz2
samba-041be88bd04a8a054b8fcb254225889b6069de55.zip
libwbclient: Make copy_passwd_entry not use talloc
Diffstat (limited to 'nsswitch')
-rw-r--r--nsswitch/libwbclient/wbc_pwd.c69
1 files changed, 41 insertions, 28 deletions
diff --git a/nsswitch/libwbclient/wbc_pwd.c b/nsswitch/libwbclient/wbc_pwd.c
index 9b8df4d907..8b7fe7664d 100644
--- a/nsswitch/libwbclient/wbc_pwd.c
+++ b/nsswitch/libwbclient/wbc_pwd.c
@@ -40,39 +40,52 @@
*
**/
-static struct passwd *copy_passwd_entry(struct winbindd_pw *p)
+static void wbcPasswdDestructor(void *ptr)
{
- struct passwd *pwd = NULL;
- wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
-
- pwd = talloc(NULL, struct passwd);
- BAIL_ON_PTR_ERROR(pwd, wbc_status);
-
- pwd->pw_name = talloc_strdup(pwd,p->pw_name);
- BAIL_ON_PTR_ERROR(pwd->pw_name, wbc_status);
-
- pwd->pw_passwd = talloc_strdup(pwd, p->pw_passwd);
- BAIL_ON_PTR_ERROR(pwd->pw_passwd, wbc_status);
-
- pwd->pw_gecos = talloc_strdup(pwd, p->pw_gecos);
- BAIL_ON_PTR_ERROR(pwd->pw_gecos, wbc_status);
-
- pwd->pw_shell = talloc_strdup(pwd, p->pw_shell);
- BAIL_ON_PTR_ERROR(pwd->pw_shell, wbc_status);
-
- pwd->pw_dir = talloc_strdup(pwd, p->pw_dir);
- BAIL_ON_PTR_ERROR(pwd->pw_dir, wbc_status);
+ struct passwd *pw = (struct passwd *)ptr;
+ free(pw->pw_name);
+ free(pw->pw_passwd);
+ free(pw->pw_gecos);
+ free(pw->pw_shell);
+ free(pw->pw_dir);
+}
- pwd->pw_uid = p->pw_uid;
- pwd->pw_gid = p->pw_gid;
+static struct passwd *copy_passwd_entry(struct winbindd_pw *p)
+{
+ struct passwd *pw = NULL;
-done:
- if (!WBC_ERROR_IS_OK(wbc_status)) {
- talloc_free(pwd);
- pwd = NULL;
+ pw = (struct passwd *)wbcAllocateMemory(1, sizeof(struct passwd),
+ wbcPasswdDestructor);
+ if (pw == NULL) {
+ return NULL;
+ }
+ pw->pw_name = strdup(p->pw_name);
+ if (pw->pw_name == NULL) {
+ goto fail;
+ }
+ pw->pw_passwd = strdup(p->pw_passwd);
+ if (pw->pw_passwd == NULL) {
+ goto fail;
+ }
+ pw->pw_gecos = strdup(p->pw_gecos);
+ if (pw->pw_gecos == NULL) {
+ goto fail;
+ }
+ pw->pw_shell = strdup(p->pw_shell);
+ if (pw->pw_shell == NULL) {
+ goto fail;
+ }
+ pw->pw_dir = strdup(p->pw_dir);
+ if (pw->pw_dir == NULL) {
+ goto fail;
}
+ pw->pw_uid = p->pw_uid;
+ pw->pw_gid = p->pw_gid;
+ return pw;
- return pwd;
+fail:
+ wbcFreeMemory(pw);
+ return NULL;
}
/**