From aa5c63cbe276ee4cb0e2f1113a790ed1d81b4d53 Mon Sep 17 00:00:00 2001 From: mycroft Date: Sun, 24 Apr 1994 01:00:39 +0000 Subject: [PATCH] Print the name of the program using a deprecated syscall. --- lib/libc/compat-43/setregid.c | 15 ++++++++++++--- lib/libc/compat-43/setreuid.c | 15 ++++++++++++--- lib/libc/compat-43/setrgid.c | 14 +++++++++++--- lib/libc/compat-43/setruid.c | 14 +++++++++++--- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/lib/libc/compat-43/setregid.c b/lib/libc/compat-43/setregid.c index 9d02a8b133ec..37e4cf894ade 100644 --- a/lib/libc/compat-43/setregid.c +++ b/lib/libc/compat-43/setregid.c @@ -31,12 +31,13 @@ * SUCH DAMAGE. * * from: @(#)kern_prot.c 7.21 (Berkeley) 5/3/91 - * $Id: setregid.c,v 1.2 1994/04/10 06:32:42 cgd Exp $ + * $Id: setregid.c,v 1.3 1994/04/24 01:00:39 mycroft Exp $ */ #include #include #include +#include extern int __setregid __P((gid_t, gid_t)); @@ -46,11 +47,19 @@ setregid(rgid, egid) { static int warned; static char w[] = - "warning: this program uses setregid(), which is deprecated.\r\n"; + ": warning: this program uses setregid(), which is deprecated.\r\n"; if (!warned) { - (void) write(STDERR_FILENO, w, sizeof(w) - 1); + struct iovec iov[2]; + extern char *__progname; /* in crt0 */ + + iov[0].iov_base = __progname; + iov[0].iov_len = strlen(__progname); + iov[1].iov_base = w; + iov[1].iov_len = strlen(w); + (void) writev(STDERR_FILENO, iov, 2); warned = 1; } + return (__setregid(rgid, egid)); } diff --git a/lib/libc/compat-43/setreuid.c b/lib/libc/compat-43/setreuid.c index 90d06de66c30..ae4130d7693b 100644 --- a/lib/libc/compat-43/setreuid.c +++ b/lib/libc/compat-43/setreuid.c @@ -31,12 +31,13 @@ * SUCH DAMAGE. * * from: @(#)kern_prot.c 7.21 (Berkeley) 5/3/91 - * $Id: setreuid.c,v 1.2 1994/04/10 06:32:44 cgd Exp $ + * $Id: setreuid.c,v 1.3 1994/04/24 01:00:40 mycroft Exp $ */ #include #include #include +#include extern int __setreuid __P((uid_t, uid_t)); @@ -46,11 +47,19 @@ setreuid(ruid, euid) { static int warned; static char w[] = - "warning: this program uses setreuid(), which is deprecated.\r\n"; + ": warning: this program uses setreuid(), which is deprecated.\r\n"; if (!warned) { - (void) write(STDERR_FILENO, w, sizeof(w) - 1); + struct iovec iov[2]; + extern char *__progname; /* in crt0 */ + + iov[0].iov_base = __progname; + iov[0].iov_len = strlen(__progname); + iov[1].iov_base = w; + iov[1].iov_len = strlen(w); + (void) writev(STDERR_FILENO, iov, 2); warned = 1; } + return (__setreuid(ruid, euid)); } diff --git a/lib/libc/compat-43/setrgid.c b/lib/libc/compat-43/setrgid.c index 00395fd0d90d..97537071adaf 100644 --- a/lib/libc/compat-43/setrgid.c +++ b/lib/libc/compat-43/setrgid.c @@ -33,11 +33,12 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)setrgid.c 5.5 (Berkeley) 2/23/91";*/ -static char *rcsid = "$Id: setrgid.c,v 1.2 1994/04/10 06:32:46 cgd Exp $"; +static char *rcsid = "$Id: setrgid.c,v 1.3 1994/04/24 01:00:41 mycroft Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include +#include int #ifdef __STDC__ @@ -49,10 +50,17 @@ setrgid(rgid) { static int warned; static char w[] = - "warning: this program uses setrgid(), which is deprecated.\r\n"; + ": warning: this program uses setrgid(), which is deprecated.\r\n"; if (!warned) { - (void) write(STDERR_FILENO, w, sizeof(w) - 1); + struct iovec iov[2]; + extern char *__progname; /* in crt0 */ + + iov[0].iov_base = __progname; + iov[0].iov_len = strlen(__progname); + iov[1].iov_base = w; + iov[1].iov_len = strlen(w); + (void) writev(STDERR_FILENO, iov, 2); warned = 1; } diff --git a/lib/libc/compat-43/setruid.c b/lib/libc/compat-43/setruid.c index c2e41510dd39..0440045e75a9 100644 --- a/lib/libc/compat-43/setruid.c +++ b/lib/libc/compat-43/setruid.c @@ -33,11 +33,12 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)setruid.c 5.5 (Berkeley) 2/23/91";*/ -static char *rcsid = "$Id: setruid.c,v 1.3 1994/04/12 23:20:35 cgd Exp $"; +static char *rcsid = "$Id: setruid.c,v 1.4 1994/04/24 01:00:42 mycroft Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include +#include int #ifdef __STDC__ @@ -49,10 +50,17 @@ setruid(ruid) { static int warned; static char w[] = - "warning: this program uses setruid(), which is deprecated.\r\n"; + ": warning: this program uses setruid(), which is deprecated.\r\n"; if (!warned) { - (void) write(STDERR_FILENO, w, sizeof(w) - 1); + struct iovec iov[2]; + extern char *__progname; /* in crt0 */ + + iov[0].iov_base = __progname; + iov[0].iov_len = strlen(__progname); + iov[1].iov_base = w; + iov[1].iov_len = strlen(w); + (void) writev(STDERR_FILENO, iov, 2); warned = 1; }