from small one page howto to huge articles all in one place
 

search text in:





Poll
Which screen resolution do you use?










poll results



Last additions:
Disable Anti-Aliasing fonts

Disable Anti-Aliasing fonts

words:

186

views:

8266

userrating:

no votes yet


May 25th. 2007:
Words

491

Views

9600

why adblockers are bad


handy one-liners for sed (Unix stream editor)
Tutorial:

handy one-liners for sed (Unix stream editor)

words:

4078

views:

25003

userrating:

no votes yet


rotating apache logfiles with cronolog

rotating apache logfiles with cronolog

words:

294

views:

9730

userrating:

no votes yet


Druckversion
You are here: manpages

CAP_GET_PROC

Section: Linux Programmer's Manual (3)
Updated: 2008-05-11
Index Return to Main Contents
 

NAME

cap_get_proc, cap_set_proc, capgetp - capability manipulation on processes  

SYNOPSIS

#include <sys/capability.h>

cap_t cap_get_proc(void);

int cap_set_proc(cap_t cap_p);

cap_t capgetp(pid_t pid, cap_t cap_d);

Link with -lcap.  

DESCRIPTION

cap_get_proc() allocates a capability state in working storage, sets its state to that of the calling process, and returns a pointer to this newly created capability state. The caller should free any releasable memory, when the capability state in working storage is no longer required, by calling cap_free() with the cap_t as an argument.

cap_set_proc() sets the values for all capability flags for all capabilities to the capability state identified by cap_p. The new capability state of the process will be completely determined by the contents of cap_p upon successful return from this function. If any flag in cap_p is set for any capability not currently permitted for the calling process, the function will fail, and the capability state of the process will remain unchanged.

capgetp() fills an existing cap_d, see cap_init(3), with the process capabilities of the process indicated by pid. This information can also be obtained from the /proc/<pid>/status file.  

RETURN VALUE

cap_get_proc() returns a non-NULL value on success, and NULL on failure.

cap_set_proc() and capgetp() return zero for success, and -1 on failure.

On failure, errno is set to EINVAL, EPERM, or ENOMEM.  

CONFORMING TO

cap_set_proc() and cap_get_proc() are specified in the withdrawn POSIX.1e draft specification. capgetp() and capsetp() (described below) are Linux extensions.  

NOTES

The library also supports the deprecated function:

cap_t capsetp(pid_t pid, cap_t cap_d);

capsetp() attempts to set the capabilities of some other process(es), pid. If pid is positive it refers to a specific process; if it is zero, it refers to the current process; -1 refers to all processes other than the current process and process '1' (typically init(8)); other negative values refer to the -pid process group. In order to use this function, the kernel must support it and the current process must have CAP_SETPCAP raised in its Effective capability set. The capabilities set in the target process(es) are those contained in cap_d. Kernels that support filesystem capabilities redefine the semantics of CAP_SETPCAP and on such systems this function will always fail for any target not equal to the current process. capsetp() returns zero for success, and -1 on failure.

Where supported by the kernel, the function capsetp() should be used with care. It existed, primarily, to overcome an early lack of support for capabilities in the filesystems supported by Linux. Note that, by default, the only processes that have CAP_SETPCAP available to them are processes started as a kernel thread. (Typically this includes init(8), kflushd and kswapd). You will need to recompile the kernel to modify this default.  

EXAMPLE

The code segment below raises the CAP_FOWNER and CAP_SETFCAP effective capabilities for the caller:

    cap_t caps;
    cap_value_t cap_list[2];

    caps = cap_get_proc();
    if (caps == NULL)
        /* handle error */;

    cap_list[0] = CAP_FOWNER;
    cap_list[1] = CAP_SETFCAP;
    if (cap_set_flag(caps, CAP_EFFECTIVE, 2, cap_list, CAP_SET) == -1)
        /* handle error */;

    if (cap_set_proc(caps) == -1)
        /* handle error */;

    if (cap_free(caps) == -1)
        /* handle error */;
 

SEE ALSO

cap_clear(3), cap_copy_ext(3), cap_from_text(3), cap_get_file(3), cap_init(3), capabilities(7)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
CONFORMING TO
NOTES
EXAMPLE
SEE ALSO

Please read "Why adblockers are bad". Ärger mit Freenet.de



to the forum.
:
:
other Ads
Stellenangebote
Stellenangebote
für Fach- und
Führungskräfte
www.nachoben.com
Other free services
toURL.org
Shorten long
URLs to short
links like
http://tourl.org/2
tourl.org
.
FeedCollector
Combine various newsfeeds to one customized webpage
www.feedcollector.org
.
Reverse DNS lookup
Find out which hostname(s)
resolve to a
given IP or other hostnames for the server
www.reversednslookup.org
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004 S&P Softwaredesign
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 62.9 ms
system status display