Add '-N dbdir', to specify that user & group lookups are to be done from

dbdir/master.passwd and dbdir/group, using simple text file parsing
routines from ../../usr.sbin/mtree/getid.c.
This commit is contained in:
lukem 2002-12-19 08:30:39 +00:00
parent 9980e6b848
commit c7c281222a
3 changed files with 58 additions and 37 deletions

View File

@ -1,13 +1,14 @@
# $NetBSD: Makefile,v 1.17 2002/09/18 14:00:44 lukem Exp $
# $NetBSD: Makefile,v 1.18 2002/12/19 08:30:39 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
.include <bsd.own.mk>
PROG= xinstall
SRCS= ${HOSTPROG:D:Ustat_flags.c} xinstall.c
SRCS= ${HOSTPROG:D:Ustat_flags.c} xinstall.c getid.c
MAN= install.1
.PATH: ${NETBSDSRCDIR}/bin/ls
CPPFLAGS+= -I${NETBSDSRCDIR}/bin/ls
.PATH: ${NETBSDSRCDIR}/bin/ls ${NETBSDSRCDIR}/usr.sbin/mtree
CPPFLAGS+= -I${NETBSDSRCDIR}/bin/ls -I${NETBSDSRCDIR}/usr.sbin/mtree
PROGNAME=install

View File

@ -1,4 +1,4 @@
.\" $NetBSD: install.1,v 1.31 2002/09/30 11:09:18 grant Exp $
.\" $NetBSD: install.1,v 1.32 2002/12/19 08:30:39 lukem Exp $
.\"
.\" Copyright (c) 1987, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -33,7 +33,7 @@
.\"
.\" @(#)install.1 8.1 (Berkeley) 6/6/93
.\"
.Dd March 20, 2002
.Dd December 19, 2002
.Dt INSTALL 1
.Os
.Sh NAME
@ -61,6 +61,9 @@
.Op Fl m Ar mode
.Ek
.Bk -words
.Op Fl N Ar dbdir
.Ek
.Bk -words
.Op Fl o Ar owner
.Ek
.Bk -words
@ -94,6 +97,9 @@
.Op Fl m Ar mode
.Ek
.Bk -words
.Op Fl N Ar dbdir
.Ek
.Bk -words
.Op Fl o Ar owner
.Ek
.Bk -words
@ -123,6 +129,9 @@
.Op Fl m Ar mode
.Ek
.Bk -words
.Op Fl N Ar dbdir
.Ek
.Bk -words
.Op Fl o Ar owner
.Ek
.Bk -words
@ -204,21 +213,6 @@ Specify the target's file flags.
for a list of possible flags and their meanings.)
.It Fl g Ar group
Specify a group.
.It Fl M Ar metalog
Write the metadata associated with each item installed to
.Ar metalog
in an
.Xr mtree 8
.Dq full path
specification line.
The metadata includes: the file name and file type, and depending upon
other options, the owner, group, file flags, modification time, and tags.
.It Fl m Ar mode
Specify an alternative mode.
The default mode is set to rwxr-xr-x (0755).
The specified mode may be either an octal or symbolic value; see
.Xr chmod 1
for a description of possible mode values.
.It Fl l Ar linkflags
Instead of copying the file make a link to the source.
The type of the link is determined by the
@ -240,6 +234,33 @@ are:
Absolute and relative have effect only for symbolic links.
Mixed links
are hard links for files on the same filesystem, symbolic otherwise.
.It Fl M Ar metalog
Write the metadata associated with each item installed to
.Ar metalog
in an
.Xr mtree 8
.Dq full path
specification line.
The metadata includes: the file name and file type, and depending upon
other options, the owner, group, file flags, modification time, and tags.
.It Fl m Ar mode
Specify an alternative mode.
The default mode is set to rwxr-xr-x (0755).
The specified mode may be either an octal or symbolic value; see
.Xr chmod 1
for a description of possible mode values.
.It Fl N Ar dbdir
Use the user database text file
.Pa master.passwd
and group database text file
.Pa group
from
.Ar dbdir ,
rather than using the results from the system's
.Xr getpwnam 3
and
.Xr getgrnam 3
(and related) library calls.
.It Fl o Ar owner
Specify an owner.
.It Fl p

View File

@ -1,4 +1,4 @@
/* $NetBSD: xinstall.c,v 1.73 2002/06/09 04:16:39 lukem Exp $ */
/* $NetBSD: xinstall.c,v 1.74 2002/12/19 08:30:39 lukem Exp $ */
/*
* Copyright (c) 1987, 1993
@ -50,7 +50,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
#if 0
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
#else
__RCSID("$NetBSD: xinstall.c,v 1.73 2002/06/09 04:16:39 lukem Exp $");
__RCSID("$NetBSD: xinstall.c,v 1.74 2002/12/19 08:30:39 lukem Exp $");
#endif
#endif /* not lint */
@ -75,6 +75,7 @@ __RCSID("$NetBSD: xinstall.c,v 1.73 2002/06/09 04:16:39 lukem Exp $");
#include "pathnames.h"
#include "stat_flags.h"
#include "mtree.h"
#define STRIP_ARGS_MAX 32
#define BACKUP_SUFFIX ".old"
@ -132,7 +133,7 @@ main(int argc, char *argv[])
setprogname(argv[0]);
iflags = 0;
while ((ch = getopt(argc, argv, "a:cbB:df:g:l:m:M:o:prsS:T:U")) != -1)
while ((ch = getopt(argc, argv, "a:cbB:df:g:l:m:M:N:o:prsS:T:U")) != -1)
switch((char)ch) {
case 'a':
afterinstallcmd = strdup(optarg);
@ -211,6 +212,12 @@ main(int argc, char *argv[])
case 'M':
metafile = optarg;
break;
case 'N':
if (! setup_getid(optarg))
errx(1,
"Unable to use user and group databases in `%s'",
optarg);
break;
case 'o':
owner = optarg;
break;
@ -256,20 +263,12 @@ main(int argc, char *argv[])
/* get group and owner id's */
if (group && !dounpriv) {
struct group *gp;
if ((gp = getgrnam(group)) != NULL)
gid = gp->gr_gid;
else if (! parseid(group, &gid))
if (gid_from_group(group, &gid) == -1 && ! parseid(group, &gid))
errx(1, "unknown group %s", group);
iflags |= HASGID;
}
if (owner && !dounpriv) {
struct passwd *pp;
if ((pp = getpwnam(owner)) != NULL)
uid = pp->pw_uid;
else if (! parseid(owner, &uid))
if (uid_from_user(owner, &uid) == -1 && ! parseid(owner, &uid))
errx(1, "unknown user %s", owner);
iflags |= HASUID;
}
@ -1007,13 +1006,13 @@ usage(void)
(void)fprintf(stderr,
"usage: %s [-Ubcprs] [-M log] [-T tags] [-B suffix] [-a afterinstallcmd]\n"
" [-f flags] [-m mode] [-o owner] [-g group] [-l linkflags]\n"
" [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group] [-l linkflags]\n"
" [-S stripflags] file1 file2\n"
" %s [-Ubcprs] [-M log] [-T tags] [-B suffix] [-a afterinstallcmd]\n"
" [-f flags] [-m mode] [-o owner] [-g group] [-l linkflags]\n"
" [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group] [-l linkflags]\n"
" [-S stripflags] file1 ... fileN directory\n"
" %s -d [-Up] [-M log] [-T tags] [-a afterinstallcmd] [-m mode]\n"
" [-o owner] [-g group] directory ...\n",
" [-N dbdir] [-o owner] [-g group] directory ...\n",
prog, prog, prog);
exit(1);
}