[amprd] Initial import (#1124482)

Jaroslav Škarvada jskarvad at fedoraproject.org
Fri Aug 29 13:18:07 UTC 2014


commit 4ff329d8bba28bd5eca34e4c44e26b02f91567be
Author: Jaroslav Škarvada <jskarvad at redhat.com>
Date:   Fri Aug 29 15:18:03 2014 +0200

    Initial import (#1124482)

 .gitignore                         |    1 +
 amprd-1.4-examples-noshebang.patch |   10 +++++
 amprd-1.4-install-fix.patch        |   48 ++++++++++++++++++++++
 amprd-1.4-pidfile.patch            |   66 ++++++++++++++++++++++++++++++
 amprd.service                      |   11 +++++
 amprd.spec                         |   77 ++++++++++++++++++++++++++++++++++++
 sources                            |    1 +
 7 files changed, 214 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..ee32fba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/amprd-1.4.tgz
diff --git a/amprd-1.4-examples-noshebang.patch b/amprd-1.4-examples-noshebang.patch
new file mode 100644
index 0000000..2190c49
--- /dev/null
+++ b/amprd-1.4-examples-noshebang.patch
@@ -0,0 +1,10 @@
+diff --git a/startup_example.sh b/startup_example.sh
+index fa5b6b0..6ea9171 100755
+--- a/startup_example.sh
++++ b/startup_example.sh
+@@ -1,5 +1,3 @@
+-#!/bin/bash
+-
+ #
+ # Example script to start amprd 1.0 - Marius, YO2LOJ,  <marius at yo2loj.ro>
+ #
diff --git a/amprd-1.4-install-fix.patch b/amprd-1.4-install-fix.patch
new file mode 100644
index 0000000..21d9ff0
--- /dev/null
+++ b/amprd-1.4-install-fix.patch
@@ -0,0 +1,48 @@
+diff --git a/Makefile b/Makefile
+index 06688e9..b56e067 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2,26 +2,22 @@
+ # Makefile for ampr-ripd
+ #
+ 
+-CONFDIR = /etc
+-SBINDIR = /usr/sbin
+-SCACHEDIR = /var/lib/amprd
+-
+-# no need to run dx-broadcast as root
+-OWN = daemon
+-GRP = daemon
++CONFDIR = $(DESTDIR)/etc
++SBINDIR = $(DESTDIR)/usr/sbin
++SCACHEDIR = $(DESTDIR)/var/lib/amprd
+ 
+ CC = gcc
+-COPT = -Wall -O2
++CFLAGS = -Wall -O2
+ LD = gcc
+-LOPT =
++LDFLAGS =
+ 
+ OBJFILES = amprd.o tunnel.o minIni.o list.o rip.o encap.o cache.o route.o
+ 
+ .c.o:
+-	$(CC) $(COPT) -c $<
++	$(CC) $(CFLAGS) -c $<
+ 
+ amprd:	$(OBJFILES)
+-	$(LD) $(LOPT) -o amprd $(OBJFILES)
++	$(LD) $(LDFLAGS) -o amprd $(OBJFILES)
+ 
+ all:	amprd
+ 
+@@ -30,6 +26,6 @@ clean:
+ 
+ install:	amprd
+ #	strip amprd
+-	install -m 755 -o $(OWN) -g $(GRP) -d                   $(SCACHEDIR)
+-	install -m 644 -o $(OWN) -g $(GRP) amprd.conf.example   $(CONFDIR)
+-	install -m 755 -o $(OWN) -g $(GRP) amprd                $(SBINDIR)
++	install -m 755 -p -d -D                    $(SCACHEDIR)
++	install -m 644 -p -D amprd.conf.example    $(CONFDIR)/amprd.conf
++	install -m 755 -p -D amprd                 $(SBINDIR)/amprd
diff --git a/amprd-1.4-pidfile.patch b/amprd-1.4-pidfile.patch
new file mode 100644
index 0000000..4439f33
--- /dev/null
+++ b/amprd-1.4-pidfile.patch
@@ -0,0 +1,66 @@
+diff --git a/amprd.c b/amprd.c
+index 4eee8d2..5a3eb99 100644
+--- a/amprd.c
++++ b/amprd.c
+@@ -68,6 +68,7 @@
+ #include "commons.h"
+ 
+ #define MAXPAYLOAD 		(2048)
++#define PIDFILE "/var/run/amprd.pid"
+ 
+ char *passwd = NULL;
+ int debug = FALSE;
+@@ -83,6 +84,7 @@ uint32_t general_ampr_gw;
+ 
+ uint32_t myips[MYIPSIZE];
+ 
++void (*sigterm_defhnd)(int);
+ 
+ void on_alarm(int sig)
+ {
+@@ -146,6 +148,16 @@ void on_hup(int sig)
+     verbose = FALSE;
+ }
+ 
++void on_term(int sig)
++{
++  signal(SIGTERM, SIG_IGN);
++
++  unlink(PIDFILE);
++
++  signal(SIGTERM, sigterm_defhnd);
++  raise(SIGTERM);
++}
++
+ uint32_t getip(const char *dev)
+ {
+     struct ifreq ifr;
+@@ -260,6 +272,7 @@ int main(int argc, char**argv)
+     struct pollfd *pollfd;
+     int i, j, payload, best, mask, bmask;
+     Tunnel *tunnel;
++    FILE *pidfile;
+ 
+     char *ip = malloc(MAXPAYLOAD + 18);   /* eth header + tcp/ip frame + checksum */
+     char *rcv = malloc(MAXPAYLOAD + 20);  /* ip header + tcp/ip frame */
+@@ -343,7 +356,6 @@ int main(int argc, char**argv)
+     sa.sa_handler = on_hup;
+     sigaction(SIGHUP, &sa, 0);
+ 
+-
+     if (FALSE == debug)
+     {
+ 	pid_t fork_res = -1;
+@@ -361,6 +373,12 @@ int main(int argc, char**argv)
+ 	}
+     }
+ 
++    sa.sa_handler = on_term;
++    sigaction(SIGTERM, &sa, 0);
++    pidfile = fopen(PIDFILE, "w");
++    fprintf(pidfile, "%d\n", (int)getpid());
++    fclose(pidfile);
++
+     pollfd = malloc(sizeof(struct pollfd) * (numtunnels + 1));
+ 
+     pollfd[0].fd = raw_socket;
diff --git a/amprd.service b/amprd.service
new file mode 100644
index 0000000..d1c1271
--- /dev/null
+++ b/amprd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description = AMPR IPIP Encapsulation Daemon
+After = network.target
+
+[Service]
+Type = forking
+PIDFile = /run/amprd.pid
+ExecStart = /usr/sbin/amprd
+
+[Install]
+WantedBy = multi-user.target
diff --git a/amprd.spec b/amprd.spec
new file mode 100644
index 0000000..05d8110
--- /dev/null
+++ b/amprd.spec
@@ -0,0 +1,77 @@
+# hardened build if not overriden
+%{!?_hardened_build:%global _hardened_build 1}
+
+%if %{?_hardened_build}%{!?_hardened_build:0}
+%global cflags_harden -fpie
+%global ldflags_harden -pie -z relro -z now
+%endif
+
+Summary: An user-space IPIP encapsulation daemon for the ampr network
+Name: amprd
+Version: 1.4
+Release: 2%{?dist}
+License: GPLv3+
+Group: Applications/Communications
+URL: http://www.yo2loj.ro/hamprojects/
+BuildRequires: dos2unix, systemd
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+Source0: http://www.yo2loj.ro/hamprojects/%{name}-%{version}.tgz
+Source1: amprd.service
+Patch0: amprd-1.4-install-fix.patch
+Patch1: amprd-1.4-pidfile.patch
+Patch2: amprd-1.4-examples-noshebang.patch
+
+%description
+An user-space IPIP encapsulation daemon with automatic RIPv2 multicast
+processing and multiple tunnel support for the ampr network.
+All RIPv2 processing, encapsulation, decapsulation and routing happens
+inside the daemon and it offers one or more virtual TUN interfaces to
+the system for your 44net traffic.
+
+%prep
+%setup -qc
+%patch0 -p1 -b .install-fix
+%patch1 -p1 -b .pidfile
+%patch2 -p1 -b .examples-noshebang
+
+dos2unix minGlue.h
+
+%build
+make %{?_smp_mflags} CFLAGS="%{optflags} %{?cflags_harden}" LDFLAGS="%{?__global_ldflags} %{?ldflags_harden}"
+
+%install
+make %{?_smp_mflags} DESTDIR=%{buildroot} install
+
+# Systemd
+install -Dpm 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
+
+# Examples
+install -Dd %{buildroot}%{_datadir}/%{name}
+install -Dpm 644 -t %{buildroot}%{_datadir}/%{name} startup_example.sh interfaces_example
+
+%post
+%systemd_post %{name}.service
+
+%preun
+%systemd_preun %{name}.service
+
+%postun
+%systemd_postun_with_restart %{name}.service
+
+%files
+%doc COPYING README
+
+%{_sbindir}/amprd
+%config(noreplace) %{_sysconfdir}/amprd.conf
+%{_datadir}/%{name}
+%{_var}/lib/amprd
+%{_unitdir}/amprd.service
+
+%changelog
+* Fri Aug 29 2014 Jaroslav Škarvada <jskarvad at redhat.com> - 1.4-2
+- Fixed ldflags_harden
+
+* Tue Jul 29 2014 Jaroslav Škarvada <jskarvad at redhat.com> - 1.4-1
+- Initial release
diff --git a/sources b/sources
index e69de29..31f6356 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+2cba21d7866c94a30c85daf7468998ae  amprd-1.4.tgz


More information about the scm-commits mailing list