Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69b5a5f0 authored by Cole Faust's avatar Cole Faust Committed by Gerrit Code Review
Browse files

Revert "Handle symlinks in sbox"

This reverts commit dd952905.

Reason for revert: There are at least b/315337725 and b/315036698 issues, reverting this cl while I fix them.

Change-Id: I644bbbe594b9dd53a99a3b6513fbcba68afe0b4a
parent dd952905
Loading
Loading
Loading
Loading
+2 −23
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import (
	"flag"
	"flag"
	"fmt"
	"fmt"
	"io"
	"io"
	"io/fs"
	"io/ioutil"
	"io/ioutil"
	"os"
	"os"
	"os/exec"
	"os/exec"
@@ -479,8 +478,7 @@ func copyFiles(copies []*sbox_proto.Copy, fromDir, toDir string, exists existsTy
// copyOneFile copies a file and its permissions.  If forceExecutable is true it adds u+x to the
// copyOneFile copies a file and its permissions.  If forceExecutable is true it adds u+x to the
// permissions.  If exists is allowFromNotExists it returns nil if the from path doesn't exist.
// permissions.  If exists is allowFromNotExists it returns nil if the from path doesn't exist.
// If write is onlyWriteIfChanged then the output file is compared to the input file and not written to
// If write is onlyWriteIfChanged then the output file is compared to the input file and not written to
// if it is the same, avoiding updating the timestamp. If from is a symlink, the symlink itself
// if it is the same, avoiding updating the timestamp.
// will be copied, instead of what it points to.
func copyOneFile(from string, to string, forceExecutable bool, exists existsType,
func copyOneFile(from string, to string, forceExecutable bool, exists existsType,
	write writeType) error {
	write writeType) error {
	err := os.MkdirAll(filepath.Dir(to), 0777)
	err := os.MkdirAll(filepath.Dir(to), 0777)
@@ -488,7 +486,7 @@ func copyOneFile(from string, to string, forceExecutable bool, exists existsType
		return err
		return err
	}
	}


	stat, err := os.Lstat(from)
	stat, err := os.Stat(from)
	if err != nil {
	if err != nil {
		if os.IsNotExist(err) && exists == allowFromNotExists {
		if os.IsNotExist(err) && exists == allowFromNotExists {
			return nil
			return nil
@@ -496,25 +494,6 @@ func copyOneFile(from string, to string, forceExecutable bool, exists existsType
		return err
		return err
	}
	}


	if stat.Mode()&fs.ModeSymlink != 0 {
		linkTarget, err := os.Readlink(from)
		if err != nil {
			return err
		}
		if write == onlyWriteIfChanged {
			toLinkTarget, err := os.Readlink(to)
			if err == nil && toLinkTarget == linkTarget {
				return nil
			}
		}
		err = os.Remove(to)
		if err != nil && !os.IsNotExist(err) {
			return err
		}

		return os.Symlink(linkTarget, to)
	}

	perm := stat.Mode()
	perm := stat.Mode()
	if forceExecutable {
	if forceExecutable {
		perm = perm | 0100 // u+x
		perm = perm | 0100 // u+x