Blame libarchive/archive_entry_perms.3

Packit Service 1d0348
.\" Copyright (c) 2003-2007 Tim Kientzle
Packit Service 1d0348
.\" Copyright (c) 2010 Joerg Sonnenberger
Packit Service 1d0348
.\" All rights reserved.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" Redistribution and use in source and binary forms, with or without
Packit Service 1d0348
.\" modification, are permitted provided that the following conditions
Packit Service 1d0348
.\" are met:
Packit Service 1d0348
.\" 1. Redistributions of source code must retain the above copyright
Packit Service 1d0348
.\"    notice, this list of conditions and the following disclaimer.
Packit Service 1d0348
.\" 2. Redistributions in binary form must reproduce the above copyright
Packit Service 1d0348
.\"    notice, this list of conditions and the following disclaimer in the
Packit Service 1d0348
.\"    documentation and/or other materials provided with the distribution.
Packit Service 1d0348
.\"
Packit Service 1d0348
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit Service 1d0348
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit Service 1d0348
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit Service 1d0348
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit Service 1d0348
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit Service 1d0348
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit Service 1d0348
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit Service 1d0348
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit Service 1d0348
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit Service 1d0348
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit Service 1d0348
.\" SUCH DAMAGE.
Packit Service 1d0348
.\"
Packit Service 1d0348
.Dd February 2, 2012
Packit Service 1d0348
.Dt ARCHIVE_ENTRY_PERMS 3
Packit Service 1d0348
.Os
Packit Service 1d0348
.Sh NAME
Packit Service 1d0348
.Nm archive_entry_gid ,
Packit Service 1d0348
.Nm archive_entry_set_gid ,
Packit Service 1d0348
.Nm archive_entry_uid ,
Packit Service 1d0348
.Nm archive_entry_set_uid ,
Packit Service 1d0348
.Nm archive_entry_perm ,
Packit Service 1d0348
.Nm archive_entry_set_perm ,
Packit Service 1d0348
.Nm archive_entry_strmode ,
Packit Service 1d0348
.Nm archive_entry_uname ,
Packit Service 1d0348
.Nm archive_entry_uname_w ,
Packit Service 1d0348
.Nm archive_entry_set_uname ,
Packit Service 1d0348
.Nm archive_entry_copy_uname ,
Packit Service 1d0348
.Nm archive_entry_copy_uname_w ,
Packit Service 1d0348
.Nm archive_entry_update_uname_utf8 ,
Packit Service 1d0348
.Nm archive_entry_gname ,
Packit Service 1d0348
.Nm archive_entry_gname_w ,
Packit Service 1d0348
.Nm archive_entry_set_gname ,
Packit Service 1d0348
.Nm archive_entry_copy_gname ,
Packit Service 1d0348
.Nm archive_entry_copy_gname_w ,
Packit Service 1d0348
.Nm archive_entry_update_gname_utf8 ,
Packit Service 1d0348
.Nm archive_entry_fflags ,
Packit Service 1d0348
.Nm archive_entry_fflags_text ,
Packit Service 1d0348
.Nm archive_entry_set_fflags ,
Packit Service 1d0348
.Nm archive_entry_copy_fflags_text ,
Packit Service 1d0348
.Nm archive_entry_copy_fflags_text_w
Packit Service 1d0348
.Nd functions for manipulating ownership and permissions in archive entry descriptions
Packit Service 1d0348
.Sh LIBRARY
Packit Service 1d0348
Streaming Archive Library (libarchive, -larchive)
Packit Service 1d0348
.Sh SYNOPSIS
Packit Service 1d0348
.In archive_entry.h
Packit Service 1d0348
.Ft gid_t
Packit Service 1d0348
.Fn archive_entry_gid "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_gid "struct archive_entry *a" "gid_t gid"
Packit Service 1d0348
.Ft uid_t
Packit Service 1d0348
.Fn archive_entry_uid "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_uid "struct archive_entry *a" "uid_t uid"
Packit Service 1d0348
.Ft mode_t
Packit Service 1d0348
.Fn archive_entry_perm "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_perm "struct archive_entry *a" "mode_t mode"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_entry_strmode "struct archive_entry *a"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_entry_gname "struct archive_entry *a"
Packit Service 1d0348
.Ft const wchar_t *
Packit Service 1d0348
.Fn archive_entry_gname_w "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_gname "struct archive_entry *a" "const char *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_copy_gname "struct archive_entry *a" "const char *name"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_copy_gname_w "struct archive_entry *a" "const wchar_t *name"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_entry_update_gname_utf8 "struct archive_entry *a" "const char *name"
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_entry_uname "struct archive_entry *a"
Packit Service 1d0348
.Ft const wchar_t *
Packit Service 1d0348
.Fn archive_entry_uname_w "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_set_uname "struct archive_entry *a" "const char *name"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_copy_uname "struct archive_entry *a" "const char *name"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fn archive_entry_copy_uname_w "struct archive_entry *a" "const wchar_t *name"
Packit Service 1d0348
.Ft int
Packit Service 1d0348
.Fn archive_entry_update_uname_utf8 "struct archive_entry *a" "const char *name"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fo archive_entry_fflags
Packit Service 1d0348
.Fa "struct archive_entry *a"
Packit Service 1d0348
.Fa "unsigned long *set_bits"
Packit Service 1d0348
.Fa "unsigned long *clear_bits"
Packit Service 1d0348
.Fc
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_entry_fflags_text "struct archive_entry *a"
Packit Service 1d0348
.Ft void
Packit Service 1d0348
.Fo archive_entry_set_fflags
Packit Service 1d0348
.Fa "struct archive_entry *a"
Packit Service 1d0348
.Fa "unsigned long set_bits"
Packit Service 1d0348
.Fa "unsigned long clear_bits"
Packit Service 1d0348
.Fc
Packit Service 1d0348
.Ft const char *
Packit Service 1d0348
.Fn archive_entry_copy_fflags_text "struct archive_entry *a" "const char *text"
Packit Service 1d0348
.Ft const wchar_t *
Packit Service 1d0348
.Fn archive_entry_copy_fflags_text_w "struct archive_entry *a" "const wchar_t *text"
Packit Service 1d0348
.Sh DESCRIPTION
Packit Service 1d0348
.Ss User id, group id and mode
Packit Service 1d0348
The functions
Packit Service 1d0348
.Fn archive_entry_uid ,
Packit Service 1d0348
.Fn archive_entry_gid ,
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_perm
Packit Service 1d0348
can be used to extract the user id, group id and permission from the given entry.
Packit Service 1d0348
The corresponding functions
Packit Service 1d0348
.Fn archive_entry_set_uid ,
Packit Service 1d0348
.Fn archive_entry_set_gid ,
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_set_perm
Packit Service 1d0348
store the given user id, group id and permission in the entry.
Packit Service 1d0348
The permission is also set as side effect of calling
Packit Service 1d0348
.Fn archive_entry_set_mode .
Packit Service 1d0348
.Pp
Packit Service 1d0348
.Fn archive_entry_strmode
Packit Service 1d0348
returns a string representation of the permission as used by the long mode of
Packit Service 1d0348
.Xr ls 1 .
Packit Service 1d0348
.Ss User and group name
Packit Service 1d0348
User and group names can be provided in one of three different ways:
Packit Service 1d0348
.Bl -tag -width "wchar_t *"
Packit Service 1d0348
.It char *
Packit Service 1d0348
Multibyte strings in the current locale.
Packit Service 1d0348
.It wchar_t *
Packit Service 1d0348
Wide character strings in the current locale.
Packit Service 1d0348
The accessor functions are named
Packit Service 1d0348
.Fn XXX_w .
Packit Service 1d0348
.It UTF-8
Packit Service 1d0348
Unicode strings encoded as UTF-8.
Packit Service 1d0348
This are convience functions to update both the multibyte and wide
Packit Service 1d0348
character strings at the same time.
Packit Service 1d0348
.El
Packit Service 1d0348
.Pp
Packit Service 1d0348
.Fn archive_entry_set_XXX
Packit Service 1d0348
is an alias for 
Packit Service 1d0348
.Fn archive_entry_copy_XXX .
Packit Service 1d0348
.Ss File Flags
Packit Service 1d0348
File flags are transparently converted between a bitmap
Packit Service 1d0348
representation and a textual format.
Packit Service 1d0348
For example, if you set the bitmap and ask for text, the library
Packit Service 1d0348
will build a canonical text format.
Packit Service 1d0348
However, if you set a text format and request a text format,
Packit Service 1d0348
you will get back the same text, even if it is ill-formed.
Packit Service 1d0348
If you need to canonicalize a textual flags string, you should first set the
Packit Service 1d0348
text form, then request the bitmap form, then use that to set the bitmap form.
Packit Service 1d0348
Setting the bitmap format will clear the internal text representation
Packit Service 1d0348
and force it to be reconstructed when you next request the text form.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The bitmap format consists of two integers, one containing bits
Packit Service 1d0348
that should be set, the other specifying bits that should be
Packit Service 1d0348
cleared.
Packit Service 1d0348
Bits not mentioned in either bitmap will be ignored.
Packit Service 1d0348
Usually, the bitmap of bits to be cleared will be set to zero.
Packit Service 1d0348
In unusual circumstances, you can force a fully-specified set
Packit Service 1d0348
of file flags by setting the bitmap of flags to clear to the complement
Packit Service 1d0348
of the bitmap of flags to set.
Packit Service 1d0348
(This differs from
Packit Service 1d0348
.Xr fflagstostr 3 ,
Packit Service 1d0348
which only includes names for set bits.)
Packit Service 1d0348
Converting a bitmap to a textual string is a platform-specific
Packit Service 1d0348
operation; bits that are not meaningful on the current platform
Packit Service 1d0348
will be ignored.
Packit Service 1d0348
.Pp
Packit Service 1d0348
The canonical text format is a comma-separated list of flag names.
Packit Service 1d0348
The
Packit Service 1d0348
.Fn archive_entry_copy_fflags_text
Packit Service 1d0348
and
Packit Service 1d0348
.Fn archive_entry_copy_fflags_text_w
Packit Service 1d0348
functions parse the provided text and sets the internal bitmap values.
Packit Service 1d0348
This is a platform-specific operation; names that are not meaningful
Packit Service 1d0348
on the current platform will be ignored.
Packit Service 1d0348
The function returns a pointer to the start of the first name that was not
Packit Service 1d0348
recognized, or NULL if every name was recognized.
Packit Service 1d0348
Note that every name \(em including names that follow an unrecognized
Packit Service 1d0348
name \(em will be evaluated, and the bitmaps will be set to reflect
Packit Service 1d0348
every name that is recognized.
Packit Service 1d0348
(In particular, this differs from
Packit Service 1d0348
.Xr strtofflags 3 ,
Packit Service 1d0348
which stops parsing at the first unrecognized name.)
Packit Service 1d0348
.Sh SEE ALSO
Packit Service 1d0348
.Xr archive_entry 3 ,
Packit Service 1d0348
.Xr archive_entry_acl 3 ,
Packit Service 1d0348
.Xr archive_read_disk 3 ,
Packit Service 1d0348
.Xr archive_write_disk 3
Packit Service 1d0348
.Xr libarchive 3 ,
Packit Service 1d0348
.Sh BUGS
Packit Service 1d0348
The platform types
Packit Service 1d0348
.Vt uid_t
Packit Service 1d0348
and
Packit Service 1d0348
.Vt gid_t
Packit Service 1d0348
are often 16 or 32 bit wide.
Packit Service 1d0348
In this case it is possible that the ids can not be correctly restored
Packit Service 1d0348
from archives and get truncated.