From ino-qc@spotteswoode.de.eu.org  Sun May  7 14:23:30 2006
Return-Path: <ino-qc@spotteswoode.de.eu.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CDE1916A438
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  7 May 2006 14:23:30 +0000 (UTC)
	(envelope-from ino-qc@spotteswoode.de.eu.org)
Received: from mail-out01.broadnet-mediascape.de (mail-out01.broadnet-mediascape.de [62.206.1.18])
	by mx1.FreeBSD.org (Postfix) with SMTP id 48F8943D69
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  7 May 2006 14:23:23 +0000 (GMT)
	(envelope-from ino-qc@spotteswoode.de.eu.org)
Received: (qmail 19634 invoked by uid 113); 7 May 2006 14:23:21 -0000
Received: from 212.99.206.141 by mail-out01 (envelope-from <ino-qc@spotteswoode.de.eu.org>, uid 106) with qmail-scanner-1.25 
 (trophie: 7.510-1002/409/116544.  
 Clear:RC:1(212.99.206.141):. 
 Processed in 0.216815 secs); 07 May 2006 14:23:21 -0000
Received: from d463ce8d.datahighways.de (HELO spotteswoode.dnsalias.org) (212.99.206.141)
  by mail-out01.broadnet-mediascape.de with SMTP; 7 May 2006 14:23:20 -0000
Received: by spotteswoode.dnsalias.org (Postfix, from userid 0)
	id F2D0C11F29; Sun,  7 May 2006 16:23:16 +0200 (CEST)
Message-Id: <20060507142316.GA558@spotteswoode.de.eu.org>
Date: Sun, 7 May 2006 16:23:16 +0200
From: clemens fischer <ino-qc@spotteswoode.de.eu.org>
Reply-To: clemens fischer <ino-qc@spotteswoode.dnsalias.org>
To: FreeBSD-gnats-submit@freebsd.org
Subject: sysutils/fcron:  fcrondyn completely broken
X-Send-Pr-Version: 3.113

>Number:         96918
>Category:       ports
>Synopsis:       sysutils/fcron:  fcrondyn completely broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 07 14:30:22 GMT 2006
>Closed-Date:    Sun May 14 18:31:12 GMT 2006
>Last-Modified:  Sun May 14 18:31:12 GMT 2006
>Originator:     clemens fischer <ino-qc@spotteswoode.dnsalias.org>
>Release:        FreeBSD 6.1-RC i386
>Organization:
<organization of PR author (multiple lines)>
>Environment:
System: FreeBSD spotteswoode.dnsalias.org 6.1-RC FreeBSD 6.1-RC #5: Mon May 1 22:23:07 CEST 2006 root@spotteswoode.dnsalias.org:/usr/obj/usr/src/sys/spott i386

>Description:

  ports/sysutils/fcron comes with a utility called "fcrondyn", which
  allows display and modification of internal tables such as scheduled
  run times of any pending jobs.

  for this to work securely, the fcron system of programs runs privilege
  separated communicating over unix domain sockets.  fcrondyn cannot
  connect to "var/run/fcron.fifo".  the error message is always the
  same:

  1  # fcrondyn -c /l/etc/fcron.conf -d
  14:22:10   fcronconf=/l/etc/fcron.conf
  14:22:10 Cannot connect() to fcron (check if fcron is running): No
           such file or directory

  i've investigated as far as i could, but could not find anything
  relevant. the error message comes from

  int connect_fcron(void) in file ./fcrondyn.c, which is simple enough.
  the point of error is in the middle of the 20 line function:

    ...
    if ( connect(fd, (struct sockaddr *) &addr, sizeof(addr.sun_family) + len) < 0 )
        die_e("Cannot connect() to fcron %s", fifofile );
    ...

  i put in the "%s, fifofile" part to see where fcrondyn is looking for
  the socket, but the output points correctly to:
  
  srw-rw-rw-  1 root wheel     0B May  7 14:55 /var/run/fcron.fifo

  since fcron itself is running and listening:
  0  # lsof -a -U -c /fcron/
  COMMAND  PID USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
  fcron   2381 root    4u  unix 0xc2be22c8      0t0      ->0xc282142c
  fcron   2381 root    5u  unix 0xc2934590      0t0      /var/run/fcron.fifo

  i don't know what to do next.  a gdb(1) session around this point
  gives:

  (gdb) p addr.sun_path
  $11 = "/var/run/fcron.fifo", '\0' <repeats 84 times>, "0"
  (gdb) s
  412         if ( connect(fd, (struct sockaddr *) &addr, sizeof(addr.sun_family) + len) < 0 )
  (gdb) info locals
  fd = 7
  addr = {sun_len = 32 ' ', sun_family = 1 '\001',
    sun_path = "/var/run/fcron.fifo", '\0' <repeats 84 times>}
  len = 19
  (gdb) s
  413             die_e("Cannot connect() to fcron %s", fifofile );
  (gdb) info locals
  fd = 7
  addr = {sun_len = 32 ' ', sun_family = 1 '\001',
    sun_path = "/var/run/fcron.fifo", '\0' <repeats 84 times>}
  len = 19
  (gdb)

  doesn't this look correct?

>How-To-Repeat:

  after installing fcron, just try "fcrondyn" from any user account.

>Fix:

  none known so far.

  clemens fischer
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sun May 7 14:32:11 UTC 2006 
State-Changed-Why:  
Awaiting maintainers feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96918 

From: Brad Huntting <huntting@glarp.com>
To: bug-followup@FreeBSD.org
Cc: huntting@glarp.com
Subject: Re: ports/96918: sysutils/fcron: fcrondyn completely broken 
Date: Sun, 07 May 2006 11:53:01 -0600

 A quick ktrace sugests (struct sockaddr_un).sun_len isnt getting
 set correctly.
 
   ...
   2078 fcrondyn CALL  connect(0x3,0xbfbfe110,0x14)
   2078 fcrondyn NAMI  "/var/run/fcron.fif"
   2078 fcrondyn RET   connect -1 errno 2 No such file or directory
   ...
 
 I have a final to study for right now, but I should have this fixed
 by weeks end.
 
 
 thanx,
 brad

From: Brad Huntting <huntting@glarp.com>
To: Edwin Groothuis <edwin@FreeBSD.org>
Cc: huntting@glarp.com
Subject: Re: ports/96918: sysutils/fcron: fcrondyn completely broken 
Date: Mon, 08 May 2006 09:34:51 -0600

 Please let me know how the attached patch works.
 
 	cd /tmp;
 	cp -r /usr/ports/sysutils/fcron .
 	patch </tmp/attached_patch
 
 If you dont see any other problems, I'll submit it to the ports-meister.
 
 
 thanx,
 brad
 
 ----------- cut here -------------
 diff -Nru /usr/ports/sysutils/fcron/Makefile fcron/Makefile
 --- /usr/ports/sysutils/fcron/Makefile	Fri Feb 10 02:51:04 2006
 +++ fcron/Makefile	Sun May  7 19:10:30 2006
 @@ -8,6 +8,7 @@
  
  PORTNAME=	fcron
  PORTVERSION=	3.0.1
 +PORTREVISION=	1
  CATEGORIES=	sysutils
  MASTER_SITES=	${MASTER_SITE_SUNSITE} \
  		http://fcron.free.fr/archives/ \
 @@ -34,6 +35,8 @@
  MAN5=		fcron.conf.5 fcrontab.5
  MAN8=		fcron.8
  
 +PAM_DIR?=	/etc/pam.d
 +
  PORTDOCS=	*
  
  .if defined(MANLANG) && exists(${WRKSRC}/doc/${MANLANG})
 @@ -55,6 +58,8 @@
  .endfor
  	${MKDIR} ${EXAMPLESDIR}
  	${INSTALL_DATA} ${FILESDIR}/fcrontab-* ${WRKSRC}/files/*.pam ${EXAMPLESDIR}
 +	[ -f ${PAM_DIR}/fcron ] || ${INSTALL_DATA} ${WRKSRC}/files/fcron.pam ${PAM_DIR}/fcron
 +	[ -f ${PAM_DIR}/fcrontab ] || ${INSTALL_DATA} ${WRKSRC}/files/fcrontab.pam ${PAM_DIR}/fcrontab
  .for n in 1 5 8
  	${INSTALL_MAN} ${MAN${n}:S|^|${DOCSRC}/man/|} ${PREFIX}/man/man${n}
  .endfor
 diff -Nru /usr/ports/sysutils/fcron/files/patch-fcrondyn.c fcron/files/patch-fcrondyn.c
 --- /usr/ports/sysutils/fcron/files/patch-fcrondyn.c	Wed Dec 31 17:00:00 1969
 +++ fcron/files/patch-fcrondyn.c	Sun May  7 19:05:18 2006
 @@ -0,0 +1,40 @@
 +--- fcrondyn.c.orig	Mon Feb  6 14:44:52 2006
 ++++ fcrondyn.c	Sun May  7 19:04:07 2006
 +@@ -35,6 +35,10 @@
 + #include "allow.h"
 + #include "read_string.h"
 + 
 ++#if (defined(__unix__) || defined(unix)) && !defined(USG)
 ++#include <sys/param.h>
 ++#endif
 ++
 + char rcs_info[] = "$Id: fcrondyn.c,v 1.14 2006/01/11 00:48:33 thib Exp thib $";
 + 
 + void info(void);
 +@@ -399,17 +403,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 (defined(BSD) && (BSD >= 199103)) /* 4.3BSD Net2 */
 ++    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 -Nru /usr/ports/sysutils/fcron/files/pkg-message.in fcron/files/pkg-message.in
 --- /usr/ports/sysutils/fcron/files/pkg-message.in	Fri Feb 10 02:51:04 2006
 +++ fcron/files/pkg-message.in	Mon May  8 09:24:35 2006
 @@ -5,12 +5,6 @@
  	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 -Nru /usr/ports/sysutils/fcron/pkg-plist fcron/pkg-plist
 --- /usr/ports/sysutils/fcron/pkg-plist	Fri Feb 10 02:51:04 2006
 +++ fcron/pkg-plist	Sun May  7 11:04:50 2006
 @@ -5,8 +5,8 @@
  etc/fcron.conf.dist
  etc/fcron.deny.dist
  sbin/fcron
 -%%EXAMPLESDIR%%/fcron.pam
 +%%PAMDIR%%/fcron
 +%%PAMDIR%%/fcrontab
  %%EXAMPLESDIR%%/fcrontab-operator
  %%EXAMPLESDIR%%/fcrontab-root
 -%%EXAMPLESDIR%%/fcrontab.pam
  @dirrm %%EXAMPLESDIR%%
 
State-Changed-From-To: feedback->closed 
State-Changed-By: itetcu 
State-Changed-When: Sun May 14 18:31:11 UTC 2006 
State-Changed-Why:  
Superceded by ports/97066 

http://www.freebsd.org/cgi/query-pr.cgi?pr=96918 
>Unformatted:
