2018-05-26 01:30:04 +02:00
|
|
|
// Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package paths
|
|
|
|
|
|
|
|
import "runtime"
|
|
|
|
|
|
|
|
type PathConfig struct {
|
|
|
|
// Whether to create the symlink in the new PATH for this tool.
|
|
|
|
Symlink bool
|
|
|
|
|
|
|
|
// Whether to log about usages of this tool to the soong.log
|
|
|
|
Log bool
|
|
|
|
|
|
|
|
// Whether to exit with an error instead of invoking the underlying tool.
|
|
|
|
Error bool
|
|
|
|
}
|
|
|
|
|
|
|
|
var Allowed = PathConfig{
|
|
|
|
Symlink: true,
|
|
|
|
Log: false,
|
|
|
|
Error: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
var Forbidden = PathConfig{
|
|
|
|
Symlink: false,
|
|
|
|
Log: true,
|
|
|
|
Error: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
// The configuration used if the tool is not listed in the config below.
|
2018-08-16 00:26:39 +02:00
|
|
|
// Currently this will create the symlink, but log and error when it's used. In
|
|
|
|
// the future, I expect the symlink to be removed, and this will be equivalent
|
|
|
|
// to Forbidden.
|
2018-05-26 01:30:04 +02:00
|
|
|
var Missing = PathConfig{
|
|
|
|
Symlink: true,
|
|
|
|
Log: true,
|
2018-08-16 00:26:39 +02:00
|
|
|
Error: true,
|
2018-05-26 01:30:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetConfig(name string) PathConfig {
|
|
|
|
if config, ok := Configuration[name]; ok {
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
return Missing
|
|
|
|
}
|
|
|
|
|
|
|
|
var Configuration = map[string]PathConfig{
|
|
|
|
"awk": Allowed,
|
|
|
|
"basename": Allowed,
|
|
|
|
"bash": Allowed,
|
2018-06-06 20:02:42 +02:00
|
|
|
"bc": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"bzip2": Allowed,
|
|
|
|
"cat": Allowed,
|
|
|
|
"chmod": Allowed,
|
|
|
|
"cmp": Allowed,
|
|
|
|
"comm": Allowed,
|
|
|
|
"cp": Allowed,
|
|
|
|
"cut": Allowed,
|
|
|
|
"date": Allowed,
|
|
|
|
"dd": Allowed,
|
|
|
|
"diff": Allowed,
|
|
|
|
"dirname": Allowed,
|
2018-08-15 08:02:11 +02:00
|
|
|
"du": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"echo": Allowed,
|
|
|
|
"egrep": Allowed,
|
|
|
|
"env": Allowed,
|
|
|
|
"expr": Allowed,
|
|
|
|
"find": Allowed,
|
2018-08-28 01:14:23 +02:00
|
|
|
"fuser": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"getconf": Allowed,
|
|
|
|
"getopt": Allowed,
|
|
|
|
"git": Allowed,
|
|
|
|
"grep": Allowed,
|
|
|
|
"gzip": Allowed,
|
|
|
|
"head": Allowed,
|
|
|
|
"hexdump": Allowed,
|
|
|
|
"hostname": Allowed,
|
2018-06-01 19:58:58 +02:00
|
|
|
"id": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"jar": Allowed,
|
|
|
|
"java": Allowed,
|
|
|
|
"javap": Allowed,
|
|
|
|
"ln": Allowed,
|
|
|
|
"ls": Allowed,
|
2018-08-15 19:14:40 +02:00
|
|
|
"lsof": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"m4": Allowed,
|
|
|
|
"make": Allowed,
|
|
|
|
"md5sum": Allowed,
|
|
|
|
"mkdir": Allowed,
|
|
|
|
"mktemp": Allowed,
|
|
|
|
"mv": Allowed,
|
2018-08-31 01:51:42 +02:00
|
|
|
"od": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"openssl": Allowed,
|
2018-08-15 08:02:11 +02:00
|
|
|
"paste": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"patch": Allowed,
|
|
|
|
"perl": Allowed,
|
2018-06-06 20:02:42 +02:00
|
|
|
"pgrep": Allowed,
|
|
|
|
"pkill": Allowed,
|
2018-08-15 19:14:40 +02:00
|
|
|
"ps": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"pstree": Allowed,
|
2018-06-06 20:02:42 +02:00
|
|
|
"pwd": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"python": Allowed,
|
|
|
|
"python2.7": Allowed,
|
|
|
|
"python3": Allowed,
|
|
|
|
"readlink": Allowed,
|
|
|
|
"realpath": Allowed,
|
|
|
|
"rm": Allowed,
|
2018-06-01 19:58:58 +02:00
|
|
|
"rmdir": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"rsync": Allowed,
|
|
|
|
"runalarm": Allowed,
|
|
|
|
"sed": Allowed,
|
|
|
|
"setsid": Allowed,
|
|
|
|
"sh": Allowed,
|
2018-06-01 19:58:58 +02:00
|
|
|
"sha1sum": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"sha256sum": Allowed,
|
|
|
|
"sha512sum": Allowed,
|
2018-06-06 20:02:42 +02:00
|
|
|
"sleep": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"sort": Allowed,
|
|
|
|
"stat": Allowed,
|
|
|
|
"sum": Allowed,
|
|
|
|
"tar": Allowed,
|
|
|
|
"tail": Allowed,
|
2018-08-31 10:12:22 +02:00
|
|
|
"tee": Allowed,
|
2018-08-28 09:18:02 +02:00
|
|
|
"todos": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"touch": Allowed,
|
|
|
|
"tr": Allowed,
|
|
|
|
"true": Allowed,
|
|
|
|
"uname": Allowed,
|
|
|
|
"uniq": Allowed,
|
2018-08-29 19:26:47 +02:00
|
|
|
"unix2dos": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"unzip": Allowed,
|
|
|
|
"wc": Allowed,
|
|
|
|
"which": Allowed,
|
|
|
|
"whoami": Allowed,
|
|
|
|
"xargs": Allowed,
|
|
|
|
"xmllint": Allowed,
|
2018-08-15 08:02:11 +02:00
|
|
|
"xxd": Allowed,
|
2018-05-26 01:30:04 +02:00
|
|
|
"xz": Allowed,
|
|
|
|
"zip": Allowed,
|
|
|
|
"zipinfo": Allowed,
|
|
|
|
|
|
|
|
// Host toolchain is removed. In-tree toolchain should be used instead.
|
|
|
|
// GCC also can't find cc1 with this implementation.
|
|
|
|
"ar": Forbidden,
|
|
|
|
"as": Forbidden,
|
|
|
|
"cc": Forbidden,
|
|
|
|
"clang": Forbidden,
|
|
|
|
"clang++": Forbidden,
|
|
|
|
"gcc": Forbidden,
|
|
|
|
"g++": Forbidden,
|
|
|
|
"ld": Forbidden,
|
|
|
|
"ld.bfd": Forbidden,
|
|
|
|
"ld.gold": Forbidden,
|
|
|
|
"pkg-config": Forbidden,
|
|
|
|
|
|
|
|
// We've got prebuilts of these
|
|
|
|
//"dtc": Forbidden,
|
|
|
|
//"lz4": Forbidden,
|
|
|
|
//"lz4c": Forbidden,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
Configuration["md5"] = Allowed
|
|
|
|
Configuration["sw_vers"] = Allowed
|
|
|
|
Configuration["xcrun"] = Allowed
|
|
|
|
}
|
|
|
|
}
|