From d298378b3d7b6e60afe199739e26db93960a89c4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 9 Jun 2021 02:36:31 +0100 Subject: [PATCH 1/5] Fix the compiler_info name for the Intel compiler. --- make/template/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/template/main.mk b/make/template/main.mk index 53430c78e..319d39c08 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -67,7 +67,7 @@ INSTMODE_BIN ?= 0755 INSTMODE_TXT ?= 0644 INSTMODE_PRV ?= 0640 -ifneq ($(COMPILER), ICC) +ifneq ($(COMPILER), Intel) CORECXXFLAGS += -Woverloaded-virtual -Wshadow ifneq ($(SYSTEM), openbsd) CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute -Wno-format-nonliteral From 3766337fcb3bef277d1fa6a116ea812a27848ab4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 9 Jun 2021 04:20:09 +0100 Subject: [PATCH 2/5] Add the --disable-ownership option to help packagers out. --- configure | 18 ++++++++--- make/configure.pm | 1 + make/template/main.mk | 69 ++++++++++++++++++++++++------------------- 3 files changed, 53 insertions(+), 35 deletions(-) diff --git a/configure b/configure index 5ccd47d9a..a3631fa34 100755 --- a/configure +++ b/configure @@ -52,6 +52,7 @@ my ($opt_binary_dir, $opt_development, $opt_disable_auto_extras, $opt_disable_interactive, + $opt_disable_ownership, $opt_distribution_label, $opt_example_dir, $opt_gid, @@ -86,6 +87,7 @@ exit 1 unless GetOptions( 'development' => \$opt_development, 'disable-auto-extras' => \$opt_disable_auto_extras, 'disable-interactive' => \$opt_disable_interactive, + 'disable-ownership' => \$opt_disable_ownership, 'distribution-label=s' => \$opt_distribution_label, 'example-dir=s' => \$opt_example_dir, 'gid=s' => \$opt_gid, @@ -124,6 +126,7 @@ our $interactive = !( defined $opt_development || defined $opt_disable_auto_extras || defined $opt_disable_interactive || + defined $opt_disable_ownership || defined $opt_distribution_label || defined $opt_example_dir || defined $opt_gid || @@ -227,7 +230,10 @@ if (defined $opt_portable) { # Parse --gid=123 or --gid=foo and extract the group id. my @group; -if (defined $opt_gid) { +if (defined $opt_disable_ownership) { + @group = getgrgid(getgid()); + print_error 'you can not use --disable-ownership and --gid at the same time!' if defined $opt_gid; +} elsif (defined $opt_gid) { @group = $opt_gid =~ /^\d+$/ ? getgrgid($opt_gid) : getgrnam($opt_gid); print_error "there is no '$opt_gid' group on this system!" unless @group; } else { @@ -243,7 +249,7 @@ unprivileged user/group to build and run as or pass the '--gid [id|name]' flag to specify an unprivileged group to run as. EOW if (!prompt_bool $interactive, "Are you sure you want to build as the $group[0] group?", 0) { - # PACKAGERS: You do not need to delete this check. Use `--gid $(id -g)` or `--gid 0` instead. + # PACKAGERS: You do not need to delete this check. Use `--disable-ownership` instead. say STDERR "If you are sure you want to build as the $group[0] group pass the --gid $group[2] flag." unless $interactive; exit 1; } @@ -254,7 +260,10 @@ $config{GID} = $group[2]; # Parse --uid=123 or --uid=foo and extract the user id. my @user; -if (defined $opt_uid) { +if (defined $opt_disable_ownership) { + @user = getpwuid(getuid()); + print_error 'you can not use --disable-ownership and --uid at the same time!' if defined $opt_uid; +} elsif (defined $opt_uid) { @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid); print_error "there is no '$opt_uid' user on this system!" unless @user; } else { @@ -270,7 +279,7 @@ unprivileged user/group to build and run as or pass the '--uid [id|name]' flag to specify an unprivileged user to run as. EOW if (!prompt_bool $interactive, "Are you sure you want to build as the $user[0] user?", 0) { - # PACKAGERS: You do not need to delete this check. Use `--uid $(id -u)` or `--uid 0` instead. + # PACKAGERS: You do not need to delete this check. Use `--disable-ownership` instead. say STDERR "If you are sure you want to build as the $user[0] user pass the --uid $user[2] flag." unless $interactive; exit 1; } @@ -448,6 +457,7 @@ EOM # Cache the distribution label so that its not lost when --update is run. $config{DISTRIBUTION} = $opt_distribution_label if $opt_distribution_label; +$config{DISABLE_OWNERSHIP} = $opt_disable_ownership // 0; write_configure_cache %config; parse_templates \%config, \%compiler, \%version; diff --git a/make/configure.pm b/make/configure.pm index a49ad1318..ce3988c9b 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -160,6 +160,7 @@ non-interactive configuration is started and any omitted values are defaulted. <|BOLD --disable-auto-extras|> Disables automatically enabling extra modules for which the dependencies are available. <|BOLD --disable-interactive|> Disables the interactive configuration wizard. + <|BOLD --disable-ownership|> Disables setting file ownership on install. <|BOLD --distribution-label |> Sets a distribution specific version label in the build configuration. <|BOLD --gid |> Sets the group to run InspIRCd as. diff --git a/make/template/main.mk b/make/template/main.mk index 319d39c08..3cc0f1200 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -67,6 +67,13 @@ INSTMODE_BIN ?= 0755 INSTMODE_TXT ?= 0644 INSTMODE_PRV ?= 0640 +DISABLE_OWNERSHIP=@DISABLE_OWNERSHIP@ +ifeq ($(DISABLE_OWNERSHIP), 1) + INSTFLAGS = +else + INSTFLAGS = -g @GID@ -o @UID@ +endif + ifneq ($(COMPILER), Intel) CORECXXFLAGS += -Woverloaded-virtual -Wshadow ifneq ($(SYSTEM), openbsd) @@ -212,41 +219,41 @@ finishmessage: target @echo "*************************************" install: target - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(BINPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(CONPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(DATPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/codepages - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/providers - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/services - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/sql - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(LOGPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MANPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MODPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(RUNPATH) - @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(SCRPATH) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/modules/"*.so $(MODPATH) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/apparmor $(SCRPATH) 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/logrotate $(SCRPATH) 2>/dev/null + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(BINPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(CONPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(DATPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/codepages + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/providers + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/services + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(EXAPATH)/sql + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(LOGPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(MANPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(MODPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(RUNPATH) + @-$(INSTALL) -d $(INSTFLAGS) -m $(INSTMODE_DIR) $(SCRPATH) + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH) + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) "$(BUILDPATH)/modules/"*.so $(MODPATH) + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/apparmor $(SCRPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/logrotate $(SCRPATH) 2>/dev/null ifeq ($(SYSTEM), darwin) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null endif ifeq ($(SYSTEM), linux) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null endif - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-testssl.1 $(MANPATH) 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/testssl $(BINPATH)/inspircd-testssl 2>/dev/null - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/*.example $(EXAPATH) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/codepages/*.example $(EXAPATH)/codepages - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/providers/*.example $(EXAPATH)/providers - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/services/*.example $(EXAPATH)/services - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/sql/*.sql $(EXAPATH)/sql - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/help.txt $(CONPATH) - -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_PRV) @CONFIGURE_DIRECTORY@/*.pem $(CONPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-testssl.1 $(MANPATH) 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_BIN) tools/testssl $(BINPATH)/inspircd-testssl 2>/dev/null + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/*.example $(EXAPATH) + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/codepages/*.example $(EXAPATH)/codepages + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/providers/*.example $(EXAPATH)/providers + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/conf/services/*.example $(EXAPATH)/services + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) docs/sql/*.sql $(EXAPATH)/sql + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/help.txt $(CONPATH) + -$(INSTALL) $(INSTFLAGS) -m $(INSTMODE_PRV) @CONFIGURE_DIRECTORY@/*.pem $(CONPATH) 2>/dev/null @echo "" @echo "*************************************" @echo "* INSTALL COMPLETE! *" From ffdae581d4d668884f9ab0ee8ae115c070c3b494 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 9 Jun 2021 04:40:53 +0100 Subject: [PATCH 3/5] Use dummy values for the user/group with --disable-ownership. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index a3631fa34..d39a80e39 100755 --- a/configure +++ b/configure @@ -231,7 +231,7 @@ if (defined $opt_portable) { # Parse --gid=123 or --gid=foo and extract the group id. my @group; if (defined $opt_disable_ownership) { - @group = getgrgid(getgid()); + @group = qw(insert-group-here . -1); print_error 'you can not use --disable-ownership and --gid at the same time!' if defined $opt_gid; } elsif (defined $opt_gid) { @group = $opt_gid =~ /^\d+$/ ? getgrgid($opt_gid) : getgrnam($opt_gid); @@ -261,7 +261,7 @@ $config{GID} = $group[2]; # Parse --uid=123 or --uid=foo and extract the user id. my @user; if (defined $opt_disable_ownership) { - @user = getpwuid(getuid()); + @user = qw(insert-user-here . -1); print_error 'you can not use --disable-ownership and --uid at the same time!' if defined $opt_uid; } elsif (defined $opt_uid) { @user = $opt_uid =~ /^\d+$/ ? getpwuid($opt_uid) : getpwnam($opt_uid); From e69ed249cbae253b592b79dbe2409709a9f9e16b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 9 Jun 2021 04:52:42 +0100 Subject: [PATCH 4/5] Fix unnecessary capitalisation at the start of a configure warning. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index d39a80e39..60624ca4f 100755 --- a/configure +++ b/configure @@ -443,7 +443,7 @@ EOQ } } elsif (!defined $opt_disable_auto_extras) { print_warning <<"EOM"; -You are building without enabling any SSL modules. This is not +you are building without enabling any SSL modules. This is not recommended as SSL greatly enhances the security and privacy of your IRC server and in a future version will be <|BOLD required|> for linking servers. From 77d5b214fb803bda42733b75d2997978f74c43af Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 9 Jun 2021 08:25:40 +0100 Subject: [PATCH 5/5] Fix uninstalling files on `make deinstall` and similar. --- make/configure.pm | 1 + make/template/main.mk | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/make/configure.pm b/make/configure.pm index ce3988c9b..908980d56 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -86,6 +86,7 @@ sub __get_template_settings($$$) { # Miscellaneous information $settings{CONFIGURE_DIRECTORY} = CONFIGURE_DIRECTORY; $settings{CONFIGURE_CACHE_FILE} = CONFIGURE_CACHE_FILE; + $settings{SOURCE_DIR} = CONFIGURE_ROOT; $settings{SYSTEM_NAME} = lc $^O; return %settings; diff --git a/make/template/main.mk b/make/template/main.mk index 3cc0f1200..66d59ee30 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -43,7 +43,8 @@ CXX = @CXX@ COMPILER = @COMPILER_NAME@ SYSTEM = @SYSTEM_NAME@ -BUILDPATH ?= $(dir $(realpath $(firstword $(MAKEFILE_LIST))))/build/@COMPILER_NAME@-@COMPILER_VERSION@ +SOURCEPATH = @SOURCE_DIR@ +BUILDPATH ?= $(SOURCEPATH)/build/@COMPILER_NAME@-@COMPILER_VERSION@ SOCKETENGINE = @SOCKETENGINE@ CORECXXFLAGS = -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow LDLIBS = -lstdc++ @@ -139,8 +140,6 @@ endif MAKEFLAGS += --no-print-directory -SOURCEPATH = $(shell pwd) - ifndef INSPIRCD_VERBOSE MAKEFLAGS += --silent endif @@ -280,23 +279,43 @@ clean: deinstall: -rm -f $(BINPATH)/inspircd - -rm -rf $(EXAPATH) - -rm -f $(MANPATH)/inspircd.1 + -rm -f $(BINPATH)/inspircd-genssl + -rm -f $(BINPATH)/inspircd-testssl + -rm -f $(CONPATH)/help.txt + -rm -f $(EXAPATH)/*.example + -rm -f $(EXAPATH)/codepages/*.example + -rm -f $(EXAPATH)/providers/*.example + -rm -f $(EXAPATH)/services/*.example + -rm -f $(EXAPATH)/sql/*.sql -rm -f $(MANPATH)/inspircd-genssl.1 - -rm -f $(MODPATH)/m_*.so + -rm -f $(MANPATH)/inspircd-testssl.1 + -rm -f $(MANPATH)/inspircd.1 -rm -f $(MODPATH)/core_*.so + -rm -f $(MODPATH)/m_*.so + -rm -f $(SCRPATH)/apparmor + -rm -f $(SCRPATH)/inspircd -rm -f $(SCRPATH)/inspircd.service + -rm -f $(SCRPATH)/logrotate -rm -f $(SCRPATH)/org.inspircd.plist + -[ -d $(BINPATH) ] && find $(BINPATH) -type d -empty -delete + -[ -d $(CONPATH) ] && find $(CONPATH) -type d -empty -delete + -[ -d $(DATPATH) ] && find $(DATPATH) -type d -empty -delete + -[ -d $(EXAPATH) ] && find $(EXAPATH) -type d -empty -delete + -[ -d $(LOGPATH) ] && find $(LOGPATH) -type d -empty -delete + -[ -d $(MANPATH) ] && find $(MANPATH) -type d -empty -delete + -[ -d $(MODPATH) ] && find $(MODPATH) -type d -empty -delete + -[ -d $(RUNPATH) ] && find $(RUNPATH) -type d -empty -delete + -[ -d $(SCRPATH) ] && find $(SCRPATH) -type d -empty -delete configureclean: + -rm -f GNUmakefile -rm -f Makefile - rm -f GNUmakefile - rm -f include/config.h - rm -rf @CONFIGURE_DIRECTORY@ + -rm -f include/config.h + -rm -rf @CONFIGURE_DIRECTORY@ distclean: clean configureclean -rm -rf "$(SOURCEPATH)/run" - find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f + -find "$(SOURCEPATH)/src/modules" -type l -delete help: @echo 'InspIRCd Makefile'