diff options
author | phaniram rampura krishnamurthy - Sun Microsystems - Bangalore India <Phaniram.Krishnamurthy@Sun.COM> | 2009-07-20 12:16:38 +0530 |
---|---|---|
committer | phaniram rampura krishnamurthy - Sun Microsystems - Bangalore India <Phaniram.Krishnamurthy@Sun.COM> | 2009-07-20 12:16:38 +0530 |
commit | 0ba964ea1a9461d43c8e39e5a9a3ab857e6786c7 (patch) | |
tree | 31e5b1c8fd740de608505c54394c04aaf24d69b1 /usr/src/lib/libpkg | |
parent | ce0bfb39c0479ba97372eb0e5bf2ef4275d0876e (diff) | |
download | illumos-gate-0ba964ea1a9461d43c8e39e5a9a3ab857e6786c7.tar.gz |
5074117 installf problem with character and block special devices.
Diffstat (limited to 'usr/src/lib/libpkg')
-rw-r--r-- | usr/src/lib/libpkg/common/isdir.c | 84 | ||||
-rw-r--r-- | usr/src/lib/libpkg/common/mapfile-vers | 1 | ||||
-rw-r--r-- | usr/src/lib/libpkg/common/pkglib.h | 4 | ||||
-rw-r--r-- | usr/src/lib/libpkg/common/verify.c | 72 |
4 files changed, 102 insertions, 59 deletions
diff --git a/usr/src/lib/libpkg/common/isdir.c b/usr/src/lib/libpkg/common/isdir.c index 55b59d5e67..9ae2751fc6 100644 --- a/usr/src/lib/libpkg/common/isdir.c +++ b/usr/src/lib/libpkg/common/isdir.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -40,6 +40,7 @@ #include <string.h> #include "pkglocale.h" #include "pkglibmsgs.h" +#include "pkglib.h" /* * Defines for cpio/compression checks. @@ -77,6 +78,7 @@ int isFstypeRemote(char *a_fstype); int isdir(char *path); int isfile(char *dir, char *file); int iscpio(char *path, int *iscomp); +int eval_ftype(char *path, char ftype, char *myftype); /* * Name: isdir @@ -389,3 +391,83 @@ _InitRemoteFstypes(void) (void) fclose(fp); } + +/* + * Name: eval_ftype + * Description: Evaluate the target's file type + * Arguments: path - Path on filesystem + * ftype - Type to be changed to + * myftype - Address into which current + * type of target will be stored + * Returns: int + * 0 - Success + * VE_EXIST - Path does not exist + * VE_FTYPE - Path file type is not recognized, + * is not supported, + * or is not what is expected + */ +int +eval_ftype(char *path, char ftype, char *myftype) +{ + struct stat status; + int retcode = 0; + int statError = 0; + + /* 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)) { + (void) reperr(pkg_gt(ERR_EXIST)); + retcode = VE_EXIST; + *myftype = '?'; + statError++; + } + /* If not then we inspect the target of the link */ + } else { + if (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'; + break; + + case S_IFBLK: + *myftype = 'b'; + break; + + case S_IFREG: + case 0: + *myftype = 'f'; + break; + + case S_IFDOOR: + *myftype = 'D'; + break; + + default: + *myftype = '?'; + return (VE_FTYPE); + } + retcode = 0; + } + return (retcode); +} diff --git a/usr/src/lib/libpkg/common/mapfile-vers b/usr/src/lib/libpkg/common/mapfile-vers index f1fd2a8001..81934e31ae 100644 --- a/usr/src/lib/libpkg/common/mapfile-vers +++ b/usr/src/lib/libpkg/common/mapfile-vers @@ -89,6 +89,7 @@ SUNWprivate { epclose; epopen; esystem; + eval_ftype; find_ca_certs; find_cl_certs; find_key_cert_pair; diff --git a/usr/src/lib/libpkg/common/pkglib.h b/usr/src/lib/libpkg/common/pkglib.h index 04b17730ca..feb80d1d0f 100644 --- a/usr/src/lib/libpkg/common/pkglib.h +++ b/usr/src/lib/libpkg/common/pkglib.h @@ -499,10 +499,12 @@ extern void ds_order(char *list[]); extern void ds_putinfo(char *buf); extern void ds_skiptoend(char *device); extern void ecleanup(void); +extern int eval_ftype(char *path, char ftype, char *myftype); /*PRINTFLIKE1*/ extern void logerr(char *fmt, ...); extern int mappath(int flag, char *path); extern int mapvar(int flag, char *varname); +extern void reperr(char *fmt, ...); /*PRINTFLIKE1*/ extern void progerr(char *fmt, ...); extern void pkgerr(PKG_ERR *); @@ -626,6 +628,7 @@ extern int isFstypeRemote(); extern int isPathRemote(); extern int iscpio(); extern int isdir(); +extern int eval_ftype(); extern int isfile(); extern int pkgexecl(); extern int pkgexecv(); @@ -653,6 +656,7 @@ extern void ds_putinfo(); extern void ds_skiptoend(); extern void ecleanup(); extern void logerr(); +extern void reperr(); extern int mappath(); extern int mapvar(); extern void progerr(); diff --git a/usr/src/lib/libpkg/common/verify.c b/usr/src/lib/libpkg/common/verify.c index c48c5b8c77..1af2d2778c 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*/ -static void +void reperr(char *fmt, ...) { char *pt; @@ -392,7 +392,6 @@ 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]; @@ -491,62 +490,19 @@ averify(int fix, char *ftype, char *path, struct ainfo *ainfo) retcode = 0; - /* 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); - } - } + /* 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 (setval) { /* |