mb

package
v0.33.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

mimixbox/internal/lib/common.go

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.

mimixbox/internal/lib/crypto.go

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.

mimixbox/internal/lib/file.go

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.

mimixbox/internal/lib/gnu.go

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.

mimixbox/internal/lib/id.go

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.

mimixbox/internal/lib/net.go

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.

mimixbox/internal/lib/option.go

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.

mimixbox/internal/lib/path.go

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.

mimixbox/internal/lib/shadow.go

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.

mimixbox/internal/lib/shell.go

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.

mimixbox/internal/lib/signal.go

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.

mimixbox/internal/lib/string.go

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.

mimixbox/internal/lib/type.go

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.

Index

Constants

View Source
const (
	ExitSuccess int = iota // 0
	ExitFailure
)
View Source
const (
	// Unknown : Don't use this bits
	Unknown os.FileMode = 1 << (9 - iota)
	// Readable : readable bits
	Readable
	// Writable : writable bits
	Writable
	// Executable : executable bits
	Executable
)
View Source
const ShellsFilePath = "/etc/shells"

Variables

View Source
var Signals []signal = []signal{
	{"1", "SIGHUP", "Hangup detected on controlling terminal or death of controlling process"},
	{"2", "SIGINT", "The process was interrupted (When user hits Cnrl+C)"},
	{"3", "SIGQUIT", "Quit program"},
	{"4", "SIGILL", "Illegal instruction"},
	{"5", "SIGTRAP", "Trace trap for debugging"},
	{"6", "SIGABRT", "Emegency stop.  Abort program (formerly SIGIOT)"},
	{"7", "SIGBUS", "Bus error. e.g. alignment errors in memory access"},
	{"8", "SIGFPE", "A floating point exception happened in the program."},
	{"9", "SIGKILL", "Kill program"},
	{"10", "SIGUSR1", "Left for the programmers to do whatever they want"},
	{"11", "SIGSEGV", "Segmentation violation"},
	{"12", "SIGUSR2", "Left for the programmers to do whatever they want"},
	{"13", "SIGPIPE", "Write on a pipe with no reader"},
	{"14", "SIGALRM", "Real-time timer (request a wake up call) expired"},
	{"15", "SIGTERM", "Software termination"},
	{"16", "SIGSTKFLT", "Unused (Stack fault in the FPU)"},
	{"17", "SIGCHLD", "Stop or exit child process"},
	{"18", "SIGCONT", "Restart from stop"},
	{"19", "SIGSTOP", "Stop process"},
	{"20", "SIGTSTP", "Stop process from terminal (When user hits Cnrl+Z)"},
	{"21", "SIGTTIN", "Signal to a backgrounded process when it tries to read input from its terminal"},
	{"22", "SIGTTOU", "Signal to a backgrounded process when it tries to write output to its terminal"},
	{"23", "SIGURG", "Network connection when urgent out of band data is sent to it"},
	{"24", "SIGXCPU", "Exceeded CPU limit"},
	{"25", "SIGXFSZ", "Exceeded file size limit"},
	{"26", "SIGVTALRM", "Virtual alram cloc"},
	{"27", "SIGPROF", "Profiling timer's timeout"},
	{"28", "SIGWINCH", "Window resize signal"},
	{"29", "SIGIO", "Input / output is possible"},
	{"30", "SIGPWR", "Power failure"},
	{"31", "SIGSYS", "Unused (Illegal argument to routine)"},
}

[Reference] https://www-uxsup.csx.cam.ac.uk/courses/moved.Building/signals.pdf

Functions

func AddLineFeed

func AddLineFeed(lines []string) []string

func BaseNameWithoutExt

func BaseNameWithoutExt(path string) string

BaseNameWithoutExt return file name without extension.

func CalcChecksum added in v0.28.0

func CalcChecksum(hash hash.Hash, path string) (string, error)

func ChecksumOutput added in v0.25.1

func ChecksumOutput(hash hash.Hash, r io.Reader, path string) error

func Chop

func Chop(line string) string

func ChopAll

func ChopAll(lines []string) []string

func CompareChecksum added in v0.25.1

func CompareChecksum(h hash.Hash, paths []string) error

e.g. hash is md5.New(), md5.New(), sha512.New(), etc...

func Concatenate

func Concatenate(path []string) ([]string, error)

func Contains

func Contains(list interface{}, elem interface{}) bool

func ConvSignalNameToNum added in v0.31.1

func ConvSignalNameToNum(name string) int32

func Copy

func Copy(src string, dest string) error

Copy file(src) to dest

func Dump added in v0.22.0

func Dump(lines []string, withNumber bool)

func DumpGroups added in v0.22.0

func DumpGroups(groups []user.Group, showName bool)

func ExistCmd

func ExistCmd(cmd string) bool

func Exists

func Exists(path string) bool

Exists reports whether the path exists.

func FromPIPE

func FromPIPE() (string, error)

func Groups added in v0.22.0

func Groups(uname string) ([]user.Group, error)

func HasHelpOpt

func HasHelpOpt(args []string) bool

func HasNoOperand added in v0.29.0

func HasNoOperand(args []string, cmdName string) bool

func HasOperand added in v0.29.0

func HasOperand(args []string, cmdName string) bool

func HasPipeData

func HasPipeData() bool

func HasVersionOpt

func HasVersionOpt(args []string) bool

func Input

func Input() (string, bool)

func Ip4 added in v0.25.1

func Ip4() ([]string, error)

func IsDir

func IsDir(path string) bool

IsDir reports whether the path exists and is a directory.

func IsExecutable

func IsExecutable(path string) bool

IsExecutable reports whether the path exists and is executable.

func IsFile

func IsFile(path string) bool

IsFile reports whether the path exists and is a file.

func IsHiddenFile

func IsHiddenFile(filePath string) bool

IsHiddenFile reports whether the path exists and is included hidden file.

func IsNamedPipe added in v0.29.0

func IsNamedPipe(path string) bool

func IsReadable

func IsReadable(path string) bool

IsReadable reports whether the path exists and is readable.

func IsRootDir

func IsRootDir(path string) bool

func IsRootUser

func IsRootUser() bool

func IsSameFileName

func IsSameFileName(src string, dest string) bool

IsSameFileName return true if src and dest is same name, false if src and dest is not same name

func IsSamePath

func IsSamePath(src string, dest string) bool

IsSamePath return true if src and dest is same path, false if src and dest is not same path or error occur

func IsSignalName added in v0.31.1

func IsSignalName(name string) bool

func IsSignalNumber added in v0.31.1

func IsSignalNumber(num string) bool
func IsSymlink(path string) bool

IsSymlink reports whether the path exists and is a symbolic link.

func IsWritable

func IsWritable(path string) bool

IsWritable reports whether the path exists and is writable.

func IsZero

func IsZero(path string) bool

IsZero reports whether the path exists and is zero size.

func ListDigit added in v0.27.16

func ListDigit(strList []string) string

func ListToFile added in v0.22.0

func ListToFile(filepath string, lines []string) error

func LookupGid added in v0.31.1

func LookupGid(groupId string) (int, error)

func LookupUid added in v0.31.1

func LookupUid(userId string) (int, error)

func Parrot

func Parrot(withNl bool)

func PrintChecksums added in v0.27.19

func PrintChecksums(cmdName string, hash hash.Hash, paths []string) (int, error)

func PrintSignal added in v0.31.1

func PrintSignal(numOrName string)

func PrintSignalList added in v0.31.1

func PrintSignalList()

func PrintStrListWithNumberLine

func PrintStrListWithNumberLine(strList []string, countEmpryLine bool)

func PrintStrWithNumberLine

func PrintStrWithNumberLine(nl int, format string, message string)

func Question

func Question(ask string) bool

func ReadFileToStrList

func ReadFileToStrList(path string) ([]string, error)

func Remove added in v0.27.1

func Remove(strings []string, target string) []string

func RemoveDir added in v0.22.0

func RemoveDir(dir string, interactive bool) error

func RemoveFile added in v0.22.0

func RemoveFile(path string, interactive bool) error

func ReplaceAll added in v0.22.0

func ReplaceAll(lines []string, target string, after string) []string

func ShowVersion added in v0.22.0

func ShowVersion(cmdName string, version string)

func SignalAtoi added in v0.31.1

func SignalAtoi(num string) int32

func SimpleBackupSuffix

func SimpleBackupSuffix() string

func Size added in v0.29.0

func Size(path string) (int64, error)

Return file size(Byte)

func TmpShellsFile added in v0.31.1

func TmpShellsFile() string

func TopDirName

func TopDirName(path string) string

TopDirName return top directory name from path.

func Walk

func Walk(dir string, ignoreErr bool) ([]string, []string, error)

Wark return 1)directory List, 2) file list, 3) error

func WithSingleCoat added in v0.32.1

func WithSingleCoat(str string) string

func WrapString

func WrapString(src string, column int) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL