summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/add
diff options
context:
space:
mode:
authorflz <flz@FreeBSD.org>2010-04-01 14:27:29 +0000
committerflz <flz@FreeBSD.org>2010-04-01 14:27:29 +0000
commit348853b7ae1be0b9abbde8c1b0ad8dcb786a2cb7 (patch)
tree1486f9eaf9804cb93c84a7078a8ff619081a81d8 /usr.sbin/pkg_install/add
parent45fc1063dc09f04be77d5f45e0f6dac1fe29025e (diff)
downloadFreeBSD-src-348853b7ae1be0b9abbde8c1b0ad8dcb786a2cb7.zip
FreeBSD-src-348853b7ae1be0b9abbde8c1b0ad8dcb786a2cb7.tar.gz
Various fixes.
- Replace hardcoded INDEX version. [1] - Fix a buffer overlap. [2] - Remove empty package when fetching fails and -K is used. [3] - Remove useless chmod2() after mkdtemp(3). [4] - Replace mkdir(1) call with mkdir(2). [5] - Get rid of some vsystem() calls. - Switch from lstat(2) to open(2) in fexists(). - Try rename(2) in move_file() first. - Bump PKG_INSTALL_VERSION to 20100401. PR: bin/145101 [1], bin/139492 [2], bin/144919 [3] bin/144920 [4], bin/144921 [5] Submitted by: gcooper [1,2,3,4,5]
Diffstat (limited to 'usr.sbin/pkg_install/add')
-rw-r--r--usr.sbin/pkg_install/add/futil.c2
-rw-r--r--usr.sbin/pkg_install/add/perform.c24
2 files changed, 18 insertions, 8 deletions
diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c
index e097140..ca095ea 100644
--- a/usr.sbin/pkg_install/add/futil.c
+++ b/usr.sbin/pkg_install/add/futil.c
@@ -50,7 +50,7 @@ make_hierarchy(char *dir)
}
}
else {
- if (vsystem("/bin/mkdir %s", dir)) {
+ if (mkdir(dir, 0777) < 0) {
if (cp2)
*cp2 = '/';
return FAIL;
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 499d6c6..b23cd52 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -78,6 +78,7 @@ pkg_do(char *pkg)
char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
char *conflict[2];
char **matched;
+ int fd;
conflictsfound = 0;
code = 0;
@@ -408,8 +409,10 @@ pkg_do(char *pkg)
goto bomb;
/* Look for the requirements file */
- if (fexists(REQUIRE_FNAME)) {
- vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */
+ if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Running requirements file first for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s INSTALL", REQUIRE_FNAME, Plist.name)) {
@@ -441,8 +444,10 @@ pkg_do(char *pkg)
}
/* If we're really installing, and have an installation file, run it */
- if (!NoInstall && fexists(pre_script)) {
- vsystem("/bin/chmod +x %s", pre_script); /* make sure */
+ if (!NoInstall && (fd = open(pre_script, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Running pre-install for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s %s", pre_script, Plist.name, pre_arg)) {
@@ -470,8 +475,10 @@ pkg_do(char *pkg)
}
/* Run the installation script one last time? */
- if (!NoInstall && fexists(post_script)) {
- vsystem("/bin/chmod +x %s", post_script); /* make sure */
+ if (!NoInstall && (fd = open(post_script, O_RDWR)) != -1) {
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */
+ close(fd);
if (Verbose)
printf("Running post-install for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s %s", post_script, Plist.name, post_arg)) {
@@ -503,7 +510,10 @@ pkg_do(char *pkg)
goto success; /* close enough for government work */
}
/* Make sure pkg_info can read the entry */
- vsystem("/bin/chmod a+rx %s", LogDir);
+ fd = open(LogDir, O_RDWR);
+ fstat(fd, &sb);
+ fchmod(fd, sb.st_mode | S_IRALL | S_IXALL); /* be sure, chmod a+rx */
+ close(fd);
move_file(".", DESC_FNAME, LogDir);
move_file(".", COMMENT_FNAME, LogDir);
if (fexists(INSTALL_FNAME))
OpenPOWER on IntegriCloud