return getgrgid(gid);
}
-static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx,
- const struct passwd *from)
+struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
+ const struct passwd *from)
{
struct passwd *ret = talloc_zero(mem_ctx, struct passwd);
return ret;
}
-struct passwd *_getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
+struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name)
{
struct passwd *temp;
return NULL;
}
- return alloc_copy_passwd(mem_ctx, temp);
+ return tcopy_passwd(mem_ctx, temp);
}
-struct passwd *_getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
+/****************************************************************************
+ talloc'ed version of getpwuid.
+****************************************************************************/
+
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
{
struct passwd *temp;
return NULL;
}
- return alloc_copy_passwd(mem_ctx, temp);
+ return tcopy_passwd(mem_ctx, temp);
}
struct group *sys_getgrgid(gid_t gid);
struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx,
const struct passwd *from);
-struct passwd *_getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name);
-struct passwd *_getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid);
+struct passwd *getpwnam_alloc(TALLOC_CTX *mem_ctx, const char *name);
+struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid);
#endif /* __LIB_UTIL_UTIL_PW_H__ */
#include "../lib/crypto/arcfour.h"
#include "rpc_client/init_lsa.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
/* The following definitions come from lib/username.c */
-struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) ;
void flush_pwnam_cache(void);
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
return tcopy_passwd(mem_ctx, pw);
}
-/****************************************************************************
- talloc copy a struct passwd.
-****************************************************************************/
-
-struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from)
-{
- struct passwd *ret = TALLOC_P(mem_ctx, struct passwd);
- if (!ret) {
- return NULL;
- }
- ret->pw_name = talloc_strdup(ret, from->pw_name);
- ret->pw_passwd = talloc_strdup(ret, from->pw_passwd);
- ret->pw_uid = from->pw_uid;
- ret->pw_gid = from->pw_gid;
- ret->pw_gecos = talloc_strdup(ret, from->pw_gecos);
- ret->pw_dir = talloc_strdup(ret, from->pw_dir);
- ret->pw_shell = talloc_strdup(ret, from->pw_shell);
- return ret;
-}
-
/****************************************************************************
Flush all cached passwd structs.
****************************************************************************/
memcache_flush(NULL, GETPWNAM_CACHE);
}
-/****************************************************************************
- talloc'ed version of getpwuid.
-****************************************************************************/
-
-struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid)
-{
- struct passwd *temp = sys_getpwuid(uid);
-
- if (!temp) {
- return NULL;
- }
-
- return tcopy_passwd(mem_ctx, temp);
-}
-
/****************************************************************************
Get a users home directory.
****************************************************************************/
#include "includes.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
#if defined(WITH_WINBIND)
#include "../libcli/auth/libcli_auth.h"
#include "secrets.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
#include "secrets.h"
#include "idmap_cache.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
#include "includes.h"
#include "secrets.h"
#include "../librpc/gen_ndr/samr.h"
+#include "../lib/util/util_pw.h"
/*
* Next two lines needed for SunOS and don't