Skip to content

Commit

Permalink
libblkid: don't require udev symlinks verification for non-root users
Browse files Browse the repository at this point in the history
There is noway how to verify LABEL/UUID for non-root users, we have to
follow udev symlinks or use cached information from blkid.tab. Use
unverified symlinks is faster.

Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Jun 16, 2009
1 parent 0fae284 commit e9799b6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions shlibs/blkid/src/evaluate.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static int verify_tag(const char *devname, const char *name, const char *value)
int fd = -1, rc = -1;
size_t len;
const char *data;
int errsv = 0;

pr = blkid_new_probe();
if (!pr)
Expand All @@ -50,8 +51,10 @@ static int verify_tag(const char *devname, const char *name, const char *value)
blkid_probe_set_request(pr, BLKID_PROBREQ_LABEL | BLKID_PROBREQ_UUID);

fd = open(devname, O_RDONLY);
if (fd < 0)
if (fd < 0) {
errsv = errno;
goto done;
}
if (blkid_probe_set_device(pr, fd, 0, 0))
goto done;
rc = blkid_do_safeprobe(pr);
Expand All @@ -66,7 +69,9 @@ static int verify_tag(const char *devname, const char *name, const char *value)
if (fd >= 0)
close(fd);
blkid_free_probe(pr);
return rc;

/* for non-root users we use unverified udev links */
return errsv == EACCES ? 0 : rc;
}

/**
Expand Down

0 comments on commit e9799b6

Please sign in to comment.