Safe versions of getpw* calls
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 1998-2005
Copyright (C) Andrew Bartlett 2002
+ Copyright (C) Timur Bakeyev 2005
+ Copyright (C) Bjoern Jacke 2006-2007
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
#include "includes.h"
+#include "system/passwd.h"
+#include "lib/util/util_pw.h"
+
+/**************************************************************************
+ Wrappers for setpwent(), getpwent() and endpwent()
+****************************************************************************/
+
+void sys_setpwent(void)
+{
+ setpwent();
+}
+
+struct passwd *sys_getpwent(void)
+{
+ return getpwent();
+}
+
+void sys_endpwent(void)
+{
+ endpwent();
+}
+
+/**************************************************************************
+ Wrappers for getpwnam(), getpwuid(), getgrnam(), getgrgid()
+****************************************************************************/
+
+struct passwd *sys_getpwnam(const char *name)
+{
+ return getpwnam(name);
+}
+
+struct passwd *sys_getpwuid(uid_t uid)
+{
+ return getpwuid(uid);
+}
+
+struct group *sys_getgrnam(const char *name)
+{
+ return getgrnam(name);
+}
+
+struct group *sys_getgrgid(gid_t gid)
+{
+ return getgrgid(gid);
+}
static struct passwd *alloc_copy_passwd(TALLOC_CTX *mem_ctx,
const struct passwd *from)
--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+
+ Safe versions of getpw* calls
+
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 1997-2001.
+ Copyright (C) Andrew Bartlett 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __LIB_UTIL_UTIL_PW_H__
+#define __LIB_UTIL_UTIL_PW_H__
+
+void sys_setpwent(void);
+struct passwd *sys_getpwent(void);
+void sys_endpwent(void);
+struct passwd *sys_getpwnam(const char *name);
+struct passwd *sys_getpwuid(uid_t uid);
+struct group *sys_getgrnam(const char *name);
+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);
+
+#endif /* __LIB_UTIL_UTIL_PW_H__ */
public_deps='tevent'
)
+bld.SAMBA_SUBSYSTEM('UTIL_PW',
+ source='util_pw.c',
+ local_include=False,
+ public_deps='talloc'
+ )
../lib/util/tevent_werror.o \
../lib/util/smb_threads.o ../lib/util/util_id.o \
../lib/util/blocking.o ../lib/util/rfc1738.o \
- ../lib/util/select.o
+ ../lib/util/select.o ../lib/util/util_pw.o
CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
#include "memcache.h"
#include "../librpc/gen_ndr/netlogon.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
/****************************************************************************
Check for a SID in an struct security_token
int groups_max(void);
int sys_getgroups(int setlen, gid_t *gidset);
int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
-void sys_setpwent(void);
-struct passwd *sys_getpwent(void);
-void sys_endpwent(void);
-struct passwd *sys_getpwnam(const char *name);
-struct passwd *sys_getpwuid(uid_t uid);
-struct group *sys_getgrnam(const char *name);
-struct group *sys_getgrgid(gid_t gid);
int sys_popen(const char *command);
int sys_pclose(int fd);
ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
#endif
}
-/**************************************************************************
- Wrappers for setpwent(), getpwent() and endpwent()
-****************************************************************************/
-
-void sys_setpwent(void)
-{
- setpwent();
-}
-
-struct passwd *sys_getpwent(void)
-{
- return getpwent();
-}
-
-void sys_endpwent(void)
-{
- endpwent();
-}
-
-/**************************************************************************
- Wrappers for getpwnam(), getpwuid(), getgrnam(), getgrgid()
-****************************************************************************/
-
-
-struct passwd *sys_getpwnam(const char *name)
-{
- return getpwnam(name);
-}
-
-struct passwd *sys_getpwuid(uid_t uid)
-{
- return getpwuid(uid);
-}
-
-struct group *sys_getgrnam(const char *name)
-{
- return getgrnam(name);
-}
-
-struct group *sys_getgrgid(gid_t gid)
-{
- return getgrgid(gid);
-}
-
/**************************************************************************
Extract a command into an arg list.
****************************************************************************/
#include "includes.h"
#include "memcache.h"
+#include "../lib/util/util_pw.h"
/* internal functions */
static struct passwd *uname_string_combinations(char *s, TALLOC_CTX *mem_ctx,
#include "popt_common.h"
#include "secrets.h"
#include "ctdbd_conn.h"
+#include "../lib/util/util_pw.h"
/* Max allowable allococation - 256mb - 0x10000000 */
#define MAX_ALLOC_SIZE (1024*1024*256)
#include "memcache.h"
#include "nsswitch/winbind_client.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
#include "includes.h"
#include "../libcli/security/security.h"
+#include "../lib/util/util_pw.h"
bool sid_check_is_unix_users(const struct dom_sid *sid)
{
#include "../librpc/gen_ndr/ndr_security.h"
#include "dbwrap.h"
#include "session.h"
+#include "../lib/util/util_pw.h"
extern const struct generic_mapping file_generic_mapping;
*/
#include "includes.h"
+#include "../lib/util/util_pw.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_QUOTA
#include "includes.h"
#include "vfstest.h"
+#include "../lib/util/util_pw.h"
static const char *null_string = "";
bld.SAMBA3_LIBRARY('samba3core',
source=LIB_SRC,
- deps='LIBCRYPTO ndr ndr-util security NDR_SECURITY charset NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 samba-util3 CHARSET3 UTIL_TDB SAMBA_VERSION krb5 flag_mapping util_reg',
+ deps='LIBCRYPTO ndr ndr-util security NDR_SECURITY charset NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 samba-util3 CHARSET3 UTIL_TDB UTIL_PW SAMBA_VERSION krb5 flag_mapping util_reg',
private_library=True,
vars=locals())