lib/util/util_pw: share sys_get{pw,gr} group of calls.
authorGünther Deschner <gd@samba.org>
Wed, 2 Mar 2011 15:06:32 +0000 (16:06 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 29 Mar 2011 23:13:06 +0000 (01:13 +0200)
Guenther

15 files changed:
lib/util/util_pw.c
lib/util/util_pw.h [new file with mode: 0644]
lib/util/wscript_build
source3/Makefile.in
source3/auth/token_util.c
source3/include/proto.h
source3/lib/system.c
source3/lib/username.c
source3/lib/util.c
source3/passdb/pdb_interface.c
source3/passdb/util_unixsids.c
source3/rpc_server/srvsvc/srv_srvsvc_nt.c
source3/smbd/ntquotas.c
source3/torture/cmd_vfs.c
source3/wscript_build

index bda7e24ede86abaf19222b50749682253f0e2e8c..cb7b45c13567ebf7ef7f8dc0563619a490219e45 100644 (file)
@@ -3,7 +3,12 @@
 
    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) 
diff --git a/lib/util/util_pw.h b/lib/util/util_pw.h
new file mode 100644 (file)
index 0000000..fa212b9
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+   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__ */
index 7f5b1d2c6788ae9a1a7a8cc1d20f517da37a7490..6aaf04c96e0b4e7b26f443447758cc11f275c013 100755 (executable)
@@ -86,3 +86,8 @@ bld.SAMBA_SUBSYSTEM('UTIL_RUNCMD',
        public_deps='tevent'
        )
 
+bld.SAMBA_SUBSYSTEM('UTIL_PW',
+       source='util_pw.c',
+       local_include=False,
+       public_deps='talloc'
+       )
index b2f4594f2cb6ca14616c75084744e4fa9bbee575..109d0801ac5e8dd3f4140964a90e02f391d08050 100644 (file)
@@ -424,7 +424,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
                   ../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 \
index 4942740ed063ecbff65a9661ce05fe1f1f7a1af0..f88511d8d634893c47e50d1bf587c495cd0abd80 100644 (file)
@@ -29,6 +29,7 @@
 #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
index 14ec2d68534aba5e725b3d464b77755f7ddbbe55..94cc9f9baa4c980a29c4c19549a33a02bfdf3311 100644 (file)
@@ -868,13 +868,6 @@ void sys_srandom(unsigned int seed);
 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);
index 092287a6020a60957a4769ca4cf2932d37f23101..d1a14033409eaf5ef1a212f04b78d4b58034bf6a 100644 (file)
@@ -1345,50 +1345,6 @@ int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset)
 #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.
 ****************************************************************************/
index 4e77bee304b2039f74343dab7cacc65a2b154d1d..eea906128e1631bfd260e55a3e1be49ce19d7100 100644 (file)
@@ -21,6 +21,7 @@
 
 #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,
index b99d9d42a8fbf5cb6ea9d8c33a325d1d742eb53c..2690a6f649001cee9bc54d8581c590ba7bd8df2e 100644 (file)
@@ -25,6 +25,7 @@
 #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)
index 8cdaaaa5698fa1a847343a7d4e7f92b87d57f5c9..046ca650cf08199d9ade9a7f79e19d69aae375cf 100644 (file)
@@ -26,6 +26,7 @@
 #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
index 00cab22debce36b4383fc7e194ff9652e9a4a04b..cf85a5dbf1c4edd0c5173fd2aaccc078e5bdba95 100644 (file)
@@ -19,6 +19,7 @@
 
 #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)
 {
index f0a105e33e0a481fee925082719fef86ae0c7074..a0ed295ed3c1ee65e3d6ec9882661db8352c91c4 100644 (file)
@@ -30,6 +30,7 @@
 #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;
 
index 95e9ec3b2457c80ba32645ca449ce80988f67280..141f1f81b2296675599f320d0e856443eb5e8336 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "../lib/util/util_pw.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_QUOTA
index ea5004ce639364b93a58eb8bc938f80212ae60da..3d7420cba9aaa80b369f8fe421af6f8677a6e52f 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 #include "vfstest.h"
+#include "../lib/util/util_pw.h"
 
 static const char *null_string = "";
 
index 3e71e94c43c4cc16f34647af97d33fd561a51402..76abe0b9bb2dae4b90b9d49e5eba50ee4cb46b95 100755 (executable)
@@ -773,7 +773,7 @@ bld.SAMBA3_SUBSYSTEM('KRBCLIENT',
 
 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())