File tree 7 files changed +49
-8
lines changed
7 files changed +49
-8
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(IPATH)
66
66
PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
67
67
INDENT := $(shell if [ -z "$(which ident 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
68
68
DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
69
+ LIBATTR := yes
69
70
70
71
# Global cleanup stuff
71
72
Original file line number Diff line number Diff line change 1
-
2
1
This is a library for getting and setting POSIX.1e (formerly POSIX 6)
3
2
draft 15 capabilities.
4
3
@@ -8,7 +7,7 @@ This library would not have been possible without the help of
8
7
9
8
More information on capabilities in the Linux kernel can be found at
10
9
11
- http://linux.kernel.org/pub/linux/libs/security/linux-privs /
10
+ http://sites.google.com/site/fullycapable /
12
11
13
12
# INSTALLATION
14
13
@@ -18,7 +17,7 @@ More information on capabilities in the Linux kernel can be found at
18
17
19
18
Linux-Caps % make install
20
19
21
- installs the library libcap.XX.Y in /lib/
20
+ installs the library libcap.XX.Y in /lib[64] /
22
21
the binaries in /sbin/
23
22
the <sys/capability.h> file in /usr/include
24
23
Original file line number Diff line number Diff line change @@ -18,6 +18,15 @@ MANS = $(MAN3S) $(MAN8S)
18
18
19
19
all : $(MANS )
20
20
21
+ .PHONY : html
22
+ html :
23
+ mkdir -p html
24
+ for man in $( MANS) ; \
25
+ do \
26
+ egrep ' ^\.so man' $$ man > /dev/null || \
27
+ groff -man -Thtml $$ man > html/$$ man.html ; \
28
+ done
29
+
21
30
install :
22
31
mkdir -p -m 755 $(MANDIR ) /man3 $(MANDIR ) /man8
23
32
for man in \
@@ -33,4 +42,6 @@ install:
33
42
34
43
clean :
35
44
$(LOCALCLEAN )
45
+ rm -rf html
46
+
36
47
Original file line number Diff line number Diff line change @@ -10,14 +10,20 @@ LIBNAME=$(LIBTITLE).so
10
10
STALIBNAME =$(LIBTITLE ) .a
11
11
#
12
12
13
- FILES =cap_alloc cap_proc cap_extint cap_flag cap_text cap_file
13
+ FILES =cap_alloc cap_proc cap_extint cap_flag cap_text
14
+
15
+ # make including file support something you can override (no libattr
16
+ # no support).
17
+ ifeq ($(LIBATTR ) ,yes)
18
+ FILES += cap_file
19
+ LDFLAGS += -lattr
20
+ endif
14
21
15
22
INCLS =libcap.h cap_names.h $(INCS )
16
23
OBJS =$(addsuffix .o, $(FILES ) )
17
24
MAJLIBNAME =$(LIBNAME ) .$(VERSION )
18
25
MINLIBNAME =$(MAJLIBNAME ) .$(MINOR )
19
26
GPERF_OUTPUT = _caps_output.gperf
20
- LDFLAGS += -lattr
21
27
22
28
all : $(MINLIBNAME ) $(STALIBNAME )
23
29
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ cap_t cap_get_fd(int fildes)
199
199
}
200
200
201
201
/*
202
- * Set the capabilities on a named file.
202
+ * Get the capabilities from a named file.
203
203
*/
204
204
205
205
cap_t cap_get_file (const char * filename )
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ include $(topdir)/Make.Rules
4
4
#
5
5
# Programs: all of the examples that we will compile
6
6
#
7
- PROGS =getpcaps getcap setcap capsh
7
+ PROGS =getpcaps capsh
8
+ ifeq ($(LIBATTR ) ,yes)
9
+ PROGS += getcap setcap
10
+ endif
11
+
8
12
BUILD =$(PROGS )
9
13
10
14
ifneq ($(DYNAMIC ) ,yes)
@@ -28,4 +32,4 @@ install: all
28
32
29
33
clean :
30
34
$(LOCALCLEAN )
31
- rm -f * .o $(BUILD ) tcapsh ping
35
+ rm -f * .o $(BUILD ) tcapsh ping hack.sh
Original file line number Diff line number Diff line change @@ -104,3 +104,23 @@ pass_capsh --secbits=47 --inh=cap_net_raw --drop=cap_net_raw \
104
104
--uid=500 --print -- -c " ./ping -c1 localhost"
105
105
106
106
rm -f ./ping
107
+
108
+ # test that we do not support capabilities on setuid shell-scripts
109
+ cat > hack.sh << EOF
110
+ #!/bin/bash
111
+ mypid=\$\$
112
+ caps=\$ (./getpcaps \$ mypid 2>&1 | cut -d: -f2)
113
+ if [ "\$ caps" != " =" ]; then
114
+ echo "Shell script got [\$ caps] - you should upgrade your kernel"
115
+ exit 1
116
+ fi
117
+ exit 0
118
+ EOF
119
+ chmod +xs hack.sh
120
+ ./hack.sh
121
+ status=$?
122
+ rm -f ./hack.sh
123
+ if [ $status -ne 0 ]; then
124
+ echo " shell scripts can have capabilities (bug)"
125
+ exit 1
126
+ fi
You can’t perform that action at this time.
0 commit comments