Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Oct 2009 10:34:28 +1000
From:      "Andrew D. Boyd" <decado@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: crashtar
Message-ID:  <4AD7BF94.908@gmail.com>
In-Reply-To: <86d44vqs9l.fsf@kopusha.onet>
References:  <permail-200910101034051e86ffa8000003cb-a_best01@message-id.uni-muenster.de> <86d44vqs9l.fsf@kopusha.onet>

next in thread | previous in thread | raw e-mail | index | archive | help
Mikolaj Golub wrote:
> On Sat, 10 Oct 2009 12:34:05 +0200 (CEST) Alexander Best wrote:
> 
>  AB> thanks. this is a cool script and very useful indeed. only thing you might
>  AB> want to do is check for root privileges at the beginning to avoid nasty error
>  AB> messages like.
> 
>  AB> awk: can't open file /var/crash/info.0
>  AB>  source line number 12
> 
> In some cases you might not need root privileges. E.g. on some servers I don't
> have root but SA gives me read access to crashdumps. In this case if the
> script had a check for root privileges I would not be able to use it.
> 
> Actually as for me the message looks informative enough, it says that we have
> some problems with accessing crash dump files, so permissions should be
> checked.
> 

Instead of checking for root you could check if the file is readable:

if [ -r FILE ]

and then print an error message.

Although the awk error message is sufficient some people might find this
helpful.

Regards,
Andrew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AD7BF94.908>