Date: Thu, 9 Jan 2020 01:17:01 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r356533 - in stable/11: contrib/mtree contrib/netbsd-tests/usr.sbin/mtree usr.sbin/fmtree Message-ID: <202001090117.0091H1Wk057094@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdrewery Date: Thu Jan 9 01:17:01 2020 New Revision: 356533 URL: https://svnweb.freebsd.org/changeset/base/356533 Log: MFC r352261,r352262,r352265: r352261: mtree: Fix -f -f not considering type changes. r352262: mtree -c: Fix username logic when getlogin(3) fails. r352265: mtree -O: Fix not descending on hash collisions Relnotes: yes Modified: stable/11/contrib/mtree/create.c stable/11/contrib/mtree/only.c stable/11/contrib/mtree/specspec.c stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh stable/11/usr.sbin/fmtree/specspec.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/mtree/create.c ============================================================================== --- stable/11/contrib/mtree/create.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/mtree/create.c Thu Jan 9 01:17:01 2020 (r356533) @@ -117,7 +117,7 @@ cwalk(FILE *fp) host[sizeof(host) - 1] = '\0'; if ((user = getlogin()) == NULL) { struct passwd *pw; - user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name : + user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name : "<unknown>"; } Modified: stable/11/contrib/mtree/only.c ============================================================================== --- stable/11/contrib/mtree/only.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/mtree/only.c Thu Jan 9 01:17:01 2020 (r356533) @@ -1,4 +1,4 @@ -/* $NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $ */ +/* $NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $"); +__RCSID("$NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $"); #endif #include <sys/param.h> @@ -89,11 +89,14 @@ static void hash_insert(char *str, uint32_t h) { struct hentry *e; + char *x; if ((e = malloc(sizeof(*e))) == NULL) mtree_err("memory allocation error"); + if ((x = strdup(str)) == NULL) + mtree_err("memory allocation error"); - e->str = str; + e->str = x; e->hash = h; e->next = table[h]; table[h] = e; @@ -110,10 +113,7 @@ fill(char *str) *ptr = '\0'; if (!hash_find(str, &h)) { - char *x = strdup(str); - if (x == NULL) - mtree_err("memory allocation error"); - hash_insert(x, h); + hash_insert(str, h); fill(str); } *ptr = '/'; @@ -135,6 +135,7 @@ load_only(const char *fname) err(1, "Duplicate entry %s", line); hash_insert(line, h); fill(line); + free(line); } fclose(fp); Modified: stable/11/contrib/mtree/specspec.c ============================================================================== --- stable/11/contrib/mtree/specspec.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/mtree/specspec.c Thu Jan 9 01:17:01 2020 (r356533) @@ -145,7 +145,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path) return (1); } if (n1->type != n2->type) { - differs = 0; + differs = F_TYPE; mismatch(n1, n2, differs, path); return (1); } Modified: stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh Thu Jan 9 01:17:01 2020 (r356533) @@ -411,7 +411,42 @@ netbsd6_nonemptydir_body() FLAVOR=netbsd6 nonemptydir_body } +atf_test_case mtree_specspec_type +mtree_specspec_type_head() +{ + atf_set "descr" "Test that spec comparisons detect type changes" +} +mtree_specspec_type_body() +{ + mkdir testdir + + touch testdir/bar + mtree -c -p testdir > mtree1.spec + + if [ ! -f mtree1.spec ]; then + atf_fail "mtree failed" + fi + + rm -f testdir/bar + ln -s foo testdir/bar + # uid change is expected to be ignored as done in -C + chown -h operator testdir/bar + mtree -c -p testdir > mtree2.spec + + if [ ! -f mtree2.spec ]; then + atf_fail "mtree failed" + fi + + atf_check -s ignore -o save:output \ + -x "mtree -f mtree1.spec -f mtree2.spec" + + if ! cut -f 3 output | egrep -q "bar file" || \ + ! cut -f 3 output | egrep -q "bar link"; then + atf_fail "mtree did not detect type change" + fi +} + atf_init_test_cases() { atf_add_test_case mtree_create @@ -423,6 +458,7 @@ atf_init_test_cases() atf_add_test_case mtree_ignore atf_add_test_case mtree_merge atf_add_test_case mtree_nonemptydir + atf_add_test_case mtree_specspec_type atf_add_test_case netbsd6_create atf_add_test_case netbsd6_check Modified: stable/11/usr.sbin/fmtree/specspec.c ============================================================================== --- stable/11/usr.sbin/fmtree/specspec.c Thu Jan 9 01:14:26 2020 (r356532) +++ stable/11/usr.sbin/fmtree/specspec.c Thu Jan 9 01:17:01 2020 (r356533) @@ -132,7 +132,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path) return (1); } if (n1->type != n2->type) { - differs = 0; + differs = F_TYPE; mismatch(n1, n2, differs, path); return (1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001090117.0091H1Wk057094>