Initial import (#1124482)
This commit is contained in:
parent
91b12d31fe
commit
4ff329d8bb
7 changed files with 214 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -0,0 +1 @@
|
|||
/amprd-1.4.tgz
|
||||
10
amprd-1.4-examples-noshebang.patch
Normal file
10
amprd-1.4-examples-noshebang.patch
Normal file
|
|
@ -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@yo2loj.ro>
|
||||
#
|
||||
48
amprd-1.4-install-fix.patch
Normal file
48
amprd-1.4-install-fix.patch
Normal file
|
|
@ -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
|
||||
66
amprd-1.4-pidfile.patch
Normal file
66
amprd-1.4-pidfile.patch
Normal file
|
|
@ -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;
|
||||
11
amprd.service
Normal file
11
amprd.service
Normal file
|
|
@ -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
|
||||
77
amprd.spec
Normal file
77
amprd.spec
Normal file
|
|
@ -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@redhat.com> - 1.4-2
|
||||
- Fixed ldflags_harden
|
||||
|
||||
* Tue Jul 29 2014 Jaroslav Škarvada <jskarvad@redhat.com> - 1.4-1
|
||||
- Initial release
|
||||
1
sources
1
sources
|
|
@ -0,0 +1 @@
|
|||
2cba21d7866c94a30c85daf7468998ae amprd-1.4.tgz
|
||||
Loading…
Add table
Add a link
Reference in a new issue