From c616f818655de93ca1967279eadea3f48d758248 Mon Sep 17 00:00:00 2001 From: Sergey Matveychuk Date: Sun, 4 Jun 2006 20:09:42 +0000 Subject: - Install pam files directly (in /etc/pam.d, unless they already exist) rather than just leaving them in the examples directory. There seems to be no real security advantage to not installing the pam files since they are required for fcron and fcrontab to operate, and root privs are required to install fcron to begin with. - The sockaddr.sa_len was not set prior to calls to bind() and connect(). The upshot begin that fcrondyn was unable to open the socket to communicate with fcron. PR: ports/97066 Submitted by: maintainer --- sysutils/fcron/Makefile | 8 ++++++++ sysutils/fcron/files/patch-config.h.in | 8 ++++++++ sysutils/fcron/files/patch-configure.in | 20 +++++++++++++++++++ sysutils/fcron/files/patch-fcrondyn.c | 29 ++++++++++++++++++++++++++++ sysutils/fcron/files/patch-socket.c | 34 +++++++++++++++++++++++++++++++++ sysutils/fcron/files/pkg-message.in | 6 ------ sysutils/fcron/pkg-plist | 6 +++++- 7 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 sysutils/fcron/files/patch-config.h.in create mode 100644 sysutils/fcron/files/patch-configure.in create mode 100644 sysutils/fcron/files/patch-fcrondyn.c create mode 100644 sysutils/fcron/files/patch-socket.c (limited to 'sysutils/fcron') diff --git a/sysutils/fcron/Makefile b/sysutils/fcron/Makefile index d96cff2a39de..df752be727df 100644 --- a/sysutils/fcron/Makefile +++ b/sysutils/fcron/Makefile @@ -8,6 +8,7 @@ PORTNAME= fcron PORTVERSION= 3.0.1 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= ${MASTER_SITE_SUNSITE} \ http://fcron.free.fr/archives/ \ @@ -20,6 +21,7 @@ COMMENT= A periodic command scheduler GNU_CONFIGURE= yes USE_GMAKE= yes +USE_AUTOTOOLS= autoconf:259 USE_PERL5_BUILD=yes CONFIGURE_ARGS= --with-etcdir=${PREFIX}/etc --with-cflags="${CFLAGS}" \ --with-rootname=root --with-rootgroup=wheel \ @@ -34,6 +36,9 @@ MAN1= fcrontab.1 MAN5= fcron.conf.5 fcrontab.5 MAN8= fcron.8 +PAMDIR?= /etc/pam.d +PLIST_SUB+= PAMDIR=${PAMDIR} + PORTDOCS= * .if defined(MANLANG) && exists(${WRKSRC}/doc/${MANLANG}) @@ -55,6 +60,9 @@ do-install: .endfor ${MKDIR} ${EXAMPLESDIR} ${INSTALL_DATA} ${FILESDIR}/fcrontab-* ${WRKSRC}/files/*.pam ${EXAMPLESDIR} + ${MKDIR} ${PAMDIR} + [ -f ${PAMDIR}/fcron ] || ${INSTALL_DATA} ${WRKSRC}/files/fcron.pam ${PAMDIR}/fcron + [ -f ${PAMDIR}/fcrontab ] || ${INSTALL_DATA} ${WRKSRC}/files/fcrontab.pam ${PAMDIR}/fcrontab .for n in 1 5 8 ${INSTALL_MAN} ${MAN${n}:S|^|${DOCSRC}/man/|} ${PREFIX}/man/man${n} .endfor diff --git a/sysutils/fcron/files/patch-config.h.in b/sysutils/fcron/files/patch-config.h.in new file mode 100644 index 000000000000..1a396012d854 --- /dev/null +++ b/sysutils/fcron/files/patch-config.h.in @@ -0,0 +1,8 @@ +--- config.h.in.orig Mon Feb 6 14:44:52 2006 ++++ config.h.in Tue May 9 17:15:19 2006 +@@ -424,3 +424,5 @@ + #define O_SYNC O_FSYNC + #endif + ++/* Define if (struct sockaddr) has an sa_len field. */ ++#undef HAVE_SA_LEN diff --git a/sysutils/fcron/files/patch-configure.in b/sysutils/fcron/files/patch-configure.in new file mode 100644 index 000000000000..63378ef5f5cf --- /dev/null +++ b/sysutils/fcron/files/patch-configure.in @@ -0,0 +1,20 @@ +--- configure.in.orig Mon Jan 9 17:21:24 2006 ++++ configure.in Tue May 9 17:04:30 2006 +@@ -57,6 +57,17 @@ + AC_STRUCT_TM + AC_TYPE_UID_T + ++dnl Check for post-Reno style struct sockaddr ++AC_CACHE_CHECK([for sa_len], ++ ac_cv_sa_len, ++[AC_TRY_COMPILE([#include ++#include ], [int main(void) { ++ struct sockaddr t;t.sa_len = 0;}], ++ ac_cv_sa_len=yes,ac_cv_sa_len=no)]) ++if test $ac_cv_sa_len = yes; then ++ AC_DEFINE(HAVE_SA_LEN) ++fi ++ + dnl Checks for library functions. + AC_PROG_GCC_TRADITIONAL + AC_FUNC_MEMCMP diff --git a/sysutils/fcron/files/patch-fcrondyn.c b/sysutils/fcron/files/patch-fcrondyn.c new file mode 100644 index 000000000000..b6d374d74c78 --- /dev/null +++ b/sysutils/fcron/files/patch-fcrondyn.c @@ -0,0 +1,29 @@ +--- fcrondyn.c.orig Mon Feb 6 14:44:52 2006 ++++ fcrondyn.c Tue May 9 15:24:22 2006 +@@ -399,17 +399,21 @@ + int fd = -1; + struct sockaddr_un addr; + int len = 0; ++ int sa_len; + + if ( (fd = socket(PF_UNIX, SOCK_STREAM, 0)) == -1 ) + die_e("could not create socket"); + + addr.sun_family = AF_UNIX; +- if ( (len = strlen(fifofile)) > sizeof(addr.sun_path) ) +- die("Error : fifo file path too long (max is %d)", sizeof(addr.sun_path)); +- strncpy(addr.sun_path, fifofile, sizeof(addr.sun_path) - 1); +- addr.sun_path[sizeof(addr.sun_path)-1] = '\0'; ++ if ( (len = strlen(fifofile)) > sizeof(addr.sun_path) - 1 ) ++ die("Error : fifo file path too long (max is %d)", sizeof(addr.sun_path) - 1); ++ strncpy(addr.sun_path, fifofile, sizeof(addr.sun_path)); ++ sa_len = (addr.sun_path - (char *)&addr) + len; ++#if HAVE_SA_LEN ++ addr.sun_len = sa_len; ++#endif + +- if ( connect(fd, (struct sockaddr *) &addr, sizeof(addr.sun_family) + len) < 0 ) ++ if ( connect(fd, (struct sockaddr *) &addr, sa_len) < 0 ) + die_e("Cannot connect() to fcron (check if fcron is running)"); + + if ( authenticate_user(fd) == ERR ) { diff --git a/sysutils/fcron/files/patch-socket.c b/sysutils/fcron/files/patch-socket.c new file mode 100644 index 000000000000..8dabb2aa077b --- /dev/null +++ b/sysutils/fcron/files/patch-socket.c @@ -0,0 +1,34 @@ +--- socket.c.orig Mon Feb 6 14:44:52 2006 ++++ socket.c Tue May 9 16:33:19 2006 +@@ -134,6 +134,7 @@ + { + struct sockaddr_un addr; + int len = 0; ++ int sa_len; + + /* used in fcron.c:main_loop():select() */ + FD_ZERO(&read_set); +@@ -145,15 +146,19 @@ + } + + addr.sun_family = AF_UNIX; +- if ( (len = strlen(fifofile)) > sizeof(addr.sun_path) ) { +- error("Error : fifo file path too long (max is %d)", sizeof(addr.sun_path)); ++ if ( (len = strlen(fifofile)) > sizeof(addr.sun_path) - 1) { ++ error("Error : fifo file path too long (max is %d)", sizeof(addr.sun_path) - 1); + goto err; + } +- strncpy(addr.sun_path, fifofile, sizeof(addr.sun_path) - 1); ++ strncpy(addr.sun_path, fifofile, sizeof(addr.sun_path)); + addr.sun_path[sizeof(addr.sun_path) -1 ] = '\0'; ++ sa_len = (addr.sun_path - (char *)&addr) + len; ++#if HAVE_SA_LEN ++ addr.sun_len = sa_len; ++#endif + + unlink(fifofile); +- if (bind(listen_fd, (struct sockaddr*) &addr, sizeof(addr.sun_family)+len+1) != 0){ ++ if (bind(listen_fd, (struct sockaddr*) &addr, sa_len) != 0){ + error_e("Cannot bind socket to '%s'", fifofile); + goto err; + } diff --git a/sysutils/fcron/files/pkg-message.in b/sysutils/fcron/files/pkg-message.in index f3409e1be538..04257be00f2b 100644 --- a/sysutils/fcron/files/pkg-message.in +++ b/sysutils/fcron/files/pkg-message.in @@ -5,12 +5,6 @@ to your /etc/rc.conf: fcron_enable="YES" cron_enable="NO" -install the pam config files - - mkdir -p %%PREFIX%%/etc/pam.d - cp %%EXAMPLESDIR%%/fcron.pam %%PREFIX%%/etc/pam.d/fcron - cp %%EXAMPLESDIR%%/fcrontab.pam %%PREFIX%%/etc/pam.d/fcrontab - and move any jobs in /etc/crontab to the root fcrontab(5) file. See: %%EXAMPLESDIR%% diff --git a/sysutils/fcron/pkg-plist b/sysutils/fcron/pkg-plist index 2fccda00cef4..61a28fe049cb 100644 --- a/sysutils/fcron/pkg-plist +++ b/sysutils/fcron/pkg-plist @@ -5,8 +5,12 @@ etc/fcron.allow.dist etc/fcron.conf.dist etc/fcron.deny.dist sbin/fcron -%%EXAMPLESDIR%%/fcron.pam %%EXAMPLESDIR%%/fcrontab-operator %%EXAMPLESDIR%%/fcrontab-root +%%EXAMPLESDIR%%/fcron.pam %%EXAMPLESDIR%%/fcrontab.pam @dirrm %%EXAMPLESDIR%% +@cwd / +%%PAMDIR%%/fcron +%%PAMDIR%%/fcrontab +@dirrmtry %%PAMDIR%% -- cgit v1.2.3