mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* ANN: capwrap - grant capabilities to executables
@ 2002-03-17 20:11 Neil Schemenauer
  2002-03-17 22:25 ` H. Peter Anvin
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Schemenauer @ 2002-03-17 20:11 UTC (permalink / raw)
  To: linux-kernel

I've written a small module¹ that enables the use of Linux capabilities
on filesystems that do not support them.  It is similar in spirit to ELF
capabilities hack² but is not specific to the ELF executable format and
is implemented as separate kernel module.

To grant capabilities to an executable, a small wrapper file is created
that includes the path to an executable followed a capability set
written in hexadecimal.  When this file is executed by the kernel, the
executable is granted the specified capabilities.  The wrapper file must
be owned by root and have the SUID bit set.

For example, to remove the SUID bit on the ping program while retaining
its functionality:

    # chmod -s /bin/ping
    # mv /bin/ping /bin/ping_real
    # echo '&/bin/ping_real 2000' > /bin/ping
    # chmod +xs /bin/ping

Comments welcome.

  Neil


¹ http://arctrix.com/nas/linux/capwrap.tar.gz
² http://atrey.karlin.mff.cuni.cz/~pavel/elfcap.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ANN: capwrap - grant capabilities to executables
  2002-03-17 20:11 ANN: capwrap - grant capabilities to executables Neil Schemenauer
@ 2002-03-17 22:25 ` H. Peter Anvin
  2002-03-17 22:45   ` Neil Schemenauer
  0 siblings, 1 reply; 3+ messages in thread
From: H. Peter Anvin @ 2002-03-17 22:25 UTC (permalink / raw)
  To: linux-kernel

Followup to:  <20020317121118.A18548@glacier.arctrix.com>
By author:    Neil Schemenauer <nas@python.ca>
In newsgroup: linux.dev.kernel
>
> I've written a small module¹ that enables the use of Linux capabilities
> on filesystems that do not support them.  It is similar in spirit to ELF
> capabilities hack² but is not specific to the ELF executable format and
> is implemented as separate kernel module.
> 
> To grant capabilities to an executable, a small wrapper file is created
> that includes the path to an executable followed a capability set
> written in hexadecimal.  When this file is executed by the kernel, the
> executable is granted the specified capabilities.  The wrapper file must
> be owned by root and have the SUID bit set.
> 
> For example, to remove the SUID bit on the ping program while retaining
> its functionality:
> 
>     # chmod -s /bin/ping
>     # mv /bin/ping /bin/ping_real
>     # echo '&/bin/ping_real 2000' > /bin/ping
>     # chmod +xs /bin/ping
> 

Why not just do this with a small program if you're doing setuid
anyway?

	-hpa
-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<amsp@zytor.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ANN: capwrap - grant capabilities to executables
  2002-03-17 22:25 ` H. Peter Anvin
@ 2002-03-17 22:45   ` Neil Schemenauer
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Schemenauer @ 2002-03-17 22:45 UTC (permalink / raw)
  To: linux-kernel

H. Peter Anvin wrote:
> Why not just do this with a small program if you're doing setuid
> anyway?

Nothing is running with root privileges (unless root is executing it).
The SUID bit on the wrapper is just a marker and does not change the
effective uid of the process.  Also, AFAIK, you can't pass capabilities
from one program to another using exec().   I don't completely
understand this stuff yet but fs/exec.c has these lines in the
prepare_binprm() function:

        cap_clear(bprm->cap_inheritable);
        cap_clear(bprm->cap_permitted);
        cap_clear(bprm->cap_effective);

Capabilities are only raised if bprm->e_uid == 0.  So, unless I'm
misunderstand the code, you can't do the same thing with a SUID wrapper.

Thanks for you're comments.

  Neil

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-03-17 22:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-17 20:11 ANN: capwrap - grant capabilities to executables Neil Schemenauer
2002-03-17 22:25 ` H. Peter Anvin
2002-03-17 22:45   ` Neil Schemenauer

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®