return ret;
}
+static int msmProcessAttributes(xmlTextReaderPtr reader, manifest_x *mfx)
+{
+ const xmlChar *node, *type;
+ int ret, depth, attributePresent = 0;
+
+ rpmlog(RPMLOG_DEBUG, "attributes\n");
+
+ depth = xmlTextReaderDepth(reader);
+
+ while ((ret = msmNextChildElement(reader, depth))) {
+ node = xmlTextReaderConstName(reader);
+ if (!node) return -1;
+
+ if (!strcmp(ASCII(node), "package")) {
+ if (attributePresent) {
+ rpmlog(RPMLOG_ERR, "Only one attribute is currently allowed per attribute section. Abort installation\n");
+ return -1;
+ }
+ attributePresent = 1;
+ type = xmlTextReaderGetAttribute(reader, XMLCHAR("type"));
+ rpmlog(RPMLOG_DEBUG, "package type is %s\n", ASCII(type));
+
+ if (type) {
+
+ if ((strcmp(type, "system") != 0) &&
+ (strcmp(type, "application") != 0)){
+ rpmlog(RPMLOG_ERR, "Not allowed attribute name in a package type specification. Abort installation.\n");
+ msmFreePointer((void**)&type);
+ return -1;
+ }
+
+ mfx->package_type = ASCII(type);
+
+ } else {
+ rpmlog(RPMLOG_ERR, "Type name must be defined. Abort installation\n");
+ return -1;
+ }
+ } else {
+ rpmlog(RPMLOG_ERR, "Not allowed element in attribute section: %s\n", ASCII(node));
+ return -1;
+ }
+
+ if (ret < 0) return ret;
+ }
+ return ret;
+}
+
static int msmProcessMsm(xmlTextReaderPtr reader, manifest_x *mfx, sw_source_x *current)
{
const xmlChar *node;
int ret, depth;
- int assignPresent = 0, requestPresent = 0, definePresent = 0; /* there must be only one section per manifest */
+ int assignPresent = 0, requestPresent = 0, definePresent = 0, attributesPresent = 0; /* there must be only one section per manifest */
mfx->sw_source = current;
rpmlog(RPMLOG_DEBUG, "manifest\n");
LISTADD(mfx->provides, provide);
ret = msmProcessProvide(reader, provide, current, mfx, NULL);
} else return -1;
+ } else if (!strcmp(ASCII(node), "attributes")) {
+ if (attributesPresent) {
+ rpmlog(RPMLOG_ERR, "A second attribute section in manifest isn't allowed. Abort installation.\n");
+ return -1;
+ }
+ attributesPresent = 1;
+ ret = msmProcessAttributes(reader, mfx);
} else if (!strcmp(ASCII(node), "define")) {
if (definePresent) {
rpmlog(RPMLOG_ERR, "A second request section in manifest isn't allowed. Abort installation.\n");
const char *type = NULL;
const char isolatedLabel[] = SMACK_ISOLATED_LABEL;
struct stat st;
+ int execLabeldefined = 0;
if (!filepath) return -1;
if (mfx->name) {
return -1;
found:
+ if (exec_label) execLabeldefined = 1;
if ((!label) || (!exec_label)) {
/* no match, use default label of AC domain */
if (mfx->request) { //AC domain is requested in manifest
// do not set SMACK64EXEC
rpmlog(RPMLOG_DEBUG, "not setting SMACK64EXEC for %s as requested in manifest\n", filepath);
} else {
- rpmlog(RPMLOG_DEBUG, "setting SMACK64EXEC %s for %s\n", exec_label, filepath);
- if (lsetxattr(filepath, SMACK64EXEC, exec_label, strlen(exec_label), 0) < 0 ) {
- rpmlog(RPMLOG_ERR, "Failed to set SMACK64EXEC %s for %s: %s\n",
- exec_label, filepath, strerror(errno));
+ if ((mfx->package_type && (strcmp(mfx->package_type, "application") == 0))
+ || (execLabeldefined == 1)) {
+ rpmlog(RPMLOG_INFO, "setting SMACK64EXEC %s for %s\n", exec_label, filepath);
+ if (lsetxattr(filepath, SMACK64EXEC, exec_label, strlen(exec_label), 0) < 0 ) {
+ rpmlog(RPMLOG_ERR, "Failed to set SMACK64EXEC %s for %s: %s\n",
+ exec_label, filepath, strerror(errno));
+ }
}
}
}