"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/libcap/libcap.h" between
proftpd-1.3.6b.tar.gz and proftpd-1.3.6c.tar.gz

About: ProFTPD is a highly configurable FTP server software (with FTPS and SFTP support).

libcap.h  (proftpd-1.3.6b):libcap.h  (proftpd-1.3.6c)
/* /*
* Copyright (c) 1997 Andrew G Morgan <morgan@linux.kernel.org> * Copyright (c) 1997 Andrew G Morgan <morgan@kernel.org>
*
* See end of file for Log.
* *
* This file contains internal definitions for the various functions in * This file contains internal definitions for the various functions in
* this small capability library. * this small capability library.
*/ */
#ifndef LIBCAP_H #ifndef LIBCAP_H
#define LIBCAP_H #define LIBCAP_H
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include "include/sys/capability.h" #include "include/sys/capability.h"
#ifndef __u8 #ifndef __u8
#define __u8 unsigned char #define __u8 uint8_t
#endif /* __8 */ #endif /* __8 */
#ifndef __u32 #ifndef __u32
#define __u32 unsigned int #define __u32 uint32_t
#endif /* __u32 */ #endif /* __u32 */
/* include the names for the caps and a definition of __CAP_BITS */ /* include the names for the caps and a definition of __CAP_BITS */
#include "cap_names.h" #include "cap_names.h"
#ifndef _LINUX_CAPABILITY_U32S_1
# define _LINUX_CAPABILITY_U32S_1 1
#endif /* ndef _LINUX_CAPABILITY_U32S */
/*
* Do we match the local kernel?
*/
#if !defined(_LINUX_CAPABILITY_VERSION)
# error Kernel <linux/capability.h> does not support library
# error file "libcap.h" --> fix and recompile libcap
#elif !defined(_LINUX_CAPABILITY_VERSION_2)
# warning Kernel <linux/capability.h> does not support 64-bit capabilities
# warning and libcap is being built with no support for 64-bit capabilities
# ifndef _LINUX_CAPABILITY_VERSION_1
# define _LINUX_CAPABILITY_VERSION_1 0x19980330
# endif
# _LIBCAP_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1
# _LIBCAP_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1
#elif defined(_LINUX_CAPABILITY_VERSION_3)
# if (_LINUX_CAPABILITY_VERSION_3 != 0x20080522)
# error Kernel <linux/capability.h> v3 does not match library
# error file "libcap.h" --> fix and recompile libcap
# else
# define _LIBCAP_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_3
# define _LIBCAP_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3
# endif
#elif (_LINUX_CAPABILITY_VERSION_2 != 0x20071026)
# error Kernel <linux/capability.h> does not match library
# error file "libcap.h" --> fix and recompile libcap
#else
# define _LIBCAP_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_2
# define _LIBCAP_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_2
#endif
#undef _LINUX_CAPABILITY_VERSION
#undef _LINUX_CAPABILITY_U32S
/* /*
* This is a pointer to a struct containing three consecutive * This is a pointer to a struct containing three consecutive
* capability sets in the order of the cap_flag_t type: the are * capability sets in the order of the cap_flag_t type: the are
* effective,inheritable and permitted. This is the type that the * effective,inheritable and permitted. This is the type that the
* user-space routines think of as 'internal' capabilities - this is * user-space routines think of as 'internal' capabilities - this is
* the type that is passed to the kernel with the system calls related * the type that is passed to the kernel with the system calls related
* to processes. * to processes.
*/ */
#if defined(VFS_CAP_REVISION_MASK) && !defined(VFS_CAP_U32)
# define VFS_CAP_U32_1 1
# define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1))
# define VFS_CAP_U32 VFS_CAP_U32_1
struct _cap_vfs_cap_data {
__le32 magic_etc;
struct {
__le32 permitted;
__le32 inheritable;
} data[VFS_CAP_U32_1];
};
# define vfs_cap_data _cap_vfs_cap_data
#endif
#ifndef CAP_TO_INDEX
# define CAP_TO_INDEX(x) ((x) >> 5) /* 1 << 5 == bits in __u32 */
#endif /* ndef CAP_TO_INDEX */
#ifndef CAP_TO_MASK
# define CAP_TO_MASK(x) (1 << ((x) & 31))
#endif /* ndef CAP_TO_MASK */
#define NUMBER_OF_CAP_SETS 3 /* effective, inheritable, permitted */
#define __CAP_BLKS (_LIBCAP_CAPABILITY_U32S)
#define CAP_SET_SIZE (__CAP_BLKS * sizeof(__u32))
#define CAP_T_MAGIC 0xCA90D0 #define CAP_T_MAGIC 0xCA90D0
struct _cap_struct { struct _cap_struct {
struct __user_cap_header_struct head; struct __user_cap_header_struct head;
struct __user_cap_data_struct set; union {
struct __user_cap_data_struct set;
__u32 flat[NUMBER_OF_CAP_SETS];
} u[_LIBCAP_CAPABILITY_U32S];
}; };
/* the maximum bits supportable */
#define __CAP_MAXBITS (__CAP_BLKS * 32)
/* string magic for cap_free */ /* string magic for cap_free */
#define CAP_S_MAGIC 0xCA95D0 #define CAP_S_MAGIC 0xCA95D0
/* Older Linux kernels only define _LINUX_CAPABILITY_VERSION. Newer Linux
* kernels use _LINUX_CAPABILITY_VERSION_1 and _LINUX_CAPABILITY_VERSION_2,
* and define _LINUX_CAPABILITY_VERSION to be _LINUX_CAPABILITY_VERSION_2.
* This means that, for proper compilation and functioning on the newer
* kernels, we need to use _LINUX_CAPABILITY_VERSION_1. But to make sure
* we still compile on the older Linux kernels, we need to make define
* our own _LINUX_CAPABILITY_VERSION_1 to be _LINUX_CAPABILITY_VERSION.
*/
#if !defined(_LINUX_CAPABILITY_VERSION_1) && \
defined(_LINUX_CAPABILITY_VERSION)
# define _LINUX_CAPABILITY_VERSION_1 _LINUX_CAPABILITY_VERSION
#endif
/*
* Do we match the local kernel?
*/
#if !defined(_LINUX_CAPABILITY_VERSION_1) || \
(_LINUX_CAPABILITY_VERSION_1 != 0x19980330)
# error "Kernel <linux/capability.h> does not match library"
# error "file "libcap.h" --> fix and recompile libcap"
#endif
/* /*
* kernel API cap set abstraction * kernel API cap set abstraction
*/ */
#define NUMBER_OF_CAP_SETS 3 /* effective, inheritable, permitted */ #define raise_cap(x,set) u[(x)>>5].flat[set] |= (1<<((x)&31))
#define CAP_SET_SIZE (sizeof(struct __user_cap_data_struct)/NUMBER_OF_CAP_SETS) #define lower_cap(x,set) u[(x)>>5].flat[set] &= ~(1<<((x)&31))
#define __CAP_BLKS (CAP_SET_SIZE/sizeof(__u32)) #define isset_cap(y,x,set) ((y)->u[(x)>>5].flat[set] & (1<<((x)&31)))
typedef struct {
__u32 _blk[__CAP_BLKS];
} __cap_s;
#define raise_cap(x) _blk[(x)>>5] |= (1<<((x)&31))
#define lower_cap(x) _blk[(x)>>5] &= ~(1<<((x)&31))
#define isset_cap(y,x) ((y)->_blk[(x)>>5] & (1<<((x)&31)))
/* /*
* Private definitions for internal use by the library. * Private definitions for internal use by the library.
*/ */
#define __libcap_check_magic(c,magic) ((c) && *(-1+(__u32 *)(c)) == (magic)) #define __libcap_check_magic(c,magic) ((c) && *(-1+(__u32 *)(c)) == (magic))
#define good_cap_t(c) __libcap_check_magic(c, CAP_T_MAGIC) #define good_cap_t(c) __libcap_check_magic(c, CAP_T_MAGIC)
#define good_cap_string(c) __libcap_check_magic(c, CAP_S_MAGIC) #define good_cap_string(c) __libcap_check_magic(c, CAP_S_MAGIC)
/* /*
* These match CAP_DIFFERS() expectations
*/
#define LIBCAP_EFF (1 << CAP_EFFECTIVE)
#define LIBCAP_INH (1 << CAP_INHERITABLE)
#define LIBCAP_PER (1 << CAP_PERMITTED)
/*
* library debugging * library debugging
*/ */
#ifdef DEBUG #ifdef DEBUG
#include <stdio.h> #include <stdio.h>
# define _cap_debug(f, x...) { \ # define _cap_debug(f, x...) do { \
fprintf(stderr, __FUNCTION__ "(" __FILE__ ":%d): ", __LINE__); \ fprintf(stderr, "%s(%s:%d): ", __FUNCTION__, __FILE__, __LINE__); \
fprintf(stderr, f, ## x); \ fprintf(stderr, f, ## x); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} } while (0)
# define _cap_debugcap(s, c) \
fprintf(stderr, __FUNCTION__ "(" __FILE__ ":%d): " s \ # define _cap_debugcap(s, c, set) do { \
"%08x\n", __LINE__, *(c)) unsigned _cap_index; \
fprintf(stderr, "%s(%s:%d): %s", __FUNCTION__, __FILE__, __LINE__, s); \
for (_cap_index=_LIBCAP_CAPABILITY_U32S; _cap_index-- > 0; ) { \
fprintf(stderr, "%08x", (c).u[_cap_index].flat[set]); \
} \
fprintf(stderr, "\n"); \
} while (0)
#else /* !DEBUG */ #else /* !DEBUG */
# define _cap_debug(f, x...) # define _cap_debug(f, x...)
# define _cap_debugcap(s, c) # define _cap_debugcap(s, c, set)
#endif /* DEBUG */ #endif /* DEBUG */
extern char *_libcap_strdup(const char *text); extern char *_libcap_strdup(const char *text);
/* /*
* These are semi-public prototypes, they will only be defined in * These are semi-public prototypes, they will only be defined in
* <sys/capability.h> if _POSIX_SOURCE is not #define'd, so we * <sys/capability.h> if _POSIX_SOURCE is not #define'd, so we
* place them here too. * place them here too.
*/ */
extern int capset(cap_user_header_t header, cap_user_data_t data); extern int capset(cap_user_header_t header, cap_user_data_t data);
extern int capget(cap_user_header_t header, const cap_user_data_t data); extern int capget(cap_user_header_t header, const cap_user_data_t data);
extern int capgetp(pid_t pid, cap_t cap_d); extern int capgetp(pid_t pid, cap_t cap_d);
extern int capsetp(pid_t pid, cap_t cap_d); extern int capsetp(pid_t pid, cap_t cap_d);
#endif /* LIBCAP_H */ /* prctl based API for altering character of current process */
#define PR_GET_KEEPCAPS 7
#define PR_SET_KEEPCAPS 8
#define PR_CAPBSET_READ 23
#define PR_CAPBSET_DROP 24
#define PR_GET_SECUREBITS 27
#define PR_SET_SECUREBITS 28
/* /*
* $Log: libcap.h,v $ * The library compares sizeof() with integer return values. To avoid
* Revision 1.5 2008-08-23 02:49:48 castaglia * signed/unsigned comparisons, leading to unfortunate
* * misinterpretations of -1, we provide a convenient cast-to-signed-integer
* Fix typo (missing backslash). * version of sizeof().
*
* Revision 1.4 2008/08/22 16:35:52 castaglia
*
* Try to handle the change in Linux capability version macro names for
* older kernels (which don't define/use the new names).
*
* Revision 1.3 2008/08/06 17:00:41 castaglia
*
* Bug#3096 - libcap version errors on newer Linux kernel. Newer Linux kernels
* have a _LINUX_CAPABILITY_VERSION_2 macro, and redefine the old
* _LINUX_CAPABILITY_VERSION macro. To play better with such kernels, redefine
* the bundled libcap to use _LINUX_CAPABILITY_VERSION_1.
*
* Revision 1.2 2003/05/15 00:49:13 castaglia
*
* Bug#2000 - mod_cap should not use bundled libcap. This patch updates the
* bundled libcap; I won't be closing the bug report just yet.
*
* Revision 1.1 2003/01/03 02:16:17 jwm
*
* Turning mod_linuxprivs into a core module, mod_cap. This is by no means
* complete.
*
* Revision 1.2 1999/09/07 23:14:19 macgyver
* Updated capabilities library and model.
*
* Revision 1.2 1999/04/17 23:25:10 morgan
* fixes from peeterj
*
* Revision 1.1.1.1 1999/04/17 22:16:31 morgan
* release 1.0 of libcap
*
* Revision 1.5 1998/06/08 00:15:28 morgan
* accommodate alpha (glibc?)
*
* Revision 1.4 1998/06/07 15:58:23 morgan
* accommodate real kernel header files :*)
*
* Revision 1.3 1998/05/24 22:54:09 morgan
* updated for 2.1.104
*
* Revision 1.2 1997/04/28 00:57:11 morgan
* zefram's replacement file with a number of bug fixes from AGM
*
* Revision 1.1 1997/04/21 04:32:52 morgan
* Initial revision
*
*/ */
#define ssizeof(x) ((ssize_t) sizeof(x))
#endif /* LIBCAP_H */
 End of changes. 17 change blocks. 
99 lines changed or deleted 121 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)