From: Sadie Powell Date: Wed, 9 Jun 2021 03:20:09 +0000 (+0100) Subject: Add the --disable-ownership option to help packagers out. X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=3766337fcb3bef277d1fa6a116ea812a27848ab4;p=user%2Fhenk%2Fcode%2Finspircd.git Add the --disable-ownership option to help packagers out. --- 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! *"