From a3a1574cdf469740a01be4c127526f1768c14efc Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@courtesan.com>
Date: Tue, 2 Oct 2012 15:08:02 -0400
Subject: [PATCH] Explicitly mark main() as public in executables to avoid an
 HP-UX ld warning.

---
 compat/mksiglist.c                                    | 2 ++
 compat/mksigname.c                                    | 2 ++
 compat/regress/fnmatch/fnm_test.c                     | 2 ++
 compat/regress/glob/globtest.c                        | 1 +
 plugins/sample_group/plugin_test.c                    | 2 ++
 plugins/sudoers/regress/check_symbols/check_symbols.c | 2 ++
 plugins/sudoers/regress/iolog_path/check_iolog_path.c | 2 ++
 plugins/sudoers/regress/logging/check_wrap.c          | 2 ++
 plugins/sudoers/regress/parser/check_addr.c           | 1 +
 plugins/sudoers/regress/parser/check_fill.c           | 2 ++
 plugins/sudoers/sudoreplay.c                          | 2 ++
 plugins/sudoers/testsudoers.c                         | 2 ++
 plugins/sudoers/visudo.c                              | 2 ++
 src/sesh.c                                            | 2 ++
 src/sudo.c                                            | 2 ++
 15 files changed, 28 insertions(+)

diff --git a/compat/mksiglist.c b/compat/mksiglist.c
index 287dfb5bb..f3fc82fec 100644
--- a/compat/mksiglist.c
+++ b/compat/mksiglist.c
@@ -32,6 +32,8 @@
 
 #include "missing.h"
 
+__dso_public int main(int argc, char *argv[]);
+
 int
 main(int argc, char *argv[])
 {
diff --git a/compat/mksigname.c b/compat/mksigname.c
index fcb8b3370..10b632464 100644
--- a/compat/mksigname.c
+++ b/compat/mksigname.c
@@ -32,6 +32,8 @@
 
 #include "missing.h"
 
+__dso_public int main(int argc, char *argv[]);
+
 int
 main(int argc, char *argv[])
 {
diff --git a/compat/regress/fnmatch/fnm_test.c b/compat/regress/fnmatch/fnm_test.c
index 2079e3b4a..0fe9772ae 100644
--- a/compat/regress/fnmatch/fnm_test.c
+++ b/compat/regress/fnmatch/fnm_test.c
@@ -20,6 +20,8 @@
 # include "compat/fnmatch.h"
 #endif
 
+__dso_public int main(int argc, char *argv[]);
+
 int
 main(int argc, char *argv[])
 {
diff --git a/compat/regress/glob/globtest.c b/compat/regress/glob/globtest.c
index b4f61f24b..8da3ed458 100644
--- a/compat/regress/glob/globtest.c
+++ b/compat/regress/glob/globtest.c
@@ -33,6 +33,7 @@ struct gl_entry {
 };
 
 int test_glob(struct gl_entry *);
+__dso_public int main(int argc, char *argv[]);
 
 int
 main(int argc, char **argv)
diff --git a/plugins/sample_group/plugin_test.c b/plugins/sample_group/plugin_test.c
index ffb90a0e4..9d75cb292 100644
--- a/plugins/sample_group/plugin_test.c
+++ b/plugins/sample_group/plugin_test.c
@@ -31,6 +31,8 @@
 
 #include "sudo_plugin.h"
 
+__dso_public int main(int argc, char *argv[]);
+
 /*
  * Simple driver to test sudoer group plugins.
  * usage: plugin_test [-p "plugin.so plugin_args ..."] user:group ...
diff --git a/plugins/sudoers/regress/check_symbols/check_symbols.c b/plugins/sudoers/regress/check_symbols/check_symbols.c
index 5e8218992..98fb9cf14 100644
--- a/plugins/sudoers/regress/check_symbols/check_symbols.c
+++ b/plugins/sudoers/regress/check_symbols/check_symbols.c
@@ -50,6 +50,8 @@
 # define LINE_MAX 2048
 #endif
 
+__dso_public int main(int argc, char *argv[]);
+
 static void
 usage(void)
 {
diff --git a/plugins/sudoers/regress/iolog_path/check_iolog_path.c b/plugins/sudoers/regress/iolog_path/check_iolog_path.c
index 374b5fb90..3a8c2940d 100644
--- a/plugins/sudoers/regress/iolog_path/check_iolog_path.c
+++ b/plugins/sudoers/regress/iolog_path/check_iolog_path.c
@@ -54,6 +54,8 @@ sudo_conv_t sudo_conv;		/* NULL in non-plugin */
 
 static char sessid[7];
 
+__dso_public int main(int argc, char *argv[]);
+
 static void
 usage(void)
 {
diff --git a/plugins/sudoers/regress/logging/check_wrap.c b/plugins/sudoers/regress/logging/check_wrap.c
index 2b9b8a22c..9be544be8 100644
--- a/plugins/sudoers/regress/logging/check_wrap.c
+++ b/plugins/sudoers/regress/logging/check_wrap.c
@@ -46,6 +46,8 @@ sudo_conv_t sudo_conv;		/* NULL in non-plugin */
 
 extern void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
 
+__dso_public int main(int argc, char *argv[]);
+
 static void
 usage(void)
 {
diff --git a/plugins/sudoers/regress/parser/check_addr.c b/plugins/sudoers/regress/parser/check_addr.c
index a73de59c7..f71629643 100644
--- a/plugins/sudoers/regress/parser/check_addr.c
+++ b/plugins/sudoers/regress/parser/check_addr.c
@@ -50,6 +50,7 @@
 #include "interfaces.h"
 
 static int check_addr_printf(int msg_type, const char *fmt, ...);
+__dso_public int main(int argc, char *argv[]);
 
 /* for match_addr.c */
 struct interface *interfaces;
diff --git a/plugins/sudoers/regress/parser/check_fill.c b/plugins/sudoers/regress/parser/check_fill.c
index d1132bf44..d7c8e3b4d 100644
--- a/plugins/sudoers/regress/parser/check_fill.c
+++ b/plugins/sudoers/regress/parser/check_fill.c
@@ -48,6 +48,8 @@
 #include "sudo_plugin.h"
 #include <gram.h>
 
+__dso_public int main(int argc, char *argv[]);
+
 /*
  * TODO: test realloc
  */
diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c
index adbc9bab6..921f7f35e 100644
--- a/plugins/sudoers/sudoreplay.c
+++ b/plugins/sudoers/sudoreplay.c
@@ -238,6 +238,8 @@ static size_t atomic_writev(int fd, struct iovec *iov, int iovcnt);
     (s)[8] == '/' && (s)[9] == 'l' && (s)[10] == 'o' && (s)[11] == 'g' && \
     (s)[12] == '\0')
 
+__dso_public int main(int argc, char *argv[]);
+
 int
 main(int argc, char *argv[])
 {
diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c
index 41856d1df..ef96f0dd8 100644
--- a/plugins/sudoers/testsudoers.c
+++ b/plugins/sudoers/testsudoers.c
@@ -127,6 +127,8 @@ extern char *malloc_options;
 extern int sudoersdebug;
 #endif
 
+__dso_public int main(int argc, char *argv[]);
+
 int
 main(int argc, char *argv[])
 {
diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c
index d8248ee45..ff30eb261 100644
--- a/plugins/sudoers/visudo.c
+++ b/plugins/sudoers/visudo.c
@@ -144,6 +144,8 @@ static struct sudoersfile_list sudoerslist;
 static struct rbtree *alias_freelist;
 static bool checkonly;
 
+__dso_public int main(int argc, char *argv[]);
+
 int
 main(int argc, char *argv[])
 {
diff --git a/src/sesh.c b/src/sesh.c
index e6d57e5e4..511c9d638 100644
--- a/src/sesh.c
+++ b/src/sesh.c
@@ -45,6 +45,8 @@
 
 sudo_conv_t sudo_conv;  /* NULL in non-plugin */
 
+__dso_public int main(int argc, char *argv[], char *envp[]);
+
 /*
  * Cleanup hook for error()/errorx()
  */
diff --git a/src/sudo.c b/src/sudo.c
index 583eb3465..c8ec005ba 100644
--- a/src/sudo.c
+++ b/src/sudo.c
@@ -147,6 +147,8 @@ static struct rlimit corelimit;
 static struct rlimit nproclimit;
 #endif
 
+__dso_public int main(int argc, char *argv[], char *envp[]);
+
 int
 main(int argc, char *argv[], char *envp[])
 {
-- 
2.40.0