Skip to content

Commit 1b5fb7e

Browse files
committedNov 11, 2008
Makefile tweaks mostly
add rule to build HTML add LIBATTR=no makefile support for not including filesystem support comment cleanup for cap_file.c. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
1 parent 7d068bb commit 1b5fb7e

File tree

7 files changed

+49
-8
lines changed

7 files changed

+49
-8
lines changed
 

‎Make.Rules

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(IPATH)
6666
PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
6767
INDENT := $(shell if [ -z "$(which ident 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
6868
DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
69+
LIBATTR := yes
6970

7071
# Global cleanup stuff
7172

‎README

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
This is a library for getting and setting POSIX.1e (formerly POSIX 6)
32
draft 15 capabilities.
43

@@ -8,7 +7,7 @@ This library would not have been possible without the help of
87

98
More information on capabilities in the Linux kernel can be found at
109

11-
http://linux.kernel.org/pub/linux/libs/security/linux-privs/
10+
http://sites.google.com/site/fullycapable/
1211

1312
# INSTALLATION
1413

@@ -18,7 +17,7 @@ More information on capabilities in the Linux kernel can be found at
1817

1918
Linux-Caps % make install
2019

21-
installs the library libcap.XX.Y in /lib/
20+
installs the library libcap.XX.Y in /lib[64]/
2221
the binaries in /sbin/
2322
the <sys/capability.h> file in /usr/include
2423

‎doc/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ MANS = $(MAN3S) $(MAN8S)
1818

1919
all: $(MANS)
2020

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+
2130
install:
2231
mkdir -p -m 755 $(MANDIR)/man3 $(MANDIR)/man8
2332
for man in \
@@ -33,4 +42,6 @@ install:
3342

3443
clean:
3544
$(LOCALCLEAN)
45+
rm -rf html
46+
3647

‎libcap/Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ LIBNAME=$(LIBTITLE).so
1010
STALIBNAME=$(LIBTITLE).a
1111
#
1212

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
1421

1522
INCLS=libcap.h cap_names.h $(INCS)
1623
OBJS=$(addsuffix .o, $(FILES))
1724
MAJLIBNAME=$(LIBNAME).$(VERSION)
1825
MINLIBNAME=$(MAJLIBNAME).$(MINOR)
1926
GPERF_OUTPUT = _caps_output.gperf
20-
LDFLAGS += -lattr
2127

2228
all: $(MINLIBNAME) $(STALIBNAME)
2329

‎libcap/cap_file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ cap_t cap_get_fd(int fildes)
199199
}
200200

201201
/*
202-
* Set the capabilities on a named file.
202+
* Get the capabilities from a named file.
203203
*/
204204

205205
cap_t cap_get_file(const char *filename)

‎progs/Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ include $(topdir)/Make.Rules
44
#
55
# Programs: all of the examples that we will compile
66
#
7-
PROGS=getpcaps getcap setcap capsh
7+
PROGS=getpcaps capsh
8+
ifeq ($(LIBATTR),yes)
9+
PROGS += getcap setcap
10+
endif
11+
812
BUILD=$(PROGS)
913

1014
ifneq ($(DYNAMIC),yes)
@@ -28,4 +32,4 @@ install: all
2832

2933
clean:
3034
$(LOCALCLEAN)
31-
rm -f *.o $(BUILD) tcapsh ping
35+
rm -f *.o $(BUILD) tcapsh ping hack.sh

‎progs/quicktest.sh

+20
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,23 @@ pass_capsh --secbits=47 --inh=cap_net_raw --drop=cap_net_raw \
104104
--uid=500 --print -- -c "./ping -c1 localhost"
105105

106106
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

0 commit comments

Comments
 (0)
Please sign in to comment.