main/postmarketos-usb-moded: use a generator to configure UID/GID for umtprd
MTP transfers write files to the home folder of the user. If no GID and UID are specified, uMTP-responder will use the GID/UID under which it is running at the time of the file transfer. This causes users to not be able to access the files on the device after transfering. This patch adds a systemd generator that: 1) reads /etc/default_user, and appends config to /etc/umtprd/umtprd.conf to set the MTP default user/group. If this file doesn't exist, 10000:10000 is the fallback uid:gid. 2) installs this config to /run/umtprd/umptrd.conf 3) adds a unit override to /run for umtprd.service that runs the daemon with this modified config The generator is used instead of hardcoding a uid and gid in umtprd.conf so that this can support immutable installs or situations where the default UID/GID is not 10000. Co-authored-by: Dylan Van Assche <dylan@postmarketos.org> Signed-off-by: Clayton Craft <craftyguy@postmarketos.org> Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7658>
This commit is contained in:
parent
974f3165f9
commit
5971d0f226
3 changed files with 43 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ sh_files="
|
|||
./main/postmarketos-initramfs/init_functions.sh
|
||||
./main/postmarketos-mkinitfs-hook-netboot/netboot.sh
|
||||
./main/postmarketos-ui-os-installer/rootfs-usr-bin-pmos_setup.sh
|
||||
./main/postmarketos-usb-moded/rootfs-usr-lib-systemd-system-generators-umtprd-config-generator
|
||||
./main/ttyescape/*.post-install
|
||||
./main/unl0kr/unlock.sh
|
||||
./device/community/soc-qcom/call_audio_idle_suspend_workaround.sh
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Maintainer: Clayton Craft <clayton@craftyguy.net>
|
||||
pkgname=postmarketos-usb-moded
|
||||
pkgver=1
|
||||
pkgver=2
|
||||
pkgrel=0
|
||||
pkgdesc="Meta package for configuring usb-moded on postmarketOS"
|
||||
url="https://postmarketos.org"
|
||||
|
|
@ -31,6 +31,7 @@ _source644="
|
|||
_source755="
|
||||
usr/bin/usb-moded-developer-mode
|
||||
usr/bin/usb-moded-tethering-mode
|
||||
usr/lib/systemd/system-generators/umtprd-config-generator
|
||||
"
|
||||
|
||||
# Avoid filename based checksum conflicts by including the whole path.
|
||||
|
|
@ -99,4 +100,5 @@ af41dc4ceb7255dbb88273916306c6e7e66c879bb67523c9571f9e812c9b36ab00ea666ade49369c
|
|||
79dc304cc5d455135f929a0ba60487f03b1b66d09245d972f685ee5ddabc8414f74159e47bbb13bff862163fa07dd9497a30ab7e32074bff95f2189685d851a2 rootfs-usr-lib-systemd-system-usb-moded.service.d-override.conf
|
||||
9aab1a91a817e2337320ee0fa1bf6133e65e9269631560c1860c3b777adb336d036cebbc2510d1df35a82bf4396d553ff9e2edd0004027c7a3130168f7f50d90 rootfs-usr-bin-usb-moded-developer-mode
|
||||
5cc40b1a0c86904d824f8f03e3f44900aaf407c5c462902f4f58cd58c603be1c5919651b91320983e21da42f5891e29df504bf4f1bddef64fedc68c2accdccbc rootfs-usr-bin-usb-moded-tethering-mode
|
||||
ca4b82b0cccbbb498b8898c4e360142136c46687e97bce85553dc1793bf8ae2e0f509c2a1acdf96b08dc7c6b69f098b56181f9033ad669cabbf5a159ad8efbaa rootfs-usr-lib-systemd-system-generators-umtprd-config-generator
|
||||
"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
# systemd generator for uMTP-Responder configuration
|
||||
# Generates config with user UID/GID in /run
|
||||
|
||||
set -e
|
||||
|
||||
late_dir="$3"
|
||||
|
||||
# fallback UID/GID
|
||||
uid=10000
|
||||
gid=10000
|
||||
|
||||
user_file="/etc/default_user"
|
||||
if [ -f "$user_file" ]; then
|
||||
user=$(cat "$user_file")
|
||||
if [ -n "$user" ]; then
|
||||
# Get UID/GID, fall back to defaults on failure
|
||||
uid=$(id -u "$user" 2>/dev/null || echo 10000)
|
||||
gid=$(id -g "$user" 2>/dev/null || echo 10000)
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p /run/umtprd
|
||||
|
||||
cat /etc/umtprd/umtprd.conf > /run/umtprd/umtprd.conf
|
||||
cat << EOF >> /run/umtprd/umtprd.conf
|
||||
|
||||
# GID/UID for file operations (generated)
|
||||
default_uid $uid
|
||||
default_gid $gid
|
||||
EOF
|
||||
|
||||
# unit override to use generated config
|
||||
mkdir -p "${late_dir}/umtprd.service.d"
|
||||
cat << EOF > "${late_dir}/umtprd.service.d/10-config-path.conf"
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/umtprd -conf /run/umtprd/umtprd.conf
|
||||
EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue