diff options
author | Anders Nordby <anders@FreeBSD.org> | 2007-06-03 20:41:10 +0000 |
---|---|---|
committer | Anders Nordby <anders@FreeBSD.org> | 2007-06-03 20:41:10 +0000 |
commit | e905822938aeefc7e15b427e4e2190311e1ba489 (patch) | |
tree | 8d85aca0d6975c7522c3611f28a382027e6a8ceb /net/pxe | |
parent | Drop maintainership of gringotts ports, no interest in this anymore. (diff) |
Various fixes:
- add standard rc.subr startup script.
- add post-install message mentioning necessary configuration steps.
- move pid-file to /var/run, the usual place. Do setuid/setgid later,
so that we can create it.
- make message about stale pid file a bit more explanatory.
Notes
Notes:
svn path=/head/; revision=192644
Diffstat (limited to 'net/pxe')
-rw-r--r-- | net/pxe/Makefile | 11 | ||||
-rw-r--r-- | net/pxe/files/patch-pxe.cc | 101 | ||||
-rw-r--r-- | net/pxe/files/pkg-message.in | 6 | ||||
-rw-r--r-- | net/pxe/files/pxe.sh.in | 29 | ||||
-rw-r--r-- | net/pxe/pkg-plist | 1 |
5 files changed, 147 insertions, 1 deletions
diff --git a/net/pxe/Makefile b/net/pxe/Makefile index 4cdfb1264cd4..1aee914df57f 100644 --- a/net/pxe/Makefile +++ b/net/pxe/Makefile @@ -7,6 +7,7 @@ PORTNAME= pxe PORTVERSION= 1.4.2 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://www.kano.org.uk/projects/pxe/ \ ftp://ftp.nuug.no/pub/anders/distfiles/ @@ -14,15 +15,20 @@ MASTER_SITES= http://www.kano.org.uk/projects/pxe/ \ MAINTAINER= anders@FreeBSD.org COMMENT= PXE daemon, set up a boot menu for netbooting PXE enabled clients +USE_RC_SUBR= pxe.sh +SUB_FILES= pkg-message GNU_CONFIGURE= yes CONFIGURE_ARGS+= --with-config=${PREFIX}/etc/pxe.conf \ --with-log=/var/log/pxe.log \ --with-setuid=nobody -DOCS= Changes INSTALL LICENCE README +DOCS= Changes INSTALL LICENCE README THANKS .include <bsd.port.pre.mk> +post-patch: + ${REINPLACE_CMD} -e 's|/tmp/pxe.pid|/var/run/pxe.pid|' ${WRKSRC}/autoconf.h.in + do-install: ${INSTALL_PROGRAM} ${WRKSRC}/pxe ${PREFIX}/sbin/ ${INSTALL_DATA} ${WRKSRC}/pxe.conf ${PREFIX}/etc/pxe.conf.sample @@ -33,4 +39,7 @@ do-install: .endfor .endif +post-install: + ${CAT} ${PKGMESSAGE} + .include <bsd.port.post.mk> diff --git a/net/pxe/files/patch-pxe.cc b/net/pxe/files/patch-pxe.cc new file mode 100644 index 000000000000..95ad40fb542c --- /dev/null +++ b/net/pxe/files/patch-pxe.cc @@ -0,0 +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 @@ + 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 @@ + } + 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 @@ + 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 @@ + } + close(chk); + ++ DoSetUID; + StartPxeService(configfile); + + exit(0); +@@ -328,6 +335,7 @@ + } + + } else { // debug ++ DoSetUID; + StartPxeService(configfile); + } + diff --git a/net/pxe/files/pkg-message.in b/net/pxe/files/pkg-message.in new file mode 100644 index 000000000000..6a259ad506c9 --- /dev/null +++ b/net/pxe/files/pkg-message.in @@ -0,0 +1,6 @@ +===> CONFIGURATION NOTE: + You need to create a configuration file. Copy + %%PREFIX%%/etc/pxe.conf.sample to %%PREFIX%%/etc/pxe.conf + and change what you need there. + + To enable the pxe daemon, add pxe_enable="YES" to your /etc/rc.conf. diff --git a/net/pxe/files/pxe.sh.in b/net/pxe/files/pxe.sh.in new file mode 100644 index 000000000000..0fb38d8fe208 --- /dev/null +++ b/net/pxe/files/pxe.sh.in @@ -0,0 +1,29 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: pxe +# REQUIRE: NETWORKING +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to enable the pxe daemon: +# +# pxe_enable="YES" + +. %%RC_SUBR%% + +name=pxe +rcvar=`set_rcvar` + +command="%%PREFIX%%/sbin/pxe" +required_files=%%PREFIX%%/etc/pxe.conf +command_args="-c ${required_files}" +pidfile=/var/pxe/${name}.pid + +# set defaults +pxe_enable=${pxe_enable:-"NO"} + +load_rc_config ${name} +run_rc_command "$1" diff --git a/net/pxe/pkg-plist b/net/pxe/pkg-plist index fab56e91d92b..df1295d12564 100644 --- a/net/pxe/pkg-plist +++ b/net/pxe/pkg-plist @@ -4,4 +4,5 @@ etc/pxe.conf.sample %%PORTDOCS%%share/doc/pxe/INSTALL %%PORTDOCS%%share/doc/pxe/LICENCE %%PORTDOCS%%share/doc/pxe/README +%%PORTDOCS%%share/doc/pxe/THANKS %%PORTDOCS%%@dirrm share/doc/pxe |