# [TopGit PATCH] tg.sh: Check for read permissions of help files

3 messages from 2008-08-06 to 2008-08-09. Participants: Bert Wesarg, Petr Baudis.
Thread: https://gitlist.dev/t/14859

## Bert Wesarg, 2008-08-06 08:02

Subject: [TopGit PATCH] tg.sh: Check for read permissions of help files
Message-ID: <1218009771-30358-1-git-send-email-bert.wesarg@googlemail.com>
URL: https://gitlist.dev/e/1218009771-30358-1-git-send-email-bert.wesarg%40googlemail.com

```
We currently check only for '-f' but we need to have read permissions as well.

And help files don't need the execution bit set.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 Makefile |    2 +-
 tg.sh    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 238d07d..f9dbe6e 100644
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ install:: all
 	install -d -m 755 "$(hooksdir)"
 	install $(hooks_out) "$(hooksdir)"
 	install -d -m 755 "$(sharedir)"
-	install $(help_out) "$(sharedir)"
+	install -m 644 $(help_out) "$(sharedir)"
 
 clean::
 	rm -f tg $(commands_out) $(hooks_out) $(help_out)
diff --git a/tg.sh b/tg.sh
index 03a392b..edac006 100644
--- a/tg.sh
+++ b/tg.sh
@@ -154,7 +154,7 @@ do_help()
 	if [ -z "$1" ] ; then
 		echo "TopGit v0.1 - A different patch queue manager"
 		echo "Usage: tg (create|delete|info|patch|summary|update|help) ..."
-	elif [ -f "@sharedir@/tg-$1.txt" ] ; then
+	elif [ -f "@sharedir@/tg-$1.txt" -a -r "@sharedir@/tg-$1.txt" ] ; then
 		cat "@sharedir@/tg-$1.txt"
 	else
 		echo "`basename $0`: no help for $1" 1>&2
-- 
tg: (e311d15..) t/check-read-permissions-of-help-files (depends on: master)

```

## Bert Wesarg, 2008-08-09 07:35

Subject: Re: [TopGit PATCH] tg.sh: Check for read permissions of help files
Message-ID: <36ca99e90808090035r6331a118k5a26486de1acf002@mail.gmail.com>
URL: https://gitlist.dev/e/36ca99e90808090035r6331a118k5a26486de1acf002%40mail.gmail.com
In-Reply-To: <1218009771-30358-1-git-send-email-bert.wesarg@googlemail.com>

```
Petr,

On Wed, Aug 6, 2008 at 10:02, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> -       elif [ -f "@sharedir@/tg-$1.txt" ] ; then
> +       elif [ -f "@sharedir@/tg-$1.txt" -a -r "@sharedir@/tg-$1.txt" ] ; then
I saw your simplified commit for this, but you should know, that '-r'
tests only for read permissions, not for a regular file, so this test
succeed also for a pipe/socket for which do you have read permissions.

Bert

>                cat "@sharedir@/tg-$1.txt"
>        else
>                echo "`basename $0`: no help for $1" 1>&2
> --
> tg: (e311d15..) t/check-read-permissions-of-help-files (depends on: master)
>

```

## Petr Baudis, 2008-08-09 08:24

Subject: Re: [TopGit PATCH] tg.sh: Check for read permissions of help files
Message-ID: <20080809082436.GU10151@machine.or.cz>
URL: https://gitlist.dev/e/20080809082436.GU10151%40machine.or.cz
In-Reply-To: <36ca99e90808090035r6331a118k5a26486de1acf002@mail.gmail.com>

```
On Sat, Aug 09, 2008 at 09:35:19AM +0200, Bert Wesarg wrote:
> Petr,
> 
> On Wed, Aug 6, 2008 at 10:02, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> > -       elif [ -f "@sharedir@/tg-$1.txt" ] ; then
> > +       elif [ -f "@sharedir@/tg-$1.txt" -a -r "@sharedir@/tg-$1.txt" ] ; then
> I saw your simplified commit for this, but you should know, that '-r'
> tests only for read permissions, not for a regular file, so this test
> succeed also for a pipe/socket for which do you have read permissions.

Is that a problem? :-)

				Petr "Pasky" Baudis

```
