]> git.neil.brown.name Git - portmap.git/blob - Makefile
9e9a4b41117c61c5a2c6a1588ae59871ad183a75
[portmap.git] / Makefile
1
2 ####################################
3 ### Beginning of configurable stuff.
4
5 # By default, logfile entries are written to the same file as used for
6 # sendmail transaction logs. Change the definition of the following macro
7 # if you disagree. See `man 3 syslog' for examples. Some syslog versions
8 # do not provide this flexibility.
9
10 FACILITY=LOG_DAEMON
11
12 # To disable tcp-wrapper style access control, comment out the following
13 # macro definitions.  Access control can also be turned off by providing
14 # no access control tables. The local system, since it runs the portmap
15 # daemon, is always treated as an authorized host.
16 # By default, access control does not do hostname lookup as there is a risk
17 # that will require portmap access, hence deadlock.  If you are sure the
18 # target system will never user NIS for hostname lookup, you can define
19 # USE_DNS to add hostname tests in hosts.allow/deny.
20
21 ifeq ($(NO_TCP_WRAPPER),)
22 CPPFLAGS += -DHOSTS_ACCESS
23 WRAP_LIB  = -lwrap
24 ifdef USE_DNS
25 CPPFLAGS += -DENABLE_DNS
26 MAN_SED += -e 's/USE_DNS/yes/'
27 endif
28 endif
29
30 # Comment out if your RPC library does not allocate privileged ports for
31 # requests from processes with root privilege, or the new portmap will
32 # always reject requests to register/unregister services on privileged
33 # ports. You can find out by running "rpcinfo -p"; if all mountd and NIS
34 # daemons use a port >= 1024 you should probably disable the next line.
35
36 CPPFLAGS += -DCHECK_PORT
37
38 # The portmap daemon runs a uid=1/gid=1 by default.  You can change that
39 # be defining DAEMON_UID and DAMEON_GID to numbers, or RPCUSER to a
40 # name, though you must be sure that name lookup will not require use
41 # of portmap.
42 ifdef RPCUSER
43 CPPFLAGS += -DRPCUSER=\"$(RPCUSER)\"
44 MAN_SED += -e 's/RPCUSER/$(RPCUSER)/'
45 else
46 MAN_SED += -e 's/RPCUSER//'
47 endif
48 ifdef DAEMON_UID
49 CPPFLAGS += -DDAEMON_UID=$(DAEMON_UID) -DDAEMON_GID=$(DAEMON_GID)
50 MAN_SED += -e 's/DAEMON_UID/$(DAEMON_UID)/' -e 's/DAEMON_GID/$(DAEMON_GID)/'
51 else
52 MAN_SED += -e 's/DAEMON_UID/1/' -e 's/DAEMON_GID/1/'
53 endif
54
55 # Warning: troublesome feature ahead!! Enable only when you are really
56 # desperate!!
57 #
58 # It is possible to prevent an attacker from manipulating your portmapper
59 # tables from outside with requests that contain spoofed source addresses.
60 # The countermeasure is to force all rpc servers to register and
61 # unregister with the portmapper via the loopback network interface,
62 # instead of via the primary network interface that every host can talk
63 # to. For this countermeasure to work it is necessary to uncomment the
64 # LOOPBACK definition below, and to take the following additional steps:
65
66 # (1) Modify the libc library (or librpc if you have one) and replace
67 # get_myaddress() by a version that selects the loopback address instead
68 # of the primary network interface address. A suitable version is
69 # provided in the file get_myaddress.c. This forces rpc servers to send
70 # all set/unset requests to the loopback address.
71
72 # (2) Rebuild all statically-linked rpc servers with the modified
73 # library.
74
75 # (3) Disable IP source routing in the kernel (otherwise an outside
76 # attacker can still send requests that appear to come from the local
77 # machine).
78
79 # Instead of (1) it may be sufficient to run the rpc servers with a
80 # preload shared object that implements the alternate get_myaddress()
81 # behavior (see Makefile.shlib). You still need to disable IP source
82 # routing, though.
83 #
84 # I warned you, you need to be really desperate to do this. It is
85 # probably much easier to just block port UDP and TCP ports 111 on
86 # your routers.
87 #
88 # CPPFLAGS += -DLOOPBACK_SETUNSET
89
90 # When the portmapper cannot find any local interfaces (it will complain
91 # to the syslog daemon) your system probably has variable-length socket
92 # address structures (struct sockaddr has a sa_len component; examples:
93 # AIX 4.1 and 4.4BSD). Uncomment next macro definition in that case.
94 #
95 # CPPFLAGS += -DHAS_SA_LEN              # AIX 4.x, BSD 4.4, FreeBSD, NetBSD
96
97 # With verbose logging on, HP-UX 9.x and AIX 4.1 leave zombies behind when
98 # SIGCHLD is not ignored. Enable next macro for a fix.
99 #
100 CPPFLAGS += -DIGNORE_SIGCHLD    # AIX 4.x, HP-UX 9.x
101
102 # Uncomment the following macro if your system does not have u_long.
103 #
104 # CPPFLAGS      +=-Du_long="unsigned long"
105
106 #
107 # LDLIBS        += -m
108 # CFLAGS        += -arch m68k -arch i386 -arch hppa
109
110 # Auxiliary libraries that you may have to specify
111 #
112 # LDLIBS        += -lrpc
113
114 # Comment out if your compiler talks ANSI and understands const
115 #
116 # CPPFLAGS += -Dconst=
117
118 ### End of configurable stuff.
119 ##############################
120
121 CPPFLAGS += -DFACILITY=$(FACILITY)
122 CFLAGS   ?= -O2
123 CFLAGS   += -Wall -Wstrict-prototypes
124
125 all:    portmap pmap_dump pmap_set portmap.man
126
127 CPPFLAGS += $(HOSTS_ACCESS)
128 portmap: CFLAGS   += -fpie
129 portmap: LDLIBS   += $(WRAP_LIB)
130 portmap: LDFLAGS  += -pie
131 portmap: portmap.o pmap_check.o from_local.o
132
133 from_local: CPPFLAGS += -DTEST
134
135 portmap.man : portmap.8
136         sed $(MAN_SED) < portmap.8 > portmap.man
137
138 install: all
139         install -o root -g root -m 0755 -s portmap ${BASEDIR}/sbin
140         install -o root -g root -m 0755 -s pmap_dump ${BASEDIR}/sbin
141         install -o root -g root -m 0755 -s pmap_set ${BASEDIR}/sbin
142         install -o root -g root -m 0644 portmap.man ${BASEDIR}/usr/share/man/man8/portmap.8
143         install -o root -g root -m 0644 pmap_dump.8 ${BASEDIR}/usr/share/man/man8
144         install -o root -g root -m 0644 pmap_set.8 ${BASEDIR}/usr/share/man/man8
145
146 clean:
147         rm -f *.o portmap pmap_dump pmap_set from_local \
148             core portmap.man
149
150 -include .depend
151 .depend: *.c
152         $(CC) -MM $(CFLAGS) *.c > .depend
153
154 .PHONY: all clean install