Merge "Allowing system_server to search sysfs_power dir"
diff --git a/public/attributes b/public/attributes
index 986b0ed..c25f1eb 100644
--- a/public/attributes
+++ b/public/attributes
@@ -148,6 +148,12 @@
attribute vendor_executes_system_violators;
expandattribute vendor_executes_system_violators false;
+# All domains which violate the requirement of not sharing files by path
+# between between vendor and core domains.
+# TODO(b/34980020)
+attribute data_between_core_and_vendor_violators;
+expandattribute data_between_core_and_vendor_violators false;
+
# hwservices that are accessible from untrusted applications
# WARNING: Use of this attribute should be avoided unless
# absolutely necessary. It is a temporary allowance to aid the
diff --git a/public/hal_audio.te b/public/hal_audio.te
index c5a6b9d..6a436bd 100644
--- a/public/hal_audio.te
+++ b/public/hal_audio.te
@@ -13,6 +13,7 @@
allow hal_audio audiohal_data_file:file create_file_perms;
')
+r_dir_file(hal_audio, proc)
r_dir_file(hal_audio, proc_asound)
allow hal_audio audio_device:dir r_dir_perms;
allow hal_audio audio_device:chr_file rw_file_perms;
diff --git a/public/shell.te b/public/shell.te
index 4ac6638..fb650bf 100644
--- a/public/shell.te
+++ b/public/shell.te
@@ -109,6 +109,7 @@
# allow shell to look through /proc/ for ps, top, netstat
r_dir_file(shell, proc)
r_dir_file(shell, proc_net)
+allow shell proc_filesystems:file r_file_perms;
allow shell proc_interrupts:file r_file_perms;
allow shell proc_meminfo:file r_file_perms;
allow shell proc_stat:file r_file_perms;
diff --git a/tools/fc_sort/fc_sort.c b/tools/fc_sort/fc_sort.c
index fcd62eb..956c37b 100644
--- a/tools/fc_sort/fc_sort.c
+++ b/tools/fc_sort/fc_sort.c
@@ -46,6 +46,9 @@
void file_context_node_destroy(file_context_node_t *x)
{
+ if (!x)
+ return;
+
free(x->path);
free(x->file_type);
free(x->context);
@@ -135,8 +138,6 @@
file_context_node_t *temp;
file_context_node_t *jumpto;
-
-
/* If a is a empty list, and b is not,
* set a as b and proceed to the end. */
if (!a && b)
@@ -164,7 +165,6 @@
fc_compare(a_current->next,
b_current) != -1) {
-
temp = a_current->next;
a_current->next = b_current;
b_current = b_current->next;
@@ -177,7 +177,6 @@
a_current = jumpto;
}
-
/* if there is anything left in b to be inserted,
put it on the end */
if (b_current) {
@@ -209,11 +208,12 @@
*/
void fc_merge_sort(file_context_bucket_t *master)
{
-
-
file_context_bucket_t *current;
file_context_bucket_t *temp;
+ if (!master)
+ return;
+
/* Loop until master is the only bucket left
* so that this will stop when master contains
* the sorted list. */
@@ -222,28 +222,20 @@
/* This loop merges buckets two-by-two. */
while (current) {
-
if (current->next) {
-
current->data =
fc_merge(current->data,
current->next->data);
-
-
temp = current->next;
current->next = current->next->next;
free(temp);
-
}
-
current = current->next;
}
}
-
-
}
@@ -292,19 +284,40 @@
/* If a escape character is found,
* skip the next character. */
c++;
+ break;
default:
- /* If no meta character has been found yet,
- * add one to the stem length. */
- if (!fc_node->meta)
- fc_node->stem_len++;
break;
}
+ /* If no meta character has been found yet,
+ * add one to the stem length. */
+ if (!fc_node->meta)
+ fc_node->stem_len++;
+
fc_node->str_len++;
c++;
}
}
+
+
+/* fc_free_file_context_node_list
+ * Free the memory allocated to the linked list and its elements.
+ */
+void fc_free_file_context_node_list(struct file_context_node *node)
+{
+ struct file_context_node *next;
+
+ while (node) {
+ next = node->next;
+ file_context_node_destroy(node);
+ free(node);
+ node = next;
+ }
+}
+
+
+
/* main
* This program takes in two arguments, the input filename and the
* output filename. The input file should be syntactically correct.
@@ -326,7 +339,6 @@
FILE *in_file, *out_file;
-
/* Check for the correct number of command line arguments. */
if (argc < 2 || argc > 3) {
fprintf(stderr, "Usage: %s <infile> [<outfile>]\n",argv[0]);
@@ -346,25 +358,33 @@
/* Initialize the head of the linked list. */
head = current = (file_context_node_t*)malloc(sizeof(file_context_node_t));
+ if (!head) {
+ fprintf(stderr, "Error: failure allocating memory.\n");
+ return 1;
+ }
head->next = NULL;
+ head->path = NULL;
+ head->file_type = NULL;
+ head->context = NULL;
/* Parse the file into a file_context linked list. */
line_buf = NULL;
- buf_len = 0;
while ( getline(&line_buf, &buf_len, in_file) != -1 ){
line_len = strlen(line_buf);
+
if( line_len == 0 || line_len == 1)
continue;
+
/* Get rid of whitespace from the front of the line. */
for (i = 0; i < line_len; i++) {
if (!isspace(line_buf[i]))
break;
}
-
if (i >= line_len)
continue;
+
/* Check if the line isn't empty and isn't a comment */
if (line_buf[i] == '#')
continue;
@@ -372,7 +392,9 @@
/* We have a valid line - allocate a new node. */
temp = (file_context_node_t *)malloc(sizeof(file_context_node_t));
if (!temp) {
+ free(line_buf);
fprintf(stderr, "Error: failure allocating memory.\n");
+ fc_free_file_context_node_list(head);
return 1;
}
temp->next = NULL;
@@ -381,19 +403,15 @@
/* Parse out the regular expression from the line. */
start = i;
-
while (i < line_len && (!isspace(line_buf[i])))
i++;
finish = i;
-
regex_len = finish - start;
if (regex_len == 0) {
file_context_node_destroy(temp);
free(temp);
-
-
continue;
}
@@ -401,13 +419,14 @@
if (!temp->path) {
file_context_node_destroy(temp);
free(temp);
+ free(line_buf);
fprintf(stderr, "Error: failure allocating memory.\n");
+ fc_free_file_context_node_list(head);
return 1;
}
/* Get rid of whitespace after the regular expression. */
for (; i < line_len; i++) {
-
if (!isspace(line_buf[i]))
break;
}
@@ -419,18 +438,21 @@
}
/* Parse out the type from the line (if it
- * is there). */
+ * is there). */
if (line_buf[i] == '-') {
temp->file_type = (char *)malloc(sizeof(char) * 3);
if (!(temp->file_type)) {
+ file_context_node_destroy(temp);
+ free(temp);
+ free(line_buf);
fprintf(stderr, "Error: failure allocating memory.\n");
+ fc_free_file_context_node_list(head);
return 1;
}
if( i + 2 >= line_len ) {
file_context_node_destroy(temp);
free(temp);
-
continue;
}
@@ -447,7 +469,6 @@
}
if (i == line_len) {
-
file_context_node_destroy(temp);
free(temp);
continue;
@@ -466,16 +487,18 @@
if (!temp->context) {
file_context_node_destroy(temp);
free(temp);
+ free(line_buf);
fprintf(stderr, "Error: failure allocating memory.\n");
+ fc_free_file_context_node_list(head);
return 1;
}
/* Set all the data about the regular
- * expression. */
+ * expression. */
fc_fill_data(temp);
/* Link this line of code at the end of
- * the linked list. */
+ * the linked list. */
current->next = temp;
current = current->next;
lines++;
@@ -485,10 +508,15 @@
/* Create the bucket linked list from the earlier linked list. */
current = head->next;
- free(head);
bcurrent = master =
(file_context_bucket_t *)
malloc(sizeof(file_context_bucket_t));
+ if (!bcurrent) {
+ printf
+ ("Error: failure allocating memory.\n");
+ fc_free_file_context_node_list(head);
+ return -1;
+ }
bcurrent->next = NULL;
bcurrent->data = NULL;
@@ -507,35 +535,35 @@
(file_context_bucket_t *)
malloc(sizeof(file_context_bucket_t));
if (!(bcurrent->next)) {
- // Static analyzer complains about a
- // memory leak of the memory used by the
- // list created with bcurrent. We could
- // try to deallocate it before returning
- // it but since this is the "main"
- // routine, it is not worth doing
- // that. Just silence the static analyzer.
- // NOLINTNEXTLINE
- printf
- ("Error: failure allocating memory.\n");
- return -1;
+ printf
+ ("Error: failure allocating memory.\n");
+ free(head);
+ fc_free_file_context_node_list(current);
+ fc_merge_sort(master);
+ fc_free_file_context_node_list(master->data);
+ free(master);
+ return -1;
}
/* Make sure the new bucket thinks it's the end of the
- * list. */
+ * list. */
bcurrent->next->next = NULL;
bcurrent = bcurrent->next;
}
-
}
/* Sort the bucket list. */
fc_merge_sort(master);
+ free(head);
+
/* Open the output file. */
if (output_name) {
if (!(out_file = fopen(output_name, "w"))) {
printf("Error: failure opening output file for write.\n");
+ fc_free_file_context_node_list(master->data);
+ free(master);
return -1;
}
} else {
@@ -544,6 +572,7 @@
/* Output the sorted file_context linked list to the output file. */
current = master->data;
+
while (current) {
/* Output the path. */
fprintf(out_file, "%s\t\t", current->path);
@@ -556,14 +585,10 @@
/* Output the context. */
fprintf(out_file, "%s\n", current->context);
- /* Remove the node. */
- temp = current;
current = current->next;
-
- file_context_node_destroy(temp);
- free(temp);
-
}
+
+ fc_free_file_context_node_list(master->data);
free(master);
if (output_name) {