Index: head/net/pxe/Makefile =================================================================== --- head/net/pxe/Makefile (revision 421315) +++ head/net/pxe/Makefile (revision 421316) @@ -1,39 +1,44 @@ # Created by: Anders Nordby # $FreeBSD$ PORTNAME= pxe PORTVERSION= 1.4.2 PORTREVISION= 2 CATEGORIES= net MASTER_SITES= http://www.kano.org.uk/projects/pxe/ \ ftp://ftp.nuug.no/pub/anders/distfiles/ MAINTAINER= ports@FreeBSD.org COMMENT= PXE daemon, set up a boot menu for netbooting PXE enabled clients +LICENSE= GPLv2+ +LICENSE_FILE= ${WRKSRC}/LICENCE + USE_RC_SUBR= pxe SUB_FILES= pkg-message GNU_CONFIGURE= yes -CONFIGURE_ARGS+= --with-config=${PREFIX}/etc/pxe.conf \ - --with-log=/var/log/pxe.log \ - --with-setuid=nobody +CONFIGURE_ARGS= --with-config=${PREFIX}/etc/pxe.conf \ + --with-log=/var/log/pxe.log \ + --with-setuid=nobody -PORTDOCS= Changes INSTALL LICENCE README THANKS -PLIST_FILES= sbin/pxe etc/pxe.conf.sample +PORTDOCS= Changes INSTALL README THANKS +PLIST_FILES= etc/pxe.conf.sample sbin/pxe OPTIONS_DEFINE= DOCS post-patch: - ${REINPLACE_CMD} -e 's|/tmp/pxe.pid|/var/run/pxe.pid|' \ + @${REINPLACE_CMD} -e 's|/tmp/pxe.pid|/var/run/pxe.pid|' \ ${WRKSRC}/autoconf.h.in do-install: ${INSTALL_PROGRAM} ${WRKSRC}/pxe ${STAGEDIR}${PREFIX}/sbin ${INSTALL_DATA} ${WRKSRC}/pxe.conf \ ${STAGEDIR}${PREFIX}/etc/pxe.conf.sample - ${MKDIR} ${STAGEDIR}${DOCSDIR} + +do-install-DOCS-on: + @${MKDIR} ${STAGEDIR}${DOCSDIR} .for f in ${PORTDOCS} ${INSTALL_DATA} ${WRKSRC}/${f} ${STAGEDIR}${DOCSDIR} .endfor .include Index: head/net/pxe/files/patch-pxe.cc =================================================================== --- head/net/pxe/files/patch-pxe.cc (revision 421315) +++ head/net/pxe/files/patch-pxe.cc (revision 421316) @@ -1,101 +1,101 @@ ---- pxe.cc.orig Sun Feb 2 13:39:26 2003 -+++ pxe.cc Sun Jun 3 21:34:25 2007 -@@ -208,6 +208,31 @@ +--- pxe.cc.orig 2003-02-02 12:39:26 UTC ++++ pxe.cc +@@ -208,6 +208,31 @@ int StartPxeService(const char *configfi return(retval); } +/****************************************************************************** + * DoSetUID - set uid and gid * + ******************************************************************************/ +void DoSetUID() +{ + // set the UID/GID to a low user +#ifndef NO_SUID + struct passwd *pw; + pw = getpwnam(SETUID); + + if(NULL == pw) + std::cout << "Unable to find passwd entry for " << SETUID + << ", continuing with user id " << getuid() << "\n"; + else + { + if((-1 == setgid(pw->pw_gid)) || (-1 == setegid(pw->pw_gid))) + std::cout << "Unable to change group id, continuing with group id " + << getgid() << "\n"; + if((-1 == setuid(pw->pw_uid)) || (-1 == seteuid(pw->pw_uid))) + std::cout << "Unable to change user id, continuing with user id " + << getuid() << "\n"; + } +#endif +} + /****************************************************************************** * main - kick things off and do cool things * -@@ -247,6 +272,15 @@ +@@ -247,6 +272,15 @@ int main(int argc, char **argv) } debug.close(); + // check to see if the daemon is already running + chk = open(LOCKFILE, O_WRONLY|O_CREAT|O_EXCL, 0644); + if(-1 == chk) + { + std::cerr << "PXE daemon already running, or left-over pid file " << LOCKFILE << " exists?\n"; + std::cerr << "Aborting startup.\n"; + return(-1); + } + // redirect the file descriptors if (0 == _debug) { debug.open("/dev/null", std::ios::out); -@@ -258,34 +292,6 @@ +@@ -258,34 +292,6 @@ int main(int argc, char **argv) debug.close(); } - - // set the UID/GID to a low user -#ifndef NO_SUID - struct passwd *pw; - pw = getpwnam(SETUID); - - if(NULL == pw) - std::cout << "Unable to find passwd entry for " << SETUID - << ", continuing with user id " << getuid() << "\n"; - else - { - if((-1 == setgid(pw->pw_gid)) || (-1 == setegid(pw->pw_gid))) - std::cout << "Unable to change group id, continuing with group id " - << getgid() << "\n"; - if((-1 == setuid(pw->pw_uid)) || (-1 == seteuid(pw->pw_uid))) - std::cout << "Unable to change user id, continuing with user id " - << getuid() << "\n"; - } -#endif - - // check to see if the daemon is already running - chk = open(LOCKFILE, O_WRONLY|O_CREAT|O_EXCL, 0644); - if(-1 == chk) - { - std::cerr << "PXE daemon already running\n"; - return(-1); - } - // if not in debug mode, fork and go if (0 == _debug) { signal(SIGCHLD, SIG_IGN); -@@ -320,6 +326,7 @@ +@@ -320,6 +326,7 @@ int main(int argc, char **argv) } close(chk); + DoSetUID; StartPxeService(configfile); exit(0); -@@ -328,6 +335,7 @@ +@@ -328,6 +335,7 @@ int main(int argc, char **argv) } } else { // debug + DoSetUID; StartPxeService(configfile); }