blog
Table des matières
- 2026:
- 2025:
4 billet(s) pour juillet 2026
| Procédure simple augmentation de la SWAP | 2026/07/17 15:49 | Jean-Baptiste |
| Exemple git clone avec Ansible | 2026/07/16 14:47 | Jean-Baptiste |
| Windows exe - Comparaison de fichiers binaires | 2026/07/16 10:25 | Jean-Baptiste |
| Pb git | 2026/07/01 17:36 | Jean-Baptiste |
Notes podman machine
podman machine init vm1 podman machine start vm1 podman machine status vm1
podman machine stop vm1
$ podman machine rm vm1 The following files will be deleted: /home/jibe/.config/containers/podman/machine/qemu/vm1.json /run/user/1000/podman/vm1.sock /run/user/1000/podman/vm1-gvproxy.sock /run/user/1000/podman/vm1-api.sock /run/user/1000/podman/vm1.log /run/user/1000/podman/vm1_vm.pid /run/user/1000/podman/qmp_vm1.sock Are you sure you want to continue? [y/N] y
Pb
Err - could not find "gvproxy"
$ podman machine start vm1 Starting machine "vm1" Error: could not find "gvproxy" in one of [/usr/local/libexec/podman /usr/local/lib/podman /usr/libexec/podman /usr/lib/podman]. To resolve this error, set the helper_binaries_dir key in the `[engine]` section of containers.conf to the directory containing your helper binaries.
Solution
sudo apt-get install gvproxy sudo ln -s $(which gvproxy) /usr/libexec/podman/
Err - "virtiofsd": executable file not found in $PATH
$ podman machine start vm1 Starting machine "vm1" ERRO[0000] process 28237 has not ended Error: failed to find virtiofsd: exec: "virtiofsd": executable file not found in $PATH
Solution
sudo apt-get install virtiofsd export PATH=$PATH:/usr/libexec/
$ podman machine start vm1
Starting machine "vm1"
This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:
podman machine set --rootful vm1
Mounting volume... /home/jibe:/home/jibe
API forwarding listening on: /run/user/1000/podman/vm1-api.sock
You can connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:
export DOCKER_HOST='unix:///run/user/1000/podman/vm1-api.sock'
Machine "vm1" started successfully
chroot escape
mkdir hideout chroot hideout # first redirect for i in {1..800}; do cd .. # climb back toward real / done chroot . # second redirect resets limits cat /srv/top-secret.txt
Solution : utiliser pivot_root
# 1) Start a fresh namespace unshare --mount --pid --fork bash # 2) Prepare a new root mkdir -p /mnt/newroot/oldroot mount --bind / /mnt/newroot/oldroot # temporary parking spot # 3) Swap roots pivot_root /mnt/newroot /mnt/newroot/oldroot # 4) Detach the former root umount -l /oldroot
Pb podman
Voir aussi :
- /proc/sys/user/max_user_namespaces
Err
Podman userland avec LDAP
$ podman ps ERRO[0000] cannot find UID/GID for user user1@acme.local: no subuid ranges found for user "user1@acme.local" in /etc/subuid - check rootless mode in man pages. WARN[0000] Using rootless single mapping into the namespace. This might break some images. Check /etc/subuid and /etc/subgid for adding sub*ids if not using a network user CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Solution
#echo "$(id -un):$(id -u):65536" | sudo tee -a /etc/subuid #echo "$(id -gn):$(id -g):65536" | sudo tee -a /etc/subgid sudo usermod --add-subuids "$(id -u)-$(( $(id -u) + 65535))" --add-subgids "$(id -g)-$(( $(id -g) + 65535))" "$(id -un)"
Go lang - process
Une lib qui marche autant pour windows et GNU/Linux
package main import ( "fmt" "github.com/shirou/gopsutil/v4/process" ) func main() { proceses_list, _ := process.Processes() for _, p := range proceses_list { processName, _ := p.Name() fmt.Printf("PID:%v ; %v\n", p.Pid, processName) } }
$ wine main.exe PID:32 ; main.exe PID:56 ; services.exe PID:68 ; winedevice.exe PID:104 ; plugplay.exe PID:112 ; explorer.exe PID:136 ; svchost.exe PID:164 ; winedevice.exe PID:252 ; rpcss.exe PID:288 ; conhost.exe
Term / Kill
proceses_list, _ := process.Processes() for _, p := range proceses_list { processName, _ := p.Name() if processName == "sleep" { p.Kill() } if processName == "cmd.exe" { p.Kill() } }
Go lang - les fichiers
Exemple lecture fichier texte
package main import ( "bufio" "fmt" "os" ) func main() { file, err := os.Open("input.txt") if err != nil { panic(err) } defer func() { if err := file.Close(); err != nil { panic(err) } }() scanner := bufio.NewScanner(file) // Iterate over each line for scanner.Scan() { line := scanner.Text() fmt.Println(line) } }
Exemple d'écriture texte
func write_file(filename string, data string) { file, err := os.Create(filename) if err != nil { panic(err) } defer func() { if err := file.Close(); err != nil { panic(err) } }() _, err = file.WriteString(data) if err != nil { panic(err) } }
Exemple de copie de fichier
Voir : https://opensource.com/article/18/6/copying-files-go
func copyFile(src, dest string) { input, err := ioutil.ReadFile(src) if err != nil { panic(err) } err = ioutil.WriteFile(dest, input, 0644) if err != nil { fmt.Println("Error creating", dest) panic(err) } }
Fichier droits POSIX octal mode
Voir aussi :
file, err := os.Lstat("/tmp/plop") if err != nil { panic(err) } mode := file.Mode() fmt.Printf("%s\n", mode) fmt.Printf("%o\n", mode)
Exemple lecture fichier CSV
package main import ( "encoding/csv" "fmt" "log" "os" "regexp" ) func IsMatchingRegex(s string, regex string) bool { return regexp.MustCompile(regex).MatchString(s) } func main() { file, err := os.Open("data.csv") if err != nil { log.Fatal(err) } defer file.Close() // Read all records from the CSV file reader := csv.NewReader(file) reader.Comma = ';' records, err := reader.ReadAll() if err != nil { log.Fatal(err) } for _, record := range records[1:] { if IsMatchingRegex(record[0], "^#") { continue } fmt.Println(record[0]) fmt.Println(record[1]) } }
Exemple de calcul de hash d'un fichier
package main import ( "crypto/sha256" "encoding/hex" "fmt" "io" "os" ) func hashFile(filePath string) (string, error) { file, err := os.Open(filePath) if err != nil { return "", fmt.Errorf("failed to open file: %w", err) } defer file.Close() hasher := sha256.New() if _, err := io.Copy(hasher, file); err != nil { return "", fmt.Errorf("failed to hash file: %w", err) } return hex.EncodeToString(hasher.Sum(nil)), nil } func main() { hash, err := hashFile("/tmp/plop") if err != nil { panic(err) } fmt.Println(hash) }
blog.txt · Dernière modification : de 127.0.0.1
