about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-01-03 15:10:52 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-01-03 15:10:52 +0000
commitc6e3c577edeb9d1758fe2994dfab8b389926ee10 (patch)
treed1c3ca5e4fd357ee63a2bbe34c908f306e5a6b14 /src
parent610a46dc7a2b7459929b20e4350b3544e67c0b09 (diff)
downloads6-frontend-c6e3c577edeb9d1758fe2994dfab8b389926ee10.tar.gz
s6-frontend-c6e3c577edeb9d1758fe2994dfab8b389926ee10.tar.xz
s6-frontend-c6e3c577edeb9d1758fe2994dfab8b389926ee10.zip
chpst doesn't need stralloc (realpath() is ok to use directly here)
Diffstat (limited to 'src')
-rw-r--r--src/alias/s6-frontend-alias-chpst.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/alias/s6-frontend-alias-chpst.c b/src/alias/s6-frontend-alias-chpst.c
index 6611924..d57ca88 100644
--- a/src/alias/s6-frontend-alias-chpst.c
+++ b/src/alias/s6-frontend-alias-chpst.c
@@ -14,7 +14,6 @@
 #include <skalibs/sgetopt.h>
 #include <skalibs/buffer.h>
 #include <skalibs/strerr2.h>
-#include <skalibs/stralloc.h>
 #include <skalibs/djbunix.h>
 
 #include <execline/config.h>
@@ -139,8 +138,8 @@ static inline size_t parseuggsym (char const *s, uint32_t *flags, uid_t *uid, gi
 int main (int argc, char const *const *argv, char const *const *envp)
 {
   static char const *valopt[6] = { "-m", "-d", "-o", "-p", "-f", "-c" } ;
-  stralloc newroot = STRALLOC_ZERO ;
   unsigned int newargc = 0 ;
+  char const *newroot = 0 ;
   char const *edir = 0 ;
   char const *argv0 = 0 ;
   char const *lockfile = 0 ;
@@ -195,11 +194,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
           if (strchr(envug, ':')) { flags |= 8192 ; newargc++ ; } else flags &= ~8192 ;
           break ;
         case 'e' : edir = l.arg ; newargc += 3 ; break ;
-        case '/' :
-          newroot.len = 0 ;
-          if (sarealpath(&newroot, l.arg) < 0 || !stralloc_0(&newroot)) dienomem() ;
-          newargc += 2 ;
-          break ;
+        case '/' : newroot = l.arg ; newargc += 2 ; break ;
         case 'n' :
           if (!int0_scan(l.arg, &niceval)) dieusage() ;
           newargc += 3 ;
@@ -227,6 +222,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
     argc -= l.ind ; argv += l.ind ;
   }
 
+  if (newroot)
+  {
+    newroot = realpath(newroot, 0) ;
+    if (!newroot) dienomem() ;
+  }
   if (flags & 32) newargc += 2 ;
   newargc += argc ;
 
@@ -317,7 +317,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
       newargv[m++] = "2" ;
     }
 
-    if (argv0 && newroot.s)
+    if (argv0 && newroot)
     {
       argv0 = 0 ;
       strerr_warnw1x("the -b option is ineffective when the -/ option is also given") ;
@@ -331,10 +331,10 @@ int main (int argc, char const *const *argv, char const *const *envp)
       newargv[m++] = "--" ;
     }
 
-    if (newroot.s)
+    if (newroot)
     {
       newargv[m++] = "chroot" ;
-      newargv[m++] = newroot.s ;
+      newargv[m++] = newroot ;
     }
 
     for (int i = 0 ; i < argc+1 ; i++) newargv[m++] = argv[i] ;