From: Karel Zak Date: Tue, 16 Jun 2009 22:30:51 +0000 (+0200) Subject: libblkid: don't require udev symlinks verification for non-root users X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9799b6d2909adf70e040d3750b6a42fa2e5254d;p=util-linux libblkid: don't require udev symlinks verification for non-root users 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 --- diff --git a/shlibs/blkid/src/evaluate.c b/shlibs/blkid/src/evaluate.c index f0ae1266..b8154e47 100644 --- a/shlibs/blkid/src/evaluate.c +++ b/shlibs/blkid/src/evaluate.c @@ -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) @@ -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); @@ -66,7 +69,9 @@ done: 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; } /**