Fix unzip in usermin
authorJamie Cameron <jcameron@webmin.com>
Mon, 26 Jul 2010 14:55:55 +0000 (07:55 -0700)
committerJamie Cameron <jcameron@webmin.com>
Mon, 26 Jul 2010 14:55:55 +0000 (07:55 -0700)
updown/updown-lib.pl
updown/upload.cgi

index 0853b6e..6942068 100755 (executable)
@@ -269,5 +269,19 @@ else {
        }
 }
 
+# webmin_command_as_user(user, env, command)
+# Return a command as some user with su if this is webmin, or un-changed for
+# usermin
+sub webmin_command_as_user
+{
+my ($user, $env, @args) = @_;
+if ($module_info{'usermin'}) {
+       return join(" ", @args);
+       }
+else {
+       return &command_as_user($user, $env, @args);
+       }
+}
+
 1;
 
index 8c8e144..7264bd2 100755 (executable)
@@ -83,7 +83,7 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                                $err = &text('upload_ecmd', "unzip");
                                }
                        else {
-                               open(OUT, &command_as_user($uinfo[0], 0, "(cd $qdir && unzip -o $qpath)")." 2>&1 </dev/null |");
+                               open(OUT, &webmin_command_as_user($uinfo[0], 0, "(cd $qdir && unzip -o $qpath)")." 2>&1 </dev/null |");
                                while(<OUT>) {
                                        $out .= $_;
                                        if (/^\s*[a-z]+:\s+(.*)/) {
@@ -101,7 +101,7 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                                $err = &text('upload_ecmd', "tar");
                                }
                        else {
-                               open(OUT, &command_as_user($uinfo[0], 0, "(cd $qdir && tar xvf $qpath)")." 2>&1 </dev/null |");
+                               open(OUT, &webmin_command_as_user($uinfo[0], 0, "(cd $qdir && tar xvf $qpath)")." 2>&1 </dev/null |");
                                while(<OUT>) {
                                        $out .= $_;
                                        if (/^(.*)/) {
@@ -119,7 +119,7 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                                $err = &text('upload_ecmd', "lha");
                                }
                        else {
-                               open(OUT, &command_as_user($uinfo[0], 0, "(cd $qdir && lha xf $qpath)")." 2>&1 </dev/null |");
+                               open(OUT, &webmin_command_as_user($uinfo[0], 0, "(cd $qdir && lha xf $qpath)")." 2>&1 </dev/null |");
                                while(<OUT>) {
                                        $out .= $_;
                                        if (/(\S[^\t]*\S)\s+\-\s+/) {
@@ -142,7 +142,7 @@ for($i=0; defined($d = $in{"upload$i"}); $i++) {
                                $err = &text('upload_ecmd', $zipper);
                                }
                        else {
-                               open(OUT, &command_as_user($uinfo[0], 0, "(cd $qdir && $zipper -c $qpath | tar xvf -)")." 2>&1 </dev/null |");
+                               open(OUT, &webmin_command_as_user($uinfo[0], 0, "(cd $qdir && $zipper -c $qpath | tar xvf -)")." 2>&1 </dev/null |");
                                while(<OUT>) {
                                        $out .= $_;
                                        if (/^(.*)/) {