From 29598b4fdec1249a5e0c071b4baa3042b7235de7 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 27 Dec 2020 22:48:27 +0100 Subject: [PATCH] Fix /tix/manifest permissions in installations. --- share/man/man7/following-development.7 | 7 ++++++ sysinstall/Makefile | 1 + sysinstall/hooks.c | 32 ++++++++++++++++++++++++++ sysinstall/sysinstall.c | 4 ++-- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/share/man/man7/following-development.7 b/share/man/man7/following-development.7 index 1532fe12..22b5e89d 100644 --- a/share/man/man7/following-development.7 +++ b/share/man/man7/following-development.7 @@ -69,6 +69,13 @@ releasing Sortix x.y, foo." to allow the maintainer to easily .Xr grep 1 for it after a release. .Sh CHANGES +.Ss Fix /tix/manifest permissions in installations +The +.Pa /tix/manifest +directory was accidentally installed by +.Xr sysinstall 8 +as mode 6603 instead of 7555. +This problem is fixed with an upgrade hook. .Ss Add socket(2) The .Pa /dev/net diff --git a/sysinstall/Makefile b/sysinstall/Makefile index f091da87..223020b4 100644 --- a/sysinstall/Makefile +++ b/sysinstall/Makefile @@ -51,6 +51,7 @@ install: all mkdir -p $(DESTDIR)$(DATADIR)/sysinstall/hooks # TODO: After releasing Sortix 1.1, remove this compatibility. touch $(DESTDIR)$(DATADIR)/sysinstall/hooks/sortix-1.1-random-seed + touch $(DESTDIR)$(DATADIR)/sysinstall/hooks/sortix-1.1-tix-manifest-mode sysinstall: $(SYSINSTALL_OBJS) $(CC) $(SYSINSTALL_OBJS) -o $@ -lmount diff --git a/sysinstall/hooks.c b/sysinstall/hooks.c index 5847df4d..beb7384e 100644 --- a/sysinstall/hooks.c +++ b/sysinstall/hooks.c @@ -17,6 +17,7 @@ * Upgrade hooks. */ +#include #include #include @@ -94,6 +95,37 @@ void upgrade_prepare(const struct release* old_release, } free(random_seed_path); } + + // TODO: After releasing Sortix 1.1, remove this compatibility. + if ( hook_needs_to_be_run(source_prefix, target_prefix, + "sortix-1.1-tix-manifest-mode") ) + { + // The mode of /tix/manifest was accidentally set to 7555 (decimal) + // instead of 0755 (octal) in sysinstall.c, i.e. mode 06603. Fix it to + // 0755. + char* path = join_paths(target_prefix, "/tix/manifest"); + if ( !path ) + { + warn("malloc"); + _exit(2); + } + struct stat st; + if ( stat(path, &st) < 0 ) + { + warn("%s", path); + _exit(2); + } + if ( (st.st_mode & 07777) == (7555 & 07777) ) + { + printf(" - Fixing /tix/manifest permissions...\n"); + if ( chmod(path, 0755) < 0 ) + { + warn("chmod: %s", path); + _exit(2); + } + } + free(path); + } } void upgrade_finalize(const struct release* old_release, diff --git a/sysinstall/sysinstall.c b/sysinstall/sysinstall.c index 35b15bdd..7979c4df 100644 --- a/sysinstall/sysinstall.c +++ b/sysinstall/sysinstall.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Jonas 'Sortie' Termansen. + * Copyright (c) 2015, 2016, 2020 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -900,7 +900,7 @@ int main(void) mkdir_or_chmod_or_die("sbin", 0755); mkdir_or_chmod_or_die("share", 0755); mkdir_or_chmod_or_die("tix", 0755); - mkdir_or_chmod_or_die("tix/manifest", 7555); + mkdir_or_chmod_or_die("tix/manifest", 0755); mkdir_or_chmod_or_die("tmp", 01777); mkdir_or_chmod_or_die("var", 0755); mkdir_or_chmod_or_die("var/empty", 0555);