From a85e47072ff808846242da49295b4b73af23b840 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 21 Jun 2023 21:15:05 +0000 Subject: deploy: 35dc3c48a50594148554010ac626480161ad357a --- 404.html | 2 +- arch/arm64.html | 2 +- arch/armv7.html | 2 +- arch/index.html | 2 +- arch/riscv.html | 2 +- arch/x86_64.html | 2 +- binary/index.html | 2 +- binary/nm.html | 2 +- binary/objdump.html | 2 +- binary/od.html | 2 +- binary/readelf.html | 2 +- binary/xxd.html | 2 +- development/c++.html | 2 +- development/c++filt.html | 2 +- development/gcc.html | 2 +- development/gcov.html | 2 +- development/glibc.html | 2 +- development/index.html | 2 +- development/ld.so.html | 15 +- development/make.html | 2 +- development/python.html | 2 +- development/symbolver.html | 2 +- index.html | 2 +- intro.html | 2 +- linux/acl.html | 265 ++++++++++++++++++++++++++++ linux/coredump.html | 2 +- linux/cryptsetup.html | 2 +- linux/index.html | 4 +- linux/input.html | 6 +- linux/ptrace_scope.html | 2 +- linux/swap.html | 2 +- linux/systemd.html | 2 +- linux/zfs.html | 416 ++++++++++++++++++++++++++++++++++++++++++++ monitor/index.html | 2 +- monitor/lsof.html | 2 +- monitor/pgrep.html | 2 +- monitor/pidstat.html | 2 +- monitor/pmap.html | 2 +- monitor/pstack.html | 2 +- monitor/ss.html | 2 +- network/firewall-cmd.html | 2 +- network/index.html | 6 +- network/nftables.html | 2 +- network/tcpdump.html | 2 +- print.html | 306 +++++++++++++++++++++++++++++++- searchindex.js | 2 +- searchindex.json | 2 +- tools/awk.html | 2 +- tools/bash.html | 2 +- tools/dot.html | 2 +- tools/emacs.html | 2 +- tools/fish.html | 2 +- tools/gdb.html | 2 +- tools/gdbserver.html | 2 +- tools/git.html | 2 +- tools/gpg.html | 2 +- tools/index.html | 2 +- tools/pacman.html | 2 +- tools/qemu.html | 2 +- tools/radare2.html | 2 +- tools/tmux.html | 2 +- tools/zsh.html | 2 +- trace_profile/index.html | 2 +- trace_profile/ltrace.html | 2 +- trace_profile/oprofile.html | 2 +- trace_profile/perf.html | 2 +- trace_profile/strace.html | 2 +- trace_profile/time.html | 2 +- web/chartjs.html | 2 +- web/html.html | 2 +- web/index.html | 2 +- 71 files changed, 1068 insertions(+), 78 deletions(-) create mode 100644 linux/acl.html create mode 100644 linux/zfs.html diff --git a/404.html b/404.html index 2fd67ff..af6d97c 100644 --- a/404.html +++ b/404.html @@ -84,7 +84,7 @@ diff --git a/arch/arm64.html b/arch/arm64.html index 3f0efd3..26e288f 100644 --- a/arch/arm64.html +++ b/arch/arm64.html @@ -83,7 +83,7 @@ diff --git a/arch/armv7.html b/arch/armv7.html index 98faefd..eb376c8 100644 --- a/arch/armv7.html +++ b/arch/armv7.html @@ -83,7 +83,7 @@ diff --git a/arch/index.html b/arch/index.html index 1d4c53d..b48d6ff 100644 --- a/arch/index.html +++ b/arch/index.html @@ -83,7 +83,7 @@ diff --git a/arch/riscv.html b/arch/riscv.html index c52b8b1..b2ccc47 100644 --- a/arch/riscv.html +++ b/arch/riscv.html @@ -83,7 +83,7 @@ diff --git a/arch/x86_64.html b/arch/x86_64.html index f536d21..262675b 100644 --- a/arch/x86_64.html +++ b/arch/x86_64.html @@ -83,7 +83,7 @@ diff --git a/binary/index.html b/binary/index.html index 576a842..cfbfec9 100644 --- a/binary/index.html +++ b/binary/index.html @@ -83,7 +83,7 @@ diff --git a/binary/nm.html b/binary/nm.html index 7f6c229..e2f26c0 100644 --- a/binary/nm.html +++ b/binary/nm.html @@ -83,7 +83,7 @@ diff --git a/binary/objdump.html b/binary/objdump.html index 9b3288f..2ffc881 100644 --- a/binary/objdump.html +++ b/binary/objdump.html @@ -83,7 +83,7 @@ diff --git a/binary/od.html b/binary/od.html index f0e722a..842acf3 100644 --- a/binary/od.html +++ b/binary/od.html @@ -83,7 +83,7 @@ diff --git a/binary/readelf.html b/binary/readelf.html index 35c64d4..87ffb33 100644 --- a/binary/readelf.html +++ b/binary/readelf.html @@ -83,7 +83,7 @@ diff --git a/binary/xxd.html b/binary/xxd.html index 732e6e7..5848087 100644 --- a/binary/xxd.html +++ b/binary/xxd.html @@ -83,7 +83,7 @@ diff --git a/development/c++.html b/development/c++.html index 4ed1fad..05a0577 100644 --- a/development/c++.html +++ b/development/c++.html @@ -83,7 +83,7 @@ diff --git a/development/c++filt.html b/development/c++filt.html index 9b9a37a..d89d7de 100644 --- a/development/c++filt.html +++ b/development/c++filt.html @@ -83,7 +83,7 @@ diff --git a/development/gcc.html b/development/gcc.html index bb2e845..f8324f0 100644 --- a/development/gcc.html +++ b/development/gcc.html @@ -83,7 +83,7 @@ diff --git a/development/gcov.html b/development/gcov.html index 582e703..d2062aa 100644 --- a/development/gcov.html +++ b/development/gcov.html @@ -83,7 +83,7 @@ diff --git a/development/glibc.html b/development/glibc.html index ab9c252..629439f 100644 --- a/development/glibc.html +++ b/development/glibc.html @@ -83,7 +83,7 @@ diff --git a/development/index.html b/development/index.html index f6e4874..b27db9f 100644 --- a/development/index.html +++ b/development/index.html @@ -83,7 +83,7 @@ diff --git a/development/ld.so.html b/development/ld.so.html index 5a8326e..9e8ce60 100644 --- a/development/ld.so.html +++ b/development/ld.so.html @@ -83,7 +83,7 @@ @@ -157,6 +157,19 @@ =symbols show search path for symbol lookup =bindings show against which definition a symbol is bound +

LD_LIBRARY_PATH and dlopen(3)

+

When dynamically loading a shared library during program runtime with +dlopen(3), only the LD_LIBRARY_PATH as it was during program startup is +evaluated. +Therefore the following is a code smell:

+
// at startup LD_LIBRARY_PATH=/moose
+
+// Assume /foo/libbar.so
+setenv("LD_LIBRARY_PATH", "/foo", true /* overwrite */);
+
+// Will look in /moose and NOT in /foo.
+dlopen("libbar.so", RTLD_LAZY);
+

Libraries specified in LD_PRELOAD are loaded from left-to-right but initialized from right-to-left.

diff --git a/development/make.html b/development/make.html index fe08ad1..23065c7 100644 --- a/development/make.html +++ b/development/make.html @@ -83,7 +83,7 @@ diff --git a/development/python.html b/development/python.html index c847ad5..7648137 100644 --- a/development/python.html +++ b/development/python.html @@ -83,7 +83,7 @@ diff --git a/development/symbolver.html b/development/symbolver.html index d43b7d0..eab2ea0 100644 --- a/development/symbolver.html +++ b/development/symbolver.html @@ -83,7 +83,7 @@ diff --git a/index.html b/index.html index 66d1f0e..f97d4df 100644 --- a/index.html +++ b/index.html @@ -83,7 +83,7 @@ diff --git a/intro.html b/intro.html index 66d1f0e..f97d4df 100644 --- a/intro.html +++ b/intro.html @@ -83,7 +83,7 @@ diff --git a/linux/acl.html b/linux/acl.html new file mode 100644 index 0000000..4166152 --- /dev/null +++ b/linux/acl.html @@ -0,0 +1,265 @@ + + + + + + acl - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+

access control list (acl)

+
+

This describes POSIX acl.

+
+

The access control list provides a flexibel permission mechanism next to the +UNIX file permissions. This allows to specify fine grained permissions for +users/groups on filesystems.

+

Filesystems which support acl typically have an acl option, which must be +specified while mounting when it is not a default option. +Filesystems must be mounted with the acl option if not enabled as default +option.

+

Files or folder that have an acl defined, can be identified by the + sign +next to the UNIX permissions.

+

The following shows on example for a zfs filesystem.

+
# mount | grep tank
+tank on /tank type zfs (rw,xattr,noacl)
+tank/foo on /tank/foo type zfs (rw,xattr,posixacl)
+
+# ls -h /tank
+drwxrwxr-x+ 2 root root 4 11. Jun 14:26 foo/
+
+

Show acl entries

+
# List current acl entries.
+getfacl /tank/foo
+
+

Modify acl entries

+
# Add acl entry for user "user123".
+setfacl -m "u:user123:rwx" /tank/foo
+
+# Remove entry for user "user123".
+setfacl -x "u:user123" /tank/foo
+
+# Add acl entry for group "group456".
+setfacl -m "g:group456:rx" /tank/foo
+
+# Add acl entry for others.
+setfacl -m "o:rx" /tank/foo
+
+# Remove extended acl entries.
+setfacl -b /tank/foo
+
+

Masking of acl entries

+

The mask defines the maximum access rights that can be given to users and +groups.

+
# Update the mask.
+setfacl -m "m:rx" /tank/foo
+
+# List acl entries.
+getfacl /tank/foo
+# file: tank/foo
+# owner: root
+# group: root
+user::rwx
+user:user123:rwx     # effective:r-x
+group::r-x
+mask::r-x
+other::rwx
+
+

References

+ + +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + diff --git a/linux/coredump.html b/linux/coredump.html index 94beab3..fbc82dd 100644 --- a/linux/coredump.html +++ b/linux/coredump.html @@ -83,7 +83,7 @@ diff --git a/linux/cryptsetup.html b/linux/cryptsetup.html index 77f71c1..a301ed1 100644 --- a/linux/cryptsetup.html +++ b/linux/cryptsetup.html @@ -83,7 +83,7 @@ diff --git a/linux/index.html b/linux/index.html index c7c04bc..3d8d8db 100644 --- a/linux/index.html +++ b/linux/index.html @@ -83,7 +83,7 @@ @@ -155,6 +155,8 @@
  • cryptsetup
  • swap
  • input
  • +
  • acl
  • +
  • zfs
  • diff --git a/linux/input.html b/linux/input.html index 5f56879..836e185 100644 --- a/linux/input.html +++ b/linux/input.html @@ -83,7 +83,7 @@ @@ -275,7 +275,7 @@ int main(int argc, char* argv[]) { - @@ -289,7 +289,7 @@ int main(int argc, char* argv[]) { - diff --git a/linux/ptrace_scope.html b/linux/ptrace_scope.html index f593a69..234dda6 100644 --- a/linux/ptrace_scope.html +++ b/linux/ptrace_scope.html @@ -83,7 +83,7 @@ diff --git a/linux/swap.html b/linux/swap.html index b5f8b3e..42952c3 100644 --- a/linux/swap.html +++ b/linux/swap.html @@ -83,7 +83,7 @@ diff --git a/linux/systemd.html b/linux/systemd.html index 0fec778..80540d8 100644 --- a/linux/systemd.html +++ b/linux/systemd.html @@ -83,7 +83,7 @@ diff --git a/linux/zfs.html b/linux/zfs.html new file mode 100644 index 0000000..78e2847 --- /dev/null +++ b/linux/zfs.html @@ -0,0 +1,416 @@ + + + + + + zfs - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + +
    + +
    + + + + + + + + +
    +
    +

    zfs

    +

    Pools are managed with the zpool(8) command and have the +following hierarchy:

    +
      +
    • pool: consists of one or more virtual devices (vdev)
    • +
    • vdev: consists of one or more physical devices (dev) and come in +different kinds such as disk, mirror, raidzX, ... +
        +
      • disk: single physical disk (vdev == dev)
      • +
      • mirror: data is identically replicated on all devs (requires at least 2 +physical devices).
      • +
      +
    • +
    +

    Data stored in a pool is distributed and stored across all vdevs by zfs. +Therefore a total failure of a single vdev can lead to total loss of a pool.

    +

    A dataset is a logical volume which can be created on top of a pool. Each +dataset can be configured with its own set of properties like +encryption, quota, .... +Datasets are managed with the zfs(8) command.

    +

    zfs pool management

    +

    Pools are by default mounted at /<POOL>.

    +

    Create, modify and destroy zfs pools

    +
    # Create a pool MOOSE with a two mirror vdevs.
    +zpool create moose mirror <dev1> <dev2> mirror <dev3> <dev4>..
    +
    +# Add new raidz1 vdev to a pool.
    +zpool add moose raidz1 <devA> <devB> <devC>..
    +
    +# Remove a vdev from a pool.
    +zpool remove moose <vdevX>
    +
    +# Destroy a pool.
    +zpool destroy moose
    +
    +
    +

    For stable device names in small home setups it is recommended to use names +from /dev/disk/by-id.

    +
    +

    Inspect zfs pools

    +
    # Show status of all pools or a single one.
    +zpool status [<pool>]
    +
    +# Show information / statistics about pools or single one.
    +zpool list [<pool>]
    +
    +# Show statistics for all devices.
    +zpool list -v
    +
    +# Show command history for pools.
    +zpool history
    +
    +

    Modify vdevs

    +
    # vdev MIRROR-0 with two devs.
    +zpool status
    +    NAME            STATE     READ WRITE CKSUM
    +    moose           ONLINE       0     0     0
    +      mirror-0      ONLINE       0     0     0
    +        virtio-200  ONLINE       0     0     0
    +        virtio-300  ONLINE       0     0     0
    +
    +# Attach new device to an existing vdev.
    +zpool attach moose virtio-200 virtio-400
    +
    +# vdev MIRROR-0 with three devs.
    +zpool status
    +    NAME            STATE     READ WRITE CKSUM
    +    moose           ONLINE       0     0     0
    +      mirror-0      ONLINE       0     0     0
    +        virtio-200  ONLINE       0     0     0
    +        virtio-300  ONLINE       0     0     0
    +        virtio-400  ONLINE       0     0     0
    +
    +# Detach device from vdev.
    +zpool detach moose virtio-200
    +
    +

    Replace faulty disk

    +
    # MIRROR-0 is degraded as one disk failed, but still intact.
    +zpool status
    +    NAME            STATE     READ WRITE CKSUM
    +    moose           DEGRADED     0     0     0
    +      mirror-0      DEGRADED     0     0     0
    +        virtio-200  UNAVAIL      0     0     0  invalid label
    +        virtio-300  ONLINE       0     0     0
    +
    +# Replace faulty disk, in mirror.
    +# No data is lost since mirror still has one good disk.
    +zpool replace moose virtio-200 virtio-400
    +
    +# MIRROR-0 back in ONLINE (good) state.
    +zpool status
    +    NAME            STATE     READ WRITE CKSUM
    +    moose           ONLINE       0     0     0
    +      mirror-0      ONLINE       0     0     0
    +        virtio-400  ONLINE       0     0     0
    +        virtio-300  ONLINE       0     0     0
    +
    +

    Import or export zfs pools

    +

    When moving pools between hosts, the pool must be exported on the currently +active host and imported on the new host.

    +
    # Export a pool called MOOSE.
    +zpool export moose
    +
    +# List pools that can be imported using BY-ID deivce names (for example).
    +zpool import -d /dev/disk/by-id
    +
    +# Import pool MOOSE using BY-ID device names (for example).
    +zpool import -d /dev/disk/by-id moose
    +
    +
    +

    Device names used by an existing pool can be changed by exporting and +importing a pool again.

    +
    +

    zfs dataset management

    +

    Datasets are by default mounted at /<POOL>/<DATASET>.

    +

    Create and destroy zfs datasets

    +
    # Create dataset FOO on pool MOOSE.
    +zfs create moose/foo
    +
    +# Destroy dataset.
    +zfs destroy moose/foo
    +
    +

    List all zfs datasets

    +
    # List all zfs datasets.
    +zfs list
    +
    +

    Mount zfs datasets

    +
    # List currently mounted datasets.
    +zfs mount
    +
    +# Mount dataset.
    +zfs mount moose/foo
    +
    +# Unmount dataset.
    +zfs unmount moose/foo
    +
    +

    Encrypted datasets

    +

    Encryption is a readonly property, can only be set when creating a dataset.

    +
    # Create encrypted dataset ENC on pool MOOSE.
    +zfs create -o encryption=on -o keyformat=passphrase moose/foo
    +
    +# Mount encrypte dataset (if key is not loaded).
    +zfs mount -l moose/foo
    +
    +# Unmount dataset and unload encryption key (unload is optional).
    +zfs umount -u moose/foo
    +
    +

    Manage zfs encryption keys

    +
    # Preload encryption key for dataset.
    +zfs load-key moose/foo
    +
    +# Preload encryption key for all datasets.
    +zfs load-key -a
    +
    +# Change encryption key for dataset.
    +zfs change-key moose/foo
    +
    +# Unload encryption key for dataset.
    +zfs unload-key moose/foo
    +
    +

    Manage dataset properties

    +
    # Get all properties for dataset.
    +zfs get quota moose/foo
    +
    +# Get single property for dataset.
    +zfs get all moose/foo
    +
    +# Get single property for all datasets.
    +zfs get quota
    +
    +# Set property on dataset.
    +zfs set quota=10G moose/foo
    +
    +

    Snapshots

    +
    # Create snapshot called V2 for dataset moose/foo.
    +zfs snapshot moose/foo@v2
    +
    +# List all snapshots.
    +zfs list -t snapshot
    +
    +# Make .zfs direcotry visible in the root of the dataset.
    +zfs set snapdir=visible moose/foo
    +
    +# Browse available snapshots in visible .zfs direcotry (readonly).
    +ls /moose/foo/.zfs/snapshot
    +v1/  v2/
    +
    +# Create a new dataset based on the V1 snapshot
    +zfs clone moose/foo@v1 moose/foov1
    +
    +# Destroy snapshot.
    +zfs destroy moose/foo@v1
    +
    +

    Access control list

    +

    Focus on posix acl.

    +
    # Set the ACL type for the FOO dataset to POSIXACL.
    +zfs set acltype=posixacl moose/foo
    +
    +# Get the ACL type of a given dataset.
    +zfs get acltype moose/foo
    +
    +
    +

    For performance reasons it is recommended to also set zfs set xattr=sa moose/foo [ref].

    +
    +

    Example: zfs pool import during startup (systemd)

    +

    The default zpool cache file is /etc/zfs/zpool.cache. When pools are imported +the cache is updated.

    +

    Enable the following targets / services to automatically import pools from the +cache.

    +
    systemctl list-dependencies
    +  ...
    +    └─zfs.target
    +      └─zfs-import.target
    +        └─zfs-import-cache.service
    +
    + +
    + + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    + + diff --git a/monitor/index.html b/monitor/index.html index 2820eec..a62a387 100644 --- a/monitor/index.html +++ b/monitor/index.html @@ -83,7 +83,7 @@ diff --git a/monitor/lsof.html b/monitor/lsof.html index 7057e21..c2993a3 100644 --- a/monitor/lsof.html +++ b/monitor/lsof.html @@ -83,7 +83,7 @@ diff --git a/monitor/pgrep.html b/monitor/pgrep.html index 9892f6a..2991d4c 100644 --- a/monitor/pgrep.html +++ b/monitor/pgrep.html @@ -83,7 +83,7 @@ diff --git a/monitor/pidstat.html b/monitor/pidstat.html index f1b6697..c32f50e 100644 --- a/monitor/pidstat.html +++ b/monitor/pidstat.html @@ -83,7 +83,7 @@ diff --git a/monitor/pmap.html b/monitor/pmap.html index 5eb9d76..8e90dd9 100644 --- a/monitor/pmap.html +++ b/monitor/pmap.html @@ -83,7 +83,7 @@ diff --git a/monitor/pstack.html b/monitor/pstack.html index ee3b82b..b6c8a6a 100644 --- a/monitor/pstack.html +++ b/monitor/pstack.html @@ -83,7 +83,7 @@ diff --git a/monitor/ss.html b/monitor/ss.html index 0638be5..e614bd3 100644 --- a/monitor/ss.html +++ b/monitor/ss.html @@ -83,7 +83,7 @@ diff --git a/network/firewall-cmd.html b/network/firewall-cmd.html index a56b855..0f9482f 100644 --- a/network/firewall-cmd.html +++ b/network/firewall-cmd.html @@ -83,7 +83,7 @@ diff --git a/network/index.html b/network/index.html index 48d79f0..c3ad3d7 100644 --- a/network/index.html +++ b/network/index.html @@ -83,7 +83,7 @@ @@ -158,7 +158,7 @@