diff --git a/contrib/sendmail/src/conf.h b/contrib/sendmail/src/conf.h index c748bf3e7cd5..f87b204962bc 100644 --- a/contrib/sendmail/src/conf.h +++ b/contrib/sendmail/src/conf.h @@ -968,7 +968,11 @@ typedef int pid_t; # if __FreeBSD__ >= 2 # include # if __FreeBSD_version >= 199512 /* 2.2-current when it appeared */ -# include +# if __FreeBSD_version >= 500012 /* Moved to libc in 5.0-current */ +# include +# else +# include +# endif # define SPT_TYPE SPT_BUILTIN # endif /* __FreeBSD_version >= 199512 */ # if __FreeBSD_version >= 222000 /* 2.2.2-release and later */ diff --git a/include/unistd.h b/include/unistd.h index 274c98d9b7d5..d859e9a232c5 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -96,6 +96,7 @@ ssize_t read __P((int, void *, size_t)); int rmdir __P((const char *)); int setgid __P((gid_t)); int setpgid __P((pid_t, pid_t)); +void setproctitle __P((const char *_fmt, ...)) __printf0like(1, 2); pid_t setsid __P((void)); int setuid __P((uid_t)); unsigned int sleep __P((unsigned int)); diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 4cde661ae25d..9d5452a98603 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -22,8 +22,8 @@ SRCS+= _rand48.c _spinlock_stub.c alarm.c arc4random.c assert.c \ pause.c popen.c psignal.c pwcache.c raise.c readdir.c rewinddir.c \ posixshm.c \ scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ - setdomainname.c sethostname.c setjmperr.c setmode.c shmat.c \ - shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \ + setdomainname.c sethostname.c setjmperr.c setmode.c setproctitle.c \ + shmat.c shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \ sigsetops.c sleep.c srand48.c stringlist.c strtofflags.c \ sysconf.c sysctl.c sysctlbyname.c \ syslog.c telldir.c termios.c time.c times.c timezone.c ttyname.c \ @@ -49,7 +49,7 @@ MAN3+= alarm.3 arc4random.3 clock.3 \ ldexp.3 lockf.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ nice.3 nlist.3 pause.3 popen.3 psignal.3 pwcache.3 \ raise.3 rand48.3 rfork_thread.3 \ - scandir.3 setjmp.3 setmode.3 shm_open.3 \ + scandir.3 setjmp.3 setmode.3 setproctitle.3 shm_open.3 \ siginterrupt.3 signal.3 sigsetops.3 sleep.3 stringlist.3 \ strtofflags.3 sysconf.3 sysctl.3 syslog.3 tcgetpgrp.3 \ tcsendbreak.3 tcsetattr.3 tcsetpgrp.3 time.3 times.3 timezone.3 \ diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index 2ca6ddf7c5d0..70fd9d2b8e98 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -6,14 +6,14 @@ SHLIB_MAJOR= 3 SHLIB_MINOR= 0 CFLAGS+=-Wall -DLIBC_SCCS -I${.CURDIR} -I${.CURDIR}/../../sys CFLAGS+=-DINET6 -SRCS= login.c login_tty.c logout.c logwtmp.c pty.c setproctitle.c \ +SRCS= login.c login_tty.c logout.c logwtmp.c pty.c \ login_cap.c login_class.c login_auth.c login_times.c login_ok.c \ login_crypt.c _secure_path.c uucplock.c property.c auth.c \ realhostname.c fparseln.c INCS= libutil.h login_cap.h MAN3+= login.3 login_auth.3 login_tty.3 logout.3 logwtmp.3 pty.3 \ - setproctitle.3 login_cap.3 login_class.3 login_times.3 login_ok.3 \ + login_cap.3 login_class.3 login_times.3 login_ok.3 \ _secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \ realhostname_sa.3 trimdomain.3 fparseln.3 MAN5+= login.conf.5 auth.conf.5 diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index f371e3f81b09..1bb4b9fd5649 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -45,7 +45,6 @@ struct utmp; struct in_addr; __BEGIN_DECLS -void setproctitle __P((const char *_fmt, ...)) __printf0like(1, 2); void login __P((struct utmp *_ut)); int login_tty __P((int _fd)); int logout __P((char *_line)); diff --git a/lib/libutil/setproctitle.3 b/lib/libutil/setproctitle.3 deleted file mode 100644 index 7fd157f857a7..000000000000 --- a/lib/libutil/setproctitle.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" Copyright (c) 1995 Peter Wemm -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, is permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice immediately at the beginning of the file, without modification, -.\" 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. -.\" 3. This work was done expressly for inclusion into FreeBSD. Other use -.\" is permitted provided this notation is included. -.\" 4. Absolutely no warranty of function or purpose is made by the author -.\" Peter Wemm. -.\" 5. Modifications may be freely made to this file providing the above -.\" conditions are met. -.\" -.\" $FreeBSD$ -.\" -.\" The following requests are required for all man pages. -.Dd December 16, 1995 -.Os FreeBSD -.Dt SETPROCTITLE 3 -.Sh NAME -.Nm setproctitle -.Nd set the process title for -.Xr ps 1 -.Sh LIBRARY -.Lb libutil -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Ft void -.Fn setproctitle "const char *fmt" "..." -.Sh DESCRIPTION -The -.Fn setproctitle -library routine sets the process title that appears on the -.Xr ps 1 -command. -.Pp -The title is set from the executable's name, followed by the -result of a -.Xr printf 3 -style expansion of the arguments as specified by the -.Va fmt -argument. -If the -.Va fmt -argument begins with a -.Dq - -character, the executable's name is skipped. -.Pp -If -.Va fmt -is NULL, the process title is restored. -.Sh EXAMPLES -To set the title on a daemon to indicate its activity: -.Bd -literal -offset indent -setproctitle("talking to %s", inet_ntoa(addr)); -.Ed -.Sh SEE ALSO -.Xr ps 1 , -.Xr w 1 , -.Xr kvm 3 , -.Xr kvm_getargv 3 , -.Xr printf 3 -.Sh STANDARDS -.Fn setproctitle -is implicitly non-standard. Other methods of causing the -.Xr ps 1 -command line to change, including copying over the argv[0] string are -also implicitly non-portable. It is preferable to use an operating system -supplied -.Fn setproctitle -if present. -.Pp -Unfortunately, it is possible that there are other calling conventions -to other versions of -.Fn setproctitle , -although none have been found by the author as yet. This is believed to be -the predominant convention. -.Pp -It is thought that the implementation is compatible with other systems, -including -.Nx -and -.Tn BSD/OS . -.Sh HISTORY -.Fn setproctitle -first appeared in -.Fx 2.2 . -Other operating systems have -similar functions. -.Sh AUTHORS -.An Peter Wemm Aq peter@FreeBSD.org -stole the idea from the -.Sy "Sendmail 8.7.3" -source code by -.An Eric Allman Aq eric@sendmail.org . diff --git a/lib/libutil/setproctitle.c b/lib/libutil/setproctitle.c deleted file mode 100644 index d0f224bff86d..000000000000 --- a/lib/libutil/setproctitle.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1995 Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, is permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice immediately at the beginning of the file, without modification, - * 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. - * 3. Absolutely no warranty of function or purpose is made by the author - * Peter Wemm. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -/* - * Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and - * in different locations. - * 1: old_ps_strings at the very top of the stack. - * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack. - * 3: ps_strings at the very top of the stack. - * This attempts to support a kernel built in the #2 and #3 era. - */ - -struct old_ps_strings { - char *old_ps_argvstr; - int old_ps_nargvstr; - char *old_ps_envstr; - int old_ps_nenvstr; -}; -#define OLD_PS_STRINGS ((struct old_ps_strings *) \ - (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings))) - -#include - -#define SPT_BUFSIZE 2048 /* from other parts of sendmail */ -extern char * __progname; /* is this defined in a .h anywhere? */ - -void -setproctitle(const char *fmt, ...) -{ - static struct ps_strings *ps_strings; - static char buf[SPT_BUFSIZE]; - static char obuf[SPT_BUFSIZE]; - static char **oargv, *kbuf; - static int oargc = -1; - static char *nargv[2] = { buf, NULL }; - char **nargvp; - int nargc; - va_list ap; - size_t len; - unsigned long ul_ps_strings; - int oid[4]; - - va_start(ap, fmt); - - if (fmt) { - buf[sizeof(buf) - 1] = '\0'; - - if (fmt[0] == '-') { - /* skip program name prefix */ - fmt++; - len = 0; - } else { - /* print program name heading for grep */ - (void) snprintf(buf, sizeof(buf), "%s: ", __progname); - len = strlen(buf); - } - - /* print the argument string */ - (void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); - - nargvp = nargv; - nargc = 1; - kbuf = buf; - } else if (*obuf != '\0') { - /* Idea from NetBSD - reset the title on fmt == NULL */ - nargvp = oargv; - nargc = oargc; - kbuf = obuf; - } else - /* Nothing to restore */ - return; - - va_end(ap); - - /* Set the title into the kernel cached command line */ - oid[0] = CTL_KERN; - oid[1] = KERN_PROC; - oid[2] = KERN_PROC_ARGS; - oid[3] = getpid(); - sysctl(oid, 4, 0, 0, kbuf, strlen(kbuf) + 1); - - if (ps_strings == NULL) { - len = sizeof(ul_ps_strings); - if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, - 0) == -1) - ul_ps_strings = PS_STRINGS; - ps_strings = (struct ps_strings *)ul_ps_strings; - } - - /* PS_STRINGS points to zeroed memory on a style #2 kernel */ - if (ps_strings->ps_argvstr) { - /* style #3 */ - if (oargc == -1) { - /* Record our original args */ - oargc = ps_strings->ps_nargvstr; - oargv = ps_strings->ps_argvstr; - for (nargc = len = 0; nargc < oargc; nargc++) { - snprintf(obuf + len, sizeof(obuf) - len, "%s%s", - len ? " " : "", oargv[nargc]); - if (len) - len++; - len += strlen(oargv[nargc]); - if (len >= sizeof(obuf)) - break; - } - } - ps_strings->ps_nargvstr = nargc; - ps_strings->ps_argvstr = nargvp; - } else { - /* style #2 - we can only restore our first arg :-( */ - if (*obuf == '\0') - strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr, - sizeof(obuf) - 1); - OLD_PS_STRINGS->old_ps_nargvstr = 1; - OLD_PS_STRINGS->old_ps_argvstr = nargvp[0]; - } -} diff --git a/sys/sys/param.h b/sys/sys/param.h index 3f4c36bc4684..97a8301b5332 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -46,7 +46,7 @@ #define BSD4_3 1 #define BSD4_4 1 #undef __FreeBSD_version -#define __FreeBSD_version 500011 /* Master, propagated to newvers */ +#define __FreeBSD_version 500012 /* Master, propagated to newvers */ #ifndef NULL #define NULL 0