From: Neil Schemenauer <nas@arctrix.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.6-mm1
Date: Tue, 11 May 2004 10:49:18 -0400 [thread overview]
Message-ID: <20040511144918.GA4764@mems-exchange.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 354 bytes --]
[Andrew Morton]
> Has been discussed on this list. It requires worrisome changes to
> the capability system, changes to PAM, changes to login and
> changes to applications.
Have you seen my capwrap[1] module? I wouldn't call it elegant but
it is very simple and flexible.
Neil
1. http://marc.theaimsgroup.com/?l=linux-kernel&m=108143257710466&w=2
[-- Attachment #2: binfmt_capwrap.c --]
[-- Type: text/x-csrc, Size: 2634 bytes --]
/*
* linux/fs/binfmt_capwrap.c
*
* Copyright (C) 2002 Neil Schemenauer
*/
#include <linux/module.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/stat.h>
#include <linux/slab.h>
#include <linux/binfmts.h>
#include <linux/init.h>
#include <linux/file.h>
#include <linux/smp_lock.h>
#include <linux/mount.h>
#include <linux/fs.h>
static int parse_cap(char **cp, unsigned int *cap)
{
char *tok, *endp;
int n;
if ((tok = strsep(cp, " \t")) == NULL)
return 0;
n = simple_strtol(tok, &endp, 16);
if (*endp != '\0')
return 0;
*cap = n;
return 1;
}
static void grant_capabilities(struct linux_binprm *bprm, unsigned int caps)
{
/* This may have to be more complicated if the kernel
* representation of capabilities changes. Right now it's trivial.
*/
bprm->cap_effective |= caps;
bprm->cap_permitted |= caps;
}
static int load_capwrap(struct linux_binprm *bprm, struct pt_regs *regs)
{
struct inode * inode = bprm->file->f_dentry->d_inode;
int mode = inode->i_mode;
char exec_name[BINPRM_BUF_SIZE];
char *cp, *tok;
unsigned int caps = 0;
struct file *file;
int retval;
/* must have magic */
if ((bprm->buf[0] != '&'))
return -ENOEXEC;
/* must be owned by root */
if (inode->i_uid != 0)
return -ENOEXEC;
/* must be SUID */
if ((bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) ||
!(mode & S_ISUID))
return -ENOEXEC;
/*
* Okay, parse the wrapper.
*/
allow_write_access(bprm->file);
fput(bprm->file);
bprm->file = NULL;
/* terminate first line */
bprm->buf[BINPRM_BUF_SIZE - 1] = '\0';
if ((cp = strchr(bprm->buf, '\n')) == NULL)
cp = bprm->buf+BINPRM_BUF_SIZE-1;
*cp = '\0';
/* name */
cp = bprm->buf+1;
if ((tok = strsep(&cp, " \t")) == NULL)
return -ENOEXEC;
strcpy(exec_name, tok);
/* capabilities to add */
if (!parse_cap(&cp, &caps))
return -ENOEXEC;
/*
* Restart the process with real executable's dentry.
*/
file = open_exec(exec_name);
if (IS_ERR(file))
return PTR_ERR(file);
bprm->file = file;
retval = prepare_binprm(bprm);
if (retval < 0)
return retval;
grant_capabilities(bprm, caps);
printk(KERN_DEBUG "capwrap: granted %s %x effective now %x\n",
exec_name, caps, bprm->cap_effective);
return search_binary_handler(bprm, regs);
}
struct linux_binfmt capwrap_format = {
.module = THIS_MODULE,
.load_binary = load_capwrap,
};
static int __init init_capwrap_binfmt(void)
{
return register_binfmt(&capwrap_format);
}
static void __exit exit_capwrap_binfmt(void)
{
unregister_binfmt(&capwrap_format);
}
module_init(init_capwrap_binfmt)
module_exit(exit_capwrap_binfmt)
MODULE_LICENSE("GPL");
next reply other threads:[~2004-05-11 14:49 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-11 14:49 Neil Schemenauer [this message]
2004-05-11 18:55 ` 2.6.6-mm1 Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2004-05-12 15:27 2.6.6-mm1 Sid Boyce
2004-05-12 12:26 2.6.6-mm1 Sid Boyce
2004-05-11 10:34 2.6.6-mm1 Sid Boyce
[not found] <fa.j4d62qo.1144tpk@ifi.uio.no>
[not found] ` <fa.gg699ad.b2omr9@ifi.uio.no>
2004-05-11 6:33 ` 2.6.6-mm1 Andy Lutomirski
2004-05-10 16:50 2.6.6-mm1 Sid Boyce
2004-05-10 12:43 2.6.6-mm1 Sid Boyce
2004-05-12 8:13 ` 2.6.6-mm1 Andrew Morton
2004-05-10 9:45 2.6.6-mm1 Andrew Morton
2004-05-10 10:52 ` 2.6.6-mm1 Dominik Karall
2004-05-10 11:18 ` 2.6.6-mm1 Dave Jones
2004-05-10 12:20 ` 2.6.6-mm1 Nick Piggin
2004-05-10 12:22 ` 2.6.6-mm1 Dave Jones
2004-05-10 14:38 ` 2.6.6-mm1 Norberto Bensa
2004-05-10 14:55 ` 2.6.6-mm1 Dominik Karall
2004-05-10 15:02 ` 2.6.6-mm1 Norberto Bensa
2004-05-10 15:22 ` 2.6.6-mm1 Dominik Karall
2004-05-10 15:33 ` 2.6.6-mm1 Norberto Bensa
2004-05-10 15:20 ` 2.6.6-mm1 Christoph Hellwig
2004-05-11 5:21 ` 2.6.6-mm1 Andrew Morton
2004-05-10 21:37 ` 2.6.6-mm1 Christoph Hellwig
2004-05-10 22:02 ` 2.6.6-mm1 Andrew Morton
2004-05-10 22:05 ` 2.6.6-mm1 Christoph Hellwig
2004-05-10 22:15 ` 2.6.6-mm1 Andrew Morton
2004-05-10 22:20 ` 2.6.6-mm1 Christoph Hellwig
2004-05-10 22:47 ` 2.6.6-mm1 Andrew Morton
2004-05-10 22:48 ` 2.6.6-mm1 Christoph Hellwig
2004-05-10 23:16 ` 2.6.6-mm1 Matt Mackall
2004-05-10 22:27 ` 2.6.6-mm1 Valdis.Kletnieks
2004-05-10 22:48 ` 2.6.6-mm1 Andrew Morton
2004-05-10 23:01 ` 2.6.6-mm1 Valdis.Kletnieks
2004-05-10 23:11 ` 2.6.6-mm1 Chris Wedgwood
2004-05-10 23:14 ` 2.6.6-mm1 Christoph Hellwig
2004-05-10 23:28 ` 2.6.6-mm1 Andrew Morton
2004-05-10 23:33 ` 2.6.6-mm1 Chris Wedgwood
2004-05-10 23:51 ` 2.6.6-mm1 Andrew Morton
2004-05-10 23:53 ` 2.6.6-mm1 Chris Wedgwood
2004-05-11 0:14 ` 2.6.6-mm1 Andrew Morton
2004-05-11 0:24 ` 2.6.6-mm1 Wim Coekaerts
2004-05-11 1:10 ` 2.6.6-mm1 Andrew Morton
2004-05-11 1:51 ` 2.6.6-mm1 Wim Coekaerts
2004-05-11 6:23 ` 2.6.6-mm1 Christoph Hellwig
2004-05-12 2:44 ` 2.6.6-mm1 Andrea Arcangeli
2004-05-12 5:11 ` 2.6.6-mm1 Chris Wedgwood
2004-05-11 15:12 ` 2.6.6-mm1 Wim Coekaerts
2004-05-12 5:42 ` 2.6.6-mm1 Christoph Hellwig
2004-05-12 5:50 ` 2.6.6-mm1 Christoph Hellwig
2004-05-11 6:22 ` 2.6.6-mm1 Christoph Hellwig
2004-05-11 6:21 ` 2.6.6-mm1 Christoph Hellwig
2004-05-11 6:37 ` 2.6.6-mm1 William Lee Irwin III
2004-05-11 6:18 ` 2.6.6-mm1 Christoph Hellwig
2004-05-10 23:33 ` 2.6.6-mm1 Chris Wright
2004-05-11 1:59 ` 2.6.6-mm1 Matt Mackall
2004-05-11 14:34 ` 2.6.6-mm1 Stephen Smalley
2004-05-11 16:48 ` 2.6.6-mm1 Chris Wright
2004-05-12 12:49 ` 2.6.6-mm1 Sean Neakums
2004-05-12 19:26 ` 2.6.6-mm1 Andrew Morton
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=20040511144918.GA4764@mems-exchange.org \
--to=nas@arctrix.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®