* blkid: exit code as non-root user, and segfault
@ 2012-12-09 17:52 Bernhard Voelker
2012-12-10 8:42 ` Karel Zak
2012-12-10 11:49 ` Karel Zak
0 siblings, 2 replies; 5+ messages in thread
From: Bernhard Voelker @ 2012-12-09 17:52 UTC (permalink / raw)
To: util-linux@vger.kernel.org
blkid returns 0 without output when running as non-root user
and when the cache /dev/.blkid.tab is not yet there:
./blkid /dev/sdb3 ; echo $?
0
That's the strace:
open("/dev/.blkid.tab", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/dev/sdb3", F_OK) = 0
stat("/dev/sdb3", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 19), ...}) = 0
open("/dev/sdb3", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
stat("/dev/.blkid.tab", 0x7fff2b7cc990) = -1 ENOENT (No such file or directory)
open("/dev/.blkid.tab", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 EACCES (Permission denied)
close(1) = 0
close(2) = 0
exit_group(0) = ?
I'd have expected either an error message along with exit code 1,
or success with some useful output.
After the cache exists, it's fine:
./blkid /dev/sdb3 ; echo $?
/dev/sdb3: LABEL="home" UUID="41ec7daa-46c3-4f19-aea0-e2c1679bb557" TYPE="ext3"
0
And another issue: blkid segfaults with this - okay, bad use of options:
./blkid -n /dev/sdb3
Segmentation fault
Backtrace:
(gdb) bt
#0 0x00007ff64fe72121 in __strlen_sse2 () from /lib64/libc.so.6
#1 0x00007ff65039029b in blkid_dev_set_search (iter=0x6090c0, search_type=0x0, search_value=0x0) at
libblkid/src/dev.c:151
#2 0x00000000004036e8 in main (argc=<optimized out>, argv=<optimized out>) at misc-utils/blkid.c:925
Using latest git; it doesn't dump core with 2.20.1.
Have a nice day,
Berny
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid: exit code as non-root user, and segfault
2012-12-09 17:52 blkid: exit code as non-root user, and segfault Bernhard Voelker
@ 2012-12-10 8:42 ` Karel Zak
2012-12-10 8:58 ` Bernhard Voelker
2012-12-10 11:49 ` Karel Zak
1 sibling, 1 reply; 5+ messages in thread
From: Karel Zak @ 2012-12-10 8:42 UTC (permalink / raw)
To: Bernhard Voelker; +Cc: util-linux@vger.kernel.org
On Sun, Dec 09, 2012 at 06:52:29PM +0100, Bernhard Voelker wrote:
> blkid returns 0 without output when running as non-root user
> and when the cache /dev/.blkid.tab is not yet there:
>
> ./blkid /dev/sdb3 ; echo $?
> 0
./blkid /dev/sdb3; echo $?2
2
> And another issue: blkid segfaults with this - okay, bad use of options:
>
> ./blkid -n /dev/sdb3
> Segmentation fault
Fixed by:
commit 2e31fe2303e4938ef735aebf13aa5b22fb031af9
Author: Karel Zak <kzak@redhat.com>
Date: Tue Dec 4 11:58:13 2012 +0100
libblkid: cleanup nonnull attribute usage
> Using latest git; it doesn't dump core with 2.20.1.
Really latest? ;-)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid: exit code as non-root user, and segfault
2012-12-10 8:42 ` Karel Zak
@ 2012-12-10 8:58 ` Bernhard Voelker
2012-12-10 9:11 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Bernhard Voelker @ 2012-12-10 8:58 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux@vger.kernel.org
On December 10, 2012 at 9:42 AM Karel Zak <kzak@redhat.com> wrote:
> On Sun, Dec 09, 2012 at 06:52:29PM +0100, Bernhard Voelker wrote:
> > blkid returns 0 without output when running as non-root user
> > and when the cache /dev/.blkid.tab is not yet there:
> >
> > ./blkid /dev/sdb3 ; echo $?
> > 0
>
> ./blkid /dev/sdb3; echo $?2
> 2
Typo? "$?2" should lead to "02".
It really exits 0 here, when run as non-root user and when
/dev/.blkid.tab doesn't exist yet.
> > And another issue: blkid segfaults with this - okay, bad use of options:
> >
> > ./blkid -n /dev/sdb3
> > Segmentation fault
>
> Fixed by:
...
> > Using latest git; it doesn't dump core with 2.20.1.
>
> Really latest? ;-)
Yes, now (forgot make after pull, sorry) ;-)
Ok, that means the segfault is fixed, but the above
issue is still there.
Have a nice day,
Berny
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid: exit code as non-root user, and segfault
2012-12-10 8:58 ` Bernhard Voelker
@ 2012-12-10 9:11 ` Karel Zak
0 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2012-12-10 9:11 UTC (permalink / raw)
To: Bernhard Voelker; +Cc: util-linux@vger.kernel.org
On Mon, Dec 10, 2012 at 09:58:34AM +0100, Bernhard Voelker wrote:
>
> On December 10, 2012 at 9:42 AM Karel Zak <kzak@redhat.com> wrote:
> > On Sun, Dec 09, 2012 at 06:52:29PM +0100, Bernhard Voelker wrote:
> > > blkid returns 0 without output when running as non-root user
> > > and when the cache /dev/.blkid.tab is not yet there:
> > >
> > > ./blkid /dev/sdb3 ; echo $?
> > > 0
> >
> > ./blkid /dev/sdb3; echo $?2
> > 2
>
> Typo? "$?2" should lead to "02".
copy & past bug
> It really exits 0 here, when run as non-root user and when
> /dev/.blkid.tab doesn't exist yet.
Anyway, I have tested the problem as root. You're right it is
possible to reproduce as non-root. Sorry.
I'll fix it. Thanks.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: blkid: exit code as non-root user, and segfault
2012-12-09 17:52 blkid: exit code as non-root user, and segfault Bernhard Voelker
2012-12-10 8:42 ` Karel Zak
@ 2012-12-10 11:49 ` Karel Zak
1 sibling, 0 replies; 5+ messages in thread
From: Karel Zak @ 2012-12-10 11:49 UTC (permalink / raw)
To: Bernhard Voelker; +Cc: util-linux@vger.kernel.org
On Sun, Dec 09, 2012 at 06:52:29PM +0100, Bernhard Voelker wrote:
> blkid returns 0 without output when running as non-root user
> and when the cache /dev/.blkid.tab is not yet there:
>
> ./blkid /dev/sdb3 ; echo $?
> 0
[...]
> access("/dev/sdb3", F_OK) = 0
> stat("/dev/sdb3", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 19), ...}) = 0
[...]
> I'd have expected either an error message along with exit code 1,
> or success with some useful output.
Well, it seems that the code differentiate between:
a) device does not exist:
$ blkid /dev/FooBar; echo $?
2
or exists but does not match:
$ blkid -t LABEL=xyz /dev/sda1; echo $?
2
b) device exists, but there is nothing to print
$ blkid /dev/sda1; echo $?
0
just for the record, you can always print device name:
$ blkid -o device /dev/sda1; echo $?
/dev/sda1
0
maybe it's not obvious at a first glance, but the current behavior
seems correct.
Maybe we can detect the special situation (and print a warning
message) when the cache is empty and user is non-root to make it more
user-friendly. I'm not sure if any change in return code is necessary.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-10 11:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-09 17:52 blkid: exit code as non-root user, and segfault Bernhard Voelker
2012-12-10 8:42 ` Karel Zak
2012-12-10 8:58 ` Bernhard Voelker
2012-12-10 9:11 ` Karel Zak
2012-12-10 11:49 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox