diff options
author | ok199659 <none@none> | 2009-07-24 11:43:35 -0700 |
---|---|---|
committer | ok199659 <none@none> | 2009-07-24 11:43:35 -0700 |
commit | b46ec01af51b4e66dbdba8ceb0a8e5ed36241df9 (patch) | |
tree | 99b6f2f41fa02d4c903a9c4297eac73c2aeb9196 /usr/src/lib/libpkg/common/verify.c | |
parent | 349b53dd4e695e3d833b5380540385145b2d3ae8 (diff) | |
download | illumos-joyent-b46ec01af51b4e66dbdba8ceb0a8e5ed36241df9.tar.gz |
backout 5074117: needs more work
Diffstat (limited to 'usr/src/lib/libpkg/common/verify.c')
-rw-r--r-- | usr/src/lib/libpkg/common/verify.c | 72 |
1 files changed, 58 insertions, 14 deletions
diff --git a/usr/src/lib/libpkg/common/verify.c b/usr/src/lib/libpkg/common/verify.c index 1af2d2778c..c48c5b8c77 100644 --- a/usr/src/lib/libpkg/common/verify.c +++ b/usr/src/lib/libpkg/common/verify.c @@ -85,7 +85,7 @@ typedef union hilo { } CHECKSUM_T; /*PRINTFLIKE1*/ -void +static void reperr(char *fmt, ...) { char *pt; @@ -392,6 +392,7 @@ averify(int fix, char *ftype, char *path, struct ainfo *ainfo) int uid, gid; int dochown; int retcode; + int statError = 0; int targ_is_dir = 0; /* replacing a directory */ char myftype; char buf[PATH_MAX]; @@ -490,19 +491,62 @@ averify(int fix, char *ftype, char *path, struct ainfo *ainfo) retcode = 0; - /* Evaluate the file type of existing object */ - retcode = eval_ftype(path, *ftype, &myftype); - - /* - * If path file type is not recognized, is not supported or - * is not what is expected, return - */ - if (retcode == VE_FTYPE) - return (retcode); - - /* If existing type is Directory, then set flag */ - if (myftype == 'd') - targ_is_dir = 1; + /* If we are to process symlinks the old way then we follow the link */ + if (nonABI_symlinks()) { + if ((*ftype == 's') ? lstat(path, &status) : + stat(path, &status)) { + reperr(pkg_gt(ERR_EXIST)); + retcode = VE_EXIST; + myftype = '?'; + statError++; + } + /* If not then we inspect the target of the link */ + } else { + if ((n = lstat(path, &status)) == -1) { + reperr(pkg_gt(ERR_EXIST)); + retcode = VE_EXIST; + myftype = '?'; + statError++; + } + } + if (!statError) { + /* determining actual type of existing object */ + switch (status.st_mode & S_IFMT) { + case S_IFLNK: + myftype = 's'; + break; + + case S_IFIFO: + myftype = 'p'; + break; + + case S_IFCHR: + myftype = 'c'; + break; + + case S_IFDIR: + myftype = 'd'; + targ_is_dir = 1; + break; + + case S_IFBLK: + myftype = 'b'; + break; + + case S_IFREG: + case 0: + myftype = 'f'; + break; + + case S_IFDOOR: + myftype = 'D'; + break; + + default: + reperr(pkg_gt(ERR_UNKNOWN)); + return (VE_FTYPE); + } + } if (setval) { /* |