Date: Sat, 5 Feb 2005 09:55:30 GMT From: Thomas Melzer <tmelzer@tomesoft.de> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/77127: update port: dns/dhid upate to version 5.2 Message-ID: <200502050955.j159tUrK076437@www.freebsd.org> Resent-Message-ID: <200502051000.j15A0fnJ052490@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 77127 >Category: ports >Synopsis: update port: dns/dhid upate to version 5.2 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sat Feb 05 10:00:40 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Thomas Melzer >Release: FreeBSD 5.3-RELEASE-p5 i386 >Organization: Thomas Melzer Softwareentwicklung >Environment: FreeBSD terra.ddns.tomesoft.de 5.3-RELEASE-p5 FreeBSD 5.3-RELEASE-p5 #0: Thu Jan 27 20:31:57 CET 2005 root@terra.ddns.tomesoft.de:/usr/obj/usr/src/sys/GENERIC i386 >Description: update DHIS client daemon to 5.2, which is the up to date version of this software. change startup script, so that client is running with non-priviledged user account replace unsafe memory/string copy functions with safe ones (related to buffer size) >How-To-Repeat: >Fix: diff -Nur dhid.old/Makefile dhid/Makefile --- dhid.old/Makefile Fri Sep 5 06:54:32 2003 +++ dhid/Makefile Thu Feb 3 10:34:37 2005 @@ -6,34 +6,74 @@ # PORTNAME= dhid -PORTVERSION= 4.0.2 +PORTVERSION= 5.2 CATEGORIES= dns MASTER_SITES= ftp://ftp.dhis.org/pub/dhis/ -DISTFILES= ${DISTNAME}${EXTRACT_SUFX} \ - ${PORTNAME}-3.1${EXTRACT_SUFX} MAINTAINER= oryx@ungulate.net COMMENT= DHIS client for updating dynamic DNS entries in dhisd DNS tables +LIB_DEPENDS= gmp.6:${PORTSDIR}/math/libgmp4 + +LDFLAGS+= -L${PREFIX}/lib +MAKE_ENV+= LDFLAGS="${LDFLAGS}" + +DOCFILES= AUTHORS CONTRIBUTORS COPYRIGHT INSTALL README WHATSNEW USE_REINPLACE= yes -OLDWRKSRC= ${WRKDIR}/${PORTNAME}-3.1 -MAN8= dhid.8 +DHID_USER=dhis +DHID_GROUP=dhis +DHID_PID_DIR=/var/run/dhis post-patch: - @${ECHO} "===> Patching dhid.h" + @${ECHO} "===> Patching dhid.h and Makefile" ${REINPLACE_CMD} -e "s^__PREFIX__^${PREFIX}^g" ${WRKSRC}/dhid.h + ${REINPLACE_CMD} -e "s^__PREFIX__^${PREFIX}^g" ${WRKSRC}/Makefile +pre-install: + @${SETENV} PKG_PREFIX=${PREFIX} \ + ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL do-install: - ${INSTALL_PROGRAM} ${WRKSRC}/dhid ${PREFIX}/sbin - ${INSTALL_MAN} ${OLDWRKSRC}/dhid.8 ${PREFIX}/man/man8 - ${INSTALL} ${COPY} -o root -g wheel -m 600 ${OLDWRKSRC}/dhid.conf ${PREFIX}/etc/dhid.conf.sample post-install: - @if [ ! -f ${PREFIX}/etc/rc.d/dhid.sh ]; then \ - ${ECHO} "===> Installing ${PREFIX}/etc/rc.d/dhid.sh startup file."; \ - ${INSTALL_SCRIPT} -m 751 ${FILESDIR}/dhid.sh ${PREFIX}/etc/rc.d/dhid.sh; \ - fi; + @${SETENV} ${SCRIPTS_ENV} PKG_PREFIX="${PREFIX}" \ + ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL + @${ECHO_MSG} "===> Installing ${PREFIX}/sbin/dhid." + @${INSTALL_PROGRAM} ${WRKSRC}/dhid ${PREFIX}/sbin + @${ECHO_CMD} "sbin/dhid" >> ${TMPPLIST} + @${ECHO_MSG} "===> Installing ${PREFIX}/bin/genkeys." + @${INSTALL_PROGRAM} ${WRKSRC}/genkeys ${PREFIX}/bin + @${ECHO_CMD} "bin/genkeys" >> ${TMPPLIST} + @${ECHO_MSG} "===> Installing ${PREFIX}/etc/dhid.conf.sample." + @${INSTALL_DATA} ${WRKSRC}/dhid.conf.sample ${PREFIX}/etc/dhid.conf.sample + @${CHOWN} ${DHID_USER}:${DHID_GROUP} ${PREFIX}/etc/dhid.conf.sample + @${CHMOD} 0600 ${PREFIX}/etc/dhid.conf.sample + @${ECHO_CMD} "etc/dhid.conf.sample" >> ${TMPPLIST} + @${ECHO_CMD} "@exec ${CHOWN} ${DHID_USER}:${DHID_GROUP} %D/etc/dhid.conf.sample" >> ${TMPPLIST} + @${ECHO_CMD} "@exec ${CHMOD} 0600 %D/etc/dhid.conf.sample" >> ${TMPPLIST} + @${MKDIR} ${DHID_PID_DIR} + @${CHOWN} ${DHID_USER}:${DHID_GROUP} ${DHID_PID_DIR} + @${CHMOD} 0700 ${DHID_PID_DIR} + @${ECHO_CMD} "@exec ${MKDIR} ${DHID_PID_DIR}" >> ${TMPPLIST} + @${ECHO_CMD} "@exec ${CHOWN} ${DHID_USER}:${DHID_GROUP} ${DHID_PID_DIR}" >> ${TMPPLIST} + @${ECHO_CMD} "@exec ${CHMOD} 0700 ${DHID_PID_DIR}" >> ${TMPPLIST} + @${ECHO_CMD} "@unexec ${RM} -rf /${DHID_PID_DIR}" >> ${TMPPLIST} +.if !exists(${PREFIX}/etc/rc.d/dhid.sh) + @${ECHO_MSG} "===> Installing ${PREFIX}/etc/rc.d/dhid.sh.sample startup file." + @${INSTALL_SCRIPT} -m 751 ${FILESDIR}/dhid.sh ${PREFIX}/etc/rc.d/dhid.sh.sample +.endif + @${ECHO_CMD} "etc/rc.d/dhid.sh.sample" >> ${TMPPLIST} +.if !defined(NOPORTDOCS) + @${ECHO_MSG} "===> Installing documentation in ${DOCSDIR}" + @${MKDIR} ${DOCSDIR} + @${CHMOD} 755 ${DOCSDIR} +.for DOCFILE in ${DOCFILES} + @${INSTALL_DATA} ${WRKSRC}/${DOCFILE} ${DOCSDIR} + @${ECHO_CMD} "share/doc/${PORTNAME}/${DOCFILE}" >> ${TMPPLIST} +.endfor + @${ECHO_CMD} "@dirrm share/doc/${PORTNAME}" >> ${TMPPLIST} +.endif + @${CAT} ${PKGMESSAGE} .include <bsd.port.mk> diff -Nur dhid.old/distinfo dhid/distinfo --- dhid.old/distinfo Wed Mar 31 05:07:32 2004 +++ dhid/distinfo Sat Feb 5 10:51:04 2005 @@ -1,4 +1,2 @@ -MD5 (dhid-4.0.2.tar.gz) = 16532ef68d89ed51a9e57ea9ac886268 -SIZE (dhid-4.0.2.tar.gz) = 12892 -MD5 (dhid-3.1.tar.gz) = f419031035f79936592c8ecf97fbe62c -SIZE (dhid-3.1.tar.gz) = 8776 +MD5 (dhid-5.2.tar.gz) = 781ba0f83dc2a32202c1cb2c3235f06f +SIZE (dhid-5.2.tar.gz) = 16485 diff -Nur dhid.old/files/dhid.sh dhid/files/dhid.sh --- dhid.old/files/dhid.sh Wed Jul 5 14:36:40 2000 +++ dhid/files/dhid.sh Sun Dec 28 21:26:54 2003 @@ -1,4 +1,5 @@ #!/bin/sh +PATH=/bin:/sbin:/usr/bin:/usr/sbin if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then echo "$0: Cannot determine the PREFIX" >&2 @@ -7,7 +8,7 @@ case "$1" in start) - [ -x "${PREFIX}/sbin/dhid" -a -f "${PREFIX}/etc/dhid.conf" ] && ${PREFIX}/sbin/dhid > /dev/null && echo -n ' dhid' + [ -x "${PREFIX}/sbin/dhid" -a -f "${PREFIX}/etc/dhid.conf" ] && su -m dhis -c ${PREFIX}/sbin/dhid > /dev/null && echo -n ' dhid' ;; stop) killall dhid && echo -n ' dhid' diff -Nur dhid.old/files/patch-aa dhid/files/patch-aa --- dhid.old/files/patch-aa Mon Feb 26 05:09:51 2001 +++ dhid/files/patch-aa Sun Dec 28 16:13:28 2003 @@ -1,13 +1,22 @@ ---- dhid.h.orig Sun Jan 14 19:39:01 2001 -+++ dhid.h Sun Jan 14 19:41:37 2001 -@@ -73,8 +73,8 @@ - #define OFFLINE_REQ 0x00000451 +--- dhid.h.orig Thu Nov 20 20:02:38 2003 ++++ dhid.h Sun Dec 28 12:14:11 2003 +@@ -56,7 +56,7 @@ + + #define DHIS_VERSION 52 /* DHIS Version */ + +-#define MAX_HOSTNAME 64 ++#define MAX_HOSTNAME 256 + #define MAX_PASS 16 /* Characters in password */ + + /* Message opcodes */ +@@ -72,8 +72,8 @@ + #define OFFLINE_REQ 0x00000551 -#define DHID_CONF "/etc/dhid.conf" -#define DHID_PID "/etc/dhid.pid" +#define DHID_CONF "__PREFIX__/etc/dhid.conf" -+#define DHID_PID "/var/run/dhid.pid" ++#define DHID_PID "/var/run/dhis/dhid.pid" #define DEF_ISPORT 58800 #define FAIL_ALLOW 3 diff -Nur dhid.old/files/patch-ab dhid/files/patch-ab --- dhid.old/files/patch-ab Mon Feb 26 05:09:51 2001 +++ dhid/files/patch-ab Sun Dec 28 16:20:36 2003 @@ -1,17 +1,26 @@ ---- Makefile.orig Sun Jan 14 19:39:56 2001 -+++ Makefile Sun Jan 14 19:40:37 2001 -@@ -25,13 +25,10 @@ - # - # DHIS(c) Dynamic Host Information System Release 4.0 - --CC=cc -+CC?=cc +--- Makefile.orig Sun Dec 28 12:04:23 2003 ++++ Makefile Sun Dec 28 15:20:15 2003 +@@ -29,8 +29,8 @@ # Add -lnsl and -lsocket to LIBS in SysV systems # --CFLAGS=-I/usr/local/include -DQRC=1 +-CFLAGS=-I/usr/local/include -DQRC=1 -Wall -LFLAGS=-L/usr/local/lib --LIBS=-lgmp ++CFLAGS=-I__PREFIX__/include -DQRC=1 -Wall ++#LFLAGS=-L/usr/local/lib + LIBS=-lgmp # Use these and comment the above if you wish to compile dhid without - # secure public key authentication or don't have the GMP library +@@ -46,10 +46,10 @@ + all: dhid genkeys + + dhid: conf.o network.o main.o +- $(CC) $(LFLAGS) -o dhid conf.o network.o main.o $(LIBS) ++ $(CC) $(LDFLAGS) -o dhid conf.o network.o main.o $(LIBS) + + genkeys: genkeys.c +- $(CC) $(CFLAGS) $(LFLAGS) -o genkeys genkeys.c $(LIBS) ++ $(CC) $(CFLAGS) $(LDFLAGS) -o genkeys genkeys.c $(LIBS) + + main.o: dhid.h main.c + $(CC) $(CFLAGS) -c main.c diff -Nur dhid.old/files/patch-ac dhid/files/patch-ac --- dhid.old/files/patch-ac Thu Jan 1 01:00:00 1970 +++ dhid/files/patch-ac Sun Dec 28 21:16:47 2003 @@ -0,0 +1,79 @@ +--- main.c.orig Thu Nov 20 21:11:59 2003 ++++ main.c Sun Dec 28 20:16:17 2003 +@@ -74,7 +74,7 @@ + unsigned char linecmd[512]; + struct in_addr sa; + sa.s_addr=cp->laddr; +- sprintf(linecmd,"%s %d %s %s",cp->off_cmd,cp->id, ++ snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->off_cmd,cp->id, + inet_ntoa((struct in_addr)sa) + ,cp->off_cmdp); + cmd_fork(linecmd); +@@ -106,7 +106,7 @@ + unsigned char linecmd[512]; + struct in_addr sa; + sa.s_addr=cp->laddr; +- sprintf(linecmd,"%s %d %s %s",cp->off_cmd,cp->id, ++ snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->off_cmd,cp->id, + inet_ntoa((struct in_addr)sa) + ,cp->off_cmdp); + cmd_fork(linecmd); +@@ -189,7 +189,7 @@ + unsigned char linecmd[512]; + struct in_addr sa; + sa.s_addr=cp->laddr; +- sprintf(linecmd,"%s %d %s %s",cp->on_cmd,cp->id, ++ snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->on_cmd,cp->id, + inet_ntoa((struct in_addr)sa) + ,cp->on_cmdp); + cmd_fork(linecmd); +@@ -223,8 +223,8 @@ + return; + cp->cserver=sp; + cp->stage=AUTH_STAGE; +- if(cp->atype==APASS) strcpy(m.pass,cp->pass); +- else memset(m.pass,0,16); ++ if(cp->atype==APASS) strlcpy(m.pass,cp->pass,sizeof(m.pass)); ++ else memset(m.pass,0,sizeof(m.pass)); + m.hdr.opcode=AUTH_REQ; + m.hdr.hostid=cp->id; + m.refresh=cp->refresh; +@@ -289,25 +289,19 @@ + int c; + extern char *optarg; + +- strcpy(conf_file,DHID_CONF); +- strcpy(pid_file,DHID_PID); ++ strlcpy(conf_file,DHID_CONF,sizeof(conf_file)); ++ strlcpy(pid_file,DHID_PID,sizeof(pid_file)); + + while((c=getopt(argc,argv,"hf:p:P:"))!=EOF) + switch(c) { + case('p'): rport=atoi(optarg); break; +- case('P'): strncpy(pid_file,optarg,sizeof(pid_file)); break; +- case('f'): strncpy(conf_file,optarg,sizeof(conf_file)); break; ++ case('P'): strlcpy(pid_file,optarg,sizeof(pid_file)); break; ++ case('f'): strlcpy(conf_file,optarg,sizeof(conf_file)); break; + case('h'): usage(argv); + default: usage(argv); + } + + +- if(getuid()) { +- syslog(LOG_ERR,"%s must be executed by root",argv[0]); +- exit(1); +- } +- +- + close(0); + close(1); + close(2); +@@ -376,7 +370,7 @@ + unsigned char linecmd[512]; + struct in_addr sa; + sa.s_addr=cp->laddr; +- sprintf(linecmd,"%s %d %s %s",cp->off_cmd,cp->id, ++ snprintf(linecmd,sizeof(linecmd),"%s %d %s %s",cp->off_cmd,cp->id, + inet_ntoa((struct in_addr)sa) + ,cp->off_cmdp); + cmd_fork(linecmd); diff -Nur dhid.old/files/patch-ad dhid/files/patch-ad --- dhid.old/files/patch-ad Thu Jan 1 01:00:00 1970 +++ dhid/files/patch-ad Sun Dec 28 16:14:28 2003 @@ -0,0 +1,63 @@ +--- conf.c.orig Wed Sep 12 10:32:09 2001 ++++ conf.c Sun Dec 28 12:11:31 2003 +@@ -155,7 +155,7 @@ + cp->id=atoi(line_entry(2,line)); + + if(!strcmp(line_entry(1,line),"hostpass")) { +- strcpy(cp->pass,line_entry(2,line)); ++ strlcpy(cp->pass,line_entry(2,line),sizeof(cp->pass)); + cp->atype=APASS; + } + if(!strcmp(line_entry(1,line),"isaddr")) { +@@ -180,32 +180,32 @@ + sp->addr=0; + sp->hostname[0]='\0'; + +- strcpy(str2,line_entry(2,line)); ++ strlcpy(str2,line_entry(2,line),sizeof(str2)); + +- strcpy(str,dot_entry(1,str2)); +- strcpy(str3,dot_entry(2,str2)); ++ strlcpy(str,dot_entry(1,str2),sizeof(str)); ++ strlcpy(str3,dot_entry(2,str2),sizeof(str3)); + + if(isdigit(str[0])) sp->addr=inet_addr(str); +- else strcpy(sp->hostname,str); ++ else strlcpy(sp->hostname,str,sizeof(sp->hostname)); + if(str3[0]!='\0') sp->port=atoi(str3); + } + if(!strcmp(line_entry(1,line),"refresh")) { +- strcpy(str,line_entry(2,line)); ++ strlcpy(str,line_entry(2,line),sizeof(str)); + cp->refresh=atoi(str); + } + if(!strcmp(line_entry(1,line),"oncmd")) { +- strcpy(cp->on_cmd,line_entry(2,line)); +- strcpy(cp->on_cmdp,line_ptr(3,line)); ++ strlcpy(cp->on_cmd,line_entry(2,line),sizeof(cp->on_cmd)); ++ strlcpy(cp->on_cmdp,line_ptr(3,line),sizeof(cp->on_cmdp)); + } + if(!strcmp(line_entry(1,line),"offcmd")) { +- strcpy(cp->off_cmd,line_entry(2,line)); +- strcpy(cp->off_cmdp,line_ptr(3,line)); ++ strlcpy(cp->off_cmd,line_entry(2,line),sizeof(cp->off_cmd)); ++ strlcpy(cp->off_cmdp,line_ptr(3,line),sizeof(cp->off_cmdp)); + } + + + if(!strcmp(line_entry(1,line),"authp")) { + #ifdef QRC +- strcat(keyp,line_entry(2,line)); ++ strlcat(keyp,line_entry(2,line),sizeof(keyp)); + cp->atype=AQRC; + #else + syslog(LOG_ERR,"QRC authentication not available in this client" +@@ -216,7 +216,7 @@ + } + if(!strcmp(line_entry(1,line),"authq")) { + #ifdef QRC +- strcat(keyq,line_entry(2,line)); ++ strlcat(keyq,line_entry(2,line),sizeof(keyq)); + cp->atype=AQRC; + #else + syslog(LOG_ERR,"QRC authentication not available in this client" diff -Nur dhid.old/files/patch-ae dhid/files/patch-ae --- dhid.old/files/patch-ae Thu Jan 1 01:00:00 1970 +++ dhid/files/patch-ae Sun Dec 28 16:15:06 2003 @@ -0,0 +1,19 @@ +--- genkeys.c.orig Wed Sep 12 10:13:07 2001 ++++ genkeys.c Sun Dec 28 12:17:03 2003 +@@ -46,12 +46,12 @@ + static int seed=0; + + if(!seed) { seed++; srandom(time(NULL)); } +- memset(buff,0,256); +- memset(temp,0,128); ++ memset(buff,0,sizeof(buff)); ++ memset(temp,0,sizeof(temp)); + + do { +- sprintf(temp,"%lu",(unsigned long int)random()); +- strcat(buff,temp); ++ snprintf(temp,sizeof(temp),"%lu",(unsigned long int)random()); ++ strlcat(buff,temp,sizeof(buff)); + + } while(strlen(buff) < n); + buff[n]='\0'; diff -Nur dhid.old/files/patch-af dhid/files/patch-af --- dhid.old/files/patch-af Thu Jan 1 01:00:00 1970 +++ dhid/files/patch-af Sun Dec 28 16:15:26 2003 @@ -0,0 +1,32 @@ +--- network.c.orig Wed Sep 12 10:13:18 2001 ++++ network.c Sun Dec 28 12:23:11 2003 +@@ -290,12 +290,12 @@ + static int seed=0; + + if(!seed) { seed++; srandom(time(NULL)); } +- memset(buff,0,256); +- memset(temp,0,128); ++ memset(buff,0,sizeof(buff)); ++ memset(temp,0,sizeof(temp)); + + do { +- sprintf(temp,"%u",(unsigned)random()); +- strcat(buff,temp); ++ snprintf(temp,sizeof(temp),"%u",(unsigned)random()); ++ strlcat(buff,temp,sizeof(buff)); + + } while(strlen(buff) < n); + buff[n]='\0'; +@@ -441,10 +441,10 @@ + if(j<0) return; + + buff[0]='\0'; +- for(i=0;i<j;i++) strcat(buff,"0"); /* Place 0's */ ++ for(i=0;i<j;i++) strlcat(buff,"0",sizeof(buff)); /* Place 0's */ + + mpz_get_str(buff2,10,x); /* Add x */ +- strcat(buff,buff2); ++ strlcat(buff,buff2,sizeof(buff)); + + /* Now copy n digits to str */ + cp1=str; diff -Nur dhid.old/pkg-install dhid/pkg-install --- dhid.old/pkg-install Thu Jan 1 01:00:00 1970 +++ dhid/pkg-install Sun Dec 28 16:10:15 2003 @@ -0,0 +1,37 @@ +#! /bin/sh + +# $FreeBSD: ports/dns/dhid/pkg-install,v 1.7 2003/01/04 01:10:13 seanc Exp $ + +PATH=/bin:/usr/sbin + +case $2 in +PRE-INSTALL) + USER=dhis + GROUP=${USER} + + if pw group show "${GROUP}" 2>/dev/null; then + echo "You already have a group \"${GROUP}\", so I will use it." + else + if pw groupadd ${GROUP} -h -; then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + exit 1 + fi + fi + + if pw user show "${USER}" 2>/dev/null; then + echo "You already have a user \"${USER}\", so I will use it." + else + if pw useradd ${USER} -g ${GROUP} -h - \ + -d /nonexsistent -s /sbin/nologin \ + -c "DHIS Daemon" + then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + exit 1 + fi + fi + ;; +esac diff -Nur dhid.old/pkg-message dhid/pkg-message --- dhid.old/pkg-message Mon Feb 26 05:09:48 2001 +++ dhid/pkg-message Thu Feb 3 10:17:43 2005 @@ -2,4 +2,3 @@ Before dhid can run, you will need to register with a DHIS provider. See http://www.dhis.org/dhis/services/ for a list of providers. Enter the DHIS account information into the dhid.conf file. - diff -Nur dhid.old/pkg-plist dhid/pkg-plist --- dhid.old/pkg-plist Sat Feb 5 23:07:51 2000 +++ dhid/pkg-plist Sat Nov 24 19:52:33 2001 @@ -1,3 +1 @@ -etc/dhid.conf.sample -etc/rc.d/dhid.sh -sbin/dhid +@comment Left empty, filled during post-install by Makefile >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200502050955.j159tUrK076437>