Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pkg_install/add Replace calls to vsystem() by calls...



details:   https://anonhg.NetBSD.org/src/rev/0773159cdc4d
branches:  trunk
changeset: 550920:0773159cdc4d
user:      tron <tron%NetBSD.org@localhost>
date:      Mon Aug 25 10:35:28 2003 +0000

description:
Replace calls to vsystem() by calls to fexec() or fcexec().

diffstat:

 usr.sbin/pkg_install/add/futil.c   |  30 ++++++++++++++++++------------
 usr.sbin/pkg_install/add/perform.c |  22 ++++++++++------------
 2 files changed, 28 insertions(+), 24 deletions(-)

diffs (144 lines):

diff -r ffbe208f4564 -r 0773159cdc4d usr.sbin/pkg_install/add/futil.c
--- a/usr.sbin/pkg_install/add/futil.c  Mon Aug 25 10:23:41 2003 +0000
+++ b/usr.sbin/pkg_install/add/futil.c  Mon Aug 25 10:35:28 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: futil.c,v 1.10 2003/08/24 21:11:37 tron Exp $  */
+/*     $NetBSD: futil.c,v 1.11 2003/08/25 10:35:28 tron Exp $  */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: futil.c,v 1.7 1997/10/08 07:45:39 charnier Exp";
 #else
-__RCSID("$NetBSD: futil.c,v 1.10 2003/08/24 21:11:37 tron Exp $");
+__RCSID("$NetBSD: futil.c,v 1.11 2003/08/25 10:35:28 tron Exp $");
 #endif
 #endif
 
@@ -80,19 +80,25 @@
                cd_to = dir;
 
        if (Mode)
-               if (vsystem("cd %s && %s -R %s %s", cd_to, CHMOD_CMD, Mode, arg))
-                       warnx("couldn't change modes of '%s' to '%s'", arg, Mode);
-       if (Owner && Group) {
-               if (vsystem("cd %s && %s -R %s.%s %s", cd_to, CHOWN_CMD, Owner, Group, arg))
+               if (fcexec(cd_to, CHMOD_CMD, "-R", Mode, arg, NULL))
+                       warnx("couldn't change modes of '%s' to '%s'", arg,
+                           Mode);
+       if (Owner != NULL && Group != NULL) {
+               if (vsystem("cd %s && %s -R %s.%s %s", cd_to, CHOWN_CMD, Owner,
+                   Group, arg))
                        warnx("couldn't change owner/group of '%s' to '%s.%s'",
                            arg, Owner, Group);
                return;
        }
-       if (Owner) {
-               if (vsystem("cd %s && %s -R %s %s", cd_to, CHOWN_CMD, Owner, arg))
-                       warnx("couldn't change owner of '%s' to '%s'", arg, Owner);
+       if (Owner != NULL) {
+               if (fcexec(cd_to, CHOWN_CMD, "-R", Owner, arg, NULL))
+                       warnx("couldn't change owner of '%s' to '%s'", arg,
+                           Owner);
                return;
-       } else if (Group)
-               if (vsystem("cd %s && %s -R %s %s", cd_to, CHGRP_CMD, Group, arg))
-                       warnx("couldn't change group of '%s' to '%s'", arg, Group);
+       }
+       if (Group != NULL) {
+               if (fcexec(cd_to, CHGRP_CMD, "-R", Group, arg, NULL))
+                       warnx("couldn't change group of '%s' to '%s'", arg,
+                           Group);
+       }
 }
diff -r ffbe208f4564 -r 0773159cdc4d usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Mon Aug 25 10:23:41 2003 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Mon Aug 25 10:35:28 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.84 2003/08/24 21:11:37 tron Exp $        */
+/*     $NetBSD: perform.c,v 1.85 2003/08/25 10:35:28 tron Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.84 2003/08/24 21:11:37 tron Exp $");
+__RCSID("$NetBSD: perform.c,v 1.85 2003/08/25 10:35:28 tron Exp $");
 #endif
 #endif
 
@@ -124,8 +124,9 @@
 
        /* make sure dbdir actually exists! */
        if (!(isdir(dbdir) || islinktodir(dbdir))) {
-               if (vsystem("/bin/mkdir -p -m 755 %s", dbdir)) {
-                       errx(EXIT_FAILURE, "Database-dir %s cannot be generated, aborting.",
+               if (fexec("mkdir", "-m", "755", "-p", dbdir, NULL)) {
+                       errx(EXIT_FAILURE,
+                           "Database-dir %s cannot be generated, aborting.",
                            dbdir);
                }
        }
@@ -219,7 +220,7 @@
                                        if (!(isdir(p->name) || islinktodir(p->name)) && !Fake) {
                                                if (Verbose)
                                                        printf("Desired prefix of %s does not exist, creating.\n", p->name);
-                                               (void) vsystem("mkdir -p %s", p->name);
+                                               (void) fexec("mkdir", "-p", p->name, NULL);
                                        }
                                        if (chdir(p->name) == -1) {
                                                warn("unable to change directory to `%s'", p->name);
@@ -427,7 +428,7 @@
 
                                        if (Verbose)
                                                printf("pkg_delete '%s'\n", installed);
-                                       vsystem("pkg_delete '%s'\n", installed);
+                                       (void) fexec("pkg_delete", installed, NULL);
                                        
                                } else {
                                        warnx("other version '%s' already installed", installed);
@@ -448,8 +449,6 @@
                if (Verbose)
                        printf("Package `%s' conflicts with `%s'.\n", PkgName, p->name);
 
-               /* was: */
-               /* if (!vsystem("/usr/sbin/pkg_info -qe '%s'", p->name)) { */
                if (findmatchingname(dbdir, p->name, note_whats_installed, installed) > 0) {
                        warnx("Conflicting package `%s'installed, please use\n"
                              "\t\"pkg_delete %s\" first to remove it!", installed, installed);
@@ -467,7 +466,6 @@
                        continue;
                if (Verbose)
                        printf("Depends pre-scan: `%s' required.\n", p->name);
-               /* if (vsystem("/usr/sbin/pkg_info -qe '%s'", p->name)) { */
                if (findmatchingname(dbdir, p->name, note_whats_installed, installed) <= 0) {
                        /* 
                         * required pkg not found. look if it's available with a more liberal
@@ -587,7 +585,7 @@
        
        /* If we're really installing, and have an installation file, run it */
        if (!NoInstall && fexists(INSTALL_FNAME)) {
-               vsystem("%s +x %s", CHMOD_CMD, INSTALL_FNAME);  /* make sure */
+               (void) fexec(CHMOD_CMD, "+x", INSTALL_FNAME, NULL);     /* make sure */
                if (Verbose)
                        printf("Running install with PRE-INSTALL for %s.\n", PkgName);
                if (!Fake && vsystem("./%s %s PRE-INSTALL", INSTALL_FNAME, PkgName)) {
@@ -652,7 +650,7 @@
                        goto success;   /* close enough for government work */
                }
                /* Make sure pkg_info can read the entry */
-               vsystem("%s a+rx %s", CHMOD_CMD, LogDir);
+               (void) fexec(CHMOD_CMD, "a+rx", LogDir, NULL);
                if (fexists(INSTALL_FNAME))
                        move_file(".", INSTALL_FNAME, LogDir);
                if (fexists(DEINSTALL_FNAME))
@@ -790,7 +788,7 @@
                if (signo)
                        printf("Signal %d received, cleaning up.\n", signo);
                if (!Fake && zapLogDir && LogDir[0])
-                       vsystem("%s -rf %s", REMOVE_CMD, LogDir);
+                       (void) fexec(REMOVE_CMD, "-fr", LogDir, NULL);
                leave_playpen(Home);
                if (signo)
                        exit(1);



Home | Main Index | Thread Index | Old Index