lib: Add proper {} to tcopy_passwd
[obnox/samba/samba-obnox.git] / lib / util / util_pw.c
index 9047ec15c0e31474874abd97d1a01f179311bfe8..dae3a69492ae43af28e16ac5c6bb8e4863edda9e 100644 (file)
 #include "system/passwd.h"
 #include "lib/util/util_pw.h"
 
-/**************************************************************************
- Wrappers for getgrgid()
-****************************************************************************/
-
-struct group *sys_getgrgid(gid_t gid)
-{
-       return getgrgid(gid);
-}
-
 struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
                            const struct passwd *from)
 {
-       struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
+       struct passwd *ret;
+       size_t len = 0;
+
+       len += strlen(from->pw_name)+1;
+       len += strlen(from->pw_passwd)+1;
+       len += strlen(from->pw_gecos)+1;
+       len += strlen(from->pw_dir)+1;
+       len += strlen(from->pw_shell)+1;
 
-       if (ret == NULL)
+       ret = talloc_pooled_object(mem_ctx, struct passwd, 5, len);
+
+       if (ret == NULL) {
                return NULL;
+       }
 
        ret->pw_name = talloc_strdup(ret, from->pw_name);
        ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);