view release on metacpan or search on metacpan
unzip-6.0/History.600 view on Meta::CPAN
- vms/build_unzip.com: optimized the distinction between "compile destination
subdir" for integrated BZIP2 compilation (should distinguish between the
different compilers supported for VAX) and "external library dir" for
user-supplied BZIP2 (and ZLIB) libraries (user-supplied library is expected
to work with any supported compiler on VAX, so no dependency on the
specific compiler used). [Steven M. Schweda]
- unzip.c: replaced tab characters in output messages by appropiate number of
spaces (assuming standard tab spacing of 8 chars), to prevent mis-formatted
output on terminals with non-standard tabstop settings. [S. M. Schweda]
- unix/unix.c
* set_symlnk_attribs(): fixed uid/gid size check before calling lchown();
* set_direc_attribs(): repared wrongly inserted patch and fixed uid/gid
size check before calling chown(). [Chr. Spieler]
- vms/vms.c: fixed user-query code for existing files on VMS when extracting
in "-V" mode (retaining version numbers); fixed some problems with exotic
extended ODS5 file names, and files named ".". [Steven M. Schweda]
- vms/cmdline.c, vms/unz_cli.cld: extended CLI to support the new extended
meaning of the -o flag (-oo => "overwrite ALL existing" when retaining
version numbers ("-V") and extracting archive members with attached version
number (new /EXISTING option). [Steven M. Schweda]
- extract.c - extract_or_test_entrylist(): added code to skip the generic user
query "overwrite (y/n/r)?" when extracting an entry with attached version
unzip-6.0/INSTALL view on Meta::CPAN
UnZip "extra fields" are used to store VMS (RMS) filesystem info,
and the format of this information may differ in various versions
of VMS. Defining this option will enable UnZip warnings when the
stored extra-field VMS version(s) do(es) not match the version of
VMS currently being used. This is a common occurrence in zipfiles
received from other sites, but since the format of the filesystem
does not seem to have changed in years (including on Alpha and
IA64 systems), the warnings are not enabled by default.
RETURN_CODES (VMS only)
VMS interprets return codes according to a rigid set of guidelines,
which means it misinterprets normal UnZip return codes as all sorts
of really nasty errors. Therefore VMS UnZip returns an alternate set
of return codes; since these may be difficult to interpret, define
RETURN_CODES for human-readable explanations.
VMS_TEXT_CONV (everybody except VMS)
VMS Stream_LF-format text files archived with the "-V" option
(/VMS), but NOT with -VV (/VMS=ALL), should be fine when extracted
on other systems. Stream_LF-files archived with -VV should be
readable as well, but they may get some junk appended.
unzip-6.0/acorn/riscos.c view on Meta::CPAN
if (SWI_OS_File_5(filename,&type,&load,&exec,(int *)&res->st_size,&attr)!=NULL)
return -1;
if (type==0)
return -1;
res->st_dev=0;
res->st_ino=0;
res->st_nlink=0;
res->st_uid=1;
res->st_gid=1;
res->st_rdev=0;
res->st_blksize=1024;
res->st_mode = ((attr & 0001) << 8) | ((attr & 0002) << 6) |
((attr & 0020) >> 2) | ((attr & 0040) >> 4);
switch (type) {
case 1: /* File */
res->st_mode |= S_IFREG;
break;
unzip-6.0/acorn/riscos.h view on Meta::CPAN
#define MAXPATHLEN 256
#define MAXFILENAMELEN 64 /* should be 11 for ADFS, 13 for DOS, 64 seems a sensible value... */
#define DIR_BUFSIZE 1024 /* this should be enough to read a whole E-Format directory */
struct stat {
unsigned int st_dev;
int st_ino;
unsigned int st_mode;
int st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned int st_rdev;
unsigned int st_size;
unsigned int st_blksize;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
typedef struct {
char *dirname;
unzip-6.0/amiga/stat.c view on Meta::CPAN
{
FreeMem((char *)inf,(long)sizeof(*inf));
UnLock(lock);
return(-1);
}
/* fill in buf */
buf->st_dev =
buf->st_nlink =
buf->st_uid =
buf->st_gid =
buf->st_rdev = 0;
buf->st_ino = inf->fib_DiskKey;
buf->st_blocks = inf->fib_NumBlocks;
buf->st_size = inf->fib_Size;
/* now the date. AmigaDOS has weird datestamps---
* ds_Days is the number of days since 1-1-1978;
* however, as Unix wants date since 1-1-1970...
*/
unzip-6.0/amiga/z-stat.h view on Meta::CPAN
#include <libraries/dos.h>
#include <time.h>
struct stat {
unsigned short st_mode;
time_t st_ctime, st_atime, st_mtime;
long st_size;
long st_ino;
long st_blocks;
short st_attr, st_dev, st_nlink, st_uid, st_gid, st_rdev;
};
#define S_IFDIR (1<<11)
#define S_IFREG (1<<10)
#if 0
/* these values here are totally random: */
# define S_IFLNK (1<<14)
# define S_IFSOCK (1<<13)
# define S_IFCHR (1<<8)
unzip-6.0/atheos/atheos.c view on Meta::CPAN
#ifdef SET_DIR_ATTRIB
typedef struct uxdirattr { /* struct for holding unix style directory */
struct uxdirattr *next; /* info until can be sorted and set at end */
char *fn; /* filename of directory */
union {
iztimes t3; /* mtime, atime, ctime */
ztimbuf t2; /* modtime, actime */
} u;
unsigned perms; /* same as min_info.file_attr */
int have_uidgid; /* flag */
ulg uidgid[2];
char fnbuf[1]; /* buffer stub for directory name */
} uxdirattr;
#define UxAtt(d) ((uxdirattr *)d) /* typecast shortcut */
#endif /* SET_DIR_ATTRIB */
#ifdef ACORN_FTYPE_NFS
/* Acorn bits for NFS filetyping */
typedef struct {
uch ID[2];
uch size[2];
unzip-6.0/atheos/atheos.c view on Meta::CPAN
/* This is used to clear or keep the SUID and GID bits on file permissions.
* It's possible that a file in an archive could have one of these bits set
* and, unknown to the person unzipping, could allow others to execute the
* file as the user or group. The new option -K bypasses this check.
*/
static unsigned filtattr(__G__ perms)
__GDEF
unsigned perms;
{
/* keep setuid/setgid/tacky perms? */
if (!uO.K_flag)
perms &= ~(S_ISUID | S_ISGID | S_ISVTX);
return (0xffff & perms);
} /* end function filtattr() */
unzip-6.0/atheos/atheos.c view on Meta::CPAN
return MPN_OK;
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2]));
static int get_extattribs(__G__ pzt, z_uidgid)
__GDEF
iztimes *pzt;
ulg z_uidgid[2];
{
/*---------------------------------------------------------------------------
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
time: adjust base year from 1980 to 1970, do usual conversions from
yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-
light savings time differences. If we have a Unix extra field, however,
we're laughing: both mtime and atime are ours. On the other hand, we
then have to check for restoration of UID/GID.
---------------------------------------------------------------------------*/
int have_uidgid_flg;
unsigned eb_izux_flg;
eb_izux_flg = (G.extra_field ? ef_scan_for_izux(G.extra_field,
G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,
#ifdef IZ_CHECK_TZ
(G.tz_is_valid ? pzt : NULL),
#else
pzt,
#endif
z_uidgid) : 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
TTrace((stderr, "\nget_extattribs: Unix e.f. modif. time = %ld\n",
pzt->mtime));
} else {
pzt->mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
TTrace((stderr, "get_extattribs: Unix e.f. access time = %ld\n",
pzt->atime));
} else {
pzt->atime = pzt->mtime;
TTrace((stderr, "\nget_extattribs: modification/access times = %ld\n",
pzt->mtime));
}
/* if -X option was specified and we have UID/GID info, restore it */
have_uidgid_flg =
#ifdef RESTORE_UIDGID
(uO.X_flag && (eb_izux_flg & EB_UX2_VALID));
#else
0;
#endif
return have_uidgid_flg;
}
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
union {
iztimes t3; /* mtime, atime, ctime */
struct utimbuf t2; /* modtime, actime */
} zt;
ulg z_uidgid[2];
int have_uidgid_flg;
/*---------------------------------------------------------------------------
If symbolic links are supported, allocate storage for a symlink control
structure, put the uncompressed "data" and other required info in it, and
add the structure to the "deferred symlinks" chain. Since we know it's a
symbolic link to start with, we shouldn't have to worry about overflowing
unsigned ints with unsigned longs.
---------------------------------------------------------------------------*/
#ifdef SYMLINKS
unzip-6.0/atheos/atheos.c view on Meta::CPAN
/* handle the AtheOS extra field if present */
if (!uO.J_flag) {
void *ptr = scanAtheOSexfield(G.extra_field,
G.lrec.extra_field_length);
if (ptr) {
setAtheOSexfield(G.filename, ptr);
}
}
have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
/* if -X option was specified and we have UID/GID info, restore it */
if (have_uidgid_flg) {
TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n"));
if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
{
if (uO.qflag)
Info(slide, 0x201, ((char *)slide,
"warning: cannot set UID %lu and/or GID %lu for %s\n",
z_uidgid[0], z_uidgid[1], FnFilter1(G.filename)));
else
Info(slide, 0x201, ((char *)slide,
" (warning) cannot set UID %lu and/or GID %lu",
z_uidgid[0], z_uidgid[1]));
}
}
/* skip restoring time stamps on user's request */
if (uO.D_flag <= 1) {
/* set the file's access and modification times */
if (utime(G.filename, &(zt.t2))) {
if (uO.qflag)
Info(slide, 0x201, ((char *)slide,
"warning: cannot set times for %s\n",
unzip-6.0/atheos/atheos.c view on Meta::CPAN
d_entry = (uxdirattr *)malloc(sizeof(uxdirattr) + strlen(G.filename));
*pd = (direntry *)d_entry;
if (d_entry == (uxdirattr *)NULL) {
return PK_MEM;
}
d_entry->fn = d_entry->fnbuf;
strcpy(d_entry->fn, G.filename);
d_entry->perms = G.pInfo->file_attr;
d_entry->have_uidgid = get_extattribs(__G__ &(d_entry->u.t3),
d_entry->uidgid);
return PK_OK;
} /* end function defer_dir_attribs() */
int set_direc_attribs(__G__ d)
__GDEF
direntry *d;
{
int errval = PK_OK;
if (UxAtt(d)->have_uidgid &&
chown(UxAtt(d)->fn, (uid_t)UxAtt(d)->uidgid[0],
(gid_t)UxAtt(d)->uidgid[1]))
{
Info(slide, 0x201, ((char *)slide,
LoadFarString(DirlistUidGidFailed),
UxAtt(d)->uidgid[0], UxAtt(d)->uidgid[1], FnFilter1(d->fn)));
if (!errval)
errval = PK_WARN;
}
/* Skip restoring directory time stamps on user' request. */
if (uO.D_flag <= 0) {
/* restore directory timestamps */
if (utime(d->fn, &UxAtt(d)->u.t2)) {
Info(slide, 0x201, ((char *)slide,
LoadFarString(DirlistUtimeFailed), FnFilter1(d->fn)));
if (!errval)
unzip-6.0/beos/beos.c view on Meta::CPAN
#ifdef SET_DIR_ATTRIB
typedef struct uxdirattr { /* struct for holding unix style directory */
struct uxdirattr *next; /* info until can be sorted and set at end */
char *fn; /* filename of directory */
union {
iztimes t3; /* mtime, atime, ctime */
ztimbuf t2; /* modtime, actime */
} u;
unsigned perms; /* same as min_info.file_attr */
int have_uidgid; /* flag */
ulg uidgid[2];
char fnbuf[1]; /* buffer stub for directory name */
} uxdirattr;
#define UxAtt(d) ((uxdirattr *)d) /* typecast shortcut */
#endif /* SET_DIR_ATTRIB */
#ifdef ACORN_FTYPE_NFS
/* Acorn bits for NFS filetyping */
typedef struct {
uch ID[2];
uch size[2];
unzip-6.0/beos/beos.c view on Meta::CPAN
/* This is used to clear or keep the SUID and SGID bits on file permissions.
* It's possible that a file in an archive could have one of these bits set
* and, unknown to the person unzipping, could allow others to execute the
* file as the user or group. The new option -K bypasses this check.
*/
static unsigned filtattr(__G__ perms)
__GDEF
unsigned perms;
{
/* keep setuid/setgid/tacky perms? */
if (!uO.K_flag)
perms &= ~(S_ISUID | S_ISGID | S_ISVTX);
return (0xffff & perms);
} /* end function filtattr() */
unzip-6.0/beos/beos.c view on Meta::CPAN
}
return MPN_INVALID; /* should never reach */
} /* end function checkdir() */
static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2]));
static int get_extattribs(__G__ pzt, z_uidgid)
__GDEF
iztimes *pzt;
ulg z_uidgid[2];
{
/*---------------------------------------------------------------------------
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
time: adjust base year from 1980 to 1970, do usual conversions from
yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-
light savings time differences. If we have a Unix extra field, however,
we're laughing: both mtime and atime are ours. On the other hand, we
then have to check for restoration of UID/GID.
---------------------------------------------------------------------------*/
int have_uidgid_flg;
unsigned eb_izux_flg;
eb_izux_flg = (G.extra_field ? ef_scan_for_izux(G.extra_field,
G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,
#ifdef IZ_CHECK_TZ
(G.tz_is_valid ? pzt : NULL),
#else
pzt,
#endif
z_uidgid) : 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
TTrace((stderr, "\nget_extattribs: Unix e.f. modif. time = %ld\n",
pzt->mtime));
} else {
pzt->mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
TTrace((stderr, "get_extattribs: Unix e.f. access time = %ld\n",
pzt->atime));
} else {
pzt->atime = pzt->mtime;
TTrace((stderr, "\nget_extattribs: modification/access times = %ld\n",
pzt->mtime));
}
/* if -X option was specified and we have UID/GID info, restore it */
have_uidgid_flg =
#ifdef RESTORE_UIDGID
(uO.X_flag && (eb_izux_flg & EB_UX2_VALID));
#else
0;
#endif
return have_uidgid_flg;
}
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
union {
iztimes t3; /* mtime, atime, ctime */
ztimbuf t2; /* modtime, actime */
} zt;
ulg z_uidgid[2];
int have_uidgid_flg;
have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
/*---------------------------------------------------------------------------
If symbolic links are supported, allocate storage for a symlink control
structure, put the uncompressed "data" and other required info in it, and
add the structure to the "deferred symlinks" chain. Since we know it's a
symbolic link to start with, we shouldn't have to worry about overflowing
unsigned ints with unsigned longs.
---------------------------------------------------------------------------*/
#ifdef SYMLINKS
unzip-6.0/beos/beos.c view on Meta::CPAN
Change the file permissions from default ones to those stored in the
zipfile.
---------------------------------------------------------------------------*/
#ifndef NO_CHMOD
if (chmod(G.filename, filtattr(__G__ G.pInfo->file_attr)))
perror("chmod (file attributes) error");
#endif
/* if -X option was specified and we have UID/GID info, restore it */
if (have_uidgid_flg
/* check that both uid and gid values fit into their data sizes */
&& ((ulg)(uid_t)(z_uidgid[0]) == z_uidgid[0])
&& ((ulg)(gid_t)(z_uidgid[1]) == z_uidgid[1])) {
TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n"));
if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
{
if (uO.qflag)
Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid,
z_uidgid[0], z_uidgid[1], FnFilter1(G.filename),
strerror(errno)));
else
Info(slide, 0x201, ((char *)slide, CannotSetUidGid,
z_uidgid[0], z_uidgid[1], strerror(errno)));
}
}
/* skip restoring time stamps on user's request */
if (uO.D_flag <= 1) {
/* set the file's access and modification times */
if (utime(G.filename, &(zt.t2))) {
if (uO.qflag)
Info(slide, 0x201, ((char *)slide, CannotSetItemTimestamps,
FnFilter1(G.filename), strerror(errno)));
unzip-6.0/beos/beos.c view on Meta::CPAN
d_entry = (uxdirattr *)malloc(sizeof(uxdirattr) + strlen(G.filename));
*pd = (direntry *)d_entry;
if (d_entry == (uxdirattr *)NULL) {
return PK_MEM;
}
d_entry->fn = d_entry->fnbuf;
strcpy(d_entry->fn, G.filename);
d_entry->perms = G.pInfo->file_attr;
d_entry->have_uidgid = get_extattribs(__G__ &(d_entry->u.t3),
d_entry->uidgid);
return PK_OK;
} /* end function defer_dir_attribs() */
int set_direc_attribs(__G__ d)
__GDEF
direntry *d;
{
int errval = PK_OK;
if (UxAtt(d)->have_uidgid &&
/* check that both uid and gid values fit into their data sizes */
((ulg)(uid_t)(UxAtt(d)->uidgid[0]) == UxAtt(d)->uidgid[0]) &&
((ulg)(gid_t)(UxAtt(d)->uidgid[1]) == UxAtt(d)->uidgid[1]) &&
chown(UxAtt(d)->fn, (uid_t)UxAtt(d)->uidgid[0],
(gid_t)UxAtt(d)->uidgid[1]))
{
Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid,
UxAtt(d)->uidgid[0], UxAtt(d)->uidgid[1], FnFilter1(d->fn),
strerror(errno)));
if (!errval)
errval = PK_WARN;
}
/* Skip restoring directory time stamps on user' request. */
if (uO.D_flag <= 0) {
/* restore directory timestamps */
if (utime(d->fn, (const struct utimbuf *)&UxAtt(d)->u.t2)) {
Info(slide, 0x201, ((char *)slide, CannotSetItemTimestamps,
FnFilter1(d->fn), strerror(errno)));
unzip-6.0/cmsmvs/vmstat.h view on Meta::CPAN
#define _OFF_T_DEFINED
#endif
#ifndef _STAT_DEFINED
struct stat {
dev_t st_dev;
ino_t st_ino;
short st_mode;
short st_nlink;
int st_uid;
int st_gid;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define _STAT_DEFINED
#endif
int stat(const char *path, struct stat *buf);
int fstat(int fd, struct stat *buf);
unzip-6.0/macos/source/macstat.c view on Meta::CPAN
if ((fpb.hFileInfo.ioFlAttrib & 0x01) == 0) {
/*
* If not locked, then everyone has write acces.
*/
buf->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
}
buf->st_ino = fpb.hFileInfo.ioDirID;
buf->st_dev = fpb.hFileInfo.ioVRefNum;
buf->st_uid = -1;
buf->st_gid = -1;
buf->st_rdev = 0;
if (CurrentFork == ResourceFork)
buf->st_size = fpb.hFileInfo.ioFlRLgLen;
else
buf->st_size = fpb.hFileInfo.ioFlLgLen;
buf->st_blksize = vpb.ioVAlBlkSiz;
buf->st_blocks = (buf->st_size + buf->st_blksize - 1)
/ buf->st_blksize;
unzip-6.0/macos/source/macstat.h view on Meta::CPAN
typedef long off_t;
#define _STAT
struct stat {
dev_t st_dev;
ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime, st_mtime, st_ctime;
long st_blksize;
long st_blocks;
};
#define S_IFMT 0xF000
#define S_IFIFO 0x1000
#define S_IFCHR 0x2000
unzip-6.0/process.c view on Meta::CPAN
# else
static zoff_t file_size OF((int fh));
# endif
#endif /* DO_SAFECHECK_2GB */
static int rec_find OF((__GPRO__ zoff_t, char *, int));
static int find_ecrec64 OF((__GPRO__ zoff_t searchlen));
static int find_ecrec OF((__GPRO__ zoff_t searchlen));
static int process_zip_cmmnt OF((__GPRO));
static int get_cdir_ent OF((__GPRO));
#ifdef IZ_HAVE_UXUIDGID
static int read_ux3_value OF((ZCONST uch *dbuf, unsigned uidgid_sz,
ulg *p_uidgid));
#endif /* IZ_HAVE_UXUIDGID */
static ZCONST char Far CannotAllocateBuffers[] =
"error: cannot allocate unzip buffers\n";
#ifdef SFX
static ZCONST char Far CannotFindMyself[] =
"unzipsfx: cannot find myself! [%s]\n";
# ifdef CHEAP_SFX_AUTORUN
unzip-6.0/process.c view on Meta::CPAN
#endif /* UNICODE_WCHAR */
#endif /* UNICODE_SUPPORT */
#ifdef USE_EF_UT_TIME
#ifdef IZ_HAVE_UXUIDGID
static int read_ux3_value(dbuf, uidgid_sz, p_uidgid)
ZCONST uch *dbuf; /* buffer a uid or gid value */
unsigned uidgid_sz; /* size of uid/gid value */
ulg *p_uidgid; /* return storage: uid or gid value */
{
zusz_t uidgid64;
switch (uidgid_sz) {
case 2:
*p_uidgid = (ulg)makeword(dbuf);
break;
case 4:
*p_uidgid = (ulg)makelong(dbuf);
break;
case 8:
uidgid64 = makeint64(dbuf);
#ifndef LARGE_FILE_SUPPORT
if (uidgid64 == (zusz_t)0xffffffffL)
return FALSE;
#endif
*p_uidgid = (ulg)uidgid64;
if ((zusz_t)(*p_uidgid) != uidgid64)
return FALSE;
break;
}
return TRUE;
}
#endif /* IZ_HAVE_UXUIDGID */
/*******************************/
/* Function ef_scan_for_izux() */
/*******************************/
unsigned ef_scan_for_izux(ef_buf, ef_len, ef_is_c, dos_mdatetime,
z_utim, z_uidgid)
ZCONST uch *ef_buf; /* buffer containing extra field */
unsigned ef_len; /* total length of extra field */
int ef_is_c; /* flag indicating "is central extra field" */
ulg dos_mdatetime; /* last_mod_file_date_time in DOS format */
iztimes *z_utim; /* return storage: atime, mtime, ctime */
ulg *z_uidgid; /* return storage: uid and gid */
{
unsigned flags = 0;
unsigned eb_id;
unsigned eb_len;
int have_new_type_eb = 0;
long i_time; /* buffer for Unix style 32-bit integer time value */
#ifdef TIME_T_TYPE_DOUBLE
int ut_in_archive_sgn = 0;
#else
int ut_zip_unzip_compatible = FALSE;
#endif
/*---------------------------------------------------------------------------
This function scans the extra field for EF_TIME, EF_IZUNIX2, EF_IZUNIX, or
EF_PKUNIX blocks containing Unix-style time_t (GMT) values for the entry's
access, creation, and modification time.
If a valid block is found, the time stamps are copied to the iztimes
structure (provided the z_utim pointer is not NULL).
If a IZUNIX2 block is found or the IZUNIX block contains UID/GID fields,
and the z_uidgid array pointer is valid (!= NULL), the owner info is
transfered as well.
The presence of an EF_TIME or EF_IZUNIX2 block results in ignoring all
data from probably present obsolete EF_IZUNIX blocks.
If multiple blocks of the same type are found, only the information from
the last block is used.
The return value is a combination of the EF_TIME Flags field with an
additional flag bit indicating the presence of valid UID/GID info,
or 0 in case of failure.
---------------------------------------------------------------------------*/
if (ef_len == 0 || ef_buf == NULL || (z_utim == 0 && z_uidgid == NULL))
return 0;
TTrace((stderr,"\nef_scan_for_izux: scanning extra field of length %u\n",
ef_len));
while (ef_len >= EB_HEADSIZE) {
eb_id = makeword(EB_ID + ef_buf);
eb_len = makeword(EB_LEN + ef_buf);
if (eb_len > (ef_len - EB_HEADSIZE)) {
unzip-6.0/process.c view on Meta::CPAN
break;
case EF_IZUNIX2:
if (have_new_type_eb == 0) {
flags &= ~0x0ff; /* ignore any previous IZUNIX field */
have_new_type_eb = 1;
}
#ifdef IZ_HAVE_UXUIDGID
if (have_new_type_eb > 1)
break; /* IZUNIX3 overrides IZUNIX2 e.f. block ! */
if (eb_len == EB_UX2_MINLEN && z_uidgid != NULL) {
z_uidgid[0] = (ulg)makeword((EB_HEADSIZE+EB_UX2_UID) + ef_buf);
z_uidgid[1] = (ulg)makeword((EB_HEADSIZE+EB_UX2_GID) + ef_buf);
flags |= EB_UX2_VALID; /* signal success */
}
#endif
break;
case EF_IZUNIX3:
/* new 3rd generation Unix ef */
have_new_type_eb = 2;
/*
Version 1 byte version of this extra field, currently 1
UIDSize 1 byte Size of UID field
UID Variable UID for this entry
GIDSize 1 byte Size of GID field
GID Variable GID for this entry
*/
#ifdef IZ_HAVE_UXUIDGID
if (eb_len >= EB_UX3_MINLEN
&& z_uidgid != NULL
&& (*((EB_HEADSIZE + 0) + ef_buf) == 1)
/* only know about version 1 */
{
uch uid_size;
uch gid_size;
uid_size = *((EB_HEADSIZE + 1) + ef_buf);
gid_size = *((EB_HEADSIZE + uid_size + 2) + ef_buf);
flags &= ~0x0ff; /* ignore any previous UNIX field */
if ( read_ux3_value((EB_HEADSIZE + 2) + ef_buf,
uid_size, z_uidgid[0])
&&
read_ux3_value((EB_HEADSIZE + uid_size + 3) + ef_buf,
gid_size, z_uidgid[1]) )
{
flags |= EB_UX2_VALID; /* signal success */
}
}
#endif /* IZ_HAVE_UXUIDGID */
break;
case EF_IZUNIX:
case EF_PKUNIX: /* PKUNIX e.f. layout is identical to IZUNIX */
if (eb_len >= EB_UX_MINLEN) {
unzip-6.0/process.c view on Meta::CPAN
/* atime not in range of UnZip's time_t */
flags &= ~EB_UT_FL_ATIME;
TTrace((stderr,
" UX access time range error: skip time!\n"));
} else {
z_utim->atime = (time_t)i_time;
}
#endif /* ?TIME_T_TYPE_DOUBLE */
}
#ifdef IZ_HAVE_UXUIDGID
if (eb_len >= EB_UX_FULLSIZE && z_uidgid != NULL) {
z_uidgid[0] = makeword((EB_HEADSIZE+EB_UX_UID) + ef_buf);
z_uidgid[1] = makeword((EB_HEADSIZE+EB_UX_GID) + ef_buf);
flags |= EB_UX2_VALID;
}
#endif /* IZ_HAVE_UXUIDGID */
}
break;
default:
break;
}
unzip-6.0/proginfo/extrafld.txt view on Meta::CPAN
(Unix3) 0x756e Short tag for this extra block type ("nu")
TSize Short total data size for this block
CRC Long CRC-32 of the remaining data
Mode Short file permissions
SizDev Long symlink'd size OR major/minor dev num
UID Short user ID
GID Short group ID
(var.) variable symbolic link filename
Mode is the standard Unix st_mode field from struct stat, containing
user/group/other permissions, setuid/setgid and symlink info, etc.
If Mode indicates that this file is a symbolic link, SizDev is the
size of the file to which the link points. Otherwise, if the file
is a device, SizDev contains the standard Unix st_rdev field from
struct stat (includes the major and minor numbers of the device).
SizDev is undefined in other cases.
If Mode indicates that the file is a symbolic link, the final field
will be the name of the file to which the link points. The file-
name length can be inferred from TSize.
unzip-6.0/qdos/izqdos.h view on Meta::CPAN
#include <qdos.h>
typedef struct
{
unsigned short shortid;
struct
{
unsigned char lo;
unsigned char hi;
} len;
char longid[8];
struct qdirect header;
} qdosextra;
typedef struct
{
unsigned short shortid;
struct
{
unsigned char lo;
unsigned char hi;
} len;
char longid[4];
struct qdirect header;
} jbextra;
#define SHORTID 0x4afb
#define JBSHORTID 0x4afb
#define LONGID "QDOS02"
#define JBLONGID "QZHD"
#define EXTRALEN (sizeof(qdosextra) - 2 * sizeof(char) - sizeof(short))
#define JBEXTRALEN (sizeof(jbextra) - 2 * sizeof(char) - sizeof(short))
unzip-6.0/qdos/qdos.c view on Meta::CPAN
"qfix: block length %u > rest ef_size %u\n", eb_len,
ef_len - EB_HEADSIZE));
break;
}
/* Must ensure that we don't use ODD addresses here */
memcpy(&qextra, ef_ptr, sizeof(qdosextra));
switch (extra->shortid) {
case SHORTID:
if (!strncmp(extra->longid, LONGID, strlen(LONGID)))
{
if (eb_len != EXTRALEN)
fputs("warning: invalid length in Qdos field", stderr);
if (extra->header.d_type)
{
fs_heads(fgetchid(G.outfile), (timeout_t)-1,
&extra->header, 14);
G.pInfo->file_attr |= S_IXUSR;
}
}
if (!strncmp(jbp->longid, JBLONGID, strlen(JBLONGID)))
{
if (eb_len != JBEXTRALEN)
fputs("warning: invalid length in QZ field", stderr);
if (jbp->header.d_type)
{
fs_heads(fgetchid(G.outfile), (timeout_t)-1,
&jbp->header, 14);
G.pInfo->file_attr |= S_IXUSR;
}
}
unzip-6.0/tandem/macros view on Meta::CPAN
#OUTPUT /COLUMN [count]/ [code 27]A.
[#IF count > 75
|THEN|
#SET count 0
]
]
]
[#DEF process^file TEXT |BODY|
#SET action 0
#SETMANY cur^owner cur^security cur^license cur^progid, &
[#FILEINFO /OWNER, SECURITY, LICENSED, PROGID/ [file]]
#SET cur^owner [#USERNAME [cur^owner]]
[#IF NOT [#EMPTYV owner]
|THEN|
[#IF owner '<>' cur^owner
|THEN|
display^action giving to [owner] (was [cur^owner])
fup^cmd GIVE [file], [owner]
[#IF cur^progid
|THEN|
#OUTPUT /COLUMN 3/... WARNING! Loss of PROGID flag
#SET cur^progid 0
]
]
]
[#IF NOT [#EMPTYV security]
|THEN|
[#IF security '<>' cur^security
|THEN|
display^action securing to [security] (was [cur^security])
fup^cmd SECURE [file], [security]
]
]
[#IF license |THEN|
[#IF NOT cur^license
|THEN|
display^action licensed
fup^cmd LICENSE [file]
]
]
[#IF progid |THEN|
[#IF NOT cur^progid
|THEN|
display^action PROGID flag set
fup^cmd SECURE [file],, PROGID
]
]
[#IF action
|THEN|
fup^cmd INFO [file]
|ELSE|
[#IF tflag
|THEN|
display^noaction
|ELSE|
#OUTPUT /HOLD/ Unchanged : [file]
[#IF cur^progid |THEN| #OUTPUT /COLUMN 39,HOLD/ P]
[#IF cur^license |THEN| #OUTPUT /COLUMN 40,HOLD/ L]
#OUTPUTV /COLUMN 43,HOLD/ cur^security
#OUTPUTV /COLUMN 50,HOLD/ cur^owner
#OUTPUT
]
]
]
#PUSH arg template file security owner progid license prev action count tflag
#PUSH cur^security cur^owner cur^license cur^progid
#SETMANY license progid, 0 0
#SET count 0
#SET tflag 0
[#LOOP |WHILE| [#MORE]
|DO|
[#CASE [#ARGUMENT /VALUE arg/ FILENAME
USER /USERNAME/
USER
SECURITY
KEYWORD /WORDLIST LICENSE/
KEYWORD /WORDLIST PROGID/
TEMPLATE
]
| 1 | #SETV file arg
| 2 | #SETV owner arg
| 3 | #SET owner [#USERNAME [arg]]
| 4 | #SETV security arg
| 5 | #SET license -1
| 6 | #SET progid -1
| 7 | #SETV template arg
]
]
[#IF [#ARGUMENT END]]
[#IF [#EMPTYV template]
|THEN|
#SETV template file
|ELSE|
#SET tflag -1
#OUTPUT /HOLD/ Template : [template]
[#IF progid |THEN| #OUTPUT /COLUMN 39,HOLD/ P]
[#IF license |THEN| #OUTPUT /COLUMN 40,HOLD/ L]
[#IF NOT [#EMPTYV security] |THEN| #OUTPUTV /HOLD/ " "[security]""]
[#IF NOT [#EMPTYV owner] |THEN| #OUTPUTV /HOLD/ " [owner]"]
#OUTPUT
]
[#IF [#EMPTYV template]
|THEN|
#OUTPUT ERROR! No filename specified
#RESET FRAMES
unzip-6.0/tandem/tandem.c view on Meta::CPAN
}
/* TANDEM version of chmod() function */
int chmod(file, unix_sec)
const char *file;
mode_t unix_sec;
{
FILE *stream;
struct nsk_sec_type {
unsigned progid : 1;
unsigned clear : 1;
unsigned null : 2;
unsigned read : 3;
unsigned write : 3;
unsigned execute: 3;
unsigned purge : 3;
};
union nsk_sec_ov {
struct nsk_sec_type bit_ov;
short int_ov;
};
union nsk_sec_ov nsk_sec;
short fnum, err, nsk_sec_int;
short len, access, exclus, extension, options;
char fname[FILENAME_MAX + 1];
char ext[EXTENSION_MAX + 1];
nsk_sec.bit_ov.progid = 0;
nsk_sec.bit_ov.clear = 0;
nsk_sec.bit_ov.null = 0;
/* 4="N", 5="C", 6="U", 7="-" */
if (unix_sec & S_IROTH) nsk_sec.bit_ov.read = 4;
else if (unix_sec & S_IRGRP) nsk_sec.bit_ov.read = 5;
else if (unix_sec & S_IRUSR) nsk_sec.bit_ov.read = 6;
else nsk_sec.bit_ov.read = 7;
unzip-6.0/tandem/tandem.c view on Meta::CPAN
err = FILE_OPEN_((char *)fname, len, &fnum, access, exclus,,,options,,,);
err = (SETMODE(fnum, SET_FILE_SECURITY, nsk_sec_int) != CCE);
err = FILE_CLOSE_(fnum);
return (err != 0 ? -1 : 0);
}
/* TANDEM version of chown() function */
int chown(file, uid, gid)
const char *file;
uid_t uid;
gid_t gid;
{
FILE *stream;
struct nsk_own_type {
unsigned group : 8;
unsigned user : 8;
};
union nsk_own_ov {
struct nsk_own_type bit_ov;
short int_ov;
};
union nsk_own_ov nsk_own;
short fnum, err, nsk_own_int;
short len, access, exclus, extension, options;
char fname[FILENAME_MAX + 1];
char ext[EXTENSION_MAX + 1];
nsk_own.bit_ov.group = gid;
nsk_own.bit_ov.user = uid;
nsk_own_int = nsk_own.int_ov;
access = NSK_RDONLY;
exclus = NSK_SHARED;
options = NSK_NOUPDATEOPENTIME;
extension = parsename (file,fname,ext);
len = strlen(fname);
unzip-6.0/tandem/tandem.c view on Meta::CPAN
/* #0 #1 #2 #3 #4 #5 #6 #7 #8 #9 */
short ulist[ulist_items]={65 };
short ulen[ulist_items] ={ 1 };
short uoff[ulist_items];
short flist[flist_size];
short extra[2];
short *rlen=&extra[0];
short *err_item=&extra[1];
unsigned short *fowner;
unsigned short *fprogid;
char *fsec;
nsk_stat_ov *nsk_ov;
nsk_file_attrs *nsk_attr;
short end, count, kind, level, options, searchid;
short info[5];
/* Initialise stat structure */
s->st_dev = _S_GUARDIANOBJECT;
s->st_ino = 0;
s->st_nlink = 0;
s->st_rdev = 0;
s->st_uid = s->st_gid = 0;
s->st_size = 0;
s->st_atime = s->st_ctime = s->st_mtime = 0;
s->st_reserved[0] = 0;
s->st_reserved[1] = 0;
s->st_reserved[2] = 0;
nsk_ov = (nsk_stat_ov *)&s->st_reserved[0];
nsk_attr = (nsk_file_attrs *)&nsk_ov->ov.nsk_ef_region;
/* Check to see if name contains a (pseudo) file extension */
extension = parsename (n,fname,ext);
unzip-6.0/tandem/tandem.c view on Meta::CPAN
/* Setup timestamps */
s->st_atime = gmt_to_time_t ((long long *)&flist[ioff[0]]);
s->st_mtime = s->st_ctime = gmt_to_time_t ((long long *)&flist[ioff[1]]);
nsk_ov->ov.creation_time = gmt_to_time_t ((long long *)&flist[ioff[2]]);
s->st_size = *(off_t *)&flist[ioff[3]];
fowner = (unsigned short *)&flist[ioff[4]];
s->st_uid = *fowner & 0x00ff;
s->st_gid = *fowner >> 8;
/* Note that Purge security (fsec[3]) in NSK has no relevance to stat() */
fsec = (char *)&flist[ioff[5]];
fprogid = (unsigned short *)&flist[ioff[6]];
s->st_mode = S_IFREG | /* Regular File */
/* Parse Read Flag */
((fsec[0] & 0x03) == 0x00 ? S_IROTH : 0) |
((fsec[0] & 0x02) == 0x00 ? S_IRGRP : 0) |
((fsec[0] & 0x03) != 0x03 ? S_IRUSR : 0) |
/* Parse Write Flag */
((fsec[1] & 0x03) == 0x00 ? S_IWOTH : 0) |
((fsec[1] & 0x02) == 0x00 ? S_IWGRP : 0) |
((fsec[1] & 0x03) != 0x03 ? S_IWUSR : 0) |
/* Parse Execute Flag */
((fsec[2] & 0x03) == 0x00 ? S_IXOTH : 0) |
((fsec[2] & 0x02) == 0x00 ? S_IXGRP : 0) |
((fsec[2] & 0x03) != 0x03 ? S_IXUSR : 0) |
/* Parse Progid */
(*fprogid == 1 ? (S_ISUID | S_ISGID) : 0) ;
/* Set up NSK additional stat fields */
nsk_attr->progid = (unsigned) flist[ioff[6]];
nsk_attr->filetype = (unsigned) flist[ioff[7]];
nsk_attr->filecode = (unsigned) flist[ioff[8]];
nsk_attr->block = (unsigned short) flist[ioff[9]];
nsk_attr->priext = (unsigned short) flist[ioff[10]];
nsk_attr->secext = (unsigned short) flist[ioff[11]];
nsk_attr->maxext = (unsigned short) flist[ioff[12]];
nsk_attr->flags.clearonpurge = (unsigned) flist[ioff[13]];
nsk_attr->licensed = (unsigned) flist[ioff[14]];
nsk_attr->flags.audited = (unsigned) flist[ioff[15]];
nsk_attr->flags.acompress = (unsigned) flist[ioff[16]];
unzip-6.0/tandem/tandem.h view on Meta::CPAN
struct nsk_file_flags flags; /* 16 */
struct nsk_owner owner; /* 16 */
unsigned short priext; /* 16 */
unsigned short secext; /* 16 */
unsigned maxext : 10;
unsigned read : 3;
unsigned write : 3;
unsigned execute : 3;
unsigned delete : 3;
unsigned licensed : 1;
unsigned progid : 1;
unsigned keylen : 8;
unsigned : 5;
unsigned keyoff : 11;
unsigned : 1;
unsigned filetype : 2;
unsigned fileopen : 1;
unsigned reclen : 12;
};
typedef struct nsk_file_attrs_def nsk_file_attrs;
unzip-6.0/tandem/tanunz.c view on Meta::CPAN
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
union {
iztimes t3; /* mtime, atime, ctime */
ztimbuf t2; /* modtime, actime */
} zt;
ulg z_uidgid[2];
unsigned eb_izux_flg;
nsk_file_attrs *znsk_attr;
short err;
unsigned short len;
#define alist_items 1
#define vlist_bytes 2
short alist[alist_items]={42 };
unsigned short vlist[alist_items];
short extra, *err_item=&extra;
unzip-6.0/tandem/tanunz.c view on Meta::CPAN
then have to check for restoration of UID/GID.
---------------------------------------------------------------------------*/
eb_izux_flg = (G.extra_field ? ef_scan_for_izux(G.extra_field,
G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,
#ifdef IZ_CHECK_TZ
(G.tz_is_valid ? &(zt.t3) : NULL),
#else
&(zt.t3),
#endif
z_uidgid) : 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
TTrace((stderr, "\nclose_outfile: Unix e.f. modif. time = %ld\n",
zt.t3.mtime));
} else {
zt.t3.mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
TTrace((stderr, "close_outfile: Unix e.f. access time = %ld\n",
zt.t3.atime));
} else {
unzip-6.0/tandem/tanunz.c view on Meta::CPAN
#endif
/*---------------------------------------------------------------------------
if -X option was specified and we have UID/GID info, restore it
this must come after the file security and modtimes changes - since once
we have secured the file to somebody else we cannot access it again.
---------------------------------------------------------------------------*/
if (uO.X_flag && eb_izux_flg & EB_UX2_VALID) {
TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n"));
if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
{
if (uO.qflag)
Info(slide, 0x201, ((char *)slide,
"warning: cannot set UID %lu and/or GID %lu for %s\n",
z_uidgid[0], z_uidgid[1], FnFilter1(G.filename)));
else
Info(slide, 0x201, ((char *)slide,
" (warning) cannot set UID %lu and/or GID %lu",
z_uidgid[0], z_uidgid[1]));
}
}
} /* end function close_outfile() */
#ifndef SFX
/************************/
/* Function version() */
unzip-6.0/theos/_stat.c view on Meta::CPAN
if (drive >= 'a' && drive <= 'Z')
drive -= 0x40;
memset(st, 0, sizeof(struct stat));
if (getlub(drive - 'A') != 255) {
st->st_org = _FDB_STAT_DIRECTORY;
st->st_mode = S_IFDIR|S_IRUSR|S_IWUSR|S_IROTH|S_IWOTH;
st->st_nlink = 1;
st->st_dev = st->st_rdev = drive - 'A';
st->st_uid = st->st_gid = getuid();
st->st_protect = _FDB_ERASE_PROTECT;
return 0;
}
errno = _errnum = ENOENT;
_errarg = fn;
return -1;
}
/* file stat */
unzip-6.0/theos/_stat.c view on Meta::CPAN
st->st_mode = S_IFCHR | S_IWUSR;
if (_isprt(st->st_dev))
st->st_mode |= S_IRUSR;
if (peekucb(&ucb->devowner) == 255) {
st->st_mode |= S_IWGRP | S_IWOTH;
if (_isprt(st->st_dev))
st->st_mode |= S_IRGRP | S_IROTH;
}
}
st->st_nlink = 1;
st->st_uid = st->st_gid = getuid();
st->st_size = 0;
st->st_atime = st->st_mtime = st->st_ctime = 0;
st->st_rlen = 0;
st->st_klen = 0;
st->st_grow = 0;
st->st_blksize = 0;
return 0;
}
/* regular file stat */
unzip-6.0/theos/_stat.c view on Meta::CPAN
case _FDB_STAT_KEYED: st->st_mode = S_IFKEY; break;
case _FDB_STAT_INDEXED: st->st_mode = S_IFIND; break;
case _FDB_STAT_RANDOM: st->st_mode = S_IFRND; break;
case _FDB_STAT_PROGRAM: st->st_mode = S_IFR16; break;
case _FDB_STAT_16_BIT_PROGRAM: st->st_mode = S_IFP16; break;
case _FDB_STAT_32_BIT_PROGRAM: st->st_mode = S_IFP32; break;
}
st->st_mode |= _tm2um_(st->st_protect = fdb->protect);
st->st_nlink = 1;
st->st_uid = st->st_gid = fdb->fileowner;
st->st_size = fdb->filesize;
st->st_atime = st->st_mtime = st->st_ctime = getfiledate(fdb);
st->st_rlen = fdb->reclen;
st->st_klen = fdb->keylen;
st->st_grow = fdb->filegrow;
st->st_blksize = 0;
return 0;
}
#include <direct.h>
unzip-6.0/theos/stat.h view on Meta::CPAN
#define S_IXOTH 0x0001 /* execute permission: other */
#define S_IREAD 0x0100 /* read permission, owner */
#define S_IEXEC 0x0040 /* execute permission, owner */
#define S_IWRITE 0x0080 /* write permission, owner */
short st_ino; /* not used */
short st_dev; /* not used */
short st_rdev; /* not used */
short st_nlink; /* not used */
short st_uid; /* owner id */
short st_gid; /* not used */
unsigned long st_size; /* size of file */
unsigned long st_atime; /* not used */
unsigned long st_mtime; /* date & time last modified */
unsigned long st_ctime; /* not used */
unsigned long st_blksize; /* buffer size */
unsigned short st_org; /* organization */
unsigned short st_rlen; /* record size */
unsigned short st_klen; /* key size */
char st_grow; /* growing factor */
char st_protect; /* native protections */
unzip-6.0/theos/theos.c view on Meta::CPAN
#ifdef USE_EF_UT_TIME
unsigned eb_izux_flg;
eb_izux_flg = (G.extra_field ? ef_scan_for_izux(G.extra_field,
G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,
#ifdef IZ_CHECK_TZ
(G.tz_is_valid ? pzt : NULL),
#else
pzt,
#endif
z_uidgid) : 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
TTrace((stderr, "\nget_extattribs: Unix e.f. modif. time = %ld\n",
pzt->mtime));
} else {
pzt->mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
TTrace((stderr, "get_extattribs: Unix e.f. access time = %ld\n",
pzt->atime));
} else {
unzip-6.0/theos/thscfg.h view on Meta::CPAN
#define isatty(a) _isatty(a)
#undef match
int open(const char *name, int mode, ...);
size_t read(int fd, char *buf, size_t len);
size_t write(int fd, char *buf, size_t len);
unsigned long lseek(int fd, long offset, int base);
int close(int);
int _fprintf(FILE *fp, const char *fmt, ...);
int _isatty(int);
typedef unsigned char uid_t;
typedef unsigned char gid_t;
extern int _sprintf(char *s, const char *fmt, ...);
#ifndef NO_BOGUS_SPC
# include <stdio.h>
# undef fprintf
# undef sprintf
# define fprintf _fprintf
# define sprintf _sprintf
#else /* NO_BOGUS_SPC */
unzip-6.0/unix/unix.c view on Meta::CPAN
#ifdef SET_DIR_ATTRIB
typedef struct uxdirattr { /* struct for holding unix style directory */
struct uxdirattr *next; /* info until can be sorted and set at end */
char *fn; /* filename of directory */
union {
iztimes t3; /* mtime, atime, ctime */
ztimbuf t2; /* modtime, actime */
} u;
unsigned perms; /* same as min_info.file_attr */
int have_uidgid; /* flag */
ulg uidgid[2];
char fnbuf[1]; /* buffer stub for directory name */
} uxdirattr;
#define UxAtt(d) ((uxdirattr *)d) /* typecast shortcut */
#endif /* SET_DIR_ATTRIB */
#ifdef ACORN_FTYPE_NFS
/* Acorn bits for NFS filetyping */
typedef struct {
uch ID[2];
uch size[2];
unzip-6.0/unix/unix.c view on Meta::CPAN
/* This is used to clear or keep the SUID and SGID bits on file permissions.
* It's possible that a file in an archive could have one of these bits set
* and, unknown to the person unzipping, could allow others to execute the
* file as the user or group. The new option -K bypasses this check.
*/
static unsigned filtattr(__G__ perms)
__GDEF
unsigned perms;
{
/* keep setuid/setgid/tacky perms? */
if (!uO.K_flag)
perms &= ~(S_ISUID | S_ISGID | S_ISVTX);
return (0xffff & perms);
} /* end function filtattr() */
unzip-6.0/unix/unix.c view on Meta::CPAN
return -1;
return 0;
}
#endif /* NO_MKDIR */
#if (!defined(MTS) || defined(SET_DIR_ATTRIB))
static int get_extattribs OF((__GPRO__ iztimes *pzt, ulg z_uidgid[2]));
static int get_extattribs(__G__ pzt, z_uidgid)
__GDEF
iztimes *pzt;
ulg z_uidgid[2];
{
/*---------------------------------------------------------------------------
Convert from MSDOS-format local time and date to Unix-format 32-bit GMT
time: adjust base year from 1980 to 1970, do usual conversions from
yy/mm/dd hh:mm:ss to elapsed seconds, and account for timezone and day-
light savings time differences. If we have a Unix extra field, however,
we're laughing: both mtime and atime are ours. On the other hand, we
then have to check for restoration of UID/GID.
---------------------------------------------------------------------------*/
int have_uidgid_flg;
unsigned eb_izux_flg;
eb_izux_flg = (G.extra_field ? ef_scan_for_izux(G.extra_field,
G.lrec.extra_field_length, 0, G.lrec.last_mod_dos_datetime,
#ifdef IZ_CHECK_TZ
(G.tz_is_valid ? pzt : NULL),
#else
pzt,
#endif
z_uidgid) : 0);
if (eb_izux_flg & EB_UT_FL_MTIME) {
TTrace((stderr, "\nget_extattribs: Unix e.f. modif. time = %ld\n",
pzt->mtime));
} else {
pzt->mtime = dos_to_unix_time(G.lrec.last_mod_dos_datetime);
}
if (eb_izux_flg & EB_UT_FL_ATIME) {
TTrace((stderr, "get_extattribs: Unix e.f. access time = %ld\n",
pzt->atime));
} else {
pzt->atime = pzt->mtime;
TTrace((stderr, "\nget_extattribs: modification/access times = %ld\n",
pzt->mtime));
}
/* if -X option was specified and we have UID/GID info, restore it */
have_uidgid_flg =
#ifdef RESTORE_UIDGID
(uO.X_flag && (eb_izux_flg & EB_UX2_VALID));
#else
0;
#endif
return have_uidgid_flg;
}
#endif /* !MTS || SET_DIR_ATTRIB */
#ifndef MTS
/****************************/
/* Function close_outfile() */
/****************************/
void close_outfile(__G) /* GRR: change to return PK-style warning level */
__GDEF
{
union {
iztimes t3; /* mtime, atime, ctime */
ztimbuf t2; /* modtime, actime */
} zt;
ulg z_uidgid[2];
int have_uidgid_flg;
have_uidgid_flg = get_extattribs(__G__ &(zt.t3), z_uidgid);
/*---------------------------------------------------------------------------
If symbolic links are supported, allocate storage for a symlink control
structure, put the uncompressed "data" and other required info in it, and
add the structure to the "deferred symlinks" chain. Since we know it's a
symbolic link to start with, we shouldn't have to worry about overflowing
unsigned ints with unsigned longs.
---------------------------------------------------------------------------*/
#ifdef SYMLINKS
if (G.symlnk) {
extent ucsize = (extent)G.lrec.ucsize;
# ifdef SET_SYMLINK_ATTRIBS
extent attribsize = sizeof(unsigned) +
(have_uidgid_flg ? sizeof(z_uidgid) : 0);
# else
extent attribsize = 0;
# endif
/* size of the symlink entry is the sum of
* (struct size (includes 1st '\0') + 1 additional trailing '\0'),
* system specific attribute data size (might be 0),
* and the lengths of name and link target.
*/
extent slnk_entrysize = (sizeof(slinkentry) + 1) + attribsize +
ucsize + strlen(G.filename);
unzip-6.0/unix/unix.c view on Meta::CPAN
FnFilter1(G.filename)));
fclose(G.outfile);
return;
}
slnk_entry->next = NULL;
slnk_entry->targetlen = ucsize;
slnk_entry->attriblen = attribsize;
# ifdef SET_SYMLINK_ATTRIBS
memcpy(slnk_entry->buf, &(G.pInfo->file_attr),
sizeof(unsigned));
if (have_uidgid_flg)
memcpy(slnk_entry->buf + 4, z_uidgid, sizeof(z_uidgid));
# endif
slnk_entry->target = slnk_entry->buf + slnk_entry->attriblen;
slnk_entry->fname = slnk_entry->target + ucsize + 1;
strcpy(slnk_entry->fname, G.filename);
/* move back to the start of the file to re-read the "link data" */
rewind(G.outfile);
if (fread(slnk_entry->target, 1, ucsize, G.outfile) != ucsize)
{
unzip-6.0/unix/unix.c view on Meta::CPAN
qlfix(__G__ G.extra_field, G.lrec.extra_field_length);
}
#endif
#if (defined(NO_FCHOWN))
fclose(G.outfile);
#endif
/* if -X option was specified and we have UID/GID info, restore it */
if (have_uidgid_flg
/* check that both uid and gid values fit into their data sizes */
&& ((ulg)(uid_t)(z_uidgid[0]) == z_uidgid[0])
&& ((ulg)(gid_t)(z_uidgid[1]) == z_uidgid[1])) {
TTrace((stderr, "close_outfile: restoring Unix UID/GID info\n"));
#if (defined(NO_FCHOWN))
if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
#else
if (fchown(fileno(G.outfile), (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
#endif
{
if (uO.qflag)
Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid,
z_uidgid[0], z_uidgid[1], FnFilter1(G.filename),
strerror(errno)));
else
Info(slide, 0x201, ((char *)slide, CannotSetUidGid,
z_uidgid[0], z_uidgid[1], strerror(errno)));
}
}
#if (!defined(NO_FCHOWN) && defined(NO_FCHMOD))
fclose(G.outfile);
#endif
#if (!defined(NO_FCHOWN) && !defined(NO_FCHMOD))
/*---------------------------------------------------------------------------
Change the file permissions from default ones to those stored in the
unzip-6.0/unix/unix.c view on Meta::CPAN
#if (defined(SYMLINKS) && defined(SET_SYMLINK_ATTRIBS))
int set_symlnk_attribs(__G__ slnk_entry)
__GDEF
slinkentry *slnk_entry;
{
if (slnk_entry->attriblen > 0) {
# if (!defined(NO_LCHOWN))
if (slnk_entry->attriblen > sizeof(unsigned)) {
ulg *z_uidgid_p = (zvoid *)(slnk_entry->buf + sizeof(unsigned));
/* check that both uid and gid values fit into their data sizes */
if (((ulg)(uid_t)(z_uidgid_p[0]) == z_uidgid_p[0]) &&
((ulg)(gid_t)(z_uidgid_p[1]) == z_uidgid_p[1])) {
TTrace((stderr,
"set_symlnk_attribs: restoring Unix UID/GID info for\n\
%s\n",
FnFilter1(slnk_entry->fname)));
if (lchown(slnk_entry->fname,
(uid_t)z_uidgid_p[0], (gid_t)z_uidgid_p[1]))
{
Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid,
z_uidgid_p[0], z_uidgid_p[1], FnFilter1(slnk_entry->fname),
strerror(errno)));
}
}
}
# endif /* !NO_LCHOWN */
# if (!defined(NO_LCHMOD))
TTrace((stderr,
"set_symlnk_attribs: restoring Unix attributes for\n %s\n",
FnFilter1(slnk_entry->fname)));
if (lchmod(slnk_entry->fname,
unzip-6.0/unix/unix.c view on Meta::CPAN
d_entry = (uxdirattr *)malloc(sizeof(uxdirattr) + strlen(G.filename));
*pd = (direntry *)d_entry;
if (d_entry == (uxdirattr *)NULL) {
return PK_MEM;
}
d_entry->fn = d_entry->fnbuf;
strcpy(d_entry->fn, G.filename);
d_entry->perms = G.pInfo->file_attr;
d_entry->have_uidgid = get_extattribs(__G__ &(d_entry->u.t3),
d_entry->uidgid);
return PK_OK;
} /* end function defer_dir_attribs() */
int set_direc_attribs(__G__ d)
__GDEF
direntry *d;
{
int errval = PK_OK;
if (UxAtt(d)->have_uidgid &&
/* check that both uid and gid values fit into their data sizes */
((ulg)(uid_t)(UxAtt(d)->uidgid[0]) == UxAtt(d)->uidgid[0]) &&
((ulg)(gid_t)(UxAtt(d)->uidgid[1]) == UxAtt(d)->uidgid[1]) &&
chown(UxAtt(d)->fn, (uid_t)UxAtt(d)->uidgid[0],
(gid_t)UxAtt(d)->uidgid[1]))
{
Info(slide, 0x201, ((char *)slide, CannotSetItemUidGid,
UxAtt(d)->uidgid[0], UxAtt(d)->uidgid[1], FnFilter1(d->fn),
strerror(errno)));
if (!errval)
errval = PK_WARN;
}
/* Skip restoring directory time stamps on user' request. */
if (uO.D_flag <= 0) {
/* restore directory timestamps */
if (utime(d->fn, &UxAtt(d)->u.t2)) {
Info(slide, 0x201, ((char *)slide, CannotSetItemTimestamps,
FnFilter1(d->fn), strerror(errno)));
unzip-6.0/unix/unix.c view on Meta::CPAN
long d_backup __attribute__ ((packed)); /* EOD */
};
#define LONGID "QDOS02"
#define EXTRALEN (sizeof(struct qdirect) + 8)
#define JBLONGID "QZHD"
#define JBEXTRALEN (sizeof(jbextra) - 4 * sizeof(char))
typedef struct {
char eb_header[4] __attribute__ ((packed)); /* place_holder */
char longid[8] __attribute__ ((packed));
struct qdirect header __attribute__ ((packed));
} qdosextra;
typedef struct {
char eb_header[4]; /* place_holder */
char longid[4];
struct qdirect header;
} jbextra;
/* The following two functions SH() and LG() convert big-endian short
* and long numbers into native byte order. They are some kind of
* counterpart to the generic UnZip's makeword() and makelong() functions.
*/
static ush SH(ush val)
unzip-6.0/unix/unix.c view on Meta::CPAN
struct _ntc_
{
long id;
long dlen;
} ntc;
long dlen = 0;
qdosextra *extra = (qdosextra *)ef_ptr;
jbextra *jbp = (jbextra *)ef_ptr;
if (!strncmp(extra->longid, LONGID, strlen(LONGID)))
{
if (eb_len != EXTRALEN)
if (uO.qflag)
Info(slide, 0x201, ((char *)slide,
"warning: invalid length in Qdos field for %s\n",
FnFilter1(G.filename)));
else
Info(slide, 0x201, ((char *)slide,
"warning: invalid length in Qdos field"));
if (extra->header.d_type)
{
dlen = extra->header.d_datalen;
}
}
if (!strncmp(jbp->longid, JBLONGID, strlen(JBLONGID)))
{
if (eb_len != JBEXTRALEN)
if (uO.qflag)
Info(slide, 0x201, ((char *)slide,
"warning: invalid length in QZ field for %s\n",
FnFilter1(G.filename)));
else
Info(slide, 0x201, ((char *)slide,
"warning: invalid length in QZ field"));
if (jbp->header.d_type)
unzip-6.0/unzip.c view on Meta::CPAN
-Y treat \".nnn\" as \";nnn\" version -2 force ODS2 names\n\
--D restore dir (-D: no) timestamps\n\
(Must quote upper-case options, like \"-V\", unless SET PROC/PARSE=EXTEND.)\
\n\n";
#endif
#else /* !VMS */
#ifdef ATH_BEO_UNX
static ZCONST char Far local2[] = " -X restore UID/GID info";
#ifdef MORE
static ZCONST char Far local3[] = "\
-K keep setuid/setgid/tacky permissions -M pipe through \"more\" pager\n";
#else
static ZCONST char Far local3[] = "\
-K keep setuid/setgid/tacky permissions\n";
#endif
#else /* !ATH_BEO_UNX */
#ifdef TANDEM
static ZCONST char Far local2[] = "\
-X restore Tandem User ID -r remove file extensions\n\
-b create 'C' (180) text files ";
#ifdef MORE
static ZCONST char Far local3[] = " \
-M pipe through \"more\" pager\n";
#else
unzip-6.0/unzip.h view on Meta::CPAN
int i_flag; /* -i: [MacOS] ignore filenames stored in Mac e.f. */
#endif
#ifdef RISCOS
int scanimage; /* -I: scan image files */
#endif
int jflag; /* -j: junk pathnames (unzip) */
#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(MACOS))
int J_flag; /* -J: ignore AtheOS/BeOS/MacOS e. f. info (unzip) */
#endif
#if (defined(__ATHEOS__) || defined(__BEOS__) || defined(UNIX))
int K_flag; /* -K: keep setuid/setgid/tacky permissions */
#endif
int lflag; /* -12slmv: listing format (zipinfo) */
int L_flag; /* -L: convert filenames from some OSes to lowercase */
int overwrite_none; /* -n: never overwrite files (no prompting) */
#ifdef AMIGA
int N_flag; /* -N: restore comments as AmigaDOS filenotes */
#endif
int overwrite_all; /* -o: OK to overwrite files without prompting */
#endif /* !FUNZIP */
int qflag; /* -q: produce a lot less output */
unzip-6.0/unzpriv.h view on Meta::CPAN
#endif
/* bad or (occasionally?) missing stddef.h: */
#if (defined(M_XENIX) || defined(DNIX))
# define NO_STDDEF_H
#endif
#if (defined(M_XENIX) && !defined(M_UNIX)) /* SCO Xenix only, not SCO Unix */
# define SCO_XENIX
# define NO_LIMITS_H /* no limits.h, but MODERN defined */
# define NO_UID_GID /* no uid_t/gid_t */
# define size_t int
#endif
#ifdef realix /* Modcomp Real/IX, real-time SysV.3 variant */
# define SYSV
# define NO_UID_GID /* no uid_t/gid_t */
#endif
#if (defined(_AIX) && !defined(_ALL_SOURCE))
# define _ALL_SOURCE
#endif
#if defined(apollo) /* defines __STDC__ */
# define NO_STDLIB_H
#endif
unzip-6.0/unzpriv.h view on Meta::CPAN
#define EF_MD5 0x4b46 /* Fred Kantor's MD5 ("FK") */
#define EF_ASIUNIX 0x756e /* ASi's Unix ("nu") */
#define EB_HEADSIZE 4 /* length of extra field block header */
#define EB_ID 0 /* offset of block ID in header */
#define EB_LEN 2 /* offset of data length field in header */
#define EB_UCSIZE_P 0 /* offset of ucsize field in compr. data */
#define EB_CMPRHEADLEN 6 /* lenght of compression header */
#define EB_UX_MINLEN 8 /* minimal "UX" field contains atime, mtime */
#define EB_UX_FULLSIZE 12 /* full "UX" field (atime, mtime, uid, gid) */
#define EB_UX_ATIME 0 /* offset of atime in "UX" extra field data */
#define EB_UX_MTIME 4 /* offset of mtime in "UX" extra field data */
#define EB_UX_UID 8 /* byte offset of UID in "UX" field data */
#define EB_UX_GID 10 /* byte offset of GID in "UX" field data */
#define EB_UX2_MINLEN 4 /* minimal "Ux" field contains UID/GID */
#define EB_UX2_UID 0 /* byte offset of UID in "Ux" field data */
#define EB_UX2_GID 2 /* byte offset of GID in "Ux" field data */
#define EB_UX2_VALID (1 << 8) /* UID/GID present */
unzip-6.0/unzpriv.h view on Meta::CPAN
typedef ulg zusz_t; /* zipentry sizes & offsets */
typedef unsigned int zucn_t; /* archive entry counts */
typedef unsigned short zuvl_t; /* multivolume numbers */
# define MASK_ZUCN64 (~(zucn_t)0)
#endif
#define MASK_ZUCN16 ((zucn_t)0xFFFF)
#ifdef NO_UID_GID
# ifdef UID_USHORT
typedef unsigned short uid_t; /* TI SysV.3 */
typedef unsigned short gid_t;
# else
typedef unsigned int uid_t; /* SCO Xenix */
typedef unsigned int gid_t;
# endif
#endif
#if (defined(GOT_UTIMBUF) || defined(sgi) || defined(ATARI))
typedef struct utimbuf ztimbuf;
#else
typedef struct ztimbuf {
time_t actime; /* new access time */
time_t modtime; /* new modification time */
} ztimbuf;
unzip-6.0/unzpriv.h view on Meta::CPAN
int process_cdir_file_hdr OF((__GPRO));
int process_local_file_hdr OF((__GPRO));
int getZip64Data OF((__GPRO__ ZCONST uch *ef_buf,
unsigned ef_len));
#ifdef UNICODE_SUPPORT
int getUnicodeData OF((__GPRO__ ZCONST uch *ef_buf,
unsigned ef_len));
#endif
unsigned ef_scan_for_izux OF((ZCONST uch *ef_buf, unsigned ef_len,
int ef_is_c, ulg dos_mdatetime,
iztimes *z_utim, ulg *z_uidgid));
#if (defined(RISCOS) || defined(ACORN_FTYPE_NFS))
zvoid *getRISCOSexfield OF((ZCONST uch *ef_buf, unsigned ef_len));
#endif
#ifndef SFX
/*---------------------------------------------------------------------------
Functions in zipinfo.c (`zipinfo-style' listing routines):
---------------------------------------------------------------------------*/
unzip-6.0/win32/w32cfg.h view on Meta::CPAN
# ifdef __LCC__
/* The LCC headers lack these declarations of MSC rtl functions in
sys/stat.h. */
struct _stati64 {
unsigned int st_dev;
unsigned short st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
unsigned int st_rdev;
__int64 st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
int _stati64(const char *, struct _stati64 *);
int _fstati64(int, struct _stati64 *);
__int64 _lseeki64(int, __int64, int);
# endif /* __LCC__ */
unzip-6.0/wince/wince.h view on Meta::CPAN
//******************************************************************************
//***** SYS\STAT.H functions
//******************************************************************************
struct stat {
// _dev_t st_dev;
// _ino_t st_ino;
unsigned short st_mode;
// short st_nlink;
// short st_uid;
// short st_gid;
// _dev_t st_rdev;
_off_t st_size;
// time_t st_atime;
time_t st_mtime;
// time_t st_ctime;
};
#define _S_IFMT 0170000 // file type mask
#define _S_IFDIR 0040000 // directory
//#define _S_IFCHR 0020000 // character special