if (!optstr || !map)
return -EINVAL;
+ DBG(CXT, mnt_debug("appling 0x%08lu flags '%s'", flags, *optstr));
+
maps[0] = map;
next = *optstr;
fl = 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;
/* 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;
}
if (!optstr || !*optstr || !value || !valsz)
return -EINVAL;
+ DBG(CXT, mnt_debug("fixing SELinux context"));
+
begin = value;
end = value + valsz;
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)
if (!optstr || !*optstr || !value || !valsz)
return -EINVAL;
+ DBG(CXT, mnt_debug("fixing uid"));
+
end = value + valsz;
if (valsz == 7 && !strncmp(value, "useruid", 7) &&
if (!optstr || !*optstr || !value || !valsz)
return -EINVAL;
+ DBG(CXT, mnt_debug("fixing gid"));
+
end = value + valsz;
if (valsz == 7 && !strncmp(value, "usergid", 7) &&
if (!optstr || !value)
return -EINVAL;
+ DBG(CXT, mnt_debug("fixing user"));
+
username = mnt_get_username(getuid());
if (!username)
return -ENOMEM;