summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-07-03 15:32:10 -0700
committerJeremy Allison <jra@samba.org>2012-07-03 15:34:22 -0700
commit90881da68509ad673c1e921831ef4f36cabb9ea8 (patch)
tree1a2fcf093318c98f05872dc7a6deee0c63dcd9ae
parenta559fcf156f4ee8c98daac52fcf3447993b9ba14 (diff)
downloadsamba-90881da68509ad673c1e921831ef4f36cabb9ea8.tar.gz
samba-90881da68509ad673c1e921831ef4f36cabb9ea8.tar.bz2
samba-90881da68509ad673c1e921831ef4f36cabb9ea8.zip
Move copy_unix_token() from locking/locking.c to lib/util.c.
Make public.
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/lib/util.c30
-rw-r--r--source3/locking/locking.c29
3 files changed, 31 insertions, 29 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 308283016c..b7f2852a48 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -497,6 +497,7 @@ bool map_open_params_to_ntcreate(const char *smb_base_fname,
uint32 *pcreate_disposition,
uint32 *pcreate_options,
uint32_t *pprivate_flags);
+struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct security_unix_token *tok);
void init_modules(void);
/* The following definitions come from lib/util_builtin.c */
diff --git a/source3/lib/util.c b/source3/lib/util.c
index f1b815878d..697f7b143d 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2460,3 +2460,33 @@ bool map_open_params_to_ntcreate(const char *smb_base_fname,
return True;
}
+
+/*************************************************************************
+ Return a talloced copy of a struct security_unix_token. NULL on fail.
+*************************************************************************/
+
+struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct security_unix_token *tok)
+{
+ struct security_unix_token *cpy;
+
+ cpy = talloc(ctx, struct security_unix_token);
+ if (!cpy) {
+ return NULL;
+ }
+
+ cpy->uid = tok->uid;
+ cpy->gid = tok->gid;
+ cpy->ngroups = tok->ngroups;
+ if (tok->ngroups) {
+ /* Make this a talloc child of cpy. */
+ cpy->groups = (gid_t *)talloc_memdup(
+ cpy, tok->groups, tok->ngroups * sizeof(gid_t));
+ if (!cpy->groups) {
+ TALLOC_FREE(cpy);
+ return NULL;
+ }
+ } else {
+ cpy->groups = NULL;
+ }
+ return cpy;
+}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 95e9b77553..d3ab7f3140 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -882,35 +882,6 @@ bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp)
return True;
}
-/*************************************************************************
- Return a talloced copy of a struct security_unix_token. NULL on fail.
- (Should this be in locking.c.... ?).
-*************************************************************************/
-
-static struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct security_unix_token *tok)
-{
- struct security_unix_token *cpy;
-
- cpy = talloc(ctx, struct security_unix_token);
- if (!cpy) {
- return NULL;
- }
-
- cpy->uid = tok->uid;
- cpy->gid = tok->gid;
- cpy->ngroups = tok->ngroups;
- if (tok->ngroups) {
- /* Make this a talloc child of cpy. */
- cpy->groups = (gid_t *)talloc_memdup(
- cpy, tok->groups, tok->ngroups * sizeof(gid_t));
- if (!cpy->groups) {
- TALLOC_FREE(cpy);
- return NULL;
- }
- }
- return cpy;
-}
-
/****************************************************************************
Adds a delete on close token.
****************************************************************************/