Browse Source

Merge tag '1.2' into ppa

ppa
Timo Röhling 10 years ago
parent
commit
cd8d445295
15 changed files with 210 additions and 112 deletions
  1. 38
    12
      CMakeLists.txt
  2. 39
    6
      README.md
  3. 0
    0
      init/postsrsd.apparmor.in
  4. 9
    6
      init/postsrsd.default.in
  5. 15
    0
      init/postsrsd.systemd.in
  6. 19
    13
      init/postsrsd.sysv-lsb.in
  7. 6
    13
      init/postsrsd.sysv-redhat.in
  8. 14
    0
      init/postsrsd.upstart.in
  9. 1
    2
      makefile
  10. 11
    7
      postinstall.cmake.in
  11. 29
    5
      postsrsd.c
  12. 0
    23
      postsrsd.upstart.in
  13. 11
    11
      sha1.c
  14. 10
    10
      srs2.c
  15. 8
    4
      srs2.h

+ 38
- 12
CMakeLists.txt View File

1
 cmake_minimum_required(VERSION 2.4)
1
 cmake_minimum_required(VERSION 2.4)
2
 project(postsrsd C)
2
 project(postsrsd C)
3
+include(CheckIncludeFile)
3
 
4
 
4
 option(GENERATE_SRS_SECRET "Generate a random SRS secret if none exists during install" ON)
5
 option(GENERATE_SRS_SECRET "Generate a random SRS secret if none exists during install" ON)
5
 option(USE_APPARMOR "Enable AppArmor profile" OFF)
6
 option(USE_APPARMOR "Enable AppArmor profile" OFF)
6
 
7
 
7
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
8
 set(CHROOT_DIR "${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}" CACHE PATH "Chroot jail for daemon")
8
-set(CONFIG_DIR "/etc/default" CACHE PATH "Location of configuration file")
9
+set(SYSCONF_DIR "/etc" CACHE PATH "Global system configuration folder")
10
+set(CONFIG_DIR "${SYSCONF_DIR}/default" CACHE PATH "Location of startup configuration file")
11
+set(DOC_DIR "share/doc/${PROJECT_NAME}" CACHE PATH "Path for documentation files")
9
 
12
 
10
 find_program(HELP2MAN help2man DOC "path to help2man executable")
13
 find_program(HELP2MAN help2man DOC "path to help2man executable")
11
 find_program(DD dd DOC "path to dd executable")
14
 find_program(DD dd DOC "path to dd executable")
13
 find_program(INSSERV insserv DOC "path to insserv executable")
16
 find_program(INSSERV insserv DOC "path to insserv executable")
14
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
17
 find_program(CHKCONFIG chkconfig DOC "path to chkconfig executable")
15
 
18
 
19
+check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
20
+if(HAVE_SYS_WAIT_H)
21
+    add_definitions(-DHAVE_SYS_WAIT_H)
22
+endif()
23
+check_include_file(wait.h HAVE_WAIT_H)
24
+if(HAVE_WAIT_H)
25
+    add_definitions(-DHAVE_WAIT_H)
26
+endif()
27
+check_include_file(sys/time.h HAVE_SYS_TIME_H)
28
+if(HAVE_SYS_TIME_H)
29
+    add_definitions(-DHAVE_SYS_TIME_H)
30
+endif()
31
+check_include_file(time.h HAVE_TIME_H)
32
+if(HAVE_TIME_H)
33
+    add_definitions(-DHAVE_TIME_H)
34
+endif()
35
+
16
 if(NOT DEFINED INIT_FLAVOR)
36
 if(NOT DEFINED INIT_FLAVOR)
17
-    if(IS_DIRECTORY "/etc/init" AND EXISTS "/lib/init/upstart-job")
37
+	if(IS_DIRECTORY "${SYSCONF_DIR}/systemd" AND EXISTS "/usr/lib/systemd/systemd")
38
+        message(STATUS "Detected init flavor: systemd")
39
+        set(INIT_FLAVOR "systemd" CACHE STRING "Init daemon of this system")
40
+    elseif(IS_DIRECTORY "${SYSCONF_DIR}/init" AND EXISTS "/lib/init/upstart-job")
18
         message(STATUS "Detected init flavor: upstart")
41
         message(STATUS "Detected init flavor: upstart")
19
         set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
42
         set(INIT_FLAVOR "upstart" CACHE STRING "Init daemon of this system")
20
-    elseif(IS_DIRECTORY "/etc/init.d" AND EXISTS "/lib/lsb/init-functions")
21
-        message(STATUS "Detected init flavor: sysv-lsb")
22
-        set(INIT_FLAVOR "sysv-lsb" CACHE STRING "Init daemon of this system")
23
-    elseif(IS_DIRECTORY "/etc/init.d" AND EXISTS "/etc/init.d/functions")
43
+    elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "${SYSCONF_DIR}/init.d/functions")
24
         message(STATUS "Detected init flavor: sysv-redhat")
44
         message(STATUS "Detected init flavor: sysv-redhat")
25
         set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
45
         set(INIT_FLAVOR "sysv-redhat" CACHE STRING "Init daemon of this system")
46
+    elseif(IS_DIRECTORY "${SYSCONF_DIR}/init.d" AND EXISTS "/lib/lsb/init-functions")
47
+        message(STATUS "Detected init flavor: sysv-lsb")
48
+        set(INIT_FLAVOR "sysv-lsb" CACHE STRING "Init daemon of this system")
26
     else()
49
     else()
27
         message(STATUS "Detected init flavor: none")
50
         message(STATUS "Detected init flavor: none")
28
         message(STATUS "System startup files will not be installed")
51
         message(STATUS "System startup files will not be installed")
38
 string(REGEX REPLACE "^/+" "" APPARMOR_PROFILE "${APPARMOR_PROFILE}")
61
 string(REGEX REPLACE "^/+" "" APPARMOR_PROFILE "${APPARMOR_PROFILE}")
39
 string(REPLACE "/" "." APPARMOR_PROFILE "${APPARMOR_PROFILE}")
62
 string(REPLACE "/" "." APPARMOR_PROFILE "${APPARMOR_PROFILE}")
40
 
63
 
41
-configure_file(${PROJECT_NAME}.lsb_init.in ${PROJECT_NAME}.lsb_init @ONLY)
42
-configure_file(${PROJECT_NAME}.rh_init.in ${PROJECT_NAME}.rh_init @ONLY)
43
-configure_file(${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
44
-configure_file(${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
64
+configure_file(init/${PROJECT_NAME}.sysv-lsb.in ${PROJECT_NAME}.sysv-lsb @ONLY)
65
+configure_file(init/${PROJECT_NAME}.sysv-redhat.in ${PROJECT_NAME}.sysv-redhat @ONLY)
66
+configure_file(init/${PROJECT_NAME}.upstart.in ${PROJECT_NAME}.upstart @ONLY)
67
+configure_file(init/${PROJECT_NAME}.apparmor.in ${PROJECT_NAME}.apparmor @ONLY)
68
+configure_file(init/${PROJECT_NAME}.systemd.in ${PROJECT_NAME}.systemd @ONLY)
69
+configure_file(init/${PROJECT_NAME}.default.in ${PROJECT_NAME}.default @ONLY)
70
+
45
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
71
 configure_file(postinstall.cmake.in postinstall.cmake @ONLY)
46
 
72
 
47
 if(HELP2MAN)
73
 if(HELP2MAN)
53
 endif()
79
 endif()
54
 
80
 
55
 if(USE_APPARMOR)
81
 if(USE_APPARMOR)
56
-	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "/etc/apparmor.d" RENAME "${APPARMOR_PROFILE}")
82
+	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.apparmor DESTINATION "${SYSCONF_DIR}/apparmor.d" RENAME "${APPARMOR_PROFILE}")
57
 endif()
83
 endif()
58
 
84
 
59
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
85
 install(TARGETS ${PROJECT_NAME} DESTINATION "sbin")
60
-install(FILES README.md main.cf.ex DESTINATION "share/doc/${PROJECT_NAME}")
86
+install(FILES README.md main.cf.ex DESTINATION "${DOC_DIR}")
61
 install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")
87
 install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/postinstall.cmake")
62
 
88
 

+ 39
- 6
README.md View File

1
+PostSRSd
2
+========
3
+
1
 About
4
 About
2
-=====
5
+-----
6
+
3
 PostSRSd provides the Sender Rewriting Scheme (SRS) via TCP-based 
7
 PostSRSd provides the Sender Rewriting Scheme (SRS) via TCP-based 
4
 lookup tables for Postfix. SRS is needed if your mail server acts
8
 lookup tables for Postfix. SRS is needed if your mail server acts
5
 as forwarder. 
9
 as forwarder. 
6
 
10
 
11
+
12
+Sender Rewriting Scheme Crash Course
13
+------------------------------------
7
 Imagine your server receives a mail from alice@example.com
14
 Imagine your server receives a mail from alice@example.com
8
 that is to be forwarded. If example.com uses the Sender Policy Framework 
15
 that is to be forwarded. If example.com uses the Sender Policy Framework 
9
 to indicate that all legit mails originate from their server, your 
16
 to indicate that all legit mails originate from their server, your 
12
 your own domain, e.g. 
19
 your own domain, e.g. 
13
 SRS0+xxxx=yy=example.com=alice@yourdomain.org (forward SRS). If the
20
 SRS0+xxxx=yy=example.com=alice@yourdomain.org (forward SRS). If the
14
 mail is bounced later and a notification arrives, you can extract the
21
 mail is bounced later and a notification arrives, you can extract the
15
-original address from the rewritten one (revere SRS) and return the
22
+original address from the rewritten one (reverse SRS) and return the
16
 notification to the sender. You might notice that the reverse SRS can
23
 notification to the sender. You might notice that the reverse SRS can
17
 be abused to turn your server into an open relay. For this reason, xxxx
24
 be abused to turn your server into an open relay. For this reason, xxxx
18
 and yy are a cryptographic signature and a time stamp. If the signature
25
 and yy are a cryptographic signature and a time stamp. If the signature
19
 does not match, the address is forged and the mail can be discarded.
26
 does not match, the address is forged and the mail can be discarded.
20
 
27
 
21
 Building
28
 Building
22
-========
29
+--------
30
+
23
 PostSRSd requires a POSIX compatible system and CMake to build. 
31
 PostSRSd requires a POSIX compatible system and CMake to build. 
24
 Optionally, help2man is used to create a manual page.
32
 Optionally, help2man is used to create a manual page.
25
 
33
 
26
 For convenience, a Makefile fragment is provided which calls CMake with
34
 For convenience, a Makefile fragment is provided which calls CMake with
27
 the recommended command line options. Just run `make`.
35
 the recommended command line options. Just run `make`.
28
 
36
 
37
+Alternatively, you can control many aspects of the build manually:
38
+
39
+    mkdir build
40
+    cd build
41
+    cmake .. <options>
42
+    make
43
+    make install
44
+
45
+The CMake script defines a number of options in addition to the
46
+standard CMake flags. Use `-D<option>=<value>` to override the defaults.
47
+
48
+*   `GENERATE_SRS_SECRET` (default: `ON`). Generate a random secret on install.
49
+*   `USE_APPARMOR` (default: `OFF`): Install an AppArmor profile for the daemon.
50
+*   `INIT_FLAVOR` (default: auto-detect). Select the appriopriate startup 
51
+    script type. Must be one of (`upstart`,`sysv-lsb`,`sysv-redhat`) or `none`.
52
+*   `CHROOT_DIR` (default: `${CMAKE_INSTALL_PREFIX}/lib/postsrsd`). Chroot jail
53
+    for the daemon.
54
+*   `SYSCONF_DIR` (default: `/etc`). Location of system configuration files.
55
+*   `CONFIG_DIR` (default: `${SYSCONF_DIR}/default`). Install destination for
56
+    the postsrsd settings.
57
+*   `DOC_DIR` (default: `${CMAKE_INSTALL_PREFIX}/share/doc/postsrsd`). Install
58
+    destination for documentation files.
59
+
29
 Installing
60
 Installing
30
-==========
61
+----------
62
+
31
 Run `make install` as root to install the daemon and the configuration
63
 Run `make install` as root to install the daemon and the configuration
32
 files.
64
 files.
33
 
65
 
34
 Configuration
66
 Configuration
35
-=============
36
-The configuration is located in `/etc/default/postsrsd`. You must store
67
+-------------
68
+
69
+The configuration is located in `/etc/default/postsrsd` by default. You must store
37
 at least one secret key in `/etc/postsrsd.secret`. The installer tries to generate
70
 at least one secret key in `/etc/postsrsd.secret`. The installer tries to generate
38
 one from `/dev/urandom`. Be careful that no one can guess your secret,
71
 one from `/dev/urandom`. Be careful that no one can guess your secret,
39
 because anyone who knows it can use your mail server as open relay!
72
 because anyone who knows it can use your mail server as open relay!

postsrsd.apparmor.in → init/postsrsd.apparmor.in View File


postsrsd.default → init/postsrsd.default.in View File

1
 # Default settings for postsrsd
1
 # Default settings for postsrsd
2
 
2
 
3
-# Local domain name. 
4
-# Addresses are rewritten to originate from this domain. The default value 
3
+# Local domain name.
4
+# Addresses are rewritten to originate from this domain. The default value
5
 # is taken from `postconf -h mydomain` and probably okay.
5
 # is taken from `postconf -h mydomain` and probably okay.
6
 #
6
 #
7
 #SRS_DOMAIN=example.com
7
 #SRS_DOMAIN=example.com
17
 # When postsrsd is installed for the first time, a random secret is generated
17
 # When postsrsd is installed for the first time, a random secret is generated
18
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.
18
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.
19
 #
19
 #
20
-#SRS_SECRET=/etc/postsrsd.secret
20
+SRS_SECRET=@SYSCONF_DIR@/@PROJECT_NAME@.secret
21
 
21
 
22
 # Local ports for TCP list.
22
 # Local ports for TCP list.
23
 # These ports are used to bind the TCP list for postfix. If you change
23
 # These ports are used to bind the TCP list for postfix. If you change
25
 # are bound to the loopback interface, and should never be exposed on
25
 # are bound to the loopback interface, and should never be exposed on
26
 # the internet.
26
 # the internet.
27
 #
27
 #
28
-#SRS_FORWARD_PORT=10001
29
-#SRS_REVERSE_PORT=10002
28
+SRS_FORWARD_PORT=10001
29
+SRS_REVERSE_PORT=10002
30
 
30
 
31
-# Drop root privileges and run as another user after initialization. 
31
+# Drop root privileges and run as another user after initialization.
32
 # This is highly recommended as postsrsd handles untrusted input.
32
 # This is highly recommended as postsrsd handles untrusted input.
33
 #
33
 #
34
 RUN_AS=nobody
34
 RUN_AS=nobody
35
 
35
 
36
+# Jail daemon in chroot environment
37
+CHROOT=@CHROOT_DIR@
38
+

+ 15
- 0
init/postsrsd.systemd.in View File

1
+[Unit]
2
+Description=PostSRSd Daemon
3
+After=network.target
4
+
5
+[Service]
6
+Type=simple
7
+Environment SRS_DOMAIN=localhost.localdomain
8
+Environment SRS_EXCLUDE_DOMAINS=
9
+EnvironmentFile=@CONFIG_DIR@/@PROJECT_NAME@
10
+ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -f${SRS_FORWARD_PORT} -r${SRS_REVERSE_PORT} -d${SRS_DOMAIN} -s${SRS_SECRET} -u${RUN_AS} -c${CHROOT} -X${SRS_EXCLUDE_DOMAINS}
11
+Restart=always
12
+
13
+[Install]
14
+WantedBy=multi-user.target
15
+

postsrsd.lsb_init.in → init/postsrsd.sysv-lsb.in View File

20
 DESC="Postfix Sender Rewriting Scheme daemon"
20
 DESC="Postfix Sender Rewriting Scheme daemon"
21
 
21
 
22
 PIDFILE=/var/run/$NAME.pid
22
 PIDFILE=/var/run/$NAME.pid
23
-SCRIPTNAME=/etc/init.d/$NAME
23
+SCRIPTNAME=@SYSCONF_DIR@/init.d/$NAME
24
 
24
 
25
 # Gracefully exit if the package has been removed.
25
 # Gracefully exit if the package has been removed.
26
 test -x $DAEMON || exit 0
26
 test -x $DAEMON || exit 0
29
 
29
 
30
 # Default configuration
30
 # Default configuration
31
 SRS_DOMAIN=`postconf -h mydomain || true`
31
 SRS_DOMAIN=`postconf -h mydomain || true`
32
-SRS_FORWARD_PORT=10001
33
-SRS_REVERSE_PORT=10002
34
-SRS_SECRET=/etc/@PROJECT_NAME@.secret
35
-RUN_AS=nobody
36
-CHROOT=@CHROOT_DIR@
32
+SRS_EXCLUDE_DOMAINS=
37
 
33
 
38
-# Read config file if it is present.
39
-if [ -r @CONFIG_DIR@/$NAME ]
40
-then
41
-    . @CONFIG_DIR@/$NAME
42
-fi
34
+# Read config file
35
+. @CONFIG_DIR@/$NAME
43
 
36
 
44
 test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
37
 test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
45
 
38
 
51
 		--pidfile $PIDFILE \
44
 		--pidfile $PIDFILE \
52
 		--name $NAME \
45
 		--name $NAME \
53
 		--startas $DAEMON \
46
 		--startas $DAEMON \
54
-		-- -4 -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
47
+		-- -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
55
 	then
48
 	then
56
 	    log_end_msg 0
49
 	    log_end_msg 0
57
 	else
50
 	else
76
 	$0 start
69
 	$0 start
77
 	ret=$?
70
 	ret=$?
78
 	;;
71
 	;;
72
+  status)
73
+        log_daemon_msg "postsrsd is running"
74
+        if [ -s $PIDFILE ]; then
75
+            PID=`cat $PIDFILE`
76
+            if kill -0 "$PID" 2>/dev/null; then
77
+                log_end_msg 0
78
+            else
79
+                log_end_msg 1
80
+            fi
81
+        else
82
+            log_end_msg 1
83
+        fi
84
+        ;;
79
   *)
85
   *)
80
-	echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
86
+	echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
81
 	exit 1
87
 	exit 1
82
 	;;
88
 	;;
83
 esac
89
 esac

postsrsd.rh_init.in → init/postsrsd.sysv-redhat.in View File

16
 DESC="Postfix Sender Rewriting Scheme daemon"
16
 DESC="Postfix Sender Rewriting Scheme daemon"
17
 
17
 
18
 PIDFILE=/var/run/$NAME.pid
18
 PIDFILE=/var/run/$NAME.pid
19
-SCRIPTNAME=/etc/init.d/$NAME
19
+SCRIPTNAME=@SYSCONF_DIR@/init.d/$NAME
20
 
20
 
21
 # Gracefully exit if the package has been removed.
21
 # Gracefully exit if the package has been removed.
22
 test -x $DAEMON || exit 0
22
 test -x $DAEMON || exit 0
23
 
23
 
24
-. /etc/init.d/functions
24
+. @SYSCONF_DIR@/init.d/functions
25
 
25
 
26
 # Default configuration
26
 # Default configuration
27
 SRS_DOMAIN=`postconf -h mydomain || true`
27
 SRS_DOMAIN=`postconf -h mydomain || true`
28
-SRS_FORWARD_PORT=10001
29
-SRS_REVERSE_PORT=10002
30
-SRS_SECRET=/etc/@PROJECT_NAME@.secret
31
-RUN_AS=nobody
32
-CHROOT=@CHROOT_DIR@
28
+SRS_EXCLUDE_DOMAINS=
33
 
29
 
34
-# Read config file if it is present.
35
-if [ -r @CONFIG_DIR@/$NAME ]
36
-then
37
-    . @CONFIG_DIR@/$NAME
38
-fi
30
+# Read config file
31
+. @CONFIG_DIR@/$NAME
39
 
32
 
40
 test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
33
 test -r "$SRS_SECRET" -a -n "$SRS_DOMAIN" || exit 0
41
 
34
 
42
 do_start()
35
 do_start()
43
 {
36
 {
44
 	echo -n "Starting $DESC: "
37
 	echo -n "Starting $DESC: "
45
-	daemon $DAEMON -4 -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" \
38
+	daemon $DAEMON -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" \
46
 	               -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
39
 	               -u"$RUN_AS" -p"$PIDFILE" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS" -D
47
 	RETVAL=$?
40
 	RETVAL=$?
48
 	echo
41
 	echo

+ 14
- 0
init/postsrsd.upstart.in View File

1
+description "Postfix Sender Rewriting Scheme daemon"
2
+author "Timo Röhling <timo.roehling@gmx.de>"
3
+
4
+start on (filesystem and net-device-up)
5
+stop on runlevel [!2345]
6
+respawn
7
+
8
+script
9
+	SRS_DOMAIN=`postconf -h mydomain || true`
10
+	SRS_EXCLUDE_DOMAINS=
11
+	. "@CONFIG_DIR@/@PROJECT_NAME@"
12
+	exec @CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" -u"$RUN_AS" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS"
13
+end script
14
+

+ 1
- 2
makefile View File

6
 
6
 
7
 build/Makefile: CMakeLists.txt
7
 build/Makefile: CMakeLists.txt
8
 	mkdir -p build
8
 	mkdir -p build
9
-	cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
9
+	cd build && cmake .. -DCMAKE_BUILD_TYPE=Release $(addprefix -DINIT_FLAVOR=,$(INIT_FLAVOR)) -DCMAKE_C_FLAGS="$(CFLAGS)" $(addprefix -DCMAKE_C_COMPILER=,$(CC))
10
 
10
 
11
-	

+ 11
- 7
postinstall.cmake.in View File

1
 set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
1
 set(GENERATE_SRS_SECRET "@GENERATE_SRS_SECRET@")
2
+set(SYSCONF_DIR "@SYSCONF_DIR@")
2
 set(CHROOT_DIR "@CHROOT_DIR@")
3
 set(CHROOT_DIR "@CHROOT_DIR@")
3
 set(CONFIG_DIR "@CONFIG_DIR@")
4
 set(CONFIG_DIR "@CONFIG_DIR@")
4
 set(INIT_FLAVOR "@INIT_FLAVOR@")
5
 set(INIT_FLAVOR "@INIT_FLAVOR@")
14
 endif()
15
 endif()
15
 
16
 
16
 if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
17
 if(INIT_FLAVOR AND NOT EXISTS "$ENV{DESTDIR}${CONFIG_DIR}/@PROJECT_NAME@")
17
-	file(INSTALL FILES "@CMAKE_CURRENT_SOURCE_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@")
18
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.default" DESTINATION "${CONFIG_DIR}" RENAME "@PROJECT_NAME@")
18
 endif()
19
 endif()
19
 
20
 
20
 if(INIT_FLAVOR STREQUAL "sysv-lsb")
21
 if(INIT_FLAVOR STREQUAL "sysv-lsb")
21
-	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.lsb_init" TYPE PROGRAM DESTINATION "/etc/init.d" RENAME "@PROJECT_NAME@")
22
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.sysv-lsb" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
22
 	if(INSSERV)
23
 	if(INSSERV)
23
 		execute_process(
24
 		execute_process(
24
-			COMMAND ${INSSERV} -p "$ENV{DESTDIR}/etc/init.d" @PROJECT_NAME@
25
+			COMMAND ${INSSERV} -p "$ENV{DESTDIR}${SYSCONF_DIR}/init.d" @PROJECT_NAME@
25
 		)
26
 		)
26
 	endif()
27
 	endif()
27
 elseif(INIT_FLAVOR STREQUAL "sysv-redhat")
28
 elseif(INIT_FLAVOR STREQUAL "sysv-redhat")
28
-	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.rh_init" TYPE PROGRAM DESTINATION "/etc/init.d" RENAME "@PROJECT_NAME@")
29
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.sysv-redhat" TYPE PROGRAM DESTINATION "${SYSCONF_DIR}/init.d" RENAME "@PROJECT_NAME@")
29
 	if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
30
 	if(CHKCONFIG AND NOT "$ENV{DESTDIR}")
30
 		execute_process(
31
 		execute_process(
31
 			COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
32
 			COMMAND ${CHKCONFIG} --add @PROJECT_NAME@
32
 		)
33
 		)
33
 	endif()
34
 	endif()
34
 elseif(INIT_FLAVOR STREQUAL "upstart")
35
 elseif(INIT_FLAVOR STREQUAL "upstart")
35
-	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "/etc/init" RENAME "@PROJECT_NAME@.conf")
36
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.upstart" DESTINATION "${SYSCONF_DIR}/init" RENAME "@PROJECT_NAME@.conf")
37
+elseif(INIT_FLAVOR STREQUAL "systemd")
38
+	file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/@PROJECT_NAME@.systemd" DESTINATION "${SYSCONF_DIR}/systemd/system" RENAME "@PROJECT_NAME@.service")
36
 endif()
39
 endif()
37
 
40
 
38
-if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}/etc/${SECRET_FILE}")
41
+if(GENERATE_SRS_SECRET AND DD AND BASE64 AND EXISTS "/dev/urandom" AND NOT EXISTS "$ENV{DESTDIR}${SYSCONF_DIR}/${SECRET_FILE}")
39
 	message(STATUS "Generating secret key")
42
 	message(STATUS "Generating secret key")
40
 	execute_process(
43
 	execute_process(
41
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
44
 		COMMAND ${DD} if=/dev/urandom bs=18 count=1
44
 		ERROR_QUIET
47
 		ERROR_QUIET
45
 		OUTPUT_STRIP_TRAILING_WHITESPACE
48
 		OUTPUT_STRIP_TRAILING_WHITESPACE
46
 	)
49
 	)
47
-file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "/etc" RENAME "${SECRET_FILE}" FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
50
+file(INSTALL FILES "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}" DESTINATION "${SYSCONF_DIR}" RENAME "${SECRET_FILE}" PERMISSIONS OWNER_READ OWNER_WRITE)
48
 file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
51
 file(REMOVE "@CMAKE_CURRENT_BINARY_DIR@/${SECRET_FILE}")
49
 endif()
52
 endif()
53
+

+ 29
- 5
postsrsd.c View File

28
 #include <pwd.h>
28
 #include <pwd.h>
29
 #include <string.h>
29
 #include <string.h>
30
 #include <poll.h>
30
 #include <poll.h>
31
+#ifdef HAVE_SYS_TIME_H
32
+#include <sys/time.h>
33
+#endif
34
+#ifdef HAVE_TIME_H
35
+#include <time.h>
36
+#endif
37
+#ifdef HAVE_SYS_WAIT_H
38
+#include <sys/wait.h>
39
+#endif
40
+#ifdef HAVE_WAIT_H
31
 #include <wait.h>
41
 #include <wait.h>
42
+#endif
32
 #include <syslog.h>
43
 #include <syslog.h>
33
 
44
 
34
 #ifndef VERSION
45
 #ifndef VERSION
35
-#define VERSION "1.1"
46
+#define VERSION "1.2"
36
 #endif
47
 #endif
37
 
48
 
38
 static char *self = NULL;
49
 static char *self = NULL;
171
   fflush (fp);
182
   fflush (fp);
172
 }
183
 }
173
 
184
 
174
-static void handle_reverse (srs_t *srs, FILE *fp, const char *address, const char *domain, const char **excludes)
185
+static void handle_reverse (srs_t *srs, FILE *fp, const char *address, const char *domain __attribute__((unused)), const char **excludes __attribute__((unused)) )
175
 {
186
 {
176
   int result;
187
   int result;
177
   char value[1024];
188
   char value[1024];
180
   if (result == SRS_SUCCESS) {
191
   if (result == SRS_SUCCESS) {
181
     output = url_encode(outputbuf, sizeof(outputbuf), value);
192
     output = url_encode(outputbuf, sizeof(outputbuf), value);
182
     fprintf (fp, "200 %s\n", output);
193
     fprintf (fp, "200 %s\n", output);
183
-    syslog (LOG_MAIL | LOG_INFO, "srs_reverse: <%s> rewritten as <%s>", address, value); 
194
+    syslog (LOG_MAIL | LOG_INFO, "srs_reverse: <%s> rewritten as <%s>", address, value);
184
   } else {
195
   } else {
185
     fprintf (fp, "500 %s\n", srs_strerror(result));
196
     fprintf (fp, "500 %s\n", srs_strerror(result));
186
     if (result != SRS_ENOTREWRITTEN && result != SRS_ENOTSRSADDRESS)
197
     if (result != SRS_ENOTREWRITTEN && result != SRS_ENOTSRSADDRESS)
224
 
235
 
225
 int main (int argc, char **argv)
236
 int main (int argc, char **argv)
226
 {
237
 {
227
-  int opt, timeout = 1800, family = AF_UNSPEC;
238
+  int opt, timeout = 1800, family = AF_INET;
228
   int daemonize = FALSE;
239
   int daemonize = FALSE;
229
   char *forward_service = NULL, *reverse_service = NULL,
240
   char *forward_service = NULL, *reverse_service = NULL,
230
        *user = NULL, *domain = NULL, *chroot_dir = NULL;
241
        *user = NULL, *domain = NULL, *chroot_dir = NULL;
234
   struct passwd *pwd = NULL;
245
   struct passwd *pwd = NULL;
235
   char secretbuf[1024], *secret = NULL;
246
   char secretbuf[1024], *secret = NULL;
236
   char *tmp;
247
   char *tmp;
248
+  time_t now;
237
   srs_t *srs;
249
   srs_t *srs;
238
   struct pollfd fds[3];
250
   struct pollfd fds[3];
239
   const char **excludes;
251
   const char **excludes;
328
   }
340
   }
329
   /* Read secret. The default installation makes this root accessible only. */
341
   /* Read secret. The default installation makes this root accessible only. */
330
   if (secret_file != NULL) {
342
   if (secret_file != NULL) {
331
-    size_t len;
332
     sf = fopen(secret_file, "rb");
343
     sf = fopen(secret_file, "rb");
333
     if (sf == NULL) {
344
     if (sf == NULL) {
334
       fprintf (stderr, "%s: Cannot open file with secret: %s\n", self, secret_file);
345
       fprintf (stderr, "%s: Cannot open file with secret: %s\n", self, secret_file);
356
 
367
 
357
   /* Open syslog now (NDELAY), because it may no longer reachable from chroot */
368
   /* Open syslog now (NDELAY), because it may no longer reachable from chroot */
358
   openlog (self, LOG_PID | LOG_NDELAY, LOG_MAIL);
369
   openlog (self, LOG_PID | LOG_NDELAY, LOG_MAIL);
370
+  /* Force loading of timezone info (suggested by patrickdk77) */
371
+  now = time(NULL);
372
+  localtime (&now);
359
   /* We also have to lookup the uid of the unprivileged user for the same reason. */
373
   /* We also have to lookup the uid of the unprivileged user for the same reason. */
360
   if (user) {
374
   if (user) {
361
     errno = 0;
375
     errno = 0;
420
     char keybuf[1024], *key;
434
     char keybuf[1024], *key;
421
 
435
 
422
     if (poll(fds, 2, 1000) < 0) {
436
     if (poll(fds, 2, 1000) < 0) {
437
+      if (errno == EINTR)
438
+        continue;
423
       if (daemonize)
439
       if (daemonize)
424
         syslog (LOG_MAIL | LOG_ERR, "Poll failure: %s", strerror(errno));
440
         syslog (LOG_MAIL | LOG_ERR, "Poll failure: %s", strerror(errno));
425
       else
441
       else
431
         conn = accept(fds[i].fd, NULL, NULL);
447
         conn = accept(fds[i].fd, NULL, NULL);
432
         if (conn < 0) continue;
448
         if (conn < 0) continue;
433
         if (fork() == 0) {
449
         if (fork() == 0) {
450
+          // close listen sockets so that we don't stop the main daemon process from restarting
451
+          close(forward_sock);
452
+          close(reverse_sock);
453
+
434
           fp = fdopen(conn, "r+");
454
           fp = fdopen(conn, "r+");
435
           if (fp == NULL) exit(EXIT_FAILURE);
455
           if (fp == NULL) exit(EXIT_FAILURE);
436
           fds[2].fd = conn;
456
           fds[2].fd = conn;
438
           if (poll(&fds[2], 1, timeout * 1000) <= 0) return EXIT_FAILURE;
458
           if (poll(&fds[2], 1, timeout * 1000) <= 0) return EXIT_FAILURE;
439
           line = fgets(linebuf, sizeof(linebuf), fp);
459
           line = fgets(linebuf, sizeof(linebuf), fp);
440
           while (line) {
460
           while (line) {
461
+            fseek (fp, 0, SEEK_CUR); /* Workaround for Solaris */
441
             char* token;
462
             char* token;
442
             token = strtok(line, " \r\n");
463
             token = strtok(line, " \r\n");
443
             if (token == NULL || strcmp(token, "get") != 0) {
464
             if (token == NULL || strcmp(token, "get") != 0) {
444
               fprintf (fp, "500 Invalid request\n");
465
               fprintf (fp, "500 Invalid request\n");
466
+              fflush (fp);
445
               return EXIT_FAILURE;
467
               return EXIT_FAILURE;
446
             }
468
             }
447
             token = strtok(NULL, "\r\n");
469
             token = strtok(NULL, "\r\n");
448
             if (!token) {
470
             if (!token) {
449
               fprintf (fp, "500 Invalid request\n");
471
               fprintf (fp, "500 Invalid request\n");
472
+              fflush (fp);
450
               return EXIT_FAILURE;
473
               return EXIT_FAILURE;
451
             }
474
             }
452
             key = url_decode(keybuf, sizeof(keybuf), token);
475
             key = url_decode(keybuf, sizeof(keybuf), token);
453
             if (!key) break;
476
             if (!key) break;
454
             handler[i](srs, fp, key, domain, excludes);
477
             handler[i](srs, fp, key, domain, excludes);
478
+            fflush (fp);
455
             if (poll(&fds[2], 1, timeout * 1000) <= 0) break;
479
             if (poll(&fds[2], 1, timeout * 1000) <= 0) break;
456
             line = fgets(linebuf, sizeof(linebuf), fp);
480
             line = fgets(linebuf, sizeof(linebuf), fp);
457
           }
481
           }

+ 0
- 23
postsrsd.upstart.in View File

1
-description "Postfix Sender Rewriting Scheme daemon"
2
-author "Timo Röhling <timo.roehling@gmx.de>"
3
-
4
-start on (filesystem and net-device-up)
5
-stop on runlevel [!2345]
6
-respawn
7
-
8
-env DEFAULTFILE=@CONFIG_DIR@/@PROJECT_NAME@
9
-
10
-script
11
-	SRS_DOMAIN=`postconf -h mydomain || true`
12
-	SRS_FORWARD_PORT=10001
13
-	SRS_REVERSE_PORT=10002
14
-	SRS_SECRET=/etc/@PROJECT_NAME@.secret
15
-	SRS_EXCLUDE_DOMAINS=
16
-	RUN_AS=nobody
17
-	CHROOT=@CHROOT_DIR@
18
-	if [ -r "$DEFAULTFILE" ]; then
19
-		. "$DEFAULTFILE"
20
-	fi
21
-	exec @CMAKE_INSTALL_PREFIX@/sbin/@POSTSRSD@ -4 -f"$SRS_FORWARD_PORT" -r"$SRS_REVERSE_PORT" -d"$SRS_DOMAIN" -s"$SRS_SECRET" -u"$RUN_AS" -c"$CHROOT" -X"$SRS_EXCLUDE_DOMAINS"
22
-end script
23
-

+ 11
- 11
sha1.c View File

334
 */
334
 */
335
 
335
 
336
 static void
336
 static void
337
-sha_digest(char *out, char *data, int len)
337
+sha_digest(char *out, char *data, unsigned len)
338
 {
338
 {
339
 	SHA_INFO ctx;
339
 	SHA_INFO ctx;
340
 	sha_init(&ctx);
340
 	sha_init(&ctx);
341
-	sha_update(&ctx, data, len);
342
-	sha_final(out, &ctx);
341
+	sha_update(&ctx, (sha_byte*)data, len);
342
+	sha_final((sha_byte*)out, &ctx);
343
 }
343
 }
344
 
344
 
345
 void
345
 void
346
-srs_hmac_init(srs_hmac_ctx_t *ctx, char *secret, int len)
346
+srs_hmac_init(srs_hmac_ctx_t *ctx, char *secret, unsigned len)
347
 {
347
 {
348
 	char	 sbuf[SHA_BLOCKSIZE];
348
 	char	 sbuf[SHA_BLOCKSIZE];
349
-	int		 i;
349
+	unsigned		 i;
350
 
350
 
351
 	if (len > SHA_BLOCKSIZE) {
351
 	if (len > SHA_BLOCKSIZE) {
352
 		sha_digest(sbuf, secret, len);
352
 		sha_digest(sbuf, secret, len);
364
 	memset(sbuf, 0, SHA_BLOCKSIZE);
364
 	memset(sbuf, 0, SHA_BLOCKSIZE);
365
 
365
 
366
 	sha_init(&ctx->sctx);
366
 	sha_init(&ctx->sctx);
367
-	sha_update(&ctx->sctx, ctx->ipad, SHA_BLOCKSIZE);
367
+	sha_update(&ctx->sctx, (sha_byte*)ctx->ipad, SHA_BLOCKSIZE);
368
 }
368
 }
369
 
369
 
370
 void
370
 void
371
-srs_hmac_update(srs_hmac_ctx_t *ctx, char *data, int len)
371
+srs_hmac_update(srs_hmac_ctx_t *ctx, char *data, unsigned len)
372
 {
372
 {
373
-	sha_update(&ctx->sctx, data, len);
373
+	sha_update(&ctx->sctx, (sha_byte*)data, len);
374
 }
374
 }
375
 
375
 
376
 void
376
 void
377
 srs_hmac_fini(srs_hmac_ctx_t *ctx, char *out)
377
 srs_hmac_fini(srs_hmac_ctx_t *ctx, char *out)
378
 {
378
 {
379
-	char	 buf[SHA_DIGESTSIZE + 1];
379
+	sha_byte buf[SHA_DIGESTSIZE + 1];
380
 
380
 
381
 	sha_final(buf, &ctx->sctx);
381
 	sha_final(buf, &ctx->sctx);
382
 	sha_init(&ctx->sctx);
382
 	sha_init(&ctx->sctx);
383
-	sha_update(&ctx->sctx, ctx->opad, SHA_BLOCKSIZE);
383
+	sha_update(&ctx->sctx, (sha_byte*)ctx->opad, SHA_BLOCKSIZE);
384
 	sha_update(&ctx->sctx, buf, SHA_DIGESTSIZE);
384
 	sha_update(&ctx->sctx, buf, SHA_DIGESTSIZE);
385
-	sha_final(out, &ctx->sctx);
385
+	sha_final((sha_byte*)out, &ctx->sctx);
386
 }
386
 }

+ 10
- 10
srs2.c View File

55
 static srs_realloc_t	srs_f_realloc	= realloc;
55
 static srs_realloc_t	srs_f_realloc	= realloc;
56
 static srs_free_t		srs_f_free		= free;
56
 static srs_free_t		srs_f_free		= free;
57
 
57
 
58
-int		
58
+int
59
 srs_set_malloc(srs_malloc_t m, srs_realloc_t r, srs_free_t f)
59
 srs_set_malloc(srs_malloc_t m, srs_realloc_t r, srs_free_t f)
60
 {
60
 {
61
 	srs_f_malloc = m;
61
 	srs_f_malloc = m;
145
 	for (i = 0; i < srs->numsecrets; i++) {
145
 	for (i = 0; i < srs->numsecrets; i++) {
146
 		memset(srs->secrets[i], 0, strlen(srs->secrets[i]));
146
 		memset(srs->secrets[i], 0, strlen(srs->secrets[i]));
147
 		srs_f_free(srs->secrets[i]);
147
 		srs_f_free(srs->secrets[i]);
148
-		srs->secrets[i] = '\0';
148
+		srs->secrets[i] = 0;
149
 	}
149
 	}
150
 	srs_f_free(srs);
150
 	srs_f_free(srs);
151
 }
151
 }
212
 #define SRS_TIME_SLOTS		(1<<(SRS_TIME_BASEBITS<<(SRS_TIME_SIZE-1)))
212
 #define SRS_TIME_SLOTS		(1<<(SRS_TIME_BASEBITS<<(SRS_TIME_SIZE-1)))
213
 
213
 
214
 int
214
 int
215
-srs_timestamp_create(srs_t *srs, char *buf, time_t now)
215
+srs_timestamp_create(srs_t *srs __attribute__((unused)), char *buf, time_t now)
216
 {
216
 {
217
 	now = now / SRS_TIME_PRECISION;
217
 	now = now / SRS_TIME_PRECISION;
218
 	buf[1] = SRS_TIME_BASECHARS[now & ((1 << SRS_TIME_BASEBITS) - 1)];
218
 	buf[1] = SRS_TIME_BASECHARS[now & ((1 << SRS_TIME_BASEBITS) - 1)];
507
 }
507
 }
508
 
508
 
509
 int
509
 int
510
-srs_parse_shortcut(srs_t *srs, char *buf, int buflen, char *senduser)
510
+srs_parse_shortcut(srs_t *srs, char *buf, unsigned buflen, char *senduser)
511
 {
511
 {
512
 	char	*srshash;
512
 	char	*srshash;
513
 	char	*srsstamp;
513
 	char	*srsstamp;
538
 						srshost, srsuser);
538
 						srshost, srsuser);
539
 		if (ret != SRS_SUCCESS)
539
 		if (ret != SRS_SUCCESS)
540
 			return ret;
540
 			return ret;
541
-		sprintf(buf, "%s@%s", srsuser, srshost);
541
+		snprintf(buf, buflen, "%s@%s", srsuser, srshost);
542
 		return SRS_SUCCESS;
542
 		return SRS_SUCCESS;
543
 	}
543
 	}
544
 
544
 
577
 }
577
 }
578
 
578
 
579
 int
579
 int
580
-srs_forward(srs_t *srs, char *buf, int buflen,
580
+srs_forward(srs_t *srs, char *buf, unsigned buflen,
581
 				const char *sender, const char *alias)
581
 				const char *sender, const char *alias)
582
 {
582
 {
583
 	char	*senduser;
583
 	char	*senduser;
584
 	char	*sendhost;
584
 	char	*sendhost;
585
 	char	*tmp;
585
 	char	*tmp;
586
-	int		 len;
586
+	unsigned		 len;
587
 
587
 
588
 	if (srs->noforward)
588
 	if (srs->noforward)
589
 		return SRS_ENOTREWRITTEN;
589
 		return SRS_ENOTREWRITTEN;
619
 					sendhost, senduser, alias);
619
 					sendhost, senduser, alias);
620
 }
620
 }
621
 
621
 
622
-int		
622
+int
623
 srs_forward_alloc(srs_t *srs, char **sptr,
623
 srs_forward_alloc(srs_t *srs, char **sptr,
624
 				const char *sender, const char *alias)
624
 				const char *sender, const char *alias)
625
 {
625
 {
650
 }
650
 }
651
 
651
 
652
 int
652
 int
653
-srs_reverse(srs_t *srs, char *buf, int buflen, const char *sender)
653
+srs_reverse(srs_t *srs, char *buf, unsigned buflen, const char *sender)
654
 {
654
 {
655
 	char	*senduser;
655
 	char	*senduser;
656
 	char	*tmp;
656
 	char	*tmp;
657
-	int		 len;
657
+	unsigned		 len;
658
 
658
 
659
 	if (!SRS_IS_SRS_ADDRESS(sender))
659
 	if (!SRS_IS_SRS_ADDRESS(sender))
660
 		return SRS_ENOTSRSADDRESS;
660
 		return SRS_ENOTSRSADDRESS;

+ 8
- 4
srs2.h View File

20
 #include <stdio.h>
20
 #include <stdio.h>
21
 #include <stdlib.h>
21
 #include <stdlib.h>
22
 #include <ctype.h>
22
 #include <ctype.h>
23
+#ifdef __APPLE__
24
+    #include <sys/types.h>
25
+#endif
26
+
23
 
27
 
24
 #ifndef __BEGIN_DECLS
28
 #ifndef __BEGIN_DECLS
25
 #define __BEGIN_DECLS
29
 #define __BEGIN_DECLS
118
 srs_t	*srs_new();
122
 srs_t	*srs_new();
119
 void	 srs_init(srs_t *srs);
123
 void	 srs_init(srs_t *srs);
120
 void	 srs_free(srs_t *srs);
124
 void	 srs_free(srs_t *srs);
121
-int		 srs_forward(srs_t *srs, char *buf, int buflen,
125
+int		 srs_forward(srs_t *srs, char *buf, unsigned buflen,
122
 				const char *sender, const char *alias);
126
 				const char *sender, const char *alias);
123
 int		 srs_forward_alloc(srs_t *srs, char **sptr,
127
 int		 srs_forward_alloc(srs_t *srs, char **sptr,
124
 				const char *sender, const char *alias);
128
 				const char *sender, const char *alias);
125
-int		 srs_reverse(srs_t *srs, char *buf, int buflen,
129
+int		 srs_reverse(srs_t *srs, char *buf, unsigned buflen,
126
 				const char *sender);
130
 				const char *sender);
127
 int		 srs_reverse_alloc(srs_t *srs, char **sptr, const char *sender);
131
 int		 srs_reverse_alloc(srs_t *srs, char **sptr, const char *sender);
128
 const char *
132
 const char *
168
 	char		opad[SHA_BLOCKSIZE + 1];
172
 	char		opad[SHA_BLOCKSIZE + 1];
169
 } srs_hmac_ctx_t;
173
 } srs_hmac_ctx_t;
170
 
174
 
171
-void	 srs_hmac_init(srs_hmac_ctx_t *ctx, char *secret, int len);
172
-void	 srs_hmac_update(srs_hmac_ctx_t *ctx, char *data, int len);
175
+void	 srs_hmac_init(srs_hmac_ctx_t *ctx, char *secret, unsigned len);
176
+void	 srs_hmac_update(srs_hmac_ctx_t *ctx, char *data, unsigned len);
173
 void	 srs_hmac_fini(srs_hmac_ctx_t *ctx, char *out);
177
 void	 srs_hmac_fini(srs_hmac_ctx_t *ctx, char *out);
174
 
178
 
175
 
179
 

Loading…
Cancel
Save