From: Karel Zak Date: Mon, 27 Sep 2010 14:25:01 +0000 (+0200) Subject: libmount: add DBG() to optstr.c X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39dd1e5087397c25e0eaeb491346a27cf14c77ac;p=util-linux libmount: add DBG() to optstr.c Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c index bb361324..507a7b53 100644 --- a/shlibs/mount/src/optstr.c +++ b/shlibs/mount/src/optstr.c @@ -622,6 +622,8 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags, if (!optstr || !map) return -EINVAL; + DBG(CXT, mnt_debug("appling 0x%08lu flags '%s'", flags, *optstr)); + maps[0] = map; next = *optstr; fl = flags; @@ -638,7 +640,7 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags, next = name; rc = mnt_optstr_remove_option_at(optstr, name, end); if (rc) - return rc; + goto err; } if (!(ent->mask & MNT_INVERT)) fl &= ~ent->id; @@ -662,14 +664,20 @@ int mnt_optstr_apply_flags(char **optstr, unsigned long flags, /* prepare name for value with optional value (e.g. loop[=%s]) */ if (p) { p = strndup(ent->name, p - ent->name); - if (!p) - return -ENOMEM; + if (!p) { + rc = -ENOMEM; + goto err; + } mnt_optstr_append_option(optstr, p, NULL); free(p); } else mnt_optstr_append_option(optstr, ent->name, NULL); } } + + return rc; +err: + DBG(CXT, mnt_debug("failed to apply flags [rc=%d]", rc)); return rc; } @@ -698,6 +706,8 @@ int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **ne if (!optstr || !*optstr || !value || !valsz) return -EINVAL; + DBG(CXT, mnt_debug("fixing SELinux context")); + begin = value; end = value + valsz; @@ -713,12 +723,18 @@ int mnt_optstr_fix_secontext(char **optstr, char *value, size_t valsz, char **ne if (!p) return -ENOMEM; + /* translate the context */ rc = selinux_trans_to_raw_context((security_context_t) p, &raw); + + DBG(CXT, mnt_debug("SELinux context '%s' translated to '%s'", + p, rc == -1 ? "FAILED" : (char *) raw)); + free(p); if (rc == -1 || !raw) return -EINVAL; + /* create quoted string from the raw context */ sz = strlen((char *) raw); if (!sz) @@ -777,6 +793,8 @@ int mnt_optstr_fix_uid(char **optstr, char *value, size_t valsz, char **next) if (!optstr || !*optstr || !value || !valsz) return -EINVAL; + DBG(CXT, mnt_debug("fixing uid")); + end = value + valsz; if (valsz == 7 && !strncmp(value, "useruid", 7) && @@ -823,6 +841,8 @@ int mnt_optstr_fix_gid(char **optstr, char *value, size_t valsz, char **next) if (!optstr || !*optstr || !value || !valsz) return -EINVAL; + DBG(CXT, mnt_debug("fixing gid")); + end = value + valsz; if (valsz == 7 && !strncmp(value, "usergid", 7) && @@ -871,6 +891,8 @@ int mnt_optstr_fix_user(char **optstr, char *value, size_t valsz, char **next) if (!optstr || !value) return -EINVAL; + DBG(CXT, mnt_debug("fixing user")); + username = mnt_get_username(getuid()); if (!username) return -ENOMEM;