summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2010-03-04 13:35:57 +0000
committerdes <des@FreeBSD.org>2010-03-04 13:35:57 +0000
commit834fb25a9ed2240101506d137b5be7d71c75f306 (patch)
tree4002c72cd1ed11909f7640bea343988cfcf63c5b /libexec
parent98b742f57cafbed05c101e60cc131f5980f044d0 (diff)
parent787cf8d03f1c58ada088933408f30fd63de85bf2 (diff)
downloadFreeBSD-src-834fb25a9ed2240101506d137b5be7d71c75f306.zip
FreeBSD-src-834fb25a9ed2240101506d137b5be7d71c75f306.tar.gz
IFH@204581
Diffstat (limited to 'libexec')
-rw-r--r--libexec/Makefile1
-rw-r--r--libexec/Makefile.inc2
-rw-r--r--libexec/atrun/Makefile2
-rw-r--r--libexec/atrun/atrun.c11
-rw-r--r--libexec/bootpd/Makefile2
-rw-r--r--libexec/bootpd/Makefile.inc2
-rw-r--r--libexec/bootpd/tools/Makefile.inc2
-rw-r--r--libexec/comsat/comsat.82
-rw-r--r--libexec/comsat/comsat.c91
-rw-r--r--libexec/fingerd/Makefile2
-rw-r--r--libexec/ftpd/ftpd.83
-rw-r--r--libexec/ftpd/ftpd.c31
-rw-r--r--libexec/ftpd/logwtmp.c57
-rw-r--r--libexec/getty/Makefile2
-rw-r--r--libexec/getty/ttys.51
-rw-r--r--libexec/mail.local/Makefile2
-rw-r--r--libexec/mknetid/Makefile2
-rw-r--r--libexec/pppoed/Makefile1
-rw-r--r--libexec/rbootd/Makefile1
-rw-r--r--libexec/revnetgroup/Makefile2
-rw-r--r--libexec/rlogind/rlogind.c13
-rw-r--r--libexec/rpc.rquotad/Makefile2
-rw-r--r--libexec/rpc.rstatd/Makefile6
-rw-r--r--libexec/rpc.rusersd/Makefile1
-rw-r--r--libexec/rpc.rusersd/rusers_proc.c400
-rw-r--r--libexec/rpc.rusersd/rusersd.c40
-rw-r--r--libexec/rpc.rwalld/Makefile2
-rw-r--r--libexec/rpc.sprayd/Makefile3
-rw-r--r--libexec/rshd/Makefile1
-rw-r--r--libexec/rtld-aout/shlib.c28
-rw-r--r--libexec/rtld-aout/support.c10
-rw-r--r--libexec/rtld-elf/Makefile1
-rw-r--r--libexec/rtld-elf/arm/rtld_start.S7
-rw-r--r--libexec/rtld-elf/map_object.c2
-rw-r--r--libexec/rtld-elf/powerpc/reloc.c85
-rw-r--r--libexec/rtld-elf/powerpc/rtld_machdep.h1
-rw-r--r--libexec/rtld-elf/powerpc/rtld_start.S6
-rw-r--r--libexec/rtld-elf/rtld.c107
-rw-r--r--libexec/rtld-elf/rtld.h6
-rw-r--r--libexec/smrsh/Makefile2
-rw-r--r--libexec/talkd/Makefile1
-rw-r--r--libexec/talkd/process.c34
-rw-r--r--libexec/tcpd/Makefile2
-rw-r--r--libexec/tftp-proxy/Makefile2
-rw-r--r--libexec/tftpd/Makefile3
-rw-r--r--libexec/ulog-helper/Makefile11
-rw-r--r--libexec/ulog-helper/ulog-helper.c79
-rw-r--r--libexec/ypxfr/Makefile3
48 files changed, 552 insertions, 525 deletions
diff --git a/libexec/Makefile b/libexec/Makefile
index 26a8ff2..78953b4 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -29,6 +29,7 @@ SUBDIR= ${_atrun} \
${_telnetd} \
tftpd \
${_tftp-proxy} \
+ ulog-helper \
${_ypxfr}
.if ${MK_AT} != "no"
diff --git a/libexec/Makefile.inc b/libexec/Makefile.inc
index 05deedc..7b6a65f 100644
--- a/libexec/Makefile.inc
+++ b/libexec/Makefile.inc
@@ -2,4 +2,6 @@
# $FreeBSD$
BINDIR?= /usr/libexec
+
+WARNS?= 6
WFORMAT?= 1
diff --git a/libexec/atrun/Makefile b/libexec/atrun/Makefile
index 4e3d4cc..2730559 100644
--- a/libexec/atrun/Makefile
+++ b/libexec/atrun/Makefile
@@ -13,6 +13,8 @@ CLEANFILES= ${MAN}
CFLAGS+=-I${MAINSRC} -I${.CURDIR}
CFLAGS+=-DLOGIN_CAP -DPAM
+
+WARNS?= 2
WFORMAT=0
DPADD= ${LIBPAM} ${LIBUTIL}
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c
index a7cef87..e4fc625 100644
--- a/libexec/atrun/atrun.c
+++ b/libexec/atrun/atrun.c
@@ -49,7 +49,6 @@ static const char rcsid[] =
#include <syslog.h>
#include <time.h>
#include <unistd.h>
-#include <utmp.h>
#ifdef __FreeBSD__
#include <paths.h>
#else
@@ -63,12 +62,6 @@ static const char rcsid[] =
#include <security/openpam.h>
#endif
-#if (MAXLOGNAME-1) > UT_NAMESIZE
-#define LOGNAMESIZE UT_NAMESIZE
-#else
-#define LOGNAMESIZE (MAXLOGNAME-1)
-#endif
-
/* Local headers */
#include "gloadavg.h"
@@ -130,7 +123,7 @@ run_file(const char *filename, uid_t uid, gid_t gid)
pid_t pid;
int fd_out, fd_in;
int queue;
- char mailbuf[LOGNAMESIZE + 1], fmt[49];
+ char mailbuf[MAXLOGNAME], fmt[49];
char *mailname = NULL;
FILE *stream;
int send_mail = 0;
@@ -231,7 +224,7 @@ run_file(const char *filename, uid_t uid, gid_t gid)
snprintf(fmt, sizeof(fmt),
"#!/bin/sh\n# atrun uid=%%ld gid=%%ld\n# mail %%%ds %%d",
- LOGNAMESIZE);
+ MAXLOGNAME - 1);
if (fscanf(stream, fmt, &nuid, &ngid, mailbuf, &send_mail) != 4)
perrx("File %s is in wrong format - aborting", filename);
diff --git a/libexec/bootpd/Makefile b/libexec/bootpd/Makefile
index 830577a..6f02477 100644
--- a/libexec/bootpd/Makefile
+++ b/libexec/bootpd/Makefile
@@ -5,6 +5,8 @@ PROG= bootpd
CFLAGS+= -DETC_ETHERS
CFLAGS+= -DSYSLOG -DDEBUG -DVEND_CMU
+WARNS?= 2
+
SUBDIR= bootpgw tools
SRCS= bootpd.c dovend.c readfile.c hash.c dumptab.c \
diff --git a/libexec/bootpd/Makefile.inc b/libexec/bootpd/Makefile.inc
index 829da30..899c9b5 100644
--- a/libexec/bootpd/Makefile.inc
+++ b/libexec/bootpd/Makefile.inc
@@ -1,3 +1,5 @@
# $FreeBSD$
BINDIR?= /usr/libexec
+
+WARNS?= 1
diff --git a/libexec/bootpd/tools/Makefile.inc b/libexec/bootpd/tools/Makefile.inc
index 4d78761..f4a306f 100644
--- a/libexec/bootpd/tools/Makefile.inc
+++ b/libexec/bootpd/tools/Makefile.inc
@@ -2,3 +2,5 @@
# $FreeBSD$
BINDIR= /usr/sbin
+
+WARNS?= 1
diff --git a/libexec/comsat/comsat.8 b/libexec/comsat/comsat.8
index 50b6b11..1f35cff 100644
--- a/libexec/comsat/comsat.8
+++ b/libexec/comsat/comsat.8
@@ -91,7 +91,7 @@ If
omitted, standard mailbox assumed.
.Sh FILES
.Bl -tag -width ".Pa /var/mail/user" -compact
-.It Pa /var/run/utmp
+.It Pa /var/run/utx.active
to find out who is logged on and on what terminals
.It Pa /var/mail/user
standard mailbox
diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c
index fd7cc8d..d0ff7a4 100644
--- a/libexec/comsat/comsat.c
+++ b/libexec/comsat/comsat.c
@@ -66,7 +66,7 @@ static const char rcsid[] =
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <utmp.h>
+#include <utmpx.h>
int debug = 0;
#define dsyslog if (debug) syslog
@@ -74,18 +74,14 @@ int debug = 0;
#define MAXIDLE 120
char hostname[MAXHOSTNAMELEN];
-struct utmp *utmp = NULL;
-time_t lastmsgtime;
-int nutmp, uf;
void jkfprintf(FILE *, char[], char[], off_t);
void mailfor(char *);
-void notify(struct utmp *, char[], off_t, int);
-void onalrm(int);
+void notify(struct utmpx *, char[], off_t, int);
void reapchildren(int);
int
-main(int argc, char *argv[])
+main(int argc __unused, char *argv[] __unused)
{
struct sockaddr_in from;
socklen_t fromlen;
@@ -102,15 +98,7 @@ main(int argc, char *argv[])
(void) recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
exit(1);
}
- if ((uf = open(_PATH_UTMP, O_RDONLY, 0)) < 0) {
- syslog(LOG_ERR, "open: %s: %m", _PATH_UTMP);
- (void) recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
- exit(1);
- }
- (void)time(&lastmsgtime);
(void)gethostname(hostname, sizeof(hostname));
- onalrm(0);
- (void)signal(SIGALRM, onalrm);
(void)signal(SIGTTOU, SIG_IGN);
(void)signal(SIGCHLD, reapchildren);
for (;;) {
@@ -121,57 +109,28 @@ main(int argc, char *argv[])
errno = 0;
continue;
}
- if (!nutmp) /* no one has logged in yet */
- continue;
- sigblock(sigmask(SIGALRM));
msgbuf[cc] = '\0';
- (void)time(&lastmsgtime);
mailfor(msgbuf);
sigsetmask(0L);
}
}
void
-reapchildren(int signo)
+reapchildren(int signo __unused)
{
while (wait3(NULL, WNOHANG, NULL) > 0);
}
void
-onalrm(int signo)
-{
- static u_int utmpsize; /* last malloced size for utmp */
- static u_int utmpmtime; /* last modification time for utmp */
- struct stat statbf;
-
- if (time(NULL) - lastmsgtime >= MAXIDLE)
- exit(0);
- (void)alarm((u_int)15);
- (void)fstat(uf, &statbf);
- if (statbf.st_mtime > utmpmtime) {
- utmpmtime = statbf.st_mtime;
- if (statbf.st_size > utmpsize) {
- utmpsize = statbf.st_size + 10 * sizeof(struct utmp);
- if ((utmp = realloc(utmp, utmpsize)) == NULL) {
- syslog(LOG_ERR, "%s", strerror(errno));
- exit(1);
- }
- }
- (void)lseek(uf, (off_t)0, SEEK_SET);
- nutmp = read(uf, utmp, (size_t)statbf.st_size)/sizeof(struct utmp);
- }
-}
-
-void
mailfor(char *name)
{
- struct utmp *utp = &utmp[nutmp];
+ struct utmpx *utp;
char *cp;
char *file;
off_t offset;
int folder;
- char buf[sizeof(_PATH_MAILDIR) + sizeof(utmp[0].ut_name) + 1];
- char buf2[sizeof(_PATH_MAILDIR) + sizeof(utmp[0].ut_name) + 1];
+ char buf[sizeof(_PATH_MAILDIR) + sizeof(utp->ut_user) + 1];
+ char buf2[sizeof(_PATH_MAILDIR) + sizeof(utp->ut_user) + 1];
if (!(cp = strchr(name, '@')))
return;
@@ -181,33 +140,35 @@ mailfor(char *name)
file = name;
else
file = cp + 1;
- sprintf(buf, "%s/%.*s", _PATH_MAILDIR, (int)sizeof(utmp[0].ut_name),
+ sprintf(buf, "%s/%.*s", _PATH_MAILDIR, (int)sizeof(utp->ut_user),
name);
if (*file != '/') {
sprintf(buf2, "%s/%.*s", _PATH_MAILDIR,
- (int)sizeof(utmp[0].ut_name), file);
+ (int)sizeof(utp->ut_user), file);
file = buf2;
}
folder = strcmp(buf, file);
- while (--utp >= utmp)
- if (!strncmp(utp->ut_name, name, sizeof(utmp[0].ut_name)))
+ setutxent();
+ while ((utp = getutxent()) != NULL)
+ if (utp->ut_type == USER_PROCESS && !strcmp(utp->ut_user, name))
notify(utp, file, offset, folder);
+ endutxent();
}
-static char *cr;
+static const char *cr;
void
-notify(struct utmp *utp, char file[], off_t offset, int folder)
+notify(struct utmpx *utp, char file[], off_t offset, int folder)
{
FILE *tp;
struct stat stb;
struct termios tio;
- char tty[20], name[sizeof(utmp[0].ut_name) + 1];
- const char *cr = utp->ut_line;
+ char tty[20];
+ const char *s = utp->ut_line;
- if (strncmp(cr, "pts/", 4) == 0)
- cr += 4;
- if (strchr(cr, '/')) {
+ if (strncmp(s, "pts/", 4) == 0)
+ s += 4;
+ if (strchr(s, '/')) {
/* A slash is an attempt to break security... */
syslog(LOG_AUTH | LOG_NOTICE, "Unexpected `/' in `%s'",
utp->ut_line);
@@ -216,10 +177,10 @@ notify(struct utmp *utp, char file[], off_t offset, int folder)
(void)snprintf(tty, sizeof(tty), "%s%.*s",
_PATH_DEV, (int)sizeof(utp->ut_line), utp->ut_line);
if (stat(tty, &stb) == -1 || !(stb.st_mode & (S_IXUSR | S_IXGRP))) {
- dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_name, tty);
+ dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_user, tty);
return;
}
- dsyslog(LOG_DEBUG, "notify %s on %s\n", utp->ut_name, tty);
+ dsyslog(LOG_DEBUG, "notify %s on %s\n", utp->ut_user, tty);
switch (fork()) {
case -1:
syslog(LOG_NOTICE, "fork failed (%m)");
@@ -229,25 +190,21 @@ notify(struct utmp *utp, char file[], off_t offset, int folder)
default:
return;
}
- (void)signal(SIGALRM, SIG_DFL);
- (void)alarm((u_int)30);
if ((tp = fopen(tty, "w")) == NULL) {
dsyslog(LOG_ERR, "%s: %s", tty, strerror(errno));
_exit(1);
}
(void)tcgetattr(fileno(tp), &tio);
cr = ((tio.c_oflag & (OPOST|ONLCR)) == (OPOST|ONLCR)) ? "\n" : "\n\r";
- (void)strncpy(name, utp->ut_name, sizeof(utp->ut_name));
- name[sizeof(name) - 1] = '\0';
switch (stb.st_mode & (S_IXUSR | S_IXGRP)) {
case S_IXUSR:
case (S_IXUSR | S_IXGRP):
(void)fprintf(tp,
"%s\007New mail for %s@%.*s\007 has arrived%s%s%s:%s----%s",
- cr, name, (int)sizeof(hostname), hostname,
+ cr, utp->ut_user, (int)sizeof(hostname), hostname,
folder ? cr : "", folder ? "to " : "", folder ? file : "",
cr, cr);
- jkfprintf(tp, name, file, offset);
+ jkfprintf(tp, utp->ut_user, file, offset);
break;
case S_IXGRP:
(void)fprintf(tp, "\007");
diff --git a/libexec/fingerd/Makefile b/libexec/fingerd/Makefile
index ae92564..b6382ad 100644
--- a/libexec/fingerd/Makefile
+++ b/libexec/fingerd/Makefile
@@ -5,8 +5,8 @@ PROG= fingerd
DPADD= ${LIBUTIL}
LDADD= -lutil
MAN= fingerd.8
-WARNS?= 2
+WARNS?= 2
WFORMAT=0
.include <bsd.prog.mk>
diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8
index 9334bd9..d7e5deb 100644
--- a/libexec/ftpd/ftpd.8
+++ b/libexec/ftpd/ftpd.8
@@ -219,8 +219,7 @@ This option may be overridden by
A synonym for
.Fl d .
.It Fl W
-Do not log FTP sessions to
-.Pa /var/log/wtmp .
+Do not log FTP sessions to the user accounting database.
.El
.Pp
The file
diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c
index 32c15f8..119c575 100644
--- a/libexec/ftpd/ftpd.c
+++ b/libexec/ftpd/ftpd.c
@@ -173,8 +173,7 @@ static struct ftphost {
char remotehost[NI_MAXHOST];
char *ident = NULL;
-static char ttyline[20];
-char *tty = ttyline; /* for klogin */
+static char wtmpid[20];
#ifdef USE_PAM
static int auth_pam(struct passwd**, const char*);
@@ -584,8 +583,7 @@ gotchild:
data_source.su_port = htons(ntohs(ctrl_addr.su_port) - 1);
- /* set this here so klogin can use it... */
- (void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid());
+ (void)snprintf(wtmpid, sizeof(wtmpid), "%xftpd", getpid());
/* Try to handle urgent data inline */
#ifdef SO_OOBINLINE
@@ -1181,7 +1179,7 @@ end_login(void)
(void) seteuid(0);
if (logged_in && dowtmp)
- ftpd_logwtmp(ttyline, "", NULL);
+ ftpd_logwtmp(wtmpid, NULL, NULL);
pw = NULL;
#ifdef LOGIN_CAP
setusercontext(NULL, getpwuid(0), 0,
@@ -1476,9 +1474,19 @@ skip:
}
#endif
- /* open wtmp before chroot */
+ dochroot =
+ checkuser(_PATH_FTPCHROOT, pw->pw_name, 1, &residue)
+#ifdef LOGIN_CAP /* Allow login.conf configuration as well */
+ || login_getcapbool(lc, "ftp-chroot", 0)
+#endif
+ ;
+ chrootdir = NULL;
+
+ /* Disable wtmp logging when chrooting. */
+ if (dochroot || guest)
+ dowtmp = 0;
if (dowtmp)
- ftpd_logwtmp(ttyline, pw->pw_name,
+ ftpd_logwtmp(wtmpid, pw->pw_name,
(struct sockaddr *)&his_addr);
logged_in = 1;
@@ -1491,13 +1499,6 @@ skip:
if (statfd < 0)
stats = 0;
- dochroot =
- checkuser(_PATH_FTPCHROOT, pw->pw_name, 1, &residue)
-#ifdef LOGIN_CAP /* Allow login.conf configuration as well */
- || login_getcapbool(lc, "ftp-chroot", 0)
-#endif
- ;
- chrootdir = NULL;
/*
* For a chrooted local user,
* a) see whether ftpchroot(5) specifies a chroot directory,
@@ -2734,7 +2735,7 @@ dologout(int status)
if (logged_in && dowtmp) {
(void) seteuid(0);
- ftpd_logwtmp(ttyline, "", NULL);
+ ftpd_logwtmp(wtmpid, NULL, NULL);
}
/* beware of flushing buffers after a SIGPIPE */
_exit(status);
diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c
index 29bea5c..711234f 100644
--- a/libexec/ftpd/logwtmp.c
+++ b/libexec/ftpd/logwtmp.c
@@ -46,47 +46,36 @@ __FBSDID("$FreeBSD$");
#include <arpa/inet.h>
#include <sys/socket.h>
-#include <fcntl.h>
-#include <time.h>
-#include <timeconv.h>
-#include <netdb.h>
-#include <utmp.h>
-#include <unistd.h>
+#include <libutil.h>
#include <stdio.h>
#include <string.h>
-#include <libutil.h>
+#include <unistd.h>
+#include <utmpx.h>
#include "extern.h"
-static int fd = -1;
-
-/*
- * Modified version of logwtmp that holds wtmp file open
- * after first call, for use with ftp (which may chroot
- * after login, but before logout).
- */
void
-ftpd_logwtmp(line, name, addr)
- char *line, *name;
- struct sockaddr *addr;
+ftpd_logwtmp(char *id, char *user, struct sockaddr *addr)
{
- struct utmp ut;
- struct stat buf;
- char host[UT_HOSTSIZE];
+ struct utmpx ut;
- if (addr == NULL)
- host[0] = '\0';
- else
- realhostname_sa(host, sizeof(host), addr, addr->sa_len);
+ memset(&ut, 0, sizeof(ut));
- if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
- return;
- if (fstat(fd, &buf) == 0) {
- (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
- (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
- (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
- ut.ut_time = _time_to_time32(time(NULL));
- if (write(fd, &ut, sizeof(struct utmp)) !=
- sizeof(struct utmp))
- (void)ftruncate(fd, buf.st_size);
+ if (user != NULL) {
+ /* Log in. */
+ ut.ut_type = USER_PROCESS;
+ (void)strncpy(ut.ut_user, user, sizeof(ut.ut_user));
+ if (addr != NULL)
+ realhostname_sa(ut.ut_host, sizeof(ut.ut_host),
+ addr, addr->sa_len);
+ } else {
+ /* Log out. */
+ ut.ut_type = DEAD_PROCESS;
}
+
+ ut.ut_pid = getpid();
+ gettimeofday(&ut.ut_tv, NULL);
+ (void)strncpy(ut.ut_id, id, sizeof(ut.ut_id));
+ (void)strncpy(ut.ut_line, "ftpd", sizeof(ut.ut_line));
+
+ pututxline(&ut);
}
diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile
index 697e81a..f967958 100644
--- a/libexec/getty/Makefile
+++ b/libexec/getty/Makefile
@@ -6,6 +6,8 @@ SRCS= main.c init.c subr.c chat.c
DPADD= ${LIBUTIL}
LDADD= -lutil
MAN= gettytab.5 ttys.5 getty.8
+
+WARNS?= 1
WFORMAT=0
.include <bsd.prog.mk>
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
index cf2423a..18151c9 100644
--- a/libexec/getty/ttys.5
+++ b/libexec/getty/ttys.5
@@ -158,7 +158,6 @@ ttyp1 none network off group=pty
.Sh SEE ALSO
.Xr login 1 ,
.Xr getttyent 3 ,
-.Xr ttyslot 3 ,
.Xr gettytab 5 ,
.Xr login.conf 5 ,
.Xr termcap 5 ,
diff --git a/libexec/mail.local/Makefile b/libexec/mail.local/Makefile
index 57837d1..3e59609 100644
--- a/libexec/mail.local/Makefile
+++ b/libexec/mail.local/Makefile
@@ -8,6 +8,8 @@ PROG= mail.local
SRCS= mail.local.c
MAN= mail.local.8
CFLAGS+=-I${SENDMAIL_DIR}/include -I.
+
+WARNS?= 2
WFORMAT=0
LIBSMDIR= ${.OBJDIR}/../../lib/libsm
diff --git a/libexec/mknetid/Makefile b/libexec/mknetid/Makefile
index 6941b8f..5ca0662 100644
--- a/libexec/mknetid/Makefile
+++ b/libexec/mknetid/Makefile
@@ -5,4 +5,6 @@ SRCS= mknetid.c hash.c parse_group.c
MAN= netid.5 mknetid.8
+WARNS?= 2
+
.include <bsd.prog.mk>
diff --git a/libexec/pppoed/Makefile b/libexec/pppoed/Makefile
index 0f0c78e..1ffaffe 100644
--- a/libexec/pppoed/Makefile
+++ b/libexec/pppoed/Makefile
@@ -5,6 +5,7 @@ DPADD= ${LIBNETGRAPH}
LDADD= -lnetgraph
MAN= pppoed.8
+WARNS?= 1
WFORMAT=0
.include <bsd.prog.mk>
diff --git a/libexec/rbootd/Makefile b/libexec/rbootd/Makefile
index 3a4099e..70b6555 100644
--- a/libexec/rbootd/Makefile
+++ b/libexec/rbootd/Makefile
@@ -5,6 +5,7 @@ PROG= rbootd
SRCS= bpf.c conf.c parseconf.c rbootd.c rmpproto.c utils.c
MAN= rbootd.8
+WARNS?= 1
WFORMAT=0
.include <bsd.prog.mk>
diff --git a/libexec/revnetgroup/Makefile b/libexec/revnetgroup/Makefile
index 7088371..d3b36fa 100644
--- a/libexec/revnetgroup/Makefile
+++ b/libexec/revnetgroup/Makefile
@@ -5,4 +5,6 @@ SRCS= revnetgroup.c hash.c parse_netgroup.c
MAN= revnetgroup.8
+WARNS?= 2
+
.include <bsd.prog.mk>
diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c
index c4db3c7..5831a25 100644
--- a/libexec/rlogind/rlogind.c
+++ b/libexec/rlogind/rlogind.c
@@ -479,18 +479,7 @@ protocol(int f, int p)
void
cleanup(int signo)
{
- char *p;
-
- p = line + sizeof(_PATH_DEV) - 1;
- if (logout(p))
- logwtmp(p, "", "");
- (void)chflags(line, 0);
- (void)chmod(line, 0666);
- (void)chown(line, 0, 0);
- *p = 'p';
- (void)chflags(line, 0);
- (void)chmod(line, 0666);
- (void)chown(line, 0, 0);
+
shutdown(netf, SHUT_RDWR);
exit(1);
}
diff --git a/libexec/rpc.rquotad/Makefile b/libexec/rpc.rquotad/Makefile
index fb3f38bc..95d4415 100644
--- a/libexec/rpc.rquotad/Makefile
+++ b/libexec/rpc.rquotad/Makefile
@@ -4,8 +4,6 @@ PROG = rpc.rquotad
SRCS = rquotad.c
MAN = rpc.rquotad.8
-WARNS ?= 6
-
DPADD= ${LIBRPCSVC} ${LIBUTIL}
LDADD= -lrpcsvc -lutil
diff --git a/libexec/rpc.rstatd/Makefile b/libexec/rpc.rstatd/Makefile
index 1083447..a42225f 100644
--- a/libexec/rpc.rstatd/Makefile
+++ b/libexec/rpc.rstatd/Makefile
@@ -4,7 +4,9 @@ PROG = rpc.rstatd
SRCS = rstatd.c rstat_proc.c
MAN = rpc.rstatd.8
-DPADD= ${LIBRPCSVC} ${LIBUTIL} ${LIBDEVSTAT}
-LDADD= -lrpcsvc -lutil -ldevstat
+DPADD= ${LIBRPCSVC} ${LIBUTIL} ${LIBDEVSTAT} ${LIBKVM}
+LDADD= -lrpcsvc -lutil -ldevstat -lkvm
+
+WARNS?= 1
.include <bsd.prog.mk>
diff --git a/libexec/rpc.rusersd/Makefile b/libexec/rpc.rusersd/Makefile
index af43bd3..6305343 100644
--- a/libexec/rpc.rusersd/Makefile
+++ b/libexec/rpc.rusersd/Makefile
@@ -12,5 +12,4 @@ LDADD= -lrpcsvc -lutil
#LDADD+= -L/usr/X11R6/lib -lXext -lX11
#.endif
-
.include <bsd.prog.mk>
diff --git a/libexec/rpc.rusersd/rusers_proc.c b/libexec/rpc.rusersd/rusers_proc.c
index 8bd9692..6b34fa7 100644
--- a/libexec/rpc.rusersd/rusers_proc.c
+++ b/libexec/rpc.rusersd/rusers_proc.c
@@ -45,56 +45,28 @@ static const char rcsid[] =
#include <sys/stat.h>
#include <stdlib.h>
#include <syslog.h>
-#include <utmp.h>
+#include <utmpx.h>
#ifdef XIDLE
#include <setjmp.h>
#include <X11/Xlib.h>
#include <X11/extensions/xidle.h>
#endif
-#define utmp rutmp
#include <rpcsvc/rnusers.h>
-#undef utmp
-
-#define IGNOREUSER "sleeper"
-
-#ifdef OSF
-#define _PATH_UTMP UTMP_FILE
-#endif
-
-#ifndef _PATH_UTMP
-#define _PATH_UTMP "/etc/utmp"
-#endif
#ifndef _PATH_DEV
#define _PATH_DEV "/dev"
#endif
-#ifndef UT_LINESIZE
-#define UT_LINESIZE sizeof(((struct utmp *)0)->ut_line)
-#endif
-#ifndef UT_NAMESIZE
-#define UT_NAMESIZE sizeof(((struct utmp *)0)->ut_name)
-#endif
-#ifndef UT_HOSTSIZE
-#define UT_HOSTSIZE sizeof(((struct utmp *)0)->ut_host)
-#endif
-
-typedef char ut_line_t[UT_LINESIZE+1];
-typedef char ut_name_t[UT_NAMESIZE+1];
-typedef char ut_host_t[UT_HOSTSIZE+1];
-
-utmpidle utmp_idle[MAXUSERS];
-rutmp old_utmp[MAXUSERS];
-ut_line_t line[MAXUSERS];
-ut_name_t name[MAXUSERS];
-ut_host_t host[MAXUSERS];
+static utmpidle utmp_idle[MAXUSERS];
+static utmp old_utmp[MAXUSERS];
+static struct utmpx utmp_list[MAXUSERS];
extern int from_inetd;
-FILE *ufp;
+void rusers_service(struct svc_req *, SVCXPRT *);
#ifdef XIDLE
-Display *dpy;
+static Display *dpy;
static jmp_buf openAbort;
@@ -106,211 +78,187 @@ abortOpen(void)
XqueryIdle(char *display)
{
- int first_event, first_error;
- Time IdleTime;
-
- (void) signal (SIGALRM, abortOpen);
- (void) alarm ((unsigned) 10);
- if (!setjmp (openAbort)) {
- if (!(dpy= XOpenDisplay(display))) {
- syslog(LOG_ERR, "Cannot open display %s", display);
- return(-1);
- }
- if (XidleQueryExtension(dpy, &first_event, &first_error)) {
- if (!XGetIdleTime(dpy, &IdleTime)) {
- syslog(LOG_ERR, "%s: unable to get idle time", display);
- return(-1);
- }
- }
- else {
- syslog(LOG_ERR, "%s: Xidle extension not loaded", display);
- return(-1);
- }
- XCloseDisplay(dpy);
- }
- else {
- syslog(LOG_ERR, "%s: server grabbed for over 10 seconds", display);
- return(-1);
- }
- (void) signal (SIGALRM, SIG_DFL);
- (void) alarm ((unsigned) 0);
-
- IdleTime /= 1000;
- return((IdleTime + 30) / 60);
+ int first_event, first_error;
+ Time IdleTime;
+
+ (void) signal (SIGALRM, abortOpen);
+ (void) alarm ((unsigned) 10);
+ if (!setjmp (openAbort)) {
+ if (!(dpy= XOpenDisplay(display))) {
+ syslog(LOG_ERR, "Cannot open display %s", display);
+ return(-1);
+ }
+ if (XidleQueryExtension(dpy, &first_event, &first_error)) {
+ if (!XGetIdleTime(dpy, &IdleTime)) {
+ syslog(LOG_ERR, "%s: unable to get idle time", display);
+ return(-1);
+ }
+ } else {
+ syslog(LOG_ERR, "%s: Xidle extension not loaded", display);
+ return(-1);
+ }
+ XCloseDisplay(dpy);
+ } else {
+ syslog(LOG_ERR, "%s: server grabbed for over 10 seconds", display);
+ return(-1);
+ }
+ (void) signal (SIGALRM, SIG_DFL);
+ (void) alarm ((unsigned) 0);
+
+ IdleTime /= 1000;
+ return((IdleTime + 30) / 60);
}
#endif
static u_int
-getidle(char *tty, char *display)
+getidle(const char *tty, const char *display __unused)
{
- struct stat st;
- char devname[PATH_MAX];
- time_t now;
- u_long idle;
-
- /*
- * If this is an X terminal or console, then try the
- * XIdle extension
- */
+ struct stat st;
+ char ttyname[PATH_MAX];
+ time_t now;
+ u_long idle;
+
+ /*
+ * If this is an X terminal or console, then try the
+ * XIdle extension
+ */
#ifdef XIDLE
- if (display && *display && (idle = XqueryIdle(display)) >= 0)
- return(idle);
+ if (display && *display && (idle = XqueryIdle(display)) >= 0)
+ return(idle);
#endif
- idle = 0;
- if (*tty == 'X') {
- u_long kbd_idle, mouse_idle;
+ idle = 0;
+ if (*tty == 'X') {
+ u_long kbd_idle, mouse_idle;
#if !defined(__FreeBSD__)
- kbd_idle = getidle("kbd", NULL);
+ kbd_idle = getidle("kbd", NULL);
#else
- kbd_idle = getidle("vga", NULL);
+ kbd_idle = getidle("vga", NULL);
#endif
- mouse_idle = getidle("mouse", NULL);
- idle = (kbd_idle < mouse_idle)?kbd_idle:mouse_idle;
- }
- else {
- sprintf(devname, "%s/%s", _PATH_DEV, tty);
- if (stat(devname, &st) < 0) {
+ mouse_idle = getidle("mouse", NULL);
+ idle = (kbd_idle < mouse_idle)?kbd_idle:mouse_idle;
+ } else {
+ sprintf(ttyname, "%s/%s", _PATH_DEV, tty);
+ if (stat(ttyname, &st) < 0) {
#ifdef DEBUG
- printf("%s: %s\n", devname, strerror(errno));
+ printf("%s: %s\n", ttyname, strerror(errno));
#endif
- return(-1);
- }
- time(&now);
+ return(-1);
+ }
+ time(&now);
#ifdef DEBUG
- printf("%s: now=%d atime=%d\n", devname, now,
- st.st_atime);
+ printf("%s: now=%d atime=%d\n", ttyname, now,
+ st.st_atime);
#endif
- idle = now - st.st_atime;
- idle = (idle + 30) / 60; /* secs->mins */
- }
- if (idle < 0) idle = 0;
+ idle = now - st.st_atime;
+ idle = (idle + 30) / 60; /* secs->mins */
+ }
- return(idle);
+ return(idle);
}
static utmpidlearr *
-do_names_2(int all)
+do_names_2(void)
{
- static utmpidlearr ut;
- struct utmp usr;
- int nusers = 0;
-
- bzero((char *)&ut, sizeof(ut));
- ut.utmpidlearr_val = &utmp_idle[0];
-
- ufp = fopen(_PATH_UTMP, "r");
- if (!ufp) {
- syslog(LOG_ERR, "%m");
- return(&ut);
- }
-
- /* only entries with both name and line fields */
- while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1 &&
- nusers < MAXUSERS)
- if (*usr.ut_name && *usr.ut_line &&
- strncmp(usr.ut_name, IGNOREUSER,
- sizeof(usr.ut_name))
-#ifdef OSF
- && usr.ut_type == USER_PROCESS
-#endif
- ) {
- utmp_idle[nusers].ui_utmp.ut_time =
- usr.ut_time;
- utmp_idle[nusers].ui_idle =
- getidle(usr.ut_line, usr.ut_host);
- utmp_idle[nusers].ui_utmp.ut_line = line[nusers];
- strncpy(line[nusers], usr.ut_line, UT_LINESIZE);
- utmp_idle[nusers].ui_utmp.ut_name = name[nusers];
- strncpy(name[nusers], usr.ut_name, UT_NAMESIZE);
- utmp_idle[nusers].ui_utmp.ut_host = host[nusers];
- strncpy(host[nusers], usr.ut_host, UT_HOSTSIZE);
-
- /* Make sure entries are NUL terminated */
- line[nusers][UT_LINESIZE] =
- name[nusers][UT_NAMESIZE] =
- host[nusers][UT_HOSTSIZE] = '\0';
- nusers++;
- }
-
- ut.utmpidlearr_len = nusers;
- fclose(ufp);
- return(&ut);
+ static utmpidlearr ut;
+ struct utmpx *usr;
+ int nusers = 0;
+
+ memset(&ut, 0, sizeof(ut));
+ ut.utmpidlearr_val = &utmp_idle[0];
+
+ setutxent();
+ while ((usr = getutxent()) != NULL && nusers < MAXUSERS) {
+ if (usr->ut_type != USER_PROCESS)
+ continue;
+
+ memcpy(&utmp_list[nusers], usr, sizeof(*usr));
+ utmp_idle[nusers].ui_utmp.ut_time = usr->ut_tv.tv_sec;
+ utmp_idle[nusers].ui_idle =
+ getidle(usr->ut_line, usr->ut_host);
+ utmp_idle[nusers].ui_utmp.ut_line =
+ utmp_list[nusers].ut_line;
+ utmp_idle[nusers].ui_utmp.ut_name =
+ utmp_list[nusers].ut_user;
+ utmp_idle[nusers].ui_utmp.ut_host =
+ utmp_list[nusers].ut_host;
+
+ nusers++;
+ }
+ endutxent();
+
+ ut.utmpidlearr_len = nusers;
+ return(&ut);
}
-int *
-rusers_num(void)
+static int *
+rusers_num(void *argp __unused, struct svc_req *rqstp __unused)
{
- static int num_users = 0;
- struct utmp usr;
-
- ufp = fopen(_PATH_UTMP, "r");
- if (!ufp) {
- syslog(LOG_ERR, "%m");
- return(NULL);
- }
-
- /* only entries with both name and line fields */
- while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
- if (*usr.ut_name && *usr.ut_line &&
- strncmp(usr.ut_name, IGNOREUSER,
- sizeof(usr.ut_name))
-#ifdef OSF
- && usr.ut_type == USER_PROCESS
-#endif
- ) {
- num_users++;
- }
-
- fclose(ufp);
- return(&num_users);
+ static int num_users = 0;
+ struct utmpx *usr;
+
+ setutxent();
+ while ((usr = getutxent()) != NULL) {
+ if (usr->ut_type != USER_PROCESS)
+ continue;
+ num_users++;
+ }
+ endutxent();
+
+ return(&num_users);
}
static utmparr *
-do_names_1(int all)
+do_names_1(void)
{
- utmpidlearr *utidle;
- static utmparr ut;
- int i;
+ utmpidlearr *utidle;
+ static utmparr ut;
+ unsigned int i;
- bzero((char *)&ut, sizeof(ut));
+ bzero((char *)&ut, sizeof(ut));
- utidle = do_names_2(all);
- if (utidle) {
- ut.utmparr_len = utidle->utmpidlearr_len;
- ut.utmparr_val = &old_utmp[0];
- for (i = 0; i < ut.utmparr_len; i++)
- bcopy(&utmp_idle[i].ui_utmp, &old_utmp[i],
- sizeof(old_utmp[0]));
+ utidle = do_names_2();
+ if (utidle) {
+ ut.utmparr_len = utidle->utmpidlearr_len;
+ ut.utmparr_val = &old_utmp[0];
+ for (i = 0; i < ut.utmparr_len; i++)
+ bcopy(&utmp_idle[i].ui_utmp, &old_utmp[i],
+ sizeof(old_utmp[0]));
- }
+ }
- return(&ut);
+ return(&ut);
}
utmpidlearr *
-rusersproc_names_2_svc(void *argp, struct svc_req *rqstp)
+rusersproc_names_2_svc(void *argp __unused, struct svc_req *rqstp __unused)
{
- return(do_names_2(0));
+
+ return (do_names_2());
}
utmpidlearr *
-rusersproc_allnames_2_svc(void *argp, struct svc_req *rqstp)
+rusersproc_allnames_2_svc(void *argp __unused, struct svc_req *rqstp __unused)
{
- return(do_names_2(1));
+
+ return (do_names_2());
}
utmparr *
-rusersproc_names_1_svc(void *argp, struct svc_req *rqstp)
+rusersproc_names_1_svc(void *argp __unused, struct svc_req *rqstp __unused)
{
- return(do_names_1(0));
+
+ return (do_names_1());
}
utmparr *
-rusersproc_allnames_1_svc(void *argp, struct svc_req *rqstp)
+rusersproc_allnames_1_svc(void *argp __unused, struct svc_req *rqstp __unused)
{
- return(do_names_1(1));
+
+ return (do_names_1());
}
+typedef void *(*rusersproc_t)(void *, struct svc_req *);
+
void
rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
{
@@ -318,8 +266,8 @@ rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
int fill;
} argument;
char *result;
- bool_t (*xdr_argument)(), (*xdr_result)();
- char *(*local)();
+ xdrproc_t xdr_argument, xdr_result;
+ rusersproc_t local;
switch (rqstp->rq_proc) {
case NULLPROC:
@@ -327,43 +275,43 @@ rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
goto leave;
case RUSERSPROC_NUM:
- xdr_argument = xdr_void;
- xdr_result = xdr_int;
- local = (char *(*)()) rusers_num;
+ xdr_argument = (xdrproc_t)xdr_void;
+ xdr_result = (xdrproc_t)xdr_int;
+ local = (rusersproc_t)rusers_num;
break;
case RUSERSPROC_NAMES:
- xdr_argument = xdr_void;
- xdr_result = xdr_utmpidlearr;
- switch (rqstp->rq_vers) {
- case RUSERSVERS_ORIG:
- local = (char *(*)()) rusersproc_names_1_svc;
- break;
- case RUSERSVERS_IDLE:
- local = (char *(*)()) rusersproc_names_2_svc;
- break;
- default:
- svcerr_progvers(transp, RUSERSVERS_ORIG, RUSERSVERS_IDLE);
- goto leave;
- /*NOTREACHED*/
- }
+ xdr_argument = (xdrproc_t)xdr_void;
+ xdr_result = (xdrproc_t)xdr_utmpidlearr;
+ switch (rqstp->rq_vers) {
+ case RUSERSVERS_ORIG:
+ local = (rusersproc_t)rusersproc_names_1_svc;
+ break;
+ case RUSERSVERS_IDLE:
+ local = (rusersproc_t)rusersproc_names_2_svc;
+ break;
+ default:
+ svcerr_progvers(transp, RUSERSVERS_ORIG, RUSERSVERS_IDLE);
+ goto leave;
+ /*NOTREACHED*/
+ }
break;
case RUSERSPROC_ALLNAMES:
- xdr_argument = xdr_void;
- xdr_result = xdr_utmpidlearr;
- switch (rqstp->rq_vers) {
- case RUSERSVERS_ORIG:
- local = (char *(*)()) rusersproc_allnames_1_svc;
- break;
- case RUSERSVERS_IDLE:
- local = (char *(*)()) rusersproc_allnames_2_svc;
- break;
- default:
- svcerr_progvers(transp, RUSERSVERS_ORIG, RUSERSVERS_IDLE);
- goto leave;
- /*NOTREACHED*/
- }
+ xdr_argument = (xdrproc_t)xdr_void;
+ xdr_result = (xdrproc_t)xdr_utmpidlearr;
+ switch (rqstp->rq_vers) {
+ case RUSERSVERS_ORIG:
+ local = (rusersproc_t)rusersproc_allnames_1_svc;
+ break;
+ case RUSERSVERS_IDLE:
+ local = (rusersproc_t)rusersproc_allnames_2_svc;
+ break;
+ default:
+ svcerr_progvers(transp, RUSERSVERS_ORIG, RUSERSVERS_IDLE);
+ goto leave;
+ /*NOTREACHED*/
+ }
break;
default:
@@ -385,6 +333,6 @@ rusers_service(struct svc_req *rqstp, SVCXPRT *transp)
exit(1);
}
leave:
- if (from_inetd)
- exit(0);
+ if (from_inetd)
+ exit(0);
}
diff --git a/libexec/rpc.rusersd/rusersd.c b/libexec/rpc.rusersd/rusersd.c
index 1835e8e..009bbfd 100644
--- a/libexec/rpc.rusersd/rusersd.c
+++ b/libexec/rpc.rusersd/rusersd.c
@@ -41,50 +41,48 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <signal.h>
#include <syslog.h>
-#define utmp rutmp
#include <rpcsvc/rnusers.h>
-#undef utmp
extern void rusers_service(struct svc_req *, SVCXPRT *);
int from_inetd = 1;
-void
+static void
cleanup(int sig __unused)
{
- (void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
- (void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL);
- exit(0);
+ (void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
+ (void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL);
+ exit(0);
}
int
-main(int argc, char *argv[])
+main(int argc __unused, char *argv[] __unused)
{
- SVCXPRT *transp;
+ SVCXPRT *transp = NULL; /* Keep compiler happy. */
int ok;
struct sockaddr_storage from;
socklen_t fromlen;
- /*
- * See if inetd started us
- */
+ /*
+ * See if inetd started us
+ */
fromlen = sizeof(from);
- if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
- from_inetd = 0;
- }
+ if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
+ from_inetd = 0;
+ }
- if (!from_inetd) {
- daemon(0, 0);
+ if (!from_inetd) {
+ daemon(0, 0);
- (void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
- (void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL);
+ (void) rpcb_unset(RUSERSPROG, RUSERSVERS_IDLE, NULL);
+ (void) rpcb_unset(RUSERSPROG, RUSERSVERS_ORIG, NULL);
(void) signal(SIGINT, cleanup);
(void) signal(SIGTERM, cleanup);
(void) signal(SIGHUP, cleanup);
- }
+ }
- openlog("rpc.rusersd", LOG_CONS|LOG_PID, LOG_DAEMON);
+ openlog("rpc.rusersd", LOG_CONS|LOG_PID, LOG_DAEMON);
if (from_inetd) {
transp = svc_tli_create(0, NULL, NULL, 0, 0);
@@ -112,7 +110,7 @@ main(int argc, char *argv[])
exit(1);
}
- svc_run();
+ svc_run();
syslog(LOG_ERR, "svc_run returned");
exit(1);
}
diff --git a/libexec/rpc.rwalld/Makefile b/libexec/rpc.rwalld/Makefile
index 83182e9..b09d663 100644
--- a/libexec/rpc.rwalld/Makefile
+++ b/libexec/rpc.rwalld/Makefile
@@ -7,4 +7,6 @@ MAN = rpc.rwalld.8
DPADD= ${LIBUTIL}
LDADD= -lutil
+WARNS?= 2
+
.include <bsd.prog.mk>
diff --git a/libexec/rpc.sprayd/Makefile b/libexec/rpc.sprayd/Makefile
index 1dd582d..5b1cb24 100644
--- a/libexec/rpc.sprayd/Makefile
+++ b/libexec/rpc.sprayd/Makefile
@@ -7,5 +7,6 @@ MAN = rpc.sprayd.8
DPADD= ${LIBRPCSVC}
LDADD= -lrpcsvc
-.include <bsd.prog.mk>
+WARNS?= 2
+.include <bsd.prog.mk>
diff --git a/libexec/rshd/Makefile b/libexec/rshd/Makefile
index 155314a..f6881e8 100644
--- a/libexec/rshd/Makefile
+++ b/libexec/rshd/Makefile
@@ -4,6 +4,7 @@
PROG= rshd
MAN= rshd.8
+WARNS?= 3
WFORMAT=0
DPADD= ${LIBUTIL} ${LIBPAM}
diff --git a/libexec/rtld-aout/shlib.c b/libexec/rtld-aout/shlib.c
index 39ec792..f2c74a4 100644
--- a/libexec/rtld-aout/shlib.c
+++ b/libexec/rtld-aout/shlib.c
@@ -82,8 +82,7 @@ add_search_dir(const char *name)
}
void
-add_search_path(path)
-char *path;
+add_search_path(char *path)
{
register char *cp, *dup;
@@ -98,7 +97,7 @@ char *path;
}
void
-std_search_path()
+std_search_path(void)
{
int i, n;
@@ -115,9 +114,7 @@ std_search_path()
*/
int
-getdewey(dewey, cp)
-int dewey[];
-char *cp;
+getdewey(int dewey[], char *cp)
{
int i, n;
@@ -142,9 +139,7 @@ char *cp;
* Return 0 if equal.
*/
int
-cmpndewey(d1, n1, d2, n2)
-int d1[], d2[];
-int n1, n2;
+cmpndewey(int d1[], int n1, int d2[], int n2)
{
register int i;
@@ -185,10 +180,7 @@ int n1, n2;
*/
char *
-findshlib(name, majorp, minorp, do_dot_a)
-char *name;
-int *majorp, *minorp;
-int do_dot_a;
+findshlib(char *name, int *majorp, int *minorp, int do_dot_a)
{
int i;
@@ -212,8 +204,7 @@ int do_dot_a;
*/
char *
-find_lib_file(name)
- const char *name;
+find_lib_file(const char *name)
{
int i;
@@ -261,12 +252,7 @@ find_lib_file(name)
*/
char *
-search_lib_dir(dir, name, majorp, minorp, do_dot_a)
- char *dir;
- char *name;
- int *majorp;
- int *minorp;
- int do_dot_a;
+search_lib_dir(char *dir, char *name, int *majorp, int *minorp, int do_dot_a)
{
size_t namelen;
DIR *dd;
diff --git a/libexec/rtld-aout/support.c b/libexec/rtld-aout/support.c
index 71a84ff..eb8bd29 100644
--- a/libexec/rtld-aout/support.c
+++ b/libexec/rtld-aout/support.c
@@ -38,8 +38,7 @@
#include "support.h"
char *
-concat(s1, s2, s3)
- const char *s1, *s2, *s3;
+concat(const char *s1, const char *s2, const char *s3)
{
int len = 1;
char *s;
@@ -61,8 +60,7 @@ concat(s1, s2, s3)
}
void *
-xmalloc(n)
- size_t n;
+xmalloc(size_t n)
{
char *p = malloc(n);
@@ -73,9 +71,7 @@ xmalloc(n)
}
void *
-xrealloc(p, n)
- void *p;
- size_t n;
+xrealloc(void *p, size_t n)
{
p = realloc(p, n);
diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index 5e9729c..d6df617 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -12,6 +12,7 @@ CSTD?= gnu99
CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD
CFLAGS+= -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR}
LDFLAGS+= -nostdlib -e .rtld_start
+WARNS?= 2
INSTALLFLAGS= -C -b
PRECIOUSPROG=
BINDIR= /libexec
diff --git a/libexec/rtld-elf/arm/rtld_start.S b/libexec/rtld-elf/arm/rtld_start.S
index da22c57..b9de767 100644
--- a/libexec/rtld-elf/arm/rtld_start.S
+++ b/libexec/rtld-elf/arm/rtld_start.S
@@ -15,13 +15,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index 6de0c9e..d231830 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -273,7 +273,7 @@ get_elf_header (int fd, const char *path)
} u;
ssize_t nbytes;
- if ((nbytes = read(fd, u.buf, PAGE_SIZE)) == -1) {
+ if ((nbytes = pread(fd, u.buf, PAGE_SIZE, 0)) == -1) {
_rtld_error("%s: read error: %s", path, strerror(errno));
return NULL;
}
diff --git a/libexec/rtld-elf/powerpc/reloc.c b/libexec/rtld-elf/powerpc/reloc.c
index 2252428..ccdcd90 100644
--- a/libexec/rtld-elf/powerpc/reloc.c
+++ b/libexec/rtld-elf/powerpc/reloc.c
@@ -47,6 +47,13 @@
((u_int32_t)(x) + 0x10000) : (u_int32_t)(x)) >> 16)
#define _ppc_la(x) ((u_int32_t)(x) & 0xffff)
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#define PLT_EXTENDED_BEGIN (1 << 13)
+#define JMPTAB_BASE(N) (18 + N*2 + ((N > PLT_EXTENDED_BEGIN) ? \
+ (N - PLT_EXTENDED_BEGIN)*2 : 0))
+
/*
* Process the R_PPC_COPY relocations
*/
@@ -313,7 +320,6 @@ done:
return (r);
}
-
/*
* Initialise a PLT slot to the resolving trampoline
*/
@@ -321,27 +327,43 @@ static int
reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela)
{
Elf_Word *where = (Elf_Word *)(obj->relocbase + rela->r_offset);
- Elf_Addr *pltresolve;
+ Elf_Addr *pltresolve, *pltlongresolve, *jmptab;
Elf_Addr distance;
+ int N = obj->pltrelasize / sizeof(Elf_Rela);
int reloff;
reloff = rela - obj->pltrela;
- if ((reloff < 0) || (reloff >= 0x8000)) {
+ if (reloff < 0)
return (-1);
- }
- pltresolve = obj->pltgot + 8;
+ pltlongresolve = obj->pltgot + 5;
+ pltresolve = pltlongresolve + 5;
distance = (Elf_Addr)pltresolve - (Elf_Addr)(where + 1);
dbg(" reloc_plt_object: where=%p,pltres=%p,reloff=%x,distance=%x",
(void *)where, (void *)pltresolve, reloff, distance);
- /* li r11,reloff */
- /* b pltresolve */
- where[0] = 0x39600000 | reloff;
- where[1] = 0x48000000 | (distance & 0x03fffffc);
+ if (reloff < PLT_EXTENDED_BEGIN) {
+ /* li r11,reloff */
+ /* b pltresolve */
+ where[0] = 0x39600000 | reloff;
+ where[1] = 0x48000000 | (distance & 0x03fffffc);
+ } else {
+ jmptab = obj->pltgot + JMPTAB_BASE(N);
+ jmptab[reloff] = (u_int)pltlongresolve;
+
+ /* lis r11,jmptab[reloff]@ha */
+ /* lwzu r12,jmptab[reloff]@l(r11) */
+ /* mtctr r12 */
+ /* bctr */
+ where[0] = 0x3d600000 | _ppc_ha(&jmptab[reloff]);
+ where[1] = 0x858b0000 | _ppc_la(&jmptab[reloff]);
+ where[2] = 0x7d8903a6;
+ where[3] = 0x4e800420;
+ }
+
/*
* The icache will be sync'd in init_pltgot, which is called
@@ -453,25 +475,28 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
int N = obj->pltrelasize / sizeof(Elf_Rela);
int reloff = rela - obj->pltrela;
- if ((reloff < 0) || (reloff >= 0x8000)) {
+ if (reloff < 0)
return (-1);
- }
pltcall = obj->pltgot;
- dbg(" reloc_jmpslot: indir, reloff=%d, N=%d\n",
+ dbg(" reloc_jmpslot: indir, reloff=%x, N=%x\n",
reloff, N);
- jmptab = obj->pltgot + 18 + N * 2;
+ jmptab = obj->pltgot + JMPTAB_BASE(N);
jmptab[reloff] = target;
- distance = (Elf_Addr)pltcall - (Elf_Addr)(wherep + 1);
+ if (reloff < PLT_EXTENDED_BEGIN) {
+ /* for extended PLT entries, we keep the old code */
+
+ distance = (Elf_Addr)pltcall - (Elf_Addr)(wherep + 1);
- /* li r11,reloff */
- /* b pltcall # use indirect pltcall routine */
- wherep[0] = 0x39600000 | reloff;
- wherep[1] = 0x48000000 | (distance & 0x03fffffc);
- __syncicache(wherep, 8);
+ /* li r11,reloff */
+ /* b pltcall # use indirect pltcall routine */
+ wherep[0] = 0x39600000 | reloff;
+ wherep[1] = 0x48000000 | (distance & 0x03fffffc);
+ __syncicache(wherep, 8);
+ }
}
return (target);
@@ -481,13 +506,14 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj,
/*
* Setup the plt glue routines.
*/
-#define PLTCALL_SIZE 20
-#define PLTRESOLVE_SIZE 24
+#define PLTCALL_SIZE 20
+#define PLTLONGRESOLVE_SIZE 20
+#define PLTRESOLVE_SIZE 24
void
init_pltgot(Obj_Entry *obj)
{
- Elf_Word *pltcall, *pltresolve;
+ Elf_Word *pltcall, *pltresolve, *pltlongresolve;
Elf_Word *jmptab;
int N = obj->pltrelasize / sizeof(Elf_Rela);
@@ -524,18 +550,27 @@ init_pltgot(Obj_Entry *obj)
* of the jumptable into the absolute-call assembler code so it
* can determine this address.
*/
- jmptab = pltcall + 18 + N * 2;
+ jmptab = obj->pltgot + JMPTAB_BASE(N);
pltcall[1] |= _ppc_ha(jmptab); /* addis 11,11,jmptab@ha */
pltcall[2] |= _ppc_la(jmptab); /* lwz 11,jmptab@l(11) */
/*
- * Skip down 32 bytes into the initial reserved area and copy
+ * Skip down 20 bytes into the initial reserved area and copy
* in the standard resolving assembler call. Into this assembler,
* insert the absolute address of the _rtld_bind_start routine
* and the address of the relocation object.
+ *
+ * We place pltlongresolve first, so it can fix up its arguments
+ * and then fall through to the regular PLT resolver.
*/
- pltresolve = obj->pltgot + 8;
+ pltlongresolve = obj->pltgot + 5;
+
+ memcpy(pltlongresolve, _rtld_powerpc_pltlongresolve,
+ PLTLONGRESOLVE_SIZE);
+ pltlongresolve[0] |= _ppc_ha(jmptab); /* lis 12,jmptab@ha */
+ pltlongresolve[1] |= _ppc_la(jmptab); /* addi 12,12,jmptab@l */
+ pltresolve = pltlongresolve + PLTLONGRESOLVE_SIZE/sizeof(uint32_t);
memcpy(pltresolve, _rtld_powerpc_pltresolve, PLTRESOLVE_SIZE);
pltresolve[0] |= _ppc_ha(_rtld_bind_start);
pltresolve[1] |= _ppc_la(_rtld_bind_start);
diff --git a/libexec/rtld-elf/powerpc/rtld_machdep.h b/libexec/rtld-elf/powerpc/rtld_machdep.h
index f5f21a4..bf589c5 100644
--- a/libexec/rtld-elf/powerpc/rtld_machdep.h
+++ b/libexec/rtld-elf/powerpc/rtld_machdep.h
@@ -57,6 +57,7 @@ void _rtld_bind_start(void);
* PLT functions. Not really correct prototypes, but the
* symbol values are needed.
*/
+void _rtld_powerpc_pltlongresolve(void);
void _rtld_powerpc_pltresolve(void);
void _rtld_powerpc_pltcall(void);
diff --git a/libexec/rtld-elf/powerpc/rtld_start.S b/libexec/rtld-elf/powerpc/rtld_start.S
index 86f76e6..00692d2 100644
--- a/libexec/rtld-elf/powerpc/rtld_start.S
+++ b/libexec/rtld-elf/powerpc/rtld_start.S
@@ -163,6 +163,12 @@ _ENTRY(_rtld_bind_start)
* The ELF object is shifted into %r11, and _rtld_bind_start is called
* to complete the binding.
*/
+_ENTRY(_rtld_powerpc_pltlongresolve)
+ lis %r12,0 # lis 12,jmptab@ha
+ addi %r12,%r12,0 # addi 12,12,jmptab@l
+ subf %r11,%r12,%r11 # reloff
+ li %r12,2
+ srw %r11,%r11,%r12 # index = reloff/sizeof(Elf_Addr)
_ENTRY(_rtld_powerpc_pltresolve)
lis %r12,0 # lis 12,_rtld_bind_start@ha
addi %r12,%r12,0 # addi 12,12,_rtld_bind_start@l
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 721fe89..d91dcee 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -87,7 +87,7 @@ static void die(void) __dead2;
static void digest_dynamic(Obj_Entry *, int);
static Obj_Entry *digest_phdr(const Elf_Phdr *, int, caddr_t, const char *);
static Obj_Entry *dlcheck(void *);
-static Obj_Entry *do_load_object(int, const char *, char *, struct stat *);
+static Obj_Entry *do_load_object(int, const char *, char *, struct stat *, int);
static int do_search_info(const Obj_Entry *obj, int, struct dl_serinfo *);
static bool donelist_check(DoneList *, const Obj_Entry *);
static void errmsg_restore(char *);
@@ -103,7 +103,7 @@ static void initlist_add_objects(Obj_Entry *, Obj_Entry **, Objlist *);
static bool is_exported(const Elf_Sym *);
static void linkmap_add(Obj_Entry *);
static void linkmap_delete(Obj_Entry *);
-static int load_needed_objects(Obj_Entry *);
+static int load_needed_objects(Obj_Entry *, int);
static int load_preload_objects(void);
static Obj_Entry *load_object(const char *, const Obj_Entry *, int);
static Obj_Entry *obj_from_addr(const void *);
@@ -366,12 +366,12 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
* future processes to honor the potentially un-safe variables.
*/
if (!trust) {
- unsetenv(LD_ "PRELOAD");
- unsetenv(LD_ "LIBMAP");
- unsetenv(LD_ "LIBRARY_PATH");
- unsetenv(LD_ "LIBMAP_DISABLE");
- unsetenv(LD_ "DEBUG");
- unsetenv(LD_ "ELF_HINTS_PATH");
+ if (unsetenv(LD_ "PRELOAD") || unsetenv(LD_ "LIBMAP") ||
+ unsetenv(LD_ "LIBRARY_PATH") || unsetenv(LD_ "LIBMAP_DISABLE") ||
+ unsetenv(LD_ "DEBUG") || unsetenv(LD_ "ELF_HINTS_PATH")) {
+ _rtld_error("environment corrupt; aborting");
+ die();
+ }
}
ld_debug = getenv(LD_ "DEBUG");
libmap_disable = getenv(LD_ "LIBMAP_DISABLE") != NULL;
@@ -474,6 +474,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
/* Initialize a fake symbol for resolving undefined weak references. */
sym_zero.st_info = ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE);
sym_zero.st_shndx = SHN_UNDEF;
+ sym_zero.st_value = -(uintptr_t)obj_main->relocbase;
if (!libmap_disable)
libmap_disable = (bool)lm_init(libmap_override);
@@ -484,7 +485,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
preload_tail = obj_tail;
dbg("loading needed objects");
- if (load_needed_objects(obj_main) == -1)
+ if (load_needed_objects(obj_main, 0) == -1)
die();
/* Make a list of all objects loaded at startup. */
@@ -897,7 +898,7 @@ digest_dynamic(Obj_Entry *obj, int early)
#endif
case DT_FLAGS:
- if ((dynp->d_un.d_val & DF_1_ORIGIN) && trust)
+ if ((dynp->d_un.d_val & DF_ORIGIN) && trust)
obj->z_origin = true;
if (dynp->d_un.d_val & DF_SYMBOLIC)
obj->symbolic = true;
@@ -931,6 +932,8 @@ digest_dynamic(Obj_Entry *obj, int early)
#endif
case DT_FLAGS_1:
+ if (dynp->d_un.d_val & DF_1_NOOPEN)
+ obj->z_noopen = true;
if ((dynp->d_un.d_val & DF_1_ORIGIN) && trust)
obj->z_origin = true;
if (dynp->d_un.d_val & DF_1_GLOBAL)
@@ -991,26 +994,26 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
obj = obj_new();
for (ph = phdr; ph < phlimit; ph++) {
- switch (ph->p_type) {
+ if (ph->p_type != PT_PHDR)
+ continue;
- case PT_PHDR:
- if ((const Elf_Phdr *)ph->p_vaddr != phdr) {
- _rtld_error("%s: invalid PT_PHDR", path);
- return NULL;
- }
- obj->phdr = (const Elf_Phdr *) ph->p_vaddr;
- obj->phsize = ph->p_memsz;
- break;
+ obj->phdr = phdr;
+ obj->phsize = ph->p_memsz;
+ obj->relocbase = (caddr_t)phdr - ph->p_vaddr;
+ break;
+ }
+
+ for (ph = phdr; ph < phlimit; ph++) {
+ switch (ph->p_type) {
case PT_INTERP:
- obj->interp = (const char *) ph->p_vaddr;
+ obj->interp = (const char *)(ph->p_vaddr + obj->relocbase);
break;
case PT_LOAD:
if (nsegs == 0) { /* First load segment */
obj->vaddrbase = trunc_page(ph->p_vaddr);
- obj->mapbase = (caddr_t) obj->vaddrbase;
- obj->relocbase = obj->mapbase - obj->vaddrbase;
+ obj->mapbase = obj->vaddrbase + obj->relocbase;
obj->textsize = round_page(ph->p_vaddr + ph->p_memsz) -
obj->vaddrbase;
} else { /* Last load segment */
@@ -1021,7 +1024,7 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
break;
case PT_DYNAMIC:
- obj->dynamic = (const Elf_Dyn *) ph->p_vaddr;
+ obj->dynamic = (const Elf_Dyn *)(ph->p_vaddr + obj->relocbase);
break;
case PT_TLS:
@@ -1029,7 +1032,7 @@ digest_phdr(const Elf_Phdr *phdr, int phnum, caddr_t entry, const char *path)
obj->tlssize = ph->p_memsz;
obj->tlsalign = ph->p_align;
obj->tlsinitsize = ph->p_filesz;
- obj->tlsinit = (void*) ph->p_vaddr;
+ obj->tlsinit = (void*)(ph->p_vaddr + obj->relocbase);
break;
}
}
@@ -1424,7 +1427,7 @@ is_exported(const Elf_Sym *def)
* returns -1 on failure.
*/
static int
-load_needed_objects(Obj_Entry *first)
+load_needed_objects(Obj_Entry *first, int flags)
{
Obj_Entry *obj, *obj1;
@@ -1433,7 +1436,7 @@ load_needed_objects(Obj_Entry *first)
for (needed = obj->needed; needed != NULL; needed = needed->next) {
obj1 = needed->obj = load_object(obj->strtab + needed->name, obj,
- false);
+ flags & ~RTLD_LO_NOLOAD);
if (obj1 == NULL && !ld_tracing)
return -1;
if (obj1 != NULL && obj1->z_nodelete && !obj1->ref_nodel) {
@@ -1464,7 +1467,7 @@ load_preload_objects(void)
savech = p[len];
p[len] = '\0';
- if (load_object(p, NULL, false) == NULL)
+ if (load_object(p, NULL, 0) == NULL)
return -1; /* XXX - cleanup */
p[len] = savech;
p += len;
@@ -1481,7 +1484,7 @@ load_preload_objects(void)
* on failure.
*/
static Obj_Entry *
-load_object(const char *name, const Obj_Entry *refobj, int noload)
+load_object(const char *name, const Obj_Entry *refobj, int flags)
{
Obj_Entry *obj;
int fd = -1;
@@ -1527,11 +1530,11 @@ load_object(const char *name, const Obj_Entry *refobj, int noload)
close(fd);
return obj;
}
- if (noload)
+ if (flags & RTLD_LO_NOLOAD)
return (NULL);
/* First use of this object, so we must map it in */
- obj = do_load_object(fd, name, path, &sb);
+ obj = do_load_object(fd, name, path, &sb, flags);
if (obj == NULL)
free(path);
close(fd);
@@ -1540,7 +1543,8 @@ load_object(const char *name, const Obj_Entry *refobj, int noload)
}
static Obj_Entry *
-do_load_object(int fd, const char *name, char *path, struct stat *sbp)
+do_load_object(int fd, const char *name, char *path, struct stat *sbp,
+ int flags)
{
Obj_Entry *obj;
struct statfs fs;
@@ -1567,6 +1571,14 @@ do_load_object(int fd, const char *name, char *path, struct stat *sbp)
object_add_name(obj, name);
obj->path = path;
digest_dynamic(obj, 0);
+ if (obj->z_noopen && (flags & (RTLD_LO_DLOPEN | RTLD_LO_TRACE)) ==
+ RTLD_LO_DLOPEN) {
+ dbg("refusing to load non-loadable \"%s\"", obj->path);
+ _rtld_error("Cannot dlopen non-loadable %s", obj->path);
+ munmap(obj->mapbase, obj->mapsize);
+ obj_free(obj);
+ return (NULL);
+ }
*obj_tail = obj;
obj_tail = &obj->next;
@@ -1985,14 +1997,18 @@ dlopen(const char *name, int mode)
Obj_Entry **old_obj_tail;
Obj_Entry *obj;
Objlist initlist;
- int result, lockstate, nodelete, noload;
+ int result, lockstate, nodelete, lo_flags;
LD_UTRACE(UTRACE_DLOPEN_START, NULL, NULL, 0, mode, name);
ld_tracing = (mode & RTLD_TRACE) == 0 ? NULL : "1";
if (ld_tracing != NULL)
environ = (char **)*get_program_var_addr("environ");
nodelete = mode & RTLD_NODELETE;
- noload = mode & RTLD_NOLOAD;
+ lo_flags = RTLD_LO_DLOPEN;
+ if (mode & RTLD_NOLOAD)
+ lo_flags |= RTLD_LO_NOLOAD;
+ if (ld_tracing != NULL)
+ lo_flags |= RTLD_LO_TRACE;
objlist_init(&initlist);
@@ -2005,7 +2021,7 @@ dlopen(const char *name, int mode)
obj = obj_main;
obj->refcount++;
} else {
- obj = load_object(name, obj_main, noload);
+ obj = load_object(name, obj_main, lo_flags);
}
if (obj) {
@@ -2015,7 +2031,7 @@ dlopen(const char *name, int mode)
mode &= RTLD_MODEMASK;
if (*old_obj_tail != NULL) { /* We loaded something new. */
assert(*old_obj_tail == obj);
- result = load_needed_objects(obj);
+ result = load_needed_objects(obj, RTLD_LO_DLOPEN);
init_dag(obj);
if (result != -1)
result = rtld_verify_versions(&obj->dagmembers);
@@ -3135,13 +3151,13 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
dtv[1] = tls_max_index;
for (obj = objs; obj; obj = obj->next) {
- if (obj->tlsoffset) {
+ if (obj->tlsoffset > 0) {
addr = (Elf_Addr)tls + obj->tlsoffset;
- memset((void*) (addr + obj->tlsinitsize),
- 0, obj->tlssize - obj->tlsinitsize);
- if (obj->tlsinit)
- memcpy((void*) addr, obj->tlsinit,
- obj->tlsinitsize);
+ if (obj->tlsinitsize > 0)
+ memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize);
+ if (obj->tlssize > obj->tlsinitsize)
+ memset((void*) (addr + obj->tlsinitsize), 0,
+ obj->tlssize - obj->tlsinitsize);
dtv[obj->tlsindex + 1] = addr;
}
}
@@ -3341,21 +3357,18 @@ allocate_tls_offset(Obj_Entry *obj)
void
free_tls_offset(Obj_Entry *obj)
{
-#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) || \
- defined(__arm__) || defined(__mips__)
+
/*
* If we were the last thing to allocate out of the static TLS
* block, we give our space back to the 'allocator'. This is a
* simplistic workaround to allow libGL.so.1 to be loaded and
- * unloaded multiple times. We only handle the Variant II
- * mechanism for now - this really needs a proper allocator.
+ * unloaded multiple times.
*/
if (calculate_tls_end(obj->tlsoffset, obj->tlssize)
== calculate_tls_end(tls_last_offset, tls_last_size)) {
tls_last_offset -= obj->tlssize;
tls_last_size = 0;
}
-#endif
}
void *
@@ -3424,7 +3437,7 @@ locate_dependency(const Obj_Entry *obj, const char *name)
if (object_match_name(needed->obj, name))
return needed->obj;
}
- _rtld_error("%s: Unexpected inconsistency: dependency %s not found",
+ _rtld_error("%s: Unexpected inconsistency: dependency %s not found",
obj->path, name);
die();
}
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index 06086b4..875e84b 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -218,6 +218,7 @@ typedef struct Struct_Obj_Entry {
bool phdr_alloc : 1; /* Phdr is allocated and needs to be freed. */
bool z_origin : 1; /* Process rpath and soname tokens */
bool z_nodelete : 1; /* Do not unload the object and dependencies */
+ bool z_noopen : 1; /* Do not load on dlopen */
bool ref_nodel : 1; /* Refcount increased to prevent dlclose */
bool init_scanned: 1; /* Object is already on init list. */
bool on_fini_list: 1; /* Object is already on fini list. */
@@ -240,6 +241,11 @@ typedef struct Struct_Obj_Entry {
#define SYMLOOK_DLSYM 0x02 /* Return newes versioned symbol. Used by
dlsym. */
+/* Flags for load_object(). */
+#define RTLD_LO_NOLOAD 0x01 /* dlopen() specified RTLD_NOLOAD. */
+#define RTLD_LO_DLOPEN 0x02 /* Load_object() called from dlopen(). */
+#define RTLD_LO_TRACE 0x04 /* Only tracing. */
+
/*
* Symbol cache entry used during relocation to avoid multiple lookups
* of the same symbol.
diff --git a/libexec/smrsh/Makefile b/libexec/smrsh/Makefile
index 6fd2801..ae86155 100644
--- a/libexec/smrsh/Makefile
+++ b/libexec/smrsh/Makefile
@@ -15,6 +15,8 @@ LIBSM= ${LIBSMDIR}/libsm.a
DPADD= ${LIBSM}
LDADD= ${LIBSM}
+WARNS?= 2
+
SRCS+= sm_os.h
CLEANFILES+=sm_os.h
diff --git a/libexec/talkd/Makefile b/libexec/talkd/Makefile
index aa6df1b..cc0c597 100644
--- a/libexec/talkd/Makefile
+++ b/libexec/talkd/Makefile
@@ -6,6 +6,5 @@ SRCS= talkd.c announce.c process.c table.c print.c ttymsg.c
.PATH: ${.CURDIR}/../../usr.bin/wall
MAN= talkd.8
CFLAGS+=-I${.CURDIR}/../../usr.bin/wall
-WFORMAT=0
.include <bsd.prog.mk>
diff --git a/libexec/talkd/process.c b/libexec/talkd/process.c
index d77f8a1..18ddc42 100644
--- a/libexec/talkd/process.c
+++ b/libexec/talkd/process.c
@@ -59,6 +59,7 @@ static const char rcsid[] =
#include <stdio.h>
#include <string.h>
#include <syslog.h>
+#include <utmpx.h>
#include "extern.h"
@@ -153,8 +154,8 @@ do_announce(CTL_MSG *mp, CTL_RESPONSE *rp)
rp->answer = result;
return;
}
-#define satosin(sa) ((struct sockaddr_in *)(sa))
- hp = gethostbyaddr((char *)&satosin(&mp->ctl_addr)->sin_addr,
+#define satosin(sa) ((struct sockaddr_in *)(void *)(sa))
+ hp = gethostbyaddr(&satosin(&mp->ctl_addr)->sin_addr,
sizeof (struct in_addr), AF_INET);
if (hp == (struct hostent *)0) {
rp->answer = MACHINE_UNKNOWN;
@@ -181,55 +182,46 @@ do_announce(CTL_MSG *mp, CTL_RESPONSE *rp)
}
}
-#include <utmp.h>
-
/*
* Search utmp for the local user
*/
int
find_user(const char *name, char *tty)
{
- struct utmp ubuf;
+ struct utmpx *ut;
int status;
- FILE *fd;
struct stat statb;
time_t best = 0;
- char line[sizeof(ubuf.ut_line) + 1];
- char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)];
+ char ftty[sizeof(_PATH_DEV) - 1 + sizeof(ut->ut_line)];
- if ((fd = fopen(_PATH_UTMP, "r")) == NULL) {
- warnx("can't read %s", _PATH_UTMP);
- return (FAILED);
- }
-#define SCMPN(a, b) strncmp(a, b, sizeof (a))
+ setutxent();
status = NOT_HERE;
(void) strcpy(ftty, _PATH_DEV);
- while (fread((char *) &ubuf, sizeof ubuf, 1, fd) == 1)
- if (SCMPN(ubuf.ut_name, name) == 0) {
- strncpy(line, ubuf.ut_line, sizeof(ubuf.ut_line));
- line[sizeof(ubuf.ut_line)] = '\0';
+ while ((ut = getutxent()) != NULL)
+ if (ut->ut_type == USER_PROCESS &&
+ strcmp(ut->ut_user, name) == 0) {
if (*tty == '\0' || best != 0) {
if (best == 0)
status = PERMISSION_DENIED;
/* no particular tty was requested */
(void) strcpy(ftty + sizeof(_PATH_DEV) - 1,
- line);
+ ut->ut_line);
if (stat(ftty, &statb) == 0) {
if (!(statb.st_mode & 020))
continue;
if (statb.st_atime > best) {
best = statb.st_atime;
- (void) strcpy(tty, line);
+ (void) strcpy(tty, ut->ut_line);
status = SUCCESS;
continue;
}
}
}
- if (strcmp(line, tty) == 0) {
+ if (strcmp(ut->ut_line, tty) == 0) {
status = SUCCESS;
break;
}
}
- fclose(fd);
+ endutxent();
return (status);
}
diff --git a/libexec/tcpd/Makefile b/libexec/tcpd/Makefile
index 6bb6080..e707a4e 100644
--- a/libexec/tcpd/Makefile
+++ b/libexec/tcpd/Makefile
@@ -18,4 +18,6 @@ CFLAGS+=-DINET6
DPADD= ${LIBWRAP}
LDADD= -lwrap
+WARNS?= 1
+
.include <bsd.prog.mk>
diff --git a/libexec/tftp-proxy/Makefile b/libexec/tftp-proxy/Makefile
index 45d8068..d8541c4 100644
--- a/libexec/tftp-proxy/Makefile
+++ b/libexec/tftp-proxy/Makefile
@@ -6,4 +6,6 @@ PROG= tftp-proxy
SRCS= tftp-proxy.c filter.c
MAN= tftp-proxy.8
+WARNS?= 3
+
.include <bsd.prog.mk>
diff --git a/libexec/tftpd/Makefile b/libexec/tftpd/Makefile
index 6036d4c..6c29243 100644
--- a/libexec/tftpd/Makefile
+++ b/libexec/tftpd/Makefile
@@ -5,7 +5,10 @@ PROG= tftpd
SRCS= tftpd.c tftpsubs.c
DPADD= ${LIBUTIL}
LDADD= -lutil
+
+WARNS?= 1
WFORMAT=0
+
MAN= tftpd.8
CFLAGS+=-I${.CURDIR}/../../usr.bin/tftp
.PATH: ${.CURDIR}/../../usr.bin/tftp
diff --git a/libexec/ulog-helper/Makefile b/libexec/ulog-helper/Makefile
new file mode 100644
index 0000000..3c1770c
--- /dev/null
+++ b/libexec/ulog-helper/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+PROG= ulog-helper
+BINOWN= root
+BINMODE=4555
+NO_MAN=
+
+DPADD= ${LIBULOG} ${LIBMD}
+LDADD= -lulog -lmd
+
+.include <bsd.prog.mk>
diff --git a/libexec/ulog-helper/ulog-helper.c b/libexec/ulog-helper/ulog-helper.c
new file mode 100644
index 0000000..eaef778
--- /dev/null
+++ b/libexec/ulog-helper/ulog-helper.c
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <pwd.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <ulog.h>
+
+/*
+ * This setuid helper utility writes user login records to disk.
+ * Unprivileged processes are not capable of writing records to utmp,
+ * wtmp and lastlog, but we do want to allow this for pseudo-terminals.
+ * Because a file descriptor to a pseudo-terminal master device can only
+ * be obtained by processes using the pseudo-terminal, we expect such a
+ * descriptor on stdin.
+ *
+ * It uses the real user ID of the calling process to determine the
+ * username. It does allow users to log arbitrary hostnames.
+ */
+
+int
+main(int argc, char *argv[])
+{
+ const char *line;
+
+ /* Device line name. */
+ if ((line = ptsname(STDIN_FILENO)) == NULL)
+ return (EX_USAGE);
+
+ if ((argc == 2 || argc == 3) && strcmp(argv[1], "login") == 0) {
+ struct passwd *pwd;
+ const char *host = NULL;
+
+ /* Username. */
+ pwd = getpwuid(getuid());
+ if (pwd == NULL)
+ return (EX_OSERR);
+
+ /* Hostname. */
+ if (argc == 3)
+ host = argv[2];
+
+ ulog_login(line, pwd->pw_name, host);
+ return (EX_OK);
+ } else if (argc == 2 && strcmp(argv[1], "logout") == 0) {
+ ulog_logout(line);
+ return (EX_OK);
+ }
+
+ return (EX_USAGE);
+}
diff --git a/libexec/ypxfr/Makefile b/libexec/ypxfr/Makefile
index 72978eb..91a42ef 100644
--- a/libexec/ypxfr/Makefile
+++ b/libexec/ypxfr/Makefile
@@ -12,7 +12,10 @@ GENSRCS=yp.h yp_clnt.c ypxfr_clnt.c
MAN= ypxfr.8
CFLAGS+= -I.
+
+WARNS?= 2
WFORMAT=0
+
DPADD= ${LIBRPCSVC}
LDADD= -lrpcsvc
OpenPOWER on IntegriCloud