diff options
author | Hannes Reinecke <hare@suse.de> | 2009-09-25 11:51:25 +0200 |
---|---|---|
committer | Hannes Reinecke <hare@suse.de> | 2011-05-15 12:45:12 +0200 |
commit | 35f543f7f2ef1e6f5e7a73144103bf29f8de4594 (patch) | |
tree | 6d46843747a51a9a030bae280c371611af238a09 | |
parent | 7572f6d457b3f32cf6da22b15a83419e33a1445b (diff) | |
download | multipath-tools-35f543f7f2ef1e6f5e7a73144103bf29f8de4594.tar.gz |
Fixup strip trailing whitespaces for getuid return value
The getuid callout might return a wwid with trailing
spaces (or containing only spaces). The existing
fixup code will only work if the getuid callout
returns a wwid with the entire space used up.
So fixup this and also update the logging output
to correctly state '<empty>' if the getuid was
found to be empty.
References: bnc#542085
Signed-off-by: Hannes Reinecke <hare@suse.de>
-rw-r--r-- | libmultipath/discovery.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 843630b..dde876f 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -837,8 +837,7 @@ get_prio (struct path * pp) static int get_uid (struct path * pp) { - char buff[CALLOUT_MAX_SIZE]; - int i; + char buff[CALLOUT_MAX_SIZE], *c; if (!pp->getuid) select_getuid(pp); @@ -852,12 +851,14 @@ get_uid (struct path * pp) return 1; } /* Strip any trailing blanks */ - i = WWID_SIZE - 1; - while (i > 0 && pp->wwid[i] == ' ') { - pp->wwid[i] = '\0'; - i--; - } - condlog(3, "%s: uid = %s (callout)", pp->dev ,pp->wwid); + c = strchr(pp->wwid, '\0'); + c--; + while (c && c >= pp->wwid && *c == ' ') { + *c = '\0'; + c--; + } + condlog(3, "%s: uid = %s (callout)", pp->dev, + *pp->wwid == '\0' ? "<empty>" : pp->wwid); return 0; } |