Commit Graph

8888 Commits

Author SHA1 Message Date
Tim Kientzle
af03c60c06 Preserve ownership if cpio is run as root. 2008-07-06 16:39:18 +00:00
Colin Percival
a6d7fc3469 Move duplicated code from tar_mode_[cru] into archive_write.
Fix a bug I introduced 7 minutes ago: clean up properly from archive_write
if we exit the argv-handling loop due to -C not having an argument.
2008-07-05 08:10:55 +00:00
Colin Percival
d47b2ddb21 Use malloc in write_archive to allocate a 64kB buffer for holding file data
instead of using 64kB of stack space in copy_file_data and write_file_data.
2008-07-05 08:03:08 +00:00
Colin Percival
85f32b2087 Clean up write_entry by eliminating fd except in the #ifdef __linux block
where it is used. [1]

Don't leak file descriptors in write_entry_backend if archive_write_header
returns ARCHIVE_FAILED.

Found by:	Coverity Prevent [1]
2008-07-05 06:05:34 +00:00
Tim Kientzle
ba779d5afd bsdcpio is now at version 1.0.0. 2008-07-05 05:17:33 +00:00
Tim Kientzle
0d35b0da0c In -pl mode, only hardlink regular files. I need to test
other implementations, but it's clear that dirs and symlinks,
at least, shouldn't be hardlinked.
2008-07-05 05:16:23 +00:00
Tim Kientzle
2ebfcda850 Remove an unused define. 2008-07-05 05:15:07 +00:00
Colin Percival
9af6e14a8c Revert CVS revision 1.68; it is now possible for entry to be NULL at the end
of write_entry.  (This was perfectly safe, since archive_entry_free(NULL) is
a no-op, but adding the check back makes the style more consistent.)
2008-07-05 02:21:51 +00:00
Tim Kientzle
6481fd43de FreeBSD-CURRENT bsdtar is synched up with libarchive-portable 2.5.5. 2008-07-05 02:09:54 +00:00
Tim Kientzle
aec34fd22e Remove HAVE_STRUCT_STAT_ST_RDEV, as it's not used anywhere. 2008-07-05 02:09:13 +00:00
Tim Kientzle
f12440da1e Stop using the deprecated linux/ext2_fs.h. 2008-07-05 02:06:55 +00:00
Tim Kientzle
fe8c1d9768 Use %H:%M for strftime() time formatting instead of the non-portable %R. 2008-07-05 02:05:55 +00:00
Edwin Groothuis
fffd993df2 On 64 bit architectures, you can run 32 bit executables and the rtld can trace them, but ldd(1) doesn't know yet how to detect them:
[/] root@ed-exigent>ldd `which httpd`
    ldd: /usr/local/sbin/httpd: can't read program header
    ldd: /usr/local/sbin/httpd: not a dynamic executable

    But...

    [/] root@ed-exigent>LD_32_TRACE_LOADED_OBJECTS==1 `which httpd`
    libm.so.4 => /lib32//libm.so.4 (0x280c8000)
    libaprutil-1.so.2 => /usr/local/lib/libaprutil-1.so.2 (0x280de000)
    libexpat.so.6 => /usr/local/lib/libexpat.so.6 (0x280f2000)
    libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x28110000)
    libapr-1.so.2 => /usr/local/lib/libapr-1.so.2 (0x281fd000)
    libcrypt.so.3 => /lib32//libcrypt.so.3 (0x2821d000)
    libpthread.so.2 => not found (0x0)
    libc.so.6 => /lib32//libc.so.6 (0x28235000)
    libpthread.so.2 => /usr/lib32/libpthread.so.2 (0x2830d000)

Added support in ldd(1) for the LD_32_xxx environment variables if
the architecture of the machine is >32 bits. If we ever go to 128
bit architectures this excercise will have to be repeated but thanks
to earlier commits today it will be relative simple.

PR:		bin/124906
Submitted by:	edwin
Approved by:	bde (mentor)
MFC after:	1 week
2008-07-03 22:37:51 +00:00
Edwin Groothuis
d3c1e14b41 Extract the determination of the kind of (dynamic) executable from
the main-loop into a seperate function.
Instead of using hardcoded environment variables, define them in a
lookup table.
For the rest, no functionality changes.

Approved by:	bde (mentor)
MFC after:	1 week
2008-07-03 22:30:18 +00:00
Edwin Groothuis
a0d476a986 stylify ldd.c, no functional changes.
Approved by:	bde (mentor)
MFC after:	1 week
2008-07-03 22:26:43 +00:00
Daniel Gerzo
9ea29562d9 - add the -m option to the example commands because they would fail w/o it
as the ``man'' user does not have a valid shell by default.

PR:		docs/121713
Approved by:	trhodes
MFC after:	3 days
2008-07-01 20:56:23 +00:00
Tim Kientzle
77f719e605 Don't try to hardlink directories. While I'm here, expand some
comments to make this section of code a little clearer.
2008-07-01 05:45:03 +00:00
Xin LI
a9f1ad5de1 Reflect the fact that we actually have NetBSD revision 1.3. 2008-06-30 23:53:15 +00:00
Xin LI
fec65af1ca Remove clause 3 and 4 of NetBSD license.
Obtained from:	NetBSD
2008-06-30 23:23:31 +00:00
Xin LI
0889440a08 Make it clear that gzcat expects each argument to be separate files.
PR:		docs/123010
Submitted by:	Andrew Wright <andrewhw ieee org>
MFC after:	2 weeks
2008-06-30 17:45:47 +00:00
Dag-Erling Smørgrav
91fad6b28d Update man page for -t. 2008-06-30 17:16:05 +00:00
Dag-Erling Smørgrav
ec7bd62201 Quick shot at implementing -t (test).
Requested by:	ache
MFC after:	2 weeks
2008-06-30 17:11:27 +00:00
David E. O'Brien
1082b19643 Note that the .POSIX special target disables the "Remaking Makefiles" feature. 2008-06-27 14:35:33 +00:00
John Baldwin
6bc1e9cd84 Rework the lifetime management of the kernel implementation of POSIX
semaphores.  Specifically, semaphores are now represented as new file
descriptor type that is set to close on exec.  This removes the need for
all of the manual process reference counting (and fork, exec, and exit
event handlers) as the normal file descriptor operations handle all of
that for us nicely.  It is also suggested as one possible implementation
in the spec and at least one other OS (OS X) uses this approach.

Some bugs that were fixed as a result include:
- References to a named semaphore whose name is removed still work after
  the sem_unlink() operation.  Prior to this patch, if a semaphore's name
  was removed, valid handles from sem_open() would get EINVAL errors from
  sem_getvalue(), sem_post(), etc.  This fixes that.
- Unnamed semaphores created with sem_init() were not cleaned up when a
  process exited or exec'd.  They were only cleaned up if the process
  did an explicit sem_destroy().  This could result in a leak of semaphore
  objects that could never be cleaned up.
- On the other hand, if another process guessed the id (kernel pointer to
  'struct ksem' of an unnamed semaphore (created via sem_init)) and had
  write access to the semaphore based on UID/GID checks, then that other
  process could manipulate the semaphore via sem_destroy(), sem_post(),
  sem_wait(), etc.
- As part of the permission check (UID/GID), the umask of the proces
  creating the semaphore was not honored.  Thus if your umask denied group
  read/write access but the explicit mode in the sem_init() call allowed
  it, the semaphore would be readable/writable by other users in the
  same group, for example.  This includes access via the previous bug.
- If the module refused to unload because there were active semaphores,
  then it might have deregistered one or more of the semaphore system
  calls before it noticed that there was a problem.  I'm not sure if
  this actually happened as the order that modules are discovered by the
  kernel linker depends on how the actual .ko file is linked.  One can
  make the order deterministic by using a single module with a mod_event
  handler that explicitly registers syscalls (and deregisters during
  unload after any checks).  This also fixes a race where even if the
  sem_module unloaded first it would have destroyed locks that the
  syscalls might be trying to access if they are still executing when
  they are unloaded.

  XXX: By the way, deregistering system calls doesn't do any blocking
  to drain any threads from the calls.
- Some minor fixes to errno values on error.  For example, sem_init()
  isn't documented to return ENFILE or EMFILE if we run out of semaphores
  the way that sem_open() can.  Instead, it should return ENOSPC in that
  case.

Other changes:
- Kernel semaphores now use a hash table to manage the namespace of
  named semaphores nearly in a similar fashion to the POSIX shared memory
  object file descriptors.  Kernel semaphores can now also have names
  longer than 14 chars (up to MAXPATHLEN) and can include subdirectories
  in their pathname.
- The UID/GID permission checks for access to a named semaphore are now
  done via vaccess() rather than a home-rolled set of checks.
- Now that kernel semaphores have an associated file object, the various
  MAC checks for POSIX semaphores accept both a file credential and an
  active credential.  There is also a new posixsem_check_stat() since it
  is possible to fstat() a semaphore file descriptor.
- A small set of regression tests (using the ksem API directly) is present
  in src/tools/regression/posixsem.

Reported by:	kris (1)
Tested by:	kris
Reviewed by:	rwatson (lightly)
MFC after:	1 month
2008-06-27 05:39:04 +00:00
Tim Kientzle
6986afe53e As reported by Alexey Shuvaev, -dumpl overwrote files after
linking them, with predictably bad results.
2008-06-26 15:46:01 +00:00
Tim Kientzle
634d062e6a Pass the entry down into the core write loop, so we
can include the filename when reporting errors.

Thanks to: Dan Nelson
2008-06-25 05:01:02 +00:00
Tim Kientzle
e6c78aec4f In -p mode, don't gaurd against '..' in paths. We continue to
check in -i mode unless --insecure is specified.

PR: bin/124924
2008-06-24 15:18:40 +00:00
Tim Kientzle
1aaade6e93 If we're using -l and can't hardlink the file because of a cross-device
link, just ignore the -l option and copy the file instead.
In particular, this should fix the COPYTREE_* macros used in the
ports infrastructure which use -l to preserve space but often get
used for cross-device copies.
2008-06-21 17:47:56 +00:00
Tim Kientzle
9b48cdcc39 Rework line-processing framework to add support for --null and
to eliminate a callback.
2008-06-21 02:20:20 +00:00
Tim Kientzle
00e3ab6e67 Various long options for GNU cpio compat. 2008-06-21 02:18:52 +00:00
Tim Kientzle
152e214a9a MfP4: test improvements, mostly for portability. 2008-06-21 02:17:18 +00:00
Joerg Wunsch
2b7b4962ab Make the search for sources in PATH_PORTS more accurate. I only
noticed that a "whereis -qs qemu" matched the distfiles subdir of qemu
rather than /usr/ports/emulators/qemu.

It now ignores all dot entries in /usr/ports, plus all entries
starting with a capital letter (maintenance stuff like Templates, but
also includes subdir CVS), plus /usr/ports/distfiles which is simply a
magic name in that respect.
2008-06-20 08:39:42 +00:00
Alexander Motin
145d2d3ac4 Add myself. Better late then never. 2008-06-19 17:10:05 +00:00
Dmitry Marakasov
9e269af67e Add myself.
Approved by:	miwi (mentor)
2008-06-19 16:29:37 +00:00
Remko Lodder
589295b90d Remove superfluous eofmarker.
Requested by:	Jaakko Heinonen
Discussed with:	Jaakko, edwin

Approved by:	imp (mentor, implicit)
2008-06-17 18:56:04 +00:00
Ermal Luçi
a10ab63b99 Add my birthday to the calendar.
Approved by:	mlaier (mentor)
2008-06-16 17:35:34 +00:00
Konstantin Belousov
05427aafc6 Struct cdev is always the member of the struct cdev_priv. When devfs
needed to promote cdev to cdev_priv, the si_priv pointer was followed.

Use member2struct() to calculate address of the wrapping cdev_priv.
Rename si_priv to __si_reserved.

Tested by:	pho
Reviewed by:	ed
MFC after:	2 weeks
2008-06-16 17:34:59 +00:00
Doug Barton
482ff78560 Include bsd.own.mk to pick up the definition of MK_GNU_CPIO 2008-06-16 07:24:05 +00:00
Doug Barton
6973701a00 1. Make the BSD version of cpio the default [1]
a. The BSD version will be built and installed unless
WITHOUT_BSD_CPIO is defined.
b. The GNU version will not be built or installed unless
WITH_GNU_CPIO is defined. If this is defined, the symlink
in /usr/bin will be to the GNU version whether the BSD
version is present or not.

When these changes are MFCed the defaults should be flipped.

2. Add a knob to disable the building of GNU grep. This will
make it easier for those that want to test the BSD version in
the ports.

Approved by:	kientzle [1]
2008-06-16 05:48:15 +00:00
Tim Kientzle
48ee9a828d MfP4: Minor portability fix. 2008-06-15 10:08:16 +00:00
Tim Kientzle
669a9b2e92 MfP4: test harness cleanup. 2008-06-15 10:07:54 +00:00
Ivan Voras
448816f0d7 Add myself to the calendar.
Approved by:	gnn (mentor)
2008-06-12 22:52:11 +00:00
Ed Schouten
436f2e5275 Fix build of fstat after minor() changes.
Even though I ran a `make universe' to see whether the changes to the
device minor number macro's broke the build, I was not expecting `make
universe' to silently continue if build errors occured, thus causing me
to overlook the build error.

Approved by:	philip (mentor)
Pointyhat to:	me
2008-06-12 10:15:14 +00:00
Colin Percival
f6dd73207f Make one-bit fields unsigned instead of signed. This has no effect,
since they are only tested for zero/nonzero; but it's arguably a bad
idea to set a {-1, 0} variable to 1 (as happens in this code).

Found by:	Coverity Prevent
2008-06-09 14:41:28 +00:00
Colin Percival
af58f6feff Rework code to avoid using a pointer after freeing it. Aside from the
possibility of memory becoming undereferenceable when it is freed, this
change should have no effect on bsdtar behaviour.

Found by:	Coverity Prevent
2008-06-09 14:03:55 +00:00
David Malone
9bcce8a03e I missed some "register"s in non-dot-C files. 2008-06-08 19:59:15 +00:00
Wojciech A. Koszek
ec4e0f15cd Make usage() 'static'. 2008-06-08 12:43:02 +00:00
David Malone
48f6b9b8b1 De-register declarations. 2008-06-04 19:50:34 +00:00
David Malone
f258a139d3 Fix a strict aliasing warning - I think it is really telling us
that the way char * and void * pointers may not be stored in the
same way.
2008-06-04 19:16:54 +00:00
Guy Helmer
16f53ec4b7 Similar to changes previously made to src/usr.bin/uniq/uniq.c,
fix truncation of lines at LINE_MAX characters by dynamically
extending line buffers.
2008-05-28 14:13:35 +00:00