diff options
author | Ed Schouten <ed@FreeBSD.org> | 2010-01-20 17:20:34 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2010-01-20 17:20:34 +0000 |
commit | f9d9f937a875f0d6b0b73f4acb820a46024faf24 (patch) | |
tree | 188e3a5b1e38254f4c9467accf44f35019065dac /sysutils | |
parent | eb24cef1f95c0f396f5e95beb69f741ba5f6f07d (diff) | |
download | ports-f9d9f937a875f0d6b0b73f4acb820a46024faf24.tar.gz ports-f9d9f937a875f0d6b0b73f4acb820a46024faf24.zip |
Notes
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/blimitd/Makefile | 8 | ||||
-rw-r--r-- | sysutils/blimitd/files/extra-patch-utmpx | 71 |
2 files changed, 78 insertions, 1 deletions
diff --git a/sysutils/blimitd/Makefile b/sysutils/blimitd/Makefile index b556df8c61b2..07d0901ece7c 100644 --- a/sysutils/blimitd/Makefile +++ b/sysutils/blimitd/Makefile @@ -26,4 +26,10 @@ post-install: ${INSTALL_SCRIPT} -m 751 ${FILESDIR}/blimitd.sh ${PREFIX}/etc/rc.d/blimitd.sh; \ fi -.include <bsd.port.mk> +.include <bsd.port.pre.mk> + +.if ${OSVERSION} >= 900007 +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-utmpx +.endif + +.include <bsd.port.post.mk> diff --git a/sysutils/blimitd/files/extra-patch-utmpx b/sysutils/blimitd/files/extra-patch-utmpx new file mode 100644 index 000000000000..a6bd694a4622 --- /dev/null +++ b/sysutils/blimitd/files/extra-patch-utmpx @@ -0,0 +1,71 @@ +--- blimitd.c ++++ blimitd.c +@@ -15,7 +15,7 @@ + #include <sysexits.h> + #include <syslog.h> + #include <unistd.h> +-#include <utmp.h> ++#include <utmpx.h> + + #include "blimitd.h" + #include "config.h" +@@ -35,7 +35,7 @@ + pid_t pid; + char *name; + FILE *utmp_fh; +- struct utmp utmp_record; ++ struct utmpx *utmp_record; + struct passwd *pw; + struct user_instance ui; + +@@ -115,23 +115,19 @@ + + /* actually do stuff */ + while (sig_no == 0) { +- /* get the logged in users */ +- if ((utmp_fh = fopen(_PATH_UTMP, "r")) == NULL) { +- syslog(LOG_ERR, "failed to open %s for reading: %m", _PATH_UTMP); +- continue; +- } + /* prepare for pw access */ + if (! setpassent(1)) { + syslog(LOG_ERR, "setpassent: %m"); + } + /* for each entry */ +- while (fread(&utmp_record, sizeof(utmp_record), 1, utmp_fh)) { +- if (utmp_record.ut_name[0] == '\0') { ++ setutxent(); ++ while ((utmp_record = getutxent()) != NULL) { ++ if (utmp_record->ut_type != USER_PROCESS) { + /* this entry has been removed */ + continue; + } + /* get their name in a char *\0 */ +- if ((name = strndup(utmp_record.ut_name, UT_NAMESIZE)) == NULL) { ++ if ((name = strndup(utmp_record->ut_user, sizeof utmp_record->ut_user)) == NULL) { + syslog(LOG_ERR, "strndup failed: %m"); + continue; + } +@@ -150,7 +146,7 @@ + + /* initialise ui for passing to enforcement functions */ + ui.pw = pw; +- if ((ui.tty = find_tty(utmp_record.ut_line, UT_LINESIZE)) == NULL) { ++ if ((ui.tty = find_tty(utmp_record->ut_line, sizeof utmp_record->ut_line)) == NULL) { + syslog(LOG_ERR, "find_tty failed: %m"); + continue; + } +@@ -163,12 +159,7 @@ + free(ui.tty); + } + +- if (ferror(utmp_fh)) { +- syslog(LOG_ERR, "error reading from %s: %m", _PATH_UTMP); +- } +- if (fclose(utmp_fh) != 0) { +- syslog(LOG_ERR, "error closing %s: %m", _PATH_UTMP); +- } ++ endutxent(); + + /* finished with the password database till next time */ + endpwent(); |