Module Name: othersrc
Committed By: lukem
Date: Sat Sep 23 04:00:21 UTC 2023
Modified Files:
othersrc/libexec/tnftpd: configure.ac tnftpd.h
othersrc/libexec/tnftpd/libnetbsd: err.c
othersrc/libexec/tnftpd/src: ftpd.c
Added Files:
othersrc/libexec/tnftpd/libnetbsd: setprogname.c
Log Message:
adapt __progname to setprogname() / getprogname()
Import setprogname() and getprogname() from
othersrc/usr.bin/tnftp/libnetbsd/setprogname.c rev 1.4.
Use getprogname() instead of __progname.
Fixes link error on modern NetBSD which correctly complained
about duplicate definition of __progname.
To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 othersrc/libexec/tnftpd/configure.ac
cvs rdiff -u -r1.38 -r1.39 othersrc/libexec/tnftpd/tnftpd.h
cvs rdiff -u -r1.5 -r1.6 othersrc/libexec/tnftpd/libnetbsd/err.c
cvs rdiff -u -r0 -r1.1 othersrc/libexec/tnftpd/libnetbsd/setprogname.c
cvs rdiff -u -r1.37 -r1.38 othersrc/libexec/tnftpd/src/ftpd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/libexec/tnftpd/configure.ac
diff -u othersrc/libexec/tnftpd/configure.ac:1.47 othersrc/libexec/tnftpd/configure.ac:1.48
--- othersrc/libexec/tnftpd/configure.ac:1.47 Sat Sep 23 03:26:02 2023
+++ othersrc/libexec/tnftpd/configure.ac Sat Sep 23 04:00:21 2023
@@ -1,4 +1,4 @@
-# $NetBSD: configure.ac,v 1.47 2023/09/23 03:26:02 lukem Exp $
+# $NetBSD: configure.ac,v 1.48 2023/09/23 04:00:21 lukem Exp $
#
# Process this file with autoconf to produce a configure script.
@@ -281,7 +281,7 @@ AC_FUNC_STRCOLL()
AC_REPLACE_FUNCS([daemon err explicit_memset fgetln fparseln \
getaddrinfo getgrouplist getnameinfo getusershell \
inet_net_pton inet_ntop inet_pton mkstemp \
- sl_init snprintf strdup strerror strsuftollx \
+ setprogname sl_init snprintf strdup strerror strsuftollx \
strlcat strlcpy strsep usleep])
AC_CHECK_FUNCS([dirfd getcwd gethostbyaddr gethostbyname gethostbyname2 \
gethostname getrusage getspnam gettimeofday \
Index: othersrc/libexec/tnftpd/tnftpd.h
diff -u othersrc/libexec/tnftpd/tnftpd.h:1.38 othersrc/libexec/tnftpd/tnftpd.h:1.39
--- othersrc/libexec/tnftpd/tnftpd.h:1.38 Sat Sep 23 02:56:08 2023
+++ othersrc/libexec/tnftpd/tnftpd.h Sat Sep 23 04:00:21 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: tnftpd.h,v 1.38 2023/09/23 02:56:08 lukem Exp $ */
+/* $NetBSD: tnftpd.h,v 1.39 2023/09/23 04:00:21 lukem Exp $ */
#define FTPD_VERSION PACKAGE_STRING
@@ -464,6 +464,11 @@ int inet_pton(int, const char *, void *)
int mkstemp(const char *);
#endif
+#if !defined(HAVE_SETPROGNAME)
+const char *getprogname(void);
+void setprogname(const char *);
+#endif
+
#if !defined(HAVE_SETEGID)
# if defined(HAVE_SETRESGID)
# define setegid(i) setresgid(-1, (i), -1)
Index: othersrc/libexec/tnftpd/libnetbsd/err.c
diff -u othersrc/libexec/tnftpd/libnetbsd/err.c:1.5 othersrc/libexec/tnftpd/libnetbsd/err.c:1.6
--- othersrc/libexec/tnftpd/libnetbsd/err.c:1.5 Wed Jan 23 05:20:01 2019
+++ othersrc/libexec/tnftpd/libnetbsd/err.c Sat Sep 23 04:00:21 2023
@@ -1,7 +1,10 @@
-/* $NetBSD: err.c,v 1.5 2019/01/23 05:20:01 lukem Exp $ */
+/* $NetBSD: err.c,v 1.6 2023/09/23 04:00:21 lukem Exp $ */
+
+/* from: NetBSD: err.c,v 1.6 2020/07/05 09:54:26 lukem Exp */
+/* upstream: othersrc/usr.bin/tnftp/libnetbsd/err.c */
/*
- * Copyright 1997-2002 Luke Mewburn <[email protected]>.
+ * Copyright 1997-2000,2020 Luke Mewburn <[email protected]>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,8 +30,6 @@
#include "tnftpd.h"
-extern char *__progname;
-
void
err(int eval, const char *fmt, ...)
{
@@ -36,7 +37,7 @@ err(int eval, const char *fmt, ...)
int sverrno;
sverrno = errno;
- (void)fprintf(stderr, "%s: ", __progname);
+ (void)fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL) {
(void)vfprintf(stderr, fmt, ap);
@@ -52,7 +53,7 @@ errx(int eval, const char *fmt, ...)
{
va_list ap;
- (void)fprintf(stderr, "%s: ", __progname);
+ (void)fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL)
(void)vfprintf(stderr, fmt, ap);
@@ -68,7 +69,7 @@ warn(const char *fmt, ...)
int sverrno;
sverrno = errno;
- (void)fprintf(stderr, "%s: ", __progname);
+ (void)fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL) {
(void)vfprintf(stderr, fmt, ap);
@@ -83,7 +84,7 @@ warnx(const char *fmt, ...)
{
va_list ap;
- (void)fprintf(stderr, "%s: ", __progname);
+ (void)fprintf(stderr, "%s: ", getprogname());
va_start(ap, fmt);
if (fmt != NULL)
(void)vfprintf(stderr, fmt, ap);
Index: othersrc/libexec/tnftpd/src/ftpd.c
diff -u othersrc/libexec/tnftpd/src/ftpd.c:1.37 othersrc/libexec/tnftpd/src/ftpd.c:1.38
--- othersrc/libexec/tnftpd/src/ftpd.c:1.37 Sat Jul 4 04:00:53 2020
+++ othersrc/libexec/tnftpd/src/ftpd.c Sat Sep 23 04:00:21 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: ftpd.c,v 1.37 2020/07/04 04:00:53 lukem Exp $ */
+/* $NetBSD: ftpd.c,v 1.38 2023/09/23 04:00:21 lukem Exp $ */
/* from NetBSD: ftpd.c,v 1.205 2019/10/15 18:29:32 christos Exp */
/*
@@ -299,8 +299,6 @@ int k5login(struct passwd *, char *, cha
void k5destroy(void);
#endif
-char * __progname;
-
int
main(int argc, char *argv[])
{
@@ -315,11 +313,7 @@ main(int argc, char *argv[])
struct sigaction sa;
sa_family_t af = AF_UNSPEC;
- __progname = strrchr(argv[0], '/');
- if (__progname == NULL)
- __progname = argv[0];
- else
- __progname++;
+ setprogname(argv[0]);
connections = 1;
ftpd_debug = 0;
@@ -4205,7 +4199,7 @@ auth_sia(struct passwd *pw, char *pwstr)
int ret;
char *args[2];
- args[0] = __progname;
+ args[0] = getprogname();
args[1] = NULL;
if (sia_ses_init(&ent, 1, args, remotehost, pw->pw_name,
Added files:
Index: othersrc/libexec/tnftpd/libnetbsd/setprogname.c
diff -u /dev/null othersrc/libexec/tnftpd/libnetbsd/setprogname.c:1.1
--- /dev/null Sat Sep 23 04:00:21 2023
+++ othersrc/libexec/tnftpd/libnetbsd/setprogname.c Sat Sep 23 04:00:21 2023
@@ -0,0 +1,53 @@
+/* $NetBSD: setprogname.c,v 1.1 2023/09/23 04:00:21 lukem Exp $ */
+
+/* from: NetBSD: setprogname.c,v 1.4 2008/04/29 08:13:38 martin Exp */
+/* upstream: othersrc/usr.bin/tnftp/libnetbsd/setprogname.c */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Todd Vierling.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 "tnftpd.h"
+
+static const char *__progname = "<unset_progname>";
+
+void
+setprogname(const char *progname)
+{
+ __progname = strrchr(progname, '/');
+ if (__progname == NULL)
+ __progname = progname;
+ else
+ __progname++;
+}
+
+const char *
+getprogname(void)
+{
+ return __progname;
+}