From nl6720 at gmail.com Wed Nov 20 14:33:12 2019 From: nl6720 at gmail.com (nl6720) Date: Wed, 20 Nov 2019 16:33:12 +0200 Subject: [PATCH] checkupdates: use $UID in temporary directory path if $USER is not set Message-ID: <20191120143312.26400-1-nl6720@gmail.com> If $USER is not set when running checkupdates, the temporary directory's name will be "checkup-db-". This will cause issues if multiple users run checkupdates. A common situation where $USER is not set is when a command is executed with systemd-run, e.g. from a systemd unit. See https://github.com/systemd/systemd/pull/8227 for details. Fall back to $UID so that the temporary directory is isolated per-user. Signed-off-by: nl6720 --- src/checkupdates.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 52f8899..f2c468c 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -85,7 +85,7 @@ if ! type -P fakeroot >/dev/null; then fi if [[ -z $CHECKUPDATES_DB ]]; then - CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" + CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER:-$UID}/" fi trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT -- 2.24.0 From eschwartz at archlinux.org Wed Nov 20 15:56:01 2019 From: eschwartz at archlinux.org (Eli Schwartz) Date: Wed, 20 Nov 2019 10:56:01 -0500 Subject: [PATCH] checkupdates: use $UID in temporary directory path if $USER is not set In-Reply-To: <20191120143312.26400-1-nl6720@gmail.com> References: <20191120143312.26400-1-nl6720@gmail.com> Message-ID: On 11/20/19 9:33 AM, nl6720 wrote: > If $USER is not set when running checkupdates, the temporary directory's > name will be "checkup-db-". This will cause issues if multiple users run > checkupdates. A common situation where $USER is not set is when a command > is executed with systemd-run, e.g. from a systemd unit. > See https://github.com/systemd/systemd/pull/8227 for details. > > Fall back to $UID so that the temporary directory is isolated per-user. Interesting issue. $UID is guaranteed to exist because bash sets it, $USER is set by the program which implements logging in to the system. > Signed-off-by: nl6720 > --- > src/checkupdates.sh.in | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in > index 52f8899..f2c468c 100644 > --- a/src/checkupdates.sh.in > +++ b/src/checkupdates.sh.in > @@ -85,7 +85,7 @@ if ! type -P fakeroot >/dev/null; then > fi > > if [[ -z $CHECKUPDATES_DB ]]; then > - CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" > + CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER:-$UID}/" This means that if users use checkupdates via a non-login session and then via a login session, we'll end up with two directories. Please either use $UID consistently, or fallback on $(id -un). > fi > > trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT > -- Eli Schwartz Bug Wrangler and Trusted User -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 1601 bytes Desc: OpenPGP digital signature URL: From nl6720 at gmail.com Wed Nov 20 16:57:07 2019 From: nl6720 at gmail.com (nl6720) Date: Wed, 20 Nov 2019 18:57:07 +0200 Subject: [PATCH] checkupdates: use $UID instead of $USER in temporary directory path In-Reply-To: References: Message-ID: <20191120165707.34383-1-nl6720@gmail.com> If $USER is not set when running checkupdates, the temporary directory's name will be "checkup-db-". This will cause issues if multiple users run checkupdates. A common situation where $USER is not set is when a command is executed with systemd-run, e.g. from a systemd unit. See https://github.com/systemd/systemd/pull/8227 for details. Replace the usage of $USER with $UID since it is guaranteed to exist and so that the temporary directory is isolated per-user. Signed-off-by: nl6720 --- src/checkupdates.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 52f8899..ba9b960 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -85,7 +85,7 @@ if ! type -P fakeroot >/dev/null; then fi if [[ -z $CHECKUPDATES_DB ]]; then - CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" + CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${UID}/" fi trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT -- 2.24.0