CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: wiz Date: Fri May 10 09:14:52 UTC 2024 Modified Files: src/usr.bin/xinstall: install.1 xinstall.c Log Message: nstall(1): add support for -v Reviewed by rillig@ and thorpej@, thanks! To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xinstall/install.1 cvs rdiff -u -r1.127 -r1.128 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/install.1 diff -u src/usr.bin/xinstall/install.1:1.47 src/usr.bin/xinstall/install.1:1.48 --- src/usr.bin/xinstall/install.1:1.47 Sun Apr 8 22:00:40 2012 +++ src/usr.bin/xinstall/install.1 Fri May 10 09:14:52 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: install.1,v 1.47 2012/04/08 22:00:40 wiz Exp $ +.\" $NetBSD: install.1,v 1.48 2024/05/10 09:14:52 wiz Exp $ .\" .\" Copyright (c) 1987, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)install.1 8.1 (Berkeley) 6/6/93 .\" -.Dd May 1, 2009 +.Dd May 9, 2024 .Dt INSTALL 1 .Os .Sh NAME @@ -37,7 +37,7 @@ .Nd install binaries .Sh SYNOPSIS .Nm -.Op Fl bcprsU +.Op Fl bcprsUv .Op Fl a Ar command .Op Fl B Ar suffix .Op Fl D Ar destdir @@ -297,6 +297,11 @@ try to change the owner, the group, or t The information that would have been updated can be stored in a log file with .Fl M Ar metalog . +.It Fl v +Cause +.Nm +to be verbose, +showing files as they are installed or backed up. .El .Pp By default, Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.127 src/usr.bin/xinstall/xinstall.c:1.128 --- src/usr.bin/xinstall/xinstall.c:1.127 Thu Jul 20 16:21:23 2023 +++ src/usr.bin/xinstall/xinstall.c Fri May 10 09:14:52 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.127 2023/07/20 16:21:23 lukem Exp $ */ +/* $NetBSD: xinstall.c,v 1.128 2024/05/10 09:14:52 wiz Exp $ */ /* * Copyright (c) 1987, 1993 @@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #else -__RCSID("$NetBSD: xinstall.c,v 1.127 2023/07/20 16:21:23 lukem Exp $"); +__RCSID("$NetBSD: xinstall.c,v 1.128 2024/05/10 09:14:52 wiz Exp $"); #endif #endif /* not lint */ @@ -120,6 +120,7 @@ __RCSID("$NetBSD: xinstall.c,v 1.127 202 static int dobackup, dodir, dostrip, dolink, dopreserve, dorename, dounpriv; static int haveopt_f, haveopt_g, haveopt_m, haveopt_o; static int numberedbackup; +static int verbose; static int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; static char pathbuf[MAXPATHLEN]; static uid_t uid = -1; @@ -186,7 +187,7 @@ main(int argc, char *argv[]) setprogname(argv[0]); iflags = 0; - while ((ch = getopt(argc, argv, "a:cbB:dD:f:g:h:l:m:M:N:o:prsS:T:U")) + while ((ch = getopt(argc, argv, "a:cbB:dD:f:g:h:l:m:M:N:o:prsS:T:Uv")) != -1) switch((char)ch) { case 'a': @@ -307,6 +308,9 @@ main(int argc, char *argv[]) case 'U': dounpriv = 1; break; + case 'v': + verbose = 1; + break; case '?': default: usage(); @@ -477,9 +481,12 @@ do_link(char *from_name, char *to_name) */ (void)unlink(tmpl); } - return (ret); - } else - return (link(from_name, to_name)); +} else { + ret = link(from_name, to_name); + } + if (ret == 0 && verbose) + (void)printf("install: link %s -> %s\n", from_name, to_name); + return ret; } /* @@ -509,6 +516,8 @@ do_symlink(char *from_name, char *to_nam if (symlink(from_name, to_name) == -1) err(EXIT_FAILURE, "symlink %s -> %s", from_name, to_name); } + if (verbose) + (void)printf("install: symlink %s -> %s\n", from_name, to_name); } /* @@ -641,7 +650,7 @@ makelink(char *from_name, char *to_name) } /* - * If absolute or relative was not specified, + * If absolute or relative was not specified, * try the names the user provided */ do_symlink(from_name, to_name); @@ -821,6 +830,8 @@ install(char *from_name, char *to_name, err(EXIT_FAILURE, "%s: rename", to_name); to_name = oto_name; } + if (verbose) + (void)printf("install: %s -> %s\n", from_name, to_name); /* * If provided a set of flags, set them, otherwise, preserve the @@ -1116,12 +1127,12 @@ static void backup(const char *to_name) { char bname[FILENAME_MAX]; - + if (numberedbackup) { /* Do numbered backup */ int cnt; char suffix_expanded[FILENAME_MAX]; - + cnt=0; do { (void)snprintf(suffix_expanded, FILENAME_MAX, suffix, @@ -1129,13 +1140,16 @@ backup(const char *to_name) (void)snprintf(bname, FILENAME_MAX, "%s%s", to_name, suffix_expanded); cnt++; - } while (access(bname, F_OK) == 0); + } while (access(bname, F_OK) == 0); } else { /* Do simple backup */ (void)snprintf(bname, FILENAME_MAX, "%s%s", to_name, suffix); } - - (void)rename(to_name, bname); + + if (rename(to_name, bname) == 0) { + if (verbose) +
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: wiz Date: Fri May 10 09:14:52 UTC 2024 Modified Files: src/usr.bin/xinstall: install.1 xinstall.c Log Message: nstall(1): add support for -v Reviewed by rillig@ and thorpej@, thanks! To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xinstall/install.1 cvs rdiff -u -r1.127 -r1.128 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: rillig Date: Fri Oct 30 20:05:00 UTC 2020 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: install(1): copy metachar table from usr.bin/make It is not worth having a dependency on usr.bin/make just for including this small table. The header file usr.bin/make/make.h, which is included for consistency with the rest of the usr.bin/make code, is using inline functions a lot and refers to several parts of make that are completely irrelevant to usr.bin/install. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.125 -r1.126 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.28 src/usr.bin/xinstall/Makefile:1.29 --- src/usr.bin/xinstall/Makefile:1.28 Tue Sep 29 12:04:48 2020 +++ src/usr.bin/xinstall/Makefile Fri Oct 30 20:05:00 2020 @@ -1,16 +1,12 @@ -# $NetBSD: Makefile,v 1.28 2020/09/29 12:04:48 roy Exp $ +# $NetBSD: Makefile,v 1.29 2020/10/30 20:05:00 rillig Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include PROG= xinstall -SRCS= xinstall.c getid.c metachar.c +SRCS= xinstall.c getid.c MAN= install.1 -.PATH: ${NETBSDSRCDIR}/usr.bin/make -CPPFLAGS+= -I${NETBSDSRCDIR}/usr.bin/make -CPPFLAGS+= -DMAKE_NATIVE - .PATH: ${NETBSDSRCDIR}/usr.sbin/mtree CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.125 src/usr.bin/xinstall/xinstall.c:1.126 --- src/usr.bin/xinstall/xinstall.c:1.125 Tue May 31 06:55:02 2016 +++ src/usr.bin/xinstall/xinstall.c Fri Oct 30 20:05:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.125 2016/05/31 06:55:02 pgoyette Exp $ */ +/* $NetBSD: xinstall.c,v 1.126 2020/10/30 20:05:00 rillig Exp $ */ /* * Copyright (c) 1987, 1993 @@ -29,6 +29,35 @@ * SUCH DAMAGE. */ +/*- + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + #define __MKTEMP_OK__ /* All uses of mktemp have been checked */ #if HAVE_NBTOOL_CONFIG_H @@ -48,7 +77,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #else -__RCSID("$NetBSD: xinstall.c,v 1.125 2016/05/31 06:55:02 pgoyette Exp $"); +__RCSID("$NetBSD: xinstall.c,v 1.126 2020/10/30 20:05:00 rillig Exp $"); #endif #endif /* not lint */ @@ -84,7 +113,6 @@ __RCSID("$NetBSD: xinstall.c,v 1.125 201 #include "pathnames.h" #include "mtree.h" -#include "metachar.h" #define BACKUP_SUFFIX ".old" @@ -143,6 +171,7 @@ static void strip(const char *); __dead static void usage(void); static char *xbasename(char *); static char *xdirname(char *); +static int needshell(const char *, int); int main(int argc, char *argv[]) @@ -1286,3 +1315,58 @@ usage(void) prog, prog, prog); exit(1); } + +/* + * The following array is used to make a fast determination of which + * characters are interpreted specially by the shell. If a command + * contains any of these characters, it is executed by the shell, not + * directly by us. + */ +static unsigned char _metachar[128] = { +/*nul soh stx etx eot enq ack bel */ + 1,0,0,0,0,0,0,0, +/* bshtnlvtnpcrsosi */ + 0,0,1,0, 0,0,0,0, +/*dle dc1 dc2 dc3 dc4 nak syn etb */ + 0,0,0,
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: rillig Date: Fri Oct 30 20:05:00 UTC 2020 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: install(1): copy metachar table from usr.bin/make It is not worth having a dependency on usr.bin/make just for including this small table. The header file usr.bin/make/make.h, which is included for consistency with the rest of the usr.bin/make code, is using inline functions a lot and refers to several parts of make that are completely irrelevant to usr.bin/install. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.125 -r1.126 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: roy Date: Tue Sep 29 12:04:48 UTC 2020 Modified Files: src/usr.bin/xinstall: Makefile Log Message: xinstall: define MAKE_NATIVE so our make parts compile To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xinstall/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: roy Date: Tue Sep 29 12:04:48 UTC 2020 Modified Files: src/usr.bin/xinstall: Makefile Log Message: xinstall: define MAKE_NATIVE so our make parts compile To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xinstall/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.27 src/usr.bin/xinstall/Makefile:1.28 --- src/usr.bin/xinstall/Makefile:1.27 Mon Sep 7 00:26:24 2020 +++ src/usr.bin/xinstall/Makefile Tue Sep 29 12:04:48 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.27 2020/09/07 00:26:24 mrg Exp $ +# $NetBSD: Makefile,v 1.28 2020/09/29 12:04:48 roy Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include @@ -9,6 +9,7 @@ MAN= install.1 .PATH: ${NETBSDSRCDIR}/usr.bin/make CPPFLAGS+= -I${NETBSDSRCDIR}/usr.bin/make +CPPFLAGS+= -DMAKE_NATIVE .PATH: ${NETBSDSRCDIR}/usr.sbin/mtree CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: pgoyette Date: Tue May 31 06:55:02 UTC 2016 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Move __MKTEMP_OK up earlier so it has an actual impact. Reduces the number of warnings during build. XXX There are still some other warnings remaining to be resolved. Fixes PR bin/48195 although we really should go back someday and fix this correctly (by replacing all uses of mktemp(3)!) To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: pgoyette Date: Tue May 31 06:55:02 UTC 2016 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Move __MKTEMP_OK up earlier so it has an actual impact. Reduces the number of warnings during build. XXX There are still some other warnings remaining to be resolved. Fixes PR bin/48195 although we really should go back someday and fix this correctly (by replacing all uses of mktemp(3)!) To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.124 src/usr.bin/xinstall/xinstall.c:1.125 --- src/usr.bin/xinstall/xinstall.c:1.124 Fri Jun 19 17:20:02 2015 +++ src/usr.bin/xinstall/xinstall.c Tue May 31 06:55:02 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.124 2015/06/19 17:20:02 christos Exp $ */ +/* $NetBSD: xinstall.c,v 1.125 2016/05/31 06:55:02 pgoyette Exp $ */ /* * Copyright (c) 1987, 1993 @@ -29,6 +29,8 @@ * SUCH DAMAGE. */ +#define __MKTEMP_OK__ /* All uses of mktemp have been checked */ + #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #else @@ -46,11 +48,10 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #else -__RCSID("$NetBSD: xinstall.c,v 1.124 2015/06/19 17:20:02 christos Exp $"); +__RCSID("$NetBSD: xinstall.c,v 1.125 2016/05/31 06:55:02 pgoyette Exp $"); #endif #endif /* not lint */ -#define __MKTEMP_OK__ /* All uses of mktemp have been checked */ #include #include #include
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: dholland Date: Sat Oct 10 22:54:03 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile Log Message: Don't assume HAVE_POSIX_SPAWN when building a host prog. From Joachim Kuebart in PR 50301. needs pullup-7 To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xinstall/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: dholland Date: Sat Oct 10 22:54:03 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile Log Message: Don't assume HAVE_POSIX_SPAWN when building a host prog. From Joachim Kuebart in PR 50301. needs pullup-7 To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xinstall/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.25 src/usr.bin/xinstall/Makefile:1.26 --- src/usr.bin/xinstall/Makefile:1.25 Wed Jun 17 15:34:08 2015 +++ src/usr.bin/xinstall/Makefile Sat Oct 10 22:54:03 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.25 2015/06/17 15:34:08 christos Exp $ +# $NetBSD: Makefile,v 1.26 2015/10/10 22:54:03 dholland Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include @@ -12,9 +12,9 @@ CPPFLAGS+= -I${NETBSDSRCDIR}/usr.bin/mak .PATH: ${NETBSDSRCDIR}/usr.sbin/mtree CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree -CPPFLAGS+= -DHAVE_POSIX_SPAWN .if (${HOSTPROG:U} == "") +CPPFLAGS+= -DHAVE_POSIX_SPAWN DPADD+= ${LIBUTIL} LDADD+= -lutil .endif
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Fri Jun 19 14:32:56 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: restore use of whitespace needing shell. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Fri Jun 19 14:32:56 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: restore use of whitespace needing shell. To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.121 src/usr.bin/xinstall/xinstall.c:1.122 --- src/usr.bin/xinstall/xinstall.c:1.121 Wed Jun 17 11:52:37 2015 +++ src/usr.bin/xinstall/xinstall.c Fri Jun 19 10:32:56 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.121 2015/06/17 15:52:37 christos Exp $ */ +/* $NetBSD: xinstall.c,v 1.122 2015/06/19 14:32:56 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.121 2015/06/17 15:52:37 christos Exp $); +__RCSID($NetBSD: xinstall.c,v 1.122 2015/06/19 14:32:56 christos Exp $); #endif #endif /* not lint */ @@ -978,7 +978,7 @@ run(const char *command, const char *fla i = 1; status = 0; - if (hasmeta(command)) { + if (needshell(command, 1)) { rv = asprintf(cmd, %s %s%s%s, command, flags ? flags : , flags ? : , to_name); if (rv 0) {
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Fri Jun 19 17:20:02 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: remove unused label To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.123 src/usr.bin/xinstall/xinstall.c:1.124 --- src/usr.bin/xinstall/xinstall.c:1.123 Fri Jun 19 13:17:24 2015 +++ src/usr.bin/xinstall/xinstall.c Fri Jun 19 13:20:02 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.123 2015/06/19 17:17:24 christos Exp $ */ +/* $NetBSD: xinstall.c,v 1.124 2015/06/19 17:20:02 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.123 2015/06/19 17:17:24 christos Exp $); +__RCSID($NetBSD: xinstall.c,v 1.124 2015/06/19 17:20:02 christos Exp $); #endif #endif /* not lint */ @@ -1038,7 +1038,6 @@ run(const char *command, const char *fla } #endif rv = wait(status); -out1: if (cmd != to_name) free(cmd); out:
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Fri Jun 19 17:20:02 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: remove unused label To generate a diff of this commit: cvs rdiff -u -r1.123 -r1.124 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Fri Jun 19 17:17:24 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: remove useless assignment and explain why. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.122 src/usr.bin/xinstall/xinstall.c:1.123 --- src/usr.bin/xinstall/xinstall.c:1.122 Fri Jun 19 10:32:56 2015 +++ src/usr.bin/xinstall/xinstall.c Fri Jun 19 13:17:24 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.122 2015/06/19 14:32:56 christos Exp $ */ +/* $NetBSD: xinstall.c,v 1.123 2015/06/19 17:17:24 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.122 2015/06/19 14:32:56 christos Exp $); +__RCSID($NetBSD: xinstall.c,v 1.123 2015/06/19 17:17:24 christos Exp $); #endif #endif /* not lint */ @@ -1001,10 +1001,12 @@ run(const char *command, const char *fla rv = posix_spawn(NULL, command, NULL, NULL, args, NULL); else rv = posix_spawnp(NULL, command, NULL, NULL, args, NULL); - if (rv != 0) { + if (rv != 0) warnc(rv, Cannot execute %s, command); - rv = -1; - } + /* + * the wait below will fail if we did not create a child it will + * make rv negative. + */ #else switch (vfork()) { case -1: @@ -1036,6 +1038,7 @@ run(const char *command, const char *fla } #endif rv = wait(status); +out1: if (cmd != to_name) free(cmd); out:
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Fri Jun 19 17:17:24 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: remove useless assignment and explain why. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Wed Jun 17 15:34:08 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: Use the bourne shell if the after command has shell metachars. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.119 -r1.120 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.24 src/usr.bin/xinstall/Makefile:1.25 --- src/usr.bin/xinstall/Makefile:1.24 Mon Jun 15 12:33:38 2015 +++ src/usr.bin/xinstall/Makefile Wed Jun 17 11:34:08 2015 @@ -1,12 +1,15 @@ -# $NetBSD: Makefile,v 1.24 2015/06/15 16:33:38 christos Exp $ +# $NetBSD: Makefile,v 1.25 2015/06/17 15:34:08 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include bsd.own.mk PROG= xinstall -SRCS= xinstall.c getid.c +SRCS= xinstall.c getid.c metachar.c MAN= install.1 +.PATH: ${NETBSDSRCDIR}/usr.bin/make +CPPFLAGS+= -I${NETBSDSRCDIR}/usr.bin/make + .PATH: ${NETBSDSRCDIR}/usr.sbin/mtree CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree CPPFLAGS+= -DHAVE_POSIX_SPAWN Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.119 src/usr.bin/xinstall/xinstall.c:1.120 --- src/usr.bin/xinstall/xinstall.c:1.119 Mon Jun 15 12:33:38 2015 +++ src/usr.bin/xinstall/xinstall.c Wed Jun 17 11:34:08 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.119 2015/06/15 16:33:38 christos Exp $ */ +/* $NetBSD: xinstall.c,v 1.120 2015/06/17 15:34:08 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.119 2015/06/15 16:33:38 christos Exp $); +__RCSID($NetBSD: xinstall.c,v 1.120 2015/06/17 15:34:08 christos Exp $); #endif #endif /* not lint */ @@ -83,6 +83,7 @@ __RCSID($NetBSD: xinstall.c,v 1.119 201 #include pathnames.h #include mtree.h +#include metachar.h #define BACKUP_SUFFIX .old @@ -969,6 +970,7 @@ static void run(const char *command, const char *flags, const char *to_name, int errunlink) { char *args[4]; + char *cmd; int status; int rv; size_t i; @@ -976,10 +978,22 @@ run(const char *command, const char *fla i = 1; status = 0; + if (hasmeta(command)) { + rv = asprintf(cmd, %s %s%s%s, command, flags ? flags : , + flags ? : , to_name); + if (rv 0) { + warn(Cannot execute %s, command); + goto out; + } + command = _PATH_BSHELL; + flags = -c; + } else + cmd = __UNCONST(to_name); + args[0] = __UNCONST(command); if (flags) args[i++] = __UNCONST(flags); - args[i++] = __UNCONST(to_name); + args[i++] = cmd; args[i] = NULL; #ifdef HAVE_POSIX_SPAWN @@ -1018,11 +1032,14 @@ run(const char *command, const char *fla _exit(1); /*NOTREACHED*/ default: - rv = wait(status); break; } #endif - if ((rv == -1 || status) errunlink) + rv = wait(status); + if (cmd != to_name) + free(cmd); +out: + if ((rv 0 || status) errunlink) (void)unlink(to_name); }
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Wed Jun 17 15:34:08 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: Use the bourne shell if the after command has shell metachars. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.119 -r1.120 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/xinstall
On Jun 17, 11:07pm, t...@catvmics.ne.jp (Takeshi Nakayama) wrote: -- Subject: Re: CVS commit: src/usr.bin/xinstall | Christos Zoulas chris...@netbsd.org wrote | | | Module Name:src | Committed By: christos | Date: Mon Jun 15 16:33:38 UTC 2015 | | Modified Files: | src/usr.bin/xinstall: Makefile xinstall.c | | Log Message: | - improve error printing | - deduplicate run functions and don't use the shell so that we handle |filenames with spaces and metacharacters consistently. | | The latter change seems to make incompatibility as before: | | - wait(2) after posix_spawnp? is missing. | - don't unlink file when execution of strip(1) is failed. | | The following is a quick fix. Fixed, thanks! christos
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Wed Jun 17 15:52:37 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: restore unlink file if strip fails (from Takeshi Nakayama) To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.121 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.120 src/usr.bin/xinstall/xinstall.c:1.121 --- src/usr.bin/xinstall/xinstall.c:1.120 Wed Jun 17 11:34:08 2015 +++ src/usr.bin/xinstall/xinstall.c Wed Jun 17 11:52:37 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.120 2015/06/17 15:34:08 christos Exp $ */ +/* $NetBSD: xinstall.c,v 1.121 2015/06/17 15:52:37 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.120 2015/06/17 15:34:08 christos Exp $); +__RCSID($NetBSD: xinstall.c,v 1.121 2015/06/17 15:52:37 christos Exp $); #endif #endif /* not lint */ @@ -1059,7 +1059,7 @@ strip(const char *to_name) stripprog = _PATH_STRIP; #endif } - run(stripprog, stripArgs, to_name, 0); + run(stripprog, stripArgs, to_name, 1); } /*
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Wed Jun 17 15:52:37 UTC 2015 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: restore unlink file if strip fails (from Takeshi Nakayama) To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.121 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Mon Jun 15 16:33:38 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: - improve error printing - deduplicate run functions and don't use the shell so that we handle filenames with spaces and metacharacters consistently. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.23 src/usr.bin/xinstall/Makefile:1.24 --- src/usr.bin/xinstall/Makefile:1.23 Mon Jun 15 03:05:09 2015 +++ src/usr.bin/xinstall/Makefile Mon Jun 15 12:33:38 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.23 2015/06/15 07:05:09 martin Exp $ +# $NetBSD: Makefile,v 1.24 2015/06/15 16:33:38 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include bsd.own.mk @@ -8,7 +8,8 @@ SRCS= xinstall.c getid.c MAN= install.1 .PATH: ${NETBSDSRCDIR}/usr.sbin/mtree -CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree -DHAVE_POSIX_SPAWN +CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree +CPPFLAGS+= -DHAVE_POSIX_SPAWN .if (${HOSTPROG:U} == ) DPADD+= ${LIBUTIL} Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.118 src/usr.bin/xinstall/xinstall.c:1.119 --- src/usr.bin/xinstall/xinstall.c:1.118 Mon Jun 15 03:05:09 2015 +++ src/usr.bin/xinstall/xinstall.c Mon Jun 15 12:33:38 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $ */ +/* $NetBSD: xinstall.c,v 1.119 2015/06/15 16:33:38 christos Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $); +__RCSID($NetBSD: xinstall.c,v 1.119 2015/06/15 16:33:38 christos Exp $); #endif #endif /* not lint */ @@ -84,7 +84,6 @@ __RCSID($NetBSD: xinstall.c,v 1.118 201 #include pathnames.h #include mtree.h -#define STRIP_ARGS_MAX 32 #define BACKUP_SUFFIX .old static int dobackup, dodir, dostrip, dolink, dopreserve, dorename, dounpriv; @@ -137,7 +136,8 @@ static void makelink(char *, char *); static void metadata_log(const char *, const char *, struct timeval *, const char *, const char *, off_t); static int parseid(char *, id_t *); -static void strip(char *); +static void run(const char *, const char *, const char *, int); +static void strip(const char *); __dead static void usage(void); static char *xbasename(char *); static char *xdirname(char *); @@ -160,7 +160,8 @@ main(int argc, char *argv[]) case 'a': afterinstallcmd = strdup(optarg); if (afterinstallcmd == NULL) -errx(1, %s, strerror(ENOMEM)); +err(EXIT_FAILURE, +Can't allocate after command); break; case 'B': suffix = optarg; @@ -229,14 +230,14 @@ main(int argc, char *argv[]) dolink |= LN_RELATIVE; break; default: - errx(1, %c: invalid link type, *p); + errx(EXIT_FAILURE, %c: invalid link type, *p); /* NOTREACHED */ } break; case 'm': haveopt_m = 1; if (!(set = setmode(optarg))) -err(1, Cannot set file mode `%s', optarg); +err(EXIT_FAILURE, Cannot set file mode `%s', optarg); mode = getmode(set, 0); free(set); break; @@ -245,7 +246,7 @@ main(int argc, char *argv[]) break; case 'N': if (! setup_getid(optarg)) -errx(1, +errx(EXIT_FAILURE, Unable to use user and group databases in `%s', optarg); break; @@ -262,7 +263,7 @@ main(int argc, char *argv[]) case 'S': stripArgs = strdup(optarg); if (stripArgs == NULL) -errx(1, %s, strerror(ENOMEM)); +err(EXIT_FAILURE, Can't allocate options); /* fall through; -S implies -s */ /*FALLTHROUGH*/ case 's': @@ -320,7 +321,7 @@ main(int argc, char *argv[]) if (gid_from_group(group, gid) == -1) { id_t id; if (!parseid(group, id)) -errx(1, unknown group %s, group); +errx(EXIT_FAILURE, unknown group %s, group); gid = id; } iflags |= HASGID; @@ -329,7 +330,7 @@ main(int argc, char *argv[]) if (uid_from_user(owner, uid) == -1) { id_t id; if (!parseid(owner, id)) -errx(1, unknown user %s, owner); +errx(EXIT_FAILURE, unknown user %s, owner); uid = id; } iflags |= HASUID; @@ -338,7 +339,7 @@ main(int argc, char *argv[]) #if ! HAVE_NBTOOL_CONFIG_H if (fflags !dounpriv) { if (string_to_flags(fflags, fileflags, NULL)) - errx(1, %s: invalid flag, fflags); + errx(EXIT_FAILURE, %s: invalid flag, fflags); /* restore fflags since string_to_flags() changed it */ fflags = flags_to_string(fileflags, -); iflags |= SETFLAGS; @@ -375,12 +376,12 @@ main(int argc, char *argv[]) /* makelink() handles checks for links */
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Mon Jun 15 16:33:38 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: - improve error printing - deduplicate run functions and don't use the shell so that we handle filenames with spaces and metacharacters consistently. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: martin Date: Mon Jun 15 07:05:09 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: Add optional support for posix_spawn (instead of vfork) and enable it for the in-tree build. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: martin Date: Mon Jun 15 07:05:09 UTC 2015 Modified Files: src/usr.bin/xinstall: Makefile xinstall.c Log Message: Add optional support for posix_spawn (instead of vfork) and enable it for the in-tree build. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xinstall/Makefile cvs rdiff -u -r1.117 -r1.118 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.22 src/usr.bin/xinstall/Makefile:1.23 --- src/usr.bin/xinstall/Makefile:1.22 Wed Aug 17 14:00:30 2011 +++ src/usr.bin/xinstall/Makefile Mon Jun 15 07:05:09 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.22 2011/08/17 14:00:30 christos Exp $ +# $NetBSD: Makefile,v 1.23 2015/06/15 07:05:09 martin Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include bsd.own.mk @@ -8,7 +8,7 @@ SRCS= xinstall.c getid.c MAN= install.1 .PATH: ${NETBSDSRCDIR}/usr.sbin/mtree -CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree +CPPFLAGS+= -I${NETBSDSRCDIR}/usr.sbin/mtree -DHAVE_POSIX_SPAWN .if (${HOSTPROG:U} == ) DPADD+= ${LIBUTIL} Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.117 src/usr.bin/xinstall/xinstall.c:1.118 --- src/usr.bin/xinstall/xinstall.c:1.117 Sun Jul 6 20:54:47 2014 +++ src/usr.bin/xinstall/xinstall.c Mon Jun 15 07:05:09 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.117 2014/07/06 20:54:47 apb Exp $ */ +/* $NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.117 2014/07/06 20:54:47 apb Exp $); +__RCSID($NetBSD: xinstall.c,v 1.118 2015/06/15 07:05:09 martin Exp $); #endif #endif /* not lint */ @@ -72,6 +72,10 @@ __RCSID($NetBSD: xinstall.c,v 1.117 201 #include util.h #include vis.h +#ifdef HAVE_POSIX_SPAWN +#include spawn.h +#endif + #include md5.h #include rmd160.h #include sha1.h @@ -965,9 +969,16 @@ copy(int from_fd, char *from_name, int t static void strip(char *to_name) { + int status; +#ifdef HAVE_POSIX_SPAWN + char *args[4]; + const char *stripprog; + int rv; +#else static const char exec_failure[] = : exec of strip failed: ; - int serrno, status; - const char * volatile stripprog, *progname; + int serrno; + const char * volatile *progname, *stripprog; +#endif char *cmd; if ((stripprog = getenv(STRIP)) == NULL || *stripprog == '\0') { @@ -992,6 +1003,26 @@ strip(char *to_name) err(1, asprintf failed); } +#ifdef HAVE_POSIX_SPAWN + status = -1; + if (stripArgs) { + args[0] = __UNCONST(sh); + args[1] = __UNCONST(-c); + args[2] = cmd; + args[3] = NULL; + rv = posix_spawn(NULL, _PATH_BSHELL, NULL, NULL, args, NULL); + } else { + args[0] = __UNCONST(strip); + args[1] = to_name; + args[2] = NULL; + rv = posix_spawnp(NULL, stripprog, NULL, NULL, args, NULL); + } + + if (rv == 0) + wait(status); + if (rv || status == -1) + unlink(to_name); +#else switch (vfork()) { case -1: serrno = errno; @@ -1016,6 +1047,7 @@ strip(char *to_name) if (wait(status) == -1 || status) (void)unlink(to_name); } +#endif free(cmd); } @@ -1028,9 +1060,33 @@ strip(char *to_name) static void afterinstall(const char *command, const char *to_name, int errunlink) { - int serrno, status; +#ifdef HAVE_POSIX_SPAWN + char *args[4]; + int rv; +#else + int serrno; +#endif + int status; char *cmd; +#ifdef HAVE_POSIX_SPAWN + /* + * build up a command line and let /bin/sh + * parse the arguments + */ + asprintf(cmd, %s %s, command, to_name); + args[0] = __UNCONST(sh); + args[1] = __UNCONST(-c); + args[2] = cmd; + args[3] = NULL; + + rv = posix_spawn(NULL, _PATH_BSHELL, NULL, NULL, args, NULL); + if (rv == 0) + wait(status); + if ((rv || status == -1) errunlink) + (void)unlink(to_name); + free(cmd); +#else switch (vfork()) { case -1: serrno = errno; @@ -1061,6 +1117,7 @@ afterinstall(const char *command, const if ((wait(status) == -1 || status) errunlink) (void)unlink(to_name); } +#endif } /*
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: apb Date: Sun Jul 6 20:50:03 UTC 2014 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: When printing a timestamp to a metalog, use 9 digits for the nanoseconds part, except use only 1 digit if the value was zero. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.115 src/usr.bin/xinstall/xinstall.c:1.116 --- src/usr.bin/xinstall/xinstall.c:1.115 Tue Sep 6 18:50:32 2011 +++ src/usr.bin/xinstall/xinstall.c Sun Jul 6 20:50:03 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.115 2011/09/06 18:50:32 joerg Exp $ */ +/* $NetBSD: xinstall.c,v 1.116 2014/07/06 20:50:03 apb Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.115 2011/09/06 18:50:32 joerg Exp $); +__RCSID($NetBSD: xinstall.c,v 1.116 2014/07/06 20:50:03 apb Exp $); #endif #endif /* not lint */ @@ -1202,8 +1202,10 @@ metadata_log(const char *path, const cha if (*type == 'f') /* type=file */ fprintf(metafp, size=%lld, (long long)size); if (tv != NULL dopreserve) - fprintf(metafp, time=%lld.%ld, - (long long)tv[1].tv_sec, (long)tv[1].tv_usec); + fprintf(metafp, time=%lld.%0*ld, + (long long)tv[1].tv_sec, + (tv[1].tv_usec == 0 ? 1 : 9), + (long)tv[1].tv_usec); if (digestresult digest) fprintf(metafp, %s=%s, digest, digestresult); if (fflags)
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: apb Date: Sun Jul 6 20:54:47 UTC 2014 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: mtree spec files want nanoseconds, so multiply the microseconds by 1000. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.116 src/usr.bin/xinstall/xinstall.c:1.117 --- src/usr.bin/xinstall/xinstall.c:1.116 Sun Jul 6 20:50:03 2014 +++ src/usr.bin/xinstall/xinstall.c Sun Jul 6 20:54:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.116 2014/07/06 20:50:03 apb Exp $ */ +/* $NetBSD: xinstall.c,v 1.117 2014/07/06 20:54:47 apb Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT(@(#) Copyright (c) 1987, 19 #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.116 2014/07/06 20:50:03 apb Exp $); +__RCSID($NetBSD: xinstall.c,v 1.117 2014/07/06 20:54:47 apb Exp $); #endif #endif /* not lint */ @@ -1202,10 +1202,10 @@ metadata_log(const char *path, const cha if (*type == 'f') /* type=file */ fprintf(metafp, size=%lld, (long long)size); if (tv != NULL dopreserve) - fprintf(metafp, time=%lld.%0*ld, + fprintf(metafp, time=%lld.%0*lld, (long long)tv[1].tv_sec, (tv[1].tv_usec == 0 ? 1 : 9), - (long)tv[1].tv_usec); + (long long)tv[1].tv_usec * 1000); if (digestresult digest) fprintf(metafp, %s=%s, digest, digestresult); if (fflags)
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: apb Date: Sun Jul 6 20:50:03 UTC 2014 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: When printing a timestamp to a metalog, use 9 digits for the nanoseconds part, except use only 1 digit if the value was zero. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: apb Date: Sun Jul 6 20:54:47 UTC 2014 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: mtree spec files want nanoseconds, so multiply the microseconds by 1000. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: joerg Date: Tue Sep 6 18:50:33 UTC 2011 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Use static and __dead. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.114 src/usr.bin/xinstall/xinstall.c:1.115 --- src/usr.bin/xinstall/xinstall.c:1.114 Thu Nov 12 10:10:49 2009 +++ src/usr.bin/xinstall/xinstall.c Tue Sep 6 18:50:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.114 2009/11/12 10:10:49 tron Exp $ */ +/* $NetBSD: xinstall.c,v 1.115 2011/09/06 18:50:32 joerg Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.114 2009/11/12 10:10:49 tron Exp $); +__RCSID($NetBSD: xinstall.c,v 1.115 2011/09/06 18:50:32 joerg Exp $); #endif #endif /* not lint */ @@ -83,21 +83,21 @@ #define STRIP_ARGS_MAX 32 #define BACKUP_SUFFIX .old -int dobackup, dodir, dostrip, dolink, dopreserve, dorename, dounpriv; -int haveopt_f, haveopt_g, haveopt_m, haveopt_o; -int numberedbackup; -int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; -char pathbuf[MAXPATHLEN]; -uid_t uid = -1; -gid_t gid = -1; -char *group, *owner, *fflags, *tags; -FILE *metafp; -char *metafile; -u_long fileflags; -char *stripArgs; -char *afterinstallcmd; -const char *suffix = BACKUP_SUFFIX; -char *destdir; +static int dobackup, dodir, dostrip, dolink, dopreserve, dorename, dounpriv; +static int haveopt_f, haveopt_g, haveopt_m, haveopt_o; +static int numberedbackup; +static int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; +static char pathbuf[MAXPATHLEN]; +static uid_t uid = -1; +static gid_t gid = -1; +static char *group, *owner, *fflags, *tags; +static FILE *metafp; +static char *metafile; +static u_long fileflags; +static char *stripArgs; +static char *afterinstallcmd; +static const char *suffix = BACKUP_SUFFIX; +static char *destdir; enum { DIGEST_NONE = 0, @@ -108,7 +108,8 @@ DIGEST_SHA384, DIGEST_SHA512, } digesttype = DIGEST_NONE; -char *digest; + +static char *digest; #define LN_ABSOLUTE 0x01 #define LN_RELATIVE 0x02 @@ -121,22 +122,21 @@ #define HASUID 0x04 /* Tell install the uid was given */ #define HASGID 0x08 /* Tell install the gid was given */ -void afterinstall(const char *, const char *, int); -void backup(const char *); -char *copy(int, char *, int, char *, off_t); -int do_link(char *, char *); -void do_symlink(char *, char *); -void install(char *, char *, u_int); -void install_dir(char *, u_int); -int main(int, char *[]); -void makelink(char *, char *); -void metadata_log(const char *, const char *, struct timeval *, +static void afterinstall(const char *, const char *, int); +static void backup(const char *); +static char *copy(int, char *, int, char *, off_t); +static int do_link(char *, char *); +static void do_symlink(char *, char *); +static void install(char *, char *, u_int); +static void install_dir(char *, u_int); +static void makelink(char *, char *); +static void metadata_log(const char *, const char *, struct timeval *, const char *, const char *, off_t); -int parseid(char *, id_t *); -void strip(char *); -void usage(void); -char *xbasename(char *); -char *xdirname(char *); +static int parseid(char *, id_t *); +static void strip(char *); +__dead static void usage(void); +static char *xbasename(char *); +static char *xdirname(char *); int main(int argc, char *argv[]) @@ -403,7 +403,7 @@ * parseid -- * parse uid or gid from arg into id, returning non-zero if successful */ -int +static int parseid(char *name, id_t *id) { char *ep; @@ -420,7 +420,7 @@ * make a hard link, obeying dorename if set * return -1 on failure */ -int +static int do_link(char *from_name, char *to_name) { char tmpl[MAXPATHLEN]; @@ -450,7 +450,7 @@ * make a symbolic link, obeying dorename if set * exit on failure */ -void +static void do_symlink(char *from_name, char *to_name) { char tmpl[MAXPATHLEN]; @@ -478,7 +478,7 @@ * makelink -- * make a link from source to destination */ -void +static void makelink(char *from_name, char *to_name) { char src[MAXPATHLEN], dst[MAXPATHLEN], lnk[MAXPATHLEN]; @@ -616,7 +616,7 @@ * install -- * build a path name and install the file */ -void +static void install(char *from_name, char *to_name, u_int flags) { struct stat from_sb; @@ -808,7 +808,7 @@ * * If to_fd 0, just calculate a digest, don't copy. */ -char * +static char * copy(int from_fd, char *from_name, int to_fd, char *to_name, off_t size) { ssize_t nr, nw; @@ -962,7 +962,7 @@ * strip -- * use strip(1) to strip the target file */ -void +static void strip(char *to_name) { static const char exec_failure[]
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: joerg Date: Tue Sep 6 18:50:33 UTC 2011 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Use static and __dead. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Wed Aug 17 14:00:31 UTC 2011 Modified Files: src/usr.bin/xinstall: Makefile Log Message: document non-literal format strings To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xinstall/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/Makefile diff -u src/usr.bin/xinstall/Makefile:1.21 src/usr.bin/xinstall/Makefile:1.22 --- src/usr.bin/xinstall/Makefile:1.21 Sat Dec 16 07:59:17 2006 +++ src/usr.bin/xinstall/Makefile Wed Aug 17 10:00:30 2011 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.21 2006/12/16 12:59:17 bouyer Exp $ +# $NetBSD: Makefile,v 1.22 2011/08/17 14:00:30 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 .include bsd.own.mk @@ -15,6 +15,8 @@ LDADD+= -lutil .endif +COPTS.xinstall.c += -Wno-format-nonliteral + PROGNAME=install
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: christos Date: Wed Aug 17 14:00:31 UTC 2011 Modified Files: src/usr.bin/xinstall: Makefile Log Message: document non-literal format strings To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xinstall/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: joerg Date: Fri May 14 17:03:19 UTC 2010 Modified Files: src/usr.bin/xinstall: install.1 Log Message: Reorder sections to canonical order. Use .Ex -std. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xinstall/install.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/install.1 diff -u src/usr.bin/xinstall/install.1:1.44 src/usr.bin/xinstall/install.1:1.45 --- src/usr.bin/xinstall/install.1:1.44 Fri May 1 21:38:19 2009 +++ src/usr.bin/xinstall/install.1 Fri May 14 17:03:19 2010 @@ -1,4 +1,4 @@ -.\ $NetBSD: install.1,v 1.44 2009/05/01 21:38:19 wiz Exp $ +.\ $NetBSD: install.1,v 1.45 2010/05/14 17:03:19 joerg Exp $ .\ .\ Copyright (c) 1987, 1990, 1993 .\ The Regents of the University of California. All rights reserved. @@ -378,11 +378,6 @@ Installing .Pa /dev/null creates an empty file. -.Sh EXIT STATUS -The -.Nm -utility exits 0 on success, -and \*[Gt]0 if an error occurs. .Sh ENVIRONMENT .Bl -tag -width Fl .It Ev STRIP @@ -393,6 +388,8 @@ .Pa /usr/bin/strip is used. .El +.Sh EXIT STATUS +.Ex -std .Sh SEE ALSO .Xr chflags 1 , .Xr chgrp 1 ,
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: joerg Date: Fri May 14 17:03:19 UTC 2010 Modified Files: src/usr.bin/xinstall: install.1 Log Message: Reorder sections to canonical order. Use .Ex -std. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xinstall/install.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: tron Date: Thu Nov 12 10:10:49 UTC 2009 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Don't assume that id_t, gid_t and uid_t use the same underlying type and use the appropriate types instead. Tested under NetBSD 5.99.22 and Darwin 10.2.0. This should fix one of the cross-builds under FreeBSD as reported by Rhialto on the current-users mailing list. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.113 src/usr.bin/xinstall/xinstall.c:1.114 --- src/usr.bin/xinstall/xinstall.c:1.113 Fri Oct 30 20:57:30 2009 +++ src/usr.bin/xinstall/xinstall.c Thu Nov 12 10:10:49 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.113 2009/10/30 20:57:30 joerg Exp $ */ +/* $NetBSD: xinstall.c,v 1.114 2009/11/12 10:10:49 tron Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.113 2009/10/30 20:57:30 joerg Exp $); +__RCSID($NetBSD: xinstall.c,v 1.114 2009/11/12 10:10:49 tron Exp $); #endif #endif /* not lint */ @@ -88,7 +88,8 @@ int numberedbackup; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; char pathbuf[MAXPATHLEN]; -id_t uid = -1, gid = -1; +uid_t uid = -1; +gid_t gid = -1; char *group, *owner, *fflags, *tags; FILE *metafp; char *metafile; @@ -312,13 +313,21 @@ /* get group and owner id's */ if (group !dounpriv) { - if (gid_from_group(group, gid) == -1 ! parseid(group, gid)) - errx(1, unknown group %s, group); + if (gid_from_group(group, gid) == -1) { + id_t id; + if (!parseid(group, id)) +errx(1, unknown group %s, group); + gid = id; + } iflags |= HASGID; } if (owner !dounpriv) { - if (uid_from_user(owner, uid) == -1 ! parseid(owner, uid)) - errx(1, unknown user %s, owner); + if (uid_from_user(owner, uid) == -1) { + id_t id; + if (!parseid(owner, id)) +errx(1, unknown user %s, owner); + uid = id; + } iflags |= HASUID; }
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: joerg Date: Fri Oct 30 20:57:30 UTC 2009 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Only trust STRIP from environment if it is non-empty. Some packages set STRIP in Makefiles and that makes install -s fail badly. OK apb@ To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.112 src/usr.bin/xinstall/xinstall.c:1.113 --- src/usr.bin/xinstall/xinstall.c:1.112 Sat Jul 25 11:45:58 2009 +++ src/usr.bin/xinstall/xinstall.c Fri Oct 30 20:57:30 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.112 2009/07/25 11:45:58 gson Exp $ */ +/* $NetBSD: xinstall.c,v 1.113 2009/10/30 20:57:30 joerg Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.112 2009/07/25 11:45:58 gson Exp $); +__RCSID($NetBSD: xinstall.c,v 1.113 2009/10/30 20:57:30 joerg Exp $); #endif #endif /* not lint */ @@ -961,7 +961,7 @@ const char * volatile stripprog, *progname; char *cmd; - if ((stripprog = getenv(STRIP)) == NULL) { + if ((stripprog = getenv(STRIP)) == NULL || *stripprog == '\0') { #ifdef TARGET_STRIP stripprog = TARGET_STRIP; #else
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: gson Date: Sat Jul 25 11:45:58 UTC 2009 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: When installing via a temporary file, base the name of the temporary file on the name of the target file, not just the target directory, to ensure uniqueness when multiple concurrent invocations of install(1) simultaneously install files in the same directory. Fixes bin/41512. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.111 src/usr.bin/xinstall/xinstall.c:1.112 --- src/usr.bin/xinstall/xinstall.c:1.111 Mon Jun 8 21:58:44 2009 +++ src/usr.bin/xinstall/xinstall.c Sat Jul 25 11:45:58 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.111 2009/06/08 21:58:44 yamt Exp $ */ +/* $NetBSD: xinstall.c,v 1.112 2009/07/25 11:45:58 gson Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.111 2009/06/08 21:58:44 yamt Exp $); +__RCSID($NetBSD: xinstall.c,v 1.112 2009/07/25 11:45:58 gson Exp $); #endif #endif /* not lint */ @@ -418,8 +418,7 @@ int ret; if (dorename) { - (void)snprintf(tmpl, sizeof(tmpl), %s/inst.XX, - xdirname(to_name)); + (void)snprintf(tmpl, sizeof(tmpl), %s.inst.XX, to_name); /* This usage is safe. */ if (mktemp(tmpl) == NULL) err(1, %s: mktemp, tmpl); @@ -448,8 +447,7 @@ char tmpl[MAXPATHLEN]; if (dorename) { - (void)snprintf(tmpl, sizeof(tmpl), %s/inst.XX, - xdirname(to_name)); + (void)snprintf(tmpl, sizeof(tmpl), %s.inst.XX, to_name); /* This usage is safe. */ if (mktemp(tmpl) == NULL) err(1, %s: mktemp, tmpl); @@ -668,8 +666,7 @@ (void)chflags(to_name, to_sb.st_flags ~(NOCHANGEBITS)); #endif if (dorename) { - (void)snprintf(tmpl, sizeof(tmpl), %s/inst.XX, - xdirname(to_name)); + (void)snprintf(tmpl, sizeof(tmpl), %s.inst.XX, to_name); oto_name = to_name; to_name = tmpl; } else {
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: gson Date: Mon Jun 8 14:22:01 UTC 2009 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: Fix race condition causing install -d to randomly fail when multiple concurrent install processes try to create the same directory. Modelled after the code handling the mkdir -p case in mkdir(1). To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.109 src/usr.bin/xinstall/xinstall.c:1.110 --- src/usr.bin/xinstall/xinstall.c:1.109 Fri May 1 20:16:23 2009 +++ src/usr.bin/xinstall/xinstall.c Mon Jun 8 14:22:01 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.109 2009/05/01 20:16:23 apb Exp $ */ +/* $NetBSD: xinstall.c,v 1.110 2009/06/08 14:22:01 gson Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.109 2009/05/01 20:16:23 apb Exp $); +__RCSID($NetBSD: xinstall.c,v 1.110 2009/06/08 14:22:01 gson Exp $); #endif #endif /* not lint */ @@ -1104,13 +1104,21 @@ if (!*p || (p != path *p == '/')) { ch = *p; *p = '\0'; -if (stat(path, sb)) { -if (errno != ENOENT || mkdir(path, 0777) 0) { +if (mkdir(path, 0777) 0) { +/* + * Can't create; path exists or no perms. + * stat() path to determine what's there now. + */ +int sverrno; +sverrno = errno; +if (stat(path, sb) 0) { + /* Not there; use mkdir()s error */ + errno = sverrno; err(1, %s: mkdir, path); } -} - else if (!S_ISDIR(sb.st_mode)) { -errx(1, %s exists but is not a directory, path); +if (!S_ISDIR(sb.st_mode)) { + errx(1, %s exists but is not a directory, path); +} } if (!(*p = ch)) break;
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: yamt Date: Mon Jun 8 21:58:44 UTC 2009 Modified Files: src/usr.bin/xinstall: xinstall.c Log Message: tabify and wrap long lines. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.110 src/usr.bin/xinstall/xinstall.c:1.111 --- src/usr.bin/xinstall/xinstall.c:1.110 Mon Jun 8 14:22:01 2009 +++ src/usr.bin/xinstall/xinstall.c Mon Jun 8 21:58:44 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.110 2009/06/08 14:22:01 gson Exp $ */ +/* $NetBSD: xinstall.c,v 1.111 2009/06/08 21:58:44 yamt Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = @(#)xinstall.c 8.1 (Berkeley) 7/21/93; #else -__RCSID($NetBSD: xinstall.c,v 1.110 2009/06/08 14:22:01 gson Exp $); +__RCSID($NetBSD: xinstall.c,v 1.111 2009/06/08 21:58:44 yamt Exp $); #endif #endif /* not lint */ @@ -1096,15 +1096,15 @@ void install_dir(char *path, u_int flags) { -char *p; -struct stat sb; -int ch; - -for (p = path;; ++p) -if (!*p || (p != path *p == '/')) { -ch = *p; -*p = '\0'; -if (mkdir(path, 0777) 0) { + char *p; + struct stat sb; + int ch; + + for (p = path;; ++p) + if (!*p || (p != path *p == '/')) { + ch = *p; + *p = '\0'; + if (mkdir(path, 0777) 0) { /* * Can't create; path exists or no perms. * stat() path to determine what's there now. @@ -1115,14 +1115,16 @@ /* Not there; use mkdir()s error */ errno = sverrno; err(1, %s: mkdir, path); -} +} if (!S_ISDIR(sb.st_mode)) { - errx(1, %s exists but is not a directory, path); + errx(1, + %s exists but is not a directory, + path); } } -if (!(*p = ch)) + if (!(*p = ch)) break; -} + } if (afterinstallcmd != NULL) afterinstall(afterinstallcmd, path, 0); @@ -1130,7 +1132,7 @@ if (!dounpriv ( ((flags (HASUID | HASGID)) chown(path, uid, gid) == -1) || chmod(path, mode) == -1 )) { -warn(%s: chown/chmod, path); + warn(%s: chown/chmod, path); } metadata_log(path, dir, NULL, NULL, NULL, 0); }
CVS commit: src/usr.bin/xinstall
Module Name:src Committed By: wiz Date: Fri May 1 21:38:19 UTC 2009 Modified Files: src/usr.bin/xinstall: install.1 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/usr.bin/xinstall/install.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/xinstall/install.1 diff -u src/usr.bin/xinstall/install.1:1.43 src/usr.bin/xinstall/install.1:1.44 --- src/usr.bin/xinstall/install.1:1.43 Fri May 1 20:16:23 2009 +++ src/usr.bin/xinstall/install.1 Fri May 1 21:38:19 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: install.1,v 1.43 2009/05/01 20:16:23 apb Exp $ +.\ $NetBSD: install.1,v 1.44 2009/05/01 21:38:19 wiz Exp $ .\ .\ Copyright (c) 1987, 1990, 1993 .\ The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\ .\ @(#)install.1 8.1 (Berkeley) 6/6/93 .\ -.Dd January 29, 2003 +.Dd May 1, 2009 .Dt INSTALL 1 .Os .Sh NAME