Skip to contentSkip to conversation

2.6.23: access permission filesystem 0.20

PATCH New Olaf Dietsche 1 participant 1 message Oct 26, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.23: access permission filesystem 0.20

This patch adds a new permission managing file system. Furthermore, it adds two modules, which make use of this file system.

One module allows granting capabilities based on user-/groupid. The second module allows to grant access to lower numbered ports based on user-/groupid, too.

Changes:
- updated to 2.6.23

This patch is available at:
<http://www.olafdietsche.de/linux/accessfs/>

Regards, Olaf.

 Documentation/filesystems/accessfs.txt |   41 +++
 fs/Kconfig                             |    1 +
 fs/Makefile                            |    1 +
 fs/accessfs/Kconfig                    |   50 ++++
 fs/accessfs/Makefile                   |   11 +
 fs/accessfs/capabilities.c             |  107 ++++++++
 fs/accessfs/inode.c                    |  426 ++++++++++++++++++++++++++++++++
 fs/accessfs/ip.c                       |   95 +++++++
 include/linux/accessfs_fs.h            |   42 +++
 include/net/sock.h                     |   43 ++++
 net/Kconfig                            |   12 +
 net/Makefile                           |    1 +
 net/hooks.c                            |   55 ++++
 net/ipv4/af_inet.c                     |    2 +-
 net/ipv6/af_inet6.c                    |    2 +-
 15 files changed, 887 insertions(+), 2 deletions(-)
Documentation/filesystems/accessfs.txt new file +41 -0
new file mode 100644
index 0000000..bf135b5
@@ -0,0 +1,41 @@
+Accessfs is a permission managing filesystem. It allows to control access to
+system resources, based on file permissions. The recommended mount point for
+this file-system is /proc/access, which will appear automatically in the
+/proc filesystem.
+
+Currently there are two modules using accessfs, userports and usercaps.
+
+With userports, you will be able to control access to IP ports based
+on user-/groupid.
+
+There's no need anymore to run internet daemons as root. You can
+individually configure which user/program can bind to protected ports
+(by default, below 1024).
+
+For example, you can say, user www is allowed to bind to port 80 or
+user mail is allowed to bind to port 25. Then, you can run apache as
+user www and sendmail as user mail. Now, you don't have to rely on
+apache or sendmail giving up superuser rights to enhance security.
+
+To use this option, you need to mount the access file system
+and do a chown on the appropriate ports:
+
+# mount -t accessfs none /proc/access
+# chown www /proc/access/net/ip/bind/80
+# chown mail /proc/access/net/ip/bind/25
+
+You can grant access to a group for individual ports as well. Just say:
+
+# chgrp lp /proc/access/net/ip/bind/515
+# chown g+x /proc/access/net/ip/bind/515
+
+With usercaps, you will be able to grant capabilities based on
+user-/groupid (root by default).
+
+For example you can create a group raw and change the capability
+net_raw to this group:
+
+# chgrp raw /proc/access/capabilities/net_raw
+# chmod ug+x /proc/access/capabilities/net_raw
+# chgrp raw /sbin/ping
+# chmod u-s /sbin/ping; chmod g+s /sbin/ping
fs/Kconfig +1 -0
index f9eed6d..008a764 100644
@@ -1425,6 +1425,7 @@ config QNX4FS_RW
 	  It's currently broken, so for now:
 	  answer N.
 
+source "fs/accessfs/Kconfig"
 
 
 config SYSV_FS
fs/Makefile +1 -0
index 720c29d..50f6d49 100644
@@ -118,3 +118,4 @@ obj-$(CONFIG_HPPFS)		+= hppfs/
 obj-$(CONFIG_DEBUG_FS)		+= debugfs/
 obj-$(CONFIG_OCFS2_FS)		+= ocfs2/
 obj-$(CONFIG_GFS2_FS)           += gfs2/
+obj-$(CONFIG_ACCESS_FS)		+= accessfs/
fs/accessfs/Kconfig new file +50 -0

50 lines not on this page · raw message

fs/accessfs/Makefile new file +11 -0
new file mode 100644
index 0000000..63a5647
@@ -0,0 +1,11 @@
+#
+# Makefile for the linux accessfs routines.
+#
+
+obj-$(CONFIG_ACCESS_FS) += accessfs.o
+obj-$(CONFIG_ACCESSFS_USER_CAPABILITIES) += usercaps.o
+obj-$(CONFIG_ACCESSFS_USER_PORTS) += userports.o
+
+accessfs-objs := inode.o
+usercaps-objs := capabilities.o
+userports-objs := ip.o
fs/accessfs/capabilities.c new file +107 -0

107 lines not on this page · raw message

fs/accessfs/inode.c new file +426 -0

426 lines not on this page · raw message

fs/accessfs/ip.c new file +95 -0

95 lines not on this page · raw message

include/linux/accessfs_fs.h new file +42 -0

42 lines not on this page · raw message

include/net/sock.h +43 -0

47 lines not on this page · raw message

net/Kconfig +12 -0
index cdba08c..50e21e2 100644
@@ -57,6 +57,18 @@ config INET
 if INET
 source "net/ipv4/Kconfig"
 source "net/ipv6/Kconfig"
+
+config NET_HOOKS
+	bool "IP: Networking hooks (Experimental)"
+	depends on INET && EXPERIMENTAL
+	default n
+	help
+	  This option enables other kernel parts or modules to hook into the
+	  networking area and provide fine grained control over the access to
+	  IP ports.
+
+	  If you're unsure, say N.
+
 source "net/netlabel/Kconfig"
 
 endif # if INET
net/Makefile +1 -0
index bbe7d2a..7ab64cf 100644
@@ -52,6 +52,7 @@ obj-$(CONFIG_NETLABEL)		+= netlabel/
 obj-$(CONFIG_IUCV)		+= iucv/
 obj-$(CONFIG_RFKILL)		+= rfkill/
 obj-$(CONFIG_NET_9P)		+= 9p/
+obj-$(CONFIG_NET_HOOKS)		+= hooks.o
 
 ifeq ($(CONFIG_NET),y)
 obj-$(CONFIG_SYSCTL)		+= sysctl_net.o
net/hooks.c new file +55 -0

55 lines not on this page · raw message

net/ipv4/af_inet.c +1 -1
index e681034..f1d1b83 100644
@@ -457,7 +457,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 
 	snum = ntohs(addr->sin_port);
 	err = -EACCES;
-	if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
+	if (ip_prot_sock(sock, uaddr, addr_len))
 		goto out;
 
 	/*      We keep a pair of addresses. rcv_saddr is the one
net/ipv6/af_inet6.c +1 -1
index b5f9637..0c28cc4 100644
@@ -263,7 +263,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		return -EINVAL;
 
 	snum = ntohs(addr->sin6_port);
-	if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
+	if (ip6_prot_sock(sock, uaddr, addr_len))
 		return -EACCES;
 
 	lock_sock(sk);