From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>,
Linux Containers
<containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Alexey Dobriyan
<adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 5/5] cr: restore file->f_cred
Date: Mon, 11 May 2009 11:05:49 -0500 [thread overview]
Message-ID: <20090511160549.GE12286@us.ibm.com> (raw)
In-Reply-To: <20090511160424.GA12234-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Ony seems useful if you're using coda or hppfs, but go ahead and
restore a file's f_cred. This is set to the cred of the task doing
the open, so often it will be the same as that of the restarted task.
Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
checkpoint/files.c | 16 ++++++++++++++--
include/linux/checkpoint_hdr.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/checkpoint/files.c b/checkpoint/files.c
index c6a946b..22c8bb9 100644
--- a/checkpoint/files.c
+++ b/checkpoint/files.c
@@ -151,7 +151,11 @@ int checkpoint_file_common(struct ckpt_ctx *ctx, struct file *file,
h->f_pos = file->f_pos;
h->f_version = file->f_version;
- /* FIX: need also file->uid, file->gid, file->f_owner, etc */
+ h->f_credref = checkpoint_obj(ctx, file->f_cred, CKPT_OBJ_CRED);
+ if (h->f_credref < 0)
+ return h->f_credref;
+
+ /* FIX: need also file->f_owner, etc */
return 0;
}
@@ -359,8 +363,16 @@ int restore_file_common(struct ckpt_ctx *ctx, struct file *file,
struct ckpt_hdr_file *h)
{
int ret;
+ struct cred *cred;
+
+ /* FIX: need to restore owner etc */
- /* FIX: need to restore uid, gid, owner etc */
+ /* restore the cred */
+ cred = ckpt_obj_fetch(ctx, h->f_credref, CKPT_OBJ_CRED);
+ if (IS_ERR(cred))
+ return PTR_ERR(cred);
+ put_cred(file->f_cred);
+ file->f_cred = get_cred(cred);
/* safe to set 1st arg (fd) to 0, as command is F_SETFL */
ret = vfs_fcntl(0, F_SETFL, h->f_flags & CKPT_SETFL_MASK, file);
diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h
index 475186a..5aa214f 100644
--- a/include/linux/checkpoint_hdr.h
+++ b/include/linux/checkpoint_hdr.h
@@ -336,6 +336,7 @@ struct ckpt_hdr_file {
__u32 _padding;
__u64 f_pos;
__u64 f_version;
+ __s32 f_credref;
} __attribute__((aligned(8)));
struct ckpt_hdr_file_generic {
--
1.6.1
next prev parent reply other threads:[~2009-05-11 16:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-11 16:04 [PATCH 0/5] cr: attempt at task userid restoration Serge E. Hallyn
[not found] ` <20090511160424.GA12234-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-05-11 16:05 ` [PATCH 1/5] cr: break out new_user_ns() Serge E. Hallyn
2009-05-11 16:05 ` [PATCH 2/5] cr: split core function out of some set*{u,g}id functions Serge E. Hallyn
2009-05-11 16:05 ` [PATCH 3/5] cr: capabilities: define checkpoint and restore fns Serge E. Hallyn
2009-05-11 16:05 ` [PATCH 4/5] cr: checkpoint and restore task credentials Serge E. Hallyn
[not found] ` <20090511160539.GD12286-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-05-12 12:34 ` [PATCH 1/1] cr: child user namespace must grab ref to creator Serge E. Hallyn
2009-05-14 8:18 ` [PATCH 4/5] cr: checkpoint and restore task credentials Alexey Dobriyan
[not found] ` <20090514081850.GA21115-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-05-14 10:52 ` Alexey Dobriyan
[not found] ` <20090514105252.GA31197-2ev+ksY9ol182hYKe6nXyg@public.gmane.org>
2009-05-14 13:58 ` Serge E. Hallyn
2009-05-14 13:54 ` Serge E. Hallyn
2009-05-11 16:05 ` Serge E. Hallyn [this message]
[not found] ` <20090511160512.GB12286-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-05-11 16:24 ` [PATCH 2/5] cr: split core function out of some set*{u, g}id functions David Howells
[not found] ` <22104.1242059047-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-05-11 18:08 ` [PATCH 2/5] cr: split core function out of some set*{u,g}id functions Serge E. Hallyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090511160549.GE12286@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=adobriyan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox